AutoIt

  • Introduction
  • License
  • Installation Directory
  • Frequently Asked Questions (FAQ)
  • Credits
  • History / ChangeLog
  • AutoIt and Developer History

Using AutoIt

  • Intended Use
  • Running Scripts
  • File Name and Path
  • AutoIt on Windows Vista
  • Command Line Parameters
  • Script Editors
  • Compiling Scripts
  • AutoIt Window Info Tool (Au3Info)
  • AutoIt Syntax Checker (Au3Check)
  • Window Titles and Text (Basic)
  • Window Titles and Text (Advanced)
  • Controls
  • Unicode Support
  • Running under Windows 64-bit Edition

Tutorials

  • My First Script (Hello World)
  • Simple Notepad Automation
  • WinZip Installation
  • String Regular Expression
  • Simple Calculator GUI

Language Reference

  • Datatypes
  • Variables
  • Macros
  • Operators
  • Conditional Statements
  • Loop Statements
  • Obj Statements
  • User Functions
  • Comments
  • Directives

GUI Reference

  • GUI Concepts
  • GUI MessageLoop Mode
  • GUI OnEvent Mode
  • GUI Constants include files

Obj/COM Reference

Keyword Reference

  • Keyword Reference

Macro Reference

  • Macro Reference

Function Reference

  • Function Reference

Appendix

  • AutoIt Constants include files
  • AutoIt3 limits/defaults
  • ASCII Characters
  • CLSIDs of Special Folders
  • GUI Control Styles
  • @OSLang Values
  • Send Key List
  • Standard Windows Fonts
  • Windows Message Codes

User Defined Function Reference

  • User Defined Function Reference


AutoIt

v3.3.14.0

©1999-2015 Jonathan Bennett & AutoIt Team

AutoIt v3 Homepage

Introduction

AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying "runtimes" required!

AutoIt was initially designed for PC "roll out" situations to reliably automate and configure thousands of PCs. Over time it has become a powerful language that supports complex expressions, user functions, loops and everything else that veteran scripters would expect. Features:

  • Easy to learn BASIC-like syntax
  • Simulate keystrokes and mouse movements
  • Manipulate windows and processes
  • Interact with all standard windows controls
  • Scripts can be compiled into standalone executables
  • Create Graphical User Interfaces (GUIs)
  • COM support
  • Regular expressions
  • Directly call external DLL and Windows API functions
  • Scriptable RunAs functions
  • Detailed helpfile and large community-based support forums
  • Compatible with Windows XP SP3 / 2003 SP2 / Vista / 2008 / Windows 7 / 2008 R2 / Windows 8 / 2012 R2
  • Unicode and x64 support
  • Digitally signed for peace of mind
  • Works with Windows User Account Control (UAC)

AutoIt has been designed to be as small as possible and stand-alone with no external .dll files or registry entries required making it safe to use on Servers. Scripts can be compiled into stand-alone executables with Aut2Exe.

Also supplied is a combined COM and DLL version of AutoIt called AutoItX that allows you to add the unique features of AutoIt to your own favorite scripting or programming languages!

Best of all, AutoIt continues to be free - but if you want to support the time, money and effort spent on the project and web hosting then you may donate at the AutoIt homepage.

Features in Detail

Basic-like Syntax and Rich Function Set

AutoIt has a BASIC-like syntax which means that most people who have ever written a script or used a high-level language should be able to pick it up easily.

Although it started life as a simple automation tool, AutoIt now has functions and features that allow it to be used as a general purpose scripting language (with awesome automation as well of course!). Language features include:

  • The usual high-level elements for functions, loops and expression parsing
  • A staggering amount of string handling functions and a Perl compatible regular expression engine (using the PCRE library).
  • COM support
  • Call Win32 and third-party DLL APIs

Built-in Editor with Syntax Highlighting

AutoIt comes with a customized "lite" version of SciTE that makes editing scripts easy. Users can also download a complete version of SciTE that includes additional tools to make things even easier.

Standalone and Small

AutoIt is a very small and standalone application with no reliance on massive runtimes such as .NET or VB. All you need to run AutoIt scripts are the main AutoIt executable (AutoIt3.exe) and the script. Scripts can also be encoded into standalone executables with the built-in script compiler Aut2Exe.

International and 64-bit Support

AutoIt is fully Unicode aware and also includes x64 versions of all the main components! How many other free scripting languages can you say that about?

Key and Mouse Simulation

Much time has been spent optimizing the keystroke and mouse simulation functions to be as accurate as possible on all versions of Windows. All the mouse and keyboard routines are highly configurable both in terms of simulation "speed" and functionality.

Window Management

You can expect to move, hide, show, resize, activate, close and pretty much do what you want with windows. Windows can be referenced by title, text on the window, size, position, class and even internal Win32 API handles.

Controls

Directly get information on and interact with edit boxes, check boxes, list boxes, combos, buttons, status bars without the risk of keystrokes getting lost. Even work with controls in windows that aren't active!

Graphical User Interfaces (GUIs)

AutoIt v3 will also allow you to create some complex GUIs - just like those below!

GUI Example 1 GUI Example 2

And much, much more...


License

Software License

AutoIt

Author : Jonathan Bennett and the AutoIt Team
WWW : https://www.autoitscript.com/site/autoit/
Email : support at autoitscript dot com
________________________________________________________

END-USER LICENSE AGREEMENT FOR THIS SOFTWARE

This End-User License Agreement ("EULA") is a legal agreement between you (either an individual or a single entity) and the mentioned author of this Software for the software product identified above, which includes computer software and may include associated media, printed materials, and "online" or electronic documentation ("SOFTWARE PRODUCT"). By installing, copying, or otherwise using the SOFTWARE PRODUCT, you agree to be bound by the terms of this EULA. If you do not agree to the terms of this EULA, do not install or use the SOFTWARE PRODUCT.

SOFTWARE PRODUCT LICENSE

The SOFTWARE PRODUCT is protected by copyright laws and international copyright treaties, as well as other intellectual property laws and treaties. The SOFTWARE PRODUCT is licensed, not sold.

The definition of SOFTWARE PRODUCT does not includes any files generated by the SOFTWARE PRODUCT, such as compiled script files in the form of standalone executables.

1. GRANT OF LICENSE

This EULA grants you the following rights:

Installation and Use. You may install and use an unlimited number of copies of the SOFTWARE PRODUCT.

Reproduction and Distribution. You may reproduce and distribute an unlimited number of copies of the SOFTWARE PRODUCT either in whole or in part; each copy should include all copyright and trademark notices, and shall be accompanied by a copy of this EULA. Copies of the SOFTWARE PRODUCT may be distributed as a standalone product or included with your own product.

Commercial Use. You may use the SOFTWARE PRODUCT for commercial purposes. You may sell for profit and freely distribute scripts and/or compiled scripts that were created with the SOFTWARE PRODUCT.

Reverse engineering. You may not reverse engineer or disassemble the SOFTWARE PRODUCT.

2. COPYRIGHT

All title and copyrights in and to the SOFTWARE PRODUCT (including but not limited to any images, photographs, animations, video, audio, music, text, and "applets" incorporated into the SOFTWARE PRODUCT), the accompanying printed materials, and any copies of the SOFTWARE PRODUCT are owned by the Author of this Software. The SOFTWARE PRODUCT is protected by copyright laws and international treaty provisions. Therefore, you must treat the SOFTWARE PRODUCT like any other copyrighted material.

MISCELLANEOUS

If you acquired this product in the United Kingdom, this EULA is governed by the laws of the United Kingdom. If this product was acquired outside the United Kingdom, then local law may apply.

Should you have any questions concerning this EULA, or if you desire to contact the author of this Software for any reason, please contact him/her at the email address mentioned at the top of this EULA.

LIMITED WARRANTY

1. NO WARRANTIES

The Author of this Software expressly disclaims any warranty for the SOFTWARE PRODUCT. The SOFTWARE PRODUCT and any related documentation is provided "as is" without warranty of any kind, either express or implied, including, without limitation, the implied warranties or merchantability, fitness for a particular purpose, or non-infringement. The entire risk arising out of use or performance of the SOFTWARE PRODUCT remains with you.

2. NO LIABILITY FOR DAMAGES

In no event shall the author of this Software be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or any other pecuniary loss) arising out of the use of or inability to use this product, even if the Author of this Software has been advised of the possibility of such damages. Because some states/jurisdictions do not allow the exclusion or limitation of liability for consequential or incidental damages, the above limitation may not apply to you.

[END OF LICENSE]


Install Directory Structure

The AutoIt installer creates a directory structure (usually located in \Program Files\AutoIt3) summarized in the following table. The installer also creates Start Menu shortcuts, but no other files are added or modified.

Files and Directories |  | Description
(Top-level files)
AutoIt3.exe |  | The AutoIt main program and only file required to run scripts!
AutoIt3_x64.exe |  | The x64 version of AutoIt (if installed).
Au3Info.exe |  | The AutoIt Window Info Tool.
Au3Info_x64.exe |  | The x64 version of Au3Info (if installed).
AU3Check.exe |  | The AutoIt syntax checker.
AutoIt.chm |  | This help file.
Uninstall.exe |  | The AutoIt uninstaller.
AutoIt v3 Website.url |  | A shortcut to https://www.autoitscript.com/site/autoit/
Aut2Exe
 | Icons\ | Contains icons used for the .au3 filetype icon in Explorer.
 | Aut2Exe.exe | The script compiler.
 | Aut2Exe_x64.exe | The x64 version of Aut2Exe (if installed).
 | UPX.exe | The UPX compressor (reduces the size of exe files).
Examples
 | COM\ | Contains examples of COMs written in AutoIt.
 | GUI\ | Contains examples of GUIs written in AutoIt.
 | Helpfile\ | Contains scripts used in many of the help file examples.
Extras
 | Au3Record\ | Contains Au3Record.exe to capture user interaction to be converted as a script.
 | AutoUpdateIt\ | Contains a script for easily retrieving the latest version of AutoIt3.
 | Editors\ | Contains syntax coloring definitions for some popular text editors.
 | Geshi\ | Contains syntax coloring file for the Geshi server-side syntax highlighter.
 | Prettify\ | Contains syntax coloring file the Google Prettify client-side javascript highlighter.
Icons
 | Contains icons used for the .au3 filetype icon in Explorer.
Include
 | Contains standard include files (pre-written user functions). See User Defined Function Reference.
AutoItX
 | Contains a DLL version of AutoIt v3 that provides a subset of the features of AutoIt via an ActiveX/COM and DLL interface.
SciTE
 | Contains a light version of SciTE which allows syntax coloring.

It should be noted that to run AutoIt scripts, the only required file is AutoIt3.exe. If you compile a script into an executable then a user does not require AutoIt to be installed to run a compiled executable.

Registry Keys

The AutoIt installer creates registry keys under HKEY_LOCAL_MACHINE\Software\AutoIt v3 or HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\AutoIt v3\ if using a 64-bit machine and HKEY_CURRENT_USER\Software\AutoIt v3. The keys are NOT used/created when AutoIt utilities are run on machines that lack a full AutoIt installation--AutoIt is "clean" to run on servers, etc.

The table below shows the default (or typical) registry keys. The keys in italic are not created by the installer itself but by the first execution of the corresponding utility:

HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\
AutoIt
 | (Default) | REG_SZ | (value not set)
 | InstallDir | REG_SZ | C:\Program Files\AutoIt3
 | Version | REG_SZ | Version Number
HKEY_CURRENT_USER\Software\AutoIt v3\
Aut2Exe
 | (Default) | REG_SZ | (value not set)
 | LastCompression | REG_DWORD | 0x2
 | LastExeDir | REG_SZ | My Documents
 | LastIcon | REG_SZ |
 | LastIconDir | REG_SZ | C:\Program Files\AutoIt3\Aut2Exe\Icons
 | LastScriptDir | REG_SZ | My Documents
AutoUpdateIt
 | (Default) | REG_SZ | (value not set)
 | DoneOption | REG_SZ | Notify
 | DownloadDir | REG_SZ | C:\Downloads\ForExample\
Au3Info
 | Default | REG_SZ | (value not set)
 | AlwaysOnTop | REG_DWORD | 0x1
 | ColorMode | REG_DWORD | 0x1
 | CoordMode | REG_DWORD | 0x1
 | HighlightColor | REG_DWORD | 0x0
 | HighlightControls | REG_DWORD | 0x1
 | Magnify | REG_DWORD | 0x0
 | WinH | REG_DWORD | 0x01c2
 | WinW | REG_DWORD | 0x012c
 | WinX | REG_DWORD | 0x0064
 | WinY | REG_DWORD | 0x0064


AutoIt

Frequently Asked Questions (FAQ)

This section gives some of the more frequently asked questions from the forum. If you can't find the answer you seek here then the forum should be your first port of call.

Questions

  1. How can I run a DOS program from within AutoIt?
  2. Why can I only use Run() to execute .exe and .com files? What about .msi / .txt and others?
  3. Why do I get errors when I try and use double quotes (") ?
  4. What do the window "title" and "text" parameters mean?
  5. Why can't I print a variable using "My var is $variable"?
  6. When I use Send() to send a variable odd things happen?
  7. What is the difference between the return value and @error?
  8. How can I exit my script with a hot-key?
  9. How can I use a custom icon when compiling my scripts?
  10. How can I make sure only one copy of my script is run?
  11. What are the current technical limits of AutoIt v3?
  12. I get a missing picture symbol in the Help file under the Examples.

1. How can I run a DOS program from within AutoIt?

If you wanted to run something like a DOS "Dir" command then you must run it though the command interpreter (command.com or cmd.exe depending on your OS). The @ComSpec macro contains the correct location of this file. You should use the RunWait() function as it waits for the DOS program to finish before continuing with the next line of the script. Here is an example of running the DOS Dir command on the C: drive: (effectively running the command command.com /c Dir C:\ )

RunWait ( @ComSpec & " /c Dir C:\")

Back To Top

2. Why can I only use Run() to execute .exe files? What about .msi / .txt and others?

Only a few file extensions are usually "runable" - these are .exe, .bat, .com, .pif. Other file types like .txt and .msi are actually executed with another program. When you double click on a "myfile.msi" file what actually happens in the background is that "msiexec.exe myfile.msi" is executed. So to run a .msi file from AutoIt you would do:

RunWait ("msiexec myfile.msi")

Or, run the command "start" which will automatically work out how to execute the file for you:

RunWait ( @ComSpec & " /c Start myfile.msi")

Or, use the ShellExecuteWait function which will automatically work out how to execute the file for you:

ShellExecuteWait ("myfile.msi")

Back To Top

3. Why do I get errors when I try and use double quotes (") ?

If you want to use double-quotes inside a string then you must "double them up". So for every one quote you want you should use two. For example if you wanted to set a variable to the string: A word in "this" sentence has quotes around it! You would do:

$var = "A word in ""this"" sentence has quotes around it!"

or use single quotes instead:

$var = 'A word in "this" sentence has quotes around it!'

Back To Top

4. What do the window "title" and "text" parameters mean?

There is a detailed description here.

Back To Top

5. Why can't I print a variable using "My var is $variable"?

If you have a variable called $msg and you want to print in inside a MsgBox then this will NOT work:

#include <MsgBoxConstants.au3>

MsgBox ($MB_OK, "Example", "My variable is $msg")

It will actually print My variable is $msg. What you need to do is tell AutoIt to join the string and the variable together using the & operator:

#include <MsgBoxConstants.au3>

MsgBox ($MB_OK, "Example", "My variable is " & $msg)

Advanced: If you have many variables to add into a string then you may find the StringFormat() function useful. For example, if I wanted to insert $var1 to $var5 into a string then it may be easier to do:

#include <MsgBoxConstants.au3>

$msg = StringFormat ("Var1 is %s, Var2 is %s, Var3 is %s, Var4 is %s", $var1, $var2, $var3, $var4)
MsgBox ($MB_OK, "Example", $msg)

Back To Top

6. When I use Send() to send a variable odd things happen?

If you are sending the contents of a variable then be mindful that if it contains special send characters like ! ^ + {SPACE} then these will be translated into special keystrokes - rarely what is wanted. To overcome this use the RAW mode of Send() that does not translate special keys:

Send ($myvar, 1)

Back To Top

7. What is the difference between the return value and @error?

Generally a return value is used to indicate the success of a function. But, if a function is already returning something ( like WinGetText() ) then we need to have a way of working out if the function was successful, so we set @error instead.

Back To Top

8. How can I exit my script with a hot-key?

Ah, an easy one. If you want to make your script exit when you press a certain key combination then use the HotKeySet() function to make a user function run when the desired key is pressed. This user function should just contain the Exit keyword.

Here some code that will cause the script to exit when CTRL+ALT+x is pressed:

HotKeySet ("^!x", "MyExit")
...
...
; Rest of Script
...
...
Func MyExit()
Exit
EndFunc ;==>MyExit

Back To Top

9. How can I use a custom icon when compiling my scripts?

You need to run the full compiler program (rather than just right-clicking a script and selecting compile). This page describes the compiler in detail.

Back To Top

10. How can I make sure only one copy of my script is run?

Use the _Singleton() function. See the User Defined Functions documentation for more information on _Singleton() and how to use it.

Back To Top

11. What are the current technical limits of AutoIt v3?

Please refer to the Limits and Defaults section for the technical limits of AutoIt3.

Additional information about theoretical limits of AutoIt3.

Value | Description
No limit | Maximum number of GUI windows.
No limit | Maximum number of use defined functions.
No limit | Maximum number of variables in use at one time.
1.7E308 to 1.7E+308 | Number range (floating point) with 15-digit precision.
0x8000000000000000 to 0x7FFFFFFFFFFFFFFF | Hexadecimal number range (32-bit/64-bit signed integer).

Back To Top

12. I get a missing picture symbol in the Help file under the Examples.

This should be the Open button that enable you to open the Examples in the Help file.
This issue is that the hhctrl.ocx isn't properly registered or corrupted.
Try registering it by doing "regsvr32 hhctrl.ocx" from the command prompt or check if the file is still valid.

Back To Top


Using AutoIt

  • Intended Use
  • Running Scripts
  • File Name and Path
  • AutoIt on Windows Vista
  • Command Line Parameters
  • Script Editors
  • Compiling Scripts
  • AutoIt Window Info Tool (Au3Info)
  • AutoIt Syntax Checker (Au3Check)
  • Window Titles and Text (Basic)
  • Window Titles and Text (Advanced)
  • Controls
  • Unicode Support
  • Running under Windows 64-bit Edition


Intended Use

AutoIt is constantly evolving as a programming language. It started as an add-on tool to automate basic tasks in GUI's of other programs, and task automation (such as sending a keystroke or clicking a button) is still at the heart of AutoIt. With the introduction of many new features, however, AutoIt has become a more powerful tool than ever before.

Just a few of the new and updated features include:

  • GUI Automation - Create a custom graphical interface for your application.
  • COM (Object) functionality fills the gap with WSH languages such as VBScript/JScript.
  • Loops, functions and expression parsing.
  • An enormous number of functions for handling and manipulating Strings.
  • A Perl-compatible regular expression engine using the PCRE library, with native 16bit mode and UCP/UTF support.
  • A powerful Recursive File List to Array function
  • Easily call Win32 and third-party DLL APIs from within your script.


Running Scripts

When you start AutoIt you will be asked to open a script file. A script file is a simple text file containing AutoIt keywords and functions that tell AutoIt what you want it to do. Script files are created in a simple text editor such as notepad.exe but there is a much better alternative in a specially modified version of the SciTE editor.

Although AutoIt v3 scripts are just plain-text files they are usually given the file extension .au3 to differentiate between a script and a plain text file. If you used the full installer to install AutoIt you can execute an AutoIt script simply by double-clicking it. There are also various options to open, edit, or compile a script if you right-click on the .au3 file.

Here is an example script. Notice that ; is used for commenting sections of code:

#include <Constants.au3>

; This is my first script
MsgBox ($MB_SYSTEMMODAL, "My First Script!", "Hello World!")

More complicated scripts can introduce functions. These are usually placed towards the end of a script or below the Global variable declaration section.

#include <Constants.au3>

MsgBox ($MB_SYSTEMMODAL, "My second script!", "Hello from the main script!")
Example_Func()

Func Example_Func()
Return MsgBox ($MB_SYSTEMMODAL, "My Second Script!", "Hello from the functions!")
EndFunc ;==>Example_Func

Command Line Parameters

Passing command line parameters to your own executable is achievable in AutoIt. Passed commandline parameters can be viewed by using the constant variables $CmdLine and $CmdLineRaw. Assigning these variables with new data will cause AutoIt to return an error, as these cannot be changed during the script's execution. Note that both variables exist whether commandline parameters are passed or not.

The special array $CmdLine is initialized at the start of the script with the command line parameters passed to your AutoIt script. If running your script instead of the executable, then the ScriptName.au3 willl be ignored as a parameter.

If you're passing strings with spaces, then you will need to escape these using "double quotes" in your commandline string.

$CmdLine[0] ; Contains the total number of items in the array.
$CmdLine[1] ; The first parameter.
$CmdLine[2] ; The second parameter.
...
$CmdLine[nth] ; The nth parameter e.g. 10 if the array contains 10 items.

So if you were to run your script directly using AutoIt3.exe:

AutoIt3.exe myScript.au3 param1 "This is a string parameter" 99

$CmdLine[0] ; This contains 3 parameters.
$CmdLine[1] ; This contains param1 and not myScript.au3 as this is ignored when running non-compiled.
$CmdLine[2] ; This contains This is a string parameter.
$CmdLine[3] ; This contains 99.
$CmdLineRaw ; This contains myScript.au3 param1 "This is a string parameter" 99.

So if you were to use the compiled executable by passing commandline parameters:

myProg.exe param1 "This is a string parameter" 99

$CmdLine[0] ; This contains 3 parameters.
$CmdLine[1] ; This contains param1.
$CmdLine[2] ; This contains This is a string parameter.
$CmdLine[3] ; This contains 99.

Note: A maximum of 63 parameters can be returned by the array $CmdLine[]. If you would like to see the entire commandline string passed to an AutoIt executable, then use $CmdLineRaw for the entire parameter string.

#include <Array.au3>
#include <WinAPIShPath.au3>

; An alternative to the limitation of $CmdLine[] only being able to return a maximum of 63 parameters.
Local $aCmdLine = _WinAPI_CommandLineToArgv ($CmdLineRaw)
_ArrayDisplay ($aCmdLine)

AutoIt specific command Line Switches

The AutoIt3.exe interpreter, or the interpreter stub of any compiled Autoit script, can normally be used to run AutoIt scripts directly from the command line. In all cases the /ErrorStdOut switch allows the redirection of a fatal error to StdOut which can then be captured by an application such as the SciTE editor. This switch can be used with both the interpreter and a compiled script.

Run a script using the interpreter:

AutoIt3.exe [/ErrorStdOut] [/AutoIt3ExecuteScript] filename [params ...] Execute the AutoIt3 script 'filename' with optional parameters

At its simplest: AutoIt3.exe myScript.au3 will run a standard AutoIt script 'myScript.au3' with no parameters.

Run a compiled script:

Compiled.exe [/ErrorStdOut] [params ...]
Execute a compiled AutoIt3 Script File produced with Aut2Exe.

Run a single line of code:

AutoIt3.exe [/ErrorStdOut] /AutoIt3ExecuteLine "command line"
Execute one line of code.

The command below will execute that single line of code and display the MsgBox with "Hello World!". The tray icon will not be displayed.

Run ( @AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(4096, ''Hello World!'', ''Hi!'')"')

Run a script using another compiled script:

Compiled.exe [/ErrorStdOut] /AutoIt3ExecuteScript file [params ...]
Execute another AutoIt script file from a compiled AutoIt3 executable.

Compiled.exe [/ErrorStdOut] /AutoIt3ExecuteLine "command line"
Execute one line of code as with AutoIt3.exe above.

This means that there is no need to have a copy of AutoIt3.exe in addition to the compiled file - the interpreter stub of the compiled file will replace it. So as long as there is at least one compiled script available, other AutoIt scripts can be run without the need to have AutoIt3.exe on the machine., either pre-installed or added via FileInstall.

Important Notes

However, the executable must have been compiled with the #pragma compile(AutoItExecuteAllowed, True) directive as the default setting does not permit use of the /AutoItExecuteScript or /AutoItExecuteLine parameters. Moreover, since the interpreter stub searches for any required standard #include files in its current folder, UDF functions and various constants may not be available as those files are normally only found in the full AutoIt install. It is therefore recommended that any scripts intended to be run in this manner are compiled to the .a3x format rather then being left as plain .au3 text files

Correct usage of single and double quotation marks is important when using the command line - even for double single quotation marks.


File Name and Path

Whenever a function parameter is specified as "filename", it implies a filename with a full path. Although AutoIt functions will often accept a relative path, this is not guaranteed to work correctly as some file functions in the Windows API require a fully qualified path. If no path is specified and only a simple name used to define a file, AutoIt will create it or search for it in the current working directory - the path for which can be found in the @WorkingDir macro.

The working directory is set to @ScriptDir at script start and this path can be altered during the running of the script by calling FileChangeDir. But note that the current working directory can be also be changed automatically by some functions - e.g. FileOpen/SaveDialog on a successful return, or Run if the "workingdir" parameter is specified.

The MSDN page Naming Files, Paths, and Namespaces has more details on how file names and paths should be written.


AutoIt on Windows Vista and beyond

AutoIt on Windows Vista

Beginning with Windows Vista, new security features have been introduced in Windows to restrict the running of files that require administrative rights. Even users with Administrative access will be prompted every time they launch an executable which will perform some administrative operation (such as writing to the registry key HKEY_LOCAL_MACHINE or writing to the C:\Windows directory). This is called User Account Control (UAC).

By default AutoIt scripts run with standard user permissions but AutoIt has been coded to allow the script writer the option to "tag" a script in order to tell AutoIt if it needs to run with full admin rights or not.

To force a script to attempt to run itself with administrative rights add the #RequireAdmin directive at the top of your script as follows:

; This script requires full Administrative rights
#RequireAdmin

#include <MsgBoxConstants.au3>

MsgBox ($MB_OK, "Info", "This script has admin rights! ")

When the script runs AutoIt will check if it already has full admin rights and if not it will cause the operating system to prompt the user for permission as shown in "UAC Prompts". If permission is not given by the user the script will terminate.

UAC Prompts

The prompts shown when launching a program that requires administrative rights are similar to those shown below. The type of prompt displayed will depend on whether the user is a "standard user" or an "administrator user". Keep in mind that even administrators will need elevated permissions to perform admin operations.

Note: The prompts shown are for the digitally signed version of AutoIt - all release versions are signed but beta versions may not be and will give a warning as shown in "Compiled Scripts" below.

Standard User Prompt

A standard user must select a user name and enter a password in order to continue and run the script with elevated rights.

Administrator User Prompt

As the user is already an administrator and just requires elevation the user needs only to click on continue - no password is needed.

Compiled Scripts

Compiled scripts (and possibly beta versions of AutoIt) are not digitally signed and will give a more serious looking warning as shown:

The user must click on Allow to continue (or enter a password if they are a standard user).

If you have your own Authenticode signature you may sign your compiled scripts yourself.

Important: Whether AutoIt or a compiled script is signed or not, you should only run scripts from sources you trust!

Even signed code can be malicious!


Scripts Editors

Script Editors

AutoIt scripts are simple text files that you can edit with any text editor. However there are many free or shareware editors that are much better for writing scripts and many feature syntax highlighting so that AutoIt keywords and functions stand out making scripting much easier and less prone to mistakes.

The current editor used by the majority of AutoIt users is SciTE, the AutoIt development team has created a custom version of SciTE with full syntax highlighting that also integrates various third-party AutoIt tools (like syntax checking and script tidying). A "lite" version of the SciTE editor comes with the AutoIt installation package. The full AutoIt version of SciTE that comes with all tools can be downloaded separately at http://www.autoitscript.com/autoit3/scite/

Some other recommended editors are:

  • TextPad
  • Crimson Editor (free)
  • Source Edit (free)
  • UltraEdit
  • Notepad++

AutoIt comes supplied with some pre-written syntax files for many editors and they can be found in the Extra installation directory (there is a link under Start Menu / AutoIt v3 / Extra).


Compiling Scripts with Aut2Exe

It is possible to take your .au3 script and compile it into a standalone executable; this executable can be used without the need for AutoIt to be installed and without the need to have AutoIt3.exe on the machine. The compilation process converts the script and its #include files, plus any files added by the FileInstall function, into a tokenised form which is then compressed and encrypted. In that way none of these additional files are required at runtime. Depending on the compilation option chosen, this "compiled" script will either be inserted into the resources of a stand-alone executable interpreter which will run it directly or saved in .a3x format. An .a3x file can be included in another script or run by an AutoIt interpreter - either Autoit3.exe itself or another compiled script with the AutoItExecuteAllowed flag set.

Caution: the script to be compiled must be free of syntax error as the compilation process does not check the syntax.

Aut2Exe can be used in three ways:

Method 1 - Start Menu

Only available if full install performed.

1. Open the Start Menu and browse to the AutoIt v3 group.

2. Click Compile Script to .exe

3. The main Aut2Exe interface should appear.

4. Use the Browse buttons to select your input (.au3) and output (.exe) files.

5. If you like you can change the icon of the resulting .exe - just browse to the icon you want (some example icons are supplied in Program Files\AutoIt3\Aut2Exe\Icons).

6. The only other option you might wish to change is the compression level (especially if using FileInstall to add extra files). Use the Compression menu to set this. As with all compression routines the better the compression you select the slower it will be. However, no matter what compression level you select the decompression speed (when the .exe is run) is the same.

7. Click on Convert to compile the script.

Note: Scripts can be compiled with .a3x extension. They should be run with AutoIt.exe filename.a3x. The .a3x contains the script itself with all referred #include plus the FileInstall files. This format allows you to distribute smaller files as they don't include the AutoIt3.exe in each compiled script. You still need to have it accessible on the target machine but just AutoIt3.exe.

Method 2 - Right Click

Only available if full install performed.

1. In Explorer browse to the .au3 file that you wish to compile.

2. Right-click the file to access the pop-up menu.

3. The file will be silently compiled with the same filename - just with a .exe extension.

When compiling in this way, Aut2Exe uses current icon/compression settings (from the last time Aut2Exe was run manually as in method 1).

Method 3 - The Command Line

The Aut2Exe.exe program can be run from the command line as follows:

Aut2exe.exe / In < infile.au3 >[/out < outfile.exe >][/icon < iconfile.ico >][/comp 0 - 4][/nopack][/x64][/bin < binfile.bin >]

Where

Switch | Usage | Default value
/in | <infile.au3> Specifies the path and file name of the bin file to be used to compile the file. | None. The file must be specified
/out | <outfile.exe> Specifies the path and name of the compiled file. <outfile.a3x> Specifies the path and file name when creating an *.a3x file. | The input filename with a .exe extension
/icon | <iconfile.ico> Specifies the path and file name of the icon to use for the compiled file. | Default icon
/comp | Specifies the compression level to be used when encoding the script (This is NOT related to UPX). It must be a number between 0 (none) and 4 (maximum). | 2
/nopack | Specifies that the file should not be compressed with UPX after compilation. | pack
/pack | Specifies that the file should be compressed with UPX after compilation. | pack
/x64 | Specifies that the script should be compiled for use on systems with x64 (64-bit) architecture. | see notes
/x86 | Specifies that the script should be compiled for use on systems with x86 (32-bit) architecture. | see notes
/console | Specifies that the script should be compiled as a Console application. | Windows application (/gui)
/gui | Specifies that the script should be compiled as a Windows application. | Windows application (/gui)

Command Line Examples

/in c:\myscript.au3 /out c:\myapp.exe /icon c:\myicon.ico /x64

Will result in the creation of c:\myapp.exe with normal compression which will use the specified icon and be compiled for use on x64 system architecture.

/in c:\myscript.au3

will result in the creation of a unicode c:\myscript.exe with normal compression which will use the default AutoIt icon for use on win_32 systems.

Command Line Notes

Long filenames should be enclosed in double-quotes like "C:\Program Files\Test\test.au3".

With the exception of /in all switches are optional.

By default, the 32-bit compiler produces a 32-bit binary and the 64-bit compiler produces a 64-bit binary. Use the /x86 and /x64 parameters to explicitly specify the output.

The /pass and /nodecompile switches are redundant as of version 3.2.8.1. They will be ignored if used and have been removed from this list.

The /ansi and /unicode switches are redundant as of version 3.3.0.0.

The /bin switch is redundant as of version 3.3.10.0 and has been removed from this list..

Technical Details

The compiled script and additional files added with FileInstall are compressed with my own (Jon) compression scheme.


AutoIt Window Info Tool

AutoIt Window Information Tool

AutoIt v3 comes with a standalone tool called the AutoIt Window Info Tool (Program Files\AutoIt3\Au3Info.exe). Au3Info allows you to get information from a specified window that can be used to effectively automate it. Information that can be obtained includes:

  • Window titles
  • Text on the window (visible and hidden)
  • Window size and position
  • Contents of the status bar
  • Position of the mouse pointer
  • Color of the pixels underneath the mouse pointer
  • Details of the Control underneath the mouse pointer

To use Au3Info just run it (from the command line or Start menu). Au3Info will remain the top most window at all times so that you can read it. Once active move to the window you are interested in and activate it - the contents of Au3Info will change to show the information that is available. With the help of Au3Info you should be automating in no time!

When Au3Info is running you may want to copy text directly from it using CTRL-C and then paste it into your script to avoid spelling/case errors. For the tabs that have information in a list view (like the control information shown below) just double-click on an entry to copy it to the clipboard. This can be difficult when you want to capture pixel/mouse information as it keeps changing! To help with this you can "freeze" the output of Au3Info by pressing CTRL-ALT-F. Press the keys again to "unfreeze".

Here is an example of Au3Info in use with the Windows "WordPad" editor:


Au3check syntax Tool

AutoIt Syntax Checker (Au3Check)

Checks the script for syntax errors.
Checks all symbols used:

  • Macros :
Usage of non-defined macros are reported as errors.

  • Variables :
Au3Check issues warning if variables are used before they are declared.
It's possible that the program is still correct, like the following:

#include <MsgBoxConstants.au3>

For $i = 1 To 2
If $i = 2 Then MsgBox ($MB_OK, "OK", $sHello)
Global $sHello = "Goodbye"
Next

However, this is bad programming style and Au3Check will issue a warning that $sHello is possibly used before it is declared.
Likewise, Global variables should never be declared within functions and always declared at the top of the script.
If one is used higher up in the code, a warning is issued.
Finally, Au3Check issues an error if a variable is used but is never either explicitly or implicitly declared.

  • Functions :
Functions may be defined later than where they are initially called. Au3Check checks that all functions are called with the correct number of parameters.
It also checks that ByRef parameters are called with variables (not l-values, expressions).
Finally, non-defined functions are reported.

Specific directives can be included in the script to manage some warnings/errors that can not be avoided.

Directives
--------------
These directives prevent Au3Check from reporting errors when the code is correct but too complex for the tool's parser. As shown in the examples below they are usually used when variables are implicitly declared - such as in a function definition or by a string parameter - and would otherwise not be recognised. In particular, #forceref can be used to prevent warnings where parameters are mandatory (such as in Windows message handlers) but are not used inside the function.

#ignorefunc funcname [, ...]

#ignorefunc can be used inside functions, like the following:

#include <MsgBoxConstants.au3>
#ignorefunc Not_Defined_Func

Local $vCallRet = Call ('Not_Defined_Func')
Local $iError = @error
Local $iExtended = @extended
MsgBox ($MB_OK, 'Not defined func example', '$vCallRet = ' & $vCallRet & _
' @error = 0x' & Hex ($iError) & ' @extended = 0x' & Hex ($iExtended) & @CRLF )

#forceref $varname [, ...]

#forceref can be used inside functions, like the following:

#include <MsgBoxConstants.au3>

Func Test_NumParams($v1 = 0, $v2 = 0, $v3 = 0, $v4 = 0, $v5 = 0, $v6 = 0, $v7 = 0, $v8 = 0, $v9 = 0)
#forceref $v1, $v2, $v3, $v4, $v5, $v6, $v7, $v8, $v9

Local $iVal = 0

For $i = 1 To @NumParams
$iVal &= Eval ("v" & $i) & " "
Next
MsgBox ($MB_OK, "@NumParams example", "@NumParams = " & @NumParams & @CRLF & @CRLF & $iVal)
EndFunc ;==>Test_NumParams

#forcedef $varname [, ...]

#forcedef can be used after Assign() functions, like the following:

Local $n = Assign ("y", 3)
#forcedef $y
$n = $y ;===> $y = 3

This command line utility can be invoked through an editor add-on. It is located in the same directory as AutoIt3.exe.
The SciTE4AutoIt3 editor provides such an environment.

Usage
--------

Au3Check [-q] [-d] [-w[-] n]... [-v[-] n]... [-I dir]... file.au3

-q : quiet (only error/warn output)
-d : as Opt("MustDeclareVars", 1)
-w 1: already included file (on)
-w 2: missing #comments-end (on)
-w 3: already declared var (off)
-w 4: local var used in global scope (off)
-w 5: local var declared but not used (off)
-w 6: warn when using Dim (off)
-w 7: warn when passing Const or expression on ByRef param(s) (on)
-I dir: additional directories for searching include files

-v 1: show include paths/files (off)
-v 2: show lexer tokens (off)
-v 3: show unreferenced UDFs and global variables (off)
Exit codes:
0: success: no errors or warnings
1: warning(s) only
2: syntax error(s)
3: usage or input error

What is not checked
--------------------------
Basically runtime information:
- No checks are made for array dimensions or indices. This can only be done during runtime.
- Logical errors, illegal parameters to functions and division by zero.


Window Titles and Text (Basic)

When automating, most windows can be uniquely identified by their title or a combination of their title & text. And by using AutoIt Window Info Tool (or even by sight) this information is easy to obtain. The titles of most windows are fairly obvious, for example Untitled - Notepad is the title of the notepad.exe editor and in many cases this is enough to automate.

Note: If a blank string "" is given for both title and text then the currently Active window will be used (this is not true in some of the more advanced WinTitleMatchModes)!

Window titles and text are case sensitive. You must match the case and punctuation exactly. To avoid problems select the title/text in the Window Info Tool and use ctrl-c to copy it and then paste it directly into your script.
You can force match in lower case using advanced modes.

Most of AutoIt's window functions have space for a title and text entry, here is the WinWaitActive function. This function pauses execution of the script until the specified window appears and is active.

WinWaitActive ( "title" [, "text" [, timeout]] )

The only required parameter for this function is title. However, the text and timeout parameters are optional. In some functions, the text parameter is not optional. If you do not wish to specify any text then just use "" (a blank string). A blank string, or nothing at all, in the text tells AutoIt that any text is valid.

To use the above function with any notepad window both these methods will work:

WinWaitActive ("Untitled - Notepad")

and

WinWaitActive ("Untitled - Notepad", "")

If the same notepad window had, "This is some text!" typed into the window, the Window Info Tool would show:

Note that the Window Info Tool has seen the title and text of the notepad window. Whatever the Window Info Tool can see is what AutoIt can see. Now we have enough information to identify this exact window even if there are lots of other notepad windows open. In this case we use:

WinWaitActive ("Untitled - Notepad", "This is some text!")

Window Text

The window text consists of all the text that AutoIt can "see". This will usually be things like the contents of edit controls (as above with "This is some text!") but will also include other text like:

  • Button text like &Yes, &No, &Next (the & indicates an underlined letter)
  • Dialog text like "Are you sure you wish to continue?"
  • Control text
  • Misc text - sometimes you don't know what it is :)

The important thing is that you can use the text along with the title to uniquely identify a window to work with.

When you specify the text parameter in a window function it is treated as a substring. So for the example above if you used the text "is some " you would get a match.

What has been described is the default mode in which AutoIt operates. There are a number of more advanced modes to use when things are not as simple as this.

Note: Hidden windows can be matched by "title" only if "text" is empty ("").


Window Titles and Text (Advanced)

AutoIt operates in one of three "Window matching" modes. The modes are set with the AutoItSetOption function using the WinTitleMatchMode option.

Mode 1 (default)

Matches partial titles from the start.

In this mode, a window titled Untitled - Notepad would be matched by "Untitled - Notepad", "Untitled", "Un", etc.

e.g.

WinWait ("Untitled")

Mode 2

Matches any substring in the title.

In this mode, a window titled Untitled - Notepad would be matched by "Untitled - Notepad", "Untitled", "Notepad", "pad", etc.

e.g.

WinWait ("Notepad")

Mode 3

Exact title match.

In this mode, a window titled Untitled - Notepad would only be matched by "Untitled - Notepad".

Mode 4 (Kept for backward compatibility)

Advanced mode

Replaced by Advanced Window Descriptions which work in any mode.

Mode -1 to -4

Case insensitive match according to the other type of match.

Advanced Window Descriptions

A special description can be used as the window title parameter. This description can be used to identify a window by the following properties:

  • TITLE - Window title
  • CLASS - The internal window classname
  • REGEXPTITLE - Window title using a regular expression (if the regular expression is wrong @error will be set to 2)
  • REGEXPCLASS - Window classname using a regular expression (if the regular expression is wrong @error will be set to 2)
  • LAST - Last window used in a previous Windows AutoIt Function (see Windows Management Functions)
  • ACTIVE - Currently active window
  • X \ Y \ W \ H - The position and size of a window
  • INSTANCE - The 1-based instance when all given properties match

One or more properties are used in the title parameter of a window command in the format:

[PROPERTY1 : Value1; PROPERTY2:Value2]

Note : if a Value must contain a ";" it must be doubled.

e.g. Wait for a window with the classname "Notepad".

WinWaitActive ("[CLASS:Notepad]", "")

e.g. Close the currently active window

WinClose ("[ACTIVE]", "")

e.g. Wait for the 2nd instance of a window with title "My Window" and classname "My Class"

WinWaitActive ("[TITLE:My Window; CLASS:My Class; INSTANCE:2]", "")

e.g. List windows matching Title defined by a regular expression

WinList ("[REGEXPTITLE:(?i)(.*SciTE.*|.*Internet Explorer.*)]")

Window Handles / HWNDs

The variant datatype in AutoIt natively supports window handles (HWNDs). A window handle is a special value that Windows assigns to windows each time they are created. When you have a handle you may use it in place of the title parameter in any of the function calls that use the title/text convention. The advantage of using window handles is that if you have multiple copies of an application open which have the same title/text then you can uniquely identify them using handles. When you use a window handle for the title parameter then the text parameter is completely ignored.

Various functions such as WinGetHandle, WinList and GUICreate return these handles. It is important to note that a window handle is not classed as a number or string - it is its own special type.

Note: Window handles will work no matter what WinTitleMatchMode is currently in use.

Example

Local $hWnd = WinGetHandle ("Untitled - Notepad", "")
WinClose ($hWnd)


Controls

One of the best features with AutoIt v3 is the ability to work directly with certain types of Window Controls. Almost everything you see on a window is a control of some kind. Buttons, listboxes, edit fields and static text are all examples of controls. In fact, Notepad is just one big "Edit" control! Because AutoIt works directly with a control, they provide a more reliable way to automate than just sending keystrokes.

Note: AutoIt only works with standard Microsoft controls. Some applications write their own custom controls which may look like a standard MS control but may resist automation. Experiment!

Using the AutoIt Window Info Tool you can move your mouse around the window you are interested in and you will be given information of the control that is currently under your mouse.

A special description can be used as the controlID parameter used in most of the Control...() functions. This description can be used to identify a control by the following properties:

  • ID - The internal control ID. The Control ID is the internal numeric identifier that windows gives to each control. It is generally the best method of identifying controls. In addition to the AutoIt Window Info Tool, other applications such as screen readers for the blind and Microsoft tools/APIs may allow you to get this Control ID
  • TEXT - The text on a control, for example "&Next" on a button
  • CLASS - The internal control classname such as "Edit" or "Button"
  • CLASSNN - The ClassnameNN value as used in previous versions of AutoIt, such as "Edit1"
  • NAME - The internal .NET Framework WinForms name (if available)
  • REGEXPCLASS - Control classname using a regular expression
  • X \ Y \ W \ H - The position and size of a control.
  • INSTANCE - The 1-based instance when all given properties match.

One or more properties are used in the controlID parameter of a control command in the format:

[PROPERTY1 : Value1; PROPERTY2:Value2]

Note: If this special format is not used then the parameter is taken to be a control ID (if numeric) or the ClassnameNN/text of the control (if a string). Although the special format is more long-winded than these methods it is much less ambiguous.

If a Value must contain a ";" it must be doubled.

e.g. Send text to the 1st Edit control in the Notepad window

ControlSend ("Untitled - Notepad", "", "[CLASS:Edit; INSTANCE:1]", "This is some text")

or

ControlSend ("Untitled - Notepad", "", "[CLASSNN:Edit1]", "This is some text")

or

ControlSend ("Untitled - Notepad", "", "Edit1", "This is some text")

e.g. Click on control ID 254 in "My Window"

ControlClick ("My Window", "", "[ID:254]")

or

ControlClick ("My Window", "", 254)

e.g. Set the text of the .NET Winforms "textBoxFolder" control to "C:\Some\Folder"

ControlSetText ("My Window", "", "[NAME:textBoxFolder]", "C:\Some\Folder")

e.g. Click the 2nd instance of a "Button" control containing the text "Finish"

ControlClick ("My Window", "", "[CLASS:Button; TEXT:Finish; INSTANCE:2]")

Control Handle (HWND)

Using the ControlGetHandle function you can determine the Handle or HWND of a control. A handle is the unique identifier that Windows gives controls. The handle changes each time the control is created. This method of accessing controls is generally only designed for users who are familiar with working with handles.

Look under the contents for Function Reference \ Window Management \ Controls for a list of the functions that work with controls.


Unicode Support

The supported file formats for text files and scripts and their notation in popular editors are shown in this table:

AutoIt Notation | Notepad | Notepad++ | SciTE (AutoIt Default Editor)
UTF8 without BOM | ANSI or UTF-8 depending on content (will force a BOM if saved) | UTF-8 without BOM | UTF-8
UTF8 with BOM | UTF-8 | UTF-8 | UTF-8 with BOM
ANSI | ANSI | ANSI | 8 bit / Code Page Property
UTF16 Little Endian | Unicode | UCS-2 Little Endian | UCS-2 Little Endian
UTF16 Little Endian without BOM | Unicode (will force a BOM if saved) | UCS-2 Little Endian without BOM (can't be selected) | Unsupported
UTF16 Big Endian | Unicode big endian | UCS-2 Big Endian | UCS-2 Big Endian
UTF16 Big Endian without BOM | Unsupported | UCS-2 Big Endian without BOM (can't be selected) | Unsupported

The recommended script format is UTF-8 with BOM as that works best with notepad.exe and the AutoIt editor SciTe and guards against scripts unintentionally getting saved in a particular code page.

ANSI formats are not recommended as they can cause problems when run on machines with different locales.

UTF16 BE or LE without a BOM are not recommended. They are widely unsupported. Even with a BOM they are not particularly common and they take up much more disk space than UTF8.

  • File operations on text files not opened with FileOpen() and explicit unicode flags auto-detect encoding similar to most modern editors. This includes all file functions that are used with a filename, for example FileRead("filename.txt"). Specifically:
    • Files containing a BOM will be opened in the relevant mode as per that BOM. UTF-8 and UTF-16 BOMs are checked.
    • UTF-8 and UTF-16 files without a BOM will be automatically detected and opened in the relevant mode.
    • Files containing nulls are opened in Binary ($FO_BINARY) mode by default (unless they are detected as valid UTF-16). Previously they would be opened in ANSI mode. Use the $FO_ANSI flag to override.
    • Files containing only characters 1-127 are opened in UTF-8 with no BOM ($FO_UTF8_NOBOM) mode by default. Previously they would be opened in ANSI mode. Use the $FO_ANSI flag to override.
    • Files containing only characters 1-255 are opened in ANSI ($FO_ANSI) mode by default.
    • Due to the above FileGetEncoding() now returns 512 ($FO_ANSI) or 256 ($FO_UTF8_NOBOM) instead of 0 which was undocumented but indicated ANSI.

    Current Limitations

    There are a few parts of AutoIt that don't yet have full Unicode support. These are:

    • Send and ControlSend - Instead, Use ControlSetText or the Clipboard functions.
    • Console operations are converted to ANSI.

    These limits will be addressed in future versions if possible.


Running under Windows 64-bit Edition

AutoIt has traditionally been a 32-bit application. With the v3.2.10.0 release, native x64 versions of some components have been added, including:

  • AutoIt (AutoIt3_x64.exe)
  • Aut2Exe (Aut2Exe_x64.exe)
  • Au3Info (Au3Info_x64.exe)
  • AutoItX (AutoItX3_x64.dll)

During installation, if AutoIt is found to be running on an x64 system then you will be given the choice to install and configure the x64 versions. These versions are fully x64 compatible, however, some scripts that use DllCall/DllStruct with custom structures may use values that break 64-bit compatibility (such as using 32-bit integers for pointers).

You can run the x86 version of AutoIt by right-clicking a script and selecting "Run Script (x86)".

To see if you are running under a x64 edition of Windows use @OSArch macro, like-wise to see if you are using the 32-bit or 64-bit version of AutoIt use @AutoItX64.

Running the 32-bit version of AutoIt on a x64 System

For Files, Windows has a special redirection mechanism for some system directories :

Directories | 32-bit Value | 64-bit Value
@SystemDir | @WindowsDir & "\System32" | @WindowsDir & "\SYSWOW64"
@ProgramFilesDir | {SystemDrive} & "\Program Files (x86)" | {SystemDrive} & "\Program Files"

It's possible to access the 64-bit version of those directories by disabling the redirection mechanism.

#include <WinAPIFiles.au3>

_WinAPI_Wow64EnableWow64FsRedirection ( True )

Additional information can be found at MSDN.

For registry interaction, use HKCR64 or HKLM64 to bypass the redirection mechanism see Registry Functions documentation.


Tutorials

  • My First Script (Hello World)
  • Simple Notepad Automation
  • WinZip Installation
  • String Regular Expression
  • Creating to GUI Calculator


Tutorial - HelloWorld

This tutorial explains the basics of creating an AutoIt script and running it. The tutorial assumes that you have already fully installed AutoIt v3 using the supplied installer.

First open a folder where you wish to create the script. Right-click in the folder and select New / AutoIt v3 Script.

A new file will be created, immediately allowing you to rename it to something more appropriate. Change 'New AutoIt v3 Script' to 'helloworld', leaving the '.au3' in the name intact if it is visible.

Now we have created the script file we want to edit it to make it do something useful. Right-click on helloworld.au3 and select Edit Script.

The SciTE editor will open and you will see something like this:

The code you see is simply some comments that you can use to organize your scripts. The lines that start with a semi-colon ; are treated as comments (ignored). ; is similar to the REM statement in a DOS batch file. The template is stored at "C:\Windows\ShellNew\Template.au3" - you can customise it to meet your own requirements.

Now we want to tell AutoIt to display a message box - this is done with the MsgBox function.

At the bottom of the file type the following:

#include <MsgBoxConstants.au3>

MsgBox ($MB_OK, "Tutorial", "Hello World!")

All functions take parameters, MsgBox takes three - a flag, a title and a message. The flag is a number that changes the way MsgBox displays - we will use $MB_OK for now. The title and message are both string parameters - when using strings in AutoIt surround the text in double or single quotes. "This is some text" or 'This is some text' - both will work fine.

Now save the script and close the editor. You've just written your very first AutoIt script! To run the script simply double-click the helloworld.au3 file (you may also right-click the file and select Run Script) .

You should see this:

Now, let's look at the flag parameter for the MsgBox function again. From the documentation page we can see various values listed which change the way MsgBox displays. The value of $MB_OK simply shows a simple message box with an OK button. A value of $MB_ICONINFORMATION displays the message box with an information icon.

Edit the script again and change $MB_OK to $MB_ICONINFORMATION so you have:

#include <MsgBoxConstants.au3>

MsgBox ($MB_ICONINFORMATION, "Tutorial", "Hello World!")

Run the script and you will see:

Experiment with the various flag values to see what kind of results you can get. Remember, if you want to use more than one flag value then simply add the required values together.


Tutorial - Notepad

This tutorial explains how to automate the opening of Notepad, automatically type some text and then close Notepad. It is assumed that you are already familiar with creating and running AutoIt scripts as shown in the HelloWorld tutorial.

First create an empty script called npad.au3 and then edit the file (using Notepad or SciTE as you prefer).

The first thing we need to know is the name of the Notepad executable. It is notepad.exe - you can get this information by looking at the properties of the Notepad shortcut icon in the Start Menu. To execute Notepad we use the AutoIt Run function. This function simply launches a given executable and then continues.

Type in the first line of script as:

Run ("notepad.exe")

Run the script - if all goes well then a new instance of Notepad should open.

When automating applications AutoIt can check for window title so that it knows which window it should work with. With Notepad the window title is obviously Untitled - Notepad. AutoIt is case-sensitive when using window titles so you must get the title exactly right - the best way to do this is to use the AutoIt Window AutoIt v3 Window Info. Run the AutoIt v3 Window Info from Start Menu \ AutoIt v3 \ AutoIt Window Info.

With the Info Tool open click on the newly opened Notepad window to activate it; the Info Tool will give you information about it. The information we are interested in is the window title.

Highlight the title in the AutoIt Info Tool window and press CTRL-C to copy it to the clipboard - we can then paste the title into our script without fear of misspelling it.

After running a copy of Notepad we need to wait for it to appear and become active before we send any keystrokes. We can wait for a window using the WinWaitActive function. Most window-related functions in AutoIt take a window title as a parameter.

Enter the following as the second line in the script (use CTRL-V or Edit\Paste to paste our window title from the clipboard).

WinWaitActive ("Untitled - Notepad")

After we are sure the Notepad window is visible we want to type in some text. This is done with the Send function.

Add this line to our script.

Send ("This is some text.")

The entire script will now look like this:

Run ("notepad.exe")
WinWaitActive ("Untitled - Notepad")
Send ("This is some text.")

Close the copy of Notepad that we previously opened (you will need to do this every time you run the script otherwise you will end up with lots of copies running!). Run the script.

You should see Notepad open, and then some text will magically appear!

Next we want to close notepad, we can do this with the WinClose function.

WinClose ("Untitled - Notepad")

When Notepad tries to close you will get a message asking you to save the changes. Use the Window Info Tool to get details of the dialog that has popped up so that we can respond to it :)

So, we add a line to wait for this dialog to become active (we will also use the window text to make the function more reliable and to distinguish this new window from the original Notepad window):

WinWaitActive ("Notepad", "Save")

Next we want to automatically press Alt-N to select the No/Don't save button (Underlined letters in windows usually indicate that you can use the ALT key and that letter as a keyboard shortcut). In the Send function to send an ALT key we use ! .

Send ("!n")

Our complete script now looks like this:

Run ("notepad.exe")
WinWaitActive ("Untitled - Notepad")
Send ("This is some text.")
WinClose ("Untitled - Notepad")
WinWaitActive ("Notepad", "Save")
;WinWaitActive("Notepad", "Do you want to save") ; When running under Windows XP
Send ("!n")

Run the script and you'll see Notepad open, some text appear and then close! You should be able to use the techniques learned in this tutorial to automate many other applications.


Tutorial - WinZip

This tutorial explains how to automate the installation of WinZip 9 SR-1. It is assumed that you are already familiar with creating and running AutoIt scripts and the use of the AutoIt v3 Window Info to read window titles and text, as shown in the HelloWorld and Notepad tutorials.

The WinZip installation consists of approximately 10 dialog boxes that you must click buttons (usually Next) to continue. We are going to write a script that simply waits for these dialog boxes to appear and then clicks the appropriate buttons. As usual with these types of installations the window title of each dialog is the same (WinZip Setup) so we must use window text to tell the difference between windows. Screenshots of each dialog will be provided and you can click on the picture to see the AutoIt v3 Window Info output for that dialog.

First create a directory that we will use for the WinZip installer and our script file. Copy the WinZip installer to this directory and create a blank script called winzipinstall.au3.

We will now run through the installation manually and write the script as we go. The script lines to automate each dialog will be shown after each picture (remember to click on the picture to see the AutoIt v3 Window Info output). You can also look at the completed script for reference.

The first script line is easy, we want to run the winzip90.exe installer. So the first line is:

Run ("winzip90.exe")

The first dialog will pop-up:

We need to wait for this window to popup and become active, and then we need to send the keystroke ALT-s to click the Setup button. The resulting script lines are:

WinWaitActive ("WinZip® 9.0 SR-1 Setup", "&Setup")
Send ("!s")

(Remember to click on the picture to see the AutoIt v3 Window Info output, this is especially important as the title contains the special (R) character which would be difficult to type).

The installation location dialog will appear next:

We need to wait for this screen to be active and then click ENTER to accept the install location. The script lines are:

WinWaitActive ("WinZip Setup", "into the following folder")
Send ("{ENTER}")

The WinZip Features dialog will appear next:

Notice that this window has exactly the same title as the first of WinZip Setup - in fact all the dialogs in the setup have this title! In order to tell the difference between these windows we must also use the window text - on each screen try to pick the most unique text you can. In this case I've chosen WinZip features include. After the window has appeared we will want to press ALT-n:

WinWaitActive ("WinZip Setup", "WinZip features include")
Send ("!n")

The License dialog will appear next:

Wait for the window to appear and then press ALT-y to accept the agreement:

WinWaitActive ("License Agreement")
Send ("!y")

Setup continues in a similar fashion for a few dialogs. The picture of each dialog is shown along with the script lines needed to automate it.

WinWaitActive ("WinZip Setup", "Quick Start Guide")
Send ("!n")

WinWaitActive ("WinZip Setup", "switch between the two interfaces")
Send ("!c")
Send ("!n")

WinWaitActive ("WinZip Setup", "&Express setup (recommended)")
Send ("!e")
Send ("!n")

WinWaitActive ("WinZip Setup", "WinZip needs to associate itself with your archives")
Send ("!n")

This is the final dialog of the setup. Notice that the Finish button doesn't have a keyboard shortcut - luckily it is the default button on this dialog so we can just press ENTER to select it. If this were not the case then we would have to TAB between controls or better yet use the ControlClick function.

WinWaitActive ("WinZip Setup", "Thank you for installing this evaluation version")
Send ("{ENTER}")

After installation WinZip will automatically start:

We simply wait for the main WinZip window to appear and then close it with the WinClose function.

WinWaitActive ("WinZip (Evaluation Version)")
WinClose ("WinZip (Evaluation Version)")

Here is the completed script - note that I have commented each dialog separately which makes it easier to follow and to change in the future (the next version of WinZip may be slightly different).

And that's it! Run the winzipinstaller.au3 script and watch as WinZip is installed in just a few seconds! The techniques used in this tutorial can be used to automate the installation of most programs.

As an exercise for the reader, try and redo the script but instead of using the Send function (which sends keys to the active window) to click on buttons try and use ControlClick instead which can be much more reliable. You will need to read up on Controls to do this.


Tutorial - Regular Expression

Here's a smallish guide on unraveling the seeming mysteries of StringRegExp().

StringRegExp( "test" , "pattern" [, flag ] )

"test" = The string to search through for matches.
"pattern" = A string consisting of certain key characters that let the function know PRECISELY what you want to match. No ifs, ands, or buts.. it's a match or it isn't.
flag [optional] = Tells the function if you just want to know if the "pattern" is found, or if you want it to return the first match, or if you want it to return all the matches in the "test" string.

The Very Basics

As you may have figured out, the "pattern" string is the only difficult part of calling a StringRegExp() (forthwith: SRE). I find it best to think of patterns as telling the function to match a string character by character. There are different ways to find a certain character: If you want to match the string "test", that should be simple enough. You want to tell SRE to first search the string for a "t". If it finds one, then it assumes it has a match, and the rest of the pattern is used to try to prove that what it's found is not a match. So, if the next character is an "e", it could still be a match. Let's say the next letter is an "x". SRE knows immediately that it hasn't found a match because the third character you tell it to look for is an "s".

Example 1

#include <MsgBoxConstants.au3>

MsgBox ($MB_OK, "SRE Example 1 Result", StringRegExp ("text", 'test'))

In this example, the message box should read "0", which means the pattern "test" was not found in the test string "text". I know this seems pretty simple, but now you know why it wasn't found.

The next way of specifying a pattern is by using a set ("[ ... ]"). You can equate a set to the logic function "OR". Let's use the previous Example. We want to find either the string "test" or the string "text". So, the way I start looking for a pattern is to think like SRE would think: The first character I want to match is "t", then the letter "e", this is the same for both strings we want to match. Now we want to match "s" OR "x", so we can use a set as a substitute: "[sx]" means match an "s" or an "x". Then the last letter is a "t" again.

Example 2

#include <MsgBoxConstants.au3>

MsgBox ($MB_OK, "SRE Example 2 Result", StringRegExp ("text", 'te[sx]t'))
MsgBox ($MB_OK, "SRE Example 2 Result", StringRegExp ("test", 'te[sx]t'))

These should both provide the result "1", because the pattern should match both "test" and "text".

You can also specify how many times to match each character by using "{number of matches}" or you can specify a range by using "{min, max}". The first example below is redundant, but shows what I mean:

Example 3

#include <MsgBoxConstants.au3>

MsgBox ($MB_OK, "SRE Example 3 Result", StringRegExp ("text", 't{1}e{1}[sx]{1}t{1}'))
MsgBox ($MB_OK, "SRE Example 3 Result", StringRegExp ("aaaabbbbcccc", 'b{4}'))

The Not-So Basics

Right now you're probably thinking "Isn't this just a glorified StringInStr() function?". Well, using a "flag" value of 0, most of the time you're right. But SRE is much more powerful than that. As you use SRE's more and more, you'll find you might know less and less about the type of pattern you are looking for. There are ways to be less and less specific about each character you wish to specify in the pattern. Take, for example, a line from an inventory log file: "There were 18 sheets left in the ream of paper." You want to find the number of remaining sheets. Well, you can't use StringInStr() because you aren't looking for "18", you're looking for "????", where ? could be any digit.

Here's how I would assemble this pattern. Look at what you do and do not know about what you want to find:
1) You know that it will ALWAYS contain nothing but digits.
2) You know that it will SOMETIMES be 2 characters long.
2a) You know that a full ream of paper is 500 sheets.
2b) You know that the minimum number of sheets is 0.
3) You know that it will ALWAYS be between 1 and 3 characters long.
4) You know that there are no other digits in the test string.

At this point, I'd like to introduce the FLAG value of "1" and the grouping characters "()". The flag value of "1" means that SRE will not only match your pattern, but also return an array, with each element of the array consisting of a captured "group" of characters. So without veering off course too much, take this example:

Example 4

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

Local $aResult = StringRegExp ("This is a test example", '(test)', $STR_REGEXPARRAYMATCH)
If Not @error Then
MsgBox ($MB_OK, "SRE Example 4 Result", $aResult[0])
EndIf
$aResult = StringRegExp ("This is a test example", '(te)(st)', $STR_REGEXPARRAYMATCH)
If Not @error Then
MsgBox ($MB_OK, "SRE Example 4 Result", $aResult[0] & "," & $aResult[1])
EndIf

So, first the pattern must match somewhere in the test string. If it does, then SRE is told to "capture" any groups ("()") and store them in the return array. You can use multiple captures, as demonstrated by the second piece of code in Example 4.

Ok, back to the log file. Now that we know how to "capture" text, let's construct our pattern: Since you know what you're looking for is digits, there are 3 ways to specify "match any digit": "[:digit:]", "[0-9]", and "\d". The first is probably the easiest to understand. There are a few classes (digit, alnum, space, etc. Check the help file for a full list) you can use to specify sets of characters, one of them being digit. "[0-9]" just specifies a range of all the digits 0 through 9. "\d" is just a special character that means the same as the first two. There is no difference between the three, and with all SRE's there are usually at least a couple ways to construct any pattern.

So, first we know we want to capture the digits, so indicate that with the opening parentheses "(". Next, we know we want to capture between 1 and 3 characters, all consisting of digits, so our pattern now looks like "([0-9]{1,3}". And finally close it off with the closing parentheses to indicate the end of our group: "([0-9]{1,3})". Let's try it:

Example 5

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

Local $aResult = StringRegExp ("There were 18 sheets left in the ream of paper.", _
'([0-9]{1,3})', $STR_REGEXPARRAYMATCH)
If Not @error Then
MsgBox ($MB_OK, "SRE Example 5 Result", $aResult[0])
EndIf

There you go, the message box correctly displays "18".

Next we need to cover non-capturing groups. The way you indicate these groups is by opening the group with "(?:" instead of just "(". Let's say your log file says "You used 36 of 279 pages." Now if you run Example 5's SRE on this, you'll come up with "36" instead of "279". Now what I like to do here is just determine what's different between the numbers. One that jumps out at me is that the second number is always followed by a space and then the word "pages". We could just modify our previous pattern to be "([0-9]{1,3} pages)", but what if our script is just looking for the starting amount of pages, without " pages" tacked onto the end of the number? Here's where you can use a non-capturing group to accomplish this.

Example 6

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

Local $aResult = StringRegExp ("You used 36 of 279 pages.", '([0-9]{1,3})(?: pages)', $STR_REGEXPARRAYMATCH)
If Not @error Then
MsgBox ($MB_OK, "SRE Example 6 Result", $aResult[0])
EndIf

This could get lengthy, but mostly I just wanted to lay out the foundation for how regular expressions work, and mainly how SRE "thinks". A few things to keep in mind:
- Remember to think about the pattern one character at a time
- The StringRegExp() function finds the first character in the pattern, then it's your job to provide enough
evidence to "prove" whether or not it truly is a match. Example 6 is a good display of this.
- Remember [ ... ] means OR ([xyz] match an "x", a "y", OR a "z")
If you have any other questions, consult the help file first! It explains in detail all of the nitty gritty syntax that comes along with SRE's. One thing to look at in particular is the section on "Repeating Characters". It can make your pattern more readable by substituting certain characters for ranges. For example: "*" is equivalent to {0,} or the range from 0 to any number of characters.

Good luck, Regular Expressions can greatly decrease the length of your code, and make it easier to modify later. Corrections and feedback are welcome!

Resources

Wikipedia Article - Regular Expressions - Thanks blindwig.

The 30 Minute Regex Tutorial - by Jim Hollenhorst.

GUI for testing various StringRegExp() patterns - Thanks steve8tch. Credit: w0uter

Thanks to neogia for this tutorial.


Tutorial - Simple calculator (Part I)

Tutorial - Creating to GUI Calculator - (Dialog Creation)

In this tutorial we will try to guide him to create a basic calculator, just as that of MS-Windows. Using the GUI's AutoIt features.
It is assumed that you are already familiar with creating and running AutoIt scripts as shown in the example.

Creation of the GUI dialog - (Design)

In this part we will begin with the creation of GUI dialog. It's good to have the idea of the design based on the utility of our program.
That is to say, how many and that type of controls will need. In this case we will use the same design that Windows Calc.
In the Fig. 1, we can see how our calculator will be finished in this part.

Fig. 1

To begin the creation of our dialog, we will begin including some libraries which declare constants we use in our dialog box. These constants contain numeric values of styles and parameters that define the appearance of each control, as well as you value for events and states. (Usually, "GUIConstantsEx.au3" already comes included and it resides in the AutoIt's folder installer). Later on we will see how to apply them, for the time being we will make the inclusion of this library writing in our script the following lines:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

How it could it turns in the basic tutorial, to begin the creation of our dialog we begin defining the window, as the title, size and position with GUICreate(). The values of the window will be the following ones:
Title = "Calculator"
Width = 260
Height = 230
Therefore, the following lines of our code would be:

GUICreate ("Calculator", 260, 230)

To store the identifier (ID) of each control
In the definition part, we will be ahead to the assignment of variables for each button that we make. When making this assignment, the variable stores the control ID that it allows us to use it to be able to to manipulate "their action" in run-time. See example.

Variable naming
The naming of each variable is a personal matter, but it's important to be clear to the one to assign name for the easy understanding of what represents in the certain code control. As it looks in the next example, this syntax used: $CTRL_btn1 that means "TO GUI Control - It's a button, Digit #1", the parameters for this button's example are the following ones:
Text ="1", Left = 54, Top = 138, Width = 36, Height = 29

$CTRL_btn1 = GUICtrlCreateButton ("1", 54, 138, 36, 29)

As I mentioned before, this makes that the code to be clearer.

Creation of each control
As we can it looks in the Fig.1, we needs to create several buttons, which we will define with GUICtrlCreateButton(). The buttons that we will define will be: the digits of 0 up to 9, the operators, memory's buttons as such Memory Clear ("MC"), Memory Restore ("MR"), etc.
You can copy the code shown below and to add to your script:

; Digit's buttons
Local $CTRL_btn0 = GUICtrlCreateButton ("0", 54, 171, 36, 29)
Local $CTRL_btn1 = GUICtrlCreateButton ("1", 54, 138, 36, 29)
Local $CTRL_btn2 = GUICtrlCreateButton ("2", 93, 138, 36, 29)
Local $CTRL_btn3 = GUICtrlCreateButton ("3", 132, 138, 36, 29)
Local $CTRL_btn4 = GUICtrlCreateButton ("4", 54, 106, 36, 29)
Local $CTRL_btn5 = GUICtrlCreateButton ("5", 93, 106, 36, 29)
Local $CTRL_btn6 = GUICtrlCreateButton ("6", 132, 106, 36, 29)
Local $CTRL_btn7 = GUICtrlCreateButton ("7", 54, 73, 36, 29)
Local $CTRL_btn8 = GUICtrlCreateButton ("8", 93, 73, 36, 29)
Local $CTRL_btn9 = GUICtrlCreateButton ("9", 132, 73, 36, 29)
Local $CTRL_btnPeriod = GUICtrlCreateButton (".", 132, 171, 36, 29)

; Memory's buttons
Local $CTRL_btnMClear = GUICtrlCreateButton ("MC", 8, 73, 36, 29)
Local $CTRL_btnMRestore = GUICtrlCreateButton ("MR", 8, 106, 36, 29)
Local $CTRL_btnMStore = GUICtrlCreateButton ("MS", 8, 138, 36, 29)
Local $CTRL_btnMAdd = GUICtrlCreateButton ("M+", 8, 171, 36, 29)

; Operators
Local $CTRL_btnChangeSign = GUICtrlCreateButton ("+/-", 93, 171, 36, 29)
Local $CTRL_btnDivision = GUICtrlCreateButton ("/", 171, 73, 36, 29)
Local $CTRL_btnMultiplication = GUICtrlCreateButton ("*", 171, 106, 36, 29)
Local $CTRL_btnSubtract = GUICtrlCreateButton ("-", 171, 138, 36, 29)
Local $CTRL_btnAdd = GUICtrlCreateButton ("+", 171, 171, 36, 29)
Local $CTRL_btnAnswer = GUICtrlCreateButton ("=", 210, 171, 36, 29)
Local $CTRL_btnInverse = GUICtrlCreateButton ("1/x", 210, 138, 36, 29)
Local $CTRL_btnSqrt = GUICtrlCreateButton ("Sqrt", 210, 73, 36, 29)
Local $CTRL_btnPercentage = GUICtrlCreateButton ("%", 210, 106, 36, 29)
Local $CTRL_btnBackspace = GUICtrlCreateButton ("Backspace", 54, 37, 63, 29)
Local $CTRL_btnClearE = GUICtrlCreateButton ("CE", 120, 37, 62, 29)
Local $CTRL_btnClear = GUICtrlCreateButton ("C", 185, 37, 62, 29)

Local $CTRL_EdtScreen = GUICtrlCreateEdit ("0.", 8, 2, 239, 23)
Local $CTRL_LblMemory = GUICtrlCreateLabel ("", 12, 39, 27, 26)

Already defined the creation of each control, is important to add the line following to show our dialog box, using GUISetState().

GUISetState ()

Messages loop
As he/she could it turns in the one , the function GUIGetMsg() gives as output a value of an event in the dialog box, and this it is received by the variable in this case, $msg that is evaluated every time that Do.. Until loop, repeats. For this part we will only add the one simpler event, which repeats in an infinite cycle until the event similar to the constant $GUI_EVENT_CLOSE (equal to -3) it's presented, and it will make that close the window and finish the script. So the following lines for our script will be:

Local $msg
Do
$msg = GUIGetMsg ()

Until $msg = $GUI_EVENT_CLOSE

Application of styles
Until this point, we have already been able to conclude the design of our dialog box. You can already execute the script and it will see almost ended the calculator, now observe that the calculator shows something not foreseen in the design. The EDIT control that represents the screen of digits not displayed correctly, which needs that we apply certain styles of appearance (to see the Fig. 2). For to correct this appearance, we will make use of EDIT styles:

Fig. 2

For this part, we only need to modify two lines of our code.

First modification: in the first addition, we will add in the line of the variable $CTRL_EdtScreen, a definition for the control (Edit) that is of reading ($ES_READONLY) and that it is justified to the right ($ES_RIGHT), for we join these two variables with the function BitOR() like it is presented in the line of code below. We will also add $WS_EX_STATICEDGE to the parameter of extended style (exStyle) to give the sunken appearance to the border. For more reference of the styles table for EDIT control, click here. (for a detailed explanation of each style).

Local $CTRL_EdtScreen = GUICtrlCreateEdit ("0.", 8, 2, 239, 23, BitOR ($ES_READONLY, $ES_RIGHT), $WS_EX_STATICEDGE)

Second modification: the second addition we will add to the line of the variable $CTRL_LblMemory, that it contains a LABEL control in which will show us the state of storage in memory that we will see in the second part. We will define that this control (Label) will have a sunken ($SS_SUNKEN) like it is presented in the line of the code. For reference of styles table for LABEL control, click here.

Local $CTRL_LblMemory = GUICtrlCreateLabel ("", 12, 39, 27, 26, $SS_SUNKEN)

After making these changes try to execute the script. The changes affects the appearance shown in the Fig. 3, now our calculator it looks as the Fig. 1, shown at the beginning. You can also look at the for reference.

Fig. 3

As an exercise for the reader, try adding $BS_FLAT to style parameter in some button, you will look a flat style in the appearance.


Language Reference

The basics of the AutoIt language:

  • Datatypes
  • Variables
  • Macros
  • Operators
  • Conditional Statements
  • Loop Statements
  • Obj Statements
  • User Functions
  • Comments
  • Directives


Language Reference - Datatypes

In AutoIt there is only one datatype called a Variant. A variant can contain numeric or string data and decides how to use the data depending on the situation it is being used in. For example, if you try and multiply two variants they will be treated as numbers, if you try and concatenate (join) two variants they will be treated as strings.

Some examples:

10 * 20 equals the number 200 (* is used to multiply two numbers)

10 * "20" equals the number 200

"10" * "20" equals the number 200

10 & 20 equals the string "1020" (& is used to join strings)

If a string is used as a number, an implicit call to Number() function is done. So if it doesn't contain a valid number, it will be assumed to equal 0. For example,

10 * "fgh" equals the number 0.

If a string is used as a boolean and it is an empty string "" , it will be assumed to equal False (see below). For example,

Not "" equals the Boolean True.

Numbers

Numbers can be standard decimal numbers like 2, 4.566, and -7.

Scientific notation is also supported; therefore, you could write 1.5e3 instead of 1500.

Integers (whole numbers) can also be represented in hexadecimal notation by preceding the integer with 0x as in 0x409 or 0x4fff.

Strings

Strings are enclosed in double-quotes like "this". If you want a string to actually contain a double-quote use it twice like:

"here is a ""double-quote"" - ok?"

You can also use single-quotes like 'this' and 'here is a ' 'single-quote' ' - ok?'

You can mix quote types to make for easier working and to avoid having to double-up your quotes to get what you want. For example if you want to use a lot of double-quotes in your strings then you should use single-quotes for declaring them:

'This "sentence" contains "lots" of "double-quotes" does it not?'

is much simpler than:

"This ""sentence"" contains ""lots"" of ""double-quotes"" does it not?"

When evaluated, strings can have Env variables or Var variables substitution according to Opt() function definition.

All AutoIt strings use UTF-16 (in fact and more precisely UCS-2) encoding.

Booleans

Booleans are logical values. Only two Boolean values exist: True and False.

They can be used in variable assignments, together with the Boolean operators And, Or and Not.

Examples:
$fBoolean1 = True
$fBoolean2 = False
$fBoolean3 = $fBoolean1 AND $fBoolean2

This will result in $fBoolean3 being False

$fBoolean1 = False
$fBoolean2 = Not $fBoolean1

This will result in $fBoolean2 being True

If Boolean values are used together with numbers, the following rules apply:

A value 0 will be equal to Boolean False
Any other number value will be equal to Boolean True

Example:
$iNumber1 = 0
$fBoolean1 = True
$fBoolean2 = $iNumber1 And $fBoolean1

This will result in $fBoolean2 being False

If you use arithmetics together with Boolean values (which is not advisable!), the following rules apply:

A Boolean True will be converted into the numeric value 1
A Boolean False will be converted into the numeric value 0

Example:
$fBoolean1 = True
$iNumber1 = 100
$iNumber2 = $fBoolean1 + $iNumber1

This will result in $iNumber2 to be the numeric value 101

If you use strings together with Boolean values, they will be converted as follows:

A Boolean True will be the string value "True"
A Boolean False will be the string value "False"

Example:
$fBoolean1=True
$sString1="Test is: "
$sString2=$sString1 & $fBoolean1

This will result in $sString2 being the string value "Test is: True"

The other way around however is different. When you use string comparisons with Boolean values, the following rules apply:
Only an empty string ("") will be a Boolean False
Any other string values (including a string equal "0") will be a Boolean True

Binary

Binary type can store any byte value. they are converted in hexadecimal representation when stored in a string variable. Example:
$bin = Binary("abc")
$str = String($bin) ; "0x616263"

Pointer

Pointer types store a memory address which is 32bits or 64bits depending on if the 32bit or 64-bit of AutoIt is used. They are converted to hexadecimal representation when stored in a string variable. Window handles (HWnd) as returned from WinGetHandle() are a pointer type.

Variable created with DllStructCreate() can be used as pointer if a 'struct*' type in the DllCall() is used.
A pointer defined by DllStructGetPtr() can be passed to such parameter with a 'struct*' type.

Datatypes and Ranges

The following table shows the internal variant datatypes and their ranges.

Data Sub-type | Range and Notes
Int32 | A 32bit signed integer number.
Int64 | A 64bit signed integer number
Double | A double-precision floating point number.
String | Can contain strings of up to 2147483647 characters.
Binary | Binary data, can contain up to 2147483647 bytes.
Pointer | A memory address pointer. 32bit or 64bit depending on the version of AutoIt used.

Some functions in AutoIt only work with 32-bit numbers (e.g. BitAND() ) and are converted automatically - these functions are documented where required.


Language Reference - Variables

A variable is just a place to store data in memory so that it can be accessed quickly. Think of it as a mailbox in memory that you can put information in or take information out of. For example you might create a variable to store the number a user's response to a question, or the result to a math equation.

Each variable has a name (again, similar to a mailbox) and must start with the $ character and may only contain letters, numbers and the underscore _ character. Here are some example names:

$Var1

$vVariable

$my_Variable

Note that all variable names are case insensitive: MyVariable() is the same as MyvARiAblE()

Each variable is stored as a variant.

Declaring Variables

Variables are declared and created with the Local and Global keywords - Dim can also be used, although this is not recommended.

Local $vVariable

Or you can declare multiple variables at once:

Global $vVariable1, $vVariable2

You can also assign a variable without declaring it first, but many prefer explicit declarations.

$vVariable = "Create and Assign"

Declaring Constants

Constants are declared and created using Const keyword and must be initialised with a value:

Const $iConst1 = 1, $iConst2 = 12

Constants can also be declared and initialized using the Enum keyword:

Enum $iConst1 = 1, $iConst2, $iConst3 ; 1, 2, 3
Enum Step 2 $iIncr0, $iIncr2, $iIncr4 ; 0, 2, 4
Enum Step * 2 $iMult1, $iMult2, $iMult4 ; 1, 2, 4

Once a constant has been assigned, it cannot be changed.

Scope

A variable's scope is controlled by when and how you declare the variable. If you declare a variable at the start of your script and outside any functions it exists in the global scope and can be read or changed from anywhere in the script.

If you declare a variable inside a function it is in local scope and can only be used within that same function. Variables created inside functions are auJasperatically destroyed when the function ends.

By default when variables are declared using Dim or assigned in a function they have local scope unless there is a global variable of the same name (in which case the global variable is reused). This can be altered by using the Local and Global keywords to declare variables and force the scope you want.

Arrays and Maps

AutoIt has 2 types of data collection variables: Arrays and Maps.

Arrays are much faster for random access and can have multiple dimensions - a dimension size is fixed at the initially declared value (although it can be altered using ReDim). Arrays are indexed using integer values referring to the order of elements and start at element[0] - elements can be extracted using the integer index or iterated by a simple For...Next loop.

Maps are better for records/dictionary type access and have a single dimension. They are indexed using either integer or string keys (integers do not refer to the order of elements) and are dynamically resized as values are added or removed. A value can only be accessed by using the original key - these keys can be iterated using the TableKeys function.

Both Arrays and Maps use similar syntax, so care is required to ensure the variable is of the correct datatype - this is determined by the first declaration line for the variable:

Using empty [ ] declares a Map:

Local $vVar[] ; A Map

Filling the [ ] with a dimension size declares an Array:

Local $vVar[3] ; An Array

Assigning element values when declaring makes the variable an Array - these three lines are functionally equivalent:

Local $vVar[3] = [1, 2, 3] ; An Array
Local $vVar[] = [1, 2, 3] ; An Array
Local $vVar = [1, 2, 3] ; An Array

Arrays

An Array is a variable containing a series of data elements. Each element in this variable can be accessed by an index number which relates to the position of the element within the Array - in AutoIt the first element of an Array is always element [0]. Arrays elements are stored in a defined order and can be sorted.

An example:

You want to store a list of names: "Jasper", "Beethoven", "Pinky" and "Fidget". You could use four separate variables to do so, but using an Array is more efficient:

Local $aArray[4]
$aArray[0] = "Jasper"
$aArray[1] = "Beethoven"
$aArray[2] = "Pinky"
$aArray[3] = "Fidget"

To access a specific value in an Array, you use the index number:

$sString = $aArray[2] ; $sString contains "Pinky"

The index number can also be substituted by another variable or an expression, so you can build complex ways to assign or access elements in an array.

The elements of an entire Array can be iterated using a For...Next loop:

; UBound returns the total number of elements - as the first is [0] the highest index is one less
For $i = 0 To UBound ($aArray) - 1
ConsoleWrite (aArray[$i] & @CRLF
Next

Arrays can also be multidimensional, when you use multiple series of index numbers. Think of rows and columns in a grid:

$aArray[0][0] = "Upper-Left"
$aArray[1][0] = "Lower-Left"
$aArray[0][1] = "Upper-Right"
$aArray[1][1] = "Lower-Right"

(These values are just examples)

You can use up to 64 dimensions in an Array. The total number of entries cannot be greater than 2^24 (16 777 216).

Arrays must be declared before use by defining their scope using the 'Global/Local/Static' keywords and either specifying the size and/or assigning some of the elements.

Local $aArray1[2] ; Array with 2 elements, none assigned
Local $aArray[] = [8, 4, 5, 9, 1] ; Array with 5 elements, all assigned
Local $aArray[7] = [3, 7.5, "string"] ; Array with 7 elements, only first 3 assigned

Data types in Arrays

An array element can contain any AutoIt datatype:

$aArray[0] = 1
$aArray[1] = True
$aArray[2] = "Text"
$aArray[3] = $aAnotherArray

An array stored inside another array can be accessed directly, but this method is slightly slower than accessing other datatypes:

Local $aInternal[3] = ["A", "B", "C"] ; Declare an array
Local $aContainer[1] = [$aInternal] ; Declare a container array holding the first
$sString = ($aContainer[0])[1] ; $sString holds "B"
; Note the requirement to enclose the first array element definition in ( )

Maps

A Map is a variable containing a series of data elements, each consisting of a key/value pairing. An element can only be accessed by a key, which can be either a string or an integer. However an integer key does not relate to the position of the element within the Map - these are in no defined order and cannot be sorted. String keys are, almost uniquely in AutoIt, case sensitive - "MyKey" is not the same as "mykey".

An example:

You want to store a number of variables in a collection so that you can pass them to a function as a single parameter. Using a Map allows you to use string keys to make an easily understood reference to the value contained within - such as the ControlIDs of a series of controls being indexed by their names. Note that elements can be addressed by either [] or dot notation:

Local $mControls[]
$mControls["Input"] = GUICtrlCreateInput (....)
$mControls.Combo = GUICtrlCreateCombo (...)
$mControls["Button"] = GUICtrlCreateButton (...)

To access a specific value in a Map, you use the key - again either notation can be used and need not be that used initially:

$idControlID = $mMap.Input ; Variable contains the ControlID for the Input
$idControlID = $mMap["Combo"] ; Variable contains the ControlID for the Combo

Integer keys must use the [] notation and are not the same as their string equivalent:

$mMap[3] = "Integer 3" ; These are separate keys
$mMap["3"] = "String 3"

Maps must be declared before use by defining their scope using the 'Global/Local/Static' keywords.

Local $mControls[]

Datatypes in Maps

A map element can contain any AutoIt datatype:

$mMap["Integer"] = 1
$mMap.Boolean = True
$mMap["String"] = "Text"
$mMap.Array = $aArray
$mMap["Map"] = $mAnotherMap

An internal map can be accessed directly:

Local $mInternal[] ; Declare a Map
$mInternal["Internal"] = "AutoIt3" ; Assign an element
Local $mContainer[] ; Declare a container Map
$mContainer.Bin = $mInternal ; Assign the first Map as an element
; All of these return "AutoIt3"
$sString = $mContainer["Bin"]["Internal"]
$sString = $mContainer.Bin.Internal
$sString = $mContainer["Bin"].Internal
$sString = $mContainer.Bin["Internal"]


Language Reference - Macros

AutoIt has an number of Macros that are special read-only variables used by AutoIt. Macros start with the @ character instead of the usual $ so are easy to tell apart. As with normal variables you can use macros in expressions but you cannot assign a value to them.

The pre-defined macros are generally used to provide easy access to system information like the location of the Windows directory or the name of the logged on user.

Go here for a complete list.


Language Reference - Operators

AutoIt has the following assignment, mathematical, comparison, and logical operators.

Operator | Description
 | Assignment operators
= | Assignment. e.g. $vVar = 5 (assigns the number 5 to $vVar)
+= | Addition assignment. e.g. $vVar += 1 (adds 1 to $vVar)
-= | Subtraction assignment.
*= | Multiplication assignment.
/= | Division assignment.
 | Concatenation operators
& | Concatenates/joins two strings. e.g. "one" & 10 (equals "one10")
&= | Concatenation assignment. e.g. $vVar = "one", and then $vVar &= 10 ($vVar now equals "one10")
 | Mathematical operators
+ | Adds two numbers. e.g. 10 + 20 (equals 30)
- | Subtracts two numbers. e.g. 20 - 10 (equals 10) Also acts as a unary minus (sets the negative value of a variable)
* | Multiplies two numbers. e.g. 20 * 10 (equals 200)
/ | Divides two numbers. e.g. 20 / 10 (equals 2)
^ | Raises a number to the power. e.g. 2 ^ 4 (equals 16)
 | Comparison operators (case insensitive if used with strings except for ==)
= | Tests if two values are equal. e.g. If $var = 5 Then (true if $vVar equals 5). Case insensitive when used with strings. See Note below about comparing mixed datatypes.
== | Tests if two strings are equal. Case sensitive. The left and right values are converted to strings if they are not strings already. This operator should only be used if string comparisons need to be case sensitive.
<> | Tests if two values are not equal. Case insensitive when used with strings. To do a case sensitive not equal comparison use Not ("string1" == "string2")
> | Tests if the first value is greater than the second. Strings are compared lexicographically even if the contents of the string happen to be numeric.
>= | Tests if the first value is greater than or equal to the second. Strings are compared lexicographically even if the contents of the string happen to be numeric.
< | Tests if the first value is less than the second. Strings are compared lexicographically even if the contents of the string happen to be numeric.
<= | Tests if the first value is less than or equal to the second. Strings are compared lexicographically even if the contents of the string happen to be numeric.
 | Logical operators
And | Logical And operation. e.g. If $vVar = 5 And $vVar2 > 6 Then (True if $vVar equals 5 and $vVar2 is greater than 6)
Or | Logical Or operation. e.g. If $vVar = 5 Or $vVar2 > 6 Then (True if $vVar equals 5 or $vVar2 is greater than 6)
Not | Logical Not operation. e.g. Not 1 (False)
 | Conditional operator
? : | Select conditionally an expression. e.g. $condition ? $expression1 : $expression2 ($expression1 if $condition is True or $expression2 if False) See the Ternary operator for an example.

When more than one operator is used in an expression the order in which things happen is controlled by operator precedence. The precedence used in AutoIt is given below. Where two operators have the same precedence the expression is evaluated left to right.

From highest precedence to lowest:

Not
^
* /
+ -
&
< > <= >= = <> ==
And Or

e.g. 2 + 4 * 10 is evaluated as 42:

4 * 10 (equals 40)

2 + 40 (equals 42)

As the * has a higher precedence than + it occurs before the addition.

You can use brackets to force a part of the expression to be evaluated first.

e.g. (2 + 4) * 10 equals 60.

Note the following when using the logical operators And, Or:

e.g. If MyFunc1() Or MyFunc2() Then (MyFunc2() is not called if MyFunc1() returns true)

e.g. If MyFunc1() And MyFunc2() Then (MyFunc2() is not called if MyFunc1() returns false)

Note: Care is needed if comparing mixed datatypes, as unless the == case-sensitive string operator is used, mixed comparisons are usually made numerically. Most strings will be evaluated as 0 and so the result may well not be the one expected. It is recommended to force the items being compared into the same datatype using Number/String before the comparison.


Language Reference - Conditional Statements

You will often want to change the flow of your script based on a condition or series of conditions. Is one number bigger than another? Or, does a string contain a certain value?

Conditions are evaluated as True (non-zero) or False (zero). Conditions generally use comparison operators like ==, <>, >=.

The following conditional statements are available in AutoIt:

  • If...Then...Else
  • Select...Case
  • Switch...Case
  • Ternary

All three statements are similar and decide which code to execute depending on the condition(s) given. Here is an example of an If statement that pops up a message box depending on the value of a variable.

#include <Constants.au3>

Local $iNumber = - 20

If $iNumber > 0 Then
MsgBox ($MB_SYSTEMMODAL, "Example", "$iNumber was positive!")
ElseIf $iNumber < 0 Then
MsgBox ($MB_SYSTEMMODAL, "Example", "$iNumber was negative!")
Else
MsgBox ($MB_SYSTEMMODAL, "Example", "$iNumber was zero.")
EndIf

A Select statement is very similar, but is generally used for situations where you want to test a large number of conditions as it is generally easier to read than a large If/ElseIf type block. e.g.

#include <Constants.au3>

Local $iNumber = 30

Select
Case $iNumber > 1 And $iNumber <= 10
MsgBox ($MB_SYSTEMMODAL, "Example", "$iNumber was greater than 1")

Case $iNumber > 10 And $iNumber <= 20
MsgBox ($MB_SYSTEMMODAL, "Example", "$iNumber was greater than 10")

Case $iNumber > 20 And $iNumber <= 30
MsgBox ($MB_SYSTEMMODAL, "Example", "$iNumber was greater than 20")

Case $iNumber > 30 And $iNumber <= 40
MsgBox ($MB_SYSTEMMODAL, "Example", "$iNumber was greater than 30")

Case $iNumber > 40
MsgBox ($MB_SYSTEMMODAL, "Example", "$iNumber was greater than 40")
EndSelect

A Switch statement is very similar to Select statement, but is generally used for situations where the same expression is tested against some different possible values.

#include <Constants.au3>

Local $iNumber = 30

Switch Int ($iNumber)
Case 1 To 10
MsgBox ($MB_SYSTEMMODAL, "Example", "$iNumber was greater than 1")

Case 11 To 20
MsgBox ($MB_SYSTEMMODAL, "Example", "$iNumber was greater than 10")

Case 21 To 30
MsgBox ($MB_SYSTEMMODAL, "Example", "$iNumber was greater than 20")

Case 31 To 40
MsgBox ($MB_SYSTEMMODAL, "Example", "$iNumber was greater than 30")

Case Else
MsgBox ($MB_SYSTEMMODAL, "Example", "$iNumber was greater than 40 or less or equal to 0")

EndSwitch

With each of these structures, the first condition that is true controls which group of statements get executed. All subsequent conditions and their associated statements get ignored.

A Ternary statement can be used when there is a simple binary choice to be made it avoids the overhead of the structures associated with the other conditional statements.

#include <Constants.au3>

MsgBox ($MB_SYSTEMMODAL, "Result: 1=1", (1 = 1) ? "True!" : "False!")
MsgBox ($MB_SYSTEMMODAL, "Result: 1=2", (1 = 2) ? "True!" : "False!")


Language Reference - Loops Statements

Language Reference - Loop Statements

A loop is how you refer to a section of script that you repeat a number of times. You might want to loop a given number of times or you might wish to repeat a section of script as long as a certain condition is true or false.

The following loop statements are available in AutoIt:

  • For...Next
  • While...WEnd
  • Do...Until
  • For...In...Next

While all the statements perform similar functions, they are slightly different and one will usually be more appropriate than another for a given situation.

A loop with little or no interior code will use CPU cycles very rapidly and in the worst case could cause overheating. A Sleep(10) line within the loop is sufficient to prevent this - note that this is not required if the code within the loop contains a blocking function (e.g. MsgBox) or GUIGetMsg.


Language Reference - Obj Statements

An obj is how you refer to an object. You might want to enumerate elements in an Object collection

The following obj statements are available in AutoIt:

  • With...EndWith
  • For...In...Next


Language Reference - User Functions

A function is a section of code that can be called from the script to perform a certain "function". There are two sorts of functions in AutoIt, built-in functions and user functions.

Note that all function names are case insensitive: msgbox() is read as MsgBox() and MyFunc() is the same as MyfunC()

Built-in Functions

The full list of built-in functions is here and the notes on using them are here.

User Functions

User functions are declared using the Func...EndFunc statements.

Functions can accept parameters and return values as required.

Function names must start with either a letter or an underscore, and the remainder of the name can contain any combination of letters and numbers and underscores. Some valid function names are:

MyFunc

Func1

_My_Func1

Here is an example of using a function to double a number 10 times:

#include <Constants.au3>

Local $iNumber = 10
Local $iDoubled = 0

For $i = 1 To 10
$iDoubled = MyDouble($iNumber)
MsgBox ($MB_OK, "", $iNumber & " doubled is " & $iDoubled)
$iNumber = $iDoubled
Next
Exit

Func MyDouble($iValue)
$iValue = $iValue * 2
Return $iValue
EndFunc ;==>MyDouble


Language Reference - Comments

Although only one statement per line is allowed, a long statement can span multiple lines if an underscore " _" preceded by a blank is placed at the end of a "broken" line. String definition cannot be split in several lines, concatenation need to be used.

#include <Constants.au3>

MsgBox ($MB_SYSTEMMODAL, "", "This is a rather long line, so I " & _
"broke it with the underscore, _, character.")

The semicolon (;) is the comment character. Unless the semicolon is within a string, all text following it is ignored by the script interpreter/compiler.

; The next line contains a meaningful, end-of-line comment
Sleep (5000) ; Pause for 5 seconds

You can combine underscore and semicolon to put comments on lines and still have a long statement span on next line.

Local $aArray_1_ ; This _ is not a continuation character, nor is the next one
Local $aArray_2_
Local $aArray_3[8][2] = [ _
["Word", 4], _ ; Comment 1
["Test", 3], _
["pi", 3.14159], _ ; Associate the name with the value
["e", 2.718281828465], _ ; Same here
["test;1;2;3", 123], _
[';', Asc (';')], _ ; This comment is removed, but the strings remain.
["", 0]]

It is also possible to comment of large blocks of script by using the #cs and #ce directives.


Language Reference - Directives

Pre-processor directives are a means of telling a script (or compiler) to behave in a special way. They begin with a hash (#) and are placed at the top of a script.

Below is a list of alphabetized pre-processor directives supported in AutoIt.

Directive | Description
#comments... | Specify that an entire section of script should be commented out
#include | Includes a file in the current script.
#include-once | Specifies that the current file may only be included once.
#NoTrayIcon | Indicates that the AutoIt tray icon will not be shown when the script starts.
#OnAutoItStartRegister | Registers a function to be called when AutoIt starts.
#pragma compile | Changes how the script is compiled.
#RequireAdmin | Specifies that the current script requires full administrator rights to run.


GUI Reference

  • GUI Concepts
  • GUI MessageLoop Mode
  • GUI OnEvent Mode
  • GUI Constants include files


GUI Reference

AutoIt has the ability to create simple Graphical User Interfaces (GUIs) that consist of windows and controls.

GUI Concepts

A GUI consists of one or more windows and each window contains one or more controls. GUIs are "event driven" which means you react to events - like a button that is clicked. You spend most of your time idling and waiting for an event to happen - this is a little different to a normal script where you are in control of what happens and when! Think of it as waiting by the door for the postman - you sit there until a letter pops through the postbox and then you look at the letters and decide what to do with them - this is exactly how GUIs work - you wait for the postman to come to you.

Of course, you may choose to do other tasks while the GUI is active - for example you might use the GUI functions to create an elaborate progress box that you update while your script performs complex actions.

GUI Controls

All users will be familiar with controls - anything you click on or interact with in a window is a type of control. The types of controls that can be created with AutoIt are listed below - you will have used most of them in other Windows programs.

  • Label
 A plain piece of text.
  • Button
 A simple button.
  • Input
 A single line control that you can enter text into.
  • Edit
 A multi-line control that you can enter text into.
  • Checkbox
 A box that can be "checked" or "unchecked".
  • Radio
 A set of circular buttons - only one can be active at once.
  • Combo
 A list with a dropdown box.
  • List
 A list.
  • Date
 A date picker.
  • Pic
 A picture.
  • Icon
 An icon.
  • Progress
 A progress bar.
  • Tab
 A group of controls that are contained in tabs.
  • UpDown
 A control that can be added to input controls.
  • Avi
 Display an AVI format clip.
  • Menu
 A menu across the top of the window.
  • ContextMenu
 A menu that appears when you right click inside the window.
  • TreeView
 A control similar to the windows file-explorer.
  • Slider
 A control similar to the windows sound volume control.
  • ListView
 A control displaying columns information.
  • ListViewItem
 A control displaying item in a listview control.
  • Graphic
 A control displaying graphics drawn with GUICtrlSetGraphic.
  • Dummy
 A dummy user control.

Here is an example of a single window GUI that contains many of the controls available. As you can see it is possible to create very detailed GUIs!

Controls are created with the GUICtrlCreate... set of functions. When a control is created a Control ID is returned. The most important things to note about a control ID is that:

  • The control ID is a positive number (that is, a number greater than 0)
  • Each control ID is unique - even when there are multiple windows
  • The control ID is actually the same value as the Control ID that the AutoIt Window Info Tool shows.

GUI Basic Functions

These are the main functions that you will need to create a GUI. They are just the basics though, there are many more when you are ready to create some really advanced GUIs.

Function | Explanation
GUICreate | Create a window.
GUICtrlCreate... | Create various controls in a window.
GUISetState | Display or hide the window.
GUIGetMsg | Poll the GUI to see if an event has happened (MessageLoop mode only)
GUICtrlRead | Read the data in a control.
GUICtrlSetData | Set/change the data in a control.
GUICtrlUpdate... | Change various options for a control (color, style, etc.)

You will need to #include <GUIConstantsEx.au3> for basic GUI related constants. There are other files containing constants related to the various controls you can create on the GUI.

First let's create a window, call it "Hello World" and make it 200 by 100 pixels in size. When a new window is created it is hidden - so we must "show" it.

#include <GUIConstantsEx.au3>

GUICreate ("Hello World", 200, 100)
GUISetState ( @SW_SHOW )
Sleep (2000)

If your run the above script you will see a window open and close after 2 seconds. Not very interesting...let's add some text and an OK button. The text will be added at position 30, 10 and the button at 70, 50 and the button will be 60 pixels wide.

#include <GUIConstantsEx.au3>

GUICreate ("Hello World", 200, 100)
GUICtrlCreateLabel ("Hello world! How are you?", 30, 10)
GUICtrlCreateButton ("OK", 70, 50, 60)
GUISetState ( @SW_SHOW )
Sleep (2000)

That's pretty good, but how do we make the GUI react to us clicking the button? Well, this is where we must make a decision as to how we will process events - via a MessageLoop or via OnEvent functions.

GUI Event Modes

As mentioned above there are two basic GUI modes: MessageLoop mode and OnEvent mode. The modes are simply two different ways of reacting to GUI events. The mode you choose will depend on personal preference, and to some extent the type of GUI you wish to create. Both modes are equally capable of creating any GUI you wish but sometimes one mode is more suited to a task than the other.

The default mode is the MessageLoop mode. To switch to OnEvent mode use Opt("GUIOnEventMode", 1).

Message-loop Mode (default)

In the Message-loop mode your script will spend the majority of its time in a tight loop. This loop will simply poll the GUI using the GUIGetMsg function. When an event has occurred the return value of the GUIGetMsg function will show the details (a button is clicked, the GUI has been closed, etc.).

In this mode you will only receive events while you are actively polling the GUIGetMsg function so you must ensure that you call it many times a second otherwise your GUI will be unresponsive.

This mode is best for GUIs where the GUI is "king" and all you care about is waiting for user events.

See this page for a more detailed explanation of the MessageLoop mode.

OnEvent Mode

In the OnEvent mode instead of constantly polling the GUI to find out if anything has happened you make the GUI temporarily pause your script and call a pre-defined function to handle the event. For example, if the user clicks Button1 the GUI halts your main script and calls a previously defined user function that deals with Button1. When the function call is completed the main script is resumed. This mode is similar to the Visual Basic forms method.

This mode is best for GUIs where the GUI is of secondary importance and your script has other tasks to perform in addition to looking after the GUI.

See this page for a more detailed explanation of the OnEvent mode.


GUI Reference - MessageLoop Mode

In the MessageLoop mode your script will spend the majority of its time in a tight loop. This loop will simply poll the GUI using the GUIGetMsg function. When an event has occurred the return value of the GUIGetMsg function will show the details (a button is clicked, the GUI has been closed, etc.).

The MessageLoop mode is the default message mode for AutoIt GUIs - the other possible mode is the OnEvent mode.

In the MessageLoop mode you will only receive events while you are actively polling the GUIGetMsg function so you must ensure that you call it many times a second otherwise your GUI will be unresponsive.

Basic MessageLoop Format

The general layout of MessageLoop code is:

While 1
$iMsg = GUIGetMsg ()
...
...
WEnd

Usually a tight loop like the one shown would send the CPU to 100% - fortunately the GUIGetMsg function automatically idles the CPU when there are no events waiting. Do not put a manual sleep in the loop for fear of stressing the CPU - this will only cause the GUI to become unresponsive.

GUI Events

There are three types of event messages that GUIGetMsg will return:

  • No Event
  • Control Event
  • System Event

No Event

When there are no events waiting to be processed GUIGetMsg returns 0. In a usual GUI this is the most common event.

Control Event

When a control is clicked or changes a control event is sent - this event is a positive number that corresponds to the controlID that was returned when the control was created with GUICtrlCreate....

System Event

System events - such as the GUI closing - are negative numbers. The different events are shown below and are defined in GUIConstantsEx.au3:

$GUI_EVENT_CLOSE
$GUI_EVENT_MINIMIZE
$GUI_EVENT_RESTORE
$GUI_EVENT_MAXIMIZE
$GUI_EVENT_PRIMARYDOWN
$GUI_EVENT_PRIMARYUP
$GUI_EVENT_SECONDARYDOWN
$GUI_EVENT_SECONDARYUP
$GUI_EVENT_MOUSEMOVE
$GUI_EVENT_RESIZED
$GUI_EVENT_DROPPED

Example GUI

In the main GUI Reference page we started a simple Hello World example that looked like this:

#include <GUIConstantsEx.au3>

GUICreate ("Hello World", 200, 100)
GUICtrlCreateLabel ("Hello world! How are you?", 30, 10)
GUICtrlCreateButton ("OK", 70, 50, 60)
GUISetState ( @SW_SHOW )
Sleep (2000)

Now we will finish the code using a MessageLoop and some of the event messages described above. It is usual because of the number of possible messages to use a Switch statement for readability.

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

Local $hGUI = GUICreate ("Hello World", 200, 100)
GUICtrlCreateLabel ("Hello world! How are you?", 30, 10)
Local $iOKButton = GUICtrlCreateButton ("OK", 70, 50, 60)
GUISetState ( @SW_SHOW , $hGUI)

Local $iMsg = 0
While 1
$iMsg = GUIGetMsg ()
Switch $iMsg
Case $iOKButton
MsgBox ($MB_SYSTEMMODAL, "GUI Event", "You selected the OK button.")

Case $GUI_EVENT_CLOSE
MsgBox ($MB_SYSTEMMODAL, "GUI Event", "You selected the Close button. Exiting...")
ExitLoop
EndSwitch
WEnd

GUIDelete ($hGUI)

It's that simple. Obviously the more windows and controls you create the more complicated it gets but the above shows you the basics.

Advanced GUIGetMsg and Multiple Windows

Control IDs are unique, even when you have multiple windows, so the above code with work fine with controls and multiple windows. However, when processing events such as $GUI_EVENT_CLOSE or $GUI_MOUSEMOVE you need to know which GUI window generated the event. To do this you must call GUIGetMsg like so:

$iMsg = GUIGetMsg (1)

When called with the 1 parameter instead of returning an event value an array will be returned, the array contains the event ( in $aArray[0] ) and extra information such as the window handle ( in $aArray[1] ). If two windows were created in the previous example then the correct way to write the code would be:

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

Local $hMainGUI = GUICreate ("Hello World", 200, 100)
GUICtrlCreateLabel ("Hello world! How are you?", 30, 10)
Local $iOKButton = GUICtrlCreateButton ("OK", 70, 50, 60)

Local $hDummyGUI = GUICreate ("Dummy window for testing", 200, 100)

GUISwitch ($hMainGUI)
GUISetState ( @SW_SHOW )

Local $aMsg = 0
While 1
$aMsg = GUIGetMsg (1)

Select
Case $aMsg[0] = $iOKButton
MsgBox ($MB_SYSTEMMODAL, "GUI Event", "You selected OK!")

Case $aMsg[0] = $GUI_EVENT_CLOSE And $aMsg[1] = $hMainGUI
MsgBox ($MB_SYSTEMMODAL, "GUI Event", "You selected CLOSE on the main GUI! Exiting...")
ExitLoop
EndSelect
WEnd

The first major change is the GUISwitch function call - when a new window is created it becomes the "default" window for future GUI operations (including control creation). In our case we want to work with the main "Hello World" window, not the test window, so we "switch". Some GUI functions allow you to use the window handle in the function call itself - these functions will do the switch automatically. In our example we could have done this with:

GUISetState ( @SW_SHOW , $hMainGUI)

The next change is the way GUIGetMsg is called and how the events are checked - notice the use of $msg[0] and $msg[1] - now we only exit the script if the close event is sent and the event is from our main window.


GUI Reference - OnEvent Mode

In the OnEvent mode instead of constantly polling the GUI to find out if anything has happened you make the GUI temporarily pause your script and call a pre-defined function to handle the event. For example, if the user clicks Button1 the GUI pauses your main script and calls a previously defined user function that deals with Button1. When the function call is completed the main script is resumed. This mode is similar to the Visual Basic forms method.

While the GUI is executing, your main script could be doing any normal scripting work, but for ease of examples we will just make the main script "idle" in an infinite While loop.

The default mode is the MessageLoop mode so before using the OnEvent mode we must use Opt("GUIOnEventMode", 1).

Basic OnEvent Format

The general layout of OnEvent code is:

While 1
Sleep (100) ; Sleep to reduce CPU usage
WEnd

Func Event1()
; Code to handle event goes here
EndFunc ;==>Event1

Func Event2()
; Code to handle event goes here
EndFunc ;==>Event2

GUI Events

In the OnEvent mode your GUI will generate the following "events":

  • Control Event
  • System Event

Both types of event will call a user defined function if one was set for the GUI (GUISetOnEvent) or for a control (GUICtrlSetOnEvent). If no functions are defined for an event then it is simply ignored. When inside this called function various macros will be set to values to help process the event.

Macro | Details
@GUI_CtrlId | The control ID of the control sending the message OR the system event ID
@GUI_WinHandle | The handle of the GUI that sent the message
@GUI_CtrlHandle | The handle of the Control that sent the message (if applicable)

Note: It is perfectly legal to use the same function for multiple events, all that you need to do in these cases is to take action based on the @GUI_CtrlId macro. For example, you could register all system events to the same function.

Control Event

When a control is clicked or changes a control event is sent. The event is sent to the function defined with GUICtrlSetOnEvent. Inside the user defined function @GUI_CtrlId is set to the controlID that was returned when the control was created with GUICtrlCreate....

System Event

System events - such as the GUI closing - are sent in a similar way to Control event, but the event type is defined by @GUI_CtrlId. The event is sent to the function defined with GUISetOnEvent. The possible system event values are shown here:

$GUI_EVENT_CLOSE
$GUI_EVENT_MINIMIZE
$GUI_EVENT_RESTORE
$GUI_EVENT_MAXIMIZE
$GUI_EVENT_PRIMARYDOWN
$GUI_EVENT_PRIMARYUP
$GUI_EVENT_SECONDARYDOWN
$GUI_EVENT_SECONDARYUP
$GUI_EVENT_MOUSEMOVE
$GUI_EVENT_RESIZED
$GUI_EVENT_DROPPED

Example GUI

In the main GUI Reference page we started a simple Hello World example that looked like this:

#include <GUIConstantsEx.au3>

GUICreate ("Hello World", 200, 100)
GUICtrlCreateLabel ("Hello world! How are you?", 30, 10)
GUICtrlCreateButton ("OK", 70, 50, 60)
GUISetState ( @SW_SHOW )
Sleep (2000)

Now we will finish the code using OnEvents and some of the event messages described above.

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Opt ("GUIOnEventMode", 1) ; Change to OnEvent mode

Local $hMainGUI = GUICreate ("Hello World", 200, 100)
GUISetOnEvent ($GUI_EVENT_CLOSE, "CLOSEButton")
GUICtrlCreateLabel ("Hello world! How are you?", 30, 10)
Local $iOKButton = GUICtrlCreateButton ("OK", 70, 50, 60)
GUICtrlSetOnEvent ($iOKButton, "OKButton")
GUISetState ( @SW_SHOW , $hMainGUI)

While 1
Sleep (100) ; Sleep to reduce CPU usage
WEnd

Func OKButton()
; Note: At this point @GUI_CtrlId would equal $iOKButton,
; and @GUI_WinHandle would equal $hMainGUI
MsgBox ($MB_OK, "GUI Event", "You selected OK!")
EndFunc ;==>OKButton

Func CLOSEButton()
; Note: At this point @GUI_CtrlId would equal $GUI_EVENT_CLOSE,
; and @GUI_WinHandle would equal $hMainGUI
MsgBox ($MB_OK, "GUI Event", "You selected CLOSE! Exiting...")
Exit
EndFunc ;==>CLOSEButton

It's that simple. Obviously the more windows and controls you create the more complicated it gets but the above shows you the basics.

Advanced Operations and Multiple Windows

Control IDs are unique, even when you have multiple windows but how do we handle multiple windows?

Here is an example similar to the one above but with another "dummy" window.

#include <GUIConstantsEx.au3>

Opt ("GUIOnEventMode", 1) ; Change to OnEvent mode

Global $hMainGUI = GUICreate ("Hello World", 200, 100)
GUISetOnEvent ($GUI_EVENT_CLOSE, "CLOSEButton")
GUICtrlCreateLabel ("Hello world! How are you?", 30, 10)
Local $iOKButton = GUICtrlCreateButton ("OK", 70, 50, 60)
GUICtrlSetOnEvent ($iOKButton, "OKButton")

Global $hDummyGUI = GUICreate ("Dummy GUI for testing", 200, 100)
GUISetOnEvent ($GUI_EVENT_CLOSE, "CLOSEButton")

GUISwitch ($hMainGUI)
GUISetState ( @SW_SHOW )

While 1
Sleep (100) ; Sleep to reduce CPU usage
WEnd

Func OKButton()
; Note: At this point @GUI_CtrlId would equal $iOKButton
MsgBox ($MB_OK, "GUI Event", "You selected OK!")
EndFunc ;==>OKButton

Func CLOSEButton()
; Note: at this point @GUI_CtrlId would equal $GUI_EVENT_CLOSE,
; @GUI_WinHandle will be either $hMainGUI or $hDummyGUI
If @GUI_WinHandle = $hMainGUI Then
MsgBox ($MB_OK, "GUI Event", "You selected CLOSE in the main window! Exiting...")
Exit
EndIf
EndFunc ;==>CLOSEButton

The first major change is the GUISwitch function call - when a new window is created it becomes the "default" window for future GUI operations (including control creation). In our case we want to work with the main "Hello World" window, not the test window, so we "switch". Some GUI functions allow you to use the window handle in the function call itself - these functions will do the switch automatically. In our example we could have done this with:

GUISetState ( @SW_SHOW , $hMainGUI)

Also notice that we used the same OnEvent function to handle the "close" button for both windows and then used @GUI_WinHandle to determine which window sent the message - then we only closed the GUI when the close button was clicked and the message came from the main window. You can just as easily use separate functions for each window if you wish.


GUI Constants include files

Below is a complete list of the GUI Constants include files available in AutoIt.

Using #include <GUIConstantsEx.au3> just includes basic constants for GUI...() functions.

File | Related Control(s)
#include <AVIConstants.au3> | AVI
#include <ButtonConstants.au3> | Button, Group, Radio, Checkbox
#include <ComboConstants.au3> | Combo
#include <DateTimeConstants.au3> | Date, MonthCal
#include <EditConstants.au3> | Edit, Input
#include <GUIConstantsEx.au3> | GUI Create, events
#include <ListboxConstants.au3> | List
#include <ListViewConstants.au3> | ListView
#include <ProgressConstants.au3> | Progress
#include <RichEditConstants.au3> | Edit, Input
#include <SliderConstants.au3> | Slider
#include <StaticConstants.au3> | Label, Pic, Icon
#include <TabConstants.au3> | Tab
#include <TreeViewConstants.au3> | TreeView
#include <UpdownConstants.au3> | Updown
#include <WindowsConstants.au3> | Gui extended style


COM Reference

COM Extensions to AutoIt

A short introduction

What is COM?

COM stands for "Component Object Model". It is the Microsoft way to interconnect software using a common interface. These interfaces are defined in a COM Object.

Before COM, you had to know the exact implementation of a program before you could 'interface' with it. Using COM, you can now "talk" to its defined Object(s). The only things you have to know are the names of the Objects that are used and which 'properties' or 'methods' they have.

What are (Object) properties or methods?

These are the two basic characteristics of an Object. You can see a 'property' as the data storage of an Object. A 'method' can be seen as an internal function call to do something with the data.

Do I need COM in my AutoIt script?

It just depends. AutoIt has a lot of built-in functions and a huge library of UDF's. You can do most of your programming with these. However if you need special 'interfacing' to other applications, using COM might save you some lines of script. Scripters have to be aware that the existence of COM Objects depend HEAVILY on the Operating System AND the installed software. The examples below have all been tested under a 'plain' Windows XP professional version with Microsoft Office 2000.

An example usage of COM in AutoIt

Let's say you want to minimize all open windows. You could do this using regular AutoIt functions like WinList and WinSetState. However, two lines of COM-code can give you the same result:

Local $oShell = ObjCreate ("shell.application")

$oShell.MinimizeAll

Side note: The example is no longer the shortest way to minimize all windows after the introduction of the WinMinimizeAll() function in AutoIt.

On the first line we create a new object called "shell.application". This is an internal Windows object, defined in shell32.dll. The pointer to this new object is assigned to the variable $oShell. $oShell is from now on an Object variable.

On the second line, we use a Method called "MinimizeAll" to the oShell object. This will minimize all windows.

All Windows versions have a huge amount of internal Objects for various purposes. And applications like Excel or Word have also their own set of Objects.

However, it is sometimes difficult to get a list of all existing Objects defined on your system with their corresponding properties and methods. Searching at Microsoft.com or Google.com might give you some clues about the Object 'X' you want to use.

For instance, you can find information about the "shell.application" object at:
http://msdn.microsoft.com/en-us/library/bb774094.aspx

To get a peek on all objects currently installed on your system, the "OLE/COM Object Viewer" is a very helpful tool. This tool will be explained in a separate section below.

Let's do another example. We would like to get a HTML source code from a certain web page. You could use the internal InetGet() function to save the result to a file and retrieve it back again with FileRead(). But these lines of code do the same:

Local $oHTTP = ObjCreate ("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET", "http://www.AutoItScript.com")
$oHTTP.Send()
$HTMLSource = $oHTTP.Responsetext

The (string) variable $HTMLSource now contains the complete HTML code of the AutoItScript.com home page (that is, the top HTML-Frame).

(Information about the "winhttp.winhttprequest" object can be found at:
http://msdn.microsoft.com/en-us/library/aa384106.aspx )

Please mind this: The existence of Objects depend on the computer's operating system and installed programs. For example, the winhttp.winhttprequest.5.1 object only exists on computers that have at least Internet Explorer version 5 installed. When you are sharing scripts that use COM objects, be sure the objects exist on all computers.

Object variables behave a bit different than other types of AutoIt variables. An Object is not a real value, but a 'pointer' to something outside the script. So you can't perform arithmetic's, nor equations on Object variables. When you assign an Object variable a different value, the 'pointer' will automatically be released. You can, for instance, force deletion of an Object by assigning it any number or any text value.

Local $oHTTP = ObjCreate ("winhttp.winhttprequest.5.1") ; Object is created
$oHTTP = 0 ; Object is deleted

You don't need to delete Objects when you are finished. If a script exits, AutoIt tries to release all active references to Objects that had been created in the script. Same thing happens when you had defined a local Object variable inside a function, and the function ends with a return.

Automation using COM

A very popular application of COM is to 'automate' programs. Instead of using the regular AutoIt functions like Send() or WinActivate(), you can make use of the Objects that are defined inside the program.

Here is an example that 'automates' Microsoft Excel:

Local $oExcel = ObjCreate ("Excel.Application") ; Create an Excel Object
$oExcel.Visible = 1 ; Let Excel show itself
$oExcel.WorkBooks.Add ; Add a new workbook
$oExcel.ActiveWorkBook.ActiveSheet.Cells(1, 1).Value = "Text" ; Fill a cell
Sleep (4000) ; Display the results for 4 seconds
$oExcel.ActiveWorkBook.Saved = 1 ; Simulate a save of the Workbook
$oExcel.Quit ; Quit Excel

The complexity of controlling other programs depends on that specific program, not on the AutoIt script. If something does not work as expected you might need to consult the applications' documentation and not the AutoIt help.

Special Statements

In AutoIt, two special statements are designed for COM usage:

With/EndWith and the For/In/Next loop.

With..EndWith

The With/EndWith statement does not add functionality, but it makes your script easier to read. For instance, the previous example using Excel can also be written as:

Local $oExcel = ObjCreate ("Excel.Application") ; Create an Excel Object

With $oExcel
.Visible = 1 ; Let Excel show itself
.WorkBooks.Add ; Add a new workbook
.ActiveWorkBook.ActiveSheet.Cells(1, 1).Value = "Text" ; Fill a cell
Sleep (4000) ; Display the results for 4 seconds
.ActiveWorkBook.Saved = 1 ; Simulate a save of the Workbook
.Quit ; Quit Excel
EndWith

This example does not save you a lot of text, but when your object uses long lines of properties/methods, you can shorten it heavily within a With statement.

For..In

The FOR...IN loop is required when using Collections. Collections are a special type of Object, that exist out of multiple sub-Objects. You could see them as Arrays (Actually, the For..In statement also works on Array-type variables).

For..In loop using an Array

Below is an example of an For..In loop. This example uses a normal AutoIt array, so it has nothing to do with COM. It's just to show you the principle:

#include <MsgBoxConstants.au3>

Local $sString = "" ; A string for displaying purposes

Local $aArray[4]
$aArray[0] = "A" ; We fill an array
$aArray[1] = 0 ; with several
$aArray[2] = 1.3434 ; different
$aArray[3] = "Example Text" ; example values.

For $iElement In $aArray ; Here it starts...
$sString &= $iElement & @CRLF
Next

; Display the results
MsgBox ($MB_OK, "For..In Array Example", "Result: " & @CRLF & $sString)

For..In loop using an Object

In most cases you can't use 'normal' Object methods to retrieve the elements of a collection. In 'COM'-terms they say you have to 'enumerate' them. This is where the For..In loop comes in.

The Excel example below loops on cells A1:O16 on the current active sheet. If one of the cells has a value less than 5, the code replaces the value with 0 (zero):

Local $oExcel = ObjCreate ("Excel.Application") ; Create an Excel Object

$oExcel.Visible = 1 ; Let Excel show itself
$oExcel.WorkBooks.Add ; Add a new workbook

Local $aArray[16][16] ; These lines
For $i = 0 To 15 ; are just
For $j = 0 To 15 ; an example to
$aArray[$i][$j] = $i ; create some
Next ; cell contents.
Next

$oExcel.activesheet.range("A1:O16").value = $aArray ; Fill cells with example numbers

Sleep (2000) ; Wait a while before continuing

For $iCell In $oExcel.ActiveSheet.Range("A1:O16")
If $iCell.Value < 5 Then
$iCell.Value = 0
EndIf
Next

$oExcel.ActiveWorkBook.Saved = 1 ; Simulate a save of the Workbook
Sleep (2000) ; Wait a while before closing
$oExcel.Quit ; Quit Excel

Advanced COM usage

The following features of AutoItCOM requires profound knowledge of COM Events and COM Error handling.

If you are a newbie to COM programming, please read some good COM documentation first.

The bible of COM is the book called "Inside OLE 2" by Kraig Brockschmidt (Microsoft Press).

You can also find some COM resources on the internet (not AutoIt related):

http://msdn.microsoft.com/en-us/library/ms694363.aspx (introduction)

http://www.garybeene.com/vb/tut-obj.htm (about Objects in Visual Basic)

http://java.sun.com/docs/books/tutorial/java/concepts/ (Using objects in Java)

http://msdn.microsoft.com/en-us/library/windows/desktop/ms686915.aspx (Object Events in C++)

http://www.garybeene.com/vb/tut-err.htm (Error handling in Visual Basic)

COM Events

Normal COM Automation mainly uses one-way communication. You 'ask' the Object for any properties or results from a Method. However a COM Object can also 'talk back' to your script when it suits it.

This could be very handy in case you need to wait for some COM-related action to happen.

Instead of writing a kind of loop, asking the Object if something interesting has happened, you can let the Object itself call a specific UDF in your script. Meanwhile you can do other things in your script (almost) simultaneously.

Not all Object to support events. You have to read the Object documentation carefully whether it supports events or not.

If it does, the second thing to know is the type of Events it supports. AutoItCOM can only receive 'dispatch' type events.

Finally you have to know the names of the Events the Object could generate, including their arguments (if any).

Only when you have all this information, you can start building an AutoIt script using COM Events.

Below is a snippet from a script that demonstrates how to receive Events from the Internet Explorer:

Local $oIE = ObjCreate ("InternetExplorer.Application.1") ; Create an Internet Explorer Object

Local $oEventObject = ObjEvent ($oIE, "IEEvent_", "DWebBrowserEvents") ; Start receiving Events.

$oIE.url = "http://www.autoitscript.com" ; Load an example web page
; From now on, the $oIE Object generates events during web page load.
; They are handled in the event functions shown below.

; Here you can let the script wait until the user wants to finish.
...(your code here)...

$oEventObject.stop ; Tell IE we want to stop receiving Events
$oEventObject = 0 ; Kill the Event Object
$oIE.quit ; Quit IE
$oIE = 0 ; Remove IE from memory (not really necessary)
Exit ; End of main script

; A few Internet Explorer Event Functions.
;
; For the full list of IE Event Functions, see the MSDN WebBrowser documentation at:
; http://msdn.microsoft.com/en-us/library/aa768400.aspx

Func IEEvent_StatusTextChange($sText)
; In the complete script (see link below) we show the contents in a GUI Edit box.
GUICtrlSetData ($GUIEdit, "IE Status text changed to: " & $sText & @CRLF , "append")
EndFunc ;==>IEEvent_StatusTextChange

Func IEEvent_BeforeNavigate($sURL, $iFlags, $sTargetFrameName, $dPostData, $sHeaders, $bCancel)
; In the complete script (see link below) we show the contents in a GUI Edit box.
; Note: the declaration is different from the one on MSDN.
GUICtrlSetData ($GUIEdit, "BeforeNavigate: " & $sURL & " Flags: " & $iFlags & @CRLF , "append")
EndFunc ;==>IEEvent_BeforeNavigate

Click here to view the complete script.

The main line in this script is: $EventObject = ObjEvent ($oIE, "IEEvent_", ...).
This function takes the object $oIE and reroutes it's events to AutoIt functions whose names start with IEEvent_. The third parameter is optional. It is used when an Object has multiple Event interfaces and you don't want AutoIt to choose one automatically.

The Object responsible for the continuous rerouting is $EventObject. This variable does not require any further attention, unless you want to stop the events.

To stop rerouting Events, you can not just delete the variable like $EventObject = "". The reason is that the 'calling' Object is still holding a reference to this variable, and it won't loose it until the Object itself quits. You could solve this problem by killing the 'calling' Object, but you can also tell the Object that you don't want to receive any events by using: $EventObject.Stop. Then you can (but not really necessary) kill the Event by assigning it any value, like: $EventObject = ""

If you know the names of the Events $oIE fires, you can implement the Events you are interested in by creating AutoIt UDF's with the name IEEvent_Eventname(optional arguments). Be sure you use the correct number of arguments and in their correct order as specified for THAT Event function. Otherwise you might end up with unexpected values.

You don't have to implement ALL event functions. Those not implemented will just be ignored.

More script examples using COM Event functions can be found via this URL.

Limitations on COM Events in AutoIt

Some Objects (like the 'WebBrowser') pass arguments to their Event Functions 'by reference'. This is intended to allow the user change these arguments and passing it back to the Object. However, AutoIt uses its own variable scheme, which is not compatible to COM variables. This means that all values from Objects need to be converted into AutoIt variables, thus losing the reference to the original memory space. Maybe in the near future we can solve this limitation for you !

COM Error Handling

Using COM without proper error handling can be very tricky. Especially when you are not familiar with the Objects in your script.

Only if there is no way to prevent a COM error, you could install an "Error Handler" in which you take action after the error has happened. It is not a solution to make a buggy script work properly. Neither does it catch non-COM related script errors (e.g. declaration and syntax errors).

Error handling is implemented in the same way as a normal COM Event, using ObjEvent() and a user defined COM Event Function. The only difference is the usage of the fixed string "AutoIt.Error" as the name of the object.

An example:

#include <MsgBoxConstants.au3>

Global $iEventError = 0 ; To be checked to know if COM error occurs. Must be reset after handling.

Local $oMyError = ObjEvent ("AutoIt.Error", "ErrFunc") ; Install a custom error handler

; Perform a deliberate failure (the object doesn't exist)
Local $oIE = ObjCreate ("InternetExplorer.Application")
$oIE.visible = 1
$oIE.bogus
If $iEventError Then
MsgBox ($MB_OK, "", "There was an error on the previous line.")
$iEventError = 0 ; Reset after displaying a COM Error occurred
EndIf
Exit

; This is a custom error handler
Func ErrFunc()
$sHexNumber = Hex ($oMyError.number, 8)
MsgBox ($MB_OK, "", "We intercepted a COM Error !" & @CRLF & _
"Number is: " & $sHexNumber & @CRLF & _
"WinDescription is: " & $oMyError.windescription)
$iEventError = 1 ; Use to check when a COM Error occurs
EndFunc ;==>ErrFunc

One thing is special about the Error Event Handler, and that is the Object it returns. This is an AutoIt Error Object that contains some useful properties and methods. It's implementation is partly based on the "Err" Object in VB(script):

Properties of the AutoIt Error Object:

.number | The Windows HRESULT value from a COM call
.windescription | The FormatWinError() text derived from .number
.source | Name of the Object generating the error (contents from ExcepInfo.source)
.description | Source Object's description of the error (contents from ExcepInfo.description)
.helpfile | Source Object's helpfile for the error (contents from ExcepInfo.helpfile)
.helpcontext | Source Object's helpfile context id number (contents from ExcepInfo.helpcontext)
.lastdllerror | The number returned from GetLastError()
.scriptline | The script line on which the error was generated

A note for UDF writers

You can have as many COM Error event handlers as you like. The last registered and alive object is the one that gets called.

However, you can never stop an existing Error Handler without releasing the variable it had been assigned to. That happens when that variable goes out of scope or gets reassigned.

OLE/COM Object Viewer

The "OLE/COM Object Viewer" is a very handy tool to get a peek on all COM objects currently installed on your system. It is part of the Windows Server 2003 resource kit (OK for Windows XP and above) and can be downloaded for free from: http://www.microsoft.com/en-us/download/details.aspx?id=17657

The setup of this program is a bit awkward. It will not create any start menu icon for you. Instead, a file called oleview.exe will be installed in the C:\Program Files\Resource Kit directory (default install).

When running oleview.exe, some systems will complain about a missing file called iviewers.dll. This file is required, but strangely enough not included in the latest setup. You can obtain this dll from an older version of oleview.exe at: http://download.microsoft.com/download/2/f/1/2f15a59b-6cd7-467b-8ff2-f162c3932235/ovi386.exe. It will install the files by default to the C:\MSTOOLS\BIN directory. You only need the file iviewer.dll. Copy it to the same directory where oleview.exe resides, then register the dll using the command line: regsvr32 iviewers.dll.

Let's do an example with the Oleviewer. Run it and follow this tree: Object Classes->Grouped by Component Category->Control->Microsoft Web Browser.

In the left-hand pane you see all the COM Interfaces that have been defined for this object. We talk about those later. Take a closer look at the right column. It contains a lot of information about this object that can be useful in an AutoIt script. Most important is the "VersionIndependentProgID". This is the name to be used in an ObjCreate(), ObjGet() or ObjEvent(). Furthermore it contains the directory and filename that contains the object. This can be an EXE, a DLL or an OCX file. InProcServer32 means that the object runs in the same thread as your script (in-process). When you see LocalServer32, the object runs as a separate process. The object must also contain a type library (the lines following "TypeLib="), otherwise it can't be used in an AutoIt script.

The interfaces in the left-hand pane provide various ways of interacting with the object. Some are used for storage (IStorage, IPersist), others for embedding in a GUI (IOleObject, IOleControl). AutoIt uses the IDispatch interface for automation. This interface 'exposes' all scriptable methods and properties that the object supports. If there is no IDispatch interface for an object, you can't use the object in an AutoIt script.

Let's take a look at this interface. Right-click on the name IDispatch and choose "View..." from the context menu. Then click the "View TypeInfo..." button. (Note: if this button is greyed out, you failed to register the iviewers.dll file -- see above., or the object does not have a type library)

The "ITypeInfo Viewer" window shows all the information that has been provided for the object; it may not be complete. If the developer decides not to include a help file, you will only see the names of the method/properties and nothing else. The "Microsoft Web Browser" type library is however quite extensive. Just click an item in the left-hand pane, and a description will be shown at the right. Sometimes you have to browse through "Inherited Interfaces" to retrieve more methods for the object.

The syntax of the described methods/properties are in C/C++ style. A property described as "HRESULT Resizable([in] VARIANT_BOOL pbOffline)", has to be rewritten in AutoIt like: $Resizable=$Object.Resizable ($Object holds the object created with ObjCreate or ObjGet).

COMmonly mixed up terms

These terms are commonly mixed up with COM, but have a different meanings:

OOP = Object Oriented Programming. A programming technique in which software components are put together from reusable building blocks known as Objects.

DDE = Dynamic Data Exchange.

You can say this is the predecessor of COM. It used IPC to transfer information and commands between different applications.

OLE =Object Linking and Embedding

In its first version, OLE was an extended version of DDE to 'embed' data from one program into another. The current generation of OLE is built on top of COM and is part of ActiveX.

Automation = This is a way of manipulating another application's objects. It is used in OLE, ActiveX and COM.

ActiveX = The next generation OLE with Automation, at first mainly developed to interface between applications over a network (especially web browsers). ActiveX is built on top of COM.

DCOM=Distributed COM. A slight modification to COM, making it able to communicate between different physical computers.

.NET (dot Net)= This is not really a piece of software, but an 'idea' from Microsoft to interconnect just about "everything" through (their) software. "dot Net" is used mainly for Web-based services.

COMmunist = This is not a supporter of COM, but someone who believes in communism (a theory that the common people should own all the property).


Keywords

Keyword Reference

Below is a complete list of the keywords available in AutoIt. Click on a keyword name for a detailed description.

Keyword | Description
False / True | Boolean values for use in logical expressions.
#comments-start | Specify that an entire section of script should be commented out.
ContinueCase | Abort the code in the current Case block and continue with the code in the next Case block when in a Select or Switch structure.
ContinueLoop | Continue a While/Do/For loop.
Default | Keyword value use in function call.
Dim / Global / Local / Const | Declare a variable, a constant, or create an array.
Do...Until | Loop based on an expression.
Enum | Enumerates constants.
Exit | Terminates the script.
ExitLoop | Terminate a While/Do/For loop.
For...To...Step...Next | Loop based on an expression.
For...In...Next | Enumerates elements in an Object collection or an Array.
Func...Return...EndFunc | Defines a user-defined function that takes zero or more arguments and optionally returns a result.
If...Then | Conditionally run a single statement.
If...ElseIf...Else...EndIf | Conditionally run statements.
#include-once | Specifies that the current file should only be included once.
#include | Includes a file in the current script.
#NoTrayIcon | Indicates that the AutoIt tray icon will not be shown when the script starts.
Null | Keyword value to use in function call.
#OnAutoItStartRegister | Registers a function to be called when AutoIt starts.
#pragma | A special directive for controlling aspects of how the script is compiled.
ReDim | Resize an existing array.
#RequireAdmin | Specifies that the current script requires full administrator rights to run.
Select...Case...EndSelect | Conditionally run statements.
Static | Declare a static variable or create a static array.
Switch...Case...EndSwitch | Conditionally run statements.
Volatile | Function qualifier.
While...WEnd | Loop based on an expression.
With...EndWith | Used to reduce long references to dot-accessible type of variables.


Keyword #comments-start

Keyword Reference

#comments-start

Specify that an entire section of script should be commented out.

#comments-start
...
...
#comments-end

Remarks

The #comments-start and #comments-end directives can be nested.
You can also use the abbreviated keywords #cs and #ce.
Additionally, the directives themselves can be commented out!

Example

#include <MsgBoxConstants.au3>

#comments-start
    MsgBox($MB_SYSTEMMODAL, "", "This won't display ")
    MsgBox($MB_SYSTEMMODAL, "", "nor will this.")
#comments-end

; #cs
MsgBox($MB_SYSTEMMODAL, "", "This will display if '#cs/#ce' are commented out.")
; #ce


Keyword #include

Keyword Reference

#include

Includes a file in the current script.

#include "[path\]filename"
#include <filename>

Parameters

filename The filename of the current script to include. Path is optional. This must be a string--it cannot be a variable.
If "..." is used, the filename is taken to be relative to the current script.
If <...> is used the filename is taken to be relative to include library directory (usually C:\Program Files\AutoIt3\Include). The include library contains many pre-written user-functions for you to use!

Remarks

Other scripts can be included into an Autoit script using the #include command - these can be in either .au3 or .a3x format. The content of the included file is inserted into the script at the point of the #include command - in most cases this is the beginning of the script so that any variable or constant declarations within the included text are available to the rest of the script.

If you include the same file containing a user defined function more than once you will get a "Duplicate function" error. When writing an include file that may be used in this way, make sure that the firstline contains #include-once to prevent that file from being included more than once.

There is a special registry value that can be created at "HKEY_CURRENT_USER\Software\AutoIt v3\AutoIt" called "Include". It should be a REG_SZ (string) value. The contents of this value are a semi-colon delimited list of directories that should be searched for files when resolving #include's in addition to the standard locations.

The search order used by AutoIt depends on which form of #include you use. The tables below show the order directories are searched using both forms.

Using #include <>

Standard library | The path of the currently running interpreter with "\Include" appended is searched.
User-defined libraries | The registry value mentioned above is read and each directory is searched in the order they appear in.
Script directory | The directory of the currently executing script.

Using #include "" (This is the reverse of #include <>).
Script directory | The directory of the currently executing script.
User-defined libraries | The registry value mentioned above is read and each directory is searched in the reverse order they appear in.
Standard library | The path of the currently running interpreter with "\Include" appended is searched.

A note about using the /AutoIt3ExecuteScript option. Since the standard library is searched for in the current interpreter's directory, the standard library functions will not be found; that library will only be found when run through AutoIt3.exe. It's recommended that you compile a script to the .a3x format before attempting to run it with /AutoIt3ExecuteScript.

Aut2Exe uses the same algorithm as AutoIt3.exe with the only difference being it looks for the Include sub-directory as being in a sibling directory to itself (..\Include).

If Opt("TrayIconDebug",1) only 64 include files name can be displayed in the traytooltip. for the other no filename will be displayed.

Related

#include-once

Example

#include "include-TIME.au3"

MsgBox($MB_SYSTEMMODAL, "", "Example")
#include <MsgBoxConstants.au3>
Exit

; Running script.au3 will output two message boxes:
; one with 'Example', followed by one with the time.


Keyword #include-once

Keyword Reference

#include-once

Specifies that the current file should only be included once.

#include-once

Remarks

It is quite common to have the same "#include <filename.au3>" line in several of the files included included in a script. If the same file were to be included several times, it is quite likely that this would generate a "Duplicate function" or "Cannot redeclare a Const" error. So when writing a script intended for use as an include file, add #include-once to prevent that file from being included more than once. Note that the #include-once line must be placed at the top of the script and before any other #include lines.

It is not recommended to add a #include-once line to scripts which are not intended to be used as include files within other scripts.

Related

#include

Example

; Use #include-once when creating UDFs so the file isn't included multiple times
; if you call the same UDF in multiple files.

#include-once
#include <MsgBoxConstants.au3>

; Rename this file as IncludeFunc.au3 and place next to the main script.
; Then add #include "IncludeFunc.au3" at the top of the script.

Func IncludeFunc()
    MsgBox($MB_SYSTEMMODAL, "", "This is an example of including a file.")
EndFunc   ;==>IncludeFunc


Keyword #pragma

Keyword Reference

#pragma

A special directive for controlling aspects of how the script is compiled.

#pragma pragma-option

Parameters

pragma-option compile

Remarks

See pragma directives for more details.

Example

#pragma compile(Out, myProg.exe)
; Uncomment to use the following icon. Make sure the file path is correct and matches the installation of your AutoIt install path.
; #pragma compile(Icon, C:\Program Files\AutoIt3\Icons\au3.ico)
#pragma compile(ExecLevel, highestavailable)
#pragma compile(Compatibility, win7)
#pragma compile(UPX, False)
#pragma compile(FileDescription, myProg - a description of the application)
#pragma compile(ProductName, myProg)
#pragma compile(ProductVersion, 3.7)
#pragma compile(FileVersion, 3.7.0.0, 3.7.100.201) ; The last parameter is optional.
#pragma compile(LegalCopyright, © Joe Bloggs)
#pragma compile(LegalTrademarks, '"Trademark something, and some text in "quotes" etc...')
#pragma compile(CompanyName, 'Joe Bloggs & Co')

#include <MsgBoxConstants.au3>

If @Compiled Then
    Example()
Else
    MsgBox($MB_SYSTEMMODAL, "", "Please compile before running.")
EndIf

Func Example()
    ; Retrieve the file version of the AutoIt executable.
    Local $sFileVersion = FileGetVersion(@AutoItExe)

    ; Display the file version. This should be equal to @AutoItVersion.
    MsgBox($MB_SYSTEMMODAL, "", $sFileVersion)
EndFunc   ;==>Example


Keyword #NoTrayIcon

Keyword Reference

#NoTrayIcon

Indicates that the AutoIt tray icon will not be shown when the script starts.

#NoTrayIcon

Remarks

It is possible to use Opt("TrayIconHide", 1) to remove the AutoIt tray icon but it will still be visible for a second when the script starts. Placing the #NoTrayIcon directive at the top of your script will stop the icon from being shown at startup.

You may still turn the icon back on later in the script using Opt("TrayIconHide", 0)

Related

TrayIconHide (Option)

Example

#NoTrayIcon
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Display a message box about the tray icon appearing once the OK button is selected.
    MsgBox($MB_SYSTEMMODAL, "", "The tray icon will display once OK is selected.")

    ; Display the tray icon.
    Opt("TrayIconHide", 0)

    ; Wait 5 seconds before closing the script.
    Sleep(5000)
EndFunc   ;==>Example


Keyword #OnAutoItStartRegister

Keyword Reference

#OnAutoItStartRegister

Registers a function to be called when AutoIt starts.

#OnAutoItStartRegister "function"

Parameters

function The name of the user function to call.

Remarks

The function cannot reference any variables defined in an #include.

Related

OnAutoItExitRegister

Example

; Register Example() and SomeFunc() to be called when AutoIt starts.

#OnAutoItStartRegister "Example"
#OnAutoItStartRegister "SomeFunc"

Sleep(1000)

Func Example()
    MsgBox(4096, "", "Function 'Example' is called first.")
EndFunc   ;==>Example

Func SomeFunc()
    MsgBox(4096, "", "Function 'SomeFunc' is called second.")
EndFunc   ;==>SomeFunc


Keyword #RequireAdmin

Keyword Reference

#RequireAdmin

Specifies that the current script requires full administrator rights to run.

#RequireAdmin

Remarks

This function was primarily aimed at allowing AutoIt scripts to work correctly with Windows User Account Control (UAC).

For more details see AutoIt on Windows Vista.

As this function launch a new process, some functions as ConsoleWrite() cannot be captured (SciTE will not display anything).
In case system doesn't have elevation mechanism (e.g. disabled UAC) new process will run under the same user as the original.

Related

IsAdmin

Example

#include <MsgBoxConstants.au3>

#RequireAdmin

If IsAdmin() Then MsgBox($MB_SYSTEMMODAL, "", "The script is running with admin rights.")


Keyword Func...Return...EndFunc

Keyword Reference

Func...Return...EndFunc

Defines a user-defined function that takes zero or more arguments and optionally returns a result.

Func functioname ( [Const] [ByRef] $param1, ..., [Const] [ByRef] $paramN, $optionalpar1 = value, ...)
...
[Return [value]]
EndFunc

Parameters

The parameters are set by you. You later call the function like any other built-in function.

Remarks

Variables and functions are case-insensitive, therefore SomeFunc() is the same as SoMEFunC(). and vice versa.

The Const keyword is optional and indicates that the value of the parameter will not change during the execution of the function. A variable declared Const can only be passed to a function using a Const parameter.

The ByRef keyword indicates that the parameter should be treated as a reference to the original. By default the parameter is copied into a new variable but ByRef links the new variable to the original. Note that not only a named variable can be passed for a ByRef parameter - unnamed temporary variables, such as function return values, may be passed as ByRef parameters as well. However, a literal cannot be passed to a ByRef parameter. ByRef should be used when passing large amounts of data (such as the contents of a file) where copying all the data would impose a significant performance penalty. Another advantage is that passing a parameter ByRef when the function is intended to change the content of the parameter removes any requirement to Return the changed value as the original is directly affected.

Declaring parameters as both ByRef and Const is useful when the large original variable must remain unchanged as AutoIt will return an error if the function attempts to alter it inadvertantly. The order of the keywords is not important, as long as they are both in front of the parameter they modify.

Entire arrays can be passed to functions (and returned from them) by simply using the array name without any brackets. Arrays should be passed to user-defined functions using the ByRef keyword to avoid the overhead of copying all the data in the array. Note that AutoIt only copies an array parameter if the contents are changed, so it is only in this case that ByRef offers an advantage, although it is recommended that to use it in all cases.

Optional parameters are defined by assigning a default value to them. The value may be a global variable, macro or literal value. Optional parameters always appear last in the function definition. All parameters added after the first optional parameter must also be optional. Inside the function, the number of parameters given when the function was called can be retrieved with the @NumParams macro (see example 2).

Use the Return keyword to exit the function. Unlike built-in functions, user-defined functions return 0 unless another return value is specified. Using Return with SetError() allows @error and @extended values to be returned as well as a value.

Note that function declarations cannot appear inside other function declarations.

Related

Const, Global/Local, #include

Example

Example 1

#include <Date.au3>
#include <Math.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Sample script with two user-defined functions.
    ; Notice the use of variables, ByRef and Return.

    Local $iFoo = 2
    Local $iBar = 5
    MsgBox($MB_SYSTEMMODAL, "", "Today is " & Today() & @CRLF & "$iFoo equals " & $iFoo)
    Swap($iFoo, $iBar)
    MsgBox($MB_SYSTEMMODAL, "", "After swapping $iFoo and $iBar:" & @CRLF & "$iFoo now contains " & $iFoo)
    MsgBox($MB_SYSTEMMODAL, "", "Finally:" & @CRLF & "The larger of 3 and 4 is " & _Max(3, 4))
EndFunc   ;==>Example

Func Swap(ByRef $vVar1, ByRef $vVar2) ; Swap the contents of two variables.
    Local $vTemp = $vVar1
    $vVar1 = $vVar2
    $vVar2 = $vTemp
EndFunc   ;==>Swap

Func Today() ; Return the current date in mm/dd/yyyy form.
    Return @MON & "/" & @MDAY & "/" & @YEAR
EndFunc   ;==>Today

Example 2

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Sample scriptusing @NumParams macro
    Test_Numparams(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
EndFunc   ;==>Example

Func Test_Numparams($vVar1 = 0, $vVar2 = 0, $vVar3 = 0, $vVar4 = 0, $vVar5 = 0, $vVar6 = 0, $vVar7 = 0, $vVar8 = 0, $vVar9 = 0, _
        $vVar10 = 0, $vVar11 = 0, $vVar12 = 0, $vVar13 = 0, $vVar14 = 0, $vVar15 = 0, $vVar16 = 0, $vVar17 = 0, $vVar18 = 0, $vVar19 = 0)
    #forceref $vVar1, $vVar2, $vVar3, $vVar4, $vVar5, $vVar6, $vVar7, $vVar8, $vVar9, $vVar10
    #forceref $vVar11, $vVar12, $vVar13, $vVar14, $vVar15, $vVar16, $vVar17, $vVar18, $vVar19
    Local $sVal = ""
    For $i = 1 To @NumParams
        $sVal &= Eval("vVar" & $i) & " "
    Next
    MsgBox($MB_SYSTEMMODAL, "", "@NumParams = " & @NumParams & @CRLF & @CRLF & $sVal)
EndFunc   ;==>Test_Numparams


Keyword Dim / Global / Local / Const

Keyword Reference

Dim / Global / Local / Const

Declare a variable, a constant, or create an array.

Global | Local [Const] $variable [ = initializer ]
Global | Local [Const] $aArray[subscript 1]...[subscript n] [ = initializer ]

Parameters

Const | [optional] If present, the Const keyword creates a constant rather than a variable.
$variable | The name of the variable/constant to declare.
initializer | The value that will be initially assigned to the variable. A Const must include the initializer. The initializer can be a function call.
subscript | The number of elements to create for the array dimension, indexed 0 to n-1.

Remarks

The Dim/Local/Global keywords perform similar functions:
1. Declare a variable before you use it (similar to VBScript)
2. Create an array

Note: In AutoIt you can create a variable simply by assigning a value ($myvar = 0) but many people like to explicitly declare them. If AutoItSetOption("MustDeclareVars", 1) is active, then variables must be declared prior to use.

You can also declare multiple variables on a single line:

Local $vVar_1, $vVar_2, $vVar_3

And initialize the variables:

Local $vVar_1 = 10, $vVar_2 = "20", $vVar_3 = 30

Creating constants can be done in a similar way:

Const $CONST_1 = 1, $CONST_2 = 2, $CONST_3 = 3
Global Const $PI = 3.14, $MEANING_OF_LIFE = 42
Local Const $iApples = 500

Once created, you cannot change the value of a constant. Also, you cannot change an existing variable into a constant.

To initialize an array, specify the values for each element inside square brackets, separated by commas. For multiple dimensions, nest the initializers. You can specify fewer elements in the initializer than declared, but not more. Function calls can also be placed in the initializers of an array. If the function call returns an array, then the one array element will contain that returned array.

Local $aArray_1[12] = [3, 7.5, "string"], $aArray_1[5] = [8, 4, 5, 9, 1]
Local $aGrid[2][4] = [["Paul", "Jim", "Richard", "Louis"], [485.44, 160.68, 275.16, 320.00]]
Global $aTest[5] = [3, 1, StringSplit("Abe|Jack|Bobby|Marty", "|"), Cos(0)]

The difference between Dim, Local and Global is the scope in which they are created:
Dim = Local scope if the variable name doesn't already exist globally (in which case it reuses the global variable!)
Global = Forces creation of the variable in the Global scope
Local = Forces creation of the variable in the Local/Function scope

You should use Local or Global, instead of Dim, to explicitly state which scope is desired for a variable/constant/array.

When using variables, the local scope is checked first and then the global scope second.

When creating arrays you are limited to up to 64 dimensions and/or a total of 16 million elements.

A unique feature in AutoIt is the ability to copy arrays like this:
$mycopy = $myarray
In this case $mycopy will be an exact copy of $myarray and will have the same dimensions - no Dim statement is required to size the array first. If AutoItSetOption ( "MustDeclareVars", 1) is active then the variable $mycopy would still need to be declared first, but would not need to be sized. If the variable $mycopy was already an array or single value it will be erased before the copy takes place.

To erase an array (maybe because it is a large global array and you want to free the memory), simply assign a single value to it:
$aArray = 0
This will free the array and convert it back to the single value of 0.

Declaring the same variable name again will erase all array values and reset the dimensions to the new definition. Declaring a variable with a simple value in the same scope will not change the value in the variable.

If you declare a variable with the same name as a parameter, using Local inside a user function, an error will occur. Global can be used to assign to global variables inside a function, but if a local variable (or parameter) has the same name as a global variable, the local variable will be the only one used. It is recommended that local and global variables have distinct names.

Related

AutoItSetOption, UBound, ReDim, Static

Example

Example 1

; Example 1 - Declaring variables
Local $i, $j = 23, $k
Global $g_fPI = 3.14159, $g_iRADIUS
Local $iDaysWorking = 5

; Example 2 - Declaring arrays
Global $g_aChessBoard[8][8]
Local $aStates[2], $aWindowsStats[4]

; Example 3 - Declaring constant variables
Const $iX1 = 11, $iY1 = 23, $iZ1 = 55
Global Const $PI = 3.14159, $E = 2.71828
Local Const $DAYS_WORKING = 5

Example 2

#AutoIt3Wrapper_Au3Check_Parameters=-q -d -w- 3 -w- 6 ; Already declared var=off, warn when using Dim=off

#include <MsgBoxConstants.au3>

Dim $vVariableThatIsGlobal = "This is a variable that has ""Program Scope"" aka Global."

MsgBox($MB_SYSTEMMODAL, "", "An example of why Dim can cause more problems than solve them.")

Example()

Func Example()
    ; That looks alright to me as it displays the following text: This is a variable that has "Program Scope" aka Global.
    MsgBox($MB_SYSTEMMODAL, "", $vVariableThatIsGlobal)

    ; Call some random function.
    Local $vReturn = SomeFunc()

    ; The Global variable ($vVariableThatIsGlobal) changed because I totally forgot I had a duplicate variable name in "SomeFunc".
    MsgBox($MB_SYSTEMMODAL, $vReturn, "The variable has now changed: " & $vVariableThatIsGlobal)
EndFunc   ;==>Example

Func SomeFunc()
    ; This should create a variable in Local scope if the variable name doesn't already exist.
    ; For argument sake I totally forgot that I declared a variable already with the same name.
    ; Well I only want this to be changed in the function and not the variable at the top of the script.
    ; Should be OK right? Think again.
    Dim $vVariableThatIsGlobal = ""

    For $i = 1 To 10
        $vVariableThatIsGlobal &= $i ; This will return 12345678910 totally wiping the previous contents of $vVariableThatIsGlobal.
    Next
    Return $vVariableThatIsGlobal
EndFunc   ;==>SomeFunc


Keyword ContinueCase

Keyword Reference

ContinueCase

Abort the code in the current Case block and continue with the code in the next Case block when in a Select or Switch structure.

ContinueCase

Remarks

Normally in a Select or Switch structure, the code within each Case block ends when the next Case statement is encountered. Executing ContinueCase tells AutoIt to stop executing the code within the current Case block and start executing the code within the next Case block. AutoIt does not evaluate the next Case comparison statement - only the code inside the block is run.

Trying to execute ContinueCase outside of a Select or Switch will cause a fatal error.

Related

Select...EndSelect, Switch...EndSwitch

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $sName = InputBox("", "Please enter a word.", "", " M", Default, Default, Default, Default, 10)
    Local $sMsg = ""

    Switch @error
        Case 2
            $sMsg = "Timeout "
            ContinueCase
        Case 1 ; Continuing previous case
            $sMsg &= "Cancellation"
        Case 0
            Switch $sName
                Case "a", "e", "i", "o", "u"
                    $sMsg = "Vowel"
                Case "QP"
                    $sMsg = "Mathematics"
                Case "Q" To "QZ"
                    $sMsg = "Science"
                Case Else
                    $sMsg = "Others"
            EndSwitch
        Case Else
            $sMsg = "Something went horribly wrong."
    EndSwitch

    MsgBox($MB_SYSTEMMODAL, "", $sMsg)
EndFunc   ;==>Example


Keyword ContinueLoop

Keyword Reference

ContinueLoop

Continue a While/Do/For loop.

ContinueLoop [level]

Parameters

level [optional] The level of the loop to restart. The default is 1 (meaning the current loop).

Remarks

ContinueLoop will continue execution of the loop at the expression testing statement (that is the While, Until or Next statement).

A negative level or zero value has no effect.

Even though any program that uses ContinueLoop can be rewritten using If-ElseIf-EndIf statements, ContinueLoop can make long scripts easier to understand.
Be careful with While/Do loops; you can create infinite loops by using ContinueLoop incorrectly.

Related

Do, ExitLoop, For, While

Example

#include <MsgBoxConstants.au3>

; Display all the numbers for 1 to 10 but skip displaying  7.
For $i = 1 To 10
    If $i = 7 Then
        ContinueLoop ; Skip displaying the message box when $i is equal to 7.
    EndIf
    MsgBox($MB_SYSTEMMODAL, "", "The value of $i is: " & $i)
Next


Keyword Default

Keyword Reference

Default

Keyword value use in function call.

$var = Default

Remarks

This keyword should not be used in a general computation expression. AutoIt will not detect such situations because it has too much of a performance penalty.

When used in parameter passing, the behavior is specified in the corresponding AutoIt function documentation.
For UDF's, it is the scripter's responsibility to check if the parameter has been set to Default and to perform the desired behavior in this situation.
If used, the passed parameter will be set to the Default keyword and not to an optional parameter value, if defined.

Related

IsKeyword, Null

Example

#include <MsgBoxConstants.au3>

Example(Default, Default)

Func Example($vParam1 = Default, $vParam2 = "Two", $vParam3 = Default)
    If $vParam1 = Default Then $vParam1 = "One" ; If the Default keyword is used, the assign the variable as "One"
    If $vParam3 = Default Then $vParam3 = "Three" ; If the Default keyword is used, the assign the variable as "Three"

    ; Display the following parameters passed to the function.
    MsgBox($MB_SYSTEMMODAL, "Paramaters", "1 = " & $vParam1 & @CRLF & _
            "2 = " & $vParam2 & @CRLF & _
            "3 = " & $vParam3)
EndFunc   ;==>Example


Keyword Do...Until

Keyword Reference

Do...Until

Loop based on an expression.

Do
statements
...
Until <expression>

Parameters

expression The statements in between Do...Until are executed until the expression is true.

Remarks

Do...Until statements may be nested.
The expression is tested after the loop is executed, so the loop will be executed one or more times.

Related

ContinueLoop, ExitLoop

Example

#include <MsgBoxConstants.au3>

Local $i = 0
Do
    MsgBox($MB_SYSTEMMODAL, "", "The value of $i is: " & $i) ; Display the value of $i.
    $i = $i + 1 ; Or $i += 1 can be used as well.
Until $i = 10 ; Increase the value of $i until it equals the value of 10.


Keyword Enum

Keyword Reference

Enum

Enumerates constants.

[scope] Enum [Step <stepval>] <constantlist>

Parameters

scope | [optional] The scope the Enum should be placed in, either Local, Global, Dim or none. If none, Dim behavior is used.
stepval | [optional] The default step is to add 1. Other possible step methods are: *n, +n, -n where n is a whole number.
constantlist | A list constants to be enumerated.

Remarks

By default, the first constant will be 0 and the rest will be incremented by 1 from there.
When using the multiply operator to step, the first constant will be assigned 1 and the rest will be multiplied based on the previous constant value.
Constants can be explicitly assigned by any valid statement.

Example

Example 1

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; These variables will enumerate from 0 to 2.
    Local Enum $eVar1, $eVar2, $eVar3
    MsgBox($MB_SYSTEMMODAL, "", "$eVar1 is equal to (0): " & $eVar1 & @CRLF & _
            "$eVar2 is equal to (1): " & $eVar2 & @CRLF & _
            "$eVar3 is equal to (2): " & $eVar3 & @CRLF)

    ; These variables will enumerate from 1 to 2 and then $eVariant3 is set to 5 which will continue to
    ; increment by 1.
    Local Enum $eVariant1 = 1, $eVariant2, $eVariant3 = 5, $eVariant4
    MsgBox($MB_SYSTEMMODAL, "", "$eVariant1 is equal to (1): " & $eVariant1 & @CRLF & _
            "$eVariant2 is equal to (2): " & $eVariant2 & @CRLF & _
            "$eVariant3 is equal to (5): " & $eVariant3 & @CRLF & _
            "$eVariant3 is equal to (6): " & $eVariant4 & @CRLF)

    ; Multiply each enumeration by 2.
    Local Enum Step *2 $eFoo1, $eFoo2, $eFoo3, $eFoo4
    MsgBox($MB_SYSTEMMODAL, "", "$eFoo1 is equal to (1): " & $eFoo1 & @CRLF & _
            "$eFoo2 is equal to (2): " & $eFoo2 & @CRLF & _
            "$eFoo3 is equal to (4): " & $eFoo3 & @CRLF & _
            "$eFoo3 is equal to (8): " & $eFoo4 & @CRLF)
EndFunc   ;==>Example

Example 2

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create variables in Local scope and enumerate through the variables. Default is to start from 0.
    Local Enum $eCat, $eDog, $eMouse, $eHamster ; $eHamster is equal to the value 3, not 4.

    ; Create an array in Local scope with 4 elements.
    Local $aAnimalNames[4]

    ; Assign each array element with the name of the respective animal. For example the name of the cat is Jasper.
    $aAnimalNames[$eCat] = 'Jasper' ; $eCat is equal to 0, similar to using $aAnimalNames[0]
    $aAnimalNames[$eDog] = 'Beethoven' ; $eDog is equal to 1, similar to using $aAnimalNames[1]
    $aAnimalNames[$eMouse] = 'Pinky' ; $eMouse is equal to 2, similar to using $aAnimalNames[2]
    $aAnimalNames[$eHamster] = 'Fidget' ; $eHamster is equal to 3, similar to using $aAnimalNames[3]

    ; Display the values of the array.
    MsgBox($MB_SYSTEMMODAL, '', '$aAnimalNames[$eCat] = ' & $aAnimalNames[$eCat] & @CRLF & _
            '$aAnimalNames[$eDog] = ' & $aAnimalNames[$eDog] & @CRLF & _
            '$aAnimalNames[$eMouse] = ' & $aAnimalNames[$eMouse] & @CRLF & _
            '$aAnimalNames[$eHamster] = ' & $aAnimalNames[$eHamster] & @CRLF)

    ; Sometimes using this approach for accessing an element is more practical than using a numerical value, due to the fact that changing the index value of
    ; the enum constant has no affect on it's position in the array. Therefore changing the location of $eCat in the array is as simple as changing the order
    ; it appears in the initial declaration e.g.

    ; Local Enum $eDog, $eMouse, $eCat, $eHamster

    ; Now $eCat is the 2nd element in the array. If you were using numerical values, you would have to manually change all references of $aAnimalNames[0] to
    ; $aAnimalNames[2], as well as for the other elements which have now shifted.
EndFunc   ;==>Example


Keyword Exit

Keyword Reference

Exit

Terminates the script.

Exit [return code]

Parameters

return code [optional] Integer that sets the script's return code. This code can be used by Windows or the DOS variable %ERRORLEVEL%. The default is 0. Scripts normally set an errorlevel of 0 if the script executed properly; error levels 1 and above typically indicate that the script did not execute properly.

Remarks

The parameter, if included, can be enclosed in parentheses. Thus, the following are equivalent: Exit, Exit 0, and Exit(0). However, Exit() is invalid.

The code can be retrieved in an OnAutoItExitRegister function by @exitCode.

Related

ExitLoop, OnAutoItExitRegister

Example

Example 1

; very simple script

Exit

Example 2

; Terminate script if no command-line arguments
If $CmdLine[0] = 0 Then Exit (1)


Keyword ExitLoop

Keyword Reference

ExitLoop

Terminate a While/Do/For loop.

ExitLoop [level]

Parameters

level [optional] The number of loop levels to exit from. The default is 1 (meaning the current loop).

Remarks

A negative level or zero value has no effect.

ExitLoop will break out of a While, Do or For loop.
ExitLoop is useful when you would otherwise need to perform error checking in both the loop-test and the loop-body.

Related

ContinueLoop, Do, Exit, For, While

Example

#include <MsgBoxConstants.au3>

Local $iSum = 0, $iAns = 0

While 1 ;use infinite loop since ExitLoop will get called
    $iAns = InputBox("Running total=" & $iSum, _
            "   Enter a positive number.  (A negative number exits)")
    If $iAns < 0 Then ExitLoop
    $iSum = $iSum + $iAns
WEnd

MsgBox($MB_SYSTEMMODAL, "", "The sum was: " & $iSum)


Keyword False / True

Keyword Reference

False / True

Boolean values for use in logical expressions.

$var = False
$var = True

Remarks

These keywords should not be used in expressions as AutoIt will not detect this 'misuse' and the results will be unpredictable.

Related

IsBool

Example

#include <MsgBoxConstants.au3>

Local $bBoolean = False
If Not ($bBoolean = True) Then MsgBox($MB_SYSTEMMODAL, "Bool comparison", "OK") ; If $bBoolean is NOT equal to True then display the messagebox


Keyword For...To...Step...Next

Keyword Reference

For...To...Step...Next

Loop based on an expression.

For <variable> = <start> To <stop> [Step <stepval>]
statements
...
Next

Parameters

variable | The variable used for the count.
start | The initial numeric value of the variable.
stop | The final numeric value of the variable.
stepval | [optional] The numeric value (possibly fractional) that the count is increased by each loop. Default is 1.

Remarks

The variable will be created automatically with Local scope, even when MustDeclareVars is on.

For...Next statements may be nested. The For loop terminates when the value of variable exceeds the stop threshold. If stepVal or stop is a variable, its value is only read the first time the loop executes.

A For loop will execute zero times if:
start > stop and step > 0, or
start < stop and step is negative

Related

ContinueLoop, ExitLoop

Example

#include <MsgBoxConstants.au3>

For $i = 5 To 1 Step -1
    MsgBox($MB_SYSTEMMODAL, "", "Count down!" & @CRLF & $i)
Next
MsgBox($MB_SYSTEMMODAL, "", "Blast Off!")


Keyword For...In...Next

Keyword Reference

For...In...Next

Enumerates elements in an Object collection or an Array.

For <Variable> In <expression>
statements
...
Next

Parameters

Variable | A variable to which an element is being assigned
expression | Must be an expression resulting in an Object, or an Array with at least one element

Remarks

The Variable will be created automatically with a Local scope, even when MustDeclareVars is on.
If the expression is an Object collection with no elements, or an multi-dimensional array, the loop will be skipped and the Variable will contain an empty string.
If the expression is not an Object nor an Array, the script stops with an error, unless a COM Error handler had been configured.
AutoIt Arrays are read-only when using For...In. While you can assign the variable inside the For...In loop a value, this change is not reflected in the array itself. To modify the contents of an array during enumeration, use a For...To loop.

For...In...Next statements may be nested.

Related

With...EndWith

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Using an Array
    Local $aArray[4]

    $aArray[0] = "a"
    $aArray[1] = 0
    $aArray[2] = 1.3434
    $aArray[3] = "test"

    Local $sString = ""
    For $vElement In $aArray
        $sString = $sString & $vElement & @CRLF
    Next

    MsgBox($MB_SYSTEMMODAL, "", "For..IN Arraytest:" & @CRLF & "Result is: " & @CRLF & $sString)

    ; Using an Object Collection

    Local $oShell = ObjCreate("shell.application")
    Local $oShellWindows = $oShell.windows

    If IsObj($oShellWindows) Then
        $sString = ""

        For $Window In $oShellWindows
            $sString = $sString & $Window.LocationName & @CRLF
        Next

        MsgBox($MB_SYSTEMMODAL, "", "You have the following windows open:" & @CRLF & $sString)
    Else

        MsgBox($MB_SYSTEMMODAL, "", "You have no open shell windows.")
    EndIf
EndFunc   ;==>Example


Keyword If...Then

Keyword Reference

If...Then

Conditionally run a single statement.

If <expression> Then statement

Parameters

expression If the expression is true, the statement is executed.

Remarks

This version of the If statement is used to execute a single statement without the overhead of an EndIf.
The expression can contain the boolean operators of And, Or, and Not as well as the logical operators <, <=, >, >=, =, ==, and <> grouped with parentheses as needed.

Related

If...Else...EndIf, Select...Case...EndSelect, Switch...EndSwitch, Ternary

Example

#include <MsgBoxConstants.au3>

; Terminates script if no command-line arguments
If $CmdLine[0] = 0 Then Exit

; Alternative:
If $CmdLine[0] = 0 Then
    Exit
EndIf

MsgBox($MB_SYSTEMMODAL, "", "Script has command-line arguments.")


Keyword If...ElseIf...Else...EndIf

Keyword Reference

If...ElseIf...Else...EndIf

Conditionally run statements.

If <expression> Then
statements
...
[ElseIf expression-n Then
[elseif statements ... ]]
...
[Else
[else statements]
...
EndIf

Parameters

expression If the expression is true, the first statement block is executed. If not, the first true ElseIf block is executed. Otherwise, the "Else" block is executed.

Remarks

If statements may be nested.
The expression can contain the boolean operators of And, Or, and Not as well as the logical operators <, <=, >, >=, =, ==, and <> grouped with parentheses as needed.

Related

If...Then, Select...Case...EndSelect, Switch...EndSwitch, Ternary

Example

#include <MsgBoxConstants.au3>

Local $sString = ""
If $sString > 0 Then
    MsgBox($MB_SYSTEMMODAL, "", "Value is positive.")
ElseIf $sString < 0 Then
    MsgBox($MB_SYSTEMMODAL, "", "Value is negative.")
Else
    If StringIsXDigit($sString) Then
        MsgBox($MB_SYSTEMMODAL, "", "Value might be hexadecimal!")
    Else
        MsgBox($MB_SYSTEMMODAL, "", "Value is a string.")
    EndIf
EndIf


Keyword Null

Keyword Reference

Null

Keyword value to use in function call.

$var = Null

Remarks

Use this keyword to trigger specific operations of functions that accept it as parameter.
Null evaluates only to Null, still in mathematical operations this keyword has value of 0, and as string it has no value (empty string).
COM method will receive Null as VT_NULL VARIANT. DllCall's wstr and str types will be set to NULL (pointers).

Related

Default, IsKeyword

Example

; Message box with an "Error" title.

DllCall("user32.dll", "int", "MessageBoxW", "hwnd", 0, "wstr", "Some text", "wstr", Null, "dword", 0)


Keyword ReDim

Keyword Reference

ReDim

Resize an existing array.

ReDim $aArray[subscript 1]...[subscript n]

Parameters

$aArray | The name of the array to resize.
subscript | The number of elements to create for the array dimension, indexed 0 to n-1.

Remarks

The ReDim keyword is similar to Global/Local, except that ReDim preserves the values in the array instead of removing the values while resizing an array.
The number of dimensions must remain the same, or the old array will be forgotten during the ReDim.
The array will retain the scope (Global or Local) that it had prior to resizing.

Related

Dim, UBound

Example

Example 1

#include <Array.au3>

Example()

Func Example()
    Local $aArray[1] ; Create a 1-dimensional array with 1 element.
    For $i = 0 To 100 ; Loop through values 0 to 100 to access the index of the array
        ReDim $aArray[UBound($aArray) + 1] ; Determine the current size of the array and increase by 1
        $aArray[$i] = $i
    Next
    _ArrayDisplay($aArray) ; Display the array.
EndFunc   ;==>Example

Example 2

#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aArray[1] = [0], $iArrayTotal = 5000, $iCount = 0, $iDimension = 0

    Local $hTimer = TimerInit() ; Start the timer.
    For $i = 1 To $iArrayTotal
        ; Returns True if ReDimmed or False if it wasn"t. This uses ByRef, so just pass the Array and a previously declared variable for monitoring the dimension.
        If ReDim1D($aArray, $iDimension) Then
            $iCount += 1 ; If the array was ReDimmed then add to the ReDim count for output at the end of the example.
        EndIf
        $aArray[0] += 1 ; Increase zeroth index [0] by a value of 1.
        $aArray[$i] = "Row " & $i & ": Col 0" ; Add random data.
    Next
    $hTimer = Round(TimerDiff($hTimer)) ; End the timer and find the difference from start to finish.

    ReDim $aArray[$aArray[0] + 1] ; Remove the empty elements by ReDimming the total count plus the element for holding the count.

    MsgBox($MB_SYSTEMMODAL, "How many times?", "The amount of times a " & $iArrayTotal & " element array was ""ReDimmed"" was " & $iCount & " times." & @CRLF & _
            "It only took " & $hTimer & " milliseconds to complete.")
    ; If using the method of increasing the array size by 1, $iCount would return 5000, not 29 as demonstrated in this example.
EndFunc   ;==>Example

; ReDim when required by increasing the total array size as totalsize * 1.3 and rounding to the next highest integer.
Func ReDim1D(ByRef $aArray, ByRef $iDimension) ; Where zeroth index [0] is the element count.
    Local $bReturn = False
    If ($aArray[0] + 1) >= $iDimension Then
        $bReturn = True
        $iDimension = Ceiling(($aArray[0] + 1) * 1.3)
        ReDim $aArray[$iDimension]
    EndIf
    Return $bReturn
EndFunc   ;==>ReDim1D


Keyword Select...Case...EndSelect

Keyword Reference

Select...Case...EndSelect

Conditionally run statements.

Select
Case <expression1>
statement1
...
[Case <expression2>
statement2
...]
[Case <expressionn>
statementn
...]
[Case Else
statementElse
...]
EndSelect

Parameters

<expression> If the expression is true the following statements up to the next Case or EndSelect statement are executed. If more than one of the Case statements are true, only the first one is executed.

Remarks

Select statements may be nested.
The expression can contain the boolean operators of And, Or, and Not as well as the logical operators <, <=, >, >=, =, ==, and <> grouped with parentheses as needed.

Related

If...Then, If...Else...EndIf, Switch...EndSwitch, ContinueCase

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iValue = 0
    Local $sBlank = "Test"

    Select
        Case $iValue = 1
            MsgBox($MB_SYSTEMMODAL, "", "The first expression was True.")
        Case $sBlank = "Test"
            MsgBox($MB_SYSTEMMODAL, "", "The second expression was True")
        Case Else ; If nothing matches then execute the following.
            MsgBox($MB_SYSTEMMODAL, "", "No preceding case was True.")
    EndSelect
EndFunc   ;==>Example


Keyword Static

Keyword Reference

Static

Declare a static variable or create a static array.

Static [Scope] $variable [ = initializer ]
Static [Scope] $aArray[subscript 1]...[subscript n] [ = initializer ]

Parameters

Scope | An optional modifier, Local or Global that indicates where the variable is visible.
$variable | The name of the static variable to declare.
initializer | The value that will be initially assigned to the variable. The initializer can be a function call of involve mathematical or string operations. This initializer is only evaluated the first time this variable declaration is encountered.
subscript | The number of elements to create for the array dimension, indexed 0 to n-1.

Remarks

The Static keyword can appear on the line before the optional scope specifier, or after. e.g. Local Static or Static Local are both acceptable.

If the scope specifier Local is used, then the static variable is visible and usable only in the function in which it is declared and it's resolved in the environment of execution (logical scope). This means that conditionally declared variable is visible only when declaraion condition is met. If the scope specifier Global is used, then the static variable is visible and usable in all parts of the script; in this regard, a Global Static has very little difference from a Global variable. If the scope specifier is not used, then the static variable will be created in the local scope; in this way, Static is similar to Dim.

The difference between Local and Static is variable lifetime. Local variables are only stored while the function is called and are visible only within the function in which they are declared; when the function returns, all its local variables are released. Static variables are likewise visible only in the function in which they are declared, but they continue to exist, retaining their last value, after the function finishes execution. When looking for variables, the local scope is checked first and then the global scope second.

The Static keyword performs similar functions to the Global/Local/Dim keywords.

  1. They all declare a variable before you use it.

  2. They all can create an array.

Note: Static variables must be declared using the Static keyword prior to use, no matter how AutoItSetOption("MustDeclareVars") is set. Static variables can not be Const.

You can also declare multiple static variables on a single line:

Static $a, $b, $c

And initialize the variables:

Static $a = 2, $b = 10, $c = 20

When initializing a static variable, the initialization value is evaluated and assigned only the first time, when the variable is created. On all subsequent passes, the initializer is ignored.

See Local for more information about using arrays, which has all the same functionality as in Local, except for:
  1. Reinitializing a Static variable has no effect.

  2. You can not change a static variable to a local or global variable nor vice-versa.

If you want to resize an array use ReDim.

Related

AutoItSetOption, Local, ReDim, UBound

Example

Example 1

#include <MsgBoxConstants.au3>

; Call the Example function to initialize the Static variable in Local scope.
Example()

; Call the Example function a second time to show that the variable has retained the data we last assigned to it.
Example()

Func Example()
    Local Static $sString = "This is a line of text which is declared using a Static variable in Local scope." & @CRLF & @CRLF & _
            "The variable $sString will now be visible to this function only and until the script closes."
    MsgBox($MB_SYSTEMMODAL, "", $sString)
    $sString = "If using just Local scope this string wouldn't be visible if this function was called multiple times, but since we're using the Static keyword" & @CRLF & _
            "the variable $sString will retain the data last assigned to it."
EndFunc   ;==>Example

Example 2

#include <MsgBoxConstants.au3>

Example()

Func Example()
    SomeFunc() ; This will display a message box of 1, 1.
    SomeFunc() ; This will display a message box of 1, 2.
    SomeFunc() ; This will display a message box of 1, 3.
EndFunc   ;==>Example

Func SomeFunc()
    ; This initialises a Static variable in Local scope. When a variable is declared just in Local scope (within a Function,)
    ; it's destroyed when the Function ends/returns. This isn't the case for a Static variable. The variable can't be
    ; accessed from anywhere else in the script apart from the Function it was declared in.
    Local Static $vVariableThatIsStatic = 0
    Local $vVariableThatIsLocal = 0
    $vVariableThatIsLocal += 1 ; This will always be 1 as it was destroyed once returned from SomeFunc.
    $vVariableThatIsStatic += 1 ; This will increase by 1.
    MsgBox($MB_SYSTEMMODAL, $vVariableThatIsLocal, $vVariableThatIsStatic)
EndFunc   ;==>SomeFunc


Keyword Switch...Case...EndSwitch

Keyword Reference

Switch...Case...EndSwitch

Conditionally run statements.

Switch <expression>
Case <value> [To <value>] [,<value> [To <value>] ...]
statement1
...
[Case <value> [To <value>] [,<value> [To <value>] ...]
statement2
...]
[Case Else
statementN
...]
EndSwitch

Parameters

<expression> | An expression that returns a value. The value from the expression is then compared against the values of each case until a match is found. This expression is always evaluated exactly once each time through the structure.
<value> To <value> | The case is executed if the expression is between the two values.
<value> | The case is executed if the expression matches the value.

Remarks

If no cases match the Switch value, then the Case Else section, if present, is executed. If no cases match and Case Else is not defined, then none of the code inside the Switch structure, other than the condition, will be executed.

Switch statements may be nested. Switch statements are case-insensitive.

Related

If...Then, If...Else...EndIf, Select...EndSelect, ContinueCase

Example

#include <MsgBoxConstants.au3>

Local $sMsg = ""

Switch @HOUR
    Case 6 To 11
        $sMsg = "Good Morning"
    Case 12 To 17
        $sMsg = "Good Afternoon"
    Case 18 To 21
        $sMsg = "Good Evening"
    Case Else
        $sMsg = "What are you still doing up?"
EndSwitch

MsgBox($MB_SYSTEMMODAL, "", $sMsg)


Operator Ternary

Operator Reference

Ternary

Conditionally chooses one of two responses based on the result of an expression.

(expression) ? (expression1 if expression is True) : (expression2 if expression is False)

Parameters

expression If the expression is true, the expression1 is executed - if false, the expression2 is executed

Remarks

This Conditional operator allows a binary choice to be executed without the overhead of an If...Else...EndIf structure.

Although not necessary in all cases, it is strongly recommended that the 3 elements are enclosed in parentheses.

Related

If...Else...EndIf, Select...Case...EndSelect, Switch...EndSwitch

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; The values are the same so the expression is True
    MsgBox($MB_SYSTEMMODAL, "Result: 1=1", (1 = 1) ? "True!" : "False!")
    ; The values are not the same so the expression is False
    MsgBox($MB_SYSTEMMODAL, "Result: 1=2", (1 = 2) ? "True!" : "False!")
EndFunc   ;==>Example


Keyword Volatile

Warning: This feature is experimental. It may not work, may contain bugs or may be changed or removed without notice.

DO NOT REPORT BUGS OR REQUEST NEW FEATURES FOR THIS FEATURE.

Keyword Reference

Volatile

Function qualifier.

Volatile Func functioname(...)
...
EndFunc

Remarks

Use Volatile qualifier to modify certain aspects of function execution.

The following rules apply to functions that are declared with this qualifier:

Callback function | During function execution the main AutoIt's message pump is not blocked as it normally is for non-Volatile callbacks.
COM event function | The execution is synchronous (see example).

SetTimer callbacks are not safe as Volatile so be sure to avoid them.
For all other cases there is no difference in execution of Volatile functions compared to regular functions.

Related

Func

Example

_COM_Example()

Func _COM_Example()
    ; Create Internet Explorer object
    Local $oIE = ObjCreate("InternetExplorer.Application")
    ; Check for errors
    If @error Then Return
    $oIE.Visible = True ; set visibility
    ; Custom sink object
    ObjEvent($oIE, "_IEEvent_", "DWebBrowserEvents2")
    ; Navigate somewhere
    $oIE.navigate("http://www.google.com")
    ; Check for errors while loading
    If @error Then
        $oIE.Quit()
        Return
    EndIf
    ; Wait for page to load
    While 1
        If $oIE.readyState = "complete" Or $oIE.readyState = 4 Then ExitLoop
        Sleep(10)
    WEnd

    ; Wait few seconds to see if more events will be fired
    Sleep(3000)
    ; Nothing more to do. Close IE and return from the function
    $oIE.Quit()
EndFunc   ;==>_COM_Example

; BeforeNavigate2 method definition
Volatile Func _IEEvent_BeforeNavigate2($oIEpDisp, $sIEURL, $iIEFlags, $sIETargetFrameName, $sIEPostData, $iIEHeaders, ByRef $bIECancel)

    ConsoleWrite("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--BeforeNavigate2 fired--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & _
            "$oIEpDisp = " & $oIEpDisp() & "  -  " & ObjName($oIEpDisp) & @CRLF & _ ; e.g. default property and name for the object
            "$sIEURL = " & $sIEURL & @CRLF & _
            "$iIEFlags = " & $iIEFlags & @CRLF & _
            "$sIETargetFrameName = " & $sIETargetFrameName & @CRLF & _
            "$sIEPostData = " & $sIEPostData & @CRLF & _
            "$iIEHeaders = " & $iIEHeaders & @CRLF & _
            "$bIECancel = " & $bIECancel & @CRLF & _
            "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & @CRLF)

    ; Cancel navigation
    $bIECancel = True
EndFunc   ;==>_IEEvent_BeforeNavigate2


Keyword With...EndWith

Keyword Reference

With...EndWith

Used to reduce long references to dot-accessible type of variables.

With <expression>
statements
...
EndWith

Parameters

expression Must be an object type expression

Remarks

With...EndWith statements may be nested.

Related

For...In...Next

Example

Local $oExcel = ObjCreate("Excel.Application")
$oExcel.visible = 1
$oExcel.workbooks.add

With $oExcel.activesheet
    .cells(2, 2).value = 1
    .range("A1:B2").clear
EndWith

$oExcel.quit


Keyword While...WEnd

Keyword Reference

While...WEnd

Loop based on an expression.

While <expression>
statements
...
WEnd

Parameters

expression If the expression is true the following statements up to the WEnd statement are executed. This loop continues until the expression is false.

Remarks

While...WEnd statements may be nested.
The expression is tested before the loop is executed so the loop will be executed zero or more times.
To create an infinite loop, you can use a non-zero number as the expression.

Related

ContinueLoop, ExitLoop

Example

Example 1

#include <MsgBoxConstants.au3>

Local $i = 0
While $i <= 10
    MsgBox($MB_SYSTEMMODAL, "", "Value of $i is: " & $i)
    $i = $i + 1
WEnd

Example 2

; Set the Escape hotkey to terminate the script.
HotKeySet("{ESC}", "_Terminate")

Example()

Func Example()
    ; Initialize a Local variable.
    Local $aMgp = 0

    ; Create an endless loop, 1 will always be 1 therefore True.
    While 1
        ; Assign a Local variable the coords of the cursor (array).
        $aMgp = MouseGetPos()

        ; Display a tooltip near the cursor with its coords.
        ToolTip("x: " & $aMgp[0] & ", y: " & $aMgp[1], $aMgp[0] + 10, $aMgp[1] + 10)

        ; Avoid high CPU usage.
        Sleep(50)
    WEnd
EndFunc   ;==>Example

Func _Terminate()
    Exit
EndFunc   ;==>_Terminate


Macros

Macro Reference

Below is an alphabetized list of all the macros available in AutoIt.

Macro | Description
@AppDataCommonDir | Path to Application Data
@AppDataDir | Path to current user's Roaming Application Data
@AutoItExe | The full path and filename of the AutoIt executable currently running. For compiled scripts it is the path of the compiled script; for .a3x and .au3 files it is the path of the interpreter running the file.
@AutoItPID | Process identifier (PID) of the current script.
@AutoItVersion | Version number of AutoIt such as 3.3.10.2
@AutoItX64 | Returns 1 if the script is running under the native x64 version of AutoIt.
@COM_EventObj | Object the COM event is being fired on. Only valid in a COM event function.
@CommonFilesDir | Path to Common Files folder
@Compiled | Returns 1 if script is a compiled executable or an .a3x file; returns 0 if an .au3 file.
@ComputerName | Computer's network name.
@ComSpec Value of %COMSPEC%, the SPECified secondary COMmand interpreter;
primary for command line uses, e.g. Run(@ComSpec & " /k help | more")
@CPUArch | Returns "X86" when the CPU is a 32-bit CPU and "X64" when the CPU is 64-bit.
@CR | Carriage return, Chr(13); occasionally used for line breaks.
@CRLF | @CR & @LF; typically used for line breaks.
@DesktopCommonDir | Path to Desktop
@DesktopDepth | Depth of the primary display in bits per pixel.
@DesktopDir | Path to current user's Desktop
@DesktopHeight | Height of the primary display in pixels. (Vertical resolution)
@DesktopRefresh | Refresh rate of the primary display in hertz.
@DesktopWidth | Width of the primary display in pixels. (Horizontal resolution)
@DocumentsCommonDir | Path to Documents
@error | Status of the error flag. See the function SetError().
@exitCode | Exit code as set by Exit statement.
@exitMethod | Exit method. See the function OnAutoItExitRegister().
@extended | Extended function return - used in certain functions such as StringReplace().
@FavoritesCommonDir | Path to Favorites
@FavoritesDir | Path to current user's Favorites
@GUI_CtrlHandle | Last click GUI Control handle. Only valid in an event Function. See the GUICtrlSetOnEvent() function.
@GUI_CtrlId | Last click GUI Control identifier. Only valid in an event Function. See the GUICtrlSetOnEvent() function.
@GUI_DragFile | Filename of the file being dropped. Only valid on Drop Event. See the GUISetOnEvent() function.
@GUI_DragId | Drag GUI Control identifier. Only valid on Drop Event. See the GUISetOnEvent() function.
@GUI_DropId | Drop GUI Control identifier. Only valid on Drop Event. See the GUISetOnEvent() function.
@GUI_WinHandle | Last click GUI window handle. Only valid in an event Function. See the GUICtrlSetOnEvent() function.
@HomeDrive | Drive letter of drive containing current user's home directory.
@HomePath | Directory part of current user's home directory. To get the full path, use in conjunction with @HomeDrive.
@HomeShare | Server and share name containing current user's home directory.
@HotKeyPressed | Last hotkey pressed. See the HotKeySet() function.
@HOUR | Hours value of clock in 24-hour format. Range is 00 to 23
@IPAddress1 | IP address of first network adapter. Tends to return 127.0.0.1 on some computers.
@IPAddress2 | IP address of second network adapter. Returns 0.0.0.0 if not applicable.
@IPAddress3 | IP address of third network adapter. Returns 0.0.0.0 if not applicable.
@IPAddress4 | IP address of fourth network adapter. Returns 0.0.0.0 if not applicable.
@KBLayout | Returns code denoting Keyboard Layout. See Appendix for possible values.
@LF | Line feed, Chr(10); occasionally used for line breaks.
@LocalAppDataDir | Path to current user's Local Application Data
@LogonDNSDomain | Logon DNS Domain.
@LogonDomain | Logon Domain.
@LogonServer | Logon server.
@MDAY | Current day of month. Range is 01 to 31
@MIN | Minutes value of clock. Range is 00 to 59
@MON | Current month. Range is 01 to 12
@MSEC | Milliseconds value of clock. Range is 000 to 999. The update frequency of this value depends on the timer resolution of the hardware and may not update every millisecond.
@MUILang | Returns code denoting Multi Language if available (Vista is OK by default). See Appendix for possible values.
@MyDocumentsDir | Path to My Documents target
@NumParams | Number of parameters used in calling the user function.
@OSArch | Returns one of the following: "X86", "IA64", "X64" - this is the architecture type of the currently running operating system.
@OSBuild | Returns the OS build number. For example, Windows 2003 Server returns 3790
@OSLang | Returns code denoting OS Language. See Appendix for possible values.
@OSServicePack | Service pack info in the form of "Service Pack 3".
@OSType | Returns "WIN32_NT" for XP/2003/Vista/2008/Win7/2008R2/Win8/2012/Win8.1/2012R2.
@OSVersion Returns one of the following: "WIN_10", "WIN_81", "WIN_8", "WIN_7", "WIN_VISTA", "WIN_XP", "WIN_XPe",
for Windows servers: "WIN_2016", "WIN_2012R2", "WIN_2012", "WIN_2008R2", "WIN_2008", "WIN_2003"".
@ProgramFilesDir | Path to Program Files folder
@ProgramsCommonDir | Path to Start Menu's Programs folder
@ProgramsDir | Path to current user's Programs (folder on Start Menu)
@ScriptDir | Directory containing the running script. Only includes a trailing backslash when the script is located in the root of a drive.
@ScriptFullPath | Equivalent to @ScriptDir & "\" & @ScriptName
@ScriptLineNumber | Line number being executed - useful for debug statements (e.g. location of function call). Only significant in uncompiled scripts - note that #include files return their internal line numbering
@ScriptName | Filename of the running script.
@SEC | Seconds value of clock. Range is 00 to 59
@StartMenuCommonDir | Path to Start Menu folder
@StartMenuDir | Path to current user's Start Menu
@StartupCommonDir | Path to Startup folder
@StartupDir | current user's Startup folder
@SW_DISABLE | Disables the window.
@SW_ENABLE | Enables the window.
@SW_HIDE | Hides the window and activates another window.
@SW_LOCK | Lock the window to avoid repainting.
@SW_MAXIMIZE | Activates the window and displays it as a maximized window.
@SW_MINIMIZE | Minimizes the specified window and activates the next top-level window in the Z order.
@SW_RESTORE | Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
@SW_SHOW | Activates the window and displays it in its current size and position.
@SW_SHOWDEFAULT | Sets the show state based on the SW_ value specified by the program that started the application.
@SW_SHOWMAXIMIZED | Activates the window and displays it as a maximized window.
@SW_SHOWMINIMIZED | Activates the window and displays it as a minimized window.
@SW_SHOWMINNOACTIVE | Displays the window as a minimized window. This value is similar to @SW_SHOWMINIMIZED, except the window is not activated.
@SW_SHOWNA | Displays the window in its current size and position. This value is similar to @SW_SHOW, except the window is not activated.
@SW_SHOWNOACTIVATE | Displays a window in its most recent size and position. This value is similar to @SW_SHOWNORMAL, except the window is not activated.
@SW_SHOWNORMAL | Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
@SW_UNLOCK | Unlock window to allow painting.
@SystemDir | Path to the Windows' System (or System32) folder.
@TAB | Tab character, Chr(9)
@TempDir | Path to the temporary files folder.
@TRAY_ID | Last clicked item identifier during a TraySetOnEvent() or TrayItemSetOnEvent() action.
@TrayIconFlashing | Returns 1 if tray icon is flashing; otherwise, returns 0.
@TrayIconVisible | Returns 1 if tray icon is visible; otherwise, returns 0.
@UserName | ID of the currently logged on user.
@UserProfileDir | Path to current user's Profile folder.
@WDAY | Numeric day of week. Range is 1 to 7 which corresponds to Sunday through Saturday.
@WindowsDir | Path to Windows folder
@WorkingDir | Current/active working directory. Only includes a trailing backslash when the script is located in the root of a drive.
@YDAY | Current day of year. Range is 001 to 366 (or 001 to 365 if not a leap year)
@YEAR | Current four-digit year


Macros Reference - AutoIt Related

Macro Reference - AutoIt Related

Below is a list of AutoIt-related macros.

The full list of macros can be found here.

Macro | Description
@Compiled | Returns 1 if script is a compiled executable or an .a3x file; returns 0 if an .au3 file.
@error | Status of the error flag. See the function SetError().
@exitCode | Exit code as set by Exit statement.
@exitMethod | Exit method. See the function OnAutoItExitRegister().
@extended | Extended function return - used in certain functions such as StringReplace().
@NumParams | Number of parameters used in calling the user function.
@ScriptName | Filename of the running script.
@ScriptDir | Directory containing the running script. Only includes a trailing backslash when the script is located in the root of a drive.
@ScriptFullPath | Equivalent to @ScriptDir & "\" & @ScriptName
@ScriptLineNumber | Line number being executed - useful for debug statements (e.g. location of function call). Only significant in uncompiled scripts - note that #include files return their internal line numbering
@WorkingDir | Current/active working directory. Only includes a trailing backslash when the script is located in the root of a drive.
@AutoItExe | The full path and filename of the AutoIt executable currently running. For compiled scripts it is the path of the compiled script; for .a3x and .au3 files it is the path of the interpreter running the file.
@AutoItPID | Process identifier (PID) of the current script.
@AutoItVersion | Version number of AutoIt such as 3.3.10.2
@AutoItX64 | Returns 1 if the script is running under the native x64 version of AutoIt.
@COM_EventObj | Object the COM event is being fired on. Only valid in a COM event function.
@GUI_CtrlId | Last click GUI Control identifier. Only valid in an event Function. See the GUICtrlSetOnEvent() function.
@GUI_CtrlHandle | Last click GUI Control handle. Only valid in an event Function. See the GUICtrlSetOnEvent() function.
@GUI_DragId | Drag GUI Control identifier. Only valid on Drop Event. See the GUISetOnEvent() function.
@GUI_DragFile | Filename of the file being dropped. Only valid on Drop Event. See the GUISetOnEvent() function.
@GUI_DropId | Drop GUI Control identifier. Only valid on Drop Event. See the GUISetOnEvent() function.
@GUI_WinHandle | Last click GUI window handle. Only valid in an event Function. See the GUICtrlSetOnEvent() function.
@HotKeyPressed | Last hotkey pressed. See the HotKeySet() function.
For use with the WinSetState(), Run(), RunWait, FileCreateShortcut() and FileGetShortcut() functions:
@SW_DISABLE | Disables the window.
@SW_ENABLE | Enables the window.
@SW_HIDE | Hides the window and activates another window.
@SW_LOCK | Lock the window to avoid repainting.
@SW_MAXIMIZE | Activates the window and displays it as a maximized window.
@SW_MINIMIZE | Minimizes the specified window and activates the next top-level window in the Z order.
@SW_RESTORE | Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
@SW_SHOW | Activates the window and displays it in its current size and position.
@SW_SHOWDEFAULT | Sets the show state based on the SW_ value specified by the program that started the application.
@SW_SHOWMAXIMIZED | Activates the window and displays it as a maximized window.
@SW_SHOWMINIMIZED | Activates the window and displays it as a minimized window.
@SW_SHOWMINNOACTIVE | Displays the window as a minimized window. This value is similar to @SW_SHOWMINIMIZED, except the window is not activated.
@SW_SHOWNA | Displays the window in its current size and position. This value is similar to @SW_SHOW, except the window is not activated.
@SW_SHOWNOACTIVATE | Displays a window in its most recent size and position. This value is similar to @SW_SHOWNORMAL, except the window is not activated.
@SW_SHOWNORMAL | Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
@SW_UNLOCK | Unlock window to allow painting.
@TRAY_ID | Last clicked item identifier during a TraySetOnEvent() or TrayItemSetOnEvent() action.
@TrayIconFlashing | Returns 1 if tray icon is flashing; otherwise, returns 0.
@TrayIconVisible | Returns 1 if tray icon is visible; otherwise, returns 0.
@CR | Carriage return, Chr(13); occasionally used for line breaks.
@LF | Line feed, Chr(10); occasionally used for line breaks.
@CRLF | @CR & @LF; typically used for line breaks.
@TAB | Tab character, Chr(9)


Macro Reference - Directory

Below is a list of Directory macros. Note that paths do not contain a trailing backslash.

The full list of macros can be found here.

Macro | Description
Macros for "All Users" data.
@AppDataCommonDir | Path to Application Data
@DesktopCommonDir | Path to Desktop
@DocumentsCommonDir | Path to Documents
@FavoritesCommonDir | Path to Favorites
@ProgramsCommonDir | Path to Start Menu's Programs folder
@StartMenuCommonDir | Path to Start Menu folder
@StartupCommonDir | Path to Startup folder

Macros for Current User data.
@AppDataDir | Path to current user's Roaming Application Data
@LocalAppDataDir | Path to current user's Local Application Data
@DesktopDir | Path to current user's Desktop
@MyDocumentsDir | Path to My Documents target
@FavoritesDir | Path to current user's Favorites
@ProgramsDir | Path to current user's Programs (folder on Start Menu)
@StartMenuDir | Path to current user's Start Menu
@StartupDir | current user's Startup folder
@UserProfileDir | Path to current user's Profile folder.

Other macros for the computer system:
@HomeDrive | Drive letter of drive containing current user's home directory.
@HomePath | Directory part of current user's home directory. To get the full path, use in conjunction with @HomeDrive.
@HomeShare | Server and share name containing current user's home directory.
@LogonDNSDomain | Logon DNS Domain.
@LogonDomain | Logon Domain.
@LogonServer | Logon server.
@ProgramFilesDir | Path to Program Files folder
@CommonFilesDir | Path to Common Files folder
@WindowsDir | Path to Windows folder
@SystemDir | Path to the Windows' System (or System32) folder.
@TempDir | Path to the temporary files folder.
@ComSpec Value of %COMSPEC%, the SPECified secondary COMmand interpreter;
primary for command line uses, e.g. Run(@ComSpec & " /k help | more")


Macro Reference - System Info

Below is a list of System information macros.

The full list of macros can be found here.

Macro | Description
@CPUArch | Returns "X86" when the CPU is a 32-bit CPU and "X64" when the CPU is 64-bit.
@KBLayout | Returns code denoting Keyboard Layout. See Appendix for possible values.
@MUILang | Returns code denoting Multi Language if available (Vista is OK by default). See Appendix for possible values.
@OSArch | Returns one of the following: "X86", "IA64", "X64" - this is the architecture type of the currently running operating system.
@OSLang | Returns code denoting OS Language. See Appendix for possible values.
@OSType | Returns "WIN32_NT" for XP/2003/Vista/2008/Win7/2008R2/Win8/2012/Win8.1/2012R2.
@OSVersion | Returns one of the following: "WIN_10", "WIN_81", "WIN_8", "WIN_7", "WIN_VISTA", "WIN_XP", "WIN_XPe", for Windows servers: "WIN_2016", "WIN_2012R2", "WIN_2012", "WIN_2008R2", "WIN_2008", "WIN_2003"".
@OSBuild | Returns the OS build number. For example, Windows 2003 Server returns 3790
@OSServicePack | Service pack info in the form of "Service Pack 3".
@ComputerName | Computer's network name.
@UserName | ID of the currently logged on user.
@IPAddress1 | IP address of first network adapter. Tends to return 127.0.0.1 on some computers.
@IPAddress2 | IP address of second network adapter. Returns 0.0.0.0 if not applicable.
@IPAddress3 | IP address of third network adapter. Returns 0.0.0.0 if not applicable.
@IPAddress4 | IP address of fourth network adapter. Returns 0.0.0.0 if not applicable.
@DesktopHeight | Height of the primary display in pixels. (Vertical resolution)
@DesktopWidth | Width of the primary display in pixels. (Horizontal resolution)
@DesktopDepth | Depth of the primary display in bits per pixel.
@DesktopRefresh | Refresh rate of the primary display in hertz.


Macro Reference - Time And Date

Below is a list of Time and Date macros. Notice that most return values are two-digits long.

The full list of macros can be found here.

Macro | Description
@MSEC | Milliseconds value of clock. Range is 000 to 999. The update frequency of this value depends on the timer resolution of the hardware and may not update every millisecond.
@SEC | Seconds value of clock. Range is 00 to 59
@MIN | Minutes value of clock. Range is 00 to 59
@HOUR | Hours value of clock in 24-hour format. Range is 00 to 23
@MDAY | Current day of month. Range is 01 to 31
@MON | Current month. Range is 01 to 12
@YEAR | Current four-digit year
@WDAY | Numeric day of week. Range is 1 to 7 which corresponds to Sunday through Saturday.
@YDAY | Current day of year. Range is 001 to 366 (or 001 to 365 if not a leap year)


Functions

Function Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

See Function Notes for details on usage.

Function | Description
Abs | Calculates the absolute value of a number.
ACos | Calculates the arcCosine of a number.
AdlibRegister | Registers an Adlib function.
AdlibUnRegister | Unregisters an adlib function.
Asc | Returns the ASCII code of a character.
AscW | Returns the unicode code of a character.
ASin | Calculates the arcsine of a number.
Assign | Assigns a variable by name with the data.
ATan | Calculates the arctangent of a number.
AutoItSetOption | Changes the operation of various AutoIt functions/parameters.
AutoItWinGetTitle | Retrieves the title of the AutoIt window.
AutoItWinSetTitle | Changes the title of the AutoIt window.
Beep | Plays back a beep to the user.
Binary | Returns the binary representation of an expression.
BinaryLen | Returns the number of bytes in a binary variant.
BinaryMid | Extracts a number of bytes from a binary variant.
BinaryToString | Converts a binary variant into a string.
BitAND | Performs a bitwise AND operation.
BitNOT | Performs a bitwise NOT operation.
BitOR | Performs a bitwise OR operation.
BitRotate | Performs a bit shifting operation, with rotation.
BitShift | Performs a bit shifting operation.
BitXOR | Performs a bitwise exclusive OR (XOR) operation.
BlockInput | Disable/enable the mouse and keyboard.
Break | Enables or disables the users' ability to exit a script from the tray icon menu.
Call | Calls a user-defined or built-in function contained in first parameter.
CDTray | Opens or closes the CD tray.
Ceiling | Returns a number rounded up to the next integer.
Chr | Returns a character corresponding to an ASCII code.
ChrW | Returns a character corresponding to a unicode code.
ClipGet | Retrieves text from the clipboard.
ClipPut | Writes text to the clipboard.
ConsoleRead | Read from the STDIN stream of the AutoIt script process.
ConsoleWrite | Writes data to the STDOUT stream. Some text editors can read this stream as can other programs which may be expecting data on this stream.
ConsoleWriteError | Writes data to the STDERR stream. Some text editors can read this stream as can other programs which may be expecting data on this stream.
ControlClick | Sends a mouse click command to a given control.
ControlCommand | Sends a command to a control.
ControlDisable | Disables or "grays-out" a control.
ControlEnable | Enables a "grayed-out" control.
ControlFocus | Sets input focus to a given control on a window.
ControlGetFocus | Returns the ControlRef# of the control that has keyboard focus within a specified window.
ControlGetHandle | Retrieves the internal handle of a control.
ControlGetPos | Retrieves the position and size of a control relative to its window.
ControlGetText | Retrieves text from a control.
ControlHide | Hides a control.
ControlListView | Sends a command to a ListView32 control.
ControlMove | Moves a control within a window.
ControlSend | Sends a string of characters to a control.
ControlSetText | Sets text of a control.
ControlShow | Shows a control that was hidden.
ControlTreeView | Sends a command to a TreeView32 control.
Cos | Calculates the cosine of a number.
Dec | Returns a numeric representation of a hexadecimal string.
DirCopy | Copies a directory and all sub-directories and files (Similar to xcopy).
DirCreate | Creates a directory/folder.
DirGetSize | Returns the size in bytes of a given directory.
DirMove | Moves a directory and all sub-directories and files.
DirRemove | Deletes a directory/folder.
DllCall | Dynamically calls a function in a DLL.
DllCallAddress | Dynamically calls a function at a specific memory address.
DllCallbackFree | Frees a previously created handle created with DllCallbackRegister.
DllCallbackGetPtr | Returns the pointer to a callback function that can be passed to the Win32 API.
DllCallbackRegister | Creates a user-defined DLL Callback function.
DllClose | Closes a previously opened DLL.
DllOpen | Opens a DLL file for use in DllCall.
DllStructCreate | Creates a C/C++ style structure to be used in DllCall.
DllStructGetData | Returns the data of an element of the struct.
DllStructGetPtr | Returns the pointer to the struct or an element in the struct.
DllStructGetSize | Returns the size of the struct in bytes.
DllStructSetData | Sets the data of an element in the struct.
DriveGetDrive | Returns an array containing the enumerated drives.
DriveGetFileSystem | Returns File System Type of a drive.
DriveGetLabel | Returns Volume Label of a drive, if it has one.
DriveGetSerial | Returns Serial Number of a drive.
DriveGetType | Returns drive type.
DriveMapAdd | Maps a network drive.
DriveMapDel | Disconnects a network drive.
DriveMapGet | Retrieves the details of a mapped drive.
DriveSetLabel | Sets the Volume Label of a drive.
DriveSpaceFree | Returns the free disk space of a path in Megabytes.
DriveSpaceTotal | Returns the total disk space of a path in Megabytes.
DriveStatus | Returns the status of the drive as a string.
EnvGet | Retrieves an environment variable.
EnvSet | Writes an environment variable.
EnvUpdate | Refreshes the OS environment.
Eval | Return the value of the variable defined by a string.
Execute | Execute an expression.
Exp | Calculates e to the power of a number.
FileChangeDir | Changes the current working directory.
FileClose | Closes a previously opened file.
FileCopy | Copies one or more files.
FileCreateNTFSLink | Creates an NTFS hardlink to a file or a directory.
FileCreateShortcut | Creates a shortcut (.lnk) to a file.
FileDelete | Delete one or more files.
FileExists | Checks if a file or directory exists.
FileFindFirstFile | Creates a search handle, defined by a path and file mask.
FileFindNextFile | Returns the next filename defined by the search handle.
FileFlush | Flushes the file's buffer to disk.
FileGetAttrib | Returns a code string representing a file's attributes.
FileGetEncoding | Determines the text encoding used in a file.
FileGetLongName | Returns the long path+name of the path+name passed.
FileGetPos | Retrieves the current file position.
FileGetShortcut | Retrieves details about a shortcut.
FileGetShortName | Returns the 8.3 short path+name of the path+name passed.
FileGetSize | Returns the size of a file in bytes.
FileGetTime | Returns the time and date information for a file.
FileGetVersion | Returns version information stored in a file.
FileInstall | Include and install a file with the compiled script.
FileMove | Moves one or more files.
FileOpen | Opens a file for reading or writing.
FileOpenDialog | Initiates a Open File Dialog.
FileRead | Read in a number of characters from a previously opened file.
FileReadLine | Read in a line of text from a previously opened text file.
FileReadToArray | Reads the specified file into an array.
FileRecycle | Sends a file or directory to the recycle bin.
FileRecycleEmpty | Empties the recycle bin.
FileSaveDialog | Initiates a Save File Dialog.
FileSelectFolder | Initiates a Browse For Folder dialog.
FileSetAttrib | Sets the attributes of one or more files/directories.
FileSetEnd | Sets the end of the file at the current file position.
FileSetPos | Sets the current file position.
FileSetTime | Sets the timestamp of one of more files.
FileWrite | Write text/data to the end of a previously opened file.
FileWriteLine | Append a line of text to the end of a previously opened text file.
Floor | Returns a number rounded down to the closest integer.
FtpSetProxy | Sets the internet proxy to use for ftp access.
FuncName | Returns the name of a function stored in a variable.
GUICreate | Create a GUI window.
GUICtrlCreateAvi | Creates an AVI video control for the GUI.
GUICtrlCreateButton | Creates a Button control for the GUI.
GUICtrlCreateCheckbox | Creates a Checkbox control for the GUI.
GUICtrlCreateCombo | Creates a ComboBox control for the GUI.
GUICtrlCreateContextMenu | Creates a context menu for a control or entire GUI window.
GUICtrlCreateDate | Creates a date control for the GUI.
GUICtrlCreateDummy | Creates a Dummy control for the GUI.
GUICtrlCreateEdit | Creates an Edit control for the GUI.
GUICtrlCreateGraphic | Creates a Graphic control for the GUI.
GUICtrlCreateGroup | Creates a Group control for the GUI.
GUICtrlCreateIcon | Creates an Icon control for the GUI.
GUICtrlCreateInput | Creates an Input control for the GUI.
GUICtrlCreateLabel | Creates a static Label control for the GUI.
GUICtrlCreateList | Creates a List control for the GUI.
GUICtrlCreateListView | Creates a ListView control for the GUI.
GUICtrlCreateListViewItem | Creates a ListView item.
GUICtrlCreateMenu | Creates a Menu control for the GUI.
GUICtrlCreateMenuItem | Creates a MenuItem control for the GUI.
GUICtrlCreateMonthCal | Creates a month calendar control for the GUI.
GUICtrlCreateObj | Creates an ActiveX control in the GUI.
GUICtrlCreatePic | Creates a Picture control for the GUI.
GUICtrlCreateProgress | Creates a Progress control for the GUI.
GUICtrlCreateRadio | Creates a Radio button control for the GUI.
GUICtrlCreateSlider | Creates a Slider control for the GUI.
GUICtrlCreateTab | Creates a Tab control for the GUI.
GUICtrlCreateTabItem | Creates a TabItem control within an existing tab control in the GUI.
GUICtrlCreateTreeView | Creates a TreeView control for the GUI.
GUICtrlCreateTreeViewItem | Creates a TreeViewItem control for the GUI.
GUICtrlCreateUpdown | Creates an UpDown control for the GUI.
GUICtrlDelete | Deletes a control.
GUICtrlGetHandle | Returns the handle for a control and some special (item) handles (Menu, ContextMenu, TreeViewItem).
GUICtrlGetState | Gets the current state of a control.
GUICtrlRead | Read state or data of a control.
GUICtrlRecvMsg | Send a message to a control and retrieve information in lParam.
GUICtrlRegisterListViewSort | Register a user defined function for an internal listview sorting callback function.
GUICtrlSendMsg | Send a message to a control.
GUICtrlSendToDummy | Sends a message to a Dummy control.
GUICtrlSetBkColor | Sets the background color of a control.
GUICtrlSetColor | Sets the text color of a control.
GUICtrlSetCursor | Sets the mouse cursor icon for a particular control.
GUICtrlSetData | Modifies the data for a control.
GUICtrlSetDefBkColor | Sets the default background color of all the controls of the GUI window.
GUICtrlSetDefColor | Sets the default text color of all the controls of the GUI window.
GUICtrlSetFont | Sets the font for a control.
GUICtrlSetGraphic | Modifies the data for a control.
GUICtrlSetImage | Sets the bitmap or icon image to use for a control.
GUICtrlSetLimit | Limits the number of characters/pixels for a control.
GUICtrlSetOnEvent | Defines a user-defined function to be called when a control is clicked.
GUICtrlSetPos | Changes the position of a control within the GUI window.
GUICtrlSetResizing | Defines the resizing method used by a control.
GUICtrlSetState | Changes the state of a control.
GUICtrlSetStyle | Changes the style of a control.
GUICtrlSetTip | Sets the tip text associated with a control.
GUIDelete | Deletes a GUI window and all controls that it contains.
GUIGetCursorInfo | Gets the mouse cursor position relative to GUI window.
GUIGetMsg | Polls the GUI to see if any events have occurred.
GUIGetStyle | Retrieves the styles of a GUI window.
GUIRegisterMsg | Register a user defined function for a known Windows Message ID (WM_MSG).
GUISetAccelerators | Sets the accelerator table to be used in a GUI window.
GUISetBkColor | Sets the background color of the GUI window.
GUISetCoord | Sets absolute coordinates for the next control.
GUISetCursor | Sets the mouse cursor icon for a GUI window.
GUISetFont | Sets the default font for a GUI window.
GUISetHelp | Sets an executable file that will be run when F1 is pressed.
GUISetIcon | Sets the icon used in a GUI window.
GUISetOnEvent | Defines a user function to be called when a system button is clicked.
GUISetState | Changes the state of a GUI window.
GUISetStyle | Changes the styles of a GUI window.
GUIStartGroup | Defines that any subsequent controls that are created will be "grouped" together.
GUISwitch | Switches the current window used for GUI functions.
Hex | Returns a string representation of an integer or of a binary type converted to hexadecimal.
HotKeySet | Sets a hotkey that calls a user function.
HttpSetProxy | Sets the internet proxy to use for http access.
HttpSetUserAgent | Sets the HTTP user-agent string which is sent with all Inet requests.
HWnd | Converts an expression into an HWND handle.
InetClose | Closes a handle returned from InetGet().
InetGet | Downloads a file from the internet using the HTTP, HTTPS or FTP protocol.
InetGetInfo | Returns detailed data for a handle returned from InetGet().
InetGetSize | Returns the size (in bytes) of a file located on the internet.
InetRead | Downloads a file from the internet using the HTTP, HTTPS or FTP protocol.
IniDelete | Deletes a value from a standard format .ini file.
IniRead | Reads a value from a standard format .ini file.
IniReadSection | Reads all key/value pairs from a section in a standard format .ini file.
IniReadSectionNames | Reads all sections in a standard format .ini file.
IniRenameSection | Renames a section in a standard format .ini file.
IniWrite | Writes a value to a standard format .ini file.
IniWriteSection | Writes a section to a standard format .ini file.
InputBox | Displays an input box to ask the user to enter a string.
Int | Returns the integer (whole number) representation of an expression.
IsAdmin | Checks if the current user has full administrator privileges.
IsArray | Checks if a variable is an array type.
IsBinary | Checks if a variable or expression is a binary type.
IsBool | Checks if a variable's base type is boolean.
IsDeclared | Check if a variable has been declared.
IsDllStruct | Checks if a variable is a DllStruct type.
IsFloat | Checks if the value of a variable or expression has a fractional component.
IsFunc | Checks if a variable or expression is a function type.
IsHWnd | Checks if a variable's base type is a pointer and window handle.
IsInt | Checks if the value of a variable or expression has no fractional component.
IsKeyword | Checks if a variable is a keyword (for example, Default).
IsNumber | Checks if a variable's base type is numeric.
IsObj | Checks if a variable or expression is an object type.
IsPtr | Checks if a variable's base type is a pointer.
IsString | Checks if a variable is a string type.
Log | Calculates the natural logarithm of a number.
MemGetStats | Retrieves memory related information.
Mod | Performs the modulus operation.
MouseClick | Perform a mouse click operation.
MouseClickDrag | Perform a mouse click and drag operation.
MouseDown | Perform a mouse down event at the current mouse position.
MouseGetCursor | Returns the cursor ID Number for the current Mouse Cursor.
MouseGetPos | Retrieves the current position of the mouse cursor.
MouseMove | Moves the mouse pointer.
MouseUp | Perform a mouse up event at the current mouse position.
MouseWheel | Moves the mouse wheel up or down.
MsgBox | Displays a simple message box with optional timeout.
Number | Returns the numeric representation of an expression.
ObjCreate | Creates a reference to a COM object from the given classname.
ObjCreateInterface | Creates a reference to an object from the given classname/object pointer, interface identifier and description string.
ObjEvent | Handles incoming events from the given Object.
ObjGet | Retrieves a reference to a COM object from an existing process or filename.
ObjName | Returns the name or interface description of an Object.
OnAutoItExitRegister | Registers a function to be called when AutoIt exits.
OnAutoItExitUnRegister | UnRegisters a function that was called when AutoIt exits.
Ping | Pings a host and returns the roundtrip-time.
PixelChecksum | Generates a checksum for a region of pixels.
PixelGetColor | Returns a pixel color according to x,y pixel coordinates.
PixelSearch | Searches a rectangle of pixels for the pixel color provided.
ProcessClose | Terminates a named process.
ProcessExists | Checks to see if a specified process exists.
ProcessGetStats | Returns an array about Memory or IO infos of a running process.
ProcessList | Returns an array listing the currently running processes (names and PIDs).
ProcessSetPriority | Changes the priority of a process.
ProcessWait | Pauses script execution until a given process exists.
ProcessWaitClose | Pauses script execution until a given process does not exist.
ProgressOff | Turns Progress window off.
ProgressOn | Creates a customizable progress bar window.
ProgressSet | Sets the position and/or text of a previously created Progress bar window.
Ptr | Converts an expression into a pointer variant.
Random | Generates a pseudo-random float-type number.
RegDelete | Deletes a key or value from the registry.
RegEnumKey | Reads the name of a subkey according to its instance.
RegEnumVal | Reads the name of a value according to its instance.
RegRead | Reads a value from the registry.
RegWrite | Creates a key or value in the registry.
Round | Returns a number rounded to a specified number of decimal places.
Run | Runs an external program.
RunAs | Runs an external program under the context of a different user.
RunAsWait | Runs an external program under the context of a different user and pauses script execution until the program finishes.
RunWait | Runs an external program and pauses script execution until the program finishes.
Send | Sends simulated keystrokes to the active window.
SendKeepActive | Attempts to keep a specified window active during Send().
SetError | Manually set the value of the @error macro (and optionally @extended, and "Return Value").
SetExtended | Manually set the value of the @extended macro.
ShellExecute | Runs an external program using the ShellExecute API.
ShellExecuteWait | Runs an external program using the ShellExecute API and pauses script execution until it finishes.
Shutdown | Shuts down the system.
Sin | Calculates the sine of a number.
Sleep | Pause script execution.
SoundPlay | Play a sound file.
SoundSetWaveVolume | Sets the system wave volume by percent.
SplashImageOn | Creates a customizable image popup window.
SplashOff | Turns SplashText or SplashImage off.
SplashTextOn | Creates a customizable text popup window.
Sqrt | Calculates the square-root of a number.
SRandom | Set Seed for random number generation.
StatusbarGetText | Retrieves the text from a standard status bar control.
StderrRead | Reads from the STDERR stream of a previously run child process.
StdinWrite | Writes a number of characters to the STDIN stream of a previously run child process.
StdioClose | Closes all resources associated with a process previously run with STDIO redirection.
StdoutRead | Reads from the STDOUT stream of a previously run child process.
String | Returns the string representation of an expression.
StringAddCR | Takes a string and prefixes all linefeed characters ( Chr(10) ) with a carriage return character ( Chr(13) ).
StringCompare | Compares two strings with options.
StringFormat | Returns a formatted string (similar to the C sprintf() function).
StringFromASCIIArray | Converts an array of ASCII codes to a string.
StringInStr | Checks if a string contains a given substring.
StringIsAlNum | Checks if a string contains only alphanumeric characters.
StringIsAlpha | Checks if a string contains only alphabetic characters.
StringIsASCII | Checks if a string contains only ASCII characters in the range 0x00 - 0x7f (0 - 127).
StringIsDigit | Checks if a string contains only digit (0-9) characters.
StringIsFloat | Checks if a string is a floating point number.
StringIsInt | Checks if a string is an integer.
StringIsLower | Checks if a string contains only lowercase characters.
StringIsSpace | Checks if a string contains only whitespace characters.
StringIsUpper | Checks if a string contains only uppercase characters.
StringIsXDigit | Checks if a string contains only hexadecimal digit (0-9, A-F) characters.
StringLeft | Returns a number of characters from the left-hand side of a string.
StringLen | Returns the number of characters in a string.
StringLower | Converts a string to lowercase.
StringMid | Extracts a number of characters from a string.
StringRegExp | Check if a string fits a given regular expression pattern.
StringRegExpReplace | Replace text in a string based on regular expressions.
StringReplace | Replaces substrings in a string.
StringReverse | Reverses the contents of the specified string.
StringRight | Returns a number of characters from the right-hand side of a string.
StringSplit | Splits up a string into substrings depending on the given delimiters.
StringStripCR | Removes all carriage return values ( Chr(13) ) from a string.
StringStripWS | Strips the white space in a string.
StringToASCIIArray | Converts a string to an array containing the ASCII code of each character.
StringToBinary | Converts a string into binary data.
StringTrimLeft | Trims a number of characters from the left hand side of a string.
StringTrimRight | Trims a number of characters from the right hand side of a string.
StringUpper | Converts a string to uppercase.
Tan | Calculates the tangent of a number.
TCPAccept | Permits an incoming connection attempt on a socket.
TCPCloseSocket | Closes a TCP socket.
TCPConnect | Create a socket connected to an existing server.
TCPListen | Creates a socket listening for an incoming connection.
TCPNameToIP | Converts an Internet name to IP address.
TCPRecv | Receives data from a connected socket.
TCPSend | Sends data on a connected socket.
TCPShutdown, UDPShutdown | Stops TCP/UDP services.
TCPStartup, UDPStartup | Starts TCP or UDP services.
TimerDiff | Returns the difference in time from a previous call to TimerInit().
TimerInit | Returns a handle that can be passed to TimerDiff() to calculate the difference in milliseconds.
ToolTip | Creates a tooltip anywhere on the screen.
TrayCreateItem | Creates a menuitem control for the tray.
TrayCreateMenu | Creates a menu control for the tray menu.
TrayGetMsg | Polls the tray to see if any events have occurred.
TrayItemDelete | Deletes a menu/item control from the tray menu.
TrayItemGetHandle | Returns the handle for a tray menu(item).
TrayItemGetState | Gets the current state of a control.
TrayItemGetText | Gets the itemtext of a tray menu/item control.
TrayItemSetOnEvent | Defines a user-defined function to be called when a tray item is clicked.
TrayItemSetState | Sets the state of a tray menu/item control.
TrayItemSetText | Sets the itemtext of a tray menu/item control.
TraySetClick | Sets the clickmode of the tray icon - what mouseclicks will display the tray menu.
TraySetIcon | Loads/Sets a specified tray icon.
TraySetOnEvent | Defines a user function to be called when a special tray action happens.
TraySetPauseIcon | Loads/Sets a specified tray pause icon.
TraySetState | Sets the state of the tray icon.
TraySetToolTip | (Re)Sets the tooltip text for the tray icon.
TrayTip | Displays a balloon tip from the AutoIt Icon.
UBound | Returns the size of array dimensions or the number of keys in a map.
UDPBind | Create a socket bound to an incoming connection.
UDPCloseSocket | Close a UDP socket.
UDPOpen | Open a socket connected to an existing server .
UDPRecv | Receives data from an opened socket.
UDPSend | Sends data on an opened socket.
VarGetType | Returns the internal type representation of a variant.
WinActivate | Activates (gives focus to) a window.
WinActive | Checks to see if a specified window exists and is currently active.
WinClose | Closes a window.
WinExists | Checks to see if a specified window exists.
WinFlash | Flashes a window in the taskbar.
WinGetCaretPos | Returns the coordinates of the caret in the foreground window.
WinGetClassList | Retrieves the classes from a window.
WinGetClientSize | Retrieves the size of a given window's client area.
WinGetHandle | Retrieves the internal handle of a window.
WinGetPos | Retrieves the position and size of a given window.
WinGetProcess | Retrieves the Process ID (PID) associated with a window.
WinGetState | Retrieves the state of a given window.
WinGetText | Retrieves the text from a window.
WinGetTitle | Retrieves the full title from a window.
WinKill | Forces a window to close.
WinList | Retrieves a list of windows.
WinMenuSelectItem | Invokes a menu item of a window.
WinMinimizeAll | Minimizes all windows.
WinMinimizeAllUndo | Undoes a previous WinMinimizeAll function.
WinMove | Moves and/or resizes a window.
WinSetOnTop | Change a window's "Always On Top" attribute.
WinSetState | Shows, hides, minimizes, maximizes, or restores a window.
WinSetTitle | Changes the title of a window.
WinSetTrans | Sets the transparency of a window.
WinWait | Pauses execution of the script until the requested window exists.
WinWaitActive | Pauses execution of the script until the requested window is active.
WinWaitClose | Pauses execution of the script until the requested window does not exist.
WinWaitNotActive | Pauses execution of the script until the requested window is not active.


Function Notes

Functions in AutoIt are first class objects. Among other things, that means you can assign a function to a variable, pass it around as an argument or return from another function.
Aside from certain specific scope-regarding declaration rules (being that the names of the built-in functions are reserved and of UDFs' can be overwritten only locally), the names of functions do not have special status in the language.

#include <MsgBoxConstants.au3>

Local $vFunc = MsgBox

$vFunc($MB_OK, "Hi there!", "Lovely day today.")

Many functions contain optional parameters that can be omitted. If you wish to specify an optional parameter, however, all preceding parameters must be specified!
For example, consider Run ( "filename", ["workingdir" [, flag]] ). If you wish to specify the flag, you must specify a workingdir.

Many Win___ functions contain an optional parameter "text". This parameter is intended to help differentiate between windows that have identical titles.

Some functions indicate success/failure as a return value, others indicate it by setting the @error flag. Some do both....
@error = 0 ;is always success
Return = varies, but is typically non-zero for success to allow easy to read code...

If SomeUserFunc() Then ;...function worked.
If Not SomeUserFunc() Then ;...function failed.

Local $sFileRead = FileReadLine ("C:\someFile.txt")
If @error = - 1 Then ; End-of-file was reached.

If a function can set the @error flag, you should always check it before using a return value - if @error indicates an error then the function return value is generally undefined...

@error is always set to 0 when entering in a function.

When the documentation states that the return value = none, AutoIt always returns a value to avoid errors. 1 is usually the value returned, but you should not depend on this return value.

When an optional parameter needs to be defined and is preceded by one or more optional parameters, the default value must be given for that parameter. Generally speaking functions should accept the Default keyword when you wish to use the default parameter. See the corresponding optional parameter description for more details.


Functions

Environment functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
ClipGet | Retrieves text from the clipboard.
ClipPut | Writes text to the clipboard.
EnvGet | Retrieves an environment variable.
EnvSet | Writes an environment variable.
EnvUpdate | Refreshes the OS environment.
MemGetStats | Retrieves memory related information.


Function ClipGet

Function Reference

ClipGet

Retrieves text from the clipboard.

ClipGet ( )

Return Value

Success: | a string containing the text on the clipboard.
Failure: | sets the @error to non-zero.
@error: | 1 = if clipboard is empty 2 = if contains a non-text entry. 3 or 4 = if cannot access the clipboard.

Remarks

When multiple selecting file/dir are stored in the clipboard, the filename/dirname are returned as texts separated by @LF.

Related

ClipPut

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Retrieve the data stored in the clipboard.
    Local $sData = ClipGet()

    ; Display the data returned by ClipGet.
    MsgBox($MB_SYSTEMMODAL, "", "The following data is stored in the clipboard: " & @CRLF & $sData)

    ; Add new data to the clipboard.
    ClipPut("A new string added to the clipboard.")

    ; Retrieve the data stored in the clipboard.
    $sData = ClipGet()

    ; Display the data returned by ClipGet.
    MsgBox($MB_SYSTEMMODAL, "", "The following data is now stored in the clipboard: " & @CRLF & $sData)
EndFunc   ;==>Example


Function ClipPut

Function Reference

ClipPut

Writes text to the clipboard.

ClipPut ( "value" )

Parameters

value The text to write to the clipboard.

Return Value

Success: | 1.
Failure: | 0.

Remarks

Any existing clipboard contents are overwritten.
An empty string "" will empty the clipboard.

Related

ClipGet

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Retrieve the data stored in the clipboard.
    Local $sData = ClipGet()

    ; Display the data returned by ClipGet.
    MsgBox($MB_SYSTEMMODAL, "", "The following data is stored in the clipboard: " & @CRLF & $sData)

    ; Add new data to the clipboard.
    ClipPut("A new string added to the clipboard.")

    ; Retrieve the data stored in the clipboard.
    $sData = ClipGet()

    ; Display the data returned by ClipGet.
    MsgBox($MB_SYSTEMMODAL, "", "The following data is now stored in the clipboard: " & @CRLF & $sData)
EndFunc   ;==>Example


Function EnvGet

Function Reference

EnvGet

Retrieves an environment variable.

EnvGet ( "envvariable" )

Parameters

envvariable Name of the environment variable to get such as "TEMP" or "PATH".

Return Value

Returns the requested variable (or an empty string if the variable does not exist).

Related

EnvSet, EnvUpdate

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Retrieve the value of the environment variable %APPDATA%.
    ; When you assign or retrieve an envorinment variable you do so minus the percentage signs (%).
    Local $sEnvVar = EnvGet("APPDATA")

    ; Display the value of the environment variable %APPDATA%.
    MsgBox($MB_SYSTEMMODAL, "", "The environment variable %APPDATA% has the value of: " & @CRLF & @CRLF & $sEnvVar) ; This returns the same value as the macro @AppDataDir does.
EndFunc   ;==>Example


Function EnvSet

Function Reference

EnvSet

Writes an environment variable.

EnvSet ( "envvariable" [, "value"] )

Parameters

envvariable | Name of the environment variable to set.
value | [optional] Value to set the environment variable to. If a value is not used the environment variable will be deleted.

Return Value

Success: | not 0.
Failure: | 0.

Remarks

A environment variable set in this way will only be accessible to programs that AutoIt spawns (Run(), RunWait()). Once AutoIt closes, the variables will cease to exist.

Related

EnvGet, EnvUpdate

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create an environment variable called %MYVAR% and assign it a value. When you assign or retrieve an environment variable you do so minus the percentage signs (%).
    EnvSet("MYVAR", "This is some text!")

    ; Retrieve the environment variable that was just assigned a value previously.
    Local $sEnvVar = EnvGet("MYVAR")

    ; Display the value of the environment variable $MYVAR%.
    MsgBox($MB_SYSTEMMODAL, "", "The environment variable %MYVAR% has the value of: " & @CRLF & @CRLF & $sEnvVar)
EndFunc   ;==>Example


Function EnvUpdate

Function Reference

EnvUpdate

Refreshes the OS environment.

EnvUpdate ( )

Return Value

Success: | none.
Failure: | sets the @error flag to 1.

Remarks

Similar effect as logging off and then on again. For example, changes to the %path% environment might not take effect until you call EnvUpdate() (or you logoff/reboot).

Related

EnvGet, EnvSet

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Retrieve the system environment variable called %PATH%.
    Local $sEnvVar = EnvGet("PATH")

    ; Assign the system environment variable called %PATH% with its current value as well as the script directory.
    ; When you assign an environment variable you do so minus the percentage signs (%).
    EnvSet("PATH", $sEnvVar & ";" & @ScriptDir)

    ; Refresh the OS environment for changes to take affect.
    EnvUpdate()

    ; Retrieve the system environment variable that was just assigned a value previously.
    $sEnvVar = EnvGet("PATH")

    ; Display the value of the environment variable $PATH%.
    MsgBox($MB_SYSTEMMODAL, "", "The environment variable %PATH% has the value of: " & $sEnvVar)
EndFunc   ;==>Example


Function MemGetStats

Function Reference

MemGetStats

Retrieves memory related information.

MemGetStats ( )

Return Value

Returns a seven-element array containing the memory information:
$aArray[0] = Memory Load (Percentage of memory in use)
$aArray[1] = Total physical RAM
$aArray[2] = Available physical RAM
$aArray[3] = Total Pagefile
$aArray[4] = Available Pagefile
$aArray[5] = Total virtual
$aArray[6] = Available virtual

All memory sizes are in kilobytes.

Example

#include <MsgBoxConstants.au3>

Local $aMem = MemGetStats()
MsgBox($MB_SYSTEMMODAL, "", "Total physical RAM (KB): " & $aMem[1])


Functions

File, Directory and Disk functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
ConsoleRead | Read from the STDIN stream of the AutoIt script process.
ConsoleWrite | Writes data to the STDOUT stream. Some text editors can read this stream as can other programs which may be expecting data on this stream.
ConsoleWriteError | Writes data to the STDERR stream. Some text editors can read this stream as can other programs which may be expecting data on this stream.
DirCopy | Copies a directory and all sub-directories and files (Similar to xcopy).
DirCreate | Creates a directory/folder.
DirGetSize | Returns the size in bytes of a given directory.
DirMove | Moves a directory and all sub-directories and files.
DirRemove | Deletes a directory/folder.
DriveGetDrive | Returns an array containing the enumerated drives.
DriveGetFileSystem | Returns File System Type of a drive.
DriveGetLabel | Returns Volume Label of a drive, if it has one.
DriveGetSerial | Returns Serial Number of a drive.
DriveGetType | Returns drive type.
DriveMapAdd | Maps a network drive.
DriveMapDel | Disconnects a network drive.
DriveMapGet | Retrieves the details of a mapped drive.
DriveSetLabel | Sets the Volume Label of a drive.
DriveSpaceFree | Returns the free disk space of a path in Megabytes.
DriveSpaceTotal | Returns the total disk space of a path in Megabytes.
DriveStatus | Returns the status of the drive as a string.
FileChangeDir | Changes the current working directory.
FileClose | Closes a previously opened file.
FileCopy | Copies one or more files.
FileCreateNTFSLink | Creates an NTFS hardlink to a file or a directory.
FileCreateShortcut | Creates a shortcut (.lnk) to a file.
FileDelete | Delete one or more files.
FileExists | Checks if a file or directory exists.
FileFindFirstFile | Creates a search handle, defined by a path and file mask.
FileFindNextFile | Returns the next filename defined by the search handle.
FileFlush | Flushes the file's buffer to disk.
FileGetAttrib | Returns a code string representing a file's attributes.
FileGetEncoding | Determines the text encoding used in a file.
FileGetLongName | Returns the long path+name of the path+name passed.
FileGetPos | Retrieves the current file position.
FileGetShortcut | Retrieves details about a shortcut.
FileGetShortName | Returns the 8.3 short path+name of the path+name passed.
FileGetSize | Returns the size of a file in bytes.
FileGetTime | Returns the time and date information for a file.
FileGetVersion | Returns version information stored in a file.
FileInstall | Include and install a file with the compiled script.
FileMove | Moves one or more files.
FileOpen | Opens a file for reading or writing.
FileOpenDialog | Initiates a Open File Dialog.
FileRead | Read in a number of characters from a previously opened file.
FileReadLine | Read in a line of text from a previously opened text file.
FileReadToArray | Reads the specified file into an array.
FileRecycle | Sends a file or directory to the recycle bin.
FileRecycleEmpty | Empties the recycle bin.
FileSaveDialog | Initiates a Save File Dialog.
FileSelectFolder | Initiates a Browse For Folder dialog.
FileSetAttrib | Sets the attributes of one or more files/directories.
FileSetEnd | Sets the end of the file at the current file position.
FileSetPos | Sets the current file position.
FileSetTime | Sets the timestamp of one of more files.
FileWrite | Write text/data to the end of a previously opened file.
FileWriteLine | Append a line of text to the end of a previously opened text file.
IniDelete | Deletes a value from a standard format .ini file.
IniRead | Reads a value from a standard format .ini file.
IniReadSection | Reads all key/value pairs from a section in a standard format .ini file.
IniReadSectionNames | Reads all sections in a standard format .ini file.
IniRenameSection | Renames a section in a standard format .ini file.
IniWrite | Writes a value to a standard format .ini file.
IniWriteSection | Writes a section to a standard format .ini file.


Function ConsoleRead

Function Reference

ConsoleRead

Read from the STDIN stream of the AutoIt script process.

ConsoleRead ( [peek = False [, binary = False]] )

Parameters

peek | [optional] If True the function does not remove the read characters from the stream.
binary | [optional] If True the function reads the data as binary instead of text (default is text).

Return Value

Success: | the data read. @extended contains the number of bytes read.
Failure: | sets the @error flag to non-zero if EOF is reached, STDIN is not connected for the process or other error.

Remarks

ConsoleRead() reads from the console standard input stream of the AutoIt script process, which is normally used by console applications to read input from a parent process.
ConsoleRead() does not block, it will return immediately. In order to get all data, it must be called in a loop.
Peeking on the stream does not remove the data from the buffer, however, it does return the available data as normal.
By default, data is returned in text format. By using the binary option, the data will be returned in binary format.

Related

ConsoleWrite, ConsoleWriteError, Run

Example

#include <MsgBoxConstants.au3>

#cs
    Compile this script to "ConsoleRead.exe".
    Open a command prompt to the directory where ConsoleRead.exe resides.
    Type the following on the command line:
    echo Hello! | ConsoleRead.exe

    When invoked in a console window, the above command echos the text "Hello!"
    but instead of displaying it, the | tells the console to pipe it to the STDIN stream
    of the ConsoleRead.exe process.
#ce

Example()

Func Example()
    If Not @Compiled Then
        MsgBox($MB_SYSTEMMODAL, "", "This script must be compiled in order to run the example.")
        Exit
    EndIf

    Local $sOutput
    While True
        $sOutput &= ConsoleRead()
        If @error Then ExitLoop
        Sleep(25)
    WEnd
    MsgBox($MB_SYSTEMMODAL, "", "Received: " & @CRLF & @CRLF & $sOutput)
EndFunc   ;==>Example


Function ConsoleWrite

Function Reference

ConsoleWrite

Writes data to the STDOUT stream. Some text editors can read this stream as can other programs which may be expecting data on this stream.

ConsoleWrite ( "data" )

Parameters

data The data you wish to output. This may either be text or binary.

Return Value

The amount of data written. If writing binary, the number of bytes written, if writing text, the number of characters written.

Remarks

The purpose for this function is to write to the STDOUT stream. Many popular text editors can read this stream. Scripts compiled as Console applications also have a STDOUT stream.

This does not write to a DOS console unless the script is compiled as a console application.

Characters are converted to ANSI before being written.

Binary data is written as-is. It will not be converted to a string. To print the hex representation of binary data, use the String() function to explicitly cast the data to a string.

Related

ConsoleRead, ConsoleWriteError

Example

Example 1

Local $sString = "This is an example of writing to the console."
ConsoleWrite($sString & @CRLF) ; Running this in a text editor which can trap console output e.g. SciTE, will display value of $sString.

Example 2 for writing in SciTe output pane

ConsoleWrite('! = Red' & @CRLF) ; ! = red text color
ConsoleWrite('> = Blue' & @CRLF) ; > = blue text color
ConsoleWrite('- = Orange' & @CRLF) ; - = orange text color
ConsoleWrite('+ = Green' & @CRLF) ; + = green text color
ConsoleWrite('(5) : = Red (jump to line 5 when double-clicked)' & @CRLF) ; '(5) :' red text color and double click jumps to (line number)
ConsoleWrite('Start with String or Integer then ' & @TAB & '6' & ' = Pink (jump to line 6 when double-clicked)' & @CRLF)
; pink text color, any sign and then @TAB & 'line number'

; Example 1
ConsoleWrite('(' & @ScriptLineNumber & ') : = Red (jump to line ' & @ScriptLineNumber & ' when double-clicked)' & @CRLF)

; Clear console output pane of SciTE after 5000 ms
Sleep(5000)
ControlSend("[CLASS:SciTEWindow]", "", "Scintilla2", "+{F5}")


Function ConsoleWriteError

Function Reference

ConsoleWriteError

Writes data to the STDERR stream. Some text editors can read this stream as can other programs which may be expecting data on this stream.

ConsoleWriteError ( "data" )

Parameters

data The data you wish to output. This may either be text or binary.

Return Value

The amount of data written. If writing binary, the number of bytes written, if writing text, the number of characters written.

Remarks

The purpose for this function is to write to the STDERR stream. Many popular text editors can read this stream. Scripts compiled as Console applications also have a STDERR stream.

This does not write to a DOS console unless the script is compiled as a console application.

Characters are converted to ANSI before being written.

Binary data is written as-is. It will not be converted to a string. To print the hex representation of binary data, use the String() function to explicitly cast the data to a string.

Related

ConsoleRead, ConsoleWrite

Example

Local $sString = "An error occurred."
ConsoleWriteError($sString & @CRLF) ; Running this in a text editor which can trap console output e.g. SciTE, will display value of $sString.


Function DirCopy

Function Reference

DirCopy

Copies a directory and all sub-directories and files (Similar to xcopy).

DirCopy ( "source dir", "dest dir" [, flag = 0] )

Parameters

source dir | Path of the source directory (with no trailing backslash). e.g. "C:\Path1"
dest dir | Path of the destination dir (with no trailing backslash). e.g. "C:\Path_Copy"
flag | [optional] this flag determines whether to overwrite files if they already exist: $FC_NOOVERWRITE (0) = (default) do not overwrite existing files $FC_OVERWRITE (1) = overwrite existing files Constants are defined in FileConstants.au3.

Return Value

Success: | 1.
Failure: | 0 if there is an error copying the directory.

Remarks

If the destination directory structure doesn't exist, it will be created (if possible).

Related

DirMove, DirRemove, FileCopy, FileMove

Example

#include <FileConstants.au3>

DirCopy(@MyDocumentsDir, @TempDir & "\Backups\MyDocs", $FC_OVERWRITE)


Function DirCreate

Function Reference

DirCreate

Creates a directory/folder.

DirCreate ( "path" )

Parameters

path Path of the directory to create.

Return Value

Success: | 1.
Failure: | 0 if there was an error creating the directory.

Remarks

This function will also create all parent directories given in "path" if they do not already exist.

Related

DirRemove, FileCopy

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $sFldr1 = "C:\Test1\"
    Local $sFldr2 = "C:\Test1\Folder1\"
    Local $sFldr3 = "C:\Test1\Folder1\Folder2\"

    If DirGetSize($sFldr1) <> -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Directory already exists!")
        Return False
    EndIf

    DirCreate($sFldr3)

    RunWait("explorer /root, C:\Test1\Folder1")
    Local $hWnd = WinGetHandle("[TITLE:Folder1;CLASS:CabinetWClass]")

    MsgBox($MB_SYSTEMMODAL, "", "Explorer is opened with Folder2 displayed.")

    DirRemove($sFldr3, 1)
    MsgBox($MB_SYSTEMMODAL, "", "The sub folder: Folder2 has been deleted.")

    WinClose($hWnd)

    DirRemove($sFldr2) ;clean up test folders
    DirRemove($sFldr1) ;clean up test folders
EndFunc   ;==>Example


Function DirGetSize

Function Reference

DirGetSize

Returns the size in bytes of a given directory.

DirGetSize ( "path" [, flag = 0] )

Parameters

path | The directory path to get the size from, e.g. "C:\Windows".
flag | [optional] this flag determines the behaviour and result of the function, and can be a combination of the following: $DIR_DEFAULT (0) = (default) $DIR_EXTENDED (1) = Extended mode is On -> returns an array that contains extended information (see Remarks). $DIR_NORECURSE (2) = Don't get the size of files in subdirectories (recursive mode is Off) Constants are defined in "AutoItConstants.au3".

Return Value

Success: | the sizes that are greater than or equal to zero
Failure: | -1 and sets the @error flag to non-zero if the path doesn't exist.

Remarks

If the script is paused then this function is paused too and will only continue when the script continues!

If you use the extended mode then the array returned from this function is a single dimension array containing the following elements:
$aArray[0] = Size
$aArray[1] = Files count
$aArray[2] = Dirs Count

Example

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iSize = DirGetSize(@HomeDrive)
    MsgBox($MB_SYSTEMMODAL, "", "Size(MegaBytes): " & Round($iSize / 1024 / 1024))

    $iSize = DirGetSize(@WindowsDir, $DIR_NORECURSE)
    MsgBox($MB_SYSTEMMODAL, "", "Size(MegaBytes): " & Round($iSize / 1024 / 1024))

    Local $hTimer = TimerInit()

    Local $aSize = DirGetSize("\\10.0.0.1\h$", $DIR_EXTENDED) ; extended mode
    If Not @error Then
        Local $iDiff = Round(TimerDiff($hTimer) / 1000) ; time in seconds
        MsgBox($MB_SYSTEMMODAL, "", "Size(Bytes): " & $aSize[0] & @CRLF _
                 & "Files: " & $aSize[1] & @CRLF & "Dirs: " & $aSize[2] & @CRLF _
                 & "TimeDiff(Sec): " & $iDiff)
    EndIf
EndFunc   ;==>Example


Function DirMove

Function Reference

DirMove

Moves a directory and all sub-directories and files.

DirMove ( "source dir", "dest dir" [, flag = 0] )

Parameters

source dir | Path of the source directory (with no trailing backslash). e.g. "C:\Path1"
dest dir | Path of the destination dir (with no trailing backslash). e.g. "C:\Path_Copy"
flag | [optional] this flag determines whether to overwrite files if they already exist: $FC_NOOVERWRITE (0) = (default) do not overwrite existing files $FC_OVERWRITE (1) = overwrite existing files Constants are defined in FileConstants.au3.

Return Value

Success: | 1.
Failure: | 0 if there is an error moving the directory.

Remarks

If the source and destination are on different volumes or UNC paths are used then a copy/delete operation will be performed rather than a move.

If the destination already exists and the overwrite flag is specified then the source directory will be moved inside the destination.

Because AutoIt lacks a "DirRename" function, use DirMove() to rename a folder!

Related

DirRemove, FileMove

Example

DirMove(@MyDocumentsDir, @TempDir & "\Backups\MyDocs")


Function DirRemove

Function Reference

DirRemove

Deletes a directory/folder.

DirRemove ( "path" [, recurse = 0] )

Parameters

path | Path of the directory to remove.
recurse | [optional] Use this flag to specify if you want to delete sub-directories too. $DIR_DEFAULT (0) = (default) deletes the folder, only if it is empty $DIR_REMOVE (1) = remove files and subdirectories (like the DOS DelTree command) Constants are define in "AutoItConstants.au3".

Return Value

Success: | 1.
Failure: | 0 if there is an error removing the directory (or if directory does not exist).

Remarks

Some directory attributes can make the deletion impossible, therefore if this is the case look at FileSetAttrib() to change the attributes of a directory.

Related

DirCopy, DirCreate, DirMove, FileDelete, FileRecycle

Example

#include <MsgBoxConstants.au3>

; Delete C:\Test1 and all subdirs and files
Example()

Func Example()
    Local $sFldr1 = "C:\Test1\"
    Local $sFldr2 = "C:\Test1\Folder1\"
    Local $sFldr3 = "C:\Test1\Folder1\Folder2\"

    If DirGetSize($sFldr1) <> -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Directory already exists!")
        Return False
    EndIf

    DirCreate($sFldr3)

    RunWait("explorer /root, C:\Test1\Folder1")
    Local $hWnd = WinGetHandle("[TITLE:Folder1;CLASS:CabinetWClass]")

    MsgBox($MB_SYSTEMMODAL, "", "Explorer is opened with Folder2 displayed.")

    DirRemove($sFldr3, 1)
    MsgBox($MB_SYSTEMMODAL, "", "The sub folder: Folder2 has been deleted.")

    WinClose($hWnd)

    DirRemove($sFldr2) ;clean up test folders
    DirRemove($sFldr1) ;clean up test folders
EndFunc   ;==>Example


Function DriveGetDrive

Function Reference

DriveGetDrive

Returns an array containing the enumerated drives.

DriveGetDrive ( "type" )

Parameters

type Type of drive to find:
$DT_ALL ("ALL")
$DT_CDROM ("CDROM")
$DT_REMOVABLE ("REMOVABLE")
$DT_FIXED ("FIXED")
$DT_NETWORK ("NETWORK")
$DT_RAMDISK ("RAMDISK")
$DT_UNKNOWN ("UNKNOWN")

Constants are defined in AutoItConstants.au3

Return Value

Success: | an array of strings (drive letter followed by colon) of drives found. The zeroth array element contains the number of drives.
Failure: | sets the @error flag to 1.

Related

DriveGetFileSystem, DriveGetLabel, DriveGetSerial, DriveGetType, DriveSetLabel, DriveSpaceFree, DriveSpaceTotal, DriveStatus

Example

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Local $aArray = DriveGetDrive($DT_ALL)
If @error Then
    ; An error occurred when retrieving the drives.
    MsgBox($MB_SYSTEMMODAL, "", "It appears an error occurred.")
Else
    For $i = 1 To $aArray[0]
        ; Show all the drives found and convert the drive letter to uppercase.
        MsgBox($MB_SYSTEMMODAL, "", "Drive " & $i & "/" & $aArray[0] & ":" & @CRLF & StringUpper($aArray[$i]))
    Next
EndIf


Function DriveGetFileSystem

Function Reference

DriveGetFileSystem

Returns File System Type of a drive.

DriveGetFileSystem ( "path" )

Parameters

path Path of drive to receive information from.

Return Value

Success: | the File System Type of the drive as a string; see table below.
Failure: | sets the @error flag to 1.

Return Value | Interpretation
$DT_UNDEFINED (1) (numeric) | Drive does NOT contain media (CD, Floppy, Zip) or media is unformatted (RAW).
$DT_FAT ("FAT") | Typical file system for drives under ~500 MB such as Floppy, RAM disks, USB "pen" drives, etc.
$DT_FAT32 ("FAT32") | Typical file system for Windows 9x/Me hard drives.
$DT_EXFAT ("exFAT") | Typical file system for drives with files over 4 GB such as RAM disks, USB "pen" drives, etc.
$DT_NTFS ("NTFS") | Typical file system for Windows hard drives.
$DT_UNWFS ("NWFS") | Typical file system for Novell Netware file servers.
$DT_CDFS ("CDFS") | Typically indicates a CD (or an ISO image mounted as a virtual CD drive).
$DT_UDF ("UDF") | Typically indicates a DVD.

Constants are defined in "AutoItConstants.au3".

Remarks

The list of possible return values might be incomplete.

Related

DriveGetDrive, DriveGetLabel, DriveGetSerial, DriveGetType, DriveSetLabel, DriveSpaceFree, DriveSpaceTotal, DriveStatus

Example

#include <MsgBoxConstants.au3>

Local $sFileSystem = DriveGetFileSystem(@HomeDrive & "\") ; Find the file system type of the home drive, generally this is the C:\ drive.
MsgBox($MB_SYSTEMMODAL, "", "File System Type: " & $sFileSystem)


Function DriveGetLabel

Function Reference

DriveGetLabel

Returns Volume Label of a drive, if it has one.

DriveGetLabel ( "path" )

Parameters

path Path of drive to receive information from.

Return Value

Success: | the Volume Label of the drive as a string.
Failure: | sets the @error flag to 1.

Related

DriveGetDrive, DriveGetFileSystem, DriveGetSerial, DriveGetType, DriveSetLabel, DriveSpaceFree, DriveSpaceTotal, DriveStatus

Example

#include <MsgBoxConstants.au3>

Local $sLabel = DriveGetLabel(@HomeDrive & "\") ; Find the volume label of the home drive, generally this is the C:\ drive.
MsgBox($MB_SYSTEMMODAL, "", "Volume Label: " & $sLabel)


Function DriveGetSerial

Function Reference

DriveGetSerial

Returns Serial Number of a drive.

DriveGetSerial ( "path" )

Parameters

path Path of drive to receive information from.

Return Value

Success: | the Serial Number of the drive as a string.
Failure: | sets the @error flag to 1.

Remarks

The value returned is not the hardware serial number as found on the label of the drive, it is the Windows Volume ID for the drive.

Related

DriveGetDrive, DriveGetFileSystem, DriveGetLabel, DriveGetType, DriveSetLabel, DriveSpaceFree, DriveSpaceTotal, DriveStatus

Example

#include <MsgBoxConstants.au3>

Local $sSerial = DriveGetSerial(@HomeDrive & "\") ; Find the serial number of the home drive, generally this is the C:\ drive.
MsgBox($MB_SYSTEMMODAL, "", "Serial Number: " & $sSerial)


Function DriveGetType

Function Reference

DriveGetType

Returns drive type.

DriveGetType ( "path" [, operation = 1] )

Parameters

path | Path of drive to receive information from.
operation | [optional] The drive type operation to perform. $DT_DRIVETYPE (1) = the type of drive (default) $DT_SSDSTATUS (2) = SSD status of the drive $DT_BUSTYPE (3) = the bus type of drive Constants are defined in AutoItConstants.au3.

Return Value

Success: | See remarks.
Failure: | Sets the @error flag to 1 if a bad path was given, or if the operation failed. Return value is "".

Remarks

If the mode parameter is $DT_DRIVETYPE (1), returns the type of drive. The path must be a string volume name, such as "C:\". Return values are:
"Unknown", "Removable", "Fixed", "Network", "CDROM", "RAMDisk"

If the mode parameter is $DT_SSDSTATUS (2), returns the SSD status of the drive. The path can be a string volume name, or an integer drive index. Return values are:
"SSD", "" (blank)

If the mode parameter is $DT_BUSTYPE (3), returns the bus type of the drive. The path can be a string volume name, or an integer drive index. Return values are:
"Unknown", "SCSI", "ATAPI", "ATA", "1394", "SSA", "Fibre", "USB", "RAID", "iSCSI", "SAS", "SATA", "SD", "MMC", "Virtual", "FileBackedVirtual"

Related

CDTray, DriveGetDrive, DriveGetFileSystem, DriveGetLabel, DriveGetSerial, DriveSetLabel, DriveSpaceFree, DriveSpaceTotal, DriveStatus

Example

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

; Check the drive type for C:\
Local $sInfo = DriveGetType("C:\")
MsgBox($MB_SYSTEMMODAL, "", "Drive Type: " & $sInfo)

; Check the SSD status for C:\
$sInfo = DriveGetType("C:\", $DT_SSDSTATUS)
MsgBox($MB_SYSTEMMODAL, "", "Drive SSD: " & $sInfo)

; Check the SSD status for disk 0
$sInfo = DriveGetType(0, $DT_SSDSTATUS)
MsgBox($MB_SYSTEMMODAL, "", "Drive SSD: " & $sInfo)

; Check the bus type status for disk 0
$sInfo = DriveGetType(0, $DT_BUSTYPE)
MsgBox($MB_SYSTEMMODAL, "", "Drive Bus: " & $sInfo)


Function DriveMapAdd

Function Reference

DriveMapAdd

Maps a network drive.

DriveMapAdd ( "device", "remote share" [, flags = 0 [, "user" [, "password"]]] )

Parameters

device | The device to map, for example "O:" or "LPT1:". If you pass an empty string for this parameter a connection is made but not mapped to a specific drive. If you specify "*" an unused drive letter will be automatically selected.
remote share | The remote share to connect to in the form "\\server\share".
flags | [optional] A combination of the following: $DMA_DEFAULT (0) = default $DMA_PERSISTENT (1) = Persistent mapping $DMA_AUTHENTICATION (8) = Show authentication dialog if required Constants are defined in "AutoItConstants.au3"
user | [optional] The username to use to connect. In the form "username" or "domain\username".
password | [optional] The password to use to connect.

Return Value

Success: | 1. (See Remarks)
Failure: | 0 if a new mapping could not be created and sets the @error flag to non-zero.
@error: | 1 = Undefined / Other error. @extended set with Windows API return 2 = Access to the remote share was denied 3 = The device is already assigned 4 = Invalid device name 5 = Invalid remote share 6 = Invalid password

Remarks

Note: When using "*" for the device parameter the drive letter selected will be returned instead of 1 or 0, e.g. "U:". If there was an error using "*" then an empty string "" will be returned.

If defined the user/password will be presented to the remote computer that will validate the credential.

Related

DriveMapDel, DriveMapGet

Example

#include <AutoItConstants.au3>

; Map X drive to \\myserver\stuff using current user
DriveMapAdd("X:", "\\myserver\stuff")

; Map X drive to \\myserver2\stuff2 using the user "jon" from "domainx" with password "tickle"
DriveMapAdd("X:", "\\myserver2\stuff2", $DMA_DEFAULT, "domainx\jon", "tickle")


Function DriveMapDel

Function Reference

DriveMapDel

Disconnects a network drive.

DriveMapDel ( "drive" )

Parameters

drive The device to disconnect, e.g. "O:" or "LPT1:".

Return Value

Success: | 1.
Failure: | 0 if the disconnection was unsuccessful.

Remarks

If a connection has no drive letter mapped you may use the connection name to disconnect, e.g. \\server\share

Related

DriveMapAdd, DriveMapGet

Example

; Map X drive to \\myserver\stuff using current user
DriveMapAdd("X:", "\\myserver\stuff")

; Disconnect
DriveMapDel("X:")


Function DriveMapGet

Function Reference

DriveMapGet

Retrieves the details of a mapped drive.

DriveMapGet ( "device" )

Parameters

device The device (drive or printer) letter to query, e.g. "O:" or "LPT1:"

Return Value

Success: | a details of the mapping, e.g. \\server\share
Failure: | an empty string "" and sets the @error flag to 1.

Related

DriveMapAdd, DriveMapDel

Example

#include <MsgBoxConstants.au3>

; Map X drive to \\myserver\stuff using current user
DriveMapAdd("X:", "\\myserver\stuff")

; Get details of the mapping
MsgBox($MB_SYSTEMMODAL, "", "Drive X: is mapped to: " & DriveMapGet("X:"))


Function DriveSetLabel

Function Reference

DriveSetLabel

Sets the Volume Label of a drive.

DriveSetLabel ( "path", "label" )

Parameters

path | Path of drive to change.
label | New volume label for the drive. (11 characters is usually max length)

Return Value

Success: | 1.
Failure: | 0.

Remarks

Most hard drives have a maximum label length of 11 characters, and DriveSetLabel() will fail if max length is exceeded. Also, FAT32 partition labels tend to revert to all capital letters.

Related

DriveGetDrive, DriveGetFileSystem, DriveGetLabel, DriveGetSerial, DriveGetType, DriveSpaceFree, DriveSpaceTotal, DriveStatus

Example

DriveSetLabel(@HomeDrive & "\", "New_Label") ; Change the label of the home drive, generally this is the C:\ drive.


Function DriveSpaceFree

Function Reference

DriveSpaceFree

Returns the free disk space of a path in Megabytes.

DriveSpaceFree ( "path" )

Parameters

path Path of drive to receive information from.

Return Value

Success: | the free disk space in Megabytes as a float number.
Failure: | 0 and sets the @error flag to 1.

Remarks

DriveSpaceFree() may even work when a complete directory path (that exists) is given. However, a file path won't work.
Use the Round() function if the return value is too precise.

Related

DriveGetDrive, DriveGetFileSystem, DriveGetLabel, DriveGetSerial, DriveGetType, DriveSetLabel, DriveSpaceTotal, DriveStatus

Example

#include <MsgBoxConstants.au3>

Local $iFreeSpace = DriveSpaceFree(@HomeDrive & "\") ; Find the free disk space of the home drive, generally this is the C:\ drive.
MsgBox($MB_SYSTEMMODAL, "", "Free Space: " & $iFreeSpace & " MB")


Function DriveSpaceTotal

Function Reference

DriveSpaceTotal

Returns the total disk space of a path in Megabytes.

DriveSpaceTotal ( "path" )

Parameters

path Path of drive to receive information from.

Return Value

Success: | the diskspace in Megabytes as a float number.
Failure: | sets the @error flag to 1.

Remarks

DriveSpaceTotal() may even work when a complete directory path (that exists) is given. However, a file path won't work.

Related

DriveGetDrive, DriveGetFileSystem, DriveGetLabel, DriveGetSerial, DriveGetType, DriveSetLabel, DriveSpaceFree, DriveStatus, FileGetSize

Example

#include <MsgBoxConstants.au3>

Local $iTotalSpace = DriveSpaceTotal(@HomeDrive & "\") ; Find the total disk space of the home drive, generally this is the C:\ drive.
MsgBox($MB_SYSTEMMODAL, "", "Total Space: " & $iTotalSpace & " MB")


Function DriveStatus

Function Reference

DriveStatus

Returns the status of the drive as a string.

DriveStatus ( "path" )

Parameters

path Path of drive to receive information from.

Return Value

Value | Interpretation
$DS_UNKNOWN ("UNKNOWN") | Drive may be unformatted (RAW).
$DS_READY@DOUBLE_WS ("READY") | Typical of hard drives and drives that contain removable media.
$DS_NOTREADY@DOUBLE_WS ("NOTREADY") | Typical of floppy and CD drives that do not contain media.
$DS_INVALID ("INVALID") | May indicate the drive letter does not exist or that a mapped network drive is inaccessible.

Constants are defined in "AutoItConstants.au3".

Remarks

The list of possible return values may be incomplete.
DriveStatus() may even work when a complete directory path (which exists) is given. However, a file path won't work.

Related

CDTray, DriveGetDrive, DriveGetFileSystem, DriveGetLabel, DriveGetSerial, DriveGetType, DriveSetLabel, DriveSpaceFree, DriveSpaceTotal, FileExists

Example

#include <MsgBoxConstants.au3>

Local $sStatus = DriveStatus(@HomeDrive & "\") ; Find the status of the home drive, generally this is the C:\ drive.
MsgBox($MB_SYSTEMMODAL, "", "Status: " & $sStatus)


Function FileChangeDir

Function Reference

FileChangeDir

Changes the current working directory.

FileChangeDir ( "path" )

Parameters

path The path to make the current working directory.

Return Value

Success: | 1.
Failure: | 0 if working directory not changed.

Remarks

@WorkingDir is changed on successful return.

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Display the current working directory.
    MsgBox($MB_SYSTEMMODAL, "", "The current working directory: " & @CRLF & @WorkingDir)

    ; Set the working directory @WorkingDir to the @WindowsDir directory. This is normally C:\Windows.
    FileChangeDir(@WindowsDir)

    ; Display the working directory after setting it to the windows directory.
    MsgBox($MB_SYSTEMMODAL, "", "The current working directory: " & @CRLF & @WorkingDir)
EndFunc   ;==>Example


Function FileClose

Function Reference

FileClose

Closes a previously opened file.

FileClose ( "filehandle" )

Parameters

filehandle The handle of a file, as returned by a previous call to FileOpen().

Return Value

Success: | 1.
Failure: | 0 if the filehandle is invalid.

Remarks

Upon termination, AutoIt automatically closes any files it opened, but calling FileClose() is still a good idea.

This function is also used to close search handles as returned by FileFindFirstFile().

Related

FileFindFirstFile, FileFindNextFile, FileFlush, FileOpen

Example

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Create a temporary file to read data from.
    If Not FileWrite($sFilePath, "This is an example of using FileClose.") Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Open the file for reading and store the handle to a variable.
    Local $hFileOpen = FileOpen($sFilePath, $FO_READ)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.")
        Return False
    EndIf

    ; Read the contents of the file using the handle returned by FileOpen.
    Local $sFileRead = FileRead($hFileOpen)

    ; Close the handle returned by FileOpen.
    FileClose($hFileOpen)

    ; Display the contents of the file.
    MsgBox($MB_SYSTEMMODAL, "", "Contents of the file:" & @CRLF & $sFileRead)

    ; Delete the temporary file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function FileCopy

Function Reference

FileCopy

Copies one or more files.

FileCopy ( "source", "dest" [, flag = 0] )

Parameters

source | The source path of the file(s) to copy. (* and ? wildcards accepted - See Remarks)
dest | The destination path of the copied file(s).
flag | [optional] this flag determines whether to overwrite files if they already exist. Can be a combination of the following: $FC_NOOVERWRITE (0) = (default) do not overwrite existing files $FC_OVERWRITE (1) = overwrite existing files $FC_CREATEPATH (8) = Create destination directory structure if it doesn't exist (See Remarks). Constants are defined in FileConstants.au3.

Return Value

Success: | 1.
Failure: | 0.

Remarks

See FileFindFirstFile() for a discussion about wildcards.

The destination directory must already exist, except using with flag value $FC_CREATEPATH (8).
For instance the combined flag $FC_OVERWRITE (1) + $FC_CREATEPATH (8) overwrites the target file and pre-checks for the destination directory structure and if it doesn't exist creates it automatically.

Some file attributes can make the overwriting impossible, if this is the case look at FileSetAttrib() to change the attributes of a file.

Related

DirCopy, DirCreate, FileDelete, FileMove

Example

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Create a temporary file to copy.
    If Not FileWrite($sFilePath, "This is an example of using FileCopy.") Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Copy Au3 files in the temporary directory to a new folder/directory called Au3Files.
    FileCopy(@TempDir & "\*.au3", @TempDir & "\Au3Files\", $FC_OVERWRITE + $FC_CREATEPATH)

    ; Display the temporary directory.
    ShellExecute(@TempDir)
EndFunc   ;==>Example


Function FileCreateNTFSLink

Function Reference

FileCreateNTFSLink

Creates an NTFS hardlink to a file or a directory.

FileCreateNTFSLink ( "source", "hardlink" [, flag = 0] )

Parameters

source | Path of the source to which the hardlink will be created.
hardlink | Path of the hardlink.
flag | [optional] this flag determines whether to overwrite link if they already exist. Can be a combination of the following: $FC_NOOVERWRITE (0) = (default) do not overwrite existing link $FC_OVERWRITE (1) = overwrite existing link Constants are defined in FileConstants.au3.

Return Value

Success: | 1.
Failure: | 0.

Remarks

The destination directory must already exist.

This function works only on volumes with the NTFS File system.

If the source is a file, the hardlink must be on the same volume.
If the source is a directory cross volume is allowed.

FileDelete() or FileMove() can be used on hardlink.

To manage the link with the explorer you can use the shell extension NTFSLink

Related

FileCreateShortcut

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Create a temporary file to link to.
    If Not FileWrite($sFilePath, "This is an example of using FileCreateNTFSLink.") Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Create a NTFS link of the .txt file to the .log file on the desktop.
    Local $iNTFSLink = FileCreateNTFSLink($sFilePath, @DesktopDir & "\ExampleNTFSLink.log")

    ; Display a message of whether the NTFS link was created.
    If $iNTFSLink Then
        ; Open the desktop directory.
        ShellExecute(@DesktopDir)

        MsgBox($MB_SYSTEMMODAL, "", "The NTFS link was created." & @CRLF & "FileCreateNTFSLink returned: " & $iNTFSLink)
    Else
        MsgBox($MB_SYSTEMMODAL, "", "The NTFS link wasn't created." & @CRLF & "FileCreateNTFSLink returned: " & $iNTFSLink)
    EndIf

    ; Delete the temporary files.
    FileDelete($sFilePath)
    FileDelete(@DesktopDir & "\ExampleNTFSLink.log")
EndFunc   ;==>Example


Function FileCreateShortcut

Function Reference

FileCreateShortcut

Creates a shortcut (.lnk) to a file.

FileCreateShortcut ( "file", "lnk" [, "workdir" [, "args" [, "desc" [, "icon" [, "hotkey" [, icon number [, state]]]]]]] )

Parameters

file | Full path and file name of file to which the shortcut will point.
lnk | Full path and file name of the shortcut.
workdir | [optional] Working directory.
args | [optional] Additional file arguments.
desc | [optional] File Description.
icon | [optional] Full Path/File name of icon to use.
hotkey | [optional] Hotkey - same as the Send() key format.
icon number | [optional] The icon instance to use (usually 0)
state | [optional] The state the shortcut is launched in. Use either @SW_SHOWNORMAL, @SW_SHOWMINNOACTIVE or @SW_SHOWMAXIMIZED

Return Value

Success: | 1.
Failure: | 0 if lnk cannot be created.

Remarks

Hotkeys for windows shortcuts are of the following form: Ctrl+Alt+X, Ctrl+Shift+X, Shift+Alt+X, Ctrl+NumPadKey, or Alt+NumPadKey where X represents a letter, number, punctuation, or function key. If you specify an invalid form, Windows typically defaults to Ctrl+Alt
Note that Windows distinguishes number pad keys from regular number and punctuation keys. FileCreateShortcut() allows you to create Ctrl+X and Alt+X shortcuts (which Windows normally only allows when X is a NumPadKey); however, you should avoid these assignments as they may conflict with standard application hotkeys.
Windows prohibits ESC, ENTER, TAB, SPACEBAR, PRINT SCREEN, SHIFT, or BACKSPACE from being used in hotkeys.

FileCreateShortcut() does not require a valid target, workdir, icon, or hotkey in order to "successfully" create the LNK file; however, the destination of the LNK file must be valid! If the hotkey you choose is already in use, your new shortcut takes precedence. Also, if you create a shortcut with the same path\name as as a pre-existing shortcut, it gets overwritten with your new version.

Related

FileCreateNTFSLink, FileGetShortcut

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the shortcut filepath.
    Local Const $sFilePath = @DesktopDir & "\FileCreateShortcutExample.lnk"

    ; Create a shortcut on the desktop to explorer.exe and set the hotkey combination Ctrl+Alt+T or in AutoIt ^!t to the shortcut.
    FileCreateShortcut(@WindowsDir & "\explorer.exe", $sFilePath, @WindowsDir, "/e,c:\", _
            "Tooltip description of the shortcut.", @SystemDir & "\shell32.dll", "^!t", "15", @SW_SHOWMAXIMIZED)

    ; Retrieve details about the shortcut.
    Local $aDetails = FileGetShortcut($sFilePath)
    If Not @error Then
        MsgBox($MB_SYSTEMMODAL, "", "Path: " & $aDetails[0] & @CRLF & _
                "Working directory: " & $aDetails[1] & @CRLF & _
                "Arguments: " & $aDetails[2] & @CRLF & _
                "Description: " & $aDetails[3] & @CRLF & _
                "Icon filename: " & $aDetails[4] & @CRLF & _
                "Icon index: " & $aDetails[5] & @CRLF & _
                "Shortcut state: " & $aDetails[6] & @CRLF)
    EndIf

    ; Delete the shortcut.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function FileDelete

Function Reference

FileDelete

Delete one or more files.

FileDelete ( "filename" )

Parameters

Filename The path of the file(s) to delete. (* and ? wildcards accepted - See Remarks)

Return Value

Success: | 1.
Failure: | 0 if files are not deleted or do not exist.

Remarks

See FileFindFirstFile() for a discussion about wildcards.

Note: If the "path" passed to FileDelete() is a folder, the files therein will be deleted just as if you had used the *.* mask.

Some file attributes can make the deletion impossible, if this is the case look at FileSetAttrib() to change the attributes of a file.

Related

DirRemove, FileCopy, FileMove, FileRecycle, FileRecycleEmpty

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Create a temporary file to read data from.
    If Not FileWrite($sFilePath, "This is an example of using FileDelete.") Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Display the contents of the file passing the filepath to FileRead instead of a handle returned by FileOpen.
    MsgBox($MB_SYSTEMMODAL, "", "Contents of the file:" & @CRLF & FileRead($sFilePath))

    ; Delete the temporary file.
    Local $iDelete = FileDelete($sFilePath)

    ; Display a message of whether the file was deleted.
    If $iDelete Then
        MsgBox($MB_SYSTEMMODAL, "", "The file was successfuly deleted.")
    Else
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst deleting the file.")
    EndIf
EndFunc   ;==>Example


Function FileExists

Function Reference

FileExists

Checks if a file or directory exists.

FileExists ( "path" )

Parameters

Path The directory or file to check.

Return Value

Success: | 1.
Failure: | 0 if path/file does not exist.

Remarks

FileExists() returns 0 if you specify a floppy drive which does not contain a disk.

Related

DriveStatus, FileGetAttrib

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    Local $iFileExists = FileExists($sFilePath)

    ; Display a message of whether the file exists or not.
    If $iFileExists Then
        MsgBox($MB_SYSTEMMODAL, "", "The file exists." & @CRLF & "FileExist returned: " & $iFileExists)
    Else
        MsgBox($MB_SYSTEMMODAL, "", "The file doesn't exist." & @CRLF & "FileExist returned: " & $iFileExists)
    EndIf

    ; Delete the temporary file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function FileFindFirstFile

Function Reference

FileFindFirstFile

Creates a search handle, defined by a path and file mask.

FileFindFirstFile ( "filename" )

Parameters

filename The path and file name. (* and ? wildcards accepted - See Remarks)

Return Value

Success: | a search "handle" for use with subsequent FileFindNextFile functions.
Failure: | -1 if nothing is found. The value of the @error flag is set to 1 only if the Folder is empty.

Remarks

The search string is not case sensitive.
Wildcards: In general, * denotes zero or more characters, and ? denotes zero or one character. If your file search string contains only wildcards (or is "*.*"), then see the example below for the return value!

You can use only one wildcard in the filename part or in the extension part i.e. a*.b?.
When using a 3-char extension any extension starting with those 3 chars will match, .e.g. "*.log" will match "test.log_1". (not described either in Microsoft documentation).

When you have finished searching with the FileFind... functions you must call FileClose() to release the search handle.

Directory name are returned according to the wildcards if any.

Due to the underlying Windows API used (FindFirstFile), this function actually searches both the long and short filenames when looking for matches. If you get unexepected results
then verfiy that it's not the short filename that is being matched.

Related

FileClose, FileFindNextFile

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign a Local variable the search handle of all files in the current directory.
    Local $hSearch = FileFindFirstFile("*.*")

    ; Check if the search was successful, if not display a message and return False.
    If $hSearch = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Error: No files/directories matched the search pattern.")
        Return False
    EndIf

    ; Assign a Local variable the empty string which will contain the files names found.
    Local $sFileName = "", $iResult = 0

    While 1
        $sFileName = FileFindNextFile($hSearch)
        ; If there is no more file matching the search.
        If @error Then ExitLoop

        ; Display the file name.
        $iResult = MsgBox(BitOR($MB_SYSTEMMODAL, $MB_OKCANCEL), "", "File: " & $sFileName)
        If $iResult <> $IDOK Then ExitLoop ; If the user clicks on the cancel/close button.
    WEnd

    ; Close the search handle.
    FileClose($hSearch)
EndFunc   ;==>Example


Function FileFindNextFile

Function Reference

FileFindNextFile

Returns the next filename defined by the search handle.

FileFindNextFile ( search [, flag = 0])

Parameters

search | The search handle, as returned by FileFindFirstFile().
flag | [optional] this flag determines whether to return detailed file attribute information in @extended. 0 = (default) use @extended to return 1 or 0 if search item is a directory. 1 = Return a string in @extended in the same format as FileGetAttrib().

Return Value

Success: | a filename according to a previous call to FileFindFirstFile(), @extended set as per the flag option.
Failure: | sets the @error flag to 1 if no more files/directories match the search.

Remarks

A previous call to FileFindFirstFile() is necessary to setup the search and get a search handle. Every subsequent call to FileFindNextFile() will return the next file found according to the search handle supplied to FileFindFirstFile(). When @error = 1, no more files found matching the original search handle.

When you have finished searching with the FileFind... functions you must call FileClose() to release the search handle.

Due to the underlying Windows API used (FindFirstFile), this function actually searches both the long and short filenames when looking for matches. If you get unexepected results
then verfiy that it's not the short filename that is being matched.

Related

FileClose, FileFindFirstFile

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign a Local variable the search handle of all files in the current directory.
    Local $hSearch = FileFindFirstFile("*.*")

    ; Check if the search was successful, if not display a message and return False.
    If $hSearch = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Error: No files/directories matched the search pattern.")
        Return False
    EndIf

    ; Assign a Local variable the empty string which will contain the files names found.
    Local $sFileName = "", $iResult = 0

    While 1
        $sFileName = FileFindNextFile($hSearch)
        ; If there is no more file matching the search.
        If @error Then ExitLoop

        ; Display the file name.
        $iResult = MsgBox(BitOR($MB_SYSTEMMODAL, $MB_OKCANCEL), "", "File: " & $sFileName)
        If $iResult <> $IDOK Then ExitLoop ; If the user clicks on the cancel/close button.
    WEnd

    ; Close the search handle.
    FileClose($hSearch)
EndFunc   ;==>Example


Function FileFlush

Function Reference

FileFlush

Flushes the file's buffer to disk.

FileFlush ( "filehandle" )

Parameters

filehandle The handle of a file, as returned by a previous call to FileOpen().

Return Value

Success: | True if the buffer was flushed (or did not need to be flushed).
Failure: | False.

Remarks

A file is flushed when its handle is closed or when Windows internal buffer is full. This function forces an immediate flushing of the buffer.
This function can only be used with file handles returned from FileOpen().

Related

FileClose, FileOpen, FileSetPos, FileWrite, FileWriteLine

Example

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Open the file for writing (overwrite the file) and store the handle to a variable.
    Local $hFileOpen = FileOpen($sFilePath, $FO_OVERWRITE)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Write data to the file using the handle returned by FileOpen.
    FileWriteLine($hFileOpen, "Line 1")
    FileWriteLine($hFileOpen, "Line 2")
    FileWriteLine($hFileOpen, "Line 3")

    ; Flush the file to disk.
    FileFlush($hFileOpen)

    ; Check file position and try to read contents for current position.
    MsgBox($MB_SYSTEMMODAL, "", "Position: " & FileGetPos($hFileOpen) & @CRLF & "Data: " & @CRLF & FileRead($hFileOpen))

    ; Now, adjust the position to the beginning.
    FileSetPos($hFileOpen, 0, $FILE_BEGIN)

    ; Check file position and try to read contents for current position.
    MsgBox($MB_SYSTEMMODAL, "", "Position: " & FileGetPos($hFileOpen) & @CRLF & "Data: " & @CRLF & FileRead($hFileOpen))

    ; Close the handle returned by FileOpen.
    FileClose($hFileOpen)

    ; Delete the temporary file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function FileGetAttrib

Function Reference

FileGetAttrib

Returns a code string representing a file's attributes.

FileGetAttrib ( "filename" )

Parameters

filename The path to the file or directory to check.

Return Value

Success: | a code string representing a file's attributes.
Failure: | "" (empty string) and sets the @error flag to 1.

Remarks

String() returned could contain a combination of these letters "RASHNDOCTX":
"R" = READONLY
"A" = ARCHIVE
"S" = SYSTEM
"H" = HIDDEN
"N" = NORMAL
"D" = DIRECTORY
"O" = OFFLINE
"C" = COMPRESSED (NTFS compression, not ZIP compression)
"T" = TEMPORARY
"X" = EFS ENCRYPTION

Related

FileExists, FileGetSize, FileGetTime, FileSetAttrib, FileSetTime

Example

Example 1

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope to store the file attributes of the current script.
    Local Const $sAttribute = FileGetAttrib(@ScriptFullPath)

    ; Display the string returned by FileGetAttrib.
    MsgBox($MB_SYSTEMMODAL, "", "The attribute string: " & @CRLF & $sAttribute)

    ; Display the string returned by AttributeToString
    MsgBox($MB_SYSTEMMODAL, "", "The attribute string with easier to understand values: " & @CRLF & _
            AttributeToString($sAttribute))
EndFunc   ;==>Example

Func AttributeToString($sAttribute)
    ; Create a 1d array of the file attribute letters by splitting the string at the comma (,).
    Local $aInput = StringSplit("R,A,S,H,N,D,O,C,T", ",")

    ; Create a 1d array using the friendlier file attribute names by splitting the string at the comma (,).
    Local $aOutput = StringSplit("Read-only /, Archive /, System /, Hidden /" & _
            ", Normal /, Directory /, Offline /, Compressed /, Temporary /", ",")

    ; Loop through the attribute letters array to replace with the friendlier value e.g. A becomes Archive or S becomes System.
    For $i = 1 To $aInput[0]
        $sAttribute = StringReplace($sAttribute, $aInput[$i], $aOutput[$i], 0, $STR_CASESENSE)
    Next

    ; Remove the single space and trailing forward slash.
    $sAttribute = StringTrimRight($sAttribute, 2)

    ; Return the attribute string.
    Return $sAttribute
EndFunc   ;==>AttributeToString

Example 2

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign a variable with the filepath to check on whether it's a file or not.
    Local $sFilePath = @ScriptFullPath

    If IsFile($sFilePath) Then
        MsgBox($MB_SYSTEMMODAL, "", "The filepath is a file.")
    Else
        MsgBox($MB_SYSTEMMODAL, "", "The filepath is not a file.")
    EndIf
EndFunc   ;==>Example

; Check if the filepath is a file. Does not validate if the file exists.
Func IsFile($sFilePath)
    Return StringInStr(FileGetAttrib($sFilePath), "D") = 0
EndFunc   ;==>IsFile

Example 3

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign a variable with the filepath to check on whether it's a directory/folder or not.
    Local $sFilePath = @ScriptDir

    If IsDir($sFilePath) Then
        MsgBox($MB_SYSTEMMODAL, "", "The filepath is a directory/folder.")
    Else
        MsgBox($MB_SYSTEMMODAL, "", "The filepath is not a directory/folder.")
    EndIf
EndFunc   ;==>Example

; Check if the filepath is a directory/folder. Does not validate if the directory/folder exists.
Func IsDir($sFilePath)
    Return StringInStr(FileGetAttrib($sFilePath), "D") > 0
EndFunc   ;==>IsDir


Function FileGetEncoding

Function Reference

FileGetEncoding

Determines the text encoding used in a file.

FileGetEncoding ( "filehandle/filename" [, mode = 1] )

Parameters

filehandle/filename | The handle of a file, as returned by a previous call to FileOpen(). Alternatively you may use a string filename as the first parameter.
mode | [optional] The UTF8 detection mode to use. $FE_ENTIRE_UTF8 (1) = Check entire file for UTF8 sequences (default) $FE_PARTIALFIRST_UTF8 (2) = Check first part of file for UTF8 sequences (the same as FileOpen() uses by default) Constants are defined in FileConstants.au3.

Return Value

Success: | the file encoding using similar values to the FileOpen() function: $FO_UTF16_LE (32) = UTF16 Little Endian. $FO_UTF16_BE (64) = UTF16 Big Endian. $FO_UTF8 (128) = UTF8 (with BOM). $FO_UTF8_NOBOM (256) = UTF8 (without BOM). $FO_ANSI (512) = ANSI (containing char > 127 and < 255)
Failure: | -1.

Constants are defined in FileConstants.au3.

Remarks

If a filename is given rather than a file handle - the file will be opened and closed during the function call.
Note: Do not mix filehandles and filenames, i.e., don't FileOpen() a file and then use a filename in this function. Use either filehandles or filenames in your routines, not both!

If a file handle is used then the "mode" parameter has no effect - the mode used for FileOpen() takes precedence.

Related

FileOpen, FileRead, FileReadLine, FileWrite, FileWriteLine

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iEncoding = FileGetEncoding(@ScriptFullPath) ; Retrieve the file encoding of the current script.
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "Error: Could not obtain the file encoding.")
    Else
        MsgBox($MB_SYSTEMMODAL, "", "FileGetEncoding: The value returned was: " & $iEncoding) ; The value returned for this example should be 0 or $FO_ANSI.
    EndIf
EndFunc   ;==>Example


Function FileGetLongName

Function Reference

FileGetLongName

Returns the long path+name of the path+name passed.

FileGetLongName ( "filename" [, flag = 0] )

Parameters

filename | Full path and file name to convert
flag | [optional] $FN_FULLPATH (0) - Default $FN_RELATIVEPATH (1) - file can have relative dir, e.g. "..\file.txt" Constants are defined in FileConstants.au3.

Return Value

Success: | the long path+name of the path+name passed.
Failure: | the parameter and sets the @error flag to 1.

Related

FileGetShortName

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath to retrieve the longname of.
    Local Const $sFilePath = @HomeDrive & "\PROGRA~1" ; Generally this is the same as @ProgramFilesDir.

    ; Display the long path+name of the program files directory.
    MsgBox($MB_SYSTEMMODAL, "", FileGetLongName($sFilePath))
EndFunc   ;==>Example


Function FileGetPos

Function Reference

FileGetPos

Retrieves the current file position.

FileGetPos ( "filehandle" )

Parameters

filehandle The handle of a file, as returned by a previous call to FileOpen().

Return Value

Success: | the position offset from the beginning of the file (First index is 0).
Failure: | 0 and sets the @error flag to non-zero.

Remarks

Failure returns 0 but 0 is also a valid file position so check @error to determine error conditions.

Related

FileOpen, FileRead, FileReadLine, FileSetPos, FileWrite, FileWriteLine

Example

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Open the file for writing (overwrite the file) and store the handle to a variable.
    Local $hFileOpen = FileOpen($sFilePath, $FO_OVERWRITE)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Write data to the file using the handle returned by FileOpen.
    FileWriteLine($hFileOpen, "Line 1")
    FileWriteLine($hFileOpen, "Line 2")
    FileWriteLine($hFileOpen, "Line 3")

    ; Flush the file to disk.
    FileFlush($hFileOpen)

    ; Check file position and try to read contents for current position.
    MsgBox($MB_SYSTEMMODAL, "", "Position: " & FileGetPos($hFileOpen) & @CRLF & "Data: " & @CRLF & FileRead($hFileOpen))

    ; Now, adjust the position to the beginning.
    FileSetPos($hFileOpen, 0, $FILE_BEGIN)

    ; Check file position and try to read contents for current position.
    MsgBox($MB_SYSTEMMODAL, "", "Position: " & FileGetPos($hFileOpen) & @CRLF & "Data: " & @CRLF & FileRead($hFileOpen))

    ; Close the handle returned by FileOpen.
    FileClose($hFileOpen)

    ; Delete the temporary file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function FileGetShortcut

Function Reference

FileGetShortcut

Retrieves details about a shortcut.

FileGetShortcut ( "lnk" )

Parameters

lnk Full path and file name of the shortcut.

Return Value

Success: | an array that contains the shortcut information. See Remarks.
Failure: | sets the @error flag to 1 if the shortcut could not be accessed.

Remarks

The array returned from this function is a single dimension array containing the following elements:
$aArray[0] = Shortcut target path
$aArray[1] = Working directory
$aArray[2] = Arguments
$aArray[3] = Description
$aArray[4] = Icon filename
$aArray[5] = Icon index
$aArray[6] = The shortcut state (@SW_SHOWNORMAL, @SW_SHOWMINNOACTIVE, @SW_SHOWMAXIMIZED)

Related

FileCreateShortcut

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the shortcut filepath.
    Local Const $sFilePath = @DesktopDir & "\FileGetShortcutExample.lnk"

    ; Create a shortcut on the desktop to explorer.exe and set the hotkey combination Ctrl+Alt+T or in AutoIt ^!t to the shortcut.
    FileCreateShortcut(@WindowsDir & "\explorer.exe", $sFilePath, @WindowsDir, "/e,c:\", _
            "Tooltip description of the shortcut.", @SystemDir & "\shell32.dll", "^!t", "15", @SW_SHOWMINNOACTIVE)

    ; Retrieve details about the shortcut.
    Local $aDetails = FileGetShortcut($sFilePath)
    If Not @error Then
        MsgBox($MB_SYSTEMMODAL, "", "Path: " & $aDetails[0] & @CRLF & _
                "Working directory: " & $aDetails[1] & @CRLF & _
                "Arguments: " & $aDetails[2] & @CRLF & _
                "Description: " & $aDetails[3] & @CRLF & _
                "Icon filename: " & $aDetails[4] & @CRLF & _
                "Icon index: " & $aDetails[5] & @CRLF & _
                "Shortcut state: " & $aDetails[6] & @CRLF)
    EndIf

    ; Delete the shortcut.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function FileGetShortName

Function Reference

FileGetShortName

Returns the 8.3 short path+name of the path+name passed.

FileGetShortName ( "filename" [, flag = 0] )

Parameters

filename | full path and file name to convert
flag | [optional] $FN_FULLPATH (0) - Default $FN_RELATIVEPATH (1) - file can have relative dir, e.g. "..\file.txt" Constants are defined in FileConstants.au3.

Return Value

Success: | the 8.3 short path+name of the path+name passed.
Failure: | the parameter and sets the @error flag to 1.

Remarks

The file needs to exist as there is no way to know the exact ~i if several file have the same 8 first characters.

Related

FileGetLongName

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath to retrieve the shortname of.
    Local Const $sFilePath = @ProgramFilesDir

    ; Display the short path+name of the program files directory.
    MsgBox($MB_SYSTEMMODAL, "", FileGetShortName($sFilePath))
EndFunc   ;==>Example


Function FileGetSize

Function Reference

FileGetSize

Returns the size of a file in bytes.

FileGetSize ( "filename" )

Parameters

filename Filename to check.

Return Value

Success: | the size of the file in bytes.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

Does not work on directories.
Divide result by 1024 to get kilobyte equivalent, or divide by 1048576 to get megabyte equivalent.

Related

DriveSpaceTotal, FileGetAttrib, FileGetTime, FileGetVersion

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Retrieve the file size (in bytes) of the AutoIt executable.
    Local $iFileSize = FileGetSize(@AutoItExe)

    ; Display the file size and convert to a readable form.
    MsgBox($MB_SYSTEMMODAL, "", ByteSuffix($iFileSize))
EndFunc   ;==>Example

Func ByteSuffix($iBytes)
    Local $iIndex = 0, $aArray = [' bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB']
    While $iBytes > 1023
        $iIndex += 1
        $iBytes /= 1024
    WEnd
    Return Round($iBytes) & $aArray[$iIndex]
EndFunc   ;==>ByteSuffix


Function FileGetTime

Function Reference

FileGetTime

Returns the time and date information for a file.

FileGetTime ( "filename" [, option = 0 [, format = 0]] )

Parameters

filename | The path to the file or directory to check.
option | [optional] Flag to indicate which timestamp $FT_MODIFIED (0) = Last modified (default) $FT_CREATED (1) = Created $FT_ACCESSED (2) = Last accessed Constants are defined in FileConstants.au3
format | [optional] to specify type of return $FT_ARRAY (0) = return an array (default) $FT_STRING (1) = return a string YYYYMMDDHHMMSS Constants are defined in FileConstants.au3

Return Value

Success: | an array or string that contains the file time information. See Remarks.
Failure: | sets the @error flag to non-zero.

Remarks

The array is a single dimension array containing six elements:
$aArray[0] = year (four digits)
$aArray[1] = month (range 01 - 12)
$aArray[2] = day (range 01 - 31)
$aArray[3] = hour (range 00 - 23)
$aArray[4] = min (range 00 - 59)
$aArray[5] = sec (range 00 - 59)
Notice that return values are zero-padded.

Related

FileGetAttrib, FileGetSize, FileGetVersion, FileSetAttrib, FileSetTime

Example

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Set the modified timestamp of the file to 1st Nov 2003 and use the current time.
    Local $iFileSetTime = FileSetTime($sFilePath, "20031101", $FT_MODIFIED)

    ; Display the modified timestamp of the file and return as a string in the format YYYYMMDDHHMMSS.
    If $iFileSetTime Then
        MsgBox($MB_SYSTEMMODAL, "", "Timestamp:" & @CRLF & FileGetTime($sFilePath, $FT_MODIFIED, 1))
    Else
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst setting the timestamp of the file.")
    EndIf

    ; Delete the temporary file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function FileGetVersion

Function Reference

FileGetVersion

Returns version information stored in a file.

FileGetVersion ( "filename" [, "stringname"] )

Parameters

filename | Filename.
stringname | [optional] Name of the string field to be retrieved from the header version file info: $FV_COMMENTS ("Comments") $FV_COMPANYNAME ("CompanyName") $FV_FILEDESCRIPTION ("FileDescription") $FV_FILEVERSION ("FileVersion") $FV_INTERNALNAME ("InternalName") $FV_LEGALCOPYRIGHT ("LegalCopyright") $FV_LEGALTRADEMARKS ("LegalTrademarks") $FV_ORIGINALFILENAME ("OriginalFilename") $FV_PRODUCTNAME ("ProductName") $FV_PRODUCTVERSION ("ProductVersion") $FV_PRIVATEBUILD ("PrivateBuild") $FV_SPECIALBUILD ("SpecialBuild") Constants are defined in FileConstants.au3.

Return Value

Success: | The version number ("#.#.#.#" format) - or the content of the specified string field.
Failure: | "0.0.0.0" if no version information (or other error) or "" if string field not filled - @error flag set to 1.

Remarks

Another special "stringname" is "DefaultLangCodepage" can be used to retrieve the default language and codepage.

The language and codepage can be used if needed to differentiate the "stringname" i.e. "080904b0\Comments" (see MSDN StringFileInfo in VerQueryValue function).

To get the version number of an AutoIt compiled script it is better to use the @AutoItVersion macro.

Related

FileGetSize, FileGetTime

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Retrieve the file version of the AutoIt executable.
    Local $sFileVersion = FileGetVersion(@AutoItExe)

    ; Display the file version. This should be equal to @AutoItVersion.
    MsgBox($MB_SYSTEMMODAL, "", $sFileVersion)
EndFunc   ;==>Example


Function FileInstall

Function Reference

FileInstall

Include and install a file with the compiled script.

FileInstall ( "source", "dest" [, flag = 0] )

Parameters

source | The source path of the file to compile. This must be a literal string; it cannot be a variable or the result of a function call. It can be a relative path (using .\ or ..\ in the path) to the source file (.au3).
dest | The destination path of the file with trailing backslash if only the directory is used. This can be a variable.
flag | [optional] this flag determines whether to overwrite files if they already exist: $FC_NOOVERWRITE (0) = (default) do not overwrite existing files $FC_OVERWRITE (1) = overwrite existing files Constants are defined in FileConstants.au3.

Return Value

Success: | 1.
Failure: | 0.

Remarks

The FileInstall() function is designed to include files into a compiled AutoIt script. These included files can then be "extracted" during execution of the compiled script if the statement is executed. Keep in mind that files such as images can greatly increase the size of a compiled script.
The source file must be specified using a string literal and can not be a variable, a macro, a calculation nor function call. The file must be able to be found during compiling, however variables, calculations and function calls do not get resolved until the script itself is running, long after compiling, making them unsuitable to define the source file.
The source cannot contain wildcards.

The only exception to the above, is that the source file may be @ScriptFullPath - this allows you to include the source script.

When this function is used from a non-compiled script, a copy operation is performed instead (to allow for easy testing pre-compilation).
Files maintain their original creation/modification timestamps when installed.

The destination directory path must already exist before this function is called, or the FileInstall() will fail, returning 0 and not creating the file, nor path. See DirCreate() for information about creating the directory path.

The file attributes on an existing file may prevent the file from being overwritten. Use FileDelete() or FileSetAttrib() to ensure the file can be installed without issue.

Related

DirCreate, FileDelete, FileSetAttrib

Example

Local $bFileInstall = False ; Change to True and ammend the file paths accordingly.

; This will install the file C:\Test.bmp to the script location.
If $bFileInstall Then FileInstall("C:\Test.bmp", @ScriptDir & "\Test.bmp")


Function FileMove

Function Reference

FileMove

Moves one or more files.

FileMove ( "source", "dest" [, flag = 0] )

Parameters

source | The source path and filename of the file to move. (* wildcards accepted - See Remarks)
dest | The destination path and filename of the moved file. (* wildcards accepted - See Remarks)
flag | [optional] this flag determines whether to overwrite files if they already exist: Can be a combination of the following: $FC_NOOVERWRITE (0) = (default) do not overwrite existing files. $FC_OVERWRITE (1) = overwrite existing files. $FC_CREATEPATH (8) = Create destination directory structure if it doesn't exist (See Remarks). Constants are defined in FileConstants.au3.

Return Value

Success: | 1.
Failure: | 0 if source cannot be moved or if dest already exists and flag=0.

Remarks

See FileFindFirstFile() for a discussion about wildcards.

If the source and destination paths are on different volumes a copy and delete operation is performed rather than a move.

Because AutoIt lacks a "FileRename" function, use FileMove() to rename a file!

The destination directory must already exist, except using with flag value $FC_CREATEPATH (8).
For instance the combined flag $FC_OVERWRITE (1) + $FC_CREATEPATH (8) overwrites the target file and prechecks for the destination directory structure and if it doesn't exist creates it automatically.

Some file attributes can make the overwriting impossible, if this is the case look at FileSetAttrib() to change the attributes of a file.

Related

DirMove, FileCopy, FileDelete, FileRecycle

Example

Example 1

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Create a temporary file to move.
    If Not FileWrite($sFilePath, "This is an example of using FileMove.") Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Move Au3 files in the temporary directory to a new folder/directory called Au3Files.
    FileMove(@TempDir & "\*.au3", @TempDir & "\Au3Files\", $FC_OVERWRITE + $FC_CREATEPATH)

    ; Display the temporary directory.
    ShellExecute(@TempDir)
EndFunc   ;==>Example

Example 2

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepaths that will be renamed.
    Local Const $sSource = _WinAPI_GetTempFileName(@TempDir), _
            $sDestination = _WinAPI_GetTempFileName(@TempDir)

    ; Create a temporary file to rename.
    If Not FileWrite($sSource, "This is an example of using FileMove.") Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Rename a file using FileMove and overwrite the new file if it exists.
    FileMove($sSource, $sDestination, $FC_OVERWRITE)

    ; Display results that the destination file was renamed.
    MsgBox($MB_SYSTEMMODAL, "", "Does the source file exist?: " & FileExists($sSource) & @CRLF & _ ; FileExists should return 0.
            "Does destination file exist?: " & FileExists($sDestination) & @CRLF) ; FileExists should return 1.

    ; Delete the temporary files. FileDelete checks if the file exists.
    FileDelete($sSource)
    FileDelete($sDestination)
EndFunc   ;==>Example


Function FileOpen

Function Reference

FileOpen

Opens a file for reading or writing.

FileOpen ( "filename" [, mode = 0] )

Parameters

filename Filename of the file to open.
mode [optional] Mode to open the file in.
Can be a combination of the following:
$FO_READ (0) = Read mode (default)
$FO_APPEND (1) = Write mode (append to end of file)
$FO_OVERWRITE (2) = Write mode (erase previous contents)
$FO_CREATEPATH (8) = Create directory structure if it doesn't exist (See Remarks).
$FO_BINARY (16) = Force binary mode (See Remarks).
$FO_UNICODE or $FO_UTF16_LE (32) = Use Unicode UTF16 Little Endian reading and writing mode.
$FO_UTF16_BE (64) = Use Unicode UTF16 Big Endian reading and writing mode.
$FO_UTF8 (128) = Use Unicode UTF8 (with BOM) reading and writing mode.
$FO_UTF8_NOBOM (256) = Use Unicode UTF8 (without BOM) reading and writing mode.
$FO_ANSI (512) = Use ANSI reading and writing mode.
$FO_UTF16_LE_NOBOM (1024) = Use Unicode UTF16 Little Endian (without BOM) reading and writing mode.
$FO_UTF16_BE_NOBOM (2048) = Use Unicode UTF16 Big Endian (without BOM) reading and writing mode.
$FO_FULLFILE_DETECT (16384) = When opening for reading and no BOM is present, use the entire file to determine if it is UTF8 or UTF16. If this is not used then only the initial part of the file (up to 64KB) is checked for performance reasons.
The folder path must already exist (except using $FO_CREATEPATH mode - See Remarks).

Constants are defined in FileConstants.au3.

Return Value

Success: | a file "handle" for use with subsequent file functions.
Failure: | -1 if error occurs.

Remarks

The file handle must be closed with the FileClose() function.

A file may fail to open due to access rights or attributes.

The default mode when writing text is UTF8 (without BOM) - use the unicode mode flags to change this. When reading without an explicit unicode mode flag, the content of the file is examined and a guess is made whether the file is UTF8, UTF16 or ANSI. If opening an existing file and that file has a BOM then the BOM will be honored regardless of the unicode mode flags passed.

Opening a file in write mode creates the file if it does not exist. Directories are not created unless the correct flag is used.

When reading and writing via the same file handle, the FileSetPos() function must be used to update the current file position.

A file can be read as binary (byte) data by using FileOpen() with the binary flag.

See "Unicode Support" for a detailed description.

Related

FileClose, FileFlush, FileGetPos, FileRead, FileReadLine, FileSetPos, FileWrite, FileWriteLine

Example

Example 1

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Create a temporary file to read data from.
    If Not FileWrite($sFilePath, "This is an example of using FileOpen.") Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Open the file for reading and store the handle to a variable.
    Local $hFileOpen = FileOpen($sFilePath, $FO_READ)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.")
        Return False
    EndIf

    ; Read the contents of the file using the handle returned by FileOpen.
    Local $sFileRead = FileRead($hFileOpen)

    ; Close the handle returned by FileOpen.
    FileClose($hFileOpen)

    ; Display the contents of the file.
    MsgBox($MB_SYSTEMMODAL, "", "Contents of the file:" & @CRLF & $sFileRead)

    ; Delete the temporary file.
    FileDelete($sFilePath)
EndFunc   ;==>Example

Example 2

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Open the file for read/write access.
    Local $hFileOpen = FileOpen($sFilePath, $FO_READ + $FO_OVERWRITE)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading/writing the file.")
        Return False
    EndIf

    ; Write some data.
    FileWrite($hFileOpen, "This is some data to show that the handle was open with read/write access." & @CRLF)

    ; Retrieve the current position in the file.
    Local $iFilePos = FileGetPos($hFileOpen)

    ; Now, adjust the position to the beginning.
    FileSetPos($hFileOpen, 0, $FILE_BEGIN)

    ; Display the contents of the file.
    MsgBox($MB_SYSTEMMODAL, "", FileRead($hFileOpen))

    ; Now, adjust the position back to the previous position.
    FileSetPos($hFileOpen, 0, $iFilePos)

    ; Write some addition data.
    FileWrite($hFileOpen, "This is some additional data.")

    ; Adjust the position back to the previous position.
    FileSetPos($hFileOpen, 0, $FILE_BEGIN)

    ; Display the contents of the file.
    MsgBox($MB_SYSTEMMODAL, "", FileRead($hFileOpen))

    ; Close the handle returned by FileOpen.
    FileClose($hFileOpen)

    ; Delete the temporary file.
    FileDelete($sFilePath)

    Return True
EndFunc   ;==>Example


Function FileOpenDialog

Function Reference

FileOpenDialog

Initiates a Open File Dialog.

FileOpenDialog ( "title", "init dir", "filter" [, options = 0 [, "default name" [, hwnd]]] )

Parameters

title | Title text of the Dialog GUI.
init dir | Initial directory selected in the GUI file tree.
filter | File type single filter such as "All (*.*)" or "Text files (*.txt)" or multiple filter groups such as "All (*.*)|Text files (*.txt)" (See Remarks).
options | [optional] Dialog Options: To use more than one option, BitOR the required values together. $FD_FILEMUSTEXIST (1) = File Must Exist (if user types a filename) $FD_PATHMUSTEXIST (2) = Path Must Exist (if user types a path, ending with a backslash) $FD_MULTISELECT (4) = Allow MultiSelect $FD_PROMPTCREATENEW (8) = Prompt to Create New File (if does not exist) Constants are defined in FileConstants.au3.
default name | [optional] Suggested file name for the user to open. Default is blank ("").
hwnd | [optional] The window handle to use as the parent for this dialog.

Return Value

Success: | the full path of the file(s) chosen. Results for multiple selections are "Directory|file1|file2|...".
Failure: | sets the @error flag to non-zero.
@error: | 1 = File selection failed. 2 = Bad file filter

Remarks

Separate the file filters with a semicolon as shown in the example.
Multiple groups of filters are separated by a pipe "|".

If default name is given, options must also be given. If none of the options are wanted, use 0 for options.

Special Windows folders (such as "My Documents") can be set as root by using the right CLSID detailed in the Appendix.

@WorkingDir is changed on successful return.

Related

FileSaveDialog, FileSelectFolder, StringSplit

Example

Example 1

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the message to display in FileOpenDialog.
    Local Const $sMessage = "Hold down Ctrl or Shift to choose multiple files."

    ; Display an open dialog to select a list of file(s).
    Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "Images (*.jpg;*.bmp)|Videos (*.avi;*.mpg)", $FD_FILEMUSTEXIST + $FD_MULTISELECT)
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.")

        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)
    Else
        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)

        ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog.
        $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF)

        ; Display the list of selected files.
        MsgBox($MB_SYSTEMMODAL, "", "You chose the following files:" & @CRLF & $sFileOpenDialog)
    EndIf
EndFunc   ;==>Example

Example 2

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the message to display in FileOpenDialog.
    Local Const $sMessage = "Select a single file of any type."

    ; Display an open dialog to select a file.
    Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "All (*.*)", $FD_FILEMUSTEXIST)
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No file was selected.")

        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)
    Else
        ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
        FileChangeDir(@ScriptDir)

        ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog.
        $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF)

        ; Display the selected file.
        MsgBox($MB_SYSTEMMODAL, "", "You chose the following file:" & @CRLF & $sFileOpenDialog)
    EndIf
EndFunc   ;==>Example


Function FileRead

Function Reference

FileRead

Read in a number of characters from a previously opened file.

FileRead ( "filehandle/filename" [, count] )

Parameters

filehandle/filename | The handle of a file, as returned by a previous call to FileOpen(). Alternatively you may use a string filename as the first parameter.
count | [optional] The number of characters to read. See remarks.

Return Value

Success: | the binary/string read. @extended is set to the number of bytes/characters returned.
Failure: | sets the @error flag to non-zero.
@error: | 1 = if file not opened in read mode or other error -1 = if end-of-file is reached

Remarks

A negative or not defined count, reads the whole file from the current position.

If a filename is given rather than a file handle - the file will be opened and closed during the function call - for parsing large files this will be much slower than using filehandles.
Note: Do not mix filehandles and filenames, i.e., don't FileOpen() a file and then use a filename in this function. Use either filehandles or filenames in your routines, not both!

Both ANSI and UTF16/UTF8 text formats can be read - See FileOpen() for details.

A file can be read as binary (byte) data by using FileOpen() with the binary flag - in this case count is in bytes rather than characters. A count value that is too large can lead to AutoIt stopping with a memory allocation failure.

Related

FileGetPos, FileOpen, FileReadLine, FileSetPos, FileWrite, FileWriteLine, String

Example

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Create a temporary file to read data from.
    If Not FileWrite($sFilePath, "This is an example of using FileRead.") Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Open the file for reading and store the handle to a variable.
    Local $hFileOpen = FileOpen($sFilePath, $FO_READ)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.")
        Return False
    EndIf

    ; Read the contents of the file using the handle returned by FileOpen.
    Local $sFileRead = FileRead($hFileOpen)

    ; Close the handle returned by FileOpen.
    FileClose($hFileOpen)

    ; Display the contents of the file.
    MsgBox($MB_SYSTEMMODAL, "", "Contents of the file:" & @CRLF & $sFileRead)

    ; Delete the temporary file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function FileReadLine

Function Reference

FileReadLine

Read in a line of text from a previously opened text file.

FileReadLine ( "filehandle/filename" [, line = 1] )

Parameters

filehandle/filename | The handle of a file, as returned by a previous call to FileOpen(). Alternatively you may use a string filename as the first parameter.
line | [optional] The line number to read. The first line of a text file is line 1 (not zero), last line is -1.

Return Value

Success: | a line of text.
Failure: | sets the @error flag to non-zero.
@error: | 1 = if file not opened in read mode or other error -1 = if end-of-file is reached

Remarks

Returns the text of the line read, any newline characters ( Chr(10) or @LF ) at the end of a line read in are automatically stripped.
If no line number to read is given, the "next" line will be read. ("Next" for a newly opened file is initially the first line.)
If a filename is given rather than a file handle - the file will be opened and closed during the function call - for parsing large text files this will be much slower than using filehandles.
Note: Do not mix filehandles and filenames, i.e., don't FileOpen() a file and then use a filename in this function. Use either filehandles or filenames in your routines, not both!

From a performance standpoint it is a bad idea to read line by line specifying "line" parameter whose value is incrementing by one. This forces AutoIt to reread the file from the beginning until it reach the specified line.

Both ANSI and UTF16/UTF8 text formats can be read - See FileOpen() for details.

Related

FileGetPos, FileOpen, FileRead, FileSetPos, FileWrite, FileWriteLine, IniRead

Example

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Create a temporary file to read data from.
    If Not FileWrite($sFilePath, "This is an example of using FileReadLine.") Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Open the file for reading and store the handle to a variable.
    Local $hFileOpen = FileOpen($sFilePath, $FO_READ)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.")
        Return False
    EndIf

    ; Read the fist line of the file using the handle returned by FileOpen.
    Local $sFileRead = FileReadLine($hFileOpen, 1)

    ; Close the handle returned by FileOpen.
    FileClose($hFileOpen)

    ; Display the first line of the file.
    MsgBox($MB_SYSTEMMODAL, "", "First line of the file:" & @CRLF & $sFileRead)

    ; Delete the temporary file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function FileReadToArray

Function Reference

FileReadToArray

Reads the specified file into an array.

FileReadToArray ( "filehandle/filename" )

Parameters

filehandle/filename The handle of a file, as returned by a previous call to FileOpen(). Alternatively you may use a string filename as the first parameter.

Return Value

Success: | a 1 dimension array containing one line of text per element and @extended set to the number of lines read.
Failure: | sets the @error flag to non_zero.
@error: | 1 = Error opening specified file 2 = Empty file

Remarks

Use @extended or UBound() to determine the number of lines read.

Related

FileRead, FileReadLine

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Read the current script file into an array using the filepath.
    Local $aArray = FileReadToArray(@ScriptFullPath)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file.
    Else
        For $i = 0 To UBound($aArray) - 1 ; Loop through the array.
            MsgBox($MB_SYSTEMMODAL, "", $aArray[$i]) ; Display the contents of the array.
        Next
    EndIf
EndFunc   ;==>Example


Function FileRecycle

Function Reference

FileRecycle

Sends a file or directory to the recycle bin.

FileRecycle ( "source" )

Parameters

source The source path of the file(s) or directory to Recycle. (* and ? wildcards accepted - See Remarks)

Return Value

Success: | 1.
Failure: | 0 (typically meaning the file is in use or does not exist).

Remarks

See FileFindFirstFile() for a discussion about wildcards.

To remove a directory, simply give the path without a trailing backslash.

Related

DirRemove, FileDelete, FileMove, FileRecycleEmpty

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Create a temporary file to read data from.
    If Not FileWrite($sFilePath, "This is an example of using FileRecycle.") Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Display the contents of the file passing the filepath to FileRead instead of a handle returned by FileOpen.
    MsgBox($MB_SYSTEMMODAL, "", "Contents of the file:" & @CRLF & FileRead($sFilePath))

    ; Delete the temporary file by sending to the recycle bin.
    Local $iRecycle = FileRecycle($sFilePath)

    ; Display a message of whether the file was deleted and open the recycle bin if successful.
    If $iRecycle Then
        MsgBox($MB_SYSTEMMODAL, "", "The file was successfuly deleted.")

        ; Open the recycle bin by using the following CLSID.
        ShellExecute("::{645FF040-5081-101B-9F08-00AA002F954E}")
    Else
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst deleting the file.")
    EndIf
EndFunc   ;==>Example


Function FileRecycleEmpty

Function Reference

FileRecycleEmpty

Empties the recycle bin.

FileRecycleEmpty ( ["source"] )

Parameters

source [optional] The rootpath to empty - if omitted the recycle bin for all drives is emptied.

Return Value

Success: | 1.
Failure: | 0 (the recycle bin cannot be emptied - see below).

Remarks

For this function to work IE4+ must be available.

Related

FileDelete, FileRecycle

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Open the recycle bin by using the following CLSID.
    ShellExecute("::{645FF040-5081-101B-9F08-00AA002F954E}")

    ; Display a message box asking whether or not you would like to delete files in the recycle bin.
    If MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL), "", "Would you like to empty the recycle bin on the " & @HomeDrive & "\ drive?") = $IDNO Then Return False

    ; Delete files in the recycle bin. This is for the @HomeDrive only, which is generally the C:\ drive.
    Local $iRecycle = FileRecycleEmpty(@HomeDrive)

    ; Display a message of whether the recycle bin was emptied successfuly.
    If $iRecycle Then
        MsgBox($MB_SYSTEMMODAL, "", "The recycle bin was emptied successfuly.")
    Else
        MsgBox($MB_SYSTEMMODAL, "", "The recycle bin wasn't emptied successfuly.")
    EndIf
EndFunc   ;==>Example


Function FileSaveDialog

Function Reference

FileSaveDialog

Initiates a Save File Dialog.

FileSaveDialog ( "title", "init dir", "filter" [, options = 0 [, "default name" [, hwnd]]] )

Parameters

title | Title text of the Dialog GUI.
init dir | Initial directory selected in the GUI file tree.
filter | File type single filter such as "All (*.*)" or "Text files (*.txt)" or multiple filter groups such as "All (*.*)|Text files (*.txt)" (See Remarks).
options | [optional] Dialog Options: To use more than one option, BitOR the required values together. $FD_PATHMUSTEXIST (2) = Path Must Exist (if user types a path, ending with a backslash) $FD_PROMPTOVERWRITE (16) = Prompt to OverWrite File Constants are defined in FileConstants.au3.
default name | [optional] File name to suggest to the user to save the file with. Default is blank ("").
hwnd | [optional] The window handle to use as the parent for this dialog.

Return Value

Success: | the full path of the file chosen. Results for multiple selections are "Directory|file1|file2|..."
Failure: | sets the @error flag to non-zero.
@error: | 1 = File selection failed. 2 = Bad file filter

Remarks

Separate the file filters with a semicolon as shown in the example.
Multiple groups of filters are separated by a pipe "|".

If default name is given, options must also be given. If none of the options are wanted, use 0 for options.

Special Windows folders (such as "My Documents") can be set as root by using the right CLSID detailed in the Appendix.

@WorkingDir is changed on successful return.

Related

FileOpenDialog, FileSelectFolder

Example

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the message to display in FileSaveDialog.
    Local Const $sMessage = "Choose a filename."

    ; Display a save dialog to select a file.
    Local $sFileSaveDialog = FileSaveDialog($sMessage, "::{450D8FBA-AD25-11D0-98A8-0800361B1103}", "Scripts (*.au3)", $FD_PATHMUSTEXIST)
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No file was saved.")
    Else
        ; Retrieve the filename from the filepath e.g. Example.au3.
        Local $sFileName = StringTrimLeft($sFileSaveDialog, StringInStr($sFileSaveDialog, "\", $STR_NOCASESENSE, -1))

        ; Check if the extension .au3 is appended to the end of the filename.
        Local $iExtension = StringInStr($sFileName, ".", $STR_NOCASESENSE)

        ; If a period (dot) is found then check whether or not the extension is equal to .au3.
        If $iExtension Then
            ; If the extension isn't equal to .au3 then append to the end of the filepath.
            If Not (StringTrimLeft($sFileName, $iExtension - 1) = ".au3") Then $sFileSaveDialog &= ".au3"
        Else
            ; If no period (dot) was found then append to the end of the file.
            $sFileSaveDialog &= ".au3"
        EndIf

        ; Display the saved file.
        MsgBox($MB_SYSTEMMODAL, "", "You saved the following file:" & @CRLF & $sFileSaveDialog)
    EndIf
EndFunc   ;==>Example


Function FileSelectFolder

Function Reference

FileSelectFolder

Initiates a Browse For Folder dialog.

FileSelectFolder ( "dialog text", "root dir" [, flag = 0 [, "initial dir" [, hwnd]]] )

Parameters

dialog text | Text greeting in dialog.
root dir | Root directory of GUI file tree. It limits a choice in the root folder. Use "" for Desktop to be root.
flag | [optional] $FSF_CREATEBUTTON (1) = Show Create Folder Button (XP only) $FSF_NEWDIALOG (2) = Use New Dialog Style (XP only) $FSF_EDITCONTROL (4) = Show Edit Control (XP only) Constants are defined in FileConstants.au3.
initial dir | [optional] The full path of the folder you selected/highlighted when displaying dialogue (if it exists in the root folder). Default is blank ("").
hwnd | [optional] The window handle to use as the parent for this dialog.

Return Value

Success: | the full path of the folder chosen.
Failure: | "" (empty string) and sets the @error flag to 1 if user cancels/closes the window.

Remarks

The root dir will be chosen if the initial dir (if given) does not exist.
A nonexistent root dir will also cause the Desktop folder to be root.
Special Windows folders (such as "My Documents") can be set as root by using the right CLSID detailed in the Appendix.
UNC paths are not supported. If you think that user's may choose files on a UNC path then the path needs to be mapped as a drive first.

The new vista+ dialog style is used if possible, regardless of the Use New Dialog Style flag. With the vista dialog style the edit control and create folder buttons are always shown, ignoring the flags parameter, and the dialog text parameter sets the title of the window.

Related

FileOpenDialog, FileSaveDialog

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the message to display in FileSelectFolder.
    Local Const $sMessage = "Select a folder"

    ; Display an open dialog to select a file.
    Local $sFileSelectFolder = FileSelectFolder($sMessage, "")
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.")
    Else
        ; Display the selected folder.
        MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder)
    EndIf
EndFunc   ;==>Example


Function FileSetAttrib

Function Reference

FileSetAttrib

Sets the attributes of one or more files/directories.

FileSetAttrib ( "file pattern", "+-RASHNOT" [, recurse = 0] )

Parameters

file pattern | The path of the file(s) to set, e.g. C:\*.au3, C:\Dir. (* and ? wildcards accepted - See Remarks)
+-RASHNOT | Attribute(s) to set/clear. e.g. "+A", "+RA-SH"
recurse | [optional] $FT_NONRECURSIVE (0) - no recursion (Default) $FT_RECURSIVE (1) - directories are recursed into. Constants are defined in FileConstants.au3.

Return Value

Success: | 1.
Failure: | 0 if encountered any errors.

Remarks

See FileFindFirstFile() for a discussion about wildcards.

The file pattern cannot contain spaces!
The attributes that can be modified with the function are + or -:
"R" = READONLY
"A" = ARCHIVE
"S" = SYSTEM
"H" = HIDDEN
"N" = NORMAL
"O" = OFFLINE
"T" = TEMPORARY

(Note that you cannot set the compressed/directory attributes with this function.)

Related

FileGetAttrib, FileGetTime, FileSetTime

Example

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>

If MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL), "", "Note: This is an example and shouldn't be run under normal circumstances. " & @CRLF & @CRLF & "Do you wish to run the example?") = $IDYES Then
    ; Mark all .au3 files in current directory as read-only and system.
    If Not FileSetAttrib(@ScriptDir & "\*.au3", "+RS") Then
        MsgBox($MB_SYSTEMMODAL, "Error", "Problem setting attributes.")
    EndIf

    ; Mark all .bmp files in @HomeDrive and sub-directories writable and archived.
    If Not FileSetAttrib(@HomeDrive & "\*.bmp", "-R+A", $FT_RECURSIVE) Then
        MsgBox($MB_SYSTEMMODAL, "Error", "Problem setting attributes.")
    EndIf
EndIf


Function FileSetEnd

Function Reference

FileSetEnd

Sets the end of the file at the current file position.

FileSetEnd ( "filehandle" )

Parameters

filehandle The handle of a file, as returned by a previous call to FileOpen().

Return Value

Success: | True if the operation succeeded.
Failure: | False.

Related

FileFlush, FileGetPos, FileOpen, FileRead, FileReadLine, FileSetPos, FileWrite, FileWriteLine

Example

Example 1

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Open the file for writing (overwrite the file) and store the handle to a variable.
    Local $hFileOpen = FileOpen($sFilePath, $FO_OVERWRITE)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Write data to the file using the handle returned by FileOpen.
    FileWriteLine($hFileOpen, "Line 1")
    FileWriteLine($hFileOpen, "Line 2")
    FileWriteLine($hFileOpen, "Line 3")

    ; Flush the file to disk.
    FileFlush($hFileOpen)

    ; Now, adjust the position to the beginning.
    FileSetPos($hFileOpen, 0, $FILE_BEGIN)

    ; Check file position and try to read contents for current position.
    MsgBox($MB_SYSTEMMODAL, "", "Position: " & FileGetPos($hFileOpen) & @CRLF & "Data: " & @CRLF & FileRead($hFileOpen))

    ; Write data to the file using the handle returned by FileOpen.
    FileWriteLine($hFileOpen, "Line 4")
    FileWriteLine($hFileOpen, "Line 5")
    FileWriteLine($hFileOpen, "Line 6")

    ; Now, adjust the position to the beginning.
    FileSetPos($hFileOpen, 0, $FILE_BEGIN)

    ; Check file position and try to read contents for current position.
    MsgBox($MB_SYSTEMMODAL, "", "Position: " & FileGetPos($hFileOpen) & @CRLF & "Data: " & @CRLF & FileRead($hFileOpen))

    ; Now, adjust the position to the beginning.
    FileSetPos($hFileOpen, 0, $FILE_BEGIN)

    ; Set the end of the file at the current position.
    FileSetEnd($hFileOpen)

    ; Check file position and try to read contents for current position. The contents have been destroyed.
    MsgBox($MB_SYSTEMMODAL, "", "Position: " & FileGetPos($hFileOpen) & @CRLF & "Data: " & @CRLF & FileRead($hFileOpen))

    ; Close the handle returned by FileOpen.
    FileClose($hFileOpen)

    ; Delete the temporary file.
    FileDelete($sFilePath)
EndFunc   ;==>Example

Example 2

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Open the file for writing (overwrite the file) and store the handle to a variable.
    Local $hFileOpen = FileOpen($sFilePath, $FO_OVERWRITE)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Write data to the file using the handle returned by FileOpen and set the end of the file.
    FileWrite($hFileOpen, "ABCDEF")
    FileSetEnd($hFileOpen)

    ; Display the file size and contents.
    MsgBox($MB_SYSTEMMODAL, "", "Size: " & FileGetSize($sFilePath) & @CRLF & "Data: " & @CRLF & FileRead($sFilePath))

    ; Expand the size of the file to 9 bytes and don't write any additional data.
    FileSetPos($hFileOpen, 9, $FILE_BEGIN)
    FileSetEnd($hFileOpen)

    ; Display the file size and contents.
    MsgBox($MB_SYSTEMMODAL, "", "Size: " & FileGetSize($sFilePath) & @CRLF & "Data: " & @CRLF & FileRead($sFilePath))

    ; Move the position after ABCDEF i.e. 6 bytes and then write additional data which will expand the file to 12 bytes.
    FileSetPos($hFileOpen, 6, $FILE_BEGIN)
    FileWrite($hFileOpen, "HIJKLM")
    FileSetEnd($hFileOpen) ; Set the end of the file.

    ; Display the file size and contents.
    MsgBox($MB_SYSTEMMODAL, "", "Size: " & FileGetSize($sFilePath) & @CRLF & "Data: " & @CRLF & FileRead($sFilePath))

    ; Truncate the file size to 9 bytes.
    FileSetPos($hFileOpen, 9, $FILE_BEGIN)
    FileSetEnd($hFileOpen) ; Set the end of the file.

    ; Display the file size and contents.
    MsgBox($MB_SYSTEMMODAL, "", "Size: " & FileGetSize($sFilePath) & @CRLF & "Data: " & @CRLF & FileRead($sFilePath))

    ; Close the handle returned by FileOpen.
    FileClose($hFileOpen)

    ; Delete the temporary file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function FileSetPos

Function Reference

FileSetPos

Sets the current file position.

FileSetPos ( "filehandle", offset, origin )

Parameters

filehandle | The handle of a file, as returned by a previous call to FileOpen().
offset | The offset to move from the origin. This value may be positive or negative. Negative values move backwards from the origin.
origin | Must be one of the following: $FILE_BEGIN (0) = Beginning of the file. $FILE_CURRENT (1) = Current position. $FILE_END (2) = End of the file. Constants are defined in FileConstants.au3.

Return Value

Success: | True if the operation succeeded.
Failure: | False.

Remarks

Include Constants.au3 in your script to use the symbolic name in parentheses to specify the origin.
Using FileSetPos() it is possible to both read and write to the same file. When attempting to read and write to the same file, always call FileFlush() between each write and read operation.
Moving the pointer to the middle of the data can be used to overwrite data.

Related

FileFlush, FileGetPos, FileOpen, FileRead, FileReadLine, FileWrite, FileWriteLine

Example

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Open the file for writing (overwrite the file) and store the handle to a variable.
    Local $hFileOpen = FileOpen($sFilePath, $FO_OVERWRITE)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Write data to the file using the handle returned by FileOpen.
    FileWriteLine($hFileOpen, "Line 1")
    FileWriteLine($hFileOpen, "Line 2")
    FileWriteLine($hFileOpen, "Line 3")

    ; Flush the file to disk.
    FileFlush($hFileOpen)

    ; Check file position and try to read contents for current position.
    MsgBox($MB_SYSTEMMODAL, "", "Position: " & FileGetPos($hFileOpen) & @CRLF & "Data: " & @CRLF & FileRead($hFileOpen))

    ; Now, adjust the position to the beginning.
    FileSetPos($hFileOpen, 0, $FILE_BEGIN)

    ; Check file position and try to read contents for current position.
    MsgBox($MB_SYSTEMMODAL, "", "Position: " & FileGetPos($hFileOpen) & @CRLF & "Data: " & @CRLF & FileRead($hFileOpen))

    ; Close the handle returned by FileOpen.
    FileClose($hFileOpen)

    ; Delete the temporary file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function FileSetTime

Function Reference

FileSetTime

Sets the timestamp of one of more files.

FileSetTime ( "file pattern", "time" [, type = 0 [, recurse = 0]] )

Parameters

file pattern | The path of the file(s) to set, e.g. C:\*.au3, C:\Dir. (* and ? wildcards accepted - See Remarks)
time | The new time to set in the format "YYYYMMDDHHMMSS" (Year, month, day, hours (24hr clock), seconds). If the time is blank "" then the current time is used.
type | [optional] The timestamp to change: $FT_MODIFIED (0) = Last modified (default) $FT_CREATED (1) = Created $FT_ACCESSED (2) = Last accessed Constants are defined in FileConstants.au3
recurse | [optional] $FT_NONRECURSIVE (0) - no recursion (Default). $FT_RECURSIVE (1) - directories are recursed into. Constants are defined in FileConstants.au3

Return Value

Success: | 1.
Failure: | 0 if error changing timestamp(s).

Remarks

See FileFindFirstFile() for a discussion about wildcards.

Using a date earlier than 1980-01-01 will have no effect.
Trying to change a timestamp on read-only files will result in an error.

Related

FileGetAttrib, FileGetTime, FileSetAttrib

Example

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Create a temporary file to read data from.
    If Not FileWrite($sFilePath, "This is an example of using FileSetTime.") Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Set the modified timestamp of the file to 1st Nov 2003 and use the current time.
    Local $iFileSetTime = FileSetTime($sFilePath, "20031101", $FT_MODIFIED)

    ; Display the modified timestamp of the file and return as a string in the format YYYYMMDDHHMMSS.
    If $iFileSetTime Then
        MsgBox($MB_SYSTEMMODAL, "", "Timestamp:" & @CRLF & FileGetTime($sFilePath, $FT_MODIFIED, 1))
    Else
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst setting the timestamp of the file.")
    EndIf

    ; Delete the temporary file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function FileWrite

Function Reference

FileWrite

Write text/data to the end of a previously opened file.

FileWrite ( "filehandle/filename", "text/data" )

Parameters

filehandle/filename | The handle of a file, as returned by a previous call to FileOpen(). Alternatively, you may use a string filename as the first parameter.
text/data | The text/data to write to the file. The text is written as is - no @CR or @LF characters are added. See remark for data type.

Return Value

Success: | 1.
Failure: | 0 if file not opened in writemode, file is read only, or file cannot otherwise be written to.

Remarks

The file must be opened in write mode or the FileWrite() command will fail.

If a filename is given rather than a file handle, the file will be opened and closed during the function call. For parsing large text files this will be much slower than using filehandles. However, filename will be created if it does not already exist.

Note: Do not mix filehandles and filenames, i.e., don't FileOpen() a file and then use a filename in this function. Either use filehandles or filenames in your routines, not both.

When writing text AutoIt will write using UTF8 (without BOM) by default. To write in another mode the file must be opened with FileOpen() and the relevant flags.

If the data is a binary type variant (and not text) it will be written to the file byte by byte. Binary operation can also be forced by using FileOpen() with the binary flag.

Related

Binary, FileFlush, FileGetPos, FileOpen, FileRead, FileReadLine, FileSetPos, FileWriteLine

Example

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Create a temporary file to write data to.
    If Not FileWrite($sFilePath, "Start of the FileWrite example, line 1. " & @CRLF) Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Open the file for writing (append to the end of a file) and store the handle to a variable.
    Local $hFileOpen = FileOpen($sFilePath, $FO_APPEND)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Write data to the file using the handle returned by FileOpen.
    FileWrite($hFileOpen, "Line 2")
    FileWrite($hFileOpen, "This is still line 2 as a new line wasn't appended to the last FileWrite call." & @CRLF)
    FileWrite($hFileOpen, "Line 3" & @CRLF)
    FileWrite($hFileOpen, "Line 4")

    ; Close the handle returned by FileOpen.
    FileClose($hFileOpen)

    ; Display the contents of the file passing the filepath to FileRead instead of a handle returned by FileOpen.
    MsgBox($MB_SYSTEMMODAL, "", "Contents of the file:" & @CRLF & FileRead($sFilePath))

    ; Delete the temporary file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function FileWriteLine

Function Reference

FileWriteLine

Append a line of text to the end of a previously opened text file.

FileWriteLine ( "filehandle/filename", "line" )

Parameters

filehandle/filename | The handle of a file, as returned by a previous call to FileOpen(). Alternatively, you may use a string filename as the first parameter.
line | The line of text to write to the text file. If the line does NOT end in @CR or @LF then a DOS linefeed (@CRLF) will be automatically added.

Return Value

Success: | 1.
Failure: | 0 if file not opened in writemode, file is read only, or file cannot otherwise be written to.

Remarks

The text file must be opened in write mode or the FileWriteLine() command will fail.

If a filename is given rather than a file handle, the file will be opened and closed during the function call. For parsing large text files this will be much slower than using filehandles. However, filename will be created if it does not already exist.

Note: Do not mix filehandles and filenames, i.e., don't FileOpen() a file and then use a filename in this function. Either use filehandles or filenames in your routines, not both.

When writing text AutoIt will write using UTF8 (without BOM) by default. To write in another mode the file must be opened with FileOpen() and the relevant flags.

The text to write cannot contain Chr(0) characters as the output is truncated. FileWrite() using a file opened in binary mode must be used to write such characters.

Related

FileFlush, FileGetPos, FileOpen, FileRead, FileReadLine, FileSetPos, FileWrite

Example

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Create a temporary file to write data to.
    If Not FileWrite($sFilePath, "Start of the FileWriteLine example, line 1. " & @CRLF) Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Open the file for writing (append to the end of a file) and store the handle to a variable.
    Local $hFileOpen = FileOpen($sFilePath, $FO_APPEND)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.")
        Return False
    EndIf

    ; Write data to the file using the handle returned by FileOpen.
    FileWriteLine($hFileOpen, "Line 2")
    FileWriteLine($hFileOpen, "This is line 3 as a new line was appended to the last FileWriteLine call." & @CRLF)
    FileWriteLine($hFileOpen, "Line 4" & @CRLF)
    FileWriteLine($hFileOpen, "Line 5")

    ; Close the handle returned by FileOpen.
    FileClose($hFileOpen)

    ; Display the contents of the file passing the filepath to FileRead instead of a handle returned by FileOpen.
    MsgBox($MB_SYSTEMMODAL, "", "Contents of the file:" & @CRLF & FileRead($sFilePath))

    ; Delete the temporary file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function IniDelete

Function Reference

IniDelete

Deletes a value from a standard format .ini file.

IniDelete ( "filename", "section" [, "key"] )

Parameters

filename | The filename of the .ini file.
section | The section name in the .ini file.
key | [optional] The key name in the .ini file to delete. If the key name is not given the entire section is deleted. The Default keyword may also be used which will cause the section to be deleted.

Return Value

Success: | 1.
Failure: | 0 if the INI file does not exist or if the file is read-only.

Remarks

A standard ini file looks like:
[SectionName]
Key=Value

Related

IniRead, IniReadSection, IniReadSectionNames, IniRenameSection, IniWrite, IniWriteSection

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Write the value of 'AutoIt' to the key 'Title' and in the section labelled 'General'.
    IniWrite($sFilePath, "General", "Title", "AutoIt")

    ; Read the INI file for the value of 'Title' in the section labelled 'General'.
    Local $sRead = IniRead($sFilePath, "General", "Title", "Default Value")

    ; Display the value returned by IniRead.
    MsgBox($MB_SYSTEMMODAL, "", "The value of 'Title' in the section labelled 'General' is: " & $sRead)

    ; Delete the key labelled 'Title'.
    IniDelete($sFilePath, "General", "Title")

    ; Read the INI file for the value of 'Title' in the section labelled 'General'.
    $sRead = IniRead($sFilePath, "General", "Title", "Default Value")

    ; Display the value returned by IniRead. Since there is no key stored the value will be the 'Default Value' passed to IniRead.
    MsgBox($MB_SYSTEMMODAL, "", "The value of 'Title' in the section labelled 'General' is: " & $sRead)

    ; Delete the INI file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function IniRead

Function Reference

IniRead

Reads a value from a standard format .ini file.

IniRead ( "filename", "section", "key", "default" )

Parameters

filename | The filename of the .ini file.
section | The section name in the .ini file.
key | The key name in the .ini file.
default | The default value to return if the requested key is not found.

Return Value

Success: | the requested key value as a string.
Failure: | the default string if requested key not found.

Remarks

A standard ini file looks like:
[SectionName]
Key=Value

All values returned are converted as a string. Therefore if you wish an integer e.g. 1000 to be a number use either Int() or Number(), like-wise if you want a hwnd to be a ptr, the use Ptr() or HWnd().

Related

FileReadLine, IniDelete, IniReadSection, IniReadSectionNames, IniRenameSection, IniWrite, IniWriteSection

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Write the value of 'AutoIt' to the key 'Title' and in the section labelled 'General'.
    IniWrite($sFilePath, "General", "Title", "AutoIt")

    ; Read the INI file for the value of 'Title' in the section labelled 'General'.
    Local $sRead = IniRead($sFilePath, "General", "Title", "Default Value")

    ; Display the value returned by IniRead.
    MsgBox($MB_SYSTEMMODAL, "", "The value of 'Title' in the section labelled 'General' is: " & $sRead)

    ; Delete the key labelled 'Title'.
    IniDelete($sFilePath, "General", "Title")

    ; Read the INI file for the value of 'Title' in the section labelled 'General'.
    $sRead = IniRead($sFilePath, "General", "Title", "Default Value")

    ; Display the value returned by IniRead. Since there is no key stored the value will be the 'Default Value' passed to IniRead.
    MsgBox($MB_SYSTEMMODAL, "", "The value of 'Title' in the section labelled 'General' is: " & $sRead)

    ; Delete the INI file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function IniReadSection

Function Reference

IniReadSection

Reads all key/value pairs from a section in a standard format .ini file.

IniReadSection ( "filename", "section" )

Parameters

filename | The filename of the .ini file.
section | The section name in the .ini file.

Return Value

Success: | a 2 dimensional array where element[n][0] is the key and element[n][1] is the value.
Failure: | sets the @error flag to non-zero if unable to read the section (The INI file may not exist or the section may not exist or is empty)

Remarks

A standard ini file looks like:
[SectionName]
Key=Value

The number of elements returned will be in $aArray[0][0]. If an @error occurs, no array is created.
$aArray[0][0] = Number
$aArray[1][0] = 1st Key
$aArray[1][1] = 1st Value
$aArray[2][0] = 2nd Key
$aArray[2][1] = 2nd Value
...
$aArray[n][0] = nth Key
$aArray[n][1] = nth Value

Only the first 32767 chars are read for legacy reasons.

Related

IniDelete, IniRead, IniReadSectionNames, IniRenameSection, IniWrite, IniWriteSection

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Create an INI section structure as a string.
    Local $sSection = "Title=AutoIt" & @LF & "Version=" & @AutoItVersion & @LF & "OS=" & @OSVersion

    ; Write the string to the section labelled 'General'.
    IniWriteSection($sFilePath, "General", $sSection)

    ; Read the INI section labelled 'General'. This will return a 2 dimensional array.
    Local $aArray = IniReadSection($sFilePath, "General")

    ; Check if an error occurred.
    If Not @error Then
        ; Enumerate through the array displaying the keys and their respective values.
        For $i = 1 To $aArray[0][0]
            MsgBox($MB_SYSTEMMODAL, "", "Key: " & $aArray[$i][0] & @CRLF & "Value: " & $aArray[$i][1])
        Next
    EndIf

    ; Delete the INI file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function IniReadSectionNames

Function Reference

IniReadSectionNames

Reads all sections in a standard format .ini file.

IniReadSectionNames ( "filename" )

Parameters

filename The filename of the .ini file.

Return Value

Success: | an array of all section names in the INI file.
Failure: | sets the @error flag to non-zero

Remarks

A standard ini file looks like:
[SectionName]
Key=Value

The number of elements returned will be in $aArray[0]. If an @error occurs, no array is returned.

Related

IniDelete, IniRead, IniReadSection, IniRenameSection, IniWrite, IniWriteSection

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Create an INI section structure as a string.
    Local $sSection = "Title=AutoIt" & @LF & "Version=" & @AutoItVersion & @LF & "OS=" & @OSVersion

    ; Write the string to the sections labelled 'General', 'Version' and 'Other'.
    IniWriteSection($sFilePath, "General", $sSection)
    IniWriteSection($sFilePath, "Version", $sSection)
    IniWriteSection($sFilePath, "Other", $sSection)

    ; Read the INI section names. This will return a 1 dimensional array.
    Local $aArray = IniReadSectionNames($sFilePath)

    ; Check if an error occurred.
    If Not @error Then
        ; Enumerate through the array displaying the section names.
        For $i = 1 To $aArray[0]
            MsgBox($MB_SYSTEMMODAL, "", "Section: " & $aArray[$i])
        Next
    EndIf

    ; Delete the INI file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function IniRenameSection

Function Reference

IniRenameSection

Renames a section in a standard format .ini file.

IniRenameSection ( "filename", "section", "new section" [, flag = 0] )

Parameters

filename | The filename of the .ini file.
section | The section name in the .ini file.
new section | The new section name.
flag [optional]
$FC_NOOVERWRITE(0) = (default) Fail if "new section" already exists.
$FC_OVERWRITE(1) = Overwrite "new section". This will erase any existing keys in "new section".

Constants are defined in FileConstants.au3.

Return Value

Success: | Non-zero.
Failure: | 0 and may sets the @error flag to non-zero, if renaming failed because the section already exists (only when flag = 0).

Remarks

A standard ini file looks like:
[SectionName]
Key=Value

Related

IniDelete, IniRead, IniReadSection, IniReadSectionNames, IniWrite, IniWriteSection

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Create an INI section structure as a string.
    Local $sSection = "Title=AutoIt" & @LF & "Version=" & @AutoItVersion & @LF & "OS=" & @OSVersion

    ; Write the string to the sections labelled 'General', 'Version' and 'Other'.
    IniWriteSection($sFilePath, "General", $sSection)
    IniWriteSection($sFilePath, "Version", $sSection)
    IniWriteSection($sFilePath, "Other", $sSection)

    ; Rename the section labelled 'General' to 'System'.
    IniRenameSection($sFilePath, "General", "System")

    ; Read the INI section names. This will return a 1 dimensional array.
    Local $aArray = IniReadSectionNames($sFilePath)

    ; Check if an error occurred.
    If Not @error Then
        ; Enumerate through the array displaying the section names.
        For $i = 1 To $aArray[0]
            MsgBox($MB_SYSTEMMODAL, "", "Section: " & $aArray[$i])
        Next
    EndIf

    ; Delete the INI file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function IniWrite

Function Reference

IniWrite

Writes a value to a standard format .ini file.

IniWrite ( "filename", "section", "key", "value" )

Parameters

filename | The filename of the .ini file.
section | The section name in the .ini file.
key | The key name in the .ini file.
value | The value to write/change.

Return Value

Success: | 1.
Failure: | 0 if file is read-only.

Remarks

A standard ini file looks like:
[SectionName]
Key=Value

If the file does not already exist, it is created so long as the directory exists. Keys and/or sections are added to the end and are not sorted in any way.

If you would like to wrap quotes around an ini value, then you need to double up the quotation marks as the first set of quotation marks are stripped. For example: ""This is a test"" will produce "This is a test" when using IniRead() or such-like.

Leading and trailing whitespace is stripped. In order to preserve the whitespace, the string must be quoted. For example, " this is a test" will preserve the whitespace but per above, the quotation marks are stripped.

Multi-line values are not possible.

If you want to use an ini file with Unicode encoding, first create an .ini file by using the FileOpen() function with the mode parameter set to a Unicode parameter.

Related

IniDelete, IniRead, IniReadSection, IniReadSectionNames, IniRenameSection, IniWriteSection

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Write the value of 'AutoIt' to the key 'Title' and in the section labelled 'General'.
    IniWrite($sFilePath, "General", "Title", "AutoIt")

    ; Read the INI file for the value of 'Title' in the section labelled 'General'.
    Local $sRead = IniRead($sFilePath, "General", "Title", "Default Value")

    ; Display the value returned by IniRead.
    MsgBox($MB_SYSTEMMODAL, "", "The value of 'Title' in the section labelled 'General' is: " & $sRead)

    ; Delete the key labelled 'Title'.
    IniDelete($sFilePath, "General", "Title")

    ; Read the INI file for the value of 'Title' in the section labelled 'General'.
    $sRead = IniRead($sFilePath, "General", "Title", "Default Value")

    ; Display the value returned by IniRead. Since there is no key stored the value will be the 'Default Value' passed to IniRead.
    MsgBox($MB_SYSTEMMODAL, "", "The value of 'Title' in the section labelled 'General' is: " & $sRead)

    ; Delete the INI file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function IniWriteSection

Function Reference

IniWriteSection

Writes a section to a standard format .ini file.

IniWriteSection ( "filename", "section", "data" [, index = 1] )

Parameters

filename | The filename of the .ini file.
section | The section name in the .ini file.
data | The data to write. The data can either be a string or an array. If the data is a string, then each key=value pair must be delimited by @LF. If the data is an array, the array must be 2-dimensional and the second dimension must be 2 elements.
index | [optional] If an array is passed as data, this specifies the index to start writing from. By default, this is 1 so that the return value of IniReadSection() can be used immediately. For manually created arrays, this value may need to be different depending on how the array was created. This parameter is ignored if a string is passed as data.

Return Value

Success: | 1.
Failure: | 0. The function will sets the @error flag to 1 if the data format is invalid.

Remarks

A standard ini file looks like:
[SectionName]
Key=Value

If file does not exist, it is created. Any directories that do not exist, will not be created. Keys and/or sections are added to the end and are not sorted in any way.
If the section being written already exists, its contents will be overwritten.

If you want to use an ini file with unicode encoding, first create an .ini file by using the FileOpen() function with the mode parameter set to "Unicode UTF16 Little Endian".

Related

IniDelete, IniRead, IniReadSection, IniReadSectionNames, IniRenameSection, IniWrite

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Create a constant variable in Local scope of the filepath that will be read/written to.
    Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Create an INI section structure as an array. The zeroth element is how many items are in the array, in this case 3.
    Local $aSection[4][2] = [[3, ""], ["Title", "AutoIt"], ["Version", @AutoItVersion], ["OS", @OSVersion]]

    ; Write the array to the section labelled 'General'.
    IniWriteSection($sFilePath, "General", $aSection)

    ; Read the INI section labelled 'General'. This will return a 2 dimensional array.
    Local $aArray = IniReadSection($sFilePath, "General")

    ; Check if an error occurred.
    If Not @error Then
        ; Enumerate through the array displaying the keys and their respective values.
        For $i = 1 To $aArray[0][0]
            MsgBox($MB_SYSTEMMODAL, "", "Key: " & $aArray[$i][0] & @CRLF & "Value: " & $aArray[$i][1])
        Next
    EndIf

    ; Delete the INI file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Functions

Graphic and Sound functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
Beep | Plays back a beep to the user.
PixelChecksum | Generates a checksum for a region of pixels.
PixelGetColor | Returns a pixel color according to x,y pixel coordinates.
PixelSearch | Searches a rectangle of pixels for the pixel color provided.
SoundPlay | Play a sound file.
SoundSetWaveVolume | Sets the system wave volume by percent.


Function Beep

Function Reference

Beep

Plays back a beep to the user.

Beep ( [Frequency = 500 [, Duration = 1000]] )

Parameters

Frequency | [optional] The frequency of the beep in hertz. Can be anywhere from 37 through 32,767 (0x25 through 0x7FFF). Default is 500 Hz.
Duration | [optional] The length of the beep in milliseconds. Default = 1000 ms.

Return Value

None. (Always returns 1 regardless of success.)

Related

SoundPlay

Example

; plays back a beep noise, at the frequency 500 for 1 second

Beep(500, 1000)


Function PixelChecksum

Function Reference

PixelChecksum

Generates a checksum for a region of pixels.

PixelChecksum ( left, top, right, bottom [, step = 1 [, hwnd [, mode = 0]]] )

Parameters

left | left coordinate of rectangle.
top | top coordinate of rectangle.
right | right coordinate of rectangle.
bottom | bottom coordinate of rectangle.
step | [optional] Instead of checksumming each pixel use a value larger than 1 to skip pixels (for speed). E.g. A value of 2 will only check every other pixel. Default is 1. It is not recommended to use a step value greater than 1.
hwnd | [optional] Window handle to be used. Default is the desktop window.
mode | [optional] default 0 ADLER checksum, 1 CRC32 Checksum.

Return Value

Success: | the checksum value of the region.
Failure: | 0.

Remarks

A checksum only allows you to see if "something" has changed in a region - it does not tell you exactly what has changed.

CRC32 checksum is a little slower than ADLDER but detects better pixel variation.

Related

PixelCoordMode (Option), PixelGetColor, PixelSearch

Example

#include <MsgBoxConstants.au3>

; Wait until something changes in the region 0,0 to 50,50

; Get initial checksum
Local $iCheckSum = PixelChecksum(0, 0, 50, 50)

; Wait for the region to change, the region is checked every 100ms to reduce CPU load
While $iCheckSum = PixelChecksum(0, 0, 50, 50)
    Sleep(100)
WEnd

MsgBox($MB_SYSTEMMODAL, "", "Something in the region has changed!")


Function AutoItSetOption

Function Reference

AutoItSetOption

Changes the operation of various AutoIt functions/parameters.

AutoItSetOption ( "option" [, param] )

Parameters

option | The option to change. See Remarks.
param | [optional] The value to assign to the option. The type and meaning vary by option. See remarks below. If the param is not provided, then the function just returns the value already assigned to the option. The keyword Default can be used for the parameter to reset the option to its default value.

Return Value

Success: | the value of the previous setting for the option.
Failure: | sets the @error flag to non-zero. Failure will occur if the parameters are invalid (such as an option that does not exist).

Remarks

You may use Opt() as an alternative to AutoItSetOption().

Options are as follows:

Option | Param
CaretCoordMode | Sets the way coords are used in the caret functions, either absolute coords or coords relative to the current active window: 0 = relative coords to the active window 1 = (default) absolute screen coordinates 2 = relative coords to the client area of the active window
ExpandEnvStrings | Changes how literal strings and % symbols are interpreted. By default strings are treated literally, this option allows you to use %environment% variables inside strings, e.g., "The temp directory is: %temp%". 0 = (default) do not expand environment variables 1 = expand environment variables Without this option the usual way would be: "The temp directory is: " & EnvGet("temp")
ExpandVarStrings | Changes how literal strings and variable/macro ($ and @) symbols are interpreted. By default strings are treated literally, this option allows you to use variables and macros inside strings, e.g., "The value of var1 is $var1$". 0 = (default) do not expand variables 1 = expand variables (when in this mode and you want to use a literal $ or @ then double it up: "This is a single dollar $$ sign".
GUICloseOnESC | When ESC is pressed on a GUI the $GUI_EVENT_CLOSE message is sent. This option toggles this behavior on and off. 0 = Don't send the $GUI_EVENT_CLOSE message when ESC is pressed. 1 = (default) Send() the $GUI_EVENT_CLOSE message when ESC is pressed.
GUICoordMode | Alters the position of a control defined by GUICtrlSetPos(). 0 = relative position to the start of the last control (upper left corner). 1 = (default) absolute coordinates still relative to the dialog box. 2 = cell positioning relative to current cell. A -1 for left or top parameter don't increment the start. So next line is -1, offset; next cell is offset,-1; current cell is -1,-1. Obviously "offset" cannot be -1 which reserved to indicate the no increment. But if you can use a multiple of the width you choose to skip or go back.
GUIDataSeparatorChar | Define the character which delimits subitems in GUICtrlSetData(). The default character is '|'.
GUIOnEventMode | Enable/disable OnEvent functions notifications. 0 = (default) disable. 1 = enable.
GUIResizeMode | Change default resizing for a control. 0 = (default) keep default control resizing. <1024 = any type of resizing see GUICtrlSetResizing().
GUIEventOptions | Change special event behavior or GUI function return values. 0 = (default) Windows behavior on click on Minimize,Restore, Maximize, Resize. 1 = suppress windows behavior on minimize, restore or maximize click button or window resize. Just sends the notification.
MouseClickDelay | Alters the length of the brief pause in between mouse clicks. Time in milliseconds to pause (default=10).
MouseClickDownDelay | Alters the length a click is held down before release. Time in milliseconds to pause (default=10).
MouseClickDragDelay | Alters the length of the brief pause at the start and end of a mouse drag operation. Time in milliseconds to pause (default=250).
MouseCoordMode | Sets the way coords are used in the mouse functions, either absolute coords or coords relative to the current active window: 0 = relative coords to the active window 1 = (default) absolute screen coordinates 2 = relative coords to the client area of the active window
MustDeclareVars | If this option is used then all variables must be pre-declared with Local, Global or in some cases Dim before they can be used - removes the chance for misspelled variables causing bugs. 0 = (default) Variables don't need to be pre-declared 1 = Variables must be pre-declared. See Dim / Global / Local / Const for details on declaring variables.
PixelCoordMode | Sets the way coords are used in the pixel functions, either absolute coords or coords relative to the window defined by hwnd (default active window): 0 = relative coords to the defined window 1 = (default) absolute screen coordinates 2 = relative coords to the client area of the defined window
SendAttachMode | Specifies if AutoIt attaches input threads when using Send() function. When not attaching (default mode=0) detecting the state of capslock/scrolllock and numlock can be unreliable under NT4. However, when you specify attach mode=1 the Send("{... down/up}") syntax will not work and there may be problems with sending keys to "hung" windows. ControlSend() ALWAYS attaches and is not affected by this mode. 0 = (default) don't attach 1 = attach
SendCapslockMode | Specifies if AutoIt should store the state of capslock before a Send() function and restore it afterwards. 0 = don't store/restore 1 = (default) store and restore
SendKeyDelay | Alters the length of the brief pause in between sent keystrokes. A value of 0 removes the delay completely. Time in milliseconds to pause (default=5).
SendKeyDownDelay | Alters the length of time a key is held down before being released during a keystroke. For applications that take a while to register keypresses you may need to raise this value from the default. A value of 0 removes the delay completely. Time in milliseconds to pause (default=5).
TCPTimeout | Defines the time before TCP functions stop if no communication. Time in milliseconds before timeout (default=100).
TrayAutoPause | Script pauses when click on tray icon. 0 = no pause 1 = (default) pause. If there is no DefaultMenu no pause will occurs.
TrayIconDebug | If enabled shows the current script line in the tray icon tip to help debugging. 0 = (default) no debug information 1 = show debug
TrayIconHide | Hides the AutoIt tray icon. Note: The icon will still initially appear for ~750 milliseconds. 0 = (default) show icon 1 = hide icon
TrayMenuMode | Extend the behaviour of the script tray icon/menu. This can be done with a combination (adding) of the following values. 0 = (default) default menu items (Script Paused/Exit) are appended to the usercreated menu; items will automatically be checked/unchecked when clicked; double clicking the tray icon returns the controlID of the $TRAY_DEFAULT item. 1 = no default menu 2 = items will not automatically check/uncheck when clicked 4 = do not return the $TRAY_DEFAULT item controlID when the tray icon is double clicked 8 = turn off auto check of radio item groups
TrayOnEventMode | Enable/disable OnEvent functions notifications for the tray. 0 = (default) disable 1 = enable
WinDetectHiddenText | Specifies if hidden window text can be "seen" by the window matching functions. 0 = (default) Do not detect hidden text 1 = Detect hidden text
WinSearchChildren | Allows the window search routines to search child windows as well as top-level windows. 0 = (default) Only search top-level windows 1 = Search top-level and child windows
WinTextMatchMode | Alters the method that is used to match window text during search operations. 1 = (default) Complete / Slow mode 2 = Quick mode In quick mode AutoIt can usually only "see" dialog text, button text and the captions of some controls. In the default mode much more text can be seen (for instance the contents of the Notepad window). If you are having performance problems when performing many window searches then changing to the "quick" mode may help.
WinTitleMatchMode | Alters the method that is used to match window titles during search operations. 1 = (default) Match the title from the start 2 = Match any substring in the title 3 = Exact title match 4 = Advanced mode (retained for backwards compatibility only - see Window Titles & Text (Advanced)) -1 to -4 = Case insensitive match according to the other type of match.
WinWaitDelay | Alters how long a script should briefly pause after a successful window-related operation. Time in milliseconds to pause (default=250).

Example

; copy any you want to change   ;default value is listed first

Opt("CaretCoordMode", 1) ;1=absolute, 0=relative, 2=client
Opt("ExpandEnvStrings", 0) ;0=don't expand, 1=do expand
Opt("ExpandVarStrings", 0) ;0=don't expand, 1=do expand
Opt("GUICloseOnESC", 1) ;1=ESC  closes, 0=ESC won't close
Opt("GUICoordMode", 1) ;1=absolute, 0=relative, 2=cell
Opt("GUIDataSeparatorChar", "|") ;"|" is the default
Opt("GUIOnEventMode", 0) ;0=disabled, 1=OnEvent mode enabled
Opt("GUIResizeMode", 0) ;0=no resizing, <1024 special resizing
Opt("GUIEventOptions", 0) ;0=default, 1=just notification, 2=GUICtrlRead tab index
Opt("MouseClickDelay", 10) ;10 milliseconds
Opt("MouseClickDownDelay", 10) ;10 milliseconds
Opt("MouseClickDragDelay", 250) ;250 milliseconds
Opt("MouseCoordMode", 1) ;1=absolute, 0=relative, 2=client
Opt("MustDeclareVars", 0) ;0=no, 1=require pre-declaration
Opt("PixelCoordMode", 1) ;1=absolute, 0=relative, 2=client
Opt("SendAttachMode", 0) ;0=don't attach, 1=do attach
Opt("SendCapslockMode", 1) ;1=store and restore, 0=don't
Opt("SendKeyDelay", 5) ;5 milliseconds
Opt("SendKeyDownDelay", 1) ;1 millisecond
Opt("TCPTimeout", 100) ;100 milliseconds
Opt("TrayAutoPause", 1) ;0=no pause, 1=Pause
Opt("TrayIconDebug", 0) ;0=no info, 1=debug line info
Opt("TrayIconHide", 0) ;0=show, 1=hide tray icon
Opt("TrayMenuMode", 0) ;0=append, 1=no default menu, 2=no automatic check, 4=menuitemID  not return
Opt("TrayOnEventMode", 0) ;0=disable, 1=enable
Opt("WinDetectHiddenText", 0) ;0=don't detect, 1=do detect
Opt("WinSearchChildren", 1) ;0=no, 1=search children also
Opt("WinTextMatchMode", 1) ;1=complete, 2=quick
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("WinWaitDelay", 250) ;250 milliseconds


Function PixelGetColor

Function Reference

PixelGetColor

Returns a pixel color according to x,y pixel coordinates.

PixelGetColor ( x , y [, hwnd] )

Parameters

x | x coordinate of pixel.
y | y coordinate of pixel.
hwnd | [optional] Window handle to be used. Default is the desktop window.

Return Value

Success: | a decimal value of pixel's color.
Failure: | -1 if invalid coordinates.

Related

MouseGetPos, PixelChecksum, PixelCoordMode (Option), PixelSearch

Example

#include <MsgBoxConstants.au3>

Local $iColor = PixelGetColor(10, 100)

MsgBox($MB_SYSTEMMODAL, "", "The decimal color is: " & $iColor)
MsgBox($MB_SYSTEMMODAL, "", "The hex color is: " & Hex($iColor, 6))


Function PixelSearch

Function Reference

PixelSearch

Searches a rectangle of pixels for the pixel color provided.

PixelSearch ( left, top, right, bottom, color [, shade-variation = 0 [, step = 1 [, hwnd]]] )

Parameters

left | left coordinate of rectangle.
top | top coordinate of rectangle.
right | right coordinate of rectangle.
bottom | bottom coordinate of rectangle.
color | Color value of pixel to find (in decimal or hex).
shade-variation | [optional] A number between 0 and 255 to indicate the allowed number of shades of variation of the red, green, and blue components of the color. Default is 0 (exact match).
step | [optional] Instead of searching each pixel use a value larger than 1 to skip pixels (for speed). E.g. A value of 2 will only check every other pixel. Default is 1. It is not recommended to use a step value greater than 1.
hwnd | [optional] Window handle to be used. Default is the desktop window.

Return Value

Success: | a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y).
Failure: | sets the @error flag to 1 if the color is not found.

Remarks

The search direction varies as follows:
Left-to-Right - left < right
Right-to-Left - right < left
Top-to-Bottom - top < bottom
Bottom-to-Top - bottom < top
Changing the search direction can be a useful optimization if the color being searched for frequently appears in in a specific quadrat of the search area since less searching is done if the search starts in the most common quadrant.

Remember, a typical display at 1024 x 768 has 786432 pixels. Although PixelSearch() is optimized, narrowing the search area helps speed up the result.

Related

PixelChecksum, PixelCoordMode (Option), PixelGetColor

Example

#include <MsgBoxConstants.au3>

; Find a pure red pixel in the range 0,0-20,300
Local $aCoord = PixelSearch(0, 0, 20, 300, 0xFF0000)
If Not @error Then
    MsgBox($MB_SYSTEMMODAL, "", "X and Y are: " & $aCoord[0] & "," & $aCoord[1])
EndIf

; Find a pure red pixel or a red pixel within 10 shades variations of pure red
$aCoord = PixelSearch(0, 0, 20, 300, 0xFF0000, 10)
If Not @error Then
    MsgBox($MB_SYSTEMMODAL, "", "X and Y are: " & $aCoord[0] & "," & $aCoord[1])
EndIf


Function SoundPlay

Function Reference

SoundPlay

Play a sound file.

SoundPlay ( "filename" [, wait = 0] )

Parameters

filename | Name of the file to be played (typically a WAV or MP3)
wait | [optional] This flag determines if the script should wait for the sound to finish before continuing: $SOUND_WAIT(1) = wait until sound has finished $SOUND_NOWAIT(0) = continue script while sound is playing (default) Constants are defined in "AutoItConstants.au3".

Return Value

None. (Always returns 1 regardless of success.)

Remarks

Terminating the script will stop the sound (if it is still playing).
Calling SoundPlay("") can be used to stop a currently playing sound. This has the side effect of also closing the open handle.
If you need to delete a sound file which you have played in the script, you should call SoundPlay("") first to ensure the handle is closed.

Related

Beep, SoundSetWaveVolume

Example

SoundPlay(@WindowsDir & "\media\tada.wav", 1)


Function SoundSetWaveVolume

Function Reference

SoundSetWaveVolume

Sets the system wave volume by percent.

SoundSetWaveVolume ( percent )

Parameters

percent percentage number between 0 and 100

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to 1 if percent is invalid.

Remarks

This controls the Wave volume, not the master volume control. Also, a value of Zero does not set mute status.

On Windows Vista, there is no system-wide wave volume. This function only changes the wave volume for the script. It can not be used to change the wave volume of other programs.

Related

SoundPlay

Example

; Set the volume to 50%.

SoundSetWaveVolume(50)


Functions

GUI functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

See Gui Constants include files if you need to use the related controls Constants .

Function | Description
GUICreate | Create a GUI window.
GUICtrlGetHandle | Returns the handle for a control and some special (item) handles (Menu, ContextMenu, TreeViewItem).
GUICtrlGetState | Gets the current state of a control.
GUICtrlRead | Read state or data of a control.
GUICtrlRecvMsg | Send a message to a control and retrieve information in lParam.
GUICtrlSendMsg | Send a message to a control.
GUICtrlSendToDummy | Sends a message to a Dummy control.
GUIDelete | Deletes a GUI window and all controls that it contains.
GUIGetCursorInfo | Gets the mouse cursor position relative to GUI window.
GUIGetMsg | Polls the GUI to see if any events have occurred.
GUIGetStyle | Retrieves the styles of a GUI window.
GUIRegisterMsg | Register a user defined function for a known Windows Message ID (WM_MSG).
GUIStartGroup | Defines that any subsequent controls that are created will be "grouped" together.
GUISwitch | Switches the current window used for GUI functions.


Function GUICreate

Function Reference

GUICreate

Create a GUI window.

GUICreate ( "title" [, width [, height [, left = -1 [, top = -1 [, style = -1 [, exStyle = -1 [, parent = 0]]]]]]] )

Parameters

title | The title of the dialog box.
width | [optional] The width of the window.
height | [optional] The height of the window.
left | [optional] The left side of the dialog box. By default (-1), the window is centered. If defined, top must also be defined.
top | [optional] The top of the dialog box. Default (-1) is centered
style | [optional] defines the style of the window. See GUI Control Styles Appendix. Use -1 for the default style which includes a combination of $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU styles. Some styles are always included: $WS_CLIPSIBLINGS, and $WS_SYSMENU if $WS_MAXIMIZEBOX or $WS_SIZEBOX is specified.
exStyle | [optional] defines the extended style of the window. See the Extended Style Table below. Use -1 for the default, which is no extended styles. Forced styles: $WS_EX_WINDOWEDGE
parent | [optional] The handle of another previously created window - this new window then becomes a child of that window.

Return Value

Success: | a windows handle.
Failure: | 0 if the window cannot be created and sets the @error flag to 1.

Remarks

By default the dialog box is non sizable and non maximizable. So WS_SIZEBOX or WS_MAXIMIZEBOX can be used in the style parameter.
As defining only one style just set this style don't forget to combine it with default ones, i.e. just defining WS_SIZEBOX will not set $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU. So the best method to define a resizeable window is to use $WS_OVERLAPPEDWINDOW.
When using $WS_EX_MDICHILD the position is relative to client area of the parent window. With $WS_EX_LAYERED it is possible to have a transparent picture on a background picture defined in the parent window.
Adding $WS_CLIPCHILDREN style can avoid some flickering when resizing GUI containing Edit control for example.
You can enable window dragging for GUI without $WS_CAPTION by using $WS_EX_CONTROLPARENT in the exStyle parameter.

To combine styles with the default style use BitOR($GUI_SS_DEFAULT_GUI, newstyle, ...).
The size specified is the size of the client area of the window. The border and title bar will make the window slightly larger than specified. Using menu controls will also change the windows height.

Extended Style table

Extended Style | result
$WS_EX_ACCEPTFILES | Allow an edit or input control within the created GUI window to receive filenames via drag and drop. The control must have also the $GUI_DROPACCEPTED state set by GUICtrlSetState(). for other controls the drag&drop info can be retrieved with @GUI_DragId, @GUI_DragFile, @GUI_DropId.
$WS_EX_APPWINDOW | Forces a top-level window onto the taskbar when the window is visible.
$WS_EX_CLIENTEDGE | Specifies that a window has a border with a sunken edge.
$WS_EX_CONTEXTHELP | Includes a question mark in the title bar of the window. Cannot be used with the $WS_MAXIMIZEBOX or $WS_MINIMIZEBOX.
$WS_EX_DLGMODALFRAME | Creates a window that has a double border; the window can, optionally, be created with a title bar by specifying the WS_CAPTION style in the style parameter.
$WS_EX_MDICHILD | Create a child window included in its parent window (simulation not real MDI).
$WS_EX_OVERLAPPEDWINDOW | Combines the $WS_EX_CLIENTEDGE and $WS_EX_WINDOWEDGE styles.
$WS_EX_STATICEDGE | Creates a window with a three-dimensional border style intended to be used for items that do not accept user input.
$WS_EX_TOPMOST | Specifies that a window created with this style should be placed above all non-topmost windows and should stay above them, even when the window is deactivated.
$WS_EX_TRANSPARENT | The window appears transparent because the bits of underlying sibling windows have already been painted.
$WS_EX_TOOLWINDOW | Creates a tool window; that is, a window intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the taskbar or in the dialog box that appears when the user presses ALT+TAB. If a tool window has a system menu, its icon is not displayed on the title bar. However, you can display the system menu by typing ALT+SPACE.
$WS_EX_WINDOWEDGE | Specifies that a window has a border with a raised edge.
$WS_EX_LAYERED | Creates a layered window. Note that this cannot be used for child windows.

To use the values specified above you must #include <WindowsConstants.au3> in your script.

Note: The handle returned from this function is a real windows handle, which means it can be used in the same way as the result of WinGetHandle().
WinMove() use before GuiSetState() to change GUI window size will not change the position/resizing of defined Controls.

Related

GUICtrlCreate..., GUICtrlSetDefBkColor, GUICtrlSetDefColor, GUIDelete, GUIGetCursorInfo, GUIGetMsg, GUIGetStyle, GUISetParameters..., GUISetState, GUISwitch, WinGetHandle, WinMove

Example

Example 1

#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example")
    Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idOK
                ExitLoop

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example

Example 2

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

Example()

Func Example()
    Local $sFilePath = "..\GUI\logo4.gif"

    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example", 400, 100)
    GUICtrlCreatePic("..\GUI\msoobe.jpg", 0, 0, 400, 100)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    Local $hChild = GUICreate("", 169, 68, 20, 20, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hGUI)

    ; Create a picture control with a transparent image.
    GUICtrlCreatePic($sFilePath, 0, 0, 169, 68)

    ; Display the child GUI.
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    ; Delete the previous GUIs and all controls.
    GUIDelete($hGUI)
    GUIDelete($hChild)
EndFunc   ;==>Example


Functions

GUI Control creation functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

See Gui Constants include files if you need to use the related controls Constants .

Function | Description
GUICtrlCreateAvi | Creates an AVI video control for the GUI.
GUICtrlCreateButton | Creates a Button control for the GUI.
GUICtrlCreateCheckbox | Creates a Checkbox control for the GUI.
GUICtrlCreateCombo | Creates a ComboBox control for the GUI.
GUICtrlCreateContextMenu | Creates a context menu for a control or entire GUI window.
GUICtrlCreateDate | Creates a date control for the GUI.
GUICtrlCreateDummy | Creates a Dummy control for the GUI.
GUICtrlCreateEdit | Creates an Edit control for the GUI.
GUICtrlCreateGraphic | Creates a Graphic control for the GUI.
GUICtrlCreateGroup | Creates a Group control for the GUI.
GUICtrlCreateIcon | Creates an Icon control for the GUI.
GUICtrlCreateInput | Creates an Input control for the GUI.
GUICtrlCreateLabel | Creates a static Label control for the GUI.
GUICtrlCreateList | Creates a List control for the GUI.
GUICtrlCreateListView | Creates a ListView control for the GUI.
GUICtrlCreateListViewItem | Creates a ListView item.
GUICtrlCreateMenu | Creates a Menu control for the GUI.
GUICtrlCreateMenuItem | Creates a MenuItem control for the GUI.
GUICtrlCreateMonthCal | Creates a month calendar control for the GUI.
GUICtrlCreateObj | Creates an ActiveX control in the GUI.
GUICtrlCreatePic | Creates a Picture control for the GUI.
GUICtrlCreateProgress | Creates a Progress control for the GUI.
GUICtrlCreateRadio | Creates a Radio button control for the GUI.
GUICtrlCreateSlider | Creates a Slider control for the GUI.
GUICtrlCreateTab | Creates a Tab control for the GUI.
GUICtrlCreateTabItem | Creates a TabItem control within an existing tab control in the GUI.
GUICtrlCreateTreeView | Creates a TreeView control for the GUI.
GUICtrlCreateTreeViewItem | Creates a TreeViewItem control for the GUI.
GUICtrlCreateUpdown | Creates an UpDown control for the GUI.
GUICtrlDelete | Deletes a control.


Function GUICtrlCreateAvi

Function Reference

GUICtrlCreateAvi

Creates an AVI video control for the GUI.

GUICtrlCreateAvi ( filename, subfileid, left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

filename | The filename of the video. Only .avi files are supported.
subfileid | id of the subfile to be used. If the file only contains one video then use 0.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $ACS_TRANSPARENT $ACS_TRANSPARENT is always used unless $ACS_NONTRANSPARENT is specified.
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To obtain the value of the control see GUICtrlRead().
To set or change information in the control see GUICtrlUpdate...() functions.

To start the video as soon as the control is created use the $ACS_AUTOPLAY style.
You can can start and stop the animation by setting the state to 1 or 0 with GUICtrlSetState(). See example.

To combine styles with the default style use BitOR($GUI_SS_DEFAULT_AVI, newstyle, ... ).
To use the values specified above you must #include <AVIConstants.au3> in your script.

Default resizing is $GUI_DOCKSIZE.

Related

GUICoordMode (option), GUICtrlUpdate..., GUIGetMsg

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example", 300, 200)

    ; Create an animation control.
    Local $idAnimation = GUICtrlCreateAvi(@SystemDir & "\shell32.dll", 165, 15, 0, 300)
    Local $idStart = GUICtrlCreateButton("Start", 60, 150, 85, 25)
    Local $idStop = GUICtrlCreateButton("Stop", 160, 150, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idStart ; Start the animation.
                GUICtrlSetState($idAnimation, $GUI_AVISTART)

            Case $idStop ; Stop the animation.
                GUICtrlSetState($idAnimation, $GUI_AVISTOP)

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function GUICtrlCreateButton

Function Reference

GUICtrlCreateButton

Creates a Button control for the GUI.

GUICtrlCreateButton ( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

text | The text of the button control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default text autofit in width).
height | [optional] The height of the control (default text autofit in height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : none. forced styles : $WS_TABSTOP
exStyle | [optional] Defines the extended style of the control. See Extended Style Table. default ( -1) : WS_EX_WINDOWEDGE

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To set or change information in the control see GUICtrlUpdate...() functions.

A Button control can display an icon or image by using the $BS_ICON or $BS_BITMAP style. Use GUICtrlSetImage() to specify the picture to use.

To combine styles with the default style use BitOR ( $GUI_SS_DEFAULT_BUTTON, newstyle, ... ).
To use the values specified above you must #include <ButtonConstants.au3> in your script.

Default resizing is $GUI_DOCKSIZE

Related

GUICoordMode (Option), GUICtrlUpdate..., GUIGetMsg

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example", 300, 200)

    ; Create a button control.
    Local $idNotepad = GUICtrlCreateButton("Run Notepad", 120, 170, 85, 25)
    Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    Local $iPID = 0

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idClose
                ExitLoop

            Case $idNotepad
                ; Run Notepad with the window maximized.
                $iPID = Run("notepad.exe", "", @SW_SHOWMAXIMIZED)

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)

    ; Close the Notepad process using the PID returned by Run.
    If $iPID Then ProcessClose($iPID)
EndFunc   ;==>Example


Function GUICtrlCreateCheckbox

Function Reference

GUICtrlCreateCheckbox

Creates a Checkbox control for the GUI.

GUICtrlCreateCheckbox ( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

text | The text of the control checkbox.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default text autofit in width).
height | [optional] The height of the control (default text autofit in height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : $BS_AUTOCHECKBOX. forced styles : $WS_TABSTOP, and $BS_AUTOCHECKBOX if no checkbox style defined.
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To obtain the value of the control see GUICtrlRead().
To set or change information in the control see GUICtrlUpdate...() functions.

A Checkbox control can display an icon or image by using the $BS_ICON or $BS_BITMAP style. Use GUICtrlSetImage() to specify the picture to use.

To combine styles with the default style use BitOR ( $GUI_SS_DEFAULT_CHECKBOX, newstyle, ... ).

To use the values specified above you must #include <ButtonConstants.au3> in your script.

Default resizing is $GUI_DOCKHEIGHT.

Related

GUICoordMode (Option), GUICtrlUpdate..., GUIGetMsg

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example", 300, 200)

    ; Create a checkbox control.
    Local $idCheckbox = GUICtrlCreateCheckbox("Standard Checkbox", 10, 10, 185, 25)
    Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idClose
                ExitLoop

            Case $idCheckbox
                If _IsChecked($idCheckbox) Then
                    MsgBox($MB_SYSTEMMODAL, "", "The checkbox is checked.", 0, $hGUI)
                Else
                    MsgBox($MB_SYSTEMMODAL, "", "The checkbox is not checked.", 0, $hGUI)
                EndIf

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example

Func _IsChecked($idControlID)
    Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked


Function GUICtrlCreateCombo

Function Reference

GUICtrlCreateCombo

Creates a ComboBox control for the GUI.

GUICtrlCreateCombo ( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

text | The text which will appear in the combo control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL forced style : $WS_TABSTOP
exStyle | [optional] Defines the extended style of the control. See Extended Style Table. default ( -1) : $WS_EX_CLIENTEDGE

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To obtain the value of the control see GUICtrlRead().
To set or change information in the control see GUICtrlUpdate...() functions.

Under Windows XP/2003 Windows will adjust the size of the opened combo. On other Windows versions you can define this size with the "height" parameter if the default value is not BIG enough to contain at least one line.

To combine styles with the default style use BitOR ( $GUI_SS_DEFAULT_COMBO, newstyle, ... ).
To use the values specified above you must #include <ComboConstants.au3> in your script.

Default resizing is $GUI_DOCKHEIGHT.

Related

GUICoordMode (Option), GUICtrlSetData, GUICtrlUpdate..., GUIGetMsg

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example", 300, 200)

    ; Create a combobox control.
    Local $idComboBox = GUICtrlCreateCombo("Item 1", 10, 10, 185, 20)
    Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)

    ; Add additional items to the combobox.
    GUICtrlSetData($idComboBox, "Item 2|Item 3", "Item 2")

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    Local $sComboRead = ""

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idClose
                ExitLoop

            Case $idComboBox
                $sComboRead = GUICtrlRead($idComboBox)
                MsgBox($MB_SYSTEMMODAL, "", "The combobox is currently displaying: " & $sComboRead, 0, $hGUI)

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function GUICtrlCreateContextMenu

Function Reference

GUICtrlCreateContextMenu

Creates a context menu for a control or entire GUI window.

GUICtrlCreateContextMenu ( [controlID] )

Parameters

controlID [optional] Control identifier as returned by a GUICtrlCreate...() function.

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

After creating the context menu main control with this function, each menu item can be created by using GUICtrlCreateMenuItem().
Sub-menus can be created using GUICtrlCreateMenu().

If you use no parameters or -1 in this function then the context menu that is created is associated with the entire GUI window rather than an individual control.

Only one context menu per control is possible. If you wish to create a new context menu one you have to delete the existing menu first.

Note: You can't create context menus for controls that already have system context menus, i.e. edit or input controls.

Related

GUICtrlCreateMenu, GUICtrlCreateMenuItem, GUICtrlDelete, GUICtrlGetHandle, GUICtrlSetState

Example

Example 1

; right click on gui to bring up context Menu.
; right click on the "ok" button to bring up a controll specific context menu.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    GUICreate("My GUI Context Menu", 300, 200)

    Local $idContextmenu = GUICtrlCreateContextMenu()

    Local $idNewsubmenu = GUICtrlCreateMenu("new", $idContextmenu)
    Local $idNewsubmenuText = GUICtrlCreateMenuItem("text", $idNewsubmenu)

    Local $idButton = GUICtrlCreateButton("OK", 100, 100, 70, 20)
    Local $idButtoncontext = GUICtrlCreateContextMenu($idButton)
    Local $idMenuAbout = GUICtrlCreateMenuItem("About button", $idButtoncontext)

    Local $idMenuOpen = GUICtrlCreateMenuItem("Open", $idContextmenu)
    Local $idMenuSave = GUICtrlCreateMenuItem("Save", $idContextmenu)
    GUICtrlCreateMenuItem("", $idContextmenu) ; separator

    Local $idMenuInfo = GUICtrlCreateMenuItem("Info", $idContextmenu)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idButton
                MsgBox($MB_SYSTEMMODAL, "Button Clicked", 'OK')
            Case $idMenuAbout
                MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'About')
            Case $idMenuOpen
                MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'Open')
            Case $idMenuSave
                MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'Save')
            Case $idMenuInfo
                MsgBox($MB_SYSTEMMODAL, "Menu Selected", 'Info')
            Case $idNewsubmenuText
                MsgBox($MB_SYSTEMMODAL, "SubMenu Selected", 'Text')
        EndSwitch
    WEnd
    GUIDelete()
EndFunc   ;==>Example

Example 2

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGui = GUICreate("My GUI", 170, 40)

    Local $idOptionsBtn = GUICtrlCreateButton("&Options", 10, 10, 70, 20, $BS_FLAT)

    ; At first create a dummy control for the options and a contextmenu for it
    Local $idOptionsDummy = GUICtrlCreateDummy()
    Local $idOptionsContext = GUICtrlCreateContextMenu($idOptionsDummy)
    GUICtrlCreateMenuItem("Common", $idOptionsContext)
    GUICtrlCreateMenuItem("File", $idOptionsContext)
    GUICtrlCreateMenuItem("", $idOptionsContext)
    Local $idOptionsExit = GUICtrlCreateMenuItem("Exit", $idOptionsContext)

    Local $idHelpBtn = GUICtrlCreateButton("&Help", 90, 10, 70, 20, $BS_FLAT)

    ; Create a dummy control and a contextmenu for the help too
    Local $idHelpDummy = GUICtrlCreateDummy()
    Local $idHelpContext = GUICtrlCreateContextMenu($idHelpDummy)
    GUICtrlCreateMenuItem("Website", $idHelpContext)
    GUICtrlCreateMenuItem("", $idHelpContext)
    Local $idHelpAbout = GUICtrlCreateMenuItem("About...", $idHelpContext)

    GUISetState(@SW_SHOW)

    Local $idMsg

    ; Loop until the user exits.
    While 1
        $idMsg = GUIGetMsg()

        Switch $idMsg
            Case $idOptionsExit, $GUI_EVENT_CLOSE
                ExitLoop

            Case $idOptionsBtn
                ShowMenu($hGui, $idMsg, $idOptionsContext)

            Case $idHelpBtn
                ShowMenu($hGui, $idMsg, $idHelpContext)

            Case $idHelpAbout
                MsgBox($MB_SYSTEMMODAL, "About...", "GUICtrlGetHandle-Sample")
        EndSwitch
    WEnd
    GUIDelete()
EndFunc   ;==>Example

; Show a menu in a given GUI window which belongs to a given GUI ctrl
Func ShowMenu($hWnd, $idCtrl, $idContext)
    Local $aPos, $x, $y
    Local $hMenu = GUICtrlGetHandle($idContext)

    $aPos = ControlGetPos($hWnd, "", $idCtrl)

    $x = $aPos[0]
    $y = $aPos[1] + $aPos[3]

    ClientToScreen($hWnd, $x, $y)
    TrackPopupMenu($hWnd, $hMenu, $x, $y)
EndFunc   ;==>ShowMenu

; Convert the client (GUI) coordinates to screen (desktop) coordinates
Func ClientToScreen($hWnd, ByRef $x, ByRef $y)
    Local $tPoint = DllStructCreate("int;int")

    DllStructSetData($tPoint, 1, $x)
    DllStructSetData($tPoint, 2, $y)

    DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "struct*", $tPoint)

    $x = DllStructGetData($tPoint, 1)
    $y = DllStructGetData($tPoint, 2)
    ; release Struct not really needed as it is a local
    $tPoint = 0
EndFunc   ;==>ClientToScreen

; Show at the given coordinates (x, y) the popup menu (hMenu) which belongs to a given GUI window (hWnd)
Func TrackPopupMenu($hWnd, $hMenu, $x, $y)
    DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
EndFunc   ;==>TrackPopupMenu


Function GUICtrlCreateDate

Function Reference

GUICtrlCreateDate

Creates a date control for the GUI.

GUICtrlCreateDate ( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

text | The preselected date (always as "yyyy/mm/dd").
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $DTS_LONGDATEFORMAT forced style : $WS_TABSTOP
exStyle | [optional] Defines the extended style of the control. See Extended Style Table. default (-1) : WS_EX_CLIENTEDGE

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To obtain the value of the control see GUICtrlRead().
To set or change information in the control see GUICtrlUpdate...() functions.

To combine styles with the default style use BitOR($GUI_SS_DEFAULT_DATE, newstyle, ... ).
To use the values specified above you must #include <DateTimeConstants.au3> in your script.

To format the date/time see example 3 to understand how to use a GUICtrlSendMsg() with a $DTM_SETFORMAT.

Default resizing is $GUI_DOCKHEIGHT.

Related

GUICoordMode (Option), GUICtrlRead, GUICtrlSetState, GUIGetMsg

Example

Example 1

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    GUICreate("My GUI get date", 200, 200, 800, 200)
    Local $idDate = GUICtrlCreateDate("1953/04/25", 10, 10, 185, 20)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    MsgBox($MB_SYSTEMMODAL, "Date", GUICtrlRead($idDate))
    GUIDelete()
EndFunc   ;==>Example

Example 2

#include <DateTimeConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    GUICreate("My GUI get date", 200, 200, 800, 200)
    Local $idDate = GUICtrlCreateDate("", 10, 10, 100, 20, $DTS_SHORTDATEFORMAT)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    MsgBox($MB_SYSTEMMODAL, "Date", GUICtrlRead($idDate))
    GUIDelete()
EndFunc   ;==>Example

Example 3

#include <DateTimeConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    GUICreate("My GUI get date", 200, 200, 800, 200)
    Local $idDate = GUICtrlCreateDate("1953/04/25", 10, 10, 185, 20)

    ; to select a specific default format
    Local $sStyle = "yyyy/MM/dd HH:mm:ss"
    GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, $sStyle)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While GUIGetMsg() <> $GUI_EVENT_CLOSE
    WEnd

    MsgBox($MB_SYSTEMMODAL, "Time", GUICtrlRead($idDate))
EndFunc   ;==>Example

Example 4

#include <DateTimeConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    GUICreate("My GUI get time", 200, 200, 800, 200)
    Local $idDate = GUICtrlCreateDate("", 20, 20, 100, 20, $DTS_TIMEFORMAT)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    MsgBox($MB_SYSTEMMODAL, "Time", GUICtrlRead($idDate))
    GUIDelete()
EndFunc   ;==>Example


Function GUICtrlCreateDummy

Function Reference

GUICtrlCreateDummy

Creates a Dummy control for the GUI.

GUICtrlCreateDummy ( )

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

This control can receive messages through a GUICtrlSendToDummy() call. The control will "notify" as normal and the value sent with GUISendToDummy can be read with GUICtrlRead().

Related

GUICtrlRead, GUICtrlSendToDummy, GUICtrlSetData, GUICtrlSetOnEvent

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()

    GUICreate("GUICtrlCreateDummy", 250, 200, 100, 200)
    GUISetBkColor(0x00E0FFFF) ; will change background color

    Local $idUser = GUICtrlCreateDummy()
    Local $idButton = GUICtrlCreateButton("event", 75, 170, 70, 20)
    Local $idCancel = GUICtrlCreateButton("Cancel", 150, 170, 70, 20)
    GUISetState(@SW_SHOW)

    Local $idMsg
    ; Loop until the user exits.
    Do
        $idMsg = GUIGetMsg()

        Select
            Case $idMsg = $idButton
                GUICtrlSendToDummy($idUser)
            Case $idMsg = $idCancel
                GUICtrlSendToDummy($idUser)
            Case $idMsg = $idUser
                ; special action before closing
                ; ...
                Exit
        EndSelect
    Until $idMsg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function GUICtrlCreateEdit

Function Reference

GUICtrlCreateEdit

Creates an Edit control for the GUI.

GUICtrlCreateEdit ( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

text | The text of the control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : $ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL forced styles : $ES_MULTILINE, $WS_TABSTOP only if not $ES_READONLY
exStyle | [optional] Defines the extended style of the control. See Extended Style Table. default ( -1) : $WS_EX_CLIENTEDGE

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To obtain the value of the control see GUICtrlRead().
To set or change information in the control see GUICtrlUpdate...() functions.

To combine styles with the default style use BitOR($GUI_SS_DEFAULT_EDIT, newstyle, ... ).
To use the values specified above you must #include <EditConstants.au3> in your script.

If you want to drag & drop a filename onto this control just add the WS_EX_ACCEPTFILES extended style on the GUICreate() and set the state to $GUI_DROPACCEPTED.
Multiple selected files will be dropped as separate lines.

Default resizing is $GUI_DOCKAUTO size and position will occur.

Creating a RichEdit control is too complex so it will not be included as a basic control.
You have to use the _GUICtrlRichEdit_Create().

Related

GUICoordMode (Option), GUICtrlRead, GUICtrlSetData, GUICtrlSetLimit, GUICtrlSetState, GUIGetMsg

Example

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

Example()

Func Example()
    GUICreate("My GUI edit") ; will create a dialog box that when displayed is centered

    Local $idMyedit = GUICtrlCreateEdit("First line" & @CRLF, 176, 32, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL)

    GUISetState(@SW_SHOW)

    Send("{END}")

    ; will be append dont' forget 3rd parameter
    GUICtrlSetData($idMyedit, "Second line", 1)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
    GUIDelete()
EndFunc   ;==>Example


Function GUICtrlCreateGraphic

Function Reference

GUICtrlCreateGraphic

Creates a Graphic control for the GUI.

GUICtrlCreateGraphic ( left, top [, width [, height [, style]]] )

Parameters

left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : $SS_NOTIFY.

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To draw in the control see GUICtrlSetGraphic().

The border and background color can be set with GUICtrlSetBkColor() and GUICtrlSetColor().

Graphic control can be clicked so they should not overlap with other controls. If overlap is needed it is important to disable the graphic control : GUICtrlSetState(-1, $GUI_DISABLE).

This control cannot be resized due to fix graphic relative addressing creation but can be dock with GUICtrlSetResizing().

Related

GUICoordMode (Option), GUICtrlDelete, GUICtrlSetBkColor, GUICtrlSetColor, GUICtrlSetGraphic, GUICtrlSetResizing, GUICtrlSetStyle, GUIGetMsg

Example

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

Global Const $g_MAXGr = 6
Global $g_a_idArray[$g_MAXGr + 1] ; 0 and $g_MAXGr entries not used to allow GUICtrlDelete result
Global $g_idDel

Example()

Func Example()
    Local $idMsg, $iInc, $i

    CreateChild()

    $i = 1
    $iInc = 1
    ; Loop until the user exits.
    Do
        $idMsg = GUIGetMsg()

        If $idMsg = $g_idDel Then
            GUICtrlDelete($g_a_idArray[$i])
            $i = $i + $iInc
            If $i < 0 Or $i > $g_MAXGr Then Exit
        EndIf
        If $idMsg > 0 Then MsgBox($MB_SYSTEMMODAL, "clicked", $idMsg & @CRLF & $g_a_idArray[5], 2)
    Until $idMsg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func CreateChild()
    GUICreate("My Draw")
    $g_idDel = GUICtrlCreateButton("Delete", 50, 165, 50)

    $g_a_idArray[1] = GUICtrlCreateGraphic(20, 50, 100, 100)
    GUICtrlSetBkColor(-1, 0xffffff)
    GUICtrlSetColor(-1, 0)

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0xffffff)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 58, 50, 40, -60, 90)

    GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 100, 100, 50, 80)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0xc0c0ff)
    GUICtrlSetGraphic(-1, $GUI_GR_RECT, 350, 200, 50, 80)
    GUICtrlCreateLabel("label", 65, 100, 30)
    GUICtrlSetColor(-1, 0xff)

    $g_a_idArray[2] = GUICtrlCreateGraphic(220, 50, 100, 100)
    GUICtrlSetStyle(-1, $SS_NOTIFY)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xff)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0xffffff)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 58, 50, 40, -60, 90)

    $g_a_idArray[3] = GUICtrlCreateGraphic(220, 150, 100, 100, 0)
    GUICtrlSetBkColor(-1, 0xf08080)
    GUICtrlSetColor(-1, 0xff)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff00)
    GUICtrlSetGraphic(-1, $GUI_GR_RECT, 50, 50, 80, 80)

    $g_a_idArray[4] = GUICtrlCreateGraphic(20, 200, 80, 80)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlSetBkColor(-1, 0xffffff)
    GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 10, 10)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 30, 40)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff00)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 70, 70)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 10, 50)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xffff00)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 10, 10)

    $g_a_idArray[5] = GUICtrlCreateGraphic(150, 10, 50, 50, 0)
    GUICtrlSetBkColor(-1, 0xa0ffa0)
    GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 20, 20) ; start point
    ; it is better to draw line and after point
    ; to avoid to switch color at each drawing
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x0000ff)
    GUICtrlSetGraphic(-1, $GUI_GR_DOT, 30, 30)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 20, 40)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000)
    GUICtrlSetGraphic(-1, $GUI_GR_DOT, 25, 25)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 40, 40)
    GUICtrlSetGraphic(-1, $GUI_GR_DOT, 40, 40)

    GUISetState(@SW_SHOW)
EndFunc   ;==>CreateChild


Function GUICtrlCreateGroup

Function Reference

GUICtrlCreateGroup

Creates a Group control for the GUI.

GUICtrlCreateGroup ( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

text | The text of the control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : none. forced styles : $WS_GROUP, $BS_GROUPBOX.
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

A group control is the thin line you see around controls (usually only Radio button) that visually groups them together. Only one Radio button within a Group can be selected at once.
If you want to have multiple groups without the visible line then you must use GUIStartGroup() to group your Radio buttons.

To use the values specified above you must #include <ButtonConstants.au3> in your script.

Default resizing is $GUI_DOCKAUTO size and position will occur.

Related

GUICoordMode (Option), GUIStartGroup

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    GUICreate("My GUI group") ; will create a dialog box that when displayed is centered

    GUICtrlCreateGroup("Group 1", 190, 60, 90, 140)
    GUICtrlCreateRadio("Radio 1", 210, 90, 50, 20)
    GUICtrlCreateRadio("Radio 2", 210, 110, 60, 50)
    GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

    GUISetState(@SW_SHOW) ; will display an empty dialog box

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function GUICtrlCreateIcon

Function Reference

GUICtrlCreateIcon

Creates an Icon control for the GUI.

GUICtrlCreateIcon ( filename, iconName, left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

filename | filename of the icon to be loaded.
iconName | Icon name if the file contains multiple icons. Can be an ordinal name if negative number. Otherwise -1.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is 32).
height | [optional] The height of the control (default is 32).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : $SS_NOTIFY forced styles : $WS_TABSTOP, $SS_ICON
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To set or change information in the control see GUICtrlUpdate...() functions.

To update the icon after the dialog box is displayed use GUICtrlSetImage()

iconName can reference the icon group number. Use a resource hacker to find the correct value.

To combine styles with the default style use BitOR($GUI_SS_DEFAULT_ICON, newstyle, ... ).
To use the values specified above you must #include <StaticConstants.au3> in your script.

Default resizing is $GUI_DOCKSIZE.

Passing a positive number will reference the string equivalent icon name.
Passing a negative number causes 1-based "index" behaviour. Some Dll can have icon extracted just with negative numbers.

Related

GUICoordMode (Option), GUICtrlSetImage, GUICtrlUpdate..., GUIGetMsg

Example

Example 1

#include <GUIConstantsEx.au3>

Example()

Func Example()
    GUICreate(" My GUI Icons", 250, 250)

    GUICtrlCreateIcon("shell32.dll", 10, 20, 20)
    GUICtrlCreateIcon(@ScriptDir & '\Extras\horse.ani', -1, 20, 40, 32, 32)
    GUICtrlCreateIcon("shell32.dll", 7, 20, 75, 32, 32)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    GUIDelete()
EndFunc   ;==>Example

Example 2

Example()

Func Example()
    Local $iOldOpt = Opt("GUICoordMode", 1)

    GUICreate("My GUI icon Race", 350, 74, -1, -1)
    GUICtrlCreateLabel("", 331, 0, 1, 74, 5)
    Local $id1 = GUICtrlCreateIcon(@ScriptDir & '\Extras\dinosaur.ani', -1, 0, 0, 32, 32)
    Local $id2 = GUICtrlCreateIcon(@ScriptDir & '\Extras\horse.ani', -1, 0, 40, 32, 32)

    GUISetState(@SW_SHOW)

    Local $a = 0
    Local $b = 0
    While ($a < 300) And ($b < 300)
        $a = $a + Int(Random(0, 1) + 0.5)
        $b = $b + Int(Random(0, 1) + 0.5)
        GUICtrlSetPos($id1, $a, 0)
        GUICtrlSetPos($id2, $b, 40)
        Sleep(10)
    WEnd
    Sleep(3000)
    Opt("GUICoordMode", $iOldOpt)
EndFunc   ;==>Example


Function GUICtrlCreateInput

Function Reference

GUICtrlCreateInput

Creates an Input control for the GUI.

GUICtrlCreateInput ( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

text | The text of the control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : $ES_LEFT, $ES_AUTOHSCROLL forced styles : $WS_TABSTOP only if no $ES_READONLY. $ES_MULTILINE is always reset.
exStyle | [optional] Defines the extended style of the control. See Extended Style Table. default ( -1) : $WS_EX_CLIENTEDGE

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To obtain the value of the control see GUICtrlRead().
To set or change information in the control see GUICtrlUpdate...() functions.

For defining an input control for entering passwords (input is hidden with an asterisk) use the $ES_PASSWORD style.

If you want to drag & drop a filename onto this control just add the WS_EX_ACCEPTFILES extended style on the GUICreate() and set the state to $GUI_DROPACCEPTED.
After multiple drag and drop files on this control, you can retrieve the files name which are separated by "|" with GUICtrlRead().

To use the values specified above you must #include <EditConstants.au3> in your script.

Default resizing is $GUI_DOCKHEIGHT.

Related

GUICoordMode (Option), GUICtrlCreateUpdown, GUICtrlRead, GUICtrlSetLimit, GUICtrlUpdate..., GUIGetMsg

Example

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

Example()

Func Example()
    GUICreate(" My GUI input acceptfile", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, $WS_EX_ACCEPTFILES)
    Local $idFile = GUICtrlCreateInput("", 10, 5, 300, 20)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    GUICtrlCreateInput("", 10, 35, 300, 20) ; will not accept drag&drop files
    Local $idBtn = GUICtrlCreateButton("Ok", 40, 75, 60, 20)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idBtn
                ExitLoop
        EndSwitch
    WEnd

    MsgBox($MB_SYSTEMMODAL, "drag drop file", GUICtrlRead($idFile))
EndFunc   ;==>Example


Function GUICtrlCreateLabel

Function Reference

GUICtrlCreateLabel

Creates a static Label control for the GUI.

GUICtrlCreateLabel ( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

text | The text of the control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default text autofit in width).
height | [optional] The height of the control (default text autofit in height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : none. forced styles : $SS_NOTIFY, $SS_LEFT
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To set or change information in the control see GUICtrlUpdate...() functions.

To combine styles with the default style use BitOR($GUI_SS_DEFAULT_LABEL, newstyle, ... ).
To use the values specified above you must #include <StaticConstants.au3> in your script.

Default resizing is $GUI_DOCKAUTO size and position will occur.

The extended style $GUI_WS_EX_PARENTDRAG can be used to allow the dragging of the parent window for windows that don't have a titlebar (no $WS_CAPTION style in GUICreate()).

To set the background to transparent, use GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT).

Related

GUICoordMode (Option), GUICtrlUpdate..., GUIGetMsg

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    GUICreate("My GUI") ; will create a dialog box that when displayed is centered

    GUISetHelp("notepad.exe") ; will run notepad if F1 is typed
    Local $iOldOpt = Opt("GUICoordMode", 2)

    Local $iWidthCell = 70
    GUICtrlCreateLabel("Line 1 Cell 1", 10, 30, $iWidthCell) ; first cell 70 width
    GUICtrlCreateLabel("Line 2 Cell 1", -1, 0) ; next line
    GUICtrlCreateLabel("Line 3 Cell 2", 0, 0) ; next line and next cell
    GUICtrlCreateLabel("Line 3 Cell 3", 0, -1) ; next cell same line
    GUICtrlCreateLabel("Line 4 Cell 1", -3 * $iWidthCell, 0) ; next line Cell1

    GUISetState(@SW_SHOW) ; will display an empty dialog box

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    $iOldOpt = Opt("GUICoordMode", $iOldOpt)
EndFunc   ;==>Example


Function GUICtrlCreateList

Function Reference

GUICtrlCreateList

Creates a List control for the GUI.

GUICtrlCreateList ( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

text | The text of the control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : $LBS_SORT, $WS_BORDER, $WS_VSCROLL forced styles : $WS_TABSTOP, $LBS_NOTIFY
exStyle | [optional] Defines the extended style of the control. See Extended Style Table. default ( -1) : $WS_EX_CLIENTEDGE

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To obtain the value of the control see GUICtrlRead().
To set or change information in the control see GUICtrlUpdate...() functions.

The different list entries that can be selected can be set with GUICtrlSetData()

To limit horizontal scrolling use GUICtrlSetLimit()

To combine styles with the default style use BitOR($GUI_SS_DEFAULT_LIST, newstyle, ... ).
To use the values specified above you must #include <ListBoxConstants.au3> in your script.

Default resizing is $GUI_DOCKAUTO size and position will occur.

Related

GUICoordMode (Option), GUICtrlSetData, GUICtrlSetLimit, GUICtrlUpdate..., GUIGetMsg

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $sMESSAGE = "The following buttons have been clicked"

    GUICreate("My GUI list") ; will create a dialog box that when displayed is centered

    Local $idAdd = GUICtrlCreateButton("Add", 64, 32, 75, 25)
    Local $idClear = GUICtrlCreateButton("Clear", 64, 72, 75, 25)
    Local $idMylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97)
    GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
    GUICtrlSetData(-1, $sMESSAGE)
    Local $idClose = GUICtrlCreateButton("my closing button", 64, 160, 175, 25)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idAdd
                GUICtrlSetData($idMylist, "You clicked button No1|")
            Case $idClear
                GUICtrlSetData($idMylist, "")
            Case $idClose
                MsgBox($MB_SYSTEMMODAL, "", "the closing button has been clicked", 2)
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function GUICtrlCreateListView

Function Reference

GUICtrlCreateListView

Creates a ListView control for the GUI.

GUICtrlCreateListView ( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

text | definition of columns heading. Each of them are separated with Opt("GUIDataSeparatorChar").
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $LVS_SHOWSELALWAYS, $LVS_SINGLESEL forced style : $LVS_REPORT
exStyle | [optional] Defines the extended style of the control. See Extended Style Table or ListView Extended Style Table. default (-1) : $LVS_EX_FULLROWSELECT, $WS_EX_CLIENTEDGE

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To add items to a ListView control use GUICtrlCreateListViewItem()

The ListView will appear by default as in the Explorer view "Details" (LVS_REPORT style is forced).
You can control initial column size by padding blanks to the column heading definition. The column can be extend during the GUICtrlCreateListViewItem() according to item size. Size of a column will be up to around 25 characters. No resizing will be done during an update by GUICtrlSetData().

To create a ListView with Icon-, SmallIcon- or List-style just use after creation:
GUICtrlSetStyle() with the styles $LVS_ICON, $LVS_LIST or $LVS_SMALLICON.

Sorting the list by clicking the column name (as in Explorer) is not currently implemented.

To have the entire line visually selected use the extended style LVS_EX_FULLROWSELECT.

To combine styles with the default style use BitOR($GUI_SS_DEFAULT_LISTVIEW, newstyle, ... ).
To use the values specified above you must #include <ListViewConstants.au3> in your script.

If you add the style $LVS_EX_CHECKBOXES to the ListView, then the borders are removed. Add the style $WS_EX_CLIENTEDGE to display the borders.

The special flag $GUI_BKCOLOR_LV_ALTERNATE can be used with Listview control to give alternate background of the ListviewItems lines.
The odd lines will get the color set by GUICtrlSetBkColor() of the Listview control.
The even lines will get the color set by GUICtrlSetBkColor() of the ListviewItem control.

Related

GUICoordMode (Option), GUICtrlCreateListViewItem, GUICtrlRegisterListViewSort, GUICtrlSetData, GUIDataSeparatorChar (Option), GUIGetMsg

Example

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

Example()

Func Example()
    GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)
    GUISetBkColor(0x00E0FFFF) ; will change background color

    Local $idListview = GUICtrlCreateListView("col1  |col2|col3  ", 10, 10, 200, 150) ;,$LVS_SORTDESCENDING)
    Local $idButton = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
    Local $idItem1 = GUICtrlCreateListViewItem("item2|col22|col23", $idListview)
    Local $idItem2 = GUICtrlCreateListViewItem("item1|col12|col13", $idListview)
    Local $idItem3 = GUICtrlCreateListViewItem("item3|col32|col33", $idListview)
    GUICtrlCreateInput("", 20, 200, 150)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping
    GUISetState(@SW_SHOW)
    GUICtrlSetData($idItem2, "ITEM1")
    GUICtrlSetData($idItem3, "||COL33")
    GUICtrlDelete($idItem1)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idButton
                MsgBox($MB_SYSTEMMODAL, "listview item", GUICtrlRead(GUICtrlRead($idListview)), 2)

            Case $idListview
                MsgBox($MB_SYSTEMMODAL, "listview", "clicked=" & GUICtrlGetState($idListview), 2)

        EndSwitch
    WEnd
EndFunc   ;==>Example


Function GUICtrlCreateListViewItem

Function Reference

GUICtrlCreateListViewItem

Creates a ListView item.

GUICtrlCreateListViewItem ( "text", listviewID )

Parameters

text | subitemtext separated with Opt("GUIDataSeparatorChar").
listviewID | controlID of the ListView control holding the item.

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

This function creates the individual ListView items that can be selected. The items function as normal controls and can be set with GUICtrlSetData().
Items can be deleted as with any other control by using GUICtrlDelete().
ListView items can be dragged and drop into an Edit or Input control with a $GUI_DROPACCEPTED state.
See GUICtrlCreateListView() about resizing of the column.

The special flag $GUI_BKCOLOR_LV_ALTERNATE can be used with Listview control to give alternate background of the ListviewItems lines.
The odd lines will get the color set by GUICtrlSetBkColor() of the Listview control.
The even lines will get the color set by GUICtrlSetBkColor() of the ListviewItem control.

The above constants are defined in #include <GUIConstantsEx.au3>

Related

GUICtrlCreateListView, GUICtrlDelete, GUICtrlRead, GUICtrlSetData, GUICtrlSetState, GUIDataSeparatorChar (Option), GUIGetMsg

Example

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

Example()

Func Example()
    GUICreate("listview items", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)
    GUISetBkColor(0x00E0FFFF) ; will change background color

    Local $idListview = GUICtrlCreateListView("col1  |col2|col3  ", 10, 10, 200, 150) ;,$LVS_SORTDESCENDING)
    Local $idButton = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
    Local $idItem1 = GUICtrlCreateListViewItem("item2|col22|col23", $idListview)
    Local $idItem2 = GUICtrlCreateListViewItem("item1|col12|col13", $idListview)
    Local $idItem3 = GUICtrlCreateListViewItem("item3|col32|col33", $idListview)
    GUICtrlCreateInput("", 20, 200, 150)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping
    GUISetState(@SW_SHOW)
    GUICtrlSetData($idItem2, "ITEM1")
    GUICtrlSetData($idItem3, "||COL33")
    GUICtrlDelete($idItem1)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idButton
                MsgBox($MB_SYSTEMMODAL, "listview item", GUICtrlRead(GUICtrlRead($idListview)), 2)

            Case $idListview
                MsgBox($MB_SYSTEMMODAL, "listview", "clicked=" & GUICtrlGetState($idListview), 2)

        EndSwitch
    WEnd
EndFunc   ;==>Example


Function GUICtrlCreateMenu

Function Reference

GUICtrlCreateMenu

Creates a Menu control for the GUI.

GUICtrlCreateMenu ( "submenutext" [, menuID = -1 [, menuentry = -1]] )

Parameters

submenutext | The submenu text.
menuID | [optional] If defined, allows you to create a submenu in the referenced menu. If equal -1 it refers to first level menu.
menuentry | [optional] Allows you to define the entry number to be created. The entries are numbered starting at 0.

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To set or change information in the control see GUICtrlUpdate...() functions.

Related

GUICtrlCreateContextMenu, GUICtrlCreateMenuItem, GUICtrlGetHandle, GUICtrlSetState, GUIGetMsg

Example

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

Example()

Func Example()
    Local $sDefaultstatus = "Ready"

    GUICreate("My GUI menu", 300, 200)

    Local $idFilemenu = GUICtrlCreateMenu("&File")
    Local $idFileitem = GUICtrlCreateMenuItem("Open", $idFilemenu)
    GUICtrlSetState(-1, $GUI_DEFBUTTON)
    Local $idHelpmenu = GUICtrlCreateMenu("?")
    GUICtrlCreateMenuItem("Save", $idFilemenu)
    GUICtrlSetState(-1, $GUI_DISABLE)
    Local $idInfoitem = GUICtrlCreateMenuItem("Info", $idHelpmenu)
    Local $idExititem = GUICtrlCreateMenuItem("Exit", $idFilemenu)
    Local $idRecentfilesmenu = GUICtrlCreateMenu("Recent Files", $idFilemenu, 1)

    GUICtrlCreateMenuItem("", $idFilemenu, 2) ; create a separator line

    Local $idViewmenu = GUICtrlCreateMenu("View", -1, 1) ; is created before "?" menu
    Local $idViewstatusitem = GUICtrlCreateMenuItem("Statusbar", $idViewmenu)
    GUICtrlSetState(-1, $GUI_CHECKED)
    GUICtrlCreateButton("OK", 50, 130, 70, 20)
    GUICtrlSetState(-1, $GUI_FOCUS)
    Local $idCancelbutton = GUICtrlCreateButton("Cancel", 180, 130, 70, 20)

    Local $idStatuslabel = GUICtrlCreateLabel($sDefaultstatus, 0, 165, 300, 16, BitOR($SS_SIMPLE, $SS_SUNKEN))

    GUISetState(@SW_SHOW)

    Local $sFile
    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $idFileitem
                $sFile = FileOpenDialog("Choose file...", @TempDir, "All (*.*)")
                If @error <> 1 Then GUICtrlCreateMenuItem($sFile, $idRecentfilesmenu)
            Case $idViewstatusitem
                If BitAND(GUICtrlRead($idViewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then
                    GUICtrlSetState($idViewstatusitem, $GUI_UNCHECKED)
                    GUICtrlSetState($idStatuslabel, $GUI_HIDE)
                Else
                    GUICtrlSetState($idViewstatusitem, $GUI_CHECKED)
                    GUICtrlSetState($idStatuslabel, $GUI_SHOW)
                EndIf
            Case $GUI_EVENT_CLOSE, $idCancelbutton, $idExititem
                ExitLoop
            Case $idInfoitem
                MsgBox($MB_SYSTEMMODAL, "Info", "Only a test...")
        EndSwitch
    WEnd
    GUIDelete()
EndFunc   ;==>Example


Function GUICtrlCreateMenuItem

Function Reference

GUICtrlCreateMenuItem

Creates a MenuItem control for the GUI.

GUICtrlCreateMenuItem ( "text", menuID [, menuentry = -1 [, menuradioitem = 0]] )

Parameters

text | The text of the control.
menuID | Allows you to create a submenu in the referenced menu. If equal -1 it refers to the first level menu.
menuentry | [optional] Allows you to define the entry number to be created. The entries are numbered starting at 0.
menuradioitem | [optional] 0 (default) = create a normal menuitem, 1 = create a menuradioitem

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To set or change information in the control see GUICtrlUpdate...() functions.

If the Text parameter is a "" then a separator line is created. GUICtrlSetState() can be used as for other controls. See example.

Related

GUICtrlCreateContextMenu, GUICtrlCreateMenu, GUICtrlUpdate..., GUIGetMsg

Example

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

Example()

Func Example()
    GUICreate("My GUI menu", 300, 200)

    Local $sStatus = "Ready"

    Local $idFileMenu = GUICtrlCreateMenu("&File")
    Local $idFileItem = GUICtrlCreateMenuItem("Open", $idFileMenu)
    GUICtrlSetState(-1, $GUI_DEFBUTTON)
    Local $idHelpMenu = GUICtrlCreateMenu("?")
    GUICtrlCreateMenuItem("Save", $idFileMenu)
    GUICtrlSetState(-1, $GUI_DISABLE)
    Local $idInfoItem = GUICtrlCreateMenuItem("Info", $idHelpMenu)
    Local $idExit = GUICtrlCreateMenuItem("Exit", $idFileMenu)
    Local $idRecentFilesMenu = GUICtrlCreateMenu("Recent Files", $idFileMenu, 1)

    GUICtrlCreateMenuItem("", $idFileMenu, 2) ; Create a separator line

    Local $idViewMenu = GUICtrlCreateMenu("View", -1, 1) ; Is created before "?" menu
    Local $idViewStatusItem = GUICtrlCreateMenuItem("Statusbar", $idViewMenu)
    GUICtrlSetState(-1, $GUI_CHECKED)
    GUICtrlCreateButton("OK", 50, 130, 70, 20)
    GUICtrlSetState(-1, $GUI_FOCUS)
    Local $idCancel = GUICtrlCreateButton("Cancel", 180, 130, 70, 20)

    Local $idStatusLabel = GUICtrlCreateLabel($sStatus, 0, 165, 300, 16, BitOR($SS_SIMPLE, $SS_SUNKEN))

    GUISetState(@SW_SHOW)

    Local $sFilePath
    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idCancel, $idExit
                Exit

            Case $idInfoItem
                MsgBox($MB_SYSTEMMODAL, "Info", "Only a test...")

            Case $idFileItem
                $sFilePath = FileOpenDialog("Choose a file...", @TempDir, "All (*.*)")
                If @error Then
                    ContinueLoop
                EndIf
                GUICtrlCreateMenuItem($sFilePath, $idRecentFilesMenu)

            Case $idViewStatusItem
                If BitAND(GUICtrlRead($idViewStatusItem), $GUI_CHECKED) = $GUI_CHECKED Then
                    GUICtrlSetState($idViewStatusItem, $GUI_UNCHECKED)
                    GUICtrlSetState($idStatusLabel, $GUI_HIDE)
                Else
                    GUICtrlSetState($idViewStatusItem, $GUI_CHECKED)
                    GUICtrlSetState($idStatusLabel, $GUI_SHOW)
                EndIf
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function GUICtrlCreateMonthCal

Function Reference

GUICtrlCreateMonthCal

Creates a month calendar control for the GUI.

GUICtrlCreateMonthCal ( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

text | The preselected date (always as "yyyy/mm/dd").
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : none. forced style : $WS_TABSTOP
exStyle | [optional] Defines the extended style of the control. See Extended Style Table. default (-1) : WS_EX_CLIENTEDGE

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To obtain the value of the control see GUICtrlRead().

Default resizing is $GUI_DOCKSIZE.

Related

GUICoordMode (Option), GUICtrlRead, GUIGetMsg

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    GUICreate("Get date", 210, 190)

    Local $idDate = GUICtrlCreateMonthCal("1953/03/25", 10, 10)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idDate
                MsgBox($MB_SYSTEMMODAL, "debug", "calendar clicked")

        EndSwitch
    WEnd

    MsgBox($MB_SYSTEMMODAL, "Date", GUICtrlRead($idDate), 2)
EndFunc   ;==>Example


Function GUICtrlCreateObj

Function Reference

GUICtrlCreateObj

Creates an ActiveX control in the GUI.

GUICtrlCreateObj ( ObjectVar, left, top [, width [, height]] )

Parameters

ObjectVar | A variable pointing to a previously opened object
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

This function attempts to embed an 'ActiveX Control' or a 'Document Object' inside the GUI.
Not every control can be embedded. They must at least support an 'IDispatch' interface.

See the Obj/COM Reference for more information about Objects.

'Document Objects' will only be visible if the Windows style $WS_CLIPCHILDREN has been used in GUICreate().

The GUI functions GUICtrlRead() and GUICtrlSet have no effect on this control. The object can only be controlled using 'methods' or 'properties' on the $ObjectVar.

Related

IsObj, ObjCreate, ObjEvent, ObjGet

Example

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

Example()

; Simple example: Embedding an Internet Explorer Object inside an AutoIt GUI
; ; See also: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/internetexplorer.asp
Func Example()
    Local $idButton_Back, $idButton_Forward
    Local $idButton_Home, $idButton_Stop, $iMsg

    Local $oIE = ObjCreate("Shell.Explorer.2")

    ; Create a simple GUI for our output
    GUICreate("Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
    GUICtrlCreateObj($oIE, 10, 40, 600, 360)
    $idButton_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30)
    $idButton_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30)
    $idButton_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30)
    $idButton_Stop = GUICtrlCreateButton("Stop", 330, 420, 100, 30)

    GUISetState(@SW_SHOW) ;Show GUI

    $oIE.navigate("http://www.autoitscript.com")

    ; Loop until the user exits.
    While 1
        $iMsg = GUIGetMsg()

        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $iMsg = $idButton_Home
                $oIE.navigate("http://www.autoitscript.com")
            Case $iMsg = $idButton_Back
                $oIE.GoBack
            Case $iMsg = $idButton_Forward
                $oIE.GoForward
            Case $iMsg = $idButton_Stop
                $oIE.Stop
        EndSelect

    WEnd

    GUIDelete()
EndFunc   ;==>Example


Function GUICtrlCreatePic

Function Reference

GUICtrlCreatePic

Creates a Picture control for the GUI.

GUICtrlCreatePic ( filename, left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

filename | filename of the picture to be loaded : supported types BMP, JPG, GIF(but not animated).
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $SS_NOTIFY forced style : $SS_BITMAP
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0 if picture cannot be created.

Remarks

To set or change information in the control see GUICtrlUpdate...() functions.

To update the picture after the dialog box is displayed just use GUICtrlSetImage().

To set the picture control to the same size as the file content set width and height to 0.

To have a transparent picture create the GUI with the WS_EX_LAYERED extended style. The left-top pixel will be used as the transparency color. If several pictures are created the last picture defines the transparent color. See example 2.

To combine styles with the default style use BitOR($GUI_SS_DEFAULT_PIC, newstyle, ... ).
To use the values specified above you must #include <StaticConstants.au3> in your script.

Default resizing is $GUI_DOCKSIZE.

If a picture is set as a background picture the other controls will overlap, so it is important to disable the pic control: GUICtrlSetState(-1, $GUI_DISABLE).

The extended style $GUI_WS_EX_PARENTDRAG can be used to allow the dragging of the parent window for windows that do not have a titlebar (no $WS_CAPTION style in GUICreate()).

The background is always set to transparent. GUICtrlSetBkColor() has no effect on pic control.

Related

GUICoordMode (Option), GUICtrlSetImage, GUICtrlUpdate..., GUIGetMsg

Example

Example 1

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

Example()

Func Example()
    GUICreate("My GUI picture", 350, 300, -1, -1, $WS_SIZEBOX + $WS_SYSMENU) ; will create a dialog box that when displayed is centered

    GUISetBkColor(0xE0FFFF)
    Local $idPic = GUICtrlCreatePic("..\GUI\mslogo.jpg", 50, 50, 200, 50)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    ; resize the control
    GUICtrlSetPos($idPic, 50, 50, 200, 100)

    Local $idMsg
    ; Loop until the user exits.
    While 1
        $idMsg = GUIGetMsg()

        If $idMsg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd

    GUIDelete()
EndFunc   ;==>Example

Example 2

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

Global $g_hGui, $g_aGuiPos, $g_hPic, $g_aPicPos

Example()

Func Example()
    $g_hGui = GUICreate("test transparentpic", 200, 100)
    $g_hPic = GUICreate("", 68, 71, 10, 20, $WS_POPUp, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $g_hGui)
    GUICtrlCreatePic("..\GUI\merlin.gif", 0, 0, 0, 0)

    GUISetState(@SW_SHOW, $g_hPic)
    GUISetState(@SW_SHOW, $g_hGui)

    HotKeySet("{ESC}", "Main")
    HotKeySet("{Left}", "Left")
    HotKeySet("{Right}", "Right")
    HotKeySet("{Down}", "Down")
    HotKeySet("{Up}", "Up")
    $g_aPicPos = WinGetPos($g_hPic)
    $g_aGuiPos = WinGetPos($g_hGui)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    HotKeySet("{ESC}")
    HotKeySet("{Left}")
    HotKeySet("{Right}")
    HotKeySet("{Down}")
    HotKeySet("{Up}")
EndFunc   ;==>Example

Func Main()
    $g_aGuiPos = WinGetPos($g_hGui)
    WinMove($g_hGui, "", $g_aGuiPos[0] + 10, $g_aGuiPos[1] + 10)
EndFunc   ;==>Main

Func Left()
    $g_aPicPos = WinGetPos($g_hPic)
    WinMove($g_hPic, "", $g_aPicPos[0] - 10, $g_aPicPos[1])
EndFunc   ;==>Left

Func Right()
    $g_aPicPos = WinGetPos($g_hPic)
    WinMove($g_hPic, "", $g_aPicPos[0] + 10, $g_aPicPos[1])
EndFunc   ;==>Right

Func Down()
    $g_aPicPos = WinGetPos($g_hPic)
    WinMove($g_hPic, "", $g_aPicPos[0], $g_aPicPos[1] + 10)
EndFunc   ;==>Down

Func Up()
    $g_aPicPos = WinGetPos($g_hPic)
    WinMove($g_hPic, "", $g_aPicPos[0], $g_aPicPos[1] - 10)
EndFunc   ;==>Up


Function GUICtrlCreateProgress

Function Reference

GUICtrlCreateProgress

Creates a Progress control for the GUI.

GUICtrlCreateProgress ( left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix.
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To obtain the value of the control see GUICtrlRead().
To set or change information in the control see GUICtrlUpdate...() functions.

To update the bar position just use GUICtrlSetData().

To combine styles with the default style use BitOR($GUI_SS_DEFAULT_PROGRESS, newstyle, ... ).
To use the values specified above you must #include <ProgressConstants.au3> in your script.

Default resizing is $GUI_DOCKAUTO size and position will occur.

Related

GUICoordMode (Option), GUICtrlSetData, GUICtrlUpdate..., GUIGetMsg

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <ProgressConstants.au3>

Example()

Func Example()
    GUICreate("My GUI Progressbar", 220, 100, 100, 200)
    Local $idProgressbar1 = GUICtrlCreateProgress(10, 10, 200, 20)
    GUICtrlSetColor(-1, 32250); not working with Windows XP Style
    Local $idProgressbar2 = GUICtrlCreateProgress(10, 40, 200, 20, $PBS_SMOOTH)
    Local $idButton = GUICtrlCreateButton("Start", 75, 70, 70, 20)
    GUISetState(@SW_SHOW)

    Local $iWait = 20; wait 20ms for next progressstep
    Local $iSavPos = 0; progressbar-saveposition

    Local $idMsg, $idM
    ; Loop until the user exits.
    Do
        $idMsg = GUIGetMsg()
        If $idMsg = $idButton Then
            GUICtrlSetData($idButton, "Stop")
            For $i = $iSavPos To 100
                If GUICtrlRead($idProgressbar1) = 50 Then MsgBox($MB_SYSTEMMODAL, "Info", "The half is done...", 1)
                $idM = GUIGetMsg()

                If $idM = -3 Then ExitLoop

                If $idM = $idButton Then
                    GUICtrlSetData($idButton, "Next")
                    $iSavPos = $i;save the current bar-position to $iSavPos
                    ExitLoop
                Else
                    $iSavPos = 0
                    GUICtrlSetData($idProgressbar1, $i)
                    GUICtrlSetData($idProgressbar2, (100 - $i))
                    Sleep($iWait)
                EndIf
            Next
            If $i > 100 Then
                ;       $iSavPos=0
                GUICtrlSetData($idButton, "Start")
            EndIf
        EndIf
    Until $idMsg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function GUICtrlCreateRadio

Function Reference

GUICtrlCreateRadio

Creates a Radio button control for the GUI.

GUICtrlCreateRadio ( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

text | The text of the control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default text autofit in width).
height | [optional] The height of the control (default text autofit in height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : none. forced styles : $BS_AUTORADIOBUTTON and $WS_TABSTOP if first radio in the group.
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To obtain the value of the control see GUICtrlRead().
To set or change information in the control see GUICtrlUpdate...() functions.

To combine styles with the default style use BitOR($GUI_SS_DEFAULT_RADIO, newstyle, ... ).
To use the values specified above you must #include <ButtonConstants.au3> in your script.

Default resizing is $GUI_DOCKHEIGHT.

Related

GUICoordMode (Option), GUICtrlUpdate..., GUIGetMsg

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    GUICreate("My GUI radio") ; will create a dialog box that when displayed is centered

    Local $idRadio1 = GUICtrlCreateRadio("Radio 1", 10, 10, 120, 20)
    Local $idRadio2 = GUICtrlCreateRadio("Radio 2", 10, 40, 120, 20)
    GUICtrlSetState($idRadio2, $GUI_CHECKED)

    GUISetState(@SW_SHOW) ; will display an  dialog box with 1 checkbox

    Local $idMsg
    ; Loop until the user exits.
    While 1
        $idMsg = GUIGetMsg()
        Select
            Case $idMsg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $idMsg = $idRadio1 And BitAND(GUICtrlRead($idRadio1), $GUI_CHECKED) = $GUI_CHECKED
                MsgBox($MB_SYSTEMMODAL, 'Info:', 'You clicked the Radio 1 and it is Checked.')
            Case $idMsg = $idRadio2 And BitAND(GUICtrlRead($idRadio2), $GUI_CHECKED) = $GUI_CHECKED
                MsgBox($MB_SYSTEMMODAL, 'Info:', 'You clicked on Radio 2 and it is Checked.')
        EndSelect
    WEnd
EndFunc   ;==>Example


Function GUICtrlCreateSlider

Function Reference

GUICtrlCreateSlider

Creates a Slider control for the GUI.

GUICtrlCreateSlider ( left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $TBS_AUTOTICKS
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To obtain the value of the control see GUICtrlRead().
To set or change information in the control see GUICtrlUpdate...() functions.

To update the bar position just use GUICtrlSetData().
To set the min and max value use GUICtrlSetLimit().

To combine styles with the default style use BitOR($GUI_SS_DEFAULT_SLIDER, newstyle, ... ).
To use the values specified above you must #include <SliderConstants.au3> in your script.

Default resizing is $GUI_DOCKAUTO size and position will occur.

Related

GUICoordMode (Option), GUICtrlSetData, GUICtrlSetLimit, GUICtrlUpdate..., GUIGetMsg

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()

    GUICreate("slider", 220, 100, 100, 200)
    GUISetBkColor(0x00E0FFFF) ; will change background color

    Local $idSlider1 = GUICtrlCreateSlider(10, 10, 200, 20)
    GUICtrlSetLimit(-1, 200, 0) ; change min/max value
    Local $idButton = GUICtrlCreateButton("Value?", 75, 70, 70, 20)
    GUISetState(@SW_SHOW)
    GUICtrlSetData($idSlider1, 45) ; set cursor

    Local $idMsg
    ; Loop until the user exits.
    Do
        $idMsg = GUIGetMsg()

        If $idMsg = $idButton Then
            MsgBox($MB_SYSTEMMODAL, "slider1", GUICtrlRead($idSlider1), 2)
        EndIf
    Until $idMsg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function GUICtrlCreateTab

Function Reference

GUICtrlCreateTab

Creates a Tab control for the GUI.

GUICtrlCreateTab ( left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : none. forced styles : $TCS_TOOLTIPS, $WS_TABSTOP, $WS_CLIPSIBLINGS
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

A tab control is a control which can only contain tabitem controls. Any other controls should be created within these tabitems using GUICtrlCreate... functions as shown in the example. It is important to close the tab structure by creating a final tabitem control with a null text - GUICtrlCreateTabItem("").

To set or change information in the control see GUICtrlUpdate...() functions.

To combine styles with the default style use BitOR($GUI_SS_DEFAULT_TAB, newstyle, ... ).
To use the default value add #include <TabConstants.au3> in your script.

Default resizing is $GUI_DOCKSIZE.

A GUI can only hold a single tab control, but it is possible to create child GUIs each holding a tab control.

Related

GUICoordMode (Option), GUICtrlCreate..., GUICtrlCreateTabItem, GUICtrlUpdate..., GUIGetMsg

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    GUICreate("My GUI Tab") ; will create a dialog box that when displayed is centered

    GUISetBkColor(0x00E0FFFF)
    GUISetFont(9, 300)

    GUICtrlCreateTab(10, 10, 200, 100)

    GUICtrlCreateTabItem("tab0")
    GUICtrlCreateLabel("label0", 30, 80, 50, 20)
    GUICtrlCreateButton("OK0", 20, 50, 50, 20)
    GUICtrlCreateInput("default", 80, 50, 70, 20)

    GUICtrlCreateTabItem("tab----1")
    GUICtrlCreateLabel("label1", 30, 80, 50, 20)
    GUICtrlCreateCombo("", 20, 50, 60, 120)
    GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo|guinness", "Jon") ; default Jon
    GUICtrlCreateButton("OK1", 80, 50, 50, 20)

    GUICtrlCreateTabItem("tab2")
    GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
    GUICtrlCreateLabel("label2", 30, 80, 50, 20)
    GUICtrlCreateButton("OK2", 140, 50, 50)

    GUICtrlCreateTabItem("") ; end tabitem definition

    GUICtrlCreateLabel("label3", 20, 130, 50, 20)

    GUISetState(@SW_SHOW)

    Local $idMsg
    ; Loop until the user exits.
    While 1
        $idMsg = GUIGetMsg()

        If $idMsg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>Example


Function GUICtrlCreateTabItem

Function Reference

GUICtrlCreateTabItem

Creates a TabItem control within an existing tab control in the GUI.

GUICtrlCreateTabItem ( "text" )

Parameters

text The text of the control.

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To select a specific tabitem to be shown when the GUI opens use GUICtrlSetState(-1, $GUI_SHOW) as shown in the example.

It is important to close the tab structure by creating a final tabitem control with a null text - GUICtrlCreateTabItem("").

Controls for a specific tabitem should be created after the tabitem and before the creating a further tabitem or closing the tab structure. To create a new control on an existing tabitem, use GUISwitch($hWin, $tabitem) to select the correct tabitem and then create the new control. Do not forget to close the tabitem structure once again with GUICtrlCreateTabItem("").

The tabitem control cannot be colored (too much code ...).

GUICtrlRead() will return the index of the clicked tab item, or the controlID when advanced mode is used.

To set or change information in the control see GUICtrlUpdate...() functions.

Related

GUICtrlCreateTab, GUICtrlRead, GUICtrlSetState, GUIEventOptions (Option), GUIGetMsg, GUISwitch

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    GUICreate("My GUI Tab", 250, 150); will create a dialog box that when displayed is centered

    GUISetBkColor(0x00E0FFFF)
    GUISetFont(9, 300)

    Local $idTab = GUICtrlCreateTab(10, 10, 200, 100)

    GUICtrlCreateTabItem("tab0")
    GUICtrlCreateLabel("label0", 30, 80, 50, 20)
    GUICtrlCreateButton("OK0", 20, 50, 50, 20)
    GUICtrlCreateInput("default", 80, 50, 70, 20)

    GUICtrlCreateTabItem("tab----1")
    GUICtrlCreateLabel("label1", 30, 80, 50, 20)
    GUICtrlCreateCombo("", 20, 50, 60, 120)
    GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo|guinness", "Jon"); default Jon
    GUICtrlCreateButton("OK1", 80, 50, 50, 20)

    GUICtrlCreateTabItem("tab2")
    GUICtrlSetState(-1, $GUI_SHOW); will be display first
    GUICtrlCreateLabel("label2", 30, 80, 50, 20)
    GUICtrlCreateButton("OK2", 140, 50, 50)

    GUICtrlCreateTabItem(""); end tabitem definition

    GUICtrlCreateLabel("Click on tab and see the title", 20, 130, 250, 20)

    GUISetState(@SW_SHOW)

    Local $idMsg
    ; Loop until the user exits.
    While 1
        $idMsg = GUIGetMsg()

        If $idMsg = $GUI_EVENT_CLOSE Then ExitLoop
        If $idMsg = $idTab Then
            ; display the clicked tab
            WinSetTitle("My GUI Tab", "", "My GUI Tab" & GUICtrlRead($idTab))
        EndIf
    WEnd
EndFunc   ;==>Example


Function GUICtrlCreateTreeView

Function Reference

GUICtrlCreateTreeView

Creates a TreeView control for the GUI.

GUICtrlCreateTreeView ( left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS forced style : $WS_TABSTOP
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To set or change information in the control see GUICtrlUpdate...() functions.

To combine styles with the default style use BitOR($GUI_SS_DEFAULT_TREEVIEW, newstyle, ... ).
To use the values specified above you must #include <TreeViewConstants.au3> in your script.

Related

GUICoordMode (Option), GUICtrlCreateTreeViewItem, GUICtrlRead, GUICtrlUpdate..., GUIGetMsg

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    GUICreate("My GUI with treeview", 350, 215)

    Local $idTreeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
    Local $idGeneralitem = GUICtrlCreateTreeViewItem("General", $idTreeview)
    GUICtrlSetColor(-1, 0x0000C0)
    Local $idDisplayitem = GUICtrlCreateTreeViewItem("Display", $idTreeview)
    GUICtrlSetColor(-1, 0x0000C0)
    Local $idAboutitem = GUICtrlCreateTreeViewItem("About", $idGeneralitem)
    Local $idCompitem = GUICtrlCreateTreeViewItem("Computer", $idGeneralitem)
    GUICtrlCreateTreeViewItem("User", $idGeneralitem)
    GUICtrlCreateTreeViewItem("Resolution", $idDisplayitem)
    GUICtrlCreateTreeViewItem("Other", $idDisplayitem)

    Local $idStartlabel = GUICtrlCreateLabel("TreeView Demo", 190, 90, 100, 20)
    Local $idAboutlabel = GUICtrlCreateLabel("This little scripts demonstates the using of a treeview-control.", 190, 70, 100, 60)
    GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "aboutlabel"-text during initialization
    Local $idCompinfo = GUICtrlCreateLabel("Name:" & @TAB & @ComputerName & @CRLF & "OS:" & @TAB & @OSVersion & @CRLF & "SP:" & @TAB & @OSServicePack, 120, 30, 200, 80)
    GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "compinfo"-text during initialization

    GUICtrlCreateLabel("", 0, 170, 350, 2, $SS_SUNKEN)
    Local $idTogglebutton = GUICtrlCreateButton("&Toggle", 35, 185, 70, 20)
    Local $idInfobutton = GUICtrlCreateButton("&Info", 105, 185, 70, 20)
    Local $idStatebutton = GUICtrlCreateButton("Col./Exp.", 175, 185, 70, 20)
    Local $idCancelbutton = GUICtrlCreateButton("&Cancel", 245, 185, 70, 20)

    GUICtrlSetState($idGeneralitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "General"-item and paint in bold
    GUICtrlSetState($idDisplayitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "Display"-item and paint in bold

    GUISetState(@SW_SHOW)

    Local $idMsg, $idItem, $hItem, $sText
    ; Loop until the user exits.
    While 1
        $idMsg = GUIGetMsg()
        Select
            Case $idMsg = $idCancelbutton Or $idMsg = $GUI_EVENT_CLOSE
                ExitLoop

            Case $idMsg = $idTogglebutton ; Toggle the bold painting
                If BitAND(GUICtrlRead($idGeneralitem), $GUI_DEFBUTTON) Then
                    GUICtrlSetState($idGeneralitem, 0)
                    GUICtrlSetState($idDisplayitem, 0)
                Else
                    GUICtrlSetState($idGeneralitem, $GUI_DEFBUTTON)
                    GUICtrlSetState($idDisplayitem, $GUI_DEFBUTTON)
                EndIf

            Case $idMsg = $idInfobutton
                $idItem = GUICtrlRead($idTreeview) ; Get the controlID of the current selected treeview item
                If $idItem = 0 Then
                    MsgBox($MB_SYSTEMMODAL, "TreeView Demo", "No item currently selected")
                Else
                    $sText = GUICtrlRead($idItem, 1) ; Get the text of the treeview item
                    If $sText == "" Then
                        MsgBox($MB_SYSTEMMODAL, "Error", "Error while retrieving infos about item")
                    Else
                        MsgBox($MB_SYSTEMMODAL, "TreeView Demo", "Current item selected is: " & $sText)
                    EndIf
                EndIf

            Case $idMsg = $idStatebutton
                $idItem = GUICtrlRead($idTreeview)
                If $idItem > 0 Then
                    $hItem = GUICtrlGetHandle($idItem)
                    GUICtrlSendMsg($idTreeview, $TVM_EXPAND, $TVE_TOGGLE, $hItem)
                EndIf

                ; The following items will hide the other labels (1st and 2nd parameter) and then show the 'own' labels (3rd and 4th parameter)
            Case $idMsg = $idGeneralitem
                GUIChangeItems($idAboutlabel, $idCompinfo, $idStartlabel, $idStartlabel)

            Case $idMsg = $idAboutitem
                GUICtrlSetState($idCompinfo, $GUI_HIDE)
                GUIChangeItems($idStartlabel, $idStartlabel, $idAboutlabel, $idAboutlabel)

            Case $idMsg = $idCompitem
                GUIChangeItems($idStartlabel, $idAboutlabel, $idCompinfo, $idCompinfo)
        EndSelect
    WEnd

    GUIDelete()
EndFunc   ;==>Example

Func GUIChangeItems($idHidestart, $idHideend, $idShowstart, $idShowend)
    Local $idX

    For $idX = $idHidestart To $idHideend
        GUICtrlSetState($idX, $GUI_HIDE)
    Next
    For $idX = $idShowstart To $idShowend
        GUICtrlSetState($idX, $GUI_SHOW)
    Next
EndFunc   ;==>GUIChangeItems


Function GUICtrlCreateTreeViewItem

Function Reference

GUICtrlCreateTreeViewItem

Creates a TreeViewItem control for the GUI.

GUICtrlCreateTreeViewItem ( "text", treeviewID )

Parameters

text | The text of the control.
treeviewID | treeview identifier as return by treeview or treeviewitem creation if subtree is created.

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

For setting more information see GUICtrlUpdate...() functions.

To paint a treeview item in bold (to show as default) use GUICtrlSetState($treeviewItem, $GUI_DEFBUTTON), to turn off this behaviour use GUICtrlSetState() with another value but $GUI_DEFBUTTON, for instance GUICtrlSetState($treeviewItem, 0).

To expand a treeview item use GUICtrlSetState($treeviewItem, $GUI_EXPAND).

To select a specific treeview item use GUICtrlSetState($treeviewItem, $GUI_FOCUS).

Related

GUICtrlCreateTreeView, GUICtrlGetHandle, GUICtrlRead, GUICtrlUpdate..., GUIGetMsg

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    GUICreate("My GUI with treeview", 350, 215)

    Local $idTreeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
    Local $idGeneralitem = GUICtrlCreateTreeViewItem("General", $idTreeview)
    GUICtrlSetColor(-1, 0x0000C0)
    Local $idDisplayitem = GUICtrlCreateTreeViewItem("Display", $idTreeview)
    GUICtrlSetColor(-1, 0x0000C0)
    Local $idAboutitem = GUICtrlCreateTreeViewItem("About", $idGeneralitem)
    Local $idCompitem = GUICtrlCreateTreeViewItem("Computer", $idGeneralitem)
    GUICtrlCreateTreeViewItem("User", $idGeneralitem)
    GUICtrlCreateTreeViewItem("Resolution", $idDisplayitem)
    GUICtrlCreateTreeViewItem("Other", $idDisplayitem)

    Local $idStartlabel = GUICtrlCreateLabel("TreeView Demo", 190, 90, 100, 20)
    Local $idAboutlabel = GUICtrlCreateLabel("This little scripts demonstates the using of a treeview-control.", 190, 70, 100, 60)
    GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "aboutlabel"-text during initialization
    Local $idCompinfo = GUICtrlCreateLabel("Name:" & @TAB & @ComputerName & @CRLF & "OS:" & @TAB & @OSVersion & @CRLF & "SP:" & @TAB & @OSServicePack, 120, 30, 200, 80)
    GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "compinfo"-text during initialization

    GUICtrlCreateLabel("", 0, 170, 350, 2, $SS_SUNKEN)
    Local $idTogglebutton = GUICtrlCreateButton("&Toggle", 35, 185, 70, 20)
    Local $idInfobutton = GUICtrlCreateButton("&Info", 105, 185, 70, 20)
    Local $idStatebutton = GUICtrlCreateButton("Col./Exp.", 175, 185, 70, 20)
    Local $idCancelbutton = GUICtrlCreateButton("&Cancel", 245, 185, 70, 20)

    GUICtrlSetState($idGeneralitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "General"-item and paint in bold
    GUICtrlSetState($idDisplayitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "Display"-item and paint in bold

    GUISetState(@SW_SHOW)

    Local $idMsg, $idItem, $hItem, $sText
    ; Loop until the user exits.
    While 1
        $idMsg = GUIGetMsg()
        Select
            Case $idMsg = $idCancelbutton Or $idMsg = $GUI_EVENT_CLOSE
                ExitLoop

            Case $idMsg = $idTogglebutton ; Toggle the bold painting
                If BitAND(GUICtrlRead($idGeneralitem), $GUI_DEFBUTTON) Then
                    GUICtrlSetState($idGeneralitem, 0)
                    GUICtrlSetState($idDisplayitem, 0)
                Else
                    GUICtrlSetState($idGeneralitem, $GUI_DEFBUTTON)
                    GUICtrlSetState($idDisplayitem, $GUI_DEFBUTTON)
                EndIf

            Case $idMsg = $idInfobutton
                $idItem = GUICtrlRead($idTreeview) ; Get the controlID of the current selected treeview item
                If $idItem = 0 Then
                    MsgBox($MB_SYSTEMMODAL, "TreeView Demo", "No item currently selected")
                Else
                    $sText = GUICtrlRead($idItem, 1) ; Get the text of the treeview item
                    If $sText == "" Then
                        MsgBox($MB_SYSTEMMODAL, "Error", "Error while retrieving infos about item")
                    Else
                        MsgBox($MB_SYSTEMMODAL, "TreeView Demo", "Current item selected is: " & $sText)
                    EndIf
                EndIf

            Case $idMsg = $idStatebutton
                $idItem = GUICtrlRead($idTreeview)
                If $idItem > 0 Then
                    $hItem = GUICtrlGetHandle($idItem)
                    GUICtrlSendMsg($idTreeview, $TVM_EXPAND, $TVE_TOGGLE, $hItem)
                EndIf

                ; The following items will hide the other labels (1st and 2nd parameter) and then show the 'own' labels (3rd and 4th parameter)
            Case $idMsg = $idGeneralitem
                GUIChangeItems($idAboutlabel, $idCompinfo, $idStartlabel, $idStartlabel)

            Case $idMsg = $idAboutitem
                GUICtrlSetState($idCompinfo, $GUI_HIDE)
                GUIChangeItems($idStartlabel, $idStartlabel, $idAboutlabel, $idAboutlabel)

            Case $idMsg = $idCompitem
                GUIChangeItems($idStartlabel, $idAboutlabel, $idCompinfo, $idCompinfo)
        EndSelect
    WEnd

    GUIDelete()
EndFunc   ;==>Example

Func GUIChangeItems($idHidestart, $idHideend, $idShowstart, $idShowend)
    Local $idX

    For $idX = $idHidestart To $idHideend
        GUICtrlSetState($idX, $GUI_HIDE)
    Next
    For $idX = $idShowstart To $idShowend
        GUICtrlSetState($idX, $GUI_SHOW)
    Next
EndFunc   ;==>GUIChangeItems


Function GUICtrlCreateUpdown

Function Reference

GUICtrlCreateUpdown

Creates an UpDown control for the GUI.

GUICtrlCreateUpdown ( inputcontrolID [, style = -1] )

Parameters

inputcontrolID | The controlID of the input control in which the updown control will be created, or -1 for the last created control.
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $UDS_ALIGNRIGHT. forced style : $UDS_SETBUDDYINT and $UDS_ALIGNRIGHT if no align defined.

Return Value

Success: | the identifier (controlID) of the new control.
Failure: | 0.

Remarks

To use the values specified above you must #include <UpDownConstants.au3> in your script.

Max and min value can be set with GUICtrlSetLimit().
By default Windows increases the value when clicking the upper arrow button.

Default height resizing is done according to the one of the related input control.

Related

GUICtrlCreateInput, GUICtrlSetData, GUICtrlSetLimit

Example

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

Example()

Func Example()
    GUICreate("My GUI UpDown", -1, -1, -1, -1, $WS_SIZEBOX)

    Local $idInput = GUICtrlCreateInput("2", 10, 10, 50, 20)
    GUICtrlCreateUpdown($idInput)

    ; Attempt to resize input control
    GUICtrlSetPos($idInput, 10, 10, 100, 40)

    GUISetState(@SW_SHOW)

    Local $idMsg
    ; Loop until the user exits.
    While 1
        $idMsg = GUIGetMsg()

        Switch $idMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    MsgBox($MB_SYSTEMMODAL, "Updown", GUICtrlRead($idInput))
EndFunc   ;==>Example


Function GUICtrlDelete

Function Reference

GUICtrlDelete

Deletes a control.

GUICtrlDelete ( controlID )

Parameters

controlID The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.

Return Value

Success: | 1.
Failure: | 0.

Remarks

For context menu controls see GUICtrlCreateContextMenu() remarks.

Related

GUICreate, GUICtrlCreate..., GUICtrlCreateContextMenu

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    GUICreate("My GUI delete control", 200, 200, 800, 200)
    Local $idDate = GUICtrlCreateDate("1953/04/25", 10, 10, 185, 20)
    Local $idDel = GUICtrlCreateButton("Delete control", 50, 50, 70, 20)
    GUISetState(@SW_SHOW)

    Local $idMsg
    ; Loop until the user exits.
    Do
        $idMsg = GUIGetMsg()
        If $idMsg = $idDel Then
            GUICtrlDelete($idDate)
            GUICtrlDelete($idDel)
        EndIf
    Until $idMsg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Functions

GUI Control update functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

See Gui Constants include files if you need to use the related controls Constants .

Function | Description
GUICtrlRegisterListViewSort | Register a user defined function for an internal listview sorting callback function.
GUICtrlSetBkColor | Sets the background color of a control.
GUICtrlSetColor | Sets the text color of a control.
GUICtrlSetCursor | Sets the mouse cursor icon for a particular control.
GUICtrlSetData | Modifies the data for a control.
GUICtrlSetDefBkColor | Sets the default background color of all the controls of the GUI window.
GUICtrlSetDefColor | Sets the default text color of all the controls of the GUI window.
GUICtrlSetFont | Sets the font for a control.
GUICtrlSetGraphic | Modifies the data for a control.
GUICtrlSetImage | Sets the bitmap or icon image to use for a control.
GUICtrlSetLimit | Limits the number of characters/pixels for a control.
GUICtrlSetOnEvent | Defines a user-defined function to be called when a control is clicked.
GUICtrlSetPos | Changes the position of a control within the GUI window.
GUICtrlSetResizing | Defines the resizing method used by a control.
GUICtrlSetState | Changes the state of a control.
GUICtrlSetStyle | Changes the style of a control.
GUICtrlSetTip | Sets the tip text associated with a control.


Function GUICtrlRegisterListViewSort

Function Reference

GUICtrlRegisterListViewSort

Register a user defined function for an internal listview sorting callback function.

GUICtrlRegisterListViewSort ( controlID, "function" )

Parameters

controlID | The listview controlID for which the user function should proceed.
function | The name of the user function to call when the sorting callback runs.

Return Value

Success: | 1.
Failure: | 0.

Remarks

!!! To make the user function workable you have to define it with maximum 4 function parameters otherwise the function won't be called !!!
i.e:
Func MySortFunction($nListViewID, $LParam1, $LParam2, $nColumn)
...
EndFunc

Or

Func MySortFunction($nListViewID, $LParam1, $LParam2)
...
EndFunc

When the user function is called then these 4 parameters have the following values:

Position | Parameter | Meaning
1 | controlID | The controlID of the listview control for which the callback function is used.
2 | lParam1 | The lParam value of the first item (by default the item controlID).
3 | lParam2 | The lParam value of the second item (by default the item controlID).
4 | column | The column that was clicked for sorting (the first column number is 0).

The following values have to be Returned to change the behaviour of the sorting callback:

Return value | Meaning
-1 | 1st item should precede the 2nd.
0 | No Change.
1 | 1st item should follow the 2nd.

See also examples for sorting with self created GUI listview items.

Related

GUICtrlCreateListView

Example

Example 1

; sorting 3 column's different

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>

Global $g_iCurCol = -1
Global $g_iSortDir = 1
Global $g_bSet = False
Global $g_iCol = -1

Example()

Func Example()
    GUICreate("Test", 300, 200)

    Local $idLv = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180)
    GUICtrlRegisterListViewSort(-1, "LVSort") ; Register the function "SortLV" for the sorting callback

    GUICtrlCreateListViewItem("ABC|666|10.05.2004", $idLv)
    GUICtrlSetImage(-1, "shell32.dll", 7)
    GUICtrlCreateListViewItem("DEF|444|11.05.2005", $idLv)
    GUICtrlSetImage(-1, "shell32.dll", 12)
    GUICtrlCreateListViewItem("CDE|444|12.05.2004", $idLv)
    GUICtrlSetImage(-1, "shell32.dll", 3)

    GUISetState(@SW_SHOW)

    Local $idMsg
    ; Loop until the user exits.
    While 1
        $idMsg = GUIGetMsg()
        Switch $idMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idLv
                $g_bSet = False
                $g_iCurCol = $g_iCol
                GUICtrlSendMsg($idLv, $LVM_SETSELECTEDCOLUMN, GUICtrlGetState($idLv), 0)
        EndSwitch
    WEnd

    GUIDelete()
EndFunc   ;==>Example

; Our sorting callback funtion
Func LVSort($hWnd, $nItem1, $nItem2, $iColumn)
    Local $sVal1, $sVal2, $iResult

    ; Switch the sorting direction
    If $iColumn = $g_iCurCol Then
        If Not $g_bSet Then
            $g_iSortDir = $g_iSortDir * -1
            $g_bSet = True
        EndIf
    Else
        $g_iSortDir = 1
    EndIf
    $g_iCol = $iColumn

    $sVal1 = GetSubItemText($hWnd, $nItem1, $iColumn)
    $sVal2 = GetSubItemText($hWnd, $nItem2, $iColumn)

    ; If it is the 3rd colum (column starts with 0) then compare the dates
    If $iColumn = 2 Then
        $sVal1 = StringRight($sVal1, 4) & StringMid($sVal1, 4, 2) & StringLeft($sVal1, 2)
        $sVal2 = StringRight($sVal2, 4) & StringMid($sVal2, 4, 2) & StringLeft($sVal2, 2)
    EndIf

    $iResult = 0 ; No change of item1 and item2 positions

    If $sVal1 < $sVal2 Then
        $iResult = -1 ; Put item2 before item1
    ElseIf $sVal1 > $sVal2 Then
        $iResult = 1 ; Put item2 behind item1
    EndIf

    $iResult = $iResult * $g_iSortDir

    Return $iResult
EndFunc   ;==>LVSort

; Retrieve the text of a listview item in a specified column
Func GetSubItemText($idCtrl, $idItem, $iColumn)
    Local $tLvfi = DllStructCreate("uint;ptr;int;int[2];int")

    DllStructSetData($tLvfi, 1, $LVFI_PARAM)
    DllStructSetData($tLvfi, 3, $idItem)

    Local $tBuffer = DllStructCreate("char[260]")

    Local $nIndex = GUICtrlSendMsg($idCtrl, $LVM_FINDITEM, -1, DllStructGetPtr($tLvfi));

    Local $tLvi = DllStructCreate("uint;int;int;uint;uint;ptr;int;int;int;int")

    DllStructSetData($tLvi, 1, $LVIF_TEXT)
    DllStructSetData($tLvi, 2, $nIndex)
    DllStructSetData($tLvi, 3, $iColumn)
    DllStructSetData($tLvi, 6, DllStructGetPtr($tBuffer))
    DllStructSetData($tLvi, 7, 260)

    GUICtrlSendMsg($idCtrl, $LVM_GETITEMA, 0, DllStructGetPtr($tLvi));

    Local $sItemText = DllStructGetData($tBuffer, 1)

    Return $sItemText
EndFunc   ;==>GetSubItemText

Example 2

; sorting with selfcreated items by DllCall

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>

Global $g_iCurCol = -1
Global $g_iSortDir = 1
Global $g_bSet = False
Global $g_iCol = -1

Example()

Func Example()

    $g_iCurCol = -1
    $g_iSortDir = 1
    $g_bSet = False
    $g_iCol = -1

    Local $hGUI = GUICreate("Test", 300, 200)

    Local $idLv = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180)
    GUICtrlRegisterListViewSort(-1, "LVSort2") ; Register the function "SortLV" for the sorting callback

    MyGUICtrlCreateListViewItem("ABC|666|10.05.2004", $idLv, -1)
    MyGUICtrlCreateListViewItem("DEF|444|11.05.2005", $idLv, -1)
    MyGUICtrlCreateListViewItem("CDE|444|12.05.2004", $idLv, -1)

    GUISetState(@SW_SHOW)

    Local $idMsg
    ; Loop until the user exits.
    While 1
        $idMsg = GUIGetMsg()
        Switch $idMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idLv
                $g_bSet = False
                $g_iCurCol = $g_iCol
                GUICtrlSendMsg($idLv, $LVM_SETSELECTEDCOLUMN, GUICtrlGetState($idLv), 0)
                DllCall("user32.dll", "int", "InvalidateRect", "hwnd", ControlGetHandle($hGUI, "", $idLv), "int", 0, "int", 1)
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Our sorting callback funtion
Func LVSort2($hWnd, $idItem1, $idItem2, $idColumn)
    Local $sVal1, $sVal2, $iResult

    ; Switch the sorting direction
    If $idColumn = $g_iCurCol Then
        If Not $g_bSet Then
            $g_iSortDir = $g_iSortDir * -1
            $g_bSet = True
        EndIf
    Else
        $g_iSortDir = 1
    EndIf
    $g_iCol = $idColumn

    $sVal1 = GetSubItemText($hWnd, $idItem1, $idColumn)
    $sVal2 = GetSubItemText($hWnd, $idItem2, $idColumn)

    ; If it is the 3rd colum (column starts with 0) then compare the dates
    If $idColumn = 2 Then
        $sVal1 = StringRight($sVal1, 4) & StringMid($sVal1, 4, 2) & StringLeft($sVal1, 2)
        $sVal2 = StringRight($sVal2, 4) & StringMid($sVal2, 4, 2) & StringLeft($sVal2, 2)
    EndIf

    $iResult = 0 ; No change of item1 and item2 positions

    If $sVal1 < $sVal2 Then
        $iResult = -1 ; Put item2 before item1
    ElseIf $sVal1 > $sVal2 Then
        $iResult = 1 ; Put item2 behind item1
    EndIf

    $iResult = $iResult * $g_iSortDir

    Return $iResult
EndFunc   ;==>LVSort2

; Create and insert items directly into the listview
Func MyGUICtrlCreateListViewItem($sText, $idCtrl, $iIndex)
    Local $tLvitem = DllStructCreate("uint;int;int;uint;uint;ptr;int;int;int;int;")
    Local $tText = DllStructCreate("char[260]")
    Local $aText = StringSplit($sText, "|")

    If $iIndex = -1 Then $iIndex = GUICtrlSendMsg($idCtrl, $LVM_GETITEMCOUNT, 0, 0)

    DllStructSetData($tText, 1, $aText[1]) ; Save the item text in the struct

    DllStructSetData($tLvitem, 1, BitOR($LVIF_TEXT, $LVIF_PARAM))
    DllStructSetData($tLvitem, 2, $iIndex)
    DllStructSetData($tLvitem, 6, DllStructGetPtr($tText))
    ; Set the lParam of the struct to the line index - unique within the listview
    DllStructSetData($tLvitem, 9, $iIndex)

    $iIndex = GUICtrlSendMsg($idCtrl, $LVM_INSERTITEMA, 0, DllStructGetPtr($tLvitem))

    If $iIndex > -1 Then
        ; Insert now the rest of the column text
        For $i = 2 To $aText[0]
            DllStructSetData($tText, 1, $aText[$i])
            DllStructSetData($tLvitem, 3, $i - 1) ; Store the subitem index

            GUICtrlSendMsg($idCtrl, $LVM_SETITEMTEXTA, $iIndex, DllStructGetPtr($tLvitem))
        Next
    EndIf

    ; Change the column width to fit the item text
    For $i = 0 To 2
        GUICtrlSendMsg($idCtrl, $LVM_SETCOLUMNWIDTH, $i, -1)
        GUICtrlSendMsg($idCtrl, $LVM_SETCOLUMNWIDTH, $i, -2)
    Next
EndFunc   ;==>MyGUICtrlCreateListViewItem

; Retrieve the text of a listview item in a specified column
Func GetSubItemText($idCtrl, $idItem, $iColumn)
    Local $tLvfi = DllStructCreate("uint;ptr;int;int[2];int")

    DllStructSetData($tLvfi, 1, $LVFI_PARAM)
    DllStructSetData($tLvfi, 3, $idItem)

    Local $tBuffer = DllStructCreate("char[260]")

    Local $iIndex = GUICtrlSendMsg($idCtrl, $LVM_FINDITEM, -1, DllStructGetPtr($tLvfi));

    Local $tLvi = DllStructCreate("uint;int;int;uint;uint;ptr;int;int;int;int")

    DllStructSetData($tLvi, 1, $LVIF_TEXT)
    DllStructSetData($tLvi, 2, $iIndex)
    DllStructSetData($tLvi, 3, $iColumn)
    DllStructSetData($tLvi, 6, DllStructGetPtr($tBuffer))
    DllStructSetData($tLvi, 7, 260)

    GUICtrlSendMsg($idCtrl, $LVM_GETITEMA, 0, DllStructGetPtr($tLvi));

    Local $sItemText = DllStructGetData($tBuffer, 1)

    Return $sItemText
EndFunc   ;==>GetSubItemText


Function GUICtrlSetBkColor

Function Reference

GUICtrlSetBkColor

Sets the background color of a control.

GUICtrlSetBkColor ( controlID, backgroundcolor )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.
backgroundcolor | The RGB color to use.

Return Value

Success: | 1.
Failure: | 0.

Remarks

Only Button, Label, Checkbox, Group, Radio, Edit, Input, List, Listview, ListviewItem, Treeview, TreeviewItem, Graphic, Progress, Slider and Combo controls can currently be colored.

Progress controls cannot be painted if the "Windows XP style" is used.
Checkbox, Radio, Group Progress, Combo controls cannot be painted if the "Windows XP/Vista style" is used.

Button controls are always painted in "Windows Classic style". They cannot have the $BS_ICON style.

The special flag $GUI_BKCOLOR_TRANSPARENT can be used with Label, Group, Radio, Checkbox controls to give them a transparent background.

The special flag $GUI_BKCOLOR_LV_ALTERNATE can be used with Listview control to give alternate background of the ListviewItems lines.
The odd lines will get the color set by GUICtrlSetBkColor() of the Listview control.
The even lines will get the color set by GUICtrlSetBkColor() of the ListviewItem control.

Related

GUICtrlCreate..., GUICtrlSetColor, GUICtrlSetDefBkColor

Example

#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example", 300, 200)

    ; Create a label control.
    Local $idLabel = GUICtrlCreateLabel("A string of text", 10, 10, 185, 17)
    Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)

    ; Set the background color of the label control.
    GUICtrlSetBkColor($idLabel, $COLOR_RED)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idClose
                ExitLoop

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function GUICtrlSetColor

Function Reference

GUICtrlSetColor

Sets the text color of a control.

GUICtrlSetColor ( controlID, textcolor )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.
textcolor | The RGB color to use.

Return Value

Success: | 1.
Failure: | 0.

Remarks

Only Button, Label, Checkbox, Group, Radio, Edit, Input, List, Listview, ListviewItem, Treeview, TreeviewItem, Graphic, Progress and Combo controls can currently be colored.

Checkbox, Radio, Group or Progress controls cannot be painted if the "Windows XP/Vista style" is used.

Button controls are always painted in "Windows Classic style".

Related

GUICtrlCreate..., GUICtrlSetBkColor, GUICtrlSetDefColor

Example

#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example", 300, 200)

    ; Create a label control.
    Local $idLabel = GUICtrlCreateLabel("A string of text", 10, 10, 185, 17)
    Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)

    ; Set the color of the label control.
    GUICtrlSetColor($idLabel, $COLOR_RED)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idClose
                ExitLoop

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function GUICtrlSetCursor

Function Reference

GUICtrlSetCursor

Sets the mouse cursor icon for a particular control.

GUICtrlSetCursor ( controlID, cursorID )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.
cursorID | cursor ID as used by Windows SetCursor API (use -1 for the default mouse cursor for the control)

Return Value

Success: | 1.
Failure: | 0.

Remarks

Unlike GUISetCursor() which changes the mouse cursor for an entire window, this function sets the mouse cursor that is used when the mouse is hovering over the specified control.

If the cursorID is invalid the standard arrow will be displayed.

For a list of valid cursor IDs see MouseGetCursor().
CursorId = 16 will hide the mouse cursor.

Related

GUISetCursor

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    GUICreate("put cursor over label", 300, 100)
    GUICtrlCreateLabel("label", 125, 40)
    GUICtrlSetCursor(-1, 4)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
EndFunc   ;==>Example


Function GUICtrlSetData

Function Reference

GUICtrlSetData

Modifies the data for a control.

GUICtrlSetData ( controlID, data [, default] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.
data | Combo, List, ListView, ListViewItem: An Opt("GUIDataSeparatorChar",...) separated list of items. Progress: The percentage. Slider: The value. Button, Checkbox, Combo, Edit, Group, Input, Label, List, Menu, MenuItem, Radio, TabItem, TreeViewItem: Replaces the text. Date : The date or time depending the style of the control and the regional settings. Dummy: The value.
default | [optional] Combo, List: The default value. Edit, Input: If non-empty (""), the string is inserted at the current insertion point (caret).

Return Value

Success: | 1.
Failure: | 0. -1 in case of invalid data

Remarks

For Combo or List control :
If the "data" corresponds to an already existing entry it is set as the default.
If the "data" starts with GUIDataSeparatorChar or is an empty string "" the previous list is destroyed. A trailing GUIDataSeparatorChar is ignored.

For ListView, ListViewItem controls :
To update a specific column just forget about the others ie "||update" to update 3rd column.
If "update" is empty the column/subitem will be erased. For example "|" will erase the second column/subitem, "" will erase the first.

For Monthcal controls :
The "data" date format is "yyyy/mm/dd".

For Date controls:
The date and time is in the format defined by the regional settings. GUICtrlRead() use the same default format.

Related

GUICtrlCreate..., GUICtrlRead, GUICtrlUpdate..., GUIDataSeparatorChar (Option)

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    GUICreate("My GUI") ; will create a dialog box that when displayed is centered

    GUICtrlCreateCombo("", 10, 10)

    GUICtrlSetData(-1, "item1|item2|item3", "item3")

    GUISetState(@SW_SHOW) ; will display an empty dialog box with a combo control with focus on

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
EndFunc   ;==>Example


Function GUICtrlSetDefBkColor

Function Reference

GUICtrlSetDefBkColor

Sets the default background color of all the controls of the GUI window.

GUICtrlSetDefBkColor ( defbkcolor [, winhandle] )

Parameters

defbkcolor | Default background color for all controls.
winhandle | [optional] Windows handle as returned by GUICreate() (default is the previously used window).

Return Value

Success: | 1.
Failure: | 0.

Related

GUICreate, GUICtrlSetBkColor, GUICtrlSetDefColor

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    GUICreate("test GUISetTextColor", 100, 100) ; will create a dialog box that when displayed is centered

    GUICtrlSetDefBkColor(0xFF0000) ; will change text color for all defined controls

    GUICtrlCreateLabel("label", 10, 5)

    GUICtrlCreateRadio("radio", 10, 25, 50)
    GUICtrlSetBkColor(-1, 0x0000FF) ; will change text color for specified control

    GUICtrlCreateButton("button", 10, 55)

    GUISetState(@SW_SHOW) ; will display an empty dialog box

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
EndFunc   ;==>Example


Function GUICtrlSetDefColor

Function Reference

GUICtrlSetDefColor

Sets the default text color of all the controls of the GUI window.

GUICtrlSetDefColor ( deftextcolor [, winhandle] )

Parameters

deftextcolor | Default text color for all controls.
winhandle | [optional] Windows handle as returned by GUICreate() (default is the previously used window).

Return Value

Success: | 1.
Failure: | 0.

Related

GUICreate, GUICtrlSetColor, GUICtrlSetDefBkColor

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    GUICreate("test GUISetTextColor", 100, 100) ; will create a dialog box that when displayed is centered

    GUICtrlSetDefColor(0xFF0000) ; will change text color for all defined controls

    GUICtrlCreateLabel("label", 10, 5)

    GUICtrlCreateRadio("radio", 10, 25, 50)
    GUICtrlSetColor(-1, 0x0000FF) ; will change text color for specified control

    GUICtrlCreateButton("button", 10, 55)

    GUISetState(@SW_SHOW) ; will display an empty dialog box

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
EndFunc   ;==>Example


Function GUICtrlSetFont

Function Reference

GUICtrlSetFont

Sets the font for a control.

GUICtrlSetFont ( controlID, size [, weight [, attribute [, fontname [, quality]]]] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.
size | Fontsize (default is 8.5).
weight [optional] The weight of the font in the range 0 through 1000. For example, 400 is normal and 700 is bold. If this value is zero, a default weight is used.
The following values are defined for convenience.
$FW_DONTCARE = 0 (Use the default font weight)
$FW_THIN = 100
$FW_EXTRALIGHT = 200
$FW_LIGHT = 300
$FW_NORMAL = 400
$FW_MEDIUM = 500
$FW_SEMIBOLD = 600
$FW_BOLD = 700
$FW_EXTRABOLD = 800
$FW_HEAVY = 900

Constants are defined in FontConstants.au3.
attribute [optional] Font attributes, which can be a combination of the following added together:
$GUI_FONTITALIC (2) = Italic
$GUI_FONTUNDER (4) = Underlined
$GUI_FONTSTRIKE (8) = Strike

Constants are defined in GUIConstantsEx.au3.
fontname | [optional] Name of the font to use. (OS default GUI font is used if the font is "" or is not found).
quality [optional] Font quality to select. The following qualities are accepted:
$DEFAULT_QUALITY (0) = Appearance of the font does not matter.
$DRAFT_QUALITY (1) = Appearance of the font is less important than when $PROOF_QUALITY is used. For GDI raster fonts, scaling is enabled, which means that more font sizes are available, but the quality may be lower. Bold, italic, underline, and strikeout fonts are synthesized if necessary.
$PROOF_QUALITY (2) = (default) Character quality of the font is more important than exact matching of the logical-font attributes. For GDI raster fonts, scaling is disabled and the font closest in size is chosen. Although the chosen font size may not be mapped exactly when $PROOF_QUALITY is used, the quality of the font is high and there is no distortion of appearance. Bold, italic, underline, and strikeout fonts are synthesized if necessary.
$NONANTIALIASED_QUALITY (3) = Font is never antialiased.
$ANTIALIASED_QUALITY (4) = Font is always antialiased if the font supports it and the size of the font is not too small or too large.
$CLEARTYPE_QUALITY (5) = If set, text is rendered (when possible) using ClearType antialiasing method. See the remarks on the msdn page for LOGFONT for details about when cleartype is not available.
If neither $ANTIALIASED_QUALITY nor $NONANTIALIASED_QUALITY is selected, the font is antialiased only if the user chooses smooth screen fonts in Control Panel.
Constants are defined in FontConstants.au3

Return Value

Success: | 1.
Failure: | 0.

Remarks

By default, controls use the font set by GUISetFont().
See the Appendix for a complete list of Windows fonts and the Windows versions under which they are supported.

Size can contain a decimal as in 8.5.

For some controls such as labels, the default size can be 8.5 instead of 9 according to Windows Theme Values.

For Quality parameter check MSDN, some Windows XP installation need CLEARTYPE_QUALITY=5

Related

GUICtrlCreate..., GUISetFont

Example

#include <GUIConstantsEx.au3>
#include <FontConstants.au3>

Example()

Func Example()
    ; Font type to be used for setting the font of the controls.
    Local Const $sFont = "Comic Sans Ms"

    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example", 300, 200)

    ; Create label controls.
    GUICtrlCreateLabel("A string of text underlined", 10, 10, 185, 17)
    GUICtrlSetFont(-1, 9, $FW_NORMAL, $GUI_FONTUNDER, $sFont) ; Set the font of the previous control.

    Local $idLabel2 = GUICtrlCreateLabel("A string of italic text", 10, 30, 185, 17)
    GUICtrlSetFont($idLabel2, 9, $FW_NORMAL,  $GUI_FONTITALIC, $sFont) ; Set the font of the controlID stored in $iLabel2.

    Local $idLabel3 = GUICtrlCreateLabel("A string of text with a strike through", 10, 50, 290, 17)
    GUICtrlSetFont($idLabel3, 9, $FW_NORMAL, $GUI_FONTSTRIKE, $sFont) ; Set the font of the controlID stored in $iLabel3.

    Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idClose
                ExitLoop

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function GUICtrlSetGraphic

Function Reference

GUICtrlSetGraphic

Modifies the data for a control.

GUICtrlSetGraphic ( controlID, type [, par1 [, ... par6]] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreateGraphic() function.
type | type of drawing : dot, line, bezier, rect, ellipse, pie.
par1...par6 | See the Graphic Type table below.

Return Value

Success: | 1.
Failure: | 0. -1 in case of invalid data

Remarks

The point position (x,y) is relative to the GUICtrlCreateGraphic() coordinates. It can be outside the graphic control but inside of the GUI window.

Graphic Type table

Type | Parameters | result
$GUI_GR_COLOR | Color [,BkColor] | Define the color of the next drawings. When BkColor is equal to $GUI_GR_NOBKCOLOR the drawing will not be filled. It is the default. For Color the default line color is black.
$GUI_GR_MOVE | x,y | Move the current position without drawing.
$GUI_GR_DOT | x,y | Draw a point(smallest square around the point), the next drawing will start from previous position.
$GUI_GR_PIXEL | x,y | Draw a pixel, the next drawing will start from previous position.
$GUI_GR_LINE | x,y | Draw a line.
$GUI_GR_BEZIER | x,y,x1,y1,x2,y2 | Draw a bezier curve with 2 control points.
$GUI_GR_RECT | x,y,w,h | Draw a rectangle. If w=h it will be a square.
$GUI_GR_ELLIPSE | x,y,w,h | Draw an ellipse. If w=h it will be a circle.
$GUI_GR_PIE | x,y,r,sa,wa | Draw a pie radius=r startangle=sa sweepangle=wa. Angles are in degrees.
$GUI_GR_CLOSE |  | to close the current drawing. It has to be added to $GUI_GR_LINE or $GUI_GR_BEZIER to close current drawing. Use alone will be ignored.
$GUI_GR_REFRESH |  | to force refresh after dynamic update of graphics.
$GUI_GR_HINT |  | to display control point and end point of bezier/line curve.
$GUI_GR_PENSIZE | n | set pensize for the next drawings. It has to be defined before $GUI_GR_COLOR to be taken in account.
$GUI_GR_NOBKCOLOR |  | is a dummy BkColor to force closed drawing not to be filled. Just line drawings.

Due to design constraints RECT, ELLIPSE and PIE graphics are drawn first. For example, a LINE will always be drawn over a RECT. If the drawing order is important to the look of the graphic, then it is recommended that multiple graphic controls be used instead of using a single control to do all the drawing.

Related

GUICtrlCreateGraphic

Example

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

Global Const $g_MAXGr = 6
Global $g_aidGraphics[$g_MAXGr + 1] ; 0 and $g_MAXGr entries not used to allow GUICtrlDelete result
Global $g_idDel, $g_hChild

Example()

Func Example()
    Local $idMsg, $iInc, $i

    GUICreate("My Main", -1, -1, 100, 100)
    Local $idDel1 = GUICtrlCreateButton("ReCreate", 50, 200, 50)
    GUISetState(@SW_SHOW)
    CreateChild()

    $i = 1
    $iInc = 1
    ;$i=5   ; uncomment to delete starting from last define Graphic control
    ;$iInc=-1

    Do
        $idMsg = GUIGetMsg()
        If $idMsg = $idDel1 Then $i = Create($iInc)

        If $idMsg = $g_idDel Then
            GUICtrlDelete($g_aidGraphics[$i])
            $i = $i + $iInc
            If $i < 0 Or $i > $g_MAXGr Then Exit
        EndIf
    Until $idMsg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func Create($iInc)
    GUIDelete($g_hChild)
    CreateChild()
    If $iInc = -1 Then Return 5
    Return 1
EndFunc   ;==>Create

Func CreateChild()
    $g_hChild = GUICreate("My Draw")
    $g_idDel = GUICtrlCreateButton("Delete", 50, 165, 50)

    $g_aidGraphics[1] = GUICtrlCreateGraphic(20, 50, 100, 100)
    GUICtrlSetBkColor(-1, 0xffffff)
    GUICtrlSetColor(-1, 0)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0xffffff)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 58, 50, 40, -60, 90)

    GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 100, 100, 50, 80)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0xc0c0ff)
    GUICtrlSetGraphic(-1, $GUI_GR_RECT, 350, 200, 50, 80)
    GUICtrlCreateLabel("label", 65, 100, 30)
    GUICtrlSetColor(-1, 0xff)

    $g_aidGraphics[2] = GUICtrlCreateGraphic(220, 10, 100, 100)

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xff)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0xffffff)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 58, 50, 40, -60, 90)

    $g_aidGraphics[3] = GUICtrlCreateGraphic(220, 110, 100, 100)
    GUICtrlSetBkColor(-1, 0xf08080)
    GUICtrlSetColor(-1, 0xff)
    GUICtrlSetGraphic(-1, $GUI_GR_HINT, 1)

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff00)
    GUICtrlSetGraphic(-1, $GUI_GR_RECT, 50, 50, 80, 80)

    $g_aidGraphics[4] = GUICtrlCreateGraphic(20, 200, 80, 80)
    GUICtrlSetBkColor(-1, 0xffffff)
    GUICtrlSetGraphic(-1, $GUI_GR_HINT, 1)

    GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 10, 10)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 30, 40)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff00)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 70, 70)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 10, 50)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xffff00)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 10, 10)

    $g_aidGraphics[5] = GUICtrlCreateGraphic(150, 10, 50, 50)
    GUICtrlSetBkColor(-1, 0xa0ffa0)
    GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 20, 20) ; start point
    ; it is better to draw line and after point
    ; to avoid to switch color at each drawing
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x0000ff)
    GUICtrlSetGraphic(-1, $GUI_GR_DOT, 30, 30)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 20, 40)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000)
    GUICtrlSetGraphic(-1, $GUI_GR_DOT, 25, 25)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 40, 40)
    GUICtrlSetGraphic(-1, $GUI_GR_DOT, 30, 40)

    $g_aidGraphics[6] = GUICtrlCreateGraphic(110, 260, 230, 130)
    GUICtrlSetColor(-1, 0) ; to display a black border line
    GUICtrlSetBkColor(-1, 0xc0c0ff)
    GUICtrlSetGraphic(-1, $GUI_GR_HINT, 3) ; to display control lines and end points

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xff); fill in blue
    GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 120, 20) ; start point
    GUICtrlSetGraphic(-1, $GUI_GR_BEZIER, 120, 100, 200, 20, 200, 100)
    GUICtrlSetGraphic(-1, $GUI_GR_BEZIER + $GUI_GR_CLOSE, 100, 40, 40, 100, 40, 20)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 60, 30) ; start point

    GUISetState(@SW_SHOW)
EndFunc   ;==>CreateChild


Function GUICtrlSetImage

Function Reference

GUICtrlSetImage

Sets the bitmap or icon image to use for a control.

GUICtrlSetImage ( controlID, filename [, iconname [, icontype]] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.
filename | The filename containing the picture to be display on the control.
iconname | [optional] Icon name if the file contains multiple icons. Can be an ordinal name if negative number. Otherwise -1.
icontype | [optional] To select a specific icon size : 0 = small, 1 = normal (default). For a TreeViewItem the icon size : 2 = selected, 4 for non-selected item.

Return Value

Success: | 1.
Failure: | 0.

Remarks

Use a resource hacker to know the value of the valid icon name in a file.

If used on a Button control the image will be displayed on the button. Images can also be set for Checkbox controls as long as the $BS_PUSHLIKE style is used. In both case the $BS_ICON or $BS_BITMAP styles are needed to select the type of the picture used. The first icon resolution will be used in a multi icon resolution file. I.E. if a 128x128 is the first resolution and the control is 64x64 the image will be truncated.

!!! If you use this command on a TreeViewItem the first time, then all other items will use this icon/image automatically by default !!!
If you use GUICtrlSetImage() on a TreeView or ListView then all items of it will change to this icon/image.

Passing a positive number will reference the string equivalent icon name.
Passing a negative number causes 1-based "index" behaviour. Some Dll can have icon extracted just with negative numbers.

Related

GUICtrlCreateButton, GUICtrlCreateCheckbox, GUICtrlCreateIcon, GUICtrlCreatePic

Example

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    GUICreate("My GUI") ; will create a dialog box that when displayed is centered

    GUICtrlCreateButton("my picture button", 10, 20, 40, 40, $BS_ICON)
    GUICtrlSetImage(-1, "shell32.dll", 22)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
EndFunc   ;==>Example


Function GUICtrlSetLimit

Function Reference

GUICtrlSetLimit

Limits the number of characters/pixels for a control.

GUICtrlSetLimit ( controlID, max [, min = 0] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.
max | For List controls it is the extent you can scroll horizontally in pixels. For Input/Edit controls it is the max number of characters that can be entered.
min | [optional] For Slider and UpDown controls you can specify a min value. Default = 0

Return Value

Success: | 1.
Failure: | 0.

Related

GUICtrlCreateEdit, GUICtrlCreateInput, GUICtrlCreateList, GUICtrlCreateSlider, GUICtrlCreateUpdown

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    GUICreate("My GUI limit input 3 chars") ; will create a dialog box that when displayed is centered

    GUICtrlCreateInput("", 10, 20)
    GUICtrlSetLimit(-1, 3) ; to limit the entry to 3 chars

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
EndFunc   ;==>Example


Function GUICtrlSetOnEvent

Function Reference

GUICtrlSetOnEvent

Defines a user-defined function to be called when a control is clicked.

GUICtrlSetOnEvent ( controlID, "function" )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.
function | The name of the user function to call.

Return Value

Success: | 1.
Failure: | 0.

Remarks

OnEvent functions are only called when the option GUIOnEventMode is set to 1 - when in this mode GUIGetMsg() is NOT used at all.

You can not call a function using parameters.

Within the called user function the control identifier can be retrieved with @GUI_CtrlId.
If needed the windows handle and the control handle can be retrieved with @GUI_WinHandle or @GUI_CtrlHandle.

If the function is an empty string "" the previous user-defined is disabled.

Related

GUICtrlCreate..., GUICtrlCreateDummy, GUICtrlSendToDummy, GUIGetMsg, GUIOnEventMode (Option), GUISetOnEvent

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Opt("GUICoordMode", 2)
    Opt("GUIResizeMode", 1)
    Opt("GUIOnEventMode", 1)

    GUICreate("Parent1")
    GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
    GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
    GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")

    GUICtrlCreateButton("OK", 10, 30, 50)
    GUICtrlSetOnEvent(-1, "OKPressed")

    GUICtrlCreateButton("Cancel", 0, -1)
    GUICtrlSetOnEvent(-1, "CancelPressed")

    GUISetState(@SW_SHOW)

    ; Just idle around
    While 1
        Sleep(10)
    WEnd
EndFunc   ;==>Example

Func OKPressed()
    MsgBox($MB_SYSTEMMODAL, "OK Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle)
EndFunc   ;==>OKPressed

Func CancelPressed()
    MsgBox($MB_SYSTEMMODAL, "Cancel Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle)
EndFunc   ;==>CancelPressed

Func SpecialEvents()
    Select
        Case @GUI_CtrlId = $GUI_EVENT_CLOSE
            MsgBox($MB_SYSTEMMODAL, "Close Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)
            Exit

        Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE
            MsgBox($MB_SYSTEMMODAL, "Window Minimized", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)

        Case @GUI_CtrlId = $GUI_EVENT_RESTORE
            MsgBox($MB_SYSTEMMODAL, "Window Restored", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)

    EndSelect
EndFunc   ;==>SpecialEvents


Function GUICtrlSetPos

Function Reference

GUICtrlSetPos

Changes the position of a control within the GUI window.

GUICtrlSetPos ( controlID, left [, top [, width [, height]]] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.
left | The left side of the control.
top | [optional] The top of the control.
width | [optional] The width of the control.
height | [optional] The height of the control .

Return Value

Success: | 1.
Failure: | 0.

Remarks

If the Default keyword is used as a parameter, the current value is not modified.

Related

GUICtrlCreate...

Example

Example 1

#include <GUIConstantsEx.au3>

Example()

Func Example()

    GUICreate("My GUI position") ; will create a dialog box that when displayed is centered

    GUISetFont(16)
    Local $idLabel = GUICtrlCreateLabel("my moving label", 10, 20)

    GUISetState(@SW_SHOW)

    Local $idMsg, $bToggle = False
    While 1
        $idMsg = GUIGetMsg()

        If $idMsg = $GUI_EVENT_CLOSE Then Exit
        $bToggle = Not $bToggle
        If $bToggle Then
            GUICtrlSetPos($idLabel, 20, 20)
        Else
            GUICtrlSetPos($idLabel, 20, 30)
        EndIf
        Sleep(160)
    WEnd
EndFunc   ;==>Example

Example 2

#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iOldOpt = Opt("GUICoordMode", 1)

    Local $hGUI = GUICreate("My GUI icon Race", 350, 74, -1, -1)
    GUICtrlCreateLabel("", 331, 0, 1, 74, 5)
    Local $idIcon1 = GUICtrlCreateIcon(@ScriptDir & '\Extras\dinosaur.ani', -1, 0, 0, 32, 32)
    Local $idIcon2 = GUICtrlCreateIcon(@ScriptDir & '\Extras\horse.ani', -1, 0, 40, 32, 32)

    GUISetState(@SW_SHOW)

    Local $a = 0, $b = 0
    While ($a < 300) And ($b < 300)
        $a += Random(0, 1, 1)
        $b += Random(0, 1, 1)
        GUICtrlSetPos($idIcon1, $a, 0)
        GUICtrlSetPos($idIcon2, $b, 40)
        Sleep(10)
    WEnd
    Opt("GUICoordMode", $iOldOpt)
    If $a > $b Then
        MsgBox($MB_SYSTEMMODAL, 'Race results', 'The dinosaur won', 0, $hGUI)
    Else
        MsgBox($MB_SYSTEMMODAL, 'Race results', 'The horse won', 0, $hGUI)
    EndIf
EndFunc   ;==>Example


Function GUICtrlSetResizing

Function Reference

GUICtrlSetResizing

Defines the resizing method used by a control.

GUICtrlSetResizing ( controlID, resizing )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.
resizing | See the Docking Values table below for values that can be used (add together multiple values if required).

Return Value

Success: | 1.
Failure: | 0.

Remarks

When a GUI window is resized the controls within react - how they react is determined by this function. To be able to resize a GUI window it needs to have been created with the $WS_SIZEBOX and $WS_SYSMENU styles. See GUICreate().

Docking Values Table

Resizing | Value | No displacement of
$GUI_DOCKAUTO | 1 | resize and reposition according to new window size
$GUI_DOCKLEFT | 2 | Left side
$GUI_DOCKRIGHT | 4 | Right side
$GUI_DOCKHCENTER | 8 | Position will not move relative to horizontal center
$GUI_DOCKTOP | 32 | Top side
$GUI_DOCKBOTTOM | 64 | Bottom side
$GUI_DOCKVCENTER | 128 | Position will not move relative to vertical center
$GUI_DOCKWIDTH | 256 | Width will not change
$GUI_DOCKHEIGHT | 512 | Height will not change
 | Composite resizing
$GUI_DOCKSIZE | 768 | (256+512) Size will not change
$GUI_DOCKMENUBAR | 544 | (512+32) so the control will stay at the top of window with no change in Height
$GUI_DOCKSTATEBAR | 576 | (512+64) so the control stay at the bottom of the window with no change in Height
$GUI_DOCKALL | 802 | (2+32+256+512) so the control will not move during resizing
$GUI_DOCKBORDERS | 102 | (2+4+32+64) so the control will grow as the window

The default resizing for a given control is control dependent see the control doc.
A default value for any control can be set with GUIResizeMode (Option).

The automatic resizing event can be disabled if GUIEventOptions (Option) is set to 1.

Related

GUICtrlCreate..., GUIEventOptions (Option), GUIResizeMode (Option)

Example

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

Example()

Func Example()
    Opt("GUICoordMode", 2)
    GUICreate("My InputBox", 190, 114, -1, -1, $WS_SIZEBOX + $WS_SYSMENU) ; start the definition

    GUISetFont(8, -1, "Arial")

    GUICtrlCreateLabel("Prompt", 8, 7) ; add prompt info
    GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP)

    Local $idEdit = GUICtrlCreateInput("Default", -1, 3, 175, 20, $ES_PASSWORD) ; add the input area
    GUICtrlSetState($idEdit, $GUI_FOCUS)
    GUICtrlSetResizing($idEdit, $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)

    Local $idOK = GUICtrlCreateButton("OK", -1, 3, 75, 24) ; add the button that will close the GUI
    GUICtrlSetResizing($idOK, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE + $GUI_DOCKHCENTER)

    Local $idCancel = GUICtrlCreateButton("Annuler", 25, -1) ; add the button that will close the GUI
    GUICtrlSetResizing($idCancel, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE + $GUI_DOCKHCENTER)

    GUISetState(@SW_SHOW) ; to display the GUI

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
EndFunc   ;==>Example


Function GUICtrlSetState

Function Reference

GUICtrlSetState

Changes the state of a control.

GUICtrlSetState ( controlID, state )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.
state | See the State table below.

Return Value

Success: | 1.
Failure: | 0.

Remarks

State table

State | Comments
$GUI_CHECKED (1) | Radio, Checkbox or ListViewItem will be checked.
$GUI_INDETERMINATE (2) | Checkbox having the tristate attribute will be greyed.
$GUI_UNCHECKED (4) | Radio, Checkbox or ListViewItem will be unchecked.
$GUI_DROPACCEPTED (8) | Control will accept drop action : from file or from a drag of another control. See remarks.
$GUI_SHOW (16) | Control will be visible. On Tabitem control will select the first tab to be displayed.
$GUI_HIDE (32) | Control will not be visible.
$GUI_ENABLE (64) | Control will be enabled.
$GUI_DISABLE (128) | Control will be greyed out.
$GUI_FOCUS (256) | Control will be given input/selected focus.
$GUI_DEFBUTTON (512) | Control will be set as the default button on the window. See remark about TreeviewItems.
$GUI_EXPAND (1024) | TreeViewItem will expand its child items.
$GUI_ONTOP (2048) | Control will be have the ontop attribute for the window (zOrdering).
$GUI_NODROPACCEPTED (4096) | Control will not accept drop action.
$GUI_NOFOCUS (8192) | Listview control will loose focus.
$GUI_AVISTART (0) | Avi control will start playing.
$GUI_AVISTOP (1) | Avi control will stop playing.
$GUI_AVICLOSE (2) | Avi control will stop playing and release resource.

State values can be summed up as for example $GUI_DISABLE (128) + $GUI_HIDE (32) sets the control in an disabled and hidden state.

If an AVI control has to be hidden with $GUI_HIDE (32) it should be closed with $GUI_AVICLOSE (1).

State of a "contextmenu" control cannot be changed.
State of a "listviewitem" control can be changed if the associated "listview" control has been created with an extended style $LVS_EX_CHECKBOXES. $GUI_FOCUS (256) and $GUI_NOFOCUS (8192) can be used on specific listviewitem provided listview control style allows to display it : $LVS_SHOWSELALWAYS.
State of a "menu or a ""menuitem" control cannot be hidden.

! Important information for $GUI_EXPAND: this state is only used for TreeViewItems. If you want to use this 'action' then at least 1 Sub-TreeViewItem has to exist/created under this item !
If you want to select another item in a TreeView then you can use $GUI_FOCUS (256) - the parent TreeView gets the window focus and the specified item is marked as selected.
If you want to set a treeview item as a default item which means painting it bold you can use $GUI_DEFBUTTON (512) - to turn it off just use another value but $GUI_DEFBUTTON (512), for instance 0. This state will not be returned by GUICtrlGetState().

If $GUI_DROPACCEPTED (8) is set to a visible control a drag & drop can be taken in account. The edit/input control will be set with the filename.
For other controls on reception of $GUI_EVENT_DROPPED, @GUI_DragId will return the controlID from where the drag start (-1 if from a file, @GUI_DragFile contain the filename being dropped) and @GUI_DropId returns the controlID of the dropped control.
Only dragging a ListviewItem will start the drag & drop process. The @GUI_DragId will be the ListView controlID.

Related

GUICtrlCreate..., GUICtrlGetState

Example

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

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example", 420, 200, -1, -1, -1, $WS_EX_ACCEPTFILES)

    ; Create a label and set the state as drop accepted.
    Local $idLabel = GUICtrlCreateLabel("Drop a file on this label.", 10, 10, 400, 40, $WS_BORDER)
    GUICtrlSetState($idLabel, $GUI_DROPACCEPTED)

    ; Create an input and set the state as drop accepted.
    Local $idInput = GUICtrlCreateInput("", 10, 60, 400, 22)
    GUICtrlSetState($idInput, $GUI_DROPACCEPTED)

    Local $idOK = GUICtrlCreateButton("OK", 310, 170, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idOK
                ExitLoop

            Case $GUI_EVENT_DROPPED
                ; If the value of @GUI_DropId is $idLabel, then set the label of the dragged file.
                If @GUI_DropId = $idLabel Then GUICtrlSetData($idLabel, @GUI_DragFile)

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function GUICtrlSetStyle

Function Reference

GUICtrlSetStyle

Changes the style of a control.

GUICtrlSetStyle ( controlID, style [, exStyle] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.
style | Defines the style of the control. See GUI Control Styles Appendix.
exStyle | [optional] Defines the extended Style of the control. See Extended Style Table.

Return Value

Success: | 1.
Failure: | 0.

Remarks

Some styles cannot be changed dynamically, check MSDN documentation. $CBS_UPPERCASE combo style is one example.

Related

GUICtrlCreate...

Example

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

Example()

Func Example()
    GUICreate("My GUI style") ; will create a dialog box that when displayed is centered

    GUICtrlCreateLabel("my label which will split on several lines", 10, 20, 100, 100)
    GUICtrlSetStyle(-1, $SS_RIGHT)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
EndFunc   ;==>Example


Function GUICtrlSetTip

Function Reference

GUICtrlSetTip

Sets the tip text associated with a control.

GUICtrlSetTip ( controlID, tiptext [, "title" [, icon [, options]]] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.
tiptext | Tip text that will be displayed when the mouse is hovered over the control.
title | [optional] The title for the tooltip.
icon | [optional] Pre-defined icon to show next to the title: requires a title. $TIP_NOICON (0) = No icon $TIP_INFOICON (1) = Info icon $TIP_WARNINGICON (2) = Warning icon $TIP_ERRORICON (3) = Error Icon Constants are defined in "AutoItConstants.au3".
options | [optional] Sets different options for how the tooltip will be displayed (Can be added together): $TIP_BALLOON (1) = Display as Balloon Tip. $TIP_CENTER (2) = Center the tip horizontally along the control. Constants are defined in "AutoItConstants.au3".

Return Value

Success: | 1.
Failure: | 0.

Remarks

This tip text is displayed in a tooltip rectangular area.
To skip an optional parameter, leaving its default value intact, use the Default keyword..
You may use @CR or @LF to create multi-line tooltips.
To display an icon, you must specify a non-empty title. The icon appears on the same row as the title and thus requires a title to be present.

Related

GUICtrlUpdate...

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    GUICreate("My GUI control tip") ; will create a dialog box that when displayed is centered

    GUICtrlCreateLabel("my label", 10, 20)
    GUICtrlSetTip(-1, "tip of my label")

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
EndFunc   ;==>Example


Functions

GUI set parameters functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

See Gui Constants include files if you need to use the related controls Constants .

Function | Description
GUISetAccelerators | Sets the accelerator table to be used in a GUI window.
GUISetBkColor | Sets the background color of the GUI window.
GUISetCoord | Sets absolute coordinates for the next control.
GUISetCursor | Sets the mouse cursor icon for a GUI window.
GUISetFont | Sets the default font for a GUI window.
GUISetHelp | Sets an executable file that will be run when F1 is pressed.
GUISetIcon | Sets the icon used in a GUI window.
GUISetOnEvent | Defines a user function to be called when a system button is clicked.
GUISetState | Changes the state of a GUI window.
GUISetStyle | Changes the styles of a GUI window.


Function GUISetAccelerators

Function Reference

GUISetAccelerators

Sets the accelerator table to be used in a GUI window.

GUISetAccelerators ( accelerators [, winhandle] )

Parameters

accelerators | A 2 dimensional array holding the accelerator table (See remarks).
winhandle | [optional] Windows handle as returned by GUICreate() (default is the previously used window).

Return Value

Success: | 1.
Failure: | 0.

Remarks

Accelerator keys are similar to HotKeys, but there are 2 important differences:

- 1. They are only active when the GUI specified in the function is active which means that, unlike HotKeys, Accelerator keys will not interfere with other running applications.

- 2. They cannot fire a function directly - they action their associated control which then fires the function using GUIGetMsg() or GUICtrlSetOnEvent(). If there is no suitable control available in the GUI then a dummy control can be created using GUICtrlCreateDummy.

The array passed as a parameter to this function contains the Accelerator keys and the ControlIDs of the associated controls. The array must be defined as Local/Global $aArray[n][2] - where n is the number of Accelerator keys to set:

$aArray[0][0] = 1st Accelerator key (in HotKeySet() format)
$aArray[0][1] = Associated ControlID for 1st accelerator, as returned by GUICtrlCreate...
$aArray[1][0] = 2nd Accelerator key
$aArray[1][1] = Associated ControlID for 2nd accelerator
...
$aArray[n][0] = nth Accelerator key
$aArray[n][1] = Associated ControlID for the nth accelerator

Passing this function a non-array parameter will unset all accelerators for the specified winhandle.

Related

GUICreate, HotKeySet

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    GUICreate("Custom MsgBox", 225, 80)

    GUICtrlCreateLabel("Please select a button.", 10, 10)
    Local $idYes = GUICtrlCreateButton("Yes", 10, 50, 65, 25)
    Local $idNo = GUICtrlCreateButton("No", 80, 50, 65, 25)
    Local $idExit = GUICtrlCreateButton("Exit", 150, 50, 65, 25)

    ; Set GUIAccelerators for the button controlIDs, these being Ctrl + y and Ctrl + n
    Local $aAccelKeys[2][2] = [["^y", $idYes], ["^n", $idNo]]
    GUISetAccelerators($aAccelKeys)

    GUISetState(@SW_SHOW) ; Display the GUI.

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                MsgBox($MB_SYSTEMMODAL, "You selected", "Close")
                ExitLoop

            Case $idYes
                MsgBox($MB_SYSTEMMODAL, "You selected", "Yes") ; Displays if the button was selected or the hotkey combination Ctrl + y was pressed.

            Case $idNo
                MsgBox($MB_SYSTEMMODAL, "You selected", "No") ; Displays if the button was selected or the hotkey combination Ctrl + n was pressed.

            Case $idExit
                MsgBox($MB_SYSTEMMODAL, "You selected", "Exit")
                ExitLoop

        EndSwitch
    WEnd
    GUIDelete() ; Delete the GUI.
EndFunc   ;==>Example


Function GUISetBkColor

Function Reference

GUISetBkColor

Sets the background color of the GUI window.

GUISetBkColor ( background [, winhandle] )

Parameters

background | Background color of the dialog box.
winhandle | [optional] Windows handle as returned by GUICreate() (default is the previously used window).

Return Value

Success: | 1.
Failure: | 0.

Related

GUICreate

Example

#include <ColorConstantS.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    GUICreate("My GUI") ; will create a dialog box that when displayed is centered

    GUISetBkColor($COLOR_RED) ; will change background color

    GUISetState(@SW_SHOW) ; will display an empty dialog box

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    GUIDelete()
EndFunc   ;==>Example


Function GUISetCoord

Function Reference

GUISetCoord

Sets absolute coordinates for the next control.

GUISetCoord ( left, top [, width [, height [, winhandle]]] )

Parameters

left | The left side of the control.
top | The top of the control.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
winhandle | [optional] Windows handle as returned by GUICreate() (default is the previously used window).

Return Value

Success: | 1.
Failure: | 0.

Remarks

To be used specifically in Opt ("GUICoordMode", 2). It allows you to set the current position to a precise point and from that position to create controls by row (x_offset,-1) or by columns (-1, y_offset).

Related

GUICtrlCreate...

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Opt("GUICoordMode", 2) ; relative to cell mode

    GUICreate("My GUI Set Coord", 200, 100)
    GUICtrlCreateCheckbox("Check #1", 20, 10, 75)
    GUICtrlCreateCheckbox("Notify #2", 10, -1) ; next cell in the line

    GUISetCoord(20, 60)

    GUICtrlCreateButton("OK #3", -1, -1)
    GUICtrlCreateButton("Cancel #4", 10, -1)
    GUICtrlSetState(-1, $GUI_FOCUS)

    GUISetState(@SW_SHOW) ; will display an empty dialog box

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    GUIDelete()
EndFunc   ;==>Example


Function GUISetCursor

Function Reference

GUISetCursor

Sets the mouse cursor icon for a GUI window.

GUISetCursor ( [cursorID [, override = 0 [, winhandle]]] )

Parameters

cursorID | [optional] Cursor Id (See Remarks).
override | [optional] Force the requested mouse cursor even when over controls (see below). $GUI_CURSOR_NOOVERRIDE (0) = (default) Don't override a control's default mouse cursor. $GUI_CURSOR_OVERRIDE (1) = override control's default mouse cursor. Constants are defined in GUIConstantsEx.au3.
winhandle | [optional] Windows handle as returned by GUICreate() (default is the previously used window).

Return Value

None.

Remarks

If the cursorID is invalid the standard arrow will be displayed.

Usually when you move the mouse cursor over an edit control or other control the mouse cursor changes shape. The "override" option allows you to force the requested mouse cursor to be shown at all times. Note: If you have changed a controls mouse cursor with GUICtrlSetCursor() then this control mouse cursor will always be shown.

For a list of valid cursor IDs see MouseGetCursor().
CursorId = 16 will hide the mouse cursor.

Related

GUICtrlSetCursor

Example

#include <GUIConstantsEx.au3>

Global $g_iIDC = -1, $g_iNewIDC = 0
Global $g_aArray = StringSplit("Hand|AppStarting|Arrow|Cross|Help|IBeam|Icon (obsolete)|No|" & _
        "Size (obsolete)|SizeAll|SizeNESW|SizeNS|SizeNWSE|SizeWE|UpArrow|Wait|None", "|", 2) ; The flag parameter is set to flag = 2 as we don't require the total count of the array.

Example()

Func Example()
    HotKeySet("{ESC}", "Increment")

    GUICreate("Press ESC to Increment", 400, 400, 0, 0)

    GUISetState(@SW_SHOW)

    While GUIGetMsg() <> $GUI_EVENT_CLOSE
        If $g_iNewIDC <> $g_iIDC Then
            $g_iIDC = $g_iNewIDC
            GUISetCursor($g_iIDC)
        EndIf
        ToolTip("GUI Cursor #" & $g_iIDC & " (" & $g_aArray[$g_iIDC] & ")")
    WEnd

    GUIDelete()
EndFunc   ;==>Example

Func Increment()
    $g_iNewIDC = $g_iIDC + 1
    If $g_iNewIDC > 16 Then $g_iNewIDC = 0
EndFunc   ;==>Increment


Function GUISetFont

Function Reference

GUISetFont

Sets the default font for a GUI window.

GUISetFont ( size [, weight [, attribute [, fontname [, winhandle [, quality]]]]] )

Parameters

size | Fontsize (default is 8.5).
weight [optional] The weight of the font in the range 0 through 1000. For example, 400 is normal and 700 is bold. If this value is zero, a default weight is used.
The following values are defined for convenience.
$FW_DONTCARE = 0 (Use the default font weight)
$FW_THIN = 100
$FW_EXTRALIGHT = 200
$FW_LIGHT = 300
$FW_NORMAL = 400
$FW_MEDIUM = 500
$FW_SEMIBOLD = 600
$FW_BOLD = 700
$FW_EXTRABOLD = 800
$FW_HEAVY = 900

Constants are defined in FontConstants.au3.
attribute [optional] Font attributes, which can be a combination of the following added together:
$GUI_FONTNORMAL (0) = Normal (Default)
$GUI_FONTITALIC (2) = Italic
$GUI_FONTUNDER (4) = Underlined
$GUI_FONTSTRIKE (8) = Strike

Constants are defined in GUIConstantsEx.au3.
fontname | [optional] Font to use. (OS default GUI font is used if the font is "" or is not found).
winhandle | [optional] Windows handle as returned by GUICreate() (default is the previously used window).
quality [optional] Font quality to select. The following qualities are accepted:
$DEFAULT_QUALITY (0) = Appearance of the font does not matter (Default).
$DRAFT_QUALITY (1) = Appearance of the font is less important than when $PROOF_QUALITY is used. For GDI raster fonts, scaling is enabled, which means that more font sizes are available, but the quality may be lower. Bold, italic, underline, and strikeout fonts are synthesized if necessary.
$PROOF_QUALITY (2) = (default) Character quality of the font is more important than exact matching of the logical-font attributes. For GDI raster fonts, scaling is disabled and the font closest in size is chosen. Although the chosen font size may not be mapped exactly when $PROOF_QUALITY is used, the quality of the font is high and there is no distortion of appearance. Bold, italic, underline, and strikeout fonts are synthesized if necessary.
$NONANTIALIASED_QUALITY (3) = Font is never anti aliased.
$ANTIALIASED_QUALITY (4) = Font is always anti aliased if the font supports it and the size of the font is not too small or too large.
$CLEARTYPE_QUALITY (5) = If set, text is rendered (when possible) using ClearType anti aliasing method. See the remarks on the MSDN page for LOGFONT for details about when ClearType is not available.
If neither $ANTIALIASED_QUALITY nor $NONANTIALIASED_QUALITY is selected, the font is anti aliased only if the user chooses smooth screen fonts in Control Panel.
Constants are defined in FontConstants.au3

Return Value

Success: | 1.
Failure: | 0.

Remarks

See the Appendix for a complete list of Windows fonts and the Windows versions under which they are supported.

Size can contain a decimal as in 8.5.

For some control as label ones the default can be 8.5 instead of 9 according to Windows Theme Values.

For Quality parameter check MSDN, some Windows XP installation need CLEARTYPE_QUALITY=5

Related

GUICtrlSetFont

Example

#include <GUIConstantsEx.au3>
#include <FontConstants.au3>

Example()

Func Example()
    GUICreate("My GUI default font") ; will create a dialog box that when displayed is centered

    Local $sFont = "Comic Sans MS"
    GUISetFont(9,  $FW_NORMAL, $GUI_FONTUNDER, $sFont) ; will display underlined characters
    GUICtrlCreateLabel("underlined label", 10, 20)

    GUISetFont(9,  $FW_NORMAL, $GUI_FONTITALIC, $sFont) ; will display underlined characters
    GUICtrlCreateLabel("italic label", 10, 40)

    GUISetFont(9,  $FW_NORMAL, $GUI_FONTSTRIKE, $sFont) ; will display underlined characters
    GUICtrlCreateLabel("strike label", 10, 60)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    GUIDelete()
EndFunc   ;==>Example


Function GUISetHelp

Function Reference

GUISetHelp

Sets an executable file that will be run when F1 is pressed.

GUISetHelp ( helpfile [, winhandle] )

Parameters

helpfile | file that will be run if F1 is pressed when the GUI is active.
winhandle | [optional] Windows handle as returned by GUICreate() (default is the previously used window).

Return Value

Success: | 1.
Failure: | 0.

Related

GUICreate

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("Example")

    Local $sAutoItInstallDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & ((@OSArch = 'X64') ? "\Wow6432Node" : "") & "\AutoIt v3\AutoIt", "InstallDir")
    If Not @error Then
        GUISetHelp('hh.exe "' & $sAutoItInstallDir & '\AutoIt.chm"')
    EndIf

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    GUIDelete()
EndFunc   ;==>Example


Function GUISetIcon

Function Reference

GUISetIcon

Sets the icon used in a GUI window.

GUISetIcon ( iconfile [, iconID [, winhandle]] )

Parameters

iconfile | used to display the icon in the title area.
iconID | [optional] The ID of the icon in the iconfile. (Default is -1).
winhandle | [optional] Windows handle as returned by GUICreate() (default is the previously used window).

Return Value

Success: | 1.
Failure: | 0.

Remarks

Passing a positive number will reference the string equivalent icon name.
Passing a negative number causes 1-based "index" behaviour. Some Dll can have icon extracted

just with negative numbers.

Related

GUICreate

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; X64 running support
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"

    ; Retrieve the following ico file. This can be found in the include folder which is in the installation path of AutoIt.
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\icons\au3.ico"

    GUICreate("My GUI new icon") ; will create a dialog box that when displayed is centered

    GUISetIcon($sFile) ; will change icon

    GUISetState(@SW_SHOW); will display an empty dialog box

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    GUIDelete()
EndFunc   ;==>Example


Function GUISetOnEvent

Function Reference

GUISetOnEvent

Defines a user function to be called when a system button is clicked.

GUISetOnEvent ( specialID, "function" [, winhandle] )

Parameters

specialID | See the Special ID table below.
function | The name of the user function to call.
winhandle | [optional] Windows handle as returned by GUICreate() (default is the previously used window).

Return Value

Success: | 1.
Failure: | 0.

Remarks

OnEvent functions are only called when Opt("GUIOnEventMode", 1) - when in this mode GUIGetMsg() is NOT used at all.

You can not call a function using parameters.

If Opt ("GUIEventOptions", 1) the minimize, restore and maximize button will not do any action on the window just a simple notification.

If the function is an empty string "" the previous user-defined is disabled.

Special ID table

Special Id | Comments
$GUI_EVENT_CLOSE | dialog box being closed (either by defined button or system menu).
$GUI_EVENT_MINIMIZE | dialog box minimized with Windows title bar button.
$GUI_EVENT_RESTORE | dialog box restored by click on task bar icon.
$GUI_EVENT_MAXIMIZE | dialog box maximized with Windows title bar button.
$GUI_EVENT_MOUSEMOVE | the mouse cursor has moved.
$GUI_EVENT_PRIMARYDOWN | the primary mouse button was pressed.
$GUI_EVENT_PRIMARYUP | the primary mouse button was released.
$GUI_EVENT_SECONDARYDOWN | the secondary mouse button was pressed.
$GUI_EVENT_SECONDARYUP | the secondary mouse button was released.
$GUI_EVENT_RESIZED | dialog box has been resized.
$GUI_EVENT_DROPPED | End of a Drag&Drop action @GUI_DragId, @GUI_DragFile and @GUI_DropId will be used to retrieve the ID's/file corresponding to the involve control.

Related

GUICtrlSetOnEvent, GUIEventOptions (Option), GUIOnEventMode (Option)

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Opt("GUICoordMode", 2)
    Opt("GUIResizeMode", 1)
    Opt("GUIOnEventMode", 1)

    GUICreate("Parent1")
    GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
    GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
    GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")

    GUICtrlCreateButton("OK", 10, 30, 50)
    GUICtrlSetOnEvent(-1, "OKPressed")

    GUICtrlCreateButton("Cancel", 0, -1)
    GUICtrlSetOnEvent(-1, "CancelPressed")

    GUISetState(@SW_SHOW)

    ; Just idle around
    While 1
        Sleep(10)
    WEnd
EndFunc   ;==>Example

Func OKPressed()
    MsgBox($MB_SYSTEMMODAL, "OK Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle)
EndFunc   ;==>OKPressed

Func CancelPressed()
    MsgBox($MB_SYSTEMMODAL, "Cancel Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle)
EndFunc   ;==>CancelPressed

Func SpecialEvents()
    Select
        Case @GUI_CtrlId = $GUI_EVENT_CLOSE
            MsgBox($MB_SYSTEMMODAL, "Close Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)

            GUIDelete()
            Exit

        Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE
            MsgBox($MB_SYSTEMMODAL, "Window Minimized", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)

        Case @GUI_CtrlId = $GUI_EVENT_RESTORE
            MsgBox($MB_SYSTEMMODAL, "Window Restored", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle)

    EndSelect
EndFunc   ;==>SpecialEvents


Function GUISetState

Function Reference

GUISetState

Changes the state of a GUI window.

GUISetState ( [flag [, winhandle]] )

Parameters

flag | [optional] @SW_SHOW = Shows a previously hidden window (default) @SW_HIDE = Hide window @SW_MINIMIZE = Minimize window @SW_MAXIMIZE = Maximize window @SW_RESTORE = Undoes a window minimization @SW_DISABLE = Disables the window @SW_ENABLE = Enables the window @SW_LOCK = Lock the window to avoid repainting. @SW_UNLOCK = Unlock windows to allow painting. @SW_SHOWDEFAULT - Sets the show state based on the SW_ flag specified in the STARTUPINFO structure @SW_SHOWMAXIMIZED - Activates the window and displays it as a maximized window @SW_SHOWMINIMIZED - Activates the window and displays it as a minimized window @SW_SHOWMINNOACTIVE - Displays the window as a minimized window @SW_SHOWNA - Displays the window in its current state @SW_SHOWNOACTIVATE - Displays a window in its most recent size and position @SW_SHOWNORMAL - Activates and displays a window
winhandle | [optional] Windows handle as returned by GUICreate() (default is the previously used window).

Return Value

Success: | 1.
Failure: | 0.

Remarks

When windows are created they are initially hidden so you must use this function to display them (@SW_SHOW).

Only one window can be locked with @SW_LOCK. Any other @SW_LOCK will lock the requested window.
@SW_UNLOCK just ignored the "winhandle" to unlock any locked window.

Related

GUICreate

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    GUICreate("My GUI") ; start the definition

    GUISetState(@SW_SHOW) ; will display an empty dialog box

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd
EndFunc   ;==>Example


Function GUISetStyle

Function Reference

GUISetStyle

Changes the styles of a GUI window.

GUISetStyle ( Style [, ExStyle [, winhandle]] )

Parameters

style | defines the style of the window. See GUI Control Styles Appendix. Use -1 to leave it unchanged.
exStyle | [optional] defines the extended style of the window. See the Extended Style Table. -1 is the default. Use -1 to leave it unchanged.
winhandle | [optional] Windows handle as returned by GUICreate() (default is the previously used window).

Return Value

Success: | 1.
Failure: | 0.

Remarks

No checking is done on style value, neither non interaction with already defined control. It is the designer responsibility to take care of this compatibility.

Related

GUIGetStyle

Example

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

Example()

Func Example()

    GUICreate("Gui Style", 260, 100)
    Local $idButton = GUICtrlCreateButton("Set Style", 45, 50, 150, 20)
    GUISetState(@SW_SHOW)

    Local $bNewStyle = False, $idMsg
    While 1
        $idMsg = GUIGetMsg()
        Switch $idMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idButton
                If Not $bNewStyle Then
                    GUISetStyle(BitOR($WS_POPUPWINDOW, $WS_THICKFRAME), BitOR($WS_EX_CLIENTEDGE, $WS_EX_TOOLWINDOW))
                    GUICtrlSetData($idButton, 'Undo Style')
                    $bNewStyle = True
                Else
                    GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU), 0)
                    GUICtrlSetData($idButton, 'Set Style')
                    $bNewStyle = False
                EndIf
        EndSwitch
    WEnd

    GUIDelete()
EndFunc   ;==>Example


Function GUIDelete

Function Reference

GUIDelete

Deletes a GUI window and all controls that it contains.

GUIDelete ( [winhandle] )

Parameters

winhandle [optional] Windows handle as returned by GUICreate() (default is the previously used window).

Return Value

Success: | 1.
Failure: | 0.

Related

GUICreate, GUISwitch

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    GUICreate("My GUI") ; will create a dialog box that when displayed is centered

    GUISetState(@SW_SHOW) ; will display an empty dialog box

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    GUIDelete();    ; will return 1
EndFunc   ;==>Example


Function GUICtrlGetHandle

Function Reference

GUICtrlGetHandle

Returns the handle for a control and some special (item) handles (Menu, ContextMenu, TreeViewItem).

GUICtrlGetHandle ( controlID )

Parameters

controlID Control identifier as returned by a GUICtrlCreate...() function.

Return Value

Success: | the handle of the given control ID.
Failure: | 0.

Remarks

The following controls will not return a handle: GUICtrlCreateDummy(), GUICtrlCreateGraphic(), GUICtrlCreateObj(), GUICtrlCreateListViewItem() and GUICtrlCreateTabItem().

ListViewItems and TabItems are managed through indexes. To get the index of these items use DllCall() and DllStructCreate().

Related

IsHWnd

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    GUICreate("My GUI", 300, 200)

    Local $idFileMenu = GUICtrlCreateMenu("&File")
    GUICtrlCreateMenuItem("&Open", $idFileMenu)
    GUICtrlCreateMenuItem("&Save", $idFileMenu)
    GUICtrlCreateMenuItem("", $idFileMenu)

    Local $idOptionsMenu = GUICtrlCreateMenu("O&ptions", $idFileMenu)
    GUICtrlCreateMenuItem("View", $idOptionsMenu)
    GUICtrlCreateMenuItem("", $idOptionsMenu)
    GUICtrlCreateMenuItem("Tools", $idOptionsMenu)

    GUICtrlCreateMenuItem("", $idFileMenu)
    Local $idExitItem = GUICtrlCreateMenuItem("&Exit", $idFileMenu)

    Local $idHelpMenu = GUICtrlCreateMenu("&?")
    Local $idAboutItem = GUICtrlCreateMenuItem("&About", $idHelpMenu)

    Local $idEndBtn = GUICtrlCreateButton("End", 110, 140, 70, 20)

    SetMenuColor($idFileMenu, 0xEEBB99) ; BGR color value
    SetMenuColor($idOptionsMenu, 0x66BB99); BGR color value
    SetMenuColor($idHelpMenu, 0x99BBEE) ; BGR color value

    GUISetState(@SW_SHOW)

    Local $idMsg
    ; Loop until the user exits.
    While 1
        $idMsg = GUIGetMsg()

        Switch $idMsg
            Case $idExitItem, $idEndBtn, $GUI_EVENT_CLOSE
                ExitLoop

            Case $idAboutItem
                MsgBox($MB_SYSTEMMODAL, "About...", "Colored menu sample")
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Apply the color to the menu
Func SetMenuColor($nMenuID, $nColor)
    Local Const $MIM_APPLYTOSUBMENUS = 0x80000000
    Local Const $MIM_BACKGROUND = 0x00000002

    Local $hMenu = GUICtrlGetHandle($nMenuID)

    Local $hBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $nColor)
    $hBrush = $hBrush[0]

    Local $tMenuInfo = DllStructCreate("dword;dword;dword;uint;dword;dword;ptr")
    DllStructSetData($tMenuInfo, 1, DllStructGetSize($tMenuInfo))
    DllStructSetData($tMenuInfo, 2, BitOR($MIM_APPLYTOSUBMENUS, $MIM_BACKGROUND))
    DllStructSetData($tMenuInfo, 5, $hBrush)

    DllCall("user32.dll", "int", "SetMenuInfo", "hwnd", $hMenu, "struct*", $tMenuInfo)

    ; release Struct not really needed as it is a local
    $tMenuInfo = 0
EndFunc   ;==>SetMenuColor


Function GUICtrlGetState

Function Reference

GUICtrlGetState

Gets the current state of a control.

GUICtrlGetState ( controlID )

Parameters

controlID The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.

Return Value

Success: | the state. See GUICtrlSetState() for values.
Failure: | -1 if control is not defined.

Remarks

As opposed to GUICtrlRead() this function returns ONLY the state of a control enabled/disabled/hidden/show/dropaccepted

Exceptions:
For ListView controls it returns the number of the clicked column.

Related

GUICtrlRead, GUICtrlSetState

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    GUICreate("My GUI (GetControlState)")
    Local $idCheckbox = GUICtrlCreateCheckbox("checkbox", 10, 10)
    GUICtrlSetState(-1, 1) ; checked

    GUISetState(@SW_SHOW) ; will display an empty dialog box

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    MsgBox($MB_SYSTEMMODAL, "state", StringFormat("GUICtrlRead=%d\nGUICtrlGetState=%d", GUICtrlRead($idCheckbox), GUICtrlGetState($idCheckbox)))
EndFunc   ;==>Example


Function GUICtrlRead

Function Reference

GUICtrlRead

Read state or data of a control.

GUICtrlRead ( controlID [, advanced = 0] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.
advanced | [optional] returns extended information of a control. $GUI_READ_DEFAULT (0) = (Default) Returns a value with state or data of a control. $GUI_READ_EXTENDED (1) = Returns extended information of a control (see Remarks). Constants are defined in GUIConstantsEx.au3.

Return Value

Success: | depends on the control (see below).
Failure: | 0.

Type | Value
Checkbox, Radio | The checked state ($GUI_CHECKED or $GUI_UNCHECKED)
Combo, List | The value selected
Input, Edit | The text entered
Button | The display text
Date | The selected date in the format defined by the regional settings
Progress | Current percentage
Slider | Current value
Tab | The index of the selected tabitem (0-based)
Menu, MenuItem | State of the menu/item. See State table
TreeView | Control identifier (controlID) of the selected TreeViewItem
TreeViewItem | State of the TreeViewItem
ListView | Control identifier (controlID) of the selected ListViewItem. 0 means no item is selected
ListViewItem | The text of the selected item/lines in the ListView
Dummy | The value set by GUICtrlSendToDummy() or GUICtrlSetData()

Remarks

In 'advanced' mode the return value contains additional data of the control (see below).

Note: not all controls return additional data!

Type | Additional Value
Checkbox, Radio | The text of the control.
Menu, MenuItem | The text of the control.
TreeView | The text of the current selected TreeViewItem.
TreeViewItem | The text of the TreeViewItem.
ListViewItem | The state of the ListViewItem if $LVS_EX_CHECKBOXES exStyle used in advanced mode. See State table
Tab | The controlID of the tabitem selected

For Checkbox and Radio controls only the $GUI_CHECKED (1), $GUI_UNCHECKED (4) or $GUI_INDETERMINATE (2) states are returned so the value can be used directly.

For Listview items several states can be returned as $GUI_CHECKED and $GUI_UNCHECKED (only for listview controls with LVS_EX_CHECKBOXES-exstyle and on 'advanced' return) . So use i.e. BitAND(GUICtrlRead($Item),$GUI_CHECKED) to test if the item is checked.

For Treeview items several states can be returned as $GUI_FOCUS, $GUI_EXPAND and $GUI_CHECKED, $GUI_UNCHECKED (only for treeview controls with TVS_CHECKBOXES-style . So use i.e. BitAND(GUICtrlRead($Item),$GUI_CHECKED) to test if the item is checked.

Related

GUICtrlCreate..., GUICtrlGetState, GUICtrlSendMsg, GUICtrlSendToDummy, GUICtrlSetData, GUICtrlUpdate..., GUIEventOptions (Option), GUIGetMsg

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    GUICreate("My GUICtrlRead") ; will create a dialog box that when displayed is centered

    Local $idMenu1 = GUICtrlCreateMenu("File")

    Local $idList = GUICtrlCreateList("", 10, 10, -1, 100)
    GUICtrlSetData(-1, "item1|item2|item3", "item2")

    Local $idButton = GUICtrlCreateButton("Read", 10, 110, 50)
    GUICtrlSetState(-1, $GUI_FOCUS) ; the focus is on this button

    GUISetState(@SW_SHOW) ; will display an empty dialog box

    Local $idMsg, $iMenustate, $sMenutext
    ; Loop until the user exits.
    Do
        $idMsg = GUIGetMsg()
        If $idMsg = $idButton Then
            MsgBox($MB_SYSTEMMODAL, "Selected listbox entry", GUICtrlRead($idList)) ; display the selected listbox entry
            $iMenustate = GUICtrlRead($idMenu1) ; return the state of the menu item
            $sMenutext = GUICtrlRead($idMenu1, $GUI_READ_EXTENDED) ; return the text of the menu item
            MsgBox($MB_SYSTEMMODAL, "State and text of the menuitem", "state:" & $iMenustate & @CRLF & "text:" & $sMenutext)
        EndIf
    Until $idMsg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function GUICtrlRecvMsg

Function Reference

GUICtrlRecvMsg

Send a message to a control and retrieve information in lParam.

GUICtrlRecvMsg ( controlID , msg [, wParam [, lParamType]] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.
msg | type of message to be send to the control as defined in the Windows controls documentation.
wParam | [optional] An integer first param to be send to the control.
lParamType | [optional] Define the type of lParam that will be returned: 0 (default) for wParam and lParam, 1 for lParam String, 2 for lParam RECT struct.

Return Value

Success: | the value returned by the SendMessage Windows API.
Failure: | 0.

Remarks

This function allows the sending of special Windows messages directly to the control using the SendMessage API. It is used to enable special control features not available with the simple GUICtrlRead() and GUICtrlUpdate... range of functions.

If the wParam and lParamType parameters are not specified then an array of two elements is returned (LPwParam, LPlParam).

The RECT is returned in an array of 4 elements (Left, Top, Right, Bottom).

Related

GUICtrlSendMsg, GUICtrlUpdate...

Example

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a GUI with an edit control.
    Local $hGUI = GUICreate("Example")
    Local $idEdit = GUICtrlCreateEdit("Line 0" & @CRLF, 0, 0, 400, 350)
    Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25)

    ; Set data of the edit control.
    For $i = 1 To 25
        GUICtrlSetData($idEdit, "Line " & $i & @CRLF, 1)
    Next

    ; Set focus to the edit control.
    GUICtrlSetState($idEdit, $GUI_FOCUS)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Initialize the variable $aCtrlRecvMsg for storing the value returned by GUICtrlRecvMsg.
    Local $aCtrlRecvMsg = 0

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idOK
                ; Send the message EM_GETSEL, to retrieve the current selection of the edit control.
                $aCtrlRecvMsg = GUICtrlRecvMsg($idEdit, $EM_GETSEL)

                ; Set focus to the edit control.
                GUICtrlSetState($idEdit, $GUI_FOCUS)

                ; If GUICtrlRecvMsg returned the value of 0, then an error occurred otherwise display the contents of the array.
                If $aCtrlRecvMsg = 0 Then
                    MsgBox($MB_SYSTEMMODAL, "", "An error occurred. The value returned was - " & $aCtrlRecvMsg)
                Else
                    MsgBox($MB_SYSTEMMODAL, "", "Start: " & $aCtrlRecvMsg[0] & " End: " & $aCtrlRecvMsg[1])
                EndIf

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function GUICtrlSendMsg

Function Reference

GUICtrlSendMsg

Send a message to a control.

GUICtrlSendMsg ( controlID, msg , wParam, lParam )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.
msg | type of message to be send to the control as defined in the Windows control documentation.
wParam | The first param to send to the control.
lParam | The second param to send to the control.

Return Value

Success: | the value returned by the SendMessage Windows API.
Failure: | 0.

Remarks

This function allows the sending of special Windows messages directly to the control using the SendMessage API. It is used to enable special control features not available with the simple GUICtrlRead() and GUICtrlUpdate.... range of functions.

The parameters (wParam and lParam) can be an integer or a string.

GUICtrlSendMsg() should be used for messages that have no special return types. For more advanced messages where you must be able to receive extra data you must use GUICtrlRecvMsg().

Related

GUICtrlCreate..., GUICtrlRead, GUICtrlRecvMsg, GUICtrlUpdate..., GUIGetMsg

Example

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>

Example()

Func Example()
    GUICreate("Marquee Progress Bar", 290, 90, -1, -1) ; An example of starting/stopping a scrolling marquee of a progress bar.
    Local $idProgress = GUICtrlCreateProgress(10, 10, 270, 20, $PBS_MARQUEE)
    Local $idStart = GUICtrlCreateButton("&Start", 10, 60, 70, 25)
    Local $idStop = GUICtrlCreateButton("S&top", 85, 60, 70, 25)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idStart
                GUICtrlSendMsg($idProgress, $PBM_SETMARQUEE, 1, 50) ; Send the message $PBM_SETMARQUEE and wParam of 1 to start the scrolling marquee.

            Case $idStop
                GUICtrlSendMsg($idProgress, $PBM_SETMARQUEE, 0, 50) ; Send the message $PBM_SETMARQUEE and wParam of 0 to stop the scrolling marquee.

        EndSwitch
    WEnd
EndFunc   ;==>Example


Function GUICtrlSendToDummy

Function Reference

GUICtrlSendToDummy

Sends a message to a Dummy control.

GUICtrlSendToDummy ( controlID [, state] )

Parameters

controlID | The control identifier (controlID) as returned by GUICtrlCreateDummy()
state | [optional] value that can be retrieved later on by GUICtrlRead()

Return Value

Success: | 1.
Failure: | 0.

Remarks

When this function is called a notification that can be handled through the message loop or with a GUICtrlSetOnEvent() function is generated (as if the control had been "clicked" on).

Note that the function will not action the dummy control if the GUI in which it was created is hidden, as by design none of the controls on such a GUI can be actioned.

Related

GUICtrlCreateDummy, GUICtrlRead, GUICtrlSetOnEvent

Example

#include <GUIConstantsEx.au3>

Global $g_idUserDummy, $g_iState = 0

Example()

Func Example()
    Opt("GUIOnEventMode", 1) ; Set the option to use GUIOnEventMode.

    GUICreate("GUISendToDummy", 220, 200, 100, 200)
    GUISetBkColor(0x00E0FFFF) ; Change the background color of the GUI.
    GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit") ; Set an event to call the 'OnExit' function.

    $g_idUserDummy = GUICtrlCreateDummy()
    GUICtrlSetOnEvent(-1, "OnDummy") ; Set an event to call the 'OnExit' function when this control is selected.

    GUICtrlCreateButton("Click", 70, 170, 85, 25)
    GUICtrlSetOnEvent(-1, "OnClick") ; Set an event to call the 'OnClick' function when this control is selected.

    GUICtrlSendToDummy($g_idUserDummy, 1) ; Set state to be checked Onclick

    ; Display the GUI.
    GUISetState(@SW_SHOW)
    ; Loop until the user exits.
    While 1
        Sleep(100)
    WEnd
EndFunc   ;==>Example

Func OnClick()
    Return GUICtrlSendToDummy($g_idUserDummy) ; Send a message to the dummy control that the close button was selected, which will then proceed to call the function 'OnExit'.
EndFunc   ;==>OnClick

Func OnDummy()
    If GUICtrlRead($g_idUserDummy) Then
        GUISetBkColor(0x000000FF) ; Change the background color of the GUI on dummy state
    Else
        Exit
    EndIf
EndFunc   ;==>OnDummy

Func OnExit()
    Exit ; Exit the script.
EndFunc   ;==>OnExit


Function GUIGetCursorInfo

Function Reference

GUIGetCursorInfo

Gets the mouse cursor position relative to GUI window.

GUIGetCursorInfo ( [winhandle] )

Parameters

winhandle [optional] The handle of the window to use. If omitted the "current" window will be used.

Return Value

Success: | a five-element array that containing the mouse cursor information: $aArray[0] = X coord (horizontal) $aArray[1] = Y coord (vertical) $aArray[2] = Primary down (1 if pressed, 0 if not pressed) $aArray[3] = Secondary down (1 if pressed, 0 if not pressed) $aArray[4] = ID of the control that the mouse cursor is hovering over (or 0 if none)
Failure: | sets the @error flag to non-zero.

Remarks

The coordinates given are relative to the GUI window (known as client coords).

If the "winhandle" parameter is used then the specified window becomes the new "current" window.

The mouse cursor position is successful only on an window created by a GUICreate(). When no winhandle it will be successful if the GUI Windows is active.

ListViewItem or TreeViewItem controlID will never be returned, only the parent Listview or TreeView control ID is.

Related

GUICreate, GUIGetMsg

Example

#include <GUIConstantsEx.au3>

Global $g_idX = 0, $g_idY = 0

Example()

Func Example()
    HotKeySet("{ESC}", "GetPos")

    GUICreate("Press Esc to Get Pos", 400, 400)
    $g_idX = GUICtrlCreateLabel("0", 10, 10, 50)
    $g_idY = GUICtrlCreateLabel("0", 10, 30, 50)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    GUIDelete()
EndFunc   ;==>Example

Func GetPos()
    Local $a = GUIGetCursorInfo()
    GUICtrlSetData($g_idX, $a[0])
    GUICtrlSetData($g_idY, $a[1])
EndFunc   ;==>GetPos


Function GUIGetMsg

Function Reference

GUIGetMsg

Polls the GUI to see if any events have occurred.

GUIGetMsg ( [advanced = 0] )

Parameters

advanced [optional] return extended information in an array.
$GUI_EVENT_SINGLE (0) = (default) Returns a single event.
$GUI_EVENT_ARRAY (1) = returns an array containing the event and extended information.

Constants are defined in GUIConstantsEx.au3.

Return Value

Returns an event, or an array depending on the "advanced" parameter.

The "event" returned is the control ID of the control sending the message, or it is a special event (like the window is closing, minimizing). Or if there is no message, the event is 0.

Event ID: | the ID of the control sending the message
$GUI_EVENT_NONE (0): | No event
$GUI_EVENT_CLOSE: | dialog box being closed (either by defined button or system menu).
$GUI_EVENT_MINIMIZE: | dialog box minimized with Windows title bar button.
$GUI_EVENT_RESTORE: | dialog box restored by click on task bar icon.
$GUI_EVENT_MAXIMIZE: | dialog box maximized with Windows title bar button.
$GUI_EVENT_MOUSEMOVE: | the mouse cursor has moved.
$GUI_EVENT_PRIMARYDOWN: | the primary mouse button was pressed.
$GUI_EVENT_PRIMARYUP: | the primary mouse button was released.
$GUI_EVENT_SECONDARYDOWN: | the secondary mouse button was pressed.
$GUI_EVENT_SECONDARYUP: | the secondary mouse button was released.
$GUI_EVENT_RESIZED: | dialog box has been resized.
$GUI_EVENT_DROPPED: | End of a Drag&Drop action @GUI_DragId, @GUI_DragFile and @GUI_DropId will be used to retrieve the ID's/file corresponding to the involve control.

Constants are defined in GUIConstantsEx.au3.

When using the "advanced" parameter the information is returned in an array with extended information:

$aArray[0] = 0 or Event ID or Control ID
$aArray[1] = The window handle the event is from
$aArray[2] = The control handle the event is from (if applicable)
$aArray[3] = The current X position of the mouse cursor (relative to the GUI window)
$aArray[4] = The current Y position of the mouse cursor (relative to the GUI window)

If the GUIOnEventMode option is set to 1 then the return from GUIGetMsg is always 0 and the @error is set to 1.

If the option GUIEventOptions is set to 1 the minimize, restore and maximize button will not do any action on the window just a simple notification.

Remarks

This function automatically idles the CPU when required so that it can be safely used in tight loops without hogging all the CPU.

Information about the mouse position and the hovering control can be retrieved with GUIGetCursorInfo(). No event is fired when the mouse is over a control so GUIGetCursorInfo() must be called to retrieve the controlID.

Related

GUICreate, GUICtrlCreate..., GUICtrlRead, GUICtrlSendMsg, GUICtrlSetOnEvent, GUIEventOptions (Option), GUIGetCursorInfo, GUIOnEventMode (Option)

Example

Example 1

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

; -------------------------------------------------------------------------------------
; Example - Press the button to see the value of the radio boxes
; The script also detects state changes (closed/minimized/timeouts, etc).
Func Example()
    Opt("GUICoordMode", 1)

    GUICreate("Radio Box Demo", 400, 280)

    ; Create the controls
    Local $idButton_1 = GUICtrlCreateButton("B&utton 1", 30, 20, 120, 40)
    GUICtrlCreateGroup("Group 1", 30, 90, 165, 160)
    GUIStartGroup()
    Local $idRadio_1 = GUICtrlCreateRadio("Radio &0", 50, 120, 70, 20)
    GUICtrlCreateRadio("Radio &1", 50, 150, 60, 20)
    Local $idRadio_3 = GUICtrlCreateRadio("Radio &2", 50, 180, 60, 20)

    ; Init our vars that we will use to keep track of GUI events
    Local $iRadioVal1 = 0 ; We will assume 0 = first radio button selected, 2 = last button

    ; Show the GUI
    GUISetState(@SW_SHOW)

    Local $idMsg = 0
    ; In this message loop we use variables to keep track of changes to the radios, another
    ; way would be to use GUICtrlRead() at the end to read in the state of each control
    While 1
        $idMsg = GUIGetMsg()
        Select
            Case $idMsg = $GUI_EVENT_CLOSE
                MsgBox($MB_SYSTEMMODAL, "", "Dialog was closed")
                ExitLoop
            Case $idMsg = $GUI_EVENT_MINIMIZE
                MsgBox($MB_SYSTEMMODAL, "", "Dialog minimized", 2)
            Case $idMsg = $GUI_EVENT_MAXIMIZE
                MsgBox($MB_SYSTEMMODAL, "", "Dialog restored", 2)

            Case $idMsg = $idButton_1
                MsgBox($MB_SYSTEMMODAL, "", "Default button clicked:" & @CRLF & "Radio " & $iRadioVal1)

            Case $idMsg >= $idRadio_1 And $idMsg <= $idRadio_3
                $iRadioVal1 = $idMsg - $idRadio_1

        EndSelect
    WEnd

    GUIDelete()
EndFunc   ;==>Example

Example 2

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a GUI.
    Local $hGUI1 = GUICreate("Example GUI1")
    ; Create a button.
    Local $idButton1 = GUICtrlCreateButton("Button1", 10, 10, 80, 22)
    ; Display the GUI
    GUISetState(@SW_SHOW, $hGUI1)

    ; Create a GUI.
    Local $hGUI2 = GUICreate("Example GUI2", 300, 300)
    ; Create a button.
    Local $idButton2 = GUICtrlCreateButton("Button2", 10, 10, 80, 22)
    ; Display the GUI
    GUISetState(@SW_SHOW, $hGUI2)

    ; Initialize a Local variable.
    Local $aMsg = 0

    While 1
        ; Assign to $aMsg the advanced GUI messages.
        $aMsg = GUIGetMsg($GUI_EVENT_ARRAY)

        ; Switch from GUIs
        Switch $aMsg[1]
            Case $hGUI1
                ; The event comes from the GUI1

                ; Switch from event ID
                Switch $aMsg[0]
                    Case $GUI_EVENT_CLOSE
                        ExitLoop
                    Case $idButton1
                        MsgBox($MB_SYSTEMMODAL, "", "Button1 clicked.")
                EndSwitch
            Case $hGUI2
                ; The event comes from the GUI2

                ; Switch from event ID
                Switch $aMsg[0]
                    Case $GUI_EVENT_CLOSE
                        GUIDelete($hGUI2)
                    Case $idButton2
                        MsgBox($MB_SYSTEMMODAL, "", "Button2 clicked.")
                EndSwitch
        EndSwitch
    WEnd

    ; Delete the previous GUIs and all controls.
    GUIDelete($hGUI1)
EndFunc   ;==>Example


Function GUIGetStyle

Function Reference

GUIGetStyle

Retrieves the styles of a GUI window.

GUIGetStyle ( [winhandle] )

Parameters

winhandle [optional] Windows handle as returned by GUICreate() (default is the previously used window).

Return Value

Success: | a two-element array that containing the styles information: $aArray[0] = Style $aArray[1] = ExStyle
Failure: | sets the @error flag to non-zero.

Remarks

Be careful Style changes after GUISetState().

Related

GUICreate, GUISetStyle

Example

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

Example()

Func Example()

    Local $hGUI = GUICreate("Gui Style", 260, 100)
    Local $idBtnStyle = GUICtrlCreateButton("Set Style", 45, 50, 150, 20)

    Local $aGUIStyle = GUIGetStyle($hGUI) ; be careful the style change after opening

    GUISetState(@SW_SHOW)

    Local $bNewStyle = False, $idMsg
    While 1
        $idMsg = GUIGetMsg()
        Switch $idMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idBtnStyle
                If Not $bNewStyle Then
                    GUISetStyle(BitOR($WS_POPUPWINDOW, $WS_THICKFRAME), BitOR($WS_EX_CLIENTEDGE, $WS_EX_TOOLWINDOW))
                    GUICtrlSetData($idBtnStyle, 'Undo Style')
                    $bNewStyle = True
                Else
                    GUISetStyle($aGUIStyle[0], $aGUIStyle[1])
                    GUICtrlSetData($idBtnStyle, 'Set Style')
                    $bNewStyle = False
                EndIf
            Case Else
        EndSwitch
    WEnd

    GUIDelete($hGUI)
EndFunc   ;==>Example


Function GUIRegisterMsg

Function Reference

GUIRegisterMsg

Register a user defined function for a known Windows Message ID (WM_MSG).

GUIRegisterMsg ( msgID, "function" )

Parameters

msgID | A Windows Message ID (see Appendix: Windows Message Codes).
function | The name of the user function to call when the message appears or an empty string "" to unregister a message.

Return Value

Success: | 1.
Failure: | 0.

Remarks

!!! To make the user function workable you have to define it with maximum 4 function parameters otherwise the function won't be called !!!
i.e:
Func MyUserFunction($hWndGUI, $MsgID, $WParam, $LParam)
...
EndFunc

Or

Func MyUserFunction($hWndGUI, $MsgID)
...
EndFunc

When the user function is called then these 4 parameters have the following values:

Position | Parameter | Meaning
1 | hWnd | The Window handle of the GUI in which the message appears.
2 | Msg | The Windows message ID.
3 | wParam | The first message parameter as hex value.
4 | lParam | The second message parameter as hex value.

Up to 256 user functions can be registered for message IDs.

By default after finishing the user function the AutoIt internal message handler will be proceed.
That won't be if your Return a value (See WM_COMMAND in example) or if you use the keyword 'Return' without any value.
By using 'Return' without any return value the AutoIt internal message handler (if there is one for this message) will NOT be proceed!

!!! If you want AutoIt to run its internal handler for a message, return the variable $GUI_RUNDEFMSG (in GUIConstantsEx.au3) from the function (see also examples) !!!
I.e. if you want to return earlier than the user function ends and also proceed the AutoIt internal message handler.

Warning: blocking of running user functions which executes window messages with commands such as "MsgBox()" can lead to unexpected behavior, the return to the system should be as fast as possible !!!

Some controls consume internally specific Windows Message ID, so registering them will have no effect, e.g; WM_CHAR, WM_KEYDOWN, WM_KEYUP are consumed by an edit control.

Related

GUICtrlGetHandle

Example

; Create an ownerdrawn/colored button

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local Const $BS_OWNERDRAW = 0x0000000B

    GUICreate("My Ownerdrawn Created Button", 300, 200)

    Local $idButton = GUICtrlCreateButton("", 90, 50, 120, 30)
    GUICtrlSetStyle($idButton, BitOR($WS_TABSTOP, $BS_NOTIFY, $BS_OWNERDRAW)) ; Set the ownerdrawn flag

    Local $idButton2 = GUICtrlCreateButton("Normal Button", 90, 110, 120, 30)

    GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
    ; WM_DRAWITEM has to registered before showing GUI otherwise the initial drawing isn't done
    GUIRegisterMsg($WM_DRAWITEM, "MY_WM_DRAWITEM")

    GUISetState(@SW_SHOW)

    Local $iMsg
    While 1
        $iMsg = GUIGetMsg()

        Switch $iMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idButton
                ; Normally should not run through cause of our MY_WM_COMMAND function
                MsgBox($MB_SYSTEMMODAL, "Info", "Button pressed")

            Case $idButton2
                ; Normally should not run through cause of our MY_WM_COMMAND function
                MsgBox($MB_SYSTEMMODAL, "Info", "Button2 pressed")
        EndSwitch
    WEnd

    GUIDelete()
EndFunc   ;==>Example

; React on a button click
Func MY_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    Local $nNotifyCode = BitShift($wParam, 16)
    Local $nID = BitAND($wParam, 0x0000FFFF)
    Local $hCtrl = $lParam

    If $nID <> 2 And $nNotifyCode = 0 Then ; Check for IDCANCEL - 2
        ; Ownerdrawn buttons don't send something by pressing ENTER
        ; So IDOK - 1 comes up, now check for the control that has the current focus
        If $nID = 1 Then
            Local $hFocus = DllCall("user32.dll", "hwnd", "GetFocus")
            Local $nCtrlID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hFocus[0])
            PostButtonClick($hWnd, $nCtrlID[0])
        Else
            MsgBox($MB_SYSTEMMODAL, "MY_WM_COMMAND", "GUIHWnd" & @TAB & ":" & $hWnd & @CRLF & _
                    "MsgID" & @TAB & ":" & $iMsg & @CRLF & _
                    "wParam" & @TAB & ":" & $wParam & @CRLF & _
                    "lParam" & @TAB & ":" & $lParam & @CRLF & @CRLF & _
                    "WM_COMMAND - Infos:" & @CRLF & _
                    "-----------------------------" & @CRLF & _
                    "Code" & @TAB & ":" & $nNotifyCode & @CRLF & _
                    "CtrlID" & @TAB & ":" & $nID & @CRLF & _
                    "CtrlHWnd" & @TAB & ":" & $hCtrl)
        EndIf
        Return 0 ; Only workout clicking on the button
    EndIf
    ; Proceed the default AutoIt3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default AutoIt3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_COMMAND

; RePost a WM_COMMAND message to a ctrl in a gui window
Func PostButtonClick($hWnd, $nCtrlID)
    DllCall("user32.dll", "int", "PostMessage", _
            "hwnd", $hWnd, _
            "int", $WM_COMMAND, _
            "int", BitAND($nCtrlID, 0x0000FFFF), _
            "hwnd", GUICtrlGetHandle($nCtrlID))
EndFunc   ;==>PostButtonClick

; Draw the button
Func MY_WM_DRAWITEM($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam
    Local $tDrawItem = DllStructCreate("uint;uint;uint;uint;uint;uint;uint;int[4];dword", $lParam)
    Local Const $ODT_BUTTON = 4

    Local $nCtlType = DllStructGetData($tDrawItem, 1)
    If $nCtlType = $ODT_BUTTON Then
        ; Local $nCtrlID = DllStructGetData($tDrawItem, 2)
        Local $nItemState = DllStructGetData($tDrawItem, 5)
        Local $hCtrl = DllStructGetData($tDrawItem, 6)
        Local $hDC = DllStructGetData($tDrawItem, 7)
        Local $nLeft = DllStructGetData($tDrawItem, 8, 1)
        Local $nTop = DllStructGetData($tDrawItem, 8, 2)
        Local $nRight = DllStructGetData($tDrawItem, 8, 3)
        Local $nBottom = DllStructGetData($tDrawItem, 8, 4)
        Local $sText = "Ownerdrawn Button"
        Local $nTextColor = 0x5555DD
        Local $nBackColor = 0xFFEEDD
        DrawButton($hWnd, $hCtrl, $hDC, $nLeft, $nTop, $nRight, $nBottom, $nItemState, $sText, $nTextColor, $nBackColor)
        $tDrawItem = 0
        Return 1
    EndIf

    $tDrawItem = 0
    Return $GUI_RUNDEFMSG ; Proceed the default AutoIt3 internal message commands
EndFunc   ;==>MY_WM_DRAWITEM

; The main drawing procedure
Func DrawButton($hWnd, $hCtrl, $hDC, $nLeft, $nTop, $nRight, $nBottom, $nItemState, $sText, $nTextColor, $nBackColor)
    #forceref $hWnd
    ;Local $bDefault    = FALSE
    Local Const $GWL_STYLE = -16
    Local Const $ODS_SELECTED = 0x0001
    Local Const $ODS_GRAYED = 0x0002
    Local Const $ODS_DISABLED = 0x0004
    ; Local Const $ODS_CHECKED = 0x0008
    Local Const $ODS_FOCUS = 0x0010
    ; Local Const $ODS_HOTLIGHT = 0x0040
    ; Local Const $ODS_INACTIVE = 0x0080
    ; Local Const $ODS_NOACCEL = 0x0100
    ; Local Const $ODS_NOFOCUSRECT = 0x0200
    Local Const $DFC_BUTTON = 4
    Local Const $DFCS_BUTTONPUSH = 0x0010
    ; Local $bChecked = BitAND($nItemState, $ODS_CHECKED)
    Local $bFocused = BitAND($nItemState, $ODS_FOCUS)
    Local $bGrayed = BitAND($nItemState, BitOR($ODS_GRAYED, $ODS_DISABLED))
    Local $bSelected = BitAND($nItemState, $ODS_SELECTED)

    Local $tRECT = DllStructCreate("int;int;int;int")
    DllStructSetData($tRECT, 1, $nLeft)
    DllStructSetData($tRECT, 2, $nTop)
    DllStructSetData($tRECT, 3, $nRight)
    DllStructSetData($tRECT, 4, $nBottom)

    Local $nClrTxt
    If $bGrayed Then
        $nClrTxt = SetTextColor($hDC, GetSysColor($COLOR_HIGHLIGHTTEXT))
    ElseIf $nTextColor = -1 Then
        $nClrTxt = SetTextColor($hDC, GetSysColor($COLOR_BTNTEXT))
    Else
        $nClrTxt = SetTextColor($hDC, $nTextColor)
    EndIf

    Local $hBrush, $nClrSel
    If $nBackColor = -1 Then
        $hBrush = GetSysColorBrush($COLOR_BTNFACE)
        $nClrSel = GetSysColor($COLOR_BTNFACE)
    Else
        $hBrush = CreateSolidBrush($nBackColor)
        $nClrSel = $nBackColor;
    EndIf

    Local $nClrBk = SetBkColor($hDC, $nClrSel)
    Local $hOldBrush = SelectObject($hDC, $hBrush)

    Local $nTmpLeft = $nLeft
    Local $nTmpTop = $nTop
    Local $nTmpRight = $nRight
    Local $nTmpBottom = $nBottom

    If $bSelected Then
        InflateRect($nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, -1, -1)
        Local $hBrushSel = CreateSolidBrush(GetSysColor($COLOR_BTNSHADOW))
        FrameRect($hDC, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, $hBrushSel)
        DeleteObject($hBrushSel)
    Else
        If $bFocused And Not $bSelected Then InflateRect($nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, -1, -1)
        DrawFrameControl($hDC, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, $DFC_BUTTON, $DFCS_BUTTONPUSH)
    EndIf

    $nTmpLeft = $nLeft
    $nTmpTop = $nTop
    $nTmpRight = $nRight
    $nTmpBottom = $nBottom

    If $bSelected Then
        InflateRect($nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, -2, -2)
    Else
        If $bFocused And Not $bSelected Then
            InflateRect($nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, -3, -3)
            $nTmpLeft -= 1
            $nTmpTop -= 1
        Else
            InflateRect($nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, -2, -2)
            $nTmpLeft -= 1
            $nTmpTop -= 1
        EndIf
    EndIf

    FillRect($hDC, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, $hBrush)

    If $bSelected Or $bGrayed Then
        $nTmpLeft = $nTmpLeft + 2
        $nTmpTop = $nTmpTop + 2
    EndIf

    Local $iFlags = BitOR($DT_NOCLIP, $DT_CENTER, $DT_VCENTER)

    If Not BitAND(GetWindowLong($hCtrl, $GWL_STYLE), $BS_MULTILINE) Then $iFlags = BitOR($iFlags, $DT_SINGLELINE)

    DrawText($hDC, $sText, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, $iFlags)

    If $bGrayed Then
        $nTmpLeft = $nLeft
        $nTmpTop = $nTop
        $nTmpRight = $nRight
        $nTmpBottom = $nBottom

        $nTmpLeft -= 1

        $nClrTxt = SetTextColor($hDC, GetSysColor($COLOR_GRAYTEXT))
        DrawText($hDC, $sText, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, BitOR($DT_NOCLIP, $DT_CENTER, $DT_VCENTER, $DT_SINGLELINE))
    EndIf

    $nTmpLeft = $nLeft
    $nTmpTop = $nTop
    $nTmpRight = $nRight
    $nTmpBottom = $nBottom

    If $bFocused Then
        $hBrush = CreateSolidBrush(0)
        FrameRect($hDC, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, $hBrush)

        $nTmpLeft = $nLeft
        $nTmpTop = $nTop
        $nTmpRight = $nRight
        $nTmpBottom = $nBottom

        InflateRect($nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom, -4, -4)
        DrawFocusRect($hDC, $nTmpLeft, $nTmpTop, $nTmpRight, $nTmpBottom)
    EndIf

    SelectObject($hDC, $hOldBrush)
    DeleteObject($hBrush)
    SetTextColor($hDC, $nClrTxt)
    SetBkColor($hDC, $nClrBk)

    Return 1
EndFunc   ;==>DrawButton

; Some graphic / windows functions
Func CreateSolidBrush($nColor)
    Local $hBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $nColor)
    Return $hBrush[0]
EndFunc   ;==>CreateSolidBrush

Func GetSysColor($nIndex)
    Local $nColor = DllCall("user32.dll", "int", "GetSysColor", "int", $nIndex)
    Return $nColor[0]
EndFunc   ;==>GetSysColor

Func GetSysColorBrush($nIndex)
    Local $hBrush = DllCall("user32.dll", "hwnd", "GetSysColorBrush", "int", $nIndex)
    Return $hBrush[0]
EndFunc   ;==>GetSysColorBrush

Func DrawFrameControl($hDC, $nLeft, $nTop, $nRight, $nBottom, $nType, $nState)
    Local $tRECT = DllStructCreate("int;int;int;int")

    DllStructSetData($tRECT, 1, $nLeft)
    DllStructSetData($tRECT, 2, $nTop)
    DllStructSetData($tRECT, 3, $nRight)
    DllStructSetData($tRECT, 4, $nBottom)

    DllCall("user32.dll", "int", "DrawFrameControl", "hwnd", $hDC, "struct*", $tRECT, "int", $nType, "int", $nState)

    $tRECT = 0
EndFunc   ;==>DrawFrameControl

Func DrawFocusRect($hDC, $nLeft, $nTop, $nRight, $nBottom)
    Local $tRECT = DllStructCreate("int;int;int;int")

    DllStructSetData($tRECT, 1, $nLeft)
    DllStructSetData($tRECT, 2, $nTop)
    DllStructSetData($tRECT, 3, $nRight)
    DllStructSetData($tRECT, 4, $nBottom)

    DllCall("user32.dll", "int", "DrawFocusRect", "hwnd", $hDC, "struct*", $tRECT)

    $tRECT = 0
EndFunc   ;==>DrawFocusRect

Func DrawText($hDC, $sText, $nLeft, $nTop, $nRight, $nBottom, $nFormat)
    Local $nLen = StringLen($sText)

    Local $tRECT = DllStructCreate("int;int;int;int")
    DllStructSetData($tRECT, 1, $nLeft)
    DllStructSetData($tRECT, 2, $nTop)
    DllStructSetData($tRECT, 3, $nRight)
    DllStructSetData($tRECT, 4, $nBottom)

    Local $tText = DllStructCreate("char[260]")
    DllStructSetData($tText, 1, $sText)

    DllCall("user32.dll", "int", "DrawText", "hwnd", $hDC, "struct*", $tText, "int", $nLen, "struct*", $tRECT, "int", $nFormat)

    $tRECT = 0
    $tText = 0
EndFunc   ;==>DrawText

Func FillRect($hDC, $nLeft, $nTop, $nRight, $nBottom, $hBrush)
    Local $tRECT = DllStructCreate("int;int;int;int")

    DllStructSetData($tRECT, 1, $nLeft)
    DllStructSetData($tRECT, 2, $nTop)
    DllStructSetData($tRECT, 3, $nRight)
    DllStructSetData($tRECT, 4, $nBottom)

    DllCall("user32.dll", "int", "FillRect", "hwnd", $hDC, "struct*", $tRECT, "hwnd", $hBrush)

    $tRECT = 0
EndFunc   ;==>FillRect

Func FrameRect($hDC, $nLeft, $nTop, $nRight, $nBottom, $hBrush)
    Local $tRECT = DllStructCreate("int;int;int;int")

    DllStructSetData($tRECT, 1, $nLeft)
    DllStructSetData($tRECT, 2, $nTop)
    DllStructSetData($tRECT, 3, $nRight)
    DllStructSetData($tRECT, 4, $nBottom)

    DllCall("user32.dll", "int", "FrameRect", "hwnd", $hDC, "struct*", $tRECT, "hwnd", $hBrush)

    $tRECT = 0
EndFunc   ;==>FrameRect

Func InflateRect(ByRef $nLeft, ByRef $nTop, ByRef $nRight, ByRef $nBottom, $nX, $nY)
    Local $tRECT = DllStructCreate("int;int;int;int")

    DllStructSetData($tRECT, 1, $nLeft)
    DllStructSetData($tRECT, 2, $nTop)
    DllStructSetData($tRECT, 3, $nRight)
    DllStructSetData($tRECT, 4, $nBottom)

    DllCall("user32.dll", "int", "InflateRect", "struct*", $tRECT, "int", $nX, "int", $nY)

    $nLeft = DllStructGetData($tRECT, 1)
    $nTop = DllStructGetData($tRECT, 2)
    $nRight = DllStructGetData($tRECT, 3)
    $nBottom = DllStructGetData($tRECT, 4)

    $tRECT = 0
EndFunc   ;==>InflateRect

Func SetBkColor($hDC, $nColor)
    Local $nOldColor = DllCall("gdi32.dll", "int", "SetBkColor", "hwnd", $hDC, "int", $nColor)
    Return $nOldColor[0]
EndFunc   ;==>SetBkColor

Func SetTextColor($hDC, $nColor)
    Local $nOldColor = DllCall("gdi32.dll", "int", "SetTextColor", "hwnd", $hDC, "int", $nColor)
    Return $nOldColor[0]
EndFunc   ;==>SetTextColor

Func SelectObject($hDC, $hObj)
    Local $hOldObj = DllCall("gdi32.dll", "hwnd", "SelectObject", "hwnd", $hDC, "hwnd", $hObj)
    Return $hOldObj[0]
EndFunc   ;==>SelectObject

Func DeleteObject($hObj)
    DllCall("gdi32.dll", "hwnd", "DeleteObject", "hwnd", $hObj)
EndFunc   ;==>DeleteObject

Func GetWindowLong($hWnd, $nIndex)
    Local $nVal = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", $hWnd, "int", $nIndex)
    Return $nVal[0]
EndFunc   ;==>GetWindowLong


Function GUIStartGroup

Function Reference

GUIStartGroup

Defines that any subsequent controls that are created will be "grouped" together.

GUIStartGroup ( [winhandle] )

Parameters

winhandle [optional] Windows handle as returned by GUICreate() (default is the previously used window).

Return Value

Success: | 1.
Failure: | 0.

Remarks

This function is generally used when working with radio button controls. When you click a radio button all other radio buttons in the same grouping are reset. The GUIStartGroup() function allows you to easily define these groups.

Related

GUICtrlCreateGroup

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Opt("GUICoordMode", 1)

    GUICreate("Radio Box Grouping Demo", 400, 280)

    ; Create the controls
    Local $idButton_1 = GUICtrlCreateButton("B&utton 1", 30, 20, 120, 40)
    GUICtrlCreateGroup("Group 1", 30, 90, 165, 160)
    GUIStartGroup()
    Local $idRadio_1 = GUICtrlCreateRadio("Radio &0", 50, 120, 70, 20)
    Local $idRadio_2 = GUICtrlCreateRadio("Radio &1", 50, 150, 60, 20)
    Local $idRadio_3 = GUICtrlCreateRadio("Radio &2", 50, 180, 60, 20)
    GUIStartGroup()
    Local $idRadio_4 = GUICtrlCreateRadio("Radio &A", 120, 120, 70, 20)
    Local $idRadio_5 = GUICtrlCreateRadio("Radio &B", 120, 150, 60, 20)
    Local $idRadio_6 = GUICtrlCreateRadio("Radio &C", 120, 180, 60, 20)
    GUIStartGroup()
    Local $idInput_1 = GUICtrlCreateInput("Input 1", 200, 20, 160, 30)
    Local $idInput_2 = GUICtrlCreateInput("Input 2", 200, 70, 160, 30)

    ; Set the defaults (radio buttons clicked, default button, etc)
    GUICtrlSetState($idRadio_1, $GUI_CHECKED)
    GUICtrlSetState($idRadio_6, $GUI_CHECKED)
    GUICtrlSetState($idButton_1, $GUI_FOCUS + $GUI_DEFBUTTON)

    ; Init our vars that we will use to keep track of radio events
    Local $iRadioVal1 = 0 ; We will assume 0 = first radio button selected, 2 = last button
    Local $iRadioVal2 = 2

    GUISetState(@SW_SHOW)

    Local $idMsg
    ; In this message loop we use variables to keep track of changes to the radios, another
    ; way would be to use GUICtrlRead() at the end to read in the state of each control.  Both
    ; methods are equally valid
    While 1
        $idMsg = GUIGetMsg()
        Select
            Case $idMsg = $GUI_EVENT_CLOSE
                ExitLoop

            Case $idMsg = $idButton_1
                MsgBox($MB_SYSTEMMODAL, "", "Radio " & $iRadioVal1 & @CRLF & "Radio " & Chr($iRadioVal2 + Asc("A")) & @CRLF & GUICtrlRead($idInput_1) & @CRLF & GUICtrlRead($idInput_2))

            Case $idMsg = $idRadio_1 Or $idMsg = $idRadio_2 Or $idMsg = $idRadio_3
                $iRadioVal1 = $idMsg - $idRadio_1

            Case $idMsg = $idRadio_4 Or $idMsg = $idRadio_5 Or $idMsg = $idRadio_6
                $iRadioVal2 = $idMsg - $idRadio_4

        EndSelect
    WEnd

    GUIDelete()
EndFunc   ;==>Example


Function GUISwitch

Function Reference

GUISwitch

Switches the current window used for GUI functions.

GUISwitch ( winhandle [, tabitemID] )

Parameters

winhandle | The handle of the window to switch to.
tabitemID | [optional] controlID of the tabitem control to be selected.

Return Value

Success: | handle of the previous GUI.
Failure: | a null handle.

Remarks

Many of the GUI specific functions work on the "current" window - this is usually the last window created with GUICreate(). This function allows you to make another window "current". That's does not mean that the referenced window will become active. You have to use WinActivate().

Using the tabitemID allow to create new control in the specified tabitem control. Don't forget to close tabitem definition GUICtrlCreateTabItem("")

Related

GUICreate, GUICtrlCreateTabItem, GUIDelete

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUIParent1 = GUICreate("Parent1")
    GUICtrlCreateTab(10, 10)
    Local $idTabItem = GUICtrlCreateTabItem("tab1")
    GUICtrlCreateTabItem("tab2")
    GUICtrlCreateTabItem("")

    Local $hGUIParent2 = GUICreate("Parent2", -1, -1, 100, 100)

    GUISwitch($hGUIParent2)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    GUISwitch($hGUIParent1, $idTabItem)
    GUICtrlCreateButton("OK", 50, 50, 50)
    GUICtrlCreateTabItem("")

    GUISetState(@SW_SHOW, $hGUIParent1)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    GUIDelete($hGUIParent1)
    GUIDelete($hGUIParent2)
EndFunc   ;==>Example


Functions

Keyboard functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
HotKeySet | Sets a hotkey that calls a user function.
Send | Sends simulated keystrokes to the active window.
SendKeepActive | Attempts to keep a specified window active during Send().


Function HotKeySet

Function Reference

HotKeySet

Sets a hotkey that calls a user function.

HotKeySet ( "key" [, "function"] )

Parameters

key | The key combination to use as the hotkey. Same format as Send(). See remarks.
function | [optional] The name of the function to call when the key is pressed. Not specifying this parameter will unset a previous hotkey.

Return Value

Success: | 1.
Failure: | 0.

Remarks

It is recommended to use lower-case keys/characters (e.g. "b" and not "B") when setting hotkeys to avoid errors as with some keyboard layouts upper and lower case keys may be mapped differently.

Keyboard with 102 keys as the Hungarian keyboard need to use "{OEM_102}" to capture the "í" key.

If two AutoIt scripts set the same hotkeys, you should avoid running those scripts simultaneously as the second script cannot capture the hotkey unless the first script terminates or unregisters the key prior to the second script setting the hotkey. If the scripts use GUIs, then consider using GUISetAccelerators as these keys are only active when the parent GUI is active.

A hotkey-press *typically* interrupts the active AutoIt function/statement and runs its user function until it completes or is interrupted. Exceptions are as follows:
1) If the current function is a "blocking" function, then the key-presses are buffered and execute as soon as the blocking function completes. MsgBox() and FileSelectFolder() are examples of blocking functions. Try the behavior of Shift-Alt-d in the Example.
2) If you have paused the script by clicking on the AutoIt Tray icon, any hotkeys pressed during this paused state are ignored.

The following hotkeys cannot be set:

ASC nnnn | Cannot be used as in Send(). It will use "A" first char as Send() does when the "{...}" is invalid.
Ctrl+Alt+Delete | It is reserved by Windows
F12 | It is also reserved by Windows, according to its API.
NumPad's Enter Key | Instead, use {Enter} which captures both Enter keys on the keyboard.
Win+B,D,E,F,L,M,R,U; and Win+Shift+M | These are built-in Windows shortcuts. Note: Win+B and Win+L might only be reserved on Windows XP and above.
Alt, Ctrl, Shift, Win | These are the modifier keys themselves!
Other | Any global hotkeys a user has defined using third-party software, any combos of two or more "base keys" such as '{F1}{F2}', and any keys of the form '{LALT}' or '{ALTDOWN}'.

When you set a hotkey, AutoIt captures the key-press and does not pass it on to the active application, with one exception: the Lock keys (NumLock, CapsLock, and ScrollLock) still toggle their respective state!
To Send() a key combination which will trigger a HotKeySet() event, either use ControlSend() or unregister the HotKeySet() event, otherwise, the Send() event may trigger an infinite loop.

; capture and pass along a keypress
HotKeySet("{Esc}", "captureEsc")
Func captureEsc()
; ... can do stuff here
HotKeySet("{Esc}")
Send("{Esc}")
HotKeySet("{Esc}", "captureEsc")
EndFunc

The called function can not be given parameters. They will be ignored.

@HotKeyPressed macro can be used inside the function to handle several keys in the same function.

Related

GUISetAccelerators, Send

Example

Example 1

#include <MsgBoxConstants.au3>

; Press Esc to terminate script, Pause/Break to "pause"

Global $g_bPaused = False

HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage") ; Shift-Alt-d

While 1
    Sleep(100)
WEnd

Func TogglePause()
    $g_bPaused = Not $g_bPaused
    While $g_bPaused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

Func Terminate()
    Exit
EndFunc   ;==>Terminate

Func ShowMessage()
    MsgBox($MB_SYSTEMMODAL, "", "This is a message.")
EndFunc   ;==>ShowMessage

Example 2

#include <MsgBoxConstants.au3>

; Press Esc to terminate script, Pause/Break to "pause"

Global $g_bPaused = False

HotKeySet("{PAUSE}", "HotKeyPressed")
HotKeySet("{ESC}", "HotKeyPressed")
HotKeySet("+!d", "HotKeyPressed") ; Shift-Alt-d

While 1
    Sleep(100)
WEnd

Func HotKeyPressed()
    Switch @HotKeyPressed ; The last hotkey pressed.
        Case "{PAUSE}" ; String is the {PAUSE} hotkey.
            $g_bPaused = Not $g_bPaused
            While $g_bPaused
                Sleep(100)
                ToolTip('Script is "Paused"', 0, 0)
            WEnd
            ToolTip("")

        Case "{ESC}" ; String is the {ESC} hotkey.
            Exit

        Case "+!d" ; String is the Shift-Alt-d hotkey.
            MsgBox($MB_SYSTEMMODAL, "", "This is a message.")

    EndSwitch
EndFunc   ;==>HotKeyPressed


Function Send

Function Reference

Send

Sends simulated keystrokes to the active window.

Send ( "keys" [, flag = 0] )

Parameters

keys | The sequence of keys to send.
flag | [optional] Changes how "keys" is processed: $SEND_DEFAULT (0) = Text contains special characters like + and ! to indicate SHIFT and ALT key-presses (default). $SEND_RAW (1) = keys are sent raw. Constants are defined in "AutoItConstants.au3".

Return Value

None.

Remarks

See the Appendix for some tips on using Send(). AutoIt can send all ASCII and Extended ASCII characters (0-255). To send UNICODE characters you must use the "ASC" option and the code of the character you wish to send (see {ASC} at the bottom of the table below).

The "Send()" command syntax is similar to that of ScriptIt and the Visual Basic "SendKeys" command. Characters are sent as written with the exception of the following characters:

'!'
This tells AutoIt to send an ALT keystroke, therefore Send("This is text!a") would send the keys "This is text" and then press "ALT+a".

N.B. Some programs are very choosy about capital letters and ALT keys, i.e., "!A" is different from "!a". The first says ALT+SHIFT+A, the second is ALT+a. If in doubt, use lowercase!

'+'
This tells AutoIt to send a SHIFT keystroke; therefore, Send("Hell+o") would send the text "HellO". Send("!+a") would send "ALT+SHIFT+a".

'^'
This tells AutoIt to send a CONTROL keystroke; therefore, Send("^!a") would send "CTRL+ALT+a".

N.B. Some programs are very choosy about capital letters and CTRL keys, i.e., "^A" is different from "^a". The first says CTRL+SHIFT+A, the second is CTRL+a. If in doubt, use lowercase!

'#'
The hash now sends a Windows keystroke; therefore, Send("#r") would send Win+r which launches the Run() dialog box.

You can set SendCapslockMode to make CAPS LOCK disabled at the start of a Send() operation and restored upon completion.
However, if a user is holding down the Shift key when a Send() function begins, text may be sent in uppercase.
One workaround is to Send("{SHIFTDOWN}{SHIFTUP}") before the other Send() operations.

Certain keyboards as the Czech keyboard sends different characters when using the Shift Key or with CAPS LOCK enabled while sending a character. Due to the send AutoIt implementation the CAPS LOCKed character will be sent as a Shifted character so it will not work.
Certain special keys can be sent and should be enclosed in braces:

N.B. Windows does not allow the simulation of the "CTRL-ALT-DEL" combination!

Send() Command (if zero flag) | Resulting Keypress
{!} | !
{#} | #
{+} | +
{^} | ^
{{} | {
{}} | }
{SPACE} | SPACE
{ENTER} | ENTER key on the main keyboard
{ALT} | ALT
{BACKSPACE} or {BS} | BACKSPACE
{DELETE} or {DEL} | DELETE
{UP} | Up arrow
{DOWN} | Down arrow
{LEFT} | Left arrow
{RIGHT} | Right arrow
{HOME} | HOME
{END} | END
{ESCAPE} or {ESC} | ESCAPE
{INSERT} or {INS} | INS
{PGUP} | PageUp
{PGDN} | PageDown
{F1} - {F12} | Function keys
{TAB} | TAB
{PRINTSCREEN} | Print Screen key
{LWIN} | Left Windows key
{RWIN} | Right Windows key
{NUMLOCK on} | NUMLOCK (on/off/toggle)
{CAPSLOCK off} | CAPSLOCK (on/off/toggle)
{SCROLLLOCK toggle} | SCROLLLOCK (on/off/toggle)
{BREAK} | for Ctrl+Break processing
{PAUSE} | PAUSE
{NUMPAD0} - {NUMPAD9} | Numpad digits
{NUMPADMULT} | Numpad Multiply
{NUMPADADD} | Numpad Add
{NUMPADSUB} | Numpad Subtract
{NUMPADDIV} | Numpad Divide
{NUMPADDOT} | Numpad period
{NUMPADENTER} | Enter key on the numpad
{APPSKEY} | Windows App key
{LALT} | Left ALT key
{RALT} | Right ALT key
{LCTRL} | Left CTRL key
{RCTRL} | Right CTRL key
{LSHIFT} | Left Shift key
{RSHIFT} | Right Shift key
{SLEEP} | Computer SLEEP key
{ALTDOWN} | Holds the ALT key down until {ALTUP} is sent
{SHIFTDOWN} | Holds the SHIFT key down until {SHIFTUP} is sent
{CTRLDOWN} | Holds the CTRL key down until {CTRLUP} is sent
{LWINDOWN} | Holds the left Windows key down until {LWINUP} is sent
{RWINDOWN} | Holds the right Windows key down until {RWINUP} is sent
{ASC nnnn} | Send the ALT+nnnn key combination
{BROWSER_BACK} | Select the browser "back" button
{BROWSER_FORWARD} | Select the browser "forward" button
{BROWSER_REFRESH} | Select the browser "refresh" button
{BROWSER_STOP} | Select the browser "stop" button
{BROWSER_SEARCH} | Select the browser "search" button
{BROWSER_FAVORITES} | Select the browser "favorites" button
{BROWSER_HOME} | Launch the browser and go to the home page
{VOLUME_MUTE} | Mute the volume
{VOLUME_DOWN} | Reduce the volume
{VOLUME_UP} | Increase the volume
{MEDIA_NEXT} | Select next track in media player
{MEDIA_PREV} | Select previous track in media player
{MEDIA_STOP} | Stop media player
{MEDIA_PLAY_PAUSE} | Play/pause media player
{LAUNCH_MAIL} | Launch the email application
{LAUNCH_MEDIA} | Launch media player
{LAUNCH_APP1} | Launch user app1
{LAUNCH_APP2} | Launch user app2
{OEM_102} | Either the angle bracket key or the backslash key on the RT 102-key keyboard

To send the ASCII value A (same as pressing ALT+065 on the numeric keypad)
Send("{ASC 065}")

(When using 2 digit ASCII codes you must use a leading 0, otherwise an obsolete 437 code page is used).

To send UNICODE characters enter the character code (decimal or hex), for example this sends a Chinese character
Send("{ASC 2709}") or Send("{ASC 0xA95}")

Single keys can also be sent repeated:
Send("{DEL 4}") ;Presses the DEL key 4 times
Send("{S 30}") ;Sends 30 'S' characters
Send("+{TAB 4}") ;Presses SHIFT+TAB 4 times

No key is sent if the count is zero allowing the count to be set programatically:
Send("{M " & $iCount & "}") ;Presses the M key as many times as set in the $iCount variable

To hold a key down
Send("{a down}") ;Holds the A key down
Send("{a up}") ;Releases the A key

To set the state of the capslock, numlock and scrolllock keys
Send("{NumLock on}") ;Turns the NumLock key on
Send("{CapsLock off}") ;Turns the CapsLock key off
Send("{ScrollLock toggle}") ;Toggles the state of ScrollLock

If you wish to use a variable for the count, try
$n = 4
Send("+{TAB " & $n & "}")

If you wish to send the ASCII value A four times, then try
$x = Chr(65)
Send("{" & $x & " 4}")

Most laptop computer keyboards have a special Fn key. This key cannot be simulated.

Note, by setting the flag parameter to 1 the above "special" processing will be disabled. This is useful when you want to send some text copied from a variable and you want the text sent exactly as written.

For example, open Folder Options (in the control panel) and try the following:

Send("{TAB}") | Navigate to next control (button, checkbox, etc)
Send("+{TAB}") | Navigate to previous control.
Send("^{TAB}") | Navigate to next WindowTab (on a Tabbed dialog window)
Send("^+{TAB}") | Navigate to previous WindowTab.
Send("{SPACE}") | Can be used to toggle a checkbox or click a button.
Send("{+}") | Usually checks a checkbox (if it's a "real" checkbox.)
Send("{-}") | Usually unchecks a checkbox.
Send("{NumPadMult}") | Recursively expands folders in a SysTreeView32.

Use Alt-key combos to access menu items. Also, open Notepad and try the following:
Send("!f") Send() Alt+f, the access key for Notepad's file menu. Try other letters!

Send("{DOWN}") | Move down a menu.
Send("{UP}") | Move up a menu.
Send("{LEFT}") | Move leftward to new menu or expand a submenu.
Send("{RIGHT}") | Move rightward to new menu or collapse a submenu.

When running a script on a remote computer through a program as psexec (www.sysinternals.com) or beyondexec (www.beyondlogic.org) it is necessary, specially when sending strokes to a program launch by the script with a Run() function, to use ControlSend() or other ControlXXX functions to directly communicate with the control. Send() even with Opt("SendAttachMode", 1) will not work.
Using the -s mode when submitting can help to have better rights on the remote computer.

Opt("SendKeyDelay",...) alters the the length of the brief pause in between sent keystrokes.
Opt("SendKeyDownDelay",...) alters the length of time a key is held down before being released during a keystroke.
Set both "SendKeyDelay" and "SendKeyDownDelay" to 0 to remove all delays when sending keystrokes. This may be required under certain circumstances, for example, when locking the system ("#l") it may be necessary to remove the delays in order to prevent the WIN key from being stuck down.

Related

BlockInput, ControlSend, HotKeySet, SendAttachMode (Option), SendKeepActive, SendKeyDelay (Option), SendKeyDownDelay (Option), WinMenuSelectItem

Example

Example()

Func Example()
    ; Simulate the key combination Win + R to open the Run dialogue window.
    Send("#r")

    ; Wait 10 seconds for the Run dialogue window to appear.
    WinWait("Run", "", 10)

    ; Simulate entering notepad.exe and pressing the 'ENTER' key.
    Send("notepad.exe{Enter}")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Simulate entering the following string and pressing the 'F5' key to input the date and time into edit control of Notepad.
    Send("Today's time/date is {F5}")

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)

    ; Now a screen will pop up and ask to save the changes, the classname of the window is called
    ; "#32770" and simulating the "TAB" key to move to the second button in which the "ENTER" is simulated to not "save the file"
    WinWaitActive("[CLASS:#32770]")
    Sleep(500)
    Send("{TAB}{ENTER}")
EndFunc   ;==>Example


Function SendKeepActive

Function Reference

SendKeepActive

Attempts to keep a specified window active during Send().

SendKeepActive ( "title" [, "text"] )

Parameters

title | The title/hWnd/class of the window to activate. See Title special definition. Use a blank title to disable the function.
text | [optional] The text of the window. . Default is an empty string. See Text special definition.

Return Value

Success: | 1.
Failure: | 0 if window is not found.

Remarks

Using SendKeepActive("") attempts to reset the active window in between each simulated keystroke from Send().

Related

Send

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Keep the Notepad window active when using the Send function.
    SendKeepActive("[CLASS:Notepad]")

    ; Simulate entering a string of text. If you try to change to a different window other than Notepad, then the Notepad window will
    ; be brought to focus again.
    For $i = 1 To 10
        Sleep(500)
        Send("notepad - ")
    Next

    ; Disable the Notepad window being active when using the Send function.
    SendKeepActive("")

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)

    ; Now a screen will pop up and ask to save the changes, the classname of the window is called
    ; "#32770" and simulating the "TAB" key to move to the second button in which the "ENTER" is simulated to not "save the file"
    WinWaitActive("[CLASS:#32770]")
    Sleep(500)
    Send("{TAB}{ENTER}")
EndFunc   ;==>Example


Functions

Math functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
Abs | Calculates the absolute value of a number.
ACos | Calculates the arcCosine of a number.
ASin | Calculates the arcsine of a number.
ATan | Calculates the arctangent of a number.
BitAND | Performs a bitwise AND operation.
BitNOT | Performs a bitwise NOT operation.
BitOR | Performs a bitwise OR operation.
BitRotate | Performs a bit shifting operation, with rotation.
BitShift | Performs a bit shifting operation.
BitXOR | Performs a bitwise exclusive OR (XOR) operation.
Ceiling | Returns a number rounded up to the next integer.
Cos | Calculates the cosine of a number.
Exp | Calculates e to the power of a number.
Floor | Returns a number rounded down to the closest integer.
Log | Calculates the natural logarithm of a number.
Mod | Performs the modulus operation.
Random | Generates a pseudo-random float-type number.
Round | Returns a number rounded to a specified number of decimal places.
Sin | Calculates the sine of a number.
Sqrt | Calculates the square-root of a number.
SRandom | Set Seed for random number generation.
Tan | Calculates the tangent of a number.


Function Abs

Function Reference

Abs

Calculates the absolute value of a number.

Abs ( expression )

Parameters

expression Any valid numeric expression.

Return Value

Returns absolute value of expression.

Remarks

A string has a value of zero.

Example

#include <MsgBoxConstants.au3>

; Assign a Local variable an absolute number.
Local $fAbs = Abs(-123.45)

MsgBox($MB_SYSTEMMODAL, "", $fAbs)


Function ACos

Function Reference

ACos

Calculates the arcCosine of a number.

ACos ( expression )

Parameters

expression Any value between -1 and 1 inclusive.

Return Value

Returns the trigonometric arccosine of the number. Result is in radians.

Remarks

ACos(x) is mathematically defined only for -1 < x < 1, so ACos() tends to return -1.#IND for other values of x.

Related

ASin, ATan, Cos, Sin, Tan

Example

Example 1

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign a Local variable the arcCosine of 0.5.
    Local $fArcCos1 = ACos(0.5)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $fArcCos1 & " rad.")

    ; Assign a Local constant variable the approximate PI number.
    Local Const $PI = 3.141592653589793

    ; Assign a Local variable the formula to switch from radian to degree (equals to one radian in degree).
    Local $fRadToDeg = 180 / $PI

    ; Assign a Local variable a number in degree.
    Local $fArcCos2 = $fRadToDeg * ACos(-1)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $fArcCos2 & " deg.")
EndFunc   ;==>Example

Example 2

; Example of using ACos with degrees.
#include <Math.au3>
#include <MsgBoxConstants.au3>

Local $fDegree = _Degree(ACos(-1))

MsgBox($MB_SYSTEMMODAL, Default, "ACos(-1) = " & $fDegree & " degrees")


Function ASin

Function Reference

ASin

Calculates the arcsine of a number.

ASin ( expression )

Parameters

expression Any value between -1 and 1 (inclusive).

Return Value

Returns the trigonometric arcsine of the number. Result is in radians.

Remarks

ASin(x) is mathematically defined only for -1 < x < 1, so ASin() tends to return -1.#IND for other values of x.

Related

ACos, ATan, Cos, Sin, Tan

Example

Example 1

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign a Local variable the arcSine of 0.5.
    Local $fArcSin1 = ASin(0.5)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $fArcSin1 & " rad.")

    ; Assign a Local constant variable the approximate PI number.
    Local Const $PI = 3.141592653589793

    ; Assign a Local variable the formula to switch from radian to degree (equals to one radian in degree).
    Local $fRadToDeg = 180 / $PI

    ; Assign a Local variable a number in degree.
    Local $fArcSin2 = $fRadToDeg * ASin(1)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $fArcSin2 & " deg.")
EndFunc   ;==>Example

Example 2

; Example of using ASin with degrees
#include <Math.au3>
#include <MsgBoxConstants.au3>

Local $fDegree = _Degree(ASin(0.5))

MsgBox($MB_SYSTEMMODAL, Default, "ASin(0.5) = " & $fDegree & " degrees")


Function ATan

Function Reference

ATan

Calculates the arctangent of a number.

ATan ( expression )

Parameters

expression Any valid numeric expression.

Return Value

Returns the trigonometric arctangent of the number. Result is in radians.

Remarks

The result of 4 * ATan(1) is pi.

Related

ACos, ASin, Cos, Sin, Tan

Example

Example 1

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign a Local variable the arcTangent of 0.5.
    Local $fArcTan1 = ATan(0.5)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $fArcTan1 & " rad.")

    ; Assign a Local constant variable the approximate PI number.
    Local Const $PI = 3.141592653589793

    ; Assign a Local variable the formula to switch from radian to degree (equals to one radian in degree).
    Local $fRadToDeg = 180 / $PI

    ; Assign a Local variable a number in degree.
    Local $fArcTan2 = $fRadToDeg * ATan(1)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $fArcTan2 & " deg.")
EndFunc   ;==>Example

Example 2

; Example of using ATan with degrees
#include <Math.au3>
#include <MsgBoxConstants.au3>

Local $fDegree = _Degree(ATan(1))

MsgBox($MB_SYSTEMMODAL, Default, "ATan(1) = " & $fDegree & " degrees")


Function BitAND

Function Reference

BitAND

Performs a bitwise AND operation.

BitAND ( value1, value2 [, value n] )

Parameters

value1 | The first number.
value2 | The second number.
value n | [optional] The nth number - up to 255 values can be specified.

Return Value

Returns the value of the parameters bitwise-AND'ed together.
Bit operations are performed as 32-bit integers.

Remarks

Remember hex notation can be used for numbers.
BitAND() returns 1 in each bit position where all input arguments have a 1 in the corresponding position and 0 in all others.

Related

BitNOT, BitOR, BitRotate, BitShift, BitXOR, Hex

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Note: "b" is the symbol for byte.

    ; Assign a Local variable the bitwise AND operation of 1 and 0.
    Local $iBitAND1 = BitAND(1, 0)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitAND1)

    ; Assign a Local variable the bitwise AND operation of 1 and 1.
    Local $iBitAND2 = BitAND(1, 1)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitAND2)

    ; Assign a Local variable the bitwise AND operation of 13 (1101b) and 7 (0111b).
    Local $iBitAND3 = BitAND(13, 7) ; 1101b AND 0111b = 0101b

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitAND3)

    ; Assign a Local variable the bitwise AND operation of 2 (0010b), 3 (0011b) and 6 (0110b).
    Local $iBitAND4 = BitAND(2, 3, 6) ; 0010b AND 0011b AND 0110b = 0010b

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitAND4)
EndFunc   ;==>Example


Function BitNOT

Function Reference

BitNOT

Performs a bitwise NOT operation.

BitNOT ( value )

Parameters

value The number to operate on.

Return Value

Returns the bitwise NOT of the value.
Bit operations are performed as 32-bit integers.

Remarks

Remember hex notation can be used for numbers.
Remember that in 2's-complement notation, BitNOT() is functionally equivalent to adding 1 and negating the result.
Also remember that NOT changes a 0 bit to 1 and vice-versa.

Related

BitAND, BitOR, BitRotate, BitShift, BitXOR, Hex

Example

#include <MsgBoxConstants.au3>

; Assign a Local variable the bitwise NOT operation of 5.
Local $iBitNOT1 = BitNOT(5)

#cs Comments:
    Note: "b" is the symbol for byte.

    Result is -6 because for 32-bit numbers
    +5 == 0000 0000 0000 0000 0000 0000 0000 0101b
    -6 == 1111 1111 1111 1111 1111 1111 1111 1010b
    and the first bit is signed
#ce

; Display the result.
MsgBox($MB_SYSTEMMODAL, "", $iBitNOT1)


Function BitOR

Function Reference

BitOR

Performs a bitwise OR operation.

BitOR ( value1, value2 [, value n] )

Parameters

value1 | The first number.
value2 | The second number.
value n | [optional] The nth number - up to 255 values can be specified.

Return Value

Returns the two parameters bitwise-OR'ed together.
Bit operations are performed as 32-bit integers.

Remarks

Remember hex notation can be used for numbers.
BitOR() returns 0 in each bit position where all input arguments have a 0 in the corresponding position and 1 wherever there is at least one 1-bit.

Related

BitAND, BitNOT, BitRotate, BitShift, BitXOR, Hex

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Note: "b" is the symbol for byte.

    ; Assign a Local variable the bitwise OR operation of 1 and 0.
    Local $iBitOR1 = BitOR(1, 0) ; 0001b OR 0000b = 0001b

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitOR1)

    ; Assign a Local variable the bitwise OR operation of 1 and 1.
    Local $iBitOR2 = BitOR(1, 1) ; 0001b OR 0001b = 0001b

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitOR2)

    ; Assign a Local variable the bitwise OR operation of 13 (1101b) and 7 (0111b).
    Local $iBitOR3 = BitOR(13, 7) ; 1101b OR 0111b = 1111b

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitOR3)

    ; Assign a Local variable the bitwise OR operation of 2 (0010b), 3 (0011b) and 6 (0110b).
    Local $iBitOR4 = BitOR(2, 3, 6) ; 0010b OR 0011b OR 0110b = 0111b

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitOR4)
EndFunc   ;==>Example


Function BitRotate

Function Reference

BitRotate

Performs a bit shifting operation, with rotation.

BitRotate ( value [, shift = 1 [, size = "W"]] )

Parameters

value | The number to be operate on.
shift | [optional] Number of bits to rotate to the left (negative numbers rotate right). If not given, the default is 1.
size | [optional] A string that determines the rotation size, the default is (16 bits). See below.
Size parameter :
"B" | rotate bits within the low-order byte (8 bits).
"W" | rotate bits within the low-order word (16 bits).
"D" | rotate bits within the entire double-word (32 bits).

Return Value

Success: | the value rotated by the required number of bits.
Failure: | Sets the flag @error to non-zero if size is invalid.

Remarks

Remember hex notation can be used for numbers.

Related

BitAND, BitNOT, BitOR, BitShift, BitXOR, Hex

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Note: "b" is the symbol for byte.

    ; Assign a Local variable the bitwise left-rotate operation of 2.
    Local $iBitRotate1 = BitRotate(2, 1) ; 2 = 0010b left-rotated once -> 4 = 0100b

    ; Note: It is equivalent to do this: BitShift(2, -1)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitRotate1)

    ; Assign a Local variable the bitwise right-rotate operation of 1.
    Local $iBitRotate2 = BitRotate(1, -1) ; 1 = 0001b right-rotated once -> 32768 (32 bits) = 1000 0000 0000 0000b

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitRotate2)

    ; Assign a Local variable the bitwise right-rotate operation of 14.
    Local $iBitRotate3 = BitRotate(14, -2) ; 14 = 1110b right-rotated twice -> 32771 (16 bits) = 1000 0000 0000 0011b

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitRotate3)

    ; Assign a Local variable the bitwise right-rotate operation of 14 on 32 bits.
    Local $iBitRotate4 = BitRotate(14, -2, "D")
    ; 14 = 1110b right-rotated twice -> -2147483645 (32 bits) = 1000 0000 0000 0000 0000 0000 0000 0011b (the first bit is signed)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitRotate4)
EndFunc   ;==>Example


Function BitShift

Function Reference

BitShift

Performs a bit shifting operation.

BitShift ( value, shift )

Parameters

value | The number to be shifted.
shift | Number of bits to shift to the right (negative numbers shift left).

Return Value

Returns the value shifted by the required number of bits.
Bit operations are performed as 32-bit integers.

Remarks

Remember hex notation can be used for numbers.
Right shifts are equivalent to halving; left shifts to doubling.

Related

BitAND, BitNOT, BitOR, BitRotate, BitXOR, Hex

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Note: "b" is the symbol for byte.

    ; Assign a Local variable the bitwise left-shift operation of 2.
    Local $iBitShift1 = BitShift(2, -1) ; 2 = 0010b left-shifted once -> 4 = 0100b

    ; Note: It is equivalent to do this: BitRotate(2, 1)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitShift1)

    ; Assign a Local variable the bitwise right-shift operation of 1.
    Local $iBitShift2 = BitShift(1, 1) ; 1 = 0001b right-shifted once -> 0 = 0000b

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitShift2)

    ; Assign a Local variable the bitwise left-shift operation of 14.
    Local $iBitShift3 = BitShift(14, -2) ; 14 = 1110b left-shifted twice -> 56 = 0011 1000b

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitShift3)

    ; Assign a Local variable the bitwise
    Local $iBitShift4 = BitShift(1, -31)
    ;1 = 0001b right-shifted 31 times -> -2147483648 (32 bits) = 1000 0000 0000 0000 0000 0000 0000 0000b

    ;Note: in 2's-complement notation, the 32nd digit from the right has a negative sign.

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitShift4)
EndFunc   ;==>Example


Function BitXOR

Function Reference

BitXOR

Performs a bitwise exclusive OR (XOR) operation.

BitXOR ( value1, value2 [, value n] )

Parameters

value1 | The first number.
value2 | The second number.
value n | [optional] The nth number - up to 255 values can be specified.

Return Value

Returns the value of the parameters bitwise-XOR'ed together.
Bit operations are performed as 32-bit integers.

Remarks

Remember hex notation can be used for numbers.
BitXOR() returns 1 in a bit position if there are an odd number of 1's in the corresponding bit position in all the input arguments, and 0 otherwise.

Related

BitAND, BitNOT, BitOR, BitRotate, BitShift, Hex

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Note: "b" is the symbol for byte.

    ; Assign a Local variable the bitwise XOR operation of 1 and 0.
    Local $iBitXOR1 = BitXOR(1, 0) ; 0001b XOR 0000b = 0001b

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitXOR1)

    ; Assign a Local variable the bitwise XOR operation of 1 and 1.
    Local $iBitXOR2 = BitXOR(1, 1) ; 0001b XOR 0001b = 0000b

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitXOR2)

    ; Assign a Local variable the bitwise XOR operation of 13 (1101b) and 7 (0111b).
    Local $iBitXOR3 = BitXOR(13, 7) ; 1101b XOR 0111b = 1010b

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitXOR3)

    ; Assign a Local variable the bitwise XOR operation of 2 (0010b), 3 (0011b) and 6 (0110b).
    Local $iBitXOR4 = BitXOR(2, 3, 6) ; 0010b XOR 0011b XOR 0110b = 0111b

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iBitXOR4)
EndFunc   ;==>Example


Function Cos

Function Reference

Cos

Calculates the cosine of a number.

Cos ( expression )

Parameters

expression Value in radians.

Return Value

Returns the trigonometric cosine of the number.

Remarks

1° = pi / 180 radians.

Related

ACos, ASin, ATan, Sin, Tan

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign a Local constant variable the approximate PI number.
    Local Const $PI = 3.141592653589793

    ; Assign a Local variable the cosine of PI / 4 (equals to Sqrt(2) / 2).
    Local $fCos1 = Cos($PI / 4)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $fCos1)

    ; Assign a Local variable the formula to switch from radian to degree (equals to one degree in radian).
    Local $fDegToRad = $PI / 180

    ; Assign a Local variable the cosine of 90 degrees (firstly converted to radians).
    Local $fCos2 = Cos(90 * $fDegToRad)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $fCos2)
EndFunc   ;==>Example


Function Ceiling

Function Reference

Ceiling

Returns a number rounded up to the next integer.

Ceiling ( expression )

Parameters

expression Any valid numeric expression.

Return Value

Returns the rounded number.

Related

Floor, Int, Number, Round

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign a Local variable an array containing the numbers.
    Local $aNumber[8] = [4.8, 4.5, 4.3, 4, -4.8, -4.5, -4.3, -4]

    ; Assign a Local variable a string which will contain the results.
    Local $sResults = ""

    ; Loop through the array: calculate the ceiling and format the result.
    For $i = 0 To 7
        $sResults &= "Ceiling(" & $aNumber[$i] & ") = " & Ceiling($aNumber[$i]) & @CRLF & ($i = 3 ? @CRLF : "")
    Next

    ; Display the results.
    MsgBox($MB_SYSTEMMODAL, "", $sResults)
EndFunc   ;==>Example


Function Exp

Function Reference

Exp

Calculates e to the power of a number.

Exp ( expression )

Parameters

expression Any valid numeric expression.

Return Value

Returns e raised to the power of expression.

Remarks

e is the base of the natural logarithm and is approximately 2.71828182845905

Related

Log

Example

#include <MsgBoxConstants.au3>

; Assign a Local variable the Euler's number of 5.
Local $fExp1 = Exp(5)

; Display the result.
MsgBox($MB_SYSTEMMODAL, "", $fExp1)


Function Floor

Function Reference

Floor

Returns a number rounded down to the closest integer.

Floor ( expression )

Parameters

expression Any valid numeric expression.

Return Value

Returns the rounded number.

Related

Ceiling, Int, Number, Round

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign a Local variable an array containing the numbers.
    Local $aNumber[8] = [4.8, 4.5, 4.3, 4, -4.8, -4.5, -4.3, -4]

    ; Assign a Local variable a string which will contain the results.
    Local $sResults = ""

    ; Loop through the array: calculate the floor and format the result.
    For $i = 0 To 7
        $sResults &= "Floor(" & $aNumber[$i] & ") = " & Floor($aNumber[$i]) & @CRLF & ($i = 3 ? @CRLF : "")
    Next

    ; Display the results.
    MsgBox($MB_SYSTEMMODAL, "", $sResults)
EndFunc   ;==>Example


Function Log

Function Reference

Log

Calculates the natural logarithm of a number.

Log ( expression )

Parameters

expression Any positive number.

Return Value

Success: | the parameter's natural logarithm.
Failure: | Tends to return -1.#IND for non-positive parameters.

Remarks

@error is always 0

Related

Exp

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign a Local variable the natural logarithm of 1000.
    Local $fLog1 = Log(1000)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $fLog1)

    ; Assign a Local variable the base-10 natural logarithm of 1000.
    Local $fLog2 = Log10(1000)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $fLog2)
EndFunc   ;==>Example

; User-defined function for common log
Func Log10($fNb)
    Return Log($fNb) / Log(10) ; 10 is the base
EndFunc   ;==>Log10


Function Mod

Function Reference

Mod

Performs the modulus operation.

Mod ( value1, value2 )

Parameters

value1 | The dividend.
value2 | The divisor.

Return Value

Success: | the remainder when value1 is divided by value2.
Failure: | -1.#IND if the divisor is zero.

Remarks

This function guarantees that Mod(dividend, divisor) = dividend - Int(dividend / divisor) * divisor.

This function does not guarantee that dividend or divisor can be represented, specifically with floating point numbers.

If integers are passed this function does an integral modulo operation. Otherwise it falls back to a floating point operation which per the previous remark means it may not produce the expected output.

Related

Int

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign a Local variable the number 18.
    Local $iNb = 18

    ; If the mudulus operation of $iNb by 2 equals to 0 then $iNb is even.
    If Mod($iNb, 2) = 0 Then
        MsgBox($MB_SYSTEMMODAL, "", $iNb & " is an even number.")
    Else
        MsgBox($MB_SYSTEMMODAL, "", $iNb & " is an odd number.")
    EndIf

    ; Assign a Local variable the modulus operation of 4 by 7.
    Local $iMod1 = Mod(4, 7) ; 4%7 = 4 because the divisor > dividend

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iMod1)

    ; Assign a Local variable the modulus operation of 1 by 3/4.
    Local $iMod2 = Mod(1, 3 / 4) ; 1%(3/4) = 0.25 because the divisor is a float

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iMod2)
EndFunc   ;==>Example


Function Random

Function Reference

Random

Generates a pseudo-random float-type number.

Random ( [Min = 0 [, Max = 1 [, Flag = 0]]] )

Parameters

Min | [optional] The smallest number to be generated. The default is 0.
Max | [optional] The largest number to be generated. The default is 1.
Flag | [optional] If this is set to 1 then an integer result will be returned. Default is a floating point number.

Return Value

Success: | a pseudo-random number between Min and Max.
Failure: | sets the @error flag to non-zero.

Remarks

If only one argument is provided, then this is interpreted to be the Max parameter.

The result will be in the range of Min to Max INCLUSIVE when using integers (just short of Max when using floats).

If Min and Max are the same value then Random() will return that value - the @error flag will not be set in this case

When using integers Max-Min must be less than 2^31.

Comments based on the original source

This function uses the Mersenne Twister random number generator, MT19937, written by Takuji Nishimura, Makoto Matsumoto, Shawn Cokus, Matthe Bellew and Isaku Wada.

The Mersenne Twister is an algorithm for generating random numbers. It was designed with consideration of the flaws in various other generators. The period, 219937-1, and the order of equidistribution, 623 dimensions, are far greater. The generator is also fast; it avoids multiplication and division, and it benefits from caches and pipelines. For more information see the inventors' web page at http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html

Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Related

Round, SRandom

Example

Example 1

#include <MsgBoxConstants.au3>

; Flip a coin.
Example()

Func Example()
    If Random(0, 1, 1) Then ; Return an integer between 0 and 1.
        MsgBox($MB_SYSTEMMODAL, "", "The side of the coin was: Heads") ; If the random integer was 1 then heads was thrown.
    Else
        MsgBox($MB_SYSTEMMODAL, "", "The side of the coin was: Tails") ; If the random integer was 0 then tails was thrown.
    EndIf
EndFunc   ;==>Example

Example 2

#include <MsgBoxConstants.au3>

; Roll a die.

Example()

Func Example()
    MsgBox($MB_SYSTEMMODAL, "", "The die landed on number " & Random(1, 6, 1) & ".") ; Return an integer between 1 and 6.
EndFunc   ;==>Example

Example 3

#include <MsgBoxConstants.au3>

; Create a random string of text.

Example()

Func Example()
    Local $sText = ""
    For $i = 1 To Random(5, 20, 1) ; Return an integer between 5 and 20 to determine the length of the string.
        $sText &= Chr(Random(65, 122, 1)) ; Return an integer between 65 and 122 which represent the ASCII characters between a (lower-case) to Z (upper-case).
    Next
    MsgBox($MB_SYSTEMMODAL, "", "The random string of text was: " & $sText) ; Display the string of text.
EndFunc   ;==>Example

Example 4

#include <MsgBoxConstants.au3>

; Result of when Min and Max are the same value.

Example()

Func Example()
    Local $iRandom = Random(10, 10)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred, due to the fact both values are exactly the same: " & $iRandom)
    EndIf
EndFunc   ;==>Example


Function Round

Function Reference

Round

Returns a number rounded to a specified number of decimal places.

Round ( expression [, decimalplaces] )

Parameters

expression | Any valid numeric expression.
decimalplaces | [optional] Number indicating how many places to the right of the decimal are included in the rounding. If omitted, Round returns an integer.

Return Value

Returns rounded number.

Remarks

The decimalplaces parameter can be negative which allows you to round to the ones, tens, hundred, etc. place. Note that up to fifteen digits of a number are displayed, and note that decimalplaces will never pad a number with trailing zeros.

Related

Ceiling, Floor, Int, Number, Random

Example

Example 1

#include <MsgBoxConstants.au3>

Local $iRound1 = Round(-1.582, 1) ; Returns -1.6.
Local $iRound2 = Round(3.1415, 9) ; No change is made.
Local $iRound3 = Round(123.5, -1) ; Returns 120

MsgBox($MB_SYSTEMMODAL, "", "The following values were rounded: " & @CRLF & _
        $iRound1 & @CRLF & $iRound2 & @CRLF & $iRound3)

Example 2

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign a Local variable an Array which will contain the rounded numbers.
    Local $aRound[5]

    $aRound[0] = Round(-1.582, 1) ; Returns -1.6.
    $aRound[1] = Round(3.1415, 9) ; Returns 3.1415
    $aRound[2] = Round(123.5, -1) ; Returns 120.
    $aRound[3] = Round(123.5) ; Returns 124.
    $aRound[4] = Round(50) ; Returns 50.

    ; Display the results.
    For $i = 0 To UBound($aRound) - 1
        MsgBox($MB_SYSTEMMODAL, "", "Round" & $i & ": " & $aRound[$i] & @CRLF)
    Next
EndFunc   ;==>Example


Function Sin

Function Reference

Sin

Calculates the sine of a number.

Sin ( expression )

Parameters

expression Value in radians.

Return Value

Returns the trigonometric sine of the number.

Remarks

1° = pi / 180 radians.

Related

ACos, ASin, ATan, Cos, Tan

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign a Local constant variable the approximate PI number.
    Local Const $PI = 3.141592653589793

    ; Assign a Local variable the sine of PI / 4 (equals to Sqrt(2) / 2).
    Local $fSin1 = Sin($PI / 4)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $fSin1)

    ; Assign a Local variable the formula to switch from radian to degree (equals to one degree in radian).
    Local $fDegToRad = $PI / 180

    ; Assign a Local variable the sine of 90 degrees (firstly converted to radians).
    Local $fSin2 = Sin(90 * $fDegToRad)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $fSin2)
EndFunc   ;==>Example


Function Sqrt

Function Reference

Sqrt

Calculates the square-root of a number.

Sqrt ( expression )

Parameters

expression Any nonnegative expression to get the square-root of.

Return Value

Success: | the square-root.
Failure: | -1.#IND if parameter is negative.

Remarks

To compute an nth root, use the power operator: x ^ (1/n)
MsgBox(4096,"The cube root of 27 is", 27 ^ (1/3) )

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign a Local variable the square-root of 2.
    Local $fSqrt1 = Sqrt(2)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $fSqrt1)

    ; Assign a Local variable the square-root of 9.
    Local $fSqrt2 = Sqrt(9)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $fSqrt2)
EndFunc   ;==>Example


Function SRandom

Function Reference

SRandom

Set Seed for random number generation.

SRandom ( Seed )

Parameters

Seed Seed value for random number generation. Number between -2^31 and 2^31-1

Return Value

None.

Remarks

When using SRandom() sequence of random numbers will be repeated each time you run the script. For example, you can test the speed of the script and the random numbers will not affect the test results.
After each call to SRandom() random number generator starts a new sequence. Use the SRandom(@SEC), for random sequences.

Related

Random

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Sets the seed to the number 12.
    SRandom(12)

    ; Assign a Local variable the random number based on the above seed.
    Local $iRandom1 = Random()

    ; Note: You will get the same result each time as the seed is constant.

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $iRandom1)
EndFunc   ;==>Example


Function Tan

Function Reference

Tan

Calculates the tangent of a number.

Tan ( expression )

Parameters

expression Value in radians.

Return Value

Returns the trigonometric tangent of the number.

Remarks

1° = pi / 180 radians.
Note that Tan() is "infinite" for ... -3PI/2, -PI/2, PI/2, 3PI/2, 5PI/2, ... and tends to return 1.63317787283838e+016 for such multiples of Pi-halves.

Related

ACos, ASin, ATan, Cos, Sin

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign a Local constant variable the approximate PI number.
    Local Const $PI = 3.141592653589793

    ; Assign a Local variable the tangent of PI / 4.
    Local $fTan1 = Tan($PI / 4)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $fTan1)

    ; Assign a Local variable the formula to switch from radian to degree (equals to one degree in radian).
    Local $iDegToRad = $PI / 180

    ; Assign a Local variable the tangent of 90 degrees (firstly converted to radians).
    Local $fTan2 = Tan(90 * $iDegToRad)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $fTan2)
EndFunc   ;==>Example


Functions

Message Boxes and Dialogs functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
InputBox | Displays an input box to ask the user to enter a string.
MsgBox | Displays a simple message box with optional timeout.
ProgressOff | Turns Progress window off.
ProgressOn | Creates a customizable progress bar window.
ProgressSet | Sets the position and/or text of a previously created Progress bar window.
SplashImageOn | Creates a customizable image popup window.
SplashOff | Turns SplashText or SplashImage off.
SplashTextOn | Creates a customizable text popup window.
ToolTip | Creates a tooltip anywhere on the screen.


Function InputBox

Function Reference

InputBox

Displays an input box to ask the user to enter a string.

InputBox ( "title", "prompt" [, "default" [, "password char" [, width = -1 [, height = -1 [, left = Default [, top = Default [, timeout = 0 [, hwnd]]]]]]]] )

Parameters

title | The title of the input box.
prompt | A message to the user indicating what kind of input is expected.
default | [optional] The value that the input box starts with.
password char | [optional] The character to replace all typed characters with in the display. If you want the actual typed character to appear, define with an empty string ("") (default) or a space for the first character. If you provide a multi-character string, only the first character is used for character masking. There are special meanings for the second and subsequent characters. See Remarks.
width | [optional] The width of the window.
height | [optional] The height of the window.
left | [optional] The left side of the input box. By default, the box is centered.
top | [optional] The top of the input box. By default, the box is centered.
timeout | [optional] How many seconds to wait before automatically canceling the InputBox().
hwnd | [optional] The window handle to use as the parent for this dialog.

Return Value

Success: | the string that was entered.
Failure: | "" (empty string) and sets the @error flag to non-zero.
@error: | 1 = The Cancel button was pushed. 2 = The Timeout time was reached. 3 = The InputBox failed to open. This is usually caused by bad arguments. 4 = The InputBox cannot be displayed on any monitor. 5 = Invalid parameters width without height or left without top.

Remarks

The InputBox() is user-resizable, but has a minimum size of approximately 190 x 115 pixels. Default size is approximately 250 x 190 pixels.

The string returned will not exceed 254 characters and if input contains carriage returns or linefeeds, the result will be truncated at the first occurrence of those characters.

The second and subsequent characters of the password field can be used to restrict input. Use a space to fill the first character to still see the characters typed. Putting an M after the first character indicates that input is Mandatory; i.e. you must enter something. Nothing will happen if you press the Ok button when there is nothing in the InputBox(). It will not close and return the string.

If your script is going to use an inputbox you must include the pragma directive "#pragma compile(inputboxres, true)"

You can also specify the maximum length at the end of the password field. Just enter a number as the last character(s) to specify the length of the string.

Related

MsgBox

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Places the input box in the top left corner displaying the characters as they
    ; are typed.
    Local $sAnswer = InputBox("Question", "Where were you born?", "Planet Earth", "", _
             - 1, -1, 0, 0)

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $sAnswer)

    ; Asks the user to enter a password.  Don't forget to validate it!
    Local $sPasswd = InputBox("Security Check", "Enter your password.", "", "*")

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $sPasswd)

    ; Asks the user to enter a 1 or 2 character response.  The M in the password
    ; field indicates that empty string is not accepted and the 2 indicates that the
    ; responce will be at most 2 characters long.
    Local $sValue = InputBox("Testing", "Enter the 1 or 2 character code.", "", " M2")

    ; Display the result.
    MsgBox($MB_SYSTEMMODAL, "", $sValue)
EndFunc   ;==>Example


Function MsgBox

Function Reference

MsgBox

Displays a simple message box with optional timeout.

MsgBox ( flag, "title", "text" [, timeout = 0 [, hwnd]] )

Parameters

flag | The flag indicates the type of message box and the possible button combinations. See remarks.
title | The title of the message box.
text | The text of the message box.
timeout | [optional] Timeout in seconds. After the timeout has elapsed the message box will be automatically closed. The default is 0, which is no timeout.
hwnd | [optional] The window handle to use as the parent for this dialog.

Return Value

Success: | the ID of the button pressed.
Failure: | $IDTIMEOUT (-1) if the message box timed out.

Button Pressed | Return Value
OK | $IDOK (1)
CANCEL | $IDCANCEL (2)
ABORT | $IDABORT (3)
RETRY | $IDRETRY (4)
IGNORE | $IDIGNORE (5)
YES | $IDYES (6)
NO | $IDNO (7)
TRY AGAIN ** | $IDTRYAGAIN (10)
CONTINUE ** | $IDCONTINUE (11)

Constants are defined in MsgBoxConstants.au3.

Remarks

The flag parameter can be a combination of the following values:

Constant Name | Decimal flag | Button-related result | Hexadecimal flag
$MB_OK | 0 | OK button | 0x0
$MB_OKCANCEL | 1 | OK and Cancel | 0x1
$MB_ABORTRETRYIGNORE | 2 | Abort, Retry, and Ignore | 0x2
$MB_YESNOCANCEL | 3 | Yes, No, and Cancel | 0x3
$MB_YESNO | 4 | Yes and No | 0x4
$MB_RETRYCANCEL | 5 | Retry and Cancel | 0x5
$MB_CANCELTRYCONTINUE | 6 | Cancel, Try Again, Continue | 0x6
$MB_HELP | 16384 | Adds a Help button to the message box. When the user clicks the Help button or presses F1, the system sends a WM_HELP message to the owner. | 0x4000
Constant Name | decimal flag | Icon-related Result | hexadecimal flag
 | 0 | (No icon) | 0x0
$MB_ICONERROR | 16 | Stop-sign icon | 0x10
$MB_ICONQUESTION | 32 | Question-mark icon | 0x20
$MB_ICONWARNING | 48 | Exclamation-point icon | 0x30
$MB_ICONINFORMATION | 64 | Information-sign icon consisting of an 'i' in a circle | 0x40
Constant Name | decimal flag | Default-related Result | hexadecimal flag
$MB_DEFBUTTON1 | 0 | First button is default button | 0x0
$MB_DEFBUTTON2 | 256 | Second button is default button | 0x100
$MB_DEFBUTTON3 | 512 | Third button is default button | 0x200
$MB_DEFBUTTON4 | 768 | Fourth button is default button | 0x300
Constant Name | decimal flag | Modality-related Result | hexadecimal flag
$MB_APPLMODAL | 0 | Application 0x0
$MB_SYSTEMMODAL | 4096 | System modal (dialog has an icon) | 0x1000
$MB_TASKMODAL | 8192 | Task modal | 0x2000
Constant Name | decimal flag | Miscellaneous-related Result | hexadecimal flag
 | 0 | (nothing else special) | 0x0
$MB_DEFAULT_DESKTOP_ONLY | 131072 | MsgBox() shows on the desktop of the interactive window station. | 0x20000
$MB_RIGHT | 524288 | title and text are right-justified | 0x80000
$MB_RTLREADING | 1048576 | Displays message and caption text using right-to-left reading order on Hebrew and Arabic systems. | 0x100000
$MB_SETFOREGROUND | 65536 | The message box becomes the foreground window. | 0x10000
$MB_TOPMOST | 262144 | MsgBox() has top-most attribute set | 0x40000
$MB_SERVICE_NOTIFICATION | 2097152 | The function displays a message box on the current active desktop, even if there is no user logged on to the computer. | 0x200000

For example, to specify a SYSTEMMODAL box with the YES/NO buttons the flag value would be 4096+4 (or 4100) If using hexadecimal flags, that would be 0x1000+0x4 (or 0x1004).

A message box appears centered on screen and resizes according to the text it contains. However, the title could get truncated if the SYSTEMMODAL flag (4096) is used..

If "title" is equal to Default keyword @Scriptname is used

Special note; MsgBox does not support the use of the timeout parameter when the $MB_SERVICE_NOTIFICATION flag is used when calling MsgBox from a service. The message box window is not owned by the process calling MsgBox when $MB_SERVICE_NOTIFICATION is specified.

Constants are defined in MsgBoxConstants.au3

Related

InputBox, SplashTextOn, ToolTip, TrayTip

Example

Example 1

#include <MsgBoxConstants.au3>

MsgBox($MB_SYSTEMMODAL, "Title", "This message box will timeout after 10 seconds or select the OK button.", 10)

Example 2

#include <MsgBoxConstants.au3>

Local $iTimeout = 10

; Display a message box with a nested variable in its text.
MsgBox($MB_SYSTEMMODAL, "Title", "This message box will timeout after " & $iTimeout & " seconds or select the OK button.", $iTimeout)


Function ProgressOff

Function Reference

ProgressOff

Turns Progress window off.

ProgressOff ( )

Return Value

None.

Related

ProgressOn, ProgressSet

Example

Example()

Func Example()
    ; Display a progress bar window.
    ProgressOn("Progress Meter", "Increments every second", "0%")

    ; Update the progress value of the progress bar window every second.
    For $i = 10 To 100 Step 10
        Sleep(1000)
        ProgressSet($i, $i & "%")
    Next

    ; Set the "subtext" and "maintext" of the progress bar window.
    ProgressSet(100, "Done", "Complete")
    Sleep(5000)

    ; Close the progress window.
    ProgressOff()
EndFunc   ;==>Example


Function ProgressOn

Function Reference

ProgressOn

Creates a customizable progress bar window.

ProgressOn ( "title", "maintext" [, "subtext" [, x pos [, y pos [, opt]]]] )

Parameters

title | Title for progress window.
maintext | Text for Main, Bold, Upper label.
subtext | [optional] text for Sub, Normal, Lower label. (default is blank)
x pos | [optional] position from left (in pixels) of progress window. (default is centered)
y pos | [optional] position from top (in pixels) of progress window. (default is centered)
opt | [optional] Default is 'always on top/with title' Add up the following options you want: $DLG_NOTITLE (1) = borderless, titleless window $DLG_NOTONTOP (2) = Without "always on top" attribute $DLG_MOVEABLE (16) = Window can be moved Constants are defined in AutoItConstants.au3

Return Value

None.

Remarks

To skip an optional parameter, leaving its default value intact, use:
"" for string parameters
-1 for numeric parameters
If ProgressOn() is called while a progress window already exists, the window is redrawn/moved. (If you want multiple simultaneous progress windows, you need to use multiple scripts.)

Related

ProgressOff, ProgressSet

Example

Example()

Func Example()
    ; Display a progress bar window.
    ProgressOn("Progress Meter", "Increments every second", "0%")

    ; Update the progress value of the progress bar window every second.
    For $i = 10 To 100 Step 10
        Sleep(1000)
        ProgressSet($i, $i & "%")
    Next

    ; Set the "subtext" and "maintext" of the progress bar window.
    ProgressSet(100, "Done", "Complete")
    Sleep(5000)

    ; Close the progress window.
    ProgressOff()
EndFunc   ;==>Example


Function ProgressSet

Function Reference

ProgressSet

Sets the position and/or text of a previously created Progress bar window.

ProgressSet ( percent [, "subtext" [, "maintext"]] )

Parameters

percent | Percentage (value between 0. and 100.) to set the progress bar at.
subtext | [optional] Set the text for the Sub, Normal, Lower label.
maintext | [optional] Set the text for the Main, Bold, Upper label.

Return Value

None.

Remarks

Notice that the subtext argument comes before maintext.

Related

ProgressOff, ProgressOn

Example

Example()

Func Example()
    ; Display a progress bar window.
    ProgressOn("Progress Meter", "Increments every second", "0%")

    ; Update the progress value of the progress bar window every second.
    For $i = 10 To 100 Step 10
        Sleep(1000)
        ProgressSet($i, $i & "%")
    Next

    ; Set the "subtext" and "maintext" of the progress bar window.
    ProgressSet(100, "Done", "Complete")
    Sleep(5000)

    ; Close the progress window.
    ProgressOff()
EndFunc   ;==>Example


Function SplashImageOn

Function Reference

SplashImageOn

Creates a customizable image popup window.

SplashImageOn ( "title", "file" [, width [, height [, x pos [, y pos [, opt]]]]] )

Parameters

title | Title for splash window.
file | full path\filename of image (BMP, GIF, or JPG)
width | [optional] width of window in pixels. (default is 500)
height | [optional] height of window in pixels. (default is 400)
x pos | [optional] position from left (in pixels) of splash window. (default is centered)
y pos | [optional] position from top (in pixels) of splash window. (default is centered)
opt | [optional] Default is 'always on top/with title' Add up the following options you want: $DLG_NOTITLE (1) = borderless, titleless window $DLG_NOTONTOP (2) = Without "always on top" attribute $DLG_MOVEABLE (16) = Window can be moved Constants are defined in AutoItConstants.au3.

Return Value

None.

Remarks

To skip an optional parameter, leaving its default value intact, use a value of -1.

The image is scaled to specified width and height and should be a Bitmap, GIF, or JPEG image. Icons (ICOs) will not display, though the window still appears. PNG images throw an error message of failing to load, and so do invalid files/paths.

Images are not embedded in the executable unless you use FileInstall()

Only one SplashImage/Text window is allowed at one time; so if you wish to cycle through multiple images/text, simply call SplashImageOn()/SplashTextOn() again with the new information.

Splash with opt=1 cannot be moved and cannot be activated by click.

Related

SplashOff, SplashTextOn

Example

Local $sDestination = "..\GUI\mslogo.jpg"

SplashImageOn("Splash Screen", $sDestination, 250, 50)
Sleep(3000)
SplashOff()


Function SplashOff

Function Reference

SplashOff

Turns SplashText or SplashImage off.

SplashOff ( )

Return Value

None.

Related

SplashImageOn, SplashTextOn

Example

#include <MsgBoxConstants.au3>

SplashTextOn("Example", "Splash Screen", 500, 400, 100, 100)
MsgBox($MB_SYSTEMMODAL, 'Test 1', 'Splash is visible')
SplashOff()
MsgBox($MB_SYSTEMMODAL, 'Test 2', 'Splash is Off')


Function SplashTextOn

Function Reference

SplashTextOn

Creates a customizable text popup window.

SplashTextOn ( "title", "text" [, w = 500 [, h = 400 [, x pos [, y pos [, opt = 0 [, "fontname" [, fontsz = 12 [, fontwt]]]]]]]] )

Parameters

title | Title for splash window.
text | Text for splash window.
w | [optional] Width of window in pixels. (default 500)
h | [optional] Height of window in pixels. (default 400)
x pos | [optional] Position from left (in pixels) of splash window. (default is centered)
y pos | [optional] Position from top (in pixels) of splash window. (default is centered)
opt | [optional] Add them up - default is 'center justified/always on top/with title' $DLG_CENTERONTOP (0) = Center justified/always on top/with title (default) $DLG_NOTITLE (1) = Thin bordered titleless window $DLG_NOTONTOP (2) = Without "always on top" attribute $DLG_TEXTLEFT (4) = Left justified text $DLG_TEXTRIGHT (8) = Right justified text $DLG_MOVEABLE (16) = Windows can be moved $DLG_TEXTVCENTER (32) = Center text vertically Constants are defined in AutoItConstants.au3.
fontname | [optional] Name of the font to use. (OS default GUI font is used if the font is "" or is not found)
fontsz | [optional] Font size. (default is 12; standard sizes are 6 8 9 10 11 12 14 16 18 20 22 24 26 28 36 48 72)
fontwt | [optional] The weight of the font in the range 0 through 1000. For example, 400 is normal and 700 is bold. If this value is zero, a default weight is used. The following values are defined for convenience. $FW_DONTCARE (0) (Use the default font weight) $FW_THIN (100) $FW_EXTRALIGHT (200) $FW_LIGHT (300) $FW_NORMAL (400) $FW_MEDIUM (500) $FW_SEMIBOLD (600) $FW_BOLD (700) $FW_EXTRABOLD (800) $FW_HEAVY (900) Constants are defined in FontConstants.au3.

Return Value

Return the Handle of the splash window that can be used in ControlSetText().

Remarks

To skip an optional parameter, leaving its default value intact, use:
"" for string parameters
-1 for numeric parameters

Only one SplashImage/Text window is allowed at one time; so if you wish to cycle through multiple images/text, simply call SplashImageOn()/SplashTextOn() again with the new information.

Even better is to use ControlSetText() to update text without flicker...
If the text is center and multiline, the ControlSetText() will not override the number of lines created by the SplashTextOn().

Splash with opt=1 cannot be moved and cannot be activated by click.

Standard font names include:
Arial, Comic Sans MS, Courier New, Lucida Console, Microsoft Sans Serif, System, Tahoma, Times New Roman, and WingDings
See the Appendix for a complete list of Windows fonts and the Windows versions under which they are supported.

Use @LF to display several lines.

Related

ControlSetText, MsgBox, SplashImageOn, SplashOff, ToolTip

Example

#include <AutoItConstants.au3>

SplashTextOn("Title", "Message goes here.", -1, -1, -1, -1, $DLG_TEXTLEFT, "", 24)
Sleep(3000)
SplashOff()

; ; FLICKER
Local $sMessage = ""
SplashTextOn("TitleFoo", $sMessage, -1, -1, -1, -1, $DLG_TEXTLEFT, "")
For $i = 1 To 20
    $sMessage = $sMessage & $i & @CRLF
    SplashTextOn("TitleFoo", $sMessage, -1, -1, -1, -1, $DLG_TEXTLEFT, "")
    Sleep(100)
Next

; ; SMOOTH
$sMessage = ""
SplashTextOn("TitleFoo", $sMessage, -1, -1, -1, -1, $DLG_TEXTLEFT, "")
For $i = 1 To 20
    $sMessage = $sMessage & $i & @CRLF
    ControlSetText("TitleFoo", "", "Static1", $sMessage)
    Sleep(100)
Next


Function ToolTip

Function Reference

ToolTip

Creates a tooltip anywhere on the screen.

ToolTip ( "text" [, x [, y [, "title" [, icon = 0 [, options]]]]] )

Parameters

text | The text of the tooltip. (An empty string clears a displaying tooltip)
x | [optional] The x position of the tooltip.
y | [optional] The y position of the tooltip.
title | [optional] The title for the tooltip.
icon | [optional] Pre-defined icon to show next to the title: Requires a title. $TIP_NOICON (0) = No icon $TIP_INFOICON (1) = Info icon $TIP_WARNINGICON (2) = Warning icon $TIP_ERRORICON (3) = Error Icon Constants are defined in "AutoItConstants.au3".
options | [optional] Sets different options for how the tooltip will be displayed (Can be added together): $TIP_BALLOON (1) = Display as Balloon Tip $TIP_CENTER (2) = Center the tip at the x,y coordinates instead of using them for the upper left corner. $TIP_FORCEVISIBLE (4) = Force the tooltip to always be visible confining it to monitor borders if necessary. If multiple monitors are used, then the tooltip will "snap-to" the nearest monitor. Constants are defined in "AutoItConstants.au3".

Return Value

Success: | 1.
Failure: | 0 when title length is greater than 99.

Remarks

To skip an optional parameter, leaving its default value intact, use the Default keyword.

If the x and y coordinates are omitted, the tip is placed near the mouse cursor.
A Tooltip will appear until the script terminates or ToolTip("") is called.
You may use @CR or @LF to create multi-line tooltips.
To display an icon, you must specify a non-empty title. The icon appears on the same row as the title and thus requires a title to be present.
If using the center flag, the center of the tooltip will be at the coordinates specified. If using the center flag with a Balloon Tip, the stem will be centered on the balloon and will point to the coordinates specified.

Related

MsgBox, SplashTextOn, TrayTip

Example

; This will create a tooltip in the upper left of the screen

ToolTip("This is a tooltip", 0, 0)
Sleep(2000) ; Sleep to give tooltip time to display


Functions

Misc. functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
AdlibRegister | Registers an Adlib function.
AdlibUnRegister | Unregisters an adlib function.
AutoItSetOption | Changes the operation of various AutoIt functions/parameters.
AutoItWinGetTitle | Retrieves the title of the AutoIt window.
AutoItWinSetTitle | Changes the title of the AutoIt window.
BlockInput | Disable/enable the mouse and keyboard.
Break | Enables or disables the users' ability to exit a script from the tray icon menu.
Call | Calls a user-defined or built-in function contained in first parameter.
CDTray | Opens or closes the CD tray.
Execute | Execute an expression.
OnAutoItExitRegister | Registers a function to be called when AutoIt exits.
OnAutoItExitUnRegister | UnRegisters a function that was called when AutoIt exits.
SetError | Manually set the value of the @error macro (and optionally @extended, and "Return Value").
SetExtended | Manually set the value of the @extended macro.
VarGetType | Returns the internal type representation of a variant.


Function AdlibRegister

Function Reference

AdlibRegister

Registers an Adlib function.

AdlibRegister ( "function" [, time = 250] )

Parameters

function | The name of the adlib function to be registered.
time | [optional] how often in milliseconds to call the function. Default is 250 ms.

Return Value

Success: | 1.
Failure: | 0.

Remarks

Every 250 ms (or time ms) the specified "function" is called--typically to check for unforeseen errors. For example, you could use adlib in a script which causes an error window to pop up unpredictably.
The adlib function should be kept simple as it is executed often and during this time the main script is paused. Also, the time parameter should be used carefully to avoid CPU load.
You can not register a function using parameters.

Several Adlib functions can be registered. Re-registering an already existing Adlib function will update it with a new time.

Related

AdlibUnRegister

Example

#include <MsgBoxConstants.au3>

If ProcessExists("SciTE.exe") = 0 Then
    MsgBox($MB_SYSTEMMODAL, "", "You will need SciTE.exe to be running for ConsoleWrite to display.")
EndIf

Example()

Func Example()
    ; Register the function MyAdLibFunc() to be called every 250ms (default).
    AdlibRegister("MyAdLibFunc")

    ; Sleep does not stop AdLib functions from running.
    Sleep(1000)

    ; AdLib functions don't run while a blocking function is shown e.g. MsgBox, InputBox, WinWait, WinWaitClose etc.
    MsgBox($MB_SYSTEMMODAL, "", "No console message(s) will be shown whilst the messagebox is displayed.")

    ; The AdLib function MyAdLibFunc() will start again.
    Sleep(2000)

    ; Unregister the function MyAdLibFunc() from being called every 250ms.
    AdlibUnRegister("MyAdLibFunc")
EndFunc   ;==>Example

Func MyAdLibFunc()
    ; Assign a static variable to hold the number of times the function is called.
    Local Static $iCount = 0
    $iCount += 1

    ConsoleWrite("MyAdLibFunc called " & $iCount & " time(s)" & @CRLF)
EndFunc   ;==>MyAdLibFunc


Function AdlibUnRegister

Function Reference

AdlibUnRegister

Unregisters an adlib function.

AdlibUnRegister ( ["function"] )

Parameters

function [optional] The name of the adlib function to be Unregistered. See remarks for more information.

Return Value

Returns the number of adlib functions currently registered.

Remarks

If the function name is not specified then the last registered function will be unregistered.

Related

AdlibRegister

Example

#include <MsgBoxConstants.au3>

If ProcessExists("SciTE.exe") = 0 Then
    MsgBox($MB_SYSTEMMODAL, "", "You will need SciTE.exe to be running for ConsoleWrite to display.")
EndIf

Example()

Func Example()
    ; Register the function MyAdLibFunc() to be called every 250ms (default).
    AdlibRegister("MyAdLibFunc")

    ; Sleep does not stop AdLib functions from running.
    Sleep(1000)

    ; AdLib functions don't run while a blocking function is shown e.g. MsgBox, InputBox, WinWait, WinWaitClose etc.
    MsgBox($MB_SYSTEMMODAL, "", "No console message(s) will be shown whilst the messagebox is displayed.")

    ; The AdLib function MyAdLibFunc() will start again.
    Sleep(2000)

    ; Unregister the function MyAdLibFunc() from being called every 250ms.
    AdlibUnRegister("MyAdLibFunc")
EndFunc   ;==>Example

Func MyAdLibFunc()
    ; Assign a static variable to hold the number of times the function is called.
    Local Static $iCount = 0
    $iCount += 1

    ConsoleWrite("MyAdLibFunc called " & $iCount & " time(s)" & @CRLF)
EndFunc   ;==>MyAdLibFunc


Function AutoItWinGetTitle

Function Reference

AutoItWinGetTitle

Retrieves the title of the AutoIt window.

AutoItWinGetTitle ( )

Return Value

Returns a string containing the title of the AutoIt window.

Related

AutoItWinSetTitle, WinGetTitle

Example

#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Set the title of the AutoIt Hidden Window.
    AutoItWinSetTitle("My AutoIt Window")

    ; Display AutoIt's Hidden Window.
    AutoItWinShow()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Display AutoIt's Hidden Window. Returns the handle of the window.
Func AutoItWinShow()
    Local $hWnd = WinGetHandle(AutoItWinGetTitle()) ; Get the handle of the AutoIt Hidden Window by finding out the title of the AutoIt Hidden Window.
    WinMove($hWnd, "", (@DesktopWidth / 2) - 250, (@DesktopHeight / 2) - 250, 500, 500) ; Move the AutoIt Hidden Window and re-size for a better view.
    WinSetState($hWnd, "", @SW_SHOW) ; Show the AutoIt Hidden Window, normally this is hidden, but in the interest of this example I'm displaying it.
    Return $hWnd
EndFunc   ;==>AutoItWinShow


Function AutoItWinSetTitle

Function Reference

AutoItWinSetTitle

Changes the title of the AutoIt window.

AutoItWinSetTitle ( "newtitle" )

Parameters

newtitle The new title to give to the window.

Return Value

None.

Remarks

The AutoIt window is usually hidden. The purpose of changing the title is to allow other programs (or other AutoIt scripts) to interact with AutoIt.

Related

AutoItWinGetTitle, WinSetTitle

Example

Example 1

; Check if the script is already running
; Note: The recommended approach is to use _Singleton from Misc.au3

#include <MsgBoxConstants.au3>

Local $sMyAutoItTitle = "ThisIsSomeUniqueStringThatOtherWindowsWontHave"

If WinExists($sMyAutoItTitle) Then
    ; The script is already running

    MsgBox($MB_SYSTEMMODAL, Default, "The script is already running." & @CRLF & @CRLF & _
            "It's PID is: " & WinGetProcess($sMyAutoItTitle))
Else
    ; This is the first instance of the script.

    ; Set the autoit window title
    AutoItWinSetTitle($sMyAutoItTitle)

    ; Run this script again.
    If @Compiled Then
        Run('"' & @ScriptFullPath & '"')
    Else
        Run('"' & @AutoItExe & '" "' & @ScriptFullPath & '"')
    EndIf

    MsgBox($MB_SYSTEMMODAL, Default, "This is the first instance." & @CRLF & @CRLF & _
            "My PID is: " & @AutoItPID)
EndIf

Example 2

#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Set the title of the AutoIt Hidden Window.
    AutoItWinSetTitle("My AutoIt Window")

    ; Display AutoIt's Hidden Window.
    AutoItWinShow()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Display AutoIt's Hidden Window. Returns the handle of the window.
Func AutoItWinShow()
    Local $hWnd = WinGetHandle(AutoItWinGetTitle()) ; Get the handle of the AutoIt Hidden Window by finding out the title of the AutoIt Hidden Window.
    WinMove($hWnd, "", (@DesktopWidth / 2) - 250, (@DesktopHeight / 2) - 250, 500, 500) ; Move the AutoIt Hidden Window and re-size for a better view.
    WinSetState($hWnd, "", @SW_SHOW) ; Show the AutoIt Hidden Window, normally this is hidden, but in the interest of this example I"m displaying it.
    Return $hWnd
EndFunc   ;==>AutoItWinShow


Function BlockInput

Function Reference

BlockInput

Disable/enable the mouse and keyboard.

BlockInput ( flag )

Parameters

flag $BI_DISABLE (1) = Disable user input
$BI_ENABLE (0) = Enable user input

Constants are defined in "AutoItConstants.au3".

Return Value

Success: | 1.
Failure: | 0. Already Enable or #RequireAdmin not used.

Remarks

The table below shows how BlockInput() behavior depends on the Windows version; however, pressing Ctrl+Alt+Del on any platform will re-enable input due to a Windows API feature.

Operating System | "BlockInput()" Results
Windows XP | User input is blocked and AutoIt can simulate mouse and keyboard input. See remarks below for an issue with Windows XP SP1.
Windows Vista and above | User input is blocked and AutoIt can simulate mouse and keyboard if #RequireAdmin is used.

A Windows hotfix was released for Windows XP SP1 that contained a bug that prevents the Alt keystroke from being sent (via the Send() function) while BlockInput() is active. The Windows bug is fixed in Windows XP SP2 and newer.

BlockInput() only affects user-input. Input from functions like Send() or MouseMove() still work.

Related

Send

Example

#RequireAdmin

#include <AutoItConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Disable user input from the mouse and keyboard.
    BlockInput($BI_DISABLE)

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Send the 'F5' key to the edit control of Notepad to display the date and time. The handle returned by WinWait is used for the "title" parameter of ControlSend.
    ControlSend($hWnd, "", "Edit1", "{F5}")

    ; Enable user input from the mouse and keyboard.
    BlockInput($BI_ENABLE)

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)

    ; Now a screen will pop up and ask to save the changes, the classname of the window is called
    ; "#32770" and simulating the "TAB" key to move to the second button in which the "ENTER" is simulated to not "save the file"
    WinWaitActive("[CLASS:#32770]")
    Sleep(500)
    Send("{TAB}{ENTER}")
EndFunc   ;==>Example


Function Break

Function Reference

Break

Enables or disables the users' ability to exit a script from the tray icon menu.

Break ( mode )

Parameters

mode Sets the script break mode:
$BREAK_ENABLE (1) = Break is enabled (user can quit) (default)
$BREAK_DISABLE (0) = Break is disabled (user cannot quit)

Constants are defined in "AutoItConstants.au3".

Return Value

None.

Remarks

Please only disable break with good reason.
AutoIt normally creates a tray icon when running, and right-clicking this icon allows the user to pause or exit the script. If Break() is disabled (0), then the user cannot terminate the script this way.

Example

Break(0) ;Disable break


Function Call

Function Reference

Call

Calls a user-defined or built-in function contained in first parameter.

Call ( "function" [, param1 [, param2 [, paramN]]] )

Parameters

function | The name of function or function to call.
param | Arguments that will be passed to the function being invoked.

Return Value

Success: | the return value of the called function. Both @error and @extended may contain values if the called function set them.
Failure: | sets the @error flag to 0xDEAD and @extended to 0xBEEF if the function does not exist or invalid number of parameters.

Remarks

The function can pass arguments to functions, however, ByRef parameters are not supported; there is no way to retrieve the ByRef parameter.

A special array can be passed in lieu of individual parameters. This array must have its first element set to "CallArgArray" and elements 1 - n will be passed as separate arguments to the function. If using this special array, no other arguments can be passed to Call(). See example for a demonstration.
Both Call() itself can set the @error flag or the called function can set the @error flag. If Call() sets the @error flag, the value will be 0xDEAD and @extended will also be set to 0xBEEF. See the example for a demonstration of testing for a function that was not found.

Related

Execute

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; This calls a function accepting no arguments.
    Call("Test1")

    ; This calls a function accepting one argument and passes it an argument.
    Call("Test2", "Message from Call()!")

    ; This demonstrates how to use the special array argument.
    Local $aArgs[4]
    $aArgs[0] = "CallArgArray" ; This is required, otherwise, Call() will not recognize the array as containing arguments
    $aArgs[1] = "This is a string" ; Parameter one is a string
    $aArgs[2] = 47 ; Parameter two is a number
    Local $aArray[2]
    $aArray[0] = "Array Element 0"
    $aArray[1] = "Array Element 1"
    $aArgs[3] = $aArray ; Parameter three is an array

    ; We've built the special array, now call the function
    Call("Test3", $aArgs)

    ; Test calling a function that does not exist.  This shows the proper way to test by
    ; checking that both @error and @extended contain the documented failure values.
    Local Const $sFunction = "DoesNotExist"
    Call($sFunction)
    If @error = 0xDEAD And @extended = 0xBEEF Then MsgBox($MB_SYSTEMMODAL, "", "Function does not exist.")
EndFunc   ;==>Example

Func Test1()
    MsgBox($MB_SYSTEMMODAL, "", "Hello")
EndFunc   ;==>Test1

Func Test2($sMsg)
    MsgBox($MB_SYSTEMMODAL, "", $sMsg)
EndFunc   ;==>Test2

Func Test3($sString, $nNumber, $aArray)
    MsgBox($MB_SYSTEMMODAL, "", "The string is: " & @CRLF & $sString)
    MsgBox($MB_SYSTEMMODAL, "", "The number is: " & @CRLF & $nNumber)
    For $i = 0 To UBound($aArray) - 1
        MsgBox($MB_SYSTEMMODAL, "", "Array[" & $i & "] contains:" & @CRLF & $aArray[$i])
    Next
EndFunc   ;==>Test3


Function CDTray

Function Reference

CDTray

Opens or closes the CD tray.

CDTray ( "drive", "status" )

Parameters

drive | The drive letter of the CD tray to control, in the format D:, E:, etc.
status | Specifies if you want the CD tray to be open or closed: $CDTRAY_OPEN ("open") - to be open $CDTRAY_CLOSED ("closed") - to be closed on cd tray (not laptop-style) Constants are defined in AutoItConstants.au3

Return Value

Success: | 1.
Failure: | 0 if drive is locked via CD burning software or if the drive letter is not a CD drive.

Remarks

CDTray() works as expected with virtual CD drives such as DAEMON Tools.
CDTray() does not work on non-local/mapped CD drives; CDTray() must be run from the computer whose drive it affects.
CDTray("X:", "close") returns 1 on laptop-style cd trays that can only be closed manually.

Related

DriveGetType, DriveStatus

Example

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

; Get List of all CDRom's
Local $aCDRom = DriveGetDrive($DT_CDROM)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "", "No CDRom found.")
    Exit
EndIf

; Open the CD tray of the first CDRom
CDTray($aCDRom[1], $CDTRAY_OPEN)
Sleep(2000)
CDTray($aCDRom[1], $CDTRAY_CLOSED) ; does not work on laptop-style cd trays that can only be closed manually.


Function Execute

Function Reference

Execute

Execute an expression.

Execute ( string )

Parameters

string string representing an expression to be evaluated.

Return Value

Success: | the value of the evaluated expression.
Failure: | "" (empty string) and sets the @error flag to non-zero.

Related

Assign, Call, Eval

Example

Local $a = 1
Local $v = Execute("$a+1") ; $v is set to 2


Function OnAutoItExitRegister

Function Reference

OnAutoItExitRegister

Registers a function to be called when AutoIt exits.

OnAutoItExitRegister ( "function" )

Parameters

function The name of the user function to call.

Return Value

Success: | 1. @extended can be set if already registered.
Failure: | 0.

Remarks

The exit code can be retrieved with @exitCode.
The mode of exit can be retrieved with @exitMethod.

$EXITCLOSE_NORMAL (0) | Natural closing.
$EXITCLOSE_BYEXIT (1) | close by Exit function.
$EXITCLOSE_BYCLICK (2) | close by clicking on exit of the systray.
$EXITCLOSE_BYLOGOFF (3) | close by user logoff.
$EXITCLOSE_BYSUTDOWN (4) | close by Windows shutdown.

Constants are defined in "AutoItConstants.au3".

Related

Exit, OnAutoItExitUnRegister, OnAutoItStartRegister

Example

#include <MsgBoxConstants.au3>

OnAutoItExitRegister("MyTestFunc")
OnAutoItExitRegister("MyTestFunc2")

Sleep(1000)

Func MyTestFunc()
    MsgBox($MB_SYSTEMMODAL, "Exit Results 1", 'Exit Message from MyTestFunc()')
EndFunc   ;==>MyTestFunc

Func MyTestFunc2()
    MsgBox($MB_SYSTEMMODAL, "Exit Results 2", 'Exit Message from MyTestFunc()')
EndFunc   ;==>MyTestFunc2


Function OnAutoItExitUnRegister

Function Reference

OnAutoItExitUnRegister

UnRegisters a function that was called when AutoIt exits.

OnAutoItExitUnRegister ( "function" )

Parameters

function The name of the user function that was called.

Return Value

Success: | 1.
Failure: | 0.

Related

OnAutoItExitRegister

Example

#include <MsgBoxConstants.au3>

OnAutoItExitRegister("MyTestFunc")
OnAutoItExitRegister("MyTestFunc2")

Sleep(1000)

OnAutoItExitUnRegister("MyTestFunc")

Func MyTestFunc()
    MsgBox($MB_SYSTEMMODAL, "Exit Results 1", 'Exit Message from MyTestFunc()')
EndFunc   ;==>MyTestFunc

Func MyTestFunc2()
    MsgBox($MB_SYSTEMMODAL, "Exit Results 2", 'Exit Message from MyTestFunc()')
EndFunc   ;==>MyTestFunc2


Function SetError

Function Reference

SetError

Manually set the value of the @error macro (and optionally @extended, and "Return Value").

SetError ( code [, extended = 0 [, return value]] )

Parameters

code | The required value (integer) to set into the @error macro.
extended | [optional] The required value (integer) to set into the @extended macro. This sets the same macro as the SetExtended() function.
return value | [optional] The value to be returned by the function - if no parameter used the return value is undefined.

Return Value

Returns the "return value" parameter (undefined if the parameter is not used).
@error and @extended will be set to the values set in the function call (both default = 0)

Remarks

When entering a function @error is set to 0. Unless SetError() is called, then @error will remain 0 when the function ends. This means that in order for @error to be set after a function, it must be explicitly set. This also means you may need to backup the status of @error in a variable if you are testing it in a While-WEnd loop.
The extended parameter is optional. It is provided as a way to set both @error and @extended at the same time. If only @extended needs to be set, then it is recommended to use the SetExtended() function instead.
The return value parameter is optional. It is provided as a way to use the Return SetError(...) syntax to define the value to be returned at the same time as setting @error (and possibly @extended). If a specific value is not set then the return value will be undefined and should not be used subsequently by the code.

@error is limited between the values of -2147483648 to 2147483647.

Related

SetExtended

Example

Example 1

#include <MsgBoxConstants.au3>

Local $fResult = myDiv(5, 0)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Error", "Division by Zero")
Else
    MsgBox($MB_SYSTEMMODAL, "Result", $fResult)
EndIf
Exit

Func myDiv($iDividend, $iDivisor)
    If $iDividend = 0 And $iDivisor = 0 Then
        SetError(2) ; Indeterminate form 0/0.
    ElseIf $iDivisor = 0 Then
        SetError(1) ; Plain division by zero.
    EndIf
    Return $iDividend / $iDivisor
EndFunc   ;==>myDiv

Example 2

#include <MsgBoxConstants.au3>

Local $sReturn = Example()

; Display the return value, @error and @extended value.
MsgBox($MB_SYSTEMMODAL, "", "Return value = " & $sReturn & @CRLF & _
        "Value of @error is: " & @error & @CRLF & _
        "Value of @extended is: " & @extended)

Func Example()
    Return SetError(3, 10, "Some return value") ; Set @error to 3, @extended to 10 and return the string "Some return value."
EndFunc   ;==>Example


Function SetExtended

Function Reference

SetExtended

Manually set the value of the @extended macro.

SetExtended ( code [, return value] )

Parameters

code | The required value (integer) to set into the @extended macro.
return value | [optional] The value to be returned by the function - if no parameter used the return value is undefined.

Return Value

Returns the "return value" parameter (undefined if the parameter is not used).
@extended will be set to the values set in the function call (default = 0)

Remarks

When entering a function @extended is set to 0. Unless SetExtended() is called, then @extended will remain 0 when the function ends. This means that in order for @extended to be set after a function returns, it must be explicitly set in the function. This also means you may need to backup the status of @extended in a variable if you are testing it in a While-WEnd loop.
The return value parameter is optional. It is provided as a way to use the Return SetExtended(...) syntax to define the value to be returned at the same time as setting @extended. If a specific value is not set then the return value will be undefined and should not be used subsequently by the code.

@extended is limited between the values of -2147483648 to 2147483647.

Related

SetError

Example

#include <MsgBoxConstants.au3>

SetExtended(10)
MsgBox($MB_SYSTEMMODAL, "", "Value of @extended is: " & @extended)


Function VarGetType

Function Reference

VarGetType

Returns the internal type representation of a variant.

VarGetType ( expression )

Parameters

expression An expression to check the internal type of.

Return Value

Returns a string representing the type of the expression.

Remarks

See language datatypes for a detailed description.

IsInt() can return different results as it tries to convert from a float, for example calling VarGetType() with a value of 2.0 will return "Double", but IsInt() will return 1 for the same value.

Related

IsArray, IsBinary, IsBool, IsDllStruct, IsFloat, IsFunc, IsHWnd, IsInt, IsKeyword, IsObj, IsPtr, IsString

Example

#include <MsgBoxConstants.au3>

Local $aArray[2] = [1, "Example"]
Local $mMap[]
Local $dBinary = Binary("0x00204060")
Local $bBoolean = False
Local $pPtr = Ptr(-1)
Local $hWnd = WinGetHandle(AutoItWinGetTitle())
Local $iInt = 1
Local $fFloat = 2.0
Local $oObject = ObjCreate("Scripting.Dictionary")
Local $sString = "Some text"
Local $tStruct = DllStructCreate("wchar[256]")
Local $vKeyword = Default
Local $fuFunc = ConsoleWrite
Local $fuUserFunc = Test

MsgBox($MB_SYSTEMMODAL, "", _
        "Variable Types" & @CRLF & @CRLF & _
        "$aArray : " & @TAB & @TAB & VarGetType($aArray) & " variable type." & @CRLF & _
        "$mMap : " & @TAB & @TAB & VarGetType($mMap) & " variable type." & @CRLF & _
        "$dBinary : " & @TAB & @TAB & VarGetType($dBinary) & " variable type." & @CRLF & _
        "$bBoolean : " & @TAB & VarGetType($bBoolean) & " variable type." & @CRLF & _
        "$pPtr : " & @TAB & @TAB & VarGetType($pPtr) & " variable type." & @CRLF & _
        "$hWnd : " & @TAB & @TAB & VarGetType($hWnd) & " variable type." & @CRLF & _
        "$iInt : " & @TAB & @TAB & VarGetType($iInt) & " variable type." & @CRLF & _
        "$fFloat : " & @TAB & @TAB & VarGetType($fFloat) & " variable type." & @CRLF & _
        "$oObject : " & @TAB & VarGetType($oObject) & " variable type." & @CRLF & _
        "$sString : " & @TAB & @TAB & VarGetType($sString) & " variable type." & @CRLF & _
        "$tStruct : " & @TAB & @TAB & VarGetType($tStruct) & " variable type." & @CRLF & _
        "$vKeyword : " & @TAB & VarGetType($vKeyword) & " variable type." & @CRLF & _
        "MsgBox : " & @TAB & @TAB & VarGetType(MsgBox) & " variable type." & @CRLF & _
        "$fuFunc : " & @TAB & @TAB & VarGetType($fuFunc) & " variable type." & @CRLF & _
        "Func 'Test' : " & @TAB & VarGetType(Test) & " variable type." & @CRLF & _
        "$fuUserFunc : " & @TAB & VarGetType($fuUserFunc) & " variable type.")

Func Test()
EndFunc   ;==>Test


Functions

Mouse functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
MouseClick | Perform a mouse click operation.
MouseClickDrag | Perform a mouse click and drag operation.
MouseDown | Perform a mouse down event at the current mouse position.
MouseGetCursor | Returns the cursor ID Number for the current Mouse Cursor.
MouseGetPos | Retrieves the current position of the mouse cursor.
MouseMove | Moves the mouse pointer.
MouseUp | Perform a mouse up event at the current mouse position.
MouseWheel | Moves the mouse wheel up or down.


Function MouseClick

Function Reference

MouseClick

Perform a mouse click operation.

MouseClick ( "button" [, x, y [, clicks = 1 [, speed = 10]]] )

Parameters

button | The button to click: $MOUSE_CLICK_RIGHT ("right") $MOUSE_CLICK_MIDDLE ("middle") $MOUSE_CLICK_MAIN ("main") $MOUSE_CLICK_MENU ("menu") $MOUSE_CLICK_PRIMARY ("primary") $MOUSE_CLICK_SECONDARY ("secondary") Constants are defined in "AutoItConstants.au3".
x, y | [optional] The x/y coordinates to move the mouse to. If no x and y coords are given, the current position is used (default).
clicks | [optional] The number of times to click the mouse. Default is 1.
speed | [optional] the speed to move the mouse in the range 1 (fastest) to 100 (slowest). A speed of 0 will move the mouse instantly. Default speed is 10.

Return Value

Success: | 1.
Failure: | 0, the button is not in the list or invalid parameter as x without y.

Remarks

If the button is an empty string, the left button will be clicked.
If x or y equal to the Default keyword no move occurs in the corresponding coordinate.

If the user has swapped the left and right mouse buttons in the control panel, then the behaviour of the buttons is different. "Left" and "right" always click those buttons, whether the buttons are swapped or not. The "primary" or "main" button will be the main click, whether or not the buttons are swapped. The "secondary" or "menu" buttons will usually bring up the context menu, whether the buttons are swapped or not.

Button | Normal | Swapped
"" | Left | Left
"left" | Left | Left
"middle" | Middle | Middle
"right" | Right | Right
"primary" | Left | Right
"main" | Left | Right
"secondary" | Right | Left
"menu" | Right | Left

Related

ControlClick, MouseClickDelay (Option), MouseClickDrag, MouseCoordMode (Option), MouseDown, MouseGetPos, MouseMove, MouseUp, MouseWheel

Example

#include <AutoItConstants.au3>

; Double click at the current mouse position.
MouseClick($MOUSE_CLICK_LEFT)
MouseClick($MOUSE_CLICK_LEFT)

; Double click at the x, y position of 0, 500.
MouseClick($MOUSE_CLICK_LEFT, 0, 500, 2)

; Double click at the x, y position of 0, 500. This is a better approach as it takes into account left/right handed users.
MouseClick($MOUSE_CLICK_PRIMARY, 0, 500, 2)


Function MouseClickDrag

Function Reference

MouseClickDrag

Perform a mouse click and drag operation.

MouseClickDrag ( "button", x1, y1, x2, y2 [, speed = 10] )

Parameters

button | The button to click: $MOUSE_CLICK_RIGHT ("right") $MOUSE_CLICK_MIDDLE ("middle") $MOUSE_CLICK_MAIN ("main") $MOUSE_CLICK_MENU ("menu") $MOUSE_CLICK_PRIMARY ("primary") $MOUSE_CLICK_SECONDARY ("secondary") Constants are defined in "AutoItConstants.au3".
x1, y1 | The x/y coords to start the drag operation from.
x2, y2 | The x/y coords to end the drag operation at.
speed | [optional] the speed to move the mouse in the range 1 (fastest) to 100 (slowest). A speed of 0 will move the mouse instantly. Default speed is 10.

Return Value

Success: | 1.
Failure: | 0, the button is not in the list.

Remarks

If the button is an empty string, the left button will be clicked.

If the user has swapped the left and right mouse buttons in the control panel, then the behaviour of the buttons is different. "Left" and "right" always click those buttons, whether the buttons are swapped or not. The "primary" or "main" button will be the main click, whether or not the buttons are swapped. The "secondary" or "menu" buttons will usually bring up the context menu, whether the buttons are swapped or not. See the table in MouseClick for more explanation

Related

MouseClick, MouseClickDragDelay (Option), MouseCoordMode (Option), MouseDown, MouseGetPos, MouseMove, MouseUp, MouseWheel

Example

#include <AutoItConstants.au3>

; Left click drag from 0, 200 to 600, 700

MouseClickDrag($MOUSE_CLICK_LEFT, 0, 200, 600, 700)


Function MouseDown

Function Reference

MouseDown

Perform a mouse down event at the current mouse position.

MouseDown ( "button" )

Parameters

button The button to click:
$MOUSE_CLICK_RIGHT ("right")
$MOUSE_CLICK_MIDDLE ("middle")
$MOUSE_CLICK_MAIN ("main")
$MOUSE_CLICK_MENU ("menu")
$MOUSE_CLICK_PRIMARY ("primary")
$MOUSE_CLICK_SECONDARY ("secondary")

Constants are defined in "AutoItConstants.au3".

Return Value

Success: | 1.
Failure: | 0, the button is not in the list.

Remarks

See MouseClick remarks.
User responsibility: For every MouseDown() there should eventually be a corresponding MouseUp() event.

Related

MouseClick, MouseClickDownDelay (Option), MouseClickDrag, MouseCoordMode (Option), MouseGetPos, MouseMove, MouseUp

Example

#include <AutoItConstants.au3>

MouseDown($MOUSE_CLICK_LEFT) ; Set the left mouse button state as down.
Sleep(100)
MouseUp($MOUSE_CLICK_LEFT) ; Set the left mouse button state as up.


Function MouseGetCursor

Function Reference

MouseGetCursor

Returns the cursor ID Number for the current Mouse Cursor.

MouseGetCursor ( )

Return Value

Returns a cursor ID Number:
-1 = UNKNOWN (@error can be set if the handle to the cursor cannot be found)
0 = HAND
1 = APPSTARTING
2 = ARROW
3 = CROSS
4 = HELP
5 = IBEAM
6 = ICON (Obsolete for applications marked version 4.0 or later)
7 = NO
8 = SIZE (Obsolete for applications marked version 4.0 or later)
9 = SIZEALL
10 = SIZENESW
11 = SIZENS
12 = SIZENWSE
13 = SIZEWE
14 = UPARROW
15 = WAIT

Related

MouseGetPos

Example

#include <MsgBoxConstants.au3>

Sleep(1000) ; Allow time for the cursor to change its state.

; Create an array of possible cursor states using StringSplit.
Local $aArray = StringSplit("Hand|AppStarting|Arrow|Cross|Help|IBeam|Icon (obsolete)|No|" & _
        "Size (obsolete)|SizeAll|SizeNESW|SizeNS|SizeNWSE|SizeWE|UpArrow|Wait|Empty", "|", 2) ; The flag parameter is set to flag = 2 as we don't require the total count of the array.
#cs
    The array returned will contain the following values:
    $aArray[0] = "Hand"
    $aArray[1] = "AppStarting"
    $aArray[2] = "Arrow"
    ...
    $aArray[16] = "Empty"
#ce

Local $iCursor = MouseGetCursor()
MsgBox($MB_SYSTEMMODAL, "CursorID = " & $iCursor, "Which means " & $aArray[$iCursor] & ".") ; Use the CursorID value as the index value of the array


Function MouseGetPos

Function Reference

MouseGetPos

Retrieves the current position of the mouse cursor.

MouseGetPos ( [dimension] )

Parameters

dimension [optional] argument that determines what the return value will be. See Return Value.

Return Value

Dimension | Values
None | Returns a two-element array containing the mouse coordinates: $aArray[0] = X coord (horizontal), $aArray[1] = Y coord (vertical)
0 | Returns the X co-ordinate as an integer.
1 | Returns the Y co-ordinate as an integer.

If dimension is not a number @error will be set to 1.

Remarks

See MouseCoordMode for relative/absolute position settings. If relative positioning, numbers may be negative.

Related

MouseClick, MouseClickDrag, MouseCoordMode (Option), MouseDown, MouseGetCursor, MouseMove, MouseUp, MouseWheel, PixelGetColor

Example

#include <MsgBoxConstants.au3>

Local $aPos = MouseGetPos()
MsgBox($MB_SYSTEMMODAL, "Mouse x, y:", $aPos[0] & ", " & $aPos[1])


Function MouseMove

Function Reference

MouseMove

Moves the mouse pointer.

MouseMove ( x, y [, speed = 10] )

Parameters

x | The screen x coordinate to move the mouse to.
y | The screen y coordinate to move the mouse to.
speed | [optional] the speed to move the mouse in the range 1 (fastest) to 100 (slowest). A speed of 0 will move the mouse instantly. Default speed is 10.

Return Value

None.

Remarks

User mouse movement is hindered during a non-instantaneous MouseMove() operation.
If MouseCoordMode is relative positioning, numbers may be negative.

Related

MouseClick, MouseClickDrag, MouseCoordMode (Option), MouseDown, MouseGetPos, MouseUp, MouseWheel

Example

MouseMove(10, 100) ; Move the mouse cursor to the x, y position of 10, 100.
MouseMove(700, 700, 0) ; Move the mouse cursor to the x, y position of 700, 700 and move instantly.


Function MouseUp

Function Reference

MouseUp

Perform a mouse up event at the current mouse position.

MouseUp ( "button" )

Parameters

button The button to click:
$MOUSE_CLICK_RIGHT ("right")
$MOUSE_CLICK_MIDDLE ("middle")
$MOUSE_CLICK_MAIN ("main")
$MOUSE_CLICK_MENU ("menu")
$MOUSE_CLICK_PRIMARY ("primary")
$MOUSE_CLICK_SECONDARY ("secondary")

Constants are defined in "AutoItConstants.au3".

Return Value

Success: | 1.
Failure: | 0, the button is not in the list.

Remarks

See MouseClick remarks.
User responsibility: For every MouseDown() there should eventually be a corresponding MouseUp() event.

Related

MouseClick, MouseClickDrag, MouseCoordMode (Option), MouseDown, MouseGetPos, MouseMove

Example

#include <AutoItConstants.au3>

MouseDown($MOUSE_CLICK_LEFT) ; Set the left mouse button state as down.
Sleep(100)
MouseUp($MOUSE_CLICK_LEFT) ; Set the left mouse button state as up.


Function MouseWheel

Function Reference

MouseWheel

Moves the mouse wheel up or down.

MouseWheel ( "direction" [, clicks = 1] )

Parameters

direction | The direction to move the wheel: $MOUSE_WHEEL_UP ("up") $MOUSE_WHEEL_DOWN ("down") Constants are defined in "AuoItConstants.au3".
clicks | [optional] The number of times to move the wheel. Default is 1.

Return Value

Success: | 1.
Failure: | 0, the direction is not recognized.

Related

MouseClick, MouseClickDrag, MouseCoordMode (Option), MouseGetPos, MouseMove

Example

#include <AutoItConstants.au3>

; Move the mouse wheel up ten times.

MouseWheel($MOUSE_WHEEL_UP, 10)


Functions

Network functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
FtpSetProxy | Sets the internet proxy to use for ftp access.
HttpSetProxy | Sets the internet proxy to use for http access.
HttpSetUserAgent | Sets the HTTP user-agent string which is sent with all Inet requests.
InetClose | Closes a handle returned from InetGet().
InetGet | Downloads a file from the internet using the HTTP, HTTPS or FTP protocol.
InetGetInfo | Returns detailed data for a handle returned from InetGet().
InetGetSize | Returns the size (in bytes) of a file located on the internet.
InetRead | Downloads a file from the internet using the HTTP, HTTPS or FTP protocol.
Ping | Pings a host and returns the roundtrip-time.
TCPAccept | Permits an incoming connection attempt on a socket.
TCPCloseSocket | Closes a TCP socket.
TCPConnect | Create a socket connected to an existing server.
TCPListen | Creates a socket listening for an incoming connection.
TCPNameToIP | Converts an Internet name to IP address.
TCPRecv | Receives data from a connected socket.
TCPSend | Sends data on a connected socket.
TCPShutdown, UDPShutdown | Stops TCP/UDP services.
TCPStartup, UDPStartup | Starts TCP or UDP services.
UDPBind | Create a socket bound to an incoming connection.
UDPCloseSocket | Close a UDP socket.
UDPOpen | Open a socket connected to an existing server .
UDPRecv | Receives data from an opened socket.
UDPSend | Sends data on an opened socket.


Function FtpSetProxy

Function Reference

FtpSetProxy

Sets the internet proxy to use for ftp access.

FtpSetProxy ( mode = 0 [, "proxy:port" [, "username" [, "password"]]] )

Parameters

mode | The proxy mode to use: $PROXY_IE (0) = (default) Use current Internet Explorer settings for proxy. $PROXY_NONE (1) = Use no proxy (direct access) $PROXY_SPECIFIED (2) = Use the proxy specified Constants are deined in "AutoItConstants.au3".
proxy:port | [optional] The address and port of the proxy to use. See remarks below.
username | [optional] If required, the username for the proxy
password | [optional] If required, the password for the proxy

Return Value

None.

Remarks

Internet Explorer 3 or greater must be installed for this function to work.

Only CERN proxy servers are supported.

Proxy servers are usually made up of a web address and port number. Most ISPs use the port number of 8080. If your proxy was "www.proxy.com" and port was "8080" then you would use this to set the proxy:
FtpSetProxy(2, "www.proxy.com:8080")

Most proxy servers do not require a username and password.

When using mode 0 you may specify a username and password and these will be used with the Internet Explorer configured proxy.

Related

HttpSetProxy, InetGet, InetGetSize, InetRead

Example

; Use no proxy
FtpSetProxy(1)

; Use IE defaults for proxy
FtpSetProxy(0)

; Use the proxy "www-cache.myisp.net" on port 8080
FtpSetProxy(2, "www-cache.myisp.net:8080")


Function HttpSetProxy

Function Reference

HttpSetProxy

Sets the internet proxy to use for http access.

HttpSetProxy ( mode = 0 [, "proxy:port" [, "username" [, "password"]]] )

Parameters

mode | The proxy mode to use: $PROXY_IE (0) = (default) Use current Internet Explorer settings for proxy. $PROXY_NONE (1) = Use no proxy (direct access) $PROXY_SPECIFIED (2) = Use the proxy specified Constants are deined in "AutoItConstants.au3".
proxy:port | [optional] The address and port of the proxy to use. See remarks below.
username | [optional] If required, the username for the proxy
password | [optional] If required, the password for the proxy

Return Value

None.

Remarks

Internet Explorer 3 or greater must be installed for this function to work.

Only CERN proxy servers are supported.

Proxy servers are usually made up of a web address and port number. Most ISPs use the port number of 8080. If your proxy was "www.proxy.com" and port was "8080" then you would use this to set the proxy:
HttpSetProxy(2, "www.proxy.com:8080")

Most proxy servers do not require a username and password.

When using mode 0 you may specify a username and password and these will be used with the Internet Explorer configured proxy.

Related

FtpSetProxy, InetGet, InetGetSize, InetRead

Example

; Use no proxy
HttpSetProxy(1)

; Use IE defaults for proxy
HttpSetProxy(0)

; Use the proxy "www-cache.myisp.net" on port 8080
HttpSetProxy(2, "www-cache.myisp.net:8080")


Function HttpSetUserAgent

Function Reference

HttpSetUserAgent

Sets the HTTP user-agent string which is sent with all Inet requests.

HttpSetUserAgent ( "user agent" )

Parameters

user agent The string to set as the user-agent. The default user-agent is "AutoIt". Passing an empty string will reset the user-agent back to the default.

Return Value

The previous user agent.

Related

InetGet, InetGetSize, InetRead

Example

HttpSetUserAgent("MyUserAgent")


Function InetClose

Function Reference

InetClose

Closes a handle returned from InetGet().

InetClose ( handle )

Parameters

handle A handle return from InetGet().

Return Value

True: | if the handle was found and closed.
False: | if not.

Remarks

InetGet() handles must be closed or resources will leak.

Closing the handle to a download still in progress will cancel the download.

Related

InetGet

Example

#include <InetConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Save the downloaded file to the temporary folder.
    Local $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Download the file in the background with the selected option of 'force a reload from the remote site.'
    Local $hDownload = InetGet("http://www.autoitscript.com/autoit3/files/beta/update.dat", $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)

    ; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

    ; Retrieve the number of total bytes received and the filesize.
    Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD)
    Local $iFileSize = FileGetSize($sFilePath)

    ; Close the handle returned by InetGet.
    InetClose($hDownload)

    ; Display details about the total number of bytes read and the filesize.
    MsgBox($MB_SYSTEMMODAL, "", "The total download size: " & $iBytesSize & @CRLF & _
            "The total filesize: " & $iFileSize)

    ; Delete the file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function InetGet

Function Reference

InetGet

Downloads a file from the internet using the HTTP, HTTPS or FTP protocol.

InetGet ( "URL", "filename" [, options = 0 [, background = 0]] )

Parameters

URL | URL of the file to download. See remarks below.
filename | Local filename to download to.
options | [optional]$INET_LOCALCACHE (0) = Get the file from local cache if available (default). $INET_FORCERELOAD (1) = Forces a reload from the remote site. $INET_IGNORESSL (2) = Ignore all SSL errors (with HTTPS connections). $INET_ASCIITRANSFER (4) = Use ASCII when transferring files with the FTP protocol (Can not be combined with flag $INET_BINARYTRANSFER (8)). $INET_BINARYTRANSFER (8) = Use BINARY when transferring files with the FTP protocol (Can not be combined with flag $INET_ASCIITRANSFER (4)). This is the default transfer mode if none are provided. $INET_FORCEBYPASS (16) = By-pass forcing the connection online (See remarks). Constants are defined in InetConstants.au3.
background | [optional] $INET_DOWNLOADWAIT (0) = Wait until the download is complete before continuing (default). $INET_DOWNLOADBACKGROUND (1) = return immediately and download in the background (see remarks). Constants are defined in InetConstants.au3

Return Value

Success: | the return value changes depending on if the download is in the background: Background: a handle is returned. Wait: the number of bytes downloaded.
Failure: | Background: a handle is returned. Wait: 0 and sets the flag to non-zero.

Remarks

Internet Explorer 3 or greater must be installed for this function to work.

Use the returned handle with InetGetInfo() to determine if there was an error with the download.
The returned handle must be closed with InetClose().

The URL parameter should be in the form "http://www.somesite.com/path/file.html" - just like an address you would type into your web browser.

To use a username and password when connecting simply prefix the servername with "username:password@", e.g.
"http://myuser:mypassword@www.somesite.com"

Notes about the "background" Parameter

By default the function waits until the download has finished before returning. If the background parameter is set to $INET_DOWNLOADBACKGROUND (1) the function returns immediately and the download continues in the background. The function InetGetInfo() can be used to check the status of the download. It takes the handle returned from InetGet().

Multiple downloads are supported if they are started in background mode.

To abort a download call InetClose() and pass it the handle returned by InetGet().

By default AutoIt forces a connection before starting a download. For dial-up users this will prompt to go online or dial the modem (depending on how the system is configured). The options value $INET_FORCEBYPASS (16) disables this behavior. Disabling the behavior can be useful for persistent connects (Broadband, LAN). However, it is also required to work around certain issues in Windows Vista and Windows 7.

Related

FtpSetProxy, HttpSetProxy, HttpSetUserAgent, InetClose, InetGetInfo, InetGetSize, InetRead

Example

Example 1

#include <InetConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

; Download a file in the background.
; Wait for the download to complete.

Example()

Func Example()
    ; Save the downloaded file to the temporary folder.
    Local $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Download the file in the background with the selected option of 'force a reload from the remote site.'
    Local $hDownload = InetGet("http://www.autoitscript.com/autoit3/files/beta/update.dat", $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)

    ; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

    ; Retrieve the number of total bytes received and the filesize.
    Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD)
    Local $iFileSize = FileGetSize($sFilePath)

    ; Close the handle returned by InetGet.
    InetClose($hDownload)

    ; Display details about the total number of bytes read and the filesize.
    MsgBox($MB_SYSTEMMODAL, "", "The total download size: " & $iBytesSize & @CRLF & _
            "The total filesize: " & $iFileSize)

    ; Delete the file.
    FileDelete($sFilePath)
EndFunc   ;==>Example

Example 2

#include <InetConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

; Download a file in the background.
; Wait for the download to complete.

Example()

Func Example()
    ; Save the downloaded file to the temporary folder.
    Local $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Download the file by waiting for it to complete. The option of 'get the file from the local cache' has been selected.
    Local $iBytesSize = InetGet("http://www.autoitscript.com/autoit3/files/beta/update.dat", $sFilePath, $INET_FORCERELOAD)

    ; Retrieve the filesize.
    Local $iFileSize = FileGetSize($sFilePath)

    ; Display details about the total number of bytes read and the filesize.
    MsgBox($MB_SYSTEMMODAL, "", "The total download size: " & $iBytesSize & @CRLF & _
            "The total filesize: " & $iFileSize)

    ; Delete the file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function InetGetInfo

Function Reference

InetGetInfo

Returns detailed data for a handle returned from InetGet().

InetGetInfo ( [handle [, index = -1]] )

Parameters

handle | [optional] A handle return from InetGet().
index | [optional] The index for the data to retrieve. If this value is -1 an array containing all of the below data will be returned. $INET_DOWNLOADREAD (0) - Bytes read so far (this is updated while the download progresses). $INET_DOWNLOADSIZE (1) - The size of the download in bytes (this may not always be present). $INET_DOWNLOADCOMPLETE (2) - Set to True if the download is complete, False if the download is still ongoing. $INET_DOWNLOADSUCCESS (3) - True if the download was successful. If this is False then the next data member will be non-zero. $INET_DOWNLOADERROR (4) - The error value for the download. The value itself is arbitrary. Testing that the value is non-zero is sufficient for determining if an error occurred. $INET_DOWNLOADEXTENDED (5) - The extended value for the download. The value is arbitrary and is primarily only useful to the AutoIt developers. Constants are defined in InetConstants.au3.

Return Value

Success: | the request data.
Failure: | an empty string and sets the @error flag to non-zero.

Remarks

If called with no arguments then the total number of active downloads will be returned.

This function can be called in a loop to query the number of bytes download or to pause until a download is complete.

Related

InetGet

Example

#include <InetConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Save the downloaded file to the temporary folder.
    Local $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Download the file in the background with the selected option of 'force a reload from the remote site.'
    Local $hDownload = InetGet("http://www.autoitscript.com/autoit3/files/beta/update.dat", $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)

    ; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
    Do
        Sleep(250)
    Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)

    ; Retrieve details about the download file.
    Local $aData = InetGetInfo($hDownload)
    If @error Then
        FileDelete($sFilePath)
        Return False ; If an error occurred then return from the function and delete the file.
    EndIf

    ; Close the handle returned by InetGet.
    InetClose($hDownload)

    ; Display details about the downloaded file.
    MsgBox($MB_SYSTEMMODAL, "", "Bytes read: " & $aData[$INET_DOWNLOADREAD] & @CRLF & _
            "Size: " & $aData[$INET_DOWNLOADSIZE] & @CRLF & _
            "Complete: " & $aData[$INET_DOWNLOADCOMPLETE] & @CRLF & _
            "successful: " & $aData[$INET_DOWNLOADSUCCESS] & @CRLF & _
            "@error: " & $aData[$INET_DOWNLOADERROR] & @CRLF & _
            "@extended: " & $aData[$INET_DOWNLOADEXTENDED] & @CRLF)

    ; Delete the file.
    FileDelete($sFilePath)
EndFunc   ;==>Example


Function InetGetSize

Function Reference

InetGetSize

Returns the size (in bytes) of a file located on the internet.

InetGetSize ( "URL" [, options = 0] )

Parameters

URL | URL of the file to download. See remarks below.
options | [optional] $INET_LOCALCACHE (0) = Get the file from local cache if available (default). $INET_FORCERELOAD (1) = Forces a reload from the remote site. $INET_IGNORESSL (2) = Ignore all SSL errors (with HTTPS connections). $INET_ASCIITRANSFER (4) = Use ASCII when transferring files with the FTP protocol (Can not be combined with flag $INET_BINARYTRANSFER (8)). $INET_BINARYTRANSFER (8) = Use BINARY when transferring files with the FTP protocol (Can not be combined with flag $INET_ASCIITRANSFER (4)). This is the default transfer mode if none are provided. Constants are defined in InetConstants.au3.

Return Value

Success: | the size of the file in bytes.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

Internet Explorer 3 or greater must be installed for this function to work. (For ftp:// URLs IE 5 is required!)

The URL parameter should be in the form "http://www.somesite.com/path/file.html" - just like an address you would type into your web browser.

To use a username and password when connecting simply prefix the servername with "username:password@", e.g.
"http://myuser:mypassword@www.somesite.com"

Not all servers will correctly give the file size, especially when using a proxy server.

Related

FtpSetProxy, HttpSetProxy, HttpSetUserAgent, InetGet, InetRead

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Retrieve the size of the file. The option of 'get the file from the local cache' has been selected.
    Local $iSize = InetGetSize("http://www.autoitscript.com/autoit3/files/beta/update.dat")
    MsgBox($MB_SYSTEMMODAL, "", "The size of the file: " & $iSize)
EndFunc   ;==>Example


Function InetRead

Function Reference

InetRead

Downloads a file from the internet using the HTTP, HTTPS or FTP protocol.

InetRead ( "URL" [, options = 0] )

Parameters

URL | URL of the file to download. See remarks below.
options | [optional] $INET_LOCALCACHE (0) = Get the file from local cache if available (default). $INET_FORCERELOAD (1) = Forces a reload from the remote site. $INET_IGNORESSL (2) = Ignore all SSL errors (with HTTPS connections). $INET_ASCIITRANSFER (4) = Use ASCII when transferring files with the FTP protocol (Can not be combined with flag $INET_BINARYTRANSFER (8)). $INET_BINARYTRANSFER (8) = Use BINARY when transferring files with the FTP protocol (Can not be combined with flag $INET_ASCIITRANSFER (4)). This is the default transfer mode if none are provided. $INET_FORCEBYPASS (16) = By-pass forcing the connection online (See remarks). Constants are defined in InetConstants.au3.

Return Value

Success: | a binary string and @extended set to the number of bytes downloaded.
Failure: | "" (empty string) and sets the @error flag to non-zero.

Remarks

Internet Explorer 3 or greater must be installed for this function to work.

The URL parameter should be in the form "http://www.somesite.com/path/file.html" - just like an address you would type into your web browser.

To use a username and password when connecting simply prefix the servername with "username:password@", e.g.
"http://myuser:mypassword@www.somesite.com"

The returned data is in binary format. The BinaryToString() function can be used to convert the data to a string.

By default AutoIt forces a connection before starting a download. For dial-up users this will prompt to go online or dial the modem (depending on how the system is configured). The options value $INET_FORCEBYPASS (16) disables this behavior. Disabling the behavior can be useful for persistent connects (Broadband, LAN). However, it is also required to work around certain issues in Windows Vista and Windows 7.

Related

FtpSetProxy, HttpSetProxy, HttpSetUserAgent, InetGet, InetGetSize

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Read the file without downloading to a folder. The option of 'get the file from the local cache' has been selected.
    Local $dData = InetRead("http://www.autoitscript.com/autoit3/files/beta/update.dat")

    ; The number of bytes read is returned using the @extended macro.
    Local $iBytesRead = @extended

    ; Convert the ANSI compatible binary string back into a string.
    Local $sData = BinaryToString($dData)

    ; Display the results.
    MsgBox($MB_SYSTEMMODAL, "", "The number of bytes read: " & $iBytesRead & @CRLF & @CRLF & $sData)
EndFunc   ;==>Example


Function Ping

Function Reference

Ping

Pings a host and returns the roundtrip-time.

Ping ( "address/hostname" [, timeout = 4000] )

Parameters

address/hostname | Can be i.e. "www.autoitscript.com" or "87.106.244.38".
timeout | [optional] Is the time to wait for an answer in milliseconds (default is 4000).

Return Value

Success: | the roundtrip-time in milliseconds ( greater than 0 ).
Failure: | 0 if host is not pingable or other network errors occurred and sets the @error flag to non-zero.
@error: | 1 = Host is offline 2 = Host is unreachable 3 = Bad destination 4 = Other errors

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Ping the AutoIt website with a timeout of 250ms.
    Local $iPing = Ping("autoitscript.com", 250)

    If $iPing Then ; If a value greater than 0 was returned then display the following message.
        MsgBox($MB_SYSTEMMODAL, "", "The roundtrip-time took: " & $iPing & "ms.")
    Else
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred with @error value of: " & @error)
    EndIf
EndFunc   ;==>Example


Function TCPAccept

Function Reference

TCPAccept

Permits an incoming connection attempt on a socket.

TCPAccept ( mainsocket )

Parameters

mainsocket The main socket identifier (SocketID) as returned by a TCPListen() function.

Return Value

Success: | the connected socket identifier.
Failure: | -1 and sets the @error flag to non-zero.
@error: | -2 not connected. Windows API WSAGetError return value (see MSDN).

Related

TCPCloseSocket, TCPListen, TCPRecv, TCPStartup, TCPTimeout (Option)

Example

Example 1

#include <MsgBoxConstants.au3>

; I am the server, start me first! (Start in second the TCPConnect example script).

Example()

Func Example()
    TCPStartup() ; Start the TCP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")

    ; Assign Local variables the loopback IP Address and the Port.
    Local $sIPAddress = "127.0.0.1" ; This IP Address only works for testing on your own computer.
    Local $iPort = 65432 ; Port used for the connection.

    ; Bind to the IP Address and Port specified with a maximum of 100 pending connexions
    ;(Take a look at the example of this function for further details).
    Local $iListenSocket = TCPListen($sIPAddress, $iPort, 100)
    Local $iError = 0

    ; If an error occurred display the error code and return False.
    If @error Then
        ; Someone is probably already listening on this IP Address and Port (script already running?).
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not listen, Error code: " & $iError)
        Return False
    EndIf

    ; Assign Local variable to be used by Listening and Client sockets.
    Local $iSocket = 0
    Do ; Wait for someone to connect (Unlimited).
        ; Accept incomming connexions if present (Socket to close when finished; one socket per client).
        $iSocket = TCPAccept($iListenSocket)

        ; If an error occurred display the error code and return False.
        If @error Then
            $iError = @error
            MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not accept the incoming connection, Error code: " & $iError)
            Return False
        EndIf
    Until $iSocket <> -1 ;if different from -1 a client is connected.

    ; Close the Listening socket to allow afterward binds.
    TCPCloseSocket($iListenSocket)

    MsgBox($MB_SYSTEMMODAL, "", "Client Connected.")

    ; Close the socket.
    TCPCloseSocket($iSocket)
EndFunc   ;==>Example

Func OnAutoItExit()
    TCPShutdown() ; Close the TCP service.
EndFunc   ;==>OnAutoItExit

Example 2

#include <MsgBoxConstants.au3>

; Note: Check the Example 1 to get the useful comments, this example only demonstrates the SocketToIP user-defined function.

; I am the server, start me first! (Start in second the TCPConnect example script).

Example()

Func Example()
    TCPStartup()

    OnAutoItExitRegister("OnAutoItExit")

    Local $sIPAddress = "127.0.0.1"
    Local $iPort = 65432

    Local $iListenSocket = TCPListen($sIPAddress, $iPort, 100)
    Local $iError = 0

    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not listen, Error code: " & $iError)
        Return False
    EndIf

    Local $iSocket = 0
    Do
        $iSocket = TCPAccept($iListenSocket)

        If @error Then
            $iError = @error
            MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not accept the incoming connection, Error code: " & $iError)
            Return False
        EndIf
    Until $iSocket <> -1

    TCPCloseSocket($iListenSocket)

    ; Retrieve the IP Address associated with the accepted socket and assign it to a Local variable.
    Local $sClientIPAddress = SocketToIP($iSocket)

    ; Note: The above function does NOT work with the Listen socket, you can also use it with the socket returned by the TCPConnect function.

    ; Display the sucessful message with the client IP Address.
    MsgBox($MB_SYSTEMMODAL, "", "Client Connected, IP Address: " & $sClientIPAddress)

    TCPCloseSocket($iSocket)
EndFunc   ;==>Example

Func SocketToIP($iSocket)
    Local $tSockAddr = 0, $aRet = 0
    $tSockAddr = DllStructCreate("short;ushort;uint;char[8]")
    $aRet = DllCall("Ws2_32.dll", "int", "getpeername", "int", $iSocket, "struct*", $tSockAddr, "int*", DllStructGetSize($tSockAddr))
    If Not @error And $aRet[0] = 0 Then
        $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "int", DllStructGetData($tSockAddr, 3))
        If Not @error Then Return $aRet[0]
    EndIf
    Return 0
EndFunc   ;==>SocketToIP

Func OnAutoItExit()
    TCPShutdown() ; Close the TCP service.
EndFunc   ;==>OnAutoItExit


Function TCPCloseSocket

Function Reference

TCPCloseSocket

Closes a TCP socket.

TCPCloseSocket ( socket )

Parameters

socket The socket identifier (SocketID) as returned by a TCPListen(),TCPConnect() or TCPAccept() functions.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | Windows API WSAGetError return value (see MSDN).

Related

TCPAccept, TCPConnect, TCPListen, TCPShutdown, TCPStartup

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

; Start First clicking on "1. Server"
; Then start a second instance of the script selecting "2. Client"

Example()

Func Example()
    TCPStartup() ; Start the TCP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")

    ; Assign Local variables the loopback IP Address and the Port.
    Local $sIPAddress = "127.0.0.1" ; This IP Address only works for testing on your own computer.
    Local $iPort = 65432 ; Port used for the connection.

    #Region GUI
    Local $sTitle = "TCP Start"
    Local $hGUI = GUICreate($sTitle, 250, 70)

    Local $idBtnServer = GUICtrlCreateButton("1. Server", 65, 10, 130, 22)

    Local $idBtnClient = GUICtrlCreateButton("2. Client", 65, 40, 130, 22)

    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idBtnServer
                WinSetTitle($sTitle, "", "TCP Server started")
                GUICtrlSetState($idBtnClient, $GUI_HIDE)
                GUICtrlSetState($idBtnServer, $GUI_DISABLE)
                If Not MyTCP_Server($sIPAddress, $iPort) Then ExitLoop
            Case $idBtnClient
                WinSetTitle($sTitle, "", "TCP Client started")
                GUICtrlSetState($idBtnServer, $GUI_HIDE)
                GUICtrlSetState($idBtnClient, $GUI_DISABLE)
                If Not MyTCP_Client($sIPAddress, $iPort) Then ExitLoop
        EndSwitch

        Sleep(10)
    WEnd

    #EndRegion GUI
EndFunc   ;==>Example

Func MyTCP_Client($sIPAddress, $iPort)
    ; Assign a Local variable the socket and connect to a listening socket with the IP Address and Port specified.
    Local $iSocket = TCPConnect($sIPAddress, $iPort)
    Local $iError = 0

    ; If an error occurred display the error code and return False.
    If @error Then
        ; The server is probably offline/port is not opened on the server.
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not connect, Error code: " & $iError)
        Return False
    EndIf

    ; Send the string "tata" to the server.
    TCPSend($iSocket, "tata")

    ; If an error occurred display the error code and return False.
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not send the data, Error code: " & $iError)
        Return False
    EndIf

    ; Close the socket.
    TCPCloseSocket($iSocket)
EndFunc   ;==>MyTCP_Client

Func MyTCP_Server($sIPAddress, $iPort)
    ; Assign a Local variable the socket and bind to the IP Address and Port specified with a maximum of 100 pending connexions.
    Local $iListenSocket = TCPListen($sIPAddress, $iPort, 100)
    Local $iError = 0

    If @error Then
        ; Someone is probably already listening on this IP Address and Port (script already running?).
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not listen, Error code: " & $iError)
        Return False
    EndIf

    ; Assign a Local variable to be used by the Client socket.
    Local $iSocket = 0

    Do ; Wait for someone to connect (Unlimited).
        ; Accept incomming connexions if present (Socket to close when finished; one socket per client).
        $iSocket = TCPAccept($iListenSocket)

        ; If an error occurred display the error code and return False.
        If @error Then
            $iError = @error
            MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not accept the incoming connection, Error code: " & $iError)
            Return False
        EndIf

        If GUIGetMsg() = $GUI_EVENT_CLOSE Then Return False
    Until $iSocket <> -1 ;if different from -1 a client is connected.

    ; Close the Listening socket to allow afterward binds.
    TCPCloseSocket($iListenSocket)

    ; Assign a Local variable the data received.
    Local $sReceived = TCPRecv($iSocket, 4) ;we're waiting for the string "tata" OR "toto" (example script TCPRecv): 4 bytes length.

    ; Notes: If you don't know how much length will be the data,
    ; use e.g: 2048 for maxlen parameter and call the function until the it returns nothing/error.

    ; Display the string received.
    MsgBox($MB_SYSTEMMODAL, "", "Server:" & @CRLF & "Received: " & $sReceived)

    ; Close the socket.
    TCPCloseSocket($iSocket)
EndFunc   ;==>MyTCP_Server

Func OnAutoItExit()
    TCPShutdown() ; Close the TCP service.
EndFunc   ;==>OnAutoItExit


Function TCPConnect

Function Reference

TCPConnect

Create a socket connected to an existing server.

TCPConnect ( IPAddr, port )

Parameters

IPAddr | Internet Protocol dotted address(IpV4) as "192.162.1.1".
port | port on which the created socket will be connected.

Return Value

Success: | the main socket identifier.
Failure: | -1 or 0 and sets the @error flag to non-zero.
@error: | -2 not connected. 1 IPAddr is incorrect. 2 port is incorrect. 10060 Connection timed out. A connection attempt failed because the connected party did not properly respond after a period of time, or the established connection failed because the connected host has failed to respond. See connect timeout example. Windows API WSAGetError return value (see MSDN).

Remarks

This function is used by a client to communicate with the server.

Related

TCPListen, TCPRecv, TCPSend, TCPStartup, TCPTimeout (Option)

Example

Example 1

#include <MsgBoxConstants.au3>

; I am the client, start me after the server! (Start first the TCPAccept example script).

Example()

Func Example()
    TCPStartup() ; Start the TCP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")

    ; Assign Local variables the loopback IP Address and the Port.
    Local $sIPAddress = "127.0.0.1" ; This IP Address only works for testing on your own computer.
    Local $iPort = 65432 ; Port used for the connection.

    ; Assign a Local variable the socket and connect to a Listening socket with the IP Address and Port specified.
    Local $iSocket = TCPConnect($sIPAddress, $iPort)

    ; If an error occurred display the error code and return False.
    If @error Then
        ; The server is probably offline/port is not opened on the server.
        Local $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not connect, Error code: " & $iError)
        Return False
    Else
        MsgBox($MB_SYSTEMMODAL, "", "Connection successful")
    EndIf

    ; Close the socket.
    TCPCloseSocket($iSocket)
EndFunc   ;==>Example

Func OnAutoItExit()
    TCPShutdown() ; Close the TCP service.
EndFunc   ;==>OnAutoItExit

TCPConnect with timeout

#include <MsgBoxConstants.au3>

; I am the client, start me after the server no more than 10sec ! (The server script is the TCPAccept example script).

Example()

Func Example()
    TCPStartup() ; Start the TCP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")

    ; Assign Local variables the loopback IP Address and the Port.
    Local $sIPAddress = "127.0.0.1" ; This IP Address only works for testing on your own computer.
    Local $iPort = 65432 ; Port used for the connection.

    Opt("TCPTimeout", 1000)
    Local $nMaxTimeout = 10 ; script will abort if no server available after 10 secondes

    Local $iSocket, $iError

    While 1
        ; Assign a Local variable the socket and connect to a Listening socket with the IP Address and Port specified.
        $iSocket = TCPConnect($sIPAddress, $iPort)

        ; If an error occurred display the error code and return False.
        If @error = 10060 Then
            ; Timeout occurs try again
            $nMaxTimeout -= 1
            If $nMaxTimeout < 0 Then
                MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not connect, after " & 10 - $nMaxTimeout & " TimeOut")
                Return False
            EndIf
            ContinueLoop
        ElseIf @error Then
            $iError = @error
            ; The server is probably offline/port is not opened on the server.
            MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not connect, Error code: " & $iError)
            Return False
        Else
            MsgBox($MB_SYSTEMMODAL, "", "Connection successful after " & 10 - $nMaxTimeout & " TimeOut")
            ExitLoop
        EndIf

    WEnd

    ; Close the socket.
    TCPCloseSocket($iSocket)
EndFunc   ;==>Example

Func OnAutoItExit()
    TCPShutdown() ; Close the TCP service.
EndFunc   ;==>OnAutoItExit


Function TCPListen

Function Reference

TCPListen

Creates a socket listening for an incoming connection.

TCPListen ( IPAddr, port [, MaxPendingConnection] )

Parameters

IPAddr | Internet Protocol dotted address(IpV4) as "192.162.1.1".
port | port on which the created socket will be connected.
MaxPendingConnection | [optional] Maximum length of the queue of pending connections. By default the maximum reasonable value will be set.

Return Value

Success: | the main socket identifier.
Failure: | -1 or 0 and sets the @error flag to non-zero.
@error: | 1 IPAddr is incorrect. 2 port is incorrect. Windows API WSAGetError return value (see MSDN).

Related

TCPAccept, TCPCloseSocket, TCPConnect, TCPSend, TCPShutdown, TCPStartup, TCPTimeout (Option)

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    TCPStartup() ; Start the TCP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")

    ; Assign Local variables the loopback IP Address and the Port.
    Local $sIPAddress = "127.0.0.1" ; This IP Address only works for testing on your own computer.
    Local $iPort = 65432 ; Port used for the connection.

    ; Assign a Local variable the Listening socket and bind to the IP Address and Port specified with a maximum of 100 pending connexions.
    Local $iListenSocket = TCPListen($sIPAddress, $iPort, 100)

    ; Notes: You can only listen on private IPs, such as the one used here;
    ; or on the range of 192 to 223 (generally 192.168.X.X, use @IPAddress1 to test on your local IP [you will need another computer]).
    ; The Listen socket identifier is only used for the TCP Accept function.

    ; If an error occurred display the error code and return False.
    If @error Then
        ; Someone is probably already listening on this IP Address and Port (script already running?).
        Local $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not listen, Error code: " & $iError)
        Return False
    Else
        MsgBox($MB_SYSTEMMODAL, "", "Listen successful.")
    EndIf

    ; Close the Listening socket to allow afterward binds.
    ; While not closed, any other program can NOT bind to the same IP Address and Port.
    TCPCloseSocket($iListenSocket)
EndFunc   ;==>Example

Func OnAutoItExit()
    TCPShutdown() ; Close the TCP service.
EndFunc   ;==>OnAutoItExit


Function TCPNameToIP

Function Reference

TCPNameToIP

Converts an Internet name to IP address.

TCPNameToIP ( name )

Parameters

name String containing an Internet name.

Return Value

Success: | a string containing IP address corresponding to the name.
Failure: | "" and sets the @error flag to non-zero.
@error: | Windows API WSAGetError return value (see MSDN).

Remarks

TCPStartup() is needed before this call.

Related

TCPStartup

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Start the TCP service.
    TCPStartup()

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")

    ; Assign a Local variable the IP address of www.autoitscript.com.
    Local $sIPAddress = TCPNameToIP("www.autoitscript.com")

    ; If an error occurred display the error code and return False.
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "Error code: " & @error)
        Return False
    Else
        ; Display the IP address.
        MsgBox($MB_SYSTEMMODAL, "", "Domain name to IP :" & $sIPAddress)
    EndIf
EndFunc   ;==>Example

Func OnAutoItExit()
    TCPShutdown() ; Close the TCP service.
EndFunc   ;==>OnAutoItExit


Function TCPRecv

Function Reference

TCPRecv

Receives data from a connected socket.

TCPRecv ( mainsocket, maxlen [, flag = 0] )

Parameters

mainsocket | The connected socket identifier (SocketID) as returned by a TCPAccept() or a TCPConnect() function.
maxlen | max # of characters to receive.
flag | [optional] Forces the function to return binary data if set to 1 (default is 0, and will auto detect between binary/string). $TCP_DATA_DEFAULT (0) - (Default) will auto detect between binary/string $TCP_DATA_BINARY (1) - return binary data Constants are defined in "AutoItConstants.au3".

Return Value

Success: | the binary/string sent by the connected socket.
Failure: | "" and sets the @error flag to non-zero.
@error: | -1 invalid socket. -2 not connected. Windows API WSAGetError return value (see MSDN).
@extended: | 1 no byte received.

Remarks

For backwards compatibility reasons this function will try to return strings by default. If null (0x00) characters are received then the return value will be a binary type.
To force the function to always return binary data (the most sensible option) then use the "flag" parameter set to 1.
If Unicode strings need to be transmitted they must be encoded/decoded with StringToBinary()/BinaryToString().

Related

BinaryLen, BinaryMid, BinaryToString, TCPAccept, TCPConnect, TCPSend, TCPStartup, TCPTimeout (Option)

Example

Example 1

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

; Start First clicking on "1. Server"
; Then start a second instance of the script selecting "2. Client"

Example()

Func Example()
    TCPStartup() ; Start the TCP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")

    ; Assign Local variables the loopback IP Address and the Port.
    Local $sIPAddress = "127.0.0.1" ; This IP Address only works for testing on your own computer.
    Local $iPort = 65432 ; Port used for the connection.

    #Region GUI
    Local $sTitle = "TCP Start"
    Local $hGUI = GUICreate($sTitle, 250, 70)

    Local $idBtnServer = GUICtrlCreateButton("1. Server", 65, 10, 130, 22)

    Local $idBtnClient = GUICtrlCreateButton("2. Client", 65, 40, 130, 22)

    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idBtnServer
                WinSetTitle($sTitle, "", "TCP Server started")
                GUICtrlSetState($idBtnClient, $GUI_HIDE)
                GUICtrlSetState($idBtnServer, $GUI_DISABLE)
                If Not MyTCP_Server($sIPAddress, $iPort) Then ExitLoop
            Case $idBtnClient
                WinSetTitle($sTitle, "", "TCP Client started")
                GUICtrlSetState($idBtnServer, $GUI_HIDE)
                GUICtrlSetState($idBtnClient, $GUI_DISABLE)
                If Not MyTCP_Client($sIPAddress, $iPort) Then ExitLoop
        EndSwitch

        Sleep(10)
    WEnd

    #EndRegion GUI
EndFunc   ;==>Example

Func MyTCP_Client($sIPAddress, $iPort)
    ; Assign a Local variable the socket and connect to a listening socket with the IP Address and Port specified.
    Local $iSocket = TCPConnect($sIPAddress, $iPort)
    Local $iError = 0

    ; If an error occurred display the error code and return False.
    If @error Then
        ; The server is probably offline/port is not opened on the server.
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not connect, Error code: " & $iError)
        Return False
    EndIf

    ; Send the string "tata" to the server.
    TCPSend($iSocket, "tata")

    ; If an error occurred display the error code and return False.
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not send the data, Error code: " & $iError)
        Return False
    EndIf

    ; Close the socket.
    TCPCloseSocket($iSocket)
EndFunc   ;==>MyTCP_Client

Func MyTCP_Server($sIPAddress, $iPort)
    ; Assign a Local variable the socket and bind to the IP Address and Port specified with a maximum of 100 pending connexions.
    Local $iListenSocket = TCPListen($sIPAddress, $iPort, 100)
    Local $iError = 0

    If @error Then
        ; Someone is probably already listening on this IP Address and Port (script already running?).
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not listen, Error code: " & $iError)
        Return False
    EndIf

    ; Assign a Local variable to be used by the Client socket.
    Local $iSocket = 0

    Do ; Wait for someone to connect (Unlimited).
        ; Accept incomming connexions if present (Socket to close when finished; one socket per client).
        $iSocket = TCPAccept($iListenSocket)

        ; If an error occurred display the error code and return False.
        If @error Then
            $iError = @error
            MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not accept the incoming connection, Error code: " & $iError)
            Return False
        EndIf

        If GUIGetMsg() = $GUI_EVENT_CLOSE Then Return False
    Until $iSocket <> -1 ;if different from -1 a client is connected.

    ; Close the Listening socket to allow afterward binds.
    TCPCloseSocket($iListenSocket)

    ; Assign a Local variable the data received.
    Local $sReceived = TCPRecv($iSocket, 4) ;we're waiting for the string "tata" OR "toto" (example script TCPRecv): 4 bytes length.

    ; Notes: If you don't know how much length will be the data,
    ; use e.g: 2048 for maxlen parameter and call the function until the it returns nothing/error.

    ; Display the string received.
    MsgBox($MB_SYSTEMMODAL, "", "Server:" & @CRLF & "Received: " & $sReceived)

    ; Close the socket.
    TCPCloseSocket($iSocket)
EndFunc   ;==>MyTCP_Server

Func OnAutoItExit()
    TCPShutdown() ; Close the TCP service.
EndFunc   ;==>OnAutoItExit

Example 2

; I am the client, start me after the server! (Start first the example 2 of the TCPSend function).

#include <AutoItConstants.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    TCPStartup() ; Start the TCP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")

    ; Assign Local variables the loopback IP Address and the Port.
    Local $sIPAddress = "127.0.0.1" ; This IP Address only works for testing on your own computer.
    Local $iPort = 65432 ; Port used for the connection.

    ; Assign a Local variable the socket and connect to a listening socket with the IP Address and Port specified.
    Local $iSocket = TCPConnect($sIPAddress, $iPort)
    Local $iError = 0

    ; If an error occurred display the error code and return False.
    If @error Then
        ; The server is probably offline/port is not opened on the server.
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not connect, Error code: " & $iError)
        Return False
    EndIf

    ; Assign a Local variable the path of the file which will be received.
    Local $sFilePath = FileSaveDialog("Save as", @MyDocumentsDir, "All types (*.*)", BitOR($FD_PATHMUSTEXIST, $FD_PROMPTOVERWRITE))

    ; If an error occurred display the error code and return False.
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONEXCLAMATION), "", "Client:" & @CRLF & "Invalid file chosen, Error code: " & $iError)
        Return False
    EndIf

    ; Assign a Local variable the handle of the file opened in binary overwrite mode.
    Local $hFile = FileOpen($sFilePath, BitOR($FO_BINARY, $FO_OVERWRITE))

    ; Assign Locales Constant variables the number representing 4 KiB; the binary code for the end of the file and the length of the binary code.
    Local Const $i4KiB = 4096, $bEOF = Binary(@CRLF & "{EOF}"), $iEOFLen = BinaryLen($bEOF)

    ; Assign a Local variable the empty binary data which will contain the binary data of the file.
    Local $bData = Binary("")

    ; Assign a Local variable to store the length of the data received.
    Local $iDataLen = 0

    ; Assign a Local variable a boolean.
    Local $bEOFReached = False

    Do
        $bData = TCPRecv($iSocket, $i4KiB, $TCP_DATA_BINARY)

        ; If an error occurred display the error code and return False.
        If @error Then
            $iError = @error
            MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Connection lost, Error code: " & $iError)
            Return False
        EndIf

        $iDataLen = BinaryLen($bData)

        ; If nothing is received, retry for the incoming data.
        If $iDataLen = 0 Then ContinueLoop

        ; If the end of the file is reached.
        If BinaryMid($bData, 1 + $iDataLen - $iEOFLen, $iEOFLen) = $bEOF Then
            ; Strip the EOF code from the file data.
            $bData = BinaryMid($bData, 1, $iDataLen - $iEOFLen)

            ; Set the EOFReached to True.
            $bEOFReached = True
        EndIf

        FileWrite($hFile, $bData)
    Until $bEOFReached

    ; Close the file handle.
    FileClose($hFile)

    ; Display the successful message.
    MsgBox($MB_SYSTEMMODAL, "", "Client:" & @CRLF & "File received.")

    ; Close the socket.
    TCPCloseSocket($iSocket)
EndFunc   ;==>Example

Func OnAutoItExit()
    TCPShutdown() ; Close the TCP service.
EndFunc   ;==>OnAutoItExit


Function TCPSend

Function Reference

TCPSend

Sends data on a connected socket.

TCPSend ( mainsocket, data )

Parameters

mainsocket | The connected socket identifier (SocketID) as returned by a TCPConnect() function.
data | binary/string to be send to the connected socket.

Return Value

Success: | the number of bytes sent to the connected socket.
Failure: | 0 and sets the @error flag to non-zero.
@error: | Windows API WSAGetError return value (see MSDN).

Remarks

If Unicode strings need to be transmitted they must be encoded/decoded with StringToBinary()/BinaryToString().

Related

StringToBinary, TCPConnect, TCPListen, TCPRecv, TCPStartup, TCPTimeout (Option)

Example

Example 1

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

; Start First clicking on "1. Server"
; Then start a second instance of the script selecting "2. Client"

Example()

Func Example()
    TCPStartup() ; Start the TCP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")

    ; Assign Local variables the loopback IP Address and the Port.
    Local $sIPAddress = "127.0.0.1" ; This IP Address only works for testing on your own computer.
    Local $iPort = 65432 ; Port used for the connection.

    #Region GUI
    Local $sTitle = "TCP Start"
    Local $hGUI = GUICreate($sTitle, 250, 70)

    Local $idBtnServer = GUICtrlCreateButton("1. Server", 65, 10, 130, 22)

    Local $idBtnClient = GUICtrlCreateButton("2. Client", 65, 40, 130, 22)

    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idBtnServer
                WinSetTitle($sTitle, "", "TCP Server started")
                GUICtrlSetState($idBtnClient, $GUI_HIDE)
                GUICtrlSetState($idBtnServer, $GUI_DISABLE)
                If Not MyTCP_Server($sIPAddress, $iPort) Then ExitLoop
            Case $idBtnClient
                WinSetTitle($sTitle, "", "TCP Client started")
                GUICtrlSetState($idBtnServer, $GUI_HIDE)
                GUICtrlSetState($idBtnClient, $GUI_DISABLE)
                If Not MyTCP_Client($sIPAddress, $iPort) Then ExitLoop
        EndSwitch

        Sleep(10)
    WEnd

    #EndRegion GUI
EndFunc   ;==>Example

Func MyTCP_Client($sIPAddress, $iPort)
    ; Assign a Local variable the socket and connect to a listening socket with the IP Address and Port specified.
    Local $iSocket = TCPConnect($sIPAddress, $iPort)
    Local $iError = 0

    ; If an error occurred display the error code and return False.
    If @error Then
        ; The server is probably offline/port is not opened on the server.
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not connect, Error code: " & $iError)
        Return False
    EndIf

    ; Send the string "tata" to the server.
    TCPSend($iSocket, "tata")

    ; If an error occurred display the error code and return False.
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not send the data, Error code: " & $iError)
        Return False
    EndIf

    ; Close the socket.
    TCPCloseSocket($iSocket)
EndFunc   ;==>MyTCP_Client

Func MyTCP_Server($sIPAddress, $iPort)
    ; Assign a Local variable the socket and bind to the IP Address and Port specified with a maximum of 100 pending connexions.
    Local $iListenSocket = TCPListen($sIPAddress, $iPort, 100)
    Local $iError = 0

    If @error Then
        ; Someone is probably already listening on this IP Address and Port (script already running?).
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not listen, Error code: " & $iError)
        Return False
    EndIf

    ; Assign a Local variable to be used by the Client socket.
    Local $iSocket = 0

    Do ; Wait for someone to connect (Unlimited).
        ; Accept incomming connexions if present (Socket to close when finished; one socket per client).
        $iSocket = TCPAccept($iListenSocket)

        ; If an error occurred display the error code and return False.
        If @error Then
            $iError = @error
            MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not accept the incoming connection, Error code: " & $iError)
            Return False
        EndIf

        If GUIGetMsg() = $GUI_EVENT_CLOSE Then Return False
    Until $iSocket <> -1 ;if different from -1 a client is connected.

    ; Close the Listening socket to allow afterward binds.
    TCPCloseSocket($iListenSocket)

    ; Assign a Local variable the data received.
    Local $sReceived = TCPRecv($iSocket, 4) ;we're waiting for the string "tata" OR "toto" (example script TCPRecv): 4 bytes length.

    ; Notes: If you don't know how much length will be the data,
    ; use e.g: 2048 for maxlen parameter and call the function until the it returns nothing/error.

    ; Display the string received.
    MsgBox($MB_SYSTEMMODAL, "", "Server:" & @CRLF & "Received: " & $sReceived)

    ; Close the socket.
    TCPCloseSocket($iSocket)
EndFunc   ;==>MyTCP_Server

Func OnAutoItExit()
    TCPShutdown() ; Close the TCP service.
EndFunc   ;==>OnAutoItExit

Example 2

; I am the server, start me first! (Start in second the example 2 of the TCPRecv function).

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign a Local variable the path of a file chosen through a dialog box.
    Local $sFilePath = FileOpenDialog("Select a file to send", @MyDocumentsDir, "All types (*.*)", BitOR($FD_FILEMUSTEXIST, $FD_PATHMUSTEXIST))
    Local $iError = 0

    ; Note: Choose a file bigger than 4 kiB otherwise the first example is enough.

    ; If an error occurred display the error code and return False.
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONEXCLAMATION), "", "Server:" & @CRLF & "Invalid file chosen, Error code: " & $iError)
        Return False
    EndIf

    TCPStartup() ; Start the TCP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")

    ; Assign Local variables the loopback IP Address and the Port.
    Local $sIPAddress = "127.0.0.1" ; This IP Address only works for testing on your own computer.
    Local $iPort = 65432 ; Port used for the connection.

    ; Assign a Local variable the socket and bind to the IP Address and Port specified with a maximum of 100 pending connexions.
    Local $iListenSocket = TCPListen($sIPAddress, $iPort, 100)

    ; If an error occurred display the error code and return False.
    If @error Then
        ; Someone is probably already listening on this IP Address and Port (script already running?).
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not listen, Error code: " & $iError)
        Return False
    EndIf

    ; Assign a Local variable to be used by the Client socket.
    Local $iSocket = 0

    Do ; Wait for someone to connect (Unlimited).
        ; Accept incomming connexions if present (Socket to close when finished; one socket per client).
        $iSocket = TCPAccept($iListenSocket)

        ; If an error occurred display the error code and return False.
        If @error Then
            $iError = @error
            MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not accept the incoming connection, Error code: " & $iError)
            Return False
        EndIf
    Until $iSocket <> -1 ;if different from -1 a client is connected.

    ; Close the Listening socket to allow afterward binds.
    TCPCloseSocket($iListenSocket)

    ; Assign a Local variable the size of the file previously chosen.
    Local $iFileSize = FileGetSize($sFilePath)

    ; Assign a Local variable the handle of the file opened in binary mode.
    Local $hFile = FileOpen($sFilePath, $FO_BINARY)

    ; Assign a Local variable the offset of the file being read.
    Local $iOffset = 0

    ; Assign a Local variable the number representing 4 KiB.
    Local Const $i4KiB = 4096

    ; Note: The file is send by parts of 4 KiB.

    ; Send the binary data of the file to the server.
    Do
        ; Set the file position to the current offset.
        FileSetPos($hFile, $iOffset, $FILE_BEGIN)

        ; The file is read from the position set to 4 KiB and directly wrapped into the TCPSend function.
        TCPSend($iSocket, FileRead($hFile, $i4KiB))

        ; If an error occurred display the error code and return False.
        If @error Then
            $iError = @error
            MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not send the data, Error code: " & $iError)

            ; Close the socket.
            TCPCloseSocket($iSocket)
            Return False
        EndIf

        ; Increment the offset of 4 KiB to send the next 4 KiB data.
        $iOffset += $i4KiB
    Until $iOffset >= $iFileSize

    ; Close the file handle.
    FileClose($hFile)

    ; Tell the client the file is fully sent with a code.
    TCPSend($iSocket, @CRLF & "{EOF}")

    ; Display the successful message.
    MsgBox($MB_SYSTEMMODAL, "", "Server:" & @CRLF & "File sent.")

    ; Close the socket.
    TCPCloseSocket($iSocket)
EndFunc   ;==>Example

Func OnAutoItExit()
    TCPShutdown() ; Close the TCP service.
EndFunc   ;==>OnAutoItExit


Function TCPShutdown, UDPShutdown

Function Reference

TCPShutdown, UDPShutdown

Stops TCP/UDP services.

TCPShutdown ( )
UDPShutdown ( )

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | Windows API WSACleanup return value (see MSDN).

Remarks

A script must call one TCPShutdown() call for every successful TCPStartup() call.
UDPShutdown() is just an alias of TCPShutdown().

Related

TCPCloseSocket, TCPListen, TCPStartup, UDPCloseSocket

Example

Close the TCP service.

Example()

Func Example()
    TCPStartup() ; Start the TCP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")
EndFunc   ;==>Example

Func OnAutoItExit()
    TCPShutdown() ; Close the TCP service.
EndFunc   ;==>OnAutoItExit

Close the UDP service

Example()

Func Example()
    UDPStartup() ; Start the UDP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")
EndFunc   ;==>Example

Func OnAutoItExit()
    UDPShutdown() ; Close the UDP service.
EndFunc   ;==>OnAutoItExit


Function TCPStartup, UDPStartup

Function Reference

TCPStartup, UDPStartup

Starts TCP or UDP services.

TCPStartup ( )
UDPStartup ( )

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | Windows API WSAStartup return value (see MSDN).

Remarks

There must be a TCPShutdown() call to avoid memory consumption.
A script must call one TCPShutdown() call for every successful TCPStartup() call.
UDPStartup() is just an alias of TCPStartup().

Related

TCPAccept, TCPCloseSocket, TCPConnect, TCPListen, TCPNameToIP, TCPRecv, TCPSend, TCPShutdown, UDPCloseSocket

Example

Start the TCP service.

Example()

Func Example()
    TCPStartup() ; Start the TCP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")
EndFunc   ;==>Example

Func OnAutoItExit()
    TCPShutdown() ; Close the TCP service.
EndFunc   ;==>OnAutoItExit

Start the UDP service

Example()

Func Example()
    UDPStartup() ; Start the UDP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")
EndFunc   ;==>Example

Func OnAutoItExit()
    UDPShutdown() ; Close the UDP service.
EndFunc   ;==>OnAutoItExit


Function UDPBind

Function Reference

UDPBind

Create a socket bound to an incoming connection.

UDPBind ( IPAddr, port )

Parameters

IPAddr | Internet Protocol dotted address(IpV4) as "192.162.1.1".
port | port on which the created socket will be bound.

Return Value

Success: | an array : $aArray[1] contains the real socket, $aArray[2] contains the specified IP address and $aArray[3] contains the port. We need this information in subsequent calls to UDPRecv(), where we pass this socket structure/array.
Failure: | Sets the @error flag to non-zero.
@error: | 1 - IPAddr is incorrect. 2 - port is incorrect. Windows API WSAGetError return value (see MSDN).

Related

UDPCloseSocket, UDPOpen, UDPRecv, UDPSend

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    UDPStartup() ; Start the UDP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")

    ; Assign Local variables the loopback IP Address and the Port.
    Local $sIPAddress = "127.0.0.1" ; This IP Address only works for testing on your own computer.
    Local $iPort = 65532 ; Port used for the connection.

    ; Assign a Local variable the socket and bind to the IP Address and Port specified.
    Local $aSocket = UDPBind($sIPAddress, $iPort)

    ; If an error occurred display the error code and return False.
    If @error Then
        ; Someone is probably already binded on this IP Address and Port (script already running?).
        Local $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not bind, Error code: " & $iError)
        Return False
    Else
        MsgBox($MB_SYSTEMMODAL, "", "Bind successful.")
    EndIf

    ; Close the Listening socket to allow afterward binds.
    ; While not closed, any other program can NOT bind to the same IP Address and Port.
    UDPCloseSocket($aSocket)
EndFunc   ;==>Example

Func OnAutoItExit()
    UDPShutdown() ; Close the UDP service.
EndFunc   ;==>OnAutoItExit


Function UDPCloseSocket

Function Reference

UDPCloseSocket

Close a UDP socket.

UDPCloseSocket ( socketarray )

Parameters

socketarray The socket/array as returned by a UDPBind() or UDPOpen() functions.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to no-zero.
@error: | -3 or -4 invalid socketarray. Windows API WSAGetError return value (see MSDN).

Related

UDPShutdown(), UDPStartup(), UDPBind, UDPOpen

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

; Start First clicking on "1. Server"
; Then start a second instance of the script selecting "2. Client"

Example()

Func Example()
    UDPStartup() ; Start the UDP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")

    ; Assign Local variables the loopback IP Address and the Port.
    Local $sIPAddress = "127.0.0.1" ; This IP Address only works for testing on your own computer.
    Local $iPort = 65532 ; Port used for the connection.

    #Region GUI
    Local $sTitle = "UDP Start"
    Local $hGUI = GUICreate($sTitle, 250, 70)

    Local $idBtnServer = GUICtrlCreateButton("1. Server", 65, 10, 130, 22)

    Local $idBtnClient = GUICtrlCreateButton("2. Client", 65, 40, 130, 22)

    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idBtnServer
                WinSetTitle($sTitle, "", "UDP Server started")
                GUICtrlSetState($idBtnClient, $GUI_HIDE)
                GUICtrlSetState($idBtnServer, $GUI_DISABLE)
                If Not MyUDP_Server($sIPAddress, $iPort) Then ExitLoop
            Case $idBtnClient
                WinSetTitle($sTitle, "", "UDP Client started")
                GUICtrlSetState($idBtnServer, $GUI_HIDE)
                GUICtrlSetState($idBtnClient, $GUI_DISABLE)
                If Not MyUDP_Client($sIPAddress, $iPort) Then ExitLoop
        EndSwitch

        Sleep(10)
    WEnd

    #EndRegion GUI
EndFunc   ;==>Example

Func MyUDP_Server($sIPAddress, $iPort)
    ; Assign a Local variable the socket and bind to the IP Address and Port specified.
    Local $iSocket = UDPBind($sIPAddress, $iPort)

    ; If an error occurred display the error code and return False.
    If @error Then
        ; Someone is probably already binded on this IP Address and Port (script already running?).
        Local $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not bind, Error code: " & $iError)
        Return False
    EndIf

    ; Assign a Local variable to store the data received.
    Local $sReceived = ""

    Do
        ; We are waiting for the string "toto" OR "tata" (example script UDPSend): 4 bytes length.
        $sReceived = UDPRecv($iSocket, 4)
    Until $sReceived <> ""

    ; Notes: If you don't know how much length will be the data,
    ; use e.g: 2048 for maxlen parameter and call the function until the it returns nothing/error.

    ; Display the string received.
    MsgBox($MB_SYSTEMMODAL, "", "Server:" & @CRLF & "Received: " & $sReceived)

    ; Close the socket.
    UDPCloseSocket($iSocket)
EndFunc   ;==>MyUDP_Server

Func MyUDP_Client($sIPAddress, $iPort)
    ; Assign a Local variable the socket and connect to a listening socket with the IP Address and Port specified.
    Local $iSocket = UDPOpen($sIPAddress, $iPort)
    Local $iError = 0

    ; If an error occurred display the error code and return False.
    If @error Then
        ; The server is probably offline/port is not opened on the server.
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not connect, Error code: " & $iError)
        Return False
    EndIf

    ; Send the string "toto" converted to binary to the server.
    UDPSend($iSocket, StringToBinary("toto"))

    ; If an error occurred display the error code and return False.
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not send the data, Error code: " & $iError)
        Return False
    EndIf

    ; Close the socket.
    UDPCloseSocket($iSocket)
EndFunc   ;==>MyUDP_Client

Func OnAutoItExit()
    UDPShutdown() ; Close the UDP service.
EndFunc   ;==>OnAutoItExit


Function UDPOpen

Function Reference

UDPOpen

Open a socket connected to an existing server .

UDPOpen ( IPAddr, port [, flag = 0] )

Parameters

IPAddr | Internet Protocol dotted address(IpV4) as "192.162.1.1".
port | port on which the created socket will be connected.
flag | [optional] $UDP_OPEN_DEFAULT (0) - (Default) - No additional options are set. $UDP_OPEN_BROADCAST (1) - Allow the broadcasting on the address "255.255.255.255". Constants are defined in "AutoItConstants.au3".

Return Value

Success: | an array : $aArray[1] contains the real socket, $aArray[2] contains the specified IP address and $aArray[3] contains the port. We need this information in subsequent calls to UDPSend(), where we pass this socket structure/array.
Failure: | $aArray[0]=0 and set the @error flag to non-zero.
@error: | Windows API WSAGetError return value (see MSDN).

Remarks

This function is used by a client to communicate with the server.

Related

UDPBind, UDPCloseSocket, UDPRecv, UDPSend

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

; Start First clicking on "1. Server"
; Then start a second instance of the script selecting "2. Client"

Example()

Func Example()
    UDPStartup() ; Start the UDP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")

    ; Assign Local variables the loopback IP Address and the Port.
    Local $sIPAddress = "127.0.0.1" ; This IP Address only works for testing on your own computer.
    Local $iPort = 65532 ; Port used for the connection.

    #Region GUI
    Local $sTitle = "UDP Start"
    Local $hGUI = GUICreate($sTitle, 250, 70)

    Local $idBtnServer = GUICtrlCreateButton("1. Server", 65, 10, 130, 22)

    Local $idBtnClient = GUICtrlCreateButton("2. Client", 65, 40, 130, 22)

    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idBtnServer
                WinSetTitle($sTitle, "", "UDP Server started")
                GUICtrlSetState($idBtnClient, $GUI_HIDE)
                GUICtrlSetState($idBtnServer, $GUI_DISABLE)
                If Not MyUDP_Server($sIPAddress, $iPort) Then ExitLoop
            Case $idBtnClient
                WinSetTitle($sTitle, "", "UDP Client started")
                GUICtrlSetState($idBtnServer, $GUI_HIDE)
                GUICtrlSetState($idBtnClient, $GUI_DISABLE)
                If Not MyUDP_Client($sIPAddress, $iPort) Then ExitLoop
        EndSwitch

        Sleep(10)
    WEnd

    #EndRegion GUI
EndFunc   ;==>Example

Func MyUDP_Server($sIPAddress, $iPort)
    ; Assign a Local variable the socket and bind to the IP Address and Port specified.
    Local $iSocket = UDPBind($sIPAddress, $iPort)

    ; If an error occurred display the error code and return False.
    If @error Then
        ; Someone is probably already binded on this IP Address and Port (script already running?).
        Local $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not bind, Error code: " & $iError)
        Return False
    EndIf

    ; Assign a Local variable to store the data received.
    Local $sReceived = ""

    Do
        ; We are waiting for the string "toto" OR "tata" (example script UDPSend): 4 bytes length.
        $sReceived = UDPRecv($iSocket, 4)
    Until $sReceived <> ""

    ; Notes: If you don't know how much length will be the data,
    ; use e.g: 2048 for maxlen parameter and call the function until the it returns nothing/error.

    ; Display the string received.
    MsgBox($MB_SYSTEMMODAL, "", "Server:" & @CRLF & "Received: " & $sReceived)

    ; Close the socket.
    UDPCloseSocket($iSocket)
EndFunc   ;==>MyUDP_Server

Func MyUDP_Client($sIPAddress, $iPort)
    ; Assign a Local variable the socket and connect to a listening socket with the IP Address and Port specified.
    Local $iSocket = UDPOpen($sIPAddress, $iPort)
    Local $iError = 0

    ; If an error occurred display the error code and return False.
    If @error Then
        ; The server is probably offline/port is not opened on the server.
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not connect, Error code: " & $iError)
        Return False
    EndIf

    ; Send the string "toto" converted to binary to the server.
    UDPSend($iSocket, StringToBinary("toto"))

    ; If an error occurred display the error code and return False.
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not send the data, Error code: " & $iError)
        Return False
    EndIf

    ; Close the socket.
    UDPCloseSocket($iSocket)
EndFunc   ;==>MyUDP_Client

Func OnAutoItExit()
    UDPShutdown() ; Close the UDP service.
EndFunc   ;==>OnAutoItExit


Function UDPRecv

Function Reference

UDPRecv

Receives data from an opened socket.

UDPRecv ( socketarray, maxlen [, flag = 0] )

Parameters

socketarray | The socket/array as returned by a UDPBind() function.
maxlen | max # of characters to receive.
flag | [optional] UDP_DATA_DEFAULT (0) - will auto detect between binary/string. UDP_DATA_BINARY (1) - return binary data $UDP_DATA_ARRAY (2) - returned in an Array : [0] data, [1] from IP, [2] from Port. If you want both just use 3. Constants are defined in "AutoItConstants.au3".

Return Value

Success: | a binary/string sent by the opened socket or an array if flag = 2 or 3.
Failure: | "" and sets the @error flag to non-zero.
@error: | -1 invalid socket. -2 not connected. -3 or -4 invalid socketarray. Windows API WSAGetError return value (see MSDN).

Remarks

For backwards compatibility reasons this function will try to return strings by default. If null (0x00) characters are received then the return value will be a binary type.
To force the function to always return binary data (the most sensible option) then use the "flag" parameter set to 1.

Related

BinaryLen, BinaryMid, UDPBind, UDPOpen, UDPSend

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

; Start First clicking on "1. Server"
; Then start a second instance of the script selecting "2. Client"

Example()

Func Example()
    UDPStartup() ; Start the UDP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")

    ; Assign Local variables the loopback IP Address and the Port.
    Local $sIPAddress = "127.0.0.1" ; This IP Address only works for testing on your own computer.
    Local $iPort = 65532 ; Port used for the connection.

    #Region GUI
    Local $sTitle = "UDP Start"
    Local $hGUI = GUICreate($sTitle, 250, 70)

    Local $idBtnServer = GUICtrlCreateButton("1. Server", 65, 10, 130, 22)

    Local $idBtnClient = GUICtrlCreateButton("2. Client", 65, 40, 130, 22)

    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idBtnServer
                WinSetTitle($sTitle, "", "UDP Server started")
                GUICtrlSetState($idBtnClient, $GUI_HIDE)
                GUICtrlSetState($idBtnServer, $GUI_DISABLE)
                If Not MyUDP_Server($sIPAddress, $iPort) Then ExitLoop
            Case $idBtnClient
                WinSetTitle($sTitle, "", "UDP Client started")
                GUICtrlSetState($idBtnServer, $GUI_HIDE)
                GUICtrlSetState($idBtnClient, $GUI_DISABLE)
                If Not MyUDP_Client($sIPAddress, $iPort) Then ExitLoop
        EndSwitch

        Sleep(10)
    WEnd

    #EndRegion GUI
EndFunc   ;==>Example

Func MyUDP_Server($sIPAddress, $iPort)
    ; Assign a Local variable the socket and bind to the IP Address and Port specified.
    Local $iSocket = UDPBind($sIPAddress, $iPort)

    ; If an error occurred display the error code and return False.
    If @error Then
        ; Someone is probably already binded on this IP Address and Port (script already running?).
        Local $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not bind, Error code: " & $iError)
        Return False
    EndIf

    ; Assign a Local variable to store the data received.
    Local $sReceived = ""

    Do
        ; We are waiting for the string "toto" OR "tata" (example script UDPSend): 4 bytes length.
        $sReceived = UDPRecv($iSocket, 4)
    Until $sReceived <> ""

    ; Notes: If you don't know how much length will be the data,
    ; use e.g: 2048 for maxlen parameter and call the function until the it returns nothing/error.

    ; Display the string received.
    MsgBox($MB_SYSTEMMODAL, "", "Server:" & @CRLF & "Received: " & $sReceived)

    ; Close the socket.
    UDPCloseSocket($iSocket)
EndFunc   ;==>MyUDP_Server

Func MyUDP_Client($sIPAddress, $iPort)
    ; Assign a Local variable the socket and connect to a listening socket with the IP Address and Port specified.
    Local $iSocket = UDPOpen($sIPAddress, $iPort)
    Local $iError = 0

    ; If an error occurred display the error code and return False.
    If @error Then
        ; The server is probably offline/port is not opened on the server.
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not connect, Error code: " & $iError)
        Return False
    EndIf

    ; Send the string "toto" converted to binary to the server.
    UDPSend($iSocket, StringToBinary("toto"))

    ; If an error occurred display the error code and return False.
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not send the data, Error code: " & $iError)
        Return False
    EndIf

    ; Close the socket.
    UDPCloseSocket($iSocket)
EndFunc   ;==>MyUDP_Client

Func OnAutoItExit()
    UDPShutdown() ; Close the UDP service.
EndFunc   ;==>OnAutoItExit


Function UDPSend

Function Reference

UDPSend

Sends data on an opened socket.

UDPSend ( socketarray, data )

Parameters

socketarray | The main socket/array as returned by a UDPOpen() function.
data | binary/string to be sent to the connected socket

Return Value

Success: | the number of bytes sent to the opened socket.
Failure: | sets the @error flag to non-zero.
@error: | -3 or -4 invalid socketarray. 1 - IPAddr is incorrect. 2 - port is incorrect. Windows API WSAGetError return value (see MSDN).

Related

UDPBind, UDPOpen, UDPRecv

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

; Start First clicking on "1. Server"
; Then start a second instance of the script selecting "2. Client"

Example()

Func Example()
    UDPStartup() ; Start the UDP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")

    ; Assign Local variables the loopback IP Address and the Port.
    Local $sIPAddress = "127.0.0.1" ; This IP Address only works for testing on your own computer.
    Local $iPort = 65532 ; Port used for the connection.

    #Region GUI
    Local $sTitle = "UDP Start"
    Local $hGUI = GUICreate($sTitle, 250, 70)

    Local $idBtnServer = GUICtrlCreateButton("1. Server", 65, 10, 130, 22)

    Local $idBtnClient = GUICtrlCreateButton("2. Client", 65, 40, 130, 22)

    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idBtnServer
                WinSetTitle($sTitle, "", "UDP Server started")
                GUICtrlSetState($idBtnClient, $GUI_HIDE)
                GUICtrlSetState($idBtnServer, $GUI_DISABLE)
                If Not MyUDP_Server($sIPAddress, $iPort) Then ExitLoop
            Case $idBtnClient
                WinSetTitle($sTitle, "", "UDP Client started")
                GUICtrlSetState($idBtnServer, $GUI_HIDE)
                GUICtrlSetState($idBtnClient, $GUI_DISABLE)
                If Not MyUDP_Client($sIPAddress, $iPort) Then ExitLoop
        EndSwitch

        Sleep(10)
    WEnd

    #EndRegion GUI
EndFunc   ;==>Example

Func MyUDP_Server($sIPAddress, $iPort)
    ; Assign a Local variable the socket and bind to the IP Address and Port specified.
    Local $iSocket = UDPBind($sIPAddress, $iPort)

    ; If an error occurred display the error code and return False.
    If @error Then
        ; Someone is probably already binded on this IP Address and Port (script already running?).
        Local $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Server:" & @CRLF & "Could not bind, Error code: " & $iError)
        Return False
    EndIf

    ; Assign a Local variable to store the data received.
    Local $sReceived = ""

    Do
        ; We are waiting for the string "toto" OR "tata" (example script UDPSend): 4 bytes length.
        $sReceived = UDPRecv($iSocket, 4)
    Until $sReceived <> ""

    ; Notes: If you don't know how much length will be the data,
    ; use e.g: 2048 for maxlen parameter and call the function until the it returns nothing/error.

    ; Display the string received.
    MsgBox($MB_SYSTEMMODAL, "", "Server:" & @CRLF & "Received: " & $sReceived)

    ; Close the socket.
    UDPCloseSocket($iSocket)
EndFunc   ;==>MyUDP_Server

Func MyUDP_Client($sIPAddress, $iPort)
    ; Assign a Local variable the socket and connect to a listening socket with the IP Address and Port specified.
    Local $iSocket = UDPOpen($sIPAddress, $iPort)
    Local $iError = 0

    ; If an error occurred display the error code and return False.
    If @error Then
        ; The server is probably offline/port is not opened on the server.
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not connect, Error code: " & $iError)
        Return False
    EndIf

    ; Send the string "toto" converted to binary to the server.
    UDPSend($iSocket, StringToBinary("toto"))

    ; If an error occurred display the error code and return False.
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not send the data, Error code: " & $iError)
        Return False
    EndIf

    ; Close the socket.
    UDPCloseSocket($iSocket)
EndFunc   ;==>MyUDP_Client

Func OnAutoItExit()
    UDPShutdown() ; Close the UDP service.
EndFunc   ;==>OnAutoItExit


Functions

Obj/COM functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
ObjCreate | Creates a reference to a COM object from the given classname.
ObjCreateInterface | Creates a reference to an object from the given classname/object pointer, interface identifier and description string.
ObjEvent | Handles incoming events from the given Object.
ObjGet | Retrieves a reference to a COM object from an existing process or filename.
ObjName | Returns the name or interface description of an Object.


Function ObjCreate

Function Reference

ObjCreate

Creates a reference to a COM object from the given classname.

ObjCreate ( "classname" [, "servername" [, "username" [, "password"]]] )

Parameters

classname | The class of the object in the following format: "appname.objectype" It can also be a string representation of the CLSID.
servername | [optional] name of a remote computer from which the object must be obtained.
username | [optional] name of a usercode on the remote computer. You have to enter this in the format "computer\usercode" or "domain\usercode".
password | [optional] password for the usercode on the remote computer.

Return Value

Success: | an object.
Failure: | sets the @error flag to non-zero.

Remarks

Use ObjCreate() if you want to have a new instance of the referring application.
If you want to connect to an existing process, use ObjGet() instead.

Keep in mind that not all computers have the same set of Objects. So always check for errors after calling ObjCreate(). To check errors use ObjEvent().

The following requirements apply if you want to access objects on remote computers:

  • The user running the script must have the appropriate permissions.

  • The Object on the remote computer must support DCOM (Distributed COM)

  • The remote computer must have 'Remote Registry Service' and 'File and Printer sharing' services running.

See the Obj/COM Reference for more information about Objects.

Related

GUICtrlCreateObj, IsObj, ObjEvent, ObjGet, ObjName

Example

Example 1

#include <MsgBoxConstants.au3>

; Counting the number of open shell windows

Local $oShell = ObjCreate("shell.application") ; Get the Windows Shell Object
Local $oShellWindows = $oShell.Windows() ; Get the collection of open shell Windows

If IsObj($oShellWindows) Then
    Local $sString = "" ; String for displaying purposes

    For $oWnd In $oShellWindows ; Count all existing shell windows
        $sString &= $oWnd.LocationName & @CRLF
    Next

    MsgBox($MB_SYSTEMMODAL, "", "Shell Windows:" & @CRLF & "You have the following shell windows:" & @CRLF & @CRLF & $sString)
EndIf

Example 2

#include <MsgBoxConstants.au3>

; Open the MediaPlayer on a REMOTE computer

Local $oRemoteMedia = ObjCreate("MediaPlayer.MediaPlayer.1", "name-of-remote-computer")

If Not @error Then
    MsgBox($MB_SYSTEMMODAL, "Remote ObjCreate Test", "ObjCreate() of a remote Mediaplayer Object successful !")
    $oRemoteMedia.Open(@WindowsDir & "\media\tada.wav") ; Play sound if file is present
Else
    MsgBox($MB_SYSTEMMODAL, "Remote ObjCreate Test", "Failed to open remote Object. Error code: " & Hex(@error, 8))
EndIf


Function ObjCreateInterface

Warning: This feature is experimental. It may not work, may contain bugs or may be changed or removed without notice.

DO NOT REPORT BUGS OR REQUEST NEW FEATURES FOR THIS FEATURE.

Function Reference

ObjCreateInterface

Creates a reference to an object from the given classname/object pointer, interface identifier and description string.

ObjCreateInterface ( "CLSID" , "IID" [, "interface_description",[flag = True]] )

Parameters

CLSID | Class identifier or object pointer. If this is a class identifier it can be in either ProgID or the string representation of the CLSID.
IID | String representation of interface identifier.
interface_description | [optional] String describing v-table of the object. Use keyword Default to access IDispatch for dual interfaces.
flag | [optional] Default value is True meaning the object interface inherits from IUnknown.

Return Value

Success: | an object.
Failure: | sets the @error flag to non-zero.

Remarks

ObjCreateInterface() creates objects with methods that are listed in interface-description string.
For COM objects (IUnknown based) first three methods are always QueryInterface, AddRef and Release. Don't specify them inside the description strings.

Methods listed inside description string must be in v-table order of the interface. If you provide an invalid or incorrect description AutoIt may become unstable or crash.

Format of the description string is:
$sTagInterface = "MethodName1 RetType(ParamType1;ParamType2;...); MethodName2 RetType(..."

By default, AutoIt uses the 'stdcall' calling convention for COM. To use the 'cdecl' place ':cdecl' after the return type.

Valid Types are:

Type | Details
none | no value (only valid for return type - equivalent to void in C)
byte | an unsigned 8 bit integer
boolean | an unsigned 8 bit integer
short | a 16 bit integer
word, ushort | an unsigned 16 bit integer
int, long | a 32 bit integer
bool | a 32 bit integer
dword, ulong, uint | an unsigned 32 bit integer
hresult | a 32 bit integer
int64 | a 64 bit integer
uint64 | an unsigned 64 bit integer
ptr | a general pointer (void *)
hwnd | a window handle (pointer)
handle | an handle (pointer)
float | a single precision floating point number
double | a double precision floating point number
int_ptr, long_ptr, lresult, lparam | an integer big enough to hold a pointer when running on x86 or x64 versions of AutoIt.
uint_ptr, ulong_ptr, dword_ptr, wparam | an unsigned integer big enough to hold a pointer when running on x86 or x64 versions of AutoIt.
str | an ANSI string (a minimum of 65536 chars is allocated).
wstr | a UNICODE wide character string (a minimum of 65536 chars is allocated).
bstr | a composite data type that consists of a length prefix, a data string and a terminator
variant | a tagged union that can be used to represent any other data type
idispatch, object | a composite data type that represents object with IDispatch interface
clsid | 128-bit integer in form of GUID string
struct | structure created with DllStructCreate()
* | Add * to the end of another type to pass it by reference. For example "int*" passes a pointer to an "int" type.

See the Obj/COM Reference for more information about Objects.

Related

ObjCreate

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Declare the CLSID, IID and interface description for ITaskbarList.
    ; It is not necessary to describe the members of IUnknown.
    Local Const $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}"
    Local Const $sIID_ITaskbarList = "{56FDF342-FD6D-11D0-958A-006097C9A090}"
    Local Const $sTagITaskbarList = "HrInit hresult(); AddTab hresult(hwnd); DeleteTab hresult(hwnd); ActivateTab hresult(hwnd); SetActiveAlt hresult(hwnd);"

    ; Create the object.
    Local $oTaskbarList = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList, $sTagITaskbarList)

    ; Initialize the iTaskbarList object.
    $oTaskbarList.HrInit()

    ; Run Notepad.
    Run("notepad.exe")

    ; Wait for the Notepad window to appear and get a handle to it.
    Local $hNotepad = WinWait("[CLASS:Notepad]")

    ; Tell the user what to look for.
    MsgBox($MB_SYSTEMMODAL, "", "Look in the Taskbar and you should see an entry for Notepad." & @CRLF & @CRLF & "Press OK to continue.")

    ; Delete the Notepad entry from the Taskbar.
    $oTaskbarList.DeleteTab($hNotepad)

    ; Tell the user to look again.
    MsgBox($MB_SYSTEMMODAL, "", "Look in the Taskbar.  There should no longer be a Notepad entry but Notepad is still running." & @CRLF & @CRLF & "Press OK to continue.")

    ; Close Notepad.
    WinClose($hNotepad)
EndFunc   ;==>Example


Function ObjEvent

Function Reference

ObjEvent

Handles incoming events from the given Object.

ObjEvent ( $ObjectVar, "functionprefix" [, "interface name"] )
ObjEvent ( "AutoIt.Error" [, "function"] )

Parameters

$ObjectVar | A variable containing an Object from which you want to receive events
"functionprefix" | The prefix of the functions you define to handle receiving events. The prefix is appended by the Objects method name.
"interface name" | [optional] name of an Event interface to use. Note: It must be a supported as outgoing for the Object AND it must be of type DISPATCH.

Return Value

Success: | an object or a function name.
Failure: | sets the @error flag to non-zero.

Remarks

The first format is used to receive Events from the given Object.
To receive a specific event, create an AutoIt function name using the given prefix appended with the event name.

The second format is used for COM Error Handling.
If any COM error occurs, the given function is being called. First parameter for the function will be error object.
You can use it to access different properties of this object.
If the second parameter is omitted, it will return the name of the current Error handler function or function, depending what was used when registering.

Properties of the AutoIt Error Object:

.number | The Windows HRESULT value from a COM call
.windescription | The FormatWinError() text derived from .number
.source | Name of the Object generating the error (contents from ExcepInfo.source)
.description | Source Object's description of the error (contents from ExcepInfo.description)
.helpfile | Source Object's helpfile for the error (contents from ExcepInfo.helpfile)
.helpcontext | Source Object's helpfile context id number (contents from ExcepInfo.helpcontext)
.lastdllerror | The number returned from GetLastError()
.scriptline | The script line on which the error was generated

See the Obj/COM Reference for a detailed explanation.

Related

GUICtrlCreateObj, IsObj, ObjCreate, ObjGet

Example

Example 1

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Error monitoring. This will trap all COM errors while alive.
    ; This particular object is declared as local, meaning after the function returns it will not exist.
    Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

    ; Create Internet Explorer object
    Local $oIE = ObjCreate("InternetExplorer.Application")
    ; Check for errors
    If @error Then Return

    $oIE.Visible = True ; set visibility

    ; Custom sink object
    Local $oIEEvents = ObjEvent($oIE, "_IEEvent_", "DWebBrowserEvents2")

    ; Navigate somewhere
    $oIE.navigate("http://www.google.com/")
    ; Check for errors while loading
    If @error Then
        $oIE.Quit()
        Return
    EndIf

    ; Wait for page to load
    While 1
        If $oIE.readyState = "complete" Or $oIE.readyState = 4 Then ExitLoop
        Sleep(10)
    WEnd

    ; Deliberately cause error by calling non-existing method
    $oIE.PlayMeARockAndRollSong()

    ; Check for errors
    If @error Then MsgBox($MB_SYSTEMMODAL, "COM Error", "@error is set to COM error number." & @CRLF & "@error = 0x" & Hex(@error))

    ; Wait few seconds to see if more events will be fired
    Sleep(3000)

    ; Nothing more to do. Close IE and return from the function
    $oIE.Quit()

    #forceref $oErrorHandler, $oIEEvents
EndFunc   ;==>Example

; BeforeNavigate2 method definition
Func _IEEvent_BeforeNavigate2($oIEpDisp, $sIEURL, $iIEFlags, $sIETargetFrameName, $sIEPostData, $iIEHeaders, $bIECancel)
    ConsoleWrite("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!--BeforeNavigate2 fired--!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & _
            "$oIEpDisp = " & $oIEpDisp() & "  -  " & ObjName($oIEpDisp) & @CRLF & _ ; e.g. default property and name for the object
            "$sIEURL = " & $sIEURL & @CRLF & _
            "$iIEFlags = " & $iIEFlags & @CRLF & _
            "$sIETargetFrameName = " & $sIETargetFrameName & @CRLF & _
            "$sIEPostData = " & $sIEPostData & @CRLF & _
            "$iIEHeaders = " & $iIEHeaders & @CRLF & _
            "$bIECancel = " & $bIECancel & @CRLF & _
            "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " & @CRLF & @CRLF)
EndFunc   ;==>_IEEvent_BeforeNavigate2

; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc

Example 2

Global $__g_oTemplateCOMErrorHandler = 0

Local $oShell = ObjCreate("Shell.Application")

; Wrap calls that are likely to fatal error

; This won't fatal error, it will set @error as in 3.3.11.0
Template_COMErrorRegister()
$oShell.InvalidFunction()
If @error Then MsgBox(4096, "COM Error Detected", @error)
Template_COMErrorUnregister()

; This will fatal error, the 2nd line will not be reached.
$oShell.InvalidFunction()
If @error Then MsgBox(4096, "COM Error Detected", @error)

Func Template_COMErrorRegister()
    $__g_oTemplateCOMErrorHandler = ObjEvent("AutoIt.Error", "Template_COMErrFunc")
EndFunc   ;==>Template_COMErrorRegister

Func Template_COMErrorUnregister()
    $__g_oTemplateCOMErrorHandler = 0
EndFunc   ;==>Template_COMErrorUnregister

Func Template_COMErrFunc()
    ; Do nothing special, just check @error after suspect functions.
EndFunc   ;==>Template_COMErrFunc


Function ObjGet

Function Reference

ObjGet

Retrieves a reference to a COM object from an existing process or filename.

ObjGet ( "filename" [, "classname" [, instance]] )

Parameters

filename | The full path and name to the file containing the object (See remarks).
classname | [optional] Class identifier. Can be in either ProgID or the string representation of the CLSID.
instance | [optional] Instance of the object for ROT objects of the same (co)class.

Return Value

Success: | an object.
Failure: | sets the @error flag to non-zero.

Remarks

The filename is optional if you want to use only the class identifier, but the parameter can't be omitted.
Use an empty string if you want to access objects from running objects table (ROT). You can use third parameter to specify wanted instance in that case.
In all other cases third parameter is ignored.

If you use a filename, the classname is optional. It's only required when you want to load an object of a specific class.
Classname parameter does not have default value. If it's specified then it's processed.

See the Obj/COM Reference for more information about Objects.

Related

GUICtrlCreateObj, IsObj, ObjCreate, ObjEvent, ObjName

Example

Example 1

#include <MsgBoxConstants.au3>

; Example getting an Object using it's class name
; ; Excel must be activated for this example to be successful

Example()

Func Example()
    Local $oExcel = ObjGet("", "Excel.Application") ; Get an existing Excel Object

    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "Excel File Test" & @CRLF & "Error Getting an active Excel Object. Error code: " & Hex(@error, 8))
        Return False
    EndIf

    $oExcel.Visible = 1 ; Let the guy show himself
    $oExcel.workbooks.add ; Add a new workbook
EndFunc   ;==>Example

Example 2

; Example getting an Object using a file name
; ; An Excel file with filename Worksheet.xls must be created in the script directory
; in order for this example to work.
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $sFileName = @ScriptDir & "\Worksheet.xls"

    If Not FileExists($sFileName) Then
        MsgBox($MB_SYSTEMMODAL, "", "Excel File Test" & @CRLF & "Can't run this test, because you didn't create the Excel file " & $sFileName)
        Return False
    EndIf

    Local $oExcelDoc = ObjGet($sFileName) ; Get an Excel Object from an existing filename

    If IsObj($oExcelDoc) Then

        ; Tip: Uncomment these lines to make Excel visible (credit: DaleHohm)
        ; $oExcelDoc.Windows(1).Visible = 1; Set the first worksheet in the workbook visible
        ; $oExcelDoc.Application.Visible = 1; Set the application visible (without this Excel will exit)

        Local $sString = "" ; String for displaying purposes

        For $oProperty In $oExcelDoc.BuiltinDocumentProperties
            $sString &= $oProperty.Name & ":" & $oProperty.Value & @CRLF
        Next

        MsgBox($MB_SYSTEMMODAL, "", "Excel File Test:" & @CRLF & "The document properties of " & $sFileName & " are:" & @CRLF & @CRLF & $sString)

        $oExcelDoc.Close ; Close the Excel document

    Else
        MsgBox($MB_SYSTEMMODAL, "", "Excel File Test" & @CRLF & "Error: Could not open " & $sFileName & " as an Excel Object.")
    EndIf
EndFunc   ;==>Example


Function ObjName

Function Reference

ObjName

Returns the name or interface description of an Object.

ObjName ( $Objectvariable [, Flag = 1] )

Parameters

$Objectvariable | A variable containing an Object whose name you want to retrieve
Flag | [optional] $OBJ_NAME (1) = (default) The name of the Object $OBJ_STRING (2) = Description string of the Object $OBJ_PROGID (3) = The ProgID of the Object $OBJ_FILE (4) = The file that is associated with the object in the Registry $OBJ_MODULE (5) = Module name in which the object runs (WIN XP And above). Marshaller for non-inproc objects. $OBJ_CLSID (6) = CLSID of the object's coclass $OBJ_IID (7) = IID of the object's interface Constants are defined in "AutoItConstants.au3".

Return Value

Success: | a string representing the name
Failure: | "" (empty string) and sets the @error flag to non-zero.

Remarks

Not all Objects support flags 2 to 7. Always test for @error in these cases.

Related

IsObj, ObjCreate, ObjGet

Example

Example 1

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Local $oInternet = ObjCreate("InternetExplorer.Application")
$oInternet.Navigate("http://www.google.com") ; Opening a web page that contains a form
Sleep(4000) ; Give the page time to load

Local $oDoc = $oInternet.Document ; Example object to test
Local $oForm = $oDoc.Forms(0) ; Example object to test

MsgBox($MB_SYSTEMMODAL, "", "Interface name of $oInternet is: " & ObjName($oInternet) & @CRLF & _
        "Object name of $oInternet is:    " & ObjName($oInternet, $OBJ_STRING) & @CRLF & _
        "Interface name of $oDoc is:      " & ObjName($oDoc) & @CRLF & _
        "Object name of $oDoc is:         " & ObjName($oDoc, $OBJ_STRING) & @CRLF & _
        "Interface name of $oForm is:     " & ObjName($oForm) & @CRLF & _
        "Object name of $oForm is:        " & ObjName($oForm, $OBJ_STRING))
$oInternet.Quit()

Example 2

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Local $oObj = ObjCreate("InternetExplorer.Application")
ObjName_FlagsValue($oObj)

Func ObjName_FlagsValue(ByRef $oObj)
    Local $sInfo = ''

    $sInfo &= '+>' & @TAB & 'ObjName($oObj,1) {The name of the Object} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_NAME) & @CRLF

    ; HELPFILE REMARKS: Not all Objects support flags 2 to 7. Always test for @error in these cases.
    $sInfo &= '+>' & @TAB & 'ObjName($oObj,2) {Description string of the Object} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_STRING)
    If @error Then $sInfo &= '@error = ' & @error
    $sInfo &= @CRLF & @CRLF

    $sInfo &= '+>' & @TAB & 'ObjName($oObj,3) {The ProgID of the Object} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_PROGID)
    If @error Then $sInfo &= '@error = ' & @error
    $sInfo &= @CRLF & @CRLF

    $sInfo &= '+>' & @TAB & 'ObjName($oObj,4) {The file that is associated with the object in the Registry} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_FILE)
    If @error Then $sInfo &= '@error = ' & @error
    $sInfo &= @CRLF & @CRLF

    $sInfo &= '+>' & @TAB & 'ObjName($oObj,5) {Module name in which the object runs (WIN XP And above). Marshaller for non-inproc objects.} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_MODULE)
    If @error Then $sInfo &= '@error = ' & @error
    $sInfo &= @CRLF & @CRLF

    $sInfo &= '+>' & @TAB & 'ObjName($oObj,6) {CLSID of the object''s coclass} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_CLSID)
    If @error Then $sInfo &= '@error = ' & @error
    $sInfo &= @CRLF & @CRLF

    $sInfo &= '+>' & @TAB & 'ObjName($oObj,7) {IID of the object''s interface} =' & @CRLF & @TAB & ObjName($oObj, $OBJ_IID)
    If @error Then $sInfo &= '@error = ' & @error
    $sInfo &= @CRLF & @CRLF

    MsgBox($MB_SYSTEMMODAL, "ObjName:", $sInfo)
EndFunc   ;==>ObjName_FlagsValue


Functions

Process functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
DllCall | Dynamically calls a function in a DLL.
DllCallAddress | Dynamically calls a function at a specific memory address.
DllCallbackFree | Frees a previously created handle created with DllCallbackRegister.
DllCallbackGetPtr | Returns the pointer to a callback function that can be passed to the Win32 API.
DllCallbackRegister | Creates a user-defined DLL Callback function.
DllClose | Closes a previously opened DLL.
DllOpen | Opens a DLL file for use in DllCall.
DllStructCreate | Creates a C/C++ style structure to be used in DllCall.
DllStructGetData | Returns the data of an element of the struct.
DllStructGetPtr | Returns the pointer to the struct or an element in the struct.
DllStructGetSize | Returns the size of the struct in bytes.
DllStructSetData | Sets the data of an element in the struct.
ProcessClose | Terminates a named process.
ProcessExists | Checks to see if a specified process exists.
ProcessGetStats | Returns an array about Memory or IO infos of a running process.
ProcessList | Returns an array listing the currently running processes (names and PIDs).
ProcessSetPriority | Changes the priority of a process.
ProcessWait | Pauses script execution until a given process exists.
ProcessWaitClose | Pauses script execution until a given process does not exist.
Run | Runs an external program.
RunAs | Runs an external program under the context of a different user.
RunAsWait | Runs an external program under the context of a different user and pauses script execution until the program finishes.
RunWait | Runs an external program and pauses script execution until the program finishes.
ShellExecute | Runs an external program using the ShellExecute API.
ShellExecuteWait | Runs an external program using the ShellExecute API and pauses script execution until it finishes.
Shutdown | Shuts down the system.
StderrRead | Reads from the STDERR stream of a previously run child process.
StdinWrite | Writes a number of characters to the STDIN stream of a previously run child process.
StdioClose | Closes all resources associated with a process previously run with STDIO redirection.
StdoutRead | Reads from the STDOUT stream of a previously run child process.


Function DllCall

Function Reference

DllCall

Dynamically calls a function in a DLL.

DllCall ( "dll", "return type", "function" [, type1, param1 [, type n, param n]] )

Parameters

dll | The filename of the DLL to use. e.g. "user32.dll". A handle obtained from DllOpen can also be used (See Remarks).
return type | The return type of the function (see below).
function | The name, eg. "MessageBox" or the ordinal value, e.g. 62, of the function in the DLL to call.
type1 | [optional] The type of the parameter (see remarks).
param1 | [optional] The actual parameter (see remarks).
type n | [optional] The type of the nth parameter (see remarks).
param n | [optional] The actual nth parameter (see remarks).

Valid Types are:

Type | Details
NONE | no value (only valid for return type - equivalent to void in C)
BYTE | an unsigned 8 bit integer
BOOLEAN | an unsigned 8 bit integer
SHORT | a 16 bit integer
USHORT | an unsigned 16 bit integer
WORD | an unsigned 16 bit integer
INT | a 32 bit integer
LONG | a 32 bit integer
BOOL | a 32 bit integer
UINT | an unsigned 32 bit integer
ULONG | an unsigned 32 bit integer
DWORD | an unsigned 32 bit integer
INT64 | a 64 bit integer
UINT64 | an unsigned 64 bit integer
PTR | a general pointer (void *)
HWND | a window handle (pointer)
HANDLE | an handle (pointer)
FLOAT | a single precision floating point number
DOUBLE | a double precision floating point number
INT_PTR, LONG_PTR, LRESULT, LPARAM | an integer big enough to hold a pointer when running on x86 or x64 versions of AutoIt.
UINT_PTR, ULONG_PTR, DWORD_PTR, WPARAM | an unsigned integer big enough to hold a pointer when running on x86 or x64 versions of AutoIt.
STR | an ANSI string (a minimum of 65536 chars is allocated).
WSTR | a UNICODE wide character string (a minimum of 65536 chars is allocated).
STRUCT | structure created with DllStructCreate()
* | Add * to the end of another type to pass it by reference. For example "int*" passes a pointer to an "int" type.

Conversions from Windows API types to AutoIt types:

WINDOWS API Type | AutoIt Type
LPCSTR/LPSTR | STR
LPCWSTR/LPWSTR | WSTR
LPVOID | PTR
LPxyz | xyz*
HINSTANCE | HANDLE
HRESULT | LONG
LONGLONG/LARGE_INTEGER | INT64
ULONGLONG/ULARGE_INTEGER | UINT64
SIZE_T | ULONG_PTR
To use nested structures inside a structure you must re-define the nested structure. For example, a structure containing 2 POINT structures ("long;long") would be declared as "long;long;long;long". The first two long values correspond to the first POINT structure and the second two values correspond to the second POINT structure.

For more Windows API types see MSDN.

Return Value

Success: | an array. See remarks.
Failure: | sets the @error flag to non-zero.
@error: | 1 = unable to use the DLL file, 2 = unknown "return type", 3 = "function" not found in the DLL file, 4 = bad number of parameters, 5 = bad parameter.

Remarks

If a dll filename is given then the DLL is automatically loaded and then closed at the end of the call. If you want to manually control the loading and unloading of the DLL then you should use DllOpen() and DllClose() and use a handle instead of a filename in this function.

By default, AutoIt uses the 'stdcall' calling method. To use the 'cdecl' method place ':cdecl' after the return type.
DllCall("SQLite.dll", "int:cdecl", "sqlite3_open", "str", $sDatabase_Filename , "long*", 0).

By default, AutoIt tries to use the ANSI version of a function name, i.e. MessageBoxA is attempted when MessageBox is given as the function name. To call the unicode version use MessageBoxW.

If the function call fails then @error is set to non-zero.
Otherwise an array is returned that contains the function return value and a copy of all the parameters (including parameters that the function may have modified when passed by reference).
$return[0] = function return value
$return[1] = param1
$return[2] = param2
...
$return[n] = paramn

Related

DllCallbackFree, DllCallbackGetPtr, DllCallbackRegister, DllClose, DllOpen, DllStructCreate, DllStructGetPtr

Example

Example 1

; Calling the MessageBox API directly.
DllCall("user32.dll", "int", "MessageBox", _
        "hwnd", 0, _ ; Handle to the parent window
        "str", "Some text", _ ; The text of the message box
        "str", "Some title", _ ; The title of the message box
        "int", 0) ; Flags for the message box.

Example 2

#include <MsgBoxConstants.au3>

; Calling a function that modifies parameters,
Local $iPID = Run("notepad")

Local $hWnd = WinWait("[CLASS:Notepad]", "", 2000)

If $hWnd = 0 Then
    ; Timeout occured.
    Exit MsgBox($MB_SYSTEMMODAL, Default, "Unable to start notepad!")
EndIf

Local $aResult = DllCall("user32.dll", "int", "GetWindowText", "hwnd", $hWnd, "str", "", "int", 32768)
MsgBox($MB_SYSTEMMODAL, Default, "Number of characters returned: " & $aResult[0])
MsgBox($MB_SYSTEMMODAL, Default, "Text (returned in parameter 2): '" & $aResult[2] & "'")

WinClose($hWnd)

Example 3

#include <MsgBoxConstants.au3>

; Show the Windows PickIconDlg.
Local $sFileName = @SystemDir & '\shell32.dll'

; Create a structure to store the icon index
Local $tIconIndex = DllStructCreate("int")
Local $tString = DllStructCreate("wchar[260]")
Local $iStructsize = DllStructGetSize($tString) / 2
DllStructSetData($tString, 1, $sFileName)

; Run the PickIconDlg - '62' is the ordinal value for this function
DllCall("shell32.dll", "none", 62, _
        "hwnd", 0, _
        "struct*", $tString, _
        "int", $iStructsize, _
        "struct*", $tIconIndex)

$sFileName = DllStructGetData($tString, 1)
Local $iIconIndex = DllStructGetData($tIconIndex, 1)

; Show the new filename and icon index
MsgBox($MB_SYSTEMMODAL, "Info", "Last selected file: " & $sFileName & @CRLF & "Icon-Index: " & $iIconIndex)


Function DllCallAddress

Function Reference

DllCallAddress

Dynamically calls a function at a specific memory address.

DllCallAddress ( "return type", address [, type1, param1 [, type n, param n]] )

Parameters

return type | The return type of the function (see below).
address | The address of a function. If this value is invalid your script will crash!
type1 | [optional] The type of the parameter (see remarks).
param1 | [optional] The actual parameter (see remarks).
type n | [optional] The type of the nth parameter (see remarks).
param n | [optional] The actual nth parameter (see remarks).

Valid Types are:

Type | Details
NONE | no value (only valid for return type - equivalent to void in C)
BYTE | an unsigned 8 bit integer
BOOLEAN | an unsigned 8 bit integer
SHORT | a 16 bit integer
USHORT | an unsigned 16 bit integer
WORD | an unsigned 16 bit integer
INT | a 32 bit integer
LONG | a 32 bit integer
BOOL | a 32 bit integer
UINT | an unsigned 32 bit integer
ULONG | an unsigned 32 bit integer
DWORD | an unsigned 32 bit integer
INT64 | a 64 bit integer
UINT64 | an unsigned 64 bit integer
PTR | a general pointer (void *)
HWND | a window handle (pointer)
HANDLE | an handle (pointer)
FLOAT | a single precision floating point number
DOUBLE | a double precision floating point number
INT_PTR, LONG_PTR, LRESULT, LPARAM | an integer big enough to hold a pointer when running on x86 or x64 versions of AutoIt.
UINT_PTR, ULONG_PTR, DWORD_PTR, WPARAM | an unsigned integer big enough to hold a pointer when running on x86 or x64 versions of AutoIt.
STR | an ANSI string (a minimum of 65536 chars is allocated).
WSTR | a UNICODE wide character string (a minimum of 65536 chars is allocated).
STRUCT | structure created with DllStructCreate()
* | Add * to the end of another type to pass it by reference. For example "int*" passes a pointer to an "int" type.

Conversions from Windows API types to AutoIt types:

WINDOWS API Type | AutoIt Type
LPCSTR/LPSTR | STR
LPCWSTR/LPWSTR | WSTR
LPVOID | PTR
LPxyz | xyz*
HINSTANCE | HANDLE
HRESULT | LONG
LONGLONG/LARGE_INTEGER | INT64
ULONGLONG/ULARGE_INTEGER | UINT64
SIZE_T | ULONG_PTR
To use nested structures inside a structure you must re-define the nested structure. For example, a structure containing 2 POINT structures ("long;long") would be declared as "long;long;long;long". The first two long values correspond to the first POINT structure and the second two values correspond to the second POINT structure.

For more Windows API types see MSDN.

Return Value

Success: | an array. See remarks.
Failure: | sets the @error flag to non-zero.
@error: | 2 = unknown "return type", 4 = bad number of parameters, 5 = bad parameter

Remarks

By default, AutoIt uses the 'stdcall' calling method. To use the 'cdecl' method place ':cdecl' after the return type.

If the function call fails then the @error flag is set to non-zero.
Otherwise an array is returned that contains the function return value and a copy of all the parameters (including parameters that the function may have modified when passed by reference).
$return[0] = function return value
$return[1] = param1
$return[2] = param2
...
$return[n] = paramn

Special Note: This is an advanced function. Incorrect use of this function may cause AutoIt to crash. Before using this function make sure DllCall() doesn't do what you need.

Related

DllCall, DllCallbackFree, DllCallbackGetPtr, DllCallbackRegister, DllClose, DllOpen, DllStructCreate, DllStructGetPtr

Example

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

Example()

Func Example()
    ; Enable GUI event mode.
    Opt("GUIOnEventMode", 1)

    ; Create a simple GUI.
    Local $hWnd = GUICreate("DllCallAddress Example")

    ; Register the close event handler.
    GUISetOnEvent($GUI_EVENT_CLOSE, "OnClose")

    ; Show the GUI.
    GUISetState(@SW_SHOWNORMAL, $hWnd)

    ; Get a pointer to the window's WindowProc().
    Local $pWndProc = _WinAPI_GetWindowLong($hWnd, $GWL_WNDPROC)

    ; Tell the user what is about to happen.
    MsgBox($MB_SYSTEMMODAL, "DllCallAddress Example Msg", "When you press OK the test window will close.")

    ; Explicitly generate a WM_CLOSE event and pass it directly to the WindowProc().
    ; This should never be done in a real application (Use _SendMessage() instead) but
    ; it demonstrates how to use the function.
    DllCallAddress("LRESULT", $pWndProc, "HWND", $hWnd, "UINT", $WM_CLOSE, "WPARAM", 0, "LPARAM", 0)
EndFunc   ;==>Example

Func OnClose()
    GUIDelete(@GUI_WinHandle)
    MsgBox($MB_SYSTEMMODAL, "DllCallAddress Example Msg", "Close event received, the test window should now be closed.")
EndFunc   ;==>OnClose


Function DllCallbackFree

Function Reference

DllCallbackFree

Frees a previously created handle created with DllCallbackRegister.

DllCallbackFree ( handle )

Parameters

handle The DllCallback handle, as returned by a previous call to DllCallbackRegister().

Return Value

None.

Remarks

Upon termination, AutoIt automatically closes any handles it opened but calling DllCallbackFree() is still a good idea.

Related

DllCall, DllCallbackGetPtr, DllCallbackRegister

Example

#include <MsgBoxConstants.au3>

; Create callback function.
Local $hHandle = DllCallbackRegister("_EnumWindowsProc", "int", "hwnd;lparam")

; Call EnumWindows.
DllCall("user32.dll", "int", "EnumWindows", "ptr", DllCallbackGetPtr($hHandle), "lparam", 10)

; Delete callback function.
DllCallbackFree($hHandle)

; Callback Procedure
Func _EnumWindowsProc($hWnd, $lParam)
    ; If the Title is empty or if the window is not visible then continue enumeration.
    If WinGetTitle($hWnd) = "" Or BitAND(WinGetState($hWnd), 2) = 0 Then Return 1

    Local $iRes = MsgBox(BitOR($MB_SYSTEMMODAL, $MB_OKCANCEL), _
            WinGetTitle($hWnd), "$hWnd=" & $hWnd & @CRLF & _
            "$lParam=" & $lParam & @CRLF & _
            "$hWnd(type)=" & VarGetType($hWnd))

    If $iRes <> $IDOK Then Return 0 ; Cancel/Close button clicked, return 0 to stop enumeration.

    Return 1 ; Return 1 to continue enumeration.
EndFunc   ;==>_EnumWindowsProc


Function DllCallbackGetPtr

Function Reference

DllCallbackGetPtr

Returns the pointer to a callback function that can be passed to the Win32 API.

DllCallbackGetPtr ( handle )

Parameters

handle A DllCallback handle returned from DllCallbackRegister().

Return Value

Success: | the pointer to the callback function.
Failure: | 0.

Remarks

Use DllCallbackGetPtr() to pass the address of a callback function to the Win32 API when using DllCall().

Related

DllCall, DllCallbackFree, DllCallbackRegister

Example

#include <MsgBoxConstants.au3>

; Create callback function.
Local $hHandle = DllCallbackRegister("_EnumWindowsProc", "int", "hwnd;lparam")

; Call EnumWindows.
DllCall("user32.dll", "int", "EnumWindows", "ptr", DllCallbackGetPtr($hHandle), "lparam", 10)

; Delete callback function.
DllCallbackFree($hHandle)

; Callback Procedure
Func _EnumWindowsProc($hWnd, $lParam)
    ; If the Title is empty or if the window is not visible then continue enumeration.
    If WinGetTitle($hWnd) = "" Or BitAND(WinGetState($hWnd), 2) = 0 Then Return 1

    Local $iRes = MsgBox(BitOR($MB_SYSTEMMODAL, $MB_OKCANCEL), _
            WinGetTitle($hWnd), "$hWnd=" & $hWnd & @CRLF & _
            "$lParam=" & $lParam & @CRLF & _
            "$hWnd(type)=" & VarGetType($hWnd))

    If $iRes <> $IDOK Then Return 0 ; Cancel/Close button clicked, return 0 to stop enumeration.

    Return 1 ; Return 1 to continue enumeration.
EndFunc   ;==>_EnumWindowsProc


Function DllCallbackRegister

Function Reference

DllCallbackRegister

Creates a user-defined DLL Callback function.

DllCallbackRegister ( "function", "return type", "params" )

Parameters

function | The name of the User Defined Function to call.
return type | The return type and calling convention of the function (see DllCall).
params | A semi-colon separated list of parameters that will be passed to this function. See Remarks.

Return Value

Success: | a dll "handle" to be used with DllCallbackGetPtr() and DllCallbackFree() functions.
Failure: | 0 if error occurs.

Remarks

Uses all DllCall() types except "struct".
When finished working with a callback, call the DllCallbackFree() function to close it. AutoIt normally closes all files upon termination, but explicitly calling DllCallbackFree() is still a good idea.

Related

DllCall, DllCallbackFree, DllCallbackGetPtr

Example

#include <MsgBoxConstants.au3>

; Create callback function.
Local $hHandle = DllCallbackRegister("_EnumWindowsProc", "int", "hwnd;lparam")

; Call EnumWindows.
DllCall("user32.dll", "int", "EnumWindows", "ptr", DllCallbackGetPtr($hHandle), "lparam", 10)

; Delete callback function.
DllCallbackFree($hHandle)

; Callback Procedure
Func _EnumWindowsProc($hWnd, $lParam)
    ; If the Title is empty or if the window is not visible then continue enumeration.
    If WinGetTitle($hWnd) = "" Or BitAND(WinGetState($hWnd), 2) = 0 Then Return 1

    Local $iRes = MsgBox(BitOR($MB_SYSTEMMODAL, $MB_OKCANCEL), _
            WinGetTitle($hWnd), "$hWnd=" & $hWnd & @CRLF & _
            "$lParam=" & $lParam & @CRLF & _
            "$hWnd(type)=" & VarGetType($hWnd))

    If $iRes <> $IDOK Then Return 0 ; Cancel/Close button clicked, return 0 to stop enumeration.

    Return 1 ; Return 1 to continue enumeration.
EndFunc   ;==>_EnumWindowsProc


Function DllClose

Function Reference

DllClose

Closes a previously opened DLL.

DllClose ( dllhandle )

Parameters

dllhandle The handle of a dll, as returned by a previous call to DllOpen().

Return Value

None.

Remarks

Upon termination, AutoIt automatically closes any dlls it opened but calling DllClose() is still a good idea.

Related

DllCall, DllOpen

Example

Local $hDLL = DllOpen("user32.dll")
DllCall($hDLL, "int", "MessageBox", "hwnd", 0, "str", "Some text", "str", "Some title", "int", 0)
DllClose($hDLL)


Function DllOpen

Function Reference

DllOpen

Opens a DLL file for use in DllCall.

DllOpen ( "filename" )

Parameters

filename Filename of the DLL file to open.

Return Value

Success: | a dll "handle" to be used with subsequent Dll functions.
Failure: | -1 if error occurs.

Remarks

When finished working with a dll, call the DllClose() function to close it. AutoIt normally closes all files upon termination, but explicitly calling DllClose() is still a good idea.

Related

DllCall, DllClose

Example

Local $hDLL = DllOpen("user32.dll")
DllCall($hDLL, "int", "MessageBox", "hwnd", 0, "str", "Some text", "str", "Some title", "int", 0)
DllClose($hDLL)


Function DllStructCreate

Function Reference

DllStructCreate

Creates a C/C++ style structure to be used in DllCall.

DllStructCreate ( Struct [, Pointer] )

Parameters

Struct | A string representing the structure to create (See Remarks).
Pointer | [optional] If supplied the struct will not allocate memory but use the pointer supplied.

Return Value

Success: | a variable for use with DllStruct calls.
Failure: | sets the @error flag to non-zero.
@error: | 1 = Variable passed to DllStructCreate was not a string. 2 = There is an unknown Data Type in the string passed. 3 = Failed to allocate the memory needed for the struct, or Pointer = 0. 4 = Error allocating memory for the passed string.

Type | Details
BYTE | 8bit(1byte) unsigned char
BOOLEAN | 8bit(1byte) unsigned char
CHAR | 8bit(1byte) ASCII char
WCHAR | 16bit(2byte) UNICODE wide char
SHORT | 16bit(2bytes) signed integer
USHORT | 16bit(2bytes) unsigned integer
WORD | 16bit(2bytes) unsigned integer
INT | 32bit(4bytes) signed integer
LONG | 32bit(4bytes) signed integer
BOOL | 32bit(4bytes) signed integer
UINT | 32bit(4bytes) unsigned integer
ULONG | 32bit(4bytes) unsigned integer
DWORD | 32bit(4bytes) unsigned integer
INT64 | 64bit(8bytes) signed integer
UINT64 | 64bit(8bytes) unsigned integer
PTR | 32 or 64bit pointer (depending on if the x86 or x64 version of AutoIt is used)
HWND | 32 or 64bit pointer (depending on if the x86 or x64 version of AutoIt is used)
HANDLE | 32 or 64bit pointer (depending on if the x86 or x64 version of AutoIt is used)
FLOAT | 32bit(4bytes) floating point
DOUBLE | 64bit(8bytes) floating point
INT_PTR, LONG_PTR, LRESULT, LPARAM | 32 or 64bit signed integer (depending on if the x86 or x64 version of AutoIt is used)
UINT_PTR, ULONG_PTR, DWORD_PTR, WPARAM | 32 or 64bit unsigned integer (depending on if the x86 or x64 version of AutoIt is used)
STRUCT | The following datatypes will be align according to C declaration rules. See below.
ENDSTRUCT | End of the collection datatypes. Padding can occurs see below.
ALIGN | n bytes boundary where datatype must be aligned.

Remarks

Each data type must be separated by a semi-colon ';'.

Create arrays by adding '[size]' after the data type: DllStructCreate("int;char[128]")

An elementname can be added similar to a C-style declaration: DllStructCreate("int n;char buffer[128]").
This dataname can be used in place of the element in other DllStruct... functions. The dataname must be alphanumeric or an underscore.

If a collection of datatypes is defined as in a "struct{}" in C declaration, the "STRUCT; ...; ENDSTRUCT;" must be used.
This needs to be done to respect alignment inside the entire structure creation. No need if all datatypes are in the defined structure as an implicit structure alignment is done.

DllStructCreate("int;STRUCT;ptr;int;ENDSTRUCT;int") ; structure is 32 bytes under a Windows 64-bit and 16 under Windows 32-bit
DllStructCreate("int;ptr;int;int") ; structure is 24 bytes under a Windows 64-bit and 16 under Windows 32-bit

To use a different alignment prefix the structure with the align keyword. The default value for n is 8. Valid values are 1, 2, 4, 8, and 16. The alignment of a member will be on a boundary that is either a multiple of n or a multiple of the size of the member, whichever is smaller. This is equivalent to the #pragma pack option with the Microsoft Visual C++ compiler.

DllStructCreate("short;int") ; structure is 8 bytes, the "int" is at offset 4
DllStructCreate("align 2;short;int") ; structure is 6 bytes, the "int" is at offset 2

DllStructCreate("byte;double") ; structure is 16 bytes, the "double" is at offset 8
DllStructCreate("align 4;byte;double") ; structure is 12 bytes, the "double" is at offset 4

If a change of alignment is needed "align" can be use before the first element which need to be changed.
"align" or "align 8" leads to default alignment.

To release allocated memory just set the returned variable to 0.

The following aggregate alignment rules apply:
The alignment of an array is the same as the alignment of one of the elements of the array.

The alignment of the beginning of a structure is the maximum alignment of any individual member.
Each member within the structure is be placed at its proper alignment as defined in the previous table, which require implicit internal padding, depending on the previous member.

Structure size is an integral multiple of its alignment, which requires padding after the last member.

Related

DllCall, DllStructGetData, DllStructGetPtr, DllStructGetSize, DllStructSetData, IsDllStruct

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    #cs Comments:
    Create the following structure (C language):
    struct {
        int var1;
        unsigned char var2;
        unsigned int var3;
        char var4[128];
    };

    Schema:
    ------------------------------------
    \ int    \ byte   \ uint   \ char   \
     \   var1 \   var2 \   var3 \   var4 \
      ------------------------------------
    #ce

    ; Assign a Local constant variable the definition of a structure (read carefully the DllStructCreate remarks).
    Local Const $tagSTRUCT1 = "struct;int var1;byte var2;uint var3;char var4[128];endstruct"

    ; Note: The tag variable is declared as Constant because its value will never change for any script execution.

    ; Assign a Local variable the structure.
    Local $tSTRUCT1 = DllStructCreate($tagSTRUCT1)

    ; If an error occurred display the error code and return False.
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "Error in DllStructCreate, Code: " & @error)
        Return False
    EndIf

    ; Set the data of the element var1 (int) in the $tSTRUCT1.
    DllStructSetData($tSTRUCT1, "var1", -1) ; Or 1 instead of "var1".

    ; Set the data of the element var2 (byte) in the $tSTRUCT1.
    DllStructSetData($tSTRUCT1, 2, 255) ; Or "var2" instead of 2.

    ; Set the data of the element var3 (uint) in the $tSTRUCT1.
    DllStructSetData($tSTRUCT1, "var3", -1) ; The -1 (signed int) will be typecasted to unsigned int.
    ; Or 3 instead of "var3".

    ; Set the data of the element var4 (char) in the $tSTRUCT1.
    DllStructSetData($tSTRUCT1, "var4", "Hello") ; Or 4 instead of "var4".

    ; Note: This element can contain up to 128 characters.

    ; Change the data of the element var4 (char) in the $tSTRUCT1, at the index 1 of the char array (1 based index).
    DllStructSetData($tSTRUCT1, "var4", Asc("h"), 1)

    ; Display the results.
    MsgBox($MB_SYSTEMMODAL, "", "Struct Size: " & DllStructGetSize($tSTRUCT1) & @CRLF & _
            "Struct pointer: " & DllStructGetPtr($tSTRUCT1) & @CRLF & _
            "Data:" & @CRLF & _
            DllStructGetData($tSTRUCT1, 1) & @CRLF & _ ; Or "var1" instead of 1.
            DllStructGetData($tSTRUCT1, "var2") & @CRLF & _ ; Or 2 instead of "var2".
            DllStructGetData($tSTRUCT1, 3) & @CRLF & _ ; Or "var3" instead of 3.
            DllStructGetData($tSTRUCT1, 4)) ; Or "var4" instead of 4.

    ; Release the resources used by the structure.
    $tSTRUCT1 = 0
EndFunc   ;==>Example


Function DllStructGetData

Function Reference

DllStructGetData

Returns the data of an element of the struct.

DllStructGetData ( Struct, Element [, index = Default] )

Parameters

Struct | The struct returned by DllStructCreate().
Element | Which element of the struct you want to access, starting at 1 or the element name as defined in DllStructCreate().
index | [optional] For elements that are an array this specifies the 1-based index to retrieve. If omitted or the Default keyword then the entire array is retrieved (Useful for quickly retrieving strings). Not used for non-array elements.

Return Value

Success: | Data in the element of the struct.
Failure: | 0.
@error: | 1 = Struct not a valid struct returned by DllStructCreate(). 2 = Element out of range or unknown. 3 = Index out of range. 4 = Element data type is unknown 5 = Index <= 0.

Remarks

When the element is char or char[n], wchar or wchar[n] the data returned is always a String(),
when the element is byte[n] and index is omitted the data returned is a binary type,
otherwise it always returns the best fit AutoIt datatype corresponding to the type of the individual element (e.g. byte returns Int32, float returns Double).

Related

DllStructCreate, DllStructSetData

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    #cs Comments:
    Create the following structure (C language):
    struct {
        int var1;
        unsigned char var2;
        unsigned int var3;
        char var4[128];
    };

    Schema:
    ------------------------------------
    \ int    \ byte   \ uint   \ char   \
     \   var1 \   var2 \   var3 \   var4 \
      ------------------------------------
    #ce

    ; Assign a Local constant variable the definition of a structure (read carefully the DllStructCreate remarks).
    Local Const $tagSTRUCT1 = "struct;int var1;byte var2;uint var3;char var4[128];endstruct"

    ; Note: The tag variable is declared as Constant because its value will never change for any script execution.

    ; Assign a Local variable the structure.
    Local $tSTRUCT1 = DllStructCreate($tagSTRUCT1)

    ; If an error occurred display the error code and return False.
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "Error in DllStructCreate, Code: " & @error)
        Return False
    EndIf

    ; Set the data of the element var1 (int) in the $tSTRUCT1.
    DllStructSetData($tSTRUCT1, "var1", -1) ; Or 1 instead of "var1".

    ; Set the data of the element var2 (byte) in the $tSTRUCT1.
    DllStructSetData($tSTRUCT1, 2, 255) ; Or "var2" instead of 2.

    ; Set the data of the element var3 (uint) in the $tSTRUCT1.
    DllStructSetData($tSTRUCT1, "var3", -1) ; The -1 (signed int) will be typecasted to unsigned int.
    ; Or 3 instead of "var3".

    ; Set the data of the element var4 (char) in the $tSTRUCT1.
    DllStructSetData($tSTRUCT1, "var4", "Hello") ; Or 4 instead of "var4".

    ; Note: This element can contain up to 128 characters.

    ; Change the data of the element var4 (char) in the $tSTRUCT1, at the index 1 of the char array (1 based index).
    DllStructSetData($tSTRUCT1, "var4", Asc("h"), 1)

    ; Display the results.
    MsgBox($MB_SYSTEMMODAL, "", "Struct Size: " & DllStructGetSize($tSTRUCT1) & @CRLF & _
            "Struct pointer: " & DllStructGetPtr($tSTRUCT1) & @CRLF & _
            "Data:" & @CRLF & _
            DllStructGetData($tSTRUCT1, 1) & @CRLF & _ ; Or "var1" instead of 1.
            DllStructGetData($tSTRUCT1, "var2") & @CRLF & _ ; Or 2 instead of "var2".
            DllStructGetData($tSTRUCT1, 3) & @CRLF & _ ; Or "var3" instead of 3.
            DllStructGetData($tSTRUCT1, 4)) ; Or "var4" instead of 4.

    ; Release the resources used by the structure.
    $tSTRUCT1 = 0
EndFunc   ;==>Example


Function DllStructGetPtr

Function Reference

DllStructGetPtr

Returns the pointer to the struct or an element in the struct.

DllStructGetPtr ( Struct [, Element] )

Parameters

Struct | The struct returned by DllStructCreate().
Element | [optional] The element of the struct whose pointer you need, starting at 1 or the element name as defined in DllStructCreate().

Return Value

Success: | The pointer to the struct.
Failure: | 0.
@error: | 1 = Struct not a valid struct returned by DllStructCreate(). 2 = Element out of range.

Remarks

Used in DllCall().

Related

DllCall, DllStructCreate

Example

Example 1

#include <MsgBoxConstants.au3>
#include <StructureConstants.au3>

Example()

Func Example()
    ; Assign a Local variable the handle of the current active window.
    Local $hWnd = WinGetHandle("") ; Same as: "[active]".

    ; Assign a Local variable the window's rectangle (array).
    Local $aWndPos = WinGetPos($hWnd)

    ; Assign a Local variable the structure created with the tagRECT definition.
    Local $tRECT = DllStructCreate($tagRECT)
    Local $iError = 0

    ; If an error occurred display the error code and return False.
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), Default, "Error in DllStructCreate, Code: " & $iError)
        Return False
    EndIf

    ; Make the DllCall of the GetWindowRect function.
    DllCall("user32.dll", "int", "GetWindowRect", _
            "hwnd", $hWnd, _
            "ptr", DllStructGetPtr($tRECT))

    ; If an error occurred display the error code and return False.
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), Default, "Error in DllCall, Code: " & $iError)
        Return False
    EndIf

    ; Note: The 2nd parameter of the GetWindowRect function requires a pointer,
    ; the result returned by the DllStructCreate is NOT a pointer, but using 'struct*' allows to pass a structure as a ptr.

    ; Assign Local variables the returned rectangle.
    Local $iLeft = DllStructGetData($tRECT, "Left") ; Or 1 instead of "Left".
    Local $iTop = DllStructGetData($tRECT, 2) ; Or "Top" instead of 2.
    Local $iRight = DllStructGetData($tRECT, 3) ; Or "Right" instead of 3.
    Local $iBottom = DllStructGetData($tRECT, "Bottom") ; Or 4 instead of "Bottom".

    ; Release the resources used by the structure.
    $tRECT = 0

    ; Display the results of WinGetPos and the returned rectangle.
    MsgBox($MB_SYSTEMMODAL, "", "WinGetPos(): (" & $aWndPos[0] & ", " & $aWndPos[1] & ") " & _
            "(" & $aWndPos[2] + $aWndPos[0] & ", " & $aWndPos[3] + $aWndPos[1] & ")" & @CRLF & _
            "GetWindowRect(): (" & $iLeft & ", " & $iTop & ") (" & $iRight & ", " & $iBottom & ")")
EndFunc   ;==>Example

Example 2

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign a Local variable a structure with the definition of an int.
    Local $tSTRUCT1 = DllStructCreate("int")
    Local $iError = 0

    ; If an error occurred display the error code and return False.
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), Default, "Error in DllCall, Code: " & $iError)
        Return False
    EndIf

    ; Assign a Local variable the tSTRUCT1 structure except that the elements will be got according to the new definition.
    Local $tSTRUCT2 = DllStructCreate("uint", DllStructGetPtr($tSTRUCT1, 1))

    ; If an error occurred display the error code and return False.
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), Default, "Error in DllCall, Code: " & $iError)
        Return False
    EndIf

    Local $tSTRUCT3 = DllStructCreate("float", DllStructGetPtr($tSTRUCT1, 1))

    ; If an error occurred display the error code and return False.
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), Default, "Error in DllCall, Code: " & $iError)
        Return False
    EndIf

    ; Notes: -The structures points to the same structure (they have the same pointer);
    ; The first element got with the:
    ; *tSTRUCT1 struct will be an int.
    ; *tSTRUCT2 struct will be an unsigned int (the element is casted from int to uint).
    ; *tSTRUCT3 struct will be a float (the element is casted from int to float).
    ;
    ; -The "reinterpret_cast" casting operator is used.

    ; Set the data of the first element (int) in the $tSTRUCT1.
    DllStructSetData($tSTRUCT1, 1, -1)

    ; Display the different data types of the same data.
    MsgBox($MB_SYSTEMMODAL, "", _
            "int: " & DllStructGetData($tSTRUCT1, 1) & @CRLF & _
            "uint: " & DllStructGetData($tSTRUCT2, 1) & @CRLF & _
            "float: " & DllStructGetData($tSTRUCT3, 1))

    ; Release the resources used by the structures.
    $tSTRUCT1 = 0
    $tSTRUCT2 = 0
    $tSTRUCT3 = 0
EndFunc   ;==>Example


Function DllStructGetSize

Function Reference

DllStructGetSize

Returns the size of the struct in bytes.

DllStructGetSize ( Struct )

Parameters

Struct The struct returned by DllStructCreate().

Return Value

Success: | the size of the struct in bytes.
Failure: | 0.
@error: | 1 = Struct not a correct struct returned by DllStructCreate().

Remarks

Used when data in the struct needs to hold the struct size.

Related

DllStructCreate, DllStructSetData

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign a Local constant variable the definition of a structure.
    Local Const $tagSTRUCT1 = "struct;int var1;byte var2;uint var3;char var4[128];endstruct"

    ; Assign a Local variable the structure.
    Local $tSTRUCT1 = DllStructCreate($tagSTRUCT1)

    ; If an error occurred display the error code and return False.
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "Error in DllStructCreate, Code: " & @error)
        Return False
    EndIf

    #cs Comments:
    -The default alignment for the data is 4 bytes, thus each element will take at least 4 bytes.
    -The min size can be obtained by setting an alignment of 1 at the beginning of the struct definition: "align 1;struct; ..."

    -Detailed information on the struct size:
    var1: int - 4 bytes
    var2: byte - 1 byte + 3 bytes alignment = 4 bytes
    var3: uint - 4 bytes
    var4: char[128] - 1 * 128 bytes
    #ce

    MsgBox($MB_SYSTEMMODAL, "", "Struct Size: " & DllStructGetSize($tSTRUCT1))
EndFunc   ;==>Example


Function DllStructSetData

Function Reference

DllStructSetData

Sets the data of an element in the struct.

DllStructSetData ( Struct, Element, value [, index] )

Parameters

Struct | The struct returned by DllStructCreate().
Element | Which element of the struct you want to access, starting at 1, or the element name as defined in DllStructCreate().
value | The new value to place in the struct element.
index | [optional] For elements that are an array this specifies the 1-based index to set. If omitted or the Default keyword then as much of the value as possible will be set in element starting at index 1 (Useful for quickly setting strings). Not used for non-array elements.

Return Value

Success: | value, which is read back from the struct.
Failure: | 0.
@error: | 1 = Struct not a valid struct returned by DllStructCreate(). 2 = Element out of range or unknown. 3 = Index out of range. 4 = Element data type is unknown 5 = Index <=0.

Remarks

When the element is char[n], wchar[n] or byte[n] the data can be a string. byte[n] also accepts binary data. Otherwise the data has to be either an AutoIt type compatible with the element type, or a number which will be converted to the required type.
Native AutoIt strings are implicitely converted to ANSI prior to copy into a char[n] or byte[n] element. You need to convert native Unicode strings to UTF8 when the element is expecting this encoding (e.g. in DllCall).

Related

DllStructCreate, DllStructGetData, DllStructGetSize

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    #cs Comments:
    Create the following structure (C language):
    struct {
        int var1;
        unsigned char var2;
        unsigned int var3;
        char var4[128];
    };

    Schema:
    ------------------------------------
    \ int    \ byte   \ uint   \ char   \
     \   var1 \   var2 \   var3 \   var4 \
      ------------------------------------
    #ce

    ; Assign a Local constant variable the definition of a structure (read carefully the DllStructCreate remarks).
    Local Const $tagSTRUCT1 = "struct;int var1;byte var2;uint var3;char var4[128];endstruct"

    ; Note: The tag variable is declared as Constant because its value will never change for any script execution.

    ; Assign a Local variable the structure.
    Local $tSTRUCT1 = DllStructCreate($tagSTRUCT1)

    ; If an error occurred display the error code and return False.
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "Error in DllStructCreate, Code: " & @error)
        Return False
    EndIf

    ; Set the data of the element var1 (int) in the $tSTRUCT1.
    DllStructSetData($tSTRUCT1, "var1", -1) ; Or 1 instead of "var1".

    ; Set the data of the element var2 (byte) in the $tSTRUCT1.
    DllStructSetData($tSTRUCT1, 2, 255) ; Or "var2" instead of 2.

    ; Set the data of the element var3 (uint) in the $tSTRUCT1.
    DllStructSetData($tSTRUCT1, "var3", -1) ; The -1 (signed int) will be typecasted to unsigned int.
    ; Or 3 instead of "var3".

    ; Set the data of the element var4 (char) in the $tSTRUCT1.
    DllStructSetData($tSTRUCT1, "var4", "Hello") ; Or 4 instead of "var4".

    ; Note: This element can contain up to 128 characters.

    ; Change the data of the element var4 (char) in the $tSTRUCT1, at the index 1 of the char array (1 based index).
    DllStructSetData($tSTRUCT1, "var4", Asc("h"), 1)

    ; Display the results.
    MsgBox($MB_SYSTEMMODAL, "", "Struct Size: " & DllStructGetSize($tSTRUCT1) & @CRLF & _
            "Struct pointer: " & DllStructGetPtr($tSTRUCT1) & @CRLF & _
            "Data:" & @CRLF & _
            DllStructGetData($tSTRUCT1, 1) & @CRLF & _ ; Or "var1" instead of 1.
            DllStructGetData($tSTRUCT1, "var2") & @CRLF & _ ; Or 2 instead of "var2".
            DllStructGetData($tSTRUCT1, 3) & @CRLF & _ ; Or "var3" instead of 3.
            DllStructGetData($tSTRUCT1, 4)) ; Or "var4" instead of 4.

    ; Release the resources used by the structure.
    $tSTRUCT1 = 0
EndFunc   ;==>Example


Function ProcessClose

Function Reference

ProcessClose

Terminates a named process.

ProcessClose ( "process" )

Parameters

process The name or PID of the process to terminate.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 = OpenProcess failed 2 = AdjustTokenPrivileges Failed 3 = TerminateProcess Failed 4 = Cannot verify if process exists
@extended: | sets to Windows API GetLastError()

Remarks

Process names are executables without the full path, e.g., "notepad.exe" or "winword.exe"

If multiple processes have the same name, the one with the highest PID is terminated--regardless of how recently the process was spawned.

PID is the unique number which identifies a Process. A PID can be obtained through the ProcessExists() or Run() commands.

The process is polled approximately every 250 milliseconds.

Related

ProcessExists, ProcessList, ProcessWait, ProcessWaitClose, Run, RunAs, Shutdown, WinClose, WinKill

Example

Example()

Func Example()
    ; Run Notepad
    Local $iPID = Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    WinWait("[CLASS:Notepad]", "", 10)

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Close the Notepad process using the PID returned by Run.
    ProcessClose($iPID)
EndFunc   ;==>Example


Function ProcessExists

Function Reference

ProcessExists

Checks to see if a specified process exists.

ProcessExists ( "process" )

Parameters

process The name or PID of the process to check.

Return Value

Success: | the PID of the process.
Failure: | 0 if process does not exist.

Remarks

Process names are executables without the full path, e.g., "notepad.exe" or "winword.exe"

PID is the unique number which identifies a Process.

The process is polled approximately every 250 milliseconds.

Related

ProcessClose, ProcessList, ProcessWait, ProcessWaitClose, WinExists

Example

#include <MsgBoxConstants.au3>

If ProcessExists("notepad.exe") Then ; Check if the Notepad process is running.
    MsgBox($MB_SYSTEMMODAL, "", "Notepad is running")
Else
    MsgBox($MB_SYSTEMMODAL, "", "Notepad is not running")
EndIf


Function ProcessGetStats

Function Reference

ProcessGetStats

Returns an array about Memory or IO infos of a running process.

ProcessGetStats ( ["process" [, type = 0]] )

Parameters

process | [optional] The name or PID of the process to get infos from. Default (-1) is the current process.
type | [optional] $PROCESS_STATS_MEMORY (0) = (default) memory infos. $PROCESS_STATS_IO (1) = IO infos. Constants are defined in "AutoItConstants.au3".

Return Value

Success: | an array of infos data (See Remarks).
Failure: | sets the @error flag to non-zero.

Remarks

The array returned is mono-dimensional and is made up as follows:

Type = $PROCESS_STATS_MEMORY
$aArray[0] = WorkingSetSize
$aArray[1] = PeakWorkingSetSize

Type = $PROCESS_STATS_IO
$aArray[0] = number of read operations performed.
$aArray[1] = number of write operations performed.
$aArray[2] = number of I/O operations performed, other than read and write operations.
$aArray[3] = number of bytes read.
$aArray[4] = number of bytes write.
$aArray[5] = number of bytes transferred during operations other than read and write operations.

Related

ProcessList

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Retrieve memory details about the current process.
    Local $aMemory = ProcessGetStats()

    ; If $aMemory is an array then display the following details about the process.
    If IsArray($aMemory) Then
        MsgBox($MB_SYSTEMMODAL, "", "WorkingSetSize: " & $aMemory[0] & @CRLF & _
                "PeakWorkingSetSize: " & $aMemory[1])
    Else
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred.")
    EndIf
EndFunc   ;==>Example


Function ProcessSetPriority

Function Reference

ProcessSetPriority

Changes the priority of a process.

ProcessSetPriority ( "process", priority )

Parameters

process | The name or PID of the process to check.
priority | A flag which determines what priority to set $PROCESS_LOW (0) = Idle/Low $PROCESS_BELOWNORMAL (1) = Below Normal $PROCESS_NORMAL (2) = Normal $PROCESS_ABOVENORMAL (3) = Above Normal $PROCESS_HIGH (4) = High $PROCESS_REALTIME (5) = Realtime (Use with caution, may make the system unstable) Constants are define in "AutoItConstants.au3".

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1. 2 if attempting to use an unsupported priority class.

Related

ProcessList

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Set the priority of the Notepad process to "Idle/Low".
    ProcessSetPriority("notepad.exe", 0)

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function ProcessList

Function Reference

ProcessList

Returns an array listing the currently running processes (names and PIDs).

ProcessList ( ["name"] )

Parameters

name [optional] If a name is given only processes of the same name will be returned.

Return Value

Success: | an array of process names and PIDs (See Remarks).
Failure: | sets the @error flag to 1 when the array cannot be built.

Remarks

The array returned is two-dimensional and is made up as follows:
$aArray[0][0] = Number of processes
$aArray[1][0] = 1st Process name
$aArray[1][1] = 1st Process ID (PID)
$aArray[2][0] = 2nd Process name
$aArray[2][1] = 2nd Process ID (PID)
...
$aArray[n][0] = nth Process name
$aArray[n][1] = nth Process ID (PID)

The list can be empty if $aArray[0][0] = 0. No @error set in this case.

Related

ProcessClose, ProcessExists, ProcessGetStats, ProcessSetPriority, ProcessWait, ProcessWaitClose, WinGetProcess

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Display a list of Notepad processes returned by ProcessList.
    Local $aProcessList = ProcessList("notepad.exe")
    For $i = 1 To $aProcessList[0][0]
        MsgBox($MB_SYSTEMMODAL, "", $aProcessList[$i][0] & @CRLF & "PID: " & $aProcessList[$i][1])
    Next

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function ProcessWait

Function Reference

ProcessWait

Pauses script execution until a given process exists.

ProcessWait ( "process" [, timeout = 0] )

Parameters

process | The name of the process to check.
timeout | [optional] Specifies how long to wait (in seconds). Default is to wait indefinitely.

Return Value

Success: | the Pid of the process.
Failure: | 0 if the wait timed out.

Remarks

Process names are executables without the full path, e.g., "notepad.exe" or "winword.exe"

The process is polled approximately every 250 milliseconds.

This function is the only process function not to accept a PID. Because PIDs are allocated randomly, waiting for a particular PID to exist doesn't make sense.

Related

ProcessClose, ProcessExists, ProcessList, ProcessWaitClose, RunAsWait, RunWait, WinGetProcess, WinWait, WinWaitActive

Example

; Wait for the Notepad process to exist.

ProcessWait("notepad.exe")


Function ProcessWaitClose

Function Reference

ProcessWaitClose

Pauses script execution until a given process does not exist.

ProcessWaitClose ( "process" [, timeout = 0] )

Parameters

process | The name or PID of the process to check.
timeout | [optional] Specifies how long to wait (in seconds). Default is to wait indefinitely.

Return Value

Success: | 1 and sets @extended to the exit code of the process.
Failure: | 0 if the wait timed out. On invalid PID the @error flag is set to non-zero and @extended is set to 0xCCCCCCCC.

Remarks

Process names are executables without the full path, e.g., "notepad.exe" or "winword.exe"

PID is the unique number which identifies a Process. A PID can be obtained through the ProcessExists() or Run() commands.

The process is polled approximately every 250 milliseconds.

The return is 1 if the process was not existing.

Related

ProcessClose, ProcessExists, ProcessList, ProcessWait, RunAsWait, RunWait, WinGetProcess, WinWaitClose

Example

; Wait until no instance of Notepad exists.
ProcessWaitClose("notepad.exe")

; Wait until this particular instance of Notepad is closed by the user.
Local $iPID = Run("notepad.exe")
ProcessWaitClose($iPID)


Function Run

Function Reference

Run

Runs an external program.

Run ( "program" [, "workingdir" [, show_flag [, opt_flag]]] )

Parameters

program | The full path of the program (EXE, BAT, COM, or PIF) to run (see remarks).
workingdir | [optional] The working directory. Blank ("") uses the current working directory. This is not the path to the program.
show_flag | [optional] The "show" flag of the executed program: @SW_HIDE = Hidden window (or Default keyword) @SW_MINIMIZE = Minimized window @SW_MAXIMIZE = Maximized window
opt_flag | [optional] Controls various options related to how the parent and child process interact. $STDIN_CHILD (0x1) = Provide a handle to the child's STDIN stream $STDOUT_CHILD (0x2) = Provide a handle to the child's STDOUT stream $STDERR_CHILD (0x4) = Provide a handle to the child's STDERR stream $STDERR_MERGED (0x8) = Provides the same handle for STDOUT and STDERR. Implies both $STDOUT_CHILD and $STDERR_CHILD. $STDIO_INHERIT_PARENT (0x10) = Provide the child with the parent's STDIO streams. This flag can not be combined with any other STDIO flag. This flag is only useful when the parent is compiled as a Console application. $RUN_CREATE_NEW_CONSOLE (0x10000) = The child console process should be created with it's own window instead of using the parent's window. This flag is only useful when the parent is compiled as a Console application. Constants are defined in AutoItConstants.au3.

Return Value

Success: | the PID of the process that was launched.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

Paths with spaces need to be enclosed in quotation marks.

To run DOS (console) commands, try Run(@ComSpec & " /c " & 'commandName', "", @SW_HIDE) ; don't forget " " before "/c"

After running the requested program the script continues. To pause execution of the script until the spawned program has finished use the RunWait() function instead.

Providing the Standard I/O parameter with the proper values permits interaction with the child process through the StderrRead(), StdinWrite() and StdoutRead() functions. Combine the flag values (or use $STDERR_CHILD, $STDIN_CHILD & $STDOUT_CHILD) to manage more than one stream.

In order for the streams to close, the following conditions must be met:
1) The child process has closed its end of the stream (this happens when the child closes).
2) AutoIt must read any captured streams until there is no more data.
3) If STDIN is provided for the child, StdinWrite() must be called to close the stream. Once all streams are detected as no longer needed, all internal resources will automatically be freed.

StdioClose() can be used to force the STDIO streams closed.

Related

ConsoleRead, ProcessClose, RunAs, RunAsWait, RunWait, ShellExecute, ShellExecuteWait, StderrRead, StdinWrite, StdioClose, StdoutRead

Example

Example()

Func Example()
    ; Run Notepad with the window maximized.
    Local $iPID = Run("notepad.exe", "", @SW_SHOWMAXIMIZED)

    ; Wait 10 seconds for the Notepad window to appear.
    WinWait("[CLASS:Notepad]", "", 10)

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Close the Notepad process using the PID returned by Run.
    ProcessClose($iPID)
EndFunc   ;==>Example


Function RunWait

Function Reference

RunWait

Runs an external program and pauses script execution until the program finishes.

RunWait ( "program" [, "workingdir" [, show_flag [, opt_flag]]] )

Parameters

program | The full path of the program (EXE, BAT, COM, or PIF) to run (see remarks).
workingdir | [optional] The working directory. Blank ("") uses the current working directory. This is not the path to the program.
show_flag | [optional] The "show" flag of the executed program: @SW_HIDE = Hidden window (or Default keyword) @SW_MINIMIZE = Minimized window @SW_MAXIMIZE = Maximized window
opt_flag | [optional] Controls various options related to how the parent and child process interact. 0x10000 ($RUN_CREATE_NEW_CONSOLE) = The child console process should be created with its own window instead of using the parents window. This flag is only useful when the parent is compiled as a Console application.

Return Value

Success: | the exit code of the program that was run.
Failure: | sets the @error flag to non-zero.

Remarks

Paths with spaces need to be enclosed in quotation marks.

To run DOS commands, try RunWait(@ComSpec & " /c " & "commandName") ; don't forget " " before "/c"

After running the requested program the script pauses until the program terminates. To run a program and then immediately continue script execution use the Run() function instead.

Some programs will appear to return immediately even though they are still running; these programs spawn another process - you may be able to use the ProcessWaitClose() function to handle these cases.

Related

ProcessWait, ProcessWaitClose, Run, RunAs, RunAsWait, ShellExecute, ShellExecuteWait

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad and wait for the Notepad process to close.
    Local $iReturn = RunWait("notepad.exe")

    ; Display the return code of the Notepad process.
    MsgBox($MB_SYSTEMMODAL, "", "The return code from Notepad was: " & $iReturn)
EndFunc   ;==>Example


Function RunAs

Function Reference

RunAs

Runs an external program under the context of a different user.

RunAs ( "username", "domain", "password", logon_flag, "program" [, "workingdir" [, show_flag [, opt_flag]]] )

Parameters

username | The username to log on with.
domain | The domain to authenticate against.
password | The password for the user.
logon_flag | $RUN_LOGON_NOPROFILE (0) - Interactive logon with no profile. $RUN_LOGON_PROFILE (1) - Interactive logon with profile. $RUN_LOGON_NETWORK (2) - Network credentials only. $RUN_LOGON_INHERIT (4) - Inherit the calling process's environment instead of the user's environment. Constants are defined in "AutoItConstants.au3".
program | The full path of the program (EXE, BAT, COM, or PIF) to run (see remarks).
workingdir | [optional] The working directory. If not specified, then the value of @SystemDir will be used. This is not the path to the program.
show_flag | [optional] The "show" flag of the executed program: @SW_HIDE = Hidden window (or Default keyword) @SW_MINIMIZE = Minimized window @SW_MAXIMIZE = Maximized window
opt_flag | [optional] Controls various options related to how the parent and child process interact. $STDIN_CHILD (0x1) = Provide a handle to the child's STDIN stream $STDOUT_CHILD (0x2) = Provide a handle to the child's STDOUT stream $STDERR_CHILD (0x4) = Provide a handle to the child's STDERR stream $STDERR_MERGED (0x8) = Provides the same handle for STDOUT and STDERR. Implies both $STDOUT_CHILD and $STDERR_CHILD. $STDIO_INHERIT_PARENT (0x10) = Provide the child with the parent's STDIO streams. This flag can not be combined with any other STDIO flag. This flag is only useful when the parent is compiled as a Console application. $RUN_CREATE_NEW_CONSOLE (0x10000) = The child console process should be created with it's own window instead of using the parent's window. This flag is only useful when the parent is compiled as a Console application. Constants are defined in AutoItConstants.au3

Return Value

Success: | the PID of the process that was launched.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

Paths with spaces need to be enclosed in quotation marks.

It is important to specify a working directory the user you are running as has access to, otherwise the function will fail.

It is recommended that you only load the user's profile is you are sure you need it. There is a small chance a profile can be stuck in memory under the right conditions. If a script using RunAs() happens to be running as the SYSTEM account (for example, if the script is running as a service) and the user's profile is loaded, then you must take care that the script remains running until the child process closes.

When running as an administrator, the Secondary Logon (RunAs()) service must be enabled or this function will fail. This does not apply when running as the SYSTEM account.

After running the requested program the script continues. To pause execution of the script until the spawned program has finished use the RunAsWait() function instead.

Providing the Standard I/O parameter with the proper values permits interaction with the child process through the StderrRead(), StdinWrite() and StdoutRead() functions. Combine the flag values (or use $STDERR_CHILD, $STDIN_CHILD & $STDOUT_CHILD) to manage more than one stream.

In order for the streams to close, the following conditions must be met:
1) The child process has closed its end of the stream (this happens when the child closes).
2) AutoIt must read any captured streams until there is no more data.
3) If STDIN is provided for the child, StdinWrite() must be called to close the stream. Once all streams are detected as no longer needed, all internal resources will automatically be freed.

StdioClose() can be used to force the STDIO streams closed.

The "load profile" and "network credentials only" options are incompatible. Using both will produce undefined results.

There is an issue in the Windows XP generation of Windows which prevents STDIO redirection and the show flag from working. See Microsoft Knowledge Base article KB818858 for more information about which versions are affected as well as a hotfix for the issue. Users running Windows XP SP2 or later, or Windows Vista or later are not affected.

Related

ProcessClose, Run, RunAsWait, RunWait, ShellExecute, ShellExecuteWait, StderrRead, StdinWrite, StdioClose, StdoutRead

Example

#include <AutoItConstants.au3>

Example()

Func Example()
    ; Change the username and password to the appropriate values for your system.
    Local $sUserName = "Username"
    Local $sPassword = "Password"

    ; Run Notepad with the window maximized. Notepad is run under the user previously specified.
    Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, $RUN_LOGON_NOPROFILE, "notepad.exe", "", @SW_SHOWMAXIMIZED)

    ; Wait 10 seconds for the Notepad window to appear.
    WinWait("[CLASS:Notepad]", "", 10)

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Close the Notepad process using the PID returned by RunAs.
    ProcessClose($iPID)
EndFunc   ;==>Example


Function RunAsWait

Function Reference

RunAsWait

Runs an external program under the context of a different user and pauses script execution until the program finishes.

RunAsWait ( "username", "domain", "password", logon_flag, "program" [, "workingdir" [, show_flag [, opt_flag]]] )

Parameters

username | The username to log on with.
domain | The domain to authenticate against.
password | The password for the user.
logon_flag | $RUN_LOGON_NOPROFILE (0) - Interactive logon with no profile. $RUN_LOGON_PROFILE (1) - Interactive logon with profile. $RUN_LOGON_NETWORK (2) - Network credentials only. $RUN_LOGON_INHERIT (4) - Inherit the calling process's environment instead of the user's environment. Constants are defined in "AutoItConstants.au3".
program | The full path of the program (EXE, BAT, COM, or PIF) to run (see remarks).
workingdir | [optional] The working directory. If not specified, then the value of @SystemDir will be used. This is not the path to the program.
show_flag | [optional] The "show" flag of the executed program: @SW_HIDE = Hidden window (or Default keyword) @SW_MINIMIZE = Minimized window @SW_MAXIMIZE = Maximized window
opt_flag | [optional] Controls various options related to how the parent and child process interact. $RUN_CREATE_NEW_CONSOLE (0x10000) = The child console process should be created with its own window instead of using the parent's window. This flag is only useful when the parent is compiled as a Console application. Constant is defined in AutoItConstants.au3

Return Value

Success: | the exit code of the program that was run.
Failure: | sets the @error flag to non-zero.

Remarks

Paths with spaces need to be enclosed in quotation marks.

It is important to specify a working directory the user you are running as has access to, otherwise the function will fail.

It is recommended that you only load the user's profile is you are sure you need it. There is a small chance a profile can be stuck in memory under the right conditions. If a script using RunAs() happens to be running as the SYSTEM account (for example, if the script is running as a service) and the user's profile is loaded, then you must take care that the script remains running until the child process closes.

When running as an administrator, the Secondary Logon (RunAs()) service must be enabled or this function will fail. This does not apply when running as the SYSTEM account.

After running the requested program the script pauses until the program terminates. To run a program and then immediately continue script execution use the RunAs() function instead.

Some programs will appear to return immediately even though they are still running; these programs spawn another process - you may be able to use the ProcessWaitClose() function to handle these cases.

The "load profile" and "network credentials only" options are incompatible. Using both will produce undefined results.

There is an issue in the Windows XP generation of Windows which prevents STDIO redirection and the show flag from working. See Microsoft Knowledge Base article KB818858 for more information about which versions are affected as well as a hotfix for the issue. Users running Windows XP SP2 or later, or Windows Vista or later are not affected.

Related

ProcessWait, ProcessWaitClose, Run, RunAs, RunWait, ShellExecute, ShellExecuteWait

Example

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Change the username and password to the appropriate values for your system.
    Local $sUserName = "Username"
    Local $sPassword = "Password"

    ; Run Notepad and wait for the Notepad process to close. Notepad is run under the user previously specified.
    Local $iReturn = RunAsWait($sUserName, @ComputerName, $sPassword, $RUN_LOGON_NOPROFILE, "notepad.exe")

    ; Display the return code of the Notepad process.
    MsgBox($MB_SYSTEMMODAL, "", "The return code from Notepad was: " & $iReturn)
EndFunc   ;==>Example


Function ShellExecute

Function Reference

ShellExecute

Runs an external program using the ShellExecute API.

ShellExecute ( "filename" [, "parameters" [, "workingdir" [, "verb" [, showflag]]]] )

Parameters

filename | The name of the file to run (EXE, .txt, .lnk, etc).
parameters | [optional] Any parameters for the program. Blank ("") uses none.
workingdir | [optional] The working directory. Blank ("") uses the current working directory.
verb | [optional] The "verb" to use, common verbs include: $SHEX_OPEN ("open") = Opens the file specified. The file can be an executable file, a document file, or a folder $SHEX_EDIT ("edit") = Launches an editor and opens the document for editing. If "filename" is not a document file, the function will fail $SHEX_PRINT ("print") = Prints the document file specified. If "filename" is not a document file, the function will fail $SHEX_PROPERTIES ("properties") = Displays the file or folder's properties See remarks for more information on the default behavior when a verb is not specified. Constants are defined in "AutoItConstants.au3".
showflag | [optional] The "show" flag of the executed program: @SW_HIDE = Hidden window @SW_MINIMIZE = Minimized window @SW_MAXIMIZE = Maximized window

Return Value

Success: | the PID of the process that was launched. Or -1 if there was no PID available.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

After running the requested program the script continues. To pause execution of the script until the spawned program has finished use the ShellExecuteWait() function instead.

When no verb is specified the default verb is used. The default verb is the verb configured in the registry. If no verb is set as default in the registry then the "open" verb is used. If the "open" verb is not present then the first verb listed in the registry is used.

Related

Run, RunAs, RunAsWait, RunWait, ShellExecuteWait

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Retrieve the following text file. This can be found in the include folder which is in the installation path of AutoIt.
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"

    ; Execute the readme file (.txt) with the default editor used for text files in Windows.
    Local $iPID = ShellExecute($sFile)

    MsgBox($MB_SYSTEMMODAL, "", "PID: " & $iPID)
EndFunc   ;==>Example


Function ShellExecuteWait

Function Reference

ShellExecuteWait

Runs an external program using the ShellExecute API and pauses script execution until it finishes.

ShellExecuteWait ( "filename" [, "parameters" [, "workingdir" [, "verb" [, showflag]]]] )

Parameters

filename | The name of the file to run (EXE, .txt, .lnk, etc).
parameters | [optional] Any parameters for the program. Blank ("") uses none.
workingdir | [optional] The working directory. Blank ("") uses the current working directory.
verb | [optional] The "verb" to use, common verbs include: $SHEX_OPEN ("open") = Opens the file specified. The file can be an executable file, a document file, or a folder $SHEX_EDIT ("edit") = Launches an editor and opens the document for editing. If "filename" is not a document file, the function will fail $SHEX_PRINT ("print") = Prints the document file specified. If "filename" is not a document file, the function will fail $SHEX_PROPERTIES ("properties") = Displays the file or folder's properties See remarks for more information on the default behavior when a verb is not specified. Constants are defined in "AutoItConstants.au3".
showflag | [optional] The "show" flag of the executed program: @SW_HIDE = Hidden window @SW_MINIMIZE = Minimized window @SW_MAXIMIZE = Maximized window

Return Value

Success: | the exit code of the program that was run.
Failure: | sets the @error flag to non-zero.

Remarks

After running the requested program the script pauses until the requested program terminates

When no verb is specified the default verb is used. The default verb is the verb configured in the registry. If no verb is set as default in the registry then the "open" verb is used. If the "open" verb is not present then the first verb listed in the registry is used.

Related

Run, RunAs, RunAsWait, RunWait, ShellExecute

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Execute Notepad and wait for the Notepad process to close.
    Local $iReturn = ShellExecuteWait("notepad.exe")

    ; Display the return code of the Notepad process.
    MsgBox($MB_SYSTEMMODAL, "", "The return code from Notepad was: " & $iReturn)
EndFunc   ;==>Example


Function Shutdown

Function Reference

Shutdown

Shuts down the system.

Shutdown ( code )

Parameters

code A combination of shutdown codes. See "remarks".

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to Windows API GetLastError().

Remarks

The shutdown code is a combination of the following values:
$SD_LOGOFF (0) = Logoff
$SD_SHUTDOWN (1) = Shutdown
$SD_REBOOT (2) = Reboot
$SD_FORCE (4) = Force
$SD_POWERDOWN (8) = Power down
$SD_FORCEHUNG (16) = Force if hung
$SD_STANDBY (32) = Standby
$SD_HIBERNATE (64) = Hibernate

Constants are defined in AutoItConstants.au3.

Required values should be BitOR()'ed together. To shutdown and power down, for example, the code would be BitOR($SD_SHUTDOWN, $SD_POWERDOWN).

Standby or Hibernate are ignored if other codes are set.

Related

ProcessClose

Example

; Force a reboot

Shutdown(6)


Function StderrRead

Function Reference

StderrRead

Reads from the STDERR stream of a previously run child process.

StderrRead ( process_id [, peek = False [, binary = False]] )

Parameters

process_id | The process ID of a child process, as returned by a previous call to Run.
peek | [optional] If True the function does not remove the read characters from the stream.
binary | [optional] If True the function reads the data as binary instead of text (default is text).

Return Value

Success: | the data read. @extended contains the number of bytes read.
Failure: | sets the @error flag to non-zero if EOF is reached, STDERR was not redirected for the process or other error.

Remarks

StderrRead() reads from the console standard output stream of a child process, which is normally used by console applications to write to the screen. During the call to Run() for the child process you wish to read from the STD I/O parameter must have included the value of $STDERR_CHILD (4) for this function to work properly (see the Run() function).
StderrRead() does not block, it will return immediately. In order to get all data, it must be called in a loop.
Peeking on the stream does not remove the data from the buffer, however, it does return the available data as normal.
By default, data is returned in text format. By using the binary option, the data will be returned in binary format.

Related

Run, RunAs, StdinWrite, StdioClose, StdoutRead

Example

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iPID = Run(@ComSpec & " /c DIR Example.au3", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    Local $sOutput = ""
    While 1
        $sOutput = StdoutRead($iPID)
        If @error Then ; Exit the loop if the process closes or StdoutRead returns an error.
            ExitLoop
        EndIf
        MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $sOutput)
    WEnd

    While 1
        $sOutput = StderrRead($iPID)
        If @error Then ; Exit the loop if the process closes or StderrRead returns an error.
            ExitLoop
        EndIf
        MsgBox($MB_SYSTEMMODAL, "Stderr Read:", $sOutput)
    WEnd
EndFunc   ;==>Example


Function StdinWrite

Function Reference

StdinWrite

Writes a number of characters to the STDIN stream of a previously run child process.

StdinWrite ( process_id [, data] )

Parameters

process_id | The process ID of a child process, as returned by a previous call to Run.
data | [optional] The data you wish to output. This may either be text or binary.

Return Value

Success: | the number of characters written.
Failure: | sets the @error flag to non-zero if STDIN was not redirected for the process or other error.

Remarks

StdinWrite() writes to the console standard input stream for a child process, which is normally used by console applications to read input from the user i.e. from the keyboard. During the call to Run() for the child process you wish to write to the STD I/O parameter must have included the value of $STDIN_CHILD (1) for this function to work properly (see the Run() function).

The optional second parameter is the string that you wish StdinWrite() to write to the stream. If the function is called with no second argument, StdinWrite() closes the stream and invalidates it for further writing.

The stream is a first-in first-out buffer with an arbitrary limited size; if at any time when this function is called (unless it's being called to close the stream) there is no room for more characters to be written to the stream, the StdinWrite() function will block (pause) and not return until the child process closes the stream or reads enough characters from the stream to permit the write procedure to complete. This means that the AutoIt process will be halted, and there will be no processing of hotkeys, GUI messages, etc. until the child process reads from the STDIN stream.

Characters are converted to ANSI before being written.

Binary data is written as-is. It will not be converted to a string. To print the hex representation of binary data, use the String() function to explicitly cast the data to a string.

Related

Run, RunAs, StderrRead, StdioClose, StdoutRead

Example

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iPID = Run("sort.exe", @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)

    ; Write a string of items to be sorted to child sort.exe's Stdin.
    StdinWrite($iPID, "Banana" & @CRLF & "Elephant" & @CRLF & "Apple" & @CRLF & "Deer" & @CRLF & "Car" & @CRLF)

    ; Calling StdinWrite without a second parameter closes the stream.
    StdinWrite($iPID)

    Local $sOutput = "" ; Store the output of StdoutRead to a variable.

    While 1
        $sOutput &= StdoutRead($iPID) ; Read the Stdout stream of the PID returned by Run.
        If @error Then ; Exit the loop if the process closes or StdoutRead returns an error.
            ExitLoop
        EndIf
    WEnd

    MsgBox($MB_SYSTEMMODAL, "", "The sorted string is: " & @CRLF & $sOutput)
EndFunc   ;==>Example


Function StdioClose

Function Reference

StdioClose

Closes all resources associated with a process previously run with STDIO redirection.

StdioClose ( process_id )

Parameters

process_id The process ID of a child process, as returned by a previous call to Run.

Return Value

Success: | Non-zero.
Failure: | 0 if the process did not have STDIO redirection or was already closed.

Remarks

This function closes all handles and releases all resources related to STDIO. It will no longer be possible to read the STDIO data from the process. Any pending data will be lost.

Related

Run, RunAs, StderrRead, StdinWrite, StdoutRead

Example

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3> ; Required for _ArrayDisplay only.

; Recursively display a list of files in a directory.
Example()

Func Example()
    Local $sFilePath = @ScriptDir ; Search the current script directory.
    Local $sFilter = "*.*" ; Search for all files in the current directory. For a list of valid wildcards, search for 'Wildcards' in the Help file.
    Local $sOutput = "" ; Store the output of StdoutRead to a variable.

    ; If the file path isn't a directory then return from the 'Example' function.
    If Not StringInStr(FileGetAttrib($sFilePath), "D") Then
        Return SetError(1, 0, 0)
    EndIf

    ; Remove trailing backslashes and append a single trailing backslash.
    $sFilePath = StringRegExpReplace($sFilePath, "[\\/]+\z", "") & "\"

    #cs
        Commandline parameters for DIR:
        /B - Simple output.
        /A-D - Search for all files, minus folders.
        /S - Search within subfolders.
    #ce
    Local $iPID = Run(@ComSpec & ' /C DIR "' & $sFilePath & $sFilter & '" /B /A-D /S', $sFilePath, @SW_HIDE, $STDOUT_CHILD)

    ; Close the Stdio stream of the PID returned by Run. This will cause the message box to display due to not being able to read the stdout stream.
    StdioClose($iPID)

    While 1
        $sOutput &= StdoutRead($iPID) ; Read the Stdout stream of the PID returned by Run.
        If @error Then ; Exit the loop if the process closes or StdoutRead returns an error.
            ExitLoop
        EndIf
    WEnd

    ; Use StringSplit to split the output of StdoutRead to an array. All carriage returns (@CRLF) are stripped and @CRLF (line feed) is used as the delimiter.
    Local $aArray = StringSplit(StringTrimRight(StringStripCR($sOutput), StringLen(@CRLF)), @CRLF)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "It appears there was an error trying to find all the files in the current script directory.")
    Else
        ; Display the results.
        _ArrayDisplay($aArray)
    EndIf
EndFunc   ;==>Example


Function StdoutRead

Function Reference

StdoutRead

Reads from the STDOUT stream of a previously run child process.

StdoutRead ( process_id [, peek = False [, binary = False]] )

Parameters

process_id | The process ID of a child process, as returned by a previous call to Run.
peek | [optional] If True the function does not remove the read characters from the stream.
binary | [optional] If True the function reads the data as binary instead of text (default is text).

Return Value

Success: | the data read. @extended contains the number of bytes read.
Failure: | sets the @error flag to non-zero if EOF is reached, STDOUT was not redirected for the process or other error.

Remarks

StdoutRead() reads from the console standard output stream of a child process, which is normally used by console applications to write to the screen. During the call to Run() for the child process you wish to read from the STD I/O parameter must have included the value of $STDOUT_CHILD (2) for this function to work properly (see the Run() function).
StdoutRead() does not block, it will return immediately. In order to get all data, it must be called in a loop.
Peeking on the stream does not remove the data from the buffer, however, it does return the available data as normal.
By default, data is returned in text format. By using the binary option, the data will be returned in binary format.

Related

Run, RunAs, StderrRead, StdinWrite, StdioClose

Example

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3> ; Required for _ArrayDisplay only.

; Recursively display a list of files in a directory.
Example()

Func Example()
    Local $sFilePath = @ScriptDir ; Search the current script directory.
    Local $sFilter = "*.*" ; Search for all files in the current directory. For a list of valid wildcards, search for 'Wildcards' in the Help file.

    ; If the file path isn't a directory then return from the 'Example' function.
    If Not StringInStr(FileGetAttrib($sFilePath), "D") Then
        Return SetError(1, 0, 0)
    EndIf

    ; Remove trailing backslashes and append a single trailing backslash.
    $sFilePath = StringRegExpReplace($sFilePath, "[\\/]+\z", "") & "\"

    #cs
        Commandline parameters for DIR:
        /B - Simple output.
        /A-D - Search for all files, minus folders.
        /S - Search within subfolders.
    #ce
    Local $iPID = Run(@ComSpec & ' /C DIR "' & $sFilePath & $sFilter & '" /B /A-D /S', $sFilePath, @SW_HIDE, $STDOUT_CHILD)
    ; If you want to search with files that contains unicode characters, then use the /U commandline parameter.

    ; Wait until the process has closed using the PID returned by Run.
    ProcessWaitClose($iPID)

    ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead.
    Local $sOutput = StdoutRead($iPID)

    ; Use StringSplit to split the output of StdoutRead to an array. All carriage returns (@CRLF) are stripped and @CRLF (line feed) is used as the delimiter.
    Local $aArray = StringSplit(StringTrimRight(StringStripCR($sOutput), StringLen(@CRLF)), @CRLF)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "It appears there was an error trying to find all the files in the current script directory.")
    Else
        ; Display the results.
        _ArrayDisplay($aArray)
    EndIf
EndFunc   ;==>Example


Functions

Registry functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
RegDelete | Deletes a key or value from the registry.
RegEnumKey | Reads the name of a subkey according to its instance.
RegEnumVal | Reads the name of a value according to its instance.
RegRead | Reads a value from the registry.
RegWrite | Creates a key or value in the registry.


Function RegDelete

Function Reference

RegDelete

Deletes a key or value from the registry.

RegDelete ( "keyname" [, "valuename"] )

Parameters

keyname | The registry key to delete.
valuename | [optional] The valuename to delete.

Return Value

Success: | 1.
Special: | 0 if the key/value does not exist.
Failure: | 2 if error deleting key/value and sets the @error flag to non-zero.
@error: | 1 = unable to open requested key 2 = unable to open requested main key 3 = unable to remote connect to the registry -1 = unable to delete requested value -2 = unable to delete requested key/value

Remarks

A registry key must start with "HKEY_LOCAL_MACHINE" ("HKLM") or "HKEY_USERS" ("HKU") or "HKEY_CURRENT_USER" ("HKCU") or "HKEY_CLASSES_ROOT" ("HKCR") or "HKEY_CURRENT_CONFIG" ("HKCC").

When running on 64-bit Windows if you want to delete a key or value specific to the 64-bit environment you have to suffix the HK... with 64 i.e. HKLM64.

To access the (Default) value use "" (an empty string) for the valuename.

Deleting from the registry is potentially dangerous--please exercise caution!

It is possible to access remote registries by using a keyname in the form "\\computername\keyname". To use this feature you must have the correct access rights.

Related

RegEnumKey, RegEnumVal, RegRead, RegWrite

Example

RegDelete("HKEY_CURRENT_USER\Software\Test", "TestKey")

RegWrite("HKEY_CURRENT_USER\Software\Test")
RegWrite("HKEY_CURRENT_USER\Software\Test1")


Function RegEnumKey

Function Reference

RegEnumKey

Reads the name of a subkey according to its instance.

RegEnumKey ( "keyname", instance )

Parameters

keyname | The registry key to read.
instance | The 1-based key instance to retrieve

Return Value

Success: | the requested subkey name.
Failure: | an empty string and sets the @error flag to non-zero.
@error: | 1 = unable to open requested key 2 = unable to open requested main key 3 = unable to remote connect to the registry -1 = unable to retrieve requested subkey (key instance out of range)

Remarks

A registry key must start with "HKEY_LOCAL_MACHINE" ("HKLM") or "HKEY_USERS" ("HKU") or "HKEY_CURRENT_USER" ("HKCU") or "HKEY_CLASSES_ROOT" ("HKCR") or "HKEY_CURRENT_CONFIG" ("HKCC").

When running on 64-bit Windows if you want to enum a key specific to the 64-bit environment you have to suffix the HK... with 64 i.e. HKLM64.

Related

RegDelete, RegEnumVal, RegWrite

Example

#include <MsgBoxConstants.au3>

Local $sSubKey = ""
For $i = 1 To 10
    $sSubKey = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE", $i)
    If @error Then ExitLoop
    MsgBox($MB_SYSTEMMODAL, "SubKey #" & $i & " under HKLM\SOFTWARE: ", $sSubKey)
Next


Function RegEnumVal

Function Reference

RegEnumVal

Reads the name of a value according to its instance.

RegEnumVal ( "keyname", instance )

Parameters

keyname | The registry key to read.
instance | The 1-based value instance to retrieve

Return Value

Success: | the requested registry value. @extended is set to the type of the value.
Failure: | sets the @error flag to non-zero.
@error: | 1 = unable to open requested key 2 = unable to open requested main key 3 = unable to remote connect to the registry -1 = unable to retrieve requested value name (value instance out of range)

Remarks

A registry key must start with "HKEY_LOCAL_MACHINE" ("HKLM") or "HKEY_USERS" ("HKU") or "HKEY_CURRENT_USER" ("HKCU") or "HKEY_CLASSES_ROOT" ("HKCR") or "HKEY_CURRENT_CONFIG" ("HKCC").

When running on 64-bit Windows if you want to enum a value specific to the 64-bit environment you have to suffix the HK... with 64 i.e. HKLM64.

Related

RegDelete, RegEnumKey, RegWrite

Example

#include <MsgBoxConstants.au3>

; X64 running support
Local $sWow64 = ""
If @AutoItX64 Then $sWow64 = "\Wow6432Node"

Local $sVar = ""

For $i = 1 To 100
    $sVar = RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", $i)
    If @error <> 0 Then ExitLoop
    MsgBox($MB_SYSTEMMODAL, "Value Name  #" & $i & " under in AutoIt3 key", $sVar)
Next


Function RegRead

Function Reference

RegRead

Reads a value from the registry.

RegRead ( "keyname", "valuename" )

Parameters

keyname | The registry key to read.
valuename | The value to read.

Return Value

Success: | the requested registry value. @extended is set to the type of the value $REG_... . These types are defined in the "Constants.au3" include file.
Failure: | sets the @error flag to non-zero.
@error: | 1 = unable to open requested key 2 = unable to open requested main key 3 = unable to remote connect to the registry -1 = unable to open requested value -2 = value type not supported

Remarks

A registry key must start with "HKEY_LOCAL_MACHINE" ("HKLM") or "HKEY_USERS" ("HKU") or "HKEY_CURRENT_USER" ("HKCU") or "HKEY_CLASSES_ROOT" ("HKCR") or "HKEY_CURRENT_CONFIG" ("HKCC").

When running on 64-bit Windows if you want to read a value specific to the 64-bit environment you have to suffix the HK... with 64 i.e. HKLM64.

AutoIt supports registry keys of type REG_BINARY, REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ, REG_QWORD, and REG_DWORD.

To access the (Default) value use "" (an empty string) for the valuename.

When reading a REG_BINARY key the result is a binary datatype (in previous versions it was a string of hex characters).

When reading a REG_MULTI_SZ key the multiple entries are separated by @LF - use with StringSplit(..., @LF) to get each entry.

It is possible to access remote registries by using a keyname in the form "\\computername\keyname". To use this feature you must have the correct access rights.

Related

RegDelete, RegWrite, StringSplit

Example

#include <MsgBoxConstants.au3>

Local $sVar = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir")
MsgBox($MB_SYSTEMMODAL, "Program files are in:", $sVar)


Function RegWrite

Function Reference

RegWrite

Creates a key or value in the registry.

RegWrite ( "keyname" [, "valuename", "type", value] )

Parameters

keyname | The registry key to write to. If no other parameters are specified this key will simply be created.
valuename | [optional] The valuename to write to.
type | [optional] Type of key to write: "REG_SZ", "REG_MULTI_SZ", "REG_EXPAND_SZ", "REG_DWORD", "REG_QWORD", or "REG_BINARY".
value | [optional] The value to write.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero if error writing registry key or value.
@error: | 1 = unable to open requested key 2 = unable to open requested main key 3 = unable to remote connect to the registry -1 = unable to open requested value -2 = value type not supported

Remarks

A registry key must start with "HKEY_LOCAL_MACHINE" ("HKLM") or "HKEY_USERS" ("HKU") or "HKEY_CURRENT_USER" ("HKCU") or "HKEY_CLASSES_ROOT" ("HKCR") or "HKEY_CURRENT_CONFIG" ("HKCC").

When running on 64-bit Windows if you want to write a key or value specific to the 64-bit environment you have to suffix the HK... with 64 i.e. HKLM64.

AutoIt supports registry keys of type REG_BINARY, REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ, REG_QWORD, and REG_DWORD.

To access the (Default) value use "" (an empty string) for the valuename.

When writing a REG_MULTI_SZ key you must separate each value with @LF. The value must NOT end with @LF unless you want an empty substring (see example).

It is possible to access remote registries by using a keyname in the form "\\computername\keyname". To use this feature you must have the correct access rights.

Related

RegDelete, RegEnumKey, RegEnumVal, RegRead

Example

; Write a single REG_SZ value
RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey", "REG_SZ", "Hello this is a test")

; Write the REG_MULTI_SZ value of "line1" and "line2"
RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey1", "REG_MULTI_SZ", "line1" & @CRLF & "line2")

; Write the REG_MULTI_SZ value of "line1"
RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey2", "REG_MULTI_SZ", "line1")

; always add and extra null string
RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey3", "REG_MULTI_SZ", "line1" & @CRLF & "line2" & @CRLF)
RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey4", "REG_MULTI_SZ", "line1" & @CRLF & @CRLF & "line2" & @CRLF)

; empty REG_MULTI_SZ
RegWrite("HKEY_CURRENT_USER\Software\Test", "TestKey5", "REG_MULTI_SZ", "")

; create just the key
RegWrite("HKEY_CURRENT_USER\Software\Test1")


Functions

String functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
StringAddCR | Takes a string and prefixes all linefeed characters ( Chr(10) ) with a carriage return character ( Chr(13) ).
StringCompare | Compares two strings with options.
StringFormat | Returns a formatted string (similar to the C sprintf() function).
StringFromASCIIArray | Converts an array of ASCII codes to a string.
StringInStr | Checks if a string contains a given substring.
StringIsAlNum | Checks if a string contains only alphanumeric characters.
StringIsAlpha | Checks if a string contains only alphabetic characters.
StringIsASCII | Checks if a string contains only ASCII characters in the range 0x00 - 0x7f (0 - 127).
StringIsDigit | Checks if a string contains only digit (0-9) characters.
StringIsFloat | Checks if a string is a floating point number.
StringIsInt | Checks if a string is an integer.
StringIsLower | Checks if a string contains only lowercase characters.
StringIsSpace | Checks if a string contains only whitespace characters.
StringIsUpper | Checks if a string contains only uppercase characters.
StringIsXDigit | Checks if a string contains only hexadecimal digit (0-9, A-F) characters.
StringLeft | Returns a number of characters from the left-hand side of a string.
StringLen | Returns the number of characters in a string.
StringLower | Converts a string to lowercase.
StringMid | Extracts a number of characters from a string.
StringRegExp | Check if a string fits a given regular expression pattern.
StringRegExpReplace | Replace text in a string based on regular expressions.
StringReplace | Replaces substrings in a string.
StringReverse | Reverses the contents of the specified string.
StringRight | Returns a number of characters from the right-hand side of a string.
StringSplit | Splits up a string into substrings depending on the given delimiters.
StringStripCR | Removes all carriage return values ( Chr(13) ) from a string.
StringStripWS | Strips the white space in a string.
StringToASCIIArray | Converts a string to an array containing the ASCII code of each character.
StringTrimLeft | Trims a number of characters from the left hand side of a string.
StringTrimRight | Trims a number of characters from the right hand side of a string.
StringUpper | Converts a string to uppercase.


Function StringAddCR

Function Reference

StringAddCR

Takes a string and prefixes all linefeed characters ( Chr(10) ) with a carriage return character ( Chr(13) ).

StringAddCR ( "string" )

Parameters

string The string to convert.

Return Value

Returns the string with all instances of linefeed characters ( @LF ) prefixed with a carriage return character ( @CR ).

Related

StringReplace, StringStripCR

Example

#include <MsgBoxConstants.au3>

; Add the carriage return charcter to all the line feed characters in the string.
Local $sString = StringAddCR("This is a sentence " & @LF & "with " & Chr(10) & "whitespace.")
MsgBox($MB_SYSTEMMODAL, "", $sString)


Function StringCompare

Function Reference

StringCompare

Compares two strings with options.

StringCompare ( "string1", "string2" [, casesense = 0] )

Parameters

string1 | The first string to evaluate.
string2 | The second string to evaluate.
casesense | [optional] Flag to indicate if the operations should be case sensitive. $STR_NOCASESENSE (0) = not case sensitive, using the user's locale (default) $STR_CASESENSE (1) = case sensitive $STR_NOCASESENSEBASIC (2) = not case sensitive, using a basic/faster comparison Constants are defined in StringConstants.au3.

Return Value

0: | string1 and string2 are equal
> 0: | string1 is greater than string2
< 0: | string1 is less than string2

Related

StringInStr, StringLeft, StringLen, StringLower, StringMid, StringRight, StringTrimLeft, StringTrimRight, StringUpper

Example

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

Local $sStr1 = "Tiësto"
Local $sStr2 = "TIËSTO"

; Compare two strings without using case sensitivity.
Local $iCmp = StringCompare($sStr1, $sStr2)
MsgBox($MB_SYSTEMMODAL, "", _
        "Comparing '" & $sStr1 & "' To '" & $sStr2 & "'" & @CRLF & _
        "StringCompare Result (mode $STR_NOCASESENSE): " & $iCmp)

; Compare two strings with using case sensitivity.
$iCmp = StringCompare($sStr1, $sStr2, $STR_CASESENSE)
MsgBox($MB_SYSTEMMODAL, "", _
        "Comparing '" & $sStr1 & "' To '" & $sStr2 & "'" & @CRLF & _
        "StringCompare Result (mode $STR_CASESENSE): " & $iCmp)

; Compare two strings without using case sensitivity.
$iCmp = StringCompare($sStr1, $sStr2, $STR_NOCASESENSEBASIC)
MsgBox($MB_SYSTEMMODAL, "", _
        "Comparing '" & $sStr1 & "' To '" & $sStr2 & "'" & @CRLF & _
        "StringCompare Result (mode $STR_NOCASESENSEBASIC): " & $iCmp)


Function StringInStr

Function Reference

StringInStr

Checks if a string contains a given substring.

StringInStr ( "string", "substring" [, casesense = 0 [, occurrence = 1 [, start = 1 [, count]]]] )

Parameters

string | The string to evaluate.
substring | The substring to search for.
casesense | [optional] Flag to indicate if the operations should be case sensitive. $STR_NOCASESENSE (0) = not case sensitive, using the user's locale (default) $STR_CASESENSE (1) = case sensitive $STR_NOCASESENSEBASIC (2) = not case sensitive, using a basic/faster comparison Constants are defined in StringConstants.au3.
occurrence | [optional] Which occurrence of the substring to find in the string. Use a negative occurrence to search from the right side. The default value is 1 (finds first occurrence).
start | [optional] The starting position of the search.
count | [optional] The number of characters to search. This effectively limits the search to a portion of the full string. See remarks.

Return Value

Success: | the position of the substring.
Failure: | 0 if substring not found.
@error: | 1 = Invalid "start" or "occurrence" parameter given.

Remarks

The first character position is 1.

The count parameter must not be shorter than the substring being searched for. The count parameter (combined with the start parameter) effectively limits the search to a substring of the full string. The following two statements are equivalent:
StringInStr("the string to search", "string", 0, 1, 1, 11)
StringInStr(StringMid("the string to search", 1, 11), "string")

Related

StringCompare, StringLeft, StringLen, StringLower, StringMid, StringRegExp, StringRight, StringSplit, StringTrimLeft, StringTrimRight, StringUpper

Example

#include <MsgBoxConstants.au3>

; Retrieve the character position of where the string 'white' first occurs in the sentence.
Local $iPosition = StringInStr("This is a sentence with whitespace.", "white")
MsgBox($MB_SYSTEMMODAL, "", "The search string 'white' first appears at position: " & $iPosition)


Function StringIsAlNum

Function Reference

StringIsAlNum

Checks if a string contains only alphanumeric characters.

StringIsAlNum ( "string" )

Parameters

string The string to check

Return Value

Success: | 1.
Failure: | 0 if string contains non-alphanumeric characters.

Remarks

Keep in mind that any whitespace will cause StringIsAlNum() to return 0.

Related

StringIsAlpha, StringIsASCII, StringIsDigit, StringIsLower, StringIsSpace, StringIsUpper, StringIsXDigit, StringLower, StringUpper

Example

#include <MsgBoxConstants.au3>

Local $sString = "This is a sentence with whitespace." ; Check whether this string contains only alphanumeric characters.
If StringIsAlNum($sString) Then
    MsgBox($MB_SYSTEMMODAL, "", "The variable contains only alphanumeric characters.")
Else
    MsgBox($MB_SYSTEMMODAL, "", "The variable does not contain alphanumeric characters.")
EndIf


Function StringIsAlpha

Function Reference

StringIsAlpha

Checks if a string contains only alphabetic characters.

StringIsAlpha ( "string" )

Parameters

string The string to check

Return Value

Success: | 1.
Failure: | 0 if string contains non-alphabetic characters.

Remarks

Keep in mind that any whitespace will cause StringIsAlpha() to return 0.

Related

StringIsAlNum, StringIsASCII, StringIsDigit, StringIsLower, StringIsSpace, StringIsUpper, StringIsXDigit, StringLower, StringUpper

Example

#include <MsgBoxConstants.au3>

Local $sString = "This is a sentence with whitespace." ; Check whether this string contains only alphabetic characters.
If StringIsAlpha($sString) Then
    MsgBox($MB_SYSTEMMODAL, "", "The variable contains only alphabetic characters.")
Else
    MsgBox($MB_SYSTEMMODAL, "", "The variable does not contain alphabetic characters.")
EndIf


Function StringIsASCII

Function Reference

StringIsASCII

Checks if a string contains only ASCII characters in the range 0x00 - 0x7f (0 - 127).

StringIsASCII ( "string" )

Parameters

string The string to check

Return Value

Success: | 1.
Failure: | 0 if string contains extended ASCII characters.

Related

StringIsAlNum, StringIsAlpha, StringIsDigit, StringIsLower, StringIsSpace, StringIsUpper, StringIsXDigit, StringLower, StringUpper

Example

#include <MsgBoxConstants.au3>

Local $sString = "This is a sentence with whitespace." ; Check whether this string contains only ASCII characters.
If StringIsASCII($sString) Then
    MsgBox($MB_SYSTEMMODAL, "", "The variable contains ASCII characters.")
Else
    MsgBox($MB_SYSTEMMODAL, "", "The variable does not contain ASCII characters.")
EndIf


Function StringIsDigit

Function Reference

StringIsDigit

Checks if a string contains only digit (0-9) characters.

StringIsDigit ( "string" )

Parameters

string The string to check

Return Value

Success: | 1.
Failure: | 0 if string contains non-digits.

Remarks

See examples.

Related

StringIsAlNum, StringIsAlpha, StringIsASCII, StringIsInt, StringIsLower, StringIsSpace, StringIsUpper, StringIsXDigit

Example

#include <MsgBoxConstants.au3>

MsgBox($MB_SYSTEMMODAL, "", "Is the string 42 a digit: " & StringIsDigit("42") & @CRLF & _ ; Returns 1, as the string contains only digit (0-9) characters.
        "Is the string 00 a digit: " & StringIsDigit("00") & @CRLF & _ ; Returns 1, as the string contains only digit (0-9) characters.
        "Is the string 1.0 a digit: " & StringIsDigit("1.0") & @CRLF & _ ; Returns 0, due to the decimal point.
        "Is the number 1.0 a digit: " & StringIsDigit(1.0) & @CRLF & _ ; Returns 1, due to the number to string conversion.
        "Is the string 1+2 a digit: " & StringIsDigit("1+2") & @CRLF) ; Returns 0, as the + (plus) symbol is present in the string.


Function StringIsFloat

Function Reference

StringIsFloat

Checks if a string is a floating point number.

StringIsFloat ( "string" )

Parameters

string The string or expression to check.

Return Value

Success: | 1.
Failure: | 0 if not floating point format.

Remarks

A string is a float if it contains at least one decimal digit and exactly one period; the only other character allowed is an optional plus or minus at the beginning. (StringIsFloat() does not accept a comma character as the decimal point even if the computer Locale settings use that symbol.) If parameter is not a string, its value is converted to a string. See examples.

Related

IsFloat, StringIsInt

Example

#include <MsgBoxConstants.au3>

MsgBox($MB_SYSTEMMODAL, "", "Is the string 1.5 a floating point number: " & StringIsFloat("1.5") & @CRLF & _ ; Returns 1, due to the decimal point.
        "Is the string 7. a floating point number: " & StringIsFloat("7.") & @CRLF & _ ; Returns 1, due to the decimal point.
        "Is the string 3/4 a floating point number: " & StringIsFloat("3/4") & @CRLF & _ ; Returns 0, as the string 3 / (forward slash) 4 is not a floating point number.
        "Is the number 1.0 a floating point number: " & StringIsFloat(1.0) & @CRLF & _ ; Returns 1, due to the number to string conversion as well as the decimal point.
        "Is the string 2 a floating point number: " & StringIsFloat("2") & @CRLF) ; Returns 0, due to 2 being an integer.


Function StringFormat

Function Reference

StringFormat

Returns a formatted string (similar to the C sprintf() function).

StringFormat ( "format control", var1 [, ... var32] )

Parameters

format control | The format and flags to use (see Remarks).
var1...var32 | Up to 32 variables that will be output according to the "format control".

Return Value

Returns the formatted string according to "format control" parameter.

Remarks

To prevent buffer overflow, each "variable" is limited to 65535 characters.
Escape characters can be contain in the "format control" such as \n (@LF), \r (@CR), \t (@TAB]. So if you want to have a "\" you need to use \\, samething for "%" %%.

"variable format" is; %[flags] [width] [.precision] type

If a format specification is invalid, the behaviour is undefined. If you specify invalid input you can in special circumstances create unhandled exception and cause program termination.

Width Specification

The second optional field of the format specification is the width specification. The width argument is a nonnegative decimal integer controlling the minimum number of characters printed. If the number of characters in the output value is less than the specified width, blanks are added to the left or the right of the values — depending on whether the – flag (for left alignment) is specified — until the minimum width is reached. If width is prefixed with 0, zeros are added until the minimum width is reached (not useful for left-aligned numbers).

The width specification never causes a value to be truncated. If the number of characters in the output value is greater than the specified width, or if width is not given, all characters of the value are printed (subject to the precision specification).

Type Specification

Type | Variable type | Output format
d, i | Integer | Signed decimal integer.
o | Integer | Unsigned octal integer.
u | Integer | Unsigned decimal integer.
x | Integer | Unsigned hexadecimal integer, using "abcdef".
X | Integer | Unsigned hexadecimal integer, using "ABCDEF".
e | Float | Signed value having the form [ - ]d.dddd e [sign]ddd where d is a single decimal digit, dddd is one or more decimal digits, ddd is exactly three decimal digits, and sign is + or -.
E | Float | Identical to the e format except that E rather than e introduces the exponent.
f | Float | Signed value having the form [ - ]dddd.dddd, where dddd is one or more decimal digits. The number of digits before the decimal point depends on the magnitude of the number, and the number of digits after the decimal point depends on the requested precision.
g | Float | Signed value printed in f or e format, whichever is more compact for the given value and precision. The e format is used only when the exponent of the value is less than -4 or greater than or equal to the precision argument. Trailing zeros are truncated, and the decimal point appears only if one or more digits follow it.
G | Float | Identical to the g format, except that E, rather than e, introduces the exponent (where appropriate).
s | String | String.

Flag Specification

Flag | Meaning | Default
- | Left align the result within the given field width. | Right align.
+ | Prefix the output value with a sign (+ or -) if the output value is of a signed type. | Sign appears only for negative signed values (-).
0 | If width is prefixed with 0, zeros are added until the minimum width is reached. If 0 and - appear, the 0 is ignored. If 0 is specified with an integer format (i, u, x, X, o, d) the 0 is ignored. | No padding.
Blank | Prefix the output value with a blank if the output value is signed and positive; the blank is ignored if both the blank and + flags appear. | No blank appears.
# | When used with the o, x, or X format, the # flag prefixes any nonzero output value with 0, 0x, or 0X, respectively. | No blank appears.
# | When used with the e, E, or f format, the # flag forces the output value to contain a decimal point in all cases. | Decimal point appears only if digits follow it.
# | When used with the g or G format, the # flag forces the output value to contain a decimal point in all cases and prevents the truncation of trailing zeros. Ignored when used with d, i, u, or s. | Decimal point appears only if digits follow it. Trailing zeros are truncated.

Precision Specification

The third optional field of the format specification is the precision specification. It specifies a nonnegative decimal integer, preceded by a period (.), which specifies the number of characters to be printed, the number of decimal places, or the number of significant digits (see Table below). Unlike the width specification, the precision specification can cause either truncation of the output value or rounding of a floating-point value. If precision is specified as 0 and the value to be converted is 0, the result is no characters output, as shown below:

StringFormat( "%.0d", 0 ); /* No characters return */

How Precision Values Affect Type

Type | Meaning | Default
d, i, u, o, x, X | The precision specifies the minimum number of digits to be printed. If the number of digits in the argument is less than precision, the output value is padded on the left with zeros. The value is not truncated when the number of digits exceeds precision. | Default precision is 1.
e, E | The precision specifies the number of digits to be printed after the decimal point. The last printed digit is rounded. | Default precision is 6; if precision is 0 or the period (.) appears without a number following it, no decimal point is printed.
f The precision value specifies the number of digits after the decimal point. If a decimal point appears, at least one digit appears before it. The value is rounded to the appropriate number of digits. | Default precision is 6; if precision is 0, or if the period (.) appears without a number following it, no decimal point is printed.
g, G | The precision specifies the maximum number of significant digits printed. | Six significant digits are printed, with any trailing zeros truncated.
s | The precision specifies the maximum number of characters to be printed. Characters in excess of precision are not printed. | Characters are printed until a null character is encountered.

Example

Example()

Func Example()
    Local $iInt_Unsigned = 43951789
    Local $iInt_Negative = -43951789

    ConsoleWrite(@CRLF & "Numeric Formats" & @CRLF)

    PrintFormat($iInt_Unsigned, "%d", "standard positive integer with no sign", 1) ; 43951789
    PrintFormat($iInt_Negative, "%d", "standard negative integer with sign", 1) ; -43951789
    PrintFormat($iInt_Unsigned, "%i", "standard integer", 1) ; 43951789
    PrintFormat($iInt_Unsigned, "%09i", "9 digits with leading zero", 1) ; 043951789
    PrintFormat($iInt_Unsigned, "%e", "scientific notation") ; 4.395179e+007
    PrintFormat($iInt_Unsigned, "%u", "unsigned integer with positive integer", 1) ; 43951789
    PrintFormat($iInt_Negative, "%u", "unsigned integer with negative integer", 1) ; 4251015507
    PrintFormat($iInt_Unsigned, "%f", "floating point") ; 43951789.000000
    PrintFormat($iInt_Unsigned, "%.2f", "floating point with 2 digits after decimal point", 1) ; 43951789.00
    PrintFormat($iInt_Unsigned, "%o", "octal", 1) ; 247523255
    PrintFormat($iInt_Unsigned, "%s", "string", 1) ; 43951789
    PrintFormat($iInt_Unsigned, "%x", "hexadecimal (lower-case)", 1) ; 29ea6ad
    PrintFormat($iInt_Unsigned, "%X", "hexadecimal (upper-case)", 1) ; 29EA6AD
    PrintFormat($iInt_Unsigned, "%+d", "sign specifier on a positive integer", 1) ; +43951789
    PrintFormat($iInt_Negative, "%+d", "sign specifier on a negative integer", 1) ; -43951789

    Local $sString = "string"
    Local $sString_Long = "longstring"

    ConsoleWrite(@CRLF & "String Formats - [ ] used to show beginning/end of string" & @CRLF)

    PrintFormat($sString, "[%s]", "standard string", 1) ; [string]
    PrintFormat($sString, "[%10s]", "10 chars right justified with added spaces") ; [    string]
    PrintFormat($sString, "[%-10s]", "10 chars left justified with added spaces") ; [string    ]
    PrintFormat($sString_Long, "[%10.8s]", "right justified but precision 8 so truncated") ; [  longer s]
    PrintFormat($sString_Long, "[%-10.8s]", "left justifed but precision 8 so truncated") ; [longer s  ]
    PrintFormat($sString, "[%010s]", "10 chars with leading zero") ; [0000string]

    ConsoleWrite(@CRLF & "Date Format - each % uses a new parameter" & @CRLF)

    ConsoleWrite('"%02i\%02i\%04i" 0n (1, 9, 2013) => ' & StringFormat("%02i\%02i\%04i", 1, 9, 2013) & @CRLF & @CRLF)
EndFunc   ;==>Example

Func PrintFormat($vVar, $sFormat, $sExplan, $iTab = 0)
    ConsoleWrite('"' & $sFormat & '" on ' & $vVar & @TAB & ' => ' & StringFormat($sFormat, $vVar))
    If $iTab Then ConsoleWrite(@TAB)
    ConsoleWrite(@TAB & " ; " & $sExplan & @CRLF)
EndFunc   ;==>PrintFormat


Function StringFromASCIIArray

Function Reference

StringFromASCIIArray

Converts an array of ASCII codes to a string.

StringFromASCIIArray ( array,[start = 0 [, end = -1 [, encoding = 0]]] )

Parameters

array | The array of ASCII codes to convert to characters.
start | [optional] The 0-based index to start processing from (Default: 0).
end | [optional] The 0-based index to end processing at (Default: UBound($aArray)). Note that the character at this index is NOT included in the output.
encoding | [optional] The array contains values in the specified character set: $SE_UTF16 (0) = UTF-16 (Default) $SE_ANSI (1) = ANSI $SE_UTF8 (2) = UTF-8 Constants are defined in StringConstants.au3.

Return Value

Success: | a string with character representations of the ASCII codes.
Failure: | an empty string and sets the @error flag to non-zero.
@error: | 1 = Input is not an array. 2 = Invalid start index.

Remarks

The returned string may contain embedded Chr(0) but will still be a string type. Most string functions will stop at the first Chr(0) found, however, if access to the entire contents of the string is required then the StringToBinary() function can convert it into a BinaryString preserving all the data.

If you attempt to create an array manually (As opposed to using an array returned from StringToASCIIArray()) then the codes in the array must be specified in UNICODE.

Related

StringToASCIIArray

Example

#include <MsgBoxConstants.au3>
#include <Array.au3> ; Required for _ArrayDisplay() only.

Example()

Func Example()
    ; Convert the string to an ASCII array.
    Local $aArray = StringToASCIIArray("This is a sentence with whitespace.")

    ; Display the array to see that it contains the ASCII values for each character in the string.
    _ArrayDisplay($aArray)

    ; Convert the array into a string.
    Local $sString = StringFromASCIIArray($aArray)

    ; Display the string to see that it matches the original string initially converted to an array.
    MsgBox($MB_SYSTEMMODAL, "", $sString)
EndFunc   ;==>Example


Function StringIsInt

Function Reference

StringIsInt

Checks if a string is an integer.

StringIsInt ( "string" )

Parameters

string The string to check.

Return Value

Success: | 1.
Failure: | 0 if string cannot be an integer.

Remarks

StringIsInt() also returns 1 for non-string integer expressions; however, StringIsInt() returns 0 for hexadecimal expressions such as "4ff0". The only punctuation allowed is either a plus or a minus at the beginning of the string.

Related

IsInt, StringIsDigit, StringIsFloat

Example

#include <MsgBoxConstants.au3>

MsgBox($MB_SYSTEMMODAL, "", "Is the string +42 an integer: " & StringIsInt("+42") & @CRLF & _ ; Returns 1, due to the + (plus) symbol being at the beginning of the string.
        "Is the string -00 an integer: " & StringIsInt("-00") & @CRLF & _ ; Returns 1, due to the - (minus) symbol being at the beginning of the string.
        "Is the string 1.0 an integer: " & StringIsInt("1.0") & @CRLF & _ ; Returns 0, due to the decimal point.
        "Is the number 1.0 an integer: " & StringIsInt(1.0) & @CRLF & _ ; Returns 1, due to the number to string conversion.
        "Is the string 1+2 an integer: " & StringIsInt("1+2") & @CRLF) ; Returns 0, as the + (plus) symbol is not at the beginning of the string.


Function StringIsLower

Function Reference

StringIsLower

Checks if a string contains only lowercase characters.

StringIsLower ( "string" )

Parameters

string The string to check

Return Value

Success: | 1.
Failure: | 0 if string contains non-lowercase characters.

Remarks

Note that digits/punctuation/whitespace will cause StringIsLower() to return 0.

Related

StringIsAlNum, StringIsAlpha, StringIsASCII, StringIsDigit, StringIsSpace, StringIsUpper, StringIsXDigit, StringLower, StringUpper

Example

#include <MsgBoxConstants.au3>

Local $sString = "lowercase" ; Check whether this string contains only lowercase characters.
If StringIsLower($sString) Then
    MsgBox($MB_SYSTEMMODAL, "", "The variable is a lowercase string")
Else
    MsgBox($MB_SYSTEMMODAL, "", "The variable is not a lowercase string")
EndIf


Function StringIsSpace

Function Reference

StringIsSpace

Checks if a string contains only whitespace characters.

StringIsSpace ( "string" )

Parameters

string The string to check

Return Value

Success: | 1.
Failure: | 0 if string contains non-whitespace characters.

Remarks

Whitespace includes Chr(9) thru Chr(13) which are HorizontalTab, LineFeed, VerticalTab, FormFeed, and CarriageReturn. Whitespace also includes the null string ( Chr(0) ) and the standard space ( Chr(32) ).

Related

StringIsAlNum, StringIsAlpha, StringIsASCII, StringIsDigit, StringIsLower, StringIsUpper, StringIsXDigit, StringLower, StringStripCR, StringStripWS, StringUpper

Example

#include <MsgBoxConstants.au3>

Local $sString = "   " & @CRLF & @CRLF & Chr(11) & @TAB & " " & @CRLF ; Check whether this string contains only whitespace characters.
If StringIsSpace($sString) Then
    MsgBox($MB_SYSTEMMODAL, "", "The variable contains only whitespace characters.")
Else
    MsgBox($MB_SYSTEMMODAL, "", "The variable does not contain whitespace characters.")
EndIf


Function StringIsUpper

Function Reference

StringIsUpper

Checks if a string contains only uppercase characters.

StringIsUpper ( "string" )

Parameters

string The string to check

Return Value

Success: | 1.
Failure: | 0 if string contains non-uppercase characters.

Remarks

Note that digits/punctuation/whitespace will cause StringIsUpper() to return 0.

Related

StringIsAlNum, StringIsAlpha, StringIsASCII, StringIsDigit, StringIsLower, StringIsSpace, StringIsXDigit, StringLower, StringUpper

Example

#include <MsgBoxConstants.au3>

Local $sString = "UPPERCASESTRING" ; Check whether this string contains only uppercase characters.
If StringIsUpper($sString) Then
    MsgBox($MB_SYSTEMMODAL, "", "The variable is an uppercase string")
Else
    MsgBox($MB_SYSTEMMODAL, "", "The variable is not an uppercase string")
EndIf


Function StringIsXDigit

Function Reference

StringIsXDigit

Checks if a string contains only hexadecimal digit (0-9, A-F) characters.

StringIsXDigit ( "string" )

Parameters

string The string to check

Return Value

Success: | 1.
Failure: | 0 if string contains non-hexadecimal characters.

Remarks

Valid characters are 0123456789abcdefABCDEF.
Note that a string containing whitespace or the "0x" prefix will cause StringIsXDigit() to return 0.

Related

StringIsAlNum, StringIsAlpha, StringIsASCII, StringIsDigit, StringIsLower, StringIsSpace, StringIsUpper, StringLower, StringUpper

Example

#include <MsgBoxConstants.au3>

MsgBox($MB_SYSTEMMODAL, "", "Is the string 42 a hexadecimal digit: " & StringIsXDigit("42") & @CRLF & _ ; Returns 1, as the string contains only hexadecimal (0-9, A-F) characters.
        "Is the string 00 a hexadecimal digit: " & StringIsXDigit("00") & @CRLF & _ ; Returns 1, as the string contains only hexadecimal (0-9, A-F) characters.
        "Is the string 1.0 a hexadecimal digit: " & StringIsXDigit("1.0") & @CRLF & _ ; Returns 0, due to the decimal point.
        "Is the number 1.0 a hexadecimal digit: " & StringIsXDigit(1.0) & @CRLF & _ ; Returns 1, due to the number to string conversion.
        "Is the string 'A string' a hexadecimal digit: " & StringIsXDigit("A string.") & @CRLF) ; Returns 0, due to the string containing whitespace.


Function StringLeft

Function Reference

StringLeft

Returns a number of characters from the left-hand side of a string.

StringLeft ( "string", count )

Parameters

string | The string to evaluate.
count | The number of characters to get.

Return Value

Returns a string containing the leftmost count characters of the string.

Remarks

If count exceeds string length, the entire string is returned.
If count is negative, an empty string is returned.

Related

StringCompare, StringInStr, StringLen, StringLower, StringMid, StringReplace, StringRight, StringSplit, StringTrimLeft, StringTrimRight, StringUpper

Example

#include <MsgBoxConstants.au3>

Local $sString = StringLeft("This is a sentence with whitespace.", 5) ; Retrieve 5 characters from the left of the string.
MsgBox($MB_SYSTEMMODAL, "", "The 5 leftmost characters are: " & $sString)


Function StringLen

Function Reference

StringLen

Returns the number of characters in a string.

StringLen ( "string" )

Parameters

string The string to evaluate.

Return Value

Returns the length of the string.

Remarks

A numeric expression is automatically evaluated and converted to a string.

Related

StringCompare, StringInStr, StringLeft, StringLower, StringMid, StringReplace, StringRight, StringSplit, StringTrimLeft, StringTrimRight, StringUpper

Example

#include <MsgBoxConstants.au3>

; Retrieve the length of a string.
; If the string is using only ASCII characters, then the length is equal to the size in bytes e.g. 10 characters is 10 bytes.
Local $iLength = StringLen("This is a sentence with whitespace.")
MsgBox($MB_SYSTEMMODAL, "", "The length of this string is " & $iLength & " characters.")


Function StringLower

Function Reference

StringLower

Converts a string to lowercase.

StringLower ( "string" )

Parameters

string The string to convert.

Return Value

Returns the string converted to lowercase.

Related

StringCompare, StringInStr, StringIsAlNum, StringIsAlpha, StringIsASCII, StringIsLower, StringIsSpace, StringIsUpper, StringIsXDigit, StringLeft, StringLen, StringMid, StringReplace, StringRight, StringSplit, StringTrimLeft, StringTrimRight, StringUpper

Example

#include <MsgBoxConstants.au3>

Local $sString = StringLower("This is a string") ; Convert the following string to lowercase.
MsgBox($MB_SYSTEMMODAL, "", "StringLower returned: " & $sString)


Function StringMid

Function Reference

StringMid

Extracts a number of characters from a string.

StringMid ( "string", start [, count = -1] )

Parameters

string | The string to evaluate.
start | The character position to start. (1 = first character)
count | [optional] The number of characters to extract. By default the entire remainder of the string.

Return Value

Returns the extracted string.

Remarks

If start is out-of-bounds, an empty string is returned. If start is valid but count is out-of-bounds, the entire remainder of the string is returned.

Related

StringCompare, StringInStr, StringLeft, StringLen, StringLower, StringReplace, StringRight, StringSplit, StringTrimLeft, StringTrimRight, StringUpper

Example

#include <MsgBoxConstants.au3>

; Retrieve 5 characters from the 10th position in the string.
Local $sString = StringMid("This is a sentence with whitespace.", 10, 5)
MsgBox($MB_SYSTEMMODAL, "", $sString)


Function StringRegExp

Function Reference

StringRegExp

Check if a string fits a given regular expression pattern.

StringRegExp ( "test", "pattern" [, flag = 0 [, offset = 1]] )

Parameters

test | The subject string to check
pattern | The regular expression to match.
flag | [optional] A number to indicate how the function behaves. See below for details. The default is 0.
offset | [optional] The string position to start the match (starts at 1). The default is 1.
Flag | Values
$STR_REGEXPMATCH (0) | Returns 1 (match) or 0 (no match). (Default).
$STR_REGEXPARRAYMATCH (1) | Return array of matches.
$STR_REGEXPARRAYFULLMATCH (2) | Return array of matches including the full match (Perl / PHP style).
$STR_REGEXPARRAYGLOBALMATCH (3) | Return array of global matches.
$STR_REGEXPARRAYGLOBALFULLMATCH (4) | Return an array of arrays containing global matches including the full match (Perl / PHP style).
Constants are defined in StringConstants.au3.

Return Value

Flag = $STR_REGEXPMATCH (0) :

@error: | Meaning
2: | Bad pattern. @extended = offset of error in pattern.

Flag = $STR_REGEXPARRAYMATCH (1) or $STR_REGEXPARRAYFULLMATCH (2) :

@error: | Meaning
0: | Array is valid. Check @extended for next offset
1: | Array is invalid. No matches.
2: | Bad pattern, array is invalid. @extended = offset of error in pattern.

Flag = $STR_REGEXPARRAYGLOBALMATCH (3) or $STR_REGEXPARRAYGLOBALFULLMATCH (4) :

@error: | Meaning
0: | Array is valid.
1: | Array is invalid. No matches.
2: | Bad pattern, array is invalid. @extended = offset of error in pattern.

Remarks

The flag parameter can have one of 5 values ($STR_REGEXPMATCH (0) through $STR_REGEXPARRAYGLOBALFULLMATCH (4)).

$STR_REGEXPMATCH (0) | returns 1 (true) or 0 (false) if the pattern was found or not.
$STR_REGEXPARRAYMATCH (1) $STR_REGEXPARRAYFULLMATCH (2) | find the first match and return captured groups in an array; when the pattern has no capturing groups, the first match is returned in the array.
$STR_REGEXPARRAYGLOBALMATCH (3) $STR_REGEXPARRAYGLOBALFULLMATCH (4) | fill the array with all matching instances.

$STR_REGEXPARRAYFULLMATCH (2) and $STR_REGEXPARRAYGLOBALFULLMATCH (4) include the full matching text as the first element of the return array, not just the captured groups as with flag $STR_REGEXPARRAYMATCH (1) and $STR_REGEXPARRAYGLOBALMATCH (3).

Regular expression notation is a compact way of specifying a pattern for subject strings that can be searched and from which specific parts can be extracted by StringRegExp() or replaced when using StringRegExpReplace().

More precisely, the regular expression engine tries to match a pattern (a kind of programmatic format) with a subject string, both from left to right. Should a mismatch occur, the engines tries to backtrack (return to successively previous states) as much as needed, expecting that the rest of the pattern will match as well.

Backtracking is a fundamental feature of regular expression engines and one that every novice programmer already understand and uses daily. It is like leaving a specific mark on every fork in the road and going back to the last untried path when the choosen path turns out to be a dead end: you backtrack as needed until you find the right point (match success) or explore every path without reaching your goal (match failure). Searching a given filename with optional wildcards inside a directory tree is no different.

AutoIt uses the PCRE engine. PCRE means "Perl-Compatible Regular Expressions" and is the most comprehensive open-source engine available. This implementation includes Unicode Category Properties (UCP) support, which allows fine-grain processing of most human languages.
However to maintain compatibility with previous versions and keep matching speed at its best, the UCP support is not enabled by default. You can enable it by prepending the string (*UCP) at the very start of your pattern. When enabled, the UCP setting changes the extend of a number of regular expression elements, as documented below where applicable.

This page is only a summary for the most used pattern elements. For full in-depth discussion of regular expressions as implemented in AutoIt, refer to the complete description of PCRE patterns.
Unless you are already familiar with regular expressions you will probably need to read several parts of this summary more than once to grasp how they work and inter-relate.

Caution: bad regular expressions can produce a quasi-infinite loop hogging the CPU, and can even cause a crash.

Global settings

These settings are only recognized at the start of the pattern and affect it globally.

Newline conventions

Newline sequences affect where the ^ and $ anchors match and what \N and . do not match. By default the newline sequence is @CRLF as an unbreakable sequence or lone @CR or @LF.
The default can be changed by prepending one of the following sequence at the start of a pattern.
(*CR) | Carriage return (@CR).
(*LF) | Line feed (@LF).
(*CRLF) | Carriage return immediately followed by linefeed (@CRLF).
(*ANYCRLF) | Any of @CRLF, @CR or @LF. This is the default newline convention.
(*ANY) | Any Unicode newline sequence: @CRLF, @LF, VT, FF, @CR or \x85.

What \R matches
(*BSR_ANYCRLF) | By default \R matches @CRLF, @CR or @LF only.
(*BSR_UNICODE) | Changes \R to match any Unicode newline sequence: @CRLF, @LF, VT, FF, @CR or \x85.

PCRE patterns may contain options, which are enclosed in (? ) sequences. Options can be grouped together: "(?imx)". Options following an hyphen are negated: "(?im-sx)".
Options appearing outside a group affect the remaining of the pattern from that point onwards. Options appearing inside a group affect that group only. Options loose their special meaning inside a character class, where they are treated literally.
(?i) | Caseless: matching becomes case-insensitive from that point on. By default, matching is case-sensitive. When UCP is enabled casing applies to the entire Unicode plane 0, else applies by default to ASCII letters A-Z and a-z only.
(?m) | Multiline: ^ and $ match at newline sequences within data. By default, multiline is off.
(?s) | Single-line or DotAll: . matches anything including a newline sequence. By default, DotAll is off hence . does not match a newline sequence.
(?U) | Ungreedy: quantifiers become lazy (non-greedy) from that point on. By default, matching is greedy - see below for further explanation.
(?x) | eXtended: whitespaces outside character classes are ignored and # starts a comment up to the next solid newline in pattern. Meaningless whitespaces between components make regular expressions much more readable. By default, whitespaces match themselves and # is a literal character.

Characters

Regular expressions patterns consist of literal Unicode text parts which match themselves, intermixed with regular expression specifiers or options. Specifiers and options use a few metacharacters which have a special meaning by themselves or introduce special pattern elements described in the tables below.
In literal parts, alphanumeric characters always stand for themselves: the pattern "literal part with 中国文字" matches exactly the string "literal part with 中国文字" ("中国文字" means "chinese text".)
Some non-alphanumeric characters called metacharacters have special behavior, discussed thereafter.

Representing some characters literally

The special sequences below are used to represent certain characters literally.
\a | Represents "alarm", the BEL character (Chr(7)).
\c X | Represents "control-X", where X is any 7-bit ASCII character. For example, "\cM" represents ctrl-M, same as \x0D or \r (Chr(13)).
\e | Represents the "escape" control character (Chr(27)). Not to be confused with the escaping of a character!
\f | Represents "formfeed" (Chr(12)).
\n | Represents "linefeed" (@LF, Chr(10)).
\r | Represents "carriage return" (@CR, Chr(13)).
\t | Represents "tab" (@TAB, Chr(9)).
\ddd | Represents character with octal code ddd, OR backreference to capturing group number ddd in decimal. For example, ([a-z])\1 would match a doubled letter. Best avoided as it can be ambiguous! Favor the hex representations below.
\x hh | Represents Unicode character with hex codepoint hh: "\x7E" represents a tilde, "~".
\x{hhhh} | Represents Unicode character with hex codepoint hhhh: "\x{20AC}" represents the Euro symbol, "€" (ChrW(0x20AC)).
\x | where x is non-alphanumeric, stands for a literal x. Used to represent metacharacters literally: "\.\[" represents a dot followed by a left square bracket, ".[".
\Q ... \E | Verbatim sequence: metacharacters loose their special meaning between \Q and \E: "\Q(.)\E" matches "(.)" and is equivalent to, but more readable than, "\(\.\)".

Metacharacters

PCRE metacharacters are \ . ^ $ | [ ( { * + ? # which have one or more special meaning, depending on context.
To insert a literal metacharacter, precede it by adding a backslash (this is called escaping (or quoting) a character): "\$" means the dollar character.
Metacharacters will be discussed in separate sections where their behavior or meaning belong.

Character types

. | Matches any single character except, by default, a newline sequence. Matches newlines as well when option (?s) is active.
\d | Matches any decimal digit (any Unicode decimal digit in any language when UCP is enabled).
\D | Matches any non-digit.
\h | Matches any horizontal whitespace character (see table below).
\H | Matches any character that is not a horizontal whitespace character.
\N | Matches any character except a newline sequence regardless of option (?s).
\p{ppp} | Only when UCP is enabled: matches any Unicode character having the property ppp. E.g. "\b\p{Cyrillic}+" matches any cyrillic word; "\p{Sc}" matches any currency symbol. See reference documentation for details.
\P{ppp} | Only when UCP is enabled: matches any Unicode character not having the property ppp.
\R | Matches any Unicode newline sequence by default, or the currently active (*BSR_...) setting. By default \R matches "(?>\r\n|\n|\r)" where "(?>...)" is an atomic group, making the sequence "\r\n" (@CRLF) unbreakable.
\s | Matches any whitespace character (see table below).
\S | Matches any non-whitespace character.
\v | Matches any vertical whitespace character (see table below).
\V | Matches any character that is not a vertical whitespace character.
\w | Matches any "word" character: any digit, any letter or underscore "_" (any Unicode digit, any Unicode letter in any language or underscore "_" when UCP is enabled).
\W | Matches any non-word character.
\X | Only when UCP is enabled: matches any Unicode extended grapheme cluster - an unbreakable sequence of codepoints which represent a single character for the user. As a consequence \X may match more than one character in the subject string, contrary to all other sequences in this table.

Horizontal whitespace characters matched by \h

\h is equivalent to "[\x09 \xA0]" by default (or "[\x09 \xA0\x{1680}\x{180E}\x{2000}-\x{200A}\x{202F}\x{205F}\x{3000}]" when UCP is enabled.)
This set is: Horizontal tab (HT), Space, Non-break space (adding: Ogham space mark, Mongolian vowel separator, En quad, Em quad, En space, Em space, Three-per-em space, Four-per-em space, Six-per-em space, Figure space, Punctuation space, Thin space, Hair space, Narrow no-break space, Medium mathematical space, Ideographic space when UCP is enabled.)

Vertical whitespace characters matched by \v

\v is equivalent to "[\x0A-\x0D]" by default (or "[\x0A-\x0D\x{0085}\x{2028}\x{2029}]" when UCP is enabled.)
This set is: Linefeed (LF), Vertical tab (VT), Form feed (FF), Carriage return (CR) (adding: Next line (NEL), Line separator, Paragraph separator when UCP is enabled.)

Whitespace characters matched by \s

\s is equivalent to "[\h\x0A\x0C\x0D]".
This set is: all characters in \h plus Linefeed (LF), Form feed (FF), Carriage return (CR).

Whitespace characters matched by [[:space:]]

[[:space:]] is equivalent to "\s".
This set is: all characters in \s plus Vertical tab (VT).

Character classes and POSIX classes

Character classes

A character classes defines a set of allowed (resp. disallowed) characters, which the next character in subject is expected to match (resp. not to match).
Inside a character classes, most metacharacters loose their meaning (like $ . or *) or mean something else (like ^).
[ ... ] | Matches any character in the explicit set: "[aeiou]" matches any lowercase vowel. A contiguous (in Unicode codepoint increasing order) set can be defined by putting an hyphen between the starting and ending characters: "[a-z]" matches any lowercase ASCII letter. To include a hyphen (-) in a set, put it as the first or last character of the set or escape it (\-). Notice that the pattern "[A-z]" is not the same as "[A-Za-z]": the former is equivalent to "[A-Z\[\\\]^_`a-z]". To include a closing bracket in a set, use it as the first character of the set or escape it: "[][]" and "[\[\]]" will both match either "[" or "]". Note that in a character class, only \d, \D, \h, \H, \p{}, \P{}, \s, \Q...\E, \S, \v, \V, \w, \W, and \x sequences retain their special meaning, while \b means the backspace character (Chr(8)).
[^ ... ] | Matches any character not in the set: "[^0-9]" matches any non-digit. To include a caret (^) in a set, put it after the beginning of the set or escape it (\^).

POSIX classes

These are named sets specifications to be used themselves within a character class: "[z[:digit:]w-y]" is the same as "[w-z0-9]". To negate a POSIX character class, put a caret (^) after the first colon: "[[:^digit:]]".
When UCP is enabled, several POSIX classes extend to some Unicode character subset, else they are by default restricted to 7-bit ASCII.
[:alnum:] | ASCII letters and digits (same as [^\W_] or [A-Za-z0-9]). When UCP is enabled: Unicode letters and digits (same as [^\W_] or \p{Xan}).
[:alpha:] | ASCII letters (same as [^\W\d_] or [A-Za-z]). When UCP is enabled: Unicode letters (same as [^\W\d_] or \p{L}).
[:ascii:] | ASCII characters (same as [\x00-\x7F]).
[:blank:] | Space or Tab (@TAB) (same as \h or [\x09\x20]). When UCP is enabled: Unicode horizontal whitespaces (same as \h).
[:cntrl:] | ASCII control characters (same as Chr(0) ... Chr(31) and Chr(127)).
[:digit:] | ASCII decimal digits (same as \d or [0-9]). When UCP is enabled: Unicode decimal digits (same as \d or \p{Nd}).
[:graph:] | ASCII printing characters, excluding space (same as Chr(33) ... Chr(126)).
[:lower:] | ASCII lowercase letters (same as [a-z]). When UCP is enabled: Unicode lowercase letters (same as \p{Ll}).
[:print:] | ASCII printing characters, including space (same as Chr(32) ... Chr(126)).
[:punct:] | ASCII punctuation characters, [:print:] excluding [:alnum:] and space, (33-47, 58-64, 91-96, 123-126).
[:space:] | ASCII white space (same as [\h\x0A-\x0D]). [:space:] is not quite the same as \s: it includes VT, Chr(11)).
[:upper:] | ASCII uppercase letters (same as [A-Z]). When UCP is enabled: Unicode uppercase letters (same as \p{Lu}).
[:word:] | ASCII "Word" characters (same as \w or [[:alnum:]_]). When UCP is enabled: Unicode "word" characters (same as \w or [[:alnum:]_] or \p{Xwd}).
[:xdigit:] | Hexadecimal digits (same as [0-9A-Fa-f]).

Groups are used to delimit subpatterns and are the building blocks of powerful expressions. Groups can be either capturing or not and may be nested irrespective of their nature, except comments groups. A regular expression can contain up to 65535 capturing groups.
Option letters (discussed above) can be conveniently inserted between the "?" and the ":" of non-capturing groups: "(?-i:[aeiou]{5})" matches 5 lowercase vowels. In this case options are local to the group.
( ... ) | Capturing group. The elements in the group are treated in order and can be repeated as a block. E.g. "(ab)+c" will match "abc" or "ababc", but not "abac". Capturing groups remember the text they matched for use in backreferences and they populate the optionally returned array. They are numbered starting from 1 in the order of appearance of their opening parenthesis. Capturing groups may also be treated as subroutines elsewhere in the pattern, possibly recursively.
(?<name> ... ) | Named capturing group. Can be later referenced by name as well as by number. Avoid using the name "DEFINE" (see "conditional patterns").
(?: ... ) | Non-capturing group. Does not record the matching characters in the array and cannot be re-used as backreference.
(?| ... ) | Non-capturing group with reset. Resets capturing group numbers in each top-level alternative it contains: "(?|(Mon)|(Tue)s|(Wed)nes|(Thu)rs|(Fri)|(Sat)ur|(Sun))day" matches a weekday name and captures its abbreviation in group number 1.
(?> ... ) | Atomic non-capturing group: locks and never backtracks into (gives back from) what has been matched (see also Quantifiers and greediness below). Atomic groups, like possessive quantifiers, are always greedy.
(?# ... ) | Comment group: always ignored (but may not contain a closing parenthesis, hence comment groups are not nestable).

Quantifiers (or repetition specifiers) specify how many of the preceding character, class, reference or group are expected to match. Optional greediness qualifiers denote how aggressively the repetition will behave. For instance "\d{3,5}" will match at least 3 and no more than 5 decimal digits.
By default, patterns are "greedy", which means that quantifiers * + ? {...} will match the longest string which doesn't cause the rest of the pattern to fail. Greediness can be inverted for the entire pattern by giving option (?U) at the head of the pattern, or locally by placing a question mark following a quantifier.
Non-greedy (lazy) repetitions will match the smallest string that still allows the rest of the pattern to match. E.g. given the subject "aaab", the pattern "(a*)([ab]+)" will capture "aaa" then "b", but "(?U)(a*)([ab]+)" will capture "" then "a": indeed, capturing an empty string is good enough to satisfy the lazy "(a*)" and capturing "a" matches the lazy "([ab]+)" subpattern.
Possessive quantifiers are atomic and greedy. In fact they are a short notation for simple atomic groups. "\d++" is a shorthand notation for "(?>\d+)" and its behavior is "match a complete sequence of one or more digits, but never give back any". As a consequence "\d++(\d)" can never match since the last digit (in bold) is already matched and locked by "\d++". This is in contrast with simple greediness, where "\d+(\d)" will first match a complete sequence of digits with "\d+", but then backtrack the last one to allow "(\d)" to capture it.
There are two reasons for using an atomic group or a possessive quantifier: either for matching a sequence of characters that may also appear individually (e.g. "\r\n" in the definition of \R), or for forcing a quick failure in certain situations involving unbounded repetitions, where the engine would normally spend a very long time trying a huge number of grouping combinations before failing.
? | 0 or 1, greedy.
?+ | 0 or 1, possessive.
?? | 0 or 1, lazy.
* | 0 or more, greedy.
*+ | 0 or more, possessive.
*? | 0 or more, lazy.
+ | 1 or more, greedy.
++ | 1 or more, possessive.
+? | 1 or more, lazy.
{x} | exactly x.
{x,y} | at least x and no more than y, greedy.
{x,y}+ | at least x and no more than y, possessive.
{x,y}? | at least x and no more than y, lazy.
{x,} | x or more, greedy.
{x,}+ | x or more, possessive.
{x,}? | x or more, lazy.
X|Y Matches either subpattern X or Y: "ac|dc|ground" matches "ac" or "dc" or "ground".

Backreferences permit reuse of the content of a previously captured group.
\n | References a previous capturing group by its absolute number. WARNING: if no group number n exists, it evaluates as the character with value n provided n is a valid octal value, else errors out. Due to this ambiguity, this form is not recommended. Favor the next forms for a safe semantic.
\g n | References a previous capturing group by its absolute number.
\g{n} | References a previous capturing group by its absolute number. Similar to above but clearly delimits where n ends: useful when the following character(s) is(are) digits.
\g-n | References a previous capturing group by its relative number.
\k<name> | References a previous capturing group by its name.

References to subroutines

Capturing groups are subpatterns that can be invoked (possibly recursively) exactly like subroutines in a programming language. The subpattern is simply re-run at the current matching point. See reference documentation for details and examples.
(?R) or (?0) | Recurses into the entire regular expression.
(?n) | Calls subpattern by absolute number.
(?+n) | Calls subpattern by relative number.
(?-n) | Calls subpattern by relative number.
(?&name) | Calls subpattern by name.

Anchors and assertions are tests that do not change the matching position and therefore do not consume nor capture anything.

Anchors test the position of the current matching point.
^ | Outside a character class, the caret matches at the start of the subject text, and also just after a non-final newline sequence if option (?m) is active. By default the newline sequence is @CRLF. Inside a character class, a leading ^ complements the class (excludes the characters listed there).
$ | Outside a character class, the dollar matches at the end of the subject text, and also just before a newline sequence if option (?m) is active. Inside a character class, $ means itself, a dollar sign.
\A | Matches only at the absolute beginning of subject string, irrespective of the multiline option (?m). Will never match if offset is not 1.
\G | Matches when the current position is the first matching position in subject.
\z | Matches only at end of subject string, irrespective of the multiline option (?m).
\Z | Matches only at end of subject string, or before a newline sequence at the end, irrespective of the multiline option (?m).

Assertions test the character(s) preceding (look-behind), at (word boundary) or following (look-ahead) the current matching point.
\b | Matches at a "word" boundary, i.e. between characters not both \w or \W. See \w for the meaning of "word". Inside a character class, \b means "backspace" (Chr(8)).
\B | Matches when not at a word boundary.
(?=X) | Positive look-ahead: matches when the subpattern X matches starting at the current position.
(?!X) | Negative look-ahead: matches when the subpattern X does not match starting at the current position.
(?<=X) | Positive look-behind: matches when the subpattern X matches characters preceding the current position. Pattern X must match a fixed-length string, i.e. may not use any undefinite quantifier * + or ?.
(?<!X) | Negative look-behind: matches when the subpattern X does not match characters preceding the current position. Pattern X must match a fixed-length string, i.e. may not use any undefinite quantifier * + or ?.

There are situations where it is necessary to "forget" that something has matched so far, in order to match more pertinent data later in the subject string.
\K Resets start of match at the current point in subject string. Note that groups already captured are left alone and still populate the returned array; it is therefore always possible to backreference to them later on. Action of \K is similar but not identical to a look-behind, in that \K can work on alternations of varying lengths.

These constructs are similar to If...EndIf and If...Else...EndIf blocks.
(?(condition)yes-pattern) | Allows conditional execution of pattern.
(?(condition)yes-pattern|no-pattern) | Chooses between distinct patterns depending on the result of (condition).
(n) | Tests whether the capturing group with absolute number n matched.
(+n) | Tests whether the capturing group with relative number +n matched.
(-n) | Tests whether the capturing group with relative number -n matched.
(<name>) | Tests whether the capturing group with name name matched.
(R) | Tests whether any kind of recursion occured.
(R n) | Tests whether the most recent recursion was for capturing group with absolute number n.
(R&name) | Tests whether the most recent recursion was for capturing group with name name.
(DEFINE) | Used without no-pattern, permits definition of a subroutine useable from elsewhere. "(?x) (?(DEFINE) (?<byte> 2[0-4]\d | 25[0-5] | 1\d\d | [1-9]?\d) )" defines a subroutine named "byte" which matches any component of an IPv4 address. Then an actual address can be matched by "\b (?&byte) (\.(?&byte)){3} \b".
(assertion) | Here assertion is one of positive or negative, look-ahead or look-behind assertion.

These options, escapes and constructs are simply mentioned here; see reference documentation for detail on why, when and how to use them, if at all.

Uncommon settings and options
(?J) | Enables duplicate group or subroutine names (not discussed further here).
(?X) | Causes some out-of-context sequences to raise an error, instead of being benign.
(*J) | Enables Javascript compatibility (not discussed further here).
(*LIMIT_MATCH=n) | Limits number of matches to n.
(*LIMIT_RECURSION=n) | Limits recursion to n levels.
(*NO_START_OPT) | Disables several optimizations (not discussed further here).

Backtracking control
(*ACCEPT) | Forces an immediate match success in the current subroutine or top-level pattern.
(*FAIL) or (*F) | Forces an immediate match failure.
(*MARK:name) or (*:name) | (See reference documentation.)
(*COMMIT) | (See reference documentation.)
(*PRUNE) | (See reference documentation.)
(*PRUNE:name) | (See reference documentation.)
(*SKIP) | (See reference documentation.)
(*SKIP:name) | (See reference documentation.)
(*THEN) | (See reference documentation.)
(*THEN:name) | (See reference documentation.)

1. When UCP is active, case sense matching applies to the full Unicode plane 0. There are also a small number of many-to-one mappings in Unicode, like the Greek lowercase letter sigma; these are supported by PCRE with UCP enabled.

2. Alternate forms of several escapes exist for compatibility with Perl, Ruby, Python, JavaScript, .NET and other engines. Do not use constructs not listed here: some will simply not work, some will supply wrong results, some will cause severe issues or merely crash.

3. The default newline convention is the unbreakable sequence @CRLF or a separate @CR or @LF. Similarly \R matches the same set. Know your data! If you know that your subjects use separate @LF or @CR to mean something else than a newline, you may have to change the newline convention and/or the matching of \R (see "Settings").

See also the Regular Expression tutorial, in which you can run a script to test your regular expression(s).

Related

StringInStr, StringRegExpReplace

Example

Option 1, using offset parameter

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

Local $aArray = 0, _
        $iOffset = 1
While 1
    $aArray = StringRegExp('<test>a</test> <test>b</test> <test>c</Test>', '(?i)<test>(.*?)</test>', $STR_REGEXPARRAYMATCH, $iOffset)
    If @error Then ExitLoop
    $iOffset = @extended
    For $i = 0 To UBound($aArray) - 1
        MsgBox($MB_SYSTEMMODAL, "RegExp Test with Option 1 - " & $i, $aArray[$i])
    Next
WEnd

Option 2, single return, php/preg_match() style

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

Local $aArray = StringRegExp('<test>a</test> <test>b</test> <test>c</Test>', '(?i)<test>(.*?)</test>', $STR_REGEXPARRAYFULLMATCH)
For $i = 0 To UBound($aArray) - 1
    MsgBox($MB_SYSTEMMODAL, "RegExp Test with Option 2 - " & $i, $aArray[$i])
Next

Option 3, global return, old AutoIt style

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

Local $aArray = StringRegExp('<test>a</test> <test>b</test> <test>c</Test>', '(?i)<test>(.*?)</test>', $STR_REGEXPARRAYGLOBALMATCH)
For $i = 0 To UBound($aArray) - 1
    MsgBox($MB_SYSTEMMODAL, "RegExp Test with Option 3 - " & $i, $aArray[$i])
Next

Option 4, global return, php/preg_match_all() style

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

Local $aArray = StringRegExp('F1oF2oF3o', '(F.o)*?', $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aMatch = 0
For $i = 0 To UBound($aArray) - 1
    $aMatch = $aArray[$i]
    For $j = 0 To UBound($aMatch) - 1
        MsgBox($MB_SYSTEMMODAL, "RegExp Test with Option 4 - " & $i & ',' & $j, $aMatch[$j])
    Next
Next


Function StringRegExpReplace

Function Reference

StringRegExpReplace

Replace text in a string based on regular expressions.

StringRegExpReplace ( "test", "pattern", "replace" [, count = 0] )

Parameters

test | The string to check
pattern | The regular expression to compare. See StringRegExp for pattern definition characters.
replace | The text to replace the regular expression matching text with. To insert matched group text, \0 - \9 (or $0 - $9) can be used as back-references. (See remarks)
count | [optional] The number of times to execute the replacement in the string. The default is 0. Use 0 for global replacement.

Return Value

Success: | an updated string based on regular expressions. Check @extended for the number of replacements performed.
Failure: | sets the @error flag to non-zero.
@error: | 2 = Pattern invalid. @extended = offset of error in pattern.

Remarks

To separate back-reference replacements from actual (replaced) numbers, wrap them with curly braces, i.e: "${1}5".
If a "\" needs to be in the replaced string it must be doubled. This is a consequence of the back-references mechanism.
The "\" and "$" replacement formats are the only valid back-references formats supported.

See also the Regular Expression tutorial, in which you can run a script to test your regular expression(s).

Related

StringRegExp, StringReplace

Example

#include <MsgBoxConstants.au3>

Test1()
Test2()
Test3()

; This example demonstrates a basic replacement.  It replaces the vowels aeiou
; with the @ character.
Func Test1()
    Local $sInput = "Where have all the flowers gone, long time passing?"
    Local $sOutput = StringRegExpReplace($sInput, "[aeiou]", "@")
    Display($sInput, $sOutput)
EndFunc   ;==>Test1

; The following example demonstrates using back-references to change the date
; from MM/DD/YYYY to DD.MM.YYYY
Func Test2()
    Local $sInput = 'some text1 12/31/2009 01:02:03 some text2' & @CRLF & _
            'some text3 02/28/2009 11:22:33 some text4'
    Local $sOutput = StringRegExpReplace($sInput, '(\d{2})/(\d{2})/(\d{4})', ' $2.$1.$3 ')
    Display($sInput, $sOutput)
EndFunc   ;==>Test2

; The following example demonstrates the need to double backslash
Func Test3()
    Local $sInput = '%CommonProgramFiles%\Microsoft Shared\'
    Local $sOutput = StringRegExpReplace($sInput, '%([^%]*?)%', 'C:\\WINDOWS\\Some Other Folder$')
    Display($sInput, $sOutput)
EndFunc   ;==>Test3

Func Display($sInput, $sOutput)
    ; Format the output.
    Local $sMsg = StringFormat("Input:\t%s\n\nOutput:\t%s", $sInput, $sOutput)
    MsgBox($MB_SYSTEMMODAL, "Results", $sMsg)
EndFunc   ;==>Display


Function StringReplace

Function Reference

StringReplace

Replaces substrings in a string.

StringReplace ( "string", "searchstring/start", "replacestring" [, occurrence = 0 [, casesense = 0]] )

Parameters

string | The string to evaluate.
searchstring/start | The substring to search for or the character position to start the replacement.
replacestring | The replacement string.
occurrence | [optional] The number of times to replace the searchstring. Use a negative occurrence to replace from the right side. 0 = all searchstrings will be replaced (default)
casesense | [optional] Flag to indicate if the operations should be case sensitive. $STR_NOCASESENSE (0) = not case sensitive, using the user's locale (default) $STR_CASESENSE (1) = case sensitive $STR_NOCASESENSEBASIC (2) = not case sensitive, using a basic/faster comparison Constants are defined in StringConstants.au3.

Return Value

Returns the new string with the number of replacements performed stored in the @extended macro.

Remarks

By default or if the occurrence is positive the search/replace is performed left-to-right. Thus, StringReplace("aaa", "aa", "bb") returns "bba"

If the start method is used the occurrence and casesense parameters are ignored. The function will replace the characters in "string", starting at the requested position, with the characters in "replacestring" - as many characters will be replaced as are in "replacestring". However, if there are not enough characters in "string" for the entire "replacestring" to be inserted an empty string is returned and @error is set to 1.

Related

StringAddCR, StringLeft, StringLen, StringLower, StringMid, StringRight, StringStripWS, StringTrimLeft, StringTrimRight, StringUpper

Example

#include <MsgBoxConstants.au3>

; Replace a blank space (' ') with a - (minus) character.
Local $sString = StringReplace("This is a sentence with whitespace.", " ", "-")
Local $iReplacements = @extended
MsgBox($MB_SYSTEMMODAL, "", $iReplacements & " replacements were made and the new string is:" & @CRLF & @CRLF & $sString)


Function StringReverse

Function Reference

StringReverse

Reverses the contents of the specified string.

StringReverse ( "string" [, flag = 0] )

Parameters

string | The string to reverse.
flag | [optional] Changes the way the string is reversed $STR_UTF16 (0) = reversed in full UTF-16 mode. (default) $STR_UCS2 (1) = a much faster method - only use if using UCS-2 text. Constants are defined in "StringConstants.au3".

Return Value

Returns a reversed string.

Related

StringCompare, StringInStr, StringLen, StringLower, StringMid, StringReplace, StringRight, StringSplit, StringTrimLeft, StringTrimRight, StringUpper

Example

#include <MsgBoxConstants.au3>

; Reverse the string esreveR.
MsgBox($MB_SYSTEMMODAL, "", StringReverse("esreveR"))


Function StringRight

Function Reference

StringRight

Returns a number of characters from the right-hand side of a string.

StringRight ( "string", count )

Parameters

string | The string to evaluate.
count | The number of characters to get.

Return Value

Returns a string containing the rightmost count characters of the string.

Remarks

If count exceeds string length, the entire string is returned.
If count is negative, an empty string is returned.

Related

StringCompare, StringInStr, StringLeft, StringLen, StringLower, StringMid, StringReplace, StringSplit, StringTrimLeft, StringTrimRight, StringUpper

Example

#include <MsgBoxConstants.au3>

Local $sString = StringRight("This is a sentence with whitespace.", 5) ; Retrieve 5 characters from the right of the string.
MsgBox($MB_SYSTEMMODAL, "", "The 5 rightmost characters are: " & $sString)


Function StringSplit

Function Reference

StringSplit

Splits up a string into substrings depending on the given delimiters.

StringSplit ( "string", "delimiters" [, flag = 0] )

Parameters

string | The string to evaluate.
delimiters | One or more characters to use as delimiters (case sensitive).
flag | [optional] Changes how the string split works, add multiple flag values together if required: $STR_CHRSPLIT (0) = each character in the delimiter string will mark where to split the string (default) $STR_ENTIRESPLIT (1) = entire delimiter string is needed to mark the split $STR_NOCOUNT (2) = disable the return count in the first element - effectively makes the array 0-based (must use UBound() to get the size of the array in this case). Constants are defined in StringConstants.au3.

Return Value

Returns an array, by default the first element ($aArray[0]) contains the number of strings returned, the remaining elements ($aArray[1], $aArray[2], etc.) contain the delimited strings. If the flag parameter is set to $STR_NOCOUNT (2) then the count is not returned in the first element.

If no delimiters were found then the @error flag is set to 1:
If flag is not equal to $STR_NOCOUNT, $aArray[0] is set to 1 and the full string is returned in $aArray[1].
If flag is equal to $STR_NOCOUNT, the full string is returned in $aArray[0].

Remarks

If you use an empty string "" for the delimiters, each character will be returned as an element.

If the delimiter string contains several characters function behaviour depends on the flag setting. If set to $STR_CHRSPLIT the string will be split at every instance of each of the individual characters in the delimiter - if set to $STR_ENTIRESPLIT then the string will only be split when the entire delimiter string is encountered. See second example below.

Note that the macro @CRLF is actually a 2 character string, so unless the flag parameter to $STR_ENTIRESPLIT extra blank lines will be generated as the string is split on both @CR and @LF.

StringSplit() is very useful as an alternative to StringInStr() as well as a means to populate an array.

Related

StringInStr, StringLeft, StringLen, StringLower, StringMid, StringRight, StringTrimLeft, StringTrimRight, StringUpper

Example

Example 1

#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aDays = StringSplit("Mon,Tues,Wed,Thur,Fri,Sat,Sun", ",") ; Split the string of days using the delimiter "," and the default flag value.
    #cs
        The array returned will contain the following values:
        $aDays[1] = "Mon"
        $aDays[2] = "Tues"
        $aDays[3] = "Wed"
        ...
        $aDays[7] = "Sun"
    #ce

    For $i = 1 To $aDays[0] ; Loop through the array returned by StringSplit to display the individual values.
        MsgBox($MB_SYSTEMMODAL, "", "$aDays[" & $i & "] - " & $aDays[$i])
    Next
EndFunc   ;==>Example

Example 2

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

Example()

Func Example()
    Local $sText = "This\nline\ncontains\nC-style breaks." ; Define a variable with a string of text.
    Local $aArray = StringSplit($sText, '\n', $STR_ENTIRESPLIT) ; Pass the variable to StringSplit and using the delimiter "\n".
    ; Note that flag parameter is set to $STR_ENTIRESPLIT (1) as it would split at \ or n otherwise.
    #cs
        The array returned will contain the following values:
        $aArray[1] = "This"
        $aArray[2] = "line"
        ...
        $aArray[4] = "C-style breaks."
    #ce

    For $i = 1 To $aArray[0] ; Loop through the array returned by StringSplit to display the individual values.
        MsgBox($MB_SYSTEMMODAL, "", "$aArray[" & $i & "] - " & $aArray[$i])
    Next
EndFunc   ;==>Example

Example 3

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

Example()

Func Example()
    Local $sText = "This\nline\ncontains\nC-style breaks." ; Define a variable with a string of text.

    ; Pass the variable to StringSplit and using the delimiter "\n".
    ; Note that flag parameter is set to $STR_ENTIRESPLIT (1) as it would split at \ or n otherwise.
    MsgBox($MB_SYSTEMMODAL, "", StringSplit($sText, '\n', $STR_ENTIRESPLIT)[2]) ; Directly access the array index by using array access on expression.
    #cs
        An internal temporary array is used to return a string that may contain one of the following values:
        $aArray[1] = "This"
        $aArray[2] = "line"
        ...
        $aArray[4] = "C-style breaks."
    #ce
EndFunc   ;==>Example


Function StringStripCR

Function Reference

StringStripCR

Removes all carriage return values ( Chr(13) ) from a string.

StringStripCR ( "string" )

Parameters

string The string to convert.

Return Value

Returns the string with all instances of the @CR character ( Chr(13) ) removed.

Related

StringAddCR, StringIsSpace, StringStripWS

Example

#include <MsgBoxConstants.au3>

; A string with carriage return characters.
Local $sString = "This is a sentence " & @CR & "with " & Chr(13) & "whitespace."

; Strip all carriage return characters in the string.
Local $sStrippedString = StringStripCR($sString)

; Display the before and after string.
MsgBox($MB_SYSTEMMODAL, "", "Before: " & $sString & @CRLF & @CRLF & "After: " & $sStrippedString)


Function StringStripWS

Function Reference

StringStripWS

Strips the white space in a string.

StringStripWS ( "string", flag )

Parameters

string | The string to strip.
flag | Flag to indicate the type of stripping that should be performed (add the flags together for multiple operations): $STR_STRIPLEADING (1) = strip leading white space $STR_STRIPTRAILING (2) = strip trailing white space $STR_STRIPSPACES (4) = strip double (or more) spaces between words $STR_STRIPALL (8) = strip all spaces (over-rides all other flags) Constants are defined in StringConstants.au3.

Return Value

Returns the new string stripped of the requested white space.

Remarks

Whitespace includes Chr(9) thru Chr(13) which are HorizontalTab, LineFeed, VerticalTab, FormFeed, and CarriageReturn. Whitespace also includes the null string ( Chr(0) ) and the standard space ( Chr(32) ).

To strip single spaces between words, use the function StringReplace().

Related

StringIsSpace, StringReplace, StringStripCR

Example

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

; Strip leading and trailing whitespace as well as the double spaces (or more) in between the words.
Local $sString = StringStripWS("   This   is   a   sentence   with   whitespace.    ", $STR_STRIPLEADING + $STR_STRIPTRAILING + $STR_STRIPSPACES)
MsgBox($MB_SYSTEMMODAL, "", $sString)


Function StringToASCIIArray

Function Reference

StringToASCIIArray

Converts a string to an array containing the ASCII code of each character.

StringToASCIIArray ( "string",[start = 0 [, end [, encoding = 0]]] )

Parameters

"string" | The string to convert to an array of ASCII codes.
start | [optional] The 0-based position to start processing from (Default: 0).
end | [optional] The 0-based position to end processing at (Default: StringLen("string")).
encoding | [optional] The returned array will contain values in the specified character set: $SE_UTF16 (0) = UTF-16 (Default) $SE_ANSI (1) = ANSI $SE_UTF8 (2) = UTF-8 Constants are defined in StringConstants.au3.

Return Value

Success: | an array where each element is the UNICODE code of the character at the corresponding position.
Failure: | an empty string.

Remarks

The string may contain embedded Chr(0). These will appear in the returned array as well as any data past them. Processing only stops when the end of the string is reached or the user specified end.

In order to convert binary data to an array using this function it must first be converted to a string with the BinaryToString() function.

Related

BinaryToString, StringFromASCIIArray

Example

#include <MsgBoxConstants.au3>
#include <Array.au3> ; Required for _ArrayDisplay() only.

Example()

Func Example()
    ; Convert the string to an ASCII array.
    Local $aArray = StringToASCIIArray("This is a sentence with whitespace.")

    ; Display the array to see that it contains the ASCII values for each character in the string.
    _ArrayDisplay($aArray)

    ; Convert the array into a string.
    Local $sString = StringFromASCIIArray($aArray)

    ; Display the string to see that it matches the original string initially converted to an array.
    MsgBox($MB_SYSTEMMODAL, "", $sString)
EndFunc   ;==>Example


Function StringTrimLeft

Function Reference

StringTrimLeft

Trims a number of characters from the left hand side of a string.

StringTrimLeft ( "string", count )

Parameters

string | The string to evaluate.
count | The number of characters to trim.

Return Value

Returns the string trimmed by count characters from the left.

Remarks

If count is out-of-bounds, an empty string is returned.
StringTrimLeft($str, $n) is functionally equivalent to StringRight($str, StringLen($str) - $n)

Related

StringCompare, StringInStr, StringLeft, StringLen, StringLower, StringMid, StringReplace, StringRight, StringSplit, StringTrimRight, StringUpper

Example

#include <MsgBoxConstants.au3>

Local $sString = StringTrimLeft("This is a sentence with whitespace.", 5) ; Remove the 5 leftmost characters from the string.
MsgBox($MB_SYSTEMMODAL, "", $sString)


Function StringTrimRight

Function Reference

StringTrimRight

Trims a number of characters from the right hand side of a string.

StringTrimRight ( "string", count )

Parameters

string | The string to evaluate.
count | The number of characters to trim.

Return Value

Returns the string trimmed by count characters from the right.

Remarks

If count is out-of-bounds, an empty string is returned.
StringTrimRight($str, $n) is functionally equivalent to StringLeft($str, StringLen($str) - $n)

Related

StringCompare, StringInStr, StringLeft, StringLen, StringLower, StringMid, StringReplace, StringRight, StringSplit, StringTrimLeft, StringUpper

Example

#include <MsgBoxConstants.au3>

Local $sString = StringTrimRight("This is a sentence with whitespace.", 5) ; Remove the 5 rightmost characters from the string.
MsgBox($MB_SYSTEMMODAL, "", $sString)


Function StringUpper

Function Reference

StringUpper

Converts a string to uppercase.

StringUpper ( "string" )

Parameters

string The string to convert.

Return Value

Returns the string converted to uppercase.

Related

StringCompare, StringInStr, StringIsAlNum, StringIsAlpha, StringIsASCII, StringIsLower, StringIsSpace, StringIsUpper, StringIsXDigit, StringLeft, StringLen, StringLower, StringMid, StringReplace, StringRight, StringSplit, StringTrimLeft, StringTrimRight

Example

#include <MsgBoxConstants.au3>

Local $sString = StringUpper("This is a string") ; Convert the following string to uppercase.
MsgBox($MB_SYSTEMMODAL, "", "StringUpper returned: " & $sString)


Functions

Timer and Delay functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
Sleep | Pause script execution.
TimerDiff | Returns the difference in time from a previous call to TimerInit().
TimerInit | Returns a handle that can be passed to TimerDiff() to calculate the difference in milliseconds.


Function Sleep

Function Reference

Sleep

Pause script execution.

Sleep ( delay )

Parameters

delay Amount of time to pause (in milliseconds).

Return Value

None.

Remarks

Maximum sleep time is 2147483647 milliseconds (24 days) and the minimum is 10 milliseconds. So using 1-9 will automatically default to 10 milliseconds.

Due to internal implementation, the sleep time completion is checked every 10 milisseconds so the precision cannot be less than 10.
Note that other running processes often affect the timing accuracy and so pauses are likely to last for slightly longer than requested.

Example

; Sleep for 5 seconds.

Sleep(5000)


Function TimerInit

Function Reference

TimerInit

Returns a handle that can be passed to TimerDiff() to calculate the difference in milliseconds.

TimerInit ( )

Return Value

Returns a handle that can be passed to TimerDiff() to calculate the difference in milliseconds.

Remarks

The return value from TimerInit() should be treated as an opaque handle and should only be used to pass to TimerDiff(). Any other usage of the return value is a potential error.

Related

TimerDiff

Example

#include <MsgBoxConstants.au3>

Local $hTimer = TimerInit() ; Begin the timer and store the handle in a variable.
Sleep(3000) ; Sleep for 3 seconds.
Local $fDiff = TimerDiff($hTimer) ; Find the difference in time from the previous call of TimerInit. The variable we stored the TimerInit handlem is passed as the "handle" to TimerDiff.
MsgBox($MB_SYSTEMMODAL, "Time Difference", $fDiff)


Function TimerDiff

Function Reference

TimerDiff

Returns the difference in time from a previous call to TimerInit().

TimerDiff ( handle )

Parameters

handle Handle returned from a previous call to TimerInit().

Return Value

Returns the time difference (in milliseconds) from a previous call to TimerInit().

Remarks

Some processors are known to cause the function to return incorrect result.

Related

TimerInit

Example

#include <MsgBoxConstants.au3>

Local $hTimer = TimerInit() ; Begin the timer and store the handle in a variable.
Sleep(3000) ; Sleep for 3 seconds.
Local $fDiff = TimerDiff($hTimer) ; Find the difference in time from the previous call of TimerInit. The variable we stored the TimerInit handlem is passed as the "handle" to TimerDiff.
MsgBox($MB_SYSTEMMODAL, "Time Difference", $fDiff)


Functions

Tray functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
TrayCreateItem | Creates a menuitem control for the tray.
TrayCreateMenu | Creates a menu control for the tray menu.
TrayGetMsg | Polls the tray to see if any events have occurred.
TrayItemDelete | Deletes a menu/item control from the tray menu.
TrayItemGetHandle | Returns the handle for a tray menu(item).
TrayItemGetState | Gets the current state of a control.
TrayItemGetText | Gets the itemtext of a tray menu/item control.
TrayItemSetOnEvent | Defines a user-defined function to be called when a tray item is clicked.
TrayItemSetState | Sets the state of a tray menu/item control.
TrayItemSetText | Sets the itemtext of a tray menu/item control.
TraySetClick | Sets the clickmode of the tray icon - what mouseclicks will display the tray menu.
TraySetIcon | Loads/Sets a specified tray icon.
TraySetOnEvent | Defines a user function to be called when a special tray action happens.
TraySetPauseIcon | Loads/Sets a specified tray pause icon.
TraySetState | Sets the state of the tray icon.
TraySetToolTip | (Re)Sets the tooltip text for the tray icon.
TrayTip | Displays a balloon tip from the AutoIt Icon.


Function TrayCreateItem

Function Reference

TrayCreateItem

Creates a menuitem control for the tray.

TrayCreateItem ( "text" [, menuID = -1 [, menuentry = -1 [, menuradioitem = 0]]] )

Parameters

text | The text of the control.
menuID | [optional] Allows you to create a submenu in the referenced menu. If equal -1 it will be added 'behind' the last created item (default setting).
menuentry | [optional] Allows you to define the entry number to be created. The entries are numbered starting at 0. If equal -1 it will be added 'behind' the last created entry (default setting).
menuradioitem | [optional] $TRAY_ITEM_NORMAL (0) = (default) create a normal menuitem. $TRAY_ITEM_RADIO (1) = create a menuradioitem. Constants are defined in TrayConstants.au3.

Return Value

Success: | the identifier (controlID) of the new tray menuitem.
Failure: | 0.

Remarks

If the 'text' parameter is an empty string ( "" ) then a separator line is created.

By default, normal checked menuitems (not radio menuitems) will be automatically unchecked if you click it!
To turn off this behaviour use Opt("TrayMenuMode", 2).

Radio menuitems are automatically grouped together and these groups are separated by a separator line or a normal item which is not a radio item.
By default, a clicked radio menuitem will be checked automatically and all other radio items in the same group will be unchecked!
To turn off this behaviour use Opt("TrayMenuMode", 8).

Related

TrayGetMsg, TrayItemDelete, TrayItemSetOnEvent, TrayItemSetState, TrayItemSetText

Example

#NoTrayIcon
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_CHECKED and $TRAY_ICONSTATE_SHOW constants.

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.

Example()

Func Example()
    ; Create a tray item with the radio item parameter selected.
    TrayCreateItem("Radio 1", -1, -1, $TRAY_ITEM_RADIO)
    TrayItemSetState(-1, $TRAY_CHECKED)
    TrayCreateItem("Radio 2", -1, -1, $TRAY_ITEM_RADIO)
    TrayCreateItem("Radio 3", -1, -1, $TRAY_ITEM_RADIO)

    TrayCreateItem("") ; Create a separator line.

    Local $idAbout = TrayCreateItem("About")
    TrayCreateItem("") ; Create a separator line.

    Local $idExit = TrayCreateItem("Exit")

    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

    While 1
        Switch TrayGetMsg()
            Case $idAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
                MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _
                        "Version: " & @AutoItVersion & @CRLF & _
                        "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path.

            Case $idExit ; Exit the loop.
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function TrayCreateMenu

Function Reference

TrayCreateMenu

Creates a menu control for the tray menu.

TrayCreateMenu ( "sub/menutext" [, menuID = -1 [, menuentry = -1]] )

Parameters

sub/menutext | The sub/menu text.
menuID | [optional] If defined, allows you to create a submenu in the referenced menu. Default -1 (refers to first level menu).
menuentry | [optional] Allows you to define the entry number to be created. The entries are numbered starting at 0. Default -1 (at the bottom).

Return Value

Success: | the identifier (controlID) of the new tray menu.
Failure: | 0.

Related

TrayGetMsg, TrayItemDelete, TrayItemSetState, TrayItemSetText

Example

#NoTrayIcon
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant.

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.

Example()

Func Example()
    Local $iSettings = TrayCreateMenu("Settings") ; Create a tray menu sub menu with two sub items.
    Local $iDisplay = TrayCreateItem("Display", $iSettings)
    Local $iPrinter = TrayCreateItem("Printer", $iSettings)
    TrayCreateItem("") ; Create a separator line.

    Local $idAbout = TrayCreateItem("About")
    TrayCreateItem("") ; Create a separator line.

    Local $idExit = TrayCreateItem("Exit")

    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

    While 1
        Switch TrayGetMsg()
            Case $idAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
                MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _
                        "Version: " & @AutoItVersion & @CRLF & _
                        "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path.

            Case $iDisplay, $iPrinter
                MsgBox($MB_SYSTEMMODAL, "", "A sub menu item was selected from the tray menu.")

            Case $idExit ; Exit the loop.
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function TrayItemDelete

Function Reference

TrayItemDelete

Deletes a menu/item control from the tray menu.

TrayItemDelete ( controlID )

Parameters

controlID The control identifier (controlID) as returned by a TrayCreateItem or TrayCreateMenu function.

Return Value

Success: | 1.
Failure: | 0.

Related

TrayCreateItem, TrayCreateMenu

Example

#NoTrayIcon
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant.

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.

Example()

Func Example()
    Local $idDelete = TrayCreateItem("Delete")
    TrayCreateItem("") ; Create a separator line.

    Local $idAbout = TrayCreateItem("About")
    TrayCreateItem("") ; Create a separator line.

    Local $idExit = TrayCreateItem("Exit")

    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

    While 1
        Switch TrayGetMsg()
            Case $idAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
                MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _
                        "Version: " & @AutoItVersion & @CRLF & _
                        "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path.

            Case $idDelete
                ; Display a message box to ask whether or not to delete the 'Delete' item. If the return value of MsgBox is equal to $IDYES then delete the item.
                If MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL), "", "Do you want to delete the 'Delete' tray menu item?") = $IDYES Then
                    TrayItemDelete($idDelete) ; Delete the tray menu item.
                EndIf

            Case $idExit ; Exit the loop.
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function TrayItemGetHandle

Function Reference

TrayItemGetHandle

Returns the handle for a tray menu(item).

TrayItemGetHandle ( controlID )

Parameters

controlID The control identifier (controlID) as returned by a TrayCreateItem or TrayCreateMenu function.

Return Value

Success: | the handle of the given control ID.
Failure: | 0.

Remarks

To get the handle to the tray context menu itself use '0' as controlID.

Related

TrayItemGetState, TrayItemGetText

Example

#NoTrayIcon
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant.

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.

Global Const $MIM_APPLYTOSUBMENUS = 0x80000000, $MIM_BACKGROUND = 0x00000002 ; Constants required for SetMenuColor

Example()

Func Example()
    Local $idSettings = TrayCreateMenu("Settings") ; Create a tray menu sub menu with two sub items.
    Local $idDisplay = TrayCreateItem("Display", $idSettings)
    Local $idPrinter = TrayCreateItem("Printer", $idSettings)
    TrayCreateItem("") ; Create a separator line.

    Local $idAbout = TrayCreateItem("About")
    TrayCreateItem("") ; Create a separator line.

    Local $idExit = TrayCreateItem("Exit")

    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

    SetMenuColor(0, 0xEEBB99) ; BGR color value, '0' refers to the tray menu itself.
    SetMenuColor($idSettings, 0x66BB99); BGR color value for the 'Settings' menu.

    While 1
        Switch TrayGetMsg()
            Case $idAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
                MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _
                        "Version: " & @AutoItVersion & @CRLF & _
                        "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path.

            Case $idDisplay, $idPrinter
                MsgBox($MB_SYSTEMMODAL, "", "A sub menu item was selected from the tray menu.")

            Case $idExit ; Exit the loop.
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func SetMenuColor($iMenuID, $iColor)
    Local $hMenu = TrayItemGetHandle($iMenuID) ; Get the internal menu handle

    Local $hBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $iColor)
    $hBrush = $hBrush[0]

    Local $tMenuInfo = DllStructCreate("dword;dword;dword;uint;ptr;dword;ptr")
    DllStructSetData($tMenuInfo, 1, DllStructGetSize($tMenuInfo))
    DllStructSetData($tMenuInfo, 2, BitOR($MIM_APPLYTOSUBMENUS, $MIM_BACKGROUND))
    DllStructSetData($tMenuInfo, 5, $hBrush)

    DllCall("user32.dll", "int", "SetMenuInfo", "hwnd", $hMenu, "struct*", $tMenuInfo)
EndFunc   ;==>SetMenuColor


Function TrayItemGetState

Function Reference

TrayItemGetState

Gets the current state of a control.

TrayItemGetState ( [controlID] )

Parameters

controlID [optional] The control identifier (controlID) as returned by a TrayCreateItem or TrayCreateMenu function.

Return Value

Returns the state. See TrayItemSetState table for values.

Related

TrayItemGetHandle, TrayItemSetState

Example

#NoTrayIcon
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant.

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.

Example()

Func Example()
    Local $idGetState = TrayCreateItem("Get 'About' State")
    TrayCreateItem("") ; Create a separator line.

    Local $idAbout = TrayCreateItem("About")
    TrayCreateItem("") ; Create a separator line.

    Local $idExit = TrayCreateItem("Exit")

    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

    While 1
        Switch TrayGetMsg()
            Case $idAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
                MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _
                        "Version: " & @AutoItVersion & @CRLF & _
                        "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path.

            Case $idGetState
                ; Display a message box about the state of the 'About' item.
                MsgBox($MB_SYSTEMMODAL, "", "The state of the 'About' item is: " & TrayItemGetState($idAbout))

            Case $idExit ; Exit the loop.
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function TrayItemGetText

Function Reference

TrayItemGetText

Gets the itemtext of a tray menu/item control.

TrayItemGetText ( controlID )

Parameters

controlID The control identifier (controlID) as returned by a TrayCreateItem or TrayCreateMenu function.

Return Value

Success: | The itemtext of the tray menu/item control.
Failure: | 0.

Related

TrayItemGetHandle, TrayItemSetText

Example

#NoTrayIcon
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant.

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.

Example()

Func Example()
    Local $idGetText = TrayCreateItem("Get 'About' Text")
    TrayCreateItem("") ; Create a separator line.

    Local $idAbout = TrayCreateItem("About")
    TrayCreateItem("") ; Create a separator line.

    Local $idExit = TrayCreateItem("Exit")

    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

    While 1
        Switch TrayGetMsg()
            Case $idAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
                MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _
                        "Version: " & @AutoItVersion & @CRLF & _
                        "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path.

            Case $idGetText
                ; Display a message box about the text of the 'About' item.
                MsgBox($MB_SYSTEMMODAL, "", "The text of the 'About' item is: " & TrayItemGetText($idAbout))

            Case $idExit ; Exit the loop.
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function TrayItemSetOnEvent

Function Reference

TrayItemSetOnEvent

Defines a user-defined function to be called when a tray item is clicked.

TrayItemSetOnEvent ( itemID, "function" )

Parameters

itemID | The item identifier (itemID) as returned by a TrayCreateItem function.
function | The name of the user function to call.

Return Value

Success: | 1.
Failure: | 0.
@error: | 1 = the "function" is not defined.

Remarks

OnEvent functions are only called when the option Opt("TrayOnEventMode", 1) - when in this mode TrayGetMsg() is NOT used at all.

Within the called user function the item identifier can be retrieved with @TRAY_ID.

If the function is an empty string "" the previous user-defined is disabled.

Related

TrayCreateItem, TrayGetMsg, TrayOnEventMode (Option), TraySetOnEvent

Example

#NoTrayIcon
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3>

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.
Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode.

Example()

Func Example()
    TrayCreateItem("About")
    TrayItemSetOnEvent(-1, "About")

    TrayCreateItem("") ; Create a separator line.

    TrayCreateItem("Exit")
    TrayItemSetOnEvent(-1, "ExitScript")

    TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "About") ; Display the About MsgBox when the tray icon is double clicked on with the primary mouse button.

    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

    While 1
        Sleep(100) ; An idle loop.
    WEnd
EndFunc   ;==>Example

Func About()
    ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
    MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _
            "Version: " & @AutoItVersion & @CRLF & _
            "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path.
EndFunc   ;==>About

Func ExitScript()
    Exit
EndFunc   ;==>ExitScript


Function TrayItemSetState

Function Reference

TrayItemSetState

Sets the state of a tray menu/item control.

TrayItemSetState ( controlID, state )

Parameters

controlID | The control identifier (controlID) as returned by a TrayCreateItem or TrayCreateMenu function.
state | See the State table below.

Return Value

Success: | 1.
Failure: | 0.

Remarks

State table

State | Value | Comments
No Change | 0
$TRAY_CHECKED | 1 | Menuitem will be checked
$TRAY_UNCHECKED | 4 | Menuitem will be unchecked
$TRAY_ENABLE | 64 | Menuitem will be enabled
$TRAY_DISABLE | 128 | Menuitem will be greyed out
$TRAY_FOCUS | 256 | Menuitem will be selected
$TRAY_DEFAULT | 512 | Menuitem will be set as default menuitem

State values can be summed up as for example $TRAY_CHECKED + $TRAY_DEFAULT sets the menuitem in an checked and default state.

To reset/delete the $TRAY_DEFAULT-state for a menuitem just use this function on the item with another state, for instance with $TRAY_ENABLE.

When you set $TRAY_DEFAULT state for a menuitem, the default behavior of primary double click on tray icon is to execute this default menuitem. To disable this behavior use Opt("TrayMenuMode", 4).

The above constants are defined in #include <TrayConstants.au3>.

Related

TrayCreateItem, TrayCreateMenu, TrayItemGetState, TraySetState

Example

#NoTrayIcon
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_CHECKED and $TRAY_ICONSTATE_SHOW constants.

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.

Example()

Func Example()
    Local $idSetState = TrayCreateItem("Set 'About' State")
    TrayCreateItem("") ; Create a separator line.

    Local $idAbout = TrayCreateItem("About")
    TrayCreateItem("") ; Create a separator line.

    Local $idExit = TrayCreateItem("Exit")

    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

    While 1
        Switch TrayGetMsg()
            Case $idAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
                MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _
                        "Version: " & @AutoItVersion & @CRLF & _
                        "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path.

            Case $idSetState
                ; Set the 'About' item state to checked.
                TrayItemSetState($idAbout, $TRAY_CHECKED)

            Case $idExit ; Exit the loop.
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function TrayItemSetText

Function Reference

TrayItemSetText

Sets the itemtext of a tray menu/item control.

TrayItemSetText ( controlID, text )

Parameters

controlID | The control identifier (controlID) as returned by a TrayCreateItem or TrayCreateMenu function.
text | The new text of the tray menu/item control.

Return Value

Success: | 1.
Failure: | 0.

Remarks

To change the itemtext of the default menuitems (Script Paused/Exit) use the constants $TRAY_ITEM_EXIT and $TRAY_ITEM_PAUSE as controlID.

The above constants are defined in #include <TrayConstants.au3>.

Related

TrayCreateItem, TrayCreateMenu, TrayItemGetText

Example

#NoTrayIcon
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW, $TRAY_ITEM_EXIT and $TRAY_ITEM_PAUSE constants.

Opt("TrayAutoPause", 0) ; The script will not pause when selecting the tray icon.
Opt("TrayMenuMode", 2) ; Items are not checked when selected.

Example()

Func Example()
    Local $idRandom = TrayCreateItem("Random:") ; Select this item to change the text with a random number.
    TrayCreateItem("") ; Create a separator line.

    Local $idAbout = TrayCreateItem("About")

    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

    TrayItemSetText($TRAY_ITEM_EXIT, "Exit Program") ; Set the text of the default 'Exit' item.
    TrayItemSetText($TRAY_ITEM_PAUSE, "Pause Program") ; Set the text of the default 'Pause' item.

    While 1
        Switch TrayGetMsg()
            Case $idAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
                MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _
                        "Version: " & @AutoItVersion & @CRLF & _
                        "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path.

            Case $idRandom
                ; Set the text of the 'Random' item with a random integer.
                TrayItemSetText($idRandom, "Random: " & Int(Random(1, 10, 1)))

        EndSwitch
    WEnd
EndFunc   ;==>Example


Function TrayGetMsg

Function Reference

TrayGetMsg

Polls the tray to see if any events have occurred.

TrayGetMsg ( )

Return Value

Returns an event.

The "event" returned is the control ID of the control sending the message, or it is a special event (like the mouse clicking on the tray icon). Or if there is no message, the event is 0.

Event IDs
$TRAY_EVENT_NONE (0): | No event
Control ID: | the ID of the control sending the message
$TRAY_EVENT_PRIMARYDOWN: | the primary mouse button was pressed
$TRAY_EVENT_PRIMARYUP: | the primary mouse button was released
$TRAY_EVENT_SECONDARYDOWN: | the secondary mouse button was pressed
$TRAY_EVENT_SECONDARYUP: | the secondary mouse button was released
$TRAY_EVENT_PRIMARYDOUBLE: | the primary mouse button was double pressed
$TRAY_EVENT_SECONDARYDOUBLE: | the secondary mouse button was double pressed

Constants are defined in TrayConstants.au3

Remarks

This function automatically idles the CPU when required so that it can be safely used in tight loops without hogging all the CPU.

Related

TrayCreateItem, TrayCreateMenu, TrayItemSetOnEvent

Example

#NoTrayIcon
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant.

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.

Example()

Func Example()
    Local $idAbout = TrayCreateItem("About")
    TrayCreateItem("") ; Create a separator line.

    Local $idExit = TrayCreateItem("Exit")

    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

    While 1
        Switch TrayGetMsg()
            Case $idAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
                MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _
                        "Version: " & @AutoItVersion & @CRLF & _
                        "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path.

            Case $idExit ; Exit the loop.
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function TraySetClick

Function Reference

TraySetClick

Sets the clickmode of the tray icon - what mouseclicks will display the tray menu.

TraySetClick ( flag )

Parameters

flag 0 = Tray menu will never be shown through a mouseclick
1 = Pressing primary mouse button
2 = Releasing primary mouse button
4 = Double-click primary mouse button
8 = Pressing secondary mouse button
16 = Releasing secondary mouse button
32 = Double-click secondary mouse button
64 = Hovering over the tray icon

Return Value

None.

Remarks

These flags are NOT tray event values!
Default value is "9" - pressing the primary or secondary mouse button will show the tray menu.

Related

TraySetOnEvent

Example

#NoTrayIcon
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant.

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.

Example()

Func Example()
    Local $idAbout = TrayCreateItem("About")
    TrayCreateItem("") ; Create a separator line.

    Local $idExit = TrayCreateItem("Exit")

    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.
    TraySetClick($TRAY_CLICK_HOVERING) ; Show the tray menu when the mouse if hovered over the tray icon.

    While 1
        Switch TrayGetMsg()
            Case $idAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
                MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _
                        "Version: " & @AutoItVersion & @CRLF & _
                        "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path.

            Case $idExit ; Exit the loop.
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function TraySetIcon

Function Reference

TraySetIcon

Loads/Sets a specified tray icon.

TraySetIcon ( [filename [, iconID]] )

Parameters

filename | [optional] The filename of the icon to be display in the tray.
iconID | [optional] Icon identifier if the file contains multiple icons.

Return Value

None.

Remarks

To reset the icon to the default, use the function with no parameters TraySetIcon().

Passing a positive number will reference the string equivalent icon name.
Passing a negative number causes 1-based "index" behaviour. Some Dll can have icon extracted just with negative numbers.

The filename parameter can be set to "blank", "info", "question", "stop" or "warning" to select some corresponding standard icon.

Related

TraySetPauseIcon, TraySetState

Example

#NoTrayIcon
#include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant.

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.

Example()

Func Example()
    Local $idExit = TrayCreateItem("Exit")

    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

    Local $hTimer = TimerInit() ; Begin the timer and store the handle in a variable.
    Local $fDiff = 0, $iIndex = 0

    While 1
        $fDiff = TimerDiff($hTimer) ; Find the difference in time from the previous call of TimerInit
        If $fDiff > 1000 Then ; If the difference is greater than 1 second then change the tray menu icon.

            $iIndex = -Random(0, 100, 1) ; Use a negative number for ordinal numbering.
            TraySetToolTip("Currently using the icon shell32.dll, " & $iIndex & ".") ; Set the tray menu tooltip with information about the icon index.
            TraySetIcon("shell32.dll", $iIndex) ; Set the tray menu icon using the shell32.dll and the random index number.
            $hTimer = TimerInit() ; Reset the timer.

        EndIf

        Switch TrayGetMsg()
            Case $idExit ; Exit the loop.
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function TraySetOnEvent

Function Reference

TraySetOnEvent

Defines a user function to be called when a special tray action happens.

TraySetOnEvent ( specialID, "function" )

Parameters

specialID | See the Special ID table below.
function | The name of the user function to call.

Return Value

Success: | 1.
Failure: | 0.
@error: | 1 = the "function" is not defined.

Remarks

OnEvent functions are only called when Opt("TrayOnEventMode", 1) - when in this mode TrayGetMsg() is NOT used at all.

Special ID table

Special Id | Value | Comments
$TRAY_EVENT_SHOWICON | -3 | The tray icon will be shown.
$TRAY_EVENT_HIDEICON | -4 | The tray icon will be hidden.
$TRAY_EVENT_FLASHICON | -5 | The user turned the tray icon flashing on.
$TRAY_EVENT_NOFLASHICON | -6 | The user turned the tray icon flashing off.
$TRAY_EVENT_PRIMARYDOWN | -7 | The primary mouse button was pressed on the tray icon.
$TRAY_EVENT_PRIMARYUP | -8 | The primary mouse button was released on the tray icon.
$TRAY_EVENT_SECONDARYDOWN | -9 | The secondary mouse button was pressed on the tray icon.
$TRAY_EVENT_SECONDARYUP | -10 | The secondary mouse button was released on the tray icon.
$TRAY_EVENT_MOUSEOVER | -11 | The mouse moves over the tray icon.
$TRAY_EVENT_PRIMARYDOUBLE | -13 | The primary mouse button was double pressed on the tray icon.
$TRAY_EVENT_SECONDARYDOUBLE | -14 | The secondary mouse button was double pressed on the tray icon.

If the function is an empty string "" the previous user-defined is disabled.

The above constants are defined in #include <TrayConstants.au3>.

Related

TrayItemSetOnEvent, TrayOnEventMode (Option), TraySetClick

Example

#NoTrayIcon
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_EVENT_PRIMARYDOUBLE, $TRAY_EVENT_SECONDARYUP and $TRAY_ICONSTATE_SHOW constants.

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.
Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode.

Example()

Func Example()
    TrayCreateItem("About")

    TrayCreateItem("") ; Create a separator line.

    TrayCreateItem("Exit")
    TrayItemSetOnEvent(-1, "ExitScript")

    TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "TrayEvent")
    TraySetOnEvent($TRAY_EVENT_SECONDARYUP, "TrayEvent")

    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

    While 1
        Sleep(100) ; An idle loop.
    WEnd
EndFunc   ;==>Example

Func TrayEvent()
    Switch @TRAY_ID ; Check the last tray item identifier.
        Case $TRAY_EVENT_PRIMARYDOUBLE
            ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
            MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _
                    "Version: " & @AutoItVersion & @CRLF & _
                    "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path.

        Case $TRAY_EVENT_SECONDARYUP
            MsgBox($MB_SYSTEMMODAL, "", "The secondary mouse button was released on the tray icon.")

    EndSwitch
EndFunc   ;==>TrayEvent

Func ExitScript()
    Exit
EndFunc   ;==>ExitScript


Function TraySetPauseIcon

Function Reference

TraySetPauseIcon

Loads/Sets a specified tray pause icon.

TraySetPauseIcon ( [filename [, iconID]] )

Parameters

filename | [optional] The filename of the icon to be display as pause icon in the tray.
iconID | [optional] Icon identifier if the file contains multiple icons.

Return Value

None.

Remarks

To reset the pause icon to the default (red cross), use the function with no parameters TraySetPauseIcon().

Passing a positive number will reference the string equivalent icon name.
Passing a negative number causes 1-based "index" behaviour. Some Dll can have icon extracted just with negative numbers.

Related

TraySetIcon, TraySetState

Example

#NoTrayIcon
#include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant.

Example()

Func Example()
    TraySetPauseIcon("shell32.dll", 12) ; Set the pause icon. This will flash on and off when the tray menu is selected and the script is paused.
    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

    While 1
        Sleep(100) ; An idle loop.
    WEnd
EndFunc   ;==>Example


Function TraySetState

Function Reference

TraySetState

Sets the state of the tray icon.

TraySetState ( [flag = 1] )

Parameters

flag [optional] A combination of the following:
$TRAY_ICONSTATE_SHOW (1) = Shows the tray icon (default)
$TRAY_ICONSTATE_HIDE (2) = Destroys/Hides the tray icon
$TRAY_ICONSTATE_FLASH (4) = Flashes the tray icon
$TRAY_ICONSTATE_STOPFLASH (8) = Stops tray icon flashing
$TRAY_ICONSTATE_RESET (16) = Resets the icon to the defaults (no flashing, default tip text)

Constants are defined in TrayConstants.au3.

Return Value

None.

Remarks

This function overrides Opt("TrayIconHide") and #NoTrayIcon.
The normal and pause tray icon are NOT reset by this function!

Related

TrayItemSetState, TraySetIcon, TraySetPauseIcon

Example

#NoTrayIcon
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant.

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.

Example()

Func Example()
    Local $idFlash = TrayCreateItem("Flash Icon")
    TrayCreateItem("") ; Create a separator line.

    Local $idAbout = TrayCreateItem("About")
    TrayCreateItem("") ; Create a separator line.

    Local $idExit = TrayCreateItem("Exit")

    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

    While 1
        Switch TrayGetMsg()
            Case $idAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
                MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _
                        "Version: " & @AutoItVersion & @CRLF & _
                        "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) - 1)) ; Find the folder of a full path.

            Case $idFlash
                ; Start flashing the tray icon.
                TraySetState($TRAY_ICONSTATE_FLASH)
                Sleep(5000) ; Wait for 5 seconds.
                ; Stop flashing the tray icon.
                TraySetState($TRAY_ICONSTATE_STOPFLASH)

            Case $idExit ; Exit the loop.
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function TraySetToolTip

Function Reference

TraySetToolTip

(Re)Sets the tooltip text for the tray icon.

TraySetToolTip ( [text] )

Parameters

text [optional] The new text to be displayed as tooltip. The length is limited - see Remarks.

Return Value

Success: | 1.
Failure: | 0.

Remarks

The tooltip length is limited to 128 characters.

To reset the tooltip to the default text, use the function with no parameters TraySetToolTip().

The tooltip text is only changed when the tray icon is visible!

Related

TrayTip

Example

#NoTrayIcon
#include <TrayConstants.au3>

Example()

Func Example()
    TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.
    TraySetToolTip("An example of a tray menu tooltip.") ; The tray menu icon must be shown before we can set some text.

    While 1
        Sleep(100) ; An idle loop.
    WEnd
EndFunc   ;==>Example


Function TrayTip

Function Reference

TrayTip

Displays a balloon tip from the AutoIt Icon.

TrayTip ( "title", "text", timeout [, option = 0] )

Parameters

title | Text appears in bold at the top of the balloon tip. (63 characters maximum)
text | Message the balloon tip will display. (255 characters maximum)
timeout | A rough estimate of the time (in seconds) the balloon tip should be displayed. (Windows has a min and max of about 10-30 seconds but does not always honor a time in that range.)
option | [optional] $TIP_ICONNONE (0) = No icon (default) $TIP_ICONASTERISK (1) = Info icon $TIP_ICONEXCLAMATION (2) = Warning icon $TIP_ICONHAND (3) = Error icon $TIP_NOSOUND (16) = Disable sound Constants are defined in TrayConstants.au3.

Return Value

None.

Remarks

A Tray tip will close if the AutoIt tray icon disappears. Consequently, the TrayTip() may not appear if Opt("TrayIconHide", 1) is set or if the user has disabled balloon tips via registry settings!

Windows XP usually plays a sound when displaying a balloon tip. This sound can be disabled by adding $TIP_NOSOUND to the option parameter or by setting an empty title.

To clear a balloon tip that is being displayed, call another tip with an empty text string (and any title).

Related

MsgBox, ToolTip, TrayIconHide (Option), TraySetToolTip

Example

#include <MsgBoxConstants.au3>
#include <TrayConstants.au3>

TrayTip("I'm a title", "I'm the message", 0, $TIP_ICONASTERISK)
MsgBox($MB_SYSTEMMODAL, "", "Press OK to reset the tip.")
TrayTip("clears any tray tip", "", 0)
MsgBox($MB_SYSTEMMODAL, "", "Press OK to see another tip.")
TrayTip("", "A different tray tip.", 5)
Sleep(5000)


Functions

Variables and Conversions functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
Asc | Returns the ASCII code of a character.
AscW | Returns the unicode code of a character.
Assign | Assigns a variable by name with the data.
Binary | Returns the binary representation of an expression.
BinaryLen | Returns the number of bytes in a binary variant.
BinaryMid | Extracts a number of bytes from a binary variant.
BinaryToString | Converts a binary variant into a string.
Chr | Returns a character corresponding to an ASCII code.
ChrW | Returns a character corresponding to a unicode code.
Dec | Returns a numeric representation of a hexadecimal string.
Eval | Return the value of the variable defined by a string.
FuncName | Returns the name of a function stored in a variable.
Hex | Returns a string representation of an integer or of a binary type converted to hexadecimal.
HWnd | Converts an expression into an HWND handle.
Int | Returns the integer (whole number) representation of an expression.
IsAdmin | Checks if the current user has full administrator privileges.
IsArray | Checks if a variable is an array type.
IsBinary | Checks if a variable or expression is a binary type.
IsBool | Checks if a variable's base type is boolean.
IsDeclared | Check if a variable has been declared.
IsDllStruct | Checks if a variable is a DllStruct type.
IsFloat | Checks if the value of a variable or expression has a fractional component.
IsFunc | Checks if a variable or expression is a function type.
IsHWnd | Checks if a variable's base type is a pointer and window handle.
IsInt | Checks if the value of a variable or expression has no fractional component.
IsKeyword | Checks if a variable is a keyword (for example, Default).
IsNumber | Checks if a variable's base type is numeric.
IsObj | Checks if a variable or expression is an object type.
IsPtr | Checks if a variable's base type is a pointer.
IsString | Checks if a variable is a string type.
Number | Returns the numeric representation of an expression.
Ptr | Converts an expression into a pointer variant.
String | Returns the string representation of an expression.
StringToBinary | Converts a string into binary data.
UBound | Returns the size of array dimensions or the number of keys in a map.


Function Asc

Function Reference

Asc

Returns the ASCII code of a character.

Asc ( "char" )

Parameters

char The character to get the code for. If a string is used, the code for the first character is given.

Return Value

Returns the ASCII code of the specified char.

Remarks

See the ASCII Character Code table for a complete list of available values.

Asc("0") == 48, Asc("9") == 57, Asc("A") == 65, Asc("Z") == 90, Asc("a") == 97, Asc("z") == 122, etc.

Related

AscW, Chr, ChrW

Example

#include <MsgBoxConstants.au3>

Local $iCode = Asc("A")
MsgBox($MB_SYSTEMMODAL, "", "ASCII code for A: " & $iCode)


Function AscW

Function Reference

AscW

Returns the unicode code of a character.

AscW ( "char" )

Parameters

char The character to get the code for. If a string is used, the code for the first character is given.

Return Value

Returns the unicode code of the specified char.

Remarks

See the ASCII Character Code table for a complete list of available values.
See "Unicode Support" for a detailed description.

Related

Asc, Chr, ChrW

Example

#include <MsgBoxConstants.au3>

Local $iCode = AscW("ß")
MsgBox($MB_SYSTEMMODAL, "", "Unicode code for ß: U+" & Hex($iCode, 6))


Function Chr

Function Reference

Chr

Returns a character corresponding to an ASCII code.

Chr ( ASCIIcode )

Parameters

ASCIIcode An ASCII code in the range 0-255 (e.g., 65 returns the capital letter A).

Return Value

Success: | a string containing the ASCII representation of the given code.
Failure: | an empty string and sets the @error flag to 1 if the ASCIIcode is greater than 255.

Remarks

See the ASCII Character Code table for a complete list of available values.

Chr(48) == "0", Chr(57) == "9", Chr(65) == "A", Chr(90) == "Z", Chr(97) == "a", Chr(122) == "z", etc.

Related

Asc, AscW, ChrW, String

Example

#include <MsgBoxConstants.au3>

Local $sText = ""
For $i = 65 To 90
    $sText = $sText & Chr($i) ; Or $sText &= Chr($i) can be used as well.
Next
MsgBox($MB_SYSTEMMODAL, "Uppercase alphabet", $sText) ; Display the characters between 65 to 90.


Function ChrW

Function Reference

ChrW

Returns a character corresponding to a unicode code.

ChrW ( UNICODEcode )

Parameters

UNICODEcode A unicode code in the range 0-65535 (e.g., 65 returns the capital letter A).

Return Value

Success: | a string containing the representation of the given code.
Failure: | an empty string and sets the @error flag to non-zero if the UNICODE value is greater than 65535.

Remarks

See the ASCII Character Code table for a complete list of available values.

Related

Asc, AscW, Chr, String

Example

#include <MsgBoxConstants.au3>

Local $sText = ""
For $i = 256 To 512
    $sText = $sText & ChrW($i) ; Or $sText &= ChrW($i) can be used as well.
Next
MsgBox($MB_SYSTEMMODAL, "Unicode chars 256 to 512", $sText) ; Display the unicode characters between 256 to 512.


Function Assign

Function Reference

Assign

Assigns a variable by name with the data.

Assign ( "varname", "data" [, flag = 0] )

Parameters

varname | The name of the variable you wish to assign. Cannot be an array element and must only contain letters, digits and underscore characters (as per normal variable naming conventions).
data | The data you wish to assign to the variable.
flag | [optional] controls the way that variables are assigned (add required options together): $ASSIGN_CREATE (0) = (default) Create variable if required $ASSIGN_FORCELOCAL (1) = Force creation in local scope $ASSIGN_FORCEGLOBAL (2) = Force creation in global scope $ASSIGN_EXISTFAIL (4) = Fail if variable does not already exist Constants are defined in AutoItConstants.au3

Return Value

Success: | 1.
Failure: | 0 if unable to create/assign the variable.

Remarks

If there is a need to use Assign() to create/write to a variable, then in most situations, Eval() should be used to read the variable and IsDeclared() should be used to check that the variable exists.

Related

Eval, Execute, IsDeclared

Example

#include <MsgBoxConstants.au3>

; Assign the variable string sString with data.
Assign("sString", "This is a string which is declared using the function Assign")

; Find the value of the variable string sString and assign to the variable $sEvalString.
Local $sEvalString = Eval("sString")

; Display the value of $sEvalString. This should be the same value as $sString.
MsgBox($MB_SYSTEMMODAL, "", $sEvalString)


Function Binary

Function Reference

Binary

Returns the binary representation of an expression.

Binary ( expression )

Parameters

expression An expression to convert into binary/byte data.

Return Value

Returns a Binary variant.

Remarks

See language datatypes for a detailed description.

Related

BinaryLen, BinaryMid, BinaryToString, Int, IsBinary, Number, StringToBinary

Example

#include <MsgBoxConstants.au3>

Local $dBinary = Binary("0x00204060") ; Convert the string to binary.

MsgBox($MB_SYSTEMMODAL, "", "Returns 1 as the variable is binary: " & IsBinary($dBinary))


Function BinaryLen

Function Reference

BinaryLen

Returns the number of bytes in a binary variant.

BinaryLen ( binary )

Parameters

binary The binary data to evaluate.

Return Value

Returns the length of the binary data in bytes.

Related

Binary, BinaryMid

Example

#include <MsgBoxConstants.au3>

Local $dBinary = Binary("0x10203040") ; Create binary data from a string.
MsgBox($MB_SYSTEMMODAL, "", "The length of the binary is: " & BinaryLen($dBinary))


Function BinaryMid

Function Reference

BinaryMid

Extracts a number of bytes from a binary variant.

BinaryMid ( binary, start [, count] )

Parameters

binary | The binary data to evaluate.
start | The byte position to start. (1 = first byte)
count | [optional] The number of bytes to extract. By default the entire remainder of the binary data.

Return Value

Returns the extracted binary data.

Remarks

If start is out-of-bounds, an empty binary variant is returned. If start is valid but count is out-of-bounds, the entire remainder of the binary data is returned.

Related

Binary, BinaryLen

Example

#include <MsgBoxConstants.au3>

Local $dBinary = Binary("0x10203040") ; Create binary data from a string.
Local $dExtract = BinaryMid($dBinary, 2, 2)
MsgBox($MB_SYSTEMMODAL, "", "The 2nd and 3rd bytes are: " & $dExtract)


Function BinaryToString

Function Reference

BinaryToString

Converts a binary variant into a string.

BinaryToString ( expression [, flag = 1] )

Parameters

expression | An expression to convert into a string.
flag | [optional] Changes how the binary data is converted: $SB_ANSI (1) = binary data is ANSI (default) $SB_UTF16LE (2) = binary data is UTF16 Little Endian $SB_UTF16BE (3) = binary data is UTF16 Big Endian $SB_UTF8 (4) = binary data is UTF8 Constants are defined in StringConstants.au3.

Return Value

Success: | the string representation of the binary data.
Failure: | an empty string and sets the @error flag to non-zero.
@error: | 1 = Input string had zero length. 2 = Input string had an odd number of bytes but was supposed to be UTF16 (must contain an even number of bytes to be valid UTF16).

Remarks

Unlike String() which returns a hexadecimal representation of binary data, this function will assume the binary data is a string value and convert it appropriately.
See "Unicode Support" for a detailed description.

Related

Binary, IsBinary, String, StringToASCIIArray, StringToBinary

Example

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

Example()

Func Example()
    ; Define the string that will be converted later.
    ; NOTE: This string may show up as ?? in the help file and even in some editors.
    ; This example is saved as UTF-8 with BOM.  It should display correctly in editors
    ; which support changing code pages based on BOMs.
    Local Const $sString = "Hello - 你好"

    ; Temporary variables used to store conversion results.  $dBinary will hold
    ; the original string in binary form and $sConverted will hold the result
    ; afte it's been transformed back to the original format.
    Local $dBinary = Binary(""), $sConverted = ""

    ; Convert the original UTF-8 string to an ANSI compatible binary string.
    $dBinary = StringToBinary($sString)

    ; Convert the ANSI compatible binary string back into a string.
    $sConverted = BinaryToString($dBinary)

    ; Display the resulsts.  Note that the last two characters will appear
    ; as ?? since they cannot be represented in ANSI.
    DisplayResults($sString, $dBinary, $sConverted, "ANSI")

    ; Convert the original UTF-8 string to an UTF16-LE binary string.
    $dBinary = StringToBinary($sString, $SB_UTF16LE)

    ; Convert the UTF16-LE binary string back into a string.
    $sConverted = BinaryToString($dBinary, $SB_UTF16LE)

    ; Display the resulsts.
    DisplayResults($sString, $dBinary, $sConverted, "UTF16-LE")

    ; Convert the original UTF-8 string to an UTF16-BE binary string.
    $dBinary = StringToBinary($sString, $SB_UTF16BE)

    ; Convert the UTF16-BE binary string back into a string.
    $sConverted = BinaryToString($dBinary, $SB_UTF16BE)

    ; Display the resulsts.
    DisplayResults($sString, $dBinary, $sConverted, "UTF16-BE")

    ; Convert the original UTF-8 string to an UTF-8 binary string.
    $dBinary = StringToBinary($sString, $SB_UTF8)

    ; Convert the UTF8 binary string back into a string.
    $sConverted = BinaryToString($dBinary, $SB_UTF8)

    ; Display the resulsts.
    DisplayResults($sString, $dBinary, $sConverted, "UTF8")
EndFunc   ;==>Example

; Helper function which formats the message for display.  It takes the following parameters:
; $sOriginal - The original string before conversions.
; $dBinary - The original string after it has been converted to binary.
; $sConverted- The string after it has been converted to binary and then back to a string.
; $sConversionType - A human friendly name for the encoding type used for the conversion.
Func DisplayResults($sOriginal, $dBinary, $sConverted, $sConversionType)
    MsgBox($MB_SYSTEMMODAL, "", "Original:" & @CRLF & $sOriginal & @CRLF & @CRLF & "Binary:" & @CRLF & $dBinary & @CRLF & @CRLF & $sConversionType & ":" & @CRLF & $sConverted)
EndFunc   ;==>DisplayResults


Function Dec

Function Reference

Dec

Returns a numeric representation of a hexadecimal string.

Dec ( "hex" [, flag = 0] )

Parameters

hex | The hexadecimal string to convert.
flag | [optional] Defines behavior. Can be one of the following: Default = string is interpreted as an integer. See remarks. $NUMBER_32BIT (1) = string is interpreted as a 32bit integer $NUMBER_64BIT (2) = string is interpreted as a 64bit integer $NUMBER_DOUBLE (3) = string is interpreted as a double Constants are defined in "AutoItConstants.au3".

Return Value

Success: | the required data.
Failure: | 0 and sets the @error flag to 1 if an invalid hex string was used or if an overflow occurs.

Remarks

Default behavior is that the input string is treated as an integer. In this case, if the result is within range of a 32bit integer then it's returned as a 32bit integer, otherwise it's returned as a 64bit integer - both signed.

Related

Hex

Example

#include <MsgBoxConstants.au3>

Local $iDec = Dec("FFF")
MsgBox($MB_SYSTEMMODAL, "", $iDec) ; Displays the number 4095.


Function Eval

Function Reference

Eval

Return the value of the variable defined by a string.

Eval ( string )

Parameters

string string representing name of the variable.

Return Value

Success: | the value of the variable.
Failure: | "" (empty string) and sets the @error flag to non-zero.

Remarks

If there is a need to use Eval() to read a variable, then in most situations Assign() should be used to create/write to the variable and IsDeclared() should be used to check that the variable exists.

Related

Assign, Execute, IsDeclared

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Assign the variable string sString with data.
    Assign("sString", "This is a string which is declared using the function Assign")

    ; Find the value of the variable string sString and assign to the variable $sEvalString.
    Local $sEvalString = Eval("sString")

    ; Display the value of $sEvalString. This should be the same value as $sString.
    MsgBox($MB_SYSTEMMODAL, "", $sEvalString)
EndFunc   ;==>Example


Function FuncName

Function Reference

FuncName

Returns the name of a function stored in a variable.

FuncName ( $Functionvariable )

Parameters

$Functionvariable A variable containing a Function whose name you want to retrieve.

Return Value

Success: | a string containing the name of the function.
Failure: | "" (empty string) and sets the @error flag to 1.

Related

IsFunc

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a first class object of MsgBox and assign to a Local variable.
    Local $hMsgBox = MsgBox

    ; Display a MsgBox using the previously assigned variable.
    $hMsgBox($MB_SYSTEMMODAL, "", "This is a sentence with whitespace.")

    ; Display a MsgBox that shows the function name $hMsgBox.
    $hMsgBox($MB_SYSTEMMODAL, "", "The function name of $hMsgBox is: " & FuncName($hMsgBox))
EndFunc   ;==>Example


Function Hex

Function Reference

Hex

Returns a string representation of an integer or of a binary type converted to hexadecimal.

Hex ( expression [, length] )

Parameters

expression | The expression to convert.
length | [optional] Number of characters to be returned for integer. Characters are truncated from the left-hand side if length is too small. This parameter is ignored if the data is binary data.

Return Value

Success: | a string of length (never more than 16) characters, zero-padded if necessary for integer. Returns the binary type converted.
Special: | "" (empty string) if length is less than 1.

Remarks

Omitting the second parameter (length) or using the keyword Default results in automatic sizing of the output; 8-characters display for numbers that can fit in that and 16-characters display for others.
A pointer type parameter is displayed in size of pointer by default (8 characters for x86 and 16 characters for x64).
64bit integers have 16 characters displayed by default.
Numbers passed as non-integers (those with decimal separator or exponent) are processed as doubles.

Related

BitAND, BitNOT, BitOR, BitRotate, BitShift, BitXOR, Dec

Example

#include <MsgBoxConstants.au3>

; Assign a Local variable the hex number representation of 1033.
Local $sHex1 = Hex(1033, 4)

; Display the result.
MsgBox($MB_SYSTEMMODAL, "", $sHex1)


Function HWnd

Function Reference

HWnd

Converts an expression into an HWND handle.

HWnd ( expression )

Parameters

expression An expression to convert into an HWND handle.

Return Value

Success: | If the value can be converted to an HWND, the HWND representation will be returned.
Failure: | If the HWND does not denote a valid window, a 0 (NULL) HWND will be returned and sets the @error flag to 1.

Remarks

Double numbers can not be converted to an HWND.
No literal string should be converted to an HWND because there is no guarantee that a given window will have the same HWND ever again. This is not strictly forbidden, but it is a programming mistake and should be avoided.

Related

Int, Number, Ptr, String

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Convert the handle to a string.
    Local $sHWnd = String($hWnd)

    ; Minimize the Notepad window and wait for 2 seconds.
    WinSetState(HWnd($sHWnd), "", @SW_MINIMIZE)
    Sleep(2000)

    ; Restore the Notepad window and wait for 2 seconds.
    WinSetState(HWnd($sHWnd), "", @SW_RESTORE)
    Sleep(2000)

    ; Close the Notepad window.
    WinClose(HWnd($sHWnd))
EndFunc   ;==>Example


Function Int

Function Reference

Int

Returns the integer (whole number) representation of an expression.

Int ( expression [, flag = 0] )

Parameters

expression | An expression to convert into an integer.
flag | [optional] Defines behavior. Can be one of the following: $NUMBER_AUTO (0) = (default) the result is auto-sized integer. See remarks. $NUMBER_32BIT (1) = string is interpreted as a 32bit integer $NUMBER_64BIT (2) = string is interpreted as a 64bit integer Constants are defined in "AutoItConstants.au3".

Return Value

Returns an integer.

Remarks

Default behavior is that if the result is within range of 32bit integer then 32bit integer is returned. If not, 64bit integer is returned. Both are signed.
Fractional portions are truncated, so Int(1.999999) returns 1
Int(0/0) returns -9223372036854775807, if you were wondering.
This function makes minor corrections to floating point numbers to account for the imprecise nature of floating point numbers. For example, the floating point expression 0.7 + 0.2 + 0.1 produces a floating point number that is not quite 1.0. Int() corrects for this anomaly, however, certain extremely rare circumstances may lead to Int() returning an unexpected value (the odds of getting an unexpected value are less than if Int() did not attempt any correction at all).

Related

Binary, Ceiling, Floor, HWnd, Mod, Number, Ptr, Round, String

Example

#include <MsgBoxConstants.au3>

; Assign a Local variable the int representation of 10.793.
Local $iInt = Int(10.793)

; Display the result.
MsgBox($MB_SYSTEMMODAL, "", $iInt)


Function IsAdmin

Function Reference

IsAdmin

Checks if the current user has full administrator privileges.

IsAdmin ( )

Return Value

Success: | 1 if the current user has administrator privileges.
Failure: | 0 if user lacks admin privileges.

Remarks

It returns 1 under Windows Vista only if running with a full administrator token (i.e. #RequireAdmin has been used, or has already been elevated by UAC).

Example

#include <MsgBoxConstants.au3>

If IsAdmin() Then
    MsgBox($MB_SYSTEMMODAL, "", "IsAdmin" & @CRLF & "Admin rights are detected.")
EndIf


Function IsArray

Function Reference

IsArray

Checks if a variable is an array type.

IsArray ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | 1.
Failure: | 0 if parameter is not an array variable.

Remarks

Can be useful to validate array/non-array parameters to user-defined functions.

See language datatypes for a detailed description.

Related

IsBinary, IsBool, IsFloat, IsHWnd, IsInt, IsNumber, IsPtr, IsString, VarGetType

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Retrieve the position and size of the Notepad window by passing the handle to WinGetPos.
    Local $aPos = WinGetPos($hWnd)

    ; Check if the variable is an array.
    If IsArray($aPos) Then
        MsgBox($MB_SYSTEMMODAL, "", "Window height: " & $aPos[3])
    Else
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred.")
    EndIf

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function IsBinary

Function Reference

IsBinary

Checks if a variable or expression is a binary type.

IsBinary ( expression )

Parameters

expression The variable or expression to check.

Return Value

Success: | 1.
Failure: | 0 if expression is not binary type.

Remarks

See language datatypes for a detailed description.

Related

Binary, BinaryToString, IsArray, IsBool, IsFloat, IsHWnd, IsInt, IsNumber, IsString, StringToBinary, VarGetType

Example

#include <MsgBoxConstants.au3>

Local $dBinary = Binary("0x00204060")
Local $sString = "0x00204060"

MsgBox($MB_SYSTEMMODAL, "", "Returns 1 as the variable is binary: " & IsBinary($dBinary))
MsgBox($MB_SYSTEMMODAL, "", "Returns 0 as the variable is a string: " & IsBinary($sString))


Function IsBool

Function Reference

IsBool

Checks if a variable's base type is boolean.

IsBool ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | 1.
Failure: | 0 if expression is not boolean type.

Remarks

See language datatypes for a detailed description.

Related

IsArray, IsBinary, IsFloat, IsHWnd, IsInt, IsNumber, IsPtr, IsString, VarGetType

Example

#include <MsgBoxConstants.au3>

Local $bBoolean = True
If IsBool($bBoolean) Then
    MsgBox($MB_SYSTEMMODAL, "", "The variable is boolean")
Else
    MsgBox($MB_SYSTEMMODAL, "", "The variable is not boolean")
EndIf


Function IsDeclared

Function Reference

IsDeclared

Check if a variable has been declared.

IsDeclared ( expression )

Parameters

expression string representing name of the variable to be checked.

Return Value

Success: | $DECLARED_GLOBAL (1) for Global variable or variable declared outside functions.
Special: | $DECLARED_LOCAL (-1) for Local variable.
Failure: | $DECLARED_UNKNOWN (0) when no variable can be found.

Constants are defined in AutoItConstants.au3

Remarks

If there is a need to use IsDeclared() to check that a variable exists, then in most situations Assign() should be used to create/write to the variable and Eval() should be used to read from the variable.

Related

Assign, Eval

Example

#include <MsgBoxConstants.au3>

; Check if the variable $vVar is declared. As the variable isn't will display the error message.
If Not IsDeclared("vVar") Then
    MsgBox($MB_SYSTEMMODAL, "", "The variable $vVar is not declared.")

    Local $vVar = 0 ; Initialize the variable $vVar with data.
    If IsDeclared("vVar") Then ; Check if the variable $vVar is declared.
        MsgBox($MB_SYSTEMMODAL, "", "The variable $vVar is declared.")
    Else
        MsgBox($MB_SYSTEMMODAL, "", "The variable $vVar is not declared.")
    EndIf
EndIf


Function IsDllStruct

Function Reference

IsDllStruct

Checks if a variable is a DllStruct type.

IsDllStruct ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | 1.
Failure: | 0 if expression is not DllStruct type as return by DllStructCreate.

Remarks

See language datatypes for a detailed description.

Related

DllStructCreate, VarGetType

Example

#include <MsgBoxConstants.au3>

Local $tStruct = DllStructCreate("wchar[256]")
If IsDllStruct($tStruct) Then
    MsgBox($MB_SYSTEMMODAL, "", "The variable is a dll structure")
Else
    MsgBox($MB_SYSTEMMODAL, "", "The variable is not a dll structure")
EndIf


Function IsFunc

Function Reference

IsFunc

Checks if a variable or expression is a function type.

IsFunc ( expression )

Parameters

expression The variable or expression to check.

Return Value

Success: | 1 if the variable is a User-defined function, 2 if the variable is a native function.
Failure: | 0 if expression is not function type.

Remarks

See language datatypes for a detailed description.

Related

Binary, BinaryToString, IsArray, IsBool, IsFloat, IsHWnd, IsInt, IsNumber, IsString, StringToBinary, VarGetType

Example

Example 1

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a first class object of MsgBox and assign to a Local variable.
    Local $hMsgBox = MsgBox

    ; Display a MsgBox using the previously assigned variable.
    $hMsgBox($MB_SYSTEMMODAL, "", "This is a sentence with whitespace.")

    ; Display a MsgBox that shows $hMsgBox is a native function.
    $hMsgBox($MB_SYSTEMMODAL, "", "Check if $hMsgBox is a function or not." & @CRLF & _
            @CRLF & _
            "This will return 2 as the function is native: " & IsFunc($hMsgBox))
EndFunc   ;==>Example

Example 2

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a first class object of MsgBox and assign to a Local variable.
    Local $hMsgBox = MsgBox

    ; Display a MsgBox using the previously assigned variable.
    $hMsgBox($MB_SYSTEMMODAL, "", "This is a sentence with whitespace.")

    ; Re-assign the variable $hMsgBox with our user-defined message box function.
    $hMsgBox = MyMsgBox

    ; Display a MsgBox that shows $hMsgBox is a function.
    $hMsgBox($MB_SYSTEMMODAL, "", "Check if $hMsgBox is a function or not." & @CRLF & _
            @CRLF & _
            "This will return 1 as the function is a user function: " & IsFunc($hMsgBox))
EndFunc   ;==>Example

; User-defined message box function.
Func MyMsgBox($iFlag, $sTitle, $sText = "")
    Return MsgBox($iFlag, $sTitle, $sText)
EndFunc   ;==>MyMsgBox


Function IsFloat

Function Reference

IsFloat

Checks if the value of a variable or expression has a fractional component.

IsFloat ( variable )

Parameters

variable The variable or expression to check.

Return Value

Success: | 1 - Fractional component
Failure: | 0 - No fractional component

Remarks

The function will return 0 if the value is a float with no fractional component (e.g. 1.000).
See language datatypes for a detailed description.

Related

IsArray, IsBinary, IsBool, IsHWnd, IsInt, IsNumber, IsPtr, IsString, StringIsFloat, VarGetType

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $bIsFloat1 = IsFloat(3.14159) ; Returns 1
    Local $bIsFloat2 = IsFloat(3.000) ; Returns 0 as the value is an integer i.e. 3
    Local $bIsFloat3 = IsFloat(1 / 2 - 5) ; Returns 1
    Local $bIsFloat4 = IsFloat(1.5e3) ; Returns 0 as 1.5e3 is equal to 1500.
    Local $bIsFloat5 = IsFloat("12.345") ; Returns 0 as the value is a string.

    MsgBox($MB_SYSTEMMODAL, "", "IsFloat: " & @CRLF & _
            $bIsFloat1 & @CRLF & $bIsFloat2 & @CRLF & $bIsFloat3 & @CRLF & $bIsFloat4 & @CRLF & $bIsFloat5)
EndFunc   ;==>Example


Function IsHWnd

Function Reference

IsHWnd

Checks if a variable's base type is a pointer and window handle.

IsHWnd ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | 1 if the expression is a pointer type AND a valid window handle.
Failure: | 0 if expression is not a pointer OR not a valid window handle.

Remarks

See language datatypes for a detailed description.

Related

GUICtrlGetHandle, IsArray, IsBinary, IsBool, IsFloat, IsInt, IsNumber, IsPtr, IsString, VarGetType

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Test if the window was found and display the results.
    If IsHWnd($hWnd) Then
        MsgBox($MB_SYSTEMMODAL, "", "It's a valid HWND")
    Else
        MsgBox($MB_SYSTEMMODAL, "", "It's not a valid HWND")
    EndIf
EndFunc   ;==>Example


Function IsInt

Function Reference

IsInt

Checks if the value of a variable or expression has no fractional component.

IsInt ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | 1 - No fractional component
Failure: | 0 - Fractional component

Remarks

The function will return 1 if the value is a float with no fractional component (e.g. 1.000).
See language datatypes for a detailed description.

Related

IsArray, IsBinary, IsBool, IsFloat, IsHWnd, IsNumber, IsPtr, IsString, StringIsInt, VarGetType

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $bIsInt1 = IsInt(-12345) ; Returns 1
    Local $bIsInt2 = IsInt(3.0000) ; Returns 1
    Local $bIsInt3 = IsInt("5432") ; Returns 0 as the value is a string.
    Local $bIsInt4 = IsInt(7.5 - 4.5) ; Returns 1 since it evaluates to integer 3

    MsgBox($MB_SYSTEMMODAL, "", "IsInt: " & @CRLF & _
            $bIsInt1 & @CRLF & $bIsInt2 & @CRLF & $bIsInt3 & @CRLF & $bIsInt4)
EndFunc   ;==>Example


Function IsKeyword

Function Reference

IsKeyword

Checks if a variable is a keyword (for example, Default).

IsKeyword ( variable )

Parameters

variable The variable to check.

Return Value

Success: | $KEYWORD_DEFAULT (1) the Default keyword. $KEYWORD_NULL (2) the Null keyword.
Failure: | 0 if not a keyword.

Constants are defined in AutoItConstants.au3

Remarks

See language datatypes for a detailed description.

Related

Default, Null, VarGetType

Example

#include <Constants.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Check if a variable is the Default keyword.
    Local $vDefault = Default
    If IsDefault($vDefault) Then
        MsgBox($MB_SYSTEMMODAL, "", "The variable is the Default keyword")
    Else
        MsgBox($MB_SYSTEMMODAL, "", "The variable is not the Default keyword")
    EndIf

    ; Check if a variable is the Null keyword.
    Local $vNull = Null
    If IsNull($vNull) Then
        MsgBox($MB_SYSTEMMODAL, "", "The variable is the Null keyword")
    Else
        MsgBox($MB_SYSTEMMODAL, "", "The variable is not the Null keyword")
    EndIf

    ; Check if a variable is the Null keyword. This will be false as $sString is a string datatype.
    Local $sString = 'Default'
    If IsDefault($sString) Then
        MsgBox($MB_SYSTEMMODAL, "", "The variable is the Default keyword")
    Else
        MsgBox($MB_SYSTEMMODAL, "", "The variable is not the Default keyword")
    EndIf
EndFunc   ;==>Example

Func IsDefault($vKeyword)
    Return IsKeyword($vKeyword) = $KEYWORD_DEFAULT
EndFunc   ;==>IsDefault

Func IsNull($vKeyword)
    Return IsKeyword($vKeyword) = $KEYWORD_NULL
EndFunc   ;==>IsNull


Function IsNumber

Function Reference

IsNumber

Checks if a variable's base type is numeric.

IsNumber ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | 1.
Failure: | 0 if expression is not numeric type.

Remarks

A number can be an integer/whole number or a fractional/floating-point.

If the variable is a numeric value represented as a string, then IsNumber() will return 0.

See language datatypes for a detailed description.

Related

IsArray, IsBinary, IsBool, IsFloat, IsHWnd, IsInt, IsPtr, IsString

Example

#include <MsgBoxConstants.au3>

Local $iLife = 42
If IsNumber($iLife) Then
    MsgBox($MB_SYSTEMMODAL, "", "The variable is a number")
Else
    MsgBox($MB_SYSTEMMODAL, "", "The variable is not a number")
EndIf


Function IsObj

Function Reference

IsObj

Checks if a variable or expression is an object type.

IsObj ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | 1 if expression is an object variable.
Failure: | 0 if expression is not an object variable.

Remarks

See language datatypes for a detailed description.

Related

GUICtrlCreateObj, ObjCreate, ObjEvent, ObjGet, ObjName, VarGetType

Example

#include <MsgBoxConstants.au3>

Local $oShell = ObjCreate("shell.application")
If IsObj($oShell) Then
    MsgBox($MB_SYSTEMMODAL, "", "The variable is an object")
Else
    MsgBox($MB_SYSTEMMODAL, "", "The variable is not an object")
EndIf


Function IsPtr

Function Reference

IsPtr

Checks if a variable's base type is a pointer.

IsPtr ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | 1 if the expression is a pointer type.
Failure: | 0 if expression is not pointer type.

Remarks

See language datatypes for a detailed description.

Related

IsArray, IsBool, IsFloat, IsHWnd, IsInt, IsNumber, IsString, Ptr

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Test if $hWnd is a valid pointer and display the results.
    If IsPtr($hWnd) Then
        MsgBox($MB_SYSTEMMODAL, "", "It's a valid Ptr")
    Else
        MsgBox($MB_SYSTEMMODAL, "", "It's not a valid Ptr")
    EndIf

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function IsString

Function Reference

IsString

Checks if a variable is a string type.

IsString ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | 1.
Failure: | 0 if expression is not string type.

Remarks

See language datatypes for a detailed description.

Related

IsArray, IsBinary, IsBool, IsFloat, IsHWnd, IsInt, IsNumber, IsPtr, String, VarGetType

Example

#include <MsgBoxConstants.au3>

Local $sString = "This is a string"
If IsString($sString) Then
    MsgBox($MB_SYSTEMMODAL, "", "The variable is a string")
Else
    MsgBox($MB_SYSTEMMODAL, "", "The variable is not a string")
EndIf


Function Number

Function Reference

Number

Returns the numeric representation of an expression.

Number ( expression [, flag = 0] )

Parameters

expression | An expression to convert into a number.
flag | [optional] Defines behavior. Can be one of the following: $NUMBER_AUTO (0) = (default) the result is auto-sized integer. See remarks. $NUMBER_32BIT (1) = the result is 32bit integer. $NUMBER_64BIT (2) = the result is 64bit integer. $NUMBER_DOUBLE (3) = the result is double. Constants are defined in "AutoItConstants.au3".

Return Value

Returns a number.

Remarks

If you pass number, function outputs the input.
A string beginning with letters has a numeric value of zero. A string beginning with digits has non-numeric characters stripped at the from the first one. Valid characters for Double numbers does not start the stripping.
Default behavior results in auto-sized integer. If input value after conversion is within the range of 32bit integer the result is 32bit integer. If not the result is 64bit integer. Both are signed.

Related

Binary, Ceiling, Floor, HWnd, Int, Ptr, Round, String

Example

#include <MsgBoxConstants.au3>

Local $bNumber1 = Number(1 + 2 + 10) ; Returns 13.
Local $bNumber2 = Number("3.14") ; Returns 3.14.
Local $bNumber3 = Number("24/7") ; Returns 24.
Local $bNumber4 = Number("tmp3") ; Returns 0 as this is a string.
Local $bNumber5 = Number("1,000,000") ; Returns 1 as it strips everything after and including the first comma.

MsgBox($MB_SYSTEMMODAL, "", "The following values were converted to a numeric value:" & @CRLF & _
        $bNumber1 & @CRLF & $bNumber2 & @CRLF & $bNumber3 & @CRLF & $bNumber4 & @CRLF & $bNumber5)


Function Ptr

Function Reference

Ptr

Converts an expression into a pointer variant.

Ptr ( expression )

Parameters

expression An expression to convert into a pointer variant.

Return Value

Returns the pointer representation of the expression.

Related

HWnd, Int, IsPtr, Number, String

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Convert -1 to a pointer expression.
    Local $pPtr = Ptr(-1)

    ; Test if $hPtr is a valid pointer and display the results.
    If IsPtr($pPtr) Then
        MsgBox($MB_SYSTEMMODAL, "", "It's a valid Ptr")
    Else
        MsgBox($MB_SYSTEMMODAL, "", "It's not a valid Ptr")
    EndIf
EndFunc   ;==>Example


Function String

Function Reference

String

Returns the string representation of an expression.

String ( expression )

Parameters

expression An expression to convert into a string.

Return Value

Returns a string.

Remarks

Maximum string length is 2147483647 characters (but keep in mind that no line in an AutoIt script can exceed 4095 characters.)

Related

BinaryToString, Chr, ChrW, HWnd, Int, IsString, Number, Ptr, StringToBinary

Example

#include <MsgBoxConstants.au3>

Local $sString = String(10) ; The expression passed to String will return a string representation, currently 10 is a number.
MsgBox($MB_SYSTEMMODAL, "", "$sString contains the value: " & $sString & " and IsString returns: " & IsString($sString))


Function StringToBinary

Function Reference

StringToBinary

Converts a string into binary data.

StringToBinary ( expression [, flag = 1] )

Parameters

expression | An expression to convert into binary data.
flag | [optional] Changes how the string is stored as binary: $SB_ANSI (1) = string data is ANSI (default) $SB_UTF16LE (2) = string data is UTF16 Little Endian $SB_UTF16BE (3) = string data is UTF16 Big Endian $SB_UTF8 (4) = string data is UTF8 Constants are defined in StringConstants.au3.

Return Value

Returns a binary variant.

Remarks

See "Unicode Support" for a detailed description.

Related

Binary, BinaryToString, IsBinary, String

Example

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

Example()

Func Example()
    ; Define the string that will be converted later.
    ; NOTE: This string may show up as ?? in the help file and even in some editors.
    ; This example is saved as UTF-8 with BOM.  It should display correctly in editors
    ; which support changing code pages based on BOMs.
    Local Const $sString = "Hello - 你好"

    ; Temporary variables used to store conversion results.  $dBinary will hold
    ; the original string in binary form and $sConverted will hold the result
    ; afte it's been transformed back to the original format.
    Local $dBinary = Binary(""), $sConverted = ""

    ; Convert the original UTF-8 string to an ANSI compatible binary string.
    $dBinary = StringToBinary($sString)

    ; Convert the ANSI compatible binary string back into a string.
    $sConverted = BinaryToString($dBinary)

    ; Display the resulsts.  Note that the last two characters will appear
    ; as ?? since they cannot be represented in ANSI.
    DisplayResults($sString, $dBinary, $sConverted, "ANSI")

    ; Convert the original UTF-8 string to an UTF16-LE binary string.
    $dBinary = StringToBinary($sString, $SB_UTF16LE)

    ; Convert the UTF16-LE binary string back into a string.
    $sConverted = BinaryToString($dBinary, $SB_UTF16LE)

    ; Display the resulsts.
    DisplayResults($sString, $dBinary, $sConverted, "UTF16-LE")

    ; Convert the original UTF-8 string to an UTF16-BE binary string.
    $dBinary = StringToBinary($sString, $SB_UTF16BE)

    ; Convert the UTF16-BE binary string back into a string.
    $sConverted = BinaryToString($dBinary, $SB_UTF16BE)

    ; Display the resulsts.
    DisplayResults($sString, $dBinary, $sConverted, "UTF16-BE")

    ; Convert the original UTF-8 string to an UTF-8 binary string.
    $dBinary = StringToBinary($sString, $SB_UTF8)

    ; Convert the UTF8 binary string back into a string.
    $sConverted = BinaryToString($dBinary, $SB_UTF8)

    ; Display the resulsts.
    DisplayResults($sString, $dBinary, $sConverted, "UTF8")
EndFunc   ;==>Example

; Helper function which formats the message for display.  It takes the following parameters:
; $sOriginal - The original string before conversions.
; $dBinary - The original string after it has been converted to binary.
; $sConverted- The string after it has been converted to binary and then back to a string.
; $sConversionType - A human friendly name for the encoding type used for the conversion.
Func DisplayResults($sOriginal, $dBinary, $sConverted, $sConversionType)
    MsgBox($MB_SYSTEMMODAL, "", "Original:" & @CRLF & $sOriginal & @CRLF & @CRLF & "Binary:" & @CRLF & $dBinary & @CRLF & @CRLF & $sConversionType & ":" & @CRLF & $sConverted)
EndFunc   ;==>DisplayResults


Function UBound

Function Reference

UBound

Returns the size of array dimensions or the number of keys in a map.

UBound ( Variable [, Dimension = 1] )

Parameters

Variable | An array or map variable
Dimension | [optional] For an array - Which dimension size to return: $UBOUND_DIMENSIONS (0) = Number of subscripts in the array $UBOUND_ROWS (1) = Number of rows in the array (default) $UBOUND_COLUMNS (2) = Number of columns in the array For arrays with more than 2 dimensions, just use the corresponding integer For a map - this parameter is ignored and the number of keys is returned Constants are defined in AutoItConstants.au3.

Return Value

Success: | the size of the array dimension or the number of keys within a map.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 = Array: Variable is not an array or map 2 = Dimension is invalid

Remarks

Remember that for arrays the value returned is one greater than the index of the last element in the dimension as the count starts at [0].

Related

Global/Local, ReDim, IsArray

Example

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3> ; Required for _ArrayDisplay.

Example()

Func Example()
    Local $aArray[10][20]
    Local $iRows = UBound($aArray, $UBOUND_ROWS) ; Total number of rows. In this example it will be 10.
    Local $iCols = UBound($aArray, $UBOUND_COLUMNS) ; Total number of columns. In this example it will be 20.
    Local $iDimension = UBound($aArray, $UBOUND_DIMENSIONS) ; The dimension of the array e.g. 1/2/3 dimensional.

    MsgBox($MB_SYSTEMMODAL, "", "The array is a " & $iDimension & " dimensional array with " & _
            $iRows & " row(s) & " & $iCols & " column(s).")

    ; Fill the array with data.
    For $i = 0 To $iRows - 1
        For $j = 0 To $iCols - 1
            $aArray[$i][$j] = "Row: " & $i & " - Col: " & $j
        Next
    Next
    _ArrayDisplay($aArray)
EndFunc   ;==>Example


Functions

Window functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
WinActivate | Activates (gives focus to) a window.
WinActive | Checks to see if a specified window exists and is currently active.
WinClose | Closes a window.
WinExists | Checks to see if a specified window exists.
WinFlash | Flashes a window in the taskbar.
WinGetCaretPos | Returns the coordinates of the caret in the foreground window.
WinGetClassList | Retrieves the classes from a window.
WinGetClientSize | Retrieves the size of a given window's client area.
WinGetHandle | Retrieves the internal handle of a window.
WinGetPos | Retrieves the position and size of a given window.
WinGetProcess | Retrieves the Process ID (PID) associated with a window.
WinGetState | Retrieves the state of a given window.
WinGetText | Retrieves the text from a window.
WinGetTitle | Retrieves the full title from a window.
WinKill | Forces a window to close.
WinList | Retrieves a list of windows.
WinMenuSelectItem | Invokes a menu item of a window.
WinMinimizeAll | Minimizes all windows.
WinMinimizeAllUndo | Undoes a previous WinMinimizeAll function.
WinMove | Moves and/or resizes a window.
WinSetOnTop | Change a window's "Always On Top" attribute.
WinSetState | Shows, hides, minimizes, maximizes, or restores a window.
WinSetTitle | Changes the title of a window.
WinSetTrans | Sets the transparency of a window.
WinWait | Pauses execution of the script until the requested window exists.
WinWaitActive | Pauses execution of the script until the requested window is active.
WinWaitClose | Pauses execution of the script until the requested window does not exist.
WinWaitNotActive | Pauses execution of the script until the requested window is not active.


Functions

Controls functions Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
ControlClick | Sends a mouse click command to a given control.
ControlCommand | Sends a command to a control.
ControlDisable | Disables or "grays-out" a control.
ControlEnable | Enables a "grayed-out" control.
ControlFocus | Sets input focus to a given control on a window.
ControlGetFocus | Returns the ControlRef# of the control that has keyboard focus within a specified window.
ControlGetHandle | Retrieves the internal handle of a control.
ControlGetPos | Retrieves the position and size of a control relative to its window.
ControlGetText | Retrieves text from a control.
ControlHide | Hides a control.
ControlListView | Sends a command to a ListView32 control.
ControlMove | Moves a control within a window.
ControlSend | Sends a string of characters to a control.
ControlSetText | Sets text of a control.
ControlShow | Shows a control that was hidden.
ControlTreeView | Sends a command to a TreeView32 control.
StatusbarGetText | Retrieves the text from a standard status bar control.


Function ControlClick

Function Reference

ControlClick

Sends a mouse click command to a given control.

ControlClick ( "title", "text", controlID [, button = "left" [, clicks = 1 [, x [, y]]]] )

Parameters

title | The title/hWnd/class of the window to access. See Title special definition.
text | The text of the window to access. See Text special definition.
controlID | The control to interact with. See Controls.
button | [optional] The button to click, "left", "right", "middle", "main", "menu", "primary", "secondary". Default is the left button.
clicks | [optional] The number of times to click the mouse. Default is 1.
x | [optional] The x position to click within the control. Default is center.
y | [optional] The y position to click within the control. Default is center.

Return Value

Success: | 1.
Failure: | 0.

Remarks

Some controls will resist clicking unless they are the active window. Use the WinActivate() function to force the control's window to the top before using ControlClick().
Using 2 for the number of clicks will send a double-click message to the control - this can even be used to launch programs from an explorer control!

If the user has swapped the left and right mouse buttons in the control panel, then the behaviour of the buttons is different. "Left" and "right" always click those buttons, whether the buttons are swapped or not. The "primary" or "main" button will be the main click, whether or not the buttons are swapped. The "secondary" or "menu" buttons will usually bring up the context menu, whether the buttons are swapped or not.

Button | Normal | Swapped
"" | Left | Left
"left" | Left | Left
"middle" | Middle | Middle
"right" | Right | Right
"primary" | Left | Right
"main" | Left | Right
"secondary" | Right | Left
"menu" | Right | Left

Related

ControlCommand, MouseClick, WinActivate

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Send a mouse click to the edit control of Notepad using the handle returned by WinWait.
    ControlClick($hWnd, "", "Edit1")

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function ControlCommand

Function Reference

ControlCommand

Sends a command to a control.

ControlCommand ( "title", "text", controlID, "command" [, "option"] )

Parameters

title | The title/hWnd/class of the window to access. See Title special definition.
text | The text of the window to access. See Text special definition.
controlID | The control to interact with. See Controls.
command | The command to send to the control.
option | [optional] Additional parameter required by some commands.

Return Value

Return depends on command as table below shows. In case of an error (such as an invalid command or window/control), @error=1.

Command, Option | Return Value
"IsVisible", "" | Returns 1 if Control is visible, 0 otherwise
"IsEnabled", "" | Returns 1 if Control is enabled, 0 otherwise
"ShowDropDown", "" | Displays the ComboBox dropdown
"HideDropDown", "" | Hides the ComboBox dropdown
"AddString", 'string' | Adds a string to the end in a ListBox or ComboBox
"DelString", occurrence | Deletes a string according to occurrence in a ListBox or ComboBox
"FindString", 'string' | Returns occurrence ref of the exact string in a ListBox or ComboBox
"SetCurrentSelection", occurrence | Sets selection to occurrence ref in a ListBox or ComboBox
"SelectString", 'string' | Sets selection according to string in a ListBox or ComboBox
"IsChecked", "" | Returns 1 if Button is checked, 0 otherwise
"Check", "" | Checks radio or check Button
"UnCheck", "" | Unchecks radio or check Button
"GetCurrentLine", "" | Returns the line # where the caret is in an Edit
"GetCurrentCol", "" | Returns the column # where the caret is in an Edit
"GetCurrentSelection", "" | Returns name of the currently selected item in a ListBox or ComboBox
"GetLineCount", "" | Returns # of lines in an Edit
"GetLine", line# | Returns text at line # passed of an Edit
"GetSelected", "" | Returns selected text of an Edit
"EditPaste", 'string' | Pastes the 'string' at the Edit's caret position
"CurrentTab", "" | Returns the current Tab shown of a SysTabControl32
"TabRight", "" | Moves to the next tab to the right of a SysTabControl32
"TabLeft", "" | Moves to the next tab to the left of a SysTabControl32
"SendCommandID", Command ID | Simulates the WM_COMMAND message. Usually used for ToolbarWindow32 controls - use the ToolBar tab of Au3Info to get the Command ID.

Remarks

Some controls will resist automation unless they are the active window. Use the WinActivate() function to force the control's window to the top before using ControlCommand() on these controls.

Certain commands that work on normal Combo and ListBoxes do not work on "ComboLBox" controls.

Related

ControlClick, ControlDisable, ControlEnable, ControlFocus, ControlGetFocus, ControlGetPos, ControlGetText, ControlHide, ControlListView, ControlMove, ControlSend, ControlSetText, ControlShow, ControlTreeView, StatusbarGetText, WinActivate, WinGetClassList, WinMenuSelectItem

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Send a command to the edit control of Notepad to find the number of lines. The handle returned by WinWait is used for the "title" parameter of ControlCommand.
    Local $iCount = ControlCommand($hWnd, "", "Edit1", "GetLineCount", "")

    ; Display the number of lines.
    MsgBox($MB_SYSTEMMODAL, "", "The number of lines in Notepad are: " & $iCount)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function ControlDisable

Function Reference

ControlDisable

Disables or "grays-out" a control.

ControlDisable ( "title", "text", controlID )

Parameters

title | The title/hWnd/class of the window to access. See Title special definition.
text | The text of the window to access. See Text special definition.
controlID | The control to interact with. See Controls.

Return Value

Success: | 1.
Failure: | 0.

Related

ControlCommand, ControlEnable, ControlHide

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Disable the edit control of Notepad using the handle returned by WinWait.
    ControlDisable($hWnd, "", "Edit1")

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Enable the edit control of Notepad using the handle returned by WinWait.
    ControlEnable($hWnd, "", "Edit1")

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function ControlEnable

Function Reference

ControlEnable

Enables a "grayed-out" control.

ControlEnable ( "title", "text", controlID )

Parameters

title | The title/hWnd/class of the window to access. See Title special definition.
text | The text of the window to access. See Text special definition.
controlID | The control to interact with. See Controls.

Return Value

Success: | 1.
Failure: | 0.

Related

ControlCommand, ControlDisable, ControlShow

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Disable the edit control of Notepad using the handle returned by WinWait.
    ControlDisable($hWnd, "", "Edit1")

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Enable the edit control of Notepad using the handle returned by WinWait.
    ControlEnable($hWnd, "", "Edit1")

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function ControlFocus

Function Reference

ControlFocus

Sets input focus to a given control on a window.

ControlFocus ( "title", "text", controlID )

Parameters

title | The title/hWnd/class of the window to access. See Title special definition.
text | The text of the window to access. See Text special definition.
controlID | The control to interact with. See Controls.

Return Value

Success: | 1.
Failure: | 0.

Related

ControlCommand, ControlGetFocus, ControlSend

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Set input focus to the edit control of Notepad using the handle returned by WinWait.
    ControlFocus($hWnd, "", "Edit1")

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function ControlGetFocus

Function Reference

ControlGetFocus

Returns the ControlRef# of the control that has keyboard focus within a specified window.

ControlGetFocus ( "title" [, "text"] )

Parameters

title | The title/hWnd/class of the window to access. See Title special definition.
text | [optional] The text of the window to access. See Text special definition.

Return Value

Success: | the ClassNameNN of the control that has keyboard focus within a specified window.
Failure: | "" (empty string) and sets the @error flag to 1 if window is not found.

Related

ControlCommand, ControlFocus

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Retrieve the control that has keyboard focus in Notepad. The handle returned by WinWait is used for the "title" parameter of ControlGetFocus.
    Local $sControl = ControlGetFocus($hWnd)

    ; Display the control that has keyboard focus.
    MsgBox($MB_SYSTEMMODAL, "", "The control that has keyboard focus in Notepad is: " & $sControl)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function ControlGetHandle

Function Reference

ControlGetHandle

Retrieves the internal handle of a control.

ControlGetHandle ( "title", "text", controlID )

Parameters

title | The title/hWnd/class of the window to access. See Title special definition.
text | The text of the window to access. See Text special definition.
controlID | The control to interact with. See Controls.

Return Value

Success: | the handle (HWND) value.
Failure: | 0 and sets the @error flag to non-zero if no window matches the criteria.

Remarks

This function returns a HWND/Handle value.

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Retrieve the handle of the edit control in Notepad. The handle returned by WinWait is used for the "title" parameter of ControlGetHandle.
    Local $hControl = ControlGetHandle($hWnd, "", "Edit1")

    ; Display the handle of the edit control.
    MsgBox($MB_SYSTEMMODAL, "", "The handle of Edit1 is: " & $hControl)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function ControlGetPos

Function Reference

ControlGetPos

Retrieves the position and size of a control relative to its window.

ControlGetPos ( "title", "text", controlID )

Parameters

title | The title/hWnd/class of the window to access. See Title special definition.
text | The text of the window to access. See Text special definition.
controlID | The control to interact with. See Controls.

Return Value

Success: | an array containing the size and the control's position relative to its client window: $aArray[0] = X position $aArray[1] = Y position $aArray[2] = Width $aArray[3] = Height
Failure: | sets the @error flag to 1.

Remarks

The title/text is referencing the parent window, so be careful with "", which references the active window which may not be the one containing the controlID control.

Related

ControlCommand, ControlMove

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Retrieve the position x, y and size (width and height) of the edit control in Notepad. The handle returned by WinWait is used for the "title" parameter of ControlGetPos.
    Local $aPos = ControlGetPos($hWnd, "", "Edit1")

    ; Display the position and size of the edit control.
    MsgBox($MB_SYSTEMMODAL, "", "Position: " & $aPos[0] & ", " & $aPos[1] & @CRLF & "Size: " & $aPos[2] & ", " & $aPos[3])

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function ControlGetText

Function Reference

ControlGetText

Retrieves text from a control.

ControlGetText ( "title", "text", controlID )

Parameters

title | The title/hWnd/class of the window to access. See Title special definition.
text | The text of the window to access. See Text special definition.
controlID | The control to interact with. See Controls.

Return Value

Success: | the text from a control.
Failure: | "" (empty string) and sets the @error flag to 1.

Related

ControlCommand, ControlSetText, StatusbarGetText, WinGetText

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Set the edit control in Notepad with some text. The handle returned by WinWait is used for the "title" parameter of ControlSetText.
    ControlSetText($hWnd, "", "Edit1", "This is some text")

    ; Retrieve the text of the edit control in Notepad. The handle returned by WinWait is used for the "title" parameter of ControlGetText.
    Local $sText = ControlGetText($hWnd, "", "Edit1")

    ; Display the text of the edit control.
    MsgBox($MB_SYSTEMMODAL, "", "The text in Edit1 is: " & $sText)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function ControlHide

Function Reference

ControlHide

Hides a control.

ControlHide ( "title", "text", controlID )

Parameters

title | The title/hWnd/class of the window to access. See Title special definition.
text | The text of the window to access. See Text special definition.
controlID | The control to interact with. See Controls.

Return Value

Success: | 1.
Failure: | 0 if window/control is not found.

Related

ControlCommand, ControlDisable, ControlShow, WinSetState

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Hide the edit control of Notepad using the handle returned by WinWait.
    ControlHide($hWnd, "", "Edit1")

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Show the edit control of Notepad using the handle returned by WinWait.
    ControlShow($hWnd, "", "Edit1")

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function ControlListView

Function Reference

ControlListView

Sends a command to a ListView32 control.

ControlListView ( "title", "text", controlID, "command" [, option1 [, option2]] )

Parameters

title | The title/hWnd/class of the window to access. See Title special definition.
text | The text of the window to access. See Text special definition.
controlID | The control to interact with. See Controls.
command | The command to send to the control (see below).
option1 | [optional] Additional parameter required by some commands.
option2 | [optional] Additional parameter required by some commands.

Return Value

Return depends on command as table below shows. In case of an error (such as an invalid command or window/control could not be found) then @error is set to 1.

Command, Option1, Option2 | Operation
"DeSelect", From [, To] | Deselects one or more items.
"FindItem", "string to find" [, SubItem] | Returns the item index of the string. Returns -1 if the string is not found.
"GetItemCount" | Returns the number of list items.
"GetSelected" [, option] | Returns a string containing the item index of selected items. If option=0 (default) only the first selected item is returned. If option=1 then all the selected items are returned delimited by |, e.g: "0|3|4|10". If no items are selected a blank "" string is returned.
"GetSelectedCount" | Returns the number of items that are selected.
"GetSubItemCount" | Returns the number of subitems.
"GetText", Item, SubItem | Returns the text of a given item/subitem.
"IsSelected", Item | Returns 1 if the item is selected, otherwise returns 0.
"Select", From [, To] | Selects one or more items.
"SelectAll" | Selects all items.
"SelectClear" | Clears the selection of all items.
"SelectInvert" | Inverts the current selection.
"ViewChange", "view" | Changes the current view. Valid views are "list", "details", "smallicons", "largeicons".

In a "Details" view of a ListView32 control, the "item" can be thought of as the "row" and the "subitem" as the "column".

Remarks

Some commands may fail when using a 32-bit AutoIt process to read from a 64-bit process. Likewise commands may fail when using a 64-bit AutoIt process to read from a 32-bit process.

Related

ControlCommand

Example

#include <MsgBoxConstants.au3>

ControlListView(@ProgramFilesDir & "\AutoIt3", "", "SysListView321", "SelectAll")
ControlListView(@ProgramFilesDir & "\AutoIt3", "", "SysListView321", "Deselect", 2, 5)
MsgBox($MB_SYSTEMMODAL, "", ControlListView(@ProgramFilesDir & "\AutoIt3", "", "SysListView321", "GetText", 9, 0))
MsgBox($MB_SYSTEMMODAL, "", ControlListView(@ProgramFilesDir & "\AutoIt3", "", "SysListView321", "FindItem", "14 KB", 1))
MsgBox($MB_SYSTEMMODAL, "", ControlListView(@ProgramFilesDir & "\AutoIt3", "", "SysListView321", "GetSelected", 1))


Function ControlMove

Function Reference

ControlMove

Moves a control within a window.

ControlMove ( "title", "text", controlID, x, y [, width [, height]] )

Parameters

title | The title/hWnd/class of the window to access. See Title special definition.
text | The text of the window to access. See Text special definition.
controlID | The control to interact with. See Controls.
x | X coordinate to move to relative to the window client area.
y | Y coordinate to move to relative to the window client area.
width | [optional] New width of the window.
height | [optional] New height of the window.

Return Value

Success: | 1.
Failure: | 0 if window/control is not found.

Remarks

If x and y equal to the Default keyword no move occurs, just resizing.

Related

ControlCommand, ControlGetPos

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Move the edit control of Notepad using the handle returned by WinWait.
    ControlMove($hWnd, "", "Edit1", 0, 0, 150, 150)

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function ControlSend

Function Reference

ControlSend

Sends a string of characters to a control.

ControlSend ( "title", "text", controlID, "string" [, flag = 0] )

Parameters

title | The title/hWnd/class of the window to access. See Title special definition.
text | The text of the window to access. See Text special definition.
controlID | The control to interact with. See Controls.
string | String of characters to send to the control.
flag | [optional] Changes how "keys" is processed: $SEND_DEFAULT (0) = Text contains special characters like + and ! to indicate SHIFT and ALT key-presses (default). $SEND_RAW (1) = keys are sent raw. Constants are defined in "AutoItConstants.au3".

Return Value

Success: | 1.
Failure: | 0 if window/control is not found.

Remarks

ControlSend() works in a similar way to Send() but it can send key strokes directly to a window/control, rather than just to the active window.

ControlSend() is only unreliable for command prompts as that works differently to normal windows (seems to check physical states rather than accepting the keystroke messages). For normal windows ControlSend() should be way more reliable than a normal Send() - and yes it does send shift, ctrl, alt etc.

As mention in the Send() help the keyboard that send different chars when in CAPS LOCK and using the Shift Key cannot be simulated. An example is the Czech Keyboard. A good workaround is to use the ControlSetText().

The control might first need to be given focus with the ControlFocus() command, specially when referencing an controlID created by the script itself.

Opt("SendKeyDelay",...) alters the length of the brief pause in between sent keystrokes.
Opt("SendKeyDownDelay",...) alters the length of time a key is held down before being released during a keystroke.

Related

ControlCommand, ControlFocus, ControlSetText, Send, SendKeyDelay (Option), SendKeyDownDelay (Option)

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Send a string of text to the edit control of Notepad. The handle returned by WinWait is used for the "title" parameter of ControlSend.
    ControlSend($hWnd, "", "Edit1", "This is some text")

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)

    ; Now a screen will pop up and ask to save the changes, the classname of the window is called
    ; "#32770" and simulating the "TAB" key to move to the second button in which the "ENTER" is simulated to not "save the file"
    WinWaitActive("[CLASS:#32770]")
    Sleep(500)
    Send("{TAB}{ENTER}")
EndFunc   ;==>Example


Function ControlSetText

Function Reference

ControlSetText

Sets text of a control.

ControlSetText ( "title", "text", controlID, "new text" [, flag = 0] )

Parameters

title | The title/hWnd/class of the window to access. See Title special definition.
text | The text of the window to access. See Text special definition.
controlID | The control to interact with. See Controls.
new text | The new text to be set into the control.
flag | [optional] when different from 0 (default) will force the target window to be redrawn.

Return Value

Success: | 1.
Failure: | 0 if window/control is not found.

Related

ControlCommand, ControlGetText, ControlSend, SplashTextOn

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Set the edit control in Notepad with some text. The handle returned by WinWait is used for the "title" parameter of ControlSetText.
    ControlSetText($hWnd, "", "Edit1", "This is some text")

    ; Retrieve the text of the edit control in Notepad. The handle returned by WinWait is used for the "title" parameter of ControlGetText.
    Local $sText = ControlGetText($hWnd, "", "Edit1")

    ; Display the text of the edit control.
    MsgBox($MB_SYSTEMMODAL, "", "The text in Edit1 is: " & $sText)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function ControlShow

Function Reference

ControlShow

Shows a control that was hidden.

ControlShow ( "title", "text", controlID )

Parameters

title | The title/hWnd/class of the window to access. See Title special definition.
text | The text of the window to access. See Text special definition.
controlID | The control to interact with. See Controls.

Return Value

Success: | 1.
Failure: | 0 if window/control is not found.

Related

ControlCommand, ControlEnable, ControlHide

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Hide the edit control of Notepad using the handle returned by WinWait.
    ControlHide($hWnd, "", "Edit1")

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Show the edit control of Notepad using the handle returned by WinWait.
    ControlShow($hWnd, "", "Edit1")

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function ControlTreeView

Function Reference

ControlTreeView

Sends a command to a TreeView32 control.

ControlTreeView ( "title", "text", controlID, "command" [, option1] )

Parameters

title | The title/hWnd/class of the window to access. See Title special definition.
text | The text of the window to access. See Text special definition.
controlID | The control to interact with. See Controls.
command | The command to send to the control (see below).
option1 | [optional] Additional parameter required by some commands.

Return Value

Return depends on the command as table below shows. In case of an error (such as an invalid command or window/control could not be found) then @error is set to 1.

Command, Option1 | Operation
"Check", "item" | Checks an item (if the item supports it).
"Collapse", "item" | Collapses an item to hide its children.
"Exists", "item" | Returns 1 if an item exists, otherwise 0.
"Expand", "item" | Expands an item to show its children.
"GetItemCount", "item" | Returns the number of children for a selected item.
"GetSelected" [, UseIndex] | Returns the item reference of the current selection using the text reference of the item (or index reference if UseIndex is set to 1).
"GetText", "item" | Returns the text of an item.
"IsChecked" | Returns the state of an item. 1:checked, 0:unchecked, -1:not a checkbox.
"Select", "item" | Selects an item.
"Uncheck", "item" | Unchecks an item (if the item supports it).

The "item" parameter is a string-based parameter that is used to reference a particular treeview item using a combination of text and indices. Indices are 0-based. For example:

Heading1
----> H1SubItem1
----> H1SubItem2
----> H1SubItem3
----> ----> H1S1SubItem1
Heading2
Heading3

Each "level" is separated by |. An index is preceded with #. Examples:

Item | Item Reference
Heading2 | "Heading2" or "#1"
H1SubItem2 | "Heading1|H1SubItem2" or "#0|#1"
H1S1SubItem1 | "Heading1|H1SubItem3|H1S1SubItem1" or "#0|#2|#0"

Remarks

As AutoIt is a 32-bit application some commands are not available when referencing a 64-bit application as Explorer when running on 64-bit Windows.

Related

ControlCommand

Example

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

Example()

Func Example()
    Local $hGUI = GUICreate("ControlTreeView Example", 212, 212)
    Local $idTreeView_1 = GUICtrlCreateTreeView(6, 6, 200, 160, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_CHECKBOXES), $WS_EX_CLIENTEDGE)
    Local $hTreeView_1 = ControlGetHandle($hGUI, "", $idTreeView_1)

    Local $idRoot = GUICtrlCreateTreeViewItem("Root", $idTreeView_1)
    GUICtrlCreateTreeViewItem("Item 1", $idRoot)
    GUICtrlCreateTreeViewItem("Item 2", $idRoot)
    GUICtrlCreateTreeViewItem("Item 3", $idRoot)
    Local $idItem_4 = GUICtrlCreateTreeViewItem("Item 4", $idRoot)
    GUICtrlCreateTreeViewItem("Item 4.1", $idItem_4)
    GUICtrlCreateTreeViewItem("Item 4.2", $idItem_4)
    GUICtrlCreateTreeViewItem("Item 5", $idRoot)

    GUISetState(@SW_SHOW, $hGUI)

    ControlTreeView($hGUI, "", $hTreeView_1, "Expand", "Root")

    ControlTreeView($hGUI, "", $hTreeView_1, "Exists", "Root|Item 4")
    ControlTreeView($hGUI, "", $hTreeView_1, "Check", "Root|Item 4")
    ControlTreeView($hGUI, "", $hTreeView_1, "Select", "Root|Item 4")
    ControlTreeView($hGUI, "", $hTreeView_1, "Expand", "Root|Item 4")

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    GUIDelete($hGUI)
EndFunc   ;==>Example


Function StatusbarGetText

Function Reference

StatusbarGetText

Retrieves the text from a standard status bar control.

StatusbarGetText ( "title" [, "text" [, part = 1]] )

Parameters

title | The title/hWnd/class of the window to check.
text | [optional] The text of the window to check. Default is an empty string.
part | [optional] The "part" number of the status bar to read - the default is 1. 1 is the first possible part and usually the one that contains the useful messages like "Ready" "Loading...", etc.

Return Value

Success: | the text read.
Failure: | "" (empty string) and sets the @error flag to 1 if no text could be read.

Remarks

This functions attempts to read the first standard status bar on a window (Microsoft common control: msctls_statusbar32). Some programs use their own status bars or special versions of the MS common control which StatusbarGetText() cannot read. For example, StatusbarGetText does not work on the program TextPad; however, the first region of TextPad's status bar can be read using ControlGetText("TextPad", "", "HSStatusBar1")
StatusbarGetText() can work on windows that are minimized or even hidden.

Related

ControlCommand, ControlGetText

Example

#include <MsgBoxConstants.au3>

AutoItSetOption("WinTitleMatchMode", 2)

Local $sText = StatusbarGetText("Internet Explorer")
MsgBox($MB_SYSTEMMODAL, "", "Internet Explorer's status bar says: " & $sText)


Function WinActivate

Function Reference

WinActivate

Activates (gives focus to) a window.

WinActivate ( "title" [, "text"] )

Parameters

title | The title/hWnd/class of the window to activate. See Title special definition.
text | [optional] The text of the window to activate. Default is an empty string. See Text special definition.

Return Value

Success: | the handle of the window.
Failure: | 0 if window is not found or cannot be activated.

Remarks

You can use the WinActive() function to check if WinActivate() succeeded. If multiple windows match the criteria, the window that was most recently active is the one activated. WinActivate() works on minimized windows. However, a window that is "Always On Top" could still cover up a window you Activated.

After a successful activation @extended is set to 1 if the the window was already active, 2 if not.

Related

WinClose, WinKill, WinMove, WinSetState, WinTitleMatchMode (Option)

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Activate the Notepad window using the handle returned by WinWait.
    WinActivate($hWnd)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function WinActive

Function Reference

WinActive

Checks to see if a specified window exists and is currently active.

WinActive ( "title" [, "text"] )

Parameters

title | The title/hWnd/class of the window to check. See Title special definition.
text | [optional] The text of the window to check. Default is an empty string. See Text special definition.

Return Value

Success: | the handle to the window if it is active.
Failure: | 0 otherwise.

Related

WinExists, WinTitleMatchMode (Option), WinWait, WinWaitActive, WinWaitClose, WinWaitNotActive

Example

#include <MsgBoxConstants.au3>

If WinActive("[CLASS:Notepad]") Then ; Check if Notepad is currently active.
    MsgBox($MB_SYSTEMMODAL, "", "WinActive" & @CRLF & "Notepad is active.")
Else
    MsgBox($MB_SYSTEMMODAL, "", "WinActive" & @CRLF & "Notepad is not active.")
EndIf


Function WinClose

Function Reference

WinClose

Closes a window.

WinClose ( "title" [, "text"] )

Parameters

title | The title/hWnd/class of the window to close. See Title special definition.
text | [optional] The text of the window to close. Default is an empty string. See Text special definition.

Return Value

Success: | 1.
Failure: | 0 if the window is not found.

Remarks

This function sends a close message to a window, the result depends on the window (it may ask to save data, etc.). To force a window to close, use the WinKill() function. If multiple windows match the criteria, the window that was most recently active is closed.

Related

ProcessClose, WinActivate, WinExists, WinKill, WinMove, WinSetState, WinTitleMatchMode (Option)

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    WinWait("[CLASS:Notepad]", "", 10)

    ; Wait for 2 seconds to display the Notepad window.
    Sleep(2000)

    ; Close the Notepad window using the classname of Notepad.
    WinClose("[CLASS:Notepad]")
EndFunc   ;==>Example


Function WinExists

Function Reference

WinExists

Checks to see if a specified window exists.

WinExists ( "title" [, "text"] )

Parameters

title | The title/hWnd/class of the window to check. See Title special definition.
text | [optional] The text of the window to check. Default is an empty string. See Text special definition.

Return Value

Success: | 1.
Failure: | 0 if the window is not found.

Remarks

WinExists() will return 1 even if the window is hidden.

Related

ProcessExists, WinActive, WinClose, WinTitleMatchMode (Option), WinWait, WinWaitActive, WinWaitClose, WinWaitNotActive

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    WinWait("[CLASS:Notepad]", "", 10)

    ; Test if the window exists and display the results.
    If WinExists("[CLASS:Notepad]") Then
        MsgBox($MB_SYSTEMMODAL, "", "Window exists")
    Else
        MsgBox($MB_SYSTEMMODAL, "", "Window does not exist")
    EndIf
EndFunc   ;==>Example


Function WinFlash

Function Reference

WinFlash

Flashes a window in the taskbar.

WinFlash ( "title" [, "text" [, flashes = 4 [, delay = 500]]] )

Parameters

title | The title/hWnd/class of the window to change. See Title special definition.
text | [optional] The text of the window to change. Default is an empty string. See Text special definition.
flashes | [optional] The amount of times to flash the window. Default 4.
delay | [optional] The time in milliseconds to sleep between each flash. Default 500 ms.

Return Value

None.

Remarks

This function is very useful for catching the user's eye!

Related

WinSetState

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Flash the window 4 times with a break in between each one of 1/2 second.
    WinFlash($hWnd, "", 4, 500)
EndFunc   ;==>Example


Function WinGetCaretPos

Function Reference

WinGetCaretPos

Returns the coordinates of the caret in the foreground window.

WinGetCaretPos ( )

Return Value

Success: | a 2-element array containing the following information: $aArray[0] = X coordinate $aArray[1] = Y coordinate
Failure: | sets the @error flag to non-zero.

Remarks

WinGetCaretPos() might not return accurate values for Multiple Document Interface (MDI) applications if absolute CaretCoordMode is used. See example for a workaround. Note: Some applications report static coordinates regardless of caret position!

Related

CaretCoordMode (Option)

Example

Local $aCaretPos = WinGetCaretPos()
If Not @error Then
    ToolTip("First Method", $aCaretPos[0], $aCaretPos[1])
EndIf
Sleep(2000)

$aCaretPos = _WinGetCaretPos()
If Not @error Then
    ToolTip("Second Method", $aCaretPos[0], $aCaretPos[1])
EndIf
Sleep(2000)

; A more reliable method to retrieve the caret coordinates in MDI text editors.
Func _WinGetCaretPos()
    Local $iXAdjust = 5
    Local $iYAdjust = 40

    Local $iOpt = Opt("CaretCoordMode", 0) ; Set "CaretCoordMode" to relative mode and store the previous option.
    Local $aGetCaretPos = WinGetCaretPos() ; Retrieve the relative caret coordinates.
    Local $aGetPos = WinGetPos("[ACTIVE]") ; Retrieve the position as well as height and width of the active window.
    Local $sControl = ControlGetFocus("[ACTIVE]") ; Retrieve the control name that has keyboard focus.
    Local $aControlPos = ControlGetPos("[ACTIVE]", "", $sControl) ; Retrieve the position as well as the size of the control.
    $iOpt = Opt("CaretCoordMode", $iOpt) ; Reset "CaretCoordMode" to the previous option.

    Local $aReturn[2] = [0, 0] ; Create an array to store the x, y position.
    If IsArray($aGetCaretPos) And IsArray($aGetPos) And IsArray($aControlPos) Then
        $aReturn[0] = $aGetCaretPos[0] + $aGetPos[0] + $aControlPos[0] + $iXAdjust
        $aReturn[1] = $aGetCaretPos[1] + $aGetPos[1] + $aControlPos[1] + $iYAdjust
        Return $aReturn ; Return the array.
    Else
        Return SetError(1, 0, $aReturn) ; Return the array and set @error to 1.
    EndIf
EndFunc   ;==>_WinGetCaretPos


Function WinGetClassList

Function Reference

WinGetClassList

Retrieves the classes from a window.

WinGetClassList ( "title" [, "text"] )

Parameters

title | The title/hWnd/class of the window to get the classes. See Title special definition.
text | [optional] The text of the window to get the classes. Default is an empty string. See Text special definition.

Return Value

Success: | a string containing the window classes read.
Failure: | "" and sets the @error flag to non-zero if the criteria does not match a window.

Remarks

Class names are linefeed (@LF) separated. WinGetClassList() works on both minimized and hidden windows. Up to 64KB of text can be retrieved. If multiple windows match the criteria, the classes are read from the most recently active window.

Related

ControlCommand, WinGetText

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Retrieve the classlist of the Notepad window using the handle returned by WinWait.
    Local $sClassList = WinGetClassList($hWnd)

    ; Display the classlist.
    MsgBox($MB_SYSTEMMODAL, "", $sClassList)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function WinGetClientSize

Function Reference

WinGetClientSize

Retrieves the size of a given window's client area.

WinGetClientSize ( "title" [, "text"] )

Parameters

title | The title/hWnd/class of the window to get the size. See Title special definition.
text | [optional] The text of the window to get the size. Default is an empty string. See Text special definition.

Return Value

Success: | a 2-element array containing the following information: $aArray[0] = Width of window's client area $aArray[1] = Height of window's client area
Failure: | sets the @error flag to non-zero if the window is not found.

Remarks

If the window is minimized, the returned width and height values are both zero. However, WinGetClientSize() works correctly on (non-minimized) hidden windows. If the window title "Program Manager" is used, the function will return the size of the desktop. If multiple windows match the criteria, the most recently active window is used.

Related

WinGetPos, WinMove

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Retrieve the client area of the Notepad window using the handle returned by WinWait.
    Local $aClientSize = WinGetClientSize($hWnd)

    ; Display the height and width of the client area.
    MsgBox($MB_SYSTEMMODAL, "", "Width: " & $aClientSize[0] & @CRLF & "Height: " & $aClientSize[1])

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function WinGetHandle

Function Reference

WinGetHandle

Retrieves the internal handle of a window.

WinGetHandle ( "title" [, "text"] )

Parameters

title | The title/hWnd/class of the window to get the handle. See Title special definition.
text | [optional] The text of the window to get the handle. Default is an empty string. See Text special definition.

Return Value

Success: | a handle to the window.
Failure: | sets the @error flag to non-zero if the window is not found.

Remarks

This function allows you to use handles to specify windows rather than "title" and "text".
Once you have obtained the handle you can access the required window even if its title changes.

Related

GUICreate, WinList, WinSetTitle

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    WinWait("[CLASS:Notepad]", "", 10)

    ; Retrieve the handle of the Notepad window using the classname of Notepad.
    Local $hWnd = WinGetHandle("[CLASS:Notepad]")
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when trying to retrieve the window handle of Notepad.")
        Exit
    EndIf

    ; Display the handle of the Notepad window.
    MsgBox($MB_SYSTEMMODAL, "", $hWnd)

    ; Close the Notepad window using the handle returned by WinGetHandle.
    WinClose($hWnd)
EndFunc   ;==>Example


Function WinGetPos

Function Reference

WinGetPos

Retrieves the position and size of a given window.

WinGetPos ( "title" [, "text"] )

Parameters

title | The title/hWnd/class of the window to get the position/size. See Title special definition.
text | [optional] The text of the window to get the position/size. Default is an empty string. See Text special definition.

Return Value

Success: | a 4-element array containing the following information: $aArray[0] = X position $aArray[1] = Y position $aArray[2] = Width $aArray[3] = Height
Failure: | sets the @error flag to non-zero if the window is not found.

Remarks

WinGetPos() returns negative numbers such as -32000 for minimized windows, but works fine with (non-minimized) hidden windows.
If the window title "Program Manager" is used, the function will return the size of the desktop. If multiple windows match the criteria, the most recently active window is used.

Related

WinGetClientSize, WinGetState, WinMove

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Retrieve the position as well as height and width of the active window.
    Local $aPos = WinGetPos("[ACTIVE]")

    ; Display the array values returned by WinGetPos.
    MsgBox($MB_SYSTEMMODAL, "", "X-Pos: " & $aPos[0] & @CRLF & _
            "Y-Pos: " & $aPos[1] & @CRLF & _
            "Width: " & $aPos[2] & @CRLF & _
            "Height: " & $aPos[3])
EndFunc   ;==>Example


Function WinGetProcess

Function Reference

WinGetProcess

Retrieves the Process ID (PID) associated with a window.

WinGetProcess ( "title" [, "text"] )

Parameters

title | The title/hWnd/class of the window to get the PID. See Title special definition.
text | [optional] The text of the window to get the PID. Default is an empty string. See Text special definition.

Return Value

Success: | a process ID (PID).
Failure: | -1 if the window is not found.

Related

ProcessList, ProcessWait, ProcessWaitClose

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Retrieve the PID of Notepad using the window handle returned by WinWait.
    Local $iPID = WinGetProcess($hWnd)

    ; Display the PID of the window.
    MsgBox($MB_SYSTEMMODAL, "", "The PID is: " & $iPID)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function WinGetState

Function Reference

WinGetState

Retrieves the state of a given window.

WinGetState ( "title" [, "text"] )

Parameters

title | The title/hWnd/class of the window to get the state. See Title special definition.
text | [optional] The text of the window to get the state. Default is an empty string. See Text special definition.

Return Value

Success: | a value indicating the state of the window. Multiple values are added together so use BitAND() to examine the part you are interested in: $WIN_STATE_EXISTS (1) = Window exists $WIN_STATE_VISIBLE (2) = Window is visible $WIN_STATE_ENABLED (4) = Window is enabled $WIN_STATE_ACTIVE (8) = Window is active $WIN_STATE_MINIMIZED (16) = Window is minimized $WIN_STATE_MAXIMIZED (32) = Window is maximized
Failure: | 0 and sets the @error flag to non-zero if the window is not found.

Constants are defined in "AutoItConstants.au3".

Related

BitAND, WinGetPos, WinSetState

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Retrieve the state of the Notepad window using the handle returned by WinWait.
    Local $iState = WinGetState($hWnd)

    ; Check if the Notepad window is minimized and display the appropriate message box.
    If BitAND($iState, 16) Then
        MsgBox($MB_SYSTEMMODAL, "", "Notepad is minimized and the state returned by WinGetState was - " & $iState)
    Else
        MsgBox($MB_SYSTEMMODAL, "", "Notepad isn't minimized and the state returned by WinGetState was - " & $iState)
    EndIf

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function WinGetText

Function Reference

WinGetText

Retrieves the text from a window.

WinGetText ( "title" [, "text"] )

Parameters

title | The title/hWnd/class of the window to get the text. See Title special definition.
text | [optional] The text of the window to get the text. Default is an empty string. See Text special definition.

Return Value

Success: | a string containing the window text read.
Failure: | "" if the window is not found.

Remarks

Up to 64KB of window text can be retrieved. WinGetText() works on minimized windows, but only works on hidden windows if you've set Opt("WinDetectHiddenText", 1)
If multiple windows match the criteria for WinGetText(), the information for the most recently active match is returned.
Use WinGetText("[active]") to get the active window's text.

Related

ControlGetText, WinGetClassList, WinGetTitle

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Retrieve the window text of the active window.
    Local $sText = WinGetText("[ACTIVE]")

    ; Display the window text.
    MsgBox($MB_SYSTEMMODAL, "", $sText)
EndFunc   ;==>Example


Function WinGetTitle

Function Reference

WinGetTitle

Retrieves the full title from a window.

WinGetTitle ( "title" [, "text"] )

Parameters

title | The title/hWnd/class of the window to get the title. See Title special definition.
text | [optional] The text of the window to get the title. Default is an empty string. See Text special definition.

Return Value

Success: | a string containing the complete window title.
Failure: | "" if the window is not found.

Remarks

WinGetTitle("[active]") returns the active window's title. WinGetTitle() works on both minimized and hidden windows. If multiple windows match the criteria, the most recently active window is used.

Related

AutoItWinGetTitle, WinGetText, WinSetTitle, WinTitleMatchMode (Option)

Example

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Retrieve the window title of the active window.
    Local $sText = WinGetTitle("[ACTIVE]")

    ; Display the window title.
    MsgBox($MB_SYSTEMMODAL, "", $sText)
EndFunc   ;==>Example


Function WinKill

Function Reference

WinKill

Forces a window to close.

WinKill ( "title" [, "text"] )

Parameters

title | The title/hWnd/class of the window to close. See Title special definition.
text | [optional] The text of the window to close. Default is an empty string. See Text special definition.

Return Value

Success: | 1.
Failure: | The function only returns the success value.

Remarks

The difference between this function and WinClose() is that WinKill() will forcibly terminate the window if it doesn't close quickly enough. Consequently, a user might not have time to respond to dialogs prompting the user to save data. Although WinKill() can work on both minimized and hidden windows, some windows (notably explorer windows) can only be terminated using WinClose().

Related

ProcessClose, WinActivate, WinClose, WinSetState

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Wait for 2 seconds before calling the WinKill function.
    Sleep(2000)

    ; Kill the window using the handle returned by WinWait.
    WinKill($hWnd, "")
EndFunc   ;==>Example


Function WinList

Function Reference

WinList

Retrieves a list of windows.

WinList ( ["title" [, "text"]] )

Parameters

title | [optional] The title/hWnd/class of the windows to get the list. See Title special definition.
text | [optional] The text of the windows to get the list. Default is an empty string. See Text special definition.

Return Value

Returns an array of matching window titles and handles.

Remarks

If no title and text is given then all top-level windows are returned.

The array returned is two-dimensional and is made up as follows:
$aArray[0][0] = Number of windows returned
$aArray[1][0] = 1st window title
$aArray[1][1] = 1st window handle (HWND)
$aArray[2][0] = 2nd window title
$aArray[2][1] = 2nd window handle (HWND)
...
$aArray[n][0] = nth window title
$aArray[n][1] = nth window handle (HWND)

Related

WinGetHandle

Example

Example 1

#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Retrieve a list of window handles.
    Local $aList = WinList()

    ; Loop through the array displaying only visable windows with a title.
    For $i = 1 To $aList[0][0]
        If $aList[$i][0] <> "" And BitAND(WinGetState($aList[$i][1]), 2) Then
            MsgBox($MB_SYSTEMMODAL, "", "Title: " & $aList[$i][0] & @CRLF & "Handle: " & $aList[$i][1])
        EndIf
    Next
EndFunc   ;==>Example

Example 2

#include <Array.au3>

Example()

Func Example()
    ; Retrieve a list of window handles using a regular expression. The regular expression looks for titles that contain the word SciTE or Internet Explorer.
    Local $aWinList = WinList("[REGEXPTITLE:(?i)(.*SciTE.*|.*Internet Explorer.*)]")
    _ArrayDisplay($aWinList)
EndFunc   ;==>Example


Function WinMenuSelectItem

Function Reference

WinMenuSelectItem

Invokes a menu item of a window.

WinMenuSelectItem ( "title", "text", "item" [, "item" [, "item" [, "item" [, "item" [, "item" [, "item"]]]]]] )

Parameters

title | The title/hWnd/class of the window to select the item. See Title special definition.
text | The text of the window to select the item. See Text special definition.
item | Text of Menu Item
item | [optional] Text of SubMenu item
item | [optional] Text of SubMenu item
item | [optional] Text of SubMenu item
item | [optional] Text of SubMenu item
item | [optional] Text of SubMenu item
item | [optional] Text of SubMenu item

Return Value

Success: | 1.
Failure: | 0 if the menu is not found.

Remarks

You should note that underlined menu items actually contain a & character to indicate the underlining. Thus, the menu item File would actually require the text "&File", and Convert would require "Con&vert" You can access menu items up to six levels deep; and the window can be inactive, minimized, and/or even hidden.

WinMenuSelectItem() will only work on standard menus. Unfortunately, many menus in use today are actually custom written or toolbars "pretending" to be menus. This is true for most Microsoft applications.

Related

ControlCommand, Send

Example

; This will select File and then Page Setup in notepad

WinMenuSelectItem("[CLASS:Notepad]", "", "&File", "Page Set&up...")


Function WinMinimizeAll

Function Reference

WinMinimizeAll

Minimizes all windows.

WinMinimizeAll ( )

Return Value

None.

Remarks

Send("#m") is a possible alternative.

Related

WinMinimizeAllUndo, WinSetState

Example

WinMinimizeAll()


Function WinMinimizeAllUndo

Function Reference

WinMinimizeAllUndo

Undoes a previous WinMinimizeAll function.

WinMinimizeAllUndo ( )

Return Value

None.

Remarks

Send("#+m") is a possible alternative.

Related

WinMinimizeAll, WinSetState

Example

WinMinimizeAllUndo()


Function WinMove

Function Reference

WinMove

Moves and/or resizes a window.

WinMove ( "title", "text", x, y [, width [, height [, speed]]] )

Parameters

title | The title/hWnd/class of the window to move/resize. See Title special definition.
text | The text of the window to move/resize. See Text special definition.
x | X coordinate to move to.
y | Y coordinate to move to.
width | [optional] New width of the window.
height | [optional] New height of the window.
speed | [optional] the speed to move the windows in the range 1 (fastest) to 100 (slowest). If not defined the move is instantaneous.

Return Value

Success: | a handle to the window.
Failure: | 0 if the window is not found.

Remarks

WinMove() has no effect on minimized windows, but WinMove() works on hidden windows.
If the width and height are small (or negative), the window will go no smaller than 112 x 27 pixels. If width and height are large, the window will go no larger than approximately [12+@DesktopWidth] x [12+@DesktopHeight] pixels.
Negative values are allowed for the x and y coordinates. In fact, you can move a window off screen; and if the window's program is one that remembers its last window position, the window will appear in the corner (but fully on-screen) the next time you launch the program.
If multiple windows match the criteria, the most recently active window is used.

If x and y equal to the Default keyword no move occurs, just resizing.

When speed is used the move is done with the new size.

Related

WinActivate, WinClose, WinGetClientSize, WinGetPos, WinSetState

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Retrieve the position as well as the height and width of the Notepad window. We will use this when we have to move the window back to the original position.
    Local $aPos = WinGetPos($hWnd)

    ; Move the Notepad to the x, y position of 0, 0 and set the height and width at 200, 200.
    WinMove($hWnd, "", 0, 0, 200, 200)

    ; Wait for 2 seconds to display the new position of the Notepad window.
    Sleep(2000)

    ; Move the Notepad window back to the original position by using the array returned by WinGetPos.
    WinMove($hWnd, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3])

    ; Wait for 2 seconds to display the original position of the Notepad window.
    Sleep(2000)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function WinSetOnTop

Function Reference

WinSetOnTop

Change a window's "Always On Top" attribute.

WinSetOnTop ( "title", "text", flag )

Parameters

title | The title/hWnd/class of the window to change. See Title special definition.
text | The text of the window to change. See Text special definition.
flag | Determines whether the window should have the "TOPMOST" flag set. $WINDOWS_NOONTOP (0) = remove on top flag $WINDOWS_ONTOP (1) = set on top flag Constants are defined in "AutoItConstants.au3".

Return Value

Success: | 1.
Failure: | 0 if the window is not found.

Remarks

Third-party programs which add an "Always On Top" context menu entry might not update their menu entry to reflect the AutoIt-induced change in TOPMOST status.

Related

WinSetState

Example

#include <AutoItConstants.au3>

Example()

Func Example()
    ; Retrieve the handle of the active window.
    Local $hWnd = WinGetHandle("[ACTIVE]")

    ; Set the active window as being ontop using the handle returned by WinGetHandle.
    WinSetOnTop($hWnd, "", $WINDOWS_ONTOP)

    ; Wait for 2 seconds to display the change.
    Sleep(2000)

    ; Remove the "topmost" state from the active window.
    WinSetOnTop($hWnd, "", $WINDOWS_NOONTOP)
EndFunc   ;==>Example


Function WinSetState

Function Reference

WinSetState

Shows, hides, minimizes, maximizes, or restores a window.

WinSetState ( "title", "text", flag )

Parameters

title | The title/hWnd/class of the window to change the state. See Title special definition.
text | The text of the window to change the state. See Text special definition.
flag | The "show" flag of the executed program: @SW_HIDE = Hide window @SW_SHOW = Shows a previously hidden window @SW_MINIMIZE = Minimize window @SW_MAXIMIZE = Maximize window @SW_RESTORE = Undoes a window minimization or maximization @SW_DISABLE = Disables the window @SW_ENABLE = Enables the window

Return Value

Success: | 1.
Failure: | 0 if the window is not found.

Remarks

If multiple windows match the criteria, the most recently active window is used.
@SW_MINIMIZE and @SW_MAXIMIZE even work on modal dialog windows.

Related

ControlHide, WinActivate, WinClose, WinFlash, WinGetState, WinKill, WinMinimizeAll, WinMinimizeAllUndo, WinMove, WinSetOnTop

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Set the state of the Notepad window to "hide".
    WinSetState($hWnd, "", @SW_HIDE)

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Set the state of the Notepad window to "show".
    WinSetState($hWnd, "", @SW_SHOW)

    ; Wait for 2 seconds.
    Sleep(2000)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function WinSetTitle

Function Reference

WinSetTitle

Changes the title of a window.

WinSetTitle ( "title", "text", "newtitle" )

Parameters

title | The title/hWnd/class of the window to change. See Title special definition.
text | The text of the window to change. See Text special definition.
newtitle | The new title to give to the window.

Return Value

Success: | 1.
Failure: | 0 if the window is not found.

Remarks

If multiple windows match the criteria the title of most recently active window is changed.

Related

AutoItWinSetTitle, WinGetHandle, WinGetTitle, WinTitleMatchMode (Option)

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Set the title of the Notepad window using the handle returned by WinWait.
    WinSetTitle($hWnd, "", "New Notepad Title - AutoIt")

    ; Wait for 2 seconds to display the Notepad window and the new title.
    Sleep(2000)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function WinSetTrans

Function Reference

WinSetTrans

Sets the transparency of a window.

WinSetTrans ( "title", "text", transparency )

Parameters

title | The title/hWnd/class of the window to change. See Title special definition.
text | The text of the window to change. See Text special definition.
transparency | A number in the range 0 - 255. The lower the number, the more transparent the window will become. 255 = Solid, 0 = Invisible.

Return Value

Success: | Non-zero.
Failure: | 0 and sets the @error flag to non-zero if no supported on the OS.

Remarks

Screen color must be greater or equal to 16-bit.

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Set the transparency of the Notepad window to 170.
    WinSetTrans($hWnd, "", 170)

    ; Wait for 2 seconds to display the Notepad window.
    Sleep(2000)

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example


Function WinWait

Function Reference

WinWait

Pauses execution of the script until the requested window exists.

WinWait ( "title" [, "text" [, timeout = 0]] )

Parameters

title | The title/hWnd/class of the window to check. See Title special definition.
text | [optional] The text of the window to check. Default is an empty string. See Text special definition.
timeout | [optional] Timeout in seconds if the window does not exist. Default is 0 (no timeout).

Return Value

Success: | a handle to the requested window.
Failure: | 0 if timeout occurred.

Remarks

The window is polled every 250 milliseconds or so.

Related

ProcessWait, WinActive, WinExists, WinWaitActive, WinWaitClose, WinWaitDelay (Option), WinWaitNotActive

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    WinWait("[CLASS:Notepad]", "", 10)

    ; Wait for 2 seconds to display the Notepad window.
    Sleep(2000)

    ; Close the Notepad window using the classname of Notepad.
    WinClose("[CLASS:Notepad]")
EndFunc   ;==>Example


Function WinWaitActive

Function Reference

WinWaitActive

Pauses execution of the script until the requested window is active.

WinWaitActive ( "title" [, "text" [, timeout = 0]] )

Parameters

title | The title/hWnd/class of the window to check. See Title special definition.
text | [optional] The text of the window to check. Default is an empty string. See Text special definition.
timeout | [optional] Timeout in seconds if the window is not active. Default is 0 (no timeout).

Return Value

Success: | a handle to the requested window.
Failure: | 0 if timeout occurred.

Remarks

The window is polled every 250 milliseconds or so.

Related

ProcessWait, WinActive, WinExists, WinWait, WinWaitClose, WinWaitDelay (Option), WinWaitNotActive

Example

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    WinWaitActive("[CLASS:Notepad]", "", 10)

    ; Wait for 2 seconds to display the Notepad window.
    Sleep(2000)

    ; Close the Notepad window using the classname of Notepad.
    WinClose("[CLASS:Notepad]")
EndFunc   ;==>Example


Function WinWaitClose

Function Reference

WinWaitClose

Pauses execution of the script until the requested window does not exist.

WinWaitClose ( "title" [, "text" [, timeout = 0]] )

Parameters

title | The title/hWnd/class of the window to check. See Title special definition.
text | [optional] The text of the window to check. Default is an empty string. See Text special definition.
timeout | [optional] Timeout in seconds if the window is not closed. Default is 0 (no timeout).

Return Value

Success: | 1.
Failure: | 0 if timeout occurred.

Remarks

If the window already doesn't exist when this function is called it will return 1 immediately. The window is polled every 250 milliseconds or so.

Related

ProcessWaitClose, WinActive, WinExists, WinWait, WinWaitActive, WinWaitDelay (Option), WinWaitNotActive

Example

; Wait for the window "[CLASS:Notepad]" to not exist.
WinWaitClose("[CLASS:Notepad]")

; Wait a maximum of 5 seconds for "[CLASS:Notepad]" to not exist.
WinWaitClose("[CLASS:Notepad]", "", 5)


Function WinWaitNotActive

Function Reference

WinWaitNotActive

Pauses execution of the script until the requested window is not active.

WinWaitNotActive ( "title" [, "text" [, timeout = 0]] )

Parameters

title | The title/hWnd/class of the window to check. See Title special definition.
text | [optional] The text of the window to check. Default is an empty string. See Text special definition.
timeout | [optional] Timeout in seconds if the window is still active. Default is 0 (no timeout).

Return Value

Success: | 1.
Failure: | 0 if timeout occurred.

Remarks

The window is polled every 250 milliseconds or so.

Related

WinActive, WinExists, WinWait, WinWaitActive, WinWaitClose, WinWaitDelay (Option)

Example

; Wait for the window "[CLASS:Notepad]" to not be active.
WinWaitNotActive("[CLASS:Notepad]")

; Wait a maximum of 5 seconds for "[CLASS:Notepad]" to not be active.
WinWaitNotActive("[CLASS:Notepad]", "", 5)


Appendix Reference

  • AutoIt Constants include files
  • AutoIt3 limits/defaults
  • ASCII Characters
  • CLSIDs of Special Folders
  • GUI Control Styles
  • @OSLang Values
  • Send Key List
  • Standard Windows Fonts
  • Windows Message Codes


AutoIt Constants include files

Below is a complete list of the AutoIt Constants include files available in AutoIt.

Using #include <Constants.au3> include all of them except the Font, GUI, Inet and Windows constants.

File | Related Control(s)
#include <ColorConstants.au3> | Color related
#include <Constants.au3> | Tray, Run related
#include <DirConstants.au3> | Dir related
#include <FileConstants.au3> | File related
#include <FontConstants.au3> | Font related
#include <GUIConstantsEx.au3> | GUI related
#include <InetConstants.au3> | Inet related
#include <MsgBoxConstants.au3> | MsgBox related
#include <StringConstants.au3> | String related
#include <WindowsConstants.au3> | Windows related


Limits Defaults

AutoIt3 Limits/defaults

AutoIt3 limits | Value | Description
MAX_BINARYSIZE | 2,147,483,647 | Maximum bytes of binary data.
MAX_ENVSIZE | 32767 | Maximum size for an ENV variable.
MAX_LINESIZE | 4095 | Maximum size for a line of script.
MAX_STRINGLEN | 2,147,483,647 | Maximum string length.
WINTEXTBUFFER | 32767 | WM_GETTEXT randomly fails if > 32767.
MAXCALLRECURSE | 3900 limit for x64 and 1900 limit for x86 | Maximum number of times the Call() function can recurse to itself.
MAXEXECUTERECURSE | 5100 | Maximum number of times the Execute() function can recurse to itself.
GUI_MAXCONTROLS | 65532 | Maximum number of controls in GUI box.
GUI_MAXPOINTS | 256 | Maximum number of points by graphic info page.
COM_MAXEVENT | 64 | Maximum number of COM events that can be buffered.
VAR_SUBSCRIPT_ELEMENTS | 16,777,216 | Maximum number of elements for an array.
VAR_SUBSCRIPT_MAX | 64 | Maximum number of subscripts for an array.
MAIN_TIMER_DELAY | 750 ms | Tray icon hiding/flashing/drawing is checked every 750ms.
CMDLINEPARAM_MAXLEN | 4096 | Each parameter can be this many characters.
TRAY_MAXITEMS | 505 | Maximum number of items in the tray menu.
TRAY_MAXEVENT | 32 | Maximum number of events that can be buffered.
TRAY_TOOLTIPWIDTH | 64 | Maximum number of characters displayed in a tray tooltip.

Default | Value | Description
ADLIB delay | 250 ms | Default delay in ms between ADLIB triggers. Can be defined in AdlibRegister().
 |  | Following defaults can be changed with Opt()
MouseClickDelay | 10 ms | Time between mouse clicks.
MouseClickDownDelay | 10 ms | Time the click is held down.
MouseClickDragDelay | 250 ms | The delay at the start and end of a drag operation.
TCPTimeout | 100 ms | Time after a TCP function is aborted.


ASCII Characters

ASCII Character Codes

This list is helpful with the Asc and Chr functions. Taken from ASCII Character Set

Control Characters (mostly non-printing; most useful of these are highlighted in yellow.)

Char... | Dec | Hex | Oct | Description
NUL | 0 | 00 | 000 | Null character
SOH | 1 | 01 | 001 | Start of heading, = console interrupt
STX | 2 | 02 | 002 | Start of text, maintenance mode on HP console
ETX | 3 | 03 | 003 | End of text
EOT | 4 | 04 | 004 | End of transmission, not the same as ETB
ENQ | 5 | 05 | 005 | Enquiry, goes with ACK; old HP flow control
ACK | 6 | 06 | 006 | Acknowledge, clears ENQ logon hand
BEL | 7 | 07 | 007 | Bell, rings the bell... (Plays Windows' default beep)
BS | 8 | 08 | 010 | Backspace, works on HP terminals/computers
HT | 9 | 09 | 011 | Horizontal tab, move to next tab stop
LF | 10 | 0a | 012 | Line Feed
VT | 11 | 0b | 013 | Vertical tab
FF | 12 | 0c | 014 | Form Feed, page eject
CR | 13 | 0d | 015 | Carriage Return
SO | 14 | 0e | 016 | Shift Out, alternate character set
SI | 15 | 0f | 017 | Shift In, resume default character set
DLE | 16 | 10 | 020 | Data link escape
DC1 | 17 | 11 | 021 | XON, with XOFF to pause listings; ":okay to send".
DC2 | 18 | 12 | 022 | Device control 2, block-mode flow control
DC3 | 19 | 13 | 023 | XOFF, with XON is TERM=18 flow control
DC4 | 20 | 14 | 024 | Device control 4
NAK | 21 | 15 | 025 | Negative acknowledge
SYN | 22 | 16 | 026 | Synchronous idle
ETB | 23 | 17 | 027 | End transmission block, not the same as EOT
CAN | 24 | 18 | 030 | Cancel line, MPE echoes !!!
EM | 25 | 19 | 031 | End of medium, Control-Y interrupt
SUB | 26 | 1a | 032 | Substitute
ESC | 27 | 1b | 033 | Escape, next character is not echoed
FS | 28 | 1c | 034 | File separator
GS | 29 | 1d | 035 | Group separator
RS | 30 | 1e | 036 | Record separator, block-mode terminator
US | 31 | 1f | 037 | Unit separator
DEL | 127 | 7f | 177 | Delete (rubout), cross-hatch box

Printing Characters (standard characters)

Char | Dec | Hex | Oct | Description
 | 32 | 20 | 040 | Space
! | 33 | 21 | 041 | Exclamation mark
" | 34 | 22 | 042 | Quotation mark (&quot; in HTML)
# | 35 | 23 | 043 | Cross hatch (number sign)
$ | 36 | 24 | 044 | Dollar sign
% | 37 | 25 | 045 | Percent sign
& | 38 | 26 | 046 | Ampersand
` | 39 | 27 | 047 | Closing single quote (apostrophe)
( | 40 | 28 | 050 | Opening parentheses
) | 41 | 29 | 051 | Closing parentheses
* | 42 | 2a | 052 | Asterisk (star, multiply)
+ | 43 | 2b | 053 | Plus
, | 44 | 2c | 054 | Comma
- | 45 | 2d | 055 | Hyphen, dash, minus
. | 46 | 2e | 056 | Period
/ | 47 | 2f | 057 | Slant (forward slash, divide)
0 | 48 | 30 | 060 | Zero
1 | 49 | 31 | 061 | One
2 | 50 | 32 | 062 | Two
3 | 51 | 33 | 063 | Three
4 | 52 | 34 | 064 | Four
5 | 53 | 35 | 065 | Five
6 | 54 | 36 | 066 | Six
7 | 55 | 37 | 067 | Seven
8 | 56 | 38 | 070 | Eight
9 | 57 | 39 | 071 | Nine
: | 58 | 3a | 072 | Colon
; | 59 | 3b | 073 | Semicolon
< | 60 | 3c | 074 | Less than sign
= | 61 | 3d | 075 | Equals sign
> | 62 | 3e | 076 | Greater than sign
? | 63 | 3f | 077 | Question mark
@ | 64 | 40 | 100 | At-sign
A | 65 | 41 | 101 | Uppercase A
B | 66 | 42 | 102 | Uppercase B
C | 67 | 43 | 103 | Uppercase C
D | 68 | 44 | 104 | Uppercase D
E | 69 | 45 | 105 | Uppercase E
F | 70 | 46 | 106 | Uppercase F
G | 71 | 47 | 107 | Uppercase G
H | 72 | 48 | 110 | Uppercase H
I | 73 | 49 | 111 | Uppercase I
J | 74 | 4a | 112 | Uppercase J
K | 75 | 4b | 113 | Uppercase K
L | 76 | 4c | 114 | Uppercase L
M | 77 | 4d | 115 | Uppercase M
N | 78 | 4e | 116 | Uppercase N
O | 79 | 4f | 117 | Uppercase O
P | 80 | 50 | 120 | Uppercase P
Q | 81 | 51 | 121 | Uppercase Q
R | 82 | 52 | 122 | Uppercase R
S | 83 | 53 | 123 | Uppercase S
T | 84 | 54 | 124 | Uppercase T
U | 85 | 55 | 125 | Uppercase U
V | 86 | 56 | 126 | Uppercase V
W | 87 | 57 | 127 | Uppercase W
X | 88 | 58 | 130 | Uppercase X
Y | 89 | 59 | 131 | Uppercase Y
Z | 90 | 5a | 132 | Uppercase Z
[ | 91 | 5b | 133 | Opening square bracket
\ | 92 | 5c | 134 | Reverse slant (Backslash)
] | 93 | 5d | 135 | Closing square bracket
^ | 94 | 5e | 136 | Caret (Circumflex)
_ | 95 | 5f | 137 | Underscore
` | 96 | 60 | 140 | Opening single quote
a | 97 | 61 | 141 | Lowercase a
b | 98 | 62 | 142 | Lowercase b
c | 99 | 63 | 143 | Lowercase c
d | 100 | 64 | 144 | Lowercase d
e | 101 | 65 | 145 | Lowercase e
f | 102 | 66 | 146 | Lowercase f
g | 103 | 67 | 147 | Lowercase g
h | 104 | 68 | 150 | Lowercase h
i | 105 | 69 | 151 | Lowercase i
j | 106 | 6a | 152 | Lowercase j
k | 107 | 6b | 153 | Lowercase k
l | 108 | 6c | 154 | Lowercase l
m | 109 | 6d | 155 | Lowercase m
n | 110 | 6e | 156 | Lowercase n
o | 111 | 6f | 157 | Lowercase o
p | 112 | 70 | 160 | Lowercase p
q | 113 | 71 | 161 | Lowercase q
r | 114 | 72 | 162 | Lowercase r
s | 115 | 73 | 163 | Lowercase s
t | 116 | 74 | 164 | Lowercase t
u | 117 | 75 | 165 | Lowercase u
v | 118 | 76 | 166 | Lowercase v
w | 119 | 77 | 167 | Lowercase w
x | 120 | 78 | 170 | Lowercase x
y | 121 | 79 | 171 | Lowercase y
z | 122 | 7a | 172 | Lowercase z
{ | 123 | 7b | 173 | Opening curly brace
| | 124 | 7c | 174 | Vertical line
} | 125 | 7d | 175 | Closing curly brace
~ | 126 | 7e | 176 | Tilde (approximate)

Extended Character Set (ANSI)

Char | Dec | Hex | Oct | Description
€ | 128 | 80 | 200 |
 | 129 | 81 | 201 | Note: does not display in this compiled html help file
' | 130 | 82 | 202 |
ƒ | 131 | 83 | 203 |
" | 132 | 84 | 204 |
… | 133 | 85 | 205 |
† | 134 | 86 | 206 |
‡ | 135 | 87 | 207 |
ˆ | 136 | 88 | 210 |
‰ | 137 | 89 | 211 |
Š | 138 | 8A | 212 |
‹ | 139 | 8B | 213 |
Œ | 140 | 8C | 214 |
 | 141 | 8D | 215 | Note: does not display in this compiled html help file
Ž | 142 | 8E | 216 |
 | 143 | 8F | 217 | Note: does not display in this compiled html help file
� | 144 | 90 | 220 | Note: does not display in this compiled html help file
' | 145 | 91 | 221 |
' | 146 | 92 | 222 |
" | 147 | 93 | 223 |
" | 148 | 94 | 224 |
• | 149 | 95 | 225 |
- | 150 | 96 | 226 |
- | 151 | 97 | 227 |
˜ | 152 | 98 | 230 |
™ | 153 | 99 | 231 |
š | 154 | 9A | 232 |
› | 155 | 9B | 233 |
œ | 156 | 9C | 234 |
 | 157 | 9D | 235 | Note: does not display in this compiled html help file
ž | 158 | 9E | 236 |
Ÿ | 159 | 9F | 237 |
 | 160 | A0 | 240 |
¡ | 161 | A1 | 241 |
¢ | 162 | A2 | 242 |
£ | 163 | A3 | 243 |
¤ | 164 | A4 | 244 |
¥ | 165 | A5 | 245 |
¦ | 166 | A6 | 246 |
§ | 167 | A7 | 247 |
¨ | 168 | A8 | 250 |
© | 169 | A9 | 251 |
ª | 170 | AA | 252 |
« | 171 | AB | 253 |
¬ | 172 | AC | 254 |
 | 173 | AD | 255 | Note: may not display in this compiled html help file
® | 174 | AE | 256 |
¯ | 175 | AF | 257 |
° | 176 | B0 | 260 |
± | 177 | B1 | 261 |
² | 178 | B2 | 262 |
³ | 179 | B3 | 263 |
´ | 180 | B4 | 264 |
µ | 181 | B5 | 265 |
¶ | 182 | B6 | 266 |
· | 183 | B7 | 267 |
¸ | 184 | B8 | 270 |
¹ | 185 | B9 | 271 |
º | 186 | BA | 272 |
» | 187 | BB | 273 |
¼ | 188 | BC | 274 |
½ | 189 | BD | 275 |
¾ | 190 | BE | 276 |
¿ | 191 | BF | 277 |
À | 192 | C0 | 300 |
Á | 193 | C1 | 301 |
Â | 194 | C2 | 302 |
Ã | 195 | C3 | 303 |
Ä | 196 | C4 | 304 |
Å | 197 | C5 | 305 |
Æ | 198 | C6 | 306 |
Ç | 199 | C7 | 307 |
È | 200 | C8 | 310 |
É | 201 | C9 | 311 |
Ê | 202 | CA | 312 |
Ë | 203 | CB | 313 |
Ì | 204 | CC | 314 |
Í | 205 | CD | 315 |
Î | 206 | CE | 316 |
Ï | 207 | CF | 317 |
Ð | 208 | D0 | 320 |
Ñ | 209 | D1 | 321 |
Ò | 210 | D2 | 322 |
Ó | 211 | D3 | 323 |
Ô | 212 | D4 | 324 |
Õ | 213 | D5 | 325 |
Ö | 214 | D6 | 326 |
× | 215 | D7 | 327 |
Ø | 216 | D8 | 330 |
Ù | 217 | D9 | 331 |
Ú | 218 | DA | 332 |
Û | 219 | DB | 333 |
Ü | 220 | DC | 334 |
Ý | 221 | DD | 335 |
Þ | 222 | DE | 336 |
ß | 223 | DF | 337 |
à | 224 | E0 | 340 |
á | 225 | E1 | 341 |
â | 226 | E2 | 342 |
ã | 227 | E3 | 343 |
ä | 228 | E4 | 344 |
å | 229 | E5 | 345 |
æ | 230 | E6 | 346 |
ç | 231 | E7 | 347 |
è | 232 | E8 | 350 |
é | 233 | E9 | 351 |
ê | 234 | EA | 352 |
ë | 235 | EB | 353 |
ì | 236 | EC | 354 |
í | 237 | ED | 355 |
î | 238 | EE | 356 |
ï | 239 | EF | 357 |
ð | 240 | F0 | 360 |
ñ | 241 | F1 | 361 |
ò | 242 | F2 | 362 |
ó | 243 | F3 | 363 |
ô | 244 | F4 | 364 |
õ | 245 | F5 | 365 |
ö | 246 | F6 | 366 |
÷ | 247 | F7 | 367 |
ø | 248 | F8 | 370 |
ù | 249 | F9 | 371 |
ú | 250 | FA | 372 |
û | 251 | FB | 373 |
ü | 252 | FC | 374 |
ý | 253 | FD | 375 |
þ | 254 | FE | 376 |
ÿ | 255 | FF | 377 |


CLSID List

For use with FileOpenDialog, FileSaveDialog, or FileSelectFolder

List taken from Registry Guide for Windows at WinGuides Network

Note: Not all values may work as parameters for the AutoIt functions listed above.

Example: FileSelectFolder("Choose a folder.", "::{D20EA4E1-3957-11d2-A40B-0C5020524152}", 1)

Folder | Value for the File___'s directory parameter
Administrative Tools | "::{D20EA4E1-3957-11d2-A40B-0C5020524153}"
Briefcase | "::{85BBD920-42A0-1069-A2E4-08002B30309D}"
Control Panel | "::{21EC2020-3AEA-1069-A2DD-08002b30309d}"
Fonts | "::{D20EA4E1-3957-11d2-A40B-0C5020524152}"
History | "::{FF393560-C2A7-11CF-BFF4-444553540000}"
Inbox | "::{00020D75-0000-0000-C000-000000000046}"
Microsoft Network | "::{00028B00-0000-0000-C000-000000000046}"
My Computer | "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
My Documents | "::{450D8FBA-AD25-11D0-98A8-0800361B1103}"
My Network Places | "::{208D2C60-3AEA-1069-A2D7-08002B30309D}"
Network Computers | "::{1f4de370-d627-11d1-ba4f-00a0c91eedba}"
Network Connections | "::{7007ACC7-3202-11D1-AAD2-00805FC1270E}"
Printers and Faxes | "::{2227A280-3AEA-1069-A2DE-08002B30309D}"
Programs Folder | "::{7be9d83c-a729-4d97-b5a7-1b7313c39e0a}"
Recycle Bin | "::{645FF040-5081-101B-9F08-00AA002F954E}"
Scanners and Cameras | "::{E211B736-43FD-11D1-9EFB-0000F8757FCD}"
Scheduled Tasks | "::{D6277990-4C6A-11CF-8D87-00AA0060F5BF}"
Start Menu Folder | "::{48e7caab-b918-4e58-a94d-505519c795dc}"
Temporary Internet Files | "::{7BD29E00-76C1-11CF-9DD0-00A0C9034933}"
Web Folders | "::{BDEADF00-C265-11d0-BCED-00A0C90AB50F}"


GUI Control Styles

This page contains a list of the common and extended styles that can be used with windows, and also specific styles that can be used with controls. These styles are used in the "style" and/or "exStyle" parameters of many of the GUI functions. To use these values you must #include the file specified at the top of each section.

Extended | Avi | Button | Checkbox | Combo | Date | Edit/Input | Label/Static | ListBox | ListView | ListView Extended | MonthCal | Progress | Slider | Tab | TreeView | UpDown

Note: The "Value" is given just for reference, you should always use the "name" of the style in order to keep your scripts readable.

Common Styles | Value | Description
 |  | #include <WindowsConstants.au3>
Default/forced for GUI creation |  | $GUI_SS_DEFAULT_GUI see GUICreate function.
$WS_BORDER | 0x00800000 | Creates a window that has a thin-line border.
$WS_POPUP | 0x80000000 | Creates a pop-up window. This style cannot be used with the WS_CHILD style.
$WS_CAPTION | 0x00C00000 | Creates a window that has a title bar (includes the WS_BORDER style)
$WS_CLIPCHILDREN | 0x02000000 | Excludes the area occupied by child windows when drawing occurs within the parent window. This style is used when creating the parent window.
$WS_CLIPSIBLINGS | 0x04000000 | Clips child windows relative to each other; that is, when a particular child window receives a WM_PAINT message, the WS_CLIPSIBLINGS style clips all other overlapping child windows out of the region of the child window to be updated. If WS_CLIPSIBLINGS is not specified and child windows overlap, it is possible, when drawing within the client area of a child window, to draw within the client area of a neighboring child window.
$WS_DISABLED | 0x08000000 | Creates a window that is initially disabled.
$WS_DLGFRAME | 0x00400000 | Creates a window that has a border of a style typically used with dialog boxes.
$WS_HSCROLL | 0x00100000 | Creates a window that has a horizontal scroll bar.
$WS_MAXIMIZE | 0x01000000 | Creates a window that is initially maximized.
$WS_MAXIMIZEBOX | 0x00010000 | Creates a window that has a maximize button. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU style must also be specified.
$WS_MINIMIZE | 0x20000000 | Creates a window that is initially minimized.
$WS_MINIMIZEBOX | 0x00020000 | Creates a window that has a minimize button. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU style must also be specified.
$WS_OVERLAPPED | 0x00000000 | Creates an overlapped window. An overlapped window has a title bar and a border. Same as the WS_TILED style
$WS_OVERLAPPEDWINDOW | 0x00CF0000 | Creates an overlapped window with the WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles. Same as the WS_TILEDWINDOW style.
$WS_POPUPWINDOW | 0x80880000 | Creates a pop-up window with WS_BORDER, WS_POPUP, and WS_SYSMENU styles. The WS_CAPTION and WS_POPUPWINDOW styles must be combined to make the window menu visible.
$WS_SIZEBOX | 0x00040000 | Creates a window that has a sizing border. Same as the WS_THICKFRAME style.
$WS_SYSMENU | 0x00080000 | Creates a window that has a window menu on its title bar. The WS_CAPTION style must also be specified.
$WS_THICKFRAME | 0x00040000 | Creates a window that has a sizing border. Same as the WS_SIZEBOX style
$WS_VSCROLL | 0x00200000 | Creates a window that has a vertical scroll bar.
$WS_VISIBLE | 0x10000000 | Creates a window that is initially visible.
$WS_CHILD | 0x40000000 | Creates a child window. A window with this style cannot have a menu bar. This style cannot be used with the WS_POPUP style.
$WS_GROUP | 0x00020000 | Specifies the first control of a group of controls. The group consists of this first control and all controls defined after it, up to the next control with the WS_GROUP style.
$WS_TABSTOP | 0x00010000 | Turns the control into a tab stop, which enables the user to select the control by tabbing through the controls in a dialog box.
$DS_MODALFRAME | 0x00000080 | Creates a dialog box with a modal dialog-box frame that can be combined with a title bar and window menu by specifying the WS_CAPTION and WS_SYSMENU styles.
$DS_SETFOREGROUND | 0x00000200 | This style is useful for modal dialog boxes that require immediate attention from the user regardless of whether the owner window is the foreground window.
$DS_CONTEXTHELP | 0x00002000 | Includes a question mark in the title bar of the dialog box. Cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX styles. Same as WS_EX_CONTEXTHELP extended style.

Common Extended Styles | Value | Description
Top |  | #include <WindowsConstants.au3>
$WS_EX_ACCEPTFILES | 0x00000010 | Allow an edit or input control within the created GUI window to receive filenames via drag and drop. The control must have also the $GUI_DROPACCEPTED state set by GUICtrlSetState.
$WS_EX_APPWINDOW | 0x00040000 | Forces a top-level window onto the taskbar when the window is visible.
$WS_EX_COMPOSITED | 0x02000000 | Paints all descendants of a window in bottom-to-top painting order using double-buffering.
$WS_EX_CLIENTEDGE | 0x00000200 | Specifies that a window has a border with a sunken edge.
$WS_EX_CONTEXTHELP | 0x00000400 | Includes a question mark in the title bar of the window. Cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX
$WS_EX_DLGMODALFRAME | 0x00000001 | Creates a window that has a double border; the window can, optionally, be created with a title bar by specifying the WS_CAPTION style in the dwStyle parameter.
$WS_EX_LAYOUTRTL | 0x400000 | Specifies that a window has a layout from right to left (RTL) instead of the standard left to right (LTR).
$WS_EX_MDICHILD | 0x00000040 | Create a child window that will be moved with its parent.(simulation of a MDI window maximize/minimize are not simulated).
$WS_EX_OVERLAPPEDWINDOW | 0x00000300 | Combines the WS_EX_CLIENTEDGE and WS_EX_WINDOWEDGE styles.
$WS_EX_STATICEDGE | 0x00020000 | Creates a window with a three-dimensional border style intended to be used for items that do not accept user input.
$WS_EX_TOPMOST | 0x00000008 | Specifies that a window created with this style should be placed above all non-topmost windows and should stay above them, even when the window is deactivated.
$WS_EX_TRANSPARENT | 0x00000020 | The window appears transparent because the bits of underlying sibling windows have already been painted.
$WS_EX_TOOLWINDOW | 0x00000080 | Creates a tool window; that is, a window intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the taskbar or in the dialog box that appears when the user presses ALT+TAB. If a tool window has a system menu, its icon is not displayed on the title bar. However, you can display the system menu by typing ALT+SPACE.
$WS_EX_WINDOWEDGE | 0x00000100 | Specifies that a window has a border with a raised edge.
$WS_EX_LAYERED | 0x00080000 | Creates a layered window. Note that this cannot be used for child windows.
$GUI_WS_EX_PARENTDRAG | 0x00100000 | Allow the label or pic control to be used as the title bar to drag the whole the parent window. (Needs #include <GUIConstantsEx.au3>)

Checkbox Styles | Value | Description
Top |  | #include <ButtonConstants.au3>
Default/forced |  | See GUICtrlCreateCheckbox function.
$BS_3STATE | 0x0005 | Creates a check box in which the box can be unavailable as well as selected or cleared. Use the unavailable state to show that the state of the check box is not determined.
$BS_AUTO3STATE | 0x0006 | Creates a three-state check box in which the state cycles through selected, unavailable, and cleared each time the user selects the check box.
$BS_AUTOCHECKBOX | 0x0003 | Creates a check box in which the check state switches between selected and cleared each time the user selects the check box.
$BS_CHECKBOX | 0x0002 | Creates a small, empty check box with a label displayed to the right of it. To display the text to the left of the check box, combine this flag with the BS_RIGHTBUTTON style.
$BS_LEFT | 0x0100 | Left-aligns the text in the button rectangle on the right side of the check box.
$BS_PUSHLIKE | 0x1000 | Makes a button (such as a check box, three-state check box, or radio button) look and act like a push button. The button looks raised when it isn't pushed or checked, and sunken when it is pushed or checked.
$BS_RIGHT | 0x0200 | Right-aligns text in the button rectangle on the right side of the check box.
$BS_RIGHTBUTTON | 0x0020 | Positions a check box square on the right side of the button rectangle.
$BS_GROUPBOX | 0x0007 | Creates a rectangle in which other buttons can be grouped. Any text associated with this style is displayed in the rectangle's upper-left corner.
$BS_AUTORADIOBUTTON | 0x0009 | Same as a radio button, except that when the user selects it, the button automatically highlights itself and removes the selection from any other radio buttons with the same style in the same group.

Push Button Styles | Value | Description
Top |  | #include <ButtonConstants.au3>
Default/forced |  | See GUICtrlCreateButton, GUICtrlCreateCheckbox, GUICtrlCreateRadio functions.
$BS_BOTTOM | 0x0800 | Places the text at the bottom of the button rectangle.
$BS_CENTER | 0x0300 | Centers the text horizontally in the button rectangle.
$BS_DEFPUSHBUTTON | 0x0001 | Creates a push button with a heavy black border. If the button is in a dialog box, the user can select the button by pressing the ENTER key, even when the button does not have the input focus. This style is useful for enabling the user to quickly select the most likely option, or default.
$BS_MULTILINE | 0x2000 | Wraps the button text to multiple lines if the text string is too long to fit on a single line in the button rectangle.
$BS_TOP | 0x0400 | Places text at the top of the button rectangle.
$BS_VCENTER | 0x0C00 | Vertically centers text in the button rectangle.
$BS_ICON | 0x0040 | Specifies that the button displays an icon.
$BS_BITMAP | 0x0080 | Specifies that the button displays a bitmap.
$BS_FLAT | 0x8000 | Specifies that the button is two-dimensional; it does not use the default shading to create a 3-D image.
$BS_NOTIFY | 0x4000 | Enables a button to send BN_KILLFOCUS and BN_SETFOCUS notification messages to its parent window. Note that buttons send the BN_CLICKED notification message regardless of whether it has this style. To get BN_DBLCLK notification messages, the button must have the BS_RADIOBUTTON or BS_OWNERDRAW style.

Combo Styles | Value | Description
Top |  | #include <ComboConstants.au3>
Default/forced |  | $GUI_SS_DEFAULT_COMBO see GUICtrlCreateCombo function.
$CBS_AUTOHSCROLL | 0x0040 | Automatically scrolls the text in an edit control to the right when the user types a character at the end of the line. If this style is not set, only text that fits within the rectangular boundary is enabled.
$CBS_DISABLENOSCROLL | 0x0800 | Shows a disabled vertical scroll bar in the list box when the box does not contain enough items to scroll. Without this style, the scroll bar is hidden when the list box does not contain enough items.
$CBS_DROPDOWN | 0x0002 | Displays only the edit control by default. The user can display the list box by selecting an icon next to the edit control.
$CBS_DROPDOWNLIST | 0x0003 | Displays a static text field that displays the current selection in the list box.
$CBS_LOWERCASE | 0x4000 | Converts to lowercase any uppercase characters that are typed into the edit control of a combo box.
$CBS_NOINTEGRALHEIGHT | 0x0400 | Specifies that the combo box will be exactly the size specified by the application when it created the combo box. Usually, Windows CE sizes a combo box so that it does not display partial items.
$CBS_OEMCONVERT | 0x0080 | Converts text typed in the combo box edit control from the Windows CE character set to the OEM character set and then back to the Windows CE set. This style is most useful for combo boxes that contain file names. It applies only to combo boxes created with the CBS_DROPDOWN style.
$CBS_SIMPLE | 0x0001 | Displays the list box at all times. The current selection in the list box is displayed in the edit control.
$CBS_SORT | 0x0100 | Sorts strings that are typed into the list box.
$CBS_UPPERCASE | 0x2000 | Converts to uppercase any lowercase characters that are typed into the edit control of a combo box.

List Styles | Value | Description
Top |  | #include <ListBoxConstants.au3>
Default/forced |  | $GUI_SS_DEFAULT_LIST see GUICtrlCreateList function.
$LBS_DISABLENOSCROLL | 0x1000 | Shows a disabled vertical scroll bar for the list box when the box does not contain enough items to scroll. If you do not specify this style, the scroll bar is hidden when the list box does not contain enough items.
$LBS_NOINTEGRALHEIGHT | 0x0100 | Specifies that the list box will be exactly the size specified by the application when it created the list box.
$LBS_NOSEL | 0x4000 | Specifies that the user can view list box strings but cannot select them.
$LBS_NOTIFY | 0x0001 | Notifies the parent window when the user taps or double-taps a string in the list box.
$LBS_SORT | 0x0002 | Sorts strings in the list box alphabetically.
$LBS_STANDARD | 0xA00003 | Sorts strings in the list box alphabetically. The parent window receives an input message when the user taps or double-taps a string. The list box has borders on all sides. (LBS_NOTIFY | LBS_SORT | WS_VSCROLL | WS_BORDER)
$LBS_USETABSTOPS | 0x0080 | Enables a list box to recognize and expand tab characters when drawing its strings. The default tab positions are 32 dialog box units. A dialog box unit is equal to one-fourth of the current dialog box base-width unit.

Edit/Input Styles | Value | Description
Top |  | #include <EditConstants.au3>
Default/forced |  | $GUI_SS_DEFAULT_EDIT, $GUI_SS_DEFAULT_INPUT see GUICtrlCreateEdit or GUICtrlCreateInput function.
$ES_AUTOHSCROLL | 0x0080 | Automatically scrolls text to the right by 10 characters when the user types a character at the end of the line. When the user presses the ENTER key, the control scrolls all text back to the zero position.
$ES_AUTOVSCROLL | 0x0040 | Scrolls text up one page when the user presses the ENTER key on the last line.
$ES_CENTER | 0x0001 | Centers text in a multiline edit control.
$ES_LOWERCASE | 0x0010 | Converts all characters to lowercase as they are typed into the edit control.
$ES_NOHIDESEL | 0x0100 | Negates the default behavior for an edit control. The default behavior hides the selection when the control loses the input focus and inverts the selection when the control receives the input focus. If you specify ES_NOHIDESEL, the selected text is inverted, even if the control does not have the focus.
$ES_NUMBER | 0x2000 | Accepts into the edit control only digits to be typed.
$ES_OEMCONVERT | 0x0400 | This style is most useful for edit controls that contain file names.
$ES_MULTILINE | 0x0004 | Designates a multiline edit control. The default is a single-line edit control.
$ES_PASSWORD | 0x0020 | Displays an asterisk (*) for each character that is typed into the edit control.
$ES_READONLY | 0x0800 | Prevents the user from typing or editing text in the edit control.
$ES_RIGHT | 0x0002 | Right-aligns text in a multiline edit control.
$ES_UPPERCASE | 0x0008 | Converts all characters to uppercase as they are typed into the edit control.
$ES_WANTRETURN | 0x1000 | Specifies that a carriage return be inserted when the user presses the ENTER key while typing text into a multiline edit control in a dialog box. If you do not specify this style, pressing the ENTER key has the same effect as pressing the dialog box's default push button. This style has no effect on a single-line edit control.

Progress Bar Styles | Value | Description
Top |  | #include <ProgressConstants.au3>
$PBS_MARQUEE | 0x08 | Displays progress status as a scrolling marquee.
$PBS_SMOOTH | 0x01 | Displays progress status in a smooth scrolling bar instead of the default segmented bar. Note This style is supported only in the Windows Classic theme. All other themes won't visually change with or without this style.
$PBS_SMOOTHREVERSE | 0x10 | Displays progress status with a smooth backward transition when changing from a higher value to a lower value. By default, the control will instantly jump to the lower value. Note This style is supported only on Windows Vista or later.
$PBS_VERTICAL | 0x04 | Displays progress status vertically, from bottom to top.

Up-down Styles | Value | Description
Top |  | #include <UpDownConstants.au3>
Default/forced |  | $GUI_SS_DEFAULT_UPDOWN see GUICtrlCreateUpdown function.
$UDS_ALIGNLEFT | 0x08 | Positions the up-down control next to the left edge of the buddy window. The buddy window is moved to the right and its width is decreased to accommodate the width of the up-down control.
$UDS_ALIGNRIGHT | 0x04 | Positions the up-down control next to the right edge of the buddy window. The width of the buddy window is decreased to accommodate the width of the up-down control.
$UDS_ARROWKEYS | 0x20 | Causes the up-down control to process the UP ARROW and DOWN ARROW keys on the keyboard.
$UDS_HORZ | 0x40 | Causes the up-down control's arrows to point left and right instead of up and down.
$UDS_NOTHOUSANDS | 0x80 | Prevents insertion of a thousands separator between every three decimal positions.
$UDS_WRAP | 0x01 | Causes the position to wrap if it is incremented or decremented beyond the end or beginning of the range.

Label/Static Styles | Value | Description
Top |  | #include <StaticConstants.au3>
Default/forced |  | $GUI_SS_DEFAULT_LABEL, $GUI_SS_DEFAULT_ICON, $GUI_SS_DEFAULT_PIC see GUICtrlCreateLabel, GUICtrlCreateIcon, GUICtrlCreatePic functions.
$SS_BLACKFRAME | 0x07 | Specifies a box with a frame around the control that is the same color as the Window Frame. The default Windows color is black. Frame-style static controls do not display text.
$SS_BLACKRECT | 0x04 | Specifies a rectangle filled with the current window frame color. This color is black in the default color scheme. Rectangle-style static controls do not display text.
$SS_CENTER | 0x01 | Specifies a simple rectangle and centers the error value text in the rectangle. The control automatically wraps words that extend past the end of a line to the beginning of the next centered line.
$SS_CENTERIMAGE | 0x0200 | Specifies that the midpoint of a static control with the SS_BITMAP style will remain fixed when you resize the control. The four sides are adjusted to accommodate a new bitmap. If the bitmap is smaller than the control's client area, the rest of the client area is filled with the color of the pixel in the upper-left corner of the bitmap. It can be used with static control having only one line of text. This style bit do not result in unused portions of the control being filled with the color of the top left pixel of the bitmap or icon. Unused portions of the control will remain the background color.
$SS_ETCHEDFRAME | 0x12 | Draws the frame of the static control using the EDGE_ETCHED edge style. Frame-style static controls do not display text.
$SS_ETCHEDHORZ | 0x10 | Draws the top and bottom edges of the static control using the EDGE_ETCHED edge style. Frame-style static controls do not display text.
$SS_ETCHEDVERT | 0x11 | Draws the left and right edges of the static control using the EDGE_ETCHED edge style. Frame-style static controls do not display text.
$SS_GRAYFRAME | 0x08 | Specifies a box with a frame drawn with the same color as the screen background (desktop). This color is gray in the default color scheme. Frame-style static controls do not display text.
$SS_GRAYRECT | 0x05 | Specifies a rectangle filled with the current screen background color. This color is gray in the default color scheme. Rectangle-style static controls do not display text.
$SS_LEFT | 0x0000 | Specifies a simple rectangle and left-aligns the text in the rectangle. The text is formatted before it is displayed. Words that extend past the end of a line are automatically wrapped to the beginning of the next left-aligned line. Words that are longer than the width of the control are truncated.
$SS_LEFTNOWORDWRAP | 0x0C | Specifies a rectangle and left-aligns the text in the rectangle. Tabs are expanded, but words are not wrapped. Text that extends past the end of a line is clipped.
$SS_NOPREFIX | 0x80 | Prevents interpretation of any ampersand (&) characters in the control's text as accelerator prefix characters. An application can combine SS_NOPREFIX with other styles by using the bitwise OR (|) operator. This can be useful when file names or other strings that might contain an ampersand (&) must be displayed within a static control in a dialog box.
$SS_NOTIFY | 0x0100 | Sends the parent window the STN_CLICKED notification when the user clicks the control.
$SS_RIGHT | 0x0002 | Specifies a rectangle and right-aligns the specified text in the rectangle.
$SS_RIGHTJUST | 0x0400 | Specifies that the lower right corner of a static control with the SS_BITMAP or SS_ICON style is to remain fixed when the control is resized. Only the top and left sides are adjusted to accommodate a new bitmap or icon.
$SS_SIMPLE | 0x0B | Specifies a simple rectangle and displays a single line of left-aligned text in the rectangle. The text line cannot be shortened or altered in any way. Also, if the control is disabled, the control does not gray its text.
$SS_SUNKEN | 0x1000 | Draws a half-sunken border around a static control.
$SS_WHITEFRAME | 0x09 | Specifies a box with a frame drawn with the same color as the window background. This color is white in the default color scheme. Frame-style static controls do not display text.
$SS_WHITERECT | 0x06 | Specifies a rectangle filled with the current window background color. This color is white in the default color scheme. Rectangle-style static controls do not display text.

Tab Styles | Value | Description
Top |  | #include <TabConstants.au3>
Default/forced |  | See GUICtrlCreateTab function.
$TCS_SCROLLOPPOSITE | 0x0001 | Unneeded tabs scroll to the opposite side of the control when a tab is selected.
$TCS_BOTTOM | 0x0002 | Tabs appear at the bottom of the control. This value equals TCS_RIGHT. This style is not supported if you use comctl32.dll version 6.
$TCS_RIGHT | 0x0002 | Tabs appear vertically on the right side of controls that use the TCS_VERTICAL style. This value equals TCS_BOTTOM. This style is not supported if you use visual styles.
$TCS_MULTISELECT | 0x0004 | Multiple tabs can be selected by holding down CTRL when clicking. This style must be used with the TCS_BUTTONS style.
$TCS_FLATBUTTONS | 0x0008 | Selected tabs appear as being indented into the background while other tabs appear as being on the same plane as the background. This style only affects tab controls with the TCS_BUTTONS style.
$TCS_FORCEICONLEFT | 0x0010 | Icons are aligned with the left edge of each fixed-width tab. This style can only be used with the TCS_FIXEDWIDTH style.
$TCS_FORCELABELLEFT | 0x0020 | Labels are aligned with the left edge of each fixed-width tab; that is, the label is displayed immediately to the right of the icon instead of being centered. This style can only be used with the TCS_FIXEDWIDTH style, and it implies the TCS_FORCEICONLEFT style.
$TCS_HOTTRACK | 0x0040 | Items under the pointer are automatically highlighted
$TCS_VERTICAL | 0x0080 | Tabs appear at the left side of the control, with tab text displayed vertically. This style is valid only when used with the TCS_MULTILINE style. To make tabs appear on the right side of the control, also use the TCS_RIGHT style. This style is not supported if you use comctl32.dll version 6.
$TCS_TABS | 0x0000 | Tabs appear as tabs, and a border is drawn around the display area. This style is the default.
$TCS_BUTTONS | 0x0100 | Tabs appear as buttons, and no border is drawn around the display area.
$TCS_SINGLELINE | 0x0000 | Only one row of tabs is displayed. The user can scroll to see more tabs, if necessary. This style is the default.
$TCS_MULTILINE | 0x0200 | Multiple rows of tabs are displayed, if necessary, so all tabs are visible at once.
$TCS_RIGHTJUSTIFY | 0x0000 | The width of each tab is increased, if necessary, so that each row of tabs fills the entire width of the tab control. This window style is ignored unless the TCS_MULTILINE style is also specified.
$TCS_FIXEDWIDTH | 0x0400 | All tabs are the same width. This style cannot be combined with the TCS_RIGHTJUSTIFY style.
$TCS_RAGGEDRIGHT | 0x0800 | Rows of tabs will not be stretched to fill the entire width of the control. This style is the default.
$TCS_FOCUSONBUTTONDOWN | 0x1000 | The tab control receives the input focus when clicked.
$TCS_OWNERDRAWFIXED | 0x2000 | The parent window is responsible for drawing tabs.
$TCS_TOOLTIPS | 0x4000 | The tab control has a tooltip control associated with it.
$TCS_FOCUSNEVER | 0x8000 | The tab control does not receive the input focus when clicked.

Avi Clip Styles | Value | Description
Top |  | #include <AVIConstants.au3>
Default/forced |  | $GUI_SS_DEFAULT_AVI see GUICtrlCreateAvi function.
$ACS_AUTOPLAY | 0x04 | Starts playing the animation as soon as the AVI clip is opened.
$ACS_CENTER | 0x01 | Centers the animation in the animation control's window.
$ACS_TRANSPARENT | 0x02 | Allows you to match an animation's background color to that of the underlying window, creating a "transparent" background. (Default value)
$ACS_NONTRANSPARENT | 0x10 | To override default ACS_TRANSPARENT

Date Styles | Value | Description
Top |  | #include <DateTimeConstants.au3>
Default/forced |  | $GUI_SS_DEFAULT_DATE see GUICtrlCreateDate function.
$DTS_UPDOWN | 0x01 | Places an up-down control to the right of a DTP control to modify time values. This style can be used instead of the drop-down month calendar, which is the default style.
$DTS_SHOWNONE | 0x02 | Enables the control to accept "no date" as a valid selection state.
$DTS_LONGDATEFORMAT | 0x04 | Displays the date in long format. The default format string for this style is defined by LOCALE_SLONGDATEFORMAT, which produces output like "Friday, April 19, 1998."
$DTS_TIMEFORMAT | 0x09 | Displays the time. The default format string for this style is defined by LOCALE_STIMEFORMAT, which produces output like "5:31:42 PM."
$DTS_RIGHTALIGN | 0x20 | The drop-down month calendar will be right-aligned with the control instead of left-aligned, which is the default.
$DTS_SHORTDATEFORMAT | 0x00 | Displays the date in short format. The default format string for this style is defined by LOCALE_SSHORTDATE, which produces output like "4/19/96".

MonthCal Styles | Value | Description
Top |  | #include <DateTimeConstants.au3>
Default/forced |  | See GUICtrlCreateMonthCal function.
$MCS_NOTODAY | 0x10 | The month calendar control will not display the "today" date at the bottom of the control.
$MCS_NOTODAYCIRCLE | 0x08 | The month calendar control will not circle the "today" date.
$MCS_WEEKNUMBERS | 0x04 | The month calendar control will display week numbers (1-52) to the left of each row of days. Week 1 is defined as the first week that contains at least four days.

TreeView Styles | Value | Description
Top |  | #include <TreeViewConstants.au3>
Default/forced |  | $GUI_SS_DEFAULT_TREEVIEW see GUICtrlCreateTreeView function.
$TVS_HASBUTTONS | 0x0001 | Displays plus (+) and minus (-) buttons next to parent items. The user clicks the buttons to expand or collapse a parent item's list of child items. To include buttons with items at the root of the tree view, TVS_LINESATROOT must also be specified.
$TVS_HASLINES | 0x0002 | Uses lines to show the hierarchy of items.
$TVS_LINESATROOT | 0x0004 | Uses lines to link items at the root of the tree view control. This value is ignored if TVS_HASLINES is not also specified.
$TVS_DISABLEDRAGDROP | 0x0010 | Prevents the tree view control from sending TVN_BEGINDRAG notification messages.
$TVS_SHOWSELALWAYS | 0x0020 | Causes a selected item to remain selected when the tree view control loses focus.
$TVS_RTLREADING | 0x0040 | Normal windows display text left-to-right (LTR). Windows can be mirrored to display languages such as Hebrew or Arabic that read right-to-left (RTL). Normally, tree view text will be displayed in same direction as the the text in its parent window. If TVS_RTLREADING is set, tree view text will read in the opposite direction from the text in the parent window.
$TVS_NOTOOLTIPS | 0x0080 | The tree view control does not support tooltips.
$TVS_CHECKBOXES | 0x0100 | Enables check boxes for items in a tree-view control. Once a tree-view control is created with this style, the style cannot be removed. Instead, you must destroy the control and create a new one in its place.
$TVS_TRACKSELECT | 0x0200 | Enables hot tracking in a tree view control.
$TVS_SINGLEEXPAND | 0x0400 | When this style is enabled, changing the selection in the tree view will automatically cause the item being selected to expand and the item being unselected to collapse. If the mouse is used to single-click the selected item and that item is closed, it will be expanded. If the user holds the CTRL key down while selecting an item, the item being unselected will not be collapsed.
$TVS_FULLROWSELECT | 0x1000 | Enables full-row selection in the tree view. The entire row of the selected item is highlighted, and clicking anywhere on an item's row will cause it to be selected. This style cannot be used in conjunction with the TVS_HASLINES style.
$TVS_NOSCROLL | 0x2000 | Disables both horizontal and vertical scrolling in the control. The control will not display any scroll bars.
$TVS_NONEVENHEIGHT | 0x4000 | The height of the items can be set to an odd height with the TVM_SETITEMHEIGHT message. By default, the height of items must be an even value.

Slider Styles | Value | Description
Top |  | #include <SliderConstants.au3>
Default/forced |  | $GUI_SS_DEFAULT_SLIDER see GUICtrlCreateSlider function.
$TBS_AUTOTICKS | 0x0001 | Adds tick marks when you set the range on the trackbar by using the TBM_SETRANGE message.
$TBS_BOTH | 0x0008 | Places ticks on both sides of the trackbar.
$TBS_BOTTOM | 0x0000 | Places ticks on the bottom of a horizontal trackbar.
$TBS_HORZ | 0x0000 | Specifies a horizontal trackbar. This is the default.
$TBS_VERT | 0x0002 | Places ticks on the left side of a vertical trackbar.
$TBS_NOTHUMB | 0x0080 | Specifies that the trackbar has no slider.
$TBS_NOTICKS | 0x0010 | Specifies that no ticks are placed on the trackbar.
$TBS_LEFT | 0x0004 | Places ticks on the left side of a vertical trackbar.
$TBS_RIGHT | 0x0000 | Places ticks on the right side of a vertical trackbar.
$TBS_TOP | 0x0004 | Places ticks on the top of a horizontal trackbar.

ListView Styles | Value | Description
Top |  | #include <ListViewConstants.au3>
Default/forced |  | $GUI_SS_DEFAULT_LISTVIEW see GUICtrlCreateListView function.
$LVS_ICON | 0x0000 | This style specifies icon view.
$LVS_REPORT | 0x0001 | This style specifies report view.
$LVS_SMALLICON | 0x0002 | This style specifies small icon view.
$LVS_LIST | 0x0003 | This style specifies list view.
$LVS_EDITLABELS | 0x0200 | Item text can be edited in place.
$LVS_NOCOLUMNHEADER | 0x4000 | Column headers are not displayed in report view. By default, columns have headers in report view.
$LVS_NOSORTHEADER | 0x8000 | Column headers do not work like buttons. This style can be used if clicking a column header in report view does not carry out an action, such as sorting.
$LVS_SINGLESEL | 0x0004 | Only one item at a time can be selected.
$LVS_SHOWSELALWAYS | 0x0008 | The selection, if any, is always shown, even if the control does not have the focus.
$LVS_SORTASCENDING | 0x0010 | Item indices are sorted based on item text in ascending order.
$LVS_SORTDESCENDING | 0x0020 | Item indices are sorted based on item text in descending order.
$LVS_NOLABELWRAP | 0x0080 | Item text is displayed on a single line in icon view. By default, item text may wrap in icon view.

ListView Extended Styles | Value | Description
Top |  | #include <ListViewConstants.au3>
$LVS_EX_FULLROWSELECT | 0x00000020 | When an item is selected, the item and all its subitems are highlighted.
$LVS_EX_GRIDLINES | 0x00000001 | Displays gridlines around items and subitems.
$LVS_EX_HEADERDRAGDROP | 0x00000010 | Enables drag-and-drop reordering of columns in a list view control.
$LVS_EX_TRACKSELECT | 0x00000008 | Enables hot-track selection in a list view control. Hot track selection means that an item is automatically selected when the cursor remains over the item for a certain period of time
$LVS_EX_CHECKBOXES | 0x00000004 | Enables check boxes for items in a list view control.
$LVS_EX_BORDERSELECT | 0x00008000 | If this style is set, when an item is selected the border color of the item changes rather than the item being highlighted.
$LVS_EX_DOUBLEBUFFER | 0x00010000 | Paints via double-buffering, which reduces flicker. This extended style also enables alpha-blended marquee selection on systems where it is supported.
$LVS_EX_FLATSB | 0x00000100 | Enables flat scroll bars in the list view.
$LVS_EX_MULTIWORKAREAS | 0x00002000 | The control will not autoarrange its icons until one or more work areas are defined.
$LVS_EX_SNAPTOGRID | 0x00080000 | In icon view, icons automatically snap into a grid.
$LVS_EX_SUBITEMIMAGES | 0x00000002 | Allows images to be displayed for subitems.
$LVS_EX_INFOTIP | 0x00000400 | Displays a tooltip when the item is not fully visible. Sends a notification message to $LVN_GETINFOTIP


OS Language Values-Codes

@KBLayout, @MUILang, @OSLang values/codes

Possible return values (strings) of @KBLayout, @MUILang, @OSLang

List was generated from "Language Identifier Constants and Strings" in MSDN.

Note: Codes that contain letters could possible have the letters in uppercase.

Hex | Dec | Country code | Meaning
0004 | 4 | zh-CHS | Chinese - Simplified
0401 | 1025 | ar-SA | Arabic - Saudi Arabia
0402 | 1026 | bg-BG | Bulgarian - Bulgaria
0403 | 1027 | ca-ES | Catalan - Spain
0404 | 1028 | zh-TW | Chinese (Traditional) - Taiwan
0405 | 1029 | cs-CZ | Czech - Czech Republic
0406 | 1030 | da-DK | Danish - Denmark
0407 | 1031 | de-DE | German - Germany
0408 | 1032 | el-GR | Greek - Greece
0409 | 1033 | en-US | English - United States
040A | 1034 | es-ES_tradnl | Spanish - Spain
040B | 1035 | fi-FI | Finnish - Finland
040C | 1036 | fr-FR | French - France
040D | 1037 | he-IL | Hebrew - Israel
040E | 1038 | hu-HU | Hungarian - Hungary
040F | 1039 | is-IS | Icelandic - Iceland
0410 | 1040 | it-IT | Italian - Italy
0411 | 1041 | ja-JP | Japanese - Japan
0412 | 1042 | ko-KR | Korean - Korea
0413 | 1043 | nl-NL | Dutch - Netherlands
0414 | 1044 | nb-NO | Norwegian (Bokmål) - Norway
0415 | 1045 | pl-PL | Polish - Poland
0416 | 1046 | pt-BR | Portuguese - Brazil
0417 | 1047 | rm-CH | Romansh - Switzerland
0418 | 1048 | ro-RO | Romanian - Romania
0419 | 1049 | ru-RU | Russian - Russia
041A | 1050 | hr-HR | Croatian - Croatia
041B | 1051 | sk-SK | Slovak - Slovakia
041C | 1052 | sq-AL | Albanian - Albania
041D | 1053 | sv-SE | Swedish - Sweden
041E | 1054 | th-TH | Thai - Thailand
041F | 1055 | tr-TR | Turkish - Turkey
0420 | 1056 | ur-PK | Urdu - Pakistan
0421 | 1057 | id-ID | Indonesian - Indonesia
0422 | 1058 | uk-UA | Ukrainian - Ukraine
0423 | 1059 | be-BY | Belarusian - Belarus
0424 | 1060 | sl-SI | Slovenian - Slovenia
0425 | 1061 | et-EE | Estonian - Estonia
0426 | 1062 | lv-LV | Latvian - Latvia
0427 | 1063 | lt-LT | Lithuanian - Lithuanian
0428 | 1064 | tg-Cyrl-TJ | Tajik (Cyrillic) - Tajikistan
0429 | 1065 | fa-IR | Persian - Iran
042A | 1066 | vi-VN | Vietnamese - Vietnam
042B | 1067 | hy-AM | Armenian - Armenia
042C | 1068 | az-Latn-AZ | Azeri (Latin) - Azerbaijan
042D | 1069 | eu-ES | Basque - Basque
042E | 1070 | hsb-DE | Upper Sorbian - Germany
042F | 1071 | mk-MK | Macedonian - Macedonia
0432 | 1074 | tn-ZA | Setswana / Tswana - South Africa
0434 | 1076 | xh-ZA | isiXhosa - South Africa
0435 | 1077 | zu-ZA | isiZulu - South Africa
0436 | 1078 | af-ZA | Afrikaans - South Africa
0437 | 1079 | ka-GE | Georgian - Georgia
0438 | 1080 | fo-FO | Faroese - Faroe Islands
0439 | 1081 | hi-IN | Hindi - India
043A | 1082 | mt-MT | Maltese - Malta
043B | 1083 | se-NO | Sami (Northern) - Norway
043e | 1086 | ms-MY | Malay - Malaysia
043F | 1087 | kk-KZ | Kazakh - Kazakhstan
0440 | 1088 | ky-KG | Kyrgyz - Kyrgyzstan
0441 | 1089 | sw-KE | Swahili - Kenya
0442 | 1090 | tk-TM | Turkmen - Turkmenistan
0443 | 1091 | uz-Latn-UZ | Uzbek (Latin) - Uzbekistan
0444 | 1092 | tt-RU | Tatar - Russia
0445 | 1093 | bn-IN | Bangla - Bangladesh
0446 | 1094 | pa-IN | Punjabi - India
0447 | 1095 | gu-IN | Gujarati - India
0448 | 1096 | or-IN | Oriya - India
0449 | 1097 | ta-IN | Tamil - India
044A | 1098 | te-IN | Telugu - India
044B | 1099 | kn-IN | Kannada - India
044C | 1100 | ml-IN | Malayalam - India
044D | 1101 | as-IN | Assamese - India
044E | 1102 | mr-IN | Marathi - India
044F | 1103 | sa-IN | Sanskrit - India
0450 | 1104 | mn-MN | Mongolian (Cyrillic) - Mongolia
0451 | 1105 | bo-CN | Tibetan - China
0452 | 1106 | cy-GB | Welsh - United Kingdom
0453 | 1107 | km-KH | Khmer - Cambodia
0454 | 1108 | lo-LA | Lao - Lao PDR
0456 | 1110 | gl-ES | Galician - Spain
0457 | 1111 | kok-IN | Konkani - India
045A | 1114 | syr-SY | Syriac - Syria
045B | 1115 | si-LK | Sinhala - Sri Lanka
045C | 1116 | chr-Cher-US | Cherokee - Cherokee
045D | 1117 | iu-Cans-CA | Inuktitut (Canadian_Syllabics) - Canada
045E | 1118 | am-ET | Amharic - Ethiopia
0461 | 1121 | ne-NP | Nepali - Nepal
0462 | 1122 | fy-NL | Frisian - Netherlands
0463 | 1123 | ps-AF | Pashto - Afghanistan
0464 | 1124 | fil-PH | Filipino - Philippines
0465 | 1125 | dv-MV | Divehi - Maldives
0468 | 1128 | ha-Latn-NG | Hausa - Nigeria
046A | 1130 | yo-NG | Yoruba - Nigeria
046B | 1131 | quz-BO | Quechua - Bolivia
046C | 1132 | nso-ZA | Sesotho sa Leboa - South Africa
046D | 1133 | ba-RU | Bashkir - Russia
046E | 1134 | lb-LU | Luxembourgish - Luxembourg
046F | 1135 | kl-GL | Greenlandic - Greenland
0470 | 1136 | ig-NG | Igbo - Nigeria
0473 | 1139 | ti-ET | Tigrinya - Ethiopia
0475 | 1141 | haw-US | Hawiian - United States
0478 | 1144 | ii-CN | Yi - China
047A | 1146 | arn-CL | Mapudungun - Chile
047C | 1148 | moh-CA | Mohawk - Canada
047E | 1150 | br-FR | Breton - France
0480 | 1152 | ug-CN | Uyghur - China
0481 | 1153 | mi-NZ | Maori - New Zealand
0482 | 1154 | oc-FR | Occitan - France
0483 | 1155 | co-FR | Corsican - France
0484 | 1156 | gsw-FR | Alsatian - France
0485 | 1157 | sah-RU | Sakha - Russia
0486 | 1158 | qut-GT | K'iche - Guatemala
0487 | 1159 | rw-RW | Kinyarwanda - Rwanda
0488 | 1160 | wo-SN | Wolof - Senegal
048C | 1164 | prs-AF | Dari - Afghanistan
0491 | 1169 | gd-GB | Scottish Gaelic - United Kingdom
0492 | 1170 | ku-Arab-IQ | Central Kurdish - Iraq
0801 | 2049 | ar-IQ | Arabic - Iraq
0803 | 2051 | ca-ES-valencia | Valencian - Valencia
0804 | 2052 | zh-CN | Chinese (Simplified) - China
0807 | 2055 | de-CH | German - Switzerland
0809 | 2057 | en-GB | English - United Kingdom
080A | 2058 | es-MX | Spanish - Mexico
080C | 2060 | fr-BE | French - Belgium
0810 | 2064 | it-CH | Italian - Switzerland
0813 | 2067 | nl-BE | Dutch - Belgium
0814 | 2068 | nn-NO | Norwegian (Nynorsk) - Norway
0816 | 2070 | pt-PT | Portuguese - Portugal
081A | 2074 | sr-Latn-CS | Serbian (Latin) - Serbia and Montenegro
081D | 2077 | sv-FI | Swedish - Finland
0820 | 2080 | ur-IN | Urdu - (reserved)
082C | 2092 | az-Cyrl-AZ | Azeri (Cyrillic) - Azerbaijan
082E | 2094 | dsb-DE | Lower Sorbian - Germany
0832 | 2098 | tn-BW | Setswana / Tswana - Botswana
083B | 2107 | se-SE | Sami (Northern) - Sweden
083C | 2108 | ga-IE | Irish - Ireland
083E | 2110 | ms-BN | Malay - Brunei Darassalam
0843 | 2115 | uz-Cyrl-UZ | Uzbek (Cyrillic) - Uzbekistan
0845 | 2117 | bn-BD | Bangla - Bangladesh
0846 | 2118 | pa-Arab-PK | Punjabi - Pakistan
0849 | 2121 | ta-LK | Tamil - Sri Lanka
0850 | 2128 | mn-Mong-CN | Mongolian (Mong) - Mongolia
0859 | 2137 | sd-Arab-PK | Sindhi - Pakistan
085D | 2141 | iu-Latn-CA | Inuktitut (Latin) - Canada
085F | 2143 | tzm-Latn-DZ | Tamazight (Latin) - Algeria
0867 | 2151 | ff-Latn-SN | Pular - Senegal
086B | 2155 | quz-EC | Quechua - Ecuador
0873 | 2163 | ti-ER | (reserved) - (reserved)
0873 | 2163 | ti-ER | Tigrinya - Eritrea
0C01 | 3073 | ar-EG | Arabic - Egypt
0C04 | 3076 | zh-HK | Chinese - Hong Kong SAR
0C07 | 3079 | de-AT | German - Austria
0C09 | 3081 | en-AU | English - Australia
0C0A | 3082 | es-ES | Spanish - Spain
0C0C | 3084 | fr-CA | French - Canada
0C1A | 3098 | sr-Cyrl-CS | Serbian (Cyrillic) - Serbia and Montenegro
0C3B | 3131 | se-FI | Sami (Northern) - Finland
0C6B | 3179 | quz-PE | Quechua - Peru
1001 | 4097 | ar-LY | Arabic - Libya
1004 | 4100 | zh-SG | Chinese - Singapore
1007 | 4103 | de-LU | German - Luxembourg
1009 | 4105 | en-CA | English - Canada
100A | 4106 | es-GT | Spanish - Guatemala
100C | 4108 | fr-CH | French - Switzerland
101A | 4122 | hr-BA | Croatian (Latin) - Bosnia and Herzegovina
103B | 4155 | smj-NO | Sami (Lule) - Norway
105F | 4191 | tzm-Tfng-MA | Central Atlas Tamazight (Tifinagh) - Morocco
1401 | 5121 | ar-DZ | Arabic - Algeria
1404 | 5124 | zh-MO | Chinese - Macao SAR
1407 | 5127 | de-LI | German - Liechtenstein
1409 | 5129 | en-NZ | English - New Zealand
140A | 5130 | es-CR | Spanish - Costa Rica
140C | 5132 | fr-LU | French - Luxembourg
141A | 5146 | bs-Latn-BA | Bosnian (Latin) - Bosnia and Herzegovina
143B | 5179 | smj-SE | Sami (Lule) - Sweden
1801 | 6145 | ar-MA | Arabic - Morocco
1809 | 6153 | en-IE | English - Ireland
180A | 6154 | es-PA | Spanish - Panama
180C | 6156 | fr-MC | French - Monaco
181A | 6170 | sr-Latn-BA | Serbian (Latin) - Bosnia and Herzegovina
183B | 6203 | sma-NO | Sami (Southern) - Norway
1C01 | 7169 | ar-TN | Arabic - Tunisia
1c09 | 7177 | en-ZA | English - South Africa
1C0A | 7178 | es-DO | Spanish - Dominican Republic
1C1A | 7194 | sr-Cyrl-BA | Serbian (Cyrillic) - Bosnia and Herzegovina
1C3B | 7227 | sma-SE | Sami (Southern) - Sweden
2001 | 8193 | ar-OM | Arabic - Oman
2009 | 8201 | en-JM | English - Jamaica
200A | 8202 | es-VE | Spanish - Venezuela
201A | 8218 | bs-Cyrl-BA | Bosnian (Cyrillic) - Bosnia and Herzegovina
203B | 8251 | sms-FI | Sami (Skolt) - Finland
2401 | 9217 | ar-YE | Arabic - Yemen
2409 | 9225 | en-029 | English - Caribbean
240A | 9226 | es-CO | Spanish - Colombia
241A | 9242 | sr-Latn-RS | Serbian (Latin) - Serbia
243B | 9275 | smn-FI | Sami (Inari) - Finland
2801 | 10241 | ar-SY | Arabic - Syria
2809 | 10249 | en-BZ | English - Belize
280A | 10250 | es-PE | Spanish - Peru
281A | 10266 | sr-Cyrl-RS | Serbian (Cyrillic) - Serbia
2C01 | 11265 | ar-JO | Arabic - Jordan
2C09 | 11273 | en-TT | English - Trinidad and Tobago
2C0A | 11274 | es-AR | Spanish - Argentina
2C1A | 11290 | sr-Latn-ME | Serbian (Latin) - Montenegro
3001 | 12289 | ar-LB | Arabic - Lebanon
3009 | 12297 | en-ZW | English - Zimbabwe
300A | 12298 | es-EC | Spanish - Ecuador
301A | 12314 | sr-Cyrl-ME | Serbian (Cyrillic) - Montenegro
3401 | 13313 | ar-KW | Arabic - Kuwait
3409 | 13321 | en-PH | English - Philippines
340A | 13322 | es-CL | Spanish - Chile
3801 | 14337 | ar-AE | Arabic - U.A.E.
380A | 14346 | es-UY | Spanish - Uruguay
3C01 | 15361 | ar-BH | Arabic - Bahrain
3C0A | 15370 | es-PY | Spanish - Paraguay
4001 | 16385 | ar-QA | Arabic - Qatar
4009 | 16393 | en-IN | English - India
400A | 16394 | es-BO | Spanish - Bolivia
4409 | 17417 | en-MY | English - Malaysia
440A | 17418 | es-SV | Spanish - El Salvador
4809 | 18441 | en-SG | English - Singapore
480A | 18442 | es-HN | Spanish - Honduras
4C0A | 19466 | es-NI | Spanish - Nicaragua
500A | 20490 | es-PR | Spanish - Puerto Rico
540A | 21514 | es-US | Spanish - United States
7C04 | 31748 | zh-CHT | Chinese - Traditional

Example

#include <MsgBoxConstants.au3>

MsgBox($MB_SYSTEMMODAL, "", "The language of the OS is: " & _GetLanguage() & " (" & LCIDToLocaleName("0x" & @OSLang) & ")")

; Retrieve the language of the operating system.
Func _GetLanguage()
    ; @OSLang is four characters in length, the first two is the dialect and the remaining two are the language group.
    ; Therefore we only require the language group and therefore select the two right-most characters.
    Switch StringRight(@OSLang, 2)
        Case "07"
            Return "German"
        Case "09"
            Return "English"
        Case "0a"
            Return "Spanish"
        Case "0b"
            Return "Finnish"
        Case "0c"
            Return "French"
        Case "10"
            Return "Italian"
        Case "13"
            Return "Dutch"
        Case "14"
            Return "Norwegian"
        Case "15"
            Return "Polish"
        Case "16"
            Return "Portuguese"
        Case "1d"
            Return "Swedish"

        Case Else
            Return "Other (can't determine with @OSLang directly)"

    EndSwitch
EndFunc   ;==>_GetLanguage

Func LCIDToLocaleName($iLCID)
    Local $aRet = DllCall("kernel32.dll", "int", "LCIDToLocaleName", "int", $iLCID, "wstr", "", "int", 85, "dword", 0)
    Return $aRet[2]
EndFunc   ;==>LCIDToLocaleName


Send Key list

Quick reference for the Send( "keys" [, flag] ) Command. ^ Ctrl ! Alt + Shift # Win

AutoIt can send all ASCII and Extended ASCII characters (0-255), to send UNICODE characters you must use the "ASC" option and the code of the character you wish to Send(see {ASC} below).

To send the ASCII value A (same as pressing ALT+065 on the numeric keypad)

Send ("{ASC 065}")

(When using 2 digit ASCII codes you must use a leading 0, otherwise an obsolete 437 code page is used).

To send UNICODE characters enter the character code, for example this sends a Chinese character

Send ("{ASC 2709}")

Single keys can also be repeated, e.g.

Send ("{DEL 4}") ; Presses the DEL key 4 times
Send ("{S 30}") ; Sends 30 'S' characters
Send ("+{TAB 4}") ; Presses Shift + Tab 4 times

To hold a key down

Send ("{a down}") ; Holds the A key down
Send ("{a up}") ; Releases the A key

If you with to use a variable for the count, try

Local $iCount = 4
Send ("+{TAB " & $iCount & "}")

If you wish to send the ASCII value A four times, then try

Local $iChr = Chr (65)
Send ("{" & $iChr & " 4}")

Most laptop computer keyboards have a special Fn key. This key cannot be simulated.

Note, by setting the flag parameter to 1 the "keys" parameter is sent RAW. This is useful when you want to send some text copied from a variable and you want the text sent exactly as written.

Send is quite useful because windows can be navigated without needing a mouse.

For example, open Folder Options (in the control panel) and try the following:

Send("{TAB}") | Navigate to next control (button, checkbox, etc)
Send("+{TAB}") | Navigate to previous control.
Send("^{TAB}") | Navigate to next WindowTab (on a Tabbed dialog window)
Send("^+{TAB}") | Navigate to previous WindowTab.
Send("{SPACE}") | Can be used to toggle a checkbox or click a button.
Send("{+}") | Usually checks a checkbox (if it's a "real" checkbox.)
Send("{-}") | Usually unchecks a checkbox.
Send("{NumPadMult}") | Recursively expands folders in a SysTreeView32.

Use Alt-key combos to access menu items. Also, open Notepad and try the following:

Send("!f") | Send Alt+f, the access key for Notepad's file menu. Try other letters!
Send("{DOWN}") | Move down a menu.
Send("{UP}") | Move up a menu.
Send("{LEFT}") | Move leftward to new menu or expand a submenu.
Send("{RIGHT}") | Move rightward to new menu or collapse a submenu.

See Windows' Help--press Win+F1--for a complete list of keyboard shortcuts if you don't know the importance of Alt+F4, PrintScreen, Ctrl+C, and so on.

Send Command (if zero flag) | Resulting Keypress
{!} | !
{#} | #
{+} | +
{^} | ^
{{} | {
{}} | }
{SPACE} | SPACE
{ENTER} | ENTER key on the main keyboard
{ALT} | ALT
{BACKSPACE} or {BS} | BACKSPACE
{DELETE} or {DEL} | DELETE
{UP} | Up arrow
{DOWN} | Down arrow
{LEFT} | Left arrow
{RIGHT} | Right arrow
{HOME} | HOME
{END} | END
{ESCAPE} or {ESC} | ESCAPE
{INSERT} or {INS} | INS
{PGUP} | PGUP
{PGDN} | PGDN
{F1} - {F12} | Function keys
{TAB} | TAB
{PRINTSCREEN} | PRINTSCR
{LWIN} | Left Windows key
{RWIN} | Right Windows key
{NUMLOCK} | NUMLOCK
{CAPSLOCK} | CAPSLOCK
{SCROLLLOCK} | SCROLLLOCK
{BREAK} | for Ctrl+Break processing
{PAUSE} | PAUSE
{NUMPAD0} - {NUMPAD9} | Numpad digits
{NUMPADMULT} | Numpad Multiply
{NUMPADADD} | Numpad Add
{NUMPADSUB} | Numpad Subtract
{NUMPADDIV} | Numpad Divide
{NUMPADDOT} | Numpad period
{NUMPADENTER} | Enter key on the numpad
{APPSKEY} | Windows App key
{LALT} | Left ALT key
{RALT} | Right ALT key
{LCTRL} | Left CTRL key
{RCTRL} | Right CTRL key
{LSHIFT} | Left Shift key
{RSHIFT} | Right Shift key
{SLEEP} | Computer SLEEP key
{ALTDOWN} | Holds the ALT key down until {ALTUP} is sent
{SHIFTDOWN} | Holds the SHIFT key down until {SHIFTUP} is sent
{CTRLDOWN} | Holds the CTRL key down until {CTRLUP} is sent
{LWINDOWN} | Holds the left Windows key down until {LWINUP} is sent
{RWINDOWN} | Holds the right Windows key down until {RWINUP} is sent
{ASC nnnn} | Send the ALT+nnnn key combination
{BROWSER_BACK} | Select the browser "back" button
{BROWSER_FORWARD} | Select the browser "forward" button
{BROWSER_REFRESH} | Select the browser "refresh" button
{BROWSER_STOP} | Select the browser "stop" button
{BROWSER_SEARCH} | Select the browser "search" button
{BROWSER_FAVORITES} | Select the browser "favorites" button
{BROWSER_HOME} | Launch the browser and go to the home page
{VOLUME_MUTE} | Mute the volume
{VOLUME_DOWN} | Reduce the volume
{VOLUME_UP} | Increase the volume
{MEDIA_NEXT} | Select next track in media player
{MEDIA_PREV} | Select previous track in media player
{MEDIA_STOP} | Stop media player
{MEDIA_PLAY_PAUSE} | Play/pause media player
{LAUNCH_MAIL} | Launch the email application
{LAUNCH_MEDIA} | Launch media player
{LAUNCH_APP1} | Launch user app1
{LAUNCH_APP2} | Launch user app2
{OEM_102} | Either the angle bracket key or the backslash key on the RT 102-key keyboard to be used at least for Hungarian keyboard for "Í" or "í"


Standard Windows Fonts

Click on the column headers to see a list of standard fonts that are installed with that version of Windows.
Recommend Fonts are highlighted in yellow.

Font Name | WinXP | Vista | Win7 | Win8
Monospaced Fonts |  |  |  |
Consolas |  | x | x | x
Courier | x | x | x | x
Courier New | x | x | x | x
Lucida Console | x | x | x | x
Symbol Fonts |  |  |  |
Cambria Math |  | x | x | x
Marlett | x | x | x | x
Segoe UI Symbol |  |  | x | x
Symbol | x | x | x | x
Webdings | x | x | x | x
Wingdings | x | x | x | x
Proportional Fonts |  |  |  |
Arial | x | x | x | x
Arial Black | x | x | x | x
Calibri |  | x | x | x
Cambria |  | x | x | x
Candara |  | x | x | x
Comic Sans MS | x | x | x | x
Constantia |  | x | x | x
Corbel |  | x | x | x
Estrangelo Edessa | x | x | x | x
Franklin Gothic Medium | x | x | x | x
Gabriola |  |  | x | x
Gautami | x | x | x | x
Georgia | x | x | x | x
Impact | x | x | x | x
Latha | x | x | x | x
Lucida Sans Unicode | x | x | x | x
Modern | x | x | x | x
MS Sans Serif | x | x | x | x
MS Serif | x | x | x | x
MV Boli | x | x | x | x
Myanmar Text |  |  |  | x
Nyala |  | x | x | x
Palatino Linotype | x | x | x | x
Plantagenet Cherokee |  | x | x | x
Roman | x | x | x | x
Script | x | x | x | x
Segoe Print |  | x | x | x
Segoe Script |  | x | x | x
Segoe UI |  | x | x | x
Small Fonts | x | x | x | x
Sylfaen | x | x | x | x
Tahoma | x | x | x | x
Times New Roman | x | x | x | x
Trebuchet MS | x | x | x | x
Tunga | x | x | x | x
Verdana | x | x | x | x


Windows Message Codes

Message (sorted by name) | Code | Code | Message (sorted by code)
WM_ACTIVATE | 0x0006 | 0x0000 | WM_NULL
WM_ACTIVATEAPP | 0x001C | 0x0001 | WM_CREATE
WM_AFXFIRST | 0x0360 | 0x0002 | WM_DESTROY
WM_AFXLAST | 0x037F | 0x0003 | WM_MOVE
WM_APP | 0x8000 | 0x0005 | WM_SIZE
WM_APPCOMMAND | 0x0319 | 0x0006 | WM_ACTIVATE
WM_ASKCBFORMATNAME | 0x030C | 0x0007 | WM_SETFOCUS
WM_CANCELJOURNAL | 0x004B | 0x0008 | WM_KILLFOCUS
WM_CANCELMODE | 0x001F | 0x000A | WM_ENABLE
WM_CAPTURECHANGED | 0x0215 | 0x000B | WM_SETREDRAW
WM_CHANGECBCHAIN | 0x030D | 0x000C | WM_SETTEXT
WM_CHANGEUISTATE | 0x0127 | 0x000D | WM_GETTEXT
WM_CHAR | 0x0102 | 0x000E | WM_GETTEXTLENGTH
WM_CHARTOITEM | 0x002F | 0x000F | WM_PAINT
WM_CHILDACTIVATE | 0x0022 | 0x0010 | WM_CLOSE
WM_CLEAR | 0x0303 | 0x0011 | WM_QUERYENDSESSION
WM_CLOSE | 0x0010 | 0x0013 | WM_QUERYOPEN
WM_COMMAND | 0x0111 | 0x0016 | WM_ENDSESSION
WM_COMMNOTIFY | 0x0044 | 0x0012 | WM_QUIT
WM_COMPACTING | 0x0041 | 0x0014 | WM_ERASEBKGND
WM_COMPAREITEM | 0x0039 | 0x0015 | WM_SYSCOLORCHANGE
WM_CONTEXTMENU | 0x007B | 0x0018 | WM_SHOWWINDOW
WM_COPY | 0x0301 | 0x001A | WM_WININICHANGE
WM_COPYDATA | 0x004A | 0x001A | WM_SETTINGCHANGE
WM_CREATE | 0x0001 | 0x001B | WM_DEVMODECHANGE
WM_CTLCOLORBTN | 0x0135 | 0x001C | WM_ACTIVATEAPP
WM_CTLCOLORDLG | 0x0136 | 0x001D | WM_FONTCHANGE
WM_CTLCOLOREDIT | 0x0133 | 0x001E | WM_TIMECHANGE
WM_CTLCOLORLISTBOX | 0x0134 | 0x001F | WM_CANCELMODE
WM_CTLCOLORMSGBOX | 0x0132 | 0x0020 | WM_SETCURSOR
WM_CTLCOLORSCROLLBAR | 0x0137 | 0x0021 | WM_MOUSEACTIVATE
WM_CTLCOLORSTATIC | 0x0138 | 0x0022 | WM_CHILDACTIVATE
WM_CUT | 0x0300 | 0x0023 | WM_QUEUESYNC
WM_DEADCHAR | 0x0103 | 0x0024 | WM_GETMINMAXINFO
WM_DELETEITEM | 0x002D | 0x0026 | WM_PAINTICON
WM_DESTROY | 0x0002 | 0x0027 | WM_ICONERASEBKGND
WM_DESTROYCLIPBOARD | 0x0307 | 0x0028 | WM_NEXTDLGCTL
WM_DEVICECHANGE | 0x0219 | 0x002A | WM_SPOOLERSTATUS
WM_DEVMODECHANGE | 0x001B | 0x002B | WM_DRAWITEM
WM_DISPLAYCHANGE | 0x007E | 0x002C | WM_MEASUREITEM
WM_DRAWCLIPBOARD | 0x0308 | 0x002D | WM_DELETEITEM
WM_DRAWITEM | 0x002B | 0x002E | WM_VKEYTOITEM
WM_DROPFILES | 0x0233 | 0x002F | WM_CHARTOITEM
WM_ENABLE | 0x000A | 0x0030 | WM_SETFONT
WM_ENDSESSION | 0x0016 | 0x0031 | WM_GETFONT
WM_ENTERIDLE | 0x0121 | 0x0032 | WM_SETHOTKEY
WM_ENTERMENULOOP | 0x0211 | 0x0033 | WM_GETHOTKEY
WM_ENTERSIZEMOVE | 0x0231 | 0x0037 | WM_QUERYDRAGICON
WM_ERASEBKGND | 0x0014 | 0x0039 | WM_COMPAREITEM
WM_EXITMENULOOP | 0x0212 | 0x003D | WM_GETOBJECT
WM_EXITSIZEMOVE | 0x0232 | 0x0041 | WM_COMPACTING
WM_FONTCHANGE | 0x001D | 0x0044 | WM_COMMNOTIFY
WM_GETDLGCODE | 0x0087 | 0x0046 | WM_WINDOWPOSCHANGING
WM_GETFONT | 0x0031 | 0x0047 | WM_WINDOWPOSCHANGED
WM_GETHOTKEY | 0x0033 | 0x0048 | WM_POWER
WM_GETICON | 0x007F | 0x004A | WM_COPYDATA
WM_GETMINMAXINFO | 0x0024 | 0x004B | WM_CANCELJOURNAL
WM_GETOBJECT | 0x003D | 0x004E | WM_NOTIFY
WM_GETTEXT | 0x000D | 0x0050 | WM_INPUTLANGCHANGEREQUEST
WM_GETTEXTLENGTH | 0x000E | 0x0051 | WM_INPUTLANGCHANGE
WM_HANDHELDFIRST | 0x0358 | 0x0052 | WM_TCARD
WM_HANDHELDLAST | 0x035F | 0x0053 | WM_HELP
WM_HELP | 0x0053 | 0x0054 | WM_USERCHANGED
WM_HOTKEY | 0x0312 | 0x0055 | WM_NOTIFYFORMAT
WM_HSCROLL | 0x0114 | 0x007B | WM_CONTEXTMENU
WM_HSCROLLCLIPBOARD | 0x030E | 0x007C | WM_STYLECHANGING
WM_ICONERASEBKGND | 0x0027 | 0x007D | WM_STYLECHANGED
WM_IME_CHAR | 0x0286 | 0x007E | WM_DISPLAYCHANGE
WM_IME_COMPOSITION | 0x010F | 0x007F | WM_GETICON
WM_IME_COMPOSITIONFULL | 0x0284 | 0x0080 | WM_SETICON
WM_IME_CONTROL | 0x0283 | 0x0081 | WM_NCCREATE
WM_IME_ENDCOMPOSITION | 0x010E | 0x0082 | WM_NCDESTROY
WM_IME_KEYDOWN | 0x0290 | 0x0083 | WM_NCCALCSIZE
WM_IME_KEYLAST | 0x010F | 0x0084 | WM_NCHITTEST
WM_IME_KEYUP | 0x0291 | 0x0085 | WM_NCPAINT
WM_IME_NOTIFY | 0x0282 | 0x0086 | WM_NCACTIVATE
WM_IME_REQUEST | 0x0288 | 0x0087 | WM_GETDLGCODE
WM_IME_SELECT | 0x0285 | 0x0088 | WM_SYNCPAINT
WM_IME_SETCONTEXT | 0x0281 | 0x00A0 | WM_NCMOUSEMOVE
WM_IME_STARTCOMPOSITION | 0x010D | 0x00A1 | WM_NCLBUTTONDOWN
WM_INITDIALOG | 0x0110 | 0x00A2 | WM_NCLBUTTONUP
WM_INITMENU | 0x0116 | 0x00A3 | WM_NCLBUTTONDBLCLK
WM_INITMENUPOPUP | 0x0117 | 0x00A4 | WM_NCRBUTTONDOWN
WM_INPUT | 0x00FF | 0x00A5 | WM_NCRBUTTONUP
WM_INPUTLANGCHANGE | 0x0051 | 0x00A6 | WM_NCRBUTTONDBLCLK
WM_INPUTLANGCHANGEREQUEST | 0x0050 | 0x00A7 | WM_NCMBUTTONDOWN
WM_KEYDOWN | 0x0100 | 0x00A8 | WM_NCMBUTTONUP
WM_KEYFIRST | 0x0100 | 0x00A9 | WM_NCMBUTTONDBLCLK
WM_KEYLAST | 0x0109 | 0x00AB | WM_NCXBUTTONDOWN
WM_KEYUP | 0x0101 | 0x00AC | WM_NCXBUTTONUP
WM_KILLFOCUS | 0x0008 | 0x00AD | WM_NCXBUTTONDBLCLK
WM_LBUTTONDBLCLK | 0x0203 | 0x00FF | WM_INPUT
WM_LBUTTONDOWN | 0x0201 | 0x0100 | WM_KEYFIRST
WM_LBUTTONUP | 0x0202 | 0x0100 | WM_KEYDOWN
WM_MBUTTONDBLCLK | 0x0209 | 0x0101 | WM_KEYUP
WM_MBUTTONDOWN | 0x0207 | 0x0102 | WM_CHAR
WM_MBUTTONUP | 0x0208 | 0x0103 | WM_DEADCHAR
WM_MDIACTIVATE | 0x0222 | 0x0104 | WM_SYSKEYDOWN
WM_MDICASCADE | 0x0227 | 0x0105 | WM_SYSKEYUP
WM_MDICREATE | 0x0220 | 0x0106 | WM_SYSCHAR
WM_MDIDESTROY | 0x0221 | 0x0107 | WM_SYSDEADCHAR
WM_MDIGETACTIVE | 0x0229 | 0x0109 | WM_KEYLAST
WM_MDIICONARRANGE | 0x0228 | 0x0109 | WM_UNICHAR
WM_MDIMAXIMIZE | 0x0225 | 0x010D | WM_IME_STARTCOMPOSITION
WM_MDINEXT | 0x0224 | 0x010E | WM_IME_ENDCOMPOSITION
WM_MDIREFRESHMENU | 0x0234 | 0x010F | WM_IME_COMPOSITION
WM_MDIRESTORE | 0x0223 | 0x010F | WM_IME_KEYLAST
WM_MDISETMENU | 0x0230 | 0x0110 | WM_INITDIALOG
WM_MDITILE | 0x0226 | 0x0111 | WM_COMMAND
WM_MEASUREITEM | 0x002C | 0x0112 | WM_SYSCOMMAND
WM_MENUCHAR | 0x0120 | 0x0113 | WM_TIMER
WM_MENUCOMMAND | 0x0126 | 0x0114 | WM_HSCROLL
WM_MENUDRAG | 0x0123 | 0x0115 | WM_VSCROLL
WM_MENUGETOBJECT | 0x0124 | 0x0116 | WM_INITMENU
WM_MENURBUTTONUP | 0x0122 | 0x0117 | WM_INITMENUPOPUP
WM_MENUSELECT | 0x011F | 0x011F | WM_MENUSELECT
WM_MOUSEACTIVATE | 0x0021 | 0x0120 | WM_MENUCHAR
WM_MOUSEFIRST | 0x0200 | 0x0121 | WM_ENTERIDLE
WM_MOUSEHOVER | 0x02A1 | 0x0122 | WM_MENURBUTTONUP
WM_MOUSELAST(2K,XP,2k3) | 0x020D | 0x0123 | WM_MENUDRAG
WM_MOUSELAST(95) | 0x0209 | 0x0124 | WM_MENUGETOBJECT
WM_MOUSELAST(NT4,98) | 0x020A | 0x0125 | WM_UNINITMENUPOPUP
WM_MOUSELEAVE | 0x02A3 | 0x0126 | WM_MENUCOMMAND
WM_MOUSEMOVE | 0x0200 | 0x0127 | WM_CHANGEUISTATE
WM_MOUSEWHEEL | 0x020A | 0x0128 | WM_UPDATEUISTATE
WM_MOVE | 0x0003 | 0x0129 | WM_QUERYUISTATE
WM_MOVING | 0x0216 | 0x0132 | WM_CTLCOLORMSGBOX
WM_NCACTIVATE | 0x0086 | 0x0133 | WM_CTLCOLOREDIT
WM_NCCALCSIZE | 0x0083 | 0x0134 | WM_CTLCOLORLISTBOX
WM_NCCREATE | 0x0081 | 0x0135 | WM_CTLCOLORBTN
WM_NCDESTROY | 0x0082 | 0x0136 | WM_CTLCOLORDLG
WM_NCHITTEST | 0x0084 | 0x0137 | WM_CTLCOLORSCROLLBAR
WM_NCLBUTTONDBLCLK | 0x00A3 | 0x0138 | WM_CTLCOLORSTATIC
WM_NCLBUTTONDOWN | 0x00A1 | 0x0200 | WM_MOUSEFIRST
WM_NCLBUTTONUP | 0x00A2 | 0x0200 | WM_MOUSEMOVE
WM_NCMBUTTONDBLCLK | 0x00A9 | 0x0201 | WM_LBUTTONDOWN
WM_NCMBUTTONDOWN | 0x00A7 | 0x0202 | WM_LBUTTONUP
WM_NCMBUTTONUP | 0x00A8 | 0x0203 | WM_LBUTTONDBLCLK
WM_NCMOUSEHOVER | 0x02A0 | 0x0204 | WM_RBUTTONDOWN
WM_NCMOUSELEAVE | 0x02A2 | 0x0205 | WM_RBUTTONUP
WM_NCMOUSEMOVE | 0x00A0 | 0x0206 | WM_RBUTTONDBLCLK
WM_NCPAINT | 0x0085 | 0x0207 | WM_MBUTTONDOWN
WM_NCRBUTTONDBLCLK | 0x00A6 | 0x0208 | WM_MBUTTONUP
WM_NCRBUTTONDOWN | 0x00A4 | 0x0209 | WM_MBUTTONDBLCLK
WM_NCRBUTTONUP | 0x00A5 | 0x0209 | WM_MOUSELAST(95)
WM_NCXBUTTONDBLCLK | 0x00AD | 0x020A | WM_MOUSEWHEEL
WM_NCXBUTTONDOWN | 0x00AB | 0x020A | WM_MOUSELAST(NT4,98)
WM_NCXBUTTONUP | 0x00AC | 0x020B | WM_XBUTTONDOWN
WM_NEXTDLGCTL | 0x0028 | 0x020C | WM_XBUTTONUP
WM_NEXTMENU | 0x0213 | 0x020D | WM_XBUTTONDBLCLK
WM_NOTIFY | 0x004E | 0x020D | WM_MOUSELAST(2K,XP,2k3)
WM_NOTIFYFORMAT | 0x0055 | 0x0210 | WM_PARENTNOTIFY
WM_NULL | 0x0000 | 0x0211 | WM_ENTERMENULOOP
WM_PAINT | 0x000F | 0x0212 | WM_EXITMENULOOP
WM_PAINTCLIPBOARD | 0x0309 | 0x0213 | WM_NEXTMENU
WM_PAINTICON | 0x0026 | 0x0214 | WM_SIZING
WM_PALETTECHANGED | 0x0311 | 0x0215 | WM_CAPTURECHANGED
WM_PALETTEISCHANGING | 0x0310 | 0x0216 | WM_MOVING
WM_PARENTNOTIFY | 0x0210 | 0x0218 | WM_POWERBROADCAST
WM_PASTE | 0x0302 | 0x0219 | WM_DEVICECHANGE
WM_PENWINFIRST | 0x0380 | 0x0220 | WM_MDICREATE
WM_PENWINLAST | 0x038F | 0x0221 | WM_MDIDESTROY
WM_POWER | 0x0048 | 0x0222 | WM_MDIACTIVATE
WM_POWERBROADCAST | 0x0218 | 0x0223 | WM_MDIRESTORE
WM_PRINT | 0x0317 | 0x0224 | WM_MDINEXT
WM_PRINTCLIENT | 0x0318 | 0x0225 | WM_MDIMAXIMIZE
WM_QUERYDRAGICON | 0x0037 | 0x0226 | WM_MDITILE
WM_QUERYENDSESSION | 0x0011 | 0x0227 | WM_MDICASCADE
WM_QUERYNEWPALETTE | 0x030F | 0x0228 | WM_MDIICONARRANGE
WM_QUERYOPEN | 0x0013 | 0x0229 | WM_MDIGETACTIVE
WM_QUERYUISTATE | 0x0129 | 0x0230 | WM_MDISETMENU
WM_QUEUESYNC | 0x0023 | 0x0231 | WM_ENTERSIZEMOVE
WM_QUIT | 0x0012 | 0x0232 | WM_EXITSIZEMOVE
WM_RBUTTONDBLCLK | 0x0206 | 0x0233 | WM_DROPFILES
WM_RBUTTONDOWN | 0x0204 | 0x0234 | WM_MDIREFRESHMENU
WM_RBUTTONUP | 0x0205 | 0x0281 | WM_IME_SETCONTEXT
WM_RENDERALLFORMATS | 0x0306 | 0x0282 | WM_IME_NOTIFY
WM_RENDERFORMAT | 0x0305 | 0x0283 | WM_IME_CONTROL
WM_SETCURSOR | 0x0020 | 0x0284 | WM_IME_COMPOSITIONFULL
WM_SETFOCUS | 0x0007 | 0x0285 | WM_IME_SELECT
WM_SETFONT | 0x0030 | 0x0286 | WM_IME_CHAR
WM_SETHOTKEY | 0x0032 | 0x0288 | WM_IME_REQUEST
WM_SETICON | 0x0080 | 0x0290 | WM_IME_KEYDOWN
WM_SETREDRAW | 0x000B | 0x0291 | WM_IME_KEYUP
WM_SETTEXT | 0x000C | 0x02A1 | WM_MOUSEHOVER
WM_SETTINGCHANGE | 0x001A | 0x02A3 | WM_MOUSELEAVE
WM_SHOWWINDOW | 0x0018 | 0x02A0 | WM_NCMOUSEHOVER
WM_SIZE | 0x0005 | 0x02A2 | WM_NCMOUSELEAVE
WM_SIZECLIPBOARD | 0x030B | 0x02B1 | WM_WTSSESSION_CHANGE
WM_SIZING | 0x0214 | 0x02C0 | WM_TABLET_FIRST
WM_SPOOLERSTATUS | 0x002A | 0x02DF | WM_TABLET_LAST
WM_STYLECHANGED | 0x007D | 0x0300 | WM_CUT
WM_STYLECHANGING | 0x007C | 0x0301 | WM_COPY
WM_SYNCPAINT | 0x0088 | 0x0302 | WM_PASTE
WM_SYSCHAR | 0x0106 | 0x0303 | WM_CLEAR
WM_SYSCOLORCHANGE | 0x0015 | 0x0304 | WM_UNDO
WM_SYSCOMMAND | 0x0112 | 0x0305 | WM_RENDERFORMAT
WM_SYSDEADCHAR | 0x0107 | 0x0306 | WM_RENDERALLFORMATS
WM_SYSKEYDOWN | 0x0104 | 0x0307 | WM_DESTROYCLIPBOARD
WM_SYSKEYUP | 0x0105 | 0x0308 | WM_DRAWCLIPBOARD
WM_TABLET_FIRST | 0x02C0 | 0x0309 | WM_PAINTCLIPBOARD
WM_TABLET_LAST | 0x02DF | 0x030A | WM_VSCROLLCLIPBOARD
WM_TCARD | 0x0052 | 0x030B | WM_SIZECLIPBOARD
WM_THEMECHANGED | 0x031A | 0x030C | WM_ASKCBFORMATNAME
WM_TIMECHANGE | 0x001E | 0x030D | WM_CHANGECBCHAIN
WM_TIMER | 0x0113 | 0x030E | WM_HSCROLLCLIPBOARD
WM_UNDO | 0x0304 | 0x030F | WM_QUERYNEWPALETTE
WM_UNICHAR | 0x0109 | 0x0310 | WM_PALETTEISCHANGING
WM_UNINITMENUPOPUP | 0x0125 | 0x0311 | WM_PALETTECHANGED
WM_UPDATEUISTATE | 0x0128 | 0x0312 | WM_HOTKEY
WM_USER | 0x0400 | 0x0317 | WM_PRINT
WM_USERCHANGED | 0x0054 | 0x0318 | WM_PRINTCLIENT
WM_VKEYTOITEM | 0x002E | 0x0319 | WM_APPCOMMAND
WM_VSCROLL | 0x0115 | 0x031A | WM_THEMECHANGED
WM_VSCROLLCLIPBOARD | 0x030A | 0x0358 | WM_HANDHELDFIRST
WM_WINDOWPOSCHANGED | 0x0047 | 0x035F | WM_HANDHELDLAST
WM_WINDOWPOSCHANGING | 0x0046 | 0x0360 | WM_AFXFIRST
WM_WININICHANGE | 0x001A | 0x037F | WM_AFXLAST
WM_WTSSESSION_CHANGE | 0x02B1 | 0x0380 | WM_PENWINFIRST
WM_XBUTTONDBLCLK | 0x020D | 0x038F | WM_PENWINLAST
WM_XBUTTONDOWN | 0x020B | 0x0400 | WM_USER
WM_XBUTTONUP | 0x020C | 0x8000 | WM_APP


AutoIt

Credits

Forum names are used where available.

AutoIt v3 Coding

Active Authors

  • Jonathan Bennett <Jon>

Inactive Authors

  • Dragana R. <trancexx>
  • Jason Boggs <Valik>
  • Jean-Paul Mesnage <jpm>
  • Dave Fulgham <DaveF>
  • Larry Keys <LarryDalooza>
  • Holger Kotsch <Holger>
  • David Nuttall <Nutster>
  • Sven P <SvenP>
  • Tylo <Tylo>

Documentation and UDF Libraries

  • Many of the above authors, as well as those documented in the UDF Libraries
  • The authors as documented in the include files themselves
  • Gary Frost <GaryFrost>
  • guinness
  • Philip Gump <CyberSlug>
  • Brian Keene
  • Jeremy Landes <jlandes>
  • Mat
  • J-Paul Mesnage <jpm>
  • Alexander Samuelsson <AdmiralAlkex>
  • ScriptKitty
  • water
  • Jos van der Zande <Jos>
  • Melba23
  • Florian Bailly <FireFox>
  • James Brooks <James>
  • Michał Lipok <mLipok>
  • Yashied
  • Eukalyptus

SciTE4AutoIt

  • Jos van der Zande <Jos>

Au3Check

Created by Tylo.

  • Tylo
  • Jos van der Zande <Jos>

Special Thanks

  • Everyone who continues to use and support AutoIt
  • The authors of UPX which is used for creating compressed executables produced by AutoIt


History

IMPORTANT: See here for recent script-breaking changes.

Here is the summarized history of the changes to AutoIt v3.

(For the complete technical history click here. For the complete history including all changes between beta versions click here.)

3.3.14.0 (10th July, 2015) (Release)

AutoIt:

  • Changed: Minimum OS requirements are now Windows XP SP3 and Windows Server 2003 SP2.
  • Changed: PCRE regular expression engine updated to 8.35.
  • Changed: Default text file encoding changed to UTF8 without BOM.
  • Changed: FileOpen() has new modes for forcing ANSI, UTF16-BE/LE without BOM.
  • Added #2761: AutoIt.chm title version.
  • Added #2365: FileFindNextFile() - information in @extended.
  • Added #2647: Return the line count from FileReadToArray() in @extended.
  • Added #2665: FileCopy() no longer fails when copying EFS files to destinations that don't support encryption.
  • Added #2686: Random() to return max value when min equals max.
  • Added #2346: FileSetEnd().
  • Added: Regular expression caching. Small performance improvements when using the same pattern multiple times.
  • Added: Constants for native Functions in AutoItConstants.au3.
  • Added #3012: GUISetFont() default value doc.
  • Added: @OSVersion supports Windows 10 and Windows Server 2016.
  • Fixed: Functions fixed for extended length paths: FileOpen(), FileCopy(), FileMove(), FileDelete().
  • Fixed #2755: SetError() doc precision.
  • Fixed #2743: Hex() crash with invalid len.
  • Fixed #2685: HotKeySet() fails to register a Hungarian letter.
  • Fixed #2588: Menu/Statusbar location problem.
  • Fixed #2471: Bad restore for script using $WS_EX_LAYOUTRTL.
  • Fixed #2287: GUICtrlSetState() $GUI_ONTOP not set.
  • Fixed #1573: TCPTimeout for Connect.
  • Fixed #2596: TCP/UDP @error values to be unique.
  • Fixed #2626: ControlGetText(), WinGetText(), WinGetTitle() wrong encoding for some words.
  • Fixed #2538: GuiSetAccelerators() was still firing events on disabled button controls.
  • Fixed #2671: StringSplit() was splitting incorrectly with regards to case sensitivity.
  • Fixed #2372: Incorrect line number given on a bad function call. (Still issues with Callback line errors).
  • Fixed #2805: FileWriteLine() was not returning a failure when disk was full.
  • Fixed #2623: RegDelete() returning 0 rather than 2 when a key exists but no write permissions to delete it.
  • Fixed #2813: Accessing "last created control" once GUI deleted caused a hard crash.
  • Fixed #2640: Odd conversion of strings containing numbers in expressions.
  • Fixed #2363: Call() with invalid user function was not setting @error correctly when used as an expression within another function call.
  • Fixed #2364: Call() with CallArgArray and no parameters.
  • Fixed #2789: With EndWith parameter issue.
  • Fixed #2820: WinExists() and other Win functions were incorrectly converting strings containing numbers into window handles and causing false matches.
  • Fixed #2502: Copy-on-write optimization when passing array and map elements ByRef was incorrect.
  • Fixed: Assigning objects by reference to COM properties like "$obj(some, params) = $obj2".
  • Fixed #2639: Unable to Copy/Paste from Embedded IE object.
  • Fixed #2839: GUISetAccelerators() with an invalid array can cause a hard crash.
  • Fixed #2920: Doc precision about no control position/resizing on initially window for GUiCreate()/WinMove().
  • Fixed #2924: Progress bar style documentation.
  • Fixed #3028: GUICtrlCreateCombo() doc formatting.
  • Fixed #3040: Int() doc typos.
  • Fixed #3042: Number() doc clarifications.
  • Fixed #3041: AutoItWinGetTitle() doc example typos.
  • Fixed #3039: AutoItWinSetTitle() doc example typos.
  • Fixed #3057: StringSplit() Return Value if $STR_NOCOUNT doc.
  • Fixed #2993: _Excel_RangeFind returns only last occurrence of string found.

AutoItX:

  • Changed: AutoItX3.psd1 renamed to AutoItX.psd. PSModulePath updated on install so that the system will auto-import.
  • Fixed #2694: ControlListView not finding controls in x64 mode.

UDFs:

  • Changed: _SQLite 3.8.4.3 -> 3.8.10.0.
  • Changed: Reduced duplicate code for finding the maximum and minimum value in an array.
  • Changed: _ArrayAdd() now uses constants to change addition behaviour and datatype forcing.
  • Changed: _ArrayInsert now uses constants to change addition behaviour and datatype forcing.
  • Changed: _GDIPlus_Startup() need explicit Dll for GDI+ v1.1 support under Vista or Server 2008.
  • Changed: Removed internal redraw code from _GUIListView_DeleteAllItems() and _GUIListView_DeleteSelectedItems().
  • Changed: _ArrayUnique() can now deal with Int64 values via new parameter.
  • Changed: Re-wrote _StringInsert() using native functions.
  • Changed: _HexToString() to _StringToHex() now handles strings and binary as UTF-8 by default.
  • Changed: _FileWriteToLine() overwrite optional parameter is now boolean and not an integer of zero or one. The old values are still supported for now.
  • Changed: _Excel_BookOpen() changed from @error = 4 to @error = 0 and @extended = 1 if Workbook could not be opened Read-Write. THIS IS A SCRIPT BREAKING CHANGE
  • Changed: _Word_DocOpen() changed from @error = 4 to @error = 0 and @extended = 1 if document could not be opened Read-Write. THIS IS A SCRIPT BREAKING CHANGE
  • Changed: Re-wrote _MathCheckDiv().
  • Changed: _ArrayTranspose() algorithm.
  • Added #2732: ObjName() doc example.
  • Added #2751: Regions and GUI control tip labels to the control sample example.
  • Added #2764: _WinAPI_ShellExecuteEx(), _WinAPI_GetPriorityClass() doc constants.
  • Added: $SS_ENHMETAFILE, $SS_REALSIZECONTROL, $STM_SETICON, $STM_GETICON, $STM_SETIMAGE, $STM_GETIMAGE to StaticConstants.au3.
  • Added #2826: Quit to close the browser.
  • Added #2836: _WinAPI_SfcIsKeyProtected() doc example.
  • Added: More _GDIPlus_Font* functions.
  • Added: _WinAPI_GetFontResourceInfo() return more Font information.
  • Added: _WinAPI_GetFontMemoryResourceInfo().
  • Added #2922: _VersionCompare() with different number of fields.
  • Added #2968: Optional parameter $iMSeconds to _SetTime().
  • Added: $SB_ANSI, $SB_UTF16LE, $SB_UTF16BE and $SB_UTF8 constants to StringConstants.au3, for use with BinaryToString() and StringToBinary().
  • Added: Constants to Assign() and IsDeclared().
  • Added #2982: _FTP_Connect() example improvement.
  • Added #2976: #pragma default value.
  • Added #2998: Added missing key (03 - control-break processing) to the _IsPressed() documentation.
  • Added: _GDIPlus_ImageGetDimension().
  • Added: _GDIPlus_BitmapCreateDIBFromBitmap() can be used to allow .PNG in GUICtrlCreatePic().
  • Added: _GDIPlus_ImageGetThumbnail().
  • Added #3034: _Timer_SetTimer() doc example.
  • Fixed #2734: Incorrectly setting the wrong member.
  • Fixed #2736: DriveGetType() and _WinAPI_SetWindowPos() doc Constants.au3 to AutoItConstants.au3.
  • Fixed #2737: _WinAPI_ShellGetStockIconInfo() doc $SIID_ constants.
  • Fixed #2744: Requires IE5 removal as Min OS = Windows XP.
  • Fixed #2741: _WinAPI_DrawThemeEdge() constants reference in BorderConstants.au3.
  • Fixed #2740: _WinAPI_IsProcessorFeaturePresent() doc $PF_* constants.
  • Fixed #2739: _WinAPI_SetLocaleInfo() doc $LOCALE_* constants.
  • Fixed #2738: _WinAPI_ShellRestricted() doc $REST_* constants.
  • Fixed #2745: Mismatch of supported operating system with the official AutoIt site.
  • Fixed #2746: IE6Example.htm refreshing and associated COMRef.htm.
  • Fixed #2749: Bad Include in COM example.
  • Fixed #2748: Variable used before declaration.
  • Fixed #2758: _ArrayPermute() with multicharacter delimiter.
  • Fixed #2782: Documentation of various constants.
  • Fixed #2803: _ArrayMinIndex() and _ArrayMaxIndex() failing with 1-dimensional arrays that had 1 element only.
  • Fixed: _ArrayAdd() failing with a trailing delimiter in $vValue.
  • Fixed #2816: Doc precision with _GDIPlus_ImageLoadFromFile() specifying -1 when it's 0 on failure.
  • Fixed: _Crypt_DecryptData() and _Crypt_EncryptData() failing with a blank string when using the RC4 algorithm.
  • Fixed #2821: Example comment was incorrect for _DateToDayOfWeekISO().
  • Fixed #2823: _ChooseFont() default color BGR not RGB.
  • Fixed: Limit bug in _ArrayToClip(), _ArrayExtract() and _ArrayToString().
  • Fixed #2828: Typo of security in _IEFormElementSetValue().
  • Fixed: Limit bug in _ArraySwap().
  • Fixed #2861: _WinAPI_ReadDirectoryChanges() example.
  • Fixed #2874: _GUICtrlRichEdit_SetCharColor() not at insertpoint.
  • Fixed #2909: Backslash was not appended in _PathMake() if $sDir was blank.
  • Fixed #2908: _ScreenCapture_Capture() failing due to out of bounds error.
  • Fixed #2917: _WinAPI_AddMRUString() example crash when run in X64 mode (Msdn Bug CreateMRUListW !!!).
  • Fixed #2918: _GDIPlus_GetEncoderParameterList() not working.
  • Fixed: Range setting in _ArrayDisplay().
  • Fixed: _Array_FindAll() return array incorrectly dimesioned for row search.
  • Fixed #2964: Incorrect structure for $tagWNDCLASS.
  • Fixed: _WinAPI_IsWritable() wrong detection when the device is not ready.
  • Fixed: The seconds parameter in _SetTime() being set as milliseconds.
  • Fixed #2967: Incorrect format of AM/PM when the time was 00:00.
  • Fixed #2983: _WinApi_GetString() doc.
  • Fixed #3011: _FileListToArrayRec() not closing the open handle.
  • Fixed: _Word_DocFind(), _Word_DocFindReplace() and _Word_DocPrint() did not set @extended to the COM error code.
  • Fixed: _StringExplode not using full delimiter to split.
  • Fixed #3018: _GDIPlus_EffectCreateHueSaturationLightness () doc and _GDIPlus_BitmapApplyEffect() crash.
  • Fixed #3038: _Timer_SetTimer() callback function parameters.
  • Fixed #3037: _RunDOS() waits for command completion.
  • Fixed #3055: Bad link in _WinAPI_IOCTL() doc.
  • Fixed #3052: _ArraySort() doc clarification for 2D.
  • Fixed #3059: Miscelaneous => Miscellaneous in Help : Typos.
  • Fixed #3063: Removed additional param in the $tagRAWKEYBOARD structure.

Au3Check:

  • Fixed: False error report on COM variable.
  • Fixed: False error report on With statement.
  • Added: Support of UTF8 with BOM files.

Others:

  • Changed: Improved highlighting AutoIt code inside the HTML files.
  • Added: Icons\MyAutoit3_*.ico to be used when compiling user scripts (small footprint).
  • Added: lang-autoit.js code highlighting file for Google Prettify. See the Extras\Prettify folder.
  • Fixed: Re-writing the scripts which generate the syntax files for the editors and GeSHi, resulted in missing descriptions being added and correct sorting of functions.

3.3.12.0 (1st June, 2014) (Release)

AutoIt:

  • Changed: PCRE regular expression engine updated to 8.34.
  • Added #2557: Send() special control strings will no longer treat 0 repetitions as 1. No keys will be sent.
  • Added #2489: HttpSetUserAgent() now returns the previous user agent string.
  • Added #2481: FileSelectFolder() will use the Windows Vista style if available.
  • Fixed #2562: StringRegExp() & Null character.
  • Fixed #2581: Dec() wasn't working correctly for flags 0, 1, 2.
  • Fixed #2568: StringStripWS() and StringIsSpace() now treats null as a whitespace character.
  • Fixed #2566: "override" cursor in GUISetCursor() fails inside client area.
  • Fixed #2573: "override" cursor in GUISetCursor() fails outside of client area.
  • Fixed #2478: Assign() and Eval() do not restrict variable names.
  • Fixed #2316: PowerPoint COM event handler initialization error.
  • Fixed #2512: ObjName() crash.
  • Fixed #2613: AutoIt crashes whenever an array value returned from a WMI query is null.
  • Fixed #2309: Bad conversion of VT_BSTR|VT_BYREF COM variants when the referenced string is null.
  • Fixed #2648: FileSaveDialog() not adding extension when user types manually.
  • Fixed #2717: Appendix constants page precision about Inet Constants.

UDFs:

  • Removed: Usage of Call() in _FTP_ProgressDownload(), _FTP_ProgressUpload() and _SQLite_Startup(). See documentation for changes to $hFunctionCall and $hPrintCallback parameters. THIS IS A SCRIPT BREAKING CHANGE.
  • Removed: http://api.exip.org/?call=ip from _GetIP() as the site was taken offline.
  • Removed: _WinAPI_GetUDFVersion() as all UDFs share the same version number as the AutoIt version they are shipped with.
  • Changed: Constant variables are now used in the UDFs rather than their value.
  • Changed: Re-wrote _FileWriteToLine() to use FileReadToArray().
  • Changed: Re-wrote _DateDayOfWeek() which can now return the days of the week of the user's locale.
  • Changed: _FileReadToArray() now returns a 1D/2D array depending on parameters used.
  • Changed: Re-wrote _DateToMonth() which can now return the months of the user's locale.
  • Changed: Re-wrote Array UDF to add 2D support and add some functions. THIS IS A SCRIPT BREAKING CHANGE.
  • Changed: Excel UDF was re-written. Functions and/or parameters have been renamed, removed or added. THIS IS A SCRIPT BREAKING CHANGE.
  • Changed: _SQLite 3.8.2.0 -> 3.8.4.3.
  • Added: Error checking to _ArrayDelete() when $iElement was out of bounds.
  • Added: Example for _WinAPI_SystemParametersInfo().
  • Added: A timer of 5 minutes to _GetIP() between each public IP retrieval. This is to reduce overloading the IP discovery sites.
  • Added: $STR_REGEXP* contants in StringConstants.au3 for StringRegExp().
  • Added: _SQLite_SQLiteExe() download sqlite3.exe when needed.
  • Added: http://bot.whatismyipaddress.com as an IP disovery site to _GetIP().
  • Added: _Array1DToHistogram().
  • Added #2726: Group ID to return array for _GUICtrlListView_GetGroupInfoByIndex().
  • Fixed: _FileListToArrayRec() array concatenation bug.
  • Fixed #2550: _GUICtrlComboBox_GetEditText() struct sizing.
  • Fixed: _INetSmtpMail() SmtpServer IPaddr checking.
  • Fixed #2618: _StringBetween() behaviour when $sStart and $sEnd are identical.
  • Fixed #2660: Button on GUI example.
  • Fixed: _IECreate() disable use of Windows Key.
  • Fixed #2689: When $bCursor in _ScreenCapture_Capture() was set to True and the PC was locked.
  • Fixed #2693: _GUICtrlListView_GetItemTextArray() return value doc.
  • Fixed #2697: missing $GW_ENABLEDPOPUP constant.
  • Fixed #2700: _GUICtrlRichEdit_SetCharBkColor() not at insertpoint.
  • Fixed #2706: $tagWINDOWINFO bad struct.
  • Fixed: _GUICtrlListView_GetView() and _GUICtrlListView_SetView() were using 0 for detailed view and 1 for large icon view, when it's the opposite way around. THIS IS A SCRIPT BREAKING CHANGE.
  • Fixed: Incorrect default style for _GUICtrlMenu_CreateMenu() and _GUICtrlMenu_CreatePopup() and changed documentation to use constant values.

Au3Check:

  • Fixed #2612: Function reference ByRef.
  • Fixed: Undetected errors.

AutoIt3Help:

  • Changed: Version number to 1.0.0.6.
  • Added: Windows activation when already open.

Others:

  • Changed: Help file syntax variable names to a standard naming convention for easier understanding and consitency in the calltip syntax files.
  • Added: Keywords and Macros to the Notepad++ autoit.xml file.
  • Fixed #2677: AutoIt.chm Installdir.htm reference.
  • Fixed #2676: AutoIt.chm Installdir.htm \Sqlite reference.
  • Fixed #2725: AutoIt3.chm printing example.

3.3.10.2 (30th December, 2013) (Release)

AutoIt:

  • Fixed #2576: All AutoIt EXEs and tools not working on older Athlon XP processors due to SSE compiler options.

Aut2Exe:

  • Fixed #2580: Aut2Exe failing to run multiple times on Windows XP prior to SP3.

Others:

  • Fixed #2571: Notepad++ autoit.xml was incorrectly formatted and not displaying calltips.

3.3.10.1 (28th December, 2013) (Release)

AutoIt:

Aut2Exe:

  • Fixed: Aut2Exe was leaving a temporary file around.

UDFs:

  • Added: Error checking to _GDIPlus_GraphicsDrawString() in case _GDIPlus_GraphicsMeasureString() fails to return an array.
  • Fixed: Incorrect function being called for _GDIPlus_BitmapCloneArea().
  • Fixed: _ArrayDisplay() user function call and range bug.

3.3.10.0 (23rd December, 2013) (Release)

AutoIt:

  • Removed: PluginOpen() and PlugInClose() removed to due to not being used and never having progressed past the experimental stage.
  • Changed: Removed Windows 2000 support. Minimum supported OS is now Windows XP RTM / Windows Server 2003.
  • Changed: upx.exe from 3.07 -> 3.91.
  • Changed: PCRE regular expression engine updated to 8.33.
  • Changed: Default newline character for PCRE regexes changed to ANYCRLF.
  • Changed: ReDim works on arrays declared as static.
  • Changed: Run-time errors on objects no longer fatal (execution of the script is not halted).
  • Changed: Allowing multiple COM Error Handlers. Last one registered and alive gets called.
  • Changed: VT_NULL VARIANT converts to Null keyword (previously empty string).
  • Changed: Default manifest file on AutoIt and compiled exes is set for "AsInvoker" and tagged with compatibility for Vista/Win7/Win8 and Win8.1.
  • Changed: #NoAutoIt3Execute option replaced with #pragma compile(AutoItExecuteAllowed, false). Default is false.
  • Changed: IsAdmin() function changed to be based on token membership. Maybe more acurate for Sandbox type environments.
  • Changed: ShellExecute() will return the process ID.
  • Added: DriveGetType() updated so that it can detect SSD, and also bus types (SATA, USB, etc.).
  • Added: Interpreter accepts 64bit hex numbers.
  • Added: Keyword Null.
  • Added #488: Third parameter for ObjGet() function to specify object instance.
  • Added: Compound assignment operators for object properties.
  • Added #1191: Explicit size of arrays optional for explicit initialization.
  • Added: Array access on expression: StringSplit("a,b", ",")[1].
  • Added: Dot access on expression: ObjCreate("Shell.Application").GetSystemInformation("DirectoryServiceAvailable").
  • Added: Empty arrays.
  • Added: Functions can now be referenced in variables and the function can be called through the variable.
  • Added: FuncName().
  • Added: Built-in functions that take a callback now be passed directly in addition to the old method of passing as a string. Built-in functions can also be passed now (be careful that the function you pass matches what the caller expects).
  • Added: C++ style ternary operators: Local $fResult = ("foo" = "bar") ? True : False.
  • Added: Expression as default function parameter.
  • Added: With...EndWith can be used on expressions having dot-access.
  • Added: Nested "With...EndWith".
  • Added: Call() calls built-in functions.
  • Added: ByRef with Call() function.
  • Added: Support for more COM VARIANT types.
  • Added: @OSVersion supports Windows 8.1 and Windows 2012 R2.
  • Added: Regular expressions (PCRE engine) now using the new native 16bit mode and also compiled with full UCP support. Prefix patterns with (*UCP) to enable.
  • Added: @LocalAppDataDir for local AppData (@AppDataDir is the roaming location).
  • Added: StringReverse() - a UTF16 compatible string reversal function.
  • Added: FileReadToArray() - native version of _FileReadToArray().
  • Added #2358: FileInstall() accepts @ScriptFullPath as the first parameter to allow easy inclusion of the script source.
  • Added #2433: Monospaced in Fonts appendix.
  • Fixed #2067: -2147483648 not stored as int32.
  • Fixed #2003: ProcessWaitClose() using too much CPU.
  • Fixed #2076: COM VARIANT not correctly set for boolean True.
  • Fixed #2015: DllCallbackRegister() mangles floating point numbers under x64.
  • Fixed: x64 DllCall not setting double type parameters correctly.
  • Fixed: DllCallbackRegister() not returning floating point types correctly.
  • Fixed: Different issues with Static keyword.
  • Fixed #2078: Error in COM expression.
  • Fixed #2073: Unexpected termination with ContinueLoop.
  • Fixed #1485: Unexpected termination with ContinueCase.
  • Fixed: Crash in ObjEvent() for ByRef object parameters.
  • Fixed #2068: Repeated calls to Acos() no longer produce strange results. NOTE: This fix increases the size of AutoIt by approximately 60KB.
  • Fixed: ObjGet() fails validating class identifier properly when first parameter for the function is specified.
  • Fixed #2111: RunAs() could fail even if a user had the correct permissions to use it.
  • Fixed #1395: DLLCallbacks on Exit.
  • Fixed: Ptr() returns null pointer for objects.
  • Fixed #1319: Hang at exit for RichEdit user controls.
  • Fixed #2138: Fixed GUICtrlRead() on dummy controls was corrupting strings and possibly crashing AutoIt.
  • Fixed #1760: #OnAutoItStartRegister ignores single quoted function names.
  • Fixed #2146: Crash when closing AutoIt when started from a console window.
  • Fixed: DLLStruct type forgotten in comparison operations.
  • Fixed: "struct" type parameter in DllCall() overwrites possibly following parameters.
  • Fixed #1566: Array as its own element issue.
  • Fixed #1551: Crash the script when changing array.
  • Fixed: ReDim allows initialization to non-array.
  • Fixed #2166: StringToASCIIArray() and StringFromASCIIArray() did not correctly return an empty string when the start index is greater than the end index.
  • Fixed #1901: 32-bit compiled scripts now work from the system32 directory on 64-bit Windows.
  • Fixed #2157: ProcessList() would crash if there were more than 512 running processes.
  • Fixed #2215: Bad syntax check for default function parameters.
  • Fixed #2222: Non-ASCII characters not allowed in object properties/methods.
  • Fixed #2235: ProcessGetStats() defaulted to using the current process if an invalid process was specified.
  • Fixed #2253: Ping() returns success with no connection.
  • Fixed #1498: #RequireAdmin endless loop for disabled UAC.
  • Fixed #1698: GUICtrlSetLimit(), limit 32767
  • Fixed: Subtle bugs with Ping()
  • Fixed #2286: GUICtrtlGetState() without a controlID parameter runs but aborts AutoIt.
  • Fixed #2350: Strange issue when using $SS_ETCHEDVERT and $SS_ETCHEDHORZ.
  • Fixed #2311: Wrong handling of casesense parameter in StringReplace()
  • Fixed #2361: RegRead() doesn't read REG_QWORD values.
  • Fixed #2362: WinGetText() and ControlGetText() would sometimes give invalid results due to the target application's handling of WM_GETTEXT.
  • Fixed #2075: GUICtrlSetImage() changes icon position on resizable window.
  • Fixed #1667: WinMove() Child window.
  • Fixed #2367: Sometimes two COM objects wouldn't be classed as equal during comparisons.
  • Fixed #1024: GUICtrlSetTip() for tabitems sets incorrectly in certain situations.
  • Fixed #2366: For loop not working as expected.
  • Fixed #2384: UDPRecv() and TCPRecv() not setting @error correctly in some instances.
  • Fixed #2314: Cursor flickers when moving over certain GUI controls.
  • Fixed #2066: DllStructSetData() returning int64 instead of int32 in some cases.
  • Fixed #2427: ControlTreeView() does not used Option2.
  • Fixed #2105: RegRead() and DWORD types incorrectly stored as double.
  • Fixed #2299: GUI Button Text Left-Justify for colored button.
  • Fixed #1954: ListViewItem returns 0 (failure) even though it populates the ListView.
  • Fixed #2152: X^2 Not Working in Hex().
  • Fixed #1870: @GUI_DRAGFILE.
  • Fixed #2461: GUICtrlSetImage doesn't handle certain types of .gif file.
  • Fixed #2167: $WS_EX_LAYOUTRTL and GUICtrlCreateMenu causes bug.
  • Fixed #2468: #OnAutoItStartRegister function doc precision.
  • Fixed #2315: @OSVersion WIN_2012 support.
  • Fixed #2171: TCPTimeout inconsistent.
  • Fixed #2518: Static keyword not working correctly.
  • Fixed: StringStripCR() and StringAddCR() not working with strings that contain nulls.

UDFs:

  • Removed #2174: Explicitly checking if the source and insert strings for _StringInsert() were strings and forcing an @error return value. (@error values 2 and 3 have been removed, please check the documentation.)
  • Removed #2187: Forcing _GUICtrlRichEdit_Create() to create a richedit control in a positive position. (@error values 103 and 104 have been removed, please check the documentation.)
  • Removed #2172: Select...EndSelect statement from _StringRepeat() and replaced with an If...EndIf as well as optimised the code.
  • Removed: Documentation and example for _Iif(). Scripts should be updated to use ternary operators instead. THIS IS A SCRIPT BREAKING CHANGE.
  • Removed: Documentation and example for _StringEncrypt(). Scripts should be updated to use the Crypt functions instead. Look at _Crypt_EncryptData() for an alternative example.
  • Removed: _ArrayCreate() from Array.au3.
  • Removed: Function headers in the UDFs, as information about the function can be found in the help file, This removal resulted in a 32.23% size reduction to the includes folder (7.01MB ->> 4.40MB).
  • Removed: Documentation and example for _StringReverse(). Scripts should be updated to use the native function StringReverse() instead.
  • Removed: $tagGDIPPENCODERPARAMS (duplicate of $tagGDIPENCODERPARAMS).
  • Changed #2117: _FileCountLines() writing to a temporary array to calculate the number of lines in a file.
  • Changed: _FileListToArray() to accept the Default keyword to use the default parameters.
  • Changed: _FileReadToArray() to parse the file using a regular expression. Now various line endings (not recommended) are displayed correctly in the array.
  • Changed: Word UDF was completely re-written. Function names changed from _Word* to _Word_*. THIS IS A SCRIPT BREAKING CHANGE.
  • Changed: _Max() and _Min() functions now use the ternary operator.
  • Changed: Re-wrote _ReplaceStringInFile() by removing the need to write to a temporary array. (@error values 4, 5 and 6 have been removed, please check the documentation.)
  • Changed: Re-wrote _GetIP() for improved efficency and added http://www.myexternalip.com/raw to find the external IP address.
  • Changed: _SQLite 3.7.2.0 -> 3.8.2.0.
  • Changed: IE3.au3 v3.0-0 to v3.0-1 (see header info for changes).
  • Changed: Array UDF now takes into consideration empty arrays.
  • Changed: Re-wrote _ProcessGetName() for speed enhancements.
  • Changed: Re-wrote _PathSplit() by using a regular expression. Contributed by DXRW4E.
  • Changed: _GDIPlus_GraphicsGetSmoothingMode(), _GDIPlus_GraphicsSetSmoothingMode() functions.
  • Changed: _FileWriteToLine() can read a file with various line endings (not recommended).
  • Changed: $tagGDIPENCODERPARAMS using $tagGDIPENCODERPARAM.
  • Changed: _GDIPlus...() using integer or float for positioning.
  • Changed: Modified _ArrayUnique() with a faster version and improved error checking.
  • Changed: $INTERNET_FLAG_NO_CACHE_WRITE default value for _FTP_ListToArray*().
  • Changed: _ArrayDisplay() - new function with new functionalities.
  • Changed: GUIListView - new _Delete* functions.
  • Added: _WinAPI_GetProcAddress() function.
  • Added #2126: Documentation remark about _ArrayDisplay() being able to display a maximum of 65530 items.
  • Added #1158: WinAPIEx integrated, split under WinAPI*.au3.
  • Added #2250: DirMove() to the related section of DirCopy().
  • Added #2155: Missing documentation for the default working directory of Run() / RunWait().
  • Added #2224: Optional parameter to _FileReadToArray() to return the array count in the first element.
  • Added #2114: Disabling and enabling the redrawing message to increase the speed of displaying _ArrayDisplay(). (Only noticeable on large arrays.)
  • Added #2120: Disabling and enabling the redrawing message to increase the speed of deleting items with _GUICtrlListView_DeleteAllItems(). (Only noticeable when deleting many items in a ListView.)
  • Added #966: Optional parameter to return the full path of the file/folder in _FileListToArray().
  • Added #2193: _StringTitleCase(), to create a title case string.
  • Added #2263: _Crypt_GenRandom(), fills a buffer with random data.
  • Added #2354: _ArrayTranspose() to the Array UDF.
  • Added #2338: Regular expression pattern matching. See the documentation of _ArraySearch() for more details.
  • Added #2340: Optional parameter to _GUICtrlListView_SimpleSort() of whether or not to reverse $vSortSense (previously $vDescending.)
  • Added: _FileListToArrayRec() to the UDFs. A recursive file search by Melba23. See the documentation for more details.
  • Added: Example for _VersionCompare().
  • Added: Graphic SmoothingMode constants (GDIPlusConstants).
  • Added: _GDIPlus_CustomLineCapCreate(), _GDIPlus_BitmapCreateFromScan() functions.
  • Added: Constants for DriveGetType() and StringSplit(). See related function documentation for more details.
  • Added: InetConstants.au3 for use with Inet functions. See related function documentation for more details.
  • Added: GDIPlus functions and their respective documentation and example.
  • Added: _GDIPlus_ParamSize() to handle X64 compatibility.
  • Added #2540: _ArrayDisplay() can copy Header and Row.
  • Fixed #2077: hwnd safety check in _GUICtrlRichEdit_Create().
  • Fixed #2088: _ArrayDisplay() not handling Default parameters correctly.
  • Fixed #2112: "Report Log Window" unresponsive when the script is closed.
  • Fixed: _GUICtrlRichEdit_* documentation error return codes.
  • Fixed #1970: _FTP_ListToArray() fails to retrieve Dir or File only.
  • Fixed #2084: Clipboard not being closed if an error occurred with _ClipBoard_SetDataEx().
  • Fixed #2125: Writing a 2-dimensional array would only write the first two columns of the array.
  • Fixed #2070: Unexpected crash on certain systems when using _GUICtrlStatusBar_GetText().
  • Fixed #2132: Documentation of _WinAPI_GetModuleHandle() and the parameter to return the handle of the calling process. (Use the Null keyword, not 0.)
  • Fixed #2162: Documentation link in the IE Management section was broken for _IEFormElementCheckBoxSelect().
  • Fixed #2170: _ArrayDisplay() fails handling arrays with no elements.
  • Fixed: _PathMake() not appending backslash to the root path.
  • Fixed #2223: Incorrect UDF being referenced in _WordErrorHandlerRegister().
  • Fixed #2252: _GUICtrlListView_DeleteAllItems() failed to remove items created using _GUICtrlListView_AddItem() on an AutoIt native listview.
  • Fixed #1861: _ArrayDisplay() incorrectly displayed an array when using the $sHeader parameter and the array contained the default separator.
  • Fixed: Using non-supported characters in the file prefix for _TempFile().
  • Fixed #2186: Documentation of _WinNet_AddConnection()* and $sLocalName. (Use the Null keyword or an empty string, not 0.)
  • Fixed #2148: Crash when passing a number instead of a string.
  • Fixed #2219: _ExcelReadSheetToArray() would cause AutoIt to hang when reading a protected worksheet.
  • Fixed #2242: Unable to write the 0th element in _FileWriteFromArray(). Now the Default keyword is supported for the parameters $iBase and $iUBound, therefore use this instead of the value 0 for default parameters. (Please check the documentation.)
  • Fixed #2218: AutoIt crash when using _GUICtrlListView_SetGroupInfo() before _GUICtrlListView_SetItemGroupID() had been called.
  • Fixed #1996: _GUICtrlListView_SimpleSort() failed to retain the ItemParam of an item.
  • Fixed #1759: Strange listview sort.
  • Fixed #2298: Failing to detect when EnumDisplayDevices returns 0.
  • Fixed: _FileWriteFromArray() failing to pass the $aArray parameter as a constant reference.
  • Fixed: $tagREBARBANDINFO not working on XP, due referencing parameters intended for Vista and above.
  • Fixed #2305: Reports the wrong width and height of the desktop when using default parameters.
  • Fixed #2335: _WinAPI_EnumWindows() and _WinAPI_EnumWindowsPopup() order
  • Fixed #2347: _WinAPI_GetMonitorInfo() wrong data.
  • Fixed #2320: Incorrect return values for certain IE functions.
  • Fixed: _GUICtrlListView_InsertItem() would fail to insert -1 if passed as the $sText parameter.
  • Fixed #2460: _StringBetween() $sStart = $sSend.
  • Fixed #2459: _StringBetween() doc Description info.
  • Fixed #2465: _IEPropertyGet() - out of date links in "ClientInfo Properties".
  • Fixed: _GDIPlus_...() functions compatible with X64.
  • Fixed #2486: _GUICtrlRichEdit_GetFont() bad multi Font return. Solved also #2485.
  • Fixed #2492: _GUIToolbar_... doc example.
  • Fixed: _SQLite_...() running in X64 Mode.
  • Fixed: _SQLite_Startup() parameter checking and doc.
  • Fixed #2550: _GUICtrlComboBox_GetEditText() struct sizing.

AutoItX:

  • Removed: Removed DevC files and Visual Studio 6 files.
  • Removed: ANSI versions of Send/WinWait functions from the native DLL.
  • Removed: DLL Imports: AU3_WinGetPosX, AU3_WinGetPosY, AU3_WinGetPosWidth, AU3_WinGetPosHeight.
  • Removed: DLL Imports: AU3_ControlGetPosX, AU3_ControlGetPosY, AU3_ControlGetPosWidth, AU3_ControlGetPosHeight.
  • Removed: DLL Imports: AU3_MousePosX, AU3_MouseGetPosY
  • Removed: DLL Imports: AU3_WinGetClientSizeWidth, AU3_WinGetClientSizeHeight.
  • Removed: DLL Imports: AU3_WinGetCaretPosX, AU3_WinGetCaretPosY.
  • Removed: DLL Imports: AU3_CDTray, AU3_BlockInput.
  • Removed: DLL Imports: AU3_RunAsSet.
  • Removed: COM Methods: CDTray, BlockInput.
  • Removed: COM Methods: RunAsSet.
  • Removed: All registry functions. The support was limited and the host language will certainly have registry functions.
  • Removed: All Ini file functions. As per registry functions.
  • Changed: Renamed AutoIt3.h to AutoItX3_DLL.h.
  • Added: AutoItX3.Assembly.dll - a .NET Assembly wrapper for the DLL.
  • Added: AutoItX3.PowerShell.dll and AutoItX3.psd1 - a set of PowerShell CmdLets.
  • Added: Visual Studio 2010 C++ Project files (easy to use in 2010 or later).
  • Added: DLL Import: AU3_WinGetPos.
  • Added: DLL Import: AU3_ControlGetPos.
  • Added: DLL Imports: AU3_MouseGetPos.
  • Added: DLL Import: AU3_WinGetClientSize.
  • Added: DLL Import: AU3_WinGetCaretPos.
  • Added: DLL Imports: AU3_RunAs, AU3_RunAsWait.
  • Added: COM Methods: RunAs, RunAsWait.
  • Fixed: Crash in AU3_PixelSearch when function fails.
  • Fixed: AutoItX3.lib files weren't correctly being copied to the install file.

Au3Check:

  • Changed: Message case changed to support SciTE inline errors.
  • Changed: An error is now generated for non-supported file encodings (Previous behavior was to silently pass the script).
  • Changed: Au3Check version numbers now match AutoIt's.
  • Changed: Explicit size of arrays optional for explicit initialization.
  • Added: Generating error for hex numbers longer than 16 characters.
  • Added: Compound assignment operators for object properties.
  • Added: Array access on expression.
  • Added: Dot access on expression.
  • Fixed #2113: Object's properties in names of keywords treated as keywords.
  • Fixed #2141: #IgnoreFunc was generating an incorrect error.

Others:

  • Added: Notepad++ autoit.xml file to the Extras\Editors folder. This contains a list of up to date functions.
  • Added: Sublime Text AutoIt.tmLanguage file to the Extras\Editors folder. This contains a list of up to date functions.
  • Added: 3rd party syntax files in Extras\Editors now include UDF functions.
  • Fixed: StringRegExpGUI missing from the help file index menu.

Au3Record:

  • Fixed #2083: There is no longer an error about a missing DLL.
  • Fixed #2337: Support of non english keyboard.

AutoIt3Help:

  • Changed: Manifest resource suggests Windows common controls v6.0.
  • Changed: Version number to 1.0.0.5.
  • Fixed #2519: Wrong page opening if launch without parameter.

3.3.8.1 (29th January, 2012) (Release)

AutoIt:

  • Fixed: Built-in editor would not compile/go when installed on x64 or in a non-standard location.

3.3.8.0 (23rd December, 2011) (Release)

AutoIt:

  • Changed: Compiling with VC10. Added workarounds for Win2000/XP RTM to allow execution of AutoIt, Aut2Exe, Au3Info, Au3Check and AutoItHelp.
  • Changed: COM Error handler passes error object as first parameter to user defined error function.
  • Changed: COM Error handler properties are read-only.
  • Changed: Dec() and Hex() work with 64bit integers.
  • Changed: Parentheses are required when invoking objects after all method names in order to have correct internal handling.
  • Changed: Dec(), Int(), Number() have second optional parameter defining non-default behavior.
  • Changed: Hex() detects doubles internally and processes them respecting binary format.
  • Changed: New visual style for the documentation.
  • Changed: 64bit integers have 16 characters display by default.
  • Removed: COM Error object no longer exposes methods Raise() and Clear().
  • Removed: Int() and Hex() no longer set @error.
  • Added: Struct/EndStruct in DllStructCreate() to solve X86/X64 data alignment.
  • Added: COM support for pure "OUT" parameters.
  • Added: Additional flags added to ObjName().
  • Added: DllCallAddress().
  • Added: ObjCreateInterface()
  • Added #1947: CHM help files now have a Forward button.
  • Added #1813: Better cross referencing for Int() and Mod().
  • Added: "struct" as DllCall() and InterfaceDispatch data type.
  • Added #2042: @OSVersion returns "Win_8" on Windows 8.
  • Fixed #1040: _ScreenCapture_Capture(): GDI object leak with cursor capture.
  • Fixed #1599: TraySetItemText() regression for default menu item.
  • Fixed #1282: WinMove before GUICtrlSetPos during GUICreation.
  • Fixed #1397: Bad HotKeySet() not detected on keyboard as Russian one.
  • Fixed #1531: default txtcolor for iput edit list combo updown with black theme.
  • Fixed #1617: GUICreate() failure after GUIDelete() can lead to a loop on Autoit exit.
  • Fixed #1596: GUICtrlSetPos() default = no change.
  • Fixed #1626: TCPRecv()/TCPSend() doc about Unicode transmission.
  • Fixed #1633: Second AdlibRegister() function starts at once when first function is too slow.
  • Fixed #1653: Doc for WM_KEYLAST Windows 2000 message.
  • Fixed #1669: StringRegExpReplace() doc about doubling of "\" in replace string.
  • Fixed #1673: WinGetProcess() doc example.
  • Fixed #1677: Invalid ContinueLoop with multiple levels.
  • Fixed #1684: FileRead() binary read memory allocation error.
  • Fixed #1685: BitRotate() shift parameter.
  • Fixed #1734: GUICtrlCreateAvi() crash with negative subfield.
  • Fixed #1923: Memory consumption while FileOpen/FileClose.
  • Fixed #1883: IsHWnd(), Return Value. (Nitpick: Value = Bool).
  • Fixed #1860: DriveStatus() Returns Ready with blank value.
  • Fixed #1854: StringIsFloat() returns 1 on non float numbers.
  • Fixed #1910: Please change $TTN_GETDISPINFO to $TTN_GETDISPINFOW.
  • Fixed #1844: SplashTextOn() crops variable when used with opt 32 and @CRLF / @LF.
  • Fixed #1932: Uninstaller, windows-register, App Paths. (+beta).
  • Fixed #1929: SetMenuColor() does not work on 64bit OS.
  • Fixed #1479: X64 ListView WM_NOTIFY Message.
  • Fixed: GUICtrlCreateLabel() related text sizing bug when no height was used.
  • Fixed #1586: DllStructSetData(char, 1, string-with-NUL-character), junk data(?).
  • Fixed #1908: ObjName() returns empty string for HTMLDocument with IE9.
  • Fixed #1658: COM / OLE object access causes error code 80020003 - member not found.
  • Fixed #1410: Using Pointer type with COM-object throws error.
  • Fixed #1565: Arrays as object properties; memory leak.
  • Fixed: ObjCreate() memory leak when using a remote computer.
  • Fixed #865: winhttp.winhttprequest.5.1 ObjEvent unhandled exception.
  • Fixed: Remote COM bug caused by incorrect CoCreateInstanceEx() parameter.
  • Fixed: Potential memory leak in COM error event code.
  • Fixed #1660: Crash on Mod() with a divisor of 0.
  • Fixed: COM methods no longer change the type of AutoIt variables.
  • Fixed #2001: Example for _GUICtrlToolbar_SetButtonText() did not work correctly.
  • Fixed #1994: Documentation for _ScreenCapture_Capture() and _ScreenCapture_CaptureWnd() incorrectly stated the functions had no return value. Moved information from Remarks up to Return area.
  • Fixed #1948: Documentation for _GUICtrlButton_SetImage() had the wrong description.
  • Fixed #1519, #1694: Int() and Number() returning wrong.
  • Fixed: Various documentation typos and grammatical errors.
  • Fixed #1982: Crash in FileGetShortName() and FileGetLongName().
  • Fixed #2046: DirGetSize("") was returning the size of the working directory root instead of -1 and setting @error.

AutoItX:

  • Fixed #1686: AU3_PixelSearch crashes.

Au3Info:

  • Added: Option "Use Spy++ control detection logic" toggle added to Au3Info (this was the mode always used in recent
  • releases, but the very old method that used to be used is useful in certain applications (for example, putty.exe).
  • Fixed #1746: Option "Use Spy++ control detection logic" toggle added to Au3Info.

UDFs:

  • Changed: _SQLite 3.6.22 -> 3.7.2.0.
  • Changed: _IEFormElementSetValue() examples #3 removed (login to Hotmail).
  • Changed: _IEFormElementSetValue() examples #4 and #5 (now #3 and #4) use the text input instead of the file input. The file input is read-only on IE9 so the Send()/ControlSend() produced no results.
  • Added: _DebugSetup() can report to a Notepad Window.
  • Added #1371: Allow Default keyword in _TempFile().
  • Added #1527: Test example to have doc example working.
  • Added #1636: _Security__LookupAccountSid() for Remote Systems.
  • Added #1569: _ArraySearch() $iPartial (->$iCompare) extended to match on variables of same type.
  • Added #1557: VK_xBUTTON in Constants.au3.
  • Added #1890: Better cross-referencing for _WinAPI_GetParent() and _WinAPI_GetAncestor().
  • Added #1925: $WS_EX_LAYOUTRTL control style to the documentation.
  • Added #2049: Missing windows message codes to WindowsConstants.au3.
  • Added: _WinAPI_StringLenA() and _WinAPI_StringLenW() functions.
  • Added: _WinAPI_DuplicateHandle() function.
  • Added: _Security__CreateProcessWithToken(), _Security__DuplicateTokenEx() and _Security__SetTokenInformation() functions.
  • Fixed #1542: _DebugSetup() closing when use with GUI handling events.
  • Fixed #1549: _SQLite_Escape() crash for strings > 64K (> 3.3.0.0).
  • Fixed #1517: _GUICtrlListView_SimpleSort() with checkbox.
  • Fixed #1588: AutoIt3.exe stay active for all processes using the Window report.
  • Fixed #1615: _GUICtrlTreeView_SetStateImageIndex() with index = 0.
  • Fixed #1620: _DebugOut() or _DebugReportVar() containing '.
  • Fixed #1513: Allow _GUI...() to use notification callback (LPSTR_TEXTCALLBACK).
  • Fixed #1608: _Crypt_EncryptFile() for file >1Mb.
  • Fixed #1644: _INetMail() with Windows Live mail.
  • Fixed #1453: _Net_Share_ShareCheck() return always 0.
  • Fixed #1664: _GUICtrlTab_GetItem() does not return text.
  • Fixed #1671: _WinAPI_WideCharToMultiByte() doc.
  • Fixed #1672: _WinAPI_GetObject() reference ANSI version.
  • Fixed #1665: _ScreenCapture_CaptureWnd() when running with Aero theme.
  • Fixed #1689: _Debug...() cannot be obfuscated.
  • Fixed #1712: _FileWriteFromArray() crash on array.
  • Fixed #1754: _PathFull() optional parameter doc.
  • Fixed #1756: _GDIPlus_Startup() Flaw on error.
  • Fixed #1920: Script crashes with error reported in Security.au3 at line 85.
  • Fixed #1895: Bugs in _GUIScrollBars_Init().
  • Fixed #1891: _ArrayDisplay() (......,i$iTranspose,...) wrong description.
  • Fixed #1933: _GetIP() is outdated and could possibly fail.
  • Fixed #1859: Bug in _WeekNumberISO().
  • Fixed #2009: Incorrect styles listed in _GUICtrlToolbar_Create().
  • Fixed #1009: SQLite library needs to support a user-defined callback for diagnostic messages instead of hard-coding ConsoleWrite().
  • Fixed #1985: _IECreate() now ensures focus is given to the document when an about URI is loaded (such as about:blank). IE9 gives focus to the URL bar which can cause later issues setting focus to elements.
  • Fixed #2004: Functions that accept Control ID/Handle were not correctly documented.
  • Fixed #1951: Missing parameter in documentation for _SQLite_SQLiteExe().
  • Fixed #1442: File handle can now be passed to _FileWriteLog().
  • Fixed #1777: Issues with Security.au3.
  • Fixed #2055: replaced DllStructGetPtr with "struct*" throughout UDFs.
  • Fixed #2048: Windows constants $WM_RBUTTONDBLCLK and $WM_MBUTTONDBLCLK were named incorrectly.
  • Fixed #2034: _GUICtrlMenu_AppendMenu() DllCall type set wrong.
  • Fixed #2060: Various documentation errors.

Au3Check:

  • Added: #forcedef directive to force var definition as after Assign().
  • Added: -w 7 to check ByRef parameter passing.
  • Fixed: Const Enum wrong ERROR.
  • Fixed: Global declared in func not detected.
  • Fixed #1051: no ERROR if keyword not followed by a separator as Local$a.

3.3.6.1 (16th April, 2010) (Release)

AutoIt:

  • Fixed #1515: FileOpen still opening in exclusive mode in some situations.

3.3.6.0 (7th March, 2010) (Release)

AutoIt:

  • Changed: Send() and ControlSend() code reworked to allow for more Unicode characters to be used.
  • Changed: FileWriteLine() performance improved.
  • Added #1376: FileOpen() mode parameter is now optional. Default mode is read.
  • Added #1054: Added FileGetEncoding().
  • Added: ControlCommand() "SendCommandID" - used to send WM_COMMAND Control ID messages. Allows the
  • automation of ToolBarWindow32 controls (amongst others). For example, the "Back" button of
  • Internet Explorer. Use Au3Info to get the Command ID from the ToolBar tab.
  • Fixed #1428: AdlibRegister/Unregister() were incorrectly using case-sensitive function names.
  • Fixed #1448: #OnAutoItStartRegister did not work in compiled scripts.
  • Fixed #961: RegDelete() was not working properly on 64bit keys when using the 32bit version of AutoIt and HKLM64.
  • Fixed: Regression in FileOpen() where it wasn't allowed to open files in read mode if they were already open in write mode.
  • Fixed #1449: GUICtrlDelete() not working for GUICtrlCreateDummy() types.
  • Fixed #1458: Inet sizes were capped to 32-bits.
  • Fixed #1459: Hard crash when too much recursion is used.
  • Fixed #1464: Regular expressions with a single character * pattern were stopping after the first null match.
  • Fixed #1463: StringToASCIIArray() working incorrectly with UTF8 characters.
  • Fixed #1475: TrayItemSetState($Value, $Tray_Checked) incorrectly enables a disabled TrayItem.

Aut2Exe:

  • Fixed #1409: Ctrl+C is no longer the shortcut for Convert. It is now Ctrl+G (Go) to avoid clashing with a Ctrl+C copy operation.

Au3Info:

  • Changed: Better identification of the control under the mouse.
  • Fixed #1444: Controls in applications like RegEdit were left highlighted.
  • Fixed #1391: ToolbarWindow32 info only showing the first toolbar.

AutoIt3Help:

  • Fixed #1423: "Open Script" button stopped working.

AutoItX:

  • Fixed: Missing .lib files readded.

UDFs:

  • Fixed #1438: AutoIt error when using _ArrayCombinations().
  • Fixed #1454: StringBetween() not working correctly.
  • Fixed #1441: _GUICtrlRichEdit_GetText() using wrong buffer length.
  • Fixed #1446: _ScreenCapture_Capture() was using height/width of 1 pixel less.
  • Fixed #1445: Documentation updated for _MemGlobalFree().
  • Fixed #1469: _GDIPlus_BitmapCloneArea() documentation updated.
  • Fixed #1466: _GUICtrlEdit_GetLine() returns an unexpected character.
  • Fixed #1487: _DateToDayOfWeekISO() returned 0-6 but should be 1-7 where Monday = 1.

3.3.4.0 (15th January, 2010) (Release)

AutoIt:

  • Removed: The "RAW" reading mode from FileOpen() has been removed.
  • Removed: InetGet("abort"), @InetGetActive and @InetGetBytesRead have been removed.
  • Removed: AdlibEnable() and AdlibDisable() have been removed.
  • Removed: OnAutoItStart and OnAutoItExit have been removed.
  • Added: Ability to read and write UTF-8 files with no BOM including automatic detection during reading.
  • Added #682: Removed the 64KB limitation for FileReadLine().
  • Added: AutoIt scripts using the line continuation character "_" are no longer limited to a combined line length of 4095 characters.
  • Added: FileRead() returns the number of characters/bytes read in @extended.
  • Added #1311: MouseGetCursor() returns hand cursor.
  • Fixed #384: Under certain circumstances the network credentials flag would prevent the process from starting when launched with RunAs() or RunAsWait().
  • Fixed #1370: StringInStr() would crash with a negative occurrence and start position greater than the string length.
  • Fixed #1367: Calling GUIDelete() from a GUIRegisterMsg() callback that returns $GUI_RUNDEFMSG would crash AutoIt.
  • Fixed #1363: FileSetPos() did not work when the origin was the current position.
  • Fixed #1355: Regression in how unsigned numbers are displayed when returned from DllCall().
  • Fixed #1396: Crash in DllCallbackGetPtr() with invalid handle.
  • Fixed #1352: StringSplit() hard crash with binary data.
  • Fixed #1398: Fixed declaration of $tagPARAFORMAT2 from GuiRichEdit.au3.

UDFs:

  • Changed: _SQLite 3.6.19 -> 3.6.22
  • Fixed #1338: bad _ArrayDisplay() GUI position error.
  • Fixed #1362: _WinAPI_WindowFromPoint() did not work with 64-bit AutoIt.
  • Fixed #1389: _IEAttach() could fail if called multiple times.
  • Fixed #1353: _FileWriteToLine() excessively strict on input text type.
  • Fixed: SQLite.au3 various errors in _SQLite_FetchData(), $iCharSize, _SQLite_QuerySingleRow(), _SQLite_GetTable2d(), _SQLite_Display2DResult() by jchd.

AutoIt3Help:

  • Fixed #1327: Some keywords would fail to open correctly in rare cases.

3.3.2.0 (18th December, 2009) (Release)

AutoIt:

  • Removed: Long deprecate URLDownloadToFile() alias for InetGet().
  • Changed: It is now possible to read from files opened for writing.
  • Changed: PCRE regular expression engine updated to 8.00.
  • Changed #899: ShellExecute[Wait]() no longer uses "open" as the default verb. See remarks section for those functions for more information.
  • Changed: Inet functions rewritten with the following additions.
  • Changed: InetGet() returns a handle which must be closed.
  • Changed: @InetGetBytes, @InetGetActive and InetGet("abort") are deprecated and will be removed in the future.
  • Changed #968: AutoUpdateIt updated by ProgAndy to use new Inet features.
  • Changed: @YDAY now returns values in the range 001 - 366 instead of 1 - 366. This makes the macro more consistent with other languages (like C/C++) and more consistent with all other date related macros which return strings with leading 0s to pad the length. THIS IS A SCRIPT BREAKING CHANGE.
  • Changed #1080: InetGet background downloads now return immediately instead of connecting to the remote host first.
  • Changed #1137: RegEnumKey() and RegEnumVal() now correctly return an empty string on failure instead of an error message string.
  • Changed: PixelChecksum() can calculate checksums from right-to-left and bottom-to-top.
  • Changed: InputBox() no longer requires passing both x and y or w and h.
  • Changed #1056: Added new Inet option to by-pass forcing the connection online.
  • Added #529: Added the "NAME" property to allow direct search for .NET WinForm control names.
  • Added #757: Set defaults for MouseClick()'s x/y parameters.
  • Added #764: Return Pid on ProcessWait() and handle on WinWait(), WinWaitActive, WinActivate(), WinActive(), WinMove() when successful.
  • Added #414: better handling of OnAutoItStart/OnAutoItExit, now #OnAutoItStartRegister, OnAutoItExitRegister() and OnAutoItExitUnRegister().
  • Added: Better handling of AdlibEnable/AdlibDisable, now AdlibRegister(), AdlibUnRegister() and AdlibDisable().
  • Added #351: Reverse PixelSearch().
  • Added #769: FileFlush() function.
  • Added #333: #NoAutoIt3Execute Directive for disabling /AutoIt3ExecuteScript or /AutoIt3ExecuteLine.
  • Added #604: $GUI_BKCOLOR_TRANSPARENT can be used with label, group, radio, checkbox controls.
  • Added #135: FileSetPos(), FileGetPos() functions for moving the file pointer around.
  • Added #582: GUICtrlSetTip() can be used on TabItem controls.
  • Added #699: Shutdown() now return @error=GetLastError() when failing.
  • Added #461: StringReplace() from right to left if occurrence <0 as for StringInStr().
  • Added: GUICtrlSetColor() and GUICtrlSetBkColor() for Combo Controls.
  • Added: GUI without title bar (no $WS_CAPTION) can be moved with the mouse.
  • Added #815: Temporary variables can be passed ByRef.
  • Added #837: FileFindNextFile() set @extended if a directory is returned.
  • Added #839: Shutdown() rewritten and now works properly when run as a non-interactive user.
  • Added: Shutdown() now takes an optional reason code.
  • Added #846: _PathFull() now supports strange but valid syntax where drives do not have a trailing slash.
  • Added #869: @MUILang macro to help MUI environment scripts.
  • Added #918: Added Quality parameter to GUICtrlSetFont() and GUISetFont().
  • Added: ProcessClose() return info on error.
  • Added: PixelChecksum() extra parameter to select CRC32 instead of ADLER.
  • Added #984: @OSVersion now returns "WIN_XPe" for Windows XP Embedded.
  • Added #938: UDPOpen() flag to allow broadcasting with 255.255.255.255.
  • Added: new types to DllCall and DllStruct to avoid confusion with MSDN description. That avoid specially X64 errors.
  • Added #351: PixelSearch() now supports both right-to-left and bottom-to-top searches.
  • Added #508: Static keyword.
  • Added #1056: New Inet option to by-pass forcing the connection online.
  • Added: DllStructSetData() and DllStructGetData() index parameter now supports the Default keyword.
  • Added #1270: GUISetIcon() now finds suitable large and small icons.
  • Added: HttpSetUserAgent(), InetClose(), InetGetInfo() and InetRead() functions.
  • Added: Multiple background downloads are now supported with InetGet().
  • Added #408: New flag for ignoring SSL errors for HTTPS connections.
  • Added #884: Better proxy support with mode 0.
  • Added #949: The user-agent can be changed.
  • Fixed: CtrlSetStyle listview on non selected tab.
  • Fixed #763: GUICtrlCreateIcon() create an empty icon on error.
  • Fixed: no mouse move when invalid button used in MouseClick() or MouseClickDrag().
  • Fixed #779: infinite loop on Exit due to GUICreate() child badly created.
  • Fixed #774: GUICtrlSetBkColor() bad label display.
  • Fixed #790: Windows region constant $ERROR rename in $ERRORREGION.
  • Fixed: StringInStr("aaa", "aa", 2) does not return 0.
  • Fixed #802: Searching for controls by Height property.
  • Fixed: Checkbox or radio painting on tab.
  • Fixed #816: data for GUI date control doc clarification.
  • Fixed #819: Crash with EventLog functions.
  • Fixed #814: InetGet() through a proxy requiring authentication did not work.
  • Fixed #813: bad handling of Windows advanced matching for [HANDLE:...] in X64 version.
  • Fixed #863: DirMove() extra dot.
  • Fixed #867: UDPRecv() can return from IP/Port.
  • Fixed #886: More explicit documentation that operator == is a forced string comparison.
  • Fixed #885: Default compared to False returned True instead of False.
  • Fixed #888: Send("{}}") Extra null char.
  • Fixed: DllCall() returning 64-bit int.
  • Fixed: GUICtrlSetImage() after GUI resized.
  • Fixed: DirMove() return code wrong under XP.
  • Fixed #931: bad GUICtrlSetResizing() for graphic control.
  • Fixed #934: MouseGetCursor() hogging mouse double click.
  • Fixed #615: License updated to be less restrictive.
  • Fixed #919: Remarks added to ConsoleWrite(), ConsoleWriteError() and StdinWrite() regarding how those functions handle binary data and non-ANSI characters.
  • Fixed #897: Documented that StringToASCIIArray() does not accept binary input (convert to a string first).
  • Fixed #937: Bad event handling of Opt("TrayMenuMode",1)
  • Fixed #969: FileFindNextFile() does not set @extended if first found is a dir.
  • Fixed #1006: @MSEC returned wrong value for values < 100.
  • Fixed #1010: FileRead() UTF8 with BOM files return too many chars.
  • Fixed #1013: MDI childs doesn't adjust to parent windows client area.
  • Fixed #1005: TraySetClick(64) = hovering.
  • Fixed: ClipPut("") not emptying.
  • Fixed #1068: Binary to Int.
  • Fixed: Bad painting on double GUICtrlSetPos() for label.
  • Fixed #1094: Send("{LSHIFT UP}") stay down.
  • Fixed #1074: InputBox() positionning on multi monitor.
  • Fixed #1105: disable colored Multiline button not properly displayed.
  • Fixed #1077: GUICtrlSetBkColor() bad recoloring.
  • Fixed #1116: GUICtrlCreateGraphic don't follow ResizeMode.
  • Fixed #1102: Better documentation of the StringInStr() count parameter.
  • Fixed #1161: Removed all documentation references to ColorMode.
  • Fixed #1156: AutoItSetOption()/Opt() now set @error instead of generating a fatal error with invalid input.
  • Fixed: Comparing pointers now works correctly.
  • Fixed #906: ActiveX controls were not told what their initial size was.
  • Fixed: Boolean tests on binary strings now behaves properly.
  • Fixed #1234: COM methods that modified boolean arguments could change them to ints.
  • Fixed #1258: System menu could display when trying to dismiss a control menu.
  • Fixed #1288: Documented how DllStructSetData() and DllStructGetData() work with arrays when omitting the index parameter.
  • Fixed #1300: DLLs could unload when calling DllCall() with an invalid function.
  • Fixed #1295: Unicode to ANSI conversion was crashing in certain situations.
  • Fixed #1304: _GDIPlus_BitmapLockBits() now correctly takes a Width and Height parameter instead of a Right and Bottom.
  • Fixed #1294: Fixed AutoIt deadlock when using the following functions with hanged windows: WinGetTitle, WinSetTitle, WinGetText, WinFlash, WinSetOnTop
  • Fixed #1332: Mod() forced a conversion to floating point numbers when it didn't need to which can cause unexpected output.
  • Fixed #1321: DllStructCreate() did not support _ in data names. Documented valid characters for data name.
  • Fixed #1322: Crash when using ControlCommand("GetSelected") on non-Edit controls.
  • Fixed #1325: Some date functions could attempt to access an invalid array.
  • Fixed #1345: Number() failed to handle numbers with a trailing decimal point.

AutoItX:

  • Removed: "ColorMode" option removed from AutoItSetOption().

Au3Info:

  • Removed: ColorMode BGR option removed since AutoIt no longer supports the option to use BGR mode.
  • Added: Control information now includes the .NET WinForm if available.
  • Added #140: ToolsBar button info.

Aut2Exe:

  • Fixed #1283: Added new option /x86 to force a 32-bit build and re-added /unicode which also forces a 32-bit build.

Au3Check:

  • Fixed #1239: Incorrect library search order.

Others:

  • Added #1050: TextPad v5 syntax files installation.

UDFs:

  • Removed: _StringAddThousandsSep() has been removed. Too many opinions on how the function should work means nobody is happy with it.
  • Removed #1112: __WinAPI_Check() has been removed as have all calls to it.
  • Changed: _StringBetween() removed last optional param (not needed after change)(SmOke_N)
  • Changed: _StringToHex(), _HexToString() and _StringReverse() have been rewritten and are faster.
  • Changed: _SQLite 3.6.7 -> 3.6.19 (SQL statement support UNICODE characters)
  • Changed: _INetGetSource() now uses InetRead().
  • Added: _GDIPlus_BrushGetSolidColor(), _GDIPlus_BrushSetSolidColor().
  • Added: $tagWIN32_FIND_DATA and corresponding attribute constants.
  • Added #868: _WinAPI_GetLayeredWindowAttributes(), _WinAPI_SetLayeredWindowAttributes().
  • Added: _Date_Time_ ... Str() can return date as yyyy/mm/dd.
  • Added #271: FTPEx.au3 for _FTP_...().
  • Added #932: mouse event constants in WinDowsConstants.au3.
  • Added #952: _ArrayDisplay() extra parameter for column header text.
  • Added #957: _Assert() in Debug.au3.
  • Added: _WinAPI_GetGuiResources()
  • Added #981: _WinAPI_WideCharToMultiByte(), _WinAPI_MultiByteToWideChar() support IN/OUT as "strings"
  • Added #1157: Encryption functions in Crypt.au3.
  • Added #1128: _WinAPI_PathFindOnPath() in WinAPI.au3.
  • Added #1228: _FTP_SetStatusCallback(), _FTP_DecodeInternetStatus() in FTPEx.au3.
  • Fixed #755: _FileReadToArray() removing empty end lines.
  • Fixed #773: Doc for _GUICtrlStatusBar_SetParts().
  • Fixed #786: _SQLite_Exec() does not return @error.
  • Fixed #809: _Soundxxx() with first parameter as filename.
  • Fixed #887: Related section based on Tweaky work.
  • Fixed #951: _ArrayDisplay() speed improvement for nb entries >4000.
  • Fixed: _SoundOpen() set @error on MCI Error.
  • Fixed #1015: _SQLite_SaveMode() renamed as _SQLite_SafeMode().
  • Fixed #1016: _WordDocSaveAs() Doc for error handling.
  • Fixed: Sound positioning in case of VBR Format Sound.
  • Fixed #1028: _ClipBoard_GetData() fix.
  • Fixed #1031: _ClipBoard_SetData() fix.
  • Fixed #1040: _ScreenCapture_Capture() leak memory.
  • Fixed #1026: _Gdiplus_BitmapCreate*() doc examples.
  • Fixed #1092: _Timer_...() datatype for X64.
  • Fixed #1059: Incorrect error handling in _FileListToArray().
  • Fixed #1101: _NowTime(), _NowDate() Doc.
  • Fixed: _WinAPI_GetWindowLong(), _WinAPI_SetWindowLong() support X64.
  • Fixed #1111: Bad grammar in comments for _DateAdd().
  • Fixed: UDF library now uses #include "" instead of #include <>.
  • Fixed #1033: UDF library now has better and more consistent error handling when DllCall() is used.
  • Fixed #1215: _ArraySearch() not searching on 2D array.
  • Fixed #1168: _ExcelBookOpen() now selects the first visible worksheet to prevent a COM error.
  • Fixed #1247: Documented that some _GUICtrlComboBoxEx_* functions don't work with certain ComboBox styles.
  • Fixed #1260: Potential buffer overflow in _WinAPI_GetLastErrorMessage().
  • Fixed #1276: _TicksToTime() incorrectly rounded seconds up.
  • Fixed #1277: Resource clean-up in example script for _GDIPlus_ImageGetGraphicsContext().
  • Fixed #1290: Invalid Left coordinate when using _GUICtrlTreeView_DisplayRectEx().
  • Fixed #1296: _GUICtrlTreeView_ClickItem() could click outside the control's parent window.
  • Fixed #1312: Errors with _GUIImageList_BeginDrag() example.
  • Fixed #1320: _GUIImageList_DragMove() documentation contained a parameter that doesn't exist.

3.3.0.0 (24th December, 2008) (Release)

AutoIt:

  • Removed: Windows 9x and Windows NT 4.0 Operating System support has been removed.
  • Changed #393: Documented that SoundSetWaveVolume() works differently in Windows Vista.
  • Changed: PCRE regular expression engine updated to 7.8.
  • Changed: @ProcessorArch changed to @OSArch as it was misleading.
  • Changed: Size limits removed from RegRead() and RegWrite() (previously 64KB for some registry types).
  • Changed: RegRead() and RegWrite() no longer use hex strings for REG_BINARY types - native binary datatypes are enforced.
  • Added: New flag for StringSplit() to not return the count in element 0.
  • Added #328: StringToASCIIArray(), StringFromASCIIArray() functions.
  • Added: New flag to Run()/RunAs() to fix issue #415 (Adds new Constants.au3 constant: $STDIO_INHERIT_PARENT).
  • Added: New flag to all Run functions for better CUI compatibility (Adds new Constants.au3 constant: $RUN_CREATE_NEW_CONSOLE).
  • Added #481: 11 pixel margin around the text in SplashTextOn() (Meets Vista UI guidelines).
  • Added #468: Added @MSEC macro for obtaining the current milliseconds for the current second.
  • Added #277: @CPUArch macro to return the capability of the processor.
  • Added #454: $FO_UTF8 allowing FileOpen() in Read mode for reading UTF8 files without BOM.
  • Added: $FO_UTF16_LE, $FO_UTF16_BE allowing FileOpen() in Read mode for reading UTF16 files without BOM.
  • Added #407: Documented that For...In loops are read-only.
  • Added #645: IniDelete() now supports the Default keyword for the 3rd parameter.
  • Fixed: Send() was incorrectly inserting a leading zero when using the {ASC 0xNNNN} format.
  • Fixed #305: GUICtrlSetFont() for Combo causing highlight.
  • Fixed #318: GUICtrlSetTip() on TreeViewItem must return 0.
  • Fixed #339: GUICtrlDelete() crashes.
  • Fixed #345: @OSVersion for Windows 2008.
  • Fixed #366: AutoIt crash on bad syntax.
  • Fixed #380: @OSVersion for Windows XP 64-bit Edition.
  • Fixed #346: FileOpenDialog/FileSaveDialog filter length limit.
  • Fixed #387: DllClose() and DllCallbackFree() crashing when an invalid handle used.
  • Fixed #449: @SystemDir does not return SysWOW64 under X64 in 32-bit mode.
  • Fixed #440: Fatal error when script ends with EOF (0x1A).
  • Fixed #464: Example script for GUICtrlCreateAvi() did not work on Vista.
  • Fixed #484: ObjGet() would crash when invalid files were specified.
  • Fixed #501: ProcessGetStats() failed for processes running as other users (including SYSTEM).
  • Fixed #92: DllStruct data truncated with char[]/wchar[].
  • Fixed: GUICtrlSetState($graphic, $GUI_HIDE) does not hide.
  • Fixed: GUICtrlSetResizing($graphic, ) not moving.
  • Fixed: GUICreate(...,Style without caption) does not resize properly.
  • Fixed: GUISetStyle(caption change) does not resize properly.
  • Fixed: GUICtrlSetState($listviewitem) does not return error.
  • Fixed #562: Specifying the TITLE property caused all other properties to be lost (Window title matching).
  • Fixed #569 TCPRecv doc example.
  • Fixed #589: Some comparison operators did not return a boolean value.
  • Fixed #583: Bad formatting of @MSEC in documentation.
  • Fixed #574: Using 0 for the SendKeyDelay or SendKeyDownDelay removes the respective delay when using Send().
  • Fixed #542: Crash with regular expressions.
  • Fixed #531: Clarification of some of the remarks for GUICtrlSetGraphic().
  • Fixed #539: StringSplit() with flag 2 and no matching delimiters wasn't returning the full string.
  • Fixed #601: Tooltip return 0 when title length >99.
  • Fixed #608: listView GUICtrlSetBkColor not redrawn.
  • Fixed #628: GUICtrlRead($ctxmenu, $adv) bad return (Saunders)
  • Fixed #640: PCRE does not support \L, \l, \N, \U, or \u : doc updated
  • Fixed #642: Installer now correctly opens the merged helpfile to the history page instead of the AutoIt-only helpfile.
  • Fixed #646: Call() now sets specific @error and @extended values when it fails to find a function.
  • Fixed #669: Typo in Dec() example.
  • Fixed #659: Documented that UNC paths are not supported when using FileSelectFolder().
  • Fixed #671: Crash when using $WS_EX_MDICHILD without specifying a valid parent.
  • Fixed: Crash when using BinaryToString() with invalid UTF16 input string. BinaryToString() now has new @error codes to support diagnosing invalid input.
  • Fixed #743: AutoIt Crash when Tray functions are use with invalid ID.
  • Fixed #748: AutoIt Crash with DllCall(0,...).

Aut2Exe:

  • Added #460: More verbose UPX errors.
  • Fixed #436: Compression level was ignored when performing compilation from the GUI.

AutoItX:

  • Changed: Native DLL: All string methods in the native API are now Unicode. The majority of functions no longer have ANSI versions.
  • Added: COM: WinList method.
  • Fixed: Native DLL: Return strings were sometimes incorrectly terminated.
  • Fixed: PixelChecksum() not returning correct values.

UDFs:

  • Removed: _StringSplit(), no longer needed.
  • Changed: StringAddThousandsSep params in regards to #442.
  • Changed #733: Doc for _GUICtrlButton_SetImageList().
  • Changed: _SQLite -> 3.6.7.
  • Changed #442: _StringAddThousandsSep() allows for regional settings.
  • Changed #290: _GDIPlus_DrawImagePoints().
  • Changed: _Sound...() functions.
  • Changed #599: _FileListToArray() speed optimization.
  • Added: _GDIPlus_StringFormatSetAlign().
  • Added: _StringExplode().
  • Added: _GDIPlus_ImageGetFlags(), _GDIPlus_ImageGetHorizontalResolution(), _GDIPlus_ImageGetPixelFormat(), _GDIPlus_ImageGetRawFormat()
  • _GDIPlus_ImageGetType(), _GDIPlus_ImageGetVerticalResolution().
  • Added: _PathGetRelative().
  • Added: _ArrayCombinations(), _ArrayPermute(), _ArrayUnique().
  • Added: _WinAPI_CreatePen(), _WinAPI_DrawLine(), _WinAPI_LineTo(), _WinAPI_MoveTo(), _WinAPI_GetBkMode(), _WinAPI_SetBkMode().
  • Added: _WinAPI_CombineRgn(), _WinAPI_CreateRectRgn(), _WinAPI_CreateRoundRectRgn(), _WinAPI_SetWindowRgn().
  • Added: _ExcelHorizontalAlignSet(), _ExcelFontSetProperties(), _ExcelBookAttach().
  • Added: _WinAPI_SetEndOfFile(), _WinAPI_SetFilePointer().
  • Added: Missing FrameConstants.au3.
  • Added: Excel UDFs.
  • Added: _Timer_GetIdleTime(), _WinAPI_GetWindowPlacement(), _WinAPI_SetWindowPlacement().
  • Added #332: Remarks to _GUICtrlStatusBar_Create().
  • Added #275: _GDIPlus_GraphicsFillPolygon().
  • Added: _GUICtrlTab_ClickTab().
  • Added: _GUICtrlComboBoxEx_GetUnicode(), _GUICtrlComboBoxEx_SetUnicode().
  • Fixed #693: _DateTimeFormat() time format
  • Fixed #701: _GUICtrlListView_ClickItem() Clicks in the wrong place when $fMove = True.
  • Fixed #700: _GUICtrlTreeView_ClickItem() Clicks in the wrong place when $fMove = True.
  • Fixed #703: _GUICtrlListBox_ClickItem() Clicks in the wrong place when $fMove = True.
  • Fixed #705: _GUICtrlToolbar_ClickButton() Clicks in the wrong place when $fMove = True.
  • Fixed #707: _GUICtrlMonthCal_Create() width and height.
  • Fixed #674: _GUICtrlTab_ClickTab() Clicks in the wrong place when $fMove = True.
  • Fixed #610: _WinAPI_CreateFile() wrong return value upon failure.
  • Fixed #619: _GUICtrlListView_SetItemSelected() memory allocation.
  • Fixed #617: corrections to six GDI+ ImageGet help file examples.
  • Fixed #621: _StringAddThousandsSep don't work with negative number.
  • Fixed #635: _GUICtrlTab_ClickTab() docs list unused $fPopupScan parameter.
  • Fixed #650: Missing BorderConstants.au3.
  • Fixed #656: _FileCountLines() returns 0 if file only contains 1 line.
  • Fixed #600: _ArraySearch() fails with 2D array.
  • Fixed #603: _FileReadToArray() does not return an array if the file contains only a single line of text.
  • Fixed #495: _GUICtrlTreeView_GetTree() returns only 1 parent.
  • Fixed #503: _Date_Time_FileTimeToLocalFileTime() example.
  • Fixed #510: _GUICtrlListView_ClickItem(): If columns inside listview exceed visible area, clicks outside of the control.
  • Fixed #500: _ChooseColor() run on 64bit.
  • Fixed #517: WinAPI UDF - bad error checking after DllCall().
  • Fixed #533: Array functions dimension check.
  • Fixed: various Timer Functions.
  • Fixed #506: _FileCountLines() deal with all common line-end-chars.
  • Fixed #485: WinAPI missing related links in helpfile.
  • Fixed #571: return value doc for _GUICtrlListBox_FindString(), _GUICtrlListBox_GetAnchorIndex() and _GUICtrlListBox_GetText().
  • Fixed #586: _GUICtrlListView_SetGroupInfo() destroyed group ID's.
  • Fixed #516: _ChooseFont() run on 64bit.
  • Fixed #595: _WinAPI_SetWindowsHookEx() help file description of $WH_KEYBOARD_LL.
  • Fixed #465: _DateTimeSplit() if seconds omitted defaulted to -1, now defaults to 0.
  • Fixed: Excel Examples.
  • Fixed #422: _GDIPlus_GraphicsSetSmoothingMode() $iSmooth accepts only 0 - 4, doc updated.
  • Fixed #388: _GUICtrlToolbar_SetButtonSize() Example.
  • Fixed #400: SQLite.dll.au3 @ProcessorArch replaced with @OSArch.
  • Fixed #390: _viPrintf replaced return type.
  • Fixed #371: _GDIPlus_Startup() return value.
  • Fixed #368: _ArrayToClip() return value.
  • Fixed #361, #362: _GUICtrlListView_InsertItem() doc.
  • Fixed #285: _ChooseColor() Example.
  • Fixed #299: _GUICtrlTab_SetItemText() buffer length for Unicode.
  • Fixed #292: _EventLog__Clear() not clearing log when backup parameter is empty.
  • Fixed #258: _ClipBoard_GetData().
  • Fixed #294: _FileReadToArray() where the file contains no @LF.
  • Fixed #303: Clock.au3 in Examples\GUI\Advanced.
  • Fixed: _GUICtrlListView_SetItemEx() text buffer.
  • Fixed #320: _WinNet_EnumResource() struct pointers.
  • Fixed #321: _GUICtrlStatusBar_GetText() buffer length for Unicode.

3.2.12.1 (12th June, 2008) (Release)

AutoIt:

  • Fixed #309: RunAs() and RunAsWait() now use @SystemDir as the working directory instead of @WorkingDir when a user-supplied working directory is not specified.
  • Fixed #325: contextmenuitem not firing events.
  • Fixed #282: Icon transparency refresh when on tab regression.
  • Fixed #360: RunAs() under Windows 2000.

3.2.12.0 (16th May, 2008) (Release)

AutoIt:

  • Removed: Unnecessary optional parameter from ProcessClose().
  • Removed: RunAsSet(). (Replaced with RunAs() and RunAsWait())
  • Removed: RunErrorsFatal option ( Opt() ).
  • Removed: ColorMode option ( Opt() ).
  • Changed: @Unicode renamed in @AutoItUnicode. @Unicode is an alias for now. It will be removed > 3.2.14.0.
  • Changed: The behavior of StdoutRead(), StderrRead(), StdinWrite() and ConsoleRead() has been changed.
  • Changed: PCRE regular expression engine updated to 7.6.
  • Changed: AutoIt internet functions (e.g. InetGet()) now use "AutoIt" as a user-agent. Previously using blank
  • which was blocked by many websites.
  • Changed: ControlClick() now accepts the same mouse buttons as MouseClick() - left/right/middle/primary/secondary/main/menu.
  • Changed: Maximum controls in a GUI window 4093 -> 65532.
  • Changed: @OSVersion can now return "WIN_2008" for Windows Server 2008.
  • Added: RunAs(), RunAsWait().
  • Added: GUISetAccelerators().
  • Added: REGEXPCLASS in Advanced Window and control definitions.
  • Added: X, Y, W, H in advanced window/control definitions.
  • Added: DllCall() new types int_ptr, uint_ptr, long_ptr, ulong_ptr. Special types that change size on x86/x64.
  • Added: "REG_QWORD" type for RegWrite().
  • Added: HotKeySet() modified to work with the {} notation.
  • Added: FileReadLine( ,-1) read last line.
  • Added: Std I/O redirection works with RunAs...().
  • Added: Std I/O merged flag for using the same stream for stdout/stderr.
  • Added: Std I/O supports binary data.
  • Added: ConsoleWrite()/ConsoleWriteError() now return the amount of data written.
  • Added: Remarks in Run() about how to close streams/release resources associated with STDIO.
  • Added: StdioClose() function to force STDIO data closed for a process.
  • Added: ProcessClose() now closes processes started by other users.
  • Added: ProcessWaitClose() returns exitcode in @extended
  • Added: Pixel...() can specified a window handle as last parameter.
  • Added: "start" and "count" parameters added to StringInStr().
  • Added: GUICtrlSetDefColor(), GUICtrlSetDefBkColor().
  • Added: Added parent window parameter to MsgBox(), FileSelectFolder(), FileOpenDialog(), FileSaveDialog().
  • Fixed: DllCall() setting wrong @error values.
  • Fixed: BlockInput() returns errors.
  • Fixed: WinWaitActive() not matching (more frequent with Windows Vista).
  • Fixed: GUICtrlSetState($GUI_SHOW) on hidden radio on an active tab.
  • Fixed: SciTE Lite not installed in the AutoIt Choosen release dir.
  • Fixed: WinMove() with Speed = 0 crash the script.
  • Fixed: Mysterious return value of 1 when no explicit value was set.
  • Fixed: ControlCommand(), "GetLineCount"
  • Fixed: _FileListToArray() when using root drive dir as c:\ under Win9x.
  • Fixed: TraySetState(4) flashing tray icon for Windows Vista.
  • Fixed: ProcessExists() wrong return.
  • Fixed: StringRegExp() crashing under Win95.
  • Fixed: Handle leak when using Run() with I/O redirection.
  • Fixed: Disabled input control background on Tab.
  • Fixed: GUICtrlDelete() of a tab if two GUI windows are used.
  • Fixed: AutoIt crash in Random() when range exceeds 2^31.
  • Fixed: #include parsing error detection.
  • Fixed: Array entry passed ByRef to a UDF.
  • Fixed: FileSetTime() erronously rounds UP on non NTFS partition.
  • Fixed: STDIO redirection sometimes failed on Windows 9x.
  • Fixed: IniReadSectionNames() returning incorrect number of sections under Win9x.
  • Fixed: AutoIt tray icon removal on script exiting.
  • Fixed: AutoIt crash when removing ObjEvent() object.
  • Fixed: ObjEvent() handler can destroy return of AutoIt Function : as WinWait("title") can return 0.
  • Fixed: DirMove() on different volume.
  • Fixed: Crash with RegRead() and REG_MULTI_SZ on x64.
  • Fixed: GuiCtrlListView() behind BG Picture. Doc updated.
  • Fixed: Various Edit control focus and DefPushButton issues.
  • Fixed: ControlTreeView() returning @error=1 on success.
  • Fixed: COM objects could lose numeric precision.
  • Fixed: StringReplace() with start float number.
  • Fixed: ControlCommand() "SelectString" wrong selection.
  • Fixed: StringSplit() flag=1 delimiters not case sensitive.
  • Fixed: In advanced Window descriptions only semi-colon must be escaped.
  • Fixed: ObjGet() memory leak.
  • Fixed: Modified AutoUpdateIt.au3 to work under x64.
  • Fixed: Resizing GUI before GUISetState().
  • Fixed: Radio events fired when GUI reactivated.
  • Fixed: GUICtrlDelete() on contextMenuItem.
  • Fixed: An attempt to FileDelete() a file that was just executed with RunWait() would sometimes fail.
  • Fixed: GUI performance problem when creating a large number of windows.
  • Fixed: GUIGetCursorInfo() with swapped mouse buttons.
  • Fixed: Random(Min,Max,1). Previously this would never actually return Max,
  • so if Max was artificially incremented by one the script will now need to be changed.

AutoItX:

  • Added: ControlTreeView().
  • Fixed: ControlListView() for native DLL version.

Aut2Exe:

  • Added: Option to compile scripts as console applications.

Au3Info:

  • Changed: Controls are always highlighted when using the finder tool.
  • Changed: Controls are not highlighted by default.
  • Changed: Control description gives the advanced version of class and instance.
  • SciTE-lite:
  • Changed: the source to version 1.76
  • Added Save Dialog extension.

UDFs:

  • See the script breaking changes page.

3.2.10.0 (25th November, 2007) (Release)

AutoIt:

  • Changed: DllCall() new method of passing types by reference using *.
  • Changed: DllCall(): short_ptr, long_ptr, int_ptr types deprecated. Use short*, long* and int* respectively.
  • Changed: Limits on Execute() removed.
  • Changed: PCRE regular expression engine updated to 7.4.
  • Added: 64bit (x64) versions of AutoIt, Aut2Exe, Au3Info and AutoItX.
  • Added: DllCallbackRegister(), DllCallbackGetPtr() and DllCallbackFree().
  • Added: DllCall() now accept doubles, int64, uint64, wparam and lparam types.
  • Added: SendKeepActive().
  • Added: ControlTreeView().
  • Added: ProcessGetStats().
  • Added: VarGetType().
  • Added: @AutoItX64 macro.
  • Added: Au3Info : Handle info for windows and controls.
  • Added: DllStructCreate() added "align" keyword to set structure alignment.
  • Fixed: Control...() functions using CLASS and TEXT together sometimes incorrect.
  • Fixed: Control...() functions using CLASSNN sometimes incorrect.
  • Fixed: Windows Vista taskbar previews causing problems with windows matching.
  • Fixed: $var = $var was not giving an error when $var didn't already exist.
  • Fixed: GUICtrlSetImage() sizing regression from 3.2.4.9.
  • Fixed: GUICtrlCreateListView() with no column.
  • Fixed: _GUICtrlListViewInsertColumn() after _GUICtrlListViewDeleteColumn() of the first column of a ListView control.
  • Fixed: Extra notification on colored button.
  • Fixed: IniReadSectionNames() for [] sections.
  • Fixed: Opt("WinTitleMatchMode", Default) fatal error.
  • Fixed: GUICtrlSetStyle() with $ES_READONLY bad $WS_TABSTOP.
  • Fixed: AutoIt Crash on exit if Win...() used with a Title being a COM object.
  • Fixed: ProcessExists() on service process under Win2K.
  • Fixed: DefPushButton behavior.
  • Fixed: ControlCommand(SelectString) order selection.
  • Fixed: Array cannot have 2^24 entries.
  • Fixed: GuiCreateMenu() on a windows without title and without client area.
  • Fixed: WinWaitActive() sometimes failing after a WinActivate().
  • Fixed: _SQLite_SQLiteExe() referencing by default "Extras\SQLite\SQlite3.exe".
  • Fixed: _Sound...() when refering to a file with "!" characters.
  • Fixed: Looping GUIRegisterMsg() doesn't unregister.
  • Fixed: Focus on ES_READONLY edit control.

3.2.8.1 (10th September, 2007) (Release)

AutoIt:

  • Fixed: Possible crash with StringRegExp().

3.2.8.0 (8th September, 2007) (Release)

AutoIt:

  • Changed: General speed improvements (currently up to 24% in some cases compared to 3.2.6.0).
  • Changed: PCRE regular expression engine updated to 7.3.
  • Changed: Recursion-based code limits relaxed.
  • Added: wchar type added to DllStructCreate().
  • Added: WinMove() speed parameter.
  • Fixed: Crash on AutoIt exit if TrayCreateItem() is not deleted.
  • Fixed: AutoIt crash on bad parameter when calling TrayCreateMenu()
  • Fixed: Character positions used in StringRegExp() not correct for characters > 127 (accents, non-Western)
  • Fixed: ProcessExist() under Windows 9x.
  • Fixed: GUISetState(@SW_DISABLE) not disabling keyboard input.
  • Fixed: Sometimes AutoIt crashes on DllStructGetData() with char[] types.
  • Fixed: Au3Info restoring last settings at startup.
  • Fixed: Better handling of notifications when using colored buttons.
  • Fixed: ControlGetText() crash on SciTE windows.
  • Fixed: $LVSCW_AUTOSIZE column truncates display string.
  • Fixed: Incorrect listview creation with GUICtrlCreateListView().
  • Fixed: Memory leak when AutoIt needed to get long file name.
  • Fixed: ListviewItem not created after other child Window creation/deletion.
  • Fixed: ControlGetFocus() returning bad ClassNN values.
  • Fixed: Detection of invalid ContinueLoop statement.

3.2.6.0 (25th August, 2007) (Release)

WARNING:

  • Previous scripts using GUICtrlSetImage(), GUISetIcon(), TraySetIcon() and TraySetPauseIcon()
  • may display a wrong Icon. To get the same icon "if nId > 0 Then newId = - nId - 1".

AutoIt:

  • Changed: iconID in all GUI functions is now the same as GUICtrlSetImage().
  • Changed: AutoIt .a3x and compiled script format. Exe2Aut will only decompile 3.2.5.1
  • and earlier files. No ExeAut utility is supplied for ongoing versions.
  • Changed: General performance improvements (currently around 30-40% over 3.2.4.9)
  • Changed: Limited Unicode support added in regular expressions.
  • Changed: ControlMove() just resizing as WinMove() if X=Y=Default.
  • Changed: PCRE engine updated from 7.0 to 7.1.
  • Changed: Suppress delay when speed=0 in MouseMove().
  • Added: GUIGetStyle().
  • Added: byte and ubyte type to DllCall().
  • Added: ClassnameNN in control and summary info in Au3Info.
  • Added: Float type to DllCall().
  • Added: AU3Check v1.54.8 support for both "#AutoIt3Wrapper_plugin_funcs" and "#Compiler_plugin_funcs".
  • Added: Extra parameter in ProcessClose() to close Stream handles.
  • Fixed: AutoIt crash on WinWait("","text") when a SciTE is open.
  • Fixed: Some crashes on Chinese systems during Unicode/ANSI conversions.
  • Fixed: Aut2Exe crashing on Chinese systems when running in ANSI.
  • Fixed: Wrong Notification on {ENTER} after clicking on a listviewItem.
  • Fixed: Wrong resetting of image on listviewitems if image set on the listview.
  • Fixed: Resizing of listview control.
  • Fixed: @error not set on bad WinGetPos() return.
  • Fixed: LVM_EDITLABEL hogging cpu.
  • Fixed: AutoIt (non UNICODE version) crash with some COM objects.
  • Fixed: GUISetState() on GUI with W=0 or H=0.
  • Fixed: GUI control Tip not reappearing after a click or timeout.
  • Fixed: GUI controls not at the right position if a Control menu is in use.
  • Fixed: EnvUpdate() in UNICODE AutoIt version not working since 3.2.3.3.
  • Fixed: FileRead(..., count) returning count-1 chars.
  • Fixed: Unicode filenames in FileInstall().
  • Fixed: LVS_EX_HEADERDRAGDROP extendedstyle.
  • Fixed: UpDown control shows through tabbed pages.
  • Fixed: GUICtrlSetState() on UPDOWN control without changing the state.
  • Fixed: FileInstall() in compiled scripts causing GUI problems.
  • Fixed: ControlGetFocus() on control not created with AutoIt GUI.
  • Fixed: @AutoItPID and ProcessList() coherency under Win9x.
  • Fixed: GUICtrlSetResizing() not returning error on non resizable control.
  • Fixed: Regression for ControlSend() SHIFTDOWN/UP since 3.2.3.13.
  • Fixed: Drag and drop on a listview control after clicking on its header.
  • Fixed: Support "resource only" dlls for GUISetImage().
  • Fixed: Default minimum for GUICtrlSetLimit() set to 0.
  • Fixed: Z order after GUICtrlSetStyle() on edit or input control.
  • Fixed: FileReadLine() getting bad cached data when reading specific line numbers with file handles.
  • Fixed: Slight lag in GUIGetMsg() under certain circumstances.
  • Fixed: StringReplace() and occurances parameter.
  • Fixed: GUICtrlSetFont() on Tab control.
  • Fixed: Leading blanks before #include cannot be compiled.
  • Fixed: Notification on ENTER on Colored button.
  • Fixed: RegWrite() setting bad registry entry in certain circumstances.
  • Fixed: AutoIt hogging CPU when text MsgBox too big.
  • Fixed: ControlSend() sometime to wrong control when using empty controlID.
  • Fixed: ProcessExists() under Win2K with processname >15 chars.
  • Fixed: Int() with string comparison wrong match.
  • Fixed: InetGetSize() in unicode version returns 0.
  • Fixed: GUICtrlCreateListView() with more than 254 columns.
  • Fixed: AutoIt Crash on recursive RegExp.
  • Fixed: BitRotate() with left bit set.
  • Fixed: FileMove() returning 1 without any move.
  • Fixed: FileRead() returning Chr(0) in ANSI mode.
  • Fixed: Au3Info control coords relative to client.
  • Fixed: StringInStr() not returning 0 when searching backward and search length greater than string.

3.2.4.9 (25th May, 2007) (Release)

AutoIt:

  • Added: StringCompare()
  • Fixed: Basic string comparisons were not working with locale as in previous versions.

3.2.4.8 (23rd May, 2007) (Release)

AutoIt:

  • Fixed: Errors with non-western codepages and ANSI format scripts.

3.2.4.7 (22nd May, 2007) (Release)

AutoIt:

  • Added: Aut2Exe options for forcing ANSI mode compilation (/ansi and /unicode)
  • Added: StringToBinary()
  • Added: Additional unicode related options for BinaryToString()

3.2.4.6 (20th May, 2007) (Release)

AutoIt:

  • Fixed: StringReplace() and occurances parameter.

3.2.4.5 (20th May, 2007) (Release)

AutoIt:

  • Changed: StringReplace() speeded up - a lot.
  • Changed: Au3Info is now resizable.
  • Added: BinaryToString() for binary buffer to ANSI string quick conversions.
  • Added: @Unicode to show if AutoIt is being run in Unicode or ANSI mode.
  • Fixed: Chr(0) now properly works with Binary()

3.2.4.4 (17th May, 2007) (Release)

AutoIt:

  • Fixed: Chr(0) now acting more sensible (now acts in a similar way to VBScript).

3.2.4.3 (17th May, 2007) (Release)

AutoIt:

  • Fixed: FileRead() not working properly with unicode files.

3.2.4.2 (15th May, 2007) (Release)

AutoIt:

  • Changed: Au3Info graphical tweaks and Summary tab.
  • Fixed: FileReadLine() getting bad cached data when reading specific line numbers with file handles.
  • Fixed: Slight lag in GUIGetMsg() under certain circumstances.

3.2.4.1 (13th May, 2007) (Release)

AutoIt:

  • Added: ChrW() and AscW() for unicode operations.
  • Fixed: Chr() and Asc() for character codes 128-255 in unicode mode.
  • Fixed: Unicode BOM was not being written in file append modes if the file was empty.
  • Fixed: Error in Include\GuiCombo.au3 and Include\IE.au3.

3.2.4.0 (10th May, 2007) (Release)

WARNING:

  • AutoIt is now compiled for Unicode! AutoIt3.exe is Unicode - AutoIt3A.exe is ANSI.
  • Au3Info tool rewritten.
  • Binary data functions completely rewritten - scripts using these functions will need to be changed.

AutoIt:

  • Changed: Removed restrictions on the maximum number of #include directives.
  • Changed: Removed restrictions on the maximum number of DllOpen() handles.
  • Changed: Removed restrictions on the maximum number of open files.
  • Changed: Removed restrictions on the maximum number of hotkeys.
  • Changed: Performance improvements in StringStripWS().
  • Changed: Binary data in variants are now treated as a special type, separate from normal strings.
  • Changed: BinaryString() renamed to Binary()
  • Changed: IsBinaryString() renamed to IsBinary()
  • Changed: ControlClick() can now click a control at a certain position.
  • Changed: ControlClick() can now properly simulate double-clicks.
  • Changed: ControlClick() no longer forces the activation of the parent window (up to the user now).
  • Changed: ControlClick() related coordinates added to Au3Info.
  • Changed: Improved the searches that can be done for windows/controls/instances.
  • Changed: From DEFAULT_QUALITY to PROOF_QUALITY for Change/Set Font functions.
  • Changed: x^y compatible with C99 standard.
  • Added: New modes for FileOpen() to force Unicode and binary operations.
  • Added: BinaryLen(), BinaryMid()
  • Added: Colored GUI buttons.
  • Added: DllStruct...() can reference elements by name rather than index.
  • Fixed: Possible crash when using StringStripWS(), flag 4 and empty strings.
  • Fixed: GUICtrlSetLimit() for UpDown controls wher min = max.
  • Fixed: GUICtrlSetTip() not always working correctly.
  • Fixed: Slow GUI tab redrawing under Windows Vista fixed.
  • Fixed: HotKeySet() bad notification.
  • Fixed: FileGetAttrib() on pagefile.sys.
  • Fixed: Invalid default parameter in GUICtrlSetData() not detected.
  • Fixed: Assign does return error on array element.
  • Fixed: FileOpen("test.txt", 2+8) returning error.
  • Fixed: Error detection in Enum statement.
  • Fixed: Opt("WinTitleMatchMode").
  • Fixed: Stack corruption resulting from improper use of DllCall() now gracefully aborts the script instead of hard crashing.
  • Fixed: Crash when reading empty REG_MULTI_SZ.
  • Fixed: Round() not returning an integer.
  • Fixed: ControlSend() to empty "" ctrl fixed for inactive window. Also shift state behavior.
  • Fixed: O^(-1).
  • Fixed: Non detection of illegal statement.
  • Fixed: HotKeySet("^{PAUSE]",...) notification.
  • Fixed: {CTRLBREAK} ->{BREAK} as ctrl is user responsability.
  • Fixed: $var = Default passed as parameter to COM object.
  • Fixed: Edit control would always have focus the first time the GUI was displayed even if it shouldn't. This behavior also ignored $GUI_FOCUS.
  • Fixed: range value for seed Number in SRandom().
  • Fixed: FileRead() crash if no count in raw mode.
  • Fixed: Opt("WinTitleMatchMode", <0) really matching case insensitive.
  • Fixed: FileSetAttrib/FileSetTime wrong setting.
  • Fixed: Execute/Call recursive overflow display error message.
  • Fixed: Aut2exe warning message if icon not found.
  • Fixed: WinGetTitle() returns 1 on error.
  • Fixed: Memory leak on keyword variable deallocation.

3.2.2.0 (23rd December, 2006) (Release)

AutoIt:

  • Removed: old WinShow, TimerStart and TimerStop functions.
  • Changed: Performance improvements (up to 100% on some scripts!).
  • Changed: @error set to GetLastError WinAPI for Run().
  • Changed: Small tweak to Floor() to ensure it is not as susceptible to floating point precision errors.
  • Changed: Small tweak to Ceiling() to ensure it is not as susceptible to floating point precision errors.
  • Changed: PixelChecksum() is now over 30x faster.
  • Changed: FileGetVersion() extra parameter to retrieve string file info.
  • Added: StringRegExp() and StringRegExpReplace() regular expression support (Perl compatible)
  • Added: Regular expression support for Window title matching.
  • Added: ShellExecute() and ShellExecuteWait() functions.
  • Added: #RequireAdmin for UAC/Windows Vista.
  • Added: Windows Vista help file entry.
  • Added: GUICtrlSetState() $GUI_DROPNOTACCEPTED.
  • Added: $GUI_FOCUS, $GUINOFOCUS for listviewitem control.
  • Added: IsDllStruct().
  • Added: SRandom() to set seed for random number generation.
  • Added: WinTitleMatchMode for case insensitive matching.
  • Added: iconID can be reference by ordinal value if negative 1-based index is use.
  • Added: CompiledScript string file info for compiled script.
  • Added: Support >32x32 icon from .exe/.dll in GUICtrlCreateIcon() or GUICtrlSetImage().
  • Added: Expanded GUICtrlSetTip() to allow creation of tooltips with titles, icons and using the balloon tip style.
  • Added: Tooltip() supports Default keyword.
  • Added: Remark added to _PathSplit() mentioning that it does not accept command line strings, only paths.
  • Added: 2 UDF's to GUIStatusBar.au3.
  • Added: GUICtrlCreateIcon() and GUICtrlSetImage() can select in multiple icon file by name.
  • Added: @KBLayout to retrieve the current keyboard configuration.
  • Added: ToolTip() option to ensure the tooltip is always displaying on a monitor.
  • Added: IniWriteSection() function.
  • Added: @extended error code on DriveMapAdd error.
  • Added: Listview Alternate coloring with $GUI_BKCOLOR_LV_ALTERNATE.
  • Fixed: MsgBox() timeout on Windows Vista.
  • Fixed: GUICtrlRead() on listview control when sorted.
  • Fixed: @OSVersion on Windows 9x.
  • Fixed: GUIGetCursorInfo() with Handle not retrieving mouse click info.
  • Fixed: DllCall() crashes when using uint, ushort.
  • Fixed: List control height when font size changes.
  • Fixed: GUICtrlSetImage() not testing icon on error.
  • Fixed: @ScriptDir equal @WorkingDir for rootdir (x:\).
  • Fixed: GUIGetCursorInfo() (winhandle) when child not active.
  • Fixed: _StringAddComma().
  • Fixed: drag & drop $GUI_EVENT_DROPPED notification on edit control.
  • Fixed: Coherency of type parameter for DllCall() and DLLSructCreate()
  • Fixed: Default keyword didn't always work correctly with COM objects.
  • Fixed: COM property write fails when using arguments.
  • Fixed: Send()/ControlSend() for US international keyboard.
  • Fixed: Send()/ControlSend() char>=Chr(128) for english keyboards.
  • Fixed: COM property write fails when using arguments.
  • Fixed: MsgBox() with task modal flag left GUI's disabled on timeout.
  • Fixed: Error reporting by messagebox even with /ErrorStdOut.
  • Fixed: GUICtrlSetImage default icon value for Icon Ctrl.
  • Fixed: GUIRegisterMsg() destroyed @error.
  • Fixed: $LVS_SORTASCENDING with GUICtrlSetImage() icon gave bad display.
  • Fixed: Some Object Collections could not be parsed in one AutoIt statement.
  • Fixed: Bad screen updating of already unchecked radiobuttons.
  • Fixed: Tray icon tooltip not displaying the scriptname when compiled.
  • Fixed: UDP...() return code on error.
  • Fixed: UDPRecv() crashed on bad parameter.
  • Fixed: COM was corrupting floating point values.
  • Fixed: GUICtrlSetState() doc remarks about menu control.
  • Fixed: Refresh after a GUICtrlSetBkColor().
  • Fixed: Crash on line beginning with ~ : "Unable to parse line".
  • Fixed: IniReadSectionNames() returned bogus data in Windows 98 when the INI file was empty or did not exist.
  • Fixed: @Compiled when the script is compiled.
  • Fixed: Send() to italian keyboard.
  • Fixed: MouseMove() in secondary screen.
  • Fixed: StringInStr() not converting to string search parameter.
  • Fixed: Int() of a binarystring.
  • Fixed: ControlSend sending() special characters.
  • Fixed: Crash in Au3exe with badly formed input file in FileInstall().
  • Fixed: Wrong execution of a compiled script containing FileInstall() inside #CS-#CE.
  • Fixed: FileInstall() referencing a file without any path will reference it from the ScriptDir to be coherent with the compiled script.
  • Fixed: Aut2exe crashed using cmdline with shortnames.
  • Fixed: Tooltip state (such as icon or title) was showing up on subsequent tooltips that didn't want those items. This affected both ToolTip() and GUICtrlSetTip().
  • Fixed: GUIRegisterMsg() destroy @error.
  • Fixed: $LVS_SORTASCENDING with GUICtrlSetImage() icon bad display.
  • Fixed: Wrong default arguments for _ArrayToString().
  • Fixed: Bad "#" instruction inhibit whole script.
  • Fixed: Installer SciTE bad link creation.
  • Fixed: Uninstaller include file removal

3.2.0.1 (13th August, 2006) (Release)

Au3Info:

  • Fixed: Buffer overrun in control code.

Exe2Aut:

  • Fixed: Exe2Aut.exe was missing its digital signature.


AutoIt and Developer History

This section is for those interested in how the AutoIt project began, and how the various developers got involved. Devs should add their own thoughts when they get time :)

Jon

October 1998

I was working on a project to create an automated Windows NT 4 build for a company in the UK. It became clear that around half the applications required featured no way to silently install them. Searched around for a while for some way to force button presses and came across Microsoft ScriptIt which was a compiled WinBatch script designed for clicking buttons in automated builds.

ScriptIt worked OK but it was extremely unreliable. It was notoriously fussy about the speed of the machine it was used on and had no way to control the key delays between keystrokes. Another feature that caused problems was that there was no way to specify a working directory when running a program which caused loads of problems with many of the applications I was scripting. Also, some of the functions didn't work under NT 5 beta (i.e. Windows 2000).

Xmas 1998

To escape the torment that was Xmas I decided to have a go at a C program that would send keystrokes hoping that I could then control the delay.

January 1999

AutoIt version 1 released on the old winfiles.com site. Syntax was similar to ScriptIt (for Send) and featured the functions Send, Run, RunWait, WinWait, WinWaitClose, WinWaitActive, WinHide, WinActivate, WinClose, WinRestore, Sleep and SetKeyDelay. From the v1.0 helpfile:

Advantages
- It's much smaller at 40Kb (600Kb smaller than ScriptIt).
- It will be updated if problems are found.
- The "Reveal" function is much better.
- Non-active as well as active windows can be waited for.
- Variable delays are possible (defined in milliseconds).
- The time in between keystrokes can be altered.
- When running an application, a working directory can be specified.
- Will force Windows to be active under Win98/NT 5.0 (Use "WinActivate")

Disadvantages
- The "[ADLIB]" section is not implemented
- The script file must be formatted correctly (no white spaces allowed on lines
containing a command).
- None of the Wilson WinBatch commands are featured.
(But who used them anyway? )
- Due to the command names I've used, the scripts tend to be a little larger.

January - April 1999

Numerous versions released up to v1.8 with features like:
- Cool /reveal mode
- Goto!
- IfWin...
- Mouse control
- ScriptIt ADLIB-like support
- Gosub
- %ENV% variable support

August 1999

AutoIt v2 released.
First version of AutoItX created.

September 1999

AutoIt v2.1 - First version of Aut2Exe created.

September 1999 - May 2001

Numerous versions and number of functions increasing at a massive rate. Basically, if someone asked for a function I stuck it in there. The problems this caused is why we don't give in all the time any more.

May 2001

AutoIt source code was a total mess. Entire source rewritten in C++.

January 2002

AutoIt v2.62 - First version of Exe2Aut created (boo...hiss)
First version of AutoItDLL created.

December 2002

AutoIt v2.64 - last version of AutoIt v2.

FileInstall function added after writing my own compression and archive library.

January 2003

Very little development was done from 2001 to 2003. Project had reached the point where I'd lost the will to work on it. The source code was a mess again because in this sort of project you tend to add on every function that everyone wants without thinking about the future. The AutoIt v2 syntax was really horrible.

Half the requests I got were for proper loops and expressions - half of the questions were "how do I use a backslash in a Run command". Arrgh.

In this time there were numerous "add-ons" like Aut2xtra created by Larry that allowed the use of some of the missing functions from AutoIt (because I hadn't the time or motivation to add them).

IIRC Larry suggested that he was frustrated with the lack of development and suggested writing a new version. I decided that if a new version was wanted then it should be more like a "proper" language. I started the development framework for AutoIt v3.

Previous versions were very strict about syntax it was "Command, param1, param2,..." and it took about a month to come up with something that could read in a line containing complex expressions (a whooooole lot of googling required). Although I "get" it now, writing the expression code in AutoIt was the 2nd hardest thing I'd ever done. (Hardest thing I've written was the compression code used in Aut2Exe that I wrote from scratch )

Most of the current devs starting helping out soon after this point. I forget when each person starting helping so hopefully they can fill in here.

March 2003

First public beta binary of AutoIt v3 (after lots of talk) released.

February 2004

After over 100 beta versions and development spiraling well out of control AutoIt v3.0.100 was finally released.

Jon :)

Larry

Early 2001 started my own automated roll out of WinNT systems. I found that the previous curator used an AutoIt script to handle some interaction. Fascination... I expounded on the control that AutoIt had in the roll out process, scrapping all other means and focusing on an "All-AutoIt" solution.

We all hung out on the Yahoo AutoItList group at that time. I had a lot of free time at work (thanks to AutoIt) and paid much attention to the AutoItList. Jon noticed my dedication and allowed (allows) me to moderate/maintain that group. Although, I haven't looked at the files section, much, in years.

By 2003, I pushed AutoIt to its limits, so began to learn C to create command line utilities (including GUI, AutGUI.exe) to use with AutoIt. Then I started to threaten everyone with trying to create a "next-generation" of AutoIt. I got about 2 days into coding a script parser and (I think) Jon got nervous about how horrible my fumbling was, and how feeble a product might ensue. So, he saved me and decided to dedicate his own efforts.

I think Jon and I have some of the same priorities, so he crowned me the original moderator of the AutoItScript forum. Subsequently, in appreciation of my laziness and with commendation to the dedication of others he began to dole out responsibility.

One of my frustrations with the AutoIt community, or just in freeware in general, I guess, is that the efforts and hours will never truly be appreciated. I am only fueled by pride in this endeavor.

Lar.

Jos

I have been using AutoIt since ver 2...
Started to become more active on the old forum just before moving to this new forum.
Started to offer help on things like:
- Helpfile creation automation.
- Made opening the Helpfile for AutoIt3 Functions and Keywords (F1) work from within Editors like Crimsom/TextPad/SciTE.

Wrote a bunch of UDF's.
Wrote Tidy in AutoIt3 syntax as way to learn AU3. This is now BCX - C because I wanted it to be faster.
Started developing the AutoIt3 Lexer for SciTE and submitted that for inclusion in SciTE v 1.60.
Started the SciTE4AutoIt3 Installer package to make a single installer for all the goodies developed by others and myself and created the Helpfile for it.
Wrote AutoIt3Wrapper to allow easy access to both Production and Beta version of AutoiT3 and allow Compiler Directives for Updating the output programs resource information.
Started the SciTE4AutoIt3 Sub-Website when SciTE became more popular.

Became moderator when too many (how do I say this politely) script kiddies started to terrorise the forums and Jon didn't always have time to be around and Larry living in a different timezone.

Wrote Obfuscator (now known as Au3Stripper) which is a based on Tidy's sourcecode to make script somewhat unreadable.

Jos :)

Valik

A long time ago I found a Diablo II bot. For whatever reason (Probably to fix something), I learned it was written in AutoIt so I came to the site to get the program. Around the time Jon started work on v3 I started learning C++. Once the v3 beta's were released I started porting some of my old scripts to v3. Eventually I either find problems or wanted features and since the source to AutoIt was available at that time and I was learning C++, it seemed like a good idea to contribute. As for becoming a moderator, much like JdeB, I grew tired of the stupidity on the forum.

Jpm

I cannot remember when I found AutoIt - but it was a simple yet powerful script language. I use it a lot to automate the reinstall process of my Windows Beta testing so that I can have the same environment (system and user) every time. I was able to install it while doing something else. The process was very slow with a 200Mhz machine...

So up until March 2003 I decided to help French people doing the French translation of the V2 version. At this time the AutoIt source code V3 was available so I decided to learn more about C and the Windows API. I wrote the converter V2 to V3 to convert my scripts - it doesn't seem so useful today but at least my C code learning was improving.

I participated in some improvements to help automation of any windows version or any OS language. I created a test AutoIt non regression suite to help our internal process of delivering good beta versions. I was so fond of having GUI creation that when Larry start his AU3GUI project, I decided to integrate it into the V3.0 version.

At the time Jon was so busy outside AutoIt so I looked after bug reports and beta versions. I try to manage the BUG report forum as much as I can and to identify/integrate the improvements that I love and that I can implement...

JP ;)


User Defined Functions

User Defined Function Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

See User Defined Function Notes for details on usage.

User Defined Function | Description
_Array1DToHistogram | Transform a 1D array to Histogram
_ArrayAdd | Adds a specified value at the end of an existing 1D or 2D array
_ArrayBinarySearch | Uses the binary search algorithm to search through a 1D or 2D array
_ArrayColDelete | Deletes a specified column from a 2D array
_ArrayColInsert | Inserts a specified column into a 1D or 2D array
_ArrayCombinations | Returns an array of the combinations of a set of elements from a selected 1D array
_ArrayConcatenate | Concatenate two arrays - either 1D or 2D with the same number of columns
_ArrayDelete | Deletes the specified element(s) from the specified 1D or 2D array
_ArrayDisplay | Displays a 1D or 2D array in a ListView
_ArrayExtract | Extracts an array from the specified element(s) of a 1D or 2D array
_ArrayFindAll | Find the indices of all ocurrences of a search query between two points in a 1D or 2D array using _ArraySearch()
_ArrayInsert | Insert a new value at the specified position of a 1D or 2D array
_ArrayMax | Returns the highest value held in a 1D or 2D array
_ArrayMaxIndex | Returns the index where the highest value occurs in a 1D or 2D array
_ArrayMin | Returns the lowest value held in a 1D or 2D array
_ArrayMinIndex | Returns the index where the lowest value occurs in a 1D or 2D array
_ArrayPermute | Returns an array of the Permutations of all Elements in a 1D array
_ArrayPop | Returns the last element of an array, deleting that element from the array at the same time
_ArrayPush | Add new values without increasing array size by inserting at the end the new value and deleting the first one or vice versa
_ArrayReverse | Takes the given array and reverses the order in which the elements appear in a 1D array
_ArraySearch | Finds an entry within a 1D or 2D array. Similar to _ArrayBinarySearch(), except that the array does not need to be sorted
_ArrayShuffle | Shuffles selected rows of 1D or 2D arrays - can be limited to a specific column in 2D arrays
_ArraySort | Sort a 1D or 2D array on a specific index using the dualpivotsort/quicksort/insertionsort algorithms
_ArraySwap | Swaps elements of a 1D array and full or part rows/columns of a 2D array
_ArrayToClip | Sends the contents of a 1D or 2D array to the clipboard, each element separated by a specified delimiter
_ArrayToString | Places the elements of a 1D or 2D array into a single string, separated by the specified delimiters
_ArrayTranspose | Transposes a 1D or 2D array (swaps rows and columns)
_ArrayTrim | Trims a certain number of characters from all elements in a 1D or 2D array
_ArrayUnique | Returns the Elements from a column of a 1D or 2D array, removing all duplicates
_Assert | Display a message if assertion fails
_ChooseColor | Creates a Color dialog box that enables the user to select a color
_ChooseFont | Creates a Font dialog box that enables the user to choose attributes for a logical font
_ClipBoard_ChangeChain | Removes a specified window from the chain of clipboard viewers
_ClipBoard_Close | Closes the clipboard
_ClipBoard_CountFormats | Retrieves the number of different data formats currently on the clipboard
_ClipBoard_Empty | Empties the clipboard and frees handles to data in the clipboard
_ClipBoard_EnumFormats | Enumerates the data formats currently available on the clipboard
_ClipBoard_FormatStr | Returns a string representation of a standard clipboard format
_ClipBoard_GetData | Retrieves data from the clipboard in a specified format
_ClipBoard_GetDataEx | Retrieves data from the clipboard in a specified format
_ClipBoard_GetFormatName | Retrieves the name of the specified registered format
_ClipBoard_GetOpenWindow | Retrieves the handle to the window that currently has the clipboard open
_ClipBoard_GetOwner | Retrieves the window handle of the current owner of the clipboard
_ClipBoard_GetPriorityFormat | Retrieves the first available clipboard format in the specified list
_ClipBoard_GetSequenceNumber | Retrieves the clipboard sequence number for the current window station
_ClipBoard_GetViewer | Retrieves the handle to the first window in the clipboard viewer chain
_ClipBoard_IsFormatAvailable | Determines whether the clipboard contains data in the specified format
_ClipBoard_Open | Opens the clipboard and prevents other applications from modifying the clipboard
_ClipBoard_RegisterFormat | Registers a new clipboard format
_ClipBoard_SetData | Places data on the clipboard in a specified clipboard format
_ClipBoard_SetDataEx | Places data on the clipboard in a specified clipboard format
_ClipBoard_SetViewer | Adds the specified window to the chain of clipboard viewers
_ClipPutFile | Copy Files to Clipboard Like Explorer does
_ColorConvertHSLtoRGB | Converts HSL to RGB
_ColorConvertRGBtoHSL | Converts RGB to HSL
_ColorGetBlue | Returns the blue component of a given color
_ColorGetCOLORREF | Returns the COLORREF color
_ColorGetGreen | Returns the green component of a given color
_ColorGetRed | Returns the red component of a given color
_ColorGetRGB | Returns an array containing RGB values in their respective positions
_ColorSetCOLORREF | Returns the COLORREF color
_ColorSetRGB | Returns the RGB color
_Crypt_DecryptData | Decrypts data using the supplied key
_Crypt_DecryptFile | Decrypts a file with specified key and algorithm
_Crypt_DeriveKey | Creates a key from algorithm and password
_Crypt_DestroyKey | Frees the resources used by a key
_Crypt_EncryptData | Encrypts data using the supplied key
_Crypt_EncryptFile | Encrypts a file with specified key and algorithm
_Crypt_GenRandom | Fill a buffer with cryptographically random data
_Crypt_HashData | Hash data with specified algorithm
_Crypt_HashFile | Hash a string with specified algorithm
_Crypt_Shutdown | Uninitialize the Crypt library
_Crypt_Startup | Initialize the Crypt library
_DateAdd | Calculates a new date/time by adding/subtracting a specified number of time intervals from an initial date/time
_DateDayOfWeek | Returns the name of the weekday, based on the specified day
_DateDaysInMonth | Returns the number of days in a month, based on the specified month and year
_DateDiff | Returns the difference between 2 dates, expressed in the type requested
_DateIsLeapYear | Checks a given year to see if it is a leap year
_DateIsValid | Checks the given date to determine if it is a valid date
_DateTimeFormat | Returns the date in the PC's regional settings format
_DateTimeSplit | Split a string containing Date and Time into two separate Arrays
_DateToDayOfWeek | Returns the weekday number for a given date
_DateToDayOfWeekISO | Returns the ISO weekday number for a given date
_DateToDayValue | Returns the day number since noon 4713 BC January 1 for a given Gregorian date
_DateToMonth | Returns the name of the month, based on the specified month
_Date_Time_CompareFileTime | Compares two file times
_Date_Time_DOSDateTimeToArray | Decode a DOS date/time to an array
_Date_Time_DOSDateTimeToFileTime | Converts MS-DOS date and time values to a file time
_Date_Time_DOSDateTimeToStr | Decode a DOS date to a string
_Date_Time_DOSDateToArray | Decode a DOS date to an array
_Date_Time_DOSDateToStr | Decode a DOS date to a string
_Date_Time_DOSTimeToArray | Decode a DOS time to an array
_Date_Time_DOSTimeToStr | Decode a DOS time to a string
_Date_Time_EncodeFileTime | Encodes and returns a $tagFILETIME structure
_Date_Time_EncodeSystemTime | Encodes and returns a $tagSYSTEMTIME structure
_Date_Time_FileTimeToArray | Decode a file time to an array
_Date_Time_FileTimeToDOSDateTime | Converts MS-DOS date and time values to a file time
_Date_Time_FileTimeToLocalFileTime | Converts a file time based on the Coordinated Universal Time to a local file time
_Date_Time_FileTimeToStr | Decode a file time to a date/time string
_Date_Time_FileTimeToSystemTime | Converts a file time to system time format
_Date_Time_GetFileTime | Retrieves the date and time that a file was created, accessed and modified
_Date_Time_GetLocalTime | Retrieves the current local date and time
_Date_Time_GetSystemTime | Retrieves the current system date and time expressed in UTC
_Date_Time_GetSystemTimeAdjustment | Determines whether the system is applying periodic time adjustments
_Date_Time_GetSystemTimeAsFileTime | Retrieves the current system date and time expressed in UTC
_Date_Time_GetSystemTimes | Retrieves system timing information
_Date_Time_GetTickCount | Retrieves the number of milliseconds that have elapsed since Windows was started
_Date_Time_GetTimeZoneInformation | Retrieves the current time zone settings
_Date_Time_LocalFileTimeToFileTime | Converts a local file time to a file time based on UTC
_Date_Time_SetFileTime | Sets the date and time that a file was created, accessed and modified
_Date_Time_SetLocalTime | Sets the current local date and time
_Date_Time_SetSystemTime | Sets the current system time and date, expressed in UTC
_Date_Time_SetSystemTimeAdjustment | Enables or disables periodic time adjustments to the system's time of day clock
_Date_Time_SetTimeZoneInformation | Sets the current time zone settings
_Date_Time_SystemTimeToArray | Decode a system time to an array
_Date_Time_SystemTimeToDateStr | Decode a system time to a date string
_Date_Time_SystemTimeToDateTimeStr | Decode a system time to a date/time string
_Date_Time_SystemTimeToFileTime | Converts a system time to file time format
_Date_Time_SystemTimeToTimeStr | Decode a system time to a time string
_Date_Time_SystemTimeToTzSpecificLocalTime | Converts a UTC time to a specified time zone's corresponding local time
_Date_Time_TzSpecificLocalTimeToSystemTime | Converts a local time to a time in UTC
_DayValueToDate | Add the given days since noon 4713 BC January 1 and returns the Gregorian date
_DebugBugReportEnv | Outputs a string containing information for Bug report submission
_DebugCOMError | Sets, resets or queries the debug level for COM errors
_DebugOut | Displays output on a debugging session started by _DebugSetup()
_DebugReport | Writes to a debugging session
_DebugReportEx | Writes to a debugging session a formatted message
_DebugReportVar | Writes to debugging session the content of a variable
_DebugSetup | Setup up a debug session using a specific reporting type
_Degree | Converts radians to degrees
_EventLog__Backup | Saves the event log to a backup file
_EventLog__Clear | Clears the event log
_EventLog__Close | Closes a read handle to the event log
_EventLog__Count | Retrieves the number of records in the event log
_EventLog__DeregisterSource | Closes a write handle to the event log
_EventLog__Full | Retrieves whether the event log is full
_EventLog__Notify | Enables an application to receive event notifications
_EventLog__Oldest | Retrieves the absolute record number of the oldest record in the event log
_EventLog__Open | Opens a handle to the event log
_EventLog__OpenBackup | Opens a handle to a backup event log
_EventLog__Read | Reads an entry from the event log
_EventLog__RegisterSource | Retrieves a registered handle to the specified event log
_EventLog__Report | Writes an entry at the end of the specified event log
_Excel_BookAttach | Attaches to the first instance of a workbook where the search string matches based on the selected mode
_Excel_BookClose | Closes the specified workbook
_Excel_BookList | Returns a list of workbooks of a specified or all Excel instances
_Excel_BookNew | Creates a new workbook
_Excel_BookOpen | Opens an existing workbook
_Excel_BookOpenText | Opens a text file and parses the content to a new workbook with a single sheet
_Excel_BookSave | Saves the specified workbook
_Excel_BookSaveAs | Saves the specified workbook with a new filename and/or type
_Excel_Close | Closes all worksheets and the instance of the Excel application
_Excel_ColumnToLetter | Converts the column number to letter(s)
_Excel_ColumnToNumber | Converts the column letter(s) to a number
_Excel_ConvertFormula | Converts cell references in a formula between A1 and R1C1 reference styles, relative and absolute reference type, or both
_Excel_Export | Exports a workbook, worksheet, chart or range as PDF or XPS
_Excel_FilterGet | Returns a list of set filters
_Excel_FilterSet | Sets/unsets filter definitions and filters the range
_Excel_Open | Connects to an existing Excel instance or creates a new one
_Excel_PictureAdd | Adds a picture on the specified workbook and worksheet
_Excel_Print | Prints a workbook, worksheet, chart or range
_Excel_RangeCopyPaste | Cuts or copies one or multiple cells, rows or columns to a range or from/to the clipboard
_Excel_RangeDelete | Deletes one or multiple cells, rows or columns from the specified worksheet
_Excel_RangeFind | Finds matching cells in a range or workbook and returns an array with information about the found cells
_Excel_RangeInsert | Inserts one or multiple empty cells, rows or columns into the specified worksheet
_Excel_RangeLinkAddRemove | Adds or removes a hyperlink to/from a specified range
_Excel_RangeRead | Reads the value, formula or displayed text from a cell or range of cells of the specified workbook and worksheet
_Excel_RangeReplace | Finds and replaces matching strings in a range or worksheet
_Excel_RangeSort | Sorts a cell range
_Excel_RangeValidate | Adds data validation to the specified range
_Excel_RangeWrite | Writes value(s) or formula(s) to a cell or a cell range on the specified workbook and worksheet
_Excel_SheetAdd | Adds new sheet(s) to a workbook and sets their names
_Excel_SheetCopyMove | Copies or moves the specified sheet before or after a specified sheet in the same or a different workbook
_Excel_SheetDelete | Deletes the specified sheet by object, string name or by number
_Excel_SheetList | Returns a list of all sheets in the specified workbook
_FileCountLines | Returns the number of lines in the specified file
_FileCreate | Creates or zero's out the length of the file specified
_FileListToArray | Lists files and\or folders in a specified folder (Similar to using Dir with the /B Switch)
_FileListToArrayRec | Lists files and\or folders in specified path with optional recursion to defined level and result sorting
_FilePrint | Prints a plain text file
_FileReadToArray | Reads the specified file into a 1D or 2D array
_FileWriteFromArray | Writes an array to a specified file
_FileWriteLog | Writes current date, time and the specified text to a log file
_FileWriteToLine | Writes text to a specific line in a file
_FTP_Close | Closes the _FTP_Open or _FTP_Connect session
_FTP_Command | Sends a command to an FTP server
_FTP_Connect | Connects to an FTP server
_FTP_DecodeInternetStatus | Decode a received Internet Status
_FTP_DirCreate | Makes an Directory on an FTP server
_FTP_DirDelete | Delete's an Directory on an FTP server
_FTP_DirGetCurrent | Get Current Directory on an FTP server
_FTP_DirPutContents | Puts an folder on an FTP server. Recursivley if selected
_FTP_DirSetCurrent | Set Current Directory on an FTP server
_FTP_FileClose | Closes the Handle returned by _FTP_FileOpen
_FTP_FileDelete | Delete an file from an FTP server
_FTP_FileGet | Get file from a FTP server
_FTP_FileGetSize | Gets filesize of a file on the FTP server
_FTP_FileOpen | Initiates access to a remote file on an FTP server for reading or writing
_FTP_FilePut | Puts an file on an FTP server
_FTP_FileRead | Reads data from a handle opened by _FTP_FileOpen()
_FTP_FileRename | Renames an file on an FTP server
_FTP_FileTimeLoHiToStr | Converts filetime Loword and Hiword to a string
_FTP_FindFileClose | Delete FindFile Handle
_FTP_FindFileFirst | Find First File on an FTP server
_FTP_FindFileNext | Find Next File on an FTP server
_FTP_GetLastResponseInfo | Retrieves the last error description or server response on the thread calling this function
_FTP_ListToArray | Get Filenames, Directories or Both of current remote directory
_FTP_ListToArray2D | Get Filenames and filesizes of current remote directory
_FTP_ListToArrayEx | Get names, sizes, attributes and times of files/dir of current remote directory
_FTP_Open | Opens an FTP session
_FTP_ProgressDownload | Downloads a file in Binary Mode and shows a Progress window or by Calling a User defined Function
_FTP_ProgressUpload | Uploads a file in Binary Mode and shows a Progress window or by Calling a User defined Function
_FTP_SetStatusCallback | Registers callback function that WinINet functions can call as progress is made during an operation
_GDIPlus_ArrowCapCreate | Creates an adjustable arrow line cap with the specified height and width
_GDIPlus_ArrowCapDispose | Release an adjustable arrow line cap object
_GDIPlus_ArrowCapGetFillState | Determines whether the arrow cap is filled
_GDIPlus_ArrowCapGetHeight | Gets the height of the arrow cap
_GDIPlus_ArrowCapGetMiddleInset | Gets the value of the inset
_GDIPlus_ArrowCapGetWidth | Gets the width of the arrow cap
_GDIPlus_ArrowCapSetFillState | Sets whether the arrow cap is filled
_GDIPlus_ArrowCapSetHeight | Sets the height of the arrow cap
_GDIPlus_ArrowCapSetMiddleInset | Gets the value of the inset
_GDIPlus_ArrowCapSetWidth | Sets the width of the arrow cap
_GDIPlus_BitmapApplyEffect | Alters a Bitmap by applying a specified effect
_GDIPlus_BitmapApplyEffectEx | Alters a Bitmap by applying a specified effect
_GDIPlus_BitmapCloneArea | Create a clone of a Bitmap object from the coordinates and format specified
_GDIPlus_BitmapConvertFormat | Converts a bitmap to a specified pixel format
_GDIPlus_BitmapCreateApplyEffect | Creates a new Bitmap by applying a specified effect to an existing Bitmap
_GDIPlus_BitmapCreateApplyEffectEx | Creates a new Bitmap by applying a specified effect to an existing Bitmap
_GDIPlus_BitmapCreateDIBFromBitmap | Creates a DIB Section
_GDIPlus_BitmapCreateFromFile | Create a Bitmap object from file
_GDIPlus_BitmapCreateFromGraphics | Creates a Bitmap object based on a Graphics object, a width, and a height
_GDIPlus_BitmapCreateFromHBITMAP | Create a Bitmap object from a bitmap handle
_GDIPlus_BitmapCreateFromHICON | Creates a Bitmap object based on an icon
_GDIPlus_BitmapCreateFromHICON32 | Creates a Bitmap object based on a 32bit icon
_GDIPlus_BitmapCreateFromMemory | Loads an image (JPG, BMP, PNG, etc.) which is saved as a binary string and converts it to a bitmap (GDI+) or hbitmap (GDI)
_GDIPlus_BitmapCreateFromResource | Creates a Bitmap object based on an icon
_GDIPlus_BitmapCreateFromScan0 | Creates a Bitmap object based on an array of bytes along with size and format information
_GDIPlus_BitmapCreateFromStream | Creates a Bitmap object based on an IStream COM interface
_GDIPlus_BitmapCreateHBITMAPFromBitmap | Create a handle to a bitmap from a bitmap object
_GDIPlus_BitmapDispose | Release a bitmap object
_GDIPlus_BitmapGetHistogram | Returns one or more histograms for specified color channels of the specified Bitmap
_GDIPlus_BitmapGetHistogramEx | Returns histograms for the Bitmap´s color channels: Red, Green, Blue, Alpha and Grey
_GDIPlus_BitmapGetHistogramSize | Returns the number of elements for allocation by _GDIPlus_BitmapGetHistogramEx()
_GDIPlus_BitmapGetPixel | Gets the color of a specified pixel in this bitmap
_GDIPlus_BitmapLockBits | Locks a portion of a bitmap for reading or writing
_GDIPlus_BitmapSetPixel | Sets the color of a specified pixel in this bitmap
_GDIPlus_BitmapUnlockBits | Unlocks a portion of a bitmap that was locked by _GDIPlus_BitmapLockBits
_GDIPlus_BrushClone | Clone a Brush object
_GDIPlus_BrushCreateSolid | Create a solid Brush object
_GDIPlus_BrushDispose | Release a Brush object
_GDIPlus_BrushGetSolidColor | Get the color of a Solid Brush object
_GDIPlus_BrushGetType | Retrieve the type of Brush object
_GDIPlus_BrushSetSolidColor | Set the color of a Solid Brush object
_GDIPlus_ColorMatrixCreate | Creates and initializes an identity color matrix
_GDIPlus_ColorMatrixCreateGrayScale | Creates and initializes a gray-scaling color matrix
_GDIPlus_ColorMatrixCreateNegative | Creates and initializes a negative color matrix
_GDIPlus_ColorMatrixCreateSaturation | Creates and initializes a saturation color matrix
_GDIPlus_ColorMatrixCreateScale | Creates and initializes a scaling color matrix
_GDIPlus_ColorMatrixCreateTranslate | Creates and initializes a translation color matrix
_GDIPlus_CustomLineCapClone | Clones a CustomLineCap object
_GDIPlus_CustomLineCapCreate | Creates a CustomLineCap object
_GDIPlus_CustomLineCapDispose | Release a custom line cap object
_GDIPlus_CustomLineCapGetStrokeCaps | Gets the end cap styles for both the start line cap and the end line cap
_GDIPlus_CustomLineCapSetStrokeCaps | Sets the distance between the base cap to the start of the line
_GDIPlus_Decoders | Get an array of information about the available image decoders
_GDIPlus_DecodersGetCount | Get the number of available image decoders
_GDIPlus_DecodersGetSize | Get the total size of the structure that is returned by _GDIPlus_GetImageDecoders
_GDIPlus_DrawImageFX | Draws a portion of an image after applying a specified effect
_GDIPlus_DrawImageFXEx | Draws a portion of an image after applying a specified effect
_GDIPlus_DrawImagePoints | Draws an image at a specified location
_GDIPlus_EffectCreate | Creates an Effect object of the type specified by the guid parameter
_GDIPlus_EffectCreateBlur | Creates a Blur class effect object
_GDIPlus_EffectCreateBrightnessContrast | Creates a BrightnessContrast class effect object
_GDIPlus_EffectCreateColorBalance | Creates a ColorBalance class effect object
_GDIPlus_EffectCreateColorCurve | Creates a ColorBalance class effect object
_GDIPlus_EffectCreateColorLUT | Creates a ColorLUT class effect object
_GDIPlus_EffectCreateColorMatrix | Creates a ColorMatrixEffect class effect object
_GDIPlus_EffectCreateHueSaturationLightness | Creates a HueSaturationLightness class effect object
_GDIPlus_EffectCreateLevels | Creates a Levels class effect object
_GDIPlus_EffectCreateRedEyeCorrection | Creates a RedEyeCorrection class effect object
_GDIPlus_EffectCreateSharpen | Creates a Sharpen class effect object
_GDIPlus_EffectCreateTint | Creates a Tint class effect object
_GDIPlus_EffectDispose | Deletes the specified Effect object
_GDIPlus_EffectGetParameters | Returns the parameters for the specified Effect object
_GDIPlus_EffectSetParameters | Sets the parameters for the specified Effect object
_GDIPlus_Encoders | Get an array of information about the available image encoders
_GDIPlus_EncodersGetCLSID | Return the encoder CLSID for a specific image file type
_GDIPlus_EncodersGetCount | Get the number of available image encoders
_GDIPlus_EncodersGetParamList | Get the parameter list for a specified image encoder
_GDIPlus_EncodersGetParamListSize | Get the size of the parameter list for a specified image encoder
_GDIPlus_EncodersGetSize | Get the total size of the structure that is returned by _GDIPlus_GetImageEncoders
_GDIPlus_FontCreate | Create a Font object
_GDIPlus_FontDispose | Release a Font object
_GDIPlus_FontFamilyCreate | Create a Font Family object
_GDIPlus_FontFamilyCreateFromCollection | Creates a FontFamily object based on a specified font family
_GDIPlus_FontFamilyDispose | Release a Font Family object
_GDIPlus_FontFamilyGetCellAscent | Gets the cell ascent, in design units, of a font family for the specified style or style combination
_GDIPlus_FontFamilyGetCellDescent | Gets the cell descent, in design units, of a font family for the specified style or style combination
_GDIPlus_FontFamilyGetEmHeight | Gets the size (commonly called em size or em height), in design units, of a font family
_GDIPlus_FontFamilyGetLineSpacing | Gets the line spacing, in design units, of this font family for the specified style or style combination
_GDIPlus_FontGetHeight | Gets the line spacing of a font in the current unit of a specified Graphics object
_GDIPlus_FontPrivateAddFont | Adds a font file to the private font collection
_GDIPlus_FontPrivateAddMemoryFont | Adds a font that is contained in system memory to a Microsoft® Windows® GDI+ font collection
_GDIPlus_FontPrivateCollectionDispose | Deletes the specified PrivateFontCollection object
_GDIPlus_FontPrivateCreateCollection | Creates a PrivateFont Collection object
_GDIPlus_GraphicsClear | Clears a Graphics object to a specified color
_GDIPlus_GraphicsCreateFromHDC | Create a Graphics object from a device context (DC)
_GDIPlus_GraphicsCreateFromHWND | Create a Graphics object from a window handle
_GDIPlus_GraphicsDispose | Release a Graphics object
_GDIPlus_GraphicsDrawArc | Draw an arc
_GDIPlus_GraphicsDrawBezier | Draw a bezier spline
_GDIPlus_GraphicsDrawClosedCurve | Draw a closed cardinal spline
_GDIPlus_GraphicsDrawClosedCurve2 | Draws a closed cardinal spline
_GDIPlus_GraphicsDrawCurve | Draw a cardinal spline
_GDIPlus_GraphicsDrawCurve2 | Draws a cardinal spline
_GDIPlus_GraphicsDrawEllipse | Draw an ellipse
_GDIPlus_GraphicsDrawImage | Draw an Image object
_GDIPlus_GraphicsDrawImagePointsRect | Draws an image
_GDIPlus_GraphicsDrawImageRect | Draws an image at a specified location
_GDIPlus_GraphicsDrawImageRectRect | Draw an Image object
_GDIPlus_GraphicsDrawLine | Draw a line
_GDIPlus_GraphicsDrawPath | Draws a sequence of lines and curves defined by a GraphicsPath object
_GDIPlus_GraphicsDrawPie | Draw a pie
_GDIPlus_GraphicsDrawPolygon | Draw a polygon
_GDIPlus_GraphicsDrawRect | Draw a rectangle
_GDIPlus_GraphicsDrawString | Draw a string
_GDIPlus_GraphicsDrawStringEx | Draw a string
_GDIPlus_GraphicsFillClosedCurve | Fill a closed cardinal spline
_GDIPlus_GraphicsFillClosedCurve2 | Creates a closed cardinal spline from an array of points and uses a brush to fill the interior of the spline
_GDIPlus_GraphicsFillEllipse | Fill an ellipse
_GDIPlus_GraphicsFillPath | Uses a brush to fill the interior of a path
_GDIPlus_GraphicsFillPie | Fill a pie
_GDIPlus_GraphicsFillPolygon | Fill a polygon
_GDIPlus_GraphicsFillRect | Fill a rectangle
_GDIPlus_GraphicsFillRegion | Uses a brush to fill a specified region
_GDIPlus_GraphicsGetCompositingMode | Gets the compositing mode currently set for a Graphics object
_GDIPlus_GraphicsGetCompositingQuality | Gets the compositing quality currently set for a Graphics object
_GDIPlus_GraphicsGetDC | Gets a handle to the device context of the Graphics object
_GDIPlus_GraphicsGetInterpolationMode | Gets the interpolation mode currently set for a Graphics object
_GDIPlus_GraphicsGetSmoothingMode | Gets the graphics object rendering quality
_GDIPlus_GraphicsGetTransform | Gets the world transformation matrix of a Graphics object
_GDIPlus_GraphicsMeasureCharacterRanges | Gets a set of region objects each of which bounds a range of character positions within a string
_GDIPlus_GraphicsMeasureString | Measures the size of a string
_GDIPlus_GraphicsReleaseDC | Releases the device context of the Graphics object
_GDIPlus_GraphicsResetClip | Sets the clipping region of a Graphics object to an infinite region
_GDIPlus_GraphicsResetTransform | Sets the world transformation matrix of a Graphics object to the identity matrix
_GDIPlus_GraphicsRestore | Restores the state of a Graphics object to the state stored by a previous call to the _GDIPlus_GraphicsSave method of the Graphics object
_GDIPlus_GraphicsRotateTransform | Updates the world transformation matrix of a Graphics object with the product of itself and a rotation matrix
_GDIPlus_GraphicsSave | Saves the current state (transformations, clipping region, and quality settings) of a Graphics object
_GDIPlus_GraphicsScaleTransform | Updates a Graphics object's world transformation matrix with the product of itself and a scaling matrix
_GDIPlus_GraphicsSetClipPath | Updates the clipping region of this Graphics object to a region that is the combination of itself and the region specified by a graphics path
_GDIPlus_GraphicsSetClipRect | Updates the clipping region of a Graphics object to a region that is the combination of itself and a rectangle
_GDIPlus_GraphicsSetClipRegion | Updates the clipping region of a Graphics object to a region that is the combination of itself and the region specified by a Region object
_GDIPlus_GraphicsSetCompositingMode | Sets the compositing mode of a Graphics object
_GDIPlus_GraphicsSetCompositingQuality | Sets the compositing quality of a Graphics object
_GDIPlus_GraphicsSetInterpolationMode | Sets the interpolation mode of a Graphics object
_GDIPlus_GraphicsSetPixelOffsetMode | Sets the pixel offset mode of a Graphics object
_GDIPlus_GraphicsSetSmoothingMode | Sets the graphics object rendering quality
_GDIPlus_GraphicsSetTextRenderingHint | Sets the contrast value of a Graphics object
_GDIPlus_GraphicsSetTransform | Sets the world transformation for a graphics object
_GDIPlus_GraphicsTransformPoints | Converts an array of points from one coordinate space to another
_GDIPlus_GraphicsTranslateTransform | Updates a Graphics object's world transformation matrix with the product of itself and a translation matrix
_GDIPlus_HatchBrushCreate | Creates a HatchBrush object based on a hatch style, a foreground color, and a background color
_GDIPlus_HICONCreateFromBitmap | Creates an icon handle from a bitmap object
_GDIPlus_ImageAttributesCreate | Creates an ImageAttributes object
_GDIPlus_ImageAttributesDispose | Releases an ImageAttributes object
_GDIPlus_ImageAttributesSetColorKeys | Sets or clears the color key (transparency range) for a specified category
_GDIPlus_ImageAttributesSetColorMatrix | Sets or clears the color- and grayscale-adjustment matrices for a specified category
_GDIPlus_ImageDispose | Release an image object
_GDIPlus_ImageGetDimension | Gets the width and height of an image which is supported by GDIPlus
_GDIPlus_ImageGetFlags | Returns enumeration of pixel data attributes contained in an image
_GDIPlus_ImageGetGraphicsContext | Get the graphics context of the image
_GDIPlus_ImageGetHeight | Get the image height
_GDIPlus_ImageGetHorizontalResolution | Returns horizontal resolution in DPI (pixels per inch) of an image
_GDIPlus_ImageGetPixelFormat | Returns pixel format of an image: Bits per pixel, Alpha channels, RGB, Grayscale, Indexed etc
_GDIPlus_ImageGetRawFormat | Returns file format GUID and image format name of an image
_GDIPlus_ImageGetThumbnail | Gets a thumbnail image from this Image object
_GDIPlus_ImageGetType | Returns type (bitmap or metafile) of an image
_GDIPlus_ImageGetVerticalResolution | Returns vertical resolution in DPI (pixels per inch) of an image
_GDIPlus_ImageGetWidth | Get the image width
_GDIPlus_ImageLoadFromFile | Create an image object based on a file
_GDIPlus_ImageLoadFromStream | Creates an Image object based on a stream
_GDIPlus_ImageResize | Resize an image to a new given size
_GDIPlus_ImageRotateFlip | Rotates and flips an image
_GDIPlus_ImageSaveToFile | Save an image to file
_GDIPlus_ImageSaveToFileEx | Save an image to file
_GDIPlus_ImageSaveToStream | Saves an Image object to a stream
_GDIPlus_ImageScale | Scales an image by a given factor
_GDIPlus_LineBrushCreate | Creates a LinearGradientBrush object from a set of boundary points and boundary colors
_GDIPlus_LineBrushCreateFromRect | Creates a LinearGradientBrush object from a rectangle and boundary colors
_GDIPlus_LineBrushCreateFromRectWithAngle | Creates a LinearGradientBrush object from a rectangle, boundary colors and angle of direction
_GDIPlus_LineBrushGetColors | Gets the starting color and ending color of a linear gradient brush
_GDIPlus_LineBrushGetRect | Gets the rectangle that defines the boundaries of a linear gradient brush
_GDIPlus_LineBrushMultiplyTransform | Updates a brush's transformation matrix with the product of itself and another matrix
_GDIPlus_LineBrushResetTransform | Resets the transformation matrix of a linear gradient brush to the identity matrix
_GDIPlus_LineBrushSetBlend | Sets the blend factors and the blend positions of a linear gradient brush to create a custom blend
_GDIPlus_LineBrushSetColors | Sets the starting color and ending color of a linear gradient brush
_GDIPlus_LineBrushSetGammaCorrection | Specifies whether gamma correction is enabled for a linear gradient brush
_GDIPlus_LineBrushSetLinearBlend | Sets the blend shape of a linear gradient brush to create a custom blend based on a triangular shape
_GDIPlus_LineBrushSetPresetBlend | Sets the colors to be interpolated for a linear gradient brush and their corresponding blend positions
_GDIPlus_LineBrushSetSigmaBlend | Sets the blend shape of a linear gradient brush to create a custom blend based on a bell-shaped curve
_GDIPlus_LineBrushSetTransform | Sets the transformation matrix of a linear gradient brush
_GDIPlus_MatrixClone | Clones a Matrix object
_GDIPlus_MatrixCreate | Creates and initializes a Matrix object that represents the identity matrix
_GDIPlus_MatrixDispose | Release a matrix object
_GDIPlus_MatrixGetElements | Gets the elements of a matrix
_GDIPlus_MatrixInvert | Replaces the elements of a matrix with the elements of its inverse
_GDIPlus_MatrixMultiply | Updates a matrix with the product of itself and another matrix
_GDIPlus_MatrixRotate | Updates a matrix with the product of itself and a rotation matrix
_GDIPlus_MatrixScale | Updates a matrix with the product of itself and a scaling matrix
_GDIPlus_MatrixSetElements | Sets the elements of a matrix
_GDIPlus_MatrixShear | Updates a matrix with the product of itself and another matrix
_GDIPlus_MatrixTransformPoints | Multiplies each point in an array by a matrix
_GDIPlus_MatrixTranslate | Updates a matrix with the product of itself and a translation matrix
_GDIPlus_PaletteInitialize | Initializes a standard, optimal, or custom color palette
_GDIPlus_ParamAdd | Add a value to an encoder parameter list
_GDIPlus_ParamInit | Allocate an empty encoder parameter list
_GDIPlus_ParamSize | Get an encoder parameter size
_GDIPlus_PathAddArc | Adds an elliptical arc to the current figure of a path
_GDIPlus_PathAddBezier | Adds a bezier spline to the current figure of a path
_GDIPlus_PathAddClosedCurve | Adds a closed cardinal spline to a path
_GDIPlus_PathAddClosedCurve2 | Adds a closed cardinal spline to a path
_GDIPlus_PathAddCurve | Adds a cardinal spline to the current figure of a path
_GDIPlus_PathAddCurve2 | Adds a cardinal spline to the current figure of a path
_GDIPlus_PathAddCurve3 | Adds a cardinal spline to the current figure of a path
_GDIPlus_PathAddEllipse | Adds an ellipse to the current figure a path
_GDIPlus_PathAddLine | Adds a line to the current figure of a path
_GDIPlus_PathAddLine2 | Adds a sequence of lines to the current figure of a path
_GDIPlus_PathAddPath | Adds a path to another path
_GDIPlus_PathAddPie | Adds a pie to a path
_GDIPlus_PathAddPolygon | Adds a polygon to a path
_GDIPlus_PathAddRectangle | Adds a rectangle to a path
_GDIPlus_PathAddString | Adds the outline of a string to a path
_GDIPlus_PathBrushCreate | Creates a PathGradientBrush object based on an array of points and initializes the wrap mode of the brush
_GDIPlus_PathBrushCreateFromPath | Creates a PathGradientBrush object based on a GraphicsPath object
_GDIPlus_PathBrushGetCenterPoint | Gets the center point of a path gradient brush
_GDIPlus_PathBrushGetFocusScales | Gets the focus scales of a path gradient brush
_GDIPlus_PathBrushGetPointCount | Gets the number of points in the array of points that defines a brush's boundary path
_GDIPlus_PathBrushGetRect | Gets the smallest rectangle that encloses the boundary path of a path gradient brush
_GDIPlus_PathBrushGetWrapMode | Gets the wrap mode currently set for a path gradient brush
_GDIPlus_PathBrushMultiplyTransform | Updates a brush's transformation matrix with the product of itself and another matrix
_GDIPlus_PathBrushResetTransform | Resets the transformation matrix of a path gradient brush to the identity matrix
_GDIPlus_PathBrushSetBlend | Sets the blend factors and the blend positions of a path gradient brush
_GDIPlus_PathBrushSetCenterColor | Sets the color of the center point of a path gradient brush
_GDIPlus_PathBrushSetCenterPoint | Sets the center point of a path gradient brush
_GDIPlus_PathBrushSetFocusScales | Sets the focus scales of a path gradient brush
_GDIPlus_PathBrushSetGammaCorrection | Specifies whether gamma correction is enabled for a path gradient brush
_GDIPlus_PathBrushSetLinearBlend | Sets the blend shape of a path gradient brush to create a custom blend based on a triangular shape
_GDIPlus_PathBrushSetPresetBlend | Sets the preset colors and the blend positions of a path gradient brush
_GDIPlus_PathBrushSetSigmaBlend | Sets the blend shape of a path gradient brush to create a custom blend based on a bell-shaped curve
_GDIPlus_PathBrushSetSurroundColor | Sets the surround color for a path gradient brush
_GDIPlus_PathBrushSetSurroundColorsWithCount | Sets the surround colors currently specified for a path gradient brush
_GDIPlus_PathBrushSetTransform | Sets the transformation matrix of a path gradient brush
_GDIPlus_PathBrushSetWrapMode | Sets the wrap mode of a path gradient brush
_GDIPlus_PathClone | Clones a path
_GDIPlus_PathCloseFigure | Closes the current figure of a path
_GDIPlus_PathCreate | Creates a GraphicsPath object and initializes the fill mode
_GDIPlus_PathCreate2 | Creates a GraphicsPath object based on an array of points, an array of types, and a fill mode
_GDIPlus_PathDispose | Releases a GraphicsPath object
_GDIPlus_PathFlatten | Applies a transformation to a path and converts each curve in the path to a sequence of connected lines
_GDIPlus_PathGetData | Gets an array of points and types from a path
_GDIPlus_PathGetFillMode | Gets the fill mode of a path
_GDIPlus_PathGetLastPoint | Gets the ending point of the last figure in a path
_GDIPlus_PathGetPointCount | Gets the number of points in a path's array of data points
_GDIPlus_PathGetPoints | Gets an array of points from a path
_GDIPlus_PathGetWorldBounds | Gets the bounding rectangle for a path
_GDIPlus_PathIsOutlineVisiblePoint | Determines whether a specified point touches the outline of a path with the specified Graphics and Pen
_GDIPlus_PathIsVisiblePoint | Determines whether a specified point lies in the area that is filled when a path is filled by a specified Graphics object
_GDIPlus_PathIterCreate | Creates a new GraphicsPathIterator object and associates it with a GraphicsPath object
_GDIPlus_PathIterDispose | Releases a GraphicsPathIterator object
_GDIPlus_PathIterGetSubpathCount | Gets the number of subpaths (also called figures) in the path
_GDIPlus_PathIterNextMarkerPath | Gets the next marker-delimited section of an iterator's associated path
_GDIPlus_PathIterNextSubpathPath | Gets the next figure (subpath) from an iterator's associated path
_GDIPlus_PathIterRewind | Rewinds an iterator to the beginning of its associated path
_GDIPlus_PathReset | Empties a path and sets the fill mode to alternate (0)
_GDIPlus_PathReverse | Reverses the order of the points that define a path's lines and curves
_GDIPlus_PathSetFillMode | Sets the fill mode of a path
_GDIPlus_PathSetMarker | Designates the last point in a path as a marker point
_GDIPlus_PathStartFigure | Starts a new figure without closing the current figure. Subsequent points added to a path are added to the new figure
_GDIPlus_PathTransform | Multiplies each of a path's data points by a specified matrix
_GDIPlus_PathWarp | Applies a warp transformation to a path. The function also flattens (converts to a sequence of straight lines) the path
_GDIPlus_PathWiden | Replaces a path with curves that enclose the area that is filled when the path is drawn by a specified pen. The function also flattens the path
_GDIPlus_PathWindingModeOutline | Transforms and flattens a path, and then converts the path's data points so that they represent only the outline of the path
_GDIPlus_PenCreate | Create a pen object
_GDIPlus_PenCreate2 | Creates a Pen object that uses the attributes of a brush
_GDIPlus_PenDispose | Release a pen object
_GDIPlus_PenGetAlignment | Gets the pen alignment
_GDIPlus_PenGetColor | Gets the pen color
_GDIPlus_PenGetCustomEndCap | Gets the custom end cap for the pen
_GDIPlus_PenGetDashCap | Gets the pen dash cap style
_GDIPlus_PenGetDashStyle | Gets the pen dash style
_GDIPlus_PenGetEndCap | Gets the pen end cap
_GDIPlus_PenGetMiterLimit | Gets the miter length currently set for a Pen object
_GDIPlus_PenGetWidth | Retrieve the width of a pen
_GDIPlus_PenSetAlignment | Sets the pen alignment
_GDIPlus_PenSetColor | Sets the pen color
_GDIPlus_PenSetCustomEndCap | Sets the custom end cap for the pen
_GDIPlus_PenSetDashCap | Sets the pen dash cap style
_GDIPlus_PenSetDashStyle | Sets the pen dash style
_GDIPlus_PenSetEndCap | Sets the pen end cap
_GDIPlus_PenSetLineCap | Sets the cap styles for the start, end, and dashes in a line drawn with the pen
_GDIPlus_PenSetLineJoin | Sets the line join for a Pen object
_GDIPlus_PenSetMiterLimit | Sets the miter limit of a Pen object
_GDIPlus_PenSetStartCap | Sets the start cap for a Pen object
_GDIPlus_PenSetWidth | Sets the width of a pen
_GDIPlus_RectFCreate | Create a $tagGDIPRECTF structure
_GDIPlus_RegionClone | Clones a Region object
_GDIPlus_RegionCombinePath | Updates a region to the portion of itself that intersects the specified path's interior
_GDIPlus_RegionCombineRect | Updates a region to the portion of itself that intersects the specified rectangle's interior
_GDIPlus_RegionCombineRegion | Updates a region to the portion of itself that intersects another region
_GDIPlus_RegionCreate | Creates a region that is infinite
_GDIPlus_RegionCreateFromPath | Creates a region that is defined by a path object and has a fill mode that is contained in the path object
_GDIPlus_RegionCreateFromRect | Creates a region that is defined by a rectangle
_GDIPlus_RegionDispose | Releases a Region object
_GDIPlus_RegionGetBounds | Gets a rectangle that encloses a region
_GDIPlus_RegionGetHRgn | Creates a GDI region from a GDI+ Region object
_GDIPlus_RegionTransform | Tansforms a region by multiplying each of its data points by a specified matrix
_GDIPlus_RegionTranslate | Offsets a region by specified amounts in the horizontal and vertical directions
_GDIPlus_Shutdown | Clean up resources used by Microsoft Windows GDI+
_GDIPlus_Startup | Initialize Microsoft Windows GDI+
_GDIPlus_StringFormatCreate | Create a String Format object
_GDIPlus_StringFormatDispose | Release a String Format object
_GDIPlus_StringFormatGetMeasurableCharacterRangeCount | Gets the number of measurable character ranges that are currently set for a StringFormat object
_GDIPlus_StringFormatSetAlign | Sets the text alignment of a string format object
_GDIPlus_StringFormatSetLineAlign | Sets the line alignment of a StringFormat object in relation to the origin of a layout rectangle
_GDIPlus_StringFormatSetMeasurableCharacterRanges | Sets a series of character ranges for a StringFormat object that, when in a string, can be measured
_GDIPlus_TextureCreate | Creates a TextureBrush object based on an image and a wrap mode
_GDIPlus_TextureCreate2 | Creates a TextureBrush object based on an image, a wrap mode and a defining rectangle
_GDIPlus_TextureCreateIA | Creates a TextureBrush object based on an image, a defining rectangle, and a set of image properties
_GetIP | Get public IP address of a network/computer
_GUICtrlAVI_Close | Closes an AVI clip
_GUICtrlAVI_Create | Creates an AVI control
_GUICtrlAVI_Destroy | Delete the control
_GUICtrlAVI_IsPlaying | Checks whether an Audio-Video Interleaved (AVI) clip is playing
_GUICtrlAVI_Open | Opens an AVI clip and displays its first frame in an animation control
_GUICtrlAVI_OpenEx | Opens an AVI clip and displays its first frame in an animation control
_GUICtrlAVI_Play | Plays an AVI clip in an animation control
_GUICtrlAVI_Seek | Directs an AVI control to display a particular frame of an AVI clip
_GUICtrlAVI_Show | Show/Hide the AVI control
_GUICtrlAVI_Stop | Stops playing an AVI clip
_GUICtrlButton_Click | Simulates the user clicking a button
_GUICtrlButton_Create | Creates a Button control
_GUICtrlButton_Destroy | Delete the Button control
_GUICtrlButton_Enable | Enables or disables mouse and keyboard input to the specified button
_GUICtrlButton_GetCheck | Gets the check state of a radio button or check box
_GUICtrlButton_GetFocus | Retrieves if the button has keyboard focus
_GUICtrlButton_GetIdealSize | Gets the size of the button that best fits its text and image, if an image list is present
_GUICtrlButton_GetImage | Retrieves a handle to the image (icon or bitmap) associated with the button
_GUICtrlButton_GetImageList | Retrieves an array that describes the image list assigned to a button control
_GUICtrlButton_GetNote | Gets the text of the note associated with the Command Link button
_GUICtrlButton_GetNoteLength | Gets the length of the note text that may be displayed in the description for a command link button
_GUICtrlButton_GetSplitInfo | Gets information for a split button control
_GUICtrlButton_GetState | Determines the state of a button or check box
_GUICtrlButton_GetText | Retrieve the text of the button
_GUICtrlButton_GetTextMargin | Gets the margins used to draw text in a button control
_GUICtrlButton_SetCheck | Sets the check state of a radio button or check box
_GUICtrlButton_SetDontClick | Sets the state of $BST_DONTCLICK flag on a button
_GUICtrlButton_SetFocus | Sets the keyboard focus to the specified button
_GUICtrlButton_SetImage | Sets the image of a button
_GUICtrlButton_SetImageList | Assigns an image list to a button control
_GUICtrlButton_SetNote | Sets the text of the note associated with a command link button
_GUICtrlButton_SetShield | Sets the elevation required state for a specified button or command link to display an elevated icon
_GUICtrlButton_SetSize | Sets the size of the button
_GUICtrlButton_SetSplitInfo | Gets information for a split button control
_GUICtrlButton_SetState | Sets the highlight state of a button. The highlight state indicates whether the button is highlighted as if the user had pushed it
_GUICtrlButton_SetStyle | Sets the style of a button
_GUICtrlButton_SetText | Sets the text of the button
_GUICtrlButton_SetTextMargin | Sets the margins for drawing text in a button control
_GUICtrlButton_Show | Show/Hide button
_GUICtrlComboBoxEx_AddDir | Adds the names of directories and files
_GUICtrlComboBoxEx_AddString | Add a string
_GUICtrlComboBoxEx_BeginUpdate | Prevents updating of the control until the EndUpdate function is called
_GUICtrlComboBoxEx_Create | Create a ComboBoxEx control
_GUICtrlComboBoxEx_CreateSolidBitMap | Creates a solid color bitmap
_GUICtrlComboBoxEx_DeleteString | Removes an item from a ComboBoxEx control
_GUICtrlComboBoxEx_Destroy | Delete the control
_GUICtrlComboBoxEx_EndUpdate | Enables screen repainting that was turned off with the BeginUpdate function
_GUICtrlComboBoxEx_FindStringExact | Search for a string
_GUICtrlComboBoxEx_GetComboBoxInfo | Gets information about the specified ComboBox
_GUICtrlComboBoxEx_GetComboControl | Gets the handle to the child combo box control
_GUICtrlComboBoxEx_GetCount | Retrieve the number of items
_GUICtrlComboBoxEx_GetCurSel | Retrieve the index of the currently selected item
_GUICtrlComboBoxEx_GetDroppedControlRect | Retrieve the screen coordinates of a combo box in its dropped-down state
_GUICtrlComboBoxEx_GetDroppedControlRectEx | Retrieve the screen coordinates of a combo box in its dropped-down state
_GUICtrlComboBoxEx_GetDroppedState | Determines whether the ListBox of a ComboBox is dropped down
_GUICtrlComboBoxEx_GetDroppedWidth | Retrieve the minimum allowable width, of the ListBox of a ComboBox
_GUICtrlComboBoxEx_GetEditControl | Gets the handle to the edit control portion of a ComboBoxEx control
_GUICtrlComboBoxEx_GetEditSel | Gets the starting and ending character positions of the current selection in the edit control of a ComboBox
_GUICtrlComboBoxEx_GetEditText | Get the text from the edit control of a ComboBoxEx
_GUICtrlComboBoxEx_GetExtendedStyle | Gets the extended styles that are in use for a ComboBoxEx control
_GUICtrlComboBoxEx_GetExtendedUI | Determines whether a ComboBox has the default user interface or the extended user interface
_GUICtrlComboBoxEx_GetImageList | Retrieves the handle to an image list assigned to a ComboBoxEx control
_GUICtrlComboBoxEx_GetItem | Retrieves an item's attributes
_GUICtrlComboBoxEx_GetItemEx | Retrieves some or all of an item's attributes
_GUICtrlComboBoxEx_GetItemHeight | Determines the height of list items or the selection field in a ComboBox
_GUICtrlComboBoxEx_GetItemImage | Retrieves the index of the item's icon
_GUICtrlComboBoxEx_GetItemIndent | Retrieves the number of image widths the item is indented
_GUICtrlComboBoxEx_GetItemOverlayImage | Retrieves the index of the item's overlay image icon
_GUICtrlComboBoxEx_GetItemParam | Retrieves the application specific value of the item
_GUICtrlComboBoxEx_GetItemSelectedImage | Retrieves the index of the item's selected image icon
_GUICtrlComboBoxEx_GetItemText | Retrieve a string from the list of a ComboBox
_GUICtrlComboBoxEx_GetItemTextLen | Gets the length, in characters, of a string in the list of a combo box
_GUICtrlComboBoxEx_GetList | Retrieves all items from the list portion of a ComboBox control
_GUICtrlComboBoxEx_GetListArray | Retrieves all items from the list portion of a ComboBox control
_GUICtrlComboBoxEx_GetLocale | Retrieves the current locale
_GUICtrlComboBoxEx_GetLocaleCountry | Retrieves the current country code
_GUICtrlComboBoxEx_GetLocaleLang | Retrieves the current language identifier
_GUICtrlComboBoxEx_GetLocalePrimLang | Extract primary language id from a language id
_GUICtrlComboBoxEx_GetLocaleSubLang | Extract sublanguage id from a language id
_GUICtrlComboBoxEx_GetMinVisible | Retrieve the minimum number of visible items in the drop-down list of a ComboBox
_GUICtrlComboBoxEx_GetTopIndex | Retrieve the 0-based index of the first visible item in the ListBox portion of a ComboBox
_GUICtrlComboBoxEx_GetUnicode | Retrieves if control is using Unicode
_GUICtrlComboBoxEx_InitStorage | Allocates memory for storing ListBox items
_GUICtrlComboBoxEx_InsertString | Inserts a new item in the control
_GUICtrlComboBoxEx_LimitText | Limits the length of the text the user may type into the edit control of a ComboBox
_GUICtrlComboBoxEx_ReplaceEditSel | Replace text selected in edit box
_GUICtrlComboBoxEx_ResetContent | Removes all items
_GUICtrlComboBoxEx_SetCurSel | Select a string in the list of a ComboBox
_GUICtrlComboBoxEx_SetDroppedWidth | Set the maximum allowable width, in pixels, of the ListBox of a ComboBox
_GUICtrlComboBoxEx_SetEditSel | Select characters in the edit control of a ComboBox
_GUICtrlComboBoxEx_SetEditText | Set the text of the edit control of the ComboBox
_GUICtrlComboBoxEx_SetExtendedStyle | Sets extended styles within a ComboBoxEx control
_GUICtrlComboBoxEx_SetExtendedUI | Select either the default user interface or the extended user interface
_GUICtrlComboBoxEx_SetImageList | Sets an image list for a ComboBoxEx control
_GUICtrlComboBoxEx_SetItem | Sets some or all of a item's attributes
_GUICtrlComboBoxEx_SetItemEx | Sets some or all of a item's attributes
_GUICtrlComboBoxEx_SetItemHeight | Set the height of list items or the selection field in a ComboBox
_GUICtrlComboBoxEx_SetItemImage | Sets the index of the item's icon in the control's image list
_GUICtrlComboBoxEx_SetItemIndent | Sets the number of image widths to indent the item
_GUICtrlComboBoxEx_SetItemOverlayImage | Sets the index of the item's overlay icon in the control's image list
_GUICtrlComboBoxEx_SetItemParam | Sets the value specific to the item
_GUICtrlComboBoxEx_SetItemSelectedImage | Sets the index of the item's overlay icon in the control's image list
_GUICtrlComboBoxEx_SetMinVisible | Set the minimum number of visible items in the drop-down list of a ComboBox
_GUICtrlComboBoxEx_SetTopIndex | Ensure that a particular item is visible in the ListBox of a ComboBox
_GUICtrlComboBoxEx_SetUnicode | Sets if control is using Unicode
_GUICtrlComboBoxEx_ShowDropDown | Show or hide the ListBox of a ComboBox
_GUICtrlComboBox_AddDir | Adds the names of directories and files
_GUICtrlComboBox_AddString | Add a string
_GUICtrlComboBox_AutoComplete | AutoComplete a ComboBox edit control
_GUICtrlComboBox_BeginUpdate | Prevents updating of the control until the EndUpdate function is called
_GUICtrlComboBox_Create | Create a ComboBox control
_GUICtrlComboBox_DeleteString | Delete a string
_GUICtrlComboBox_Destroy | Delete the control
_GUICtrlComboBox_EndUpdate | Enables screen repainting that was turned off with the BeginUpdate function
_GUICtrlComboBox_FindString | Search for a string
_GUICtrlComboBox_FindStringExact | Search for a string
_GUICtrlComboBox_GetComboBoxInfo | Gets information about the specified ComboBox
_GUICtrlComboBox_GetCount | Retrieve the number of items
_GUICtrlComboBox_GetCueBanner | Gets the cue banner text displayed in the edit control of a combo box
_GUICtrlComboBox_GetCurSel | Retrieve the index of the currently selected item
_GUICtrlComboBox_GetDroppedControlRect | Retrieve the screen coordinates of a combo box in its dropped-down state
_GUICtrlComboBox_GetDroppedControlRectEx | Retrieve the screen coordinates of a combo box in its dropped-down state
_GUICtrlComboBox_GetDroppedState | Determines whether the ListBox of a ComboBox is dropped down
_GUICtrlComboBox_GetDroppedWidth | Retrieve the minimum allowable width, of the ListBox of a ComboBox
_GUICtrlComboBox_GetEditSel | Gets the starting and ending character positions of the current selection in the edit control of a ComboBox
_GUICtrlComboBox_GetEditText | Get the text from the edit control of a ComboBox
_GUICtrlComboBox_GetExtendedUI | Determines whether a ComboBox has the default user interface or the extended user interface
_GUICtrlComboBox_GetHorizontalExtent | Gets the width, in pixels, that the ListBox of a ComboBox control can be scrolled horizontally
_GUICtrlComboBox_GetItemHeight | Determines the height of list items or the selection field in a ComboBox
_GUICtrlComboBox_GetLBText | Retrieve a string from the list of a ComboBox
_GUICtrlComboBox_GetLBTextLen | Gets the length, in characters, of a string in the list of a combo box
_GUICtrlComboBox_GetList | Retrieves all items from the list portion of a ComboBox control
_GUICtrlComboBox_GetListArray | Retrieves all items from the list portion of a ComboBox control
_GUICtrlComboBox_GetLocale | Retrieves the current locale
_GUICtrlComboBox_GetLocaleCountry | Retrieves the current country code
_GUICtrlComboBox_GetLocaleLang | Retrieves the current language identifier
_GUICtrlComboBox_GetLocalePrimLang | Extract primary language id from a language id
_GUICtrlComboBox_GetLocaleSubLang | Extract sublanguage id from a language id
_GUICtrlComboBox_GetMinVisible | Retrieve the minimum number of visible items in the drop-down list of a ComboBox
_GUICtrlComboBox_GetTopIndex | Retrieve the 0-based index of the first visible item in the ListBox portion of a ComboBox
_GUICtrlComboBox_InitStorage | Allocates memory for storing ListBox items
_GUICtrlComboBox_InsertString | Insert a string
_GUICtrlComboBox_LimitText | Limits the length of the text the user may type into the edit control of a ComboBox
_GUICtrlComboBox_ReplaceEditSel | Replace text selected in edit box
_GUICtrlComboBox_ResetContent | Remove all items from the ListBox and edit control of a ComboBox
_GUICtrlComboBox_SelectString | Searches the ListBox of a ComboBox for an item that begins with the characters in a specified string
_GUICtrlComboBox_SetCueBanner | Sets the cue banner text that is displayed for the edit control of a combo box
_GUICtrlComboBox_SetCurSel | Select a string in the list of a ComboBox
_GUICtrlComboBox_SetDroppedWidth | Set the maximum allowable width, in pixels, of the ListBox of a ComboBox
_GUICtrlComboBox_SetEditSel | Select characters in the edit control of a ComboBox
_GUICtrlComboBox_SetEditText | Set the text of the edit control of the ComboBox
_GUICtrlComboBox_SetExtendedUI | Select either the default user interface or the extended user interface
_GUICtrlComboBox_SetHorizontalExtent | Set the width, in pixels, by which a list box can be scrolled horizontally
_GUICtrlComboBox_SetItemHeight | Set the height of list items or the selection field in a ComboBox
_GUICtrlComboBox_SetMinVisible | Set the minimum number of visible items in the drop-down list of a ComboBox
_GUICtrlComboBox_SetTopIndex | Ensure that a particular item is visible in the ListBox of a ComboBox
_GUICtrlComboBox_ShowDropDown | Show or hide the ListBox of a ComboBox
_GUICtrlDTP_Create | Create a DTP control
_GUICtrlDTP_Destroy | Delete the control
_GUICtrlDTP_GetMCColor | Retrieves the specified color
_GUICtrlDTP_GetMCFont | Retrieves the month calendar font handle
_GUICtrlDTP_GetMonthCal | Retrieves the handle to child month calendar control
_GUICtrlDTP_GetRange | Retrieves the current minimum and maximum allowable system times
_GUICtrlDTP_GetRangeEx | Retrieves the current minimum and maximum allowable system times
_GUICtrlDTP_GetSystemTime | Retrieves the currently selected date and time
_GUICtrlDTP_GetSystemTimeEx | Retrieves the currently selected date and time
_GUICtrlDTP_SetFormat | Sets the display based on a given format string
_GUICtrlDTP_SetMCColor | Sets the color for a given portion of the month calendar
_GUICtrlDTP_SetMCFont | Sets the month calendar font
_GUICtrlDTP_SetRange | Sets the current minimum and maximum allowable system times
_GUICtrlDTP_SetRangeEx | Sets the current minimum and maximum allowable system times
_GUICtrlDTP_SetSystemTime | Sets the currently selected date and time
_GUICtrlDTP_SetSystemTimeEx | Sets the currently selected date and time
_GUICtrlEdit_AppendText | Append text
_GUICtrlEdit_BeginUpdate | Prevents updating of the control until the _GUICtrlEdit_EndUpdate function is called
_GUICtrlEdit_CanUndo | Determines whether there are any actions in an edit control's undo queue
_GUICtrlEdit_CharFromPos | Retrieve information about the character closest to a specified point in the client area
_GUICtrlEdit_Create | Create an Edit control
_GUICtrlEdit_Destroy | Delete the Edit control
_GUICtrlEdit_EmptyUndoBuffer | Resets the undo flag of an edit control
_GUICtrlEdit_EndUpdate | Enables screen repainting that was turned off with the _GUICtrlEdit_BeginUpdate function
_GUICtrlEdit_Find | Initiates a find dialog
_GUICtrlEdit_FmtLines | Determines whether an edit control includes soft line-break characters
_GUICtrlEdit_GetCueBanner | Gets the cue banner text displayed in the edit control
_GUICtrlEdit_GetFirstVisibleLine | Retrieves the 0-based index of the uppermost visible line in a multiline edit control
_GUICtrlEdit_GetLimitText | Gets the current text limit for an edit control
_GUICtrlEdit_GetLine | Retrieves a line of text from an edit control
_GUICtrlEdit_GetLineCount | Retrieves the number of lines
_GUICtrlEdit_GetMargins | Retrieves the widths of the left and right margins
_GUICtrlEdit_GetModify | Retrieves the state of an edit control's modification flag
_GUICtrlEdit_GetPasswordChar | Gets the password character that an edit control displays when the user enters text
_GUICtrlEdit_GetRECT | Retrieves the formatting rectangle of an edit control
_GUICtrlEdit_GetRECTEx | Retrieves the formatting rectangle of an edit control
_GUICtrlEdit_GetSel | Retrieves the starting and ending character positions of the current selection
_GUICtrlEdit_GetText | Get the text from the edit control
_GUICtrlEdit_GetTextLen | Get the length of all the text from the edit control
_GUICtrlEdit_HideBalloonTip | Hides any balloon tip associated with an edit control
_GUICtrlEdit_InsertText | Insert text
_GUICtrlEdit_LineFromChar | Retrieves the index of the line that contains the specified character index
_GUICtrlEdit_LineIndex | Retrieves the character index of the first character of a specified line
_GUICtrlEdit_LineLength | Retrieves the length, in characters, of a line
_GUICtrlEdit_LineScroll | Scrolls the text
_GUICtrlEdit_PosFromChar | Retrieves the client area coordinates of a specified character in an edit control
_GUICtrlEdit_ReplaceSel | Replaces the current selection
_GUICtrlEdit_Scroll | Scrolls the text vertically
_GUICtrlEdit_SetCueBanner | Sets the cue banner text that is displayed for the edit control
_GUICtrlEdit_SetLimitText | Sets the text limit
_GUICtrlEdit_SetMargins | Sets the widths of the left and right margins
_GUICtrlEdit_SetModify | Sets or clears the modification flag
_GUICtrlEdit_SetPasswordChar | Sets or removes the password character for an edit control
_GUICtrlEdit_SetReadOnly | Sets or removes the read-only style ($ES_READONLY)
_GUICtrlEdit_SetRECT | Sets the formatting rectangle of a multiline edit control
_GUICtrlEdit_SetRECTEx | Sets the formatting rectangle of a multiline edit control
_GUICtrlEdit_SetRECTNP | Sets the formatting rectangle of a multiline edit control
_GUICtrlEdit_SetRectNPEx | Sets the formatting rectangle of a multiline edit control
_GUICtrlEdit_SetSel | Selects a range of characters
_GUICtrlEdit_SetTabStops | Sets the tab stops
_GUICtrlEdit_SetText | Set the text
_GUICtrlEdit_ShowBalloonTip | Displays a balloon tip associated with an edit control
_GUICtrlEdit_Undo | Undoes the last edit control operation in the control's undo queue
_GUICtrlHeader_AddItem | Adds a new header item
_GUICtrlHeader_ClearFilter | Clears the filter
_GUICtrlHeader_ClearFilterAll | Clears all of the filters
_GUICtrlHeader_Create | Creates a Header control
_GUICtrlHeader_CreateDragImage | Creates a semi-transparent version of an item's image for use as a dragging image
_GUICtrlHeader_DeleteItem | Deletes a header item
_GUICtrlHeader_Destroy | Delete the Header control
_GUICtrlHeader_EditFilter | Starts editing the specified filter
_GUICtrlHeader_GetBitmapMargin | Retrieves the width of the bitmap margin
_GUICtrlHeader_GetImageList | Retrieves the handle to the image list
_GUICtrlHeader_GetItem | Retrieves information about an item
_GUICtrlHeader_GetItemAlign | Retrieves the item text alignment
_GUICtrlHeader_GetItemBitmap | Retrieves the item bitmap handle
_GUICtrlHeader_GetItemCount | Retrieves a count of the items
_GUICtrlHeader_GetItemDisplay | Returns the item display information
_GUICtrlHeader_GetItemFlags | Returns the item flag information
_GUICtrlHeader_GetItemFormat | Returns the format of the item
_GUICtrlHeader_GetItemImage | Retrieves the index of an image within the image list
_GUICtrlHeader_GetItemOrder | Retrieves the order in which the item appears
_GUICtrlHeader_GetItemParam | Retrieves the param value of the item
_GUICtrlHeader_GetItemRect | Retrieves the bounding rectangle for a given item
_GUICtrlHeader_GetItemRectEx | Retrieves the bounding rectangle for a given item
_GUICtrlHeader_GetItemText | Retrieves the item text
_GUICtrlHeader_GetItemWidth | Retrieves the item's width
_GUICtrlHeader_GetOrderArray | Retrieves the current left-to-right order of items in a header control
_GUICtrlHeader_GetUnicodeFormat | Retrieves the Unicode character format flag for the control
_GUICtrlHeader_HitTest | Tests a point to determine which item is at the specified point
_GUICtrlHeader_InsertItem | Inserts a new header item
_GUICtrlHeader_Layout | Retrieves the correct size and position of the control
_GUICtrlHeader_OrderToIndex | Retrieves an index value for an item based on its order
_GUICtrlHeader_SetBitmapMargin | Sets the width of the margin, specified in pixels, of a bitmap
_GUICtrlHeader_SetFilterChangeTimeout | Sets the filter change timeout interval
_GUICtrlHeader_SetHotDivider | Changes the hot divider color
_GUICtrlHeader_SetImageList | Assigns an image list
_GUICtrlHeader_SetItem | Sets information about an item
_GUICtrlHeader_SetItemAlign | Sets the item text alignment
_GUICtrlHeader_SetItemBitmap | Sets the item bitmap handle
_GUICtrlHeader_SetItemDisplay | Returns the item display information
_GUICtrlHeader_SetItemFlags | Returns the item flag information
_GUICtrlHeader_SetItemFormat | Sets the format of the item
_GUICtrlHeader_SetItemImage | Sets the index of an image within the image list
_GUICtrlHeader_SetItemOrder | Sets the order in which the item appears
_GUICtrlHeader_SetItemParam | Sets the param value of the item
_GUICtrlHeader_SetItemText | Sets the item text
_GUICtrlHeader_SetItemWidth | Sets the item's width
_GUICtrlHeader_SetOrderArray | Sets the current left-to-right order of items
_GUICtrlHeader_SetUnicodeFormat | Sets the Unicode character format flag for the control
_GUICtrlIpAddress_ClearAddress | Clears the contents of the IP address control
_GUICtrlIpAddress_Create | Create a GUI IP Address Control
_GUICtrlIpAddress_Destroy | Delete the IP Address control
_GUICtrlIpAddress_Get | Retrieves the address from the IP address control
_GUICtrlIpAddress_GetArray | Retrieves the address from the IP address control
_GUICtrlIpAddress_GetEx | Retrieves the address from the IP address control
_GUICtrlIpAddress_IsBlank | Determines if all fields in the IP address control are blank
_GUICtrlIpAddress_Set | Sets the address in the IP address control
_GUICtrlIpAddress_SetArray | Sets the address in the IP address control
_GUICtrlIpAddress_SetEx | Sets the address in the IP address control
_GUICtrlIpAddress_SetFocus | Sets the keyboard focus to the specified field in the IP address control
_GUICtrlIpAddress_SetFont | Set font of the control
_GUICtrlIpAddress_SetRange | Sets the valid range for the specified field in the IP address control
_GUICtrlIpAddress_ShowHide | Shows/Hides the IP address control
_GUICtrlListBox_AddFile | Adds the specified filename that contains a directory listing
_GUICtrlListBox_AddString | Add a string
_GUICtrlListBox_BeginUpdate | Prevents updating of the control until the EndUpdate function is called
_GUICtrlListBox_ClickItem | Clicks an item
_GUICtrlListBox_Create | Create a Listbox control
_GUICtrlListBox_DeleteString | Delete a string
_GUICtrlListBox_Destroy | Delete the control
_GUICtrlListBox_Dir | Adds the names of directories and files
_GUICtrlListBox_EndUpdate | Enables screen repainting that was turned off with the BeginUpdate function
_GUICtrlListBox_FindInText | Searches for an item that contains the specified text anywhere in its text
_GUICtrlListBox_FindString | Search for a string
_GUICtrlListBox_GetAnchorIndex | Retrieves the index of the anchor item
_GUICtrlListBox_GetCaretIndex | Return index of item that has the focus rectangle
_GUICtrlListBox_GetCount | Retrieves the number of items
_GUICtrlListBox_GetCurSel | Retrieve the index of the currently selected item
_GUICtrlListBox_GetHorizontalExtent | Retrieve from a list box the the scrollable width
_GUICtrlListBox_GetItemData | Retrieves the application defined value associated with an item
_GUICtrlListBox_GetItemHeight | Retrieves the height of items
_GUICtrlListBox_GetItemRect | Retrieves the rectangle that bounds an item
_GUICtrlListBox_GetItemRectEx | Retrieves the rectangle that bounds an item
_GUICtrlListBox_GetListBoxInfo | Retrieve the number of items per column in a specified list box
_GUICtrlListBox_GetLocale | Retrieves the current locale
_GUICtrlListBox_GetLocaleCountry | Retrieves the current country code
_GUICtrlListBox_GetLocaleLang | Retrieves the current language identifier
_GUICtrlListBox_GetLocalePrimLang | Extract primary language id from a language id
_GUICtrlListBox_GetLocaleSubLang | Extract sublanguage id from a language id
_GUICtrlListBox_GetSel | Retrieves the selection state of an item
_GUICtrlListBox_GetSelCount | Retrieves the total number of selected items
_GUICtrlListBox_GetSelItems | Fills a buffer with an array of selected items
_GUICtrlListBox_GetSelItemsText | Retrieves the text of selected items
_GUICtrlListBox_GetText | Returns the item (string) at the specified index
_GUICtrlListBox_GetTextLen | Gets the length of a string in a list box
_GUICtrlListBox_GetTopIndex | Retrieve the index of the first visible item in a list
_GUICtrlListBox_InitStorage | This message allocates memory for storing items
_GUICtrlListBox_InsertString | Insert a string into the list
_GUICtrlListBox_ItemFromPoint | Retrieves the 0-based index of the item nearest the specified point
_GUICtrlListBox_ReplaceString | Replaces the text of an item
_GUICtrlListBox_ResetContent | Remove all items from the list box
_GUICtrlListBox_SelectString | Searchs for an item that begins with the specified string
_GUICtrlListBox_SelItemRange | Select one or more consecutive items in a multiple-selection list box
_GUICtrlListBox_SelItemRangeEx | Select one or more consecutive items in a multiple-selection list box
_GUICtrlListBox_SetAnchorIndex | Set the anchor item—that is, the item from which a multiple selection starts
_GUICtrlListBox_SetCaretIndex | Set the focus rectangle to the item at the specified index in a multiple-selection list box
_GUICtrlListBox_SetColumnWidth | Set the width, in pixels, of all columns
_GUICtrlListBox_SetCurSel | Select a string and scroll it into view, if necessary
_GUICtrlListBox_SetHorizontalExtent | Set the width, in pixels, by which a list box can be scrolled horizontally
_GUICtrlListBox_SetItemData | Sets the value associated with the specified item
_GUICtrlListBox_SetItemHeight | Sets the height, in pixels, of items
_GUICtrlListBox_SetLocale | Set the current locale
_GUICtrlListBox_SetSel | Select a string(s) in a multiple-selection list box
_GUICtrlListBox_SetTabStops | Sets the tab-stop positions
_GUICtrlListBox_SetTopIndex | Ensure that a particular item in a list box is visible
_GUICtrlListBox_Sort | Re-sorts list box if it has the $LBS_SORT style
_GUICtrlListBox_SwapString | Swaps the text of two items at the specified indices
_GUICtrlListBox_UpdateHScroll | Update the horizontal scroll bar based on the longest string
_GUICtrlListView_AddArray | Adds items from an array to the control
_GUICtrlListView_AddColumn | Adds a new column in the control
_GUICtrlListView_AddItem | Adds a new item to the end of the list
_GUICtrlListView_AddSubItem | Adds a new subitem to the control
_GUICtrlListView_ApproximateViewHeight | Calculates the approximate height required to display a given number of items
_GUICtrlListView_ApproximateViewRect | Calculates the approximate size required to display a given number of items
_GUICtrlListView_ApproximateViewWidth | Calculates the approximate width required to display a given number of items
_GUICtrlListView_Arrange | Arranges items in icon view
_GUICtrlListView_BeginUpdate | Prevents updating of the control until the _GUICtrlListView_EndUpdate() function is called
_GUICtrlListView_CancelEditLabel | Cancels an item text editing operation
_GUICtrlListView_ClickItem | Clicks an item
_GUICtrlListView_CopyItems | Copy Items between 2 list-view controls
_GUICtrlListView_Create | Create a ListView control
_GUICtrlListView_CreateDragImage | Creates a drag image list for the specified item
_GUICtrlListView_CreateSolidBitMap | Creates a solid color bitmap
_GUICtrlListView_DeleteAllItems | Removes all items from a list-view control
_GUICtrlListView_DeleteColumn | Removes a column from a list-view control
_GUICtrlListView_DeleteItem | Removes an item from a list-view control
_GUICtrlListView_DeleteItemsSelected | Deletes item(s) selected
_GUICtrlListView_Destroy | Delete the listview control
_GUICtrlListView_DrawDragImage | Draw the Drag Image
_GUICtrlListView_EditLabel | Begins in place editing of the specified item text
_GUICtrlListView_EnableGroupView | Enables or disables whether the items in the control display as a group
_GUICtrlListView_EndUpdate | Enables screen repainting that was turned off with the _GUICtrlListView_BeginUpdate() function
_GUICtrlListView_EnsureVisible | Ensures that a list-view item is either entirely or partially visible
_GUICtrlListView_FindInText | Searches for an item that contains the specified text anywhere in its text
_GUICtrlListView_FindItem | Searches for an item with the specified characteristics
_GUICtrlListView_FindNearest | Finds the item nearest to the position specified
_GUICtrlListView_FindParam | Searches for an item with the specified lParam
_GUICtrlListView_FindText | Searches for an item with the specified text
_GUICtrlListView_GetBkColor | Retrieves the background color of a list-view control
_GUICtrlListView_GetBkImage | Retrieves the background image in the control
_GUICtrlListView_GetCallbackMask | Retrieves the callback mask for the control
_GUICtrlListView_GetColumn | Retrieves the attributes of a column
_GUICtrlListView_GetColumnCount | Retrieve the number of columns
_GUICtrlListView_GetColumnOrder | Retrieves the current left-to-right order of columns
_GUICtrlListView_GetColumnOrderArray | Retrieves the current left-to-right order of columns in the control
_GUICtrlListView_GetColumnWidth | Retrieves the width of a column in report or list view
_GUICtrlListView_GetCounterPage | Calculates the number of items that can fit vertically in the visible area
_GUICtrlListView_GetEditControl | Retrieves the handle to the edit control being used to edit an item's text
_GUICtrlListView_GetExtendedListViewStyle | Retrieves the extended styles that are currently in use
_GUICtrlListView_GetFocusedGroup | Gets the group that has the focus
_GUICtrlListView_GetGroupCount | Gets the number of groups
_GUICtrlListView_GetGroupInfo | Retrieves group information
_GUICtrlListView_GetGroupInfoByIndex | Retrieves group information
_GUICtrlListView_GetGroupRect | Gets the rectangle for a specified group
_GUICtrlListView_GetGroupViewEnabled | Checks whether the control has group view enabled
_GUICtrlListView_GetHeader | Retrieves the handle to the header control
_GUICtrlListView_GetHotCursor | Retrieves the HCURSOR value used when the pointer is over an item while hot tracking is enabled
_GUICtrlListView_GetHotItem | Retrieves the index of the hot item
_GUICtrlListView_GetHoverTime | Retrieves the amount of time that the mouse cursor must hover over an item before it is selected
_GUICtrlListView_GetImageList | Retrieves the handle to an image list used for drawing listview items
_GUICtrlListView_GetISearchString | Retrieves the incremental search string of the control
_GUICtrlListView_GetItem | Retrieves an item's attributes
_GUICtrlListView_GetItemChecked | Returns the check state for a list-view control item
_GUICtrlListView_GetItemCount | Retrieves the number of items in a list-view control
_GUICtrlListView_GetItemCut | Determines whether the item is marked for a cut and paste operation
_GUICtrlListView_GetItemDropHilited | Determines whether the item is highlighted as a drag-and-drop target
_GUICtrlListView_GetItemEx | Retrieves some or all of an item's attributes
_GUICtrlListView_GetItemFocused | Determines whether the item is highlighted as a drag-and-drop target
_GUICtrlListView_GetItemGroupID | Gets the item group ID
_GUICtrlListView_GetItemImage | Retrieves the index of the item's icon
_GUICtrlListView_GetItemIndent | Retrieves the number of image widths the item is indented
_GUICtrlListView_GetItemParam | Retrieves the application specific value of the item
_GUICtrlListView_GetItemPosition | Retrieves the position of an item
_GUICtrlListView_GetItemPositionX | Retrieves the X position of an item
_GUICtrlListView_GetItemPositionY | Retrieves the Y position of an item
_GUICtrlListView_GetItemRect | Retrieves the bounding rectangle for all or part of an item
_GUICtrlListView_GetItemRectEx | Retrieves the bounding rectangle for all or part of an item
_GUICtrlListView_GetItemSelected | Determines whether the item is selected
_GUICtrlListView_GetItemSpacing | Determines the spacing between items in the control
_GUICtrlListView_GetItemSpacingX | Determines the horizontal spacing between items in the control
_GUICtrlListView_GetItemSpacingY | Determines the vertical spacing between items in the control
_GUICtrlListView_GetItemState | Retrieves the state of a listview item
_GUICtrlListView_GetItemStateImage | Gets the state image that is displayed
_GUICtrlListView_GetItemText | Retrieves the text of an item or subitem
_GUICtrlListView_GetItemTextArray | Retrieves all of a list-view item
_GUICtrlListView_GetItemTextString | Retrieves all of a list-view item
_GUICtrlListView_GetNextItem | Searches for an item that has the specified properties
_GUICtrlListView_GetNumberOfWorkAreas | Retrieves the number of working areas in the control
_GUICtrlListView_GetOrigin | Retrieves the current view origin for the control
_GUICtrlListView_GetOriginX | Retrieves the current horizontal view origin for the control
_GUICtrlListView_GetOriginY | Retrieves the current vertical view origin for the control
_GUICtrlListView_GetOutlineColor | Retrieves the color of the border of the control
_GUICtrlListView_GetSelectedColumn | Retrieves the index of the selected column
_GUICtrlListView_GetSelectedCount | Determines the number of selected items
_GUICtrlListView_GetSelectedIndices | Retrieve indices of selected item(s)
_GUICtrlListView_GetSelectionMark | Retrieves the selection mark from the control
_GUICtrlListView_GetStringWidth | Determines the width of a specified string
_GUICtrlListView_GetSubItemRect | Retrieves information about an item bounding rectangle
_GUICtrlListView_GetTextBkColor | Retrieves the text background color of the control
_GUICtrlListView_GetTextColor | Retrieves the text color of the control
_GUICtrlListView_GetToolTips | Retrieves the ToolTip control handle
_GUICtrlListView_GetTopIndex | Retrieves the index of the topmost visible item when in list or report view
_GUICtrlListView_GetUnicodeFormat | Retrieves the Unicode character format flag for the control
_GUICtrlListView_GetView | Retrieves the current view of the control
_GUICtrlListView_GetViewDetails | Determines whether the view mode is in detail mode
_GUICtrlListView_GetViewLarge | Determines whether the view mode is in large icon mode
_GUICtrlListView_GetViewList | Determines whether the view mode is in list mode
_GUICtrlListView_GetViewRect | Retrieves the bounding rectangle of all items in the control
_GUICtrlListView_GetViewSmall | Determines whether the view mode is in small icon mode
_GUICtrlListView_GetViewTile | Determines whether the view mode is in tile mode
_GUICtrlListView_HideColumn | Hides the column "sets column width to zero"
_GUICtrlListView_HitTest | Determines which item is at a specified position
_GUICtrlListView_InsertColumn | Inserts a new column in the control
_GUICtrlListView_InsertGroup | Inserts a group
_GUICtrlListView_InsertItem | Inserts a new item in the control
_GUICtrlListView_JustifyColumn | Set Justification of a column for a list-view control
_GUICtrlListView_MapIDToIndex | Maps the ID of an item to an index
_GUICtrlListView_MapIndexToID | Maps an index to an item ID
_GUICtrlListView_RedrawItems | Forces the control to redraw a range of items
_GUICtrlListView_RegisterSortCallBack | Register the Simple Sort callback function
_GUICtrlListView_RemoveAllGroups | Removes all groups from the control
_GUICtrlListView_RemoveGroup | Removes a group from the control
_GUICtrlListView_Scroll | Scrolls the content of a list-view
_GUICtrlListView_SetBkColor | Sets the background color of the control
_GUICtrlListView_SetBkImage | Sets the background image in the control
_GUICtrlListView_SetCallBackMask | Changes the callback mask for the control
_GUICtrlListView_SetColumn | Sets the attributes of a column
_GUICtrlListView_SetColumnOrder | Sets the left-to-right order of columns
_GUICtrlListView_SetColumnOrderArray | Sets the left-to-right order of columns in the control
_GUICtrlListView_SetColumnWidth | Changes the width of a column
_GUICtrlListView_SetExtendedListViewStyle | Sets extended styles
_GUICtrlListView_SetGroupInfo | Sets group information
_GUICtrlListView_SetHotItem | Sets the hot item
_GUICtrlListView_SetHoverTime | Sets the amount of time which the mouse cursor must hover over an item before it is selected
_GUICtrlListView_SetIconSpacing | Sets the spacing between icons where the style is large icon
_GUICtrlListView_SetImageList | Assigns an image list to the control
_GUICtrlListView_SetItem | Sets some or all of a item's attributes
_GUICtrlListView_SetItemChecked | Sets the checked state
_GUICtrlListView_SetItemCount | Causes the list-view control to allocate memory for the specified number of items
_GUICtrlListView_SetItemCut | Sets whether the item is marked for a cut-and-paste operation
_GUICtrlListView_SetItemDropHilited | Sets whether the item is highlighted as a drag-and-drop target
_GUICtrlListView_SetItemEx | Sets some or all of a item's attributes
_GUICtrlListView_SetItemFocused | Sets whether the item has the focus
_GUICtrlListView_SetItemGroupID | Sets the item group ID
_GUICtrlListView_SetItemImage | Sets the index of the item's icon in the control's image list
_GUICtrlListView_SetItemIndent | Sets the number of image widths to indent the item
_GUICtrlListView_SetItemParam | Sets the value specific to the item
_GUICtrlListView_SetItemPosition | Moves an item to a specified position in the control
_GUICtrlListView_SetItemPosition32 | Moves an item to a specified position in the control
_GUICtrlListView_SetItemSelected | Sets whether the item is selected
_GUICtrlListView_SetItemState | Changes the state of an item in the control
_GUICtrlListView_SetItemStateImage | Sets the state image that is displayed
_GUICtrlListView_SetItemText | Changes the text of an item or subitem
_GUICtrlListView_SetOutlineColor | Sets the color of the border
_GUICtrlListView_SetSelectedColumn | Sets the index of the selected column
_GUICtrlListView_SetSelectionMark | Sets the selection mark in the control
_GUICtrlListView_SetTextBkColor | Sets the background color of text in the control
_GUICtrlListView_SetTextColor | Sets the color of text in the control
_GUICtrlListView_SetToolTips | Sets the ToolTip control that the control will use to display ToolTips
_GUICtrlListView_SetUnicodeFormat | Sets the UNICODE character format flag for the control
_GUICtrlListView_SetView | Sets the view of the control
_GUICtrlListView_SetWorkAreas | Creates a work area within the control
_GUICtrlListView_SimpleSort | Sorts a list-view control (limited)
_GUICtrlListView_SortItems | Starts the sort call back, also sets the Arrow in the Header
_GUICtrlListView_SubItemHitTest | Determines which listview item or subitem is at a given position
_GUICtrlListView_UnRegisterSortCallBack | UnRegister the Sort callback function
_GUICtrlMenu_AddMenuItem | Adds a new menu item to the end of the menu
_GUICtrlMenu_AppendMenu | Appends a new item to the end of the specified menu bar, drop-down menu, submenu, or shortcut menu
_GUICtrlMenu_CalculatePopupWindowPosition | Calculates an appropriate pop-up window position
_GUICtrlMenu_CheckMenuItem | Sets the state of the specified menu item's check mark attribute to either selected or clear
_GUICtrlMenu_CheckRadioItem | Checks a specified menu item and makes it a radio item
_GUICtrlMenu_CreateMenu | Creates a menu
_GUICtrlMenu_CreatePopup | Creates a drop down menu, submenu, or shortcut menu
_GUICtrlMenu_DeleteMenu | Deletes an item from the specified menu
_GUICtrlMenu_DestroyMenu | Destroys the specified menu and frees any memory that the menu occupies
_GUICtrlMenu_DrawMenuBar | Redraws the menu bar of the specified window
_GUICtrlMenu_EnableMenuItem | Enables, disables, or grays the specified menu item
_GUICtrlMenu_FindItem | Retrieves a menu item based on it's text
_GUICtrlMenu_FindParent | Retrieves the window to which a menu belongs
_GUICtrlMenu_GetItemBmp | Retrieves the bitmap displayed for the item
_GUICtrlMenu_GetItemBmpChecked | Retrieves the bitmap displayed if the item is selected
_GUICtrlMenu_GetItemBmpUnchecked | Retrieves the bitmap displayed if the item is not selected
_GUICtrlMenu_GetItemChecked | Retrieves the status of the menu item checked state
_GUICtrlMenu_GetItemCount | Retrieves the number of items in the specified menu
_GUICtrlMenu_GetItemData | Retrieves the application defined value associated with the menu item
_GUICtrlMenu_GetItemDefault | Retrieves the status of the menu item default state
_GUICtrlMenu_GetItemDisabled | Retrieves the status of the menu item disabled state
_GUICtrlMenu_GetItemEnabled | Retrieves the status of the menu item enabled state
_GUICtrlMenu_GetItemGrayed | Retrieves the status of the menu item grayed state
_GUICtrlMenu_GetItemHighlighted | Retrieves the status of the menu item highlighted state
_GUICtrlMenu_GetItemID | Retrieves the menu item ID
_GUICtrlMenu_GetItemInfo | Retrieves information about a menu item
_GUICtrlMenu_GetItemRect | Retrieves the bounding rectangle for the specified menu item
_GUICtrlMenu_GetItemRectEx | Retrieves the bounding rectangle for the specified menu item
_GUICtrlMenu_GetItemState | Retrieves the menu item state
_GUICtrlMenu_GetItemStateEx | Retrieves the menu flags associated with the specified menu item
_GUICtrlMenu_GetItemSubMenu | Retrieves a the submenu activated by a specified item
_GUICtrlMenu_GetItemText | Retrieves the text of the specified menu item
_GUICtrlMenu_GetItemType | Retrieves the menu item type
_GUICtrlMenu_GetMenu | Retrieves the handle of the menu assigned to the given window
_GUICtrlMenu_GetMenuBackground | Retrieves the brush to use for the menu's background
_GUICtrlMenu_GetMenuBarInfo | Retrieves information about the specified menu bar
_GUICtrlMenu_GetMenuContextHelpID | Retrieves the context help identifier
_GUICtrlMenu_GetMenuData | Retrieves the application defined value
_GUICtrlMenu_GetMenuDefaultItem | Retrieves the default menu item on the specified menu
_GUICtrlMenu_GetMenuHeight | Retrieves the maximum height of a menu
_GUICtrlMenu_GetMenuInfo | Retrieves information about a specified menu
_GUICtrlMenu_GetMenuStyle | Retrieves the style information for a menu
_GUICtrlMenu_GetSystemMenu | Allows the application to access the window menu for copying and modifying
_GUICtrlMenu_InsertMenuItem | Inserts a new menu item at the specified position
_GUICtrlMenu_InsertMenuItemEx | Inserts a new menu item at the specified position in a menu
_GUICtrlMenu_IsMenu | Determines whether a handle is a menu handle
_GUICtrlMenu_LoadMenu | Loads the specified menu resource from the executable file associated with an application instance
_GUICtrlMenu_MapAccelerator | Maps a menu accelerator key to it's position in the menu
_GUICtrlMenu_MenuItemFromPoint | Determines which menu item is at the specified location
_GUICtrlMenu_RemoveMenu | Deletes a menu item or detaches a submenu from the specified menu
_GUICtrlMenu_SetItemBitmaps | Associates the specified bitmap with a menu item
_GUICtrlMenu_SetItemBmp | Sets the bitmap displayed for the item
_GUICtrlMenu_SetItemBmpChecked | Sets the bitmap displayed if the item is selected
_GUICtrlMenu_SetItemBmpUnchecked | Sets the bitmap displayed if the item is not selected
_GUICtrlMenu_SetItemChecked | Sets the checked state of a menu item
_GUICtrlMenu_SetItemData | Sets the application defined value for a menu item
_GUICtrlMenu_SetItemDefault | Sets the status of the menu item default state
_GUICtrlMenu_SetItemDisabled | Sets the disabled state of a menu item
_GUICtrlMenu_SetItemEnabled | Sets the enabled state of a menu item
_GUICtrlMenu_SetItemGrayed | Sets the grayed state of a menu item
_GUICtrlMenu_SetItemHighlighted | Sets the highlighted state of a menu item
_GUICtrlMenu_SetItemID | Sets the menu item ID
_GUICtrlMenu_SetItemInfo | Changes information about a menu item
_GUICtrlMenu_SetItemState | Sets the state of a menu item
_GUICtrlMenu_SetItemSubMenu | Sets the drop down menu or submenu associated with the menu item
_GUICtrlMenu_SetItemText | Sets the text for a menu item
_GUICtrlMenu_SetItemType | Sets the menu item type
_GUICtrlMenu_SetMenu | Assigns a new menu to the specified window
_GUICtrlMenu_SetMenuBackground | Sets the background brush for the menu
_GUICtrlMenu_SetMenuContextHelpID | Sets the context help identifier for the menu
_GUICtrlMenu_SetMenuData | Sets the application defined for the menu
_GUICtrlMenu_SetMenuDefaultItem | Sets the default menu item
_GUICtrlMenu_SetMenuHeight | Sets the maximum height of the menu
_GUICtrlMenu_SetMenuInfo | Sets information for a specified menu
_GUICtrlMenu_SetMenuStyle | Sets the menu style
_GUICtrlMenu_TrackPopupMenu | Displays a shortcut menu at the specified location
_GUICtrlMonthCal_Create | Creates a Month Calendar control
_GUICtrlMonthCal_Destroy | Delete the MonthCal control
_GUICtrlMonthCal_GetCalendarBorder | Gets the size of the border, in pixels
_GUICtrlMonthCal_GetCalendarCount | Gets the number of calendars currently displayed in the calendar control
_GUICtrlMonthCal_GetColor | Retrieves a given color for the control
_GUICtrlMonthCal_GetColorArray | Retrieves the color for a given portion of a month calendar control
_GUICtrlMonthCal_GetCurSel | Retrieves the currently selected date
_GUICtrlMonthCal_GetCurSelStr | Retrieves the currently selected date in string format
_GUICtrlMonthCal_GetFirstDOW | Retrieves the first day of the week
_GUICtrlMonthCal_GetFirstDOWStr | Retrieves the first day of the week as a string
_GUICtrlMonthCal_GetMaxSelCount | Retrieves the maximum date range that can be selected in a month calendar control
_GUICtrlMonthCal_GetMaxTodayWidth | Retrieves the maximum width of the "today" string in a month calendar control
_GUICtrlMonthCal_GetMinReqHeight | Retrieves the minimum height required to display a full month
_GUICtrlMonthCal_GetMinReqRect | Retrieves the minimum size required to display a full month
_GUICtrlMonthCal_GetMinReqRectArray | Retrieves the minimum size required to display a full month in a month calendar control
_GUICtrlMonthCal_GetMinReqWidth | Retrieves the minimum width required to display a full month
_GUICtrlMonthCal_GetMonthDelta | Retrieves the scroll rate for a month calendar control
_GUICtrlMonthCal_GetMonthRange | Retrieves date information that represents the high and low display limits
_GUICtrlMonthCal_GetMonthRangeMax | Retrieves date information that represents the high limit of the controls display
_GUICtrlMonthCal_GetMonthRangeMaxStr | Retrieves date information that represents the high limit of the controls display in string format
_GUICtrlMonthCal_GetMonthRangeMin | Retrieves date information that represents the low limit of the controls display
_GUICtrlMonthCal_GetMonthRangeMinStr | Retrieves date information that represents the low limit of the controls display in string format
_GUICtrlMonthCal_GetMonthRangeSpan | Returns a value that represents the range, in months, spanned
_GUICtrlMonthCal_GetRange | Retrieves the minimum and maximum allowable dates
_GUICtrlMonthCal_GetRangeMax | Retrieves the upper limit date range
_GUICtrlMonthCal_GetRangeMaxStr | Retrieves the upper limit date range in string format
_GUICtrlMonthCal_GetRangeMin | Retrieves the lower limit date range
_GUICtrlMonthCal_GetRangeMinStr | Retrieves the lower limit date range in string form
_GUICtrlMonthCal_GetSelRange | Retrieves the upper and lower limits of the date range currently selected
_GUICtrlMonthCal_GetSelRangeMax | Retrieves the upper date range currently selected by the user
_GUICtrlMonthCal_GetSelRangeMaxStr | Retrieves the upper date range currently selected by the user in string form
_GUICtrlMonthCal_GetSelRangeMin | Retrieves the lower date range currently selected by the user
_GUICtrlMonthCal_GetSelRangeMinStr | Retrieves the lower date range currently selected by the user in string form
_GUICtrlMonthCal_GetToday | Retrieves the date information for the date specified as "today"
_GUICtrlMonthCal_GetTodayStr | Retrieves the date information for the date specified as "today" in string format
_GUICtrlMonthCal_GetUnicodeFormat | Retrieves the Unicode character format flag for the control
_GUICtrlMonthCal_HitTest | Determines which portion of a month calendar control is at a given point
_GUICtrlMonthCal_SetCalendarBorder | Sets the size of the border, in pixels
_GUICtrlMonthCal_SetColor | Sets the color for a given portion of the month calendar
_GUICtrlMonthCal_SetCurSel | Sets the currently selected date
_GUICtrlMonthCal_SetDayState | Sets the day states for all months that are currently visible
_GUICtrlMonthCal_SetFirstDOW | Sets the first day of the week for a month calendar control
_GUICtrlMonthCal_SetMaxSelCount | Sets the maximum number of days that can be selected in a month calendar control
_GUICtrlMonthCal_SetMonthDelta | Sets the scroll rate for a month calendar control
_GUICtrlMonthCal_SetRange | Sets date information that represents the high and low limits
_GUICtrlMonthCal_SetSelRange | Sets the selection for a month calendar control to a given date range
_GUICtrlMonthCal_SetToday | Sets the date information for the date specified as "today"
_GUICtrlMonthCal_SetUnicodeFormat | Sets the Unicode character format flag for the control
_GUICtrlRebar_AddBand | Adds a new band in a rebar control
_GUICtrlRebar_AddToolBarBand | Adds a new band in a rebar control
_GUICtrlRebar_BeginDrag | Adds a new band in a rebar control
_GUICtrlRebar_Create | Create a Rebar control
_GUICtrlRebar_DeleteBand | Deletes a band from a rebar control
_GUICtrlRebar_Destroy | Delete the control
_GUICtrlRebar_DragMove | Updates the drag position in the rebar control after a previous _GUICtrlRebar_BeginDrag message
_GUICtrlRebar_EndDrag | Terminates the rebar control's drag-and-drop operation
_GUICtrlRebar_GetBandBackColor | Retrieves the Band background color
_GUICtrlRebar_GetBandBorders | Retrieves the borders of a band
_GUICtrlRebar_GetBandBordersEx | Retrieves the borders of a band
_GUICtrlRebar_GetBandChildHandle | Retrieves the Handle to the child window contained in the band, if any
_GUICtrlRebar_GetBandChildSize | Retrieves the Child size settings
_GUICtrlRebar_GetBandCount | Retrieves the count of bands currently in the rebar control
_GUICtrlRebar_GetBandForeColor | Retrieves the Band foreground color
_GUICtrlRebar_GetBandHeaderSize | Retrieves the size of the band's header, in pixels
_GUICtrlRebar_GetBandID | Get the value that the control uses to identify this band for custom draw notification messages
_GUICtrlRebar_GetBandIdealSize | Get Ideal width of the band, in pixels
_GUICtrlRebar_GetBandLength | Get Length of the band, in pixels
_GUICtrlRebar_GetBandLParam | Get Application-defined value
_GUICtrlRebar_GetBandMargins | Get Length of the band, in pixels
_GUICtrlRebar_GetBandMarginsEx | Get Length of the band, in pixels
_GUICtrlRebar_GetBandRect | Retrieves the bounding rectangle for a given band in a rebar control
_GUICtrlRebar_GetBandRectEx | Retrieves the bounding rectangle for a given band in a rebar control
_GUICtrlRebar_GetBandStyle | Get the band style Flags
_GUICtrlRebar_GetBandStyleBreak | Determine if band break flag is set
_GUICtrlRebar_GetBandStyleChildEdge | Determine if band child edge flag is set
_GUICtrlRebar_GetBandStyleFixedBMP | Determine if band fixed BMP flag is set
_GUICtrlRebar_GetBandStyleFixedSize | Determine if band fixed size flag is set
_GUICtrlRebar_GetBandStyleGripperAlways | Determine if band gripper flag is set
_GUICtrlRebar_GetBandStyleHidden | Determine if band hidden flag is set
_GUICtrlRebar_GetBandStyleHideTitle | Determine if band hide title flag is set
_GUICtrlRebar_GetBandStyleNoGripper | Determine if band noGripper flag is set
_GUICtrlRebar_GetBandStyleTopAlign | Determine if band top align flag is set
_GUICtrlRebar_GetBandStyleUseChevron | Determine if band use chevron flag is set
_GUICtrlRebar_GetBandStyleVariableHeight | Determine if band variable height flag is set
_GUICtrlRebar_GetBandText | Retrieves the display text for the band
_GUICtrlRebar_GetBarHeight | Retrieves the height of the rebar control
_GUICtrlRebar_GetBarInfo | Retrieves information about the rebar control and the image list it uses
_GUICtrlRebar_GetBKColor | Retrieves a rebar control's default background color
_GUICtrlRebar_GetColorScheme | Retrieves the color scheme information from the rebar control
_GUICtrlRebar_GetRowCount | Retrieves the number of rows of bands in a rebar control
_GUICtrlRebar_GetRowHeight | Retrieves the height of a specified row in a rebar control
_GUICtrlRebar_GetTextColor | Retrieves a rebar control's default text color
_GUICtrlRebar_GetToolTips | Retrieves the handle to any ToolTip control associated with the rebar control
_GUICtrlRebar_GetUnicodeFormat | Retrieves the Unicode character format flag for the control
_GUICtrlRebar_HitTest | Determines which band is at a specified position
_GUICtrlRebar_IDToIndex | Converts a band identifier to a band index in a rebar control
_GUICtrlRebar_MaximizeBand | Resizes a band in a rebar control to either its ideal or largest size
_GUICtrlRebar_MinimizeBand | Resizes a band in a rebar control to its smallest size
_GUICtrlRebar_MoveBand | Moves a band from one index to another
_GUICtrlRebar_SetBandBackColor | Set the Band background color
_GUICtrlRebar_SetBandForeColor | Set the Band foreground color
_GUICtrlRebar_SetBandHeaderSize | Set the size of the band's header, in pixels
_GUICtrlRebar_SetBandID | Set the value that the control uses to identify this band for custom draw notification messages
_GUICtrlRebar_SetBandIdealSize | Set Ideal width of the band, in pixels
_GUICtrlRebar_SetBandLength | Set the size length of the band
_GUICtrlRebar_SetBandLParam | Set Application-defined value
_GUICtrlRebar_SetBandStyle | Set the band style Flags
_GUICtrlRebar_SetBandStyleBreak | Set whether the band is on a new line
_GUICtrlRebar_SetBandStyleChildEdge | Set whether the band has an edge at the top and bottom of the child window
_GUICtrlRebar_SetBandStyleFixedBMP | Set whether the band background bitmap does not move when the band is resized
_GUICtrlRebar_SetBandStyleFixedSize | Set whether the band can't be sized. With this style, the sizing grip is not displayed on the band
_GUICtrlRebar_SetBandStyleGripperAlways | Set whether the band will always have a sizing grip, even if it is the only band in the rebar
_GUICtrlRebar_SetBandStyleHidden | Set whether the band will not be visible
_GUICtrlRebar_SetBandStyleHideTitle | Set whether to keep band title hidden
_GUICtrlRebar_SetBandStyleNoGripper | Set whether the band will never have a sizing grip, even if there is more than one band in the rebar
_GUICtrlRebar_SetBandStyleTopAlign | Set whether to keep band in top row
_GUICtrlRebar_SetBandStyleUseChevron | Set whether to display drop-down button
_GUICtrlRebar_SetBandStyleVariableHeight | Set whether the band can be resized by the rebar control
_GUICtrlRebar_SetBandText | Sets the display text for the band of a rebar control
_GUICtrlRebar_SetBarInfo | Sets the characteristics of a rebar control
_GUICtrlRebar_SetBKColor | Sets the default background color of a rebar control
_GUICtrlRebar_SetColorScheme | Sets the color scheme of a rebar control
_GUICtrlRebar_SetTextColor | Sets a rebar control's default text color
_GUICtrlRebar_SetToolTips | Associates a ToolTip control with the rebar control
_GUICtrlRebar_SetUnicodeFormat | Sets the Unicode character format flag for the control
_GUICtrlRebar_ShowBand | Shows or hides a given band in a rebar control
_GUICtrlRichEdit_AppendText | Appends text at the end of the client area
_GUICtrlRichEdit_AutoDetectURL | Enables or disables automatic detection of URLS
_GUICtrlRichEdit_CanPaste | Can the contents of the clipboard be pasted into the control?
_GUICtrlRichEdit_CanPasteSpecial | Can the contents of the clipboard be pasted into the control in both formats?
_GUICtrlRichEdit_CanRedo | Can an undone action be redone?
_GUICtrlRichEdit_CanUndo | Can an action be undone?
_GUICtrlRichEdit_ChangeFontSize | Increment or decrement font size(s) of selected text
_GUICtrlRichEdit_Copy | Copy text to clipboard
_GUICtrlRichEdit_Create | Create an Edit control
_GUICtrlRichEdit_Cut | Cut text to clipboard
_GUICtrlRichEdit_Deselect | Deselects text, leaving none selected
_GUICtrlRichEdit_Destroy | Delete the Rich Edit control
_GUICtrlRichEdit_EmptyUndoBuffer | Resets the undo flag of the control
_GUICtrlRichEdit_FindText | Search for a text starting at insertion point or at anchor point of selection
_GUICtrlRichEdit_FindTextInRange | Search for a text in a range of inter-character positions
_GUICtrlRichEdit_GetBkColor | Gets the background color of the control
_GUICtrlRichEdit_GetCharAttributes | Returns attributes of selected text
_GUICtrlRichEdit_GetCharBkColor | Retrieves the background color of the selected text or, if none selected, of the character to the right of the insertion point
_GUICtrlRichEdit_GetCharColor | Retrieves the color of the selected text or, if none selected, of the character to the right of the insertion point
_GUICtrlRichEdit_GetCharPosFromXY | Gets inter-character position closest to a specified point in the client area
_GUICtrlRichEdit_GetCharPosOfNextWord | Gets inter-character position before the next word
_GUICtrlRichEdit_GetCharPosOfPreviousWord | Gets inter-character position before the Previous word
_GUICtrlRichEdit_GetCharWordBreakInfo | Gets inter-character position before the Previous word/
_GUICtrlRichEdit_GetFirstCharPosOnLine | Retrieves the inter-character position preceding the first character of a line
_GUICtrlRichEdit_GetFont | Gets the font attributes of a selection or, if no selection, at the insertion point
_GUICtrlRichEdit_GetLineCount | Retrieves the number of lines in a multi-line edit control
_GUICtrlRichEdit_GetLineLength | Retrieves the length of a line
_GUICtrlRichEdit_GetLineNumberFromCharPos | Retrieves the line number on which an inter-character position is found
_GUICtrlRichEdit_GetNextRedo | Retrieves the name or type ID of the next possible redo action
_GUICtrlRichEdit_GetNextUndo | Retrieves the name or type ID of the next possible Undo action
_GUICtrlRichEdit_GetNumberOfFirstVisibleLine | Gets number of the first line which is visible in the control
_GUICtrlRichEdit_GetParaAlignment | Gets the alignment of selected paragraph(s), or (if no selection) of the current paragraph
_GUICtrlRichEdit_GetParaAttributes | Gets the attributes of (first) selected paragraph or (if no selection) of the current paragraph
_GUICtrlRichEdit_GetParaBorder | Gets the border settings of (first) selected paragraph or (if no selection) of the current paragraph
_GUICtrlRichEdit_GetParaIndents | Gets the border indent settings of (first) selected paragraph or (if no selection) of the current paragraph
_GUICtrlRichEdit_GetParaNumbering | Gets the numbering style of (first) selected paragraph or (if no selection) of the current paragraph
_GUICtrlRichEdit_GetParaShading | Gets the shading settings of (first) selected paragraph or (if no selection) of the current paragraph
_GUICtrlRichEdit_GetParaSpacing | Gets the spacing settings of (first) selected paragraph or (if no selection) of the current paragraph
_GUICtrlRichEdit_GetParaTabStops | Gets the tabstops of (first) selected paragraph or (if no selection) of the current paragraph
_GUICtrlRichEdit_GetPasswordChar | Gets the password character that a rich edit control displays when the user enters text
_GUICtrlRichEdit_GetRECT | Retrieves the formatting rectangle of a control
_GUICtrlRichEdit_GetScrollPos | Gets the Scrolling position of the control
_GUICtrlRichEdit_GetSel | Gets the low and high inter-character positions of a selection
_GUICtrlRichEdit_GetSelAA | Gets the anchor and active inter-character positions of a selection, in that order
_GUICtrlRichEdit_GetSelText | Retrieves the currently selected text
_GUICtrlRichEdit_GetSpaceUnit | Gets the unit of measure of horizontal and vertical space used in parameters of various _GUICtrlRichEdit functions
_GUICtrlRichEdit_GetText | Get all of the text in the control
_GUICtrlRichEdit_GetTextInLine | Gets a line of text
_GUICtrlRichEdit_GetTextInRange | Gets the text from from one inter-character position to another
_GUICtrlRichEdit_GetTextLength | Get the length of the whole text in the control
_GUICtrlRichEdit_GetVersion | Retrieves the version of Rich Edit
_GUICtrlRichEdit_GetXYFromCharPos | Retrieves the XY coordinates of an inter-character position
_GUICtrlRichEdit_GetZoom | Gets the zoom level of the control
_GUICtrlRichEdit_GotoCharPos | Moves the insertion point to an inter-character position
_GUICtrlRichEdit_HideSelection | Hides (or shows) a selection
_GUICtrlRichEdit_InsertText | Inserts text at insertion point or anchor point of selection
_GUICtrlRichEdit_IsModified | Retrieves the state of a rich edit control's modification flag
_GUICtrlRichEdit_IsTextSelected | Is text selected?
_GUICtrlRichEdit_Paste | Paste RTF or RTF with Objects from clipboard
_GUICtrlRichEdit_PasteSpecial | Paste RTF or RTF and Objects from clipboard
_GUICtrlRichEdit_PauseRedraw | Pauses redrawing of the control
_GUICtrlRichEdit_Redo | Redoes last undone action
_GUICtrlRichEdit_ReplaceText | Replaces selected text
_GUICtrlRichEdit_ResumeRedraw | Resumes redrawing of the control
_GUICtrlRichEdit_ScrollLineOrPage | Scrolls the text down or up a line or a page
_GUICtrlRichEdit_ScrollLines | Scrolls the text down or up a number of lines
_GUICtrlRichEdit_ScrollToCaret | Scrolls to show line on which caret (insertion point) is
_GUICtrlRichEdit_SetBkColor | Sets the background color of the control
_GUICtrlRichEdit_SetCharAttributes | Turns an attribute on or off for selected text or, if none selected, for text inserted at the insertion point
_GUICtrlRichEdit_SetCharBkColor | Sets the background color of selected text or, if none selected, sets the background color of text inserted at the insertion point
_GUICtrlRichEdit_SetCharColor | Sets the color of selected text or, if none selected, sets the background color of text inserted at the insertion point
_GUICtrlRichEdit_SetEventMask | Specifies which notification messages are sent to the parent window
_GUICtrlRichEdit_SetFont | Sets the font attributes of selected text or, if none selected, sets those of text inserted at the insertion point
_GUICtrlRichEdit_SetLimitOnText | Change number of characters that can be typed, pasted or streamed in as Rich Text Format
_GUICtrlRichEdit_SetModified | Sets or clears the modification flag
_GUICtrlRichEdit_SetParaAlignment | Sets alignment of paragraph(s) in the current selection or, if no selection, of paragraphs inserted at the insertion point
_GUICtrlRichEdit_SetParaAttributes | Sets attributes of paragraph(s) in the current selection or, if no selection, of paragraphs inserted at the insertion point
_GUICtrlRichEdit_SetParaBorder | Sets the border of paragraph(s) in the current selection or, if no selection, of paragraphs inserted at the insertion point
_GUICtrlRichEdit_SetParaIndents | Sets indents of paragraph(s) in the current selection or, if no selection, of paragraphs inserted at the insertion point
_GUICtrlRichEdit_SetParaNumbering | Sets numbering of paragraph(s) in the current selection or, if no selection, of paragraph(s) inserted at the insertion point
_GUICtrlRichEdit_SetParaShading | Sets the shading of paragraph(s) in the current selection or, if no selection, of paragraphs inserted at the insertion point
_GUICtrlRichEdit_SetParaSpacing | Sets paragraph spacing of paragraphs having selected text or, if none selected, sets it for text inserted at the insertion point
_GUICtrlRichEdit_SetParaTabStops | Sets tab stops of paragraphs having selected text or, if none selected, sets it for text inserted at the insertion point
_GUICtrlRichEdit_SetPasswordChar | Sets the characters to be displayed instead of those typed, or causes typed characters to show
_GUICtrlRichEdit_SetReadOnly | Sets or removes the read-only state
_GUICtrlRichEdit_SetRECT | Sets the formatting rectangle of a Rich Edit control
_GUICtrlRichEdit_SetScrollPos | Scrolls the display such that ($ix,$iY) is in the upper left corner of the control
_GUICtrlRichEdit_SetSel | Sets the low and high character position of a selection
_GUICtrlRichEdit_SetSpaceUnit | Sets the unit of measure of horizontal and vertical space used in parameters of various _GUICtrlRichEdit functions
_GUICtrlRichEdit_SetTabStops | Sets tab stops for the control
_GUICtrlRichEdit_SetText | Sets the text of a control
_GUICtrlRichEdit_SetUndoLimit | Sets the maximum number of actions that can stored in the undo queue
_GUICtrlRichEdit_SetZoom | Sets zoom level of the control
_GUICtrlRichEdit_StreamFromFile | Sets text in a control from a file
_GUICtrlRichEdit_StreamFromVar | Sets text in a control from a variable
_GUICtrlRichEdit_StreamToFile | Writes contents of a control to a file
_GUICtrlRichEdit_StreamToVar | Writes contents of a control to a variable
_GUICtrlRichEdit_Undo | Undoes the last edit control operation in the control's undo queue
_GUICtrlSlider_ClearSel | Clears the current selection range
_GUICtrlSlider_ClearTics | Removes the current tick marks from a slider
_GUICtrlSlider_Create | Create a Slider control
_GUICtrlSlider_Destroy | Delete the control
_GUICtrlSlider_GetBuddy | Retrieves the handle to a slider control buddy window at a given location
_GUICtrlSlider_GetChannelRect | Retrieves the size and position of the bounding rectangle for a sliders's channel
_GUICtrlSlider_GetChannelRectEx | Retrieves the size and position of the bounding rectangle for a sliders's channel
_GUICtrlSlider_GetLineSize | Retrieves the number of logical positions the slider moves
_GUICtrlSlider_GetLogicalTics | Retrieves an array that contains the logical positions of the tick marks for a slider
_GUICtrlSlider_GetNumTics | Retrieves the number of tick marks from a slider
_GUICtrlSlider_GetPageSize | Retrieves the number of logical positions the slider moves
_GUICtrlSlider_GetPos | Retrieves the logical position the slider
_GUICtrlSlider_GetRange | Retrieves the maximum and minimum position for the slider
_GUICtrlSlider_GetRangeMax | Retrieves the maximum position for the slider
_GUICtrlSlider_GetRangeMin | Retrieves the minimum position for the slider
_GUICtrlSlider_GetSel | Retrieves the ending and starting position of the current selection range
_GUICtrlSlider_GetSelEnd | Retrieves the ending position of the current selection range
_GUICtrlSlider_GetSelStart | Retrieves the starting position of the current selection range
_GUICtrlSlider_GetThumbLength | Retrieves the length of the slider
_GUICtrlSlider_GetThumbRect | Retrieves the size and position of the bounding rectangle for the slider
_GUICtrlSlider_GetThumbRectEx | Retrieves the size and position of the bounding rectangle for the slider
_GUICtrlSlider_GetTic | Retrieves the logical position of a tick mark
_GUICtrlSlider_GetTicPos | Retrieves the current physical position of a tick mark
_GUICtrlSlider_GetToolTips | Retrieves the handle to the ToolTip control assigned to the slider, if any
_GUICtrlSlider_GetUnicodeFormat | Retrieves the Unicode character format flag for the control
_GUICtrlSlider_SetBuddy | Assigns a window as the buddy window for a slider control
_GUICtrlSlider_SetLineSize | Sets the number of logical positions the slider moves
_GUICtrlSlider_SetPageSize | Sets the number of logical positions the slider moves
_GUICtrlSlider_SetPos | Sets the current logical position of the slider
_GUICtrlSlider_SetRange | Sets the range of minimum and maximum logical positions for the slider
_GUICtrlSlider_SetRangeMax | Sets the maximum logical position for the slider
_GUICtrlSlider_SetRangeMin | Sets the minimum logical position for the slider
_GUICtrlSlider_SetSel | Sets the starting and ending positions for the available selection range
_GUICtrlSlider_SetSelEnd | Sets the ending logical position of the current selection range
_GUICtrlSlider_SetSelStart | Sets the starting logical position of the current selection range
_GUICtrlSlider_SetThumbLength | Sets the length of the slider
_GUICtrlSlider_SetTic | Sets a tick mark in a slider at the specified logical position
_GUICtrlSlider_SetTicFreq | Sets the interval frequency for tick marks in a slider
_GUICtrlSlider_SetTipSide | Positions a ToolTip control
_GUICtrlSlider_SetToolTips | Assigns a ToolTip control to a slider control
_GUICtrlSlider_SetUnicodeFormat | Sets the Unicode character format flag for the control
_GUICtrlStatusBar_Create | Create a statusbar
_GUICtrlStatusBar_Destroy | Delete the control
_GUICtrlStatusBar_EmbedControl | Embeds a child control in the control
_GUICtrlStatusBar_GetBorders | Retrieves the current widths of the horizontal and vertical borders
_GUICtrlStatusBar_GetBordersHorz | Retrieves the current width of the horizontal border
_GUICtrlStatusBar_GetBordersRect | Retrieves the current width of the rectangle border
_GUICtrlStatusBar_GetBordersVert | Retrieves the current width of the vertical border
_GUICtrlStatusBar_GetCount | Retrieves the number of parts
_GUICtrlStatusBar_GetHeight | Retrieves the height of the statusbar
_GUICtrlStatusBar_GetIcon | Retrieves the icon for a part
_GUICtrlStatusBar_GetParts | Retrieves the number of parts and the part edges
_GUICtrlStatusBar_GetRect | Retrieves the bounding rectangle of a part
_GUICtrlStatusBar_GetRectEx | Retrieves the bounding rectangle of a part
_GUICtrlStatusBar_GetText | Retrieves the text from the specified part
_GUICtrlStatusBar_GetTextFlags | Retrieves the text length flags for a part
_GUICtrlStatusBar_GetTextLength | Retrieves the length of a part text
_GUICtrlStatusBar_GetTextLengthEx | Retrieves the uFlag of a part
_GUICtrlStatusBar_GetTipText | Retrieves the ToolTip text for a part
_GUICtrlStatusBar_GetUnicodeFormat | Retrieves the Unicode character format flag
_GUICtrlStatusBar_GetWidth | Retrieves the width of a part
_GUICtrlStatusBar_IsSimple | Checks a status bar control to determine if it is in simple mode
_GUICtrlStatusBar_Resize | Causes the status bar to resize itself
_GUICtrlStatusBar_SetBkColor | Sets the background color
_GUICtrlStatusBar_SetIcon | Sets the icon for a part
_GUICtrlStatusBar_SetMinHeight | Sets the minimum height of a status window's drawing area
_GUICtrlStatusBar_SetParts | Sets the number of parts and the part edges
_GUICtrlStatusBar_SetSimple | Specifies whether a status window displays simple text or displays all window parts
_GUICtrlStatusBar_SetText | Sets the text in the specified part of a status window
_GUICtrlStatusBar_SetTipText | Sets the ToolTip text for a part
_GUICtrlStatusBar_SetUnicodeFormat | Sets the Unicode character format flag
_GUICtrlStatusBar_ShowHide | Show/Hide the StatusBar control
_GUICtrlTab_ActivateTab | Activates a tab by its index
_GUICtrlTab_ClickTab | Clicks a tab
_GUICtrlTab_Create | Create a TabControl control
_GUICtrlTab_DeleteAllItems | Deletes all tabs
_GUICtrlTab_DeleteItem | Deletes a tab
_GUICtrlTab_DeselectAll | Resets tabs, clearing any that were set to the pressed state
_GUICtrlTab_Destroy | Delete the control
_GUICtrlTab_FindTab | Searches for a tab with the specific text
_GUICtrlTab_GetCurFocus | Returns the index of the item that has the focus in a tab control
_GUICtrlTab_GetCurSel | Determines the currently selected tab
_GUICtrlTab_GetDisplayRect | Retrieves the display rectangle of the client area
_GUICtrlTab_GetDisplayRectEx | Retrieves the display rectangle of the client area
_GUICtrlTab_GetExtendedStyle | Retrieves the extended styles that are currently in use
_GUICtrlTab_GetImageList | Retrieves the tab control image list
_GUICtrlTab_GetItem | Retrieves information about a tab
_GUICtrlTab_GetItemCount | Retrieves the number of tabs
_GUICtrlTab_GetItemImage | Retrieves the image index for a tab
_GUICtrlTab_GetItemParam | Retrieves the param data for a tab
_GUICtrlTab_GetItemRect | Retrieves the bounding rectangle for a tab
_GUICtrlTab_GetItemRectEx | Retrieves the bounding rectangle for a tab
_GUICtrlTab_GetItemState | Retrieves the state of a tab
_GUICtrlTab_GetItemText | Retrieves the text of a tab
_GUICtrlTab_GetRowCount | Retrieves the current number of rows of tabs
_GUICtrlTab_GetToolTips | Retrieves the handle to the ToolTip control associated with the control
_GUICtrlTab_GetUnicodeFormat | Retrieves the Unicode character format flag for the control
_GUICtrlTab_HighlightItem | Sets the highlight state of a tab item
_GUICtrlTab_HitTest | Determines where a point lies control
_GUICtrlTab_InsertItem | Inserts a new tab
_GUICtrlTab_RemoveImage | Removes an image from the control's image list
_GUICtrlTab_SetCurFocus | Sets the focus to a specified tab
_GUICtrlTab_SetCurSel | Selects a tab
_GUICtrlTab_SetExtendedStyle | Sets the extended styles that are currently in use
_GUICtrlTab_SetImageList | Sets the image list associated with a tab control
_GUICtrlTab_SetItem | Sets information about a tab
_GUICtrlTab_SetItemImage | Sets the image of a tab
_GUICtrlTab_SetItemParam | Sets the param data of a tab
_GUICtrlTab_SetItemSize | Sets the width and height of tabs in a fixed width or owner drawn control
_GUICtrlTab_SetItemState | Sets the state of a tab
_GUICtrlTab_SetItemText | Sets the text of a tab
_GUICtrlTab_SetMinTabWidth | Sets the minimum width of items in a tab control
_GUICtrlTab_SetPadding | Sets the amount of space around each tab's icon and label
_GUICtrlTab_SetToolTips | Sets the handle to the ToolTip control associated with the control
_GUICtrlTab_SetUnicodeFormat | Sets the Unicode character format flag for the control
_GUICtrlToolbar_AddBitmap | Adds images to the image list
_GUICtrlToolbar_AddButton | Adds a button
_GUICtrlToolbar_AddButtonSep | Adds a separator
_GUICtrlToolbar_AddString | Adds a new string to the toolbar's string pool
_GUICtrlToolbar_ButtonCount | Retrieves a count of the buttons
_GUICtrlToolbar_CheckButton | Checks or unchecks a given button
_GUICtrlToolbar_ClickAccel | Clicks a specific button using it's accelerator
_GUICtrlToolbar_ClickButton | Clicks a specific button
_GUICtrlToolbar_ClickIndex | Clicks a specific button using it's index
_GUICtrlToolbar_CommandToIndex | Retrieves the index for the button associated with the specified command identifier
_GUICtrlToolbar_Create | Create a Toolbar control
_GUICtrlToolbar_Customize | Displays the Customize Toolbar dialog box
_GUICtrlToolbar_DeleteButton | Deletes a button from the toolbar
_GUICtrlToolbar_Destroy | Delete the control
_GUICtrlToolbar_EnableButton | Enables or disables the specified button
_GUICtrlToolbar_FindToolbar | Finds a specific toolbar
_GUICtrlToolbar_GetAnchorHighlight | Retrieves the anchor highlight setting
_GUICtrlToolbar_GetBitmapFlags | Retrieves the flags that describe the type of bitmap to be used
_GUICtrlToolbar_GetButtonBitmap | Retrieves the index of the bitmap associated with a button
_GUICtrlToolbar_GetButtonInfo | Retrieves information for a button
_GUICtrlToolbar_GetButtonInfoEx | Retrieves extended information for a button
_GUICtrlToolbar_GetButtonParam | Retrieves the button param value
_GUICtrlToolbar_GetButtonRect | Retrieves the bounding rectangle for a button
_GUICtrlToolbar_GetButtonRectEx | Retrieves the bounding rectangle for a specified toolbar button
_GUICtrlToolbar_GetButtonSize | Retrieves the current button width and height, in pixels
_GUICtrlToolbar_GetButtonState | Retrieves information about the state of the specified button
_GUICtrlToolbar_GetButtonStyle | Retrieves the style flags of a button
_GUICtrlToolbar_GetButtonText | Retrieves the display text of a button
_GUICtrlToolbar_GetColorScheme | Retrieves the color scheme information
_GUICtrlToolbar_GetDisabledImageList | Retrieves the disabled button image list
_GUICtrlToolbar_GetExtendedStyle | Retrieves the extended styles
_GUICtrlToolbar_GetHotImageList | Retrieves the hot button image list
_GUICtrlToolbar_GetHotItem | Retrieves the index of the hot item
_GUICtrlToolbar_GetImageList | Retrieves the default state image list
_GUICtrlToolbar_GetInsertMark | Retrieves the current insertion mark
_GUICtrlToolbar_GetInsertMarkColor | Retrieves the color used to draw the insertion mark
_GUICtrlToolbar_GetMaxSize | Retrieves the total size of all of the visible buttons and separators
_GUICtrlToolbar_GetMetrics | Retrieves the metrics of a toolbar control
_GUICtrlToolbar_GetPadding | Retrieves the horizontal and vertical padding
_GUICtrlToolbar_GetRows | Retrieves the number of rows of buttons
_GUICtrlToolbar_GetString | Retrieves a string from the string pool
_GUICtrlToolbar_GetStyle | Retrieves the styles currently in use for a toolbar control
_GUICtrlToolbar_GetStyleAltDrag | Indicates that the control allows buttons to be dragged
_GUICtrlToolbar_GetStyleCustomErase | Indicates that the control generates NM_CUSTOMDRAW notification messages
_GUICtrlToolbar_GetStyleFlat | Indicates that the control is flat
_GUICtrlToolbar_GetStyleList | Indicates that the control has button text to the right of the bitmap
_GUICtrlToolbar_GetStyleRegisterDrop | Indicates that the control generates TBN_GETOBJECT notification messages
_GUICtrlToolbar_GetStyleToolTips | Indicates that the control has tooltips
_GUICtrlToolbar_GetStyleTransparent | Indicates that the control is transparent
_GUICtrlToolbar_GetStyleWrapable | Indicates that the control is wrapable
_GUICtrlToolbar_GetTextRows | Retrieves the maximum number of text rows that can be displayed on a button
_GUICtrlToolbar_GetToolTips | Retrieves the handle to the ToolTip control
_GUICtrlToolbar_GetUnicodeFormat | Retrieves the Unicode character format flag
_GUICtrlToolbar_HideButton | Hides or shows the specified button
_GUICtrlToolbar_HighlightButton | Sets the highlight state of a given button control
_GUICtrlToolbar_HitTest | Determines where a point lies within the control
_GUICtrlToolbar_IndexToCommand | Retrieves the command identifier associated with the button
_GUICtrlToolbar_InsertButton | Inserts a button
_GUICtrlToolbar_InsertMarkHitTest | Retrieves the insertion mark information for a point
_GUICtrlToolbar_IsButtonChecked | Indicates whether the specified button is checked
_GUICtrlToolbar_IsButtonEnabled | Indicates whether the specified button is enabled
_GUICtrlToolbar_IsButtonHidden | Indicates whether the specified button is hidden
_GUICtrlToolbar_IsButtonHighlighted | Indicates whether the specified button is hilighted
_GUICtrlToolbar_IsButtonIndeterminate | Indicates whether the specified button is indeterminate
_GUICtrlToolbar_IsButtonPressed | Indicates that the button is being clicked
_GUICtrlToolbar_LoadBitmap | Adds a bitmap to the image list from a file
_GUICtrlToolbar_LoadImages | Loads system defined button images into a toolbar control's image list
_GUICtrlToolbar_MapAccelerator | Determines the ID of the button that corresponds to the specified accelerator
_GUICtrlToolbar_MoveButton | Moves a button from one index to another
_GUICtrlToolbar_PressButton | Presses or releases the specified button
_GUICtrlToolbar_SetAnchorHighlight | Sets the anchor highlight setting
_GUICtrlToolbar_SetBitmapSize | Sets the size of the bitmapped images to be added to a toolbar
_GUICtrlToolbar_SetButtonBitMap | Sets the index of the bitmap associated with a button
_GUICtrlToolbar_SetButtonInfo | Sets information for a button
_GUICtrlToolbar_SetButtonInfoEx | Sets extended information for a button
_GUICtrlToolbar_SetButtonParam | Sets the button param value
_GUICtrlToolbar_SetButtonSize | Sets the size of the buttons to be added to a toolbar
_GUICtrlToolbar_SetButtonState | Sets information about the state of the specified button
_GUICtrlToolbar_SetButtonStyle | Sets the style flags of a button
_GUICtrlToolbar_SetButtonText | Sets the display text of a button
_GUICtrlToolbar_SetButtonWidth | Sets the minimum and maximum button widths in the toolbar control
_GUICtrlToolbar_SetCmdID | Sets the command identifier of a toolbar button
_GUICtrlToolbar_SetColorScheme | Sets the color scheme information
_GUICtrlToolbar_SetDisabledImageList | Sets the disabled image list
_GUICtrlToolbar_SetDrawTextFlags | Sets the text drawing flags for the toolbar
_GUICtrlToolbar_SetExtendedStyle | Sets the extended styles control
_GUICtrlToolbar_SetHotImageList | Sets the hot button image list
_GUICtrlToolbar_SetHotItem | Sets the hot item
_GUICtrlToolbar_SetImageList | Sets the default button image list
_GUICtrlToolbar_SetIndent | Sets the indentation for the first button control
_GUICtrlToolbar_SetIndeterminate | Sets or clears the indeterminate state of the specified button
_GUICtrlToolbar_SetInsertMark | Sets the current insertion mark for the toolbar
_GUICtrlToolbar_SetInsertMarkColor | Sets the color used to draw the insertion mark
_GUICtrlToolbar_SetMaxTextRows | Sets the maximum number of text rows displayed button
_GUICtrlToolbar_SetMetrics | Sets the metrics of a toolbar control
_GUICtrlToolbar_SetPadding | Sets the padding control
_GUICtrlToolbar_SetParent | Sets the window to which the control sends notification messages
_GUICtrlToolbar_SetRows | Sets the number of rows of buttons
_GUICtrlToolbar_SetStyle | Sets the style control
_GUICtrlToolbar_SetStyleAltDrag | Sets whether that the control allows buttons to be dragged
_GUICtrlToolbar_SetStyleCustomErase | Sets whether the control generates NM_CUSTOMDRAW notification messages
_GUICtrlToolbar_SetStyleFlat | Sets whether the control is flat
_GUICtrlToolbar_SetStyleList | Sets whether the control has button text to the right of the bitmap
_GUICtrlToolbar_SetStyleRegisterDrop | Sets whether the control generates TBN_GETOBJECT notification messages
_GUICtrlToolbar_SetStyleToolTips | Sets whether the control has tooltips
_GUICtrlToolbar_SetStyleTransparent | Sets whether the control is transparent
_GUICtrlToolbar_SetStyleWrapable | Sets whether the control is wrapable
_GUICtrlToolbar_SetToolTips | Associates a ToolTip control with a toolbar
_GUICtrlToolbar_SetUnicodeFormat | Sets the Unicode character format flag
_GUICtrlToolbar_SetWindowTheme | Sets the visual style
_GUICtrlTreeView_Add | Adds a new item
_GUICtrlTreeView_AddChild | Adds a new item
_GUICtrlTreeView_AddChildFirst | Adds a new item
_GUICtrlTreeView_AddFirst | Adds a new item
_GUICtrlTreeView_BeginUpdate | Prevents updating of the control until the EndUpdate function is called
_GUICtrlTreeView_ClickItem | Click on a item
_GUICtrlTreeView_Create | Create a TreeView control
_GUICtrlTreeView_CreateDragImage | Creates a dragging bitmap for the specified item
_GUICtrlTreeView_CreateSolidBitMap | Creates a solid color bitmap
_GUICtrlTreeView_Delete | Removes an item and all its children
_GUICtrlTreeView_DeleteAll | Removes all items from a tree-view control
_GUICtrlTreeView_DeleteChildren | Deletes all children of a item
_GUICtrlTreeView_Destroy | Delete the control
_GUICtrlTreeView_DisplayRect | Returns the bounding rectangle for a tree item
_GUICtrlTreeView_DisplayRectEx | Returns the bounding rectangle for a tree item
_GUICtrlTreeView_EditText | Begins in-place editing of the specified item's text
_GUICtrlTreeView_EndEdit | Ends the editing of the item's text
_GUICtrlTreeView_EndUpdate | Enables screen repainting that was turned off with the BeginUpdate function
_GUICtrlTreeView_EnsureVisible | Ensures that a item is visible, expanding the parent item or scrolling the control if necessary
_GUICtrlTreeView_Expand | Expands or collapses the list of child items associated with the specified parent item, if any
_GUICtrlTreeView_ExpandedOnce | Indicates if the item's list of child items has been expanded at least once
_GUICtrlTreeView_FindItem | Retrieves a item based on it's text
_GUICtrlTreeView_FindItemEx | Retrieves a item based on a tree path
_GUICtrlTreeView_GetBkColor | Retrieve the text back color
_GUICtrlTreeView_GetBold | Indicates if the item is drawn in a bold style
_GUICtrlTreeView_GetChecked | Indicates if a item has its checkbox checked
_GUICtrlTreeView_GetChildCount | Retrieves the number of children of an parent item
_GUICtrlTreeView_GetChildren | Indicates whether the item children flag is set
_GUICtrlTreeView_GetCount | Retrieves a count of the items
_GUICtrlTreeView_GetCut | Indicates if the item is drawn as if selected as part of a cut and paste operation
_GUICtrlTreeView_GetDropTarget | Indicates whether the item is drawn as a drag and drop target
_GUICtrlTreeView_GetEditControl | Retrieves the handle to the edit control being used to edit a item's text
_GUICtrlTreeView_GetExpanded | Indicates whether the item is expanded
_GUICtrlTreeView_GetFirstChild | Retrieves the first child item of the specified item
_GUICtrlTreeView_GetFirstItem | Retrieves the topmost or very first item
_GUICtrlTreeView_GetFirstVisible | Retrieves the first visible item in the control
_GUICtrlTreeView_GetFocused | Indicates whether the item has focus
_GUICtrlTreeView_GetHeight | Retrieves the current height of the each item
_GUICtrlTreeView_GetImageIndex | Retrieves the normal state image index
_GUICtrlTreeView_GetImageListIconHandle | Retrieve ImageList handle
_GUICtrlTreeView_GetIndent | Retrieves the amount, in pixels, that child items are indented relative to their parent items
_GUICtrlTreeView_GetInsertMarkColor | Retrieves the color used to draw the insertion mark
_GUICtrlTreeView_GetISearchString | Retrieves the incremental search string
_GUICtrlTreeView_GetItemByIndex | Retrieve a item by its position in the list of child items
_GUICtrlTreeView_GetItemHandle | Retrieve the item handle
_GUICtrlTreeView_GetItemParam | Retrieves the application specific value of the item
_GUICtrlTreeView_GetLastChild | Retrieves the last child item of the specified item
_GUICtrlTreeView_GetLineColor | Retrieve the line color
_GUICtrlTreeView_GetNext | Retrieves the next item after the calling item
_GUICtrlTreeView_GetNextChild | Returns the next item at the same level as the specified item
_GUICtrlTreeView_GetNextSibling | Returns the next item at the same level as the specified item
_GUICtrlTreeView_GetNextVisible | Retrieves the next visible item that follows the specified item
_GUICtrlTreeView_GetNormalImageList | Retrieves the normal image list
_GUICtrlTreeView_GetParentHandle | Retrieve the parent handle of item
_GUICtrlTreeView_GetParentParam | Retrieve the parent control ID/Param of item
_GUICtrlTreeView_GetPrev | Retrieves the previous item before the calling item
_GUICtrlTreeView_GetPrevChild | Retrieves the previous child item of a specified item
_GUICtrlTreeView_GetPrevSibling | Returns the previous item before the calling item at the same level
_GUICtrlTreeView_GetPrevVisible | Retrieves the first visible item that precedes the specified item
_GUICtrlTreeView_GetScrollTime | Retrieves the maximum scroll time
_GUICtrlTreeView_GetSelected | Indicates whether the item appears in the selected state
_GUICtrlTreeView_GetSelectedImageIndex | Retrieves the index in the image list of the image displayed for the item when it is selected
_GUICtrlTreeView_GetSelection | Retrieves the currently selected item
_GUICtrlTreeView_GetSiblingCount | Retrieves the number of siblings at the level of an item
_GUICtrlTreeView_GetState | Retrieve the state of the item
_GUICtrlTreeView_GetStateImageIndex | Retrieves the index of the state image to display for the item
_GUICtrlTreeView_GetStateImageList | Retrieves the handle to the state image list
_GUICtrlTreeView_GetText | Retrieve the item text
_GUICtrlTreeView_GetTextColor | Retrieve the text color
_GUICtrlTreeView_GetToolTips | Retrieves the handle to the child ToolTip control
_GUICtrlTreeView_GetTree | Retrieve all items text
_GUICtrlTreeView_GetUnicodeFormat | Retrieves the Unicode character format flag
_GUICtrlTreeView_GetVisible | Indicates whether the item is currently visible in the control image
_GUICtrlTreeView_GetVisibleCount | Returns the number of items that can be fully visible in the control
_GUICtrlTreeView_HitTest | Returns information about the location of a point relative to the control
_GUICtrlTreeView_HitTestEx | Returns information about the location of a point relative to the control
_GUICtrlTreeView_HitTestItem | Returns the item at the specified coordinates
_GUICtrlTreeView_Index | Retrieves the position of the item in the list
_GUICtrlTreeView_InsertItem | Insert an item
_GUICtrlTreeView_IsFirstItem | Indicates whether the tree item is very first
_GUICtrlTreeView_IsParent | Indicates whether one item is the parent of another item
_GUICtrlTreeView_Level | Indicates the level of indentation of a item
_GUICtrlTreeView_SelectItem | Selects the specified item, scrolls the item into view, or redraws the item
_GUICtrlTreeView_SelectItemByIndex | Selects the item based on it's index in the parent list
_GUICtrlTreeView_SetBkColor | Sets the back color
_GUICtrlTreeView_SetBold | Sets whether the item is drawn using a bold sytle
_GUICtrlTreeView_SetChecked | Sets whether a item has it's checkbox checked or not
_GUICtrlTreeView_SetCheckedByIndex | Sets whether an item has it's checkbox checked or not by it's index
_GUICtrlTreeView_SetChildren | Sets whether the item children flag
_GUICtrlTreeView_SetCut | Sets whether the item is drawn as if selected as part of a cut and paste operation
_GUICtrlTreeView_SetDropTarget | Sets whether the item is drawn as a drag and drop target
_GUICtrlTreeView_SetFocused | Sets whether the item appears to have focus
_GUICtrlTreeView_SetHeight | Sets the height of the each item
_GUICtrlTreeView_SetIcon | Set an item icon
_GUICtrlTreeView_SetImageIndex | Sets the index into image list for which image is displayed when a item is in its normal state
_GUICtrlTreeView_SetIndent | Sets the width of indentation for a tree-view control and redraws the control to reflect the new width
_GUICtrlTreeView_SetInsertMark | Sets the insertion mark
_GUICtrlTreeView_SetInsertMarkColor | Sets the color used to draw the insertion mark
_GUICtrlTreeView_SetItemHeight | Sets the height of an individual item
_GUICtrlTreeView_SetItemParam | Sets the value specific to the item
_GUICtrlTreeView_SetLineColor | Sets the line color
_GUICtrlTreeView_SetNormalImageList | Sets the normal image list for the control
_GUICtrlTreeView_SetScrollTime | Sets the maximum scroll time
_GUICtrlTreeView_SetSelected | Sets whether the item appears in the selected state
_GUICtrlTreeView_SetSelectedImageIndex | Sets the selected image index
_GUICtrlTreeView_SetState | Set the state of the specified item
_GUICtrlTreeView_SetStateImageIndex | Sets the index into image list for the state image
_GUICtrlTreeView_SetStateImageList | Sets the state image list for the control
_GUICtrlTreeView_SetText | Set the text of an item
_GUICtrlTreeView_SetTextColor | Sets the text color
_GUICtrlTreeView_SetToolTips | Sets the handle to the child ToolTip control
_GUICtrlTreeView_SetUnicodeFormat | Sets the Unicode character format flag
_GUICtrlTreeView_Sort | Sorts the items
_GUIImageList_Add | Adds an image or images to an image list
_GUIImageList_AddBitmap | Adds a bitmap to an image list
_GUIImageList_AddIcon | Adds an icon to an image list
_GUIImageList_AddMasked | Adds an image or images to an image list, generating a mask from the specified bitmap
_GUIImageList_BeginDrag | Begins dragging an image
_GUIImageList_Copy | Source image is copied to the destination image's index
_GUIImageList_Create | Create an ImageList control
_GUIImageList_Destroy | Destroys an image list
_GUIImageList_DestroyIcon | Destroys an icon and frees any memory the icon occupied
_GUIImageList_DragEnter | Displays the drag image at the specified position within the window
_GUIImageList_DragLeave | Unlocks the specified window and hides the drag image, allowing the window to be updated
_GUIImageList_DragMove | Moves the image that is being dragged during a drag-and-drop operation
_GUIImageList_Draw | Draws an image list item in the specified device context
_GUIImageList_DrawEx | Draws an image list item in the specified device context
_GUIImageList_Duplicate | Creates a duplicate of an existing image list
_GUIImageList_EndDrag | Ends a drag operation
_GUIImageList_GetBkColor | Retrieves the current background color for an image list
_GUIImageList_GetIcon | Creates an icon from an image and mask in an image list
_GUIImageList_GetIconHeight | Retrieves the height of the images in an image list
_GUIImageList_GetIconSize | Retrieves the dimensions of images in an image list
_GUIImageList_GetIconSizeEx | Retrieves the dimensions of images in an image list
_GUIImageList_GetIconWidth | Retrieves the width of the images in an image list
_GUIImageList_GetImageCount | Retrieves the number of images in an image list
_GUIImageList_GetImageInfoEx | Retrieves information about an image
_GUIImageList_Remove | Remove Image(s) from the ImageList
_GUIImageList_ReplaceIcon | Replaces an image with an icon or cursor
_GUIImageList_SetBkColor | Sets the background color for an image list
_GUIImageList_SetIconSize | Sets the dimensions of images in an image list and removes all images from the list
_GUIImageList_SetImageCount | Resizes an existing image list
_GUIImageList_Swap | Swap image between Source and Destination image's index
_GUIScrollBars_EnableScrollBar | Enable/Disable scrollbar
_GUIScrollBars_GetScrollBarInfoEx | Retrieves information about the specified scroll bar
_GUIScrollBars_GetScrollBarRect | Retrieves coordinates of the scroll bar
_GUIScrollBars_GetScrollBarRGState | Retrieves the state of a scroll bar component
_GUIScrollBars_GetScrollBarXYLineButton | Retrieves the Height or width of the thumb
_GUIScrollBars_GetScrollBarXYThumbBottom | Retrieves the Position of the bottom or right of the thumb
_GUIScrollBars_GetScrollBarXYThumbTop | Retrieves the Position of the top or left of the thumb
_GUIScrollBars_GetScrollInfo | Retrieves the parameters of a scroll bar
_GUIScrollBars_GetScrollInfoEx | Retrieves the parameters of a scroll bar
_GUIScrollBars_GetScrollInfoMax | Retrieves the maximum scrolling position
_GUIScrollBars_GetScrollInfoMin | Retrieves the minimum scrolling position
_GUIScrollBars_GetScrollInfoPage | Retrieves the page size
_GUIScrollBars_GetScrollInfoPos | Retrieves the position of the scroll box
_GUIScrollBars_GetScrollInfoTrackPos | Retrieves the immediate position of a scroll box that the user is dragging
_GUIScrollBars_GetScrollPos | Retrieves the current position of the scroll box (thumb) in the specified scroll bar
_GUIScrollBars_GetScrollRange | Retrieves the current minimum and maximum scroll box (thumb) positions for the specified scroll bar
_GUIScrollBars_Init | Initialize the scrollbars for the window
_GUIScrollBars_ScrollWindow | Scrolls the contents of the specified window's client area
_GUIScrollBars_SetScrollInfo | Sets the parameters of a scroll bar
_GUIScrollBars_SetScrollInfoMax | Sets the maximum scrolling position
_GUIScrollBars_SetScrollInfoMin | Sets the minimum scrolling position
_GUIScrollBars_SetScrollInfoPage | Sets the page size
_GUIScrollBars_SetScrollInfoPos | Sets the position of the scroll box (thumb) in the specified scroll bar
_GUIScrollBars_SetScrollRange | Sets the minimum and maximum scroll box positions for the specified scroll bar
_GUIScrollBars_ShowScrollBar | Shows or hides the specified scroll bar
_GUIToolTip_Activate | Activates a ToolTip control
_GUIToolTip_AddTool | Registers a tool with the ToolTip control
_GUIToolTip_AdjustRect | Calculates the text display rectangle from the window rectangle
_GUIToolTip_BitsToTTF | Decode bit flags to TTF_* strings
_GUIToolTip_Create | Creates a ToolTip control
_GUIToolTip_Deactivate | Deactivates a ToolTip control
_GUIToolTip_DelTool | Deletes a tool from a tooltip control
_GUIToolTip_Destroy | Delete a ToolTip control
_GUIToolTip_EnumTools | Retrieves information about the current tool
_GUIToolTip_GetBubbleHeight | Returns the height of the control
_GUIToolTip_GetBubbleSize | Returns the width and height of a ToolTip control
_GUIToolTip_GetBubbleWidth | Returns the width of a ToolTip control
_GUIToolTip_GetCurrentTool | Retrieves information for the current tool
_GUIToolTip_GetDelayTime | Retrieves the initial, pop-up or reshow durations of a ToolTip control
_GUIToolTip_GetMargin | Retrieves the top, left, bottom, and right margins of a ToolTip control
_GUIToolTip_GetMarginEx | Retrieves the top, left, bottom, and right margins of a ToolTip control
_GUIToolTip_GetMaxTipWidth | Retrieves the maximum width of a ToolTip window
_GUIToolTip_GetText | Retrieves the text of a tool
_GUIToolTip_GetTipBkColor | Retrieves the background color
_GUIToolTip_GetTipTextColor | Retrieves the text color of a ToolTip control
_GUIToolTip_GetTitleBitMap | Retrieves the title bitmap icon
_GUIToolTip_GetTitleText | Retrieve the title
_GUIToolTip_GetToolCount | Returns the count of tools maintained by the ToolTip control
_GUIToolTip_GetToolInfo | Retrieves the information about a specific tool
_GUIToolTip_HitTest | Retrieves the information that a ToolTip control maintains about a tool
_GUIToolTip_NewToolRect | Sets a new bounding rectangle for a tool
_GUIToolTip_Pop | Removes a displayed ToolTip from view
_GUIToolTip_PopUp | Causes the ToolTip to display at the coordinates of the last mouse message
_GUIToolTip_SetDelayTime | Sets the initial, pop-up, and reshow durations of a ToolTip
_GUIToolTip_SetMargin | Sets the top, left, bottom, and right margins of a ToolTip
_GUIToolTip_SetMaxTipWidth | Sets the maximum width for a ToolTip window
_GUIToolTip_SetTipBkColor | Sets the background color of a ToolTip
_GUIToolTip_SetTipTextColor | Sets the text color
_GUIToolTip_SetTitle | Adds a standard icon and title string
_GUIToolTip_SetToolInfo | Sets the information for a tool
_GUIToolTip_SetWindowTheme | Sets the visual style
_GUIToolTip_ToolExists | Determines whether a tool currently exists (is displayed)
_GUIToolTip_ToolToArray | Transfers a ToolInfo structure to an array
_GUIToolTip_TrackActivate | Activates or deactivates a tracking ToolTip
_GUIToolTip_TrackPosition | Sets the position of a tracking ToolTip
_GUIToolTip_Update | Forces the current tool to be redrawn
_GUIToolTip_UpdateTipText | Sets the ToolTip text for a tool
_HexToString | Convert a hex string to a string
_IEAction | Perform any of a set of simple actions on the Browser
_IEAttach | Attach to the specified instance of Internet Explorer where the search string sub-string matches (based on the selected mode)
_IEBodyReadHTML | Returns the HTML inside the <body> tag of the document
_IEBodyReadText | Returns the Text inside the <body> tag of the document
_IEBodyWriteHTML | Replaces the HTML inside the <body> tag of the document
_IECreate | Create an Internet Explorer Browser Window
_IECreateEmbedded | Create a Webbrowser object suitable for embedding in an AutoIt GUI with GUICtrlCreateObj()
_IEDocGetObj | Given any DOM object, returns a reference to the associated document object
_IEDocInsertHTML | Inserts HTML Text in or around an element
_IEDocInsertText | Inserts Text in or around an element
_IEDocReadHTML | Returns the full HTML source of a document
_IEDocWriteHTML | Replaces the HTML for the entire document
_IEErrorNotify | Specifies whether IE.au3 automatically notifies of Warnings and Errors (to the console)
_IEFormElementCheckBoxSelect | Set the value of a specified form element
_IEFormElementGetCollection | Returns a collection object variable representing all Form Elements within a given Form
_IEFormElementGetObjByName | Returns an object reference to a Form Element by name
_IEFormElementGetValue | Returns the value of a given Form Element
_IEFormElementOptionSelect | Set the value of a specified form element
_IEFormElementRadioSelect | Set the value of a specified form element
_IEFormElementSetValue | Set the value of a specified Form Element
_IEFormGetCollection | Returns a collection object variable representing the Forms in the document or a single form by index
_IEFormGetObjByName | Returns an object reference to a Form by name
_IEFormImageClick | Simulate a mouse click on an <input type=image>. Match by sub-string match of alt text, name or src
_IEFormReset | Reset a specified Form setting the values back to their loaded defaults
_IEFormSubmit | Submit a specified Form
_IEFrameGetCollection | Returns a collection object containing the frames in a FrameSet or the iFrames on a normal page or a single Frame or iFrame by index
_IEFrameGetObjByName | Returns an object reference to a Frame or iFrame by name
_IEGetObjById | Returns an object variable by id
_IEGetObjByName | Returns an object variable by name
_IEHeadInsertEventScript | Inserts a Javascript into the Head of the document
_IEImgClick | Simulate a mouse click on an image. Match by sub-string match of alt text, name, or src
_IEImgGetCollection | Returns a collection object variable representing the IMG tags in the document or a single image by index
_IEIsFrameSet | Checks to see if the specified Window contains a FrameSet
_IELinkClickByIndex | Simulate a mouse click on a link by 0-based index (in source order)
_IELinkClickByText | Simulate a mouse click on a link with text sub-string matching the string provided
_IELinkGetCollection | Returns a collection object containing all links in the document or a single link by index
_IELoadWait | Wait for a browser page load to complete before returning
_IELoadWaitTimeout | Retrieve or set the current value in milliseconds _IELoadWait() will try before timing out
_IENavigate | Directs an existing browser window to navigate to the specified URL
_IEPropertyGet | Returns a select property of the Browser or DOM element
_IEPropertySet | Set a select property of the Browser or DOM element
_IEQuit | Close the browser and remove the object reference to it
_IETableGetCollection | Returns a collection object variable representing all the tables in a document or a single table by index
_IETableWriteToArray | Reads the contents of a Table into an array
_IETagNameAllGetCollection | Returns a collection object all elements in the document or document hierarchy in source order or a single element by index
_IETagNameGetCollection | Returns a collection object of all elements in the object with the specified TagName or a single element by index
_IE_Example | Display a new browser window pre-loaded with documents to be used in IE.au3 examples or your own testing
_IE_Introduction | Display introductory information about IE.au3 in a new browser window
_IE_VersionInfo | Returns an array of information about the IE.au3 version
_INetExplorerCapable | Converts a string to IE(Internet Explorer) capable line
_INetGetSource | Gets the source from an URL without writing a temp file
_INetMail | Opens default user's mail client with given address, subject, and body
_INetSmtpMail | Sends an email without using an external email program
_IsPressed | Check if key has been pressed
_MathCheckDiv | Checks if first number is divisible by the second number
_Max | Evaluates which of the two numbers is higher
_MemGlobalAlloc | Allocates the specified number of bytes from the heap
_MemGlobalFree | Frees the specified global memory object and invalidates its handle
_MemGlobalLock | Locks a global memory object and returns a pointer to the first byte of the object's memory block
_MemGlobalSize | Retrieves the current size of the specified global memory object
_MemGlobalUnlock | Decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE
_MemMoveMemory | Moves memory either forward or backward, aligned or unaligned
_MemVirtualAlloc | Reserves or commits a region of pages in the virtual address space of the calling process
_MemVirtualAllocEx | Reserves a region of memory within the virtual address space of a specified process
_MemVirtualFree | Releases a region of pages within the virtual address space of a process
_MemVirtualFreeEx | Releases a region of pages within the virtual address space of a process
_Min | Evaluates which of the two numbers is lower
_MouseTrap | Confine the Mouse Cursor to specified coords
_NamedPipes_CallNamedPipe | Performs a read/write operation on a named pipe
_NamedPipes_ConnectNamedPipe | Enables a named pipe server process to wait for a client process to connect
_NamedPipes_CreateNamedPipe | Creates an instance of a named pipe
_NamedPipes_CreatePipe | Creates an anonymous pipe
_NamedPipes_DisconnectNamedPipe | Disconnects the server end of a named pipe instance from a client process
_NamedPipes_GetNamedPipeHandleState | Retrieves information about a specified named pipe
_NamedPipes_GetNamedPipeInfo | Retrieves information about the specified named pipe
_NamedPipes_PeekNamedPipe | Copies data from a pipe into a buffer without removing it from the pipe
_NamedPipes_SetNamedPipeHandleState | Sets the read mode and the blocking mode of the specified named pipe
_NamedPipes_TransactNamedPipe | Reads and writes to a named pipe in one network operation
_NamedPipes_WaitNamedPipe | Waits for an instance of a named pipe to become available
_Net_Share_ConnectionEnum | Lists all connections made to a shared resource
_Net_Share_FileClose | Forces a resource to close
_Net_Share_FileEnum | Returns information about open files on a server
_Net_Share_FileGetInfo | Retrieves information about a particular opening of a server resource
_Net_Share_PermStr | Returns the string representation of a resource's permissions
_Net_Share_ResourceStr | Returns the string representation of a resource
_Net_Share_SessionDel | Ends a network session between a server and a workstation
_Net_Share_SessionEnum | Provides information about sessions established on a server
_Net_Share_SessionGetInfo | Retrieves information about a session established between a server and workstation
_Net_Share_ShareAdd | Shares a server resource
_Net_Share_ShareCheck | Checks whether or not a server is sharing a device
_Net_Share_ShareDel | Deletes a share name from a server's list of shared resources
_Net_Share_ShareEnum | Retrieves information about each shared resource on a server
_Net_Share_ShareGetInfo | Retrieves information about a particular shared resource on a server
_Net_Share_ShareSetInfo | Shares a server resource
_Net_Share_StatisticsGetSvr | Retrieves operating statistics for a server
_Net_Share_StatisticsGetWrk | Retrieves operating statistics for a workstation
_Now | Returns the current Date and Time in PC's format
_NowCalc | Returns the current Date and Time in format YYYY/MM/DD HH:MM:SS for use in date calculations
_NowCalcDate | Returns the current Date in format YYYY/MM/DD
_NowDate | Returns the current Date in the Pc's format
_NowTime | Returns the current Time in the requested format
_PathFull | Creates a path based on the relative path you provide. The newly created absolute path is returned
_PathGetRelative | Returns the relative path to a directory
_PathMake | Creates a path from drive, directory, file name and file extension parts
_PathSplit | Splits a path into the drive, directory, file name and file extension parts. An empty string is set if a part is missing
_ProcessGetName | Returns a string containing the process name that belongs to a given PID
_ProcessGetPriority | Get the priority of an open process
_Radian | Converts degrees to radians
_ReplaceStringInFile | Replaces substrings in a file
_RunDos | Executes a DOS command in a hidden command window
_ScreenCapture_Capture | Captures a region of the screen
_ScreenCapture_CaptureWnd | Captures a screen shot of a specified window or controlID
_ScreenCapture_SaveImage | Saves an image to file
_ScreenCapture_SetBMPFormat | Sets the bit format that will be used for BMP screen captures
_ScreenCapture_SetJPGQuality | Sets the quality level that will be used for JPEG screen captures
_ScreenCapture_SetTIFColorDepth | Sets the color depth used for TIFF screen captures
_ScreenCapture_SetTIFCompression | Sets the compression used for TIFF screen captures
_Security__AdjustTokenPrivileges | Enables or disables privileges in the specified access token
_Security__CreateProcessWithToken | Creates a new process and its primary thread running in the security context of the specified token
_Security__DuplicateTokenEx | Creates a new access token that duplicates an existing token
_Security__GetAccountSid | Retrieves the security identifier (SID) for an account
_Security__GetLengthSid | Returns the length, in bytes, of a valid SID
_Security__GetTokenInformation | Retrieves a specified type of information about an access token
_Security__ImpersonateSelf | Obtains an access token that impersonates the calling process security context
_Security__IsValidSid | Validates a SID
_Security__LookupAccountName | Retrieves a security identifier (SID) for the account and the name of the domain
_Security__LookupAccountSid | Retrieves the name of the account for a SID
_Security__LookupPrivilegeValue | Retrieves the locally unique identifier (LUID) for a privilege value in form of 64bit integer
_Security__OpenProcessToken | Returns the access token associated with a process
_Security__OpenThreadToken | Opens the access token associated with a thread
_Security__OpenThreadTokenEx | Opens the access token associated with a thread, impersonating the client's security context if required
_Security__SetPrivilege | Enables or disables a local token privilege
_Security__SetTokenInformation | Sets various types of information for a specified access token
_Security__SidToStringSid | Converts a binary SID to a string
_Security__SidTypeStr | Converts a SID type to string form
_Security__StringSidToSid | Converts a String SID to a binary SID
_SendMessage | Wrapper for commonly used DLL Call
_SendMessageA | Send a Message to a Window/Control (Force Ansi Call)
_SetDate | Sets the current date of the system
_SetTime | Sets the current time of the system
_Singleton | Enforce a design paradigm where only one instance of the script may be running
_SoundClose | Closes a sound previously opened with _SoundOpen
_SoundLength | Returns the length of the soundfile
_SoundOpen | Opens a sound file for use with other _Sound functions
_SoundPause | Pause a playing sound
_SoundPlay | Play a sound file
_SoundPos | Returns the current position of the sound
_SoundResume | Resume a paused sound
_SoundSeek | Seeks the sound to the specified position
_SoundStatus | Returns the status of the sound
_SoundStop | Stop a playing sound
_SQLite_Changes | Returns the number of database rows that were changed by the most recently completed statement with this connection
_SQLite_Close | Close an open database
_SQLite_Display2DResult | Returns or prints to Console a formated display of a 2Dimensional array
_SQLite_Encode | Binary encodes a string, number or binary data for use as BLOB in SQLite statements
_SQLite_ErrCode | Returns last error code (numeric)
_SQLite_ErrMsg | Returns a string describing in english the error condition for the most recent sqlite3_* API call
_SQLite_Escape | Escapes a string or number for use as TEXT in SQLite statements
_SQLite_Exec | Executes a SQLite query, does not handle results
_SQLite_FastEncode | Fast encodes binary data (exclusively) for use in SQLite statements
_SQLite_FastEscape | Fast escapes a string or number for use as TEXT in SQLite statements
_SQLite_FetchData | Fetches 1 row of data from a _SQLite_Query() based query
_SQLite_FetchNames | Read out the Column names of a _SQLite_Query() based query
_SQLite_GetTable | Passes Out a 1Dimensional Array Containing Tablenames and Data of Executed Query
_SQLite_GetTable2d | Passes out a 2Dimensional array containing column names and data of executed query
_SQLite_LastInsertRowID | Returns the ROWID of the most recent insert in the database by this connection
_SQLite_LibVersion | Returns the version number of the library
_SQLite_Open | Opens/creates a SQLite database
_SQLite_Query | Prepares a SQLite Query
_SQLite_QueryFinalize | Finalizes an _SQLite_Query() based query. The query is interrupted
_SQLite_QueryReset | Reset a _SQLite_Query() based query
_SQLite_QuerySingleRow | Read out the first row of the result from the specified query
_SQLite_SafeMode | Disable or Enable Safe mode
_SQLite_SetTimeout | Sets timeout for busy handler
_SQLite_Shutdown | Unloads SQLite.dll
_SQLite_SQLiteExe | Executes commands in sqlite3.exe
_SQLite_Startup | Loads SQLite3.dll
_SQLite_TotalChanges | Returns number of all changes (including via triggers and foreign keys) from start of connection
_StringBetween | Find strings between two string delimiters
_StringExplode | Splits up a string into substrings depending on the given delimiters as PHP Explode v5
_StringInsert | Inserts a string within another string
_StringProper | Changes a string to proper case, same as the =Proper function in Excel
_StringRepeat | Repeats a string a specified number of times
_StringTitleCase | Changes a string to a title case string
_StringToHex | Convert a string to a hex string
_TCPIpToName | Resolves IP address to Hostname(s)
_TempFile | Generate a name for a temporary file. The file is guaranteed not to exist yet
_TicksToTime | Converts the specified tick amount to hours, minutes and seconds
_Timer_Diff | Returns the difference in time from a previous call to _Timer_Init
_Timer_GetIdleTime | Returns the number of ticks since last user activity (i.e. KYBD/Mouse)
_Timer_GetTimerID | Returns the Timer ID from $wParam
_Timer_Init | Returns a timestamp (in milliseconds)
_Timer_KillAllTimers | Destroys all the timers
_Timer_KillTimer | Destroys the specified timer
_Timer_SetTimer | Creates a timer with the specified time-out value
_TimeToTicks | Converts the specified hours, minutes, and seconds to ticks
_VersionCompare | Compares two file versions for equality
_viClose | Closes a VISA connection to an Instrument/Device
_viExecCommand | Send a Command/Query to an Instrument/Device through the VISA interface (GPIB / TCP)
_viFindGpib | Send a Command/Query to an Instrument/Device through the VISA interface (GPIB / TCP)
_viGpibBusReset | GPIB BUS "reset": Use this function when the GPIB BUS gets stuck for some reason. You might be lucky and resolve the problem by calling this function
_viGTL | Go To Local mode: Instruments that accept this command will exit the "Remote Control mode" and go to "Local mode". If the instrument is already in "Local mode" this is simply ignored. Normally, if an instrument does not support this command it will simply stay in the "Remote Control mode"
_viInteractiveControl | Interactive VISA control to test your SCPI commands
_viOpen | Opens a VISA connection to an Instrument/Device
_viSetAttribute | Set any VISA attribute This function, which is called by _viSetTimeout, can ALSO be used to set the other VISA specific attributes. Read the VISA documentation for more information and a list of VISA attributes and their corresponding values
_viSetTimeout | Sets the VISA timeout in MILISECONDS
_WeekNumberISO | Calculate the weeknumber of a given date
_WinAPI_AbortPath | Closes and discards any paths in the specified device context
_WinAPI_ActivateKeyboardLayout | Sets the input locale identifier for the calling thread or the current process
_WinAPI_AddClipboardFormatListener | Places the given window in the system-maintained clipboard format listener list
_WinAPI_AddFontMemResourceEx | Adds the font resource from a memory image to the system
_WinAPI_AddFontResourceEx | Adds the font resource from the specified file to the system font table
_WinAPI_AddIconOverlay | Creates an icon by merging the source icon and overlay mask
_WinAPI_AddIconTransparency | Adds a transparency to the specified 32 bits-per-pixel icon
_WinAPI_AddMRUString | Adds a string to the top of the most recently used (MRU) list
_WinAPI_AdjustBitmap | Creates a new device-depended bitmap (DDB) from the source bitmap with new dimensions and color adjustment
_WinAPI_AdjustTokenPrivileges | Enables or disables privileges in the specified access token
_WinAPI_AdjustWindowRectEx | Calculates the required size of the window rectangle, based on the desired size of the client rectangle
_WinAPI_AlphaBlend | Displays bitmaps that have transparent or semitransparent pixels
_WinAPI_AngleArc | Draws a line segment and an arc
_WinAPI_AnimateWindow | Enables you to produce special effects when showing or hiding windows
_WinAPI_Arc | Draws an elliptical arc
_WinAPI_ArcTo | Draws an elliptical arc
_WinAPI_ArrayToStruct | Converts an array of strings to the structure
_WinAPI_AssignProcessToJobObject | Assigns a process to an existing job object
_WinAPI_AssocGetPerceivedType | Retrieves a file's perceived type based on its extension
_WinAPI_AssocQueryString | Searches for and retrieves a file or protocol association-related string from the registry
_WinAPI_AttachConsole | Attaches the calling process to the console of the specified process
_WinAPI_AttachThreadInput | Attaches the input processing mechanism of one thread to that of another thread
_WinAPI_BackupRead | Backs up a file or directory, including the security information
_WinAPI_BackupReadAbort | Finishes the use of _WinAPI_BackupRead() on the handle
_WinAPI_BackupSeek | Seeks forward in a data stream initially accessed by using the _WinAPI_BackupRead() or _WinAPI_BackupWrite() function
_WinAPI_BackupWrite | Restore a file or directory that was backed up using _WinAPI_BackupRead()
_WinAPI_BackupWriteAbort | Finishes the use of _WinAPI_BackupWrite() on the handle
_WinAPI_Beep | Generates simple tones on the speaker
_WinAPI_BeginBufferedPaint | Begins a buffered paint operation
_WinAPI_BeginDeferWindowPos | Allocates memory for a multiple-window-position structure
_WinAPI_BeginPaint | Prepares the specified window for painting
_WinAPI_BeginPath | Opens a path bracket in the specified device context
_WinAPI_BeginUpdateResource | Retrieves a handle that can be used to add, delete, or replace resources in a binary module
_WinAPI_BitBlt | Performs a bit-block transfer of color data
_WinAPI_BringWindowToTop | Brings the specified window to the top of the Z order
_WinAPI_BroadcastSystemMessage | Sends a message to the specified recipients
_WinAPI_BrowseForFolderDlg | Displays a dialog box that enables the user to select a Shell folder
_WinAPI_BufferedPaintClear | Clears a specified rectangle in the buffer to ARGB = {0,0,0,0}
_WinAPI_BufferedPaintInit | Initialize buffered painting for the current thread
_WinAPI_BufferedPaintSetAlpha | Sets the alpha to a specified value in a given rectangle
_WinAPI_BufferedPaintUnInit | Closes down buffered painting for the current thread
_WinAPI_CallNextHookEx | Passes the hook information to the next hook procedure in the current hook chain
_WinAPI_CallWindowProc | Passes the hook information to the next hook procedure in the current hook chain
_WinAPI_CallWindowProcW | Passes message information to the specified window procedure
_WinAPI_CascadeWindows | Cascades the specified child windows of the specified parent window
_WinAPI_ChangeWindowMessageFilterEx | Modifies the User Interface Privilege Isolation (UIPI) message filter for a specified window
_WinAPI_CharToOem | Converts a string into the OEM-defined character set
_WinAPI_ChildWindowFromPointEx | Determines which, if any, of the child windows belonging to the specified parent window contains the specified point
_WinAPI_ClientToScreen | Converts the client coordinates of a specified point to screen coordinates
_WinAPI_ClipCursor | Confines the cursor to a rectangular area on the screen
_WinAPI_CloseDesktop | Closes an open handle to a desktop object
_WinAPI_CloseEnhMetaFile | Closes an enhanced-metafile device context and returns a handle that identifies an enhanced-format metafile
_WinAPI_CloseFigure | Closes an open figure in a path
_WinAPI_CloseHandle | Closes an open object handle
_WinAPI_CloseThemeData | Closes the theme data handle
_WinAPI_CloseWindow | Minimizes (but does not destroy) the specified window
_WinAPI_CloseWindowStation | Closes an open window station handle
_WinAPI_CLSIDFromProgID | Looks up a CLSID in the registry, given a ProgID
_WinAPI_CoInitialize | Initializes the COM library for use by the calling process
_WinAPI_ColorAdjustLuma | Changes the luminance of a RGB value
_WinAPI_ColorHLSToRGB | Converts colors from hue-luminance-saturation (HLS) to RGB format
_WinAPI_ColorRGBToHLS | Converts colors from RGB to hue-luminance-saturation (HLS) format
_WinAPI_CombineRgn | Combines two regions and stores the result in a third region
_WinAPI_CombineTransform | Concatenates two world-space to page-space transformations
_WinAPI_CommandLineToArgv | Parses a command-line string and returns an array of the command-line arguments
_WinAPI_CommDlgExtendedError | Returns a common dialog box error string. This string indicates the most recent error to occur during the execution of one of the common dialog box functions
_WinAPI_CommDlgExtendedErrorEx | Returns a common dialog box error code
_WinAPI_CompareString | Compares two character strings for a specified locale
_WinAPI_CompressBitmapBits | Creates a compressed data block from the specified bitmap
_WinAPI_CompressBuffer | Compresses a buffer with specified compression format and engine type
_WinAPI_ComputeCrc32 | Calculates the CRC32 checksum of a block of memory
_WinAPI_ConfirmCredentials | Confirms the validity of the credential harvested
_WinAPI_CopyBitmap | Creates a duplicate of a specified bitmap with a device-independent bitmap (DIB) section
_WinAPI_CopyCursor | Creates a duplicate of a specified cursor
_WinAPI_CopyEnhMetaFile | Copies the contents of an enhanced-format metafile to a specified file
_WinAPI_CopyFileEx | Copies an existing file to a new file, notifying the application of its progress through a callback function
_WinAPI_CopyIcon | Copies the specified icon from another module
_WinAPI_CopyImage | Creates a new image (icon, cursor, or bitmap) and copies the attributes of the specified image to the new one
_WinAPI_CopyRect | Copies the coordinates of one rectangle to another
_WinAPI_CopyStruct | Creates a duplicate of a specified structure
_WinAPI_CoTaskMemAlloc | Allocates a block of task memory
_WinAPI_CoTaskMemFree | Frees a block of task memory
_WinAPI_CoTaskMemRealloc | Changes the size of a previously allocated block of task memory
_WinAPI_CoUninitialize | Closes the COM library on the current process
_WinAPI_Create32BitHBITMAP | Creates a 32 bits-per-pixel bitmap from the specified icon
_WinAPI_Create32BitHICON | Converts an icon to a 32 bits-per-pixel format and copies to the new icon
_WinAPI_CreateANDBitmap | Creates AND bitmask device-independent bitmap (DIB) from the specified bitmap
_WinAPI_CreateBitmap | Creates a bitmap with the specified width, height, and color format
_WinAPI_CreateBitmapIndirect | Creates a bitmap with the specified width, height, and color format (color planes and bits-per-pixel)
_WinAPI_CreateBrushIndirect | Creates a logical brush that has the specified style, color, and pattern
_WinAPI_CreateBuffer | Allocates a block of memory from the internal library heap
_WinAPI_CreateBufferFromStruct | Allocates a block of memory from the internal library heap and initializes it with the structure's data
_WinAPI_CreateCaret | Creates a new shape for the system caret and assigns ownership of the caret to the specified window
_WinAPI_CreateColorAdjustment | Creates $tagCOLORADJUSTMENT structure specifies the color adjustment
_WinAPI_CreateCompatibleBitmap | Creates a bitmap compatible with the specified device context
_WinAPI_CreateCompatibleBitmapEx | Creates a bitmap compatible with the device and fills it the specified color
_WinAPI_CreateCompatibleDC | Creates a memory device context compatible with the specified device
_WinAPI_CreateDesktop | Creates a new desktop, associates it with the current window station of the calling process
_WinAPI_CreateDIB | Creates an uncompressed device-independent bitmap (DIB) with the specified width, height, and color depth
_WinAPI_CreateDIBColorTable | Creates RGB color table from the specified array of colors
_WinAPI_CreateDIBitmap | Creates a compatible bitmap (DDB) from a DIB and, optionally, sets the bitmap bits
_WinAPI_CreateDIBSection | Creates a DIB that applications can write to directly
_WinAPI_CreateDirectory | Creates a new directory
_WinAPI_CreateDirectoryEx | Creates a new directory with the attributes of a specified template directory
_WinAPI_CreateEllipticRgn | Creates an elliptical region
_WinAPI_CreateEmptyIcon | Creates a fully transparent icon with the specified width, height, and color depth
_WinAPI_CreateEnhMetaFile | Creates a device context for an enhanced-format metafile
_WinAPI_CreateEvent | Creates or opens a named or unnamed event object
_WinAPI_CreateFile | Creates or opens a file or other device
_WinAPI_CreateFileEx | Creates or opens a file or I/O device
_WinAPI_CreateFileMapping | Creates or opens a named or unnamed file mapping object for a specified file
_WinAPI_CreateFont | Creates a logical font with the specified characteristics
_WinAPI_CreateFontEx | Creates a logical font with the specified characteristics
_WinAPI_CreateFontIndirect | Creates a logical font that has specific characteristics
_WinAPI_CreateGUID | Creates a globally unique identifier (GUID)
_WinAPI_CreateHardLink | Establishes a hard link between an existing file and a new file
_WinAPI_CreateIcon | Creates an icon that has the specified size, colors, and bit patterns
_WinAPI_CreateIconFromResourceEx | Creates an icon or cursor from resource bits describing the icon
_WinAPI_CreateIconIndirect | Creates an icon or cursor that has the specified size, colors, and bit patterns
_WinAPI_CreateJobObject | Creates or opens a job object
_WinAPI_CreateMargins | Creates $tagMARGINS structure with specified left, right, top, and bottom retaining borders
_WinAPI_CreateMRUList | Creates a new most recently used (MRU) list
_WinAPI_CreateMutex | Creates or opens a named or unnamed mutex object
_WinAPI_CreateNullRgn | Creates an empty region
_WinAPI_CreateNumberFormatInfo | Creates a $tagNUMBERFMT structure with the specified number formatting information
_WinAPI_CreateObjectID | Creates or retrieves the object identifier for the specified file or directory
_WinAPI_CreatePen | Creates a logical pen that has the specified style, width, and color
_WinAPI_CreatePoint | Creates $tagPOINT structure with the x- and y-coordinates of the specified point
_WinAPI_CreatePolygonRgn | Creates a polygonal region
_WinAPI_CreateProcess | Creates a new process and its primary thread
_WinAPI_CreateProcessWithToken | Creates a new process and its primary thread in the security context of the specified token
_WinAPI_CreateRect | Creates $tagRECT structure with the coordinates of the specified rectangle
_WinAPI_CreateRectEx | Creates $tagRECT structure with the coordinates of the specified rectangle
_WinAPI_CreateRectRgn | Creates a rectangular region
_WinAPI_CreateRectRgnIndirect | Creates a rectangular region
_WinAPI_CreateRoundRectRgn | Creates a rectangular region with rounded corners
_WinAPI_CreateSemaphore | Creates or opens a named or unnamed semaphore object
_WinAPI_CreateSize | Creates $tagSIZE structure with the width and height of the specified rectangle
_WinAPI_CreateSolidBitmap | Creates a solid color bitmap
_WinAPI_CreateSolidBrush | Creates a logical brush that has the specified solid color
_WinAPI_CreateStreamOnHGlobal | Creates a stream object that uses a memory handle to store the stream contents
_WinAPI_CreateString | Copies a specified string to the newly allocated memory block and returns its pointer
_WinAPI_CreateSymbolicLink | Creates a symbolic link
_WinAPI_CreateTransform | Creates $tagXFORM structure specifies a world-space to page-space transformation
_WinAPI_CreateWindowEx | Creates an overlapped, pop-up, or child window
_WinAPI_CreateWindowStation | Creates a window station object, associates it with the calling process, and assigns it to the current session
_WinAPI_DecompressBuffer | Decompresses an entire compressed buffer
_WinAPI_DecryptFile | Decrypts an encrypted file or directory
_WinAPI_DeferWindowPos | Updates the specified multiple-window-position structure for the specified window
_WinAPI_DefineDosDevice | Defines, redefines, or deletes MS-DOS device names
_WinAPI_DefRawInputProc | Calls the default raw input procedure to process the raw input messages that an application does not process
_WinAPI_DefSubclassProc | Calls the next handler in a window's subclass chain
_WinAPI_DefWindowProc | Call the default window procedure to provide default processing
_WinAPI_DefWindowProcW | Calls the default window procedure to provide default processing for any window messages
_WinAPI_DeleteDC | Deletes the specified device context
_WinAPI_DeleteEnhMetaFile | Deletes an enhanced-format metafile or an enhanced-format metafile handle
_WinAPI_DeleteFile | Deletes an existing file
_WinAPI_DeleteObject | Deletes a logical pen, brush, font, bitmap, region, or palette
_WinAPI_DeleteObjectID | Removes the object identifier from a specified file or directory
_WinAPI_DeleteVolumeMountPoint | Deletes a drive letter or mounted folder
_WinAPI_DeregisterShellHookWindow | Unregisters a specified Shell window that is registered to receive Shell hook messages
_WinAPI_DestroyCaret | Destroys the caret's current shape, frees the caret from the window, and removes the caret from the screen
_WinAPI_DestroyCursor | Destroys a cursor and frees any memory the cursor occupied
_WinAPI_DestroyIcon | Destroys an icon and frees any memory the icon occupied
_WinAPI_DestroyWindow | Destroys the specified window
_WinAPI_DeviceIoControl | Sends a control code directly to a specified device driver
_WinAPI_DisplayStruct | Displays data from the specified structure or memory address as a list
_WinAPI_DllGetVersion | Retrieves a DLL-specific version information
_WinAPI_DllInstall | Registers OLE controls such as DLL or ActiveX Controls (OCX) files
_WinAPI_DllUninstall | Unregisters OLE controls such as DLL or ActiveX Controls (OCX) files
_WinAPI_DPtoLP | Converts device coordinates into logical coordinates
_WinAPI_DragAcceptFiles | Registers whether a window accepts dropped files
_WinAPI_DragFinish | Releases memory that the system allocated for use in transferring file names to the application
_WinAPI_DragQueryFileEx | Retrieves the names of dropped files that result from a successful drag-and-drop operation
_WinAPI_DragQueryPoint | Retrieves the position of the mouse pointer at the time a file was dropped during a drag-and-drop operation
_WinAPI_DrawAnimatedRects | Animates the caption of a window to indicate the opening of an icon or the minimizing or maximizing of a window
_WinAPI_DrawBitmap | Draws a bitmap into the specified device context
_WinAPI_DrawEdge | Draws one or more edges of rectangle
_WinAPI_DrawFocusRect | Draws a rectangle in the style used to indicate that the rectangle has the focus
_WinAPI_DrawFrameControl | Draws a frame control of the specified type and style
_WinAPI_DrawIcon | Draws an icon or cursor into the specified device context
_WinAPI_DrawIconEx | Draws an icon or cursor into the specified device context
_WinAPI_DrawLine | Draws a line
_WinAPI_DrawShadowText | Draws formatted text in the specified rectangle with a drop shadow
_WinAPI_DrawText | Draws formatted text in the specified rectangle
_WinAPI_DrawThemeBackground | Draws the border and fill defined by the visual style for the specified control part
_WinAPI_DrawThemeEdge | Draws one or more edges defined by the visual style of a rectangle
_WinAPI_DrawThemeIcon | Draws an image from an image list with the icon effect defined by the visual style
_WinAPI_DrawThemeParentBackground | Draws the part of a parent control that is covered by a partially-transparent or alpha-blended child control
_WinAPI_DrawThemeText | Draws text using the color and font defined by the visual style
_WinAPI_DrawThemeTextEx | Draws text using the color and font defined by the visual style
_WinAPI_DuplicateEncryptionInfoFile | Copies the EFS metadata from one file or directory to another
_WinAPI_DuplicateHandle | Duplicates an object handle
_WinAPI_DuplicateTokenEx | Creates a new primary or impersonation access token that duplicates an existing token
_WinAPI_DwmDefWindowProc | Default window procedure for Desktop Window Manager (DWM) hit testing within the non-client area
_WinAPI_DwmEnableBlurBehindWindow | Enables the blur effect on a specified window
_WinAPI_DwmEnableComposition | Enables or disables Desktop Window Manager (DWM) composition
_WinAPI_DwmExtendFrameIntoClientArea | Extends the window frame behind the client area
_WinAPI_DwmGetColorizationColor | Retrieves the current color used for Desktop Window Manager (DWM) glass composition
_WinAPI_DwmGetColorizationParameters | Retrieves the colorization parameters used for Desktop Window Manager (DWM)
_WinAPI_DwmGetWindowAttribute | Retrieves the current value of a specified attribute applied to the window
_WinAPI_DwmInvalidateIconicBitmaps | Indicates that all previously provided iconic bitmaps from a window, both thumbnails and peek representations, should be refreshed
_WinAPI_DwmIsCompositionEnabled | Determines whether Desktop Window Manager (DWM) composition is enabled
_WinAPI_DwmQueryThumbnailSourceSize | Returns the source size of the Desktop Window Manager (DWM) thumbnail
_WinAPI_DwmRegisterThumbnail | Creates a Desktop Window Manager (DWM) thumbnail relationship between the destination and source windows
_WinAPI_DwmSetColorizationParameters | Sets the colorization parameters for Desktop Window Manager (DWM)
_WinAPI_DwmSetIconicLivePreviewBitmap | Sets a static, iconic bitmap to display a live preview (also known as a Peek preview) of a window or tab
_WinAPI_DwmSetIconicThumbnail | Sets a static, iconic bitmap on a window or tab to use as a thumbnail representation
_WinAPI_DwmSetWindowAttribute | Sets the value of the specified attributes for non-client rendering to apply to the window
_WinAPI_DwmUnregisterThumbnail | Removes a Desktop Window Manager (DWM) thumbnail relationship
_WinAPI_DwmUpdateThumbnailProperties | Specifies Desktop Window Manager (DWM) thumbnail properties
_WinAPI_DWordToFloat | Converts a value of type DWORD to a value of type FLOAT
_WinAPI_DWordToInt | Converts a value of type DWORD to a value of type INT
_WinAPI_EjectMedia | Ejects media from a device
_WinAPI_Ellipse | Draws an ellipse
_WinAPI_EmptyWorkingSet | Removes as many pages as possible from the working set of the specified process
_WinAPI_EnableWindow | Enables or disables mouse and keyboard input to the specified window or control
_WinAPI_EncryptFile | Encrypts a file or directory
_WinAPI_EncryptionDisable | Disables or enables encryption of the specified directory and the files in it
_WinAPI_EndBufferedPaint | Completes a buffered paint operation and frees the associated buffered paint handle
_WinAPI_EndDeferWindowPos | Simultaneously updates the position and size of one or more windows in a single screen-refreshing cycle
_WinAPI_EndPaint | Marks the end of painting in the specified window
_WinAPI_EndPath | Closes a path bracket and selects the path defined by the bracket into the specified device context
_WinAPI_EndUpdateResource | Commits or discards a changes of the resources within module
_WinAPI_EnumChildProcess | Enumerates a child processes that belong to the specified process
_WinAPI_EnumChildWindows | Enumerates a child windows that belong to the specified parent window
_WinAPI_EnumDesktops | Enumerates all desktops associated with the specified window station of the calling process
_WinAPI_EnumDesktopWindows | Enumerates all top-level windows associated with the specified desktop
_WinAPI_EnumDeviceDrivers | Retrieves the load address for each device driver in the system
_WinAPI_EnumDisplayDevices | Obtains information about the display devices in a system
_WinAPI_EnumDisplayMonitors | Enumerates display monitors (including invisible pseudo-monitors associated with the mirroring drivers)
_WinAPI_EnumDisplaySettings | Retrieves information about one of the graphics modes for a display device
_WinAPI_EnumDllProc | Enumerates an exported functions of the specified dynamic-link library (DLL)
_WinAPI_EnumFiles | Enumerates the files and subdirectories for the specified directory with a name that matches the template
_WinAPI_EnumFileStreams | Enumerates all streams with a ::$DATA stream type in the specified file or directory
_WinAPI_EnumFontFamilies | Enumerates all uniquely-named fonts in the system that match the specified font characteristics
_WinAPI_EnumHardLinks | Enumerates all the hard links to the specified file
_WinAPI_EnumMRUList | Enumerates the contents of the most recently used (MRU) list
_WinAPI_EnumPageFiles | Retrieves information for each installed pagefile in the system
_WinAPI_EnumProcessHandles | Enumerates a handles that belong to the specified process
_WinAPI_EnumProcessModules | Retrieves a handle and name for each module in the specified process
_WinAPI_EnumProcessThreads | Enumerates a threads that belong to the specified process
_WinAPI_EnumProcessWindows | Enumerates a windows that belong to the specified process
_WinAPI_EnumRawInputDevices | Enumerates the raw input devices attached to the system
_WinAPI_EnumResourceLanguages | Enumerates a language-specific resources, of the specified type and name, associated with a binary module
_WinAPI_EnumResourceNames | Enumerates the resources of a specified type within a binary module
_WinAPI_EnumResourceTypes | Enumerates the resource types within a binary module
_WinAPI_EnumSystemGeoID | Enumerates the geographical location identifiers (GEOID) that are available on the operating system
_WinAPI_EnumSystemLocales | Enumerates the locales that are either installed on or supported by an operating system
_WinAPI_EnumUILanguages | Enumerates the user interface languages that are available on the operating system
_WinAPI_EnumWindows | Enumerates all windows
_WinAPI_EnumWindowsPopup | Enumerates popup windows
_WinAPI_EnumWindowStations | Enumerates all window stations in the current session
_WinAPI_EnumWindowsTop | Enumerates all top level windows
_WinAPI_EqualMemory | Compares two blocks of memory to determine whether the specified number of bytes are identical
_WinAPI_EqualRect | Determines whether the two specified rectangles are equal
_WinAPI_EqualRgn | Checks the two specified regions to determine whether they are identical
_WinAPI_ExcludeClipRect | Creates a new clipping region that consists of the existing clipping region minus the specified rectangle
_WinAPI_ExpandEnvironmentStrings | Expands environment variable strings and replaces them with their defined values
_WinAPI_ExtCreatePen | Creates a logical cosmetic or geometric pen that has the specified style, width, and brush attributes
_WinAPI_ExtCreateRegion | Creates a region from the specified region and transformation data
_WinAPI_ExtFloodFill | Fills an area of the display surface with the current brush
_WinAPI_ExtractIcon | Extracts an icon from the specified executable file, DLL, or icon file
_WinAPI_ExtractIconEx | Creates an array of handles to large or small icons extracted from a file
_WinAPI_ExtSelectClipRgn | Combines the specified region with the current clipping region
_WinAPI_FatalAppExit | Displays a message box and terminates the application
_WinAPI_FatalExit | Transfers execution control to the debugger
_WinAPI_FileEncryptionStatus | Retrieves the encryption status of the specified file
_WinAPI_FileExists | Tests whether the specified path is existing file
_WinAPI_FileIconInit | Initializes or reinitializes the system image list
_WinAPI_FileInUse | Tests whether the specified file in use by another application
_WinAPI_FillMemory | Fills a block of memory with the given value
_WinAPI_FillPath | Closes any open figures in the current path and fills the path's interior by using the current brush
_WinAPI_FillRect | Fills a rectangle by using the specified brush
_WinAPI_FillRgn | Fills a region by using the specified brush
_WinAPI_FindClose | Closes a file search handle
_WinAPI_FindCloseChangeNotification | Stops change notification handle monitoring
_WinAPI_FindExecutable | Retrieves the name of the executable file associated with the specified file name
_WinAPI_FindFirstChangeNotification | Creates a change notification handle and sets up initial change notification filter conditions
_WinAPI_FindFirstFile | Searches a directory for a file or subdirectory with a name that matches a specific name
_WinAPI_FindFirstFileName | Creates an enumeration of all the hard links to the specified file
_WinAPI_FindFirstStream | Enumerates the first stream with a ::$DATA stream type in the specified file or directory
_WinAPI_FindNextChangeNotification | Requests that the operating system signal a change notification handle the next time it detects an appropriate change
_WinAPI_FindNextFile | Continues a file or directory search
_WinAPI_FindNextFileName | Continues enumerating the hard links
_WinAPI_FindNextStream | Continues a stream search
_WinAPI_FindResource | Determines the location of a resource with the specified type and name in the specified module
_WinAPI_FindResourceEx | Determines the location of the resource with the specified type, name, and language in the specified module
_WinAPI_FindTextDlg | Creates a system-defined modeless Find dialog box to search for text in a document
_WinAPI_FindWindow | Retrieves the handle to the top-level window whose class name and window name match
_WinAPI_FlashWindow | Flashes the specified window one time
_WinAPI_FlashWindowEx | Flashes the specified window
_WinAPI_FlattenPath | Transforms any curves in the path that is selected into the current DC, turning each curve into a sequence of lines
_WinAPI_FloatToDWord | Converts a value of type FLOAT to a value of type DWORD
_WinAPI_FloatToInt | Returns a 4 byte float as an integer value
_WinAPI_FlushFileBuffers | Flushes the buffers of a specified file and causes all buffered data to be written
_WinAPI_FlushFRBuffer | Destroys the internal buffer that used the _WinAPI_FindTextDlg() and _WinAPI_ReplaceTextDlg() functions
_WinAPI_FlushViewOfFile | Writes to the disk a byte range within a mapped view of a file
_WinAPI_FormatDriveDlg | Opens the Shell's Format dialog
_WinAPI_FormatMessage | Formats a message string
_WinAPI_FrameRect | Draws a border around the specified rectangle by using the specified brush
_WinAPI_FrameRgn | Draws a border around the specified region by using the specified brush
_WinAPI_FreeLibrary | Decrements the reference count of the loaded dynamic-link library (DLL) module
_WinAPI_FreeMemory | Frees a memory block in the internal library heap
_WinAPI_FreeMRUList | Frees the handle associated with the most recently used (MRU) list and writes cached data to the registry
_WinAPI_FreeResource | Decrements (decreases by one) the reference count of a loaded resource
_WinAPI_GdiComment | Copies a comment from a buffer into a specified enhanced-format metafile
_WinAPI_GetActiveWindow | Retrieves the window handle to the active window attached to the calling process's message queue
_WinAPI_GetAllUsersProfileDirectory | Retrieves the path to the root of the directory that contains program data shared by all users
_WinAPI_GetAncestor | Retrieves the handle to the ancestor of the specified window
_WinAPI_GetApplicationRestartSettings | Retrieves the restart information registered for the specified process
_WinAPI_GetArcDirection | Retrieves the current arc direction for the specified device context
_WinAPI_GetAsyncKeyState | Determines whether a key is up or down at the time the function is called
_WinAPI_GetBinaryType | Determines whether a file is an executable (.exe) file, and if so, which subsystem runs the executable file
_WinAPI_GetBitmapBits | Copies the bitmap bits of a specified device-dependent bitmap into a buffer
_WinAPI_GetBitmapDimension | Retrieves a dimension of the specified bitmap
_WinAPI_GetBitmapDimensionEx | Retrieves the dimensions of a compatible bitmap
_WinAPI_GetBkColor | Retrieves the current background color for the specified device context
_WinAPI_GetBkMode | Returns the current background mix mode for a specified device context
_WinAPI_GetBoundsRect | Obtains the current accumulated bounding rectangle for a specified device context
_WinAPI_GetBrushOrg | Retrieves the current brush origin for the specified device context
_WinAPI_GetBufferedPaintBits | Retrieves a pointer to the buffer bitmap if the buffer is a device-independent bitmap (DIB)
_WinAPI_GetBufferedPaintDC | Gets the paint device context (DC)
_WinAPI_GetBufferedPaintTargetDC | Retrieves the target device context (DC)
_WinAPI_GetBufferedPaintTargetRect | Retrieves the target rectangle
_WinAPI_GetBValue | Retrieves an intensity value for the blue component of a 32-bit RGB value
_WinAPI_GetCaretBlinkTime | Returns the time required to invert the caret's pixels
_WinAPI_GetCaretPos | Retrieves the caret's position
_WinAPI_GetCDType | Retrieves a type of the media which is loaded into a specified CD-ROM device
_WinAPI_GetClassInfoEx | Retrieves information about a window class
_WinAPI_GetClassLongEx | Retrieves the specified value associated with the specified window
_WinAPI_GetClassName | Retrieves the name of the class to which the specified window belongs
_WinAPI_GetClientHeight | Retrieves the height of a window's client area
_WinAPI_GetClientRect | Retrieves the coordinates of a window's client area
_WinAPI_GetClientWidth | Retrieves the width of a window's client area
_WinAPI_GetClipboardSequenceNumber | Retrieves the clipboard sequence number for the current window station
_WinAPI_GetClipBox | Retrieves the dimensions of the bounding rectangle of the visible area
_WinAPI_GetClipCursor | Retrieves the screen coordinates of the rectangular area to which the cursor is confined
_WinAPI_GetClipRgn | Retrieves a handle identifying the current application-defined clipping region
_WinAPI_GetColorAdjustment | Retrieves the color adjustment for the specified device context (DC)
_WinAPI_GetCompressedFileSize | Retrieves the actual number of bytes of disk storage used to store a specified file
_WinAPI_GetCompression | Retrieves the current compression state of a file or directory
_WinAPI_GetConnectedDlg | Launches the Get Connected wizard within the calling application to enable network connectivity
_WinAPI_GetCurrentDirectory | Retrieves the current directory for the current process
_WinAPI_GetCurrentHwProfile | Retrieves information about the current hardware profile for the local computer
_WinAPI_GetCurrentObject | Retrieves a handle to an object of the specified type that has been selected into the specified device context
_WinAPI_GetCurrentPosition | Retrieves the current position for the specified device context
_WinAPI_GetCurrentProcess | Returns the process handle of the calling process
_WinAPI_GetCurrentProcessExplicitAppUserModelID | Retrieves the application-defined, explicit Application User Model ID for the current process
_WinAPI_GetCurrentProcessID | Returns the process identifier of the calling process
_WinAPI_GetCurrentThemeName | Retrieves the name of the current visual styles, color scheme name, and size name
_WinAPI_GetCurrentThread | Retrieves a pseudo handle for the calling thread
_WinAPI_GetCurrentThreadId | Returns the thread identifier of the calling thread
_WinAPI_GetCursor | Retrieves a handle to the current cursor
_WinAPI_GetCursorInfo | Retrieves information about the global cursor
_WinAPI_GetDateFormat | Formats a date as a date string for a locale specified by the locale identifier
_WinAPI_GetDC | Retrieves a handle of a display device context for the client area a window
_WinAPI_GetDCEx | Retrieves a handle to a device context (DC) for the client area of a specified window
_WinAPI_GetDefaultPrinter | Retrieves the printer name of the default printer for the current user on the local computer
_WinAPI_GetDefaultUserProfileDirectory | Retrieves the path to the root of the default user's profile
_WinAPI_GetDesktopWindow | Returns the handle of the Windows desktop window
_WinAPI_GetDeviceCaps | Retrieves device specific information about a specified device
_WinAPI_GetDeviceDriverBaseName | Retrieves the base name of the specified device driver
_WinAPI_GetDeviceDriverFileName | Retrieves the path available for the specified device driver
_WinAPI_GetDeviceGammaRamp | Gets the gamma ramp on direct color display boards that support downloadable gamma ramps in hardware
_WinAPI_GetDIBColorTable | Retrieves RGB color table from the DIB section bitmap
_WinAPI_GetDIBits | Retrieves the bits of the specified bitmap and copies them into a buffer as a DIB
_WinAPI_GetDiskFreeSpaceEx | Retrieves information about the amount of space that is available on a disk volume
_WinAPI_GetDlgCtrlID | Returns the identifier of the specified control
_WinAPI_GetDlgItem | Retrieves the handle of a control in the specified dialog box
_WinAPI_GetDllDirectory | Retrieves the application-specific portion of the search path used to locate DLLs for the application
_WinAPI_GetDriveBusType | Retrieves a bus type for the specified drive
_WinAPI_GetDriveGeometryEx | Retrieves extended information about the disk's geometry
_WinAPI_GetDriveNumber | Retrieves a device type, device number, and partition number for the specified drive
_WinAPI_GetDriveType | Determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive
_WinAPI_GetDurationFormat | Formats a duration of time as a time string for a locale specified by identifier
_WinAPI_GetEffectiveClientRect | Calculates the dimensions of a rectangle in the client area that contains all the specified controls
_WinAPI_GetEnhMetaFile | Creates a handle that identifies the enhanced-format metafile stored in the specified file
_WinAPI_GetEnhMetaFileBits | Retrieves the contents of the specified enhanced-format metafile
_WinAPI_GetEnhMetaFileDescription | Retrieves an optional text description from an enhanced-format metafile
_WinAPI_GetEnhMetaFileDimension | Retrieves a dimension of the specified enhanced-format metafile
_WinAPI_GetEnhMetaFileHeader | Retrieves the record containing the header for the specified enhanced-format metafile
_WinAPI_GetErrorMessage | Retrieves a text error message for the specified system error code
_WinAPI_GetErrorMode | Retrieves the error mode for the current process
_WinAPI_GetExitCodeProcess | Retrieves the termination status of the specified process
_WinAPI_GetExtended | Retrieves the last extended function return value
_WinAPI_GetFileAttributes | Retrieves file system attributes for a specified file or directory
_WinAPI_GetFileID | Retrieves the file system's 8-byte file reference number for a file
_WinAPI_GetFileInformationByHandle | Retrieves file information for the specified file
_WinAPI_GetFileInformationByHandleEx | Retrieves file information for the specified file
_WinAPI_GetFilePointerEx | Retrieves the file pointer of the specified file
_WinAPI_GetFileSizeEx | Retrieves the size of the specified file
_WinAPI_GetFileSizeOnDisk | Retrieves the file allocation size on disk
_WinAPI_GetFileTitle | Retrieves the name of the specified file
_WinAPI_GetFileType | Retrieves the file type of the specified file
_WinAPI_GetFileVersionInfo | Retrieves version information for the specified file
_WinAPI_GetFinalPathNameByHandle | Retrieves the final path of the specified file
_WinAPI_GetFinalPathNameByHandleEx | Retrieves the final path of the specified file
_WinAPI_GetFocus | Retrieves the handle of the window that has the keyboard focus
_WinAPI_GetFontMemoryResourceInfo | Reads out font information from a TTF loaded into the memory
_WinAPI_GetFontName | Retrieves the unique name of the font based on its typeface name, character set, and style
_WinAPI_GetFontResourceInfo | Retrieves the fontname from the specified font resource file
_WinAPI_GetForegroundWindow | Returns the handle of the foreground window
_WinAPI_GetFRBuffer | Retrieves the current size of the internal buffer that used the _WinAPI_FindTextDlg() and _WinAPI_ReplaceTextDlg() functions
_WinAPI_GetFullPathName | Retrieves the full path and file name of the specified file
_WinAPI_GetGeoInfo | Retrieves information about a specified geographical location
_WinAPI_GetGlyphOutline | Retrieves the outline or bitmap for a character in the TrueType font
_WinAPI_GetGraphicsMode | Retrieves the current graphics mode for the specified device context
_WinAPI_GetGuiResources | Retrieves the count of handles to graphical user interface (GUI) objects in use by the specified process
_WinAPI_GetGUIThreadInfo | Retrieves information about the active window or a specified GUI thread
_WinAPI_GetGValue | Retrieves an intensity value for the green component of a 32-bit RGB value
_WinAPI_GetHandleInformation | Retrieves certain properties of an object handle
_WinAPI_GetHGlobalFromStream | Retrieves the global memory handle to a stream
_WinAPI_GetIconDimension | Retrieves a dimension of the specified icon
_WinAPI_GetIconInfo | Retrieves information about the specified icon or cursor
_WinAPI_GetIconInfoEx | Retrieves information about the specified icon or cursor
_WinAPI_GetIdleTime | Retrieves the time that has elapsed since the last input
_WinAPI_GetKeyboardLayout | Retrieves the active input locale identifier for the specified window
_WinAPI_GetKeyboardLayoutList | Retrieves the all input locale identifiers corresponding to the current set of input locales in the system
_WinAPI_GetKeyboardState | Copies the status of the 256 virtual keys to the specified buffer
_WinAPI_GetKeyboardType | Retrieves information about the current keyboard
_WinAPI_GetKeyNameText | Retrieves a string that represents the name of a key
_WinAPI_GetKeyState | Retrieves the status of the specified virtual key
_WinAPI_GetLastActivePopup | Determines which pop-up window owned by the specified window was most recently active
_WinAPI_GetLastError | Returns the calling thread's lasterror code value
_WinAPI_GetLastErrorMessage | Returns the calling threads last error message
_WinAPI_GetLayeredWindowAttributes | Gets Layered Window Attributes
_WinAPI_GetLocaleInfo | Retrieves information about a locale specified by identifier
_WinAPI_GetLogicalDrives | Retrieves a bitmask representing the currently available disk drives
_WinAPI_GetMapMode | Retrieves the current mapping mode
_WinAPI_GetMemorySize | Retrieves the size of a memory block allocated from the internal library heap
_WinAPI_GetMessageExtraInfo | Retrieves the extra message information for the current thread
_WinAPI_GetModuleFileNameEx | Retrieves the fully-qualified path for the file containing the specified module
_WinAPI_GetModuleHandle | Returns a module handle for the specified module
_WinAPI_GetModuleHandleEx | Retrieves a module handle for the specified module
_WinAPI_GetModuleInformation | Retrieves information about the specified module
_WinAPI_GetMonitorInfo | Retrieves information about a display monitor
_WinAPI_GetMousePos | Returns the current mouse position
_WinAPI_GetMousePosX | Returns the current mouse X position
_WinAPI_GetMousePosY | Returns the current mouse Y position
_WinAPI_GetMUILanguage | Gets the language currently in use by the common controls for a particular process
_WinAPI_GetNumberFormat | Formats a number string as a number string customized for a locale specified by identifier
_WinAPI_GetObject | Retrieves information for the specified graphics object
_WinAPI_GetObjectID | Retrieves the object identifier for the specified file or directory
_WinAPI_GetObjectInfoByHandle | Retrieves information about a specified object
_WinAPI_GetObjectNameByHandle | Retrieves a name of the specified object
_WinAPI_GetObjectType | Retrieves the type of the specified object
_WinAPI_GetOpenFileName | Creates an Open dialog box that lets the user specify the drive, directory, and the name of a file or set of files to open
_WinAPI_GetOutlineTextMetrics | Retrieves text metrics for TrueType fonts
_WinAPI_GetOverlappedResult | Retrieves the results of an overlapped operation
_WinAPI_GetParent | Retrieves the handle of the specified child window's parent window
_WinAPI_GetParentProcess | Retrieves the PID of the parent process for the specified process
_WinAPI_GetPerformanceInfo | Retrieves the performance information
_WinAPI_GetPEType | Retrieves a type of the machine for the specified portable executable (PE)
_WinAPI_GetPhysicallyInstalledSystemMemory | Retrieves the amount of RAM that is physically installed on the computer
_WinAPI_GetPixel | Retrieves the color value of the pixel at the specified coordinates
_WinAPI_GetPolyFillMode | Retrieves the current polygon fill mode
_WinAPI_GetPosFromRect | Interprets the coordinates of the rectangle as offset and position coordinates
_WinAPI_GetPriorityClass | Retrieves the priority class for the specified process
_WinAPI_GetProcAddress | Retrieves the address of an exported function or variable from the specified module
_WinAPI_GetProcessAffinityMask | Obtains the affinity masks for the process and the system
_WinAPI_GetProcessCommandLine | Retrieves the command-line string for the specified process
_WinAPI_GetProcessFileName | Retrieves the fully-qualified path of the executable file for the specified process
_WinAPI_GetProcessHandleCount | Retrieves the number of open handles that belong to the specified process
_WinAPI_GetProcessID | Retrieves the process identifier of the specified process
_WinAPI_GetProcessIoCounters | Retrieves accounting information for all I/O operations performed by the specified process
_WinAPI_GetProcessMemoryInfo | Retrieves information about the memory usage of the specified process
_WinAPI_GetProcessName | Retrieves the name for the specified process
_WinAPI_GetProcessShutdownParameters | Retrieves the shutdown parameters for the currently calling process
_WinAPI_GetProcessTimes | Retrieves timing information for the specified process
_WinAPI_GetProcessUser | Retrieves the user and domain name for the specified process
_WinAPI_GetProcessWindowStation | Retrieves a handle to the current window station for the calling process
_WinAPI_GetProcessWorkingDirectory | Retrieves the current working directory for the specified process
_WinAPI_GetProfilesDirectory | Retrieves the path to the root directory where user profiles are stored
_WinAPI_GetPwrCapabilities | Retrieves information about the system power capabilities
_WinAPI_GetRawInputBuffer | Performs a buffered read of the raw input data
_WinAPI_GetRawInputBufferLength | Retrieves the required buffer size to call the _WinAPI_GetRawInputBuffer() function
_WinAPI_GetRawInputData | Retrieves the raw input from the specified device
_WinAPI_GetRawInputDeviceInfo | Retrieves information about the raw input device
_WinAPI_GetRegionData | Fills the specified buffer with data describing a region
_WinAPI_GetRegisteredRawInputDevices | Retrieves the information about the raw input devices for the current application
_WinAPI_GetRegKeyNameByHandle | Retrieves a name of the specified registry key
_WinAPI_GetRgnBox | Retrieves the bounding rectangle of the specified region
_WinAPI_GetROP2 | Retrieves the foreground mix mode of the specified device context
_WinAPI_GetRValue | Retrieves an intensity value for the red component of a 32-bit RGB value
_WinAPI_GetSaveFileName | Creates a Save dialog box that lets the user specify the drive, directory, and name of a file to save
_WinAPI_GetShellWindow | Retrieves a handle to the Shell's desktop window
_WinAPI_GetStartupInfo | Retrieves the contents of the STARTUPINFO structure that was specified when the calling process was created
_WinAPI_GetStdHandle | Retrieves a handle for the standard input, standard output, or standard error device
_WinAPI_GetStockObject | Retrieves a handle to one of the predefined stock pens, brushes, fonts, or palettes
_WinAPI_GetStretchBltMode | Retrieves the current stretching mode
_WinAPI_GetString | Returns a string located at the specified memory address
_WinAPI_GetSysColor | Retrieves the current color of the specified display element
_WinAPI_GetSysColorBrush | Retrieves a handle identifying a logical brush that corresponds to the specified color index
_WinAPI_GetSystemDefaultLangID | Returns the language identifier for the system locale
_WinAPI_GetSystemDefaultLCID | Returns the locale identifier (LCID) for the system locale
_WinAPI_GetSystemDefaultUILanguage | Retrieves the language identifier for the system default UI language of the operating system
_WinAPI_GetSystemDEPPolicy | Gets the data execution prevention (DEP) policy setting for the system
_WinAPI_GetSystemInfo | Retrieves information about the current system
_WinAPI_GetSystemMetrics | Retrieves the specified system metric or system configuration setting
_WinAPI_GetSystemPowerStatus | Retrieves the power status of the system
_WinAPI_GetSystemTimes | Retrieves system timing information
_WinAPI_GetSystemWow64Directory | Retrieves the path of the system directory used by WOW64
_WinAPI_GetTabbedTextExtent | Computes the width and height of a character string which may contain one or more tab characters
_WinAPI_GetTempFileName | Creates a name for a temporary file
_WinAPI_GetTextAlign | Retrieves the text-alignment setting for the specified device context
_WinAPI_GetTextCharacterExtra | Retrieves the current intercharacter spacing for the specified device context
_WinAPI_GetTextColor | Retrieves the current text color for the specified device context
_WinAPI_GetTextExtentPoint32 | Computes the width and height of the specified string of text
_WinAPI_GetTextFace | Retrieves the typeface name of the font that is selected into the specified device context
_WinAPI_GetTextMetrics | Retrieves basic information for the currently selected font
_WinAPI_GetThemeAppProperties | Retrieves the property flags that control how visual styles are applied in the current application
_WinAPI_GetThemeBackgroundContentRect | Retrieves the size of the content area for the background defined by the visual style
_WinAPI_GetThemeBackgroundExtent | Calculates the size and location of the background, defined by the visual style, given the content area
_WinAPI_GetThemeBackgroundRegion | Computes the region for a regular or partially transparent background that is bounded by a specified rectangle
_WinAPI_GetThemeBitmap | Retrieves the bitmap associated with a particular theme, part, state, and property
_WinAPI_GetThemeBool | Retrieves the value of a BOOL property from the SysMetrics section of theme data
_WinAPI_GetThemeColor | Retrieves the value of a color property
_WinAPI_GetThemeDocumentationProperty | Retrieves the value for a theme property from the documentation section of the specified theme file
_WinAPI_GetThemeEnumValue | Retrieves the value of an enumerated type property
_WinAPI_GetThemeFilename | Retrieves the value of a filename property
_WinAPI_GetThemeFont | Retrieves the value of a font property
_WinAPI_GetThemeInt | Retrieves the value of an INT property
_WinAPI_GetThemeMargins | Retrieves the value of a margins property
_WinAPI_GetThemeMetric | Retrieves the value of a metric property
_WinAPI_GetThemePartSize | Calculates the original size of the part defined by a visual style
_WinAPI_GetThemePosition | Retrieves the value of a position property
_WinAPI_GetThemePropertyOrigin | Retrieves the location of the theme property definition for a property
_WinAPI_GetThemeRect | Retrieves the value of a RECT property
_WinAPI_GetThemeString | Retrieves the value of a string property
_WinAPI_GetThemeSysBool | Retrieves the Boolean value of a system metric
_WinAPI_GetThemeSysColor | Retrieves the value of a system color
_WinAPI_GetThemeSysColorBrush | Retrieves a system color brush
_WinAPI_GetThemeSysFont | Retrieves the font information of a system font
_WinAPI_GetThemeSysInt | Retrieves the value of a system INT
_WinAPI_GetThemeSysSize | Retrieves the value of a system size metric from theme data
_WinAPI_GetThemeSysString | Retrieves the value of a system string
_WinAPI_GetThemeTextExtent | Calculates the size and location of the specified text when rendered in the visual style font
_WinAPI_GetThemeTextMetrics | Retrieves information about the font specified by a visual style for a particular part
_WinAPI_GetThemeTransitionDuration | Gets the duration for the specified transition
_WinAPI_GetThreadDesktop | Retrieves a handle to the desktop assigned to the specified thread
_WinAPI_GetThreadErrorMode | Retrieves the error mode for the calling thread
_WinAPI_GetThreadLocale | Retrieves the locale identifier of the current locale for the calling thread
_WinAPI_GetThreadUILanguage | Retrieves the language identifier of the first user interface language for the current thread
_WinAPI_GetTickCount | Retrieves the number of milliseconds that have elapsed since the system was started
_WinAPI_GetTickCount64 | Retrieves the number of milliseconds that have elapsed since the system was started
_WinAPI_GetTimeFormat | Formats time as a time string for a locale specified by identifier
_WinAPI_GetTopWindow | Retrieves a handle to the child window at the top of the Z order
_WinAPI_GetUDFColorMode | Retrieves the current color mode for WinAPIEx UDF library
_WinAPI_GetUpdateRect | Retrieves the coordinates of the rectangle that completely encloses the update region of the specified window
_WinAPI_GetUpdateRgn | Retrieves the update region of a window by copying it into the specified region
_WinAPI_GetUserDefaultLangID | Returns the language identifier for the current user locale
_WinAPI_GetUserDefaultLCID | Returns the locale identifier (LCID) for the user default locale
_WinAPI_GetUserDefaultUILanguage | Returns the language identifier for the user UI language for the current user
_WinAPI_GetUserGeoID | Retrieves information about the geographical location of the user
_WinAPI_GetUserObjectInformation | Retrieves information about the specified window station or desktop object
_WinAPI_GetVersion | Retrieves version of the current operating system
_WinAPI_GetVersionEx | Retrieves information about the current operating system
_WinAPI_GetVolumeInformation | Retrieves information about the file system and volume associated with the specified root directory
_WinAPI_GetVolumeInformationByHandle | Retrieves information about the file system and volume associated with the specified file
_WinAPI_GetVolumeNameForVolumeMountPoint | Retrieves a volume GUID path for the volume that is associated with the specified volume mount point
_WinAPI_GetWindow | Retrieves the handle of a window that has a specified relationship to the specified window
_WinAPI_GetWindowDC | Retrieves the device context (DC) for the entire window
_WinAPI_GetWindowDisplayAffinity | Retrieves the current display affinity setting, from any process, for a given window
_WinAPI_GetWindowExt | Retrieves the x-extent and y-extent of the window for the specified device context
_WinAPI_GetWindowFileName | Retrieves the fully-qualified path of the module associated with the specified window handle
_WinAPI_GetWindowHeight | Returns the height of the window
_WinAPI_GetWindowInfo | Retrieves information about the specified window
_WinAPI_GetWindowLong | Retrieves information about the specified window
_WinAPI_GetWindowOrg | Retrieves the x-coordinates and y-coordinates of the window origin for the specified device context
_WinAPI_GetWindowPlacement | Retrieves the placement of the window for Min, Max, and normal positions
_WinAPI_GetWindowRect | Retrieves the dimensions of the bounding rectangle of the specified window
_WinAPI_GetWindowRgn | Obtains a copy of the window region of a window
_WinAPI_GetWindowRgnBox | Retrieves the dimensions of the tightest bounding rectangle for the window region of a window
_WinAPI_GetWindowSubclass | Retrieves the reference data for the specified window subclass callback
_WinAPI_GetWindowText | Retrieves the text of the specified window's title bar
_WinAPI_GetWindowTheme | Retrieves a theme handle to a window that has visual styles applied
_WinAPI_GetWindowThreadProcessId | Retrieves the identifier of the thread that created the specified window
_WinAPI_GetWindowWidth | Returns the width of the window
_WinAPI_GetWorkArea | Retrieves the size of the working area on the primary display monitor
_WinAPI_GetWorldTransform | Retrieves the current world-space to page-space transformation
_WinAPI_GetXYFromPoint | Returns the X/Y values from a $tagPOINT structure
_WinAPI_GlobalMemoryStatus | Retrieves information about current available memory
_WinAPI_GradientFill | Fills rectangle or triangle gradient
_WinAPI_GUIDFromString | Converts a string GUID to binary form
_WinAPI_GUIDFromStringEx | Converts a string GUID to binary form
_WinAPI_HashData | Hashes a memory block
_WinAPI_HashString | Hashes a string
_WinAPI_HiByte | Returns the high BYTE of a 16-bit (2 bytes) value
_WinAPI_HideCaret | Removes the caret from the screen
_WinAPI_HiDWord | Returns the high DWORD of a 64-bit (8 bytes) value
_WinAPI_HiWord | Returns the high word of a longword value
_WinAPI_InflateRect | Increases or decreases the width and height of the specified rectangle
_WinAPI_InitMUILanguage | Enables an application to specify a language to be used with the common controls that is different from the system language
_WinAPI_InProcess | Determines whether a window belongs to the current process
_WinAPI_IntersectClipRect | Creates a new clipping region from the intersection of the current clipping region and the specified rectangle
_WinAPI_IntersectRect | Creates the intersection of two rectangles
_WinAPI_IntToDWord | Converts a value of type INT to a value of type DWORD
_WinAPI_IntToFloat | Returns a 4 byte integer as a float value
_WinAPI_InvalidateRect | Adds a rectangle to the specified window's update region
_WinAPI_InvalidateRgn | Adds a region to the specified window's update region
_WinAPI_InvertANDBitmap | Inverts the specified AND bitmask bitmap by performing a logical NOT operation
_WinAPI_InvertColor | Inverts (negative) the specified color
_WinAPI_InvertRect | Inverts a rectangle in a window by performing a logical NOT operation on the color values for each pixel
_WinAPI_InvertRgn | Inverts the colors in the specified region
_WinAPI_IOCTL | Create a unique system I/O control code (IOCTL)
_WinAPI_IsAlphaBitmap | Determines whether the specified bitmap has an alpha channel
_WinAPI_IsBadCodePtr | Determines whether the calling process has read access to the memory at the specified address
_WinAPI_IsBadReadPtr | Verifies that the calling process has read access to the specified range of memory
_WinAPI_IsBadStringPtr | Verifies that the calling process has read access to the specified range of memory
_WinAPI_IsBadWritePtr | Verifies that the calling process has write access to the specified range of memory
_WinAPI_IsChild | Tests whether a window is a child window of a specified parent window
_WinAPI_IsClassName | Wrapper to check ClassName of the control
_WinAPI_IsDoorOpen | Checks if a CD (DVD) tray is open
_WinAPI_IsElevated | Determines whether the current process is elevated
_WinAPI_IsHungAppWindow | Determines whether the specified application is not responding
_WinAPI_IsIconic | Determines whether the specified window is minimized (iconic)
_WinAPI_IsInternetConnected | Determines whether the current user is connected to the Internet
_WinAPI_IsLoadKBLayout | Determines whether the specified input locale loaded into the system
_WinAPI_IsMemory | Determines whether the specified pointer points to the memory block in the internal library heap
_WinAPI_IsNameInExpression | Determines whether a string matches the specified pattern
_WinAPI_IsNetworkAlive | Determines whether or not a local system is connected to a network, and identifies the type of network connection
_WinAPI_IsPathShared | Determines whether the path is shared
_WinAPI_IsProcessInJob | Determines whether the process is running in the specified job
_WinAPI_IsProcessorFeaturePresent | Determines whether the specified processor feature is supported by the current computer
_WinAPI_IsRectEmpty | Determines whether the specified rectangle is empty
_WinAPI_IsThemeActive | Tests if a visual style for the current application is active
_WinAPI_IsThemeBackgroundPartiallyTransparent | Retrieves whether the background specified by the visual style has transparent pieces or alpha-blended pieces
_WinAPI_IsThemePartDefined | Retrieves whether a visual style has defined parameters for the specified part
_WinAPI_IsValidLocale | Determines if the specified locale is installed or supported on the operating system
_WinAPI_IsWindow | Determines whether the specified window handle identifies an existing window
_WinAPI_IsWindowEnabled | Determines whether the specified window is enabled for mouse and keyboard input
_WinAPI_IsWindowUnicode | Determines whether the specified window is a native Unicode window
_WinAPI_IsWindowVisible | Retrieves the visibility state of the specified window
_WinAPI_IsWow64Process | Determines whether the specified process is running under WOW64
_WinAPI_IsWritable | Determines whether a disk is writable
_WinAPI_IsZoomed | Determines whether a window is maximized
_WinAPI_Keybd_Event | Synthesizes a keystroke
_WinAPI_KillTimer | Destroys the specified timer
_WinAPI_LineDDA | Determines which pixels should be highlighted for a line
_WinAPI_LineTo | Draws a line from the current position up to, but not including, the specified point
_WinAPI_LoadBitmap | Loads the specified bitmap resource from a module's executable file
_WinAPI_LoadCursor | Loads the specified cursor resource from the executable (.exe) file
_WinAPI_LoadCursorFromFile | Creates a cursor based on data contained in a file
_WinAPI_LoadIcon | Loads the specified icon resource from the executable (.exe) file associated with an application instance
_WinAPI_LoadIconMetric | Loads a specified icon resource with a client-specified system metric
_WinAPI_LoadIconWithScaleDown | Loads an icon and scales down a larger image instead of scaling up a smaller image
_WinAPI_LoadImage | Loads an icon, cursor, or bitmap
_WinAPI_LoadIndirectString | Extracts the string from the specified resource when given an indirect string
_WinAPI_LoadKeyboardLayout | Loads a new input locale identifier into the system
_WinAPI_LoadLibrary | Maps a specified executable module into the address space of the calling process
_WinAPI_LoadLibraryEx | Maps a specified executable module into the address space of the calling process
_WinAPI_LoadMedia | Loads media into a device
_WinAPI_LoadResource | Loads the specified resource into global memory
_WinAPI_LoadShell32Icon | Extracts an icon from the shell32.dll file
_WinAPI_LoadString | loads a string resource from the executable file associated with a specified module
_WinAPI_LoadStringEx | Loads a string resource for the specified language from the specified module
_WinAPI_LoByte | Returns the low BYTE of a 16-bit (2 bytes) value
_WinAPI_LocalFree | Frees the specified local memory object and invalidates its handle
_WinAPI_LockDevice | Enables or disables the mechanism that ejects media, for those devices possessing that locking capability
_WinAPI_LockFile | Locks the specified file for exclusive access by the calling process
_WinAPI_LockResource | Locks the specified resource in memory
_WinAPI_LockWindowUpdate | Disables or enables drawing in the specified window
_WinAPI_LockWorkStation | Locks the workstation's display
_WinAPI_LoDWord | Returns the low DWORD of a 64-bit (8 bytes) value
_WinAPI_LongMid | Extracts a number of bits from a DWORD (32-bit) value
_WinAPI_LookupIconIdFromDirectoryEx | Searches through icon or cursor data for the icon or cursor that best fits the current display device
_WinAPI_LoWord | Returns the low word of a longword
_WinAPI_LPtoDP | Converts a logical coordinates into device coordinates
_WinAPI_MAKELANGID | Construct language id from a primary language id and a sublanguage id
_WinAPI_MAKELCID | Construct locale id from a language id and a sort id
_WinAPI_MakeLong | Returns a long int value from two int values
_WinAPI_MakeQWord | Returns a QWORD value from two int values
_WinAPI_MakeWord | Returns a WORD (16-bit) value from two BYTE (8-bit) values
_WinAPI_MapViewOfFile | Maps a view of a file mapping into the address space of a calling process
_WinAPI_MapVirtualKey | Translates a virtual-key code into a scan code or character value, or translates a scan code into a virtual-key code
_WinAPI_MaskBlt | Combines the color data for the source and destination bitmaps using the specified mask and raster operation
_WinAPI_MessageBeep | Plays a waveform sound
_WinAPI_MessageBoxCheck | Displays a message box that gives the user the option of suppressing further occurrences
_WinAPI_MessageBoxIndirect | Creates, displays, and operates a message box
_WinAPI_MirrorIcon | Reverses (mirrors) icons so that they are displayed correctly on a mirrored device context
_WinAPI_ModifyWorldTransform | Changes the world transformation for a device context using the specified mode
_WinAPI_MonitorFromPoint | Retrieves a handle to the display monitor that contains a specified point
_WinAPI_MonitorFromRect | Retrieves a handle to the display monitor that has the largest area of intersection with a specified rectangle
_WinAPI_MonitorFromWindow | Retrieves a handle to the display monitor that has the largest area of intersection with the specified window
_WinAPI_Mouse_Event | Synthesizes mouse motion and button clicks
_WinAPI_MoveFileEx | Moves a file or directory, notifying the application of its progress through a callback function
_WinAPI_MoveMemory | Moves a block of memory from one location to another
_WinAPI_MoveTo | Updates the current position to the specified point
_WinAPI_MoveToEx | Updates the current position to the specified point
_WinAPI_MoveWindow | Changes the position and dimensions of the specified window
_WinAPI_MsgBox | Displays a message box with wider margin than original
_WinAPI_MulDiv | Multiplies two 32-bit values and then divides the 64-bit result by a third 32-bit value
_WinAPI_MultiByteToWideChar | Maps a character string to a wide-character (Unicode) string
_WinAPI_MultiByteToWideCharEx | Maps a character string to a wide-character (Unicode) string
_WinAPI_NtStatusToDosError | Converts the specified NTSTATUS error code to its equivalent system error code
_WinAPI_OemToChar | Converts a string from the OEM-defined character set into either an ANSI string
_WinAPI_OffsetClipRgn | Moves the clipping region of a device context by the specified offsets
_WinAPI_OffsetPoints | Moves a points from the array by the specified offsets
_WinAPI_OffsetRect | Moves the specified rectangle by the specified offsets
_WinAPI_OffsetRgn | Moves a region by the specified offsets
_WinAPI_OffsetWindowOrg | Modifies the window origin for a device context using the specified horizontal and vertical offsets
_WinAPI_OpenDesktop | Opens the specified desktop object
_WinAPI_OpenFileById | Opens the file that matches the specified object identifier
_WinAPI_OpenFileDlg | Creates a dialog box that lets the user specify the drive, directory, and the name of a file or set of files to be opened
_WinAPI_OpenFileMapping | Opens a named file mapping object
_WinAPI_OpenIcon | Restores a minimized (iconic) window to its previous size and position and activates the window
_WinAPI_OpenInputDesktop | Opens the desktop that receives user input
_WinAPI_OpenJobObject | Opens an existing job object
_WinAPI_OpenMutex | Opens an existing named mutex object
_WinAPI_OpenProcess | Returns a handle of an existing process object
_WinAPI_OpenProcessToken | Opens the access token associated with a process
_WinAPI_OpenSemaphore | Opens an existing named semaphore object
_WinAPI_OpenThemeData | Opens the theme data for a window and its associated class
_WinAPI_OpenWindowStation | Opens the specified window station
_WinAPI_PageSetupDlg | Creates a Page Setup dialog box that enables the user to specify the attributes of a printed page
_WinAPI_PaintDesktop | Fills the clipping region in the specified device context with the desktop pattern or wallpaper
_WinAPI_PaintRgn | Paints the specified region by using the brush currently selected into the device context
_WinAPI_ParseURL | Performs rudimentary parsing of a URL
_WinAPI_ParseUserName | Extracts the domain and user account name from a fully qualified user name
_WinAPI_PatBlt | Paints the specified rectangle using the brush that is currently selected into the specified device context
_WinAPI_PathAddBackslash | Adds a backslash to the end of a string to create the correct syntax for a path
_WinAPI_PathAddExtension | Adds a file name extension to a path string
_WinAPI_PathAppend | Appends one path to the end of another
_WinAPI_PathBuildRoot | Creates a root path from a given drive number
_WinAPI_PathCanonicalize | Removes elements of a file path according to special strings inserted into that path
_WinAPI_PathCommonPrefix | Compares two paths to determine if they share a common prefix
_WinAPI_PathCompactPath | Truncates a file path to fit within a given pixel width by replacing path components with ellipses
_WinAPI_PathCompactPathEx | Truncates a path to fit within a certain number of characters by replacing path components with ellipses
_WinAPI_PathCreateFromUrl | Converts a file URL to a Microsoft MS-DOS path
_WinAPI_PathFindExtension | Searches a path for an extension
_WinAPI_PathFindFileName | Searches a path for a file name
_WinAPI_PathFindNextComponent | Parses a path and returns the portion of that path that follows the first backslash
_WinAPI_PathFindOnPath | Searchs for a file in the default system paths
_WinAPI_PathGetArgs | Finds the command-line arguments within a given path
_WinAPI_PathGetCharType | Determines the type of character in relation to a path
_WinAPI_PathGetDriveNumber | Searches a path for a drive letter within the range of 'A' to 'Z' and returns the corresponding drive number
_WinAPI_PathIsContentType | Determines if a file's registered content type matches the specified content type
_WinAPI_PathIsDirectory | Verifies that a path is a valid directory
_WinAPI_PathIsDirectoryEmpty | Determines whether a specified path is an empty directory
_WinAPI_PathIsExe | Determines whether a file is an executable by examining the file extension
_WinAPI_PathIsFileSpec | Searches a path for any path-delimiting characters
_WinAPI_PathIsLFNFileSpec | Determines whether a file name is in long format
_WinAPI_PathIsRelative | Searches a path and determines if it is relative
_WinAPI_PathIsRoot | Parses a path to determine if it is a directory root
_WinAPI_PathIsSameRoot | Compares two paths to determine if they have a common root component
_WinAPI_PathIsSystemFolder | Determines if an existing folder contains the attributes that make it a system folder
_WinAPI_PathIsUNC | Determines if the string is a valid Universal Naming Convention (UNC) for a server and share path
_WinAPI_PathIsUNCServer | Determines if a string is a valid Universal Naming Convention (UNC) for a server path only
_WinAPI_PathIsUNCServerShare | Determines if a string is a valid Universal Naming Convention (UNC) share path
_WinAPI_PathMakeSystemFolder | Gives an existing folder the proper attributes to become a system folder
_WinAPI_PathMatchSpec | Searches a string using a Microsoft MS-DOS wild card match type
_WinAPI_PathParseIconLocation | Parses a file location string that contains a file location and icon index
_WinAPI_PathRelativePathTo | Creates a relative path from one file or folder to another
_WinAPI_PathRemoveArgs | Removes any arguments from a given path
_WinAPI_PathRemoveBackslash | Removes the trailing backslash from a given path
_WinAPI_PathRemoveExtension | Removes the file name extension from a path, if one is present
_WinAPI_PathRemoveFileSpec | Removes the trailing file name and backslash from a path, if they are present
_WinAPI_PathRenameExtension | Replaces the extension of a file name with a new extension
_WinAPI_PathSearchAndQualify | Formats a path to the fully qualified path
_WinAPI_PathSkipRoot | Parses a path, ignoring the drive letter or Universal Naming Convention (UNC) server/share path elements
_WinAPI_PathStripPath | Removes the path portion of a fully qualified path and file
_WinAPI_PathStripToRoot | Removes all parts of the path except for the root information
_WinAPI_PathToRegion | Creates a region from the path that is selected into the specified device context
_WinAPI_PathUndecorate | Removes the decoration from a path string
_WinAPI_PathUnExpandEnvStrings | Replaces folder names in a fully-qualified path with their associated environment string
_WinAPI_PathUnmakeSystemFolder | Removes the attributes from a folder that make it a system folder
_WinAPI_PathUnquoteSpaces | Removes quotes from the beginning and end of a path
_WinAPI_PathYetAnotherMakeUniqueName | Creates a unique filename based on an existing filename
_WinAPI_PickIconDlg | Displays a dialog box that allows the user to choose an icon
_WinAPI_PlayEnhMetaFile | Displays the picture stored in the specified enhanced-format metafile
_WinAPI_PlaySound | Plays a sound specified by the given file name, resource, or system event
_WinAPI_PlgBlt | Performs a bit-block transfer of color data from the specified rectangle in the source DC to the specified parallelogram in the DC context
_WinAPI_PointFromRect | Returns the top/left coordinates of a $tagRECT as a $tagPOINT structure
_WinAPI_PolyBezier | Draws one or more Bezier curves
_WinAPI_PolyBezierTo | Draws one or more Bezier curves
_WinAPI_PolyDraw | Draws a set of line segments and Bezier curves
_WinAPI_Polygon | Draws a polygon consisting of two or more vertices connected by straight lines
_WinAPI_PostMessage | Places a message in the message queue and then returns
_WinAPI_PrimaryLangId | Extract primary language id from a language id
_WinAPI_PrintDlg | Displays a Print dialog box
_WinAPI_PrintDlgEx | Displays a Print property sheet that enables the user to specify the properties of a particular print job
_WinAPI_PrintWindow | Copies a visual window into the specified device context
_WinAPI_ProgIDFromCLSID | Retrieves the ProgID for a given CLSID
_WinAPI_PtInRect | Determines whether the specified point lies within the specified rectangle
_WinAPI_PtInRectEx | Determines whether the specified point lies within the specified rectangle
_WinAPI_PtInRegion | Determines whether the specified point is inside the specified region
_WinAPI_PtVisible | Determines whether the specified point is within the clipping region
_WinAPI_QueryDosDevice | Retrieves the current mapping for a particular MS-DOS device name
_WinAPI_QueryInformationJobObject | Retrieves limit and job state information from the job object
_WinAPI_QueryPerformanceCounter | Retrieves the current value of the high-resolution performance counter
_WinAPI_QueryPerformanceFrequency | Retrieves the frequency of the high-resolution performance counter
_WinAPI_RadialGradientFill | Fills radial gradient
_WinAPI_ReadDirectoryChanges | Retrieves information that describes the changes within the specified directory
_WinAPI_ReadFile | Reads data from a file
_WinAPI_ReadProcessMemory | Reads memory in a specified process
_WinAPI_Rectangle | Draws a rectangle
_WinAPI_RectInRegion | Determines whether any part of the specified rectangle is within the boundaries of a region
_WinAPI_RectIsEmpty | Determins whether a rectangle is empty
_WinAPI_RectVisible | Determines whether any part of the specified rectangle lies within the clipping region
_WinAPI_RedrawWindow | Updates the specified rectangle or region in a window's client area
_WinAPI_RegCloseKey | Closes a handle to the specified registry key
_WinAPI_RegConnectRegistry | Establishes a connection to a predefined registry key on another computer
_WinAPI_RegCopyTree | Recursively copies the subkeys and values of the source subkey to the destination key
_WinAPI_RegCopyTreeEx | Copies the specified registry key, along with its values and subkeys, to the specified destination key
_WinAPI_RegCreateKey | Creates the specified registry key
_WinAPI_RegDeleteEmptyKey | Deletes an empty key
_WinAPI_RegDeleteKey | Deletes a subkey and its values
_WinAPI_RegDeleteKeyValue | Removes the specified value from the specified registry key and subkey
_WinAPI_RegDeleteTree | Deletes a subkey and all its descendants
_WinAPI_RegDeleteTreeEx | Deletes the subkeys and values of the specified key recursively
_WinAPI_RegDeleteValue | Removes a named value from the specified registry key
_WinAPI_RegDisableReflectionKey | Disables registry reflection for the specified key
_WinAPI_RegDuplicateHKey | Duplicates a registry key's handle
_WinAPI_RegEnableReflectionKey | Restores registry reflection for the specified disabled key
_WinAPI_RegEnumKey | Enumerates the subkeys of the specified open registry key
_WinAPI_RegEnumValue | Enumerates the values for the specified open registry key
_WinAPI_RegFlushKey | Writes all the attributes of the specified open registry key into the registry
_WinAPI_RegisterApplicationRestart | Registers the active instance of an application for restart
_WinAPI_RegisterClass | Registers a window class
_WinAPI_RegisterClassEx | Registers a window class
_WinAPI_RegisterHotKey | Defines a system-wide hot key
_WinAPI_RegisterPowerSettingNotification | Registers the application to receive power setting notifications for the specific power setting event
_WinAPI_RegisterRawInputDevices | Registers the devices that supply the raw input data
_WinAPI_RegisterShellHookWindow | Registers a specified Shell window to receive certain messages for events or notifications
_WinAPI_RegisterWindowMessage | Defines a new window message that is guaranteed to be unique throughout the system
_WinAPI_RegLoadMUIString | Loads the specified string from the specified key and subkey
_WinAPI_RegNotifyChangeKeyValue | Notifies the caller about changes to the attributes or contents of a specified registry key
_WinAPI_RegOpenKey | Opens the specified registry key
_WinAPI_RegQueryInfoKey | Retrieves information about the specified registry key
_WinAPI_RegQueryLastWriteTime | Retrieves information about the last write time to the specified registry key
_WinAPI_RegQueryMultipleValues | Retrieves the type and data for a list of value names associated with an open registry key
_WinAPI_RegQueryReflectionKey | Determines whether reflection has been disabled or enabled for the specified key
_WinAPI_RegQueryValue | Retrieves the type and data for the specified value name associated with an open registry key
_WinAPI_RegRestoreKey | Reads the registry information in a specified file and copies it over the specified key
_WinAPI_RegSaveKey | Saves the specified key and all of its subkeys and values to a new file, in the standard format
_WinAPI_RegSetValue | Sets the data and type of a specified value under a registry key
_WinAPI_ReleaseCapture | Releases the mouse capture from a window in the current thread and restores normal mouse input processing
_WinAPI_ReleaseDC | Releases a device context
_WinAPI_ReleaseMutex | Releases ownership of the specified mutex object
_WinAPI_ReleaseSemaphore | Increases the count of the specified semaphore object by a specified amount
_WinAPI_ReleaseStream | Releases a stream object
_WinAPI_RemoveClipboardFormatListener | Removes the given window from the system-maintained clipboard format listener list
_WinAPI_RemoveDirectory | Deletes an existing empty directory
_WinAPI_RemoveFontMemResourceEx | Removes the fonts added from a memory image
_WinAPI_RemoveFontResourceEx | Removes the fonts in the specified file from the system font table
_WinAPI_RemoveWindowSubclass | Removes a subclass callback from a window
_WinAPI_ReOpenFile | Reopens the specified file system object with different access rights, sharing mode, and flags
_WinAPI_ReplaceFile | Replaces one file with another file, and creates a backup copy of the original file
_WinAPI_ReplaceTextDlg | Creates a system-defined modeless dialog box that lets the user specify a string to search for and a replacement string
_WinAPI_ResetEvent | Sets the specified event object to the nonsignaled state
_WinAPI_RestartDlg | Displays a dialog box that prompts the user to restart Microsoft Windows
_WinAPI_RestoreDC | Restores a device context (DC) to the specified state
_WinAPI_RGB | Creates a RGB color value based on red, green, and blue components
_WinAPI_RotatePoints | Rotates a points from the array by the specified angle
_WinAPI_RoundRect | Draws a rectangle with rounded corners
_WinAPI_SaveDC | Saves the current state of the specified device context (DC) by copying data describing selected objects and graphic modes to a context stack
_WinAPI_SaveFileDlg | Creates a dialog box that lets the user specify the drive, directory, and name of a file to save
_WinAPI_SaveHBITMAPToFile | Saves a specified bitmap to the specified bitmap (.bmp) file
_WinAPI_SaveHICONToFile | Saves a specified single or multiple icon (HICON) to the specified icon (.ico) file
_WinAPI_ScaleWindowExt | Modifies the window for a device context using the ratios formed by the specified multiplicands and divisors
_WinAPI_ScreenToClient | Converts screen coordinates of a specified point on the screen to client coordinates
_WinAPI_SearchPath | Searches for a specified file in a specified path
_WinAPI_SelectClipPath | Selects the current path as a clipping region, combining the new region with any existing clipping region
_WinAPI_SelectClipRgn | Selects a region as the current clipping region for the specified device context
_WinAPI_SelectObject | Selects an object into the specified device context
_WinAPI_SendMessageTimeout | Sends the specified message to one of more windows
_WinAPI_SetActiveWindow | Activates the specified window
_WinAPI_SetArcDirection | Sets the drawing arc direction
_WinAPI_SetBitmapBits | Sets the bits of color data for a bitmap to the specified values
_WinAPI_SetBitmapDimensionEx | Assigns preferred dimensions to a compatible bitmap
_WinAPI_SetBkColor | Sets the current background color to the specified color value
_WinAPI_SetBkMode | Sets the background mix mode of the specified device context
_WinAPI_SetBoundsRect | Controls the accumulation of bounding rectangle information for the specified device context
_WinAPI_SetBrushOrg | Sets the brush origin that GDI assigns to the next brush an application selects into the specified device context
_WinAPI_SetCapture | Sets the mouse capture to the specified window belonging to the current thread
_WinAPI_SetCaretBlinkTime | Sets the caret blink time
_WinAPI_SetCaretPos | Moves the caret to the specified coordinates
_WinAPI_SetClassLongEx | Replaces the specified value into the specified window belongs
_WinAPI_SetColorAdjustment | Sets the color adjustment for a device context (DC)
_WinAPI_SetCompression | Sets the compression state of a file or directory
_WinAPI_SetCurrentDirectory | Changes the current directory for the current process
_WinAPI_SetCurrentProcessExplicitAppUserModelID | Specifies a unique application-defined Application User Model ID that identifies the current process to the taskbar
_WinAPI_SetCursor | Establishes the cursor shape
_WinAPI_SetDCBrushColor | Sets the current device context (DC) brush color to the specified color value
_WinAPI_SetDCPenColor | Sets the current device context (DC) pen color to the specified color value
_WinAPI_SetDefaultPrinter | Sets the default printer for the current user on the local computer
_WinAPI_SetDeviceGammaRamp | Sets the gamma ramp on direct color display boards that support downloadable gamma ramps in hardware
_WinAPI_SetDIBColorTable | Sets RGB color table in the DIB section bitmap
_WinAPI_SetDIBits | Sets the pixels in a compatible bitmap using the color data found in a DIB
_WinAPI_SetDIBitsToDevice | Sets the pixels in the specified rectangle on the device
_WinAPI_SetDllDirectory | Adds a directory to the search path used to locate DLLs for the application
_WinAPI_SetEndOfFile | Sets the physical file size for the specified file to the current position of the file pointer
_WinAPI_SetEnhMetaFileBits | Creates a memory-based enhanced-format metafile from the specified data
_WinAPI_SetErrorMode | Controls whether the system will handle the specified types of serious errors or whether the process will handle them
_WinAPI_SetEvent | Sets the specified event object to the signaled state
_WinAPI_SetFileAttributes | Sets the attributes for a file or directory
_WinAPI_SetFileInformationByHandleEx | Sets the file information for the specified file
_WinAPI_SetFilePointer | Moves the file pointer of the specified file
_WinAPI_SetFilePointerEx | Moves the file pointer of the specified file
_WinAPI_SetFileShortName | Sets the short name for the specified file
_WinAPI_SetFileValidData | Sets the valid data length of the specified file
_WinAPI_SetFocus | Sets the keyboard focus to the specified window
_WinAPI_SetFont | Sets a window font
_WinAPI_SetForegroundWindow | Puts the specified window into the foreground and activates its
_WinAPI_SetFRBuffer | Sets the size of the internal buffer that used the _WinAPI_FindTextDlg() and _WinAPI_ReplaceTextDlg() functions
_WinAPI_SetGraphicsMode | Sets the graphics mode for the specified device context
_WinAPI_SetHandleInformation | Sets certain properties of an object handle
_WinAPI_SetInformationJobObject | Sets limits for a job object
_WinAPI_SetKeyboardLayout | Sets an input locale identifier to the specified window
_WinAPI_SetKeyboardState | Copies a 256-byte array of keyboard key states into the calling process's keyboard input-state table
_WinAPI_SetLastError | Sets the last-error code for the calling thread
_WinAPI_SetLayeredWindowAttributes | Sets Layered Window Attributes
_WinAPI_SetLocaleInfo | Sets an item of information in the user override portion of the current locale
_WinAPI_SetMapMode | Sets the mapping mode of the specified device context
_WinAPI_SetMessageExtraInfo | Sets the extra message information for the current thread
_WinAPI_SetParent | Changes the parent window of the specified child window
_WinAPI_SetPixel | Sets the pixel at the specified coordinates to the specified color
_WinAPI_SetPolyFillMode | Sets the polygon fill mode for functions that fill polygons
_WinAPI_SetPriorityClass | Sets the priority class for the specified process
_WinAPI_SetProcessAffinityMask | Sets a processor affinity mask for the threads of a specified process
_WinAPI_SetProcessShutdownParameters | Sets a shutdown order for a process relative to the other processes in the system
_WinAPI_SetProcessWindowStation | Assigns the specified window station to the calling process
_WinAPI_SetRectRgn | Converts a region into a rectangular region with the specified coordinates
_WinAPI_SetROP2 | Retrieves the foreground mix mode of the specified device context
_WinAPI_SetSearchPathMode | Sets the per-process mode that the _WinAPI_SearchPath() function uses when locating files
_WinAPI_SetStretchBltMode | Sets the bitmap stretching mode in the specified device context
_WinAPI_SetSysColors | Obtains information about the display devices in a system
_WinAPI_SetSystemCursor | Enables an application to customize the system cursors
_WinAPI_SetTextAlign | Sets the text-alignment flags for the specified device context
_WinAPI_SetTextCharacterExtra | Sets the intercharacter spacing for the specified device context
_WinAPI_SetTextColor | Sets the current text color to the specified color value
_WinAPI_SetTextJustification | Specifies the amount of space the system should add to the break characters in a string of text
_WinAPI_SetThemeAppProperties | Sets the flags that determine how visual styles are implemented in the calling application
_WinAPI_SetThreadDesktop | Assigns the specified desktop to the calling thread
_WinAPI_SetThreadErrorMode | Controls whether the system will handle the specified types of serious errors or whether the calling thread will handle them
_WinAPI_SetThreadExecutionState | Prevents the system from entering sleep or turning off the display while the current application is running
_WinAPI_SetThreadLocale | Sets the current locale of the calling thread
_WinAPI_SetThreadUILanguage | Sets the user interface language for the current thread
_WinAPI_SetTimer | Creates a timer with the specified time-out value
_WinAPI_SetUDFColorMode | Sets the color mode for the WinAPIEx library
_WinAPI_SetUserGeoID | Sets the geographical location identifier for the user
_WinAPI_SetUserObjectInformation | Sets information about the specified window station or desktop object
_WinAPI_SetVolumeMountPoint | Associates a volume with a drive letter or a directory on another volume
_WinAPI_SetWindowDisplayAffinity | Stores the display affinity setting in kernel mode on the specified window
_WinAPI_SetWindowExt | Sets the horizontal and vertical extents of the window for a device context by using the specified values
_WinAPI_SetWindowLong | Sets information about the specified window
_WinAPI_SetWindowOrg | Specifies which window point maps to the viewport origin (0,0)
_WinAPI_SetWindowPlacement | Sets the placement of the window for Min, Max, and normal positions
_WinAPI_SetWindowPos | Changes the size, position, and Z order of a child, pop-up, or top-level window
_WinAPI_SetWindowRgn | Sets the window region of a window
_WinAPI_SetWindowsHookEx | Installs an application-defined hook procedure into a hook chain
_WinAPI_SetWindowSubclass | Installs or updates a window subclass callback
_WinAPI_SetWindowText | Changes the text of the specified window's title bar
_WinAPI_SetWindowTheme | Causes a window to use a different set of visual style information than its class normally uses
_WinAPI_SetWinEventHook | Sets an event hook function for a range of events
_WinAPI_SetWorldTransform | Sets a two-dimensional linear transformation between world space and page space for the specified device context
_WinAPI_SfcIsFileProtected | Determines whether the specified file is protected
_WinAPI_SfcIsKeyProtected | Determines whether the specified registry key is protected
_WinAPI_ShellAboutDlg | Displays a Windows About dialog box
_WinAPI_ShellAddToRecentDocs | Adds a file to the most recently and frequently item list
_WinAPI_ShellChangeNotify | Notifies the system of an event that an application has performed
_WinAPI_ShellChangeNotifyDeregister | Unregisters the client's window
_WinAPI_ShellChangeNotifyRegister | Registers a window to receive notifications from the file system or Shell
_WinAPI_ShellCreateDirectory | Creates a new file system folder
_WinAPI_ShellEmptyRecycleBin | Empties the Recycle Bin on the specified drive
_WinAPI_ShellExecute | Performs an operation on a specified file
_WinAPI_ShellExecuteEx | Performs an operation on a specified file
_WinAPI_ShellExtractAssociatedIcon | Returns a handle to the icon that associated with the specified file's
_WinAPI_ShellExtractIcon | Extracts the icon with the specified dimension from the specified file
_WinAPI_ShellFileOperation | Copies, moves, renames, or deletes a file system object
_WinAPI_ShellFlushSFCache | Flushes the special folder cache
_WinAPI_ShellGetFileInfo | Retrieves information about an object in the file system
_WinAPI_ShellGetIconOverlayIndex | Retrieves the index of the overlay icon in the system image list
_WinAPI_ShellGetImageList | Retrieves the system image list for small or large icons
_WinAPI_ShellGetKnownFolderIDList | Retrieves the path of a known folder as an ITEMIDLIST structure
_WinAPI_ShellGetKnownFolderPath | Retrieves the full path of a known folder identified
_WinAPI_ShellGetLocalizedName | Retrieves the localized name of a file in a Shell folder
_WinAPI_ShellGetPathFromIDList | Converts an item identifier list to a file system path
_WinAPI_ShellGetSetFolderCustomSettings | Sets or retrieves custom folder settings
_WinAPI_ShellGetSettings | Retrieves Shell state settings
_WinAPI_ShellGetSpecialFolderLocation | Retrieves a pointer to the ITEMIDLIST structure (PIDL) of a special folder
_WinAPI_ShellGetSpecialFolderPath | Retrieves the path of a special folder
_WinAPI_ShellGetStockIconInfo | Retrieves information about system-defined Shell icons
_WinAPI_ShellILCreateFromPath | Creates a pointer to an item identifier list (PIDL) from a path
_WinAPI_ShellNotifyIcon | Sends a message to the taskbar's status area
_WinAPI_ShellNotifyIconGetRect | Gets the screen coordinates of the bounding rectangle of a notification icon
_WinAPI_ShellObjectProperties | Invokes the Properties context menu command on a Shell object
_WinAPI_ShellOpenFolderAndSelectItems | Opens a Windows Explorer window with specified items in a particular folder selected
_WinAPI_ShellOpenWithDlg | Displays the Open With dialog box
_WinAPI_ShellQueryRecycleBin | Retrieves the size of the Recycle Bin and the number of items in it, for a specified drive
_WinAPI_ShellQueryUserNotificationState | Checks the state of the computer for the current user
_WinAPI_ShellRemoveLocalizedName | Removes the localized name of a file in a Shell folder
_WinAPI_ShellRestricted | Determines whether a specified administrator policy is in effect
_WinAPI_ShellSetKnownFolderPath | Redirects a known folder to a new location
_WinAPI_ShellSetLocalizedName | Sets the localized name of a file in a Shell folder
_WinAPI_ShellSetSettings | Sets Shell state settings
_WinAPI_ShellStartNetConnectionDlg | Displays a general browsing dialog box for a network resource connection
_WinAPI_ShellUpdateImage | Notifies the Shell that an image in the system image list has changed
_WinAPI_ShellUserAuthenticationDlg | Creates and displays a configurable dialog box that accepts credentials information from a user
_WinAPI_ShellUserAuthenticationDlgEx | Creates and displays a configurable dialog box that accepts credentials information from a user
_WinAPI_ShortToWord | Converts a value of type SHORT to a value of type WORD
_WinAPI_ShowCaret | Makes the caret visible on the screen at the caret's current position
_WinAPI_ShowCursor | Displays or hides the cursor
_WinAPI_ShowError | Displays an error message box with an optional exit
_WinAPI_ShowLastError | Shows the last error code and message
_WinAPI_ShowMsg | Displays an "Information" message box
_WinAPI_ShowOwnedPopups | Shows or hides all pop-up windows owned by the specified window
_WinAPI_ShowWindow | Sets the specified window's show state
_WinAPI_ShutdownBlockReasonCreate | Indicates that the system cannot be shut down and sets a reason string to be displayed to the user if system shutdown is initiated
_WinAPI_ShutdownBlockReasonDestroy | Indicates that the system can be shut down and frees the reason string
_WinAPI_ShutdownBlockReasonQuery | Retrieves the reason string set by the _WinAPI_ShutdownBlockReasonCreate() function
_WinAPI_SizeOfResource | Returns the size, in bytes, of the specified resource
_WinAPI_StretchBlt | Copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap to fit the dimensions of the destination rectangle
_WinAPI_StretchDIBits | Copies the color data for a rectangle of pixels in a DIB, JPEG, or PNG image to the specified destination rectangle, stretching or compressing the rows and columns by using the specified raster operation
_WinAPI_StrFormatByteSize | Converts a numeric value into a string that represents the number expressed as a size value in bytes, kilobytes, megabytes, or gigabytes
_WinAPI_StrFormatByteSizeEx | Converts a numeric value into a string that represents the number expressed as separated groups of digits to the left of the decimal
_WinAPI_StrFormatKBSize | Converts a numeric value into a string that represents the number expressed as a size value in kilobytes
_WinAPI_StrFromTimeInterval | Converts a time interval to a string
_WinAPI_StringFromGUID | Converts a binary GUID to string form
_WinAPI_StringLenA | Calculates the size of ANSI string
_WinAPI_StringLenW | Calculates the size of wide string
_WinAPI_StrLen | Returns the length of the specified string
_WinAPI_StrokeAndFillPath | Closes any open figures in a path, strokes the outline of the path, and fills its interior
_WinAPI_StrokePath | Renders the specified path by using the current pen
_WinAPI_StructToArray | Converts the structure to the array of strings
_WinAPI_SubLangId | Extract sublanguage id from a language id
_WinAPI_SubtractRect | Determines the coordinates of a rectangle formed by subtracting one rectangle from another
_WinAPI_SwapDWord | Converts a ULONG from little-endian to big-endian, and vice versa
_WinAPI_SwapQWord | Converts a ULONGLONG from little-endian to big-endian, and vice versa
_WinAPI_SwapWord | Converts a USHORT from little-endian to big-endian, and vice versa
_WinAPI_SwitchColor | Converts a color from BGR to RGB and vice versa
_WinAPI_SwitchDesktop | Makes the specified desktop visible and activates it
_WinAPI_SwitchToThisWindow | Switches the focus to a specified window and bring it to the foreground
_WinAPI_SystemParametersInfo | Retrieves or sets the value of one of the system-wide parameters
_WinAPI_TabbedTextOut | Writes a character string at a specified location and expanding tabs to the specified tab-stop positions
_WinAPI_TerminateJobObject | Terminates all processes currently associated with the job
_WinAPI_TerminateProcess | Terminates the specified process and all of its threads
_WinAPI_TextOut | Writes a string at the specified location, using the currently selected font, background color, and text color
_WinAPI_TileWindows | Tiles the specified child windows of the specified parent window
_WinAPI_TrackMouseEvent | Posts messages when the mouse pointer leaves a window or hovers over a window for a specified amount of time
_WinAPI_TransparentBlt | Performs a bit-block transfer of the color data corresponding to a rectangle of pixels
_WinAPI_TwipsPerPixelX | Returns the width of a pixel, in twips
_WinAPI_TwipsPerPixelY | Returns the height of a pixel, in twips
_WinAPI_UnhookWindowsHookEx | Removes a hook procedure installed in a hook chain by the _WinAPI_SetWindowsHookEx function
_WinAPI_UnhookWinEvent | Removes an event hook function
_WinAPI_UnionRect | Creates the union of two rectangles
_WinAPI_UnionStruct | Creates the structure of two structures
_WinAPI_UniqueHardwareID | Generates a unique hardware identifier (ID) for local computer
_WinAPI_UnloadKeyboardLayout | Unloads an input locale identifier
_WinAPI_UnlockFile | Unlocks a region in an open file
_WinAPI_UnmapViewOfFile | Unmaps a mapped view of a file from the calling process's address space
_WinAPI_UnregisterApplicationRestart | Removes the active instance of an application from the restart list
_WinAPI_UnregisterClass | Unregisters a window class, freeing the memory required for the class
_WinAPI_UnregisterHotKey | Frees a hot key previously registered by the calling thread
_WinAPI_UnregisterPowerSettingNotification | Unregisters the power setting notification
_WinAPI_UpdateLayeredWindow | Updates the position, size, shape, content, and translucency of a layered window
_WinAPI_UpdateLayeredWindowEx | Updates a bitmap translucency of a layered window
_WinAPI_UpdateLayeredWindowIndirect | Updates the position, size, shape, content, and translucency of a layered window
_WinAPI_UpdateResource | Adds, deletes, or replaces a resource in a portable executable (PE) file
_WinAPI_UpdateWindow | Updates the client area of a window by sending a WM_PAINT message to the window
_WinAPI_UrlApplyScheme | Determines a scheme for a specified URL string, and returns a string with an appropriate prefix
_WinAPI_UrlCanonicalize | Converts a URL string into canonical form
_WinAPI_UrlCombine | Combines the base an relative URLs in canonical form
_WinAPI_UrlCompare | Makes a case-sensitive comparison of two URL strings
_WinAPI_UrlCreateFromPath | Converts a Microsoft MS-DOS path to a canonicalized URL
_WinAPI_UrlFixup | Attempts to correct a URL whose protocol identifier is incorrect
_WinAPI_UrlGetPart | Retrieves a specified part from the URL
_WinAPI_UrlHash | Hashes a URL string
_WinAPI_UrlIs | Tests whether or not a URL is a specified type
_WinAPI_UserHandleGrantAccess | Grants or denies access to a handle to a User object to a job that has a user-interface restriction
_WinAPI_ValidateRect | Removes a rectangle from the current update region of the specified window
_WinAPI_ValidateRgn | Removes a region from the current update region of the specified window
_WinAPI_VerQueryRoot | Retrieves the fixed version information from the specified version-information resource
_WinAPI_VerQueryValue | Retrieves the non-fixed (strings) version information from the specified version-information resource
_WinAPI_VerQueryValueEx | Retrieves the text information from the version-information resource of the specified binary module
_WinAPI_WaitForInputIdle | Waits until a process is waiting for user input with no input pending, or a time out
_WinAPI_WaitForMultipleObjects | Waits until one or all of the specified objects are in the signaled state
_WinAPI_WaitForSingleObject | Waits until the specified object is in the signaled state
_WinAPI_WideCharToMultiByte | Converts a Unicode string to a multibyte string
_WinAPI_WidenPath | Redefines the current path as the area that would be painted if the path were stroked
_WinAPI_WindowFromDC | Retrieves a handle to the window associated with the specified display device context (DC)
_WinAPI_WindowFromPoint | Retrieves the handle of the window that contains the specified point
_WinAPI_WordToShort | Converts a value of type WORD to a value of type SHORT
_WinAPI_Wow64EnableWow64FsRedirection | Enables or disables file system redirection for the calling thread
_WinAPI_WriteConsole | Writes a character string to a console screen buffer
_WinAPI_WriteFile | Writes data to a file at the position specified by the file pointer
_WinAPI_WriteProcessMemory | Writes memory in a specified process
_WinAPI_ZeroMemory | Fills a block of memory with zeros
_WinNet_AddConnection | Connects a local device to a network resource
_WinNet_AddConnection2 | Connects a local device to a network resource
_WinNet_AddConnection3 | Connects a local device to a network resource
_WinNet_CancelConnection | Cancels an existing network connection
_WinNet_CancelConnection2 | Cancels an existing network connection
_WinNet_CloseEnum | Ends a network resource enumeration started by a call to _WinNet_OpenEnum()
_WinNet_ConnectionDialog | Starts a general browsing dialog box for connecting to network resources
_WinNet_ConnectionDialog1 | Starts a general browsing dialog box for connecting to network resources
_WinNet_DisconnectDialog | Starts a general browsing dialog box for disconnecting from network resources
_WinNet_DisconnectDialog1 | Starts a general browsing dialog box for disconnecting from network resources
_WinNet_EnumResource | Continues an enumeration of network resources
_WinNet_GetConnection | Retrieves the name of the network resource associated with a local device
_WinNet_GetConnectionPerformance | Returns information about the performance of a network connection resource
_WinNet_GetLastError | Retrieves the most recent extended error
_WinNet_GetNetworkInformation | Returns extended information about a specific network provider
_WinNet_GetProviderName | Obtains the provider name for a specific type of network
_WinNet_GetResourceInformation | Identifies the network provider that owns the resource
_WinNet_GetResourceParent | Returns the parent of a network resource in the network browse hierarchy
_WinNet_GetUniversalName | Converts drived based path to universal form
_WinNet_GetUser | Retrieves the default user name, or the user name used to establish a connection
_WinNet_OpenEnum | Starts an enumeration of network resources or existing connections
_WinNet_RestoreConnection | Restores the connection to a network resource
_WinNet_UseConnection | Connects a local device to a network resource
_Word_Create | Connects to an existing Word instance or creates a new Word application object
_Word_DocAdd | Adds a new or empty document to the specified Word application
_Word_DocAttach | Attaches to the first instance of a Word document where the search string matches based on the selected mode
_Word_DocClose | Closes the specified Word document
_Word_DocExport | Exports the document or a range as PDF or XPS
_Word_DocFind | Runs or repeats the specified find operation
_Word_DocFindReplace | Runs the specified find and replace operation
_Word_DocGet | Returns a collection object containing all documents or an object for a single document
_Word_DocLinkAdd | Adds a hyperlink to the document
_Word_DocLinkGet | Returns a collection object containing all links in the document or a single link object
_Word_DocOpen | Opens a Word document
_Word_DocPictureAdd | Adds a picture to the document
_Word_DocPrint | Prints all or parts of the specified document
_Word_DocRangeSet | Sets or modifies a range in a document
_Word_DocSave | Saves the specified Word document
_Word_DocSaveAs | Saves the specified Word document with a new name or format
_Word_DocTableRead | Reads a Word table and returns the content as a two-dimensional array
_Word_DocTableWrite | Writes a one or two dimensional array to a Word table
_Word_Quit | Closes all documents, the Word application and removes the object reference to it


Function Notes

User Defined Function Notes

We have included number of files that each contain standard AutoIt3 Functions, so called User Defined Functions.
UDF's are functions/Scriptlets, written in AutoIt3, you can #include in your own script and use them without the need to program it yourself or Copy&Paste them every time you need them.

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

MsgBox ($MB_SYSTEMMODAL, "What is the date?", "Today's date is " & _Now ())

This script will display today's date formatted in your pc's long format. e.g. "Sunday, December 18, 2004"

Many UDF's contain optional parameters that can be omitted. If you wish to specify an optional parameter, however, all parameters that precede it must be specified!
For example, consider _ArraySort ( ByRef $a_Array [, $i_Descending [, $i_Base=0 [, $i_Ubound=0 [, $i_Dim=1 [, $i_SortIndex=0 ]]]]] )
When a parameter is preceded with ByRef this means that the function will update this variable with a new value. These parameters must be a variable ($xyz) and cannot be a constant.

Most UDF's indicate success/failure as a return value; others indicate it by setting the @error flag. Some do both....
@error = 0 ;is always success
Return = varies, but is typically non-zero for success to allow easy to read code...

If a function can set the @error flag, you should always check it before using a return value - if @error indicates an error then the function return value is generally undefined...


User Defined Functions

Array user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <Array.au3>.

User Defined Function | Description
_Array1DToHistogram | Transform a 1D array to Histogram
_ArrayAdd | Adds a specified value at the end of an existing 1D or 2D array
_ArrayBinarySearch | Uses the binary search algorithm to search through a 1D or 2D array
_ArrayColDelete | Deletes a specified column from a 2D array
_ArrayColInsert | Inserts a specified column into a 1D or 2D array
_ArrayCombinations | Returns an array of the combinations of a set of elements from a selected 1D array
_ArrayConcatenate | Concatenate two arrays - either 1D or 2D with the same number of columns
_ArrayDelete | Deletes the specified element(s) from the specified 1D or 2D array
_ArrayDisplay | Displays a 1D or 2D array in a ListView
_ArrayExtract | Extracts an array from the specified element(s) of a 1D or 2D array
_ArrayFindAll | Find the indices of all ocurrences of a search query between two points in a 1D or 2D array using _ArraySearch()
_ArrayInsert | Insert a new value at the specified position of a 1D or 2D array
_ArrayMax | Returns the highest value held in a 1D or 2D array
_ArrayMaxIndex | Returns the index where the highest value occurs in a 1D or 2D array
_ArrayMin | Returns the lowest value held in a 1D or 2D array
_ArrayMinIndex | Returns the index where the lowest value occurs in a 1D or 2D array
_ArrayPermute | Returns an array of the Permutations of all Elements in a 1D array
_ArrayPop | Returns the last element of an array, deleting that element from the array at the same time
_ArrayPush | Add new values without increasing array size by inserting at the end the new value and deleting the first one or vice versa
_ArrayReverse | Takes the given array and reverses the order in which the elements appear in a 1D array
_ArraySearch | Finds an entry within a 1D or 2D array. Similar to _ArrayBinarySearch(), except that the array does not need to be sorted
_ArrayShuffle | Shuffles selected rows of 1D or 2D arrays - can be limited to a specific column in 2D arrays
_ArraySort | Sort a 1D or 2D array on a specific index using the dualpivotsort/quicksort/insertionsort algorithms
_ArraySwap | Swaps elements of a 1D array and full or part rows/columns of a 2D array
_ArrayToClip | Sends the contents of a 1D or 2D array to the clipboard, each element separated by a specified delimiter
_ArrayToString | Places the elements of a 1D or 2D array into a single string, separated by the specified delimiters
_ArrayTranspose | Transposes a 1D or 2D array (swaps rows and columns)
_ArrayTrim | Trims a certain number of characters from all elements in a 1D or 2D array
_ArrayUnique | Returns the Elements from a column of a 1D or 2D array, removing all duplicates


Function _ArrayAdd

Function Reference

_ArrayAdd

Adds a specified value at the end of an existing 1D or 2D array

#include <Array.au3>
_ArrayAdd ( ByRef $aArray, $vValue [, $iStart = 0 [, $sDelim_Item = "|" [, $sDelim_Row = @CRLF [, $iForce = $ARRAYFILL_FORCE_DEFAULT]]]] )

Parameters

$aArray | Array to modify
$vValue | Value(s) to add - can be a single item, a delimited string or an array
$iStart | [optional] Column in which addition is to begin (2D array only)
$sDelim_Item | [optional] Delimiter used if a string is to be split into items
$sDelim_Row | [optional] Delimiter used if a string is to be split into rows (2D only)
$iForce | [optional] Maintains default behaviour, ARRAYFILL_FORCE_DEFAULT (0) Forces $vValue addition as a single item, $ARRAYFILL_FORCE_SINGLEITEM (1) Or forces datatype for all added items $ARRAYFILL_FORCE_INT (2) $ARRAYFILL_FORCE_NUMBER (3) $ARRAYFILL_FORCE_PTR (4) $ARRAYFILL_FORCE_HWND (5) $ARRAYFILL_FORCE_STRING (6) See Remarks for more details

Return Value

Success: | the index of last added item.
Failure: | -1 and sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array 2 - $aArray is not a 1 or 2 dimensional array 3 - $vValue has too many columns to fit into $aArray 4 - $iStart outside array bounds (2D only) 5 - Number of dimensions for $avArray and $vValue arrays do not match

Remarks

Addition mode depends on $vValue type, but using $iForce can affect this. Default behaviour is as follows:

1D arrays:
Single item - adds 1 element
$sDelim_Item delimited string - adds as many elements as items
0-based 1D array - adds as many elements as items

2D arrays:
$sDelim_Item delimited string - adds 1 row, columns filled if enough items
$sDelim_Row delimited string - adds as many rows as items, only 1 column filled
$sDelim_Item & Row delimited string - adds rows and items, depending on split points
0-based 2D array - adds as many rows/columns as in array

An empty string ("") is added if there are insufficient items specified in $vValue. Excess items are ignored.

Setting the $iForce parameter can change the default insertion behaviour or amend the datatype for added items. It can be set as follows:
- $ARRAYFILL_FORCE_DEFAULT (default):
- Items are split as described above. Single items and array elements retain their datatypes - delimited strings are added as strings.
- $ARRAYFILL_FORCE_SINGLEITEM:
- If $aArray is 1D, $vValue is added as a single element.
- if $aArray is 2D the parameter is ignored.
- $ARRAYFILL_FORCE_INT, $ARRAYFILL_FORCE_NUMBER, $ARRAYFILL_FORCE_PTR, $ARRAYFILL_FORCE_HWND, $ARRAYFILL_FORCE_STRING
- If $vValue is a single item, it is forced into the defined datatype - by default it would retain its existing datatype.
- If $vValue is a delimited string, all items are forced into the specified datatype - by default they would be added to the array as strings. If different datatypes are required for the items they must be passed as an array.
- If $vValue is an array, the parameter is ignored and the array elements are added retaining their existing datatypes.

If $iForce is set to any other value it is ignored.

Related

_ArrayConcatenate, _ArrayDelete, _ArrayInsert, _ArrayPop, _ArrayPush

Example

Example 1

#include <Array.au3>
#include <MsgBoxConstants.au3>

Local $aArray_Base[2] = ["Org Item 0", "Org item 1"]
_ArrayDisplay($aArray_Base, "1D - Base array")

; Add a single item
Local $aArray = $aArray_Base
Local $sSingleFill = "New Item 2"
_ArrayAdd($aArray, $sSingleFill)
_ArrayDisplay($aArray, "1D - Single")

; Add a delimited string - each item adds new element
$aArray = $aArray_Base
Local $sFill = ""
For $i = 1 To 5
    $sFill &= "New Item " & $i + 1 & "|"
Next
$sFill = StringTrimRight($sFill, 1)
MsgBox($MB_SYSTEMMODAL, "Delimited string to add", $sFill)
_ArrayAdd($aArray, $sFill)
_ArrayDisplay($aArray, "1D - Delim string")

; Add a 1D array - each element adds new element
$aArray = $aArray_Base
Local $aFill[5]
For $i = 0 To 4
    $aFill[$i] = "New Item " & $i + 2
Next
_ArrayDisplay($aFill, "Array to add")
_ArrayAdd($aArray, $aFill)
_ArrayDisplay($aArray, "1D - 1D array")

Example 2

#include <Array.au3>

Local $aArray, $sFill

Local $aArray_Base[2][2] = [["Item 0 - 0", "Item 0 - 1"], ["Item 1 - 0", "Item 1 - 1"]]
_ArrayDisplay($aArray_Base, "2D - Base array")

; Add item delimited string
$aArray = $aArray_Base
$sFill = "New Item 2 - 0|New Item 2 - 1"
_ArrayAdd($aArray, $sFill)
_ArrayDisplay($aArray, "2D - Item delimited")

; Add row delimited string - load in col 1
$aArray = $aArray_Base
$sFill = "New Item 2 - 1" & @CRLF & "New Item 3 - 1"
_ArrayAdd($aArray, $sFill, 1)
_ArrayDisplay($aArray, "2D - Row Delimited")

; Add item & row delimited string
$aArray = $aArray_Base
$sFill = "New Item 2 - 0|New Item 2 - 1" & @CRLF & "New Item 3 - 0|New Item 3 - 1"
_ArrayAdd($aArray, $sFill)
_ArrayDisplay($aArray, "2D - Item & row Delimited")

; Add a 2D array
$aArray = $aArray_Base
Local $aFill[2][2] = [["New Item 2 - 1", "New Item 2 - 2"], ["New Item 3 - 1", "New Item 3 - 2"]]
_ArrayAdd($aArray, $aFill)
_ArrayDisplay($aArray, "2D - 2D Array")

; Add a 2D array - Single item/column - load in col 1
$aArray = $aArray_Base
Local $aFill[2][1] = [["New Item 2 - 1"], ["New Item 3 - 1"]]
_ArrayAdd($aArray, $aFill, 1)
_ArrayDisplay($aArray, "2D - 2D Array")

Example 3

#include <Array.au3>
#include <MsgBoxConstants.au3>

Local $aArray_Base[2] = ["Org Item 0", "Org item 1"]
Local $aArray
Local $sFill = ""
For $i = 2 To 6
    $sFill &= $i & "|" ; Note variables added as number datatype here
Next
$sFill = StringTrimRight($sFill, 1)
MsgBox($MB_SYSTEMMODAL, "Delimited string to add", $sFill)

; Add items by delimited string
$aArray = $aArray_Base
_ArrayAdd($aArray, $sFill)
_ArrayDisplay($aArray, "Converted to string")
; But converted to string datatype when inserted
MsgBox($MB_SYSTEMMODAL, "Result", "Data:" & @TAB & $aArray[6] & @CRLF & "Datatype:" & @TAB & VarGetType($aArray[6]))

; Add items by delimited string
$aArray = $aArray_Base
; Now force datatype to Number
_ArrayAdd($aArray, $sFill, Default, Default, Default, $ARRAYFILL_FORCE_NUMBER)
_ArrayDisplay($aArray, "Forced to number")
; And datatype is forced to required type
MsgBox($MB_SYSTEMMODAL, "Result", "Data:" & @TAB & $aArray[6] & @CRLF & "Datatype:" & @TAB & VarGetType($aArray[6]))


Function _ArrayBinarySearch

Function Reference

_ArrayBinarySearch

Uses the binary search algorithm to search through a 1D or 2D array

#include <Array.au3>
_ArrayBinarySearch ( Const ByRef $aArray, $vValue [, $iStart = 0 [, $iEnd = 0 [, $iColumn = 0]]] )

Parameters

$aArray | Array to search
$vValue | Value to find
$iStart | [optional] Index of array to start searching at
$iEnd | [optional] Index of array to stop searching at
$iColumn | [optional] Column of array to search

Return Value

Success: | the index that value was found at.
Failure: | -1 and sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array 2 - $vValue outside of array min/max values 3 - $vValue was not found in array 4 - $iStart is greater than $iEnd 5 - $aArray is not a 1D or 2D array 6 - $aArray is empty 7 - $iColumn outside array bounds

Remarks

When performing a binary search on an array of items, the array (specified column if 2D) MUST be sorted before the search is done. Otherwise undefined results will be returned.

Related

_ArrayFindAll, _ArraySearch

Example

Example 1

#include <Array.au3>
#include <MsgBoxConstants.au3>

Local $iIndex

Local $aArray[5][2]
For $i = 0 To 4
    For $j = 0 To 1
        $aArray[$i][$j] = "#" & $i & $j
    Next
Next
_ArrayDisplay($aArray, "Array")

; Search col 0
$iIndex = _ArrayBinarySearch($aArray, "#10", 0, 0, 0)
MsgBox($MB_SYSTEMMODAL, "Index", $iIndex)

; Search col 1
$iIndex = _ArrayBinarySearch($aArray, "#31", 0, 0, 1)
MsgBox($MB_SYSTEMMODAL, "Index", $iIndex)

Example 2

; using an array returned by StringSplit()

#include <Array.au3>
#include <MsgBoxConstants.au3>

Local $avArray = StringSplit("a,b,d,c,e,f,g,h,i", ",")

; sort the array to be able to do a binary search
_ArraySort($avArray, 0, 1) ; start at index 1 to skip $avArray[0]

; display sorted array
_ArrayDisplay($avArray, "$avArray AFTER _ArraySort()")

; start at index 1 to skip $avArray[0]
Local $iKeyIndex = _ArrayBinarySearch($avArray, "c", 1)
If Not @error Then
    MsgBox($MB_SYSTEMMODAL, 'Entry found', ' Index: ' & $iKeyIndex)
Else
    MsgBox($MB_SYSTEMMODAL, 'Entry Not found', ' Error: ' & @error)
EndIf


Function _ArrayColDelete

Function Reference

_ArrayColDelete

Deletes a specified column from a 2D array

#include <Array.au3>
_ArrayColDelete ( ByRef $aArray, $iColumn [, $bConvert = False] )

Parameters

$aArray | Array to modify
$iColumn | Column to delete
$bConvert | [optional] If True then if only one column remains the array is converted to 1D

Return Value

Success: | the number of columns remaining.
Failure: | -1 and sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array 2 - $aArray is not a 2D array 3 - $iColumn is outside array bounds

Related

_ArrayColInsert

Example

#include <Array.au3>

Local $aArray[4][3]
For $i = 0 To 3
    For $j = 0 To 2
        $aArray[$i][$j] = $i & $j
    Next
Next
_ArrayDisplay($aArray, "Original")

_ArrayColDelete($aArray, 2)
_ArrayDisplay($aArray, "Col 2 Deleted")

; Copy 2 col array
Local $aArray_2Col = $aArray

; Default 1 column left as 2D array
_ArrayColDelete($aArray, 0)
_ArrayDisplay($aArray, "Col 0 del - 2D array")

; Convert 1 column array to 1D
_ArrayColDelete($aArray_2Col, 0, True)
_ArrayDisplay($aArray_2Col, "Col 0 del - 1D array")


Function _ArrayColInsert

Function Reference

_ArrayColInsert

Inserts a specified column into a 1D or 2D array

#include <Array.au3>
_ArrayColInsert ( ByRef $aArray, $iColumn )

Parameters

$aArray | Array to modify
$iColumn | Column to insert - if array is 1D it is automatically converted to 2D

Return Value

Success: | the number of columns remaining.
Failure: | -1 and sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array 2 - $aArray is not a 1D or 2D array 3 - $iColumn is less than 0 or greater than upper array bound plus 1

Related

_ArrayColDelete

Example

#include <Array.au3>

Local $aArray[4] = [0, 1, 2, 3]
_ArrayDisplay($aArray, "Original")

_ArrayColInsert($aArray, 0)
; Now a 2D array
_ArrayDisplay($aArray, "Col 0 inserted")

_ArrayColInsert($aArray, 1)
_ArrayDisplay($aArray, "Col 1 inserted")

_ArrayColInsert($aArray, 3)
_ArrayDisplay($aArray, "Col 3 inserted")


Function _ArrayCombinations

Function Reference

_ArrayCombinations

Returns an array of the combinations of a set of elements from a selected 1D array

#include <Array.au3>
_ArrayCombinations ( Const ByRef $aArray, $iSet [, $sDelimiter = ""] )

Parameters

$aArray | The Array to use
$iSet | Size of the combinations set
$sDelimiter | [optional] String result separator, default is "" for none

Return Value

Success: | an array of Combinations The first element ($aArray[0]) contains the number of strings returned. The remaining elements ($aArray[1], $aArray[2], etc.) contain the Combinations.
Failure: | sets the @error flag to non-zero.
@error: | 1 - The Input Must be an Array 2 - $aArray is not a 1D array

Remarks

The input array must be 0-based, i.e. no counter in $aArray[0]. Based on an algorithm by Kenneth H. Rosen.

Related

_ArrayPermute

Example

; Declare a 1-dimensional array, and create an array showing the Possible Combinations

#include <Array.au3>

Local $aArray[5] = [1, 2, 3, 4, 5]

For $i = 1 To UBound($aArray)
    Local $aArrayCombo = _ArrayCombinations($aArray, $i, ",")
    _ArrayDisplay($aArrayCombo, "iSet = " & $i)
Next


Function _ArrayConcatenate

Function Reference

_ArrayConcatenate

Concatenate two arrays - either 1D or 2D with the same number of columns

#include <Array.au3>
_ArrayConcatenate ( Const ByRef $aArrayTarget, ByRef $aArraySource [, $iStart = 0] )

Parameters

$aArrayTarget | The array to which the source array will be concatenated
$aArraySource | The array to concatenate to the target array
$iStart | [optional] index of the first Source array entry (Default = 0)

Return Value

Success: | the number of elemets/rows in the new target array
Failure: | -1 and sets the @error flag to non-zero.
@error: | 1 - $aArrayTarget is not an array 2 - $aArraySource is not an array 3 - $aArrayTarget is not a 1D or 2D array 4 - $aArrayTarget and $aArraySource 1D/2D mismatch 5 - $aArrayTarget and $aArraySource column number mismatch (2D only) 6 - $iStart outside array bounds

Remarks

The $iStart parameter is useful when concatenating arrays which have a count in the [0] element.

Related

_ArrayAdd

Example

#include <Array.au3>

Local $aArrayTarget[5] = ["0", "1", "2", "3", "4"]
Local $aArraySource[5] = ["5", "6", "7", "8", "9"]

_ArrayDisplay($aArrayTarget, "1D Target")
_ArrayDisplay($aArraySource, "1D Source")
_ArrayConcatenate($aArrayTarget, $aArraySource)
_ArrayDisplay($aArrayTarget, "1D Target and Source concatenated")

Local $aArrayTarget[4][3]
For $i = 0 To 3
    For $j = 0 To 2
        $aArrayTarget[$i][$j] = $i & $j
    Next
Next

Local $aArraySource[4][3]
For $i = 0 To 3
    For $j = 0 To 2
        $aArraySource[$i][$j] = (4 + $i) & $j
    Next
Next

_ArrayDisplay($aArrayTarget, "2D Target")
_ArrayDisplay($aArraySource, "2D Source")
_ArrayConcatenate($aArrayTarget, $aArraySource)
_ArrayDisplay($aArrayTarget, "2D Target and Source concatenated")


Function _ArrayDelete

Function Reference

_ArrayDelete

Deletes the specified element(s) from the specified 1D or 2D array

#include <Array.au3>
_ArrayDelete ( ByRef $aArray, $vRange )

Parameters

$aArray | Array to modify
$vRange | Element(s) to delete - either a single index, a range string or a 1D array with a count in the [0] element (see example for details)

Return Value

Success: | the new size of the array (see remarks)
Failure: | -1 and sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array 2 - $aArray is not a 1D or 2D array 3 - $vRange is not a valid range string 4 - $vRange is not a 1D array or has only 1 element 5 - $vRange content is outside array bounds

Remarks

$vRange can be a string containing the rows which are to be deleted. It can be a single number or a range denoted by the first and last lines separated by a hyphen (-) - multiple items are separated by a semi-colon (;).

$vRange can also be a 1D array listing all rows to be deleted with the count in the [0] element].

In either case, the rows need not be in ascending order and can be duplicated.

Related

_ArrayAdd, _ArrayInsert

Example

#include <Array.au3>

Local $aArray[5] = [0, 1, 2, 3, 4]

_ArrayDisplay($aArray, "Original")
_ArrayDelete($aArray, 2)
_ArrayDisplay($aArray, "Element 2 deleted")

Local $aArray_Base[25][4]
For $i = 0 To 24
    For $j = 0 To 3
        $aArray_Base[$i][$j] = $i & "-" & $j
    Next
Next

; Single row
$aArray = $aArray_Base
_ArrayDisplay($aArray, "BEFORE deletion")
_ArrayDelete($aArray, 7)
_ArrayDisplay($aArray, "SINGLE ROW deleted")

; Range string
$aArray = $aArray_Base
Local $sRange = "0;11-15;24"
_ArrayDisplay($aArray, "BEFORE deletion")
_ArrayDelete($aArray, $sRange)
ConsoleWrite(" " & @error & @CRLF)
_ArrayDisplay($aArray, "RANGE STRING deleted")

; 1D array
$aArray = $aArray_Base
Local $aDel[4] = [3, 5, 11, 13]
_ArrayDisplay($aArray, "BEFORE deletion")
_ArrayDelete($aArray, $aDel)
_ArrayDisplay($aArray, "RANGE ARRAY deleted")


Function _ArrayDisplay

Function Reference

_ArrayDisplay

Displays a 1D or 2D array in a ListView

#include <Array.au3>
_ArrayDisplay ( Const ByRef $aArray [, $sTitle = "ArrayDisplay" [, $sArrayRange = "" [, $iFlags = 0 [, $vUser_Separator = Default [, $sHeader = Default [, $iMax_ColWidth = Default [, $iAlt_Color = Default [, $hUser_Function = ""]]]]]]]] )

Parameters

$aArray | Array to display
$sTitle | [optional] Title for dialog. Default = "ArrayDisplay".
$sArrayRange | [optional] Range of rows/columns to display. Default ("") = entire array. (See below for details)
$iFlags | [optional] Determine UDF options. Add required values together 0 = (default) Column text alignment - left 1 = Transposes the array 2 = Column text alignment - right 4 = Column text alignment - center 8 = Verbose - display MsgBox on error and splash screens during processing of large arrays 16 = Only 'Copy' buttons displayed 32 = No buttons displayed 64 = No 'Row' column displayed
$vUser_Separator | [optional] Sets column display option when copying data to clipboard. Character = Delimiter between columns. Number = Fixed column width - longer items will be truncated. Default = Current separator character (usually "|").
$sHeader | [optional] Column names in header (string of names separated by current separator character - usually "|"). Default see Remarks.
$iMax_Colwidth | [optional] Max width to which a ListView column will expand to show content. Default = 350 pixels.
$iAlt_Color | [optional] ListView alternate rows set to defined color. Default = all rows ListView background color.
$hUser_Function | [optional] A variable assigned to the user defined function to run. Default = none. See remarks.

Return Value

Success: | 1
Failure: | 0 and @error flag set as follows:
@error: | 1 - $aArray is not an array 2 - $aArray has too many dimensions (only 1D and 2D supported)

Remarks

If the function is passed a non-array variable or an array of more than 2 dimensions the function returns an error and the script continues. If the "verbose" parameter is set in $iFlags a MsgBox will be displayed which offers the chance to exit the script immediately or to continue the script with the normal error return.

Only 65525 rows of an array can be displayed - this is an AutoIt limitation on the total number of controls that can be displayed in a GUI - and an abitrary display limit of 250 columns has also been set. If the user tries to display an array larger than these limits an "*" is added to the truncated dimension value which will be displayed in red text. Note that using $iArrayRange to determine the elements to be displayed allows arrays larger than the display limits to be displayed in sections.

The $sArrayRange parameter syntax is as follows:

"7" | Show rows 0-7 with all columns
"7:" | Show rows 7-end with all columns
"|7" | Show all rows with columns 0-7
"|7:" | Show all rows with columns 7-end
"7|7" | Show rows 0-7 with columns 0-7
"5:7" | Show rows 5-7 with all columns
"|5:7" | Show all rows with columns 5-7
"7|5:7" | Show rows 0-7 with columns 5-7
"5:7|7" | Show rows 5-7 with columns 0-7
"5:7|5:7" | Show rows 5-7 with columns 5-7

Any column values are ignored for 1D arrays.

$sHeader names (separated by the current separator character) will be used for as many columns as there are names. If no, or not enough, custom names are specified then the default header of "Row|Col0" for 1D arrays or "Row|Col0|Col1|...|Col n" for 2D is substituted.

The 4 buttons at the bottom of the dialog have the following functions:
Copy Data & Hdr/Row | Copy the array or the selected row(s) to the clipboard adding full header and row identification.
Copy Data Only | Copy the array or the selected row(s) to the clipboard with no header or row identification.
Run User Func | Run the user-defined function passed in $sUser_Function. This function is entirely separate from the UDF and must be created and coded by the user to accept 2 (and only 2) parameters which will be provided by the UDF itself: the full array being displayed and a 1D array holding the selected rows indices with a count in the [0] element. These parameters can then be used inside the user function as required. The button is not displayed if no function is specified.
Exit script | Exit the script immediately.

The $iFlags parameter enables some or all of these buttons to be hidden.

If all buttons are displayed the array dimensions are displayed at lower left. They are in red text if any the following occur: row/column truncation, array transposition, or displaying only a range of elements - a tooltip displays the particular occurence(s).

If the "verbose" parameter is set in $iFlags a splash dialog is displayed during initial processing when the array to display has more than 10000 elements. A similar dialog is displayed when the "Copy Data" buttons are used on a 10000+ element display - if this is likely to occur consideration should be given to using a "User Function" to store the array for later processing.

An array element containing another array is displayed as {Array}.

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()

    ; Create 1D array to display
    Local $aArray_1D[5] = ["Item 0", "Item 1", "A longer Item 2 to show column expansion", "Item 3", "Item 4"]

    _ArrayDisplay($aArray_1D, "1D display")
    _ArrayDisplay($aArray_1D, "1D display transposed - 'Copy' buttons only", Default, 1 + 16) ; No buttons displayed

    ; Create 2D array to display
    Local $aArray_2D[75][255]
    For $i = 0 To UBound($aArray_2D) - 1
        For $j = 0 To UBound($aArray_2D, 2) - 1
            $aArray_2D[$i][$j] = "Item " & StringFormat("%02i", $i) & StringFormat("%02i", $j)
        Next
    Next

    _ArrayDisplay($aArray_2D, "2D display") ; Note columns truncated
    _ArrayDisplay($aArray_2D, "2D display transposed", Default, 1) ; Note all array elements displayed

    ReDim $aArray_2D[20][10]
    $aArray_2D[5][5] = "A longer item to show column expansion"
    _ArrayDisplay($aArray_2D, "Expanded column - custom titles - alternate line color - no buttons or 'Row' column", Default, 32 + 64, Default, "AA|BB|CC|DD|EE|FF|GG|HH|II|JJ", Default, 0xDDFFDD)

    ; Assign the user function to a variable to pass as a parameter
    Local $hUserFunction = _UserFunc

    $aArray_2D[5][5] = "Column alignment set to right"
    _ArrayDisplay($aArray_2D, "Range set - right align - copy column width - user function", "3:7|4:9", 2, 15, "AA|BB|CC|DD|EE|FF", Default, Default, $hUserFunction)
    _ArrayDisplay($aArray_2D, "Range set - right align - copy column width - transposed", "3:7|4:9", 3, 15, "AA|BB|CC|DD|EE|FF") ; Note no col names as transposed

    ; Create non-array variable to force error - MsgBox displayed as $iFlags set
    Local $vVar = 0
    _ArrayDisplay($vVar, "MsgBox on Error", Default, 8)

EndFunc   ;==>Example

; Note that the user function MUST have TWO parameters even if you do not intend to use both of them
Func _UserFunc($aArray_2D, $aSelected)

    ; But if a parameter is not used do this to prevent an Au3Check warning
    #forceref $aArray_2D

    _ArrayDisplay($aSelected, "Selected cols")

EndFunc   ;==>_UserFunc


Function _ArrayExtract

Function Reference

_ArrayExtract

Extracts an array from the specified element(s) of a 1D or 2D array

#include <Array.au3>
_ArrayExtract ( Const ByRef $aArray [, $iStart_Row = -1 [, $iEnd_Row = -1 [, $iStart_Col = -1 [, $iEnd_Col = -1]]]] )

Parameters

$aArray | Array from which extraction should occur
$iStart_Row | [optional] First row of the extracted array
$iEnd_Row | [optional] Last row of the extracted array
$iStart_Col | [optional] First column of the extracted array (2D only)
$iEnd_Col | [optional] Last column of the extracted array (2D only)

Return Value

Success: | 1
Failure: | -1 and sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array 2 - $aArray is not a 1D or 2D array 3 - $iStart_Row or $iEnd_Row outside array bounds 4 - $iStart_Row greater then $iEnd_Row 5 - $iStart_Col or $iEnd_Col outside array bounds 6 - $iStart_Col greater then $iEnd_Col

Related

_ArrayAdd, _ArrayInsert

Example

#include <Array.au3>

Local $aArray[4][4]
For $i = 0 To 3
    For $j = 0 To 3
        $aArray[$i][$j] = $i & $j
    Next
Next
_ArrayDisplay($aArray, "Original")
Local $aExtract = _ArrayExtract($aArray, 1, 2, 2, 3)
_ArrayDisplay($aExtract, "Row 1-2 cols 2-3")


Function _ArrayFindAll

Function Reference

_ArrayFindAll

Find the indices of all ocurrences of a search query between two points in a 1D or 2D array using _ArraySearch()

#include <Array.au3>
_ArrayFindAll ( Const ByRef $aArray, $vValue [, $iStart = 0 [, $iEnd = 0 [, $iCase = 0 [, $iCompare = 0 [, $iSubItem = 0 [, $bRow = False]]]]]] )

Parameters

$aArray | The array to search
$vValue | What to search $aArray for
$iStart | [optional] Index of array to start search
$iEnd | [optional] Index of array to end search
$iCase | [optional] If set to 1, search is case sensitive
$iCompare | [optional] 0 Casting of variables to the same type (default), "string" = 0, "" = 0 or "0" = 0 match (If $iCase = 0) 1 executes a partial search 2 comparison match if variables have same type and same value 3 compares using a regular expression pattern provided as $vValue
$iSubItem | [optional] Sub-index to search on in 2D arrays
$bRow | [optional] If True then $iSubItem sets the row to search - False (default) searches columns

Return Value

Success: | an array of all index numbers in array containing $vValue.
Failure: | sets the @error flag to non-zero (see _ArraySearch() description for @error).

Remarks

The values of $iCompare can not be combined together.

Related

_ArrayBinarySearch, _ArraySearch

Example

#include <Array.au3>

Local $aArray[5] = [0, 1, 2, 1, 0]
_ArrayDisplay($aArray, "1D array")
Local $aiResult = _ArrayFindAll($aArray, 0)
_ArrayDisplay($aiResult, "Found")

Local $aArray[5][5] = [[0, 1, 2, 1, 0], _
        [4, 5, 5, 4, 2], _
        [4, 1, 3, 1, 3], _
        [0, 3, 2, 1, 0], _
        [1, 5, 5, 4, 1]]
_ArrayDisplay($aArray, "2D array")

Local $aResult = _ArrayFindAll($aArray, 0, Default, Default, Default, Default, 4)
_ArrayDisplay($aResult, "Found in Column 4")

$aResult = _ArrayFindAll($aArray, 1, Default, Default, Default, Default, 2, True)
_ArrayDisplay($aResult, "Found in Row 2")


Function _ArrayInsert

Function Reference

_ArrayInsert

Insert a new value at the specified position of a 1D or 2D array

#include <Array.au3>
_ArrayInsert ( ByRef $aArray, $vRange [, $vValue = "" [, $iStart = 0 [, $sDelim_Item = "|" [, $sDelim_Row = @CRLF [, $iForce = $ARRAYFILL_FORCE_DEFAULT]]]]] )

Parameters

$aArray | Array to modify
$vRange | Position(s) at which to insert item(s) - see Remarks for format
$vValue | [optional] Value(s) to add - can be a single variable, a delimited string or a 1D array
$iStart | [optional] Column in which insert is to begin (2D array only)
$sDelim_Item | [optional] Delimiter used if a string is to be split into items
$sDelim_Row | [optional] Delimiter used if a string is to be split into rows (2D only)
$iForce | [optional] Maintains default behaviour, $ARRAYFILL_FORCE_DEFAULT (0) Forces $vValue addition as a single item, $ARRAYFILL_FORCE_SINGLEITEM (1) Or forces datatype for all added items $ARRAYFILL_FORCE_INT (2) $ARRAYFILL_FORCE_NUMBER (3) $ARRAYFILL_FORCE_PTR (4) $ARRAYFILL_FORCE_HWND (5) $ARRAYFILL_FORCE_STRING (6) See Remarks for more details

Return Value

Success: | the new size of the array.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array 2 - $aArray is not a 1D or 2D array 3 - $vRange incorrectly formatted (incorrect character or unordered) 4 - $vRange is not a 1D array or has only 1 element 5 - $vRange limits outside array bounds 6 - $iStart outside array bounds (2D only) 7 - $vValue not 2D array (2D only) 8 - $vValue has too many columns to fit into $aArray

Remarks

$vRange can be a string containing the rows above which a row is to to be inserted. It can be a single number or a range denoted by the first and last lines separated by a hyphen (-) - multiple items are separated by a semi-colon (;).

$vRange can also be a 1D array containing the rows above which a row is to to be inserted with the count in the [0] element].

In either case, the rows must be in ascending order but can be duplicated.

If $vValue is a delimited string all items are inserted into the array as strings. This can be over-ridden by using the $hDataType parameter which forces the items into the required datatype. Note that all items in the delimited string are converted - if the items are of different datatypes then they must be passed as an array so that their specific datatype is conserved.

Insertion mode depends on $vValue type, but using $iForce can affect this. Default behaviour is as follows:

1D arrays:
Single item - inserts 1 element containing $vValue
$sDelim_Item delimited string - matches insertion lines to items in the string
0-based 1D array - matches insertion lines to elements in the array

2D arrays:
Single item - inserts 1 row containing $vValue in the first column
$sDelim_Item delimited string - inserts 1 row at first insertion line, columns filled if enough items
$sDelim_Row delimited string - matches insertion lines to items in the string, only 1 column filled
Double-delimited string - matches insertion lines to string split on $sDelim_Row, columns to string split on $sDelim_Item
0-based 2D array - matches insertion lines to rows in the array, columns to columns in the array

An empty string ("") is added if there are insufficient items specified in $vValue. Excess items are ignored.

Setting the $iForce parameter can change the default insertion behaviour or amend the datatype for added items. It can be set as follows:
- $ARRAYFILL_FORCE_DEFAULT (default):
- Items are split as described above. Single items and array elements retain their datatypes - delimited strings are added as strings.
- $ARRAYFILL_FORCE_SINGLEITEM:
- If $aArray is 1D, $vValue is inserted as a single element.
- if $aArray is 2D the parameter is ignored.
- $ARRAYFILL_FORCE_INT, $ARRAYFILL_FORCE_NUMBER, $ARRAYFILL_FORCE_PTR, $ARRAYFILL_FORCE_HWND, $ARRAYFILL_FORCE_STRING
- If $vValue is a single item, it is forced into the defined datatype - by default it would retain its existing datatype.
- If $vValue is a delimited string, all items are forced into the specified datatype - by default they would be inserted into the array as strings. If different datatypes are required for the items they must be passed as an array.
- If $vValue is an array, the parameter is ignored and the array elements are inserted retaining their existing datatypes.

If $iForce is set to any other value it is ignored.

Related

_ArrayAdd, _ArrayDelete, _ArrayPop, _ArrayPush

Example

Example 1

#include <Array.au3>

Local $aArray_Base[10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
_ArrayDisplay($aArray_Base, "1D - Original")

; Insert single item
Local $aArray = $aArray_Base
_ArrayInsert($aArray, 2, "Insert above 2")
_ArrayDisplay($aArray, "1D - Single item")

; Insert delimited string using range array
$aArray = $aArray_Base
Local $aRange[4] = [3, 3, 5, 9]
Local $sFill = "Insert above 3|Insert above 5|Insert above 9"
_ArrayInsert($aArray, $aRange, $sFill)
_ArrayDisplay($aArray, "1D - Delim String")

; Insert 1D array using range string
$aArray = $aArray_Base
Local $aFill[4] = ["Insert above 2", "Insert above 6.1", "Insert above 6.2", "Insert above 7"]
_ArrayInsert($aArray, "2;6;6;7", $aFill)
_ArrayDisplay($aArray, "1D - 1D array")

; Insert 1D array as single item
$aArray = $aArray_Base
Local $aFill[4] = ["Insert 0", "Insert 1", "Insert 2", "Insert 3"]
_ArrayInsert($aArray, "2", $aFill, Default, Default, Default, $ARRAYFILL_FORCE_SINGLEITEM)
_ArrayDisplay($aArray, "1D - Single Item")
_ArrayDisplay(($aArray)[2], "Internal array")

Example 2

#include <Array.au3>

Local $aArray_Base[10][3]
For $i = 0 To 9
    For $j = 0 To 2
        $aArray_Base[$i][$j] = $i & " - " & $j
    Next
Next
_ArrayDisplay($aArray_Base, "2D - Original")

; Insert single item
Local $aArray = $aArray_Base
_ArrayInsert($aArray, 7, "Insert above 7-0")
_ArrayDisplay($aArray, "2D - Single item")

; Insert single item in defined column
$aArray = $aArray_Base
_ArrayInsert($aArray, 3, "Insert above 3-1", 1)
_ArrayDisplay($aArray, "2D - Defined column")

; Insert item delimited string - inserted as 1 row - other rows filled with ""
$aArray = $aArray_Base
Local $sFill = "Above 3-0|Above 3-1|Above 3-2"
_ArrayInsert($aArray, "3;5;9", $sFill)
_ArrayDisplay($aArray, "2D - Item delim string")

; Insert row delimited string using range array - inserted as 3 rows, other cols filled with ""
$aArray = $aArray_Base
Local $aRange[4] = [3, 3, 5, 9]
$sFill = "Above 3-2" & @CRLF & "Above 5-2" & @CRLF & "Above 9-2"
_ArrayInsert($aArray, $aRange, $sFill, 2) ; Insert in column 2
_ArrayDisplay($aArray, "2D - Item delim string")

; Insert item as row delimited string - inserted as 4 rows
$aArray = $aArray_Base
$sFill = "Above 3-0|3-1|3-2" & @CRLF & "Above 5a|5-1a|5-2a" & @CRLF & "Above 5b|5-1b|5-2b" & @CRLF & "Above 9|9-1|9-2"
_ArrayInsert($aArray, "3;5;5;9", $sFill)
_ArrayDisplay($aArray, "2D - Item & row delim string")

; Insert 2D array
$aArray = $aArray_Base
Local $aFill_1D[3][3] = [["Above 2", "2-1", "2-2"], ["Above 3", "3-1", "3-2"], ["Above 4", "4-1", "4-2"]]
_ArrayInsert($aArray, "2-4", $aFill_1D)
_ArrayDisplay($aArray, "2D - 2D Array")

Example 3

#include <Array.au3>
#include <MsgBoxConstants.au3>

Local $aArray_Base[2][2] = [["Org Item 0 - 0", "Org Item 0 - 1"], ["Org Item 1 - 0", "Org Item 1 - 1"]]
Local $aArray
Local $sFill = 1 & @CRLF & 2 ; Note added as number datatype here
MsgBox($MB_SYSTEMMODAL, "Delimited string to add", $sFill)

; Add items by delimited string
$aArray = $aArray_Base
 _ArrayInsert($aArray, "0;1", $sFill)
_ArrayDisplay($aArray, "Converted to string")
; But converted to string datatype here
MsgBox($MB_SYSTEMMODAL, "Result", "Data:" & @TAB & $aArray[2][0] & @CRLF & "Datatype:" & @TAB & VarGetType($aArray[2][0]))

; Add items by delimited string
$aArray = $aArray_Base
; Now force datatype to be retained
Local $hDataType = Number
 _ArrayInsert($aArray, "0;1", $sFill, Default, Default, Default, $ARRAYFILL_FORCE_NUMBER)
_ArrayDisplay($aArray, "Forced to number")
; And datatype is retained
MsgBox($MB_SYSTEMMODAL, "Result", "Data:" & @TAB & $aArray[2][0] & @CRLF & "Datatype:" & @TAB & VarGetType($aArray[2][0]))


Function _ArrayMax

Function Reference

_ArrayMax

Returns the highest value held in a 1D or 2D array

#include <Array.au3>
_ArrayMax ( Const ByRef $aArray [, $iCompNumeric = 0 [, $iStart = -1 [, $iEnd = -1 [, $iSubItem = 0]]]] )

Parameters

$aArray | Array to search
$iCompNumeric | [optional] Comparison method: 0 - compare alphanumerically 1 - compare numerically
$iStart | [optional] Index of array to start search
$iEnd | [optional] Index of array to end search
$iSubItem | [optional] Column of array to search

Return Value

Success: | the maximum value in the array.
Failure: | sets the @error flag to non-zero (see _ArrayMaxIndex() description for @error).

Related

_ArrayMaxIndex, _ArrayMin, _ArrayMinIndex, _ArrayUnique

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>

Local $aArray = StringSplit("4,2,06,8,12,5", ",")

MsgBox($MB_SYSTEMMODAL, 'Max String value', _ArrayMax($aArray, 0, 1))
MsgBox($MB_SYSTEMMODAL, 'Max Numeric value', _ArrayMax($aArray, 1, 1))

Local $aArray[4][4]
For $i = 0 To 3
    For $j = 0 To 3
        $aArray[$i][$j] = Random(0, 99, 1)
    Next
Next
_ArrayDisplay($aArray, "2D Array")
MsgBox($MB_SYSTEMMODAL, 'Max Numeric value in column 2', _ArrayMax($aArray, 1, 0, 0, 2))


Function _ArrayMaxIndex

Function Reference

_ArrayMaxIndex

Returns the index where the highest value occurs in a 1D or 2D array

#include <Array.au3>
_ArrayMaxIndex ( Const ByRef $aArray [, $iCompNumeric = 0 [, $iStart = -1 [, $iEnd = -1 [, $iSubItem = 0]]]] )

Parameters

$aArray | Array to search
$iCompNumeric | [optional] Comparison method: 0 - compare alphanumerically 1 - compare numerically
$iStart | [optional] Index of array to start search
$iEnd | [optional] Index of array to end search
$iSubItem | [optional] Column of array to search

Return Value

Success: | the index of the maximum value in the array.
Failure: | -1 and sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array or is empty 2 - $aArray is not a 1D or 2D array 3 - $iStart or $iEnd outside array bounds 4 - $iStart is greater than $iEnd 5 - $aArray is empty 6 - $iSubItem outside array bounds

Related

_ArrayMax, _ArrayMin, _ArrayMinIndex

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>

Local $aArray = StringSplit("4,2,06,8,12,5", ",")

MsgBox($MB_SYSTEMMODAL, 'Max Index String value', _ArrayMaxIndex($aArray, 0, 1))
MsgBox($MB_SYSTEMMODAL, 'Max Index Numeric value', _ArrayMaxIndex($aArray, 1, 1))

Local $aArray[4][4]
For $i = 0 To 3
    For $j = 0 To 3
        $aArray[$i][$j] = Random(0, 99, 1)
    Next
Next
_ArrayDisplay($aArray, "2D Array")
MsgBox($MB_SYSTEMMODAL, 'Max Index Numeric value in column 2', _ArrayMaxIndex($aArray, 1, 0, 0, 2))


Function _ArrayMin

Function Reference

_ArrayMin

Returns the lowest value held in a 1D or 2D array

#include <Array.au3>
_ArrayMin ( Const ByRef $aArray [, $iCompNumeric = 0 [, $iStart = -1 [, $iEnd = -1 [, $iSubItem = 0]]]] )

Parameters

$aArray | Array to search
$iCompNumeric | [optional] Comparison method: 0 - compare alphanumerically 1 - compare numerically
$iStart | [optional] Index of array to start search
$iEnd | [optional] Index of array to end search
$iSubItem | [optional] Column of array to search

Return Value

Success: | the minimum value in the array.
Failure: | sets the @error flag to non-zero (see _ArrayMinIndex() description for @error).

Related

_ArrayMax, _ArrayMaxIndex, _ArrayMinIndex, _ArrayUnique

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>

Local $aArray = StringSplit("4,2,06,8,12,5", ",")

MsgBox($MB_SYSTEMMODAL, 'Min String value', _ArrayMin($aArray, 0, 1))
MsgBox($MB_SYSTEMMODAL, 'Min Numeric value', _ArrayMin($aArray, 1, 1))

Local $aArray[4][4]
For $i = 0 To 3
    For $j = 0 To 3
        $aArray[$i][$j] = Random(0, 99, 1)
    Next
Next
_ArrayDisplay($aArray, "2D Array")
MsgBox($MB_SYSTEMMODAL, 'Min Numeric value in column 2', _ArrayMin($aArray, 1, 0, 0, 2))


Function _ArrayMinIndex

Function Reference

_ArrayMinIndex

Returns the index where the lowest value occurs in a 1D or 2D array

#include <Array.au3>
_ArrayMinIndex ( Const ByRef $aArray [, $iCompNumeric = 0 [, $iStart = -1 [, $iEnd = -1 [, $iSubItem = 0]]]] )

Parameters

$aArray | Array to search
$iCompNumeric | [optional] Comparison method: 0 - compare alphanumerically 1 - compare numerically
$iStart | [optional] Index of array to start search
$iEnd | [optional] Index of array to end search
$iSubItem | [optional] Column of array to search

Return Value

Success: | the index of the minimum value in the array.
Failure: | -1 and sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array or is empty 2 - $aArray is not a 1D or 2D array 3 - $iStart or $iEnd outside array bounds 4 - $iStart is greater than $iEnd 5 - $aArray is empty 6 - $iSubItem outside array bounds

Related

_ArrayMax, _ArrayMaxIndex, _ArrayMin

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>

Local $aArray = StringSplit("4,2,06,8,12,5", ",")

MsgBox($MB_SYSTEMMODAL, 'Min Index String value', _ArrayMinIndex($aArray, 0, 1))
MsgBox($MB_SYSTEMMODAL, 'Min Index Numeric value', _ArrayMinIndex($aArray, 1, 1))

Local $aArray[4][4]
For $i = 0 To 3
    For $j = 0 To 3
        $aArray[$i][$j] = Random(0, 99, 1)
    Next
Next
_ArrayDisplay($aArray, "2D Array")
MsgBox($MB_SYSTEMMODAL, 'Min Index Numeric value in column 2', _ArrayMinIndex($aArray, 1, 0, 0, 2))


Function _ArrayPermute

Function Reference

_ArrayPermute

Returns an array of the Permutations of all Elements in a 1D array

#include <Array.au3>
_ArrayPermute ( ByRef $aArray [, $sDelimiter = ""] )

Parameters

$aArray | The Array to get Permutations
$sDelimiter | [optional] String result separator, default is "" for none

Return Value

Success: | an array of Permutations. $aArray[0] contains the number of strings returned. The remaining elements ($aArray[1], $aArray[2] ... $aArray[n]) contain the Permutations.
Failure: | sets the @error flag to non-zero.
@error: | 1 - The Input Must be an Array 2 - $aArray is not a 1 dimensional array

Remarks

The input array must be 0-based, i.e. no counter in $aArray[0].
Based on the algorithm by Alexander Bogomolny (http://www.bearcave.com/random_hacks/permute.html).

Related

_ArrayCombinations

Example

; Declare a 1-dimensional array, return an Array of permutations

#include <Array.au3>

Local $aArray[4] = [1, 2, 3, 4]
Local $aNewArray = _ArrayPermute($aArray, ",") ;Using Default Parameters
_ArrayDisplay($aNewArray, "Array Permuted")


Function _ArrayPop

Function Reference

_ArrayPop

Returns the last element of an array, deleting that element from the array at the same time

#include <Array.au3>
_ArrayPop ( ByRef $aArray )

Parameters

$aArray Array to modify

Return Value

Success: | the last element of the array (see remarks).
Failure: | sets the @error flag to non-zero.
@error: | 1 - The Input Must be an array 2 - $aArray is not a 1D array 3 - $aArray is empty

Remarks

If $aArray has one element left, it will be set to "" after _ArrayPop() is used on it.

Related

_ArrayAdd, _ArrayDelete, _ArrayInsert, _ArrayPush

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>

Local $avArray[10]

$avArray[0] = "JPM"
$avArray[1] = "Holger"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Jeremy"
$avArray[5] = "Valik"
$avArray[6] = "Cyberslug"
$avArray[7] = "Nutster"
$avArray[8] = "JdeB"
$avArray[9] = "Tylo"

_ArrayDisplay($avArray, "$avArray BEFORE _ArrayPop()")
While UBound($avArray)
    MsgBox($MB_SYSTEMMODAL, '_ArrayPop() return value', _ArrayPop($avArray))
    _ArrayDisplay($avArray, "$avArray AFTER _ArrayPop()")
WEnd


Function _ArrayPush

Function Reference

_ArrayPush

Add new values without increasing array size by inserting at the end the new value and deleting the first one or vice versa

#include <Array.au3>
_ArrayPush ( ByRef $aArray, $vValue [, $iDirection = 0] )

Parameters

$aArray | Array to modify
$vValue | Value(s) to add (can be in an array)
$iDirection | [optional] Direction to push existing array elements: 0 = Slide left (adding at the end) 1 = Slide right (adding at the start)

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array 2 - $vValue is an array larger than $aArray (so it can't fit) 3 - $aArray is not a 1D array

Remarks

This function is used for continuous updates of data in array, where in other cases a vast size of array would be created.
It keeps all values inside the array (something like History), minus the first one or the last one depending on direction chosen.
It is similar to the push command in assembly.

Related

_ArrayAdd, _ArrayConcatenate, _ArrayDelete, _ArrayInsert, _ArrayPop

Example

#include <Array.au3>

Local $avArrayTarget[9] = [1, 2, 3, 4, 5, 6, 7, 8, 9]
Local $avArraySource[2] = [100, 200]

_ArrayDisplay($avArrayTarget, "$avArrayTarget BEFORE _ArrayPush()")
_ArrayPush($avArrayTarget, $avArraySource)
_ArrayDisplay($avArrayTarget, "$avArrayTarget AFTER _ArrayPush() array to end")
_ArrayPush($avArrayTarget, $avArraySource, 1)
_ArrayDisplay($avArrayTarget, "$avArrayTarget AFTER _ArrayPush() array to beginning")
_ArrayPush($avArrayTarget, "Hello world!", 1)
_ArrayDisplay($avArrayTarget, "$avArrayTarget AFTER _ArrayPush() string to beginning")


Function _ArrayReverse

Function Reference

_ArrayReverse

Takes the given array and reverses the order in which the elements appear in a 1D array

#include <Array.au3>
_ArrayReverse ( ByRef $aArray [, $iStart = 0 [, $iEnd = 0]] )

Parameters

$aArray | Array to modify
$iStart | [optional] Index of array to start modifying at
$iEnd | [optional] Index of array to stop modifying at

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array 2 - $iStart is greater than $iEnd 3 - $aArray is not a 1D array 4 - $aArray is empty

Related

_ArraySwap

Example

#include <Array.au3>

Local $avArray[10] = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]

_ArrayDisplay($avArray, "$avArray BEFORE _ArrayReverse()")
_ArrayReverse($avArray)
_ArrayDisplay($avArray, "$avArray AFTER _ArrayReverse()")
_ArrayReverse($avArray, 3, 6)
_ArrayDisplay($avArray, "$avArray AFTER _ArrayReverse() from index 3 to 6")


Function _ArraySearch

Function Reference

_ArraySearch

Finds an entry within a 1D or 2D array. Similar to _ArrayBinarySearch(), except that the array does not need to be sorted

#include <Array.au3>
_ArraySearch ( Const ByRef $aArray, $vValue [, $iStart = 0 [, $iEnd = 0 [, $iCase = 0 [, $iCompare = 0 [, $iForward = 1 [, $iSubItem = -1 [, $bRow = False]]]]]]] )

Parameters

$aArray | The array to search
$vValue | What to search $aArray for
$iStart | [optional] Index of array to start searching at
$iEnd | [optional] Index of array to stop searching at
$iCase | [optional] If set to 1, search is case sensitive
$iCompare | [optional] 0 Casting of variables to the same type (default), "string" = 0, "" = 0 or "0" = 0 match (If $iCase = 0) 1 executes a partial search 2 comparison match if variables have same type and same value 3 compares using a regular expression pattern provided as $vValue
$iForward | [optional] If set to 0, searches the array from end to beginning (instead of beginning to end)
$iSubItem | [optional] Sub-index to search on in 2D arrays
$bRow | [optional] If True then $iSubItem sets the row to search - False (default) searches columns

Return Value

Success: | the index that $vValue was found at.
Failure: | -1 and sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array 2 - $aArray is not a 1D or 2D array 3 - $aArray is empty 4 - $iStart is greater than $iEnd 5 - Array not 2D and $bRow set True 6 - $vValue was not found in array

Remarks

This function is likely to be slower than _ArrayBinarySearch() but is useful when the array cannot be sorted before the search.

The values of $iCompare can not be combined together.

Related

_ArrayBinarySearch, _ArrayFindAll

Example

Example 1

#include <Array.au3>
#include <MsgBoxConstants.au3>

Local $aArray[6][4]
For $i = 0 To 5
    For $j = 0 To 3
        $aArray[$i][$j] = "#" & $i & $j
    Next
Next
_ArrayDisplay($aArray, "Looking for '#32'", Default, 8)

; Search by column (looking in col 2)
Local $iIndex = _ArraySearch($aArray, "#32", 0, 0, 0, 0, 1, 2)
MsgBox($MB_SYSTEMMODAL, "Found '#32'", "Column 2 on Row " & $iIndex)

; Search by row (looking in row 3)
$iIndex = _ArraySearch($aArray, "#32", 0, 0, 0, 0, 1, 3, True)
MsgBox($MB_SYSTEMMODAL, "Found '#32'", "Row 3 in Col " & $iIndex)

Example 2

; using a 2D array

#include <Array.au3>
#include <MsgBoxConstants.au3>

Local $avArray[6][2] = [ _
        ["String0", "SubString0"], _
        ["String1", "SubString1"], _
        ["String2", "SubString2"], _
        ["String3", "SubString3"], _
        ["String4", "SubString4"], _
        ["String5", "SubString5"]]

_ArrayDisplay($avArray, "$avArray")

Local $sSearch = InputBox("_ArraySearch() demo", "String to find?")
If @error Then Exit

Local $sColumn = InputBox("_ArraySearch() demo", "Column to search?")
If @error Then Exit
$sColumn = Int($sColumn)

Local $iIndex = _ArraySearch($avArray, $sSearch, 0, 0, 0, 1, 1, $sColumn)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Not Found", '"' & $sSearch & '" was not found on column ' & $sColumn & '.')
Else
    MsgBox($MB_SYSTEMMODAL, "Found", '"' & $sSearch & '" was found in the array at position ' & $iIndex & ' on column ' & $sColumn & '.')
EndIf


Function _ArrayShuffle

Function Reference

_ArrayShuffle

Shuffles selected rows of 1D or 2D arrays - can be limited to a specific column in 2D arrays

#include <Array.au3>
_ArrayShuffle ( ByRef $aArray [, $iStart_Row = 0 [, $iEnd_Row = 0 [, $iCol = -1]]] )

Parameters

$aArray | Array to modify
$iStart_Row | [optional] Start row for shuffle - default first
$iEnd_Row | [optional] End row for shuffle - default last
$iCol | [optional] Specific column to shuffle (2D only)

Return Value

Success: | 1.
Failure: | -1 and sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array 2 - $aArray is not a 1D or 2D array 3 - $iStart or $iEnd outside array bounds 4 - $iStart greater than $iEnd 5 - $iColumn is outside array bounds

Remarks

The function uses the Fisher-Yates shuffle algorithm.

Example

#include <Array.au3>

Local $aArray_Base[10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
_ArrayDisplay($aArray_Base, "1D - Original", Default, 8)

Local $aArray = $aArray_Base
_ArrayShuffle($aArray)
_ArrayDisplay($aArray, "1D - Shuffled", Default, 8)

$aArray = $aArray_Base
_ArrayShuffle($aArray, 3, 8)
_ArrayDisplay($aArray, "1D - Shuffled - 3-8 ", Default, 8)

Local $aArray_Base[10][10]
For $i = 0 To 9
    For $j = 0 To 9
        $aArray_Base[$i][$j] = $i
    Next
Next
_ArrayDisplay($aArray_Base, "2D - Original", Default, 8)

$aArray = $aArray_Base
_ArrayShuffle($aArray)
_ArrayDisplay($aArray, "2D - Shuffled - All rows", Default, 8)

$aArray = $aArray_Base
_ArrayShuffle($aArray, 3, 8, 2)
_ArrayDisplay($aArray, "2D - Shuffled - Col 2, 3-8", Default, 8)


Function _ArraySort

Function Reference

_ArraySort

Sort a 1D or 2D array on a specific index using the dualpivotsort/quicksort/insertionsort algorithms

#include <Array.au3>
_ArraySort ( ByRef $aArray [, $iDescending = 0 [, $iStart = 0 [, $iEnd = 0 [, $iSubItem = 0 [, $iPivot = 0]]]]] )

Parameters

$aArray | Array to sort
$iDescending | [optional] If set to 1, sort in descending order
$iStart | [optional] Index of array to start sorting (default 0 = first element or row)
$iEnd | [optional] Index of array to stop sorting (default 0 = last element or row)
$iSubItem | [optional] Sub-index to sort on in 2D arrays (default 0 = first column)
$iPivot | [optional] Use pivot sort algorithm (default = quicksort)

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array 2 - $iStart is greater than $iEnd 3 - $iSubItem is greater than subitem count 4 - $aArray is not a 1D or 2D array 5 - $aArray is empty 6 - $iPivot used with 2D array

Remarks

By default the UDF uses a QuickSort algorithm to sort the array. Setting the $iPivot parameter uses a DualPivotSort algorithm on 1D arrays - this can be significantly faster for large arrays (> 50 elements) - but sorting 2D arrays with this algorithm is very much slower and the UDF will return an error in this case.
In both algorithms, relatively short arrays will be sorted using an insertion sort (< 15 elements with QuickSort; < 45 elements with Dual PivotSort).
Note that there is no guarantee that a specific algorithm will be faster in a given case.

Example

Example 1

; using a 1D array

#include <Array.au3>

Local $avArray[10] = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]

_ArrayDisplay($avArray, "BEFORE _ArraySort()")
_ArraySort($avArray)
_ArrayDisplay($avArray, "AFTER QuickSort ascending")
_ArraySort($avArray, 1)
_ArrayDisplay($avArray, "AFTER QuickSort descending")
_ArraySort($avArray, 0, 3, 6)
_ArrayDisplay($avArray, "AFTER QuickSort from index 3 to 6")
_ArraySort($avArray, 0, 0, 0, 0, 1)
_ArrayDisplay($avArray, "AFTER DualPivotSort ascending")

Example 2

; using a 2D array

#include <Array.au3>

Local $avArray[5][3] = [ _
        [5, 20, 8], _
        [4, 32, 7], _
        [3, 16, 9], _
        [2, 35, 0], _
        [1, 19, 6]]

_ArrayDisplay($avArray, "$avArray BEFORE _ArraySort()")
_ArraySort($avArray, 0, 0, 0, 0)
_ArrayDisplay($avArray, "$avArray AFTER _ArraySort() ascending column 0")
_ArraySort($avArray, 0, 0, 0, 1)
_ArrayDisplay($avArray, "$avArray AFTER _ArraySort() ascending column 1")
_ArraySort($avArray, 0, 0, 0, 2)
_ArrayDisplay($avArray, "$avArray AFTER _ArraySort() ascending column 2")


Function _ArraySwap

Function Reference

_ArraySwap

Swaps elements of a 1D array and full or part rows/columns of a 2D array

#include <Array.au3>
_ArraySwap ( ByRef $aArray, $iIndex_1, $iIndex_2 [, $bCol = False [, $iStart = -1 [, $iEnd = -1]]] )

Parameters

$aArray | Array to modify
$iIndex_1 | Index of first element (1D) or row/column (2D) to swap
$iIndex_2 | Index of second element (1D) or row/column (2D) to swap
$bCol | [optional] If True then for 2D array above parameters refer to rows; if False (default) above parameters refer to columns
$iStart | [optional] Index in row/column to start swap (2D array only)
$iEnd | [optional] Index in row/column to end swap (2D array only)

Return Value

Success: | 1
Failure: | -1 and sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array 2 - $aArray is not a 1D or 2D array 3 - $iIndex_1 or $iIndex_2 is outside array bounds 4 - $iStart or $iEnd outside array bounds 5 - $iStart is greater than $iEnd

Remarks

Optional parameters ignored for 1D arrays.

Related

_ArrayReverse

Example

#include <Array.au3>

Local $aArray[10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

_ArrayDisplay($aArray, "Original", Default, 8)
_ArraySwap($aArray, 3, 7)
_ArrayDisplay($aArray, "Swapped 3-7", Default, 8)

Local $aArray_Base[10][10]
For $i = 0 To 9
    For $j = 0 To 9
        $aArray_Base[$i][$j] = $i & " - " & $j
    Next
Next
_ArrayDisplay($aArray_Base, "Original", Default, 8)

$aArray = $aArray_Base
_ArraySwap($aArray, 3, 7)
_ArrayDisplay($aArray, "Swapped Rows 3-7", Default, 8)

$aArray = $aArray_Base
_ArraySwap($aArray, 3, 7, False, 2, 5)
_ArrayDisplay($aArray, "Swapped Rows 3-7, Cols 2-5", Default, 8)

$aArray = $aArray_Base
_ArraySwap($aArray, 3, 7, True)
_ArrayDisplay($aArray, "Swapped Cols 3-7", Default, 8)

$aArray = $aArray_Base
_ArraySwap($aArray, 3, 7, True, 2, 5)
_ArrayDisplay($aArray, "Swapped Cols 3-7, Rows 2-5", Default, 8)


Function _ArrayToClip

Function Reference

_ArrayToClip

Sends the contents of a 1D or 2D array to the clipboard, each element separated by a specified delimiter

#include <Array.au3>
_ArrayToClip ( Const ByRef $aArray [, $sDelim_Col = "|" [, $iStart_Row = -1 [, $iEnd_Row = -1 [, $sDelim_Row = @CRLF [, $iStart_Col = -1 [, $iEnd_Col = -1]]]]]] )

Parameters

$aArray | Array to copy to clipboard
$sDelim_Col | [optional] Delimiter for elements of 1D array or columns of 2D array
$iStart_Row | [optional] Index of array row to start copy
$iEnd_Row | [optional] Index of array row to stop copy
$sDelim_Row | [optional] Delimiter for rows of 2D array (2D only)
$iStart_Col | [optional] Index of array column to start copy (2D only)
$iEnd_Col | [optional] Index of array column to stop copy (2D only)

Return Value

Success: 1.
Failure: 0 and sets the @error flag to non-zero.
@error: -1 - ClipPut() failed
Other - See _ArrayToString() description for @error

Related

_ArrayToString

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>

Local $aArray = StringSplit("A,B,C,D,E,F,G,H,I", ",")
_ArrayDisplay($aArray, "1D Array")
_ArrayToClip($aArray, " - ", Default, 1, 6)
MsgBox($MB_SYSTEMMODAL, "_ArrayToClip() 1D Test", ClipGet())

Local $aArray[4][4]
For $i = 0 To 3
    For $j = 0 To 3
        $aArray[$i][$j] = $i & $j
    Next
Next
_ArrayDisplay($aArray, "2D Array")
_ArrayToClip($aArray, " :: ", Default, 1, 2, 1, 2)
MsgBox($MB_SYSTEMMODAL, "_ArrayToClip() 2D Test", ClipGet())


Function _ArrayToString

Function Reference

_ArrayToString

Places the elements of a 1D or 2D array into a single string, separated by the specified delimiters

#include <Array.au3>
_ArrayToString ( Const ByRef $aArray [, $sDelim_Col = "|" [, $iStart_Row = -1 [, $iEnd_Row = -1 [, $sDelim_Row = @CRLF [, $iStart_Col = -1 [, $iEnd_Col = -1]]]]]] )

Parameters

$aArray | Array to convert to a string
$sDelim_Col | [optional] Delimiter for elements of 1D array or columns of 2D array
$iStart_Row | [optional] Index of array row to start copy
$iEnd_Row | [optional] Index of array row to stop copy
$sDelim_Row | [optional] Delimiter for rows of 2D array (2D only)
$iStart_Col | [optional] Index of array column to start copy (2D only)
$iEnd_Col | [optional] Index of array column to stop copy (2D only)

Return Value

Success: | a string which combined selected elements separated by the delimiters.
Failure: | sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array 2 - $aArray is not a 1D or 2D array 3 - $iStart_Row or $iEnd_Row outside array bounds 4 - $iStart_Row greater then $iEnd_Row 5 - $iStart_Col or $iEnd_Col outside array bounds 6 - $iStart_Col greater then $iEnd_Col

Related

_ArrayToClip

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>

Local $aArray[20]
For $i = 0 To 19
    $aArray[$i] = $i
Next
_ArrayDisplay($aArray, "1D Array")
MsgBox($MB_SYSTEMMODAL, "Items 1-7", _ArrayToString($aArray, @TAB, 1, 7))

Local $aArray[10][10]
For $i = 0 To 9
    For $j = 0 To 9
        $aArray[$i][$j] = $i & "-" & $j
    Next
Next
_ArrayDisplay($aArray, "2D Array")
MsgBox($MB_SYSTEMMODAL, "Rows 4-7,  cols 2-5", _ArrayToString($aArray, " :: ", 4, 7, @CRLF, 2, 5))


Function _ArrayTranspose

Function Reference

_ArrayTranspose

Transposes a 1D or 2D array (swaps rows and columns)

#include <Array.au3>
_ArrayTranspose ( ByRef $aArray )

Parameters

$aArray Array to modify

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $aArray is not a 1D or 2D array 2 - $aArray is not an array

Related

_ArraySwap

Example

#include <Array.au3>

Local $aArray[3][2] = [[1, 2], [3, 4], [5, 6]]
_ArrayDisplay($aArray, "Original")
_ArrayTranspose($aArray)
_ArrayDisplay($aArray, "Transposed")

Local $aArray[5] = [1, 2, 3, 4, 5]
_ArrayDisplay($aArray, "Original 1D")
_ArrayTranspose($aArray)
_ArrayDisplay($aArray, "Transposed to 2D")
_ArrayTranspose($aArray)
_ArrayDisplay($aArray, "Re-transposed to 1D")


Function _ArrayTrim

Function Reference

_ArrayTrim

Trims a certain number of characters from all elements in a 1D or 2D array

#include <Array.au3>
_ArrayTrim ( ByRef $aArray, $iTrimNum [, $iDirection = 0 [, $iStart = 0 [, $iEnd = 0 [, $iSubItem = 0]]]] )

Parameters

$aArray | Array to modify
$iTrimNum | Number of characters to remove
$iDirection | [optional] Direction to trim: 0 - trim left 1 - trim right
$iStart | [optional] Index of array to start trim
$iEnd | [optional] Index of array to stop trim
$iSubItem | [optional] Column to trim

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array 2 - $aArray is not an 1D or 2D array 3 - $iStart or $iEnd outside array bounds 4 - $iStart is greater than $iEnd 5 - $iSubItem outside array bounds

Example

#include <Array.au3>

Local $aArray[5] = ["ab", "bc", "cd", "de", "ef"]

_ArrayDisplay($aArray, "1D array")
_ArrayTrim($aArray, 1, 1, 1, 3)
_ArrayDisplay($aArray, "Trimmed right 1 char from items 1-3")

Local $aArray[4][4], $iChr
For $i = 0 To 3
    For $j = 0 To 3
        $iChr = Random(97, 121, 1)
        $aArray[$i][$j] = Chr($iChr) & Chr($iChr + 1)
    Next
Next
_ArrayDisplay($aArray, "2D array")
_ArrayTrim($aArray, 1, 0, 1, 2, 3)
_ArrayDisplay($aArray, "Trimmed left 1 char from col 2-3 in row 1-2")


Function _ArrayUnique

Function Reference

_ArrayUnique

Returns the Elements from a column of a 1D or 2D array, removing all duplicates

#include <Array.au3>
_ArrayUnique ( Const ByRef $aArray [, $iColumn = 0 [, $iBase = 0 [, $iCase = 0 [, $iCount = $ARRAYUNIQUE_COUNT [, $iIntType = $ARRAYUNIQUE_AUTO]]]]] )

Parameters

$aArray | The Array to use
$iColumn | [optional] 0-based column to be used - default 0. (2D only)
$iBase | [optional] The array is 0-based or 1-based. Default 0 : 0-based.
$iCase | [optional] Flag to indicate if the operations should be case sensitive. Default 0 : not case sensitive.
$iCount | [optional] Flag to determine if [0] element holds the count of returned items (default) - see Remarks for details.
$iIntType | [optional] Flag to change function algorithm - see Remarks for details.

Return Value

Success: | a 1-dimensional array containing only the unique elements of that Column.
Failure: | sets the @error flag to non-zero.
@error: | 1 - $aArray is not an array or is an empty array. 2 - $aArray is not a 1D or 2D array 3 - Invalid $iBase or $iCase value 4 - Invalid $iCount value 5 - Invalid $iIntType value 6 - $iColumn ouside array bounds 7 - Mismatch of Int32 and Int64 items - requires $iIntType to be set

Remarks

Returns an array containing the unique elements.

By default $iCount is set to $ARRAYUNIQUE_COUNT (1) and a count is placed in the [0] element. Setting $iCount to $ARRAYUNIQUE_NOCOUNT (0) returns a list without a count.

The function can use a fast algorithm as long as the elements to be examined do not contain Int64 values (e.g. 64 bit integers, handles, pointers) - if these values are present then the function must use a slower algorithm. Setting the $iIntType parameter alters function behaviour as follows:

$ARRAYUNIQUE_AUTO (0) (Default) : If first element not an integer runs fast algorithm - returns error if Int64 elements are found.
: If first element is integer sets relevant FORCE32/64 value.
$ARRAYUNIQUE_FORCE32 (1) : Forces all integers to Int32, runs fast algorithm - returns error if Int64 values are found.
$ARRAYUNIQUE_FORCE64 (2) : Forces all integers to Int64, runs slow algorithm - returns error if Int32 values are found.
$ARRAYUNIQUE_MATCH (3) : 0x00000123 and 0x0123 considered the same value, only first encountered returned - runs slow algorithm.
$ARRAYUNIQUE_DISTINCT (4) : 0x00000123 and 0x0123 considered as distinct, both returned - runs slow algorithm.

Using other than the default $ARRAYUNIQUE_AUTO setting is only required it is known or suspected that Int64 values will be examined. The requirement to use a slower algorithm when dealing with Int64 values is a limitation of the Scripting.Dictionary object used within the function, not of AutoIt itself.

Related

_ArrayMax, _ArrayMin

Example

Example 1

#include <Array.au3>

Local $aArray[10] = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5] ; Create a 1-dimensional array that contains duplicate values.
_ArrayDisplay($aArray, "$aArray Initial") ; Display the current array.

Local $aArrayUnique = _ArrayUnique($aArray) ; Use default parameters to create a unique array.
_ArrayDisplay($aArrayUnique, "$aArray Unique") ; Display the unique array.

Example 2

#include <Array.au3>

Local $aArray[6][2] = [[1, "A"], [2, "B"], [3, "C"], [1, "A"], [2, "B"], [3, "C"]]
_ArrayDisplay($aArray, "2D array") ; Display the current array.
Local $aArrayUnique = _ArrayUnique($aArray) ; Use default parameters to create a unique array of the first column.
_ArrayDisplay($aArrayUnique, "$aArray first column") ; Display the unique array.

$aArrayUnique = _ArrayUnique($aArray, 1) ; Create a unique array of the second column.
_ArrayDisplay($aArrayUnique, "$aArray second column") ; Display the unique array.


Function _Array1DToHistogram

Function Reference

_Array1DToHistogram

Transform a 1D array to Histogram

#include <Array.au3>
_Array1DToHistogram ( $aArray [, $iSizing = 100] )

Parameters

$aArray | Array to transform
$iSizing | [optional] Allows to zoom the histogram. Default = 100 percent

Return Value

Success: | the array transformed.
Failure: | sets the @error flag to non-zero.
@error: | 1 - $aArray is not a 1D array

Remarks

Right alignment of negative values is not perfect due to non fixed font usage.

Example

Example 1

#include <Array.au3>

Local $aNEW[] = [0, -80, -49, -44, 80, 100, 8, 7, 6, 5, 4, 3, 2, 1]
Local $aArray = _Array1DToHistogram($aNEW, 125)
_ArrayDisplay($aArray, "_Array1DToHistogram")

Example 2

#include <Array.au3>

Local $iLimit = 500
Local $aValues[51]
Local $t, $n

For $i = 1 To $iLimit
    $t = TimerInit()
    Sleep(10)
    $n = Round(TimerDiff($t))
    $aValues[$n] += 1
Next
Local $aArray = _Array1DToHistogram($aValues)
_ArrayDisplay($aArray, "_Array1DToHistogram", "10:20")


User Defined Functions

Clipboard user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPISys.au3>.

User Defined Function | Description
_ClipBoard_ChangeChain | Removes a specified window from the chain of clipboard viewers
_ClipBoard_Close | Closes the clipboard
_ClipBoard_CountFormats | Retrieves the number of different data formats currently on the clipboard
_ClipBoard_Empty | Empties the clipboard and frees handles to data in the clipboard
_ClipBoard_EnumFormats | Enumerates the data formats currently available on the clipboard
_ClipBoard_FormatStr | Returns a string representation of a standard clipboard format
_ClipBoard_GetData | Retrieves data from the clipboard in a specified format
_ClipBoard_GetDataEx | Retrieves data from the clipboard in a specified format
_ClipBoard_GetFormatName | Retrieves the name of the specified registered format
_ClipBoard_GetOpenWindow | Retrieves the handle to the window that currently has the clipboard open
_ClipBoard_GetOwner | Retrieves the window handle of the current owner of the clipboard
_ClipBoard_GetPriorityFormat | Retrieves the first available clipboard format in the specified list
_ClipBoard_GetSequenceNumber | Retrieves the clipboard sequence number for the current window station
_ClipBoard_GetViewer | Retrieves the handle to the first window in the clipboard viewer chain
_ClipBoard_IsFormatAvailable | Determines whether the clipboard contains data in the specified format
_ClipBoard_Open | Opens the clipboard and prevents other applications from modifying the clipboard
_ClipBoard_RegisterFormat | Registers a new clipboard format
_ClipBoard_SetData | Places data on the clipboard in a specified clipboard format
_ClipBoard_SetDataEx | Places data on the clipboard in a specified clipboard format
_ClipBoard_SetViewer | Adds the specified window to the chain of clipboard viewers


Function _ClipBoard_ChangeChain

Function Reference

_ClipBoard_ChangeChain

Removes a specified window from the chain of clipboard viewers

#include <Clipboard.au3>
_ClipBoard_ChangeChain ( $hRemove, $hNewNext )

Parameters

$hRemove | Handle to the window to be removed from the chain. The handle must have been passed to the _ClipBoard_SetViewer() function.
$hNewNext | Handle to the window that follows the $hRemove window in the clipboard viewer chain. This is the handle returned by _ClipBoard_SetViewer(), unless the sequence was changed in response to a $WM_CHANGECBCHAIN message.

Return Value

None.

Remarks

The window identified by $hNewNext replaces the $hRemove window in the chain.
The _ClipBoard_SetViewer() function sends a $WM_CHANGECBCHAIN message to the first window in the clipboard viewer chain.

Related

_ClipBoard_SetViewer

See Also

Search ChangeClipboardChain in MSDN Library.

Example

#include <Clipboard.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_hNext = 0

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Clipboard", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize clipboard viewer
    $g_hNext = _ClipBoard_SetViewer($hGUI)

    GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN")
    GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Shut down clipboard viewer
    _ClipBoard_ChangeChain($hGUI, $g_hNext)
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Handle $WM_CHANGECBCHAIN messages
Func WM_CHANGECBCHAIN($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    ; Show that message was received
    MemoWrite("***** $WM_CHANGECBCHAIN *****")

    ; If the next window is closing, repair the chain
    If $wParam = $g_hNext Then
        $g_hNext = $lParam
        ; Otherwise pass the message to the next viewer
    ElseIf $g_hNext <> 0 Then
        _SendMessage($g_hNext, $WM_CHANGECBCHAIN, $wParam, $lParam, 0, "hwnd", "hwnd")
    EndIf
EndFunc   ;==>WM_CHANGECBCHAIN

; Handle $WM_DRAWCLIPBOARD messages
Func WM_DRAWCLIPBOARD($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    ; Display any text on clipboard
    MemoWrite(_ClipBoard_GetData())

    ; Pass the message to the next viewer
    If $g_hNext <> 0 Then _SendMessage($g_hNext, $WM_DRAWCLIPBOARD, $wParam, $lParam)
EndFunc   ;==>WM_DRAWCLIPBOARD


Function _ClipBoard_Close

Function Reference

_ClipBoard_Close

Closes the clipboard

#include <Clipboard.au3>
_ClipBoard_Close ( )

Return Value

Success: | True
Failure: | False

Remarks

When the window has finished examining or changing the clipboard close the clipboard by calling this function.
This enables other windows to access the clipboard. Do not place an object on the clipboard after calling this function.

Related

_ClipBoard_Open

See Also

Search CloseClipboard in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Clipboard", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Open the clipboard
    If Not _ClipBoard_Open($hGUI) Then _WinAPI_ShowError("_ClipBoard_Open failed")

    ; Show clipboard formats available
    MemoWrite("Clipboard formats ..: " & _ClipBoard_CountFormats())

    ; Empty the clipboard
    If Not _ClipBoard_Empty() Then _WinAPI_ShowError("_ClipBoard_Empty failed")

    ; Show clipboard formats available
    MemoWrite("Clipboard formats ..: " & _ClipBoard_CountFormats())

    ; Close the clipboard
    _ClipBoard_Close()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _ClipBoard_CountFormats

Function Reference

_ClipBoard_CountFormats

Retrieves the number of different data formats currently on the clipboard

#include <Clipboard.au3>
_ClipBoard_CountFormats ( )

Return Value

Returns the number of different data formats currently on the clipboard.

Related

_ClipBoard_EnumFormats, _ClipBoard_GetPriorityFormat

See Also

Search CountClipboardFormats in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $iFormat, $iCount

    ; Create GUI
    $hGUI = GUICreate("Clipboard", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Open the clipboard
    If _ClipBoard_Open($hGUI) Then

        ; Show clipboard formats available
        MemoWrite("Clipboard formats ..: " & _ClipBoard_CountFormats())

        ; Enumerate clipboard formats
        Do
            $iFormat = _ClipBoard_EnumFormats($iFormat)
            If $iFormat <> 0 Then
                $iCount += 1
                MemoWrite("Clipboard format " & $iCount & " .: " & _ClipBoard_FormatStr($iFormat))
            EndIf
        Until $iFormat = 0

        ; Close the clipboard
        _ClipBoard_Close()
    Else
        _WinAPI_ShowError("_ClipBoard_Open failed")
    EndIf

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _ClipBoard_Empty

Function Reference

_ClipBoard_Empty

Empties the clipboard and frees handles to data in the clipboard

#include <Clipboard.au3>
_ClipBoard_Empty ( )

Return Value

Success: | True
Failure: | False

Remarks

Before calling this function, you must open the clipboard by using the _ClipBoard_Open() function.
If you specified a NULL window handle when opening the clipboard, this function succeeds but sets the clipboard owner to NULL.
Note that this causes _ClipBoard_SetData() to fail.

Related

_ClipBoard_GetOwner, _ClipBoard_Open, _ClipBoard_SetData, _ClipBoard_SetDataEx

See Also

Search EmptyClipboard in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Clipboard", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Open the clipboard
    If _ClipBoard_Open($hGUI) Then
        ShowData($hGUI)

        ; Empty the clipboard
        If Not _ClipBoard_Empty() Then _WinAPI_ShowError("_ClipBoard_Empty failed")

        ; Close the clipboard
        _ClipBoard_Close()
    Else
        _WinAPI_ShowError("_ClipBoard_Open failed")
    EndIf

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Show clipboard statistics
Func ShowData($hGUI)
    MemoWrite("GUI handle ............: " & $hGUI)
    MemoWrite("Clipboard owner .......: " & _ClipBoard_GetOwner())
    MemoWrite("Clipboard open window .: " & _ClipBoard_GetOpenWindow())
    MemoWrite("Clipboard sequence ....: " & _ClipBoard_GetSequenceNumber())
    MemoWrite()
EndFunc   ;==>ShowData

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _ClipBoard_EnumFormats

Function Reference

_ClipBoard_EnumFormats

Enumerates the data formats currently available on the clipboard

#include <Clipboard.au3>
_ClipBoard_EnumFormats ( $iFormat )

Parameters

$iFormat Specifies a clipboard format that is known to be available. To start an enumeration of formats, set $iFormat to zero.
When $iFormat is zero, the function retrieves the first available clipboard format.
For subsequent calls during an enumeration, set $iFormat to the result of the previous call.

Return Value

Success: | The clipboard format that follows the specified format
Failure: | 0

Remarks

You must open the clipboard before enumerating its formats

Related

_ClipBoard_CountFormats, _ClipBoard_GetPriorityFormat, _ClipBoard_Open, _ClipBoard_RegisterFormat

See Also

Search EnumClipboardFormats in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $iFormat, $iCount

    ; Create GUI
    $hGUI = GUICreate("Clipboard", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Open the clipboard
    If _ClipBoard_Open($hGUI) Then

        ; Show clipboard formats available
        MemoWrite("Clipboard formats ..: " & _ClipBoard_CountFormats())

        ; Enumerate clipboard formats
        Do
            $iFormat = _ClipBoard_EnumFormats($iFormat)
            If $iFormat <> 0 Then
                $iCount += 1
                MemoWrite("Clipboard format " & $iCount & " .: " & _ClipBoard_FormatStr($iFormat))
            EndIf
        Until $iFormat = 0

        ; Close the clipboard
        _ClipBoard_Close()
    Else
        _WinAPI_ShowError("_ClipBoard_Open failed")
    EndIf

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _ClipBoard_FormatStr

Function Reference

_ClipBoard_FormatStr

Returns a string representation of a standard clipboard format

#include <Clipboard.au3>
_ClipBoard_FormatStr ( $iFormat )

Parameters

$iFormat Specifies a clipboard format

Return Value

Returns a String representation of the clipboard format

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $iFormat, $iCount

    ; Create GUI
    $hGUI = GUICreate("Clipboard", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Open the clipboard
    If _ClipBoard_Open($hGUI) Then

        ; Show clipboard formats available
        MemoWrite("Clipboard formats ..: " & _ClipBoard_CountFormats())

        ; Enumerate clipboard formats
        Do
            $iFormat = _ClipBoard_EnumFormats($iFormat)
            If $iFormat <> 0 Then
                $iCount += 1
                MemoWrite("Clipboard format " & $iCount & " .: " & _ClipBoard_FormatStr($iFormat))
            EndIf
        Until $iFormat = 0

        ; Close the clipboard
        _ClipBoard_Close()
    Else
        _WinAPI_ShowError("_ClipBoard_Open failed")
    EndIf

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _ClipBoard_GetData

Function Reference

_ClipBoard_GetData

Retrieves data from the clipboard in a specified format

#include <Clipboard.au3>
_ClipBoard_GetData ( [$iFormat = 1] )

Parameters

$iFormat [optional] Specifies a clipboard format:
$CF_TEXT - Text format
$CF_BITMAP - Handle to a bitmap (HBITMAP)
$CF_METAFILEPICT - Handle to a metafile picture (METAFILEPICT)
$CF_SYLK - Microsoft Symbolic Link (SYLK) format
$CF_DIF - Software Arts' Data Interchange Format
$CF_TIFF - Tagged image file format
$CF_OEMTEXT - Text format containing characters in the OEM character set
$CF_DIB - BITMAPINFO structure followed by the bitmap bits
$CF_PALETTE - Handle to a color palette
$CF_PENDATA - Data for the pen extensions to Pen Computing
$CF_RIFF - Represents audio data in RIFF format
$CF_WAVE - Represents audio data in WAVE format
$CF_UNICODETEXT - Unicode text format
$CF_ENHMETAFILE - Handle to an enhanced metafile (HENHMETAFILE)
$CF_HDROP - Handle to type HDROP that identifies a list of files
$CF_LOCALE - Handle to the locale identifier associated with text in the clipboard
$CF_DIBV5 - BITMAPV5HEADER structure followed by bitmap color and the bitmap bits
$CF_OWNERDISPLAY - Owner display format
$CF_DSPTEXT - Text display format associated with a private format
$CF_DSPBITMAP - Bitmap display format associated with a private format
$CF_DSPMETAFILEPICT - Metafile picture display format associated with a private format
$CF_DSPENHMETAFILE - Enhanced metafile display format associated with a private format

Return Value

Success: | Text for text based formats or Binary data for all other formats @extended is set to the # of characters for Text, or # of bytes for Binary
Failure: | 0

Remarks

This function performs all of the steps neccesary to get data from the clipboard. It checks to see if the data format is available, opens the clipboard, closes the clipboard and returns the data in one of two formats: String format for datatypes $CF_TEXT, $CF_OEMTEXT, or $CF_UNICODETEXT, or Binary format for every other type.
If you need a finer degree of control over retrieving data from the clipboard, you may want to use the _ClipBoard_GetDataEx() function.

Related

_ClipBoard_GetDataEx, _ClipBoard_SetData, _ClipBoard_SetDataEx

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $id_SetData, $id_GetData

    ; Create GUI
    GUICreate("Clipboard", 600, 450)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    $id_SetData = GUICtrlCreateButton("Set ClipBoard Data", 150, 410, 120, 30)
    $id_GetData = GUICtrlCreateButton("Get ClipBoard Data", 300, 410, 120, 30)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $id_SetData
                _ClipBoard_SetData("ClipBoard Library")
            Case $id_GetData
                MemoWrite(_ClipBoard_GetData())
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _ClipBoard_GetDataEx

Function Reference

_ClipBoard_GetDataEx

Retrieves data from the clipboard in a specified format

#include <Clipboard.au3>
_ClipBoard_GetDataEx ( [$iFormat = 1] )

Parameters

$iFormat [optional] Specifies a clipboard format:
$CF_TEXT - Text format
$CF_BITMAP - Handle to a bitmap (HBITMAP)
$CF_METAFILEPICT - Handle to a metafile picture (METAFILEPICT)
$CF_SYLK - Microsoft Symbolic Link (SYLK) format
$CF_DIF - Software Arts' Data Interchange Format
$CF_TIFF - Tagged image file format
$CF_OEMTEXT - Text format containing characters in the OEM character set
$CF_DIB - BITMAPINFO structure followed by the bitmap bits
$CF_PALETTE - Handle to a color palette
$CF_PENDATA - Data for the pen extensions to Pen Computing
$CF_RIFF - Represents audio data in RIFF format
$CF_WAVE - Represents audio data in WAVE format
$CF_UNICODETEXT - Unicode text format
$CF_ENHMETAFILE - Handle to an enhanced metafile (HENHMETAFILE)
$CF_HDROP - Handle to type HDROP that identifies a list of files
$CF_LOCALE - Handle to the locale identifier associated with text in the clipboard
$CF_DIBV5 - BITMAPV5HEADER structure followed by bitmap color and the bitmap bits
$CF_OWNERDISPLAY - Owner display format
$CF_DSPTEXT - Text display format associated with a private format
$CF_DSPBITMAP - Bitmap display format associated with a private format
$CF_DSPMETAFILEPICT - Metafile picture display format associated with a private format
$CF_DSPENHMETAFILE - Enhanced metafile display format associated with a private format

Return Value

Success: | Handle to a clipboard object in the specified format
Failure: | 0

Remarks

The clipboard controls the handle that the _ClipBoard_GetData() function returns, not the application.
You should copy the data immediately. The application must not free the handle nor leave it locked.
The application must not use the handle after the _ClipBoard_Empty() or _ClipBoard_Close() function is called, or after the _ClipBoard_SetData() function is called with the same clipboard format.

Related

_ClipBoard_GetData, _ClipBoard_SetData

See Also

Search GetClipboardData in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $id_SetData, $id_GetData, $hMemory, $tData

    ; Create GUI
    $hGUI = GUICreate("Clipboard", 600, 450)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    $id_SetData = GUICtrlCreateButton("Set ClipBoard Data", 150, 410, 120, 30)
    $id_GetData = GUICtrlCreateButton("Get ClipBoard Data", 300, 410, 120, 30)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $id_SetData
                _ClipBoard_SetData("ClipBoard Library")
            Case $id_GetData
                ; Open the clipboard
                If _ClipBoard_Open($hGUI) Then

                    ; Read clipboard text
                    $hMemory = _ClipBoard_GetDataEx($CF_TEXT)
                    If $hMemory = 0 Then _WinAPI_ShowError("_ClipBoard_GetDataEx failed")
                    $tData = DllStructCreate("char Text[8192]", $hMemory)
                    MemoWrite(DllStructGetData($tData, "Text"))

                    ; Close the clipboard
                    _ClipBoard_Close()
                Else
                    _WinAPI_ShowError("_ClipBoard_Open failed")
                EndIf
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _ClipBoard_GetFormatName

Function Reference

_ClipBoard_GetFormatName

Retrieves the name of the specified registered format

#include <Clipboard.au3>
_ClipBoard_GetFormatName ( $iFormat )

Parameters

$iFormat Specifies the type of format to be retrieved

Return Value

Success: | Format name
Failure: | Empty string

Remarks

The $iFormat parameter must not specify any of the predefined clipboard formats

See Also

Search GetClipboardFormatNameA in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $iFormat

    ; Create GUI
    GUICreate("Clipboard", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Register a new clipboard format
    $iFormat = _ClipBoard_RegisterFormat("AutoIt Library Text")
    If $iFormat <> 0 Then

        ; Show new format
        MemoWrite(_ClipBoard_GetFormatName($iFormat))
    Else
        _WinAPI_ShowError("_ClipBoard_RegisterFormat failed")
    EndIf

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _ClipBoard_GetOpenWindow

Function Reference

_ClipBoard_GetOpenWindow

Retrieves the handle to the window that currently has the clipboard open

#include <Clipboard.au3>
_ClipBoard_GetOpenWindow ( )

Return Value

Success: | The handle to the window that has the clipboard open
Failure: | 0 if no window has the clipboard open

Remarks

If an application or DLL specifies a NULL window handle when calling the _ClipBoard_Open() function, the clipboard is opened but is not associated with a window. In such a case, _ClipBoard_GetOpenWindow() returns 0.

Related

_ClipBoard_GetOwner, _ClipBoard_Open

See Also

Search GetOpenClipboardWindow in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Clipboard", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Open the clipboard
    If _ClipBoard_Open($hGUI) Then

        ShowData($hGUI)

        ; Close the clipboard
        _ClipBoard_Close()
    Else
        _WinAPI_ShowError("_ClipBoard_Open failed")
    EndIf

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Show clipboard statistics
Func ShowData($hGUI)
    MemoWrite("GUI handle ............: " & $hGUI)
    MemoWrite("Clipboard owner .......: " & _ClipBoard_GetOwner())
    MemoWrite("Clipboard open window .: " & _ClipBoard_GetOpenWindow())
    MemoWrite("Clipboard sequence ....: " & _ClipBoard_GetSequenceNumber())
    MemoWrite()
EndFunc   ;==>ShowData

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _ClipBoard_GetOwner

Function Reference

_ClipBoard_GetOwner

Retrieves the window handle of the current owner of the clipboard

#include <Clipboard.au3>
_ClipBoard_GetOwner ( )

Return Value

Success: | The handle to the window that owns the clipboard
Failure: | 0

Remarks

The clipboard can still contain data even if the clipboard is not currently owned. In general, the clipboard owner is the window that last placed data in clipboard.
The _ClipBoard_Empty() function assigns clipboard ownership.

Related

_ClipBoard_Empty, _ClipBoard_GetOpenWindow

See Also

Search GetClipboardOwner in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Clipboard", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Open the clipboard
    If _ClipBoard_Open($hGUI) Then

        ShowData($hGUI)

        ; Close the clipboard
        _ClipBoard_Close()
    Else
        _WinAPI_ShowError("_ClipBoard_Open failed")
    EndIf

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Show clipboard statistics
Func ShowData($hGUI)
    MemoWrite("GUI handle ............: " & $hGUI)
    MemoWrite("Clipboard owner .......: " & _ClipBoard_GetOwner())
    MemoWrite("Clipboard open window .: " & _ClipBoard_GetOpenWindow())
    MemoWrite("Clipboard sequence ....: " & _ClipBoard_GetSequenceNumber())
    MemoWrite()
EndFunc   ;==>ShowData

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _ClipBoard_GetPriorityFormat

Function Reference

_ClipBoard_GetPriorityFormat

Retrieves the first available clipboard format in the specified list

#include <Clipboard.au3>
_ClipBoard_GetPriorityFormat ( $aFormats )

Parameters

$aFormats Array with the following format:
[0] - Number of formats (n)
[1] - Format 1
[2] - Format 2
[n] - Format n

Return Value

Success: | The first clipboard format in the list for which data is available
Failure: | Format not found due to: -1 - Clipboard has data, but not in any of the formats requested 0 - Clipboard is empty

Related

_ClipBoard_CountFormats, _ClipBoard_EnumFormats

See Also

Search GetPriorityClipboardFormat in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $aFormats[3] = [2, $CF_TEXT, $CF_OEMTEXT]

    ; Create GUI
    GUICreate("Clipboard", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; See if there is any text in the clipboard
    MemoWrite("Priority formats .:. " & _ClipBoard_GetPriorityFormat($aFormats))
    MemoWrite("Unicode available .: " & _ClipBoard_IsFormatAvailable($CF_UNICODETEXT))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _ClipBoard_GetSequenceNumber

Function Reference

_ClipBoard_GetSequenceNumber

Retrieves the clipboard sequence number for the current window station

#include <Clipboard.au3>
_ClipBoard_GetSequenceNumber ( )

Return Value

Success: | The clipboard sequence number
Failure: | 0

Remarks

The system keeps a serial number for the clipboard for each window station. This number is incremented when the contents of the clipboard change or the clipboard is emptied. You can track this value to determine if the clipboard contents have changed and optimize creating data objects. If clipboard rendering is delayed, the sequence number is not incremented until the changes are rendered.

See Also

Search GetClipboardSequenceNumber in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Clipboard", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Open the clipboard
    If _ClipBoard_Open($hGUI) Then

        ShowData($hGUI)

        ; Close the clipboard
        _ClipBoard_Close()
    Else
        _WinAPI_ShowError("_ClipBoard_Open failed")
    EndIf

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Show clipboard statistics
Func ShowData($hGUI)
    MemoWrite("GUI handle ............: " & $hGUI)
    MemoWrite("Clipboard owner .......: " & _ClipBoard_GetOwner())
    MemoWrite("Clipboard open window .: " & _ClipBoard_GetOpenWindow())
    MemoWrite("Clipboard sequence ....: " & _ClipBoard_GetSequenceNumber())
    MemoWrite()
EndFunc   ;==>ShowData

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _ClipBoard_GetViewer

Function Reference

_ClipBoard_GetViewer

Retrieves the handle to the first window in the clipboard viewer chain

#include <Clipboard.au3>
_ClipBoard_GetViewer ( )

Return Value

Success: | The handle to the first window in the clipboard viewer chain
Failure: | 0 if there is no clipboard viewer

Related

_ClipBoard_SetViewer

See Also

Search GetClipboardViewer in MSDN Library.

Example

#include <Clipboard.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_hNext = 0

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Clipboard", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize clipboard viewer
    $g_hNext = _ClipBoard_SetViewer($hGUI)

    GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN")
    GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD")

    MemoWrite("GUI handle ....: " & $hGUI)
    MemoWrite("Viewer handle .: " & _ClipBoard_GetViewer())

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Shut down clipboard viewer
    _ClipBoard_ChangeChain($hGUI, $g_hNext)
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Handle $WM_CHANGECBCHAIN messages
Func WM_CHANGECBCHAIN($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    ; Show that message was received
    MemoWrite("***** $WM_CHANGECBCHAIN *****")

    ; If the next window is closing, repair the chain
    If $wParam = $g_hNext Then
        $g_hNext = $lParam
        ; Otherwise pass the message to the next viewer
    ElseIf $g_hNext <> 0 Then
        _SendMessage($g_hNext, $WM_CHANGECBCHAIN, $wParam, $lParam, 0, "hwnd", "hwnd")
    EndIf
EndFunc   ;==>WM_CHANGECBCHAIN

; Handle $WM_DRAWCLIPBOARD messages
Func WM_DRAWCLIPBOARD($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    ; Display any text on clipboard
    MemoWrite(_ClipBoard_GetData())

    ; Pass the message to the next viewer
    If $g_hNext <> 0 Then _SendMessage($g_hNext, $WM_DRAWCLIPBOARD, $wParam, $lParam)
EndFunc   ;==>WM_DRAWCLIPBOARD


Function _ClipBoard_IsFormatAvailable

Function Reference

_ClipBoard_IsFormatAvailable

Determines whether the clipboard contains data in the specified format

#include <Clipboard.au3>
_ClipBoard_IsFormatAvailable ( $iFormat )

Parameters

$iFormat Specifies a standard or registered clipboard format

Return Value

Success: | True - Clipboard contains data in the specified format
Failure: | False - Clipboard does not contain data in the specified format

See Also

Search IsClipboardFormatAvailable in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $aFormats[3] = [2, $CF_TEXT, $CF_OEMTEXT]

    ; Create GUI
    GUICreate("Clipboard", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; See if there is any text in the clipboard
    MemoWrite("Priority formats .:. " & _ClipBoard_GetPriorityFormat($aFormats))
    MemoWrite("Unicode available .: " & _ClipBoard_IsFormatAvailable($CF_UNICODETEXT))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _ClipBoard_Open

Function Reference

_ClipBoard_Open

Opens the clipboard and prevents other applications from modifying the clipboard

#include <Clipboard.au3>
_ClipBoard_Open ( $hOwner )

Parameters

$hOwner Handle to the window to be associated with the open clipboard. If this parameter is 0, the open clipboard is associated with the current task.

Return Value

Success: | True
Failure: | False

Remarks

This function fails if another window has the clipboard open. Call the _ClipBoard_Close() function after every successful call to this function.
The window identified by the $hOwner parameter does not become the clipboard owner unless the _ClipBoard_Empty() function is called. If you call _ClipBoard_Open() with hwnd set to 0, _ClipBoard_Empty() sets the clipboard owner to 0 which causes _ClipBoard_SetData() to fail.

Related

_ClipBoard_Close, _ClipBoard_Empty, _ClipBoard_EnumFormats, _ClipBoard_GetOpenWindow, _ClipBoard_SetDataEx

See Also

Search OpenClipboard in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Clipboard", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Open the clipboard
    If _ClipBoard_Open($hGUI) Then

        ShowData($hGUI)

        ; Close the clipboard
        _ClipBoard_Close()
    Else
        _WinAPI_ShowError("_ClipBoard_Open failed")
    EndIf

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Show clipboard statistics
Func ShowData($hGUI)
    MemoWrite("GUI handle ............: " & $hGUI)
    MemoWrite("Clipboard owner .......: " & _ClipBoard_GetOwner())
    MemoWrite("Clipboard open window .: " & _ClipBoard_GetOpenWindow())
    MemoWrite("Clipboard sequence ....: " & _ClipBoard_GetSequenceNumber())
    MemoWrite()
EndFunc   ;==>ShowData

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _ClipBoard_RegisterFormat

Function Reference

_ClipBoard_RegisterFormat

Registers a new clipboard format

#include <Clipboard.au3>
_ClipBoard_RegisterFormat ( $sFormat )

Parameters

$sFormat The name of the new format

Return Value

Success: | The registered clipboard format
Failure: | 0

Remarks

If a registered format with the specified name already exists, a new format is not registered and the return value identifies the existing format. This enables more than one application to copy and paste data using the same registered clipboard format. Note that the format name comparison is case-insensitive.

Related

_ClipBoard_EnumFormats

See Also

Search RegisterClipboardFormat in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $iFormat

    ; Create GUI
    GUICreate("Clipboard", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Register a new clipboard format
    $iFormat = _ClipBoard_RegisterFormat("AutoIt Library Text")
    If $iFormat <> 0 Then

        ; Show new format
        MemoWrite(_ClipBoard_GetFormatName($iFormat))
    Else
        _WinAPI_ShowError("_ClipBoard_RegisterFormat failed")
    EndIf

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _ClipBoard_SetData

Function Reference

_ClipBoard_SetData

Places data on the clipboard in a specified clipboard format

#include <Clipboard.au3>
_ClipBoard_SetData ( $vData [, $iFormat = 1] )

Parameters

$vData Data in Binary or String format, or optionally NULL (0) (owner must render, see below).
IMPORTANT: If a String is passed, and it is not of type $CF_TEXT, $CF_OEMTEXT, or $CF_UNICODETEXT, it will be treated as an ANSI string.
To force Unicode strings for other types, you must pass the data in Binary format.
Also, do NOT pass $CF_UNICODETEXT in Binary format (causes garbled data).
When $vData is NULL, it indicates that the window provides data in the specified clipboard format upon request.
If a window delays rendering, it must process the $WM_RENDERFORMAT and $WM_RENDERALLFORMATS messages.
If this function succeeds, the system owns the object identified by the $hMemory parameter.
The application may not write to or free the data once ownership has been transferred to the system, but it can lock and read from the data until the _ClipBoard_Close() function is called.
The memory must be unlocked before the clipboard is closed.
If the $hMemory parameter identifies a memory object, the object must have been allocated using the function with the $GMEM_MOVEABLE flag.
$iFormat [optional] Specifies a clipboard format:
$CF_TEXT - Text format
$CF_BITMAP - Handle to a bitmap (HBITMAP)
$CF_METAFILEPICT - Handle to a metafile picture (METAFILEPICT)
$CF_SYLK - Microsoft Symbolic Link (SYLK) format
$CF_DIF - Software Arts' Data Interchange Format
$CF_TIFF - Tagged image file format
$CF_OEMTEXT - Text format containing characters in the OEM character set
$CF_DIB - BITMAPINFO structure followed by the bitmap bits
$CF_PALETTE - Handle to a color palette
$CF_PENDATA - Data for the pen extensions to Pen Computing
$CF_RIFF - Represents audio data in RIFF format
$CF_WAVE - Represents audio data in WAVE format
$CF_UNICODETEXT - Unicode text format
$CF_ENHMETAFILE - Handle to an enhanced metafile (HENHMETAFILE)
$CF_HDROP - Handle to type HDROP that identifies a list of files
$CF_LOCALE - Handle to the locale identifier associated with text in the clipboard
$CF_DIBV5 - BITMAPV5HEADER structure followed by bitmap color and the bitmap bits
$CF_OWNERDISPLAY - Owner display format
$CF_DSPTEXT - Text display format associated with a private format
$CF_DSPBITMAP - Bitmap display format associated with a private format
$CF_DSPMETAFILEPICT - Metafile picture display format associated with a private format
$CF_DSPENHMETAFILE - Enhanced metafile display format associated with a private format

Return Value

Success: | The handle to the data
Failure: | 0

Remarks

This function performs all of the steps neccesary to put data on the clipboard. It will allocate the global memory object, open the clipboard, place the data on the clipboard and close the clipboard. If you need more control over putting data on the clipboard, you may want to use the _ClipBoard_SetDataEx() function.

Related

_ClipBoard_Empty, _ClipBoard_GetData, _ClipBoard_GetDataEx, _ClipBoard_SetDataEx

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $id_SetData, $id_GetData

    ; Create GUI
    GUICreate("Clipboard", 600, 450)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    $id_SetData = GUICtrlCreateButton("Set ClipBoard Data", 150, 410, 120, 30)
    $id_GetData = GUICtrlCreateButton("Get ClipBoard Data", 300, 410, 120, 30)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $id_SetData
                _ClipBoard_SetData("ClipBoard Library")
            Case $id_GetData
                MemoWrite(_ClipBoard_GetData())
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _ClipBoard_SetDataEx

Function Reference

_ClipBoard_SetDataEx

Places data on the clipboard in a specified clipboard format

#include <Clipboard.au3>
_ClipBoard_SetDataEx ( ByRef $hMemory [, $iFormat = 1] )

Parameters

$hMemory Handle to the data in the specified format. This parameter can be NULL, indicating that the window provides data in the specified clipboard format upon request.
If a window delays rendering, it must process the $WM_RENDERFORMAT and $WM_RENDERALLFORMATS messages.
If this function succeeds, the system owns the object identified by the $hMemory parameter.
The application may not write to or free the data once ownership has been transferred to the system, but it can lock and read from the data until the _ClipBoard_Close() function is called.
The memory must be unlocked before the clipboard is closed.
If the $hMemory parameter identifies a memory object, the object must have been allocated using the function with the $GMEM_MOVEABLE flag.
$iFormat [optional] Specifies a clipboard format:
$CF_TEXT - Text format
$CF_BITMAP - Handle to a bitmap (HBITMAP)
$CF_METAFILEPICT - Handle to a metafile picture (METAFILEPICT)
$CF_SYLK - Microsoft Symbolic Link (SYLK) format
$CF_DIF - Software Arts' Data Interchange Format
$CF_TIFF - Tagged image file format
$CF_OEMTEXT - Text format containing characters in the OEM character set
$CF_DIB - BITMAPINFO structure followed by the bitmap bits
$CF_PALETTE - Handle to a color palette
$CF_PENDATA - Data for the pen extensions to Pen Computing
$CF_RIFF - Represents audio data in RIFF format
$CF_WAVE - Represents audio data in WAVE format
$CF_UNICODETEXT - Unicode text format
$CF_ENHMETAFILE - Handle to an enhanced metafile (HENHMETAFILE)
$CF_HDROP - Handle to type HDROP that identifies a list of files
$CF_LOCALE - Handle to the locale identifier associated with text in the clipboard
$CF_DIBV5 - BITMAPV5HEADER structure followed by bitmap color and the bitmap bits
$CF_OWNERDISPLAY - Owner display format
$CF_DSPTEXT - Text display format associated with a private format
$CF_DSPBITMAP - Bitmap display format associated with a private format
$CF_DSPMETAFILEPICT - Metafile picture display format associated with a private format
$CF_DSPENHMETAFILE - Enhanced metafile display format associated with a private format

Return Value

Success: | The handle to the data
Failure: | 0

Remarks

The $iFormat parameter can identify a registered clipboard format, or it can be one of the standard clipboard formats.
If an application calls this function in response to $WM_RENDERFORMAT or $WM_RENDERALLFORMATS, the application should not use the handle after this function has been called.
If an application calls _ClipBoard_Open() with a NULL handle, _ClipBoard_Empty() sets the clipboard owner to NULL; this causes this function to fail.

Related

_ClipBoard_Empty, _ClipBoard_GetData, _ClipBoard_Open, _ClipBoard_SetData

See Also

Search SetClipboardData in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $id_SetData, $id_GetData, $hMemory, $hLock, $tData, $sData, $iSize

    ; Create GUI
    GUICreate("Clipboard", 600, 450)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    $id_SetData = GUICtrlCreateButton("Set ClipBoard Data", 150, 410, 120, 30)
    $id_GetData = GUICtrlCreateButton("Get ClipBoard Data", 300, 410, 120, 30)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $id_SetData
                ; Open clipboard
                If _ClipBoard_Open(0) Then

                    ; Empty clipboard
                    If _ClipBoard_Empty() Then

                        ; Create global memory buffer (show why using _ClipBoard_SetData is MUCH easier!)
                        $sData = "Hello from AutoIt"
                        $iSize = StringLen($sData) + 1
                        $hMemory = _MemGlobalAlloc($iSize, $GHND)
                        If $hMemory <> 0 Then
                            $hLock = _MemGlobalLock($hMemory)
                            If $hLock = 0 Then _WinAPI_ShowError("_Mem_GlobalLock failed")
                            $tData = DllStructCreate("char Text[" & $iSize & "]", $hLock)
                            DllStructSetData($tData, "Text", $sData)
                            _MemGlobalUnlock($hMemory)

                            ; Write clipboard text
                            If Not _ClipBoard_SetDataEx($hMemory, $CF_TEXT) Then _WinAPI_ShowError("_ClipBoard_SetDataEx failed")
                        Else
                            _WinAPI_ShowError("_Mem_GlobalAlloc failed")
                        EndIf

                        ; Close clipboard
                        _ClipBoard_Close()
                    Else
                        ; Close clipboard
                        _ClipBoard_Close()
                        _WinAPI_ShowError("_ClipBoard_Empty failed")
                    EndIf
                Else
                    _WinAPI_ShowError("_ClipBoard_Open failed")
                EndIf

            Case $id_GetData
                MemoWrite(_ClipBoard_GetData())
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _ClipBoard_SetViewer

Function Reference

_ClipBoard_SetViewer

Adds the specified window to the chain of clipboard viewers

#include <Clipboard.au3>
_ClipBoard_SetViewer ( $hViewer )

Parameters

$hViewer Handle to the window to be added to the clipboard chain

Return Value

Success: | The handle to the next window in the clipboard viewer chain
Failure: | 0 if there is no clipboard viewer

Remarks

The windows that are part of the clipboard viewer chain must process the clipboard messages $WM_CHANGECBCHAIN and $WM_DRAWCLIPBOARD.
Each clipboard viewer window calls the _SendMessage() function to pass these messages to the next window in the clipboard viewer chain.
A clipboard viewer window must eventually remove itself from the clipboard viewer chain by calling the _ClipBoard_ChangeChain() function.

Related

_ClipBoard_ChangeChain, _ClipBoard_GetViewer

See Also

Search SetClipboardViewer in MSDN Library.

Example

#include <Clipboard.au3>
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_hNext = 0

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Clipboard", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize clipboard viewer
    $g_hNext = _ClipBoard_SetViewer($hGUI)

    GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN")
    GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD")

    MemoWrite("GUI handle ....: " & $hGUI)
    MemoWrite("Viewer handle .: " & _ClipBoard_GetViewer())

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Shut down clipboard viewer
    _ClipBoard_ChangeChain($hGUI, $g_hNext)
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Handle $WM_CHANGECBCHAIN messages
Func WM_CHANGECBCHAIN($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    ; Show that message was received
    MemoWrite("***** $WM_CHANGECBCHAIN *****")

    ; If the next window is closing, repair the chain
    If $wParam = $g_hNext Then
        $g_hNext = $lParam
        ; Otherwise pass the message to the next viewer
    ElseIf $g_hNext <> 0 Then
        _SendMessage($g_hNext, $WM_CHANGECBCHAIN, $wParam, $lParam, 0, "hwnd", "hwnd")
    EndIf
EndFunc   ;==>WM_CHANGECBCHAIN

; Handle $WM_DRAWCLIPBOARD messages
Func WM_DRAWCLIPBOARD($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    ; Display any text on clipboard
    MemoWrite(_ClipBoard_GetData())

    ; Pass the message to the next viewer
    If $g_hNext <> 0 Then _SendMessage($g_hNext, $WM_DRAWCLIPBOARD, $wParam, $lParam)
EndFunc   ;==>WM_DRAWCLIPBOARD


User Defined Functions

Color user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIGdi.au3>.

User Defined Function | Description
_ColorConvertHSLtoRGB | Converts HSL to RGB
_ColorConvertRGBtoHSL | Converts RGB to HSL
_ColorGetBlue | Returns the blue component of a given color
_ColorGetCOLORREF | Returns the COLORREF color
_ColorGetGreen | Returns the green component of a given color
_ColorGetRed | Returns the red component of a given color
_ColorGetRGB | Returns an array containing RGB values in their respective positions
_ColorSetCOLORREF | Returns the COLORREF color
_ColorSetRGB | Returns the RGB color


Function _ColorConvertHSLtoRGB

Function Reference

_ColorConvertHSLtoRGB

Converts HSL to RGB

#include <Color.au3>
_ColorConvertHSLtoRGB ( $aArray )

Parameters

$aArray An array containing HSL values in their respective positions

Return Value

Success: | the array containing the RGB values for the inputted HSL values.
Failure: | sets the @error flag to non-zero.

Remarks

See: EasyRGB - Color mathematics and conversion formulas.

Related

_ColorConvertRGBtoHSL

Example

#include <Color.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aiInput[3] = [120, 180, 160], $aiHSL, $aiRGB, $sOutput

    $aiRGB = _ColorConvertHSLtoRGB($aiInput)
    $aiHSL = _ColorConvertRGBtoHSL($aiRGB)

    $sOutput &= StringFormat("| H: %.3f" & @TAB & "| R: %.3f" & @TAB & "| H: %.3f" & @CRLF, $aiInput[0], $aiRGB[0], $aiHSL[0])
    $sOutput &= StringFormat("| S: %.3f" & @TAB & "| G: %.3f" & @TAB & "| S: %.3f" & @CRLF, $aiInput[1], $aiRGB[1], $aiHSL[1])
    $sOutput &= StringFormat("| L: %.3f" & @TAB & "| B: %.3f" & @TAB & "| L: %.3f" & @CRLF, $aiInput[2], $aiRGB[2], $aiHSL[2])
    MsgBox($MB_SYSTEMMODAL, "AutoIt", $sOutput)
EndFunc   ;==>Example


Function _ColorConvertRGBtoHSL

Function Reference

_ColorConvertRGBtoHSL

Converts RGB to HSL

#include <Color.au3>
_ColorConvertRGBtoHSL ( $aArray )

Parameters

$aArray An array containing RGB values in their respective positions

Return Value

Success: | the array containing the HSL values for the inputted RGB values
Failure: | sets the @error flag to non-zero.

Remarks

See: EasyRGB - Color mathematics and conversion formulas.

Related

_ColorConvertHSLtoRGB

Example

#include <Color.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aiInput[3] = [128, 255, 128], $aiHSL, $aiRGB, $sOutput

    $aiHSL = _ColorConvertRGBtoHSL($aiInput)
    $aiRGB = _ColorConvertHSLtoRGB($aiHSL)

    $sOutput &= StringFormat("| R: %.3f" & @TAB & "| H: %.3f" & @TAB & "| R: %.3f" & @CRLF, $aiInput[0], $aiHSL[0], $aiRGB[0])
    $sOutput &= StringFormat("| G: %.3f" & @TAB & "| S: %.3f" & @TAB & "| G: %.3f" & @CRLF, $aiInput[1], $aiHSL[1], $aiRGB[1])
    $sOutput &= StringFormat("| B: %.3f" & @TAB & "| L: %.3f" & @TAB & "| B: %.3f" & @CRLF, $aiInput[2], $aiHSL[2], $aiRGB[2])
    MsgBox($MB_SYSTEMMODAL, "AutoIt", $sOutput)
EndFunc   ;==>Example


Function _ColorGetBlue

Function Reference

_ColorGetBlue

Returns the blue component of a given color

#include <Color.au3>
_ColorGetBlue ( $iColor )

Parameters

$iColor The RGB color to work with (0x00RRGGBB).

Return Value

Returns the component color in the range 0-255.

Related

_ColorGetGreen, _ColorGetRed, _ColorGetRGB

Example

#include <Color.au3>
#include <MsgBoxConstants.au3>

Local $iBlueColor = _ColorGetBlue(0x8080ff)
MsgBox($MB_SYSTEMMODAL, "AutoIt", $iBlueColor)


Function _ColorGetCOLORREF

Function Reference

_ColorGetCOLORREF

Returns the COLORREF color

#include <Color.au3>
_ColorGetCOLORREF ( $iColor )

Parameters

$iColor the COLORREF color to work with (0x00BBGGRR)

Return Value

Success: | an array of values in the range 0-255: [0] Red component color [1] Green component color [2] Blue component color
Failure: | sets the @error flag to non-zero.

Remarks

@extended is preserved.

Related

_ColorSetCOLORREF

Example

#include <Color.au3>
#include <MsgBoxConstants.au3>

Local $iColor = 0x8090FF

Local $aColor = _ColorGetCOLORREF($iColor)
MsgBox($MB_SYSTEMMODAL, "", "Color=" & Hex($iColor) & @CRLF & @CRLF & "Red=" & Hex($aColor[0], 2) & " Green=" & Hex($aColor[1], 2) & " Blue=" & Hex($aColor[2], 2))


Function _ColorGetGreen

Function Reference

_ColorGetGreen

Returns the green component of a given color

#include <Color.au3>
_ColorGetGreen ( $iColor )

Parameters

$iColor The RGB color to work with (0x00RRGGBB).

Return Value

Returns the component color in the range 0-255.

Related

_ColorGetBlue, _ColorGetRed, _ColorGetRGB

Example

#include <Color.au3>
#include <MsgBoxConstants.au3>

Local $iGreenColor = _ColorGetGreen(0x8080ff)
MsgBox($MB_SYSTEMMODAL, "AutoIt", $iGreenColor)


Function _ColorGetRed

Function Reference

_ColorGetRed

Returns the red component of a given color

#include <Color.au3>
_ColorGetRed ( $iColor )

Parameters

$iColor The RGB color to work with (0x00RRGGBB).

Return Value

Returns the component color in the range 0-255.

Related

_ColorGetBlue, _ColorGetGreen, _ColorGetRGB

Example

#include <Color.au3>
#include <MsgBoxConstants.au3>

Local $iRedColor = _ColorGetRed(0x8080ff)
MsgBox($MB_SYSTEMMODAL, "AutoIt", $iRedColor)


Function _ColorGetRGB

Function Reference

_ColorGetRGB

Returns an array containing RGB values in their respective positions

#include <Color.au3>
_ColorGetRGB ( $iColor )

Parameters

$iColor The RGB color to work with (0x00RRGGBB).

Return Value

Success: | an array of values in the range 0-255: [0] Red component color [1] Green component color [2] Blue component color
Failure: | sets the @error flag to non-zero.

Related

_ColorGetBlue, _ColorGetGreen, _ColorGetRed, _ColorSetRGB

Example

#include <Color.au3>
#include <MsgBoxConstants.au3>

Local $nColor = 0x8090ff

Local $aColor = _ColorGetRGB($nColor)
MsgBox($MB_SYSTEMMODAL, "AutoIt", "Color=" & Hex($nColor) & @CRLF & " Red=" & Hex($aColor[0], 2) & " Blue=" & Hex($aColor[1], 2) & " Green=" & Hex($aColor[2], 2))


Function _ColorSetCOLORREF

Function Reference

_ColorSetCOLORREF

Returns the COLORREF color

#include <Color.au3>
_ColorSetCOLORREF ( $aColor )

Parameters

$aColor an array of values in the range 0-255:
[0] Red component color
[1] Green component color
[2] Blue component color

Return Value

Success: | the COLORREF color to work with 0x00BBGGRR.
Failure: | sets the @error flag to non-zero.
@error: | 1 invalid array 2 invalid color value

Remarks

@extended is preserved.

Related

_ColorGetCOLORREF, _ColorSetRGB

Example

#include <Color.au3>
#include <MsgBoxConstants.au3>

Local $aColor[3] = [0x80, 0x90, 0xff]

Local $nColor = _ColorSetCOLORREF($aColor)
MsgBox($MB_SYSTEMMODAL, "AutoIt", " Red=" & Hex($aColor[0], 2) & " Green=" & Hex($aColor[1], 2) & " Blue=" & Hex($aColor[2], 2) & @CRLF & _
        "ColorREF=" & Hex($nColor))


Function _ColorSetRGB

Function Reference

_ColorSetRGB

Returns the RGB color

#include <Color.au3>
_ColorSetRGB ( $aColor )

Parameters

$aColor an array of values in the range 0-255:
[0] Red component color
[1] Green component color
[2] Blue component color

Return Value

Success: | the RGB color to work with 0x00RRGGBB.
Failure: | sets the @error flag to non-zero.
@error: | 1 invalid array 2 invalid color value

Remarks

@extended is preserved.

Related

_ColorGetRGB

Example

#include <Color.au3>
#include <MsgBoxConstants.au3>

Local $aColor[3] = [0x80, 0x90, 0xff]

Local $nColor = _ColorSetRGB($aColor)
MsgBox($MB_SYSTEMMODAL, "AutoIt", " Red=" & Hex($aColor[0], 2) & " Green=" & Hex($aColor[1], 2) & " Blue=" & Hex($aColor[2], 2) & @CRLF & _
        "Color=" & Hex($nColor))


User Defined Functions

Crypt user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <Crypt.au3>.

User Defined Function | Description
_Crypt_DecryptData | Decrypts data using the supplied key
_Crypt_DecryptFile | Decrypts a file with specified key and algorithm
_Crypt_DeriveKey | Creates a key from algorithm and password
_Crypt_DestroyKey | Frees the resources used by a key
_Crypt_EncryptData | Encrypts data using the supplied key
_Crypt_EncryptFile | Encrypts a file with specified key and algorithm
_Crypt_GenRandom | Fill a buffer with cryptographically random data
_Crypt_HashData | Hash data with specified algorithm
_Crypt_HashFile | Hash a string with specified algorithm
_Crypt_Shutdown | Uninitialize the Crypt library
_Crypt_Startup | Initialize the Crypt library


Function _Crypt_DecryptData

Function Reference

_Crypt_DecryptData

Decrypts data using the supplied key

#include <Crypt.au3>
_Crypt_DecryptData ( $vData, $vCryptKey, $iAlgID [, $bFinal = True] )

Parameters

$vData | Data to decrypt
$vCryptKey | Password or handle to a key if the CALG_USERKEY flag is specified
$iAlgID | The algorithm to use
$bFinal | [optional] False if this is only a segment of the full data

Return Value

Success: | a binary string containing decrypted data.
Failure: | sets the @error flag to non-zero.
@error: | 100+ - Cannot create key 20 - Failed to decrypt data

Remarks

The decrypted data is always returned as a binary string even if the encrypted data is in fact a string (cast with BinaryToString()).

Related

_Crypt_DeriveKey, _Crypt_EncryptData

See Also

Search CryptDecrypt in MSDN Library.

Example

#include <Crypt.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local Const $sUserKey = "CryptPassword" ; Declare a password string to decrypt/encrypt the data.
    Local $sData = "..upon a time there was a language without any standardized cryptographic functions. That language is no more." ; Data that will be encrypted.

    Local $bEncrypted = _Crypt_EncryptData($sData, $sUserKey, $CALG_RC4) ; Encrypt the data using the generic password string.

    $bEncrypted = _Crypt_DecryptData($bEncrypted, $sUserKey, $CALG_RC4) ; Decrypt the data using the generic password string. The return value is a binary string.
    MsgBox($MB_SYSTEMMODAL, "Decrypted data", BinaryToString($bEncrypted)) ; Convert the binary string using BinaryToString to display the initial data we encrypted.
EndFunc   ;==>Example


Function _Crypt_DecryptFile

Function Reference

_Crypt_DecryptFile

Decrypts a file with specified key and algorithm

#include <Crypt.au3>
_Crypt_DecryptFile ( $sSourceFile, $sDestinationFile, $vCryptKey, $iAlgID )

Parameters

$sSourceFile | File to process
$sDestinationFile | File to save the processed file
$vCryptKey | Password or handle to a key if the CALG_USERKEY flag is specified
$iAlgID | The algorithm to use

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 10+ - Failed to create key 2 - Failed to open source file 3 - Failed to open destination file 400+ - Failed to decrypt final piece 500+ - Failed to decrypt piece

Related

_Crypt_DeriveKey, _Crypt_EncryptFile

Example

#include <ComboConstants.au3>
#include <Crypt.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

Example()

Func Example()
    Local $iAlgorithm = $CALG_RC4

    Local $hGUI = GUICreate("File Decrypter", 425, 100)
    Local $idSourceInput = GUICtrlCreateInput("", 5, 5, 200, 20)
    Local $idSourceBrowse = GUICtrlCreateButton("...", 210, 5, 35, 20)

    Local $idDestinationInput = GUICtrlCreateInput("", 5, 30, 200, 20)
    Local $idDestinationBrowse = GUICtrlCreateButton("...", 210, 30, 35, 20)

    GUICtrlCreateLabel("Password:", 5, 60, 200, 20)
    Local $idPasswordInput = GUICtrlCreateInput("", 5, 75, 200, 20)

    Local $idCombo = GUICtrlCreateCombo("", 210, 75, 100, 20, $CBS_DROPDOWNLIST)
    GUICtrlSetData($idCombo, "3DES|AES (128bit)|AES (192bit)|AES (256bit)|DES|RC2|RC4", "RC4")
    Local $idDecrypt = GUICtrlCreateButton("Decrypt", 355, 70, 65, 25)
    GUISetState(@SW_SHOW, $hGUI)

    Local $sDestinationRead = "", $sFilePath = "", $sPasswordRead = "", $sSourceRead = ""
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idSourceBrowse
                $sFilePath = FileOpenDialog("Select a file to decrypt.", "", "All files (*.*)") ; Select a file to decrypt.
                If @error Then
                    ContinueLoop
                EndIf
                GUICtrlSetData($idSourceInput, $sFilePath) ; Set the inputbox with the filepath.

            Case $idDestinationBrowse
                $sFilePath = FileSaveDialog("Save the file as ...", "", "All files (*.*)") ; Select a file to save the decrypted data to.
                If @error Then
                    ContinueLoop
                EndIf
                GUICtrlSetData($idDestinationInput, $sFilePath) ; Set the inputbox with the filepath.

            Case $idCombo ; Check when the combobox is selected and retrieve the correct algorithm.
                Switch GUICtrlRead($idCombo) ; Read the combobox selection.
                    Case "3DES"
                        $iAlgorithm = $CALG_3DES

                    Case "AES (128bit)"
                        $iAlgorithm = $CALG_AES_128

                    Case "AES (192bit)"
                        $iAlgorithm = $CALG_AES_192

                    Case "AES (256bit)"
                        $iAlgorithm = $CALG_AES_256

                    Case "DES"
                        $iAlgorithm = $CALG_DES

                    Case "RC2"
                        $iAlgorithm = $CALG_RC2

                    Case "RC4"
                        $iAlgorithm = $CALG_RC4

                EndSwitch

            Case $idDecrypt
                $sSourceRead = GUICtrlRead($idSourceInput) ; Read the source filepath input.
                $sDestinationRead = GUICtrlRead($idDestinationInput) ; Read the destination filepath input.
                $sPasswordRead = GUICtrlRead($idPasswordInput) ; Read the password input.
                If StringStripWS($sSourceRead, $STR_STRIPALL) <> "" And StringStripWS($sDestinationRead, $STR_STRIPALL) <> "" And StringStripWS($sPasswordRead, $STR_STRIPALL) <> "" And FileExists($sSourceRead) Then ; Check there is a file available to decrypt and a password has been set.
                    If _Crypt_DecryptFile($sSourceRead, $sDestinationRead, $sPasswordRead, $iAlgorithm) Then ; Decrypt the file.
                        MsgBox($MB_SYSTEMMODAL, "Success", "Operation succeeded.")
                    Else
                        Switch @error
                            Case 1
                                MsgBox($MB_SYSTEMMODAL, "Error", "Failed to create the key.")
                            Case 2
                                MsgBox($MB_SYSTEMMODAL, "Error", "Couldn't open the source file.")
                            Case 3
                                MsgBox($MB_SYSTEMMODAL, "Error", "Couldn't open the destination file.")
                            Case 4 Or 5
                                MsgBox($MB_SYSTEMMODAL, "Error", "Decryption error.")
                        EndSwitch
                    EndIf
                Else
                    MsgBox($MB_SYSTEMMODAL, "Error", "Please ensure the relevant information has been entered correctly.")
                EndIf
        EndSwitch
    WEnd

    GUIDelete($hGUI) ; Delete the previous GUI and all controls.
EndFunc   ;==>Example


Function _Crypt_DeriveKey

Function Reference

_Crypt_DeriveKey

Creates a key from algorithm and password

#include <Crypt.au3>
_Crypt_DeriveKey ( $vPassword, $iAlgID [, $iHashAlgID = $CALG_MD5] )

Parameters

$vPassword | Password to use
$iAlgID | Encryption ID of algorithm to be used with the key
$iHashAlgID | [optional] Id of the algo to hash the password with

Return Value

Success: | a handle to a cryptographic key.
Failure: | -1 and sets the @error flag to non-zero.
@error: | 10 - Failed to create hash object 20 - Failed to hash password 30 - Failed to generate key

Remarks

The key needs to be destroyed with _Crypt_DestroyKey().

Related

_Crypt_DecryptData, _Crypt_DecryptFile, _Crypt_DestroyKey, _Crypt_EncryptData, _Crypt_EncryptFile

See Also

Search CryptDeriveKey in MSDN Library.

Example

#include <Crypt.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aStringsToEncrypt[6] = ["AutoIt", "SciTE", "Crypt", ".au3", 42, "42"]
    Local $sOutput = ""

    Local $hKey = _Crypt_DeriveKey("CryptPassword", $CALG_RC4) ; Declare a password string and algorithm to create a cryptographic key.

    For $iWord In $aStringsToEncrypt
        $sOutput &= $iWord & @TAB & " = " & _Crypt_EncryptData($iWord, $hKey, $CALG_USERKEY) & @CRLF ; Encrypt the text with the cryptographic key.
    Next

    MsgBox($MB_SYSTEMMODAL, "Encrypted data", $sOutput)

    _Crypt_DestroyKey($hKey) ; Destroy the cryptographic key.
EndFunc   ;==>Example


Function _Crypt_DestroyKey

Function Reference

_Crypt_DestroyKey

Frees the resources used by a key

#include <Crypt.au3>
_Crypt_DestroyKey ( $hCryptKey )

Parameters

$hCryptKey Key to destroy

Return Value

Success: | True
Failure: | False and sets the @error flag to non-zero
@error: | 10 - Destroying key failed

Remarks

Destroys a key previously created by _Crypt_DeriveKey()

Related

_Crypt_DeriveKey

See Also

Search CryptDestroyKey in MSDN Library.

Example

#include <Crypt.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aStringsToEncrypt[6] = ["AutoIt", "SciTE", "Crypt", ".au3", 42, "42"]
    Local $sOutput = ""

    Local $hKey = _Crypt_DeriveKey("CryptPassword", $CALG_RC4) ; Declare a password string and algorithm to create a cryptographic key.

    For $iWord In $aStringsToEncrypt
        $sOutput &= $iWord & @TAB & " = " & _Crypt_EncryptData($iWord, $hKey, $CALG_USERKEY) & @CRLF ; Encrypt the text with the cryptographic key.
    Next

    MsgBox($MB_SYSTEMMODAL, "Encrypted data", $sOutput)

    _Crypt_DestroyKey($hKey) ; Destroy the cryptographic key.
EndFunc   ;==>Example


Function _Crypt_EncryptData

Function Reference

_Crypt_EncryptData

Encrypts data using the supplied key

#include <Crypt.au3>
_Crypt_EncryptData ( $vData, $vCryptKey, $iAlgID [, $bFinal = True] )

Parameters

$vData | Data to encrypt/decrypt
$vCryptKey | Password or handle to a key if the CALG_USERKEY flag is specified
$iAlgID | The algorithm to use
$bFinal | [optional] False if this is only a segment of the full data

Return Value

Success: | a binary string containing encrypted data.
Failure: | -1 and sets the @error flag to non-zero.
@error: | 100+ - Cannot create key 20 - Failed to determine buffer 30 - Failed to encrypt data

Remarks

Returns a binary string regardless of input

Related

_Crypt_DecryptData, _Crypt_DeriveKey, _Crypt_EncryptFile

See Also

Search CryptEncrypt in MSDN Library.

Example

Example 1

#include <ComboConstants.au3>
#include <Crypt.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global $g_hKey = -1, $g_idInputEdit = -1, $g_idOutputEdit = -1

Example()

Func Example()
    Local $hGUI = GUICreate("Realtime Encryption", 400, 320)
    $g_idInputEdit = GUICtrlCreateEdit("", 0, 0, 400, 150, $ES_WANTRETURN)
    $g_idOutputEdit = GUICtrlCreateEdit("", 0, 150, 400, 150, $ES_READONLY)
    Local $idCombo = GUICtrlCreateCombo("", 0, 300, 100, 20, $CBS_DROPDOWNLIST)
    GUICtrlSetData($idCombo, "3DES|AES (128bit)|AES (192bit)|AES (256bit)|DES|RC2|RC4", "RC4")
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    GUISetState(@SW_SHOW, $hGUI)

    _Crypt_Startup() ; To optimize performance start the crypt library.

    Local $iAlgorithm = $CALG_RC4
    $g_hKey = _Crypt_DeriveKey("CryptPassword", $iAlgorithm) ; Declare a password string and algorithm to create a cryptographic key.

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit

            Case $idCombo ; Check when the combobox is selected and retrieve the correct algorithm.
                Switch GUICtrlRead($idCombo) ; Read the combobox selection.
                    Case "3DES"
                        $iAlgorithm = $CALG_3DES

                    Case "AES (128bit)"
                        $iAlgorithm = $CALG_AES_128

                    Case "AES (192bit)"
                        $iAlgorithm = $CALG_AES_192

                    Case "AES (256bit)"
                        $iAlgorithm = $CALG_AES_256

                    Case "DES"
                        $iAlgorithm = $CALG_DES

                    Case "RC2"
                        $iAlgorithm = $CALG_RC2

                    Case "RC4"
                        $iAlgorithm = $CALG_RC4

                EndSwitch

                _Crypt_DestroyKey($g_hKey) ; Destroy the cryptographic key.
                $g_hKey = _Crypt_DeriveKey("CryptPassword", $iAlgorithm) ; Re-declare a password string and algorithm to create a new cryptographic key.

                Local $sRead = GUICtrlRead($g_idInputEdit)
                If StringStripWS($sRead, $STR_STRIPALL) <> "" Then ; Check there is text available to encrypt.
                    Local $bEncrypted = _Crypt_EncryptData($sRead, $g_hKey, $CALG_USERKEY) ; Encrypt the text with the new cryptographic key.
                    GUICtrlSetData($g_idOutputEdit, $bEncrypted) ; Set the output box with the encrypted text.
                EndIf
        EndSwitch
    WEnd

    GUIDelete($hGUI) ; Delete the previous GUI and all controls.
    _Crypt_DestroyKey($g_hKey) ; Destroy the cryptographic key.
    _Crypt_Shutdown() ; Shutdown the crypt library.
EndFunc   ;==>Example

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam

    Switch _WinAPI_LoWord($wParam)
        Case $g_idInputEdit
            Switch _WinAPI_HiWord($wParam)
                Case $EN_CHANGE
                    Local $bEncrypted = _Crypt_EncryptData(GUICtrlRead($g_idInputEdit), $g_hKey, $CALG_USERKEY) ; Encrypt the text with the cryptographic key.
                    GUICtrlSetData($g_idOutputEdit, $bEncrypted) ; Set the output box with the encrypted text.
            EndSwitch
    EndSwitch
EndFunc   ;==>WM_COMMAND

Example 2

#include <Crypt.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Encrypt text using a generic password.
    Local $sEncrypted = StringEncrypt(True, 'Encrypt this data.', 'securepassword')

    ; Display the encrypted text.
    MsgBox($MB_SYSTEMMODAL, '', $sEncrypted)

    ; Decrypt the encrypted text using the generic password.
    Local $sDecrypted = StringEncrypt(False, $sEncrypted, 'securepassword')

    ; Display the decrypted text.
    MsgBox($MB_SYSTEMMODAL, '', $sDecrypted)
EndFunc   ;==>Example

Func StringEncrypt($bEncrypt, $sData, $sPassword)
    _Crypt_Startup() ; Start the Crypt library.
    Local $sReturn = ''
    If $bEncrypt Then ; If the flag is set to True then encrypt, otherwise decrypt.
        $sReturn = _Crypt_EncryptData($sData, $sPassword, $CALG_RC4)
    Else
        $sReturn = BinaryToString(_Crypt_DecryptData($sData, $sPassword, $CALG_RC4))
    EndIf
    _Crypt_Shutdown() ; Shutdown the Crypt library.
    Return $sReturn
EndFunc   ;==>StringEncrypt


Function _Crypt_EncryptFile

Function Reference

_Crypt_EncryptFile

Encrypts a file with specified key and algorithm

#include <Crypt.au3>
_Crypt_EncryptFile ( $sSourceFile, $sDestinationFile, $vCryptKey, $iAlgID )

Parameters

$sSourceFile | File to process
$sDestinationFile | File to save the processed file
$vCryptKey | Password or handle to a key if the CALG_USERKEY flag is specified
$iAlgID | The algorithm to use

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 10+ - Failed to create key 2 - Failed to open source file 3 - Failed to open destination file 400+ - Failed to encrypt final piece 500+ - Failed to encrypt piece

Remarks

The the output file can be larger than the input file depending on the algorithm.

Related

_Crypt_DecryptFile, _Crypt_DeriveKey, _Crypt_EncryptData

Example

#include <ComboConstants.au3>
#include <Crypt.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

Example()

Func Example()
    Local $iAlgorithm = $CALG_RC4

    Local $hGUI = GUICreate("File Encrypter", 425, 100)
    Local $idSourceInput = GUICtrlCreateInput("", 5, 5, 200, 20)
    Local $idSourceBrowse = GUICtrlCreateButton("...", 210, 5, 35, 20)

    Local $idDestinationInput = GUICtrlCreateInput("", 5, 30, 200, 20)
    Local $idDestinationBrowse = GUICtrlCreateButton("...", 210, 30, 35, 20)

    GUICtrlCreateLabel("Password:", 5, 60, 200, 20)
    Local $idPasswordInput = GUICtrlCreateInput("", 5, 75, 200, 20)

    Local $idCombo = GUICtrlCreateCombo("", 210, 75, 100, 20, $CBS_DROPDOWNLIST)
    GUICtrlSetData($idCombo, "3DES|AES (128bit)|AES (192bit)|AES (256bit)|DES|RC2|RC4", "RC4")
    Local $idEncrypt = GUICtrlCreateButton("Encrypt", 355, 70, 65, 25)
    GUISetState(@SW_SHOW, $hGUI)

    Local $sDestinationRead = "", $sFilePath = "", $sPasswordRead = "", $sSourceRead = ""
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idSourceBrowse
                $sFilePath = FileOpenDialog("Select a file to encrypt.", "", "All files (*.*)") ; Select a file to encrypt.
                If @error Then
                    ContinueLoop
                EndIf
                GUICtrlSetData($idSourceInput, $sFilePath) ; Set the inputbox with the filepath.

            Case $idDestinationBrowse
                $sFilePath = FileSaveDialog("Save the file as ...", "", "All files (*.*)") ; Select a file to save the encrypted data to.
                If @error Then
                    ContinueLoop
                EndIf
                GUICtrlSetData($idDestinationInput, $sFilePath) ; Set the inputbox with the filepath.

            Case $idCombo ; Check when the combobox is selected and retrieve the correct algorithm.
                Switch GUICtrlRead($idCombo) ; Read the combobox selection.
                    Case "3DES"
                        $iAlgorithm = $CALG_3DES

                    Case "AES (128bit)"
                        $iAlgorithm = $CALG_AES_128

                    Case "AES (192bit)"
                        $iAlgorithm = $CALG_AES_192

                    Case "AES (256bit)"
                        $iAlgorithm = $CALG_AES_256

                    Case "DES"
                        $iAlgorithm = $CALG_DES

                    Case "RC2"
                        $iAlgorithm = $CALG_RC2

                    Case "RC4"
                        $iAlgorithm = $CALG_RC4

                EndSwitch

            Case $idEncrypt
                $sSourceRead = GUICtrlRead($idSourceInput) ; Read the source filepath input.
                $sDestinationRead = GUICtrlRead($idDestinationInput) ; Read the destination filepath input.
                $sPasswordRead = GUICtrlRead($idPasswordInput) ; Read the password input.
                If StringStripWS($sSourceRead, $STR_STRIPALL) <> "" And StringStripWS($sDestinationRead, $STR_STRIPALL) <> "" And StringStripWS($sPasswordRead, $STR_STRIPALL) <> "" And FileExists($sSourceRead) Then ; Check there is a file available to encrypt and a password has been set.
                    If _Crypt_EncryptFile($sSourceRead, $sDestinationRead, $sPasswordRead, $iAlgorithm) Then ; Encrypt the file.
                        MsgBox($MB_SYSTEMMODAL, "Success", "Operation succeeded.")
                    Else
                        Switch @error
                            Case 1
                                MsgBox($MB_SYSTEMMODAL, "Error", "Failed to create the key.")
                            Case 2
                                MsgBox($MB_SYSTEMMODAL, "Error", "Couldn't open the source file.")
                            Case 3
                                MsgBox($MB_SYSTEMMODAL, "Error", "Couldn't open the destination file.")
                            Case 4 Or 5
                                MsgBox($MB_SYSTEMMODAL, "Error", "Encryption error.")
                        EndSwitch
                    EndIf
                Else
                    MsgBox($MB_SYSTEMMODAL, "Error", "Please ensure the relevant information has been entered correctly.")
                EndIf
        EndSwitch
    WEnd

    GUIDelete($hGUI) ; Delete the previous GUI and all controls.
EndFunc   ;==>Example


Function _Crypt_GenRandom

Function Reference

_Crypt_GenRandom

Fill a buffer with cryptographically random data

#include <Crypt.au3>
_Crypt_GenRandom ( $pBuffer, $iSize )

Parameters

$pBuffer | Pointer to buffer to fill with random data.
$iSize | Size of the buffer pointed to by $pBuffer.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.

Remarks

Optionally, the application can fill this buffer with data to use as an auxiliary random seed.

See Also

Search CryptGenRandom in MSDN Library.

Example

#include <Crypt.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Generate 16 bytes of random data
    Local $tBuff = DllStructCreate("byte[16]")
    _Crypt_GenRandom($tBuff, DllStructGetSize($tBuff))
    MsgBox($MB_SYSTEMMODAL, "Random data:", DllStructGetData($tBuff, 1))
EndFunc   ;==>Example


Function _Crypt_HashData

Function Reference

_Crypt_HashData

Hash data with specified algorithm

#include <Crypt.au3>
_Crypt_HashData ( $vData, $iAlgID [, $bFinal = True [, $hCryptHash = 0]] )

Parameters

$vData | Data to hash
$iAlgID | Hash ID to use
$bFinal | [optional] False if this is only a segment of the full data, also makes the function return a hash object instead of hash
$hCryptHash | [optional] Hash object returned from a previous call to _Crypt_HashData()

Return Value

Success: | a hash or hash object if $bFinal = False.
Failure: | -1 and sets the @error flag to non-zero.
@error: | 10 - Failed to create hash object 20 - Failed to hash data 30 - Failed to get hash size 40 - Failed to get hash

Remarks

The hash digest will be returned as a binary string, the size is specified by the algorithm.
To use this with segments of data set the $bFinal flag to False for all non ending segments and use the returned hash object with all subsequent calls.

Related

_Crypt_HashFile

See Also

Search CryptHashData in MSDN Library.

Example

#include <ComboConstants.au3>
#include <Crypt.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StringConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global $g_iAlgorithm = $CALG_SHA1, $g_idInputEdit = -1, $g_idOutputEdit = -1

Example()

Func Example()
    Local $hGUI = GUICreate("Realtime Hashing", 400, 320)
    $g_idInputEdit = GUICtrlCreateEdit("", 0, 0, 400, 150, $ES_WANTRETURN)
    $g_idOutputEdit = GUICtrlCreateEdit("", 0, 150, 400, 150, $ES_READONLY)
    Local $idCombo = GUICtrlCreateCombo("", 0, 300, 100, 20, $CBS_DROPDOWNLIST)
    GUICtrlSetData($idCombo, "MD2|MD4|MD5|SHA1", "SHA1")
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    GUISetState(@SW_SHOW, $hGUI)

    _Crypt_Startup() ; To optimize performance start the crypt library.

    Local $dHash = 0, _
            $sRead = ""
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idCombo ; Check when the combobox is selected and retrieve the correct algorithm.
                Switch GUICtrlRead($idCombo) ; Read the combobox selection.
                    Case "MD2"
                        $g_iAlgorithm = $CALG_MD2

                    Case "MD4"
                        $g_iAlgorithm = $CALG_MD4

                    Case "MD5"
                        $g_iAlgorithm = $CALG_MD5

                    Case "SHA1"
                        $g_iAlgorithm = $CALG_SHA1

                EndSwitch

                $sRead = GUICtrlRead($g_idInputEdit)
                If StringStripWS($sRead, $STR_STRIPALL) <> "" Then ; Check there is text available to hash.
                    $dHash = _Crypt_HashData($sRead, $g_iAlgorithm) ; Create a hash of the text entered.
                    GUICtrlSetData($g_idOutputEdit, $dHash) ; Set the output box with the hash data.
                EndIf
        EndSwitch
    WEnd

    GUIDelete($hGUI) ; Delete the previous GUI and all controls.
    _Crypt_Shutdown() ; Shutdown the crypt library.
EndFunc   ;==>Example

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam

    Switch _WinAPI_LoWord($wParam)
        Case $g_idInputEdit
            Switch _WinAPI_HiWord($wParam)
                Case $EN_CHANGE
                    Local $dHash = _Crypt_HashData(GUICtrlRead($g_idInputEdit), $g_iAlgorithm) ; Create a hash of the text entered.
                    GUICtrlSetData($g_idOutputEdit, $dHash) ; Set the output box with the hash data.
            EndSwitch
    EndSwitch
EndFunc   ;==>WM_COMMAND


Function _Crypt_HashFile

Function Reference

_Crypt_HashFile

Hash a string with specified algorithm

#include <Crypt.au3>
_Crypt_HashFile ( $sFilePath, $iAlgID )

Parameters

$sFilePath | Path to file to hash
$iAlgID | Hash ID to use

Return Value

Success: | a hash of file.
Failure: | -1 and sets the @error flag to non-zero.
@error: | 1 - Failed to open file 10+ - Failed to hash final piece 100+ - Failed to get hash piece

Related

_Crypt_HashData

Example

#include <ComboConstants.au3>
#include <Crypt.au3>
#include <GUIConstantsEx.au3>
#include <StringConstants.au3>

Example()

Func Example()
    Local $iAlgorithm = $CALG_SHA1

    Local $hGUI = GUICreate("Hash File", 425, 70)
    Local $idInput = GUICtrlCreateInput(@ScriptFullPath, 5, 5, 200, 20)
    Local $idBrowse = GUICtrlCreateButton("...", 210, 5, 35, 20)
    Local $idCombo = GUICtrlCreateCombo("", 250, 5, 100, 20, $CBS_DROPDOWNLIST)
    GUICtrlSetData($idCombo, "MD2|MD4|MD5|SHA1", "SHA1")
    Local $idCalculate = GUICtrlCreateButton("Calculate", 355, 40, 65, 25)
    Local $idHashLabel = GUICtrlCreateLabel("Hash Digest", 5, 50, 350, 25)
    GUISetState(@SW_SHOW, $hGUI)

    _Crypt_Startup() ; To optimize performance start the crypt library.

    Local $dHash = 0, _
            $sRead = ""
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idBrowse
                Local $sFilePath = FileOpenDialog("Open a file", "", "All files (*.*)") ; Select a file to find the hash.
                If @error Then
                    ContinueLoop
                EndIf
                GUICtrlSetData($idInput, $sFilePath) ; Set the inputbox with the filepath.
                GUICtrlSetData($idHashLabel, "Hash Digest") ; Reset the hash digest label.

            Case $idCombo ; Check when the combobox is selected and retrieve the correct algorithm.
                Switch GUICtrlRead($idCombo) ; Read the combobox selection.
                    Case "MD2"
                        $iAlgorithm = $CALG_MD2

                    Case "MD4"
                        $iAlgorithm = $CALG_MD4

                    Case "MD5"
                        $iAlgorithm = $CALG_MD5

                    Case "SHA1"
                        $iAlgorithm = $CALG_SHA1

                EndSwitch

            Case $idCalculate
                $sRead = GUICtrlRead($idInput)
                If StringStripWS($sRead, $STR_STRIPALL) <> "" And FileExists($sRead) Then ; Check there is a file available to find the hash digest
                    $dHash = _Crypt_HashFile($sRead, $iAlgorithm) ; Create a hash of the file.
                    GUICtrlSetData($idHashLabel, $dHash) ; Set the hash digest label with the hash data.
                EndIf
        EndSwitch
    WEnd

    GUIDelete($hGUI) ; Delete the previous GUI and all controls.
    _Crypt_Shutdown() ; Shutdown the crypt library.
EndFunc   ;==>Example


Function _Crypt_Shutdown

Function Reference

_Crypt_Shutdown

Uninitialize the Crypt library

#include <Crypt.au3>
_Crypt_Shutdown ( )

Return Value

None.

Remarks

Calling this function is only needed if _Crypt_Startup() has been called.

Related

_Crypt_Startup

See Also

Search CryptReleaseContext in MSDN Library.

Example

#include <Crypt.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    _Crypt_Startup() ; To optimize performance start the crypt library, though the same results will be shown if it isn't.

    Local $sData = "..upon a time there was a language without any standardized cryptographic functions. That language is no more." ; Data that will be hashed.

    Local $sOutput = "The following results show the supported algorithms for retrieving the hash of the data." & @CRLF & @CRLF & _
            "Text: " & $sData & @CRLF & _
            "MD2: " & _Crypt_HashData($sData, $CALG_MD2) & @CRLF & _
            "MD4: " & _Crypt_HashData($sData, $CALG_MD4) & @CRLF & _
            "MD5: " & _Crypt_HashData($sData, $CALG_MD5) & @CRLF & _
            "SHA1: " & _Crypt_HashData($sData, $CALG_SHA1)

    MsgBox($MB_SYSTEMMODAL, "Supported algorithms", $sOutput)

    _Crypt_Shutdown() ; Shutdown the crypt library.
EndFunc   ;==>Example


Function _Crypt_Startup

Function Reference

_Crypt_Startup

Initialize the Crypt library

#include <Crypt.au3>
_Crypt_Startup ( )

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 1 - Failed to open Advapi32.dll 2 - Failed to acquire crypt context

Remarks

Calling this function is optional.

Related

_Crypt_Shutdown

See Also

Search CryptAcquireContext in MSDN Library.

Example

#include <Crypt.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    _Crypt_Startup() ; To optimize performance start the crypt library, though the same results will be shown if it isn't.

    Local Const $sUserKey = "CryptPassword" ; Declare a password string to decrypt/encrypt the data.
    Local $sData = "..upon a time there was a language without any standardized.." ; Data that will be hashed.

    Local $sOutput = "The following results show the supported algorithms for encrypting the data." & @CRLF & @CRLF & _
            "Text: " & $sData & @CRLF & _
            "3DES: " & _Crypt_EncryptData($sData, $sUserKey, $CALG_3DES) & @CRLF & @CRLF & _
            "AES (128bit): " & _Crypt_EncryptData($sData, $sUserKey, $CALG_AES_128) & @CRLF & @CRLF & _
            "AES (192bit): " & _Crypt_EncryptData($sData, $sUserKey, $CALG_AES_192) & @CRLF & @CRLF & _
            "AES (256bit): " & _Crypt_EncryptData($sData, $sUserKey, $CALG_AES_256) & @CRLF & @CRLF & _
            "DES: " & _Crypt_EncryptData($sData, $sUserKey, $CALG_DES) & @CRLF & @CRLF & _
            "RC2: " & _Crypt_EncryptData($sData, $sUserKey, $CALG_RC2) & @CRLF & @CRLF & _
            "RC4: " & _Crypt_EncryptData($sData, $sUserKey, $CALG_RC4)

    MsgBox($MB_SYSTEMMODAL, "Supported algorithms", $sOutput)

    _Crypt_Shutdown() ; Shutdown the crypt library.
EndFunc   ;==>Example


User Defined Functions

Date user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <Date.au3>.

User Defined Function | Description
_Date_Time_CompareFileTime | Compares two file times
_Date_Time_DOSDateTimeToArray | Decode a DOS date/time to an array
_Date_Time_DOSDateTimeToFileTime | Converts MS-DOS date and time values to a file time
_Date_Time_DOSDateTimeToStr | Decode a DOS date to a string
_Date_Time_DOSDateToArray | Decode a DOS date to an array
_Date_Time_DOSDateToStr | Decode a DOS date to a string
_Date_Time_DOSTimeToArray | Decode a DOS time to an array
_Date_Time_DOSTimeToStr | Decode a DOS time to a string
_Date_Time_EncodeFileTime | Encodes and returns a $tagFILETIME structure
_Date_Time_EncodeSystemTime | Encodes and returns a $tagSYSTEMTIME structure
_Date_Time_FileTimeToArray | Decode a file time to an array
_Date_Time_FileTimeToDOSDateTime | Converts MS-DOS date and time values to a file time
_Date_Time_FileTimeToLocalFileTime | Converts a file time based on the Coordinated Universal Time to a local file time
_Date_Time_FileTimeToStr | Decode a file time to a date/time string
_Date_Time_FileTimeToSystemTime | Converts a file time to system time format
_Date_Time_GetFileTime | Retrieves the date and time that a file was created, accessed and modified
_Date_Time_GetLocalTime | Retrieves the current local date and time
_Date_Time_GetSystemTime | Retrieves the current system date and time expressed in UTC
_Date_Time_GetSystemTimeAdjustment | Determines whether the system is applying periodic time adjustments
_Date_Time_GetSystemTimeAsFileTime | Retrieves the current system date and time expressed in UTC
_Date_Time_GetSystemTimes | Retrieves system timing information
_Date_Time_GetTickCount | Retrieves the number of milliseconds that have elapsed since Windows was started
_Date_Time_GetTimeZoneInformation | Retrieves the current time zone settings
_Date_Time_LocalFileTimeToFileTime | Converts a local file time to a file time based on UTC
_Date_Time_SetFileTime | Sets the date and time that a file was created, accessed and modified
_Date_Time_SetLocalTime | Sets the current local date and time
_Date_Time_SetSystemTime | Sets the current system time and date, expressed in UTC
_Date_Time_SetSystemTimeAdjustment | Enables or disables periodic time adjustments to the system's time of day clock
_Date_Time_SetTimeZoneInformation | Sets the current time zone settings
_Date_Time_SystemTimeToArray | Decode a system time to an array
_Date_Time_SystemTimeToDateStr | Decode a system time to a date string
_Date_Time_SystemTimeToDateTimeStr | Decode a system time to a date/time string
_Date_Time_SystemTimeToFileTime | Converts a system time to file time format
_Date_Time_SystemTimeToTimeStr | Decode a system time to a time string
_Date_Time_SystemTimeToTzSpecificLocalTime | Converts a UTC time to a specified time zone's corresponding local time
_Date_Time_TzSpecificLocalTimeToSystemTime | Converts a local time to a time in UTC
_DateAdd | Calculates a new date/time by adding/subtracting a specified number of time intervals from an initial date/time
_DateDayOfWeek | Returns the name of the weekday, based on the specified day
_DateDaysInMonth | Returns the number of days in a month, based on the specified month and year
_DateDiff | Returns the difference between 2 dates, expressed in the type requested
_DateIsLeapYear | Checks a given year to see if it is a leap year
_DateIsValid | Checks the given date to determine if it is a valid date
_DateTimeFormat | Returns the date in the PC's regional settings format
_DateTimeSplit | Split a string containing Date and Time into two separate Arrays
_DateToDayOfWeek | Returns the weekday number for a given date
_DateToDayOfWeekISO | Returns the ISO weekday number for a given date
_DateToDayValue | Returns the day number since noon 4713 BC January 1 for a given Gregorian date
_DateToMonth | Returns the name of the month, based on the specified month
_DayValueToDate | Add the given days since noon 4713 BC January 1 and returns the Gregorian date
_Now | Returns the current Date and Time in PC's format
_NowCalc | Returns the current Date and Time in format YYYY/MM/DD HH:MM:SS for use in date calculations
_NowCalcDate | Returns the current Date in format YYYY/MM/DD
_NowDate | Returns the current Date in the Pc's format
_NowTime | Returns the current Time in the requested format
_SetDate | Sets the current date of the system
_SetTime | Sets the current time of the system
_TicksToTime | Converts the specified tick amount to hours, minutes and seconds
_TimeToTicks | Converts the specified hours, minutes, and seconds to ticks
_WeekNumberISO | Calculate the weeknumber of a given date


Function _Date_Time_CompareFileTime

Function Reference

_Date_Time_CompareFileTime

Compares two file times

#include <Date.au3>
_Date_Time_CompareFileTime ( $tFileTime1, $tFileTime2 )

Parameters

$tFileTime1 | first $tagFILETIME structure or a pointer to it
$tFileTime2 | second $tagFILETIME structure or a pointer to it

Return Value

Returns one of the following values:
-1 - First file time is earlier than second file time
0 - First file time is equal to second file time
1 - First file time is later than second file time

Related

$tagFILETIME

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tFileTime1, $tFileTime2

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Compare FAT Dates/Times
    $tFileTime1 = _Date_Time_DOSDateTimeToFileTime(0x3621, 0x11EF) ; 01/01/2007 02:15:30
    $tFileTime2 = _Date_Time_DOSDateTimeToFileTime(0x379F, 0x944A) ; 12/31/2007 18:34:20

    MemoWrite("Result 1: " & _Date_Time_CompareFileTime($tFileTime1, $tFileTime2))
    MemoWrite("Result 2: " & _Date_Time_CompareFileTime($tFileTime1, $tFileTime1))
    MemoWrite("Result 3: " & _Date_Time_CompareFileTime($tFileTime2, $tFileTime1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_DOSDateTimeToArray

Function Reference

_Date_Time_DOSDateTimeToArray

Decode a DOS date/time to an array

#include <Date.au3>
_Date_Time_DOSDateTimeToArray ( $iDosDate, $iDosTime )

Parameters

$iDosDate | MS-DOS date, packed as follows: Bits 0- 4 Day of the month (1–31) Bits 5- 8 Month (1 = January, 2 = February, and so on) Bits 9-15 Year offset from 1980 (add 1980 to get actual year)
$iDosTime | MS-DOS date, packed as follows: Bits 0- 4 Second divided by 2 Bits 5-10 Minute (0–59) Bits 11-15 Hour (0–23 on a 24-hour clock)

Return Value

Returns an array with the following format:
[0] - Month
[1] - Day
[2] - Year
[3] - Hour
[4] - Minute
[5] - Second

Related

_Date_Time_DOSDateToArray, _Date_Time_DOSTimeToArray

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $aDate

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Show FAT date/time
    $aDate = _Date_Time_DOSDateTimeToArray(0x3621, 0x944a) ; 01/01/2007 18:34:20
    MemoWrite("FAT date .: " & StringFormat("%02d/%02d/%04d", $aDate[0], $aDate[1], $aDate[2]))
    MemoWrite("FAT time .: " & StringFormat("%02d:%02d:%02d", $aDate[3], $aDate[4], $aDate[5]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_DOSDateTimeToFileTime

Function Reference

_Date_Time_DOSDateTimeToFileTime

Converts MS-DOS date and time values to a file time

#include <Date.au3>
_Date_Time_DOSDateTimeToFileTime ( $iFatDate, $iFatTime )

Parameters

$iFatDate | The MS-DOS date, packed as follows: Bits 0- 4 Day of the month (1–31) Bits 5- 8 Month (1 = January, 2 = February, and so on) Bits 9-15 Year offset from 1980 (add 1980 to get actual year)
$iFatTime | Ths MS-DOS time, packed as follows: Bits 0- 4 Second divided by 2 Bits 5-10 Minute (0–59) Bits 11-15 Hour (0–23 on a 24-hour clock)

Return Value

Returns a $tagFILETIME structure that receives the converted file time.

Related

$tagFILETIME, _Date_Time_FileTimeToDOSDateTime

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tFileTime1, $tFileTime2

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Compare FAT Dates/Times
    $tFileTime1 = _Date_Time_DOSDateTimeToFileTime(0x3621, 0x11EF) ; 01/01/2007 02:15:30
    $tFileTime2 = _Date_Time_DOSDateTimeToFileTime(0x379F, 0x944A) ; 12/31/2007 18:34:20

    MemoWrite("Result 1: " & _Date_Time_CompareFileTime($tFileTime1, $tFileTime2))
    MemoWrite("Result 2: " & _Date_Time_CompareFileTime($tFileTime1, $tFileTime1))
    MemoWrite("Result 3: " & _Date_Time_CompareFileTime($tFileTime2, $tFileTime1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_DOSDateTimeToStr

Function Reference

_Date_Time_DOSDateTimeToStr

Decode a DOS date to a string

#include <Date.au3>
_Date_Time_DOSDateTimeToStr ( $iDosDate, $iDosTime )

Parameters

$iDosDate | MS-DOS date, packed as follows: Bits 0- 4 Day of the month (1–31) Bits 5- 8 Month (1 = January, 2 = February, and so on) Bits 9-15 Year offset from 1980 (add 1980 to get actual year)
$iDosTime | MS-DOS date, packed as follows: Bits 0- 4 Second divided by 2 Bits 5-10 Minute (0–59) Bits 11-15 Hour (0–23 on a 24-hour clock)

Return Value

Returns a date/time string formatted as mm/dd/yyyy hh:mm:ss.

Related

_Date_Time_DOSDateToStr, _Date_Time_DOSTimeToStr

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $sDate

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Show FAT date/time
    $sDate = _Date_Time_DOSDateTimeToStr(0x3621, 0x944a) ; 01/01/2007 18:34:20
    MemoWrite("FAT date/time .: " & $sDate)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_DOSDateToArray

Function Reference

_Date_Time_DOSDateToArray

Decode a DOS date to an array

#include <Date.au3>
_Date_Time_DOSDateToArray ( $iDosDate )

Parameters

$iDosDate MS-DOS date, packed as follows:
Bits 0- 4 Day of the month (1–31)
Bits 5- 8 Month (1 = January, 2 = February, and so on)
Bits 9-15 Year offset from 1980 (add 1980 to get actual year)

Return Value

Returns an array with the following format:
[0] - Month
[1] - Day
[2] - Year

Related

_Date_Time_DOSDateTimeToArray, _Date_Time_DOSTimeToArray

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $aDate

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Show FAT date
    $aDate = _Date_Time_DOSDateToArray(0x3621) ; 01/01/2007
    MemoWrite("FAT date .: " & StringFormat("%02d/%02d/%04d", $aDate[0], $aDate[1], $aDate[2]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_DOSDateToStr

Function Reference

_Date_Time_DOSDateToStr

Decode a DOS date to a string

#include <Date.au3>
_Date_Time_DOSDateToStr ( $iDosDate )

Parameters

$iDosDate MS-DOS date, packed as follows:
Bits 0- 4 Day of the month (1–31)
Bits 5- 8 Month (1 = January, 2 = February, and so on)
Bits 9-15 Year offset from 1980 (add 1980 to get actual year)

Return Value

Returns a date string formatted as mm/dd/yyyy.

Related

_Date_Time_DOSDateTimeToStr, _Date_Time_DOSTimeToStr

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $sDate

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Show FAT date
    $sDate = _Date_Time_DOSDateToStr(0x3621) ; 01/01/2007
    MemoWrite("FAT date .: " & $sDate)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_DOSTimeToArray

Function Reference

_Date_Time_DOSTimeToArray

Decode a DOS time to an array

#include <Date.au3>
_Date_Time_DOSTimeToArray ( $iDosTime )

Parameters

$iDosTime MS-DOS date, packed as follows:
Bits 0- 4 Second divided by 2
Bits 5-10 Minute (0–59)
Bits 11-15 Hour (0–23 on a 24-hour clock)

Return Value

Returns an array with the following format:
[0] - Hour
[1] - Minute
[2] - Second

Related

_Date_Time_DOSDateTimeToArray, _Date_Time_DOSDateToArray

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $aDate

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Show FAT time
    $aDate = _Date_Time_DOSTimeToArray(0x944a) ; 18:34:20
    MemoWrite("FAT time .: " & StringFormat("%02d:%02d:%02d", $aDate[0], $aDate[1], $aDate[2]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_DOSTimeToStr

Function Reference

_Date_Time_DOSTimeToStr

Decode a DOS time to a string

#include <Date.au3>
_Date_Time_DOSTimeToStr ( $iDosTime )

Parameters

$iDosTime MS-DOS date, packed as follows:
Bits 0- 4 Second divided by 2
Bits 5-10 Minute (0–59)
Bits 11-15 Hour (0–23 on a 24-hour clock)

Return Value

Returns a time string formatted as hh:mm:ss.

Related

_Date_Time_DOSDateTimeToStr, _Date_Time_DOSDateToStr

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $sDate

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Show FAT time
    $sDate = _Date_Time_DOSTimeToStr(0x944a) ; 18:34:20
    MemoWrite("FAT time .: " & $sDate)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_EncodeFileTime

Function Reference

_Date_Time_EncodeFileTime

Encodes and returns a $tagFILETIME structure

#include <Date.au3>
_Date_Time_EncodeFileTime ( $iMonth, $iDay, $iYear [, $iHour = 0 [, $iMinute = 0 [, $iSecond = 0 [, $iMSeconds = 0]]]] )

Parameters

$iMonth | Month
$iDay | Day
$iYear | Year
$iHour | [optional] Hour
$iMinute | [optional] Minute
$iSecond | [optional] Second
$iMSeconds | [optional] Milliseconds

Return Value

Returns a $tagFILETIME structure.

Related

$tagFILETIME, _Date_Time_EncodeSystemTime

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tFile

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Encode a file time
    $tFile = _Date_Time_EncodeFileTime(@MON, @MDAY, @YEAR, @HOUR, @MIN, @SEC)
    MemoWrite("Current date/time .: " & _Date_Time_FileTimeToStr($tFile))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_EncodeSystemTime

Function Reference

_Date_Time_EncodeSystemTime

Encodes and returns a $tagSYSTEMTIME structure

#include <Date.au3>
_Date_Time_EncodeSystemTime ( $iMonth, $iDay, $iYear [, $iHour = 0 [, $iMinute = 0 [, $iSecond = 0 [, $iMSeconds = 0]]]] )

Parameters

$iMonth | Month
$iDay | Day
$iYear | Year
$iHour | [optional] Hour
$iMinute | [optional] Minute
$iSecond | [optional] Second
$iMSeconds | [optional] Milliseconds

Return Value

Returns a $tagSYSTEMTIME structure.

Related

$tagSYSTEMTIME, _Date_Time_EncodeFileTime

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tSystem

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Encode a system time
    $tSystem = _Date_Time_EncodeSystemTime(@MON, @MDAY, @YEAR, @HOUR, @MIN, @SEC)
    MemoWrite("Current date/time .: " & _Date_Time_SystemTimeToDateTimeStr($tSystem))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_FileTimeToArray

Function Reference

_Date_Time_FileTimeToArray

Decode a file time to an array

#include <Date.au3>
_Date_Time_FileTimeToArray ( ByRef $tFileTime )

Parameters

$tFileTime $tagFILETIME structure

Return Value

Returns an array with the following format:
[0] - Month
[1] - Day
[2] - Year
[3] - Hour
[4] - Minutes
[5] - Seconds
[6] - Milliseconds
[7] - Day of week

Related

$tagFILETIME

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tFile, $aFile, $sFile

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Encode a file time
    $tFile = _Date_Time_EncodeFileTime(@MON, @MDAY, @YEAR, @HOUR, @MIN, @SEC)
    $aFile = _Date_Time_FileTimeToArray($tFile)
    $sFile = StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $aFile[0], $aFile[1], $aFile[2], $aFile[3], $aFile[4], $aFile[5])
    MemoWrite("Current date/time .: " & $sFile)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_FileTimeToDOSDateTime

Function Reference

_Date_Time_FileTimeToDOSDateTime

Converts MS-DOS date and time values to a file time

#include <Date.au3>
_Date_Time_FileTimeToDOSDateTime ( $tFileTime )

Parameters

$tFileTime a $tagFILETIME structure containing the file time to convert to MS-DOS format or a pointer to it

Return Value

Returns an array with the following format:
[0] - MS-DOS date, packed as follows:
Bits 0- 4 Day of the month (1–31)
Bits 5- 8 Month (1 = January, 2 = February, and so on)
Bits 9-15 Year offset from 1980 (add 1980 to get actual year)
[1] - MS-DOS time, packed as follows:
Bits 0- 4 Second divided by 2
Bits 5-10 Minute (0–59)
Bits 11-15 Hour (0–23 on a 24-hour clock)

Related

$tagFILETIME, _Date_Time_DOSDateTimeToFileTime, _Date_Time_FileTimeToLocalFileTime, _Date_Time_FileTimeToSystemTime

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tFile, $aDOS

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Encode a file time
    $tFile = _Date_Time_EncodeFileTime(@MON, @MDAY, @YEAR, @HOUR, @MIN, @SEC)
    $aDOS = _Date_Time_FileTimeToDOSDateTime($tFile)
    MemoWrite("DOS date .: 0x" & Hex($aDOS[0], 4))
    MemoWrite("DOS time .: 0x" & Hex($aDOS[1], 4))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_FileTimeToLocalFileTime

Function Reference

_Date_Time_FileTimeToLocalFileTime

Converts a file time based on the Coordinated Universal Time to a local file time

#include <Date.au3>
_Date_Time_FileTimeToLocalFileTime ( $tFileTime )

Parameters

$tFileTime a $tagFILETIME structure containing the UTC based file time to be converted into a local file time or a pointer to it.

Return Value

Returns a $tagFILETIME structure that contains the converted local file time.

Related

$tagFILETIME, _Date_Time_FileTimeToDOSDateTime, _Date_Time_FileTimeToSystemTime, _Date_Time_LocalFileTimeToFileTime

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tFile, $tLocal

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get system time
    Local $tSystem = _Date_Time_GetSystemTime()
    $tFile = _Date_Time_SystemTimeToFileTime($tSystem)
    ;   --------------------------------------
    $tLocal = _Date_Time_FileTimeToLocalFileTime($tFile)
    MemoWrite("Local file time .: " & _Date_Time_FileTimeToStr($tLocal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_FileTimeToStr

Function Reference

_Date_Time_FileTimeToStr

Decode a file time to a date/time string

#include <Date.au3>
_Date_Time_FileTimeToStr ( ByRef $tFileTime [, $iFmt = 0] )

Parameters

$tFileTime | $tagFILETIME structure
$iFmt | [optional] 0 returns mm/dd/yyyy hh:mm:ss (Default) 1 returns yyyy/mm/dd hh:mm:ss

Return Value

Returns a date/time string formatted according to $bFmt.

Related

$tagFILETIME

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tFile

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Encode a file time
    $tFile = _Date_Time_EncodeFileTime(@MON, @MDAY, @YEAR, @HOUR, @MIN, @SEC)
    MemoWrite("Current date/time .: " & _Date_Time_FileTimeToStr($tFile))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_FileTimeToSystemTime

Function Reference

_Date_Time_FileTimeToSystemTime

Converts a file time to system time format

#include <Date.au3>
_Date_Time_FileTimeToSystemTime ( $tFileTime )

Parameters

$tFileTime a $tagFILETIME structure containing the file time to convert to system date and time format or a pointer to it.

Return Value

Returns a $tagSYSTEMTIME structure that contains the converted file time.

Related

$tagFILETIME, $tagSYSTEMTIME, _Date_Time_FileTimeToDOSDateTime, _Date_Time_FileTimeToLocalFileTime

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tFile, $tSystem

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Encode a file time
    $tFile = _Date_Time_EncodeFileTime(@MON, @MDAY, @YEAR, @HOUR, @MIN, @SEC)
    $tSystem = _Date_Time_FileTimeToSystemTime($tFile)
    MemoWrite("System file time .: " & _Date_Time_SystemTimeToDateTimeStr($tSystem))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_GetFileTime

Function Reference

_Date_Time_GetFileTime

Retrieves the date and time that a file was created, accessed and modified

#include <Date.au3>
_Date_Time_GetFileTime ( $hFile )

Parameters

$hFile Handle to the file for which dates and times are to be retrieved. The file handle must have been created using the CreateFile function with the GENERIC_READ access right.

Return Value

Returns an array with the following format:
[0] - $tagFILETIME structure with the date and time the file was created
[1] - $tagFILETIME structure with the date and time the file was accessed
[2] - $tagFILETIME structure with the date and time the file was modified

Remarks

Not all file systems can record creation and last access times and not all file systems record them in the same manner.
For example, on FAT, create time has a resolution of 10 milliseconds, write time has a resolution of 2 seconds, and access time has a resolution of 1 day (really, the access date). Therefore, the _Date_Time_GetFileTime() function may not return the same file time information set using _Date_Time_SetFileTime().
NTFS delays updates to the last access time for a file by up to one hour after the last access.

Related

$tagFILETIME, _Date_Time_SetFileTime

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hFile, $tFile, $aTime
    Local $sTempFile = @TempDir & "\Test.xyz"

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create test file and set file times
    $hFile = _WinAPI_CreateFile($sTempFile, 1)
    If $hFile = 0 Then _WinAPI_ShowError("Unable to create file")
    $tFile = _Date_Time_EncodeFileTime(@MON, @MDAY, @YEAR, @HOUR, @MIN, @SEC)
    _Date_Time_SetFileTime($hFile, $tFile, $tFile, $tFile)
    _WinAPI_CloseHandle($hFile)

    ; Read file times
    $hFile = _WinAPI_CreateFile($sTempFile, 2)
    If $hFile = 0 Then _WinAPI_ShowError("Unable to open file")
    $aTime = _Date_Time_GetFileTime($hFile)
    _WinAPI_CloseHandle($hFile)

    MemoWrite("Created ..: " & _Date_Time_FileTimeToStr($aTime[0]))
    MemoWrite("Accessed .: " & _Date_Time_FileTimeToStr($aTime[1]))
    MemoWrite("Modified .: " & _Date_Time_FileTimeToStr($aTime[2]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    FileDelete($sTempFile)
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_GetLocalTime

Function Reference

_Date_Time_GetLocalTime

Retrieves the current local date and time

#include <Date.au3>
_Date_Time_GetLocalTime ( )

Return Value

Returns a $tagSYSTEMTIME structure with the current local date and time.

Related

$tagSYSTEMTIME, _Date_Time_SetLocalTime

Example

#include <Date.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

; Under Vista the Windows API "SetLocalime" may be rejected due to system security

Global $g_idMemo

Example()

Func Example()
    Local $tCur, $tNew

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Show current local time
    $tCur = _Date_Time_GetLocalTime()
    MemoWrite("Current date/time .: " & _Date_Time_SystemTimeToDateTimeStr($tCur))

    ; Set new local time
    $tNew = _Date_Time_EncodeSystemTime(8, 19, @YEAR, 3, 10, 45)
    If Not _Date_Time_SetLocalTime($tNew) Then
        MsgBox($MB_SYSTEMMODAL, "Error", "System clock cannot be SET" & @CRLF & @CRLF & _WinAPI_GetLastErrorMessage())
        Exit
    EndIf
    $tNew = _Date_Time_GetLocalTime()
    MemoWrite("New date/time .....: " & _Date_Time_SystemTimeToDateTimeStr($tNew))

    ; Reset local time
    _Date_Time_SetLocalTime($tCur)

    ; Show current local time
    $tCur = _Date_Time_GetLocalTime()
    MemoWrite("Current date/time .: " & _Date_Time_SystemTimeToDateTimeStr($tCur))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_GetSystemTime

Function Reference

_Date_Time_GetSystemTime

Retrieves the current system date and time expressed in UTC

#include <Date.au3>
_Date_Time_GetSystemTime ( )

Return Value

Returns a $tagSYSTEMTIME structure with the current system date and time.

Related

$tagSYSTEMTIME, _Date_Time_SetSystemTime

Example

#include <Date.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

; Under Vista the Windows API "SetSystemTime" may be rejected due to system security

Global $g_idMemo

Example()

Func Example()
    Local $tCur, $tNew

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get current system time
    $tCur = _Date_Time_GetSystemTime()
    MemoWrite("Current system date/time .: " & _Date_Time_SystemTimeToDateTimeStr($tCur))

    ; Set new system time
    $tNew = _Date_Time_EncodeSystemTime(8, 19, @YEAR, 3, 10, 45)

    If Not _Date_Time_SetSystemTime($tNew) Then
        MsgBox($MB_SYSTEMMODAL, "Error", "System clock cannot be SET" & @CRLF & @CRLF & _WinAPI_GetLastErrorMessage())
        Exit
    EndIf

    $tNew = _Date_Time_GetSystemTime()
    MemoWrite("New system date/time .....: " & _Date_Time_SystemTimeToDateTimeStr($tNew))

    ; Restore system time
    _Date_Time_SetSystemTime($tCur)

    ; Get current system time
    $tCur = _Date_Time_GetSystemTime()
    MemoWrite("Current system date/time .: " & _Date_Time_SystemTimeToDateTimeStr($tCur))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_GetSystemTimeAdjustment

Function Reference

_Date_Time_GetSystemTimeAdjustment

Determines whether the system is applying periodic time adjustments

#include <Date.au3>
_Date_Time_GetSystemTimeAdjustment ( )

Return Value

Returns an array with the following format:
[1] - The number of 100 nanosecond units added to the clock at each periodic time adjustment
[2] - The number of 100 nanosecond units between periodic time adjustments.
This interval is the time period between a system's clock interrupts.
[3] - True indicates that periodic time adjustment is disabled.
At each clock interrupt, the system merely adds the interval between clock interrupts to the clock.
If False, periodic time adjustment is being used to adjust the clock.

Related

_Date_Time_SetSystemTimeAdjustment

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

; Under Vista the Windows API "SetSystemTimeAdjustment" may be rejected due to system security

Example()

Func Example()
    Local $aInfo

    ; Open the clock so we can watch the fun
    Run("RunDll32.exe shell32.dll,Control_RunDLL timedate.cpl")
    WinWaitActive("[CLASS:#32770]")

    ; Get current time adjustments
    $aInfo = _Date_Time_GetSystemTimeAdjustment()

    ; Slow down clock
    If Not _Date_Time_SetSystemTimeAdjustment($aInfo[1] / 10, False) Then
        MsgBox($MB_SYSTEMMODAL, "Error", "System clock cannot be DOWN" & @CRLF & @CRLF & _WinAPI_GetLastErrorMessage())
        Exit
    EndIf
    MsgBox($MB_SYSTEMMODAL, "Information", "Slowing down system clock", 2)

    Sleep(5000)

    ; Speed up clock
    If Not _Date_Time_SetSystemTimeAdjustment($aInfo[1] * 10, False) Then
        MsgBox($MB_SYSTEMMODAL, "Error", "System clock cannot be UP" & @CRLF & @CRLF & _WinAPI_GetLastErrorMessage())
    EndIf
    MsgBox($MB_SYSTEMMODAL, "Information", "Speeding up system clock", 2)

    Sleep(5000)

    ; Reset time adjustment
    If Not _Date_Time_SetSystemTimeAdjustment($aInfo[1], True) Then
        MsgBox($MB_SYSTEMMODAL, "Error", "System clock cannot be RESET" & @CRLF & @CRLF & _WinAPI_GetLastErrorMessage())
    Else
        MsgBox($MB_SYSTEMMODAL, "Information", "System clock restored")
    EndIf
EndFunc   ;==>Example


Function _Date_Time_GetSystemTimeAsFileTime

Function Reference

_Date_Time_GetSystemTimeAsFileTime

Retrieves the current system date and time expressed in UTC

#include <Date.au3>
_Date_Time_GetSystemTimeAsFileTime ( )

Return Value

Returns a $tagFILETIME structure with the current system date and time.

Related

$tagFILETIME

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tTime

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get system time
    $tTime = _Date_Time_GetSystemTimeAsFileTime()

    MemoWrite("System time .: " & _Date_Time_FileTimeToStr($tTime))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_GetSystemTimes

Function Reference

_Date_Time_GetSystemTimes

Retrieves system timing information

#include <Date.au3>
_Date_Time_GetSystemTimes ( )

Return Value

Returns an array with the following format:
[0] - $tagFILETIME structure with the total system idle time
[1] - $tagFILETIME structure with the total system kernel mode time
[2] - $tagFILETIME structure with the total system user mode time

Related

$tagFILETIME

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $aTime

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get system times
    $aTime = _Date_Time_GetSystemTimes()

    MemoWrite("Idle time ...: " & _Date_Time_FileTimeToStr($aTime[0]))
    MemoWrite("System time .: " & _Date_Time_FileTimeToStr($aTime[1]))
    MemoWrite("User time ...: " & _Date_Time_FileTimeToStr($aTime[2]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_GetTickCount

Function Reference

_Date_Time_GetTickCount

Retrieves the number of milliseconds that have elapsed since Windows was started

#include <Date.au3>
_Date_Time_GetTickCount ( )

Return Value

Returns the number of milliseconds that have elapsed since Windows was started.

Remarks

The elapsed time is stored as a DWORD value. The time will wrap around to zero if Windows is run continuously for 49.7 days.

Example

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

Global $g_idMemo

Example()

Func Example()
    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get tick count
    MemoWrite("Tick count .: " & _Date_Time_GetTickCount())

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_GetTimeZoneInformation

Function Reference

_Date_Time_GetTimeZoneInformation

Retrieves the current time zone settings

#include <Date.au3>
_Date_Time_GetTimeZoneInformation ( )

Return Value

Returns an array with the following format:
[0] - Daylight savings setting. Can be one of the following:
-1 - Failure
0 - Daylight savings time is not used in the current time zone
1 - Daylight savings time operating with standard time
2 - Daylight savings time operating with daylight savings time
[1] - The current bias for local time translation on this computer.
The bias is the difference in minutes between Coordinated Universal Time (UTC) and local time.
All translations between UTC and local time use the following formula: UTC = local time + bias
[2] - The description for standard time
[3] - A $tagSYSTEMTIME structure that contains a date and local time when the transition from daylight saving time to standard time occurs.
[4] - The bias value to be used during local time translations that occur during standard time.
This value is added to the value of the Bias to form the bias used during standard time.
In most time zones, this value is zero.
[5] - The description for daylight saving time
[6] - A $tagSYSTEMTIME structure that contains a date and local time when the transition from standard time to daylight saving time occurs.
[7] - The bias value to be used during local time translations that occur during daylight saving time.
This value is added to the value of the Bias member to form the bias used during daylight saving time. In most time zones this value is –60.

Remarks

In the $tagSYSTEMTIME structure, the wHour and wMinute members represent the transition time, the wDayOfWeek member to the appropriate weekday, and the wDay member indicating the occurrence of the day of the week within the month (1 to 5, where 5 indicates the final occurrence during the month if that day of the week does not occur 5 times).

Using this notation, specify 02:00 on the first Sunday in April as follows: wHour = 2, wMonth = 4, wDayOfWeek = 0, wDay = 1. Specify 02:00 on the last Thursday in October as follows: wHour = 2, wMonth = 10, wDayOfWeek = 4, wDay = 5.

Related

$tagSYSTEMTIME, _Date_Time_SetTimeZoneInformation

Example

#include <Date.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

; Under Vista the Windows API "SetTimeZoneInformation" may be rejected due to system security

Global $g_idMemo

Example()

Func Example()
    Local $aOld, $aNew

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Show current time zone information
    $aOld = _Date_Time_GetTimeZoneInformation()
    ShowTimeZoneInformation($aOld, "Current")

    ; Set new time zone information
    If Not _Date_Time_SetTimeZoneInformation($aOld[1], "A3L CST", $aOld[3], $aOld[4], "A3L CDT", $aOld[6], $aOld[7]) Then
        MsgBox($MB_SYSTEMMODAL, "Error", "System timezone cannot be SET" & @CRLF & @CRLF & _WinAPI_GetLastErrorMessage())
        Exit
    EndIf

    ; Show new time zone information
    $aNew = _Date_Time_GetTimeZoneInformation()
    ShowTimeZoneInformation($aNew, "New")

    ; Reset original time zone information
    _Date_Time_SetTimeZoneInformation($aOld[1], $aOld[2], $aOld[3], $aOld[4], $aOld[5], $aOld[6], $aOld[7])

    ; Show current time zone information
    $aOld = _Date_Time_GetTimeZoneInformation()
    ShowTimeZoneInformation($aOld, "Reset")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Show time zone information
Func ShowTimeZoneInformation(ByRef $aInfo, $sComment)
    MemoWrite("******************* " & $sComment & " *******************")
    MemoWrite("Result ............: " & $aInfo[0])
    MemoWrite("Current bias ......: " & $aInfo[1])
    MemoWrite("Standard name .....: " & $aInfo[2])
    MemoWrite("Standard date/time : " & _Date_Time_SystemTimeToDateTimeStr($aInfo[3]))
    MemoWrite("Standard bias......: " & $aInfo[4])
    MemoWrite("Daylight name .....: " & $aInfo[5])
    MemoWrite("Daylight date/time : " & _Date_Time_SystemTimeToDateTimeStr($aInfo[6]))
    MemoWrite("Daylight bias......: " & $aInfo[7])
EndFunc   ;==>ShowTimeZoneInformation


Function _Date_Time_LocalFileTimeToFileTime

Function Reference

_Date_Time_LocalFileTimeToFileTime

Converts a local file time to a file time based on UTC

#include <Date.au3>
_Date_Time_LocalFileTimeToFileTime ( $tLocalTime )

Parameters

$tLocalTime a $tagFILETIME structure that specifies the local file time to be converted into a UTC based file time or a pointer to it.

Return Value

Returns a $tagFILETIME structure with the converted UTC based file time.

Remarks

This function uses the current settings for the time zone and daylight saving time. Therefore, if it is daylight saving time, this function will take daylight saving time into account, even if the time you are converting is in standard time.

Related

$tagFILETIME, _Date_Time_FileTimeToLocalFileTime

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tTime, $tLocal

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Show local date/time as UTC
    $tTime = _Date_Time_EncodeFileTime(@MON, @MDAY, @YEAR, @HOUR, @MIN, @SEC)
    $tLocal = _Date_Time_LocalFileTimeToFileTime($tTime)
    MemoWrite("Local date/time .: " & _Date_Time_FileTimeToStr($tLocal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_SetFileTime

Function Reference

_Date_Time_SetFileTime

Sets the date and time that a file was created, accessed and modified

#include <Date.au3>
_Date_Time_SetFileTime ( $hFile, $tCreateTime, $tLastAccess, $tLastWrite )

Parameters

$hFile | Handle to the file. The file handle must have been created using the CreateFile function with the FILE_WRITE_ATTRIBUTES access right.
$tCreateTime | a $tagFILETIME structure that contains the new date and time the file was created. This be 0 if the application does not need to set this information.
$tLastAccess | a $tagFILETIME structure that contains the new date and time the file was last accessed. The last access time includes the last time the file was written to, read from, or (in the case of executable files) run. This can be 0 if the application does not need to set this information. To preserve the existing last access time for a file even after accessing a file, call SetFileTime with this parameter set to -1 before closing the file handle.
$tLastWrite | a $tagFILETIME structure that contains the new date and time the file was last written to. This can be 0 if the application does not want to set this information.

Return Value

Success: | True
Failure: | False

Remarks

Not all file systems can record creation and last access times and not all file systems record them in the same manner.
For example, on FAT, create time has a resolution of 10 milliseconds, write time has a resolution of 2 seconds, and access time has a resolution of 1 day (really, the access date). Therefore, the _Date_Time_GetFileTime() function may not return the same file time information set using _Date_Time_SetFileTime().
NTFS delays updates to the last access time for a file by up to one hour after the last access.

Related

$tagFILETIME, _Date_Time_GetFileTime

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hFile, $tFile, $aTime
    Local $sTempFile = @TempDir & "\Test.xyz"

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create test file and set file times
    $hFile = _WinAPI_CreateFile($sTempFile, 1)
    If $hFile = 0 Then _WinAPI_ShowError("Unable to create file")
    $tFile = _Date_Time_EncodeFileTime(@MON, @MDAY, @YEAR, @HOUR, @MIN, @SEC)
    _Date_Time_SetFileTime($hFile, $tFile, $tFile, $tFile)
    _WinAPI_CloseHandle($hFile)

    ; Read file times
    $hFile = _WinAPI_CreateFile($sTempFile, 2)
    If $hFile = 0 Then _WinAPI_ShowError("Unable to open file")
    $aTime = _Date_Time_GetFileTime($hFile)
    _WinAPI_CloseHandle($hFile)

    MemoWrite("Created ..: " & _Date_Time_FileTimeToStr($aTime[0]))
    MemoWrite("Accessed .: " & _Date_Time_FileTimeToStr($aTime[1]))
    MemoWrite("Modified .: " & _Date_Time_FileTimeToStr($aTime[2]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    FileDelete($sTempFile)
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_SetLocalTime

Function Reference

_Date_Time_SetLocalTime

Sets the current local date and time

#include <Date.au3>
_Date_Time_SetLocalTime ( $tSYSTEMTIME )

Parameters

$tSYSTEMTIME a $tagSYSTEMTIME structure that contains the new local date and time or a pointer to it

Return Value

Success: | True
Failure: | False

Remarks

The _Date_Time_SetLocalTime() function enables the SE_SYSTEMTIME_NAME privilege before changing the local time.

Related

$tagSYSTEMTIME, _Date_Time_GetLocalTime

Example

#include <Date.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

; Under Vista the Windows API "SetLocalTime" may be rejected due to system security

Global $g_idMemo

Example()

Func Example()
    Local $tCur, $tNew

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Show current local time
    $tCur = _Date_Time_GetLocalTime()
    MemoWrite("Current date/time .: " & _Date_Time_SystemTimeToDateTimeStr($tCur))

    ; Set new local time
    $tNew = _Date_Time_EncodeSystemTime(8, 19, @YEAR, 3, 10, 45)
    If Not _Date_Time_SetLocalTime($tNew) Then
        MsgBox($MB_SYSTEMMODAL, "Error", "System clock cannot be SET" & @CRLF & @CRLF & _WinAPI_GetLastErrorMessage())
        Exit
    EndIf
    $tNew = _Date_Time_GetLocalTime()
    MemoWrite("New date/time .....: " & _Date_Time_SystemTimeToDateTimeStr($tNew))

    ; Reset local time
    _Date_Time_SetLocalTime($tCur)

    ; Show current local time
    $tCur = _Date_Time_GetLocalTime()
    MemoWrite("Current date/time .: " & _Date_Time_SystemTimeToDateTimeStr($tCur))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_SetSystemTime

Function Reference

_Date_Time_SetSystemTime

Sets the current system time and date, expressed in UTC

#include <Date.au3>
_Date_Time_SetSystemTime ( $tSYSTEMTIME )

Parameters

$tSYSTEMTIME a $tagSYSTEMTIME structure that contains the new system date and time or a pointer to it

Return Value

Success: | True
Failure: | False

Remarks

The SetLocalTime function enables the SE_SYSTEMTIME_NAME privilege before changing the local time

Related

$tagSYSTEMTIME, _Date_Time_GetSystemTime

Example

#include <Date.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

; Under Vista the  Windows API "SetSystemTime" may be rejected due to system security

Global $g_idMemo

Example()

Func Example()
    Local $tCur, $tNew

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get current system time
    $tCur = _Date_Time_GetSystemTime()
    MemoWrite("Current system date/time .: " & _Date_Time_SystemTimeToDateTimeStr($tCur))

    ; Set new system time
    $tNew = _Date_Time_EncodeSystemTime(8, 19, @YEAR, 3, 10, 45)
    If Not _Date_Time_SetSystemTime($tNew) Then
        MsgBox($MB_SYSTEMMODAL, "Error", "System clock cannot be SET" & @CRLF & @CRLF & _WinAPI_GetLastErrorMessage())
        Exit
    EndIf
    $tNew = _Date_Time_GetSystemTime()
    MemoWrite("New system date/time .....: " & _Date_Time_SystemTimeToDateTimeStr($tNew))

    ; Restore system time
    _Date_Time_SetSystemTime($tCur)

    ; Get current system time
    $tCur = _Date_Time_GetSystemTime()
    MemoWrite("Current system date/time .: " & _Date_Time_SystemTimeToDateTimeStr($tCur))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_SetSystemTimeAdjustment

Function Reference

_Date_Time_SetSystemTimeAdjustment

Enables or disables periodic time adjustments to the system's time of day clock

#include <Date.au3>
_Date_Time_SetSystemTimeAdjustment ( $iAdjustment, $bDisabled )

Parameters

$iAdjustment | The number of 100 nanosecond units added to the time of day clock at each clock interrupt if periodic time adjustment is enabled.
$bDisabled | A value of True specifies that periodic time adjustment is to be disabled. The system is free to adjust time of day using its own internal mechanisms. The system's internal adjustment mechanisms may cause the time-of-day clock to jump noticeably when adjustments are made. A value of False specifies that periodic time adjustment is to be enabled, and will be used to adjust the time of day clock. The system will not interfere with the time adjustment scheme, and will not attempt to synchronize time of day on its own. The system will add the value of $iAdjustment to the time of day at each clock interrupt.

Return Value

Success: | True
Failure: | False

Related

_Date_Time_GetSystemTimeAdjustment

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

; Under Vista the Windows API "SetSystemTimeAdjustment" may be rejected due to system security

Example()

Func Example()
    Local $aInfo

    ; Open the clock so we can watch the fun
    Run("RunDll32.exe shell32.dll,Control_RunDLL timedate.cpl")
    WinWaitActive("[CLASS:#32770]")

    ; Get current time adjustments
    $aInfo = _Date_Time_GetSystemTimeAdjustment()

    ; Slow down clock
    If Not _Date_Time_SetSystemTimeAdjustment($aInfo[1] / 10, False) Then
        MsgBox($MB_SYSTEMMODAL, "Error", "System clock cannot be DOWN" & @CRLF & @CRLF & _WinAPI_GetLastErrorMessage())
        Exit
    EndIf
    MsgBox($MB_SYSTEMMODAL, "Information", "Slowing down system clock", 2)

    Sleep(5000)

    ; Speed up clock
    If Not _Date_Time_SetSystemTimeAdjustment($aInfo[1] * 10, False) Then
        MsgBox($MB_SYSTEMMODAL, "Error", "System clock cannot be UP" & @CRLF & @CRLF & _WinAPI_GetLastErrorMessage())
    EndIf
    MsgBox($MB_SYSTEMMODAL, "Information", "Speeding up system clock", 2)

    Sleep(5000)

    ; Reset time adjustment
    If Not _Date_Time_SetSystemTimeAdjustment($aInfo[1], True) Then
        MsgBox($MB_SYSTEMMODAL, "Error", "System clock cannot be RESET" & @CRLF & @CRLF & _WinAPI_GetLastErrorMessage())
    Else
        MsgBox($MB_SYSTEMMODAL, "Information", "System clock restored")
    EndIf
EndFunc   ;==>Example


Function _Date_Time_SetTimeZoneInformation

Function Reference

_Date_Time_SetTimeZoneInformation

Sets the current time zone settings

#include <Date.au3>
_Date_Time_SetTimeZoneInformation ( $iBias, $sStdName, $tStdDate, $iStdBias, $sDayName, $tDayDate, $iDayBias )

Parameters

$iBias | The current bias for local time translation on this computer. The bias is the difference in minutes between Coordinated Universal Time (UTC) and local time. All translations between UTC and local time use the following formula: UTC = local time + bias
$sStdName | The description for standard time
$tStdDate | A $tagSYSTEMTIME structure that contains a date and local time when the transition from daylight saving time to standard time occurs.
$iStdBias | The bias value to be used during local time translations that occur during standard time. This value is added to the value of the Bias to form the bias used during standard time. In most time zones, this value is zero.
$sDayName | The description for daylight saving time
$tDayDate | A $tagSYSTEMTIME structure that contains a date and local time when the transition from standard time to daylight saving time occurs.
$iDayBias | The bias value to be used during local time translation that occur during daylight saving time. This value is added to the value of the Bias member to form the bias used during daylight saving time. In most time zones this value is –60.

Return Value

Success: | True
Failure: | False

Remarks

To select the correct day in the month, set the wYear member to zero, the wHour and wMinute members to the transition time, the wDayOfWeek member to the appropriate weekday, and the wDay member to indicate the occurrence of the day of the week within the month (1 to 5, where 5 indicates the final occurrence during the month if that day of the week does not occur 5 times).

Using this notation, specify 02:00 on the first Sunday in April as follows: wHour = 2, wMonth = 4, wDayOfWeek = 0, wDay = 1. Specify 02:00 on the last Thursday in October as follows: wHour = 2, wMonth = 10, wDayOfWeek = 4, wDay = 5.

Related

$tagSYSTEMTIME, _Date_Time_GetTimeZoneInformation

Example

#include <Date.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

; Under Vista the Windows API "SetTimeZoneInformation" may be rejected due to system security

Global $g_idMemo

Example()

Func Example()
    Local $aOld, $aNew

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Show current time zone information
    $aOld = _Date_Time_GetTimeZoneInformation()
    ShowTimeZoneInformation($aOld, "Current")

    ; Set new time zone information
    If Not _Date_Time_SetTimeZoneInformation($aOld[1], "A3L CST", $aOld[3], $aOld[4], "A3L CDT", $aOld[6], $aOld[7]) Then
        MsgBox($MB_SYSTEMMODAL, "Error", "System time zone cannot be SET" & @CRLF & @CRLF & _WinAPI_GetLastErrorMessage())
        Exit
    EndIf

    ; Show new time zone information
    $aNew = _Date_Time_GetTimeZoneInformation()
    ShowTimeZoneInformation($aNew, "New")

    ; Reset original time zone information
    _Date_Time_SetTimeZoneInformation($aOld[1], $aOld[2], $aOld[3], $aOld[4], $aOld[5], $aOld[6], $aOld[7])

    ; Show current time zone information
    $aOld = _Date_Time_GetTimeZoneInformation()
    ShowTimeZoneInformation($aOld, "Reset")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Show time zone information
Func ShowTimeZoneInformation(ByRef $aInfo, $sComment)
    MemoWrite("******************* " & $sComment & " *******************")
    MemoWrite("Result ............: " & $aInfo[0])
    MemoWrite("Current bias ......: " & $aInfo[1])
    MemoWrite("Standard name .....: " & $aInfo[2])
    MemoWrite("Standard date/time : " & _Date_Time_SystemTimeToDateTimeStr($aInfo[3]))
    MemoWrite("Standard bias......: " & $aInfo[4])
    MemoWrite("Daylight name .....: " & $aInfo[5])
    MemoWrite("Daylight date/time : " & _Date_Time_SystemTimeToDateTimeStr($aInfo[6]))
    MemoWrite("Daylight bias......: " & $aInfo[7])
EndFunc   ;==>ShowTimeZoneInformation


Function _Date_Time_SystemTimeToArray

Function Reference

_Date_Time_SystemTimeToArray

Decode a system time to an array

#include <Date.au3>
_Date_Time_SystemTimeToArray ( ByRef $tSYSTEMTIME )

Parameters

$tSYSTEMTIME $tagSYSTEMTIME structure

Return Value

Returns an array with the following format:
[0] - Month
[1] - Day
[2] - Year
[3] - Hour
[4] - Minutes
[5] - Seconds
[6] - Milliseconds
[7] - Day of week

Related

$tagSYSTEMTIME

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tTime, $aTime

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get current system time
    $tTime = _Date_Time_GetSystemTime()
    $aTime = _Date_Time_SystemTimeToArray($tTime)
    MemoWrite("Month ........: " & $aTime[0])
    MemoWrite("Day ..........: " & $aTime[1])
    MemoWrite("Year .........: " & $aTime[2])
    MemoWrite("Hour .........: " & $aTime[3])
    MemoWrite("Minute .......: " & $aTime[4])
    MemoWrite("Second .......: " & $aTime[5])
    MemoWrite("Milliseconds .: " & $aTime[6])
    MemoWrite("Day of week ..: " & $aTime[7])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_SystemTimeToDateStr

Function Reference

_Date_Time_SystemTimeToDateStr

Decode a system time to a date string

#include <Date.au3>
_Date_Time_SystemTimeToDateStr ( ByRef $tSYSTEMTIME [, $iFmt = 0] )

Parameters

$tSYSTEMTIME | $tagSYSTEMTIME structure
$iFmt | [optional] 0 returns mm/dd/yyyy (Default) 1 returns yyyy/mm/dd

Return Value

Returns a date string formatted according to $bFmt.

Related

$tagSYSTEMTIME, _Date_Time_SystemTimeToDateTimeStr, _Date_Time_SystemTimeToTimeStr

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tDate

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get current system date
    $tDate = _Date_Time_GetSystemTime()
    MemoWrite("Current system date .: " & _Date_Time_SystemTimeToDateStr($tDate))
    MemoWrite("Current system date .: " & _Date_Time_SystemTimeToDateStr($tDate, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_SystemTimeToDateTimeStr

Function Reference

_Date_Time_SystemTimeToDateTimeStr

Decode a system time to a date/time string

#include <Date.au3>
_Date_Time_SystemTimeToDateTimeStr ( ByRef $tSYSTEMTIME [, $iFmt = 0] )

Parameters

$tSYSTEMTIME | $tagSYSTEMTIME structure
$iFmt | [optional] 0 returns mm/dd/yyyy hh:mm:ss (Default) 1 returns yyyy/mm/dd hh:mm:ss

Return Value

Returns a date/time string formatted according to $bFmt.

Related

$tagSYSTEMTIME, _Date_Time_SystemTimeToDateStr, _Date_Time_SystemTimeToTimeStr

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tTime

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Show system date/time
    $tTime = _Date_Time_GetSystemTime()
    MemoWrite("System date/time .: " & _Date_Time_SystemTimeToDateTimeStr($tTime))
    MemoWrite("System date/time .: " & _Date_Time_SystemTimeToDateTimeStr($tTime, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_SystemTimeToFileTime

Function Reference

_Date_Time_SystemTimeToFileTime

Converts a system time to file time format

#include <Date.au3>
_Date_Time_SystemTimeToFileTime ( $tSYSTEMTIME )

Parameters

$tSYSTEMTIME a $tagSYSTEMTIME structure to be converted or a pointer to it.

Return Value

Returns a $tagFILETIME structure that contains the converted file time.

Related

$tagFILETIME, $tagSYSTEMTIME

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tFile, $tSystem

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get system time
    $tSystem = _Date_Time_GetSystemTime()
    $tFile = _Date_Time_SystemTimeToFileTime($tSystem)
    MemoWrite("File time .: " & _Date_Time_FileTimeToStr($tFile))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_SystemTimeToTimeStr

Function Reference

_Date_Time_SystemTimeToTimeStr

Decode a system time to a time string

#include <Date.au3>
_Date_Time_SystemTimeToTimeStr ( ByRef $tSYSTEMTIME )

Parameters

$tSYSTEMTIME $tagSYSTEMTIME structure

Return Value

Returns a time string formatted as hh:mm:ss.

Related

$tagSYSTEMTIME, _Date_Time_SystemTimeToDateStr, _Date_Time_SystemTimeToDateTimeStr

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tFile, $tSystem

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get system time
    $tSystem = _Date_Time_GetSystemTime()
    $tFile = _Date_Time_SystemTimeToFileTime($tSystem)
    MemoWrite("File time .: " & _Date_Time_FileTimeToStr($tFile))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_SystemTimeToTzSpecificLocalTime

Function Reference

_Date_Time_SystemTimeToTzSpecificLocalTime

Converts a UTC time to a specified time zone's corresponding local time

#include <Date.au3>
_Date_Time_SystemTimeToTzSpecificLocalTime ( $tUTC [, $tTimeZone = 0] )

Parameters

$tUTC | a $tagSYSTEMTIME structure that specifies a time in UTC or a pointer to it. The function converts this time to the specified time zone's local time.
$tTimeZone | [optional] a $tagTIME_ZONE_INFORMATION structure that specifies the time zone of interest or a pointer to it. If 0, the function uses the currently active time zone.

Return Value

Returns a $tagSYSTEMTIME structure containing the local time.

Related

$tagSYSTEMTIME, $tagTIME_ZONE_INFORMATION

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tLocal, $tSystem

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Convert system time to local time
    $tSystem = _Date_Time_GetSystemTime()
    $tLocal = _Date_Time_SystemTimeToTzSpecificLocalTime($tSystem)
    MemoWrite("System time to local time .: " & _Date_Time_SystemTimeToDateTimeStr($tLocal))

    $tLocal = _Date_Time_GetLocalTime()
    $tSystem = _Date_Time_TzSpecificLocalTimeToSystemTime($tLocal)
    MemoWrite("Local time to system time .: " & _Date_Time_SystemTimeToDateTimeStr($tSystem))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Date_Time_TzSpecificLocalTimeToSystemTime

Function Reference

_Date_Time_TzSpecificLocalTimeToSystemTime

Converts a local time to a time in UTC

#include <Date.au3>
_Date_Time_TzSpecificLocalTimeToSystemTime ( $tLocalTime [, $tTimeZone = 0] )

Parameters

$tLocalTime | a $tagSYSTEMTIME structure that specifies a local time or a pointer to it. The function converts this time to the corresponding UTC time.
$tTimeZone | [optional] a $tagTIME_ZONE_INFORMATION structure that specifies the time zone of interest or a pointer to it. If 0, the function uses the currently active time zone.

Return Value

Returns a $tagSYSTEMTIME structure containing the time in UTC.

Related

$tagSYSTEMTIME, $tagTIME_ZONE_INFORMATION

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tLocal, $tSystem

    ; Create GUI
    GUICreate("Time", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Convert system time to local time
    $tSystem = _Date_Time_GetSystemTime()
    $tLocal = _Date_Time_SystemTimeToTzSpecificLocalTime($tSystem)
    MemoWrite("System time to local time .: " & _Date_Time_SystemTimeToDateTimeStr($tLocal))

    $tLocal = _Date_Time_GetLocalTime()
    $tSystem = _Date_Time_TzSpecificLocalTimeToSystemTime($tLocal)
    MemoWrite("Local time to system time .: " & _Date_Time_SystemTimeToDateTimeStr($tSystem))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _DateAdd

Function Reference

_DateAdd

Calculates a new date/time by adding/subtracting a specified number of time intervals from an initial date/time

#include <Date.au3>
_DateAdd ( $sType, $iNumber, $sDate )

Parameters

$sType | Time interval to be used: D - Add/subtract days to/from the specified date M - Add/subtract months to/from the specified date Y - Add/subtract years to/from the specified date w - Add/subtract Weeks to/from the specified date h - Add/subtract hours to/from the specified date n - Add/subtract minutes to/from the specified en date s - Add/subtract seconds to/from the specified date
$iNumber | Number of intervals to be added/subtracted (use unary minus for subtraction)
$sDate | Initial date in the format YYYY/MM/DD[ HH:MM:SS]

Return Value

Success: | Calculated date.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - Invalid $sType 2 - Invalid $iNumber 3 - Invalid $sDate

Remarks

Valid initial date must be between "2000/01/01 00:00:00". and "3000/12/31 23:59:59".

The function will not return an invalid date. For example, if 3 months are added to '2004/1/31' then the result will be '2004/04/30'.

See _DateTimeSplit() for other possible variations of the input date format.

Related

_DateDiff, _DateTimeSplit, _DateToDayOfWeek, _DateToDayOfWeekISO, _DateToDayValue, _DayValueToDate

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

; Add 5 days to today
Local $sNewDate = _DateAdd('d', 5, _NowCalcDate())
MsgBox($MB_SYSTEMMODAL, "", "Today + 5 days:" & $sNewDate)

; Subtract 2 weeks from today
$sNewDate = _DateAdd('w', -2, _NowCalcDate())
MsgBox($MB_SYSTEMMODAL, "", "Today minus 2 weeks: " & $sNewDate)

; Add 15 minutes to current time
$sNewDate = _DateAdd('n', 15, _NowCalc())
MsgBox($MB_SYSTEMMODAL, "", "Current time +15 minutes: " & $sNewDate)

; Calculated eventlogdate which returns second since 1970/01/01 00:00:00
$sNewDate = _DateAdd('s', 1087497645, "1970/01/01 00:00:00")
MsgBox($MB_SYSTEMMODAL, "", "Date: " & $sNewDate)


Function _DateDayOfWeek

Function Reference

_DateDayOfWeek

Returns the name of the weekday, based on the specified day

#include <Date.au3>
_DateDayOfWeek ( $iDayNum [, $iFormat = 0] )

Parameters

$iDayNum | Day number 1 = Sunday 2 = Monday 3 = Tuesday 4 = Wednesday 5 = Thursday 6 = Friday 7 = Saturday
$iFormat | [optional] Format: $DMW_LOCALE_USER (0) - Long name of the weekday (Default) $DMW_SHORTNAME (1) - Short name of the weekday e.g. Mon $DMW_LOCALE_LONGNAME (2) - Long name of the weekday in the user's default language $DMW_LOCALE_SHORTNAME (3) - Short name of the weekday in the user's default language

Return Value

Success: | Weekday name
Failure: | An empty string and sets @error to non-zero
@error: | 1 - Invalid weekday number.

Remarks

The function returns weekday names in English or the user's default language.

Related

_DateDaysInMonth, _DateToDayOfWeek, _DateToDayOfWeekISO

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

; Retrieve the long name
Local $sLongDayName = _DateDayOfWeek(@WDAY)

; Retrieve the abbreviated name
Local $sShortDayName = _DateDayOfWeek(@WDAY, $DMW_SHORTNAME)

MsgBox($MB_SYSTEMMODAL, "Day of Week", "Today is: " & $sLongDayName & " (" & $sShortDayName & ")")


Function _DateDaysInMonth

Function Reference

_DateDaysInMonth

Returns the number of days in a month, based on the specified month and year

#include <Date.au3>
_DateDaysInMonth ( $iYear, $iMonthNum )

Parameters

$iYear | 4-digit year.
$iMonthNum | Month number (1 = January, 12 = December).

Return Value

Success: | the number of days in the month.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - Invalid month number or year.

Related

_DateDayOfWeek

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

Local $iDays = _DateDaysInMonth(@YEAR, @MON)
MsgBox($MB_SYSTEMMODAL, "Days in Month", "This month has " & String($iDays) & " days in it.")


Function _DateDiff

Function Reference

_DateDiff

Returns the difference between 2 dates, expressed in the type requested

#include <Date.au3>
_DateDiff ( $sType, $sStartDate, $sEndDate )

Parameters

$sType | One of the following: D = Difference in days between the given dates M = Difference in months between the given dates Y = Difference in years between the given dates w = Difference in Weeks between the given dates h = Difference in hours between the given dates n = Difference in minutes between the given dates s = Difference in seconds between the given dates
$sStartDate | Input Start date in the format "YYYY/MM/DD[ HH:MM:SS]"
$sEndDate | Input End date in the format "YYYY/MM/DD[ HH:MM:SS]"

Return Value

Success: | Difference between the 2 dates.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - Invalid $sType 2 - Invalid $sStartDate 3 - Invalid $sEndDate

Remarks

Valid dates must be between "2000/01/01 00:00:00". and "3000/12/31 23:59:59"

See _DateTimeSplit() for other possible variations of the start and end date formats.

Related

_DateAdd, _DateTimeSplit, _DateToDayOfWeek, _DateToDayOfWeekISO, _DateToDayValue, _DayValueToDate, _NowCalc

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

; Calculated the number of seconds since EPOCH (1970/01/01 00:00:00)
Local $iDateCalc = _DateDiff('s', "1970/01/01 00:00:00", _NowCalc())
MsgBox($MB_SYSTEMMODAL, "", "Number of seconds since EPOCH: " & $iDateCalc)

; Calculated the number of Hours this year
$iDateCalc = _DateDiff('h', @YEAR & "/01/01 00:00:00", _NowCalc())
MsgBox($MB_SYSTEMMODAL, "", "Number of Hours this year: " & $iDateCalc)


Function _DateIsLeapYear

Function Reference

_DateIsLeapYear

Checks a given year to see if it is a leap year

#include <Date.au3>
_DateIsLeapYear ( $iYear )

Parameters

$iYear The 4-digit year to check.

Return Value

Success: | 1.
Failure: | 0 if the year is not a leap year and sets the @error flag to non-zero.
@error: | 1 - Invalid year.

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

If _DateIsLeapYear(@YEAR) Then
    MsgBox($MB_SYSTEMMODAL, "Leap Year", "This year is a leap year.")
Else
    MsgBox($MB_SYSTEMMODAL, "Leap Year", "This year is not a leap year.")
EndIf


Function _DateIsValid

Function Reference

_DateIsValid

Checks the given date to determine if it is a valid date

#include <Date.au3>
_DateIsValid ( $sDate )

Parameters

$sDate The date to be checked.

Return Value

Success: | 1.
Failure: | 0 if the specified date is not valid.

Remarks

This function takes a date input in one of the following formats:
"yyyy/mm/dd[ hh:mm[:ss]]" or "yyyy/mm/dd[Thh:mm[:ss]]"
"yyyy-mm-dd[ hh:mm[:ss]]" or "yyyy-mm-dd[Thh:mm[:ss]]"
"yyyy.mm.dd[ hh:mm[:ss]]" or "yyyy.mm.dd[Thh:mm[:ss]]"

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

Local $sDate = @YEAR & "/" & @MON & "/" & @MDAY

If _DateIsValid($sDate) Then
    MsgBox($MB_SYSTEMMODAL, "Valid Date", "The specified date is valid.")
Else
    MsgBox($MB_SYSTEMMODAL, "Valid Date", "The specified date is invalid.")
EndIf


Function _DateTimeFormat

Function Reference

_DateTimeFormat

Returns the date in the PC's regional settings format

#include <Date.au3>
_DateTimeFormat ( $sDate, $sType )

Parameters

$sDate | Input date in the format "YYYY/MM/DD[ HH:MM:SS]"
$sType | one the following: 0 - Display a date and/or time. If there is a date part, display it as a short date. If there is a time part, display it as a long time. If present, both parts are displayed. 1 - Display a date using the long date format specified in your computer's regional settings. 2 - Display a date using the short date format specified in your computer's regional settings. 3 - Display a time using the time format specified in your computer's regional settings. 4 - Display a time using the 24-hour format (hh:mm). 5 - Display a time using the 24-hour format (hh:mm:ss).

Return Value

Success: | the date in proper format.
Failure: | 0 and set the @error flag to non-zero.
@error: | 1 - Invalid $sDate 2 - Invalid $sType

Remarks

See _DateTimeSplit() for other possible variations of the input date format.

Related

_NowDate, _NowTime

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

; Show current date/time in the pc's format
MsgBox($MB_SYSTEMMODAL, "Pc Long format", _DateTimeFormat(_NowCalc(), 1))
MsgBox($MB_SYSTEMMODAL, "Pc Short format", _DateTimeFormat(_NowCalc(), 2))


Function _DateTimeSplit

Function Reference

_DateTimeSplit

Split a string containing Date and Time into two separate Arrays

#include <Date.au3>
_DateTimeSplit ( $sDate, ByRef $aDatePart, ByRef $iTimePart )

Parameters

$sDate | Any of these formats: "yyyy/mm/dd[ hh:mm[:ss]]" "yyyy/mm/dd[Thh:mm[:ss]]" "yyyy-mm-dd[ hh:mm[:ss]]" "yyyy-mm-dd[Thh:mm[:ss]]" "yyyy.mm.dd[ hh:mm[:ss]]" "yyyy.mm.dd[Thh:mm[:ss]]"
$aDatePart | array that contains the Date. $aDatePart[0] number of values returned
$iTimePart | array that contains the Time. $aTimePart[0] number of values returned

Return Value

Success: | Date and Time into two separate Arrays.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - Invalid Input Date

Related

_DateAdd, _DateDiff, _DayValueToDate

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

Local $aMyDate, $aMyTime
_DateTimeSplit("2005/01/01 14:30", $aMyDate, $aMyTime)

For $x = 1 To $aMyDate[0]
    MsgBox($MB_SYSTEMMODAL, $x, $aMyDate[$x])
Next
For $x = 1 To $aMyTime[0]
    MsgBox($MB_SYSTEMMODAL, $x, $aMyTime[$x])
Next


Function _DateToDayOfWeek

Function Reference

_DateToDayOfWeek

Returns the weekday number for a given date

#include <Date.au3>
_DateToDayOfWeek ( $iYear, $iMonth, $iDay )

Parameters

$iYear | A valid year in format YYYY
$iMonth | A valid month in format MM
$iDay | A valid day in format DD

Return Value

Success: | the day of the Week Range is 1 to 7 where 1=Sunday.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - Invalid Input Date

Related

_DateAdd, _DateDayOfWeek, _DateDiff, _DateToDayOfWeekISO, _DayValueToDate

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

; Week day number for a given date
Local $iWeekday = _DateToDayOfWeek(@YEAR, @MON, @MDAY)
; Should be equal to @WDAY
MsgBox($MB_SYSTEMMODAL, "", "Todays WeekdayNumber is: " & $iWeekday)
MsgBox($MB_SYSTEMMODAL, "", "Today is a : " & _DateDayOfWeek($iWeekday))


Function _DateToDayOfWeekISO

Function Reference

_DateToDayOfWeekISO

Returns the ISO weekday number for a given date

#include <Date.au3>
_DateToDayOfWeekISO ( $iYear, $iMonth, $iDay )

Parameters

$iYear | A valid year in format YYYY
$iMonth | A valid month in format MM
$iDay | A valid day in format DD

Return Value

Success: | the day of the Week Range is 1 to 7 where 1=Monday.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - Invalid Input Date

Related

_DateAdd, _DateDayOfWeek, _DateDiff, _DateToDayOfWeek, _DayValueToDate

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

; ISO week day number for a given date 1 = Monday - 7 = Sunday
Local $iWeekday = _DateToDayOfWeekISO(@YEAR, @MON, @MDAY)
; NOT equal to @WDAY
MsgBox($MB_SYSTEMMODAL, "", "Today's ISO week day number is: " & $iWeekday)


Function _DateToDayValue

Function Reference

_DateToDayValue

Returns the day number since noon 4713 BC January 1 for a given Gregorian date

#include <Date.au3>
_DateToDayValue ( $iYear, $iMonth, $iDay )

Parameters

$iYear | A valid year in format YYYY
$iMonth | A valid month in format MM
$iDay | A valid day in format DD

Return Value

Success: | the Julian date (days since noon 4713 BC January 1)
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - Invalid Input Date

Related

_DateAdd, _DateDiff, _DayValueToDate

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

; Julian date of today.
Local $sJulDate = _DateToDayValue(@YEAR, @MON, @MDAY)
MsgBox($MB_SYSTEMMODAL, "", "Todays Julian date is: " & $sJulDate)

; 14 days ago calculation.
Local $Y, $M, $D
$sJulDate = _DayValueToDate($sJulDate - 14, $Y, $M, $D)
MsgBox($MB_SYSTEMMODAL, "", "14 days ago:" & $M & "/" & $D & "/" & $Y)


Function _DateToMonth

Function Reference

_DateToMonth

Returns the name of the month, based on the specified month

#include <Date.au3>
_DateToMonth ( $iMonNum [, $iFormat = 0] )

Parameters

$iMonNum | Month number 1 = January 2 = February 3 = March ... 11 = November 12 = December
$iFormat | [optional] Format: $DMW_LOCALE_USER (0) - Long name of the month (Default) $DMW_SHORTNAME (1) - Short name of the month e.g. Jan $DMW_LOCALE_LONGNAME (2) - Long name of the month in the user's default language $DMW_LOCALE_SHORTNAME (3) - Short name of the month in the user's default language

Return Value

Success: | Month name
Failure: | An empty string and sets @error to non-zero
@error: | 1 - Invalid month number.

Remarks

The function returns month names in English or the user's default language.

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

; Retrieve the long name
Local $sLongMonthName = _DateToMonth(@MON)

; Retrieve the abbreviated name
Local $sShortMonthName = _DateToMonth(@MON, $DMW_SHORTNAME)

MsgBox($MB_SYSTEMMODAL, "Month of Year", "The month is: " & $sLongMonthName & " (" & $sShortMonthName & ")")


Function _DayValueToDate

Function Reference

_DayValueToDate

Add the given days since noon 4713 BC January 1 and returns the Gregorian date

#include <Date.au3>
_DayValueToDate ( $iJulianDate, ByRef $iYear, ByRef $iMonth, ByRef $iDay )

Parameters

$iJulianDate | A valid number of days.
$iYear | will return the year in format YYYY
$iMonth | will return the month in format MM
$iDay | will return the day in format DD

Return Value

Success: | the date calculated.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - Invalid Input number of days.

Related

_DateAdd, _DateDiff, _DateTimeSplit, _DateToDayOfWeek, _DateToDayOfWeekISO, _DateToDayValue

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

; Julian date of today.
Local $sJulDate = _DateToDayValue(@YEAR, @MON, @MDAY)
MsgBox($MB_SYSTEMMODAL, "", "Todays Julian date is: " & $sJulDate)

; 14 days ago calculation.
Local $Y, $M, $D
$sJulDate = _DayValueToDate($sJulDate - 14, $Y, $M, $D)
MsgBox($MB_SYSTEMMODAL, "", "14 days ago:" & $M & "/" & $D & "/" & $Y & "  (" & $sJulDate & ")")


Function _Now

Function Reference

_Now

Returns the current Date and Time in PC's format

#include <Date.au3>
_Now ( )

Return Value

Returns Current Date and Time in PC's format.

Remarks

If Date format isn't found in the registry it returns the date in the mm/dd/yyyy format.
If Time format isn't found in the registry it returns the time in the hh:mm:ss format.

Related

_NowDate, _NowTime

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

MsgBox($MB_SYSTEMMODAL, "", "Todays date/Time: " & _Now())


Function _NowCalc

Function Reference

_NowCalc

Returns the current Date and Time in format YYYY/MM/DD HH:MM:SS for use in date calculations

#include <Date.au3>
_NowCalc ( )

Return Value

Returns the current Date and Time in format YYYY/MM/DD HH:MM:SS.

Related

_NowDate, _NowTime

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

; Calculated the number of seconds since EPOCH (1970/01/01 00:00:00)
Local $iDateCalc = _DateDiff('s', "1970/01/01 00:00:00", _NowCalc())
MsgBox($MB_SYSTEMMODAL, "", "Number of seconds since EPOCH: " & $iDateCalc)

; Calculated the number of Hours this year
$iDateCalc = _DateDiff('h', @YEAR & "/01/01 00:00:00", _NowCalc())
MsgBox($MB_SYSTEMMODAL, "", "Number of Hours this year: " & $iDateCalc)


Function _NowCalcDate

Function Reference

_NowCalcDate

Returns the current Date in format YYYY/MM/DD

#include <Date.au3>
_NowCalcDate ( )

Return Value

Returns the current Date in format YYYY/MM/DD.

Related

_NowDate, _NowTime

Example

#include <Date.au3>

Local $iMsg = "Test record"
FileWriteLine(@TempDir & "\Pgm.log", _NowCalcDate() & " :" & $iMsg)


Function _NowDate

Function Reference

_NowDate

Returns the current Date in the Pc's format

#include <Date.au3>
_NowDate ( )

Return Value

Returns the current Date specified in your computer's regional settings.

Remarks

If your computer's regional settings is not accessible it returns the date in the "M/d/yyyy" format.

Related

_DateTimeFormat, _Now, _NowCalc, _NowCalcDate, _NowTime

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

MsgBox($MB_SYSTEMMODAL, '', "The Date is:" & _NowDate())


Function _NowTime

Function Reference

_NowTime

Returns the current Time in the requested format

#include <Date.au3>
_NowTime ( [$sType = 3] )

Parameters

$sType [optional]
3 = (default) Display a time using the time format specified in your computer's regional settings.
4 - Display a time using the 24-hour format (hh:mm).
5 - Display a time using the 24-hour format (hh:mm:ss).

Return Value

Returns the current TIME according to the time format used.

Remarks

If your computer's regional settings is not accessible it returns the time in the "h:mm:ss tt" format.

Related

_DateTimeFormat, _Now, _NowCalc, _NowCalcDate, _NowDate

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

MsgBox($MB_SYSTEMMODAL, '', "The time is:" & _NowTime())


Function _SetDate

Function Reference

_SetDate

Sets the current date of the system

#include <Date.au3>
_SetDate ( $iDay [, $iMonth = 0 [, $iYear = 0]] )

Parameters

$iDay | Day of the month. Values: 1-31
$iMonth | [optional] month. Values: 1-12
$iYear | [optional] year. Values: > 0 (windows might restrict this further!!)

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - Failure
@extended: | _WinAPI_GetLastError() Error code(s): MSDN: ms681381.aspx

Remarks

If the optional parameters ($iMonth,$iYear) are NOT defined, the function will not change the current value!

Related

_SetTime

See Also

Search GetLastError in MSDN Library.

Example

#include <Date.au3>

_SetDate(20) ; Set the current date to 20-xx-xxxx
_SetDate(20, 10) ; Set the current date to 20-10-xxxx
_SetDate(20, 10, 2004) ; Set the current date to 20-10-2004


Function _SetTime

Function Reference

_SetTime

Sets the current time of the system

#include <Date.au3>
_SetTime ( $iHour, $iMinute [, $iSecond = 0 [, $iMSeconds = 0]] )

Parameters

$iHour | the hour. Values: 0-23
$iMinute | the minute. Values: 0-59
$iSecond | [optional] the seconds. Values: 0-59
$iMSeconds | [optional] the milliseconds. Values: 0-999

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - Failure
@extended: | _WinAPI_GetLastError() Error code(s): MSDN: ms681381.aspx

Remarks

If the optional parameters ($iSecond and iMSeconds) are not defined, the function will not change the current value.

Related

_SetDate

See Also

Search GetLastError in MSDN Library.

Example

#include <Date.au3>

_SetTime(20, 15) ; Set time to 20:15
_SetTime(20, 15, 30) ; Set time to 20:15:30


Function _TicksToTime

Function Reference

_TicksToTime

Converts the specified tick amount to hours, minutes and seconds

#include <Date.au3>
_TicksToTime ( $iTicks, ByRef $iHours, ByRef $iMins, ByRef $iSecs )

Parameters

$iTicks | Tick amount.
$iHours | Variable to store the hours.
$iMins | Variable to store the minutes.
$iSecs | Variable to store the seconds.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $iTicks isn't an integer.

Related

_TimeToTicks

Example

; *** Demo to show a timer window
#include <Date.au3>
#include <GUIConstantsEx.au3>

Global $g_hTimer, $g_iSecs, $g_iMins, $g_iHour, $g_sTime

Example()

Func Example()
    ; Create GUI
    GUICreate("Timer", 120, 50)
    GUICtrlCreateLabel("00:00:00", 10, 10)
    GUISetState(@SW_SHOW)
    ; Start timer
    $g_hTimer = TimerInit()
    AdlibRegister("Timer", 50)
    While 1
        ; FileWriteLine("debug.log",@MIN & ":" & @SEC & " ==> before")
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
        EndSwitch
        ; FileWriteLine("debug.log",@MIN & ":" & @SEC & " ==> after")
    WEnd
EndFunc   ;==>Example

Func Timer()
    _TicksToTime(Int(TimerDiff($g_hTimer)), $g_iHour, $g_iMins, $g_iSecs)
    Local $sTime = $g_sTime ; save current time to be able to test and avoid flicker..
    $g_sTime = StringFormat("%02i:%02i:%02i", $g_iHour, $g_iMins, $g_iSecs)
    If $sTime <> $g_sTime Then ControlSetText("Timer", "", "Static1", $g_sTime)
EndFunc   ;==>Timer


Function _TimeToTicks

Function Reference

_TimeToTicks

Converts the specified hours, minutes, and seconds to ticks

#include <Date.au3>
_TimeToTicks ( [$iHours = @HOUR [, $iMins = @MIN [, $iSecs = @SEC]]] )

Parameters

$iHours | [optional] The hours.
$iMins | [optional] The minutes.
$iSecs | [optional] The seconds.

Return Value

Success: | the number of ticks.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - The specified hours, minutes, or seconds are not valid.

Related

_TicksToTime

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

Local $iSec, $iMin, $iHour
; calculate with time
Local $iStartTicks = _TimeToTicks(@HOUR, @MIN, @SEC)
; calculate 45 minutes later
Local $iEndTicks = $iStartTicks + 45 * 60 * 1000
_TicksToTime($iEndTicks, $iHour, $iMin, $iSec)
MsgBox($MB_SYSTEMMODAL, '', 'New Time:' & $iHour & ":" & $iMin & ":" & $iSec)


Function _WeekNumberISO

Function Reference

_WeekNumberISO

Calculate the weeknumber of a given date

#include <Date.au3>
_WeekNumberISO ( [$iYear = @YEAR [, $iMonth = @MON [, $iDay = @MDAY]]] )

Parameters

$iYear | [optional] Year value (default = current year)
$iMonth | [optional] Month value (default = current month)
$iDay | [optional] Day value (default = current day)

Return Value

Success: | a week number of given date.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - faulty parameters values 99 - On non-acceptable weekstart value

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

MsgBox($MB_SYSTEMMODAL, "Todays weeknumber", "Todays weeknumber is " & _WeekNumberISO())


User Defined Functions

Debug user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <Debug.au3>.

User Defined Function | Description
_Assert | Display a message if assertion fails
_DebugBugReportEnv | Outputs a string containing information for Bug report submission
_DebugCOMError | Sets, resets or queries the debug level for COM errors
_DebugOut | Displays output on a debugging session started by _DebugSetup()
_DebugReport | Writes to a debugging session
_DebugReportEx | Writes to a debugging session a formatted message
_DebugReportVar | Writes to debugging session the content of a variable
_DebugSetup | Setup up a debug session using a specific reporting type


Function _Assert

Function Reference

_Assert

Display a message if assertion fails

#include <Debug.au3>
_Assert ( $sCondition [, $bExit = True [, $iCode = 0x7FFFFFFF [, $sLine = @ScriptLineNumber]]] )

Parameters

$sCondition | The condition (expression quoted) that must evaluate to true.
$bExit | [optional] If true, the script is aborted.
$iCode | [optional] The exit code to use if the script is aborted.
$sLine | [optional] Displays the line number where the assertion failed. If this value is not changed, then the default value will show the correct line.

Return Value

Returns the result of the condition (Only valid when not exiting).

Remarks

@error and @extended are not destroyed on return.

Example

#include <Debug.au3>

Local $sABC = ""
_Assert('$sABC > ""')


Function _DebugBugReportEnv

Function Reference

_DebugBugReportEnv

Outputs a string containing information for Bug report submission

#include <Debug.au3>
_DebugBugReportEnv ( )

Return Value

Returns a string containing all information needed to submit.

Remarks

Must be used to submit a Bug Report.

Example

#include <Debug.au3>
#include <MsgBoxConstants.au3>

MsgBox($MB_SYSTEMMODAL, "Bug Report Environment", _DebugBugReportEnv())


Function _DebugCOMError

Function Reference

_DebugCOMError

Sets, resets or queries the debug level for COM errors

#include <Debug.au3>
_DebugCOMError ( [$iComDebug = 1 [, $bExit = False]] )

Parameters

$iComDebug | [optional] Debug level. Possible values are: -1 - Return the current settings 0 - Disable debugging 1 - Enable debugging. Output the debug info (default)
$bExit | [optional] True if the script must be terminated

Return Value

Success: | 1 if $iComDebug = 0 or 1 and sets @extended to: 0 - The COM error handler is not initialized 1 - The COM error handler has been initialized 2 - The COM error handler was already active 3 - The COM error handler is already disabled 1 if $iComDebug = -1 and sets the @error flag and @extented to current setting: @error = current Debug level @extended = current script termination.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $iComDebug is not an integer or < -1 or > 1 2 - The COM error handler is already set to another function (= not set by this function) 3 - _DebugSetup() did not run properly. Make sure _DebugSetup() ran properly before calling this function 4 - Installation of the custom error handler failed. @extended is set to the error code returned by ObjEvent()

Remarks

Before calling this function, _DebugSetup() must be called first to create the debug session.

Related

_DebugSetup

Example

#include <Debug.au3>
#include <MsgBoxConstants.au3>

_DebugSetup(Default, True, 1, Default, True) ; 1 = GUI output with timestamping

Example()

; *****************************************************************************
; Example
; Generate a COM error and let _DebugCOMError display the error
; *****************************************************************************
Func Example()
    ; Create application object for the Microsoft Internet Explorer
    Local $oIE = ObjCreate("InternetExplorer.Application")
    If @error <> 0 Then Exit MsgBox($MB_SYSTEMMODAL, "_DebugCOMError UDF", "Error creating a new IE application object." & _
            @CRLF & "@error = " & @error & ", @extended = " & @extended)
    ; Set up the COM error handler to write error messages using a GUI and exit on error
    _DebugCOMError(1)
    ; Provoke a COM error. Functions is unknown
    $oIE.xyz()
    If @error <> 0 Then Return MsgBox($MB_SYSTEMMODAL, "_DebugCOMError UDF", "Error occurred and handled." & _
            @CRLF & "@error = " & @error)
    ; Close the IE
    $oIE.Quit()
    $oIE = 0
EndFunc   ;==>Example


Function _DebugOut

Function Reference

_DebugOut

Displays output on a debugging session started by _DebugSetup()

#include <Debug.au3>
_DebugOut ( $sOutput )

Parameters

$sOutput The string (or other printable value) to be output to the debugging session.

Return Value

Success: | 1 (see remarks).
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $sOutput is an incompatible type. 3 - _DebugSetup() did not run properly.

Remarks

@error and @extended of the caller are preserved.

Each time _DebugOut() is called, the output is put on its own line.

Related

_DebugSetup

Example

#cs ----------------------------------------------------------------------------

    AutoIt Version: 3.2.8.1
    Author:         David Nuttall

    Script Function:
    Base script to show functionality of Debug functions.

#ce ----------------------------------------------------------------------------

#include <Debug.au3>

_DebugSetup("Check Excel")
For $i = 1 To 4
    WinActivate("Microsoft Excel")
    ; interact with Excel
    Send("{Down}")
    _DebugOut("Moved Mouse Down")
Next


Function _DebugReport

Function Reference

_DebugReport

Writes to a debugging session

#include <Debug.au3>
_DebugReport ( $sData [, $bLastError = False [, $bExit = False]] )

Parameters

$sData | Data to be reported
$bLastError | [optional] True if _WinAPI_GetLastErrorMessage() must be append to the data being reported
$bExit | [optional] True if the script must be terminated

Return Value

Success: | 1 (see remarks).
Failure: | 0.

Remarks

If no _DebugSetup() have been issued the function always returns.
@error of the caller is preserved.
@extended can be set to Windows API _WinNet_GetLastError() if $bLastError = True.
Otherwise it is preserved.

Related

_DebugSetup

Example

#include <Debug.au3>

_DebugSetup()

_DebugReport("message1")
_DebugReport("message2", True); with last error message appended


Function _DebugReportEx

Function Reference

_DebugReportEx

Writes to a debugging session a formatted message

#include <Debug.au3>
_DebugReportEx ( $sData [, $bLastError = False [, $bExit = False]] )

Parameters

$sData | Data to be reported (e.g. "dllname|functionname")
$bLastError | [optional] True if _WinAPI_GetLastErrorMessage() must be append to the data being reported
$bExit | [optional] True if the script must be terminated

Return Value

Success: | 1 (see remarks).
Failure: | 0.

Remarks

According to the @error flag value the message will be formatted as follow:
0 - report "Bad return from FUNCTION in DLL".
1 - report "unable to open a DLL"
3 - report "unable to find FUNCTION in DLL".

If $sData is does not contain a "|" or @error not as specified above the reported message will not be formated.
If no _DebugSetup() have been issued the function always returns.
@error of the caller is preserved.
@extended can be set to Windows API _WinNet_GetLastError() if $bLastError = True.
Otherwise it is preserved.

Related

_DebugSetup

Example

#include <Debug.au3>

_DebugSetup()

_DebugReport("message1")

SomeUDF("anyfunction")
If @error Then _DebugReportEx("user32|anyfunction", True); with last error message appended

Local $iRet = SomeUDF("CloseClipboard")
If @error Or $iRet = 0 Then _DebugReportEx("user32|CloseClipboard")

_DebugReport("message2")

$iRet = SomeUDF("CloseClipboard")
If @error Or $iRet = 0 Then _DebugReportEx("user32|CloseClipboard", False, True) ; Script will be terminated

_DebugReport("message3") ; will not be reported

Func SomeUDF($sFunc)
    Local $aResult = DllCall("user32.dll", "int", $sFunc)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[0]
EndFunc   ;==>SomeUDF


Function _DebugReportVar

Function Reference

_DebugReportVar

Writes to debugging session the content of a variable

#include <Debug.au3>
_DebugReportVar ( $sVarName, $vVar [, $bErrExt = False [, $iDebugLineNumber = @ScriptLineNumber]] )

Parameters

$sVarName | string representing name of the variable or a comment
$vVar | the variable to be reported
$bErrExt | [optional] True if @error and @extended must also be displayed
$iDebugLineNumber | [optional] can be used to overwrite the current calling line number. Default = @ScriptLineNumber

Return Value

None.

Remarks

If no _DebugSetup() have been issued the function always returns.
@error and @extended of the caller are preserved.

Related

_DebugSetup

Example

#include <Debug.au3>

_DebugSetup("_DebugReportVar examples", True)

Local $aArray2D[5][2]
For $r = 0 To UBound($aArray2D, 1) - 1
    For $c = 0 To UBound($aArray2D, 2) - 1
        $aArray2D[$r][$c] = $r & "," & $c
    Next
Next
_DebugReportVar("Array2D", $aArray2D)

Local $aArray[7] = [1, 1.1, "string", Binary(0x010203), Ptr(-1), False, Default]
_DebugReportVar("Array", $aArray)

Local $aArray3D[5][2][10]
_DebugReportVar("Array3D", $aArray3D)

Local $iInt = -1
_DebugReportVar("int", $iInt)

Local $iInt64 = 2 ^ 63
_DebugReportVar("int64", $iInt64)

Local $bBool = True
_DebugReportVar("bool", $bBool)

Local $fFloat = 1.1
_DebugReportVar("float", $fFloat)

Local $vKeyword = Default
_DebugReportVar("keyword", $vKeyword)

Local $sString = "stringstring"
_DebugReportVar("string", $sString)

Local $dBinary = Binary("0x0102030405060708")
_DebugReportVar("binary", $dBinary)

$dBinary = Binary("abcdefghij")
_DebugReportVar("binary", $dBinary)

Local $pPtr = Ptr(0)
_DebugReportVar("ptr", $pPtr)

Local $hWnd = WinActive("", "")
_DebugReportVar("hwnd", $hWnd)

Local $tDllstruct = DllStructCreate("int")
_DebugReportVar("dllstruct", $tDllstruct)

Local $oObj = ObjCreate("shell.application")
_DebugReportVar("obj", $oObj)


Function _DebugSetup

Function Reference

_DebugSetup

Setup up a debug session using a specific reporting type

#include <Debug.au3>
_DebugSetup ( [$sTitle = Default [, $bBugReportInfos = False [, $vReportType = 1 [, $sLogFile = "" [, $bTimeStamp = False]]]]] )

Parameters

$sTitle | [optional] Title to be displayed on the report window. Default value is "AutoIt Debug Report".
$bBugReportInfos | [optional] Display BugReport infos. Default value is False.
$vReportType | [optional] 1 - Report Log Window (Default). 2 - ConsoleWrite. 3 - MsgBox. 4 - FileWrite into $sLogFile defines the filename. 5 - Report Notepad Window. string - name of specific report function to be used.
$sLogFile | [optional] Name of the file if $vReportType = 4
$bTimeStamp | [optional] True if every message must be prefixed with a timeStamp "YYYY/MM/DD HH:MM:SS"

Return Value

Success: | the report type.
Failure: | sets the @error flag to non-zero.
@error: | 1 - if already called 2 - invalid report type 3 - invalid CallBack function

Remarks

If a specific reporting function is registered then on AutoIt exit it is called without parameters.

You can only start one debug session at a time in the running script.
You can debug several concurrent scripts using the same debugging session, just use the same $sTitle when calling _DebugSetup(). All _DebugOut() will go to the same debugging session.

Commenting out the _DebugSetup() call will effectively disable all the calls to _Debug...(), but you may want to remove the calls to all _Debug...() functions before making a release version of your script.

If the "Report Log Window" type is used then the script will end only when closing the report window.

Related

_DebugOut, _DebugReport, _DebugReportEx, _DebugReportVar

Example

#cs ----------------------------------------------------------------------------

    AutoIt Version: 3.2.8.1
    Author:         David Nuttall

    Script Function:
    Base script to show functionality of Debug functions.

#ce ----------------------------------------------------------------------------

#include <Debug.au3>

_DebugSetup("Check Excel", True) ; start displaying debug environment
For $i = 1 To 4
    WinActivate("Microsoft Excel")
    ; interact with Excel
    Send("{Down}")
    _DebugOut("Moved Mouse Down") ; forces debug notepad window to take control
Next


User Defined Functions

EventLog user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <EventLog.au3>.

User Defined Function | Description
_EventLog__Backup | Saves the event log to a backup file
_EventLog__Clear | Clears the event log
_EventLog__Close | Closes a read handle to the event log
_EventLog__Count | Retrieves the number of records in the event log
_EventLog__DeregisterSource | Closes a write handle to the event log
_EventLog__Full | Retrieves whether the event log is full
_EventLog__Notify | Enables an application to receive event notifications
_EventLog__Oldest | Retrieves the absolute record number of the oldest record in the event log
_EventLog__Open | Opens a handle to the event log
_EventLog__OpenBackup | Opens a handle to a backup event log
_EventLog__Read | Reads an entry from the event log
_EventLog__RegisterSource | Retrieves a registered handle to the specified event log
_EventLog__Report | Writes an entry at the end of the specified event log


Function _EventLog__Backup

Function Reference

_EventLog__Backup

Saves the event log to a backup file

#include <EventLog.au3>
_EventLog__Backup ( $hEventLog, $sFileName )

Parameters

$hEventLog | Handle to the event log
$sFileName | The name of the backup file

Return Value

Success: | True
Failure: | False

Remarks

The function does not clear the event log. The function fails if the user does not have the SE_BACKUP_NAME privilege.

Related

_EventLog__OpenBackup

Example

#include <EventLog.au3>

Example()

Func Example()
    Local $hEventLog

    $hEventLog = _EventLog__Open("", "Application")
    _EventLog__Backup($hEventLog, "C:\EventLog.bak")
    _EventLog__Close($hEventLog)
EndFunc   ;==>Example


Function _EventLog__Clear

Function Reference

_EventLog__Clear

Clears the event log

#include <EventLog.au3>
_EventLog__Clear ( $hEventLog, $sFileName )

Parameters

$hEventLog | Handle to the event log
$sFileName | The name of the backup file. If the name is blank, the current event log is not backed up.

Return Value

Success: | True
Failure: | False

Remarks

This function fails if the event log is empty or a file already exists with the same name as $sFileName.
After this function returns, any handles that reference the cleared event log cannot be used to read the log.

Related

_EventLog__Open

Example

#include <EventLog.au3>

Example()

Func Example()
    Local $hEventLog

    $hEventLog = _EventLog__Open("", "Application")
    _EventLog__Clear($hEventLog, "C:\EventLog.bak")
    _EventLog__Close($hEventLog)
EndFunc   ;==>Example


Function _EventLog__Close

Function Reference

_EventLog__Close

Closes a read handle to the event log

#include <EventLog.au3>
_EventLog__Close ( $hEventLog )

Parameters

$hEventLog Handle to the event log

Return Value

Success: | True
Failure: | False

Related

_EventLog__Notify, _EventLog__Open, _EventLog__OpenBackup, _EventLog__Read, _EventLog__Report

Example

#include <EventLog.au3>
#include <GUIConstantsEx.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hEventLog

    ; Create GUI
    GUICreate("EventLog", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 300, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hEventLog = _EventLog__Open("", "Application")
    MemoWrite("Log full ........: " & _EventLog__Full($hEventLog))
    MemoWrite("Log record count : " & _EventLog__Count($hEventLog))
    MemoWrite("Log oldest record: " & _EventLog__Oldest($hEventLog))
    _EventLog__Close($hEventLog)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _EventLog__Count

Function Reference

_EventLog__Count

Retrieves the number of records in the event log

#include <EventLog.au3>
_EventLog__Count ( $hEventLog )

Parameters

$hEventLog A handle to the event log

Return Value

Success: | the number of records in the event log.
Failure: | -1

Remarks

The oldest record in an event log is not necessarily record number 1.
To determine the record number of the oldest record in an event log, use the _EventLog__Oldest()

Related

_EventLog__Full, _EventLog__Oldest

Example

#include <EventLog.au3>
#include <GUIConstantsEx.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hEventLog

    ; Create GUI
    GUICreate("EventLog", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 300, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hEventLog = _EventLog__Open("", "Application")
    MemoWrite("Log full ........: " & _EventLog__Full($hEventLog))
    MemoWrite("Log record count : " & _EventLog__Count($hEventLog))
    MemoWrite("Log oldest record: " & _EventLog__Oldest($hEventLog))
    _EventLog__Close($hEventLog)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _EventLog__DeregisterSource

Function Reference

_EventLog__DeregisterSource

Closes a write handle to the event log

#include <EventLog.au3>
_EventLog__DeregisterSource ( $hEventLog )

Parameters

$hEventLog A handle to the event log

Return Value

Success: | True
Failure: | False

Related

_EventLog__Notify, _EventLog__RegisterSource


Function _EventLog__Full

Function Reference

_EventLog__Full

Retrieves whether the event log is full

#include <EventLog.au3>
_EventLog__Full ( $hEventLog )

Parameters

$hEventLog A handle to the event log

Return Value

True: | Event log is full.
False: | Event log is not full.

Related

_EventLog__Count, _EventLog__Oldest

Example

#include <EventLog.au3>
#include <GUIConstantsEx.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hEventLog

    ; Create GUI
    GUICreate("EventLog", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 300, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hEventLog = _EventLog__Open("", "Application")
    MemoWrite("Log full ........: " & _EventLog__Full($hEventLog))
    MemoWrite("Log record count : " & _EventLog__Count($hEventLog))
    MemoWrite("Log oldest record: " & _EventLog__Oldest($hEventLog))
    _EventLog__Close($hEventLog)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _EventLog__Notify

Function Reference

_EventLog__Notify

Enables an application to receive event notifications

#include <EventLog.au3>
_EventLog__Notify ( $hEventLog, $hEvent )

Parameters

$hEventLog | A handle to the event log
$hEvent | A handle to a manual-reset event object

Return Value

Success: | True
Failure: | False

Remarks

This function does not work with remote handles.
If the $hEventLog parameter is the handle to an event log on a remote computer, this function returns zero, and GetLastError returns ERROR_INVALID_HANDLE.
When an event is written to the log specified by $hEventLog, the system uses the PulseEvent function to set the event specified by the $hEvent parameter to the signaled state.
If the thread is not waiting on the event when the system calls PulseEvent, the thread will not receive the notification.
Therefore, you should create a separate thread to wait for notifications.
Note that the system calls PulseEvent no more than once every five seconds.
Therefore, even if more than one event log change occurs within a five second interval, you will only receive one notification.
The system will continue to notify you of changes until you close the handle to the event log.
To close the event log, use the _EventLog__Close() or _EventLog__DeregisterSource().

Related

_EventLog__Close, _EventLog__DeregisterSource

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hEventLog, $hEvent, $iResult

    ; Create GUI
    GUICreate("EventLog", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 300, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set up event
    $hEventLog = _EventLog__Open("", "Security")
    $hEvent = _WinAPI_CreateEvent(0, False, False, "")
    _EventLog__Notify($hEventLog, $hEvent)

    ; Wait for new event to occur
    MemoWrite("Waiting for new event")
    $iResult = _WinAPI_WaitForSingleObject($hEvent)
    _WinAPI_CloseHandle($hEvent)
    _EventLog__Close($hEventLog)

    ; Write results
    If $iResult = -1 Then
        MemoWrite("Wait failed")
    Else
        MemoWrite("New event occurred")
    EndIf

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _EventLog__Oldest

Function Reference

_EventLog__Oldest

Retrieves the absolute record number of the oldest record in the event log

#include <EventLog.au3>
_EventLog__Oldest ( $hEventLog )

Parameters

$hEventLog A handle to the event log

Return Value

Success: | the absolute record number of the oldest record in the event log.
Failure: | 0.

Remarks

The oldest record in an event log is not necessarily record number 1.

Related

_EventLog__Count, _EventLog__Full

Example

#include <EventLog.au3>
#include <GUIConstantsEx.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hEventLog

    ; Create GUI
    GUICreate("EventLog", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 300, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hEventLog = _EventLog__Open("", "Application")
    MemoWrite("Log full ........: " & _EventLog__Full($hEventLog))
    MemoWrite("Log record count : " & _EventLog__Count($hEventLog))
    MemoWrite("Log oldest record: " & _EventLog__Oldest($hEventLog))
    _EventLog__Close($hEventLog)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _EventLog__Open

Function Reference

_EventLog__Open

Opens a handle to the event log

#include <EventLog.au3>
_EventLog__Open ( $sServerName, $sSourceName )

Parameters

$sServerName | The UNC name of the server on where the event log will be opened. If blank, the operation is performed on the local computer.
$sSourceName | The name of the log

Return Value

Success: | the handle to the event log.
Failure: | 0.

Remarks

To close the handle to the event log, use the _EventLog__Close().

Related

_EventLog__Clear, _EventLog__Close, _EventLog__Read, _EventLog__Report

Example

#include <EventLog.au3>
#include <GUIConstantsEx.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hEventLog

    ; Create GUI
    GUICreate("EventLog", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 300, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hEventLog = _EventLog__Open("", "Application")
    MemoWrite("Log full ........: " & _EventLog__Full($hEventLog))
    MemoWrite("Log record count : " & _EventLog__Count($hEventLog))
    MemoWrite("Log oldest record: " & _EventLog__Oldest($hEventLog))
    _EventLog__Close($hEventLog)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _EventLog__OpenBackup

Function Reference

_EventLog__OpenBackup

Opens a handle to a backup event log

#include <EventLog.au3>
_EventLog__OpenBackup ( $sServerName, $sFileName )

Parameters

$sServerName | The UNC name of the server on where the event log will be opened. If blank, the operation is performed on the local computer.
$sFileName | The name of the backup file

Return Value

Success: | the handle to the backup event log.
Failure: | 0.

Remarks

If the backup filename specifies a remote server, $sServerName must be blank.

Related

_EventLog__Backup, _EventLog__Close

Example

#include <EventLog.au3>
#include <GUIConstantsEx.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hEventLog

    ; Create GUI
    GUICreate("EventLog", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 300, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hEventLog = _EventLog__Open("", "Application")
    _EventLog__Backup($hEventLog, "C:\EventLog.bak")
    _EventLog__Close($hEventLog)

    $hEventLog = _EventLog__OpenBackup("", "C:\EventLog.bak")
    MemoWrite("Log full ........: " & _EventLog__Full($hEventLog))
    MemoWrite("Log record count : " & _EventLog__Count($hEventLog))
    MemoWrite("Log oldest record: " & _EventLog__Oldest($hEventLog))
    _EventLog__Close($hEventLog)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _EventLog__Read

Function Reference

_EventLog__Read

Reads an entry from the event log

#include <EventLog.au3>
_EventLog__Read ( $hEventLog [, $bRead = True [, $bForward = True [, $iOffset = 0]]] )

Parameters

$hEventLog | A handle to the event log
$bRead | [optional] If True, operation proceeds sequentially from the last call to this function using this handle. If False, the read will operation proceeds from the record specified by the $iOffset parameter.
$bForward | [optional] If True, the log is read in date order. If False, the log is read in reverse date order.
$iOffset | [optional] The number of the event record at which the read operation should start. This parameter is ignored if $bRead is True.

Return Value

Success: | an array with the following format: [ 0] - True [ 1] - Number of the record [ 2] - Date at which this entry was submitted [ 3] - Time at which this entry was submitted [ 4] - Date at which this entry was received to be written to the log [ 5] - Time at which this entry was received to be written to the log [ 6] - Event identifier [ 7] - Event type. This can be one of the following values: 1 - Error event 2 - Warning event 4 - Information event 8 - Success audit event 16 - Failure audit event [ 8] - Event type string [ 9] - Event category [10] - Event source [11] - Computer name [12] - Username [13] - Event description [14] - Event data array
Failure: | $Array[0] = False

Remarks

When this function returns successfully, the read position in the event log is adjusted by the number of records read.
Though multiple records can be read, this function returns one record at a time for sanity sake.

Related

_EventLog__Close, _EventLog__Open

Example

#include <EventLog.au3>
#include <GUIConstantsEx.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hEventLog, $aEvent

    ; Create GUI
    GUICreate("EventLog", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 300, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Read most current event record
    $hEventLog = _EventLog__Open("", "Application")
    $aEvent = _EventLog__Read($hEventLog, True, False) ; read last event
    ; $hEventLog = _EventLog__Open("", "System")
    ; $aEvent = _EventLog__Read($hEventLog)
    ; $aEvent = _EventLog__Read($hEventLog, True, False)
    MemoWrite("Result ............: " & $aEvent[0])
    MemoWrite("Record number .....: " & $aEvent[1])
    MemoWrite("Submitted .........: " & $aEvent[2] & " " & $aEvent[3])
    MemoWrite("Generated .........: " & $aEvent[4] & " " & $aEvent[5])
    MemoWrite("Event ID ..........: " & $aEvent[6])
    MemoWrite("Type ..............: " & $aEvent[8])
    MemoWrite("Category ..........: " & $aEvent[9])
    MemoWrite("Source ............: " & $aEvent[10])
    MemoWrite("Computer ..........: " & $aEvent[11])
    MemoWrite("Username ..........: " & $aEvent[12])
    MemoWrite("Description .......: " & $aEvent[13])
    _EventLog__Close($hEventLog)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _EventLog__RegisterSource

Function Reference

_EventLog__RegisterSource

Retrieves a registered handle to the specified event log

#include <EventLog.au3>
_EventLog__RegisterSource ( $sServerName, $sSourceName )

Parameters

$sServerName | The UNC name of the server on where the event log will be opened. If blank, the operation is performed on the local computer.
$sSourceName | The name of the event source whose handle is to be retrieved. The source name must be a subkey of a log under the Eventlog registry key.

Return Value

Success: | the handle to an event log.
Failure: | 0.

Remarks

If the source name cannot be found, the event logging service uses the Application log; it does not create a new source.
Events are reported for the source, however, there are no message and category message files specified for looking up descriptions of the event identifiers for the source.
To close the handle to the event log, use the _EventLog__DeregisterSource().

Related

_EventLog__DeregisterSource


Function _EventLog__Report

Function Reference

_EventLog__Report

Writes an entry at the end of the specified event log

#include <EventLog.au3>
_EventLog__Report ( $hEventLog, $iType, $iCategory, $iEventID, $sUserName, $sDesc, $aData )

Parameters

$hEventLog | A handle to the event log. As of Windows XP SP2, this cannot be a handle to the Security log.
$iType | Event type. This can be one of the following values: 0 - Success event 1 - Error event 2 - Warning event 4 - Information event 8 - Success audit event 16 - Failue audit event
$iCategory | The event category. This is source specific information the category can have any value.
$iEventID | The event identifier. The event identifier specifies the entry in the message file associated with the event source.
$sUserName | User name for the event. This can be blank to indicate that no name is required.
$sDesc | Event description
$aData | Data array formated as follows: [0] - Number of bytes in array [1] - Byte 1 [2] - Byte 2 [n] - Byte n

Return Value

Success: | True
Failure: | False

Remarks

This function is used to log an event.
The entry is written to the end of the configured log for the source identified by the $hEventLog parameter.
This function adds the time, the entry's length, and the offsets before storing the entry in the log.

Related

_EventLog__Close, _EventLog__Open

Example

#include <EventLog.au3>

Example()

Func Example()
    Local $hEventLog, $aData[4] = [3, 1, 2, 3]

    $hEventLog = _EventLog__Open("", "Application")
    _EventLog__Report($hEventLog, 4, 0, 2, "Administrator", "AutoIt3 generated event", $aData)
    _EventLog__Close($hEventLog)
EndFunc   ;==>Example


User Defined Functions

Excel user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <Excel.au3>.

User Defined Function | Description
_Excel_BookAttach | Attaches to the first instance of a workbook where the search string matches based on the selected mode
_Excel_BookClose | Closes the specified workbook
_Excel_BookList | Returns a list of workbooks of a specified or all Excel instances
_Excel_BookNew | Creates a new workbook
_Excel_BookOpen | Opens an existing workbook
_Excel_BookOpenText | Opens a text file and parses the content to a new workbook with a single sheet
_Excel_BookSave | Saves the specified workbook
_Excel_BookSaveAs | Saves the specified workbook with a new filename and/or type
_Excel_Close | Closes all worksheets and the instance of the Excel application
_Excel_ColumnToLetter | Converts the column number to letter(s)
_Excel_ColumnToNumber | Converts the column letter(s) to a number
_Excel_ConvertFormula | Converts cell references in a formula between A1 and R1C1 reference styles, relative and absolute reference type, or both
_Excel_Export | Exports a workbook, worksheet, chart or range as PDF or XPS
_Excel_FilterGet | Returns a list of set filters
_Excel_FilterSet | Sets/unsets filter definitions and filters the range
_Excel_Open | Connects to an existing Excel instance or creates a new one
_Excel_PictureAdd | Adds a picture on the specified workbook and worksheet
_Excel_Print | Prints a workbook, worksheet, chart or range
_Excel_RangeCopyPaste | Cuts or copies one or multiple cells, rows or columns to a range or from/to the clipboard
_Excel_RangeDelete | Deletes one or multiple cells, rows or columns from the specified worksheet
_Excel_RangeFind | Finds matching cells in a range or workbook and returns an array with information about the found cells
_Excel_RangeInsert | Inserts one or multiple empty cells, rows or columns into the specified worksheet
_Excel_RangeLinkAddRemove | Adds or removes a hyperlink to/from a specified range
_Excel_RangeRead | Reads the value, formula or displayed text from a cell or range of cells of the specified workbook and worksheet
_Excel_RangeReplace | Finds and replaces matching strings in a range or worksheet
_Excel_RangeSort | Sorts a cell range
_Excel_RangeValidate | Adds data validation to the specified range
_Excel_RangeWrite | Writes value(s) or formula(s) to a cell or a cell range on the specified workbook and worksheet
_Excel_SheetAdd | Adds new sheet(s) to a workbook and sets their names
_Excel_SheetCopyMove | Copies or moves the specified sheet before or after a specified sheet in the same or a different workbook
_Excel_SheetDelete | Deletes the specified sheet by object, string name or by number
_Excel_SheetList | Returns a list of all sheets in the specified workbook


Function _Excel_BookAttach

Function Reference

_Excel_BookAttach

Attaches to the first instance of a workbook where the search string matches based on the selected mode

#include <Excel.au3>
_Excel_BookAttach ( $sString [, $sMode = "FilePath" [, $oInstance = Default]] )

Parameters

$sString | String to search for
$sMode | [optional] specifies search mode: FileName - Name of the open workbook FilePath - Full path to the open workbook (default) Title - Title of the Excel window
$oInstance | [optional] Object of the Excel instance to be searched (default = keyword Default = all instances)

Return Value

Success: | the Excel workbook object.
Failure: | 0 and sets @error.
@error: | 1 - An error occurred or $sString can't be found in any of the open workbooks. @extended is set to the COM error code 2 - $sMode is invalid

Related

_Excel_BookClose, _Excel_BookNew, _Excel_BookOpen, _Excel_BookOpenText

Example

Example 1

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $sWorkbook = @ScriptDir & "\Extras\_Excel1.xls"
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookAttach Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookAttach Example", "Error opening workbook '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Attach to the first Workbook where the file path matches
; *****************************************************************************
$oWorkbook = _Excel_BookAttach($sWorkbook)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookAttach Example 1", "Error attaching to '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookAttach Example 1", "Search by 'filepath':" & @CRLF & @CRLF & "Successfully attached to Workbook '" & $sWorkbook & "'." & @CRLF & @CRLF & "Value of cell B3: " & $oWorkbook.Activesheet.Range("B3").Value)

Example 2

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error <> 0 Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookAttach Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookAttach Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Attach to the first Workbook where the file name matches
; *****************************************************************************
Local $sWorkbook = "_Excel1.xls"
$oWorkbook = _Excel_BookAttach($sWorkbook, "filename")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookAttach Example 2", "Error attaching to '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookAttach Example 2", "Search by 'filename':" & @CRLF & @CRLF & "Successfully attached to Workbook '" & $sWorkbook & "'." & @CRLF & @CRLF & "Value of cell A2: " & $oWorkbook.Activesheet.Range("A2").Value)


Function _Excel_BookClose

Function Reference

_Excel_BookClose

Closes the specified workbook

#include <Excel.au3>
_Excel_BookClose ( $oWorkbook [, $bSave = True] )

Parameters

$oWorkbook | Workbook object
$bSave | [optional] If True the workbook will be saved before closing (default = True)

Return Value

Success: | 1.
Failure: | 0 and sets @error.
@error: | 1 - $oWorkbook is not an object or not a workbook object 2 - Error occurred when saving the workbook. @extended is set to the COM error code returned by the Save method 3 - Error occurred when closing the workbook. @extended is set to the COM error code returned by the Close method

Related

_Excel_BookAttach, _Excel_BookNew, _Excel_BookOpen, _Excel_BookOpenText

Example

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Create a new workbook, write some data and close it without saving
; *****************************************************************************
; Create the new workbook
Local $oWorkbook = _Excel_BookNew($oExcel)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookClose Example 1", "Error creating new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Write something into cell A1
_Excel_RangeWrite($oWorkbook, Default, "Test", "A1")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookClose Example 1", "Error writing to cell 'A1'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox(64, "Excel UDF: _Excel_BookClose Example 1", "Click OK to close the workbook without saving.")
; Close the workbook without saving
_Excel_BookClose($oWorkbook, False)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookClose Example 1", "Error saving workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookClose Example 1", "Workbook has been successfully closed.")


Function _Excel_BookList

Function Reference

_Excel_BookList

Returns a list of workbooks of a specified or all Excel instances

#include <Excel.au3>
_Excel_BookList ( [$oExcel = Default] )

Parameters

$oExcel [optional] An Excel application object (default = keyword Default = process all Excel instances)

Return Value

Success: | a two-dimensional zero based array with the following information: 0 - Object of the workbook 1 - Name of the workbook/file 2 - Complete path to the workbook/file
Failure: | 0 and sets @error.
@error: | 1 - $oExcel is not an object or not an application object

Example

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create two instances of Excel and open two workbooks
Local $sWorkbook1 = @ScriptDir & "\Extras\_Excel1.xls", $sWorkbook2 = @ScriptDir & "\Extras\_Excel2.xls"
Local $oExcel1 = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookList Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook1 = _Excel_BookOpen($oExcel1, $sWorkbook1)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookList Example", "Error opening workbook '" & $sWorkbook1 & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel1)
    Exit
EndIf
Local $oExcel2 = _Excel_Open(Default, Default, Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookList Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook2 = _Excel_BookOpen($oExcel2, $sWorkbook2)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookList Example", "Error opening workbook '" & $sWorkbook1 & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel1)
    _Excel_Close($oExcel2)
    Exit
EndIf

; *****************************************************************************
; Display a list of all workbooks of all Excel instances
; *****************************************************************************
Local $aWorkBooks = _Excel_BookList()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookList Example 2", "Error listing Workbooks." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
_ArrayDisplay($aWorkBooks, "Excel UDF: _Excel_BookList Example 2 - List of workbooks of all instances")


Function _Excel_BookNew

Function Reference

_Excel_BookNew

Creates a new workbook

#include <Excel.au3>
_Excel_BookNew ( $oExcel [, $iSheets = Default] )

Parameters

$oExcel | Excel application object where you want to create the new workbook
$iSheets | [optional] Number of sheets to create in the new workbook (default = keyword Default = Excel default value). Maximum is 255

Return Value

Success: | a new workbook object.
Failure: | 0 and sets @error.
@error: | 1 - $oExcel is not an object or not an application object 2 - Error setting SheetsInNewWorkbook to $iSheets. @extended is set to the COM error code 3 - Error returned by method Workbooks.Add. @extended is set to the COM error code 4 - Parameter $iSheets < 1 or > 255

Remarks

There seems to be a limit for property SheetsInNewWorkbook of 255.

Related

_Excel_BookAttach, _Excel_BookClose, _Excel_BookOpen, _Excel_BookOpenText

Example

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Create a new workbook with only 2 worksheets
; *****************************************************************************
_Excel_BookNew($oExcel, 2)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookNew Example 1", "Error creating new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookNew Example 1", "Workbook has been created successfully with only 2 worksheets.")


Function _Excel_BookOpen

Function Reference

_Excel_BookOpen

Opens an existing workbook

#include <Excel.au3>
_Excel_BookOpen ( $oExcel, $sFilePath [, $bReadOnly = False [, $bVisible = True [, $sPassword = Default [, $sWritePassword = Default [, $bUpdateLinks = Default]]]]] )

Parameters

$oExcel | Excel application object where you want to open the workbook
$sFilePath | Path and filename of the file to be opened
$bReadOnly | [optional] True opens the workbook as read-only (default = False)
$bVisible | [optional] True specifies that the workbook window will be visible (default = True)
$sPassword | [optional] The password that was used to read-protect the workbook, if any (default is none)
$sWritePassword | [optional] The password that was used to write-protect the workbook, if any (default is none)
$bUpdateLinks | [optional] Specifies the way external references (links) in the file are updated (default = keyword Default) Valid values are: Default: Excel prompts the user to decide how to update links. 0: Excel doesn't update links. 3: Excel updates all links.

Return Value

Success: | an workbook object. @extended is set to 1 if $bReadOnly = False but read-write access could not be granted. Please see the Remarks section for details.
Failure: | 0 and sets @error.
@error: | 1 - $oExcel is not an object or not an application object 2 - Specified $sFilePath does not exist 3 - Unable to open $sFilePath. @extended is set to the COM error code returned by the Open method

Remarks

When you set $bReadOnly = False but the document can't be opened read-write @extended is set to 1.
The Workbook was opened read-only because it has already been opened by another user/task or the file is set to read-only by the filesystem.
If you modify the workbook you need to use _Excel_BookSaveAs() to save it to another location or with another name.

When setting $bVisible = False when opening a Workbook make sure to set the Workbook to visible again before saving the Workbook.
Use $oExcel.Windows($oWorkbook.Name).Visible = True to make the Workbook visible again.
Else the Workbook will not be shown when you manually open it using Excel.
Most of the time this parameter is not needed. Using $bVisible = False in _Excel_Open is the preferred way.

If $bUpdateLinks is set to Default the user is only prompted if $bDisplayAlerts is set to True in function _Excel_Open.
If $bDisplayAlerts is set to False, Excel chooses the default response.

Related

_Excel_BookAttach, _Excel_BookClose, _Excel_BookNew, _Excel_BookOpenText

Example

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox(16, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Open an existing workbook and return its object identifier.
; *****************************************************************************
Local $sWorkbook = @ScriptDir & "\Extras\_Excel1.xls"
Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen Example 1", "Error opening '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen Example 1", "Workbook '" & $sWorkbook & "' has been opened successfully." & @CRLF & @CRLF & "Creation Date: " & $oWorkbook.BuiltinDocumentProperties("Creation Date").Value)


Function _Excel_BookOpenText

Function Reference

_Excel_BookOpenText

Opens a text file and parses the content to a new workbook with a single sheet

#include <Excel.au3>
_Excel_BookOpenText ( $oExcel, $sFilePath [, $iStartRow = 1 [, $iDataType = Default [, $sTextQualifier = $xlTextQualifierDoubleQuote [, $bConsecutiveDelimiter = False [, $sDelimiter = "," [, $aFieldInfo = "" [, $sDecimalSeparator = Default [, $sThousandsSeparator = Default [, $bTrailingMinusNumbers = True [, $iOrigin = Default]]]]]]]]]] )

Parameters

$oExcel | Excel application object where you want to open the new workbook
$sFilePath | Path and filename of the file to be opened
$iStartRow | [optional] The row at which to start parsing the file (default = 1)
$iDataType | [optional] Specifies the column format of the data in the file. Can be any of the XlTextParsingType enumeration. If set to keyword Default Excel attempts to determine the column format (default = keyword Default)
$sTextQualifier | [optional] Specifies the text qualifier (default = $xlTextQualifierDoubleQuote)
$bConsecutiveDelimiter | [optional] True will consider consecutive delimiters as one delimiter (default = False)
$sDelimiter | [optional] One or multiple characters to be used as delimiter (default = ",")
$aFieldInfo | [optional] An array containing parse information for individual columns of data. The interpretation depends on the value of DataType. When the data is delimited, this argument is an array of two-element arrays, with each two-element array specifying the conversion options for a particular column. The first element is the column number (1-based), and the second element is one of the XlColumnDataType constants specifying how the column is parsed (default = keyword Default)
$sDecimalSeparator | [optional] Decimal separator that Excel uses when recognizing numbers. Default setting is the system setting (default = keyword Default)
$sThousandsSeparator | [optional] Thousands separator that Excel uses when recognizing numbers. Default setting is the system setting (default = keyword Default)
$bTrailingMinusNumbers | [optional] True treats numbers with a minus character at the end as negative numbers. False treats such numbers as text (default = True)
$iOrigin | [optional] Origin of the text file. Can be one of the XlPlatform constants. Additionally, this could be an integer representing the code page number of the desired code page. For example, "1256" would specify that the encoding is Arabic (Windows). If this argument is omitted, the method uses the current setting of the File Origin option in the Text Import Wizard.

Return Value

Success: | an workbook object.
Failure: | 0 and sets @error.
@error: | 1: $oExcel is not an object or not an application object 2: Specified $sFilePatch does not exist 3: Unable to open or parse $sFilePath. @extended is set to the COM error code returned by the OpenText method

Remarks

Parameter $aFieldInfo has to be an array containing arrays, not a 2D array. Please see example 2.

Related

_Excel_BookAttach, _Excel_BookClose, _Excel_BookNew, _Excel_BookOpen

Example

Example 1

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox(16, "Excel UDF: _Excel_BookOpenText Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Open a text file as delimited, separator = |, pass fieldinfo and set
; DecimalSeparator and ThousandsSeparator.
; *****************************************************************************
Local $sTextFile = @ScriptDir & "\Extras\_Excel1.txt"
Local $aField1[2] = [1, $xlTextFormat]
Local $aField2[2] = [2, $xlTextFormat]
Local $aField3[2] = [3, $xlGeneralFormat]
Local $aField4[2] = [4, $xlDMYFormat]
Local $aField5[2] = [5, $xlTextFormat]
Local $aFieldInfo[5] = [$aField1, $aField2, $aField3, $aField4, $aField5]
_Excel_BookOpenText($oExcel, $sTextFile, Default, $xlDelimited, Default, True, "|", $aFieldInfo, ",", ".")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpenText Example 1", "Error opening '" & $sTextFile & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpenText Example 1", "Workbook '" & $sTextFile & "' has been opened successfully.")

Example 2

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox(16, "Excel UDF: _Excel_BookOpenText Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Open a text file as fixed, all other parameters will be determined by Excel
; *****************************************************************************
Local $sTextFile = @ScriptDir & "\Extras\_Excel2.txt"
_Excel_BookOpenText($oExcel, $sTextFile, Default, $xlFixedWidth)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpenText Example 2", "Error opening '" & $sTextFile & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpenText Example 2", "Workbook '" & $sTextFile & "' has been opened successfully.")


Function _Excel_BookSave

Function Reference

_Excel_BookSave

Saves the specified workbook

#include <Excel.au3>
_Excel_BookSave ( $oWorkbook )

Parameters

$oWorkbook Object of the workbook to save

Return Value

Success: | 1. Sets @extended to: 0 - File has not been saved because it has not been changed since the last save or file open 1 - File has been saved because it has been changed since the last save or file open
Failure: | 0 and sets @error.
@error: | 1 - $oWorkbook is not an object or not a workbook object 2 - Error occurred when saving the workbook. @extended is set to the COM error code

Remarks

A newly created workbook has to be saved using _Excel_BookSaveAs() before.

Related

_Excel_BookSaveAs

Example

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox(16, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Create a new workbook, write some data and save it to @tempdir
; *****************************************************************************
; Create the new workbook
Local $oWorkbook = _Excel_BookNew($oExcel)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSave Example 1", "Error creating new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Write something into cell A1
_Excel_RangeWrite($oWorkbook, Default, "Test", "A1")
If Not IsObj($oWorkbook) Or ObjName($oWorkbook, 1) <> "_Workbook" Then Exit SetError(1, 0, 0)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSave Example 1", "Error writing to cell 'A1'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Save the workbook to @tempdir as _Excel.xls (replacing existing file)
_Excel_BookSaveAs($oWorkbook, @TempDir & "\_Excel.xls", Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSave Example 1", "Error saving workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Write something into cell B1
_Excel_RangeWrite($oWorkbook, Default, "2nd Test", "B1")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSave Example 1", "Error writing to cell 'A1'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Save changed workbook
_Excel_BookSave($oWorkbook)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSave Example 1", "Error saving workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSave Example 1", "Workbook has been successfully saved as '" & @TempDir & "\_Excel.xls'.")


Function _Excel_BookSaveAs

Function Reference

_Excel_BookSaveAs

Saves the specified workbook with a new filename and/or type

#include <Excel.au3>
_Excel_BookSaveAs ( $oWorkbook, $sFilePath [, $iFormat = $xlWorkbookDefault [, $bOverWrite = False [, $sPassword = Default [, $sWritePassword = Default [, $bReadOnlyRecommended = False]]]]] )

Parameters

$oWorkbook | Workbook object to be saved
$sFilePath | Path and filename of the file to be read
$iFormat | [optional] Excel writeable filetype. Can be any value of the XlFileFormat enumeration.
$bOverWrite | [optional] True overwrites an already existing file (default = False)
$sPassword | [optional] The string password to protect the sheet with. If set to keyword Default no password will be used (default = keyword Default)
$sWritePassword | [optional] The string write-access password to protect the sheet with. If set to keyword Default no password will be used (default = keyword Default)
$bReadOnlyRecommended | [optional] True displays a message when the file is opened, recommending that the file be opened as read-only (default = False)

Return Value

Success: | 1.
Failure: | 0 and sets @error.
@error: | 1 - $oWorkbook is not an object 2 - $iFormat is not a number 3 - File exists, overwrite flag not set 4 - File exists but could not be deleted 5 - Error occurred when saving the workbook. @extended is set to the COM error code returned by the SaveAs method.

Remarks

Starting with Excel 2007 you have to provide both the $iFormat parameter and the correct file extension in $sFilePath.
E.g. $iFormat = $xlExcel8 and extension = "xlsx" will return an error.
Please see the XlFileFormat enumeration in ExcelConstants.au3 for possible values.

Related

_Excel_BookSave

Example

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSaveAs Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSaveAs Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Save the workbook (xls) in another format (html) to another directory and
; overwrite an existing version
; *****************************************************************************
Local $sWorkbook = @TempDir & "\_Excel1.html"
_Excel_BookSaveAs($oWorkbook, $sWorkbook, $xlHtml, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSaveAs Example 1", "Error saving workbook to '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSaveAs Example 1", "Workbook successfully saved as '" & $sWorkbook & "'.")
ShellExecute($sWorkbook)


Function _Excel_Close

Function Reference

_Excel_Close

Closes all worksheets and the instance of the Excel application

#include <Excel.au3>
_Excel_Close ( $oExcel [, $bSaveChanges = True [, $bForceClose = False]] )

Parameters

$oExcel | Excel application object as returned by _Excel_Open()
$bSaveChanges | [optional] Specifies whether changed worksheets should be saved before closing (default = True)
$bForceClose | [optional] If True the Excel application is closed even when it was not started by _Excel_Open() (default = False)

Return Value

Success: | 1.
Failure: | 0 and sets @error.
@error: | 1 - $oExcel is not an object or not an application object 2 - Error returned by method Application.Quit. @extended is set to the COM error code 3 - Error returned by method Application.Save. @extended is set to the COM error code

Remarks

If Excel was started by _Excel_Open() then _Excel_Close() closes all workbooks
(even those opened manually by the user for this instance after _Excel_Open()) and closes the specified Excel instance.
If _Excel_Open() connected to an already running instance of Excel then you have to set $bForceClose to True to do the same.

Related

_Excel_Open

Example

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object
Local $oExcel1 = ObjCreate("Excel.Application")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example", "Error creating the first Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; Open Excel application (force new instance)
Local $oExcel2 = _Excel_Open(Default, Default, Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example", "Error creating the second Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Close the Excel instance which was not opened by _Excel_Open
; (will still be running because it was not opened by _Excel_Open)
; *****************************************************************************
_Excel_Close($oExcel1)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example 1", "Error closing the Excel application." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Sleep(2000)
Local $aProcesses = ProcessList("Excel.exe")
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example 1", "Function ended successfully." & @CRLF & @CRLF & $aProcesses[0][0] & " Excel instance(s) still running.")

; *****************************************************************************
; Close the Excel instance opened by _Excel_Open
; *****************************************************************************
_Excel_Close($oExcel2)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example 2", "Error closing the Excel application." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Sleep(2000)
$aProcesses = ProcessList("Excel.exe")
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example 2", "Function ended successfully." & @CRLF & @CRLF & $aProcesses[0][0] & " Excel instance(s) still running.")

; *****************************************************************************
; Force the Excel instance not opened by _Excel_Open
; without saving open workbooks
; *****************************************************************************
_Excel_Close($oExcel1, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example 3", "Error closing the Excel application." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Sleep(2000)
$aProcesses = ProcessList("Excel.exe")
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example 3", "Function ended successfully." & @CRLF & @CRLF & $aProcesses[0][0] & " Excel instance(s) still running.")


Function _Excel_ColumnToLetter

Function Reference

_Excel_ColumnToLetter

Converts the column number to letter(s)

#include <Excel.au3>
_Excel_ColumnToLetter ( $iColumn )

Parameters

$iColumn The column number which you want to turn into letter(s)

Return Value

Success: | the column letter(s).
Failure: | "" and sets @error.
@error: | 1 - $iColumn is not a number

Related

_Excel_ColumnToNumber

Example

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; ****************************************************************************
; Translate an Excel column letter to the colunm number
; ****************************************************************************
Local $sCol = "YZ"
Local $iNumber = _Excel_ColumnToNumber($sCol)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_ColumnToNumber Example 1", "Error converting letter to number." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_ColumnToNumber Example 1", "Letter: " & $sCol & " = Number: " & $iNumber)


Function _Excel_ColumnToNumber

Function Reference

_Excel_ColumnToNumber

Converts the column letter(s) to a number

#include <Excel.au3>
_Excel_ColumnToNumber ( $sColumn )

Parameters

$sColumn The column letter(s) which you want to turn into a number (e.g. "ZZ" to 702)

Return Value

Success: | the column number.
Failure: | 0 and sets @error.
@error: | 1 - $sColumn is not a valid string

Related

_Excel_ColumnToLetter

Example

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; ****************************************************************************
; Translate a column number to the Excel colunm letter
; ****************************************************************************
Local $iCol = 676
Local $sLetter = _Excel_ColumnToLetter($iCol)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_ColumnToLetter Example 1", "Error converting number to letter." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_ColumnToLetter Example 1", "Number: " & $iCol & " = Letter: " & $sLetter)


Function _Excel_ConvertFormula

Function Reference

_Excel_ConvertFormula

Converts cell references in a formula between A1 and R1C1 reference styles, relative and absolute reference type, or both

#include <Excel.au3>
_Excel_ConvertFormula ( $oExcel, $sFormula, $iFromStyle [, $iToStyle = Default [, $iToAbsolute = Default [, $vRelativeTo = Default]]] )

Parameters

$oExcel | Excel application object
$sFormula | String containing the formula to convert
$iFromStyle | The reference style of the formula. Can be any of the XlReferenceStyle enumeration
$iToStyle | [optional] A XlReferenceStyle enumeration specifying the reference style to be returned. If omitted, the reference style isn't changed
$iToAbsolute | [optional] A XlReferenceType which specifies the converted reference type. If this argument is omitted, the reference type isn't changed
$vRelativeTo | [optional] A Range object or a A1 range that contains one cell. Relative references relate to this cell. If omitted A1 is used

Return Value

Success: | the converted formula as a string.
Failure: | "" and sets @error.
@error: | 1 - $oExcel is not an object or not an application object 2 - $vRelativeTo is not an object or a valid A1 range

Remarks

R1C1 references are language dependant.
In English: "R10C5" (row 10 column 5), in German: "Z10S5" (Zeile 10 Spalte 5)

Example

Example 1

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an new workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_ConvertFormula Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookNew($oExcel)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_ConvertFormula Example", "Error creating new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; ****************************************************************************
; Translate an A1 range to a R1C1 range and vice versa
; ****************************************************************************
Local $sFormula = "C4:G12"
; Relative: A1 to R1C1
Local $sR1C1 = _Excel_ConvertFormula($oExcel, $sFormula, $xlA1, $xlR1C1, $xlRelative)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_ConvertFormula Example 1", "Error converting formula to R1C1 style." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; R1C1 to A1
Local $sA1 = _Excel_ConvertFormula($oExcel, $sR1C1, $xlR1C1, $xlA1, $xlRelative)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_ConvertFormula Example 1", "Error converting formula to A1 style." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Show result
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_ConvertFormula Example 1", "Conversion type: Relative" & @CRLF & "  A1 to a R1C1 style: " & $sFormula & " to " & $sR1C1 & @CRLF & "  R1C1 to A1 style: " & $sR1C1 & " to " & $sA1)

; Absolute: A1 to R1C1
$sR1C1 = _Excel_ConvertFormula($oExcel, $sFormula, $xlA1, $xlR1C1, $xlAbsolute)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_ConvertFormula Example 1", "Error converting formula to R1C1 style." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; R1C1 to A1
$sA1 = _Excel_ConvertFormula($oExcel, $sR1C1, $xlR1C1, $xlA1, $xlAbsolute)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_ConvertFormula Example 1", "Error converting formula to A1 style." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Show result
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_ConvertFormula Example 1", "Conversion type: Absolute" & @CRLF & "  A1 to a R1C1 style: " & $sFormula & " to " & $sR1C1 & @CRLF & "  R1C1 to A1 style: " & $sR1C1 & " to " & $sA1)

Example 2

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an new workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_ConvertFormula Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookNew($oExcel)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_ConvertFormula Example", "Error creating new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Translate an formula from A1 to R1C1 style and use a relative reference
; *****************************************************************************
Local $sFormula = "=SUM(C4:G12)", $sReference = "B2"
Local $sConverted = _Excel_ConvertFormula($oExcel, $sFormula, $xlA1, $xlR1C1, $xlRelative, $oExcel.Range($sReference))
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_ConvertFormula Example 2", "Error converting formula." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_ConvertFormula Example 2", "Translate an A1 formula to a R1C1 and use " & $sReference & " as relative reference:" & @CRLF & $sFormula & " to " & $sConverted)


Function _Excel_Export

Function Reference

_Excel_Export

Exports a workbook, worksheet, chart or range as PDF or XPS

#include <Excel.au3>
_Excel_Export ( $oExcel, $vObject, $sFileName [, $iType = $xlTypePDF [, $iQuality = $xlQualityStandard [, $bIncludeProperties = True [, $iFrom = Default [, $iTo = Default [, $bOpenAfterPublish = Default]]]]]] )

Parameters

$oExcel | Excel application object
$vObject | Workbook, worksheet, chart or range object to export as PDF or XPS. Range can be specified as A1 range too
$sFileName | Path/name of the exported file
$iType | [optional] Can be either $xlTypePDF or $xlTypeXPS of the XlFixedFormatType enumeration (default = $xlTypePDF)
$iQuality | [optional] Can be any of the XlFixedFormatQuality enumeration (default = $xlQualityStandard)
$bIncludeProperties | [optional] True indicates that document properties should be included (default = True)
$iFrom | [optional] The page number at which to start publishing (default = keyword Default = start at the beginning)
$iTo | [optional] The page number at which to end publishing (default = keyword Default = end at the last page)
$bOpenAfterPublish | [optional] True displays the file in viewer after it is published (default = False)

Return Value

Success: | the object of the exported range.
Failure: | 0 and sets @error.
@error: | 1 - $oExcel is not an object or not an application object 2 - $vObject is not an object or an invalid A1 range. @error is set to the COM error code 3 - $sFileName is empty 4 - Error exporting the object. @extended is set to the COM error code returned by the ExportAsFixedFormat method

Related

_Excel_Print

Example

Example 1

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Export Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls", True)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Export Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Export cells A1:E10 of the active worksheet as PDF and display the file.
; *****************************************************************************
Local $sOutput = @TempDir & "\_Excel1_1.pdf"
_Excel_Export($oExcel, "A1:E10", $sOutput, Default, Default, Default, Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Export Example 1", "Error saving range to '" & $sOutput & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Export Example 1", "Range successfully exported as '" & $sOutput & "'.")

Example 2

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Export Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls", True)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Export Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Export the whole workbook as PDF.
; *****************************************************************************
Local $sOutput = @TempDir & "\_Excel1_2.pdf"
_Excel_Export($oExcel, $oWorkbook, $sOutput)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Export Example 2", "Error saving the workbook to '" & $sOutput & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Export Example 2", "The whole workbook was successfully exported as '" & $sOutput & "'.")


Function _Excel_FilterGet

Function Reference

_Excel_FilterGet

Returns a list of set filters

#include <Excel.au3>
_Excel_FilterGet ( $oWorkbook [, $vWorksheet = Default] )

Parameters

$oWorkbook | Excel workbook object
$vWorksheet | [optional] Name, index or worksheet object to be filtered. If set to keyword Default the active sheet will be filtered

Return Value

Success: | a two-dimensional zero based array with the following information: 0 - On if a filter is set for this column 1 - Number of areas (collection of ranges) the filtered column consists of 2 - Filter criteria 1. An array of strings is returned as a string separated by "|" 3 - Filter criteria 2. An array of strings is returned as a string separated by "|" 4 - An XlAutoFilterOperator value that represents the operator that associates the two filter criterias 5 - Range object for which the filters have been set 6 - Number of visible records in the filtered range (including the row with the filter arrow)
Failure: | 0 and sets @error.
@error: | 1 - $oWorkbook is not an object or not a workbook object 2 - $vWorksheet name or index are invalid or $vWorksheet is not a worksheet object. @extended is set to the COM error code 3 - No filters found

Related

_Excel_FilterSet

Example

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterGet Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls", True)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterGet Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; Set two filters
_Excel_FilterSet($oWorkbook, Default, "A:E", 3, "<610")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterGet Example", "Error filtering data." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $aShow[] = ["20", "40", "60"]
_Excel_FilterSet($oWorkbook, Default, "A:E", 2, $aShow, $xlFilterValues)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterGet Example", "Error filtering data." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterGet Example", "Filters set:" & @CRLF & "  Column B: values = 20, 40 or 60." & @CRLF & "  Column C: values <610.")

; *****************************************************************************
; Display information about the filters on the active worksheet.
; *****************************************************************************
Local $aFilters = _Excel_FilterGet($oWorkbook)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterGet Example 1", "Error filtering data." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
_ArrayDisplay($aFilters, "Excel UDF: _Excel_FilterGet Example 1", Default, Default, Default, "Filter on|#areas|Criteria1|Criteria2|Operator|Range|#Records")


Function _Excel_FilterSet

Function Reference

_Excel_FilterSet

Sets/unsets filter definitions and filters the range

#include <Excel.au3>
_Excel_FilterSet ( $oWorkbook, $vWorksheet, $vRange, $iField [, $sCriteria1 = Default [, $iOperator = Default [, $sCriteria2 = Default]]] )

Parameters

$oWorkbook | Excel workbook object
$vWorksheet | Name, index or worksheet object to be filtered. If set to keyword Default the active sheet will be filtered
$vRange | A range object or an A1 range to specify the columns to filter on. Use keyword Default to filter on all used columns of the specified worksheet
$iField | Integer offset of the field on which you want to base the filter (the leftmost field is field one). If set to 0 all Autofilters on the worksheet will be removed
$sCriteria1 | [optional] The criteria (a string or an array of strings). Use "=" to find blank fields, or use "<>" to find nonblank fields. If this argument is omitted, the criteria is All. If Operator is xlTop10Items, Criteria1 specifies the number of items (for example, "10")
$iOperator | [optional] One of the constants of the XlAutoFilterOperator enumeration specifying the type of filter
$sCriteria2 | [optional] The second criteria (a string). Used with Criteria1 and Operator to construct compound criteria

Return Value

Success: | 1.
Failure: | 0 and sets @error.
@error: | 1 - $oWorkbook is not an object or not a workbook object 2 - $vWorksheet name or index are invalid or $vWorksheet is not a worksheet object. @extended is set to the COM error code 3 - $vRange is invalid. @extended is set to the COM error code 4 - Error returned by the Filter method. @extended is set to the COM error code

Remarks

Dynamic filter:
To filter data columns you set $iOperator to $xlFilterDynamic and $sCriteria1 to any of the XlDynamicFilterCriteria enumeration.
See example 5 for details.

Related

_Excel_FilterGet

Example

Example 1

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls", True)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example", "Press Enter to set the first filter!")

; *****************************************************************************
; Filter the complete active worksheet on column 1.
; Only show rows with content >20 and <40 in the specified column.
; *****************************************************************************
_Excel_FilterSet($oWorkbook, Default, "A1:E30", 1, ">20", 1, "<40")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example 1", "Error filtering data." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example 1", "Filtered on column 'A'. Only show rows with values >20 and <40.")

; *****************************************************************************
; Add a filter to column 2.
; Only show rows with content <310 in the specified column.
; *****************************************************************************
_Excel_FilterSet($oWorkbook, Default, Default, 2, "<310")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example 2", "Error filtering data." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example 1", "Added filter on column 'B'. Only show rows with values <310.")

; *****************************************************************************
; Remove the filter from column 1.
; *****************************************************************************
_Excel_FilterSet($oWorkbook, Default, Default, 1)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example 3", "Error filtering data." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example 1", "Removed filter from column 'A'.")

; *****************************************************************************
; Only display selected values (20, 40 and 60) of column 2.
; *****************************************************************************
Local $aShow[] = ["20", "40", "60"]
_Excel_FilterSet($oWorkbook, Default, Default, 2, $aShow, $xlFilterValues)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example 4", "Error filtering data." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example 1", "Set filter in column 'B' to only display selected values (20, 40 and 60).")

; *****************************************************************************
; Remove all filters.
; *****************************************************************************
_Excel_FilterSet($oWorkbook, Default, Default, 0)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example 5", "Error filtering data." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example 1", "All filters removed.")

Example 2

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls", True)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example", "Press Enter to set the first filter!")

; *****************************************************************************
; Filter Column M by date. Show all dates in october of 2013 and 2014.
; 0-year, 1-month, 2-day, 3-hour, 4-minute, 5-second
; *****************************************************************************
Local $aShow[] = [1, "01/10/2013", 1, "01/10/2014"]
_Excel_FilterSet($oWorkbook, Default, Default, 13, Default, $xlFilterValues, $aShow)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example 6", "Error filtering data." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example 2", "Column 'M' filtered by date. Show all dates in October of 2013 and 2014.")

; *****************************************************************************
; Filter Column M by date. Show all dates of last year.
; *****************************************************************************
_Excel_FilterSet($oWorkbook, Default, Default, 13, $xlFilterLastYear, $xlFilterDynamic)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example 7", "Error filtering data." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_FilterSet Example 2", "Column 'M' filtered by date. Show all dates of last year.")


Function _Excel_Open

Function Reference

_Excel_Open

Connects to an existing Excel instance or creates a new one

#include <Excel.au3>
_Excel_Open ( [$bVisible = True [, $bDisplayAlerts = False [, $bScreenUpdating = True [, $bInteractive = True [, $bForceNew = False]]]]] )

Parameters

$bVisible | [optional] True specifies that the application will be visible (default = True)
$bDisplayAlerts | [optional] False suppresses all prompts and alert messages while opening a workbook (default = False)
$bScreenUpdating | [optional] False suppresses screen updating to speed up your script (default = True)
$bInteractive | [optional] If False, Excel blocks all keyboard and mouse input by the user (except input to dialog boxes) (default = True)
$bForceNew | [optional] True forces to create a new Excel instance even if there is already a running instance (default = False)

Return Value

Success: | the Excel application object. Sets @extended to: 0 - Excel was already running 1 - Excel was not running or $bForceNew was set to True. A new Excel instance has been created
Failure: | 0 and sets @error.
@error: | 1 - Error returned by ObjCreate. @extended is set to the COM error code.

Remarks

If $bDisplayAlerts is set to False and a message requires a response, Excel chooses the default response.

To enhance performance set $bScreenUpdating to False. The screen will not be updated until you set it back to true ($oExcel.ScreenUpdating = True).

Blocking user input ($obInteractive = False) will prevent the user from interfering with the AutoIt script.
If set to False, don't forget to set it back to True ($oExcel.Interactive = True)

Related

_Excel_Close

Example

Example 1

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; *****************************************************************************
; Create application object or connect to an already running Excel instance
; *****************************************************************************
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Open Example 1", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Open Example 1", "Excel Application has been opened successfully." & @CRLF & @CRLF & "Will _Excel_Close close the application?: " & @extended)

Example 2

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; *****************************************************************************
; Force the creation of a new Excel application and display alerts
; *****************************************************************************
_Excel_Open(Default, Default, Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Open Example 2", "Error creating a new Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $aProcesses = ProcessList("Excel.exe")
If $aProcesses[0][0] = 1 Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Open Example 2", "Excel Application has been opened successfully." & @CRLF & @CRLF & $aProcesses[0][0] & " Excel instance is running.")
Else
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Open Example 2", "Excel Application has been opened successfully." & @CRLF & @CRLF & $aProcesses[0][0] & " Excel instances are running.")
EndIf


Function _Excel_PictureAdd

Function Reference

_Excel_PictureAdd

Adds a picture on the specified workbook and worksheet

#include <Excel.au3>
_Excel_PictureAdd ( $oWorkbook, $vWorksheet, $sFile, $vRangeOrLeft [, $iTop = Default [, $iWidth = Default [, $iHeight = Default [, $bKeepRatio = True]]]] )

Parameters

$oWorkbook | Excel workbook object
$vWorksheet | Name, index or worksheet object to be written to. If set to keyword Default the active sheet will be used
$sFile | Full path to picture file being added
$vRangeOrLeft | Either an A1 range, a range object or an integer denoting the left position of the pictures upper left corner
$iTop | [optional] If $vRangeOrLeft is an integer then $iTop is the top position of the pictures upper left corner.
$iWidth | [optional] If specified, sets the width of the picture. If not specified, width will adjust automatically (default = Automatic)
$iHeight | [optional] If specified, sets the height of the picture. If not specified, height will adjust automatically (default = Automatic)
$bKeepRatio | [optional] Only used if $vRangeOrLeft is a multi-cell range (default = True) True will maintain image aspect ratio while staying within the bounds of $vRangeOrLeft. False will fill the $vRangeOrLeft regardless of original aspect ratio.

Return Value

Success: | a Shape object that represents the new picture.
Failure: | 0 and sets @error.
@error: | 1 - $oWorkbook is not an object or not a workbook object 2 - $vWorksheet name or index are invalid or $vWorksheet is not a worksheet object. @extended is set to the COM error code 3 - $vRangeOrLeft is invalid. @extended is set to the COM error code 4 - Error occurred when adding picture. @extended is set to the COM error code 5 - $sFile does not exist

Remarks

If $vRangeOrLeft is a multi cell range $iWidth and $iHeight will be ignored (to specify width/height not based on range width/height, specify a single cell $vRangeOrLeft).

If only one of $iWidth and $iHeight is specified, the other (set to default) will be scaled to maintain the original aspect ratio of the picture.
If both $iWidth and $iHeight are specified, the picture will use the specified values regardless of original aspect ratio of the picture.
If neither $iWidth nor $iHeight are specified, the picture will be auto sized to the size of the original picture.

$bKeepRatio will be ignored unless a multi cell range is specified (see Parameters for details).

Example

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_PictureAdd Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Create new Workbook
Local $oWorkbook = _Excel_BookNew($oExcel)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_PictureAdd Example", "Error creating workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Insert and resize the picture into a range of cells. Aspect ratio retained
; *****************************************************************************
Local $sPicture = @ScriptDir & "\Extras\_Excel.jpg"
_Excel_PictureAdd($oWorkbook, Default, $sPicture, "B2:D8")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_PictureAdd Example 1", "Error inserting picture." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_PictureAdd Example 1", "Picture inserted/resized at 'B2:D8', aspect ratio retained.")

; *****************************************************************************
; Insert the picture without resizing.
; *****************************************************************************
_Excel_PictureAdd($oWorkbook, Default, $sPicture, "F8")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_PictureAdd Example 2", "Error inserting picture." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_PictureAdd Example 2", "Picture inserted at 'F8' without resizing.")

; *****************************************************************************
; Insert the picture with a defined size/height.
; *****************************************************************************
_Excel_PictureAdd($oWorkbook, Default, $sPicture, "A8", Default, 300, 250)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_PictureAdd Example 3", "Error inserting picture." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_PictureAdd Example 3", "Picture inserted at 'A8' with defined size/height, aspect ratio ignored")

; *****************************************************************************
; Insert the picture with a defined size/height.
; *****************************************************************************
_Excel_PictureAdd($oWorkbook, Default, $sPicture, 250, 300, 300, 250)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_PictureAdd Example 4", "Error inserting picture." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_PictureAdd Example 4", "Picture inserted at position 250/300' with defined size/height, aspect ratio ignored")

; *****************************************************************************
; Insert the picture with a defined size/height.
; *****************************************************************************
_Excel_PictureAdd($oWorkbook, Default, $sPicture, "F2:H9", Default, Default, Default, False)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_PictureAdd Example 5", "Error inserting picture." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_PictureAdd Example 5", "Picture inserted/resized at 'F2:H9', aspect ratio ignored.")


Function _Excel_Print

Function Reference

_Excel_Print

Prints a workbook, worksheet, chart or range

#include <Excel.au3>
_Excel_Print ( $oExcel, $vObject [, $iCopies = Default [, $sPrinter = Default [, $bPreview = Default [, $iFrom = Default [, $iTo = Default [, $bPrintToFile = Default [, $bCollate = Default [, $sPrToFileName = ""]]]]]]]] )

Parameters

$oExcel | Excel application object
$vObject | Workbook, worksheet, chart or range object to print. Range can be specified as A1 range too
$iCopies | [optional] Number of copies to print (default = keyword Default = 1)
$sPrinter | [optional] Name of the printer to be used. Defaults to active printer (default = keyword Default)
$bPreview | [optional] True to invoke print preview before printing (default = keyword Default = False)
$iFrom | [optional] Page number where to start printing (default = keyword Default = first page)
$iTo | [optional] Page number where to stop printing (default = keyword Default = last page)
$bPrintToFile | [optional] True to print to a file. See parameter $sPrToFileName (default = keyword Default = False)
$bCollate | [optional] True to collate multiple copies (default = keyword Default = False)
$sPrToFileName | [optional] If $bPrintToFile is set to True, this argument specifies the name of the file you want to print to.

Return Value

Success: | the object of the printed range.
Failure: | 0 and sets @error.
@error: | 1 - $oExcel is not an object or not an application object 2 - $vObject is not an object or an invalid A1 range. @error is set to the COM error code 3 - Error printing the object. @extended is set to the COM error code

Related

_Excel_Export

Example

Example 1

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Print Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel4.xls", True)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Print Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel4.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Print range A1:B3 of the active worksheet to the default printer.
; *****************************************************************************
_Excel_Print($oExcel, "A1:B3")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Print Example 1", "Error printing cells." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Print Example 1", "Range successfully printed.")

Example 2

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Print Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel4.xls", True)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Print Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel4.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Print the active worksheet to the default printer.
; *****************************************************************************
_Excel_Print($oExcel, $oExcel.ActiveSheet)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Print Example 2", "Error printing worksheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Print Example 2", "Active Worksheet successfully printed.")

Example 3

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Print Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel4.xls", True)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Print Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel4.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Print a complete workbook to the default printer.
; *****************************************************************************
_Excel_Print($oExcel, $oWorkbook)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Print Example 3", "Error printing workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Print Example 3", "Workbook successfully printed.")


Function _Excel_RangeCopyPaste

Function Reference

_Excel_RangeCopyPaste

Cuts or copies one or multiple cells, rows or columns to a range or from/to the clipboard

#include <Excel.au3>
_Excel_RangeCopyPaste ( $oWorksheet, $vSourceRange [, $vTargetRange = Default [, $bCut = False [, $iPaste = Default [, $iOperation = Default [, $bSkipBlanks = False [, $bTranspose = False]]]]]] )

Parameters

$oWorksheet | Object of the source worksheet
$vSourceRange | Source range to copy/cut from. Can be a range object or an A1 range. If set to keyword Default then the range will be copied from the clipboard.
$vTargetRange | [optional] Target range to copy/cut to. Can be a range object or an A1 range. If set to keyword Default then the range will be copied to the clipboard (default = keyword Default)
$bCut | [optional] If set to True the source range isn't copied but cut out (default = False) This parameter is ignored when $vSourceRange is set to keyword Default.
$iPaste | [optional] The part of the range to be pasted from the clipboard (formulas, formats ...). Must be a value of the XlPasteType enumeration (default = keyword Default)
$iOperation | [optional] The paste operation (add, divide, multiply ...). Must be a value of the XlPasteSpecialOperation enunmeration (default = keyword Default)
$bSkipBlanks | [optional] If set to True blank cells from the clipboard will not be pasted into the target range (default = False)
$bTranspose | [optional] Set to True to transpose rows and columns when the range is pasted (default = False)

Return Value

Success: | the object of the target range if $vTargetRange <> Default, else 1.
Failure: | 0 and sets @error.
@error: | 1 - $oWorksheet is not an object or not a worksheet object 2 - $vSourceRange is invalid. @extended is set to the COM error code 3 - $vTargetRange is invalid. @extended is set to the COM error code 4 - Error occurred when pasting cells. @extended is set to the COM error code 5 - Error occurred when cutting cells. @extended is set to the COM error code 6 - Error occurred when copying cells. @extended is set to the COM error code 7 - $vSourceRange and $vTargetRange can't be set to keyword Default at the same time

Remarks

$vSourceRange and $vTargetRange can't be set to keyword Default at the same time.
If $vSourceRange = Default then:
* the range will be copied from the clipboard using the PasteSpecial method
* $bCut will be ignored
* $iPaste, $iOperation, $bSkipBlanks and $bTranspose will be honored
If $vSourceRange and $vTargetRange are specified parameters $iPaste, $iOperation, $bSkipBlanks and $bTranspose are ignored

Example

Example 1

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open Workbook 1
Local $oWorkbook1 = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls", True)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Copy a range with 3 rows and 2 columns on the active worksheet.
; Pass the source range as object.
; *****************************************************************************
Local $oRange = $oWorkbook1.ActiveSheet.Range("I2:J4")
_Excel_RangeCopyPaste($oWorkbook1.ActiveSheet, $oRange, "G7")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example 1", "Error copying cells." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example 1", "Range 'I2:J4' successfully copied to 'G7'.")

Example 2

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open Workbook 2
Local $oWorkbook2 = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel3.xls", True)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel3.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf
; Open Workbook 1
Local $oWorkbook1 = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls", True)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Copy a single cell from another workbook. Pass the source range as object.
; *****************************************************************************
Local $oRange = $oWorkbook2.Worksheets(1).Range("A1")
_Excel_RangeCopyPaste($oWorkbook1.Worksheets(1), $oRange, "G15")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example 2", "Error copying cells." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example 2", "Range 'A1' from workbook _Excel3.xls successfully copied to 'G15'.")

Example 3

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open Workbook 1
Local $oWorkbook1 = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Copy 2 rows (1 and 2) from worksheet 2 to the clipboard
; *****************************************************************************
_Excel_RangeCopyPaste($oWorkbook1.Worksheets(2), "1:2")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example 3", "Error copying rows." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example 3", "Rows 1+2 successfully copied from worksheet 2 to the clipboard.")

; *****************************************************************************
; Paste the range written by Example 3 from the clipboard to the active worksheet.
; Only values without formatting will be pasted.
; *****************************************************************************
_Excel_RangeCopyPaste($oWorkbook1.Activesheet, Default, "1:1", Default, $xlPasteValues)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example 4", "Error copying rows." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example 4", "2 Rows successfully pasted from the clipboard to row 1.")

Example 4

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open Workbook 1
Local $oWorkbook1 = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls", True)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Paste the format of a cell to other cells
; *****************************************************************************
_Excel_RangeCopyPaste($oWorkbook1.Activesheet, "A1") ; Copy the cell to the clipboards
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example5", "Error copying rcell A1." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
_Excel_RangeCopyPaste($oWorkbook1.Activesheet, Default, "B1:E16", Default, $xlPasteFormats) ; paste the format to the target range
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example5", "Error pasting cells." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example 5", "Format of cell 'A1' successfully pasted to 'B1:E16'.")


Function _Excel_RangeDelete

Function Reference

_Excel_RangeDelete

Deletes one or multiple cells, rows or columns from the specified worksheet

#include <Excel.au3>
_Excel_RangeDelete ( $oWorksheet, $vRange [, $iShift = Default [, $iEntireRowCol = Default]] )

Parameters

$oWorksheet | Excel worksheet object
$vRange | Range can be a range object, an A1 range (e.g. "A1:B2", "1:2" (row 1 to 2), "D:G" (columns D to G) etc.
$iShift | [optional] Specifies which way to shift the cells. Can be xlShiftToLeft or xlShiftUp of the XlDeleteShiftDirection enumeration. If set to keyword Default, Excel decides based on the shape of the range (default = keyword Default)
$iEntireRowCol | [optional] If set to 1 the entire row is deleted, if set to 2 the entire column is deleted (default = keyword Default = only delete specified range)

Return Value

Success: | 1.
Failure: | 0 and sets @error.
@error: | 1 - $oWorksheet is not an object or not an worksheet object 2 - $vRange is not a valid range. @extended is set to the COM error code 3 - Error occurred when deleting the range. @extended is set to the COM error code

Example

Example 1

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeDelete Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeDelete Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Delete a range with 3 rows and 2 columns on the active worksheet
; and shift the cells up.
; *****************************************************************************
Local $sRange = "J5:K7"
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeDelete Example 1", "Deleting cells " & $sRange & ".")
_Excel_RangeDelete($oWorkbook.ActiveSheet, $sRange, $xlShiftUp)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeDelete Example 1", "Error deleting cells." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

Example 2

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeDelete Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeDelete Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Delete 2 rows (1 and 2) on worksheet 3
; *****************************************************************************
$oWorkbook.Worksheets(3).Activate
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeDelete Example 2", "Deleting rows 1 and 2 on worksheet 3.")
_Excel_RangeDelete($oWorkbook.Worksheets(3), "1:2")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeDelete Example 2", "Error deleting rows." & @CRLF & "@error = " & @error & ", @extended = " & @extended)


Function _Excel_RangeFind

Function Reference

_Excel_RangeFind

Finds matching cells in a range or workbook and returns an array with information about the found cells

#include <Excel.au3>
_Excel_RangeFind ( $oWorkbook, $sSearch [, $vRange = Default [, $iLookIn = $xlValues [, $iLookAt = $xlPart [, $bMatchcase = False]]]] )

Parameters

$oWorkbook | Workbook object
$sSearch | Search string. Can be a string (wildcards - *?~ - can be used) or any Excel data type. See Remarks
$vRange | [optional] A range object, an A1 range (string) or keyword Default to search all sheets of the workbook (default = keyword Default)
$iLookIn | [optional] Specifies where to search. Can be any of the XLFindLookIn enumeration (default = $xlValues)
$iLookAt | [optional] Specifies whether the search text must match as a whole or any part. Can be any of the XLLookAt enumeration (default = $xlPart)
$bMatchcase | [optional] True = case sensitive, False = case insensitive (default = False)

Return Value

Success: | a two-dimensional zero based array with the following information: 0 - Name of the worksheet 1 - Name of the cell 2 - Address of the cell 3 - Value of the cell 4 - Formula of the cell 5 - Comment of the cell
Failure: | 0 and sets @error.
@error: | 1 - $oWorkbook is not an object or not a workbook object 2 - $sSearch is empty 3 - $vRange is invalid. @extended is set to the COM error code 4 - Error returned by the Find method. @extended is set to the COM error code

Remarks

This function mimics the Ctrl+F functionality of Excel, except that it adds the cells comment to the result.
Excel recognizes the following wildcards:
? (question mark) - Any single character
* (asterisk) - Any number of characters
~ (tilde) followed by ?, *, or ~ - A question mark, asterisk, or tilde

When $vRange is specified as A1 range (string) then the active sheet of $oWorkbook is being searched.

Related

_Excel_RangeReplace

See Also

See http://office.microsoft.com/en-us/excel-help/wildcard-characters-HP005203612.aspx.

Example

Example 1

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Find all occurrences of value "37000" (partial match)
; *****************************************************************************
Local $aResult = _Excel_RangeFind($oWorkbook, "37000")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example 1", "Error searching the range." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example 1", "Find all occurrences of value '37000' (partial match)." & @CRLF & "Data successfully searched.")
_ArrayDisplay($aResult, "Excel UDF: _Excel_RangeFind Example 1", "", 0, "|", "Sheet|Name|Cell|Value|Formula|Comment")

Example 2

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Find all occurrences of string "=C10*10" in the formulas, exact match
; *****************************************************************************
Local $aResult = _Excel_RangeFind($oWorkbook, "=C10*10", "A1:G15", $xlFormulas, $xlWhole)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example 2", "Error searching the range." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example 2", "Find all occurrences of string '=C10*10' in the formulas, exact match." & @CRLF & "Data successfully searched.")
_ArrayDisplay($aResult, "Excel UDF: _Excel_RangeFind Example 2", "", 0, "|", "Sheet|Name|Cell|Value|Formula|Comment")

Example 3

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Find all occurrences of string "test" in the comments
; *****************************************************************************
Local $aResult = _Excel_RangeFind($oWorkbook, "test", Default, $xlComments)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example 3", "Error searching the range." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example 3", "Find all occurrences of string 'test' in the comments." & @CRLF & "Data successfully searched.")
_ArrayDisplay($aResult, "Excel UDF: _Excel_RangeFind Example 3", "", 0, "|", "Sheet|Name|Cell|Value|Formula|Comment")

Example 4

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Find all values with "Story" at the end using wildcards and exact match
; *****************************************************************************
Local $aResult = _Excel_RangeFind($oWorkbook, "* Story", Default, Default, $xlWhole)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example 4", "Error searching the range." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example 4", "Find all values with 'Story' at the end using wildcards and exact match." & @CRLF & "Data successfully searched.")
_ArrayDisplay($aResult, "Excel UDF: _Excel_RangeFind Example 4", "", 0, "|", "Sheet|Name|Cell|Value|Formula|Comment")


Function _Excel_RangeInsert

Function Reference

_Excel_RangeInsert

Inserts one or multiple empty cells, rows or columns into the specified worksheet

#include <Excel.au3>
_Excel_RangeInsert ( $oWorksheet, $vRange [, $iShift = Default [, $iCopyOrigin = Default]] )

Parameters

$oWorksheet | Excel worksheet object
$vRange | Range can be a range object, an A1 range (e.g. "A1:B2", "1:2" (row 1 to 2), ""D:G" (columns D to G) etc.
$iShift | [optional] Specifies which way to shift the cells. Can be xlShiftToRight or xlShiftDown of the XlInsertShiftDirection enumeration. If set to keyword Default, Excel decides based on the shape of the range (default = keyword Default)
$iCopyOrigin | [optional] Specifies which formatting option to copy. Can be any of the XlInsertFormatOrigin enumeration (default = keyword Default)

Return Value

Success: | the range object containing the inserted cells, rows or columns
Failure: | 0 and sets @error.
@error: | 1 - $oWorksheet is not an object or not a worksheet object 2 - $vRange is invalid. @extended is set to the COM error code 3 - Error occurred when inserting empty cells. @extended is set to the COM error code

Remarks

The supplied range is inserted above or to the left of the supplied range, depending on the $iShift parameter.

Example

Example 1

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeInsert Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeInsert Example", "Error opening workbook '" & @ScriptDir & "\Extra\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Insert a range with 3 rows and 2 columns before A1 on the active worksheet
; and shift the cells down.
; *****************************************************************************
_Excel_RangeInsert($oWorkbook.Activesheet, "A1:B3", $xlShiftDown)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeInsert Example 1", "Error inserting cells." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeInsert Example 1", "Range successfully inserted.")

Example 2

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeInsert Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeInsert Example", "Error opening workbook '" & @ScriptDir & "\Extra\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Insert 3 columns before colum B on the active worksheet
; *****************************************************************************
_Excel_RangeInsert($oWorkbook.Activesheet, "B:D")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeInsert Example 2", "Error inserting columns." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeInsert Example 2", "3 columns successfully inserted before column B.")

Example 3

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeInsert Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeInsert Example", "Error opening workbook '" & @ScriptDir & "\Extra\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Insert 2 rows before row 1 on worksheet 2
; *****************************************************************************
_Excel_RangeInsert($oWorkbook.Worksheets(2), "1:2")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeInsert Example 3", "Error inserting rows." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeInsert Example 3", "Rows successfully inserted on worksheet 2.")


Function _Excel_RangeLinkAddRemove

Function Reference

_Excel_RangeLinkAddRemove

Adds or removes a hyperlink to/from a specified range

#include <Excel.au3>
_Excel_RangeLinkAddRemove ( $oWorkbook, $vWorksheet, $vRange, $sAddress [, $sSubAddress = Default [, $sScreenTip = Default [, $sTextToDisplay = Default]]] )

Parameters

$oWorkbook | Excel workbook object
$vWorksheet | Name, index or worksheet object to be used. If set to keyword Default the active sheet will be used
$vRange | Either a range object or an A1 range to be set to a hyperlink
$sAddress | The address for the specified link. The address can be an E-mail address, an Internet address or a file name. "" removes an existing hyperlink
$sSubAddress | [optional] The name of a location within the destination file, such as a bookmark, named range or slide number (default = keyword Default = None)
$sScreenTip | [optional] The text that appears as a ScreenTip when the mouse pointer is positioned over the specified hyperlink (default = keyword Default = Uses value of $sAddress)
$sTextToDisplay | [optional] The text to be displayed for the hyperlink (default = keyword Default = None)

Return Value

Success: | a hyperlinks object when a link is set or 1 when a link is removed.
Failure: | 0 and sets @error.
@error: | 1 - $oWorkbook is not an object or not a workbook object 2 - $vWorksheet name or index are invalid or $vWorksheet is not a worksheet object. @extended is set to the COM error code 3 - $vRange is invalid. @extended is set to the COM error code 4 - Error occurred when adding/removing the hyperlink. @extended is set to the COM error code

Remarks

Looks like Excel only writes the $sTextToDisplay to the upper left cell of a range (if the cell is empty). The remaining cells of the range remain untouced.

Example

Example 1

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeLinkAddRemove Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeLinkAddRemove Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Add a link to cells A1:C1
; *****************************************************************************
_Excel_RangeLinkAddRemove($oWorkbook, $oWorkbook.Activesheet, "A1:C1", "http://www.autoitscript.com", Default, "AutoIt Homepage")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeLinkAddRemove Example 1", "Error setting hyperlink." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeLinkAddRemove Example 1", "Links set to cells 'A1:C3'.")

; *****************************************************************************
; Remove the links from cells A1:C1
; *****************************************************************************
_Excel_RangeLinkAddRemove($oWorkbook, $oWorkbook.Activesheet, "A1:C1", "")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeLinkAddRemove Example 2", "Error setting hyperlink." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeLinkAddRemove Example 2", "Links removed from cells 'A1:C3'.")

Example 2

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeLinkAddRemove Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls", True)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeLinkAddRemove Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Insert an index sheet with links to all other sheets.
; Handles Sheet names with spaces correctly.
; *****************************************************************************
Local $oSheet = _Excel_SheetAdd($oWorkbook, 1, True, 1, "Index")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeLinkAddRemove Example 3", "Error adding sheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
$oSheet.Range("A1").Value = "Index"
Local $iRow = 2
For $iSheet = 2 To $oWorkbook.Sheets.Count
    $oSheet.Cells($iRow, 1).Value = $iRow - 1
    $oSheet.Cells($iRow, 2).Value = $oWorkbook.Worksheets($iRow).Name
    _Excel_RangeLinkAddRemove($oWorkbook, $oSheet, $oSheet.Cells($iRow, 2), $oWorkbook.Fullname, "'" & $oSheet.Cells($iRow, 2).Value & "'!A1")
    $iRow = $iRow + 1
Next
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeLinkAddRemove Example 3", "Index Sheet inserted as sheet 1.")


Function _Excel_RangeRead

Function Reference

_Excel_RangeRead

Reads the value, formula or displayed text from a cell or range of cells of the specified workbook and worksheet

#include <Excel.au3>
_Excel_RangeRead ( $oWorkbook [, $vWorksheet = Default [, $vRange = Default [, $iReturn = 1 [, $bForceFunc = False]]]] )

Parameters

$oWorkbook | Excel workbook object
$vWorksheet | [optional] Name, index or worksheet object to be read. If set to keyword Default the active sheet will be used (default = keyword Default)
$vRange | [optional] Either a range object or an A1 range. If set to Default all used cells will be processed (default = keyword Default)
$iReturn | [optional] What to return from the specified cell: 1 - Value (default) 2 - Formula 3 - The displayed text 4 - Value2. The only difference between Value and Value2 is that the Value2 property doesn’t use the Currency and Date data types
$bForceFunc | [optional] True forces to use the _ArrayTranspose function instead of the Excel transpose method (default = False). See the Remarks section for details.

Return Value

Success: | the data from the specified cell(s). A string for a cell, a zero-based array for a range of cells.
Failure: | 0 and sets @error.
@error: | 1 - $oWorkbook is not an object or not a workbook object 2 - $vWorksheet name or index are invalid or $vWorksheet is not a worksheet object. @extended is set to the COM error code 3 - $vRange is invalid. @extended is set to the COM error code 4 - Parameter $iReturn is invalid. Has to be >= 1 and <= 4 5 - Error occurred when reading data using the transpose method. @extended is set to the COM error code 6 - Maximum size of an AutoIt array exceeded (2^24 = 16,777,216 elements) 7 - Error occurred when reading data using the _ArrayTranspose function. @extended is set to the COM error code 8 - $iReturn = 3 can only return a single cell. $vRange specified > 1 cell.

Remarks

The Excel transpose method has an undocumented limit on the number of cells it can transpose (depends on the Excel version).
If you transpose > 65535 cells then $bForceFunc is forced to True.
The Excel transpose method doesn't support cells with more than 255 characters. Set $bForceFunc = True to bypass this limitation(s).
$iReturn = 3 only allows to get the displayed text of a single cell. That's an Excel limitation.

Related

_Excel_RangeWrite

Example

Example 1

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Read data from a single cell on the active sheet of the specified workbook
; *****************************************************************************
Local $sResult = _Excel_RangeRead($oWorkbook, Default, "A1")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 1", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 1", "Data successfully read." & @CRLF & "Value of cell A1: " & $sResult)

Example 2

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Read the formulas of a cell range on sheet 2 of the specified workbook
; *****************************************************************************
Local $aResult = _Excel_RangeRead($oWorkbook, 2, "A1:C1", 2)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 2", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 2", "Data successfully read." & @CRLF & "Please click 'OK' to display the formulas of cells A1:C1 of sheet 2.")
_ArrayDisplay($aResult, "Excel UDF: _Excel_RangeRead Example 2 - Cells A1:C1 of sheet 2")

Example 3

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Read the formulas of a cell range (all used cells in column A)
; *****************************************************************************
Local $aResult = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:A"), 2)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 3", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 3", "Data successfully read." & @CRLF & "Please click 'OK' to display all formulas in column A.")
_ArrayDisplay($aResult, "Excel UDF: _Excel_RangeRead Example 3 - Formulas in column A")


Function _Excel_RangeReplace

Function Reference

_Excel_RangeReplace

Finds and replaces matching strings in a range or worksheet

#include <Excel.au3>
_Excel_RangeReplace ( $oWorkbook, $vWorksheet, $vRange, $sSearch, $sReplace [, $iLookAt = $xlPart [, $bMatchcase = False]] )

Parameters

$oWorkbook | Excel workbook object
$vWorksheet | Name, index or worksheet object to be searched. If set to keyword Default the active sheet will be used
$vRange | A range object, an A1 range or keyword Default to search all cells in the specified worksheet
$sSearch | Search string
$sReplace | Replace string
$iLookAt | [optional] Specifies whether the search text must match as a whole or any part. Can be any of the XLLookAt enumeration (default = $xlPart)
$bMatchcase | [optional] True = case sensitive, False = case insensitive (default = False)

Return Value

Success: | the range object and sets @extended to 1 if cells have been changed.
Failure: | 0 and sets @error.
@error: | 1 - $oWorkbook is not an object or not a workbook object 2 - $vWorksheet name or index are invalid or $vWorksheet is not a worksheet object. @extended is set to the COM error code 3 - $sSearch is empty 4 - $vRange is invalid. @extended is set to the COM error code 5 - Error returned by the Replace method. @extended is set to the COM error code

Related

_Excel_RangeFind

Example

Example 1

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeReplace Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeReplace Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Replace content of cell A1 with another value
; *****************************************************************************
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeReplace Example 1", "Press OK to modify data in cell 'A1'.")
_Excel_RangeReplace($oWorkbook, Default, "A1", 1, 3.37)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeReplace Example 1", "Error replacing data the range." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeReplace Example 1", "Data successfully replaced in cell 'A1'.")

Example 2

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeReplace Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeReplace Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Find all cells with text "long " and remove it (replace with "")
; *****************************************************************************
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeReplace Example 1", "Press OK to modify data in cell 'G1'.")
_Excel_RangeReplace($oWorkbook, Default, Default, "long ", "")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeReplace Example 2", "Error replacing data the range." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeReplace Example 2", "Remove text 'long '." & @CRLF & "Data successfully replaced.")


Function _Excel_RangeSort

Function Reference

_Excel_RangeSort

Sorts a cell range

#include <Excel.au3>
_Excel_RangeSort ( $oWorkbook, $vWorksheet, $vRange, $vKey1 [, $iOrder1 = $xlAscending [, $iSortText = $xlSortNormal [, $iHeader = $xlNo [, $bMatchcase = False [, $iOrientation = $xlSortRows [, $vKey2 = Default [, $iOrder2 = Default [, $vKey3 = Default [, $iOrder3 = Default]]]]]]]]] )

Parameters

$oWorkbook | Excel workbook object
$vWorksheet | Name, index or worksheet object to be sorted. If set to keyword Default the active sheet will be used
$vRange | A range object, an A1 range or keyword Default to sort the whole worksheet (default = keyword Default)
$vKey1 | Specifies the first sort field, either as an A1 range or range object
$iOrder1 | [optional] Determines the sort order. Can be any of the XlSortOrder enumeration (default = $xlAscending)
$iSortText | [optional] Specifies how to sort text in $vKey1, $vKey2 and $vKey3. Can be any of the XlSortDataOption enumeration (default = $xlSortNormal)
$iHeader | [optional] Specifies whether the first row contains header information. Can be any of the XlYesNoGuess enumeration (default = $xlNo)
$bMatchCase | [optional] True to perform a case-sensitive sort, False to perform non-case sensitive sort (default = False)
$iOrientation | [optional] Specifies the sort orientation. Can be any of the XlSortOrientation enumeration (default = $xlSortColumns)
$vKey2 | [optional] See $vKey1
$iOrder2 | [optional] See $iOrder1
$vKey3 | [optional] See $vKey1
$iOrder3 | [optional] See $iOrder1

Return Value

Success: | an object of the sorted range.
Failure: | 0 and sets @error.
@error: | 1 - $oWorkbook is not an object or not a workbook object 2 - $vWorksheet name or index are invalid or $vWorksheet is not a worksheet object. @extended is set to the COM error code 3 - $vRange is invalid. @extended is set to the COM error code 4 - $vKey1 is invalid. @extended is set to the COM error code 5 - $vKey2 is invalid. @extended is set to the COM error code 6 - $vKey3 is invalid. @extended is set to the COM error code 7 - Error returned by the Sort method. @extended is set to the COM error code

Example

Example 1

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeSort Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeSort Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Sort a range with headers ascending on column I
; *****************************************************************************
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeSort Example 1", "Press OK to sort range I1:K7. Key is column I.")
_Excel_RangeSort($oWorkbook, Default, "I1:K7", "I:I", Default, Default, $xlYes)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeSort Example 1", "Error sorting data." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeSort Example 1", "Data successfully sorted in range I1:K7")

Example 2

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeSort Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeSort Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Sort a range with headers descending on column K. Sort numbers as text
; *****************************************************************************
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeSort Example 2", "Press OK to sort range I1:K7. Key is column K.")
_Excel_RangeSort($oWorkbook, Default, "I1:K7", "K:K", $xlDescending, Default, $xlYes)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeSort Example 2", "Error sorting data." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeSort Example 2", "Data successfully sorted in range I1:K7")

Example 3

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeSort Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeSort Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Sort a range with headers descending on row 1 (column headers)
; *****************************************************************************
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeSort Example 3", "Press OK to sort range I1:K7. Key is row 1.")
_Excel_RangeSort($oWorkbook, Default, "I1:K7", "1:1", $xlDescending, Default, $xlYes, Default, $xlSortRows)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeSort Example 3", "Error sorting data." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeSort Example 3", "Data successfully sorted in range I1:K7")


Function _Excel_RangeValidate

Function Reference

_Excel_RangeValidate

Adds data validation to the specified range

#include <Excel.au3>
_Excel_RangeValidate ( $oWorkbook, $vWorksheet, $vRange, $iType, $sFormula1 [, $iOperator = Default [, $sFormula2 = Default [, $bIgnoreBlank = True [, $iAlertStyle = $xlValidAlertStop [, $sErrorMessage = Default [, $sInputMessage = Default]]]]]] )

Parameters

$oWorkbook | Excel workbook object
$vWorksheet | Name, index or worksheet object. If set to keyword Default the active sheet will be used
$vRange | A range object, an A1 range or keyword Default to validate all cells in the specified worksheet
$iType | The validation type. Can be any of the XlDVType enumeration
$sFormula1 | The first part of the data validation equation
$iOperator | [optional] The data validation operator. Can be any of the XlFormatConditionOperator enumeration (default = keyword Default)
$sFormula2 | [optional] The second part of the data validation when $iOperator is $xlBetween or $xlNotBetween. Otherwise it is ignored (default = keyword Default)
$bIgnoreBlank | [optional] If set to True, cell data is considered valid if the cell is blank (default = True)
$iAlertStyle | [optional] The validation alert style. Can be any of the XlDVAlertStyle enumeration (default = $xlValidAlertStop)
$sErrorMessage | [optional] Message to be displayed in a MsgBox when invalid data has been entered (default = keyword Default)
$sInputMessage | [optional] Message to be displayed in a Tooltip when you begin to enter data (default = keyword Default)

Return Value

Success: | the range object.
Failure: | 0 and sets @error.
@error: | 1 - $oWorkbook is not an object or not a workbook object 2 - $vWorksheet name or index are invalid or $vWorksheet is not a worksheet object. @extended is set to the COM error code 3 - $vRange is invalid. @extended is set to the COM error code 4 - Error returned by the Add method. @extended is set to the COM error code

Remarks

Parameter $bDisplayAlerts for function _Excel_Open needs to be set to True to display $sErrorMessage.

If you want to validate against a list of values stored in another cell range ($iType = $xlValidateList) then
$sFormula1 has to start with a "=" (e.g. "=C:C").

Before adding a new validation rule to a range the function deletes existing validation rules of the range.

Example

Example 1

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open(True, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeValidate Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookNew($oExcel)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeValidate Example", "Error creating new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Only values from a list are valid
; *****************************************************************************
_Excel_RangeValidate($oWorkbook, Default, "A1:A10", $xlValidateList, "Yes;No;Don't know")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeValidate Example 1", "Error setting range validation." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeValidate Example 1", "Validation against a list of values successfully set for range 'A1:A10'.")

Example 2

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open(True, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeValidate Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookNew($oExcel)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeValidate Example", "Error creating new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Only values from a list defined in a cell range (column 'D') are valid
; *****************************************************************************
; Write values to a range
Local $aValidation[] = ["10", "20", "30", "40", "50"]
_Excel_RangeWrite($oWorkbook, Default, $aValidation, "D1")
; Only values from the range are valid
_Excel_RangeValidate($oWorkbook, Default, "C:C", $xlValidateList, "=D:D")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeValidate Example 2", "Error setting range validation." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeValidate Example 2", "Validation against a list of values in cell range '=D:D' successfully set for colum 'C'.")

Example 3

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open(True, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeValidate Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookNew($oExcel)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeValidate Example", "Error creating new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Only numeric values are valid
; *****************************************************************************
_Excel_RangeValidate($oWorkbook, Default, "B:B", $xlValidateDecimal, 0, $xlGreater, Default, Default, $xlValidAlertStop, "You entered a non numeric value!", "Only numeric values are valid.")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeValidate Example 3", "Error setting range validation." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeValidate Example 3", "Only numeric values are valid in column 'B'.")

Example 4

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open(True, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeValidate Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookNew($oExcel)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeValidate Example", "Error creating new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Custom validation. Sum of all cells in column 'E' has to be < 100
; *****************************************************************************
_Excel_RangeValidate($oWorkbook, Default, "E:E", $xlValidateCustom, "=SUMME(E:E)<=100", Default, Default, Default, Default, "Sum of all cells in column 'E' > 100.")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeValidate Example 4", "Error setting range validation." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeValidate Example 4", "Sum of all cells in column 'E' has to be < 100.")


Function _Excel_RangeWrite

Function Reference

_Excel_RangeWrite

Writes value(s) or formula(s) to a cell or a cell range on the specified workbook and worksheet

#include <Excel.au3>
_Excel_RangeWrite ( $oWorkbook, $vWorksheet, $vValue [, $vRange = "A1" [, $bValue = True [, $bForceFunc = False]]] )

Parameters

$oWorkbook | Excel workbook object
$vWorksheet | Name, index or worksheet object to be written to. If set to keyword Default the active sheet will be used
$vValue | Can be a string, a 1D or 2D zero based array containing the data to be written to the worksheet
$vRange | [optional] Either an A1 range or a range object (default = "A1")
$bValue | [optional] If True the $vValue will be written to the value property. If False $vValue will be written to the formula property (default = True)
$bForceFunc | [optional] True forces to use the _ArrayTranspose function instead of the Excel transpose method (default = False). See the Remarks section for details.

Return Value

Success: | the object of the range the data has been written to.
Failure: | 0 and sets @error.
@error: | 1 - $oWorkbook is not an object or not a workbook object 2 - $vWorksheet name or index are invalid or $vWorksheet is not a worksheet object. @extended is set to the COM error code 3 - $vRange is invalid. @extended is set to the COM error code 4 - Error occurred when writing a single cell. @extended is set to the COM error code 5 - Error occurred when writing data using the _ArrayTranspose function. @extended is set to the COM error code 6 - Error occurred when writing data using the transpose method. @extended is set to the COM error code

Remarks

If $vRange is a single cell and $vValue is an array then $vRange is extended to hold the full array.
This "expanded" range is then returned by the function.
If $vRange is not a single cell and $vValue is an array and $vValue > $vRange then the array gets truncated.
If $vRange is not a single cell and $vValue is an array and $vValue < $vRange then the exceeding cells get #NV.

The Excel transpose method has an undocumented limit on the number of cells or rows it can transpose (dependant on the Excel version).
The Excel transpose method doesn't support cells with more than 255 characters. Set $bForceFunc = True to bypass this limitation(s).

Related

_Excel_RangeRead

Example

Example 1

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and create a new workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookNew($oExcel)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example", "Error creating the new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Write a string with a line break to the active sheet in the active workbook
; *****************************************************************************
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "Test" & @CRLF & "String")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example 1", "Error writing to worksheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example 1", "String successfully written.")

Example 2

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and create a new workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookNew($oExcel)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example", "Error creating the new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Write a 1D array to the active sheet in the active workbook
; *****************************************************************************
Local $aArray1D[3] = ["AA", "BB", "CC"]
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $aArray1D, "A3")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example 2", "Error writing to worksheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example 2", "1D array successfully written.")

Example 3

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and create a new workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookNew($oExcel)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example", "Error creating the new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Write a part of a 2D array to the active sheet in the active workbook
; *****************************************************************************
Local $aArray2D[3][5] = [[11, 12, 13, 14, 15], [21, 22, 23, 24, 25], [31, 32, 33, 34, 35]]
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $aArray2D, "B1")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example 3", "Error writing to worksheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example 3", "2D array successfully written.")

Example 4

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and create a new workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookNew($oExcel)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example", "Error creating the new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Fill a range in the active sheet in the active workbook with a formula
; *****************************************************************************
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "=B1+3", "B5:F6", False)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example 4", "Error writing to worksheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example 4", "Range successfully filled with a formula.")


Function _Excel_SheetAdd

Function Reference

_Excel_SheetAdd

Adds new sheet(s) to a workbook and sets their names

#include <Excel.au3>
_Excel_SheetAdd ( $oWorkbook [, $vSheet = Default [, $bBefore = True [, $iCount = 1 [, $sName = ""]]]] )

Parameters

$oWorkbook | A workbook object
$vSheet | [optional] Object, index or name of the sheet before/after which the new sheet is inserted. -1 = insert before/after the last worksheet (default = keyword Default = active worksheet)
$bBefore | [optional] The new sheet will be inserted before $vSheet if True, after $vSheet if False (default = True)
$iCount | [optional] Number of worksheets to be inserted (default = 1). Maximum is 255
$sName | [optional] Name(s) of the sheet(s) to create (default = "" = follows standard Excel new sheet convention). When $iCount > 1 multiple names can be provided separated by | (pipe character). Sheets are named from left to right

Return Value

Success: | an object of the (first) added worksheet.
Failure: | 0 and sets @error.
@error: | 1 - $oWorkbook is not an object or not a workbook object 2 - $vSheet is invalid. Name or index does not exist. @extended is set to the COM error code 3 - Specified sheet already exists. @extended is set to the number of the name in $sName 4 - Error occurred when adding the sheet. @extended is set to the COM error code 5 - Error occurred when setting the name of the new sheet(s). @extended is set to the COM error code 6 - Parameter $iCount > 255

Related

_Excel_SheetDelete

Example

Example 1

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetAdd Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetAdd Example", "Error opening workbook '" & @ScriptDir & "\_Extras\Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Insert two sheets after the last sheet and name them
; *****************************************************************************
_Excel_SheetAdd($oWorkbook, -1, False, 2, "Test1|Test2")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetAdd Example 1", "Error adding sheets." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetAdd Example 1", "Two sheets added after the last one.")

Example 2

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetAdd Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls", True)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetAdd Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Insert a sheet before sheet 2. Name is default name
; *****************************************************************************
_Excel_SheetAdd($oWorkbook, 2)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetAdd Example 2", "Error adding sheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetAdd Example 2", "Sheet added before sheet 2.")

Example 3

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetAdd Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls", True)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetAdd Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Insert an index sheet with links to all other sheets.
; Handles Sheet names with spaces correctly.
; *****************************************************************************
Local $oSheet = _Excel_SheetAdd($oWorkbook, 1, True, 1, "Index")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetAdd Example 3", "Error adding sheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
$oSheet.Range("A1").Value = "Index"
Local $iRow = 2
For $iSheet = 2 To $oWorkbook.Sheets.Count
    $oSheet.Cells($iRow, 1).Value = $iRow - 1
    $oSheet.Cells($iRow, 2).Value = $oWorkbook.Worksheets($iRow).Name
    $oSheet.Hyperlinks.Add($oSheet.Cells($iRow, 2), "", "'" & $oSheet.Cells($iRow, 2).Value & "'!A1")
    $iRow = $iRow + 1
Next
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetAdd Example 3", "Index Sheet inserted as sheet 1.")


Function _Excel_SheetCopyMove

Function Reference

_Excel_SheetCopyMove

Copies or moves the specified sheet before or after a specified sheet in the same or a different workbook

#include <Excel.au3>
_Excel_SheetCopyMove ( $oSourceBook [, $vSourceSheet = Default [, $oTargetBook = $oSourceBook [, $vTargetSheet = 1 [, $bBefore = True [, $bCopy = True]]]]] )

Parameters

$oSourceBook | Object of the source workbook where the sheet should be copied/moved from
$vSourceSheet | [optional] Name, index or object of the sheet to copy/move (default = keyword Default = active sheet)
$oTargetBook | [optional] Object of the target workbook where the sheet should be copied/moved to (default = keyword Default = $oSourceBook)
$vTargetSheet | [optional] The copied/moved sheet will be placed before or after this sheet (name, index or object) (default = keyword Default = first sheet)
$bBefore | [optional] The copied/moved sheet will be placed before $vTargetSheet if True, after it if False (default = True)
$bCopy | [optional] Copy the specified sheet if True, move the sheet if False (default = True)

Return Value

Success: | an object of the copied/moved sheet.
Failure: | 0 and sets @error.
@error: | 1 - $oSourceBook is not an object or not a workbook object 2 - $oTargetBook is not an object or not a workbook object 3 - Specified source sheet does not exist. Name or index is invalid. @extended is set to the COM error code 4 - Specified target sheet does not exist. Name or index is invalid. @extended is set to the COM error code 5 - Error occurred when copying/moving the sheet. @extended is set to the COM error code

Related

_Excel_SheetDelete

Example

Example 1

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetCopyMove Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open Workbook 1
Local $oWorkbook1 = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetCopyMove Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Copy Sheet 1 after Sheet 3. Set the name of the new Sheet
; *****************************************************************************
Local $oCopiedSheet = _Excel_SheetCopyMove($oWorkbook1, 1, Default, 3, False)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetCopyMove Example 1", "Error copying sheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Set the name of the new sheet
#forceref $oCopiedSheet
$oCopiedSheet.Name = "Copied sheet"
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetCopyMove Example 1", "Sheet 1 copied after sheet 3 and renamed")

Example 2

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetCopyMove Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open Workbook 1
Local $oWorkbook1 = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetCopyMove Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Move Sheet 2 before Sheet 1. Set the name of the moved Sheet
; *****************************************************************************
Local $oMovedSheet = _Excel_SheetCopyMove($oWorkbook1, 2, Default, 1, Default, False)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetCopyMove Example 2", "Error moving sheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Set the name of the new sheet
#forceref $oMovedSheet
$oMovedSheet.Name = "Moved sheet"
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetCopyMove Example 2", "Sheet 2 moved before sheet 1")

Example 3

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetCopyMove Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open Workbook 2
Local $oWorkbook2 = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel3.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetCopyMove Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel3.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf
; Open Workbook 1
Local $oWorkbook1 = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetCopyMove Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Copy Sheet 3 of Workbook 1 after Sheet 3 of Workbook 2
; *****************************************************************************
_Excel_SheetCopyMove($oWorkbook1, 3, $oWorkbook2, 3, False)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetCopyMove Example 3", "Error copying sheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetCopyMove Example 3", "Workbook 1 Sheet 3 copied to Workbook2 after sheet 3")

Example 4

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetCopyMove Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open Workbook 2
Local $oWorkbook2 = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel3.xls", True)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetCopyMove Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel3.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf
; Open Workbook 1
Local $oWorkbook1 = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls", True)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetCopyMove Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Move Sheet 1 of Workbook 1 before Sheet 1 of Workbook 2
; *****************************************************************************
_Excel_SheetCopyMove($oWorkbook1, 1, $oWorkbook2, 1, Default, False)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetCopyMove Example 4", "Error moving sheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetCopyMove Example 4", "Workbook 1 Sheet 1 moved to Workbook2 before sheet 1")


Function _Excel_SheetDelete

Function Reference

_Excel_SheetDelete

Deletes the specified sheet by object, string name or by number

#include <Excel.au3>
_Excel_SheetDelete ( $oWorkbook [, $vSheet = Default] )

Parameters

$oWorkbook | A workbook object
$vSheet | [optional] The sheet to delete, either by object, string name or number (default = keyword Default = active Worksheet)

Return Value

Success: | 1.
Failure: | 0 and sets @error.
@error: | 1 - $oWorkbook is not an object or not a workbook object 2 - Specified sheet does not exist. @extended is set to the COM error code 3 - Error occurred when deleting the sheet. @extended is set to the COM error code

Related

_Excel_SheetAdd

Example

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open an example workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetDelete Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel1.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetDelete Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Delete sheet number 1 of the specified workbook
; *****************************************************************************
_Excel_SheetDelete($oWorkbook, 1)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetDelete Example 1", "Error deleting sheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetDelete Example 1", "First sheet has been deleted.")


Function _Excel_SheetList

Function Reference

_Excel_SheetList

Returns a list of all sheets in the specified workbook

#include <Excel.au3>
_Excel_SheetList ( $oWorkbook )

Parameters

$oWorkbook A workbook object

Return Value

Success: | a two-dimensional zero based array with the following information: 0 - Name of the worksheet 1 - Object of the worksheet
Failure: | 0 and sets @error.
@error: | 1 - $oWorkbook is not an object or not a workbook object

Example

#include <Array.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object and open a workbook
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetList Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Extras\_Excel2.xls")
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetList Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel2.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _Excel_Close($oExcel)
    Exit
EndIf

; *****************************************************************************
; Display a list of all worksheets for a specific Workbook
; *****************************************************************************
Local $aWorkSheets = _Excel_SheetList($oWorkbook)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetList Example 1", "Error listing Worksheets." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
_ArrayDisplay($aWorkSheets, "Excel UDF: _Excel_SheetList Example 1")


User Defined Functions

File user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <File.au3>.

User Defined Function | Description
_FileCountLines | Returns the number of lines in the specified file
_FileCreate | Creates or zero's out the length of the file specified
_FileListToArray | Lists files and\or folders in a specified folder (Similar to using Dir with the /B Switch)
_FileListToArrayRec | Lists files and\or folders in specified path with optional recursion to defined level and result sorting
_FilePrint | Prints a plain text file
_FileReadToArray | Reads the specified file into a 1D or 2D array
_FileWriteFromArray | Writes an array to a specified file
_FileWriteLog | Writes current date, time and the specified text to a log file
_FileWriteToLine | Writes text to a specific line in a file
_PathFull | Creates a path based on the relative path you provide. The newly created absolute path is returned
_PathGetRelative | Returns the relative path to a directory
_PathMake | Creates a path from drive, directory, file name and file extension parts
_PathSplit | Splits a path into the drive, directory, file name and file extension parts. An empty string is set if a part is missing
_ReplaceStringInFile | Replaces substrings in a file
_TempFile | Generate a name for a temporary file. The file is guaranteed not to exist yet


Function _FileCountLines

Function Reference

_FileCountLines

Returns the number of lines in the specified file

#include <File.au3>
_FileCountLines ( $sFilePath )

Parameters

$sFilePath Path and filename of the file to be read

Return Value

Success: | the number of lines in the file.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - File cannot be opened or found.

Remarks

It does not count a final @LF as a line.

Example

#include <File.au3>
#include <MsgBoxConstants.au3>

Local $iCountLines = _FileCountLines(@ScriptFullPath) ; Retrieve the number of lines in the current script.
MsgBox($MB_SYSTEMMODAL, "", "There are " & $iCountLines & " lines in this file.")


Function _FileCreate

Function Reference

_FileCreate

Creates or zero's out the length of the file specified

#include <File.au3>
_FileCreate ( $sFilePath )

Parameters

$sFilePath Path and filename of the file to be created.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - Error opening specified file 2 - File could not be written to

Example

#include <File.au3>
#include <MsgBoxConstants.au3>

If Not _FileCreate("error.log") Then
    MsgBox($MB_SYSTEMMODAL, "Error", " Error Creating/Resetting log.      error:" & @error)
EndIf


Function _FileListToArray

Function Reference

_FileListToArray

Lists files and\or folders in a specified folder (Similar to using Dir with the /B Switch)

#include <File.au3>
_FileListToArray ( $sFilePath [, $sFilter = "*" [, $iFlag = $FLTA_FILESFOLDERS [, $bReturnPath = False]]] )

Parameters

$sFilePath | Folder to generate filelist for.
$sFilter | [optional] the filter to use, default is *. (* and ? wildcards accepted - See Remarks)
$iFlag | [optional] specifies whether to return files folders or both $FLTA_FILESFOLDERS (0) = (Default) Return both files and folders $FLTA_FILES (1) = Return files only $FLTA_FOLDERS (2) = Return Folders only Constants are defined in FileConstants.au3
$bReturnPath | [optional] If True the full path is appended to the file\folder path, otherwise it is relative to the $sFilePath folder. Default is False.

Return Value

Success: | A one-dimensional array. $aArray[0] = Number of Files\Folders returned $aArray[1] = 1st File\Folder $aArray[2] = 2nd File\Folder $aArray[3] = 3rd File\Folder $aArray[n] = nth File\Folder
Failure: | sets the @error flag to non-zero.
@error: | 1 - Folder not found or invalid 2 - Invalid $sFilter 3 - Invalid $iFlag 4 - No File(s) Found

Remarks

This function uses the Windows OS to return subfolders matching the specified filter. This works perfectly for simple filters, using a complex filter with multiple wildcards may return some unexpected results (for example *test*.* will match both testX and testX.X subfolders). If this occurs, the _FileListToArrayRec() function might be better suited as it compares all subfolders to the specified filter using a RegEx, although the time taken to run the function can be noticeably greater

See FileFindFirstFile() for a discussion about wildcards.

Related

_FileListToArrayRec

Example

Example 1

#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; List all the files and folders in the desktop directory using the default parameters.
    Local $aFileList = _FileListToArray(@DesktopDir, "*")
    If @error = 1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.")
        Exit
    EndIf
    If @error = 4 Then
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.")
        Exit
    EndIf
    ; Display the results returned by _FileListToArray.
    _ArrayDisplay($aFileList, "$aFileList")
EndFunc   ;==>Example

Example 2

#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; List all the files and folders in the desktop directory using the default parameters and return the full path.
    Local $aFileList = _FileListToArray(@DesktopDir, Default, Default, True)
    If @error = 1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.")
        Exit
    EndIf
    If @error = 4 Then
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.")
        Exit
    EndIf
    ; Display the results returned by _FileListToArray.
    _ArrayDisplay($aFileList, "$aFileList")
EndFunc   ;==>Example


Function _FileListToArrayRec

Function Reference

_FileListToArrayRec

Lists files and\or folders in specified path with optional recursion to defined level and result sorting

#include <File.au3>
_FileListToArrayRec ( $sFilePath [, $sMask = "*" [, $iReturn = $FLTAR_FILESFOLDERS [, $iRecur = $FLTAR_NORECUR [, $iSort = $FLTAR_NOSORT [, $iReturnPath = $FLTAR_RELPATH]]]]] )

Parameters

$sFilePath Initial path used to generate filelist.
If path ends in \ then folders will be returned with an ending \
If path lengths > 260 chars, prefix path with "\\?\" - return paths are not affected
$sMask [optional] Filter for result. Multiple filters must be separated by ";"
Use "|" to separate 3 possible sets of filters: "Include|Exclude|Exclude_Folders"
Include = Files/Folders to include (default = "*" [all])
Exclude = Files/Folders to exclude (default = "" [none])
Exclude_Folders = only used if $iRecur = 1 AND $iReturn <> 2 to exclude defined folders (default = "" [none])
$iReturn [optional] Specifies whether to return files, folders or both and omit those with certain attributes
$FLTAR_FILESFOLDERS (0) - (Default) Return both files and folders
$FLTAR_FILES (1) - Return files only
$FLTAR_FOLDERS (2) - Return Folders only
Add one or more of the following to $iReturn to omit files/folders with that attribute
+ $FLTAR_NOHIDDEN (4) - Hidden files and folders
+ $FLTAR_NOSYSTEM (8) - System files and folders
+ $FLTAR_NOLINK (16) - Link/junction folders
$iRecur [optional] Specifies whether to search recursively in subfolders and to what level
$FLTAR_NORECUR (0) - Do not search in subfolders (Default)
$FLTAR_RECUR (1) - Search in all subfolders (unlimited recursion)
Negative integer - Search in subfolders to specified depth
$iSort [optional] Sort results in alphabetical and depth order
$FLTAR_NOSORT (0) - Not sorted (Default)
$FLTAR_SORT (1) - Sorted
$FLTAR_FASTSORT (2) - Sorted with faster algorithm (assumes files in folder returned sorted - requires NTFS and not guaranteed)
$iReturnPath [optional] Specifies displayed path of results
$FLTAR_NOPATH (0) - File/folder name only
$FLTAR_RELPATH (1) - Relative to initial path (Default)
$FLTAR_FULLPATH (2) - Full path included

Return Value

Success: | a one-dimensional array made up as follows: [0] = Number of Files/Folders returned [1] = 1st File/Folder [2] = 2nd File/Folder ... [n] = nth File\Folder
Failure: | an empty string and sets the @error flag to 1 with @extended set as follows: 1 - Path not found or invalid 2 - Invalid Include parameter 3 - Invalid Exclude parameter 4 - Invalid Exclude_Folders parameter 5 - Invalid $iReturn parameter 6 - Invalid $iRecur parameter 7 - Invalid $iSort parameter 8 - Invalid $iReturnPath parameter 9 - No files/folders found

Remarks

If the files and/or folders to be returned are all within the same folder and can be specified with a single simple filter the _FileListToArray() function might be better suited as it is considerably faster.

Include/Exclude/Exclude_Folders logic:
Non-recursive:
Include/Exclude: Files and/or folders
Exclude_Folders: Ignored
Recursive:
Include/Exclude:
$iReturn = $FLTAR_FILESFOLDERS/$FLTAR_FILES - Files only
$iReturn = $FLTAR_FOLDERS - Folders only
Exclude_Folders:
$iReturn = $FLTAR_FILESFOLDERS/$FLTAR_FILES - Folders only
$iReturn = $FLTAR_FOLDERS - Ignored

Sorting the results will significantly increase the time required for the UDF to return the array

Despite the name, this UDF is iterative, not recursive. Constants are defined in FileConstants.au3

Related

_FileListToArray

Example

#include <Array.au3> ; Only required to display the arrays
#include <File.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $sAutoItDir = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", Default, -1))
    If StringRight($sAutoItDir, 5) = "beta\" Then
        $sAutoItDir = StringTrimRight($sAutoItDir, 5)
    EndIf
    ConsoleWrite($sAutoItDir & @CRLF)

    ; A sorted list of all files and folders in the AutoIt installation
    Local $aArray = _FileListToArrayRec($sAutoItDir, "*", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT)
    _ArrayDisplay($aArray, "Sorted tree")

    ; And now ignoring the "Include" folder
    $aArray = _FileListToArrayRec($sAutoItDir, "*||include", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT)
    _ArrayDisplay($aArray, "No 'Include' folder")

    ; A sorted list of all but the .exe files in the \AutoIt3 folder
    $aArray = _FileListToArrayRec($sAutoItDir, "*|*.exe", $FLTAR_FILES, $FLTAR_NORECUR, $FLTAR_SORT)
    _ArrayDisplay($aArray, "Non .EXE files")

    ; And here are the .exe files we left out last time
    $aArray = _FileListToArrayRec($sAutoItDir, "*.exe", $FLTAR_FILES)
    _ArrayDisplay($aArray, ".EXE Files")

    ; A test for all folders and .exe files only throughout the folder tree, omitting folders beginning with I (Icons and Include)
    $aArray = _FileListToArrayRec($sAutoItDir, "*.exe||i*", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT)
    _ArrayDisplay($aArray, "Recur with filter")

    ; Look for icon files - but exlude the "Icons" folder
    $aArray = _FileListToArrayRec($sAutoItDir, "*.ico||ic*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "Ooops!", "No ico files found")
    Else
        _ArrayDisplay($aArray, "Icon files not in 'Icons' folder")
    EndIf

    ; And to show that the filter applies to files AND folders when not recursive
    $aArray = _FileListToArrayRec($sAutoItDir, "*.exe", $FLTAR_FILESFOLDERS, $FLTAR_NORECUR, $FLTAR_SORT)
    _ArrayDisplay($aArray, "Non-recur with filter")

    ; The filter also applies to folders when recursively searching for folders
    $aArray = _FileListToArrayRec($sAutoItDir, "Icons", $FLTAR_FOLDERS, $FLTAR_RECUR, $FLTAR_SORT)
    _ArrayDisplay($aArray, "Folder recur with filter")

    ; Note the exlude_folder parameter is ignored when looking for folders - "Icons" will be excluded but "Include" will still be there
    $aArray = _FileListToArrayRec($sAutoItDir, "*|ic*|i*", $FLTAR_FOLDERS, $FLTAR_RECUR, $FLTAR_SORT)
    _ArrayDisplay($aArray, "'Icons' out - 'Include' in")

    ; The root of C:\Windows showing hidden/system folders
    $aArray = _FileListToArrayRec("C:\Windows\", "*", $FLTAR_FOLDERS)
    _ArrayDisplay($aArray, "Show hidden folders")

    ; The root of C:\Windows omitting hidden/system folders
    $aArray = _FileListToArrayRec("C:\Windows\", "*", $FLTAR_FOLDERS + $FLTAR_NOHIDDEN + $FLTAR_NOSYSTEM)
    _ArrayDisplay($aArray, "Hide hidden folders")
EndFunc   ;==>Example


Function _FilePrint

Function Reference

_FilePrint

Prints a plain text file

#include <File.au3>
_FilePrint ( $sFilePath [, $iShow = @SW_HIDE] )

Parameters

$sFilePath | The file to print.
$iShow | [optional] The state of the window. (default = @SW_HIDE)

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

Uses the ShellExecute function of shell32.dll.

Example

#include <File.au3>
#include <MsgBoxConstants.au3>

Local $sFilePath = FileOpenDialog("Print File", "", "Text Documents (*.txt)", 1)
If @error Then Exit

Local $iIsPrinted = _FilePrint($sFilePath)
If $iIsPrinted Then
    MsgBox($MB_SYSTEMMODAL, "", "The file was printed.")
Else
    MsgBox($MB_SYSTEMMODAL, "", "Error: " & @error & @CRLF & "The file was not printed.")
EndIf


Function _FileReadToArray

Function Reference

_FileReadToArray

Reads the specified file into a 1D or 2D array

#include <File.au3>
_FileReadToArray ( $sFilePath, ByRef $vReturn [, $iFlags = $FRTA_COUNT [, $sDelimiter = ""]] )

Parameters

$sFilePath | Path and filename of the file to be read.
$vReturn | Variable to hold returned data - does not need to be an array.
$iFlags | [optional] Add multiple values together as required $FRTA_NOCOUNT (0) - array is 0-based use UBound() to get size $FRTA_COUNT (1) - array count in the first element. (default) $FRTA_INTARRAYS (2) - Create "array of arrays" - see remarks $FRTA_ENTIRESPLIT (4) - Use entire delimiter string as split point (default each character defines a split point)
$sDelimiter | [optional] Used to further split each line of the file - e.g. reading CSV files into a 2D array

Return Value

Success: | 1 and $vReturn holds an array.
Failure: | 0, @error flag set to non-zero and $vReturn is set to 0.
@error: | 1 - Error opening specified file 2 - Unable to split the file 3 - File lines have different numbers of fields (only if $FRTA_INTARRAYS flag not set) 4 - No delimiters found (only if $FRTA_INTARRAYS flag not set)

Remarks

If a delimiter is not specified the function returns a 1D array with each element holding a line of the file - line endings can be any mix of @CR, @LF and @CRLF.

When a delimiter is specified the function tries to further split each line of the file - how this is done depends on the setting of the $FRTA_INTARRAYS flag. If the flag is not set and each line has the same number of fields split by the delimiter then a 2D array is created, but if this is not the case then @error is set to 3 and no array is returned. If the $FRTA_INTARRAYS flag is set the function creates a 1D array where each element is a further array holding the fields of the line split on the delimiter - the lines do not need to have the same number of fields. See example below.

If the delimiter is more than a single character then the $FRTA_ENTIRESPLIT flag setting determines the split method.

Related

_FileWriteFromArray

Example

Example 1

#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aRetArray, $sFilePath = @TempDir & "\Test.txt"

    ; Create 1D array
    Local $aArray[] = ["0", "1", "2", "3", "4"]
    ; Write it to file
    _FileWriteFromArray($sFilePath, $aArray, Default, Default, @CRLF)
    Sleep(1000)

    ; Re-read it - with count
    _FileReadToArray($sFilePath, $aRetArray)
    _ArrayDisplay($aRetArray, "1D array - count", Default, 8)

    ; Re-read it - without count
    _FileReadToArray($sFilePath, $aRetArray, $FRTA_NOCOUNT)
    _ArrayDisplay($aRetArray, "1D array - no count", Default, 8)

    ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    ; Create "square" 2D array
    Local $aArray[][] = [ _
            ["00", "01", "02", "03"], _
            ["10", "11", "12", "13"], _
            ["20", "21", "22", "23"], _
            ["30", "31", "32", "33"]]
    _ArrayDisplay($aArray, "Original", Default, 8)
    ; Write it to file
    _FileWriteFromArray($sFilePath, $aArray, Default, Default, ",")
    Sleep(1000)

    ; Re-read it - with count
    _FileReadToArray($sFilePath, $aRetArray, Default, ",")
    _ArrayDisplay($aRetArray, "2D array - count", Default, 8)

    ; Re-read it - without count
    _FileReadToArray($sFilePath, $aRetArray, $FRTA_NOCOUNT, ",")
    _ArrayDisplay($aRetArray, "2D array - no count", Default, 8)

    ; Read into "array of arrays" with count
    _FileReadToArray($sFilePath, $aRetArray, $FRTA_COUNT + $FRTA_INTARRAYS, ",")
    _ArrayDisplay($aRetArray, "Array of arrays - count", Default, 8)
    ; Now look inside the arrays inside the returned array
    _ArrayDisplay($aRetArray[1], "Array 1 inside RetArray - count", Default, 8)

    ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    ; Rewrite 2D array with multiple delimiters
    _FileWriteFromArray($sFilePath, $aArray, Default, Default, ":|")
    Sleep(1000)

    ; Re-read with each delimiter acting as a split point
    _FileReadToArray($sFilePath, $aRetArray, $FRTA_NOCOUNT, ":|")
    _ArrayDisplay($aRetArray, "Split on each character", Default, 8)

    ; Re-read with whole delimiter acting as a split point
    _FileReadToArray($sFilePath, $aRetArray, $FRTA_NOCOUNT + $FRTA_ENTIRESPLIT, ":|")
    _ArrayDisplay($aRetArray, "Split on full delimiter", Default, 8)

    FileDelete($sFilePath)
EndFunc   ;==>Example

Example 2

#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Define a variable to pass to _FileReadToArray.
    Local $aArray = 0

    ; Read the current script file into an array using the variable defined previously.
    ; $iFlag is specified as 0 in which the array count will not be defined. Use UBound() to find the size of the array.
    If Not _FileReadToArray(@ScriptFullPath, $aArray, 0) Then
        MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file.
    EndIf

    ; Display the array in _ArrayDisplay.
    _ArrayDisplay($aArray)
EndFunc   ;==>Example


Function _FileWriteFromArray

Function Reference

_FileWriteFromArray

Writes an array to a specified file

#include <File.au3>
_FileWriteFromArray ( $sFilePath, Const ByRef $aArray [, $iBase = Default [, $iUBound = Default [, $sDelimiter = "|"]]] )

Parameters

$sFilePath | Path of the file to write to, or a file handle returned by FileOpen().
$aArray | The array to be written to the specified file.
$iBase | [optional] Start array index to read, normally set to 0 or 1. Default is 0.
$iUbound | [optional] Set to the last record you want to write to the File. Default is the whole array.
$sDelimiter | [optional] Delimiter character(s) for 2-dimension arrays. Default is "|".

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - Error opening specified file 2 - $aArray is not an array 3 - Error writing to file 4 - $aArray is not a 1D or 2D array 5 - Start index is greater than the $iUbound parameter

Remarks

If a string path is provided, the file will be overwritten and closed.
To use other write modes, like append or Unicode formats, open the file with FileOpen() first and pass the file handle instead.
If a file handle is passed, the file will still be open after writing.

Related

_FileReadToArray

Example

#include <File.au3>

; List all the files in the current script directory.
Local $aScriptDir = _FileListToArray(@ScriptDir)

; Create a file in the users %TEMP% directory.
Local $sFilePath = @TempDir & "\Examples.txt"

; Write array to a file by passing the file name.
_FileWriteFromArray($sFilePath, $aScriptDir, 1)

; Display the file.
ShellExecute($sFilePath)


Function _FileWriteLog

Function Reference

_FileWriteLog

Writes current date, time and the specified text to a log file

#include <File.au3>
_FileWriteLog ( $sLogPath, $sLogMsg [, $iFlag = -1] )

Parameters

$sLogPath | Path of the file to write to, or a file handle returned from FileOpen().
$sLogMsg | Message to be written to the log file
$iFlag | [optional] Flag that defines if $sLogMsg will be written to the end of file, or to the beginning. If $iFlag = -1 (default) $sLogMsg will be written to the end of file. Otherwise $sLogMsg will be written to beginning of file.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - Error opening specified file 2 - File could not be written to

Example

Example 1

; Open the logfile in write mode.

#include <File.au3>

Local $hFile = FileOpen(@ScriptDir & "\Example.log", 1)

_FileWriteLog($hFile, "Text 1") ; Write to the logfile passing the filehandle returned by FileOpen.
FileClose($hFile) ; Close the filehandle to release the file.

Example 2

; Write to the logfile passing the filepath.

#include <File.au3>

_FileWriteLog(@ScriptDir & "\Example.log", "Text 2")


Function _FileWriteToLine

Function Reference

_FileWriteToLine

Writes text to a specific line in a file

#include <File.au3>
_FileWriteToLine ( $sFilePath, $iLine, $sText [, $bOverWrite = False] )

Parameters

$sFilePath | The file to write to
$iLine | The line number to write to
$sText | The text to write
$bOverWrite | [optional] True - will overwrite the old line False - (default) will not overwrite

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - File has fewer lines than $iLine 2 - File does not exist 3 - Error when opening file 4 - $iLine is invalid 5 - $iOverWrite is invalid 6 - $sText is invalid

Remarks

If _FileWriteToLine() is called with $iOverWrite as 1 and $sText as "", it will delete the line.

Example

#include <File.au3>

; Example: Write to line 3 of c:\temp\test.txt REPLACING line 3
_FileWriteToLine("c:\temp\test.txt", 3, "my replacement for line 3", True)
; Example: Write to line 3 of c:\temp\test.txt NOT REPLACING line 3
_FileWriteToLine("c:\temp\test.txt", 3, "my insertion", False)


Function _PathFull

Function Reference

_PathFull

Creates a path based on the relative path you provide. The newly created absolute path is returned

#include <File.au3>
_PathFull ( $sRelativePath [, $sBasePath = @WorkingDir] )

Parameters

$sRelativePath | The relative path to be created
$sBasePath | [optional] The base path to be used. Default = @WorkingDir

Return Value

Returns a relative path will be built relative to $sBasePath. To bypass this behavior, use an absolute path.

Remarks

UNC paths are supported.
Pass "\" to get the root drive of $sBasePath.
Pass "" or "." to return $sBasePath.

Related

_PathMake, _PathSplit, _WinAPI_GetFullPathName

Example

#include <File.au3>
#include <MsgBoxConstants.au3>

Local $sTestPath = _PathFull(@ScriptDir & "\..\..\test")
MsgBox($MB_SYSTEMMODAL, "", @ScriptDir & @CRLF & $sTestPath)


Function _PathGetRelative

Function Reference

_PathGetRelative

Returns the relative path to a directory

#include <File.au3>
_PathGetRelative ( $sFrom, $sTo )

Parameters

$sFrom | Path to the source directory
$sTo | Path to the destination file or directory

Return Value

Success: | the path to the destination.
Failure: | the destination and sets @error to non-zero.
@error: | 1 - $sFrom equals $sTo 2 - An unexpected error occurred with the dll call or the relative path was an empty string

Remarks

The returned path will not have a trailing "\", even if it is a root drive returned after a failure.

Related

_WinAPI_PathRelativePathTo

Example

#include <File.au3>

Example()

Func Example()
    Local $sFrom, $sTo, $sPath
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir")

    $sFrom = @ScriptDir
    ConsoleWrite("Source Path: " & $sFrom & @CRLF)
    $sTo = $sFile & "\autoit3.exe"
    ConsoleWrite("Dest Path: " & $sTo & @CRLF)
    $sPath = _PathGetRelative($sFrom, $sTo)
    If @error Then
        ConsoleWrite("Error: " & @error & @CRLF)
        ConsoleWrite("Path: " & $sPath & @CRLF)
    Else
        ConsoleWrite("Relative Path: " & $sPath & @CRLF)
        ConsoleWrite("Resolved Path: " & _PathFull($sFrom & "\" & $sPath) & @CRLF)
    EndIf
EndFunc   ;==>Example


Function _PathMake

Function Reference

_PathMake

Creates a path from drive, directory, file name and file extension parts

#include <File.au3>
_PathMake ( $sDrive, $sDir, $sFileName, $sExtension )

Parameters

$sDrive | Drive (Can be UNC). If it's a drive letter, a : is automatically appended
$sDir | Directory. A trailing and preceding slash are added if not found.
$sFileName | The name of the file
$sExtension | The file extension. A period is supplied if not found in the extension

Return Value

Returns the string containing the full path.

Remarks

The path will still be built with what is passed. This doesn't check the validity of the path created, it could contain characters which are invalid on your filesystem.
You may pass "" (an empty string) for any part of the path you do not need in the final output.

Related

_PathFull, _PathSplit

Example

#include <File.au3>
#include <MsgBoxConstants.au3>

; Create a path.
Local $sFilePath = _PathMake("C:", "\Temp", "Boot", "ini")
MsgBox($MB_SYSTEMMODAL, "", $sFilePath)


Function _PathSplit

Function Reference

_PathSplit

Splits a path into the drive, directory, file name and file extension parts. An empty string is set if a part is missing

#include <File.au3>
_PathSplit ( $sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sFileName, ByRef $sExtension )

Parameters

$sFilePath | The path to be split (Can contain a UNC server or drive letter)
$sDrive | String to hold the drive
$sDir | String to hold the directory
$sFileName | String to hold the file name
$sExtension | String to hold the file extension

Return Value

Returns an array with 5 elements:
$aArray[0] = original path
$aArray[1] = drive
$aArray[2] = directory
$aArray[3] = filename
$aArray[4] = extension

Remarks

This function does not take a command line string. It works on paths, not paths with arguments.

Related

_PathFull, _PathMake

Example

#include <Array.au3>
#include <File.au3>

Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = ""
Local $aPathSplit = _PathSplit(@ScriptFullPath, $sDrive, $sDir, $sFileName, $sExtension)
_ArrayDisplay($aPathSplit, "_PathSplit of " & @ScriptFullPath)


Function _ReplaceStringInFile

Function Reference

_ReplaceStringInFile

Replaces substrings in a file

#include <File.au3>
_ReplaceStringInFile ( $sFilePath, $sSearchString, $sReplaceString [, $iCaseSensitive = 0 [, $iOccurance = 1]] )

Parameters

$sFilePath | Full path of file to replace substrings.
$sSearchString | The string to evaluate.
$sReplaceString | The replacement string.
$iCaseSensitive | [optional] Flag to indicate if the operations should be case sensitive. $STR_NOCASESENSE (0) = not case sensitive, using the user's locale (default) $STR_CASESENSE (1) = case sensitive $STR_NOCASESENSEBASIC (2) = not case sensitive, using a basic/faster comparison Constants are defined in StringConstants.au3
$iOccurance | [optional] 0 - Only the first occurrence is replaced or 1 - all occurrences are replaced (default)

Return Value

Success: | the number of occurrences found.
Failure: | -1 and sets the @error flag to non-zero.
@error: | 1 - File is read-only 2 - Unable to open the file 3 - Unable to write to the file

Example

#include <File.au3>
#include <MsgBoxConstants.au3>

Local $sFind = "BEFORE"
Local $sReplace = "AFTER"

Local $sFileName = "C:\_ReplaceStringInFile.test"

Local $iMsg = "Hello Test " & $sFind & " Hello Test" & @CRLF
$iMsg &= "Hello Test" & @CRLF
$iMsg &= @CRLF
$iMsg &= $sFind

FileWrite($sFileName, $iMsg)

MsgBox($MB_SYSTEMMODAL, "BEFORE", $iMsg)

Local $iRetval = _ReplaceStringInFile($sFileName, $sFind, $sReplace)
If $iRetval = -1 Then
    MsgBox($MB_SYSTEMMODAL, "ERROR", "The pattern could not be replaced in file: " & $sFileName & " Error: " & @error)
    Exit
Else
    MsgBox($MB_SYSTEMMODAL, "INFO", "Found " & $iRetval & " occurances of the pattern: " & $sFind & " in the file: " & $sFileName)
EndIf

$iMsg = FileRead($sFileName, 1000)
MsgBox($MB_SYSTEMMODAL, "AFTER", $iMsg)
FileDelete($sFileName)


Function _TempFile

Function Reference

_TempFile

Generate a name for a temporary file. The file is guaranteed not to exist yet

#include <File.au3>
_TempFile ( [$sDirectoryName = @TempDir [, $sFilePrefix = "~" [, $sFileExtension = ".tmp" [, $iRandomLength = 7]]]] )

Parameters

$sDirectoryName | [optional] Name of directory for filename, defaults to the users %TEMP% directory
$sFilePrefix | [optional] Filename prefix, defaults to "~"
$sFileExtension | [optional] File extenstion, defaults to ".tmp"
$iRandomLength | [optional] Number of characters to use to generate a unique name, defaults to 7

Return Value

Returns a Filename of a temporary file which does not exist

Related

_WinAPI_GetTempFileName

Example

#include <File.au3>
#include <MsgBoxConstants.au3>

; Generate a unique filename in @TempDir
Local $sTempFile_1 = _TempFile()

; Generate a unique filename in the @HomeDrive directory and starting with the "prefix" labelled prefix_
Local $sTempFile_2 = _TempFile(@HomeDrive & "\", "prefix_", ".txt", Default) ; Use the Default keyword to use the default parameters

MsgBox($MB_SYSTEMMODAL, "", "Names suitable for temporary file usage: " & @CRLF & @CRLF & _
        "File 1: " & $sTempFile_1 & @CRLF & _
        "File 2: " & $sTempFile_2)


User Defined Functions

FTPEx user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <FTPEx.au3>.

User Defined Function | Description
_FTP_Close | Closes the _FTP_Open or _FTP_Connect session
_FTP_Command | Sends a command to an FTP server
_FTP_Connect | Connects to an FTP server
_FTP_DecodeInternetStatus | Decode a received Internet Status
_FTP_DirCreate | Makes an Directory on an FTP server
_FTP_DirDelete | Delete's an Directory on an FTP server
_FTP_DirGetCurrent | Get Current Directory on an FTP server
_FTP_DirPutContents | Puts an folder on an FTP server. Recursivley if selected
_FTP_DirSetCurrent | Set Current Directory on an FTP server
_FTP_FileClose | Closes the Handle returned by _FTP_FileOpen
_FTP_FileDelete | Delete an file from an FTP server
_FTP_FileGet | Get file from a FTP server
_FTP_FileGetSize | Gets filesize of a file on the FTP server
_FTP_FileOpen | Initiates access to a remote file on an FTP server for reading or writing
_FTP_FilePut | Puts an file on an FTP server
_FTP_FileRead | Reads data from a handle opened by _FTP_FileOpen()
_FTP_FileRename | Renames an file on an FTP server
_FTP_FileTimeLoHiToStr | Converts filetime Loword and Hiword to a string
_FTP_FindFileClose | Delete FindFile Handle
_FTP_FindFileFirst | Find First File on an FTP server
_FTP_FindFileNext | Find Next File on an FTP server
_FTP_GetLastResponseInfo | Retrieves the last error description or server response on the thread calling this function
_FTP_ListToArray | Get Filenames, Directories or Both of current remote directory
_FTP_ListToArray2D | Get Filenames and filesizes of current remote directory
_FTP_ListToArrayEx | Get names, sizes, attributes and times of files/dir of current remote directory
_FTP_Open | Opens an FTP session
_FTP_ProgressDownload | Downloads a file in Binary Mode and shows a Progress window or by Calling a User defined Function
_FTP_ProgressUpload | Uploads a file in Binary Mode and shows a Progress window or by Calling a User defined Function
_FTP_SetStatusCallback | Registers callback function that WinINet functions can call as progress is made during an operation


Function _FTP_Close

Function Reference

_FTP_Close

Closes the _FTP_Open or _FTP_Connect session

#include <FTPEx.au3>
_FTP_Close ( $hSession )

Parameters

$hSession as returned by _FTP_Open() or _FTP_Connect()

Return Value

Success: | 1
Failure: | 0

Related

_FTP_Connect, _FTP_Open

See Also

Search InternetCloseHandle in MSDN Library.

Example

#include <FTPEx.au3>

Local $hOpen = _FTP_Open('MyFTP Control')
; ...
Local $iFtpc = _FTP_Close($hOpen)


Function _FTP_Command

Function Reference

_FTP_Command

Sends a command to an FTP server

#include <FTPEx.au3>
_FTP_Command ( $hFTPSession, $sFTPCommand [, $iFlags = $FTP_TRANSFER_TYPE_ASCII [, $iExpectResponse = 0 [, $iContext = 0]]] )

Parameters

$hFTPSession | as returned by _FTP_Connect()
$sFTPCommand | Command string to send to FTP Server
$iFlags | [optional] $FTP_TRANSFER_TYPE_ASCII or $FTP_TRANSFER_TYPE_BINARY
$iExpectResponse | [optional] Data socket for response in Async mode. See remarks.
$iContext | [optional] A variable that contains the application-defined value that associates this search with any application data. This is only used if the application has already called _FTP_SetStatusCallback() to set up a status callback function.

Return Value

Success: | an identifier.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

Command Examples: depends on server syntax/
The following is for Binary transfer, ASCII transfer, Passive transfer mode (used with firewalls) 'type I' 'type A' 'pasv'

If $iExpectResponse is set to True, a pointer to a handle that is created if a valid data socket is opened is returned in @extended.

Related

_FTP_Connect, _FTP_SetStatusCallback

See Also

Search FtpCommand in MSDN Library.


Function _FTP_Connect

Function Reference

_FTP_Connect

Connects to an FTP server

#include <FTPEx.au3>
_FTP_Connect ( $hInternetSession, $sServerName, $sUsername, $sPassword [, $iPassive = 0 [, $iServerPort = 0 [, $iService = $INTERNET_SERVICE_FTP [, $iFlags = 0 [, $fuContext = 0]]]]] )

Parameters

$hInternetSession | as returned by _FTP_Open()
$sServerName | Server name/ip.
$sUsername | Username.
$sPassword | Password.
$iPassive | [optional] Passive mode.
$iServerPort | [optional] Server port ( 0 is default (21) )
$iService | [optional] This can be one of the following constant values: $INTERNET_SERVICE_FTP - FTP service. $INTERNET_SERVICE_GOPHER - Gopher service. Available only on Windows XP, Windows Server 2003 R2 or earlier. $INTERNET_SERVICE_HTTP - HTTP service.
$iFlags | [optional] Special flags. $INTERNET_FLAG_PASSIVE $INTERNET_FLAG_TRANSFER_ASCII $INTERNET_FLAG_TRANSFER_BINARY
$fuContext | [optional] A variable that contains the application-defined value that associates this search with any application data. This is only used if the application has already called _FTP_SetStatusCallback() to set up a status callback function.

Return Value

Success: | an handle to connected session.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

The return handle must be closed with _FTP_Close().

Related

_FTP_Close, _FTP_Command, _FTP_DirCreate, _FTP_DirDelete, _FTP_DirGetCurrent, _FTP_DirPutContents, _FTP_DirSetCurrent, _FTP_FileDelete, _FTP_FileGet, _FTP_FileGetSize, _FTP_FilePut, _FTP_FileRename, _FTP_ListToArray, _FTP_ListToArray2D, _FTP_ListToArrayEx, _FTP_Open, _FTP_SetStatusCallback

See Also

Search InternetConnect in MSDN Library.

Example

#include <FTPEx.au3>
#include <MsgBoxConstants.au3>

Local $sServer = 'ftp.csx.cam.ac.uk' ; UNIVERSITY OF CAMBRIDGE ANONYMOUS FTP SERVER
Local $sUsername = ''
Local $sPass = ''

Local $hOpen = _FTP_Open('MyFTP Control')
Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)
If @error Then
    MsgBox($MB_SYSTEMMODAL, '_FTP_Connect', 'ERROR=' & @error)
Else
    ; do something ...
EndIf
Local $iFtpc = _FTP_Close($hConn)
Local $iFtpo = _FTP_Close($hOpen)


Function _FTP_DecodeInternetStatus

Function Reference

_FTP_DecodeInternetStatus

Decode a received Internet Status

#include <FTPEx.au3>
_FTP_DecodeInternetStatus ( $iInternetStatus )

Parameters

$iInternetStatus Internet status

Return Value

Returns a string.

Related

_FTP_SetStatusCallback

Example

#include <Debug.au3>
#include <FTPEx.au3>

_DebugSetup(StringTrimRight(@ScriptName, StringLen(".exe")) & ' example', True)

Local $sServer = 'ftp.mozilla.org'
Local $sUsername = ''
Local $sPass = ''

Local $hOpen = _FTP_Open('MyFTP Control')
Local $pCallback = _FTP_SetStatusCallback($hOpen, 'FTPStatusCallbackHandler')

Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass, 0, $INTERNET_DEFAULT_FTP_PORT, $INTERNET_SERVICE_FTP, 0, $pCallback)

Local $iFtpc = _FTP_Close($hConn)
Local $iFtpo = _FTP_Close($hOpen)

Func FTPStatusCallbackHandler($hInternet, $iContext, $iInternetStatus, $pStatusInformation, $iStatusInformationLength)
    #forceref $hInternet, $iContext
    If $iInternetStatus = $INTERNET_STATUS_REQUEST_SENT Or $iInternetStatus = $INTERNET_STATUS_RESPONSE_RECEIVED Then
        Local $iBytesRead
        Local $tStatus = DllStructCreate('dword')
        _WinAPI_ReadProcessMemory(_WinAPI_GetCurrentProcess(), $pStatusInformation, $tStatus, $iStatusInformationLength, $iBytesRead)
        _DebugOut(_FTP_DecodeInternetStatus($iInternetStatus) & ' | Size = ' & DllStructGetData($tStatus, 1) & ' Bytes    Bytes read = ' & $iBytesRead)
    Else
        _DebugOut(_FTP_DecodeInternetStatus($iInternetStatus))
    EndIf
EndFunc   ;==>FTPStatusCallbackHandler


Function _FTP_DirCreate

Function Reference

_FTP_DirCreate

Makes an Directory on an FTP server

#include <FTPEx.au3>
_FTP_DirCreate ( $hFTPSession, $sRemote )

Parameters

$hFTPSession | as returned by _FTP_Connect().
$sRemote | The Directory to Create.

Return Value

Success: | 1.
Failure: | 0.

Related

_FTP_Connect

See Also

Search FtpCreateDirectory in MSDN Library.


Function _FTP_DirDelete

Function Reference

_FTP_DirDelete

Delete's an Directory on an FTP server

#include <FTPEx.au3>
_FTP_DirDelete ( $hFTPSession, $sRemote )

Parameters

$hFTPSession | as returned by _FTP_Connect().
$sRemote | The Directory to deleted.

Return Value

Success: | 1.
Failure: | 0.

Related

_FTP_Connect

See Also

Search FtpRemoveDirectory in MSDN Library.


Function _FTP_DirGetCurrent

Function Reference

_FTP_DirGetCurrent

Get Current Directory on an FTP server

#include <FTPEx.au3>
_FTP_DirGetCurrent ( $hFTPSession )

Parameters

$hFTPSession as returned by _FTP_Connect().

Return Value

Success: | the directory name.
Failure: | 0 and sets the @error flag to non-zero.

Related

_FTP_Connect

See Also

Search FtpGetCurrentDirectory in MSDN Library.


Function _FTP_DirPutContents

Function Reference

_FTP_DirPutContents

Puts an folder on an FTP server. Recursivley if selected

#include <FTPEx.au3>
_FTP_DirPutContents ( $hFTPSession, $sLocalFolder, $sRemoteFolder, $bRecursivePut [, $iContext = 0] )

Parameters

$hFTPSession | as returned by _FTP_Connect().
$sLocalFolder | The local folder i.e. "c:\temp".
$sRemoteFolder | The remote folder i.e. '/website/home'.
$bRecursivePut | Recurse through sub-dirs. 0=Non recursive, 1=Recursive
$iContext | [optional] A variable that contains the application-defined value that associates this search with any application data. This is only used if the application has already called _FTP_SetStatusCallback() to set up a status callback function.

Return Value

Success: | the directory name.
Failure: | 0 and sets the @error flag to non-zero.

Related

_FTP_Connect, _FTP_SetStatusCallback


Function _FTP_DirSetCurrent

Function Reference

_FTP_DirSetCurrent

Set Current Directory on an FTP server

#include <FTPEx.au3>
_FTP_DirSetCurrent ( $hFTPSession, $sRemote )

Parameters

$hFTPSession | as returned by _FTP_Connect().
$sRemote | The Directory to be set.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Related

_FTP_Connect

See Also

Search FtpSetCurrentDirectory in MSDN Library.


Function _FTP_FileClose

Function Reference

_FTP_FileClose

Closes the Handle returned by _FTP_FileOpen

#include <FTPEx.au3>
_FTP_FileClose ( $hFTPFile )

Parameters

$hFTPFile as returned by _FTP_FileOpen()

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Related

_FTP_FileOpen

See Also

Search InternetCloseHandle in MSDN Library.


Function _FTP_FileDelete

Function Reference

_FTP_FileDelete

Delete an file from an FTP server

#include <FTPEx.au3>
_FTP_FileDelete ( $hFTPSession, $sRemoteFile )

Parameters

$hFTPSession | as returned by _FTP_Connect()
$sRemoteFile | The remote Location for the file.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Related

_FTP_Connect

See Also

Search FtpDeleteFile in MSDN Library.


Function _FTP_FileGet

Function Reference

_FTP_FileGet

Get file from a FTP server

#include <FTPEx.au3>
_FTP_FileGet ( $hFTPSession, $sRemoteFile, $sLocalFile [, $bFailIfExists = False [, $iFlagsAndAttributes = 0 [, $iFlags = $FTP_TRANSFER_TYPE_UNKNOWN [, $iContext = 0]]]] )

Parameters

$hFTPSession | as returned by _FTP_Connect()
$sRemoteFile | The remote Location for the file.
$sLocalFile | The local file.
$bFailIfExists | [optional] True: do not overwrite existing (default = False).
$iFlagsAndAttributes | [optional] File attributes for the new file.
$iFlags | [optional] as in _FTP_FileOpen().
$iContext | [optional] A variable that contains the application-defined value that associates this search with any application data. This is only used if the application has already called _FTP_SetStatusCallback() to set up a status callback function.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Related

_FTP_Connect, _FTP_FileOpen, _FTP_SetStatusCallback

See Also

Search FtpGetFile in MSDN Library.


Function _FTP_FileGetSize

Function Reference

_FTP_FileGetSize

Gets filesize of a file on the FTP server

#include <FTPEx.au3>
_FTP_FileGetSize ( $hFTPSession, $sFileName )

Parameters

$hFTPSession | as returned by _FTP_Connect().
$sFileName | The file name.

Return Value

Success: | the filesize as an uint64.
Failure: | sets the @error flag to non-zero.

Related

_FTP_Connect

See Also

Search FtpGetFileSize in MSDN Library.

Example

#include <FTPEx.au3>

Local $sServer = 'ftp.csx.cam.ac.uk'
Local $sUsername = ''
Local $sPass = ''

Local $hOpen = _FTP_Open('MyFTP Control')
Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)

Local $h_Handle
Local $aFile = _FTP_FindFileFirst($hConn, "/pub/software/programming/pcre/", $h_Handle)
ConsoleWrite('$sFileName = ' & $aFile[10] & ' attribute = ' & $aFile[1] & '  -> Error code: ' & @error & ' extended: ' & @extended & @CRLF)

Local $sDirset = _FTP_DirSetCurrent($hConn, "/pub/software/programming/pcre/")
ConsoleWrite('$sDirset = ' & $sDirset & '  -> Error code: ' & @error & ' extended: ' & @extended & @CRLF)

Local $iFileSize = _FTP_FileGetSize($hConn, $aFile[10])
ConsoleWrite('$sFileName = ' & $aFile[10] & ' size = ' & $iFileSize & '  -> Error code: ' & @error & ' extended: ' & @extended & @CRLF)

Local $iErr, $sMessage
$iFileSize = _FTP_GetLastResponseInfo($iErr, $sMessage) ; error =  Contrib: Not a regular file
ConsoleWrite('$sMessage = ' & $sMessage & ' err = ' & $iErr & '  -> Error code: ' & @error & ' extended: ' & @extended & @CRLF)

$aFile = _FTP_FindFileNext($h_Handle)
ConsoleWrite('$sFilenameNext1 = ' & $aFile[10] & ' attribute = ' & $aFile[1] & '  -> Error code: ' & @error & ' extended: ' & @extended & @CRLF)

$iFileSize = _FTP_FileGetSize($hConn, $aFile[10])
ConsoleWrite('$sFilenameNext1 = ' & $aFile[10] & ' size = ' & $iFileSize & '  -> Error code: ' & @error & ' extended: ' & @extended & @CRLF)

$iFileSize = _FTP_GetLastResponseInfo($iErr, $sMessage) ; no error
ConsoleWrite('$sMessage = ' & $sMessage & ' err = ' & $iErr & '  -> Error code: ' & @error & ' extended: ' & @extended & @CRLF)

Local $iFindClose = _FTP_FindFileClose($h_Handle)

Local $iFtpc = _FTP_Close($hConn)
Local $iFtpo = _FTP_Close($hOpen)


Function _FTP_FileOpen

Function Reference

_FTP_FileOpen

Initiates access to a remote file on an FTP server for reading or writing

#include <FTPEx.au3>
_FTP_FileOpen ( $hConnect, $sFileName [, $iAccess = $GENERIC_READ [, $iFlags = $INTERNET_FLAG_TRANSFER_BINARY [, $iContext = 0]]] )

Parameters

$hConnect | as returned by _FTP_Connect().
$sFileName | String of the ftp file to open.
$iAccess | [optional] The Local attribute (default $GENERIC_READ).
$iFlags [optional] Specify the conditions under which the transfers occur. The application should select one transfer type and any of the flags that indicate how the caching of the file will be controlled.

The transfer type can be one of the following values:
$FTP_TRANSFER_TYPE_ASCII - Transfers the file using FTP's ASCII (Type A) transfer method. Control and formatting information is converted to local equivalents.
$FTP_TRANSFER_TYPE_BINARY - Transfers the file using FTP's Image (Type I) transfer method. The file is transferred exactly as it exists with no changes. This is the default transfer method.
$FTP_TRANSFER_TYPE_UNKNOWN - Defaults to $FTP_TRANSFER_TYPE_BINARY.
$INTERNET_FLAG_TRANSFER_ASCII - Transfers the file as ASCII.
$INTERNET_FLAG_TRANSFER_BINARY - Transfers the file as binary.

The following values are used to control the caching of the file. The application can use one or more of these values:
$INTERNET_FLAG_HYPERLINK - Forces a reload if there was no Expires time and no LastModified time returned from the server when determining whether to reload the item from the network.
$INTERNET_FLAG_NEED_FILE - Causes a temporary file to be created if the file cannot be cached.
$INTERNET_FLAG_RELOAD - Forces a download of the requested file, object, or directory listing from the origin server, not from the cache.
$INTERNET_FLAG_RESYNCHRONIZE - Reloads HTTP resources if the resource has been modified since the last time it was downloaded. All FTP and Gopher resources are reloaded.
$iContext [optional] A variable that contains the application-defined value that associates this search with any application data.
This is only used if the application has already called _FTP_SetStatusCallback() to set up a status callback function.

Return Value

Success: | the handle to ftp file for read/write with _FTP_FileRead().
Failure: | 0 and sets the @error flag to non-zero.

Related

_FTP_FileClose, _FTP_FileGet, _FTP_FilePut, _FTP_FileRead, _FTP_SetStatusCallback

See Also

Search FtpOpenFile in MSDN Library.


Function _FTP_FilePut

Function Reference

_FTP_FilePut

Puts an file on an FTP server

#include <FTPEx.au3>
_FTP_FilePut ( $hFTPSession, $sLocalFile, $sRemoteFile [, $iFlags = 0 [, $iContext = 0]] )

Parameters

$hFTPSession | as returned by _FTP_Connect()
$sLocalFile | The local file.
$sRemoteFile | The remote Location for the file.
$iFlags [optional] Specify the conditions under which the transfers occur. The application should select one transfer type and any of the flags that indicate how the caching of the file will be controlled.

The transfer type can be one of the following values:
$FTP_TRANSFER_TYPE_ASCII - Transfers the file using FTP's ASCII (Type A) transfer method. Control and formatting information is converted to local equivalents.
$FTP_TRANSFER_TYPE_BINARY - Transfers the file using FTP's Image (Type I) transfer method. The file is transferred exactly as it exists with no changes. This is the default transfer method.
$FTP_TRANSFER_TYPE_UNKNOWN - Defaults to $FTP_TRANSFER_TYPE_BINARY.
$INTERNET_FLAG_TRANSFER_ASCII - Transfers the file as ASCII.
$INTERNET_FLAG_TRANSFER_BINARY - Transfers the file as binary.

The following values are used to control the caching of the file. The application can use one or more of these values:
$INTERNET_FLAG_HYPERLINK - Forces a reload if there was no Expires time and no LastModified time returned from the server when determining whether to reload the item from the network.
$INTERNET_FLAG_NEED_FILE - Causes a temporary file to be created if the file cannot be cached.
$INTERNET_FLAG_RELOAD - Forces a download of the requested file, object, or directory listing from the origin server, not from the cache.
$INTERNET_FLAG_RESYNCHRONIZE - Reloads HTTP resources if the resource has been modified since the last time it was downloaded. All FTP and Gopher resources are reloaded.
$iContext [optional] A variable that contains the application-defined value that associates this search with any application data.
This is only used if the application has already called _FTP_SetStatusCallback() to set up a status callback function.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

Both $sLocalFile and $sRemoteFile may be partial or fully qualified names relative to the current directory.

Related

_FTP_Connect, _FTP_FileOpen, _FTP_SetStatusCallback

See Also

Search FtpPutFile in MSDN Library.


Function _FTP_FileRead

Function Reference

_FTP_FileRead

Reads data from a handle opened by _FTP_FileOpen()

#include <FTPEx.au3>
_FTP_FileRead ( $hFTPFile, $iNumberOfBytesToRead )

Parameters

$hFTPFile | Handle returned by _FTP_FileOpen() to the ftp file.
$iNumberOfBytesToRead | Number of bytes to read.

Return Value

Success: | the binary/string read.
Failure: | 0 and sets the @error flag to non-zero.
@error: | -1 for end-of-file Non-zero for other errors.

Related

_FTP_FileOpen

See Also

Search InternetReadFile in MSDN Library.


Function _FTP_FileRename

Function Reference

_FTP_FileRename

Renames an file on an FTP server

#include <FTPEx.au3>
_FTP_FileRename ( $hFTPSession, $sExisting, $sNew )

Parameters

$hFTPSession | as returned by _FTP_Connect().
$sExisting | The old file name.
$sNew | The new file name.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Related

_FTP_Connect

See Also

Search FtpRenameFile in MSDN Library.


Function _FTP_FileTimeLoHiToStr

Function Reference

_FTP_FileTimeLoHiToStr

Converts filetime Loword and Hiword to a string

#include <FTPEx.au3>
_FTP_FileTimeLoHiToStr ( $iLoDWORD, $iHiDWORD [, $bFmt = 0] )

Parameters

$iLoDWORD | FileTime Low
$iHiDWORD | File Time Hi
$bFmt | [optional] 0 returns mm/dd/yyyy hh:mm:ss (Default) 1 returns yyyy/mm/dd hh:mm:ss

Return Value

Success: | a datetime according to $bFmt.
Failure: | an empty string.


Function _FTP_FindFileClose

Function Reference

_FTP_FindFileClose

Delete FindFile Handle

#include <FTPEx.au3>
_FTP_FindFileClose ( $hFTPFind )

Parameters

$hFTPFind as returned by _FTP_FindFileFirst()

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Related

_FTP_FindFileFirst, _FTP_FindFileNext

See Also

Search InternetCloseHandle in MSDN Library.

Example

#include <FTPEx.au3>

Local $sServer = 'ftp.csx.cam.ac.uk'
Local $sUsername = ''
Local $sPass = ''

Local $hOpen = _FTP_Open('MyFTP Control')
Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)

Local $h_Handle
Local $aFile = _FTP_FindFileFirst($hConn, "/pub/software/programming/pcre/", $h_Handle)

Local $iFindClose = _FTP_FindFileClose($h_Handle)
ConsoleWrite('$iFindClose = ' & $iFindClose & '  -> Error code: ' & @error & @CRLF)

Local $iFtpc = _FTP_Close($hConn)
Local $iFtpo = _FTP_Close($hOpen)


Function _FTP_FindFileFirst

Function Reference

_FTP_FindFileFirst

Find First File on an FTP server

#include <FTPEx.au3>
_FTP_FindFileFirst ( $hFTPSession, $sRemotePath, ByRef $hFTPFind [, $iFlags = 0 [, $iContext = 0]] )

Parameters

$hFTPSession | as returned by _FTP_Connect().
$sRemotePath | path to be used when searching the file.
$hFTPFind | returns Handle to be used in _FTP_FindFileNext() or _FTP_FindFileClose().
$iFlags | [optional] $iFlags can be a combination of : $INTERNET_FLAG_HYPERLINK $INTERNET_FLAG_NEED_FILE $INTERNET_FLAG_NO_CACHE_WRITE $INTERNET_FLAG_RELOAD $INTERNET_FLAG_RESYNCHRONIZE
$iContext | [optional] A variable that contains the application-defined value that associates this search with any application data. This is only used if the application has already called _FTP_SetStatusCallback() to set up a status callback function.

Return Value

Success: | an array: [0] - Number of elements [1] - File Attributes [2] - Creation Time Low [3] - Creation Time Hi [4] - Access Time Low [5] - Access Time Hi [6] - Last Write Low [7] - Last Write Hi [8] - File Size High [9] - File Size Low [10] - File Name [11] - Altername
Failure: | 0 and sets the @error flag to non-zero.

Related

_FTP_FindFileClose, _FTP_FindFileNext, _FTP_SetStatusCallback

See Also

Search FtpFindFirstFile in MSDN Library.

Example

#include <FTPEx.au3>

Local $sServer = 'ftp.csx.cam.ac.uk'
Local $sUsername = ''
Local $sPass = ''

Local $hOpen = _FTP_Open('MyFTP Control')
Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)

Local $h_Handle
Local $aFile = _FTP_FindFileFirst($hConn, "/pub/software/programming/pcre/", $h_Handle)
ConsoleWrite('$sFileName = ' & $aFile[10] & ' attribute = ' & $aFile[1] & '  -> Error code: ' & @error & @CRLF)

Local $iFindClose = _FTP_FindFileClose($h_Handle)

Local $iFtpc = _FTP_Close($hConn)
Local $iFtpo = _FTP_Close($hOpen)


Function _FTP_FindFileNext

Function Reference

_FTP_FindFileNext

Find Next File on an FTP server

#include <FTPEx.au3>
_FTP_FindFileNext ( $hFTPFind )

Parameters

$hFTPFind Handle as returned by _FTP_FindFileFirst().

Return Value

Success: | an array: [0] - Number of elements [1] - File Attributes [2] - Creation Time Low [3] - Creation Time Hi [4] - Access Time Low [5] - Access Time Hi [6] - Last Write Low [7] - Last Write Hi [8] - File Size High [9] - File Size Low [10] - File Name [11] - Altername
Failure: | 0 and sets the @error flag to non-zero.

Related

_FTP_FindFileClose, _FTP_FindFileFirst

See Also

Search InternetFindNextFile in MSDN Library.

Example

#include <FTPEx.au3>

Local $sServer = 'ftp.csx.cam.ac.uk'
Local $sUsername = ''
Local $sPass = ''

Local $hOpen = _FTP_Open('MyFTP Control')
Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)

Local $h_Handle
Local $aFile = _FTP_FindFileFirst($hConn, "/pub/software/programming/pcre/", $h_Handle)
ConsoleWrite('$sFileName = ' & $aFile[10] & ' attribute = ' & $aFile[1] & '  -> Error code: ' & @error & @CRLF)

$aFile = _FTP_FindFileNext($h_Handle)
ConsoleWrite('$sFilenameNext1 = ' & $aFile[10] & ' attribute = ' & $aFile[1] & '  -> Error code: ' & @error & @CRLF)

$aFile = _FTP_FindFileNext($h_Handle)
ConsoleWrite('$sFilenameNext2 = ' & $aFile[10] & ' attribute = ' & $aFile[1] & '  -> Error code: ' & @error & @CRLF)

$aFile = _FTP_FindFileNext($h_Handle)
ConsoleWrite('$sFilenameNext3 = ' & $aFile[10] & ' attribute = ' & $aFile[1] & '  -> Error code: ' & @error & @CRLF)

Local $iFindClose = _FTP_FindFileClose($h_Handle)

Local $iFtpc = _FTP_Close($hConn)
Local $iFtpo = _FTP_Close($hOpen)


Function _FTP_GetLastResponseInfo

Function Reference

_FTP_GetLastResponseInfo

Retrieves the last error description or server response on the thread calling this function

#include <FTPEx.au3>
_FTP_GetLastResponseInfo ( ByRef $iError, ByRef $sMessage )

Parameters

$iError | returns an error message pertaining to the operation that failed.
$sMessage | returns the error text.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

See Also

Search InternetGetLastResponseInfo in MSDN Library.


Function _FTP_ListToArray

Function Reference

_FTP_ListToArray

Get Filenames, Directories or Both of current remote directory

#include <FTPEx.au3>
_FTP_ListToArray ( $hFTPSession [, $iReturnType = 0 [, $iFlags = $INTERNET_FLAG_NO_CACHE_WRITE [, $iContext = 0]]] )

Parameters

$hFTPSession | as returned by _FTP_Connect().
$iReturntype | [optional] 0 = Both Files and Directories, 1 = Directories, 2 = Files.
$iFlags | [optional] default = $INTERNET_FLAG_NO_CACHE_WRITE. See _FTP_FindFileFirst().
$iContext | [optional] A variable that contains the application-defined value that associates this search with any application data. This is only used if the application has already called _FTP_SetStatusCallback() to set up a status callback function.

Return Value

Success: | an array containing the names. $Array[0] contain the number of found entries.
Failure: | $Array[0] = 0

Related

_FTP_Connect, _FTP_SetStatusCallback

Example

#include <FTPEx.au3>

Local $sServer = 'ftp.csx.cam.ac.uk'
Local $sUsername = ''
Local $sPass = ''

Local $hOpen = _FTP_Open('MyFTP Control')
Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)

Local $aFile = _FTP_ListToArray($hConn, 2)
ConsoleWrite('$NbFound = ' & $aFile[0] & '  -> Error code: ' & @error & @CRLF)
ConsoleWrite('$sFileName = ' & $aFile[1] & @CRLF)

Local $iFtpc = _FTP_Close($hConn)
Local $iFtpo = _FTP_Close($hOpen)


Function _FTP_ListToArray2D

Function Reference

_FTP_ListToArray2D

Get Filenames and filesizes of current remote directory

#include <FTPEx.au3>
_FTP_ListToArray2D ( $hFTPSession [, $iReturnType = 0 [, $iFlags = $INTERNET_FLAG_NO_CACHE_WRITE [, $iContext = 0]]] )

Parameters

$hFTPSession | as returned by _FTP_Connect().
$iReturntype | [optional] 0 = Both Files and Directories, 1 = Directories, 2 = Files.
$iFlags | [optional] default = $INTERNET_FLAG_NO_CACHE_WRITE. See _FTP_FindFileFirst().
$iContext | [optional] A variable that contains the application-defined value that associates this search with any application data. This is only used if the application has already called _FTP_SetStatusCallback() to set up a status callback function.

Return Value

Success: | a 2D array with names and size: $Array[0][0] = number of found entries ... $Array[n][0] Filename $Array[n][1] Filesize
Failure: | $Array[0][0] = 0

Related

_FTP_Connect, _FTP_SetStatusCallback

Example

#include <FTPEx.au3>

Local $sServer = 'ftp.csx.cam.ac.uk'
Local $sUsername = ''
Local $sPass = ''

Local $hOpen = _FTP_Open('MyFTP Control')
Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)

Local $aFile = _FTP_ListToArray2D($hConn, 0)
ConsoleWrite('$sFileName = ' & $aFile[0][0] & '  -> Error code: ' & @error & @CRLF)
ConsoleWrite('$sFileName = ' & $aFile[1][0] & ' size = ' & $aFile[1][1] & @error & @CRLF)
ConsoleWrite('$sFileName = ' & $aFile[2][0] & ' size = ' & $aFile[2][1] & @CRLF)

Local $iFtpc = _FTP_Close($hConn)
Local $iFtpo = _FTP_Close($hOpen)


Function _FTP_ListToArrayEx

Function Reference

_FTP_ListToArrayEx

Get names, sizes, attributes and times of files/dir of current remote directory

#include <FTPEx.au3>
_FTP_ListToArrayEx ( $hFTPSession [, $iReturnType = 0 [, $iFlags = $INTERNET_FLAG_NO_CACHE_WRITE [, $iFmt = 1 [, $iContext = 0]]]] )

Parameters

$hFTPSession | as returned by _FTP_Connect().
$iReturntype | [optional] 0 = Both Files and Directories, 1 = Directories, 2 = Files.
$iFlags | [optional] default = $INTERNET_FLAG_NO_CACHE_WRITE. See _FTP_FindFileFirst().
$iFmt | [optional] type on the date strings: 1 = yyyy/mm/dd 0 = mm/dd/yyyy
$iContext | [optional] A variable that contains the application-defined value that associates this search with any application data. This is only used if the application has already called _FTP_SetStatusCallback() to set up a status callback function.

Return Value

Success: | a 2D Array: $Array[0][0] = number of found entries ... $Array[n][0] Filename $Array[n][1] Filesize $Array[n][2] FileAttribute $Array[n][3] File Modification datetime $Array[n][4] File Creation datetime $Array[n][5] File Access datetime
Failure: | $Array[0][0] = 0.

Related

_FTP_Connect, _FTP_SetStatusCallback

Example

#include <Array.au3>
#include <FTPEx.au3>
#include <MsgBoxConstants.au3>

Local $sServer = 'ftp.csx.cam.ac.uk1'
Local $sUsername = ''
Local $sPass = ''

Local $hOpen = _FTP_Open('MyFTP Control', 0)
If Not @error Then
    ; passive allows most protected FTPs to answer
    Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)
    If Not @error Then
        Local $aFile = _FTP_ListToArrayEx($hConn, 0)
        If Not @error Then
            _ArrayDisplay($aFile)
        Else
            MsgBox($MB_SYSTEMMODAL, "Error", '_FTP_ListToArrayEx($Conn, 0)' & @CRLF & _
                    '@error = ' & @error & ' @extended = ' & @extended)
        EndIf
        Local $iFtpc = _FTP_Close($hConn)
    Else
        MsgBox($MB_SYSTEMMODAL, "Error", '_FTP_Connect($Open, ' & $sServer & ', ' & $sUsername & ', ' & $sPass & ')' & @CRLF & _
                '@error = ' & @error & ' @extended = ' & @extended)
    EndIf

    Local $iFtpo = _FTP_Close($hOpen)
Else
    MsgBox($MB_SYSTEMMODAL, "Error", "_FTP_Open('MyFTP Control')" & @CRLF & _
            '@error = ' & @error & ' @extended = ' & @extended)
EndIf


Function _FTP_Open

Function Reference

_FTP_Open

Opens an FTP session

#include <FTPEx.au3>
_FTP_Open ( $sAgent [, $iAccessType = $INTERNET_OPEN_TYPE_DIRECT [, $sProxyName = '' [, $sProxyBypass = '' [, $iFlags = 0]]]] )

Parameters

$sAgent | Random name. ( like "myftp" )
$iAccessType | [optional] Set if proxy is used: $INTERNET_OPEN_TYPE_DIRECT -> no proxy (Default) $INTERNET_OPEN_TYPE_PRECONFIG -> Retrieves the proxy or direct configuration from the registry. $INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY -> Retrieves the proxy or direct configuration from the registry and prevents the use of a startup Microsoft JScript or Internet Setup (INS) file. $INTERNET_OPEN_TYPE_PROXY -> Passes requests to the proxy unless a proxy bypass list is supplied and the name to be resolved bypasses the proxy. Then no proxy is used.
$sProxyName | [optional] ProxyName.
$sProxyBypass | [optional] ProxyByPasses's.
$iFlags | [optional] $INTERNET_FLAG_ASYNC -> Makes only asynchronous requests on handles descended from the handle returned from this function. $INTERNET_FLAG_FROM_CACHE -> Does not make network requests. All entities are returned from the cache. If the requested item is not in the cache, a suitable error, such as ERROR_FILE_NOT_FOUND, is returned.

Return Value

Success: | a handle to internet session to be used in _FTP_Connect().
Failure: | 0 and sets the @error flag to non-zero.

Related

_FTP_Close, _FTP_Connect, _FTP_SetStatusCallback

See Also

Search InternetOpen in MSDN Library.

Example

#include <FTPEx.au3>

Local $hOpen = _FTP_Open('MyFTP Control')
; ...
Local $iFtpc = _FTP_Close($hOpen)


Function _FTP_ProgressDownload

Function Reference

_FTP_ProgressDownload

Downloads a file in Binary Mode and shows a Progress window or by Calling a User defined Function

#include <FTPEx.au3>
_FTP_ProgressDownload ( $hFTPSession, $sLocalFile, $sRemoteFile [, $hFunctionToCall = 0] )

Parameters

$hFTPSession | as returned by _FTP_Connect().
$sLocalFile | The local file to create.
$sRemoteFile | The remote source file.
$hFunctionToCall | [optional] A variable assigned to the user defined function to update a progress bar or react on user interation, such as aborting or exiting the process. Default = none. See remarks.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | -1 - Local file couldn't be created -2 - Unable to get RemoteFile size -3 - Open RemoteFile failed -4 - Read from Remotefile failed -5 - Close RemoteFile failed -6 - Download aborted by PercentageFunc and Return of Called Function -7 - Local file write failed

Remarks

Information about $hFunctionToCall:
Parameter: $iPercentage - The Percentage of Progress
Return Values:
Continue Download - 1
Abort Download - zero or less than zero e.g. 0 or -1
These Return Values are returned by _FTP_ProgressUpload(), too, so you can react on different Actions like Aborting by User, closing App or TimeOut of the process.

Example

Example 1

#include <FTPEx.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <ProgressConstants.au3>

Global $g_sRemoteFile = "/pub/software/databases/rt/SRPMS/ucs-local-modperl-2.0.3-1.src.rpm"
Global $g_sLocalFile = @TempDir & "\temp.tmp"
FileDelete($g_sLocalFile)

Local $sServer = 'ftp.csx.cam.ac.uk'
Local $sUsername = ''
Local $sPass = ''

Local $hInternetSession = _FTP_Open('MyFTP Control')
; passive allows most protected FTPs to answer
Local $hFTPSession = _FTP_Connect($hInternetSession, $sServer, $sUsername, $sPass, 1)

Example()

_FTP_Close($hInternetSession)

Func Example()
    Local $fuFunctionToCall = _UpdateProgress
    ProgressOn("Download Progress", $g_sRemoteFile)
    _FTP_ProgressDownload($hFTPSession, $g_sLocalFile, $g_sRemoteFile, $fuFunctionToCall)
    ProgressOff()
EndFunc   ;==>Example

Func _UpdateProgress($iPercent)
    ProgressSet($iPercent, Int($iPercent) & "%")
    If _IsPressed("77") Then Return 0 ; Abort on F8
    Return 1 ; 1 to continue Download
EndFunc   ;==>_UpdateProgress

Example 2

#include <FTPEx.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <ProgressConstants.au3>

Global $g_sRemoteFile = "/pub/software/databases/rt/SRPMS/ucs-local-modperl-2.0.3-1.src.rpm"
Global $g_sLocalFile = @TempDir & "\temp.tmp"
FileDelete($g_sLocalFile)

Local $sServer = 'ftp.csx.cam.ac.uk'
Local $sUsername = ''
Local $sPass = ''

Local $hInternetSession = _FTP_Open('MyFTP Control')
; passive allows most protected FTPs to answer
Local $hFTPSession = _FTP_Connect($hInternetSession, $sServer, $sUsername, $sPass, 1)

Global $g_idProgressBarCtrl, $g_idBtn_Cancel
Example()

_FTP_Close($hInternetSession)

Func Example()
    ; create GUI
    GUICreate("My GUI download Progressbar", 220, 100, 100, 200)
    GUICtrlCreateLabel($g_sRemoteFile, 10, 10)
    $g_idProgressBarCtrl = GUICtrlCreateProgress(10, 40, 200, 20, $PBS_SMOOTH)
    GUICtrlSetColor(-1, 32250); not working with Windows XP Style
    $g_idBtn_Cancel = GUICtrlCreateButton("Cancel", 75, 70, 70, 20)
    GUISetState(@SW_SHOW)

    Local $fuFunctionToCall = _UpdateGUIProgressBar
    _FTP_ProgressDownload($hFTPSession, $g_sLocalFile, $g_sRemoteFile, $fuFunctionToCall)
EndFunc   ;==>Example

Func _UpdateGUIProgressBar($iPercent)
    GUICtrlSetData($g_idProgressBarCtrl, $iPercent)
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit -1 ; _FTP_DownloadProgress Aborts with -1, so you can exit your app afterwards
        Case $g_idBtn_Cancel
            Exit -2 ; Just Cancel, without special Return value
    EndSwitch
    Return 1 ; Otherwise continue Download
EndFunc   ;==>_UpdateGUIProgressBar


Function _FTP_ProgressUpload

Function Reference

_FTP_ProgressUpload

Uploads a file in Binary Mode and shows a Progress window or by Calling a User defined Function

#include <FTPEx.au3>
_FTP_ProgressUpload ( $hFTPSession, $sLocalFile, $sRemoteFile [, $hFunctionToCall = 0] )

Parameters

$hFTPSession | as returned by _FTP_Connect().
$sLocalFile | The local file to create.
$sRemoteFile | The remote source file.
$hFunctionToCall | [optional] A variable assigned to the user defined function to update a progress bar or react on user interation, such as aborting or exiting the process. Default = none. See remarks.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | -1 - Local file couldn't be opened -3 - Create File failed -4 - Write to file failed -5 - Close File failed -6 - Download aborted by PercentageFunc and Return of Called Function

Remarks

Information about $hFunctionToCall:
Parameter: $iPercentage - The Percentage of Progress
Return Values:
Continue Download - 1
Abort Download - zero or less than zero e.g. 0 or -1
These Return Values are returned by _FTP_ProgressUpload(), too, so you can react on different Actions like Aborting by User, closing App or TimeOut of the process.

Example

Example 1

#include <FTPEx.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <ProgressConstants.au3>

; This example NEED TO BE ADAPTED to valid $g_sRemoteFile/$sServer/$sUsername/$sPass

Global $g_sRemoteFile = "/pub/software/databases/rt/SRPMS/ucs-local-modperl-2.0.3-1.src.rpm"
Global $g_sLocalFile = @TempDir & "\temp.tmp"

Local $sServer = 'ftp.csx.cam.ac.uk'
Local $sUsername = ''
Local $sPass = ''

Local $hInternetSession = _FTP_Open('MyFTP Control')
; passive allows most protected FTPs to answer
Local $hFTPSession = _FTP_Connect($hInternetSession, $sServer, $sUsername, $sPass, 1)

Example()

_FTP_Close($hInternetSession)

Func Example()
    Local $fuFunctionToCall = _UpdateProgress
    ProgressOn("Upload Progress", $g_sRemoteFile)
    _FTP_ProgressUpload($hFTPSession, $g_sLocalFile, $g_sRemoteFile, $fuFunctionToCall)
    ProgressOff()
EndFunc   ;==>Example

Func _UpdateProgress($iPercent)
    ProgressSet($iPercent, $iPercent & "%")
    If _IsPressed("77") Then Return 0 ; Abort on F8
    Return 1 ; Continue upload
EndFunc   ;==>_UpdateProgress

Example 2

#include <FTPEx.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <ProgressConstants.au3>

; This example NEED TO BE ADAPTED to valid $g_sRemoteFile/$sServer/$sUsername/$sPass

Global $g_sRemoteFile = "/pub/software/databases/rt/SRPMS/ucs-local-modperl-2.0.3-1.src.rpm"
Global $g_sLocalFile = @TempDir & "\temp.tmp"

Local $sServer = 'ftp.csx.cam.ac.uk'
Local $sUsername = ''
Local $sPass = ''

Local $hInternetSession = _FTP_Open('MyFTP Control')
; passive allows most protected FTPs to answer
Local $hFTPSession = _FTP_Connect($hInternetSession, $sServer, $sUsername, $sPass, 1)

Global $g_idProgressBarCtrl, $g_idBtn_Cancel

Example()

_FTP_Close($hInternetSession)

Func Example()
    ; create GUI
    GUICreate("My GUI upload Progressbar", 220, 100, 100, 200)
    GUICtrlCreateLabel($g_sRemoteFile, 10, 10)
    $g_idProgressBarCtrl = GUICtrlCreateProgress(10, 40, 200, 20, $PBS_SMOOTH)
    GUICtrlSetColor(-1, 32250); not working with Windows XP Style
    $g_idBtn_Cancel = GUICtrlCreateButton("Cancel", 75, 70, 70, 20)
    GUISetState(@SW_SHOW)

    Local $fuFunctionToCall = _UpdateGUIProgressBar
    _FTP_ProgressUpload($hFTPSession, $g_sLocalFile, $g_sRemoteFile, $fuFunctionToCall)
    Exit @error
EndFunc   ;==>Example

Func _UpdateGUIProgressBar($iPercent)
    GUICtrlSetData($g_idProgressBarCtrl, $iPercent)
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Return -1 ; _FTP_UploadProgress Aborts with -1, so you can exit your app afterwards
        Case $g_idBtn_Cancel
            Return -2 ; Just Cancel, without special Return value
    EndSwitch
    Return 1 ; Otherwise continue Upload
EndFunc   ;==>_UpdateGUIProgressBar


Function _FTP_SetStatusCallback

Function Reference

_FTP_SetStatusCallback

Registers callback function that WinINet functions can call as progress is made during an operation

#include <FTPEx.au3>
_FTP_SetStatusCallback ( $hInternetSession, $sFunctionName )

Parameters

$hInternetSession | as returned by _FTP_Open()
$sFunctionName | the name of the User Defined Function to call.

Return Value

Success: | a pointer to callback function.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

The callback function is called with the following parameters (see InternetStatusCallback Windows API):
$hInternet, $iContext, $iInternetStatus, $pStatusInformation, $iStatusInformationLength

Related

_FTP_Command, _FTP_Connect, _FTP_DecodeInternetStatus, _FTP_DirPutContents, _FTP_FileGet, _FTP_FileOpen, _FTP_FilePut, _FTP_FindFileFirst, _FTP_ListToArray, _FTP_ListToArray2D, _FTP_ListToArrayEx, _FTP_Open

See Also

Search InternetSetStatusCallback in MSDN Library.

Example

#include <Debug.au3>
#include <FTPEx.au3>

_DebugSetup(StringTrimRight(@ScriptName, StringLen(".exe")) & ' example', True)

Local $sServer = 'ftp.mozilla.org'
Local $sUsername = ''
Local $sPass = ''

Local $hOpen = _FTP_Open('MyFTP Control')
Local $pCallback = _FTP_SetStatusCallback($hOpen, 'FTPStatusCallbackHandler')

Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass, 0, $INTERNET_DEFAULT_FTP_PORT, $INTERNET_SERVICE_FTP, 0, $pCallback)

Local $iFtpc = _FTP_Close($hConn)
Local $iFtpo = _FTP_Close($hOpen)

Func FTPStatusCallbackHandler($hInternet, $iContext, $iInternetStatus, $pStatusInformation, $iStatusInformationLength)
    #forceref $hInternet, $iContext
    If $iInternetStatus = $INTERNET_STATUS_REQUEST_SENT Or $iInternetStatus = $INTERNET_STATUS_RESPONSE_RECEIVED Then
        Local $iBytesRead
        Local $tStatus = DllStructCreate('dword')
        _WinAPI_ReadProcessMemory(_WinAPI_GetCurrentProcess(), $pStatusInformation, $tStatus, $iStatusInformationLength, $iBytesRead)
        _DebugOut(_FTP_DecodeInternetStatus($iInternetStatus) & ' | Size = ' & DllStructGetData($tStatus, 1) & ' Bytes    Bytes read = ' & $iBytesRead)
    Else
        _DebugOut(_FTP_DecodeInternetStatus($iInternetStatus))
    EndIf
EndFunc   ;==>FTPStatusCallbackHandler


GDIPlus Reference

  • Activation Management
  • ArrowCap Management
  • CustomLineCap Management
  • Bitmap Management
  • Brush Management
  • HashBrush Management
  • LineBrush Management
  • SolidBrush Management
  • TextureBrush Management
  • Effect Management
  • Font Management
  • FontPrivate Management
  • FontFamily Management
  • Graphics Management
  • GraphicsCoders Management
  • GraphicsPath Management
  • Image Management
  • ImageAttributes Management
  • Matrix Management
  • ColorMatrix Management
  • PathGradientBrush Management
  • PathIterator Management
  • Pen Management
  • Region Management
  • StringFormat Management
  • Text Management


User Defined Functions

Activation user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_RectFCreate | Create a $tagGDIPRECTF structure
_GDIPlus_Shutdown | Clean up resources used by Microsoft Windows GDI+
_GDIPlus_Startup | Initialize Microsoft Windows GDI+


Function _GDIPlus_RectFCreate

Function Reference

_GDIPlus_RectFCreate

Create a $tagGDIPRECTF structure

#include <GDIPlus.au3>
_GDIPlus_RectFCreate ( [$nX = 0 [, $nY = 0 [, $nWidth = 0 [, $nHeight = 0]]]] )

Parameters

$nX | [optional] X coordinate of upper left hand corner of rectangle
$nY | [optional] Y coordinate of upper left hand corner of rectangle
$nWidth | [optional] Rectangle width
$nHeight | [optional] Rectangle height

Return Value

Returns a $tagGDIPRECTF structure.

Related

$tagGDIPRECTF

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw a string
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
    $tLayout = _GDIPlus_RectFCreate(140, 110, 100, 20)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Hello world", $hFont, $tLayout, $hFormat, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)

    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_Shutdown

Function Reference

_GDIPlus_Shutdown

Clean up resources used by Microsoft Windows GDI+

#include <GDIPlus.au3>
_GDIPlus_Shutdown ( )

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

You must dispose of all of your GDI+ objects before you call _GDIPlus_Shutdown().

Related

_GDIPlus_Startup

See Also

Search GdiplusShutdown in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hGUI, $hBMP, $hBitmap, $hGraphic

    ; Capture upper left corner of screen
    $hBMP = _ScreenCapture_Capture("", 0, 0, 400, 300)

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Draw bitmap to GUI
    $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0)

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_ImageDispose($hBitmap)
    _WinAPI_DeleteObject($hBMP)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GDIPlus_Startup

Function Reference

_GDIPlus_Startup

Initialize Microsoft Windows GDI+

#include <GDIPlus.au3>
_GDIPlus_Startup ( [$sGDIPDLL = Default [, $bRetDllHandle = False]] )

Parameters

$sGDIPDLL | [optional] the filename of the dll to be used. Default is the installed GDI Dll.
$bRetDllHandle | [optional] True if the handle to opened GDI Dll is to be returned. Default is False.

Return Value

Success: | True or a handle to the opened GDI Dll if $bRetDllHandle = True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

Call _GDIPlus_Startup() before you create any GDI+ objects.

If GDI+ V1.1 functions are available @extended will be set to value greater than 5.
For Vista or Server 2008 the $sGDIPDLL must be defined. The gdiplus.dll can be found in @WindowsDir & "\winsxs\*.gdiplus*\gdiplus.dll"

Related

_GDIPlus_Shutdown

See Also

Search GdiplusStartup in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hGUI, $hBMP, $hBitmap, $hGraphic

    ; Capture upper left corner of screen
    $hBMP = _ScreenCapture_Capture("", 0, 0, 400, 300)

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Draw bitmap to GUI
    $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0)

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_ImageDispose($hBitmap)
    _WinAPI_DeleteObject($hBMP)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


User Defined Functions

ArrowCap user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_ArrowCapCreate | Creates an adjustable arrow line cap with the specified height and width
_GDIPlus_ArrowCapDispose | Release an adjustable arrow line cap object
_GDIPlus_ArrowCapGetFillState | Determines whether the arrow cap is filled
_GDIPlus_ArrowCapGetHeight | Gets the height of the arrow cap
_GDIPlus_ArrowCapGetMiddleInset | Gets the value of the inset
_GDIPlus_ArrowCapGetWidth | Gets the width of the arrow cap
_GDIPlus_ArrowCapSetFillState | Sets whether the arrow cap is filled
_GDIPlus_ArrowCapSetHeight | Sets the height of the arrow cap
_GDIPlus_ArrowCapSetMiddleInset | Gets the value of the inset
_GDIPlus_ArrowCapSetWidth | Sets the width of the arrow cap


Function _GDIPlus_ArrowCapCreate

Function Reference

_GDIPlus_ArrowCapCreate

Creates an adjustable arrow line cap with the specified height and width

#include <GDIPlus.au3>
_GDIPlus_ArrowCapCreate ( $fHeight, $fWidth [, $bFilled = True] )

Parameters

$fHeight | Specifies the length, in units, of the arrow from its base to its point
$fWidth | Specifies the distance, in units, between the corners of the base of the arrow
$bFilled | [optional] Fill flag: True - Arrow will be filled False - Arrow will not be filled

Return Value

Success: | a handle to a new arrowCap object.
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_ArrowCapDispose() to release the object resources.

Related

_GDIPlus_ArrowCapDispose

See Also

Search GdipCreateAdjustableArrowCap in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen, $hEndCap

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 2)
    $hEndCap = _GDIPlus_ArrowCapCreate(3, 6)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)

    ; Show pen end cap
    MsgBox($MB_SYSTEMMODAL, "Information", "Pen end cap: 0x" & Hex(_GDIPlus_PenGetCustomEndCap($hPen)))

    ; Draw arrows
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 120, 390, 120, $hPen)
    _GDIPlus_PenSetWidth($hPen, 4)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)
    _GDIPlus_PenSetWidth($hPen, 6)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 180, 390, 180, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_ArrowCapDispose($hEndCap)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_ArrowCapDispose

Function Reference

_GDIPlus_ArrowCapDispose

Release an adjustable arrow line cap object

#include <GDIPlus.au3>
_GDIPlus_ArrowCapDispose ( $hCap )

Parameters

$hCap Handle to an adjustable arrow line cap object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_ArrowCapCreate

See Also

Search GdipDeleteCustomLineCap in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen, $hEndCap

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 2)
    $hEndCap = _GDIPlus_ArrowCapCreate(3, 6)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)

    ; Show pen end cap
    MsgBox($MB_SYSTEMMODAL, "Information", "Pen end cap: 0x" & Hex(_GDIPlus_PenGetCustomEndCap($hPen)))

    ; Draw arrows
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 120, 390, 120, $hPen)
    _GDIPlus_PenSetWidth($hPen, 4)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)
    _GDIPlus_PenSetWidth($hPen, 6)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 180, 390, 180, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_ArrowCapDispose($hEndCap)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_ArrowCapGetFillState

Function Reference

_GDIPlus_ArrowCapGetFillState

Determines whether the arrow cap is filled

#include <GDIPlus.au3>
_GDIPlus_ArrowCapGetFillState ( $hArrowCap )

Parameters

$hArrowCap Handle to a ArrowCap object

Return Value

True: | Arrow cap is filled.
False: | Arrow cap is not filled or if error then @error flag is set.

Related

_GDIPlus_ArrowCapSetFillState

See Also

Search GdipGetAdjustableArrowCapFillState in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen, $hEndCap

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 4)
    $hEndCap = _GDIPlus_ArrowCapCreate(4, 6)

    ; Show fill state
    MsgBox($MB_SYSTEMMODAL, "Information", "Fill state: " & _GDIPlus_ArrowCapGetFillState($hEndCap))

    ; Draw arrow 1
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 130, 390, 130, $hPen)

    ; Draw arrow 2
    _GDIPlus_ArrowCapSetFillState($hEndCap, False)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 160, 390, 160, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_ArrowCapDispose($hEndCap)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_ArrowCapGetHeight

Function Reference

_GDIPlus_ArrowCapGetHeight

Gets the height of the arrow cap

#include <GDIPlus.au3>
_GDIPlus_ArrowCapGetHeight ( $hArrowCap )

Parameters

$hArrowCap Handle to a ArrowCap object

Return Value

Success: | the height of the arrow cap.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

The height is the distance from the base of the arrow to its vertex.

Related

_GDIPlus_ArrowCapSetHeight

See Also

Search GdipGetAdjustableArrowCapHeight in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen, $hEndCap

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 4)
    $hEndCap = _GDIPlus_ArrowCapCreate(3, 6)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)

    ; Draw arrow 1
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 120, 390, 120, $hPen)

    ; Draw arrow 2
    _GDIPlus_ArrowCapSetHeight($hEndCap, _GDIPlus_ArrowCapGetHeight($hEndCap) + 2)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)

    ; Draw arrow 3
    _GDIPlus_ArrowCapSetHeight($hEndCap, _GDIPlus_ArrowCapGetHeight($hEndCap) + 2)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 180, 390, 180, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_ArrowCapDispose($hEndCap)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_ArrowCapGetMiddleInset

Function Reference

_GDIPlus_ArrowCapGetMiddleInset

Gets the value of the inset

#include <GDIPlus.au3>
_GDIPlus_ArrowCapGetMiddleInset ( $hArrowCap )

Parameters

$hArrowCap Handle to a ArrowCap object

Return Value

Success: | the middle inset value.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

The middle inset is the number of units that the midpoint of the base shifts towards the vertex.
A middle inset of zero results in no shift -- the base is a straight line, giving the arrow a triangular shape.
A positive (greater than zero) middle inset results in a shift the specified number of units toward the vertex -- the base is an arrow shape that points toward the vertex, giving the arrow cap a V-shape.
A negative (less than zero) middle inset results in a shift the specified number of units away from the vertex -- the base becomes an arrow shape that points away from the vertex, giving the arrow either a diamond shape (if the absolute value of the middle inset is equal to the height) or distorted diamond shape.
If the middle inset is equal to or greater than the height of the arrow cap, the cap does not appear at all.
The value of the middle inset affects the arrow cap only if the arrow cap is filled.

Related

_GDIPlus_ArrowCapSetMiddleInset

See Also

Search GdipGetAdjustableArrowCapMiddleInset in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen, $hEndCap, $iInset

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 4)
    $hEndCap = _GDIPlus_ArrowCapCreate(3, 6)

    ; Draw arrow 1
    $iInset = 0.5
    _GDIPlus_ArrowCapSetMiddleInset($hEndCap, $iInset)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 120, 390, 120, $hPen)

    ; Draw arrow 2
    $iInset = _GDIPlus_ArrowCapGetMiddleInset($hEndCap) + 0.5
    _GDIPlus_ArrowCapSetMiddleInset($hEndCap, $iInset)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)

    ; Draw arrow 3
    $iInset = _GDIPlus_ArrowCapGetMiddleInset($hEndCap) + 0.5
    _GDIPlus_ArrowCapSetMiddleInset($hEndCap, $iInset)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 180, 390, 180, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_ArrowCapDispose($hEndCap)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_ArrowCapGetWidth

Function Reference

_GDIPlus_ArrowCapGetWidth

Gets the width of the arrow cap

#include <GDIPlus.au3>
_GDIPlus_ArrowCapGetWidth ( $hArrowCap )

Parameters

$hArrowCap Handle to a ArrowCap object

Return Value

Success: | the width of the arrow cap.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

The width is the distance between the endpoints of the base of the arrow.

Related

_GDIPlus_ArrowCapSetWidth

See Also

Search GdipGetAdjustableArrowCapWidth in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen, $hEndCap

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 4)
    $hEndCap = _GDIPlus_ArrowCapCreate(3, 6)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)

    ; Draw arrow 1
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 120, 390, 120, $hPen)

    ; Draw arrow 2
    _GDIPlus_ArrowCapSetWidth($hEndCap, _GDIPlus_ArrowCapGetWidth($hEndCap) + 2)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)

    ; Draw arrow 3
    _GDIPlus_ArrowCapSetWidth($hEndCap, _GDIPlus_ArrowCapGetWidth($hEndCap) + 2)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 190, 390, 190, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_ArrowCapDispose($hEndCap)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_ArrowCapSetFillState

Function Reference

_GDIPlus_ArrowCapSetFillState

Sets whether the arrow cap is filled

#include <GDIPlus.au3>
_GDIPlus_ArrowCapSetFillState ( $hArrowCap [, $bFilled = True] )

Parameters

$hArrowCap | Handle to a ArrowCap object
$bFilled | [optional] Fill state: True - Arrow cap is filled False - Arrow cap is not filled

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_ArrowCapGetFillState

See Also

Search GdipSetAdjustableArrowCapFillState in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen, $hEndCap

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 4)
    $hEndCap = _GDIPlus_ArrowCapCreate(4, 6)

    ; Show fill state
    MsgBox($MB_SYSTEMMODAL, "Information", "Fill state: " & _GDIPlus_ArrowCapGetFillState($hEndCap))

    ; Draw arrow 1
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 130, 390, 130, $hPen)

    ; Draw arrow 2
    _GDIPlus_ArrowCapSetFillState($hEndCap, False)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 160, 390, 160, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_ArrowCapDispose($hEndCap)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_ArrowCapSetHeight

Function Reference

_GDIPlus_ArrowCapSetHeight

Sets the height of the arrow cap

#include <GDIPlus.au3>
_GDIPlus_ArrowCapSetHeight ( $hArrowCap, $fHeight )

Parameters

$hArrowCap | Handle to a ArrowCap object
$fHeight | Specifies the length, in units, of the arrow from its base to its point

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_ArrowCapGetHeight

See Also

Search GdipSetAdjustableArrowCapHeight in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen, $hEndCap

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 4)
    $hEndCap = _GDIPlus_ArrowCapCreate(3, 6)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)

    ; Draw arrow 1
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 120, 390, 120, $hPen)

    ; Draw arrow 2
    _GDIPlus_ArrowCapSetHeight($hEndCap, _GDIPlus_ArrowCapGetHeight($hEndCap) + 2)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)

    ; Draw arrow 3
    _GDIPlus_ArrowCapSetHeight($hEndCap, _GDIPlus_ArrowCapGetHeight($hEndCap) + 2)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 180, 390, 180, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_ArrowCapDispose($hEndCap)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_ArrowCapSetMiddleInset

Function Reference

_GDIPlus_ArrowCapSetMiddleInset

Gets the value of the inset

#include <GDIPlus.au3>
_GDIPlus_ArrowCapSetMiddleInset ( $hArrowCap, $fInset )

Parameters

$hArrowCap | Handle to a ArrowCap object
$fInset | Inset value

Return Value

Success: | True
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

The middle inset is the number of units that the midpoint of the base shifts towards the vertex. A middle inset of zero results in no shift (the base is a straight line, giving the arrow a triangular shape).
A positive (greater than zero) middle inset results in a shift the specified number of units toward the vertex (the base is an arrow shape that points toward the vertex, giving the arrow cap a V-shape).
A negative (less than zero) middle inset results in a shift the specified number of units away from the vertex (the base becomes an arrow shape that points away from the vertex, giving the arrow either a diamond shape (if the absolute value of the middle inset is equal to the height) or distorted diamond shape.
If the middle inset is equal to or greater than the height of the arrow cap, the cap does not appear at all. The value of the middle inset affects the arrow cap only if the arrow cap is filled.

Related

_GDIPlus_ArrowCapGetMiddleInset

See Also

Search GdipSetAdjustableArrowCapMiddleInset in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen, $hEndCap, $iInset

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 4)
    $hEndCap = _GDIPlus_ArrowCapCreate(3, 6)

    ; Draw arrow 1
    $iInset = 0.5
    _GDIPlus_ArrowCapSetMiddleInset($hEndCap, $iInset)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 120, 390, 120, $hPen)

    ; Draw arrow 2
    $iInset = _GDIPlus_ArrowCapGetMiddleInset($hEndCap) + 0.5
    _GDIPlus_ArrowCapSetMiddleInset($hEndCap, $iInset)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)

    ; Draw arrow 3
    $iInset = _GDIPlus_ArrowCapGetMiddleInset($hEndCap) + 0.5
    _GDIPlus_ArrowCapSetMiddleInset($hEndCap, $iInset)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 180, 390, 180, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_ArrowCapDispose($hEndCap)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_ArrowCapSetWidth

Function Reference

_GDIPlus_ArrowCapSetWidth

Sets the width of the arrow cap

#include <GDIPlus.au3>
_GDIPlus_ArrowCapSetWidth ( $hArrowCap, $fWidth )

Parameters

$hArrowCap | Handle to a ArrowCap object
$fWidth | Specifies the width, in units, of the arrow between the endpoints of the base of the arrow

Return Value

Success: | True
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_ArrowCapGetWidth

See Also

Search GdipSetAdjustableArrowCapWidth in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen, $hEndCap

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 4)
    $hEndCap = _GDIPlus_ArrowCapCreate(3, 6)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)

    ; Draw arrow 1
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 120, 390, 120, $hPen)

    ; Draw arrow 2
    _GDIPlus_ArrowCapSetWidth($hEndCap, _GDIPlus_ArrowCapGetWidth($hEndCap) + 2)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)

    ; Draw arrow 3
    _GDIPlus_ArrowCapSetWidth($hEndCap, _GDIPlus_ArrowCapGetWidth($hEndCap) + 2)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 190, 390, 190, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_ArrowCapDispose($hEndCap)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


User Defined Functions

CustomLineCap user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_CustomLineCapClone | Clones a CustomLineCap object
_GDIPlus_CustomLineCapCreate | Creates a CustomLineCap object
_GDIPlus_CustomLineCapDispose | Release a custom line cap object
_GDIPlus_CustomLineCapGetStrokeCaps | Gets the end cap styles for both the start line cap and the end line cap
_GDIPlus_CustomLineCapSetStrokeCaps | Sets the distance between the base cap to the start of the line


Function _GDIPlus_CustomLineCapClone

Function Reference

_GDIPlus_CustomLineCapClone

Clones a CustomLineCap object

#include <GDIPlus.au3>
_GDIPlus_CustomLineCapClone ( $hCustomLineCap )

Parameters

$hCustomLineCap Pointer to a CustomLineCap object

Return Value

Success: | a handle to the cloned CustomLineCap object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the CustomLineCap object, call _GDIPlus_CustomLineCapDispose() to release the resources.

Related

_GDIPlus_CustomLineCapDispose

See Also

Search GdipCloneCustomLineCap in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphics, $hPath, $hCustomLineCap, $hClonedLineCap, $hPen
    Local $avPoints[4][2] = [[3], [-15, -15], [0, 0], [15, -15]]

    ; Initialize GDI+
    _GDIPlus_Startup()

    ;create a Graphics object from a window handle
    $hGUI = GUICreate("_GDIPlus_CustomLineCapCreate Example", 400, 200)
    GUISetState(@SW_SHOW)

    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)

    ;sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)

    ; Create GraphicsPath and add two lines to it.
    $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddLine2($hPath, $avPoints)

    ; Create a CustomLineCap object.
    $hCustomLineCap = _GDIPlus_CustomLineCapCreate(0, $hPath)

    ; Create a clone CustomLineCap object.
    $hClonedLineCap = _GDIPlus_CustomLineCapClone($hCustomLineCap)

    ; Create a Pen object, assign cloned cap as the custom end cap, and draw a line.
    $hPen = _GDIPlus_PenCreate(0xFFFF0000)
    _GDIPlus_PenSetCustomEndCap($hPen, $hClonedLineCap)

    _GDIPlus_GraphicsDrawLine($hGraphics, 50, 50, 350, 150, $hPen)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_CustomLineCapDispose($hClonedLineCap)
    _GDIPlus_CustomLineCapDispose($hCustomLineCap)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)

    ; Uninitialize GDI+
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_CustomLineCapCreate

Function Reference

_GDIPlus_CustomLineCapCreate

Creates a CustomLineCap object

#include <GDIPlus.au3>
_GDIPlus_CustomLineCapCreate ( $hPathFill, $hPathStroke [, $iLineCap = 0 [, $nBaseInset = 0]] )

Parameters

$hPathFill | Pointer to a Path object that defines the fill for the custom tip.
$hPathStroke | Pointer to a Path object that defines the contour of the nozzle custom.
$iLineCap | [optional] The line cap that will be used. $GDIP_LINECAPFLAT = Specifies a flat cap $GDIP_LINECAPSQUARE = Specifies a square cap $GDIP_LINECAPROUND = Specifies a circular cap $GDIP_LINECAPTRIANGLE = Specifies a triangular cap $GDIP_LINECAPNOANCHOR = Specifies that the line ends are not anchored $GDIP_LINECAPSQUAREANCHOR = Specifies that the line ends are anchored with a square $GDIP_LINECAPROUNDANCHOR = Specifies that the line ends are anchored with a circle $GDIP_LINECAPDIAMONDANCHOR = Specifies that the line ends are anchored with a diamond $GDIP_LINECAPARROWANCHOR = Specifies that the line ends are anchored with arrowheads $GDIP_LINECAPCUSTOM = Specifies that the line ends are made from a CustomLineCap
$nBaseInset | [optional] Distance between the tip and the line. This distance is expressed in units.

Return Value

Success: | a handle to a new CustomLineCap object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code (GDIP_ERR*).

Remarks

After you are done with the object, call _GDIPlus_CustomLineCapDispose() to release the object resources.

Related

_GDIPlus_CustomLineCapDispose

See Also

Search GdipCreateCustomLineCap in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphics, $hPath, $hCustomLineCap, $hClonedLineCap, $hPen
    Local $avPoints[4][2] = [[3], [-15, -15], [0, 0], [15, -15]]

    ; Initialize GDI+
    _GDIPlus_Startup()

    ;create a Graphics object from a window handle
    $hGUI = GUICreate("_GDIPlus_CustomLineCapCreate Example", 400, 200)
    GUISetState(@SW_SHOW)

    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)

    ;sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)

    ; Create GraphicsPath and add two lines to it.
    $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddLine2($hPath, $avPoints)

    ; Create a CustomLineCap object.
    $hCustomLineCap = _GDIPlus_CustomLineCapCreate(0, $hPath)

    ; Create a clone CustomLineCap object.
    $hClonedLineCap = _GDIPlus_CustomLineCapClone($hCustomLineCap)

    ; Create a Pen object, assign cloned cap as the custom end cap, and draw a line.
    $hPen = _GDIPlus_PenCreate(0xFFFF0000)
    _GDIPlus_PenSetCustomEndCap($hPen, $hClonedLineCap)

    _GDIPlus_GraphicsDrawLine($hGraphics, 50, 50, 350, 150, $hPen)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_CustomLineCapDispose($hClonedLineCap)
    _GDIPlus_CustomLineCapDispose($hCustomLineCap)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)

    ; Uninitialize GDI+
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_CustomLineCapDispose

Function Reference

_GDIPlus_CustomLineCapDispose

Release a custom line cap object

#include <GDIPlus.au3>
_GDIPlus_CustomLineCapDispose ( $hCap )

Parameters

$hCap Handle to a custom line cap object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code (GDIP_ERR*).

See Also

Search GdipDeleteCustomLineCap in MSDN Library.


Function _GDIPlus_CustomLineCapGetStrokeCaps

Function Reference

_GDIPlus_CustomLineCapGetStrokeCaps

Gets the end cap styles for both the start line cap and the end line cap

#include <GDIPlus.au3>
_GDIPlus_CustomLineCapGetStrokeCaps ( $hCustomLineCap )

Parameters

$hCustomLineCap Pointer to a CustomLineCap object

Return Value

Success: | an array with the following format: [0] - Start line cap style [1] - End line cap style
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_CustomLineCapSetStrokeCaps

See Also

Search GdipGetCustomLineCapStrokeCaps in MSDN Library.


Function _GDIPlus_CustomLineCapSetStrokeCaps

Function Reference

_GDIPlus_CustomLineCapSetStrokeCaps

Sets the distance between the base cap to the start of the line

#include <GDIPlus.au3>
_GDIPlus_CustomLineCapSetStrokeCaps ( $hCustomLineCap, $iStartCap, $iEndCap )

Parameters

$hCustomLineCap | Pointer to a CustomLineCap object
$iStartCap | Line cap that will be used for the start of the line to be drawn
$iEndCap | Line cap that will be used for the end of the line to be drawn

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_CustomLineCapGetStrokeCaps

See Also

Search GdipSetCustomLineCapStrokeCaps in MSDN Library.


User Defined Functions

Bitmap user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_BitmapApplyEffect | Alters a Bitmap by applying a specified effect
_GDIPlus_BitmapApplyEffectEx | Alters a Bitmap by applying a specified effect
_GDIPlus_BitmapCloneArea | Create a clone of a Bitmap object from the coordinates and format specified
_GDIPlus_BitmapConvertFormat | Converts a bitmap to a specified pixel format
_GDIPlus_BitmapCreateApplyEffect | Creates a new Bitmap by applying a specified effect to an existing Bitmap
_GDIPlus_BitmapCreateApplyEffectEx | Creates a new Bitmap by applying a specified effect to an existing Bitmap
_GDIPlus_BitmapCreateDIBFromBitmap | Creates a DIB Section
_GDIPlus_BitmapCreateFromFile | Create a Bitmap object from file
_GDIPlus_BitmapCreateFromGraphics | Creates a Bitmap object based on a Graphics object, a width, and a height
_GDIPlus_BitmapCreateFromHBITMAP | Create a Bitmap object from a bitmap handle
_GDIPlus_BitmapCreateFromHICON | Creates a Bitmap object based on an icon
_GDIPlus_BitmapCreateFromHICON32 | Creates a Bitmap object based on a 32bit icon
_GDIPlus_BitmapCreateFromMemory | Loads an image (JPG, BMP, PNG, etc.) which is saved as a binary string and converts it to a bitmap (GDI+) or hbitmap (GDI)
_GDIPlus_BitmapCreateFromResource | Creates a Bitmap object based on an icon
_GDIPlus_BitmapCreateFromScan0 | Creates a Bitmap object based on an array of bytes along with size and format information
_GDIPlus_BitmapCreateFromStream | Creates a Bitmap object based on an IStream COM interface
_GDIPlus_BitmapCreateHBITMAPFromBitmap | Create a handle to a bitmap from a bitmap object
_GDIPlus_BitmapDispose | Release a bitmap object
_GDIPlus_BitmapGetHistogram | Returns one or more histograms for specified color channels of the specified Bitmap
_GDIPlus_BitmapGetHistogramEx | Returns histograms for the Bitmap´s color channels: Red, Green, Blue, Alpha and Grey
_GDIPlus_BitmapGetHistogramSize | Returns the number of elements for allocation by _GDIPlus_BitmapGetHistogramEx()
_GDIPlus_BitmapGetPixel | Gets the color of a specified pixel in this bitmap
_GDIPlus_BitmapLockBits | Locks a portion of a bitmap for reading or writing
_GDIPlus_BitmapSetPixel | Sets the color of a specified pixel in this bitmap
_GDIPlus_BitmapUnlockBits | Unlocks a portion of a bitmap that was locked by _GDIPlus_BitmapLockBits
_GDIPlus_HICONCreateFromBitmap | Creates an icon handle from a bitmap object
_GDIPlus_PaletteInitialize | Initializes a standard, optimal, or custom color palette


Function _GDIPlus_BitmapApplyEffect

Function Reference

_GDIPlus_BitmapApplyEffect

Alters a Bitmap by applying a specified effect

#include <GDIPlus.au3>
_GDIPlus_BitmapApplyEffect ( $hBitmap, $hEffect [, $tRECT = Null] )

Parameters

$hBitmap | Handle to a Bitmap to which the effect is applied.
$hEffect | Handle to an Effect to be applied.
$tRECT | [optional] a $tagRECT structure that specifies the portion of the input bitmap to which the effect is applied.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Remarks

Pass Null to the $tRECT parameter to specify that the effect applies to the entire input bitmap (Default).

Related

$tagRECT, _GDIPlus_BitmapApplyEffectEx, _GDIPlus_EffectCreate

See Also

Search GdipBitmapApplyEffect in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    Local $iImgW = _GDIPlus_ImageGetWidth($hImage)
    Local $iImgH = _GDIPlus_ImageGetHeight($hImage)

    Local $iWidth = 600
    Local $iHeight = $iImgH * 600 / $iImgW

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    Local $hEffect = _GDIPlus_EffectCreateHueSaturationLightness(0, -100, 0)

    Local $tRECT = DllStructCreate($tagRECT)
    $tRECT.Left = $iImgW * 0.25
    $tRECT.Top = $iImgH * 0.25
    $tRECT.Right = $tRECT.Left + $iImgW * 0.5
    $tRECT.Bottom = $tRECT.Top + $iImgH * 0.5

    _GDIPlus_BitmapApplyEffect($hImage, $hEffect, $tRECT)

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


Function _GDIPlus_BitmapApplyEffectEx

Function Reference

_GDIPlus_BitmapApplyEffectEx

Alters a Bitmap by applying a specified effect

#include <GDIPlus.au3>
_GDIPlus_BitmapApplyEffectEx ( $hBitmap, $hEffect [, $iX = 0 [, $iY = 0 [, $iW = 0 [, $iH = 0]]]] )

Parameters

$hBitmap | Handle to a Bitmap to which the effect is applied.
$hEffect | Handle to an Effect to be applied.
$iX | [optional] The X coordinate of the upper left corner of the portion to which the effect is applied.
$iY | [optional] The Y coordinate of the upper left corner of the portion to which the effect is applied.
$iW | [optional] Specifies the width of the portion to which the effect is applied.
$iH | [optional] Specifies the height of the portion to which the effect is applied.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Remarks

Pass 0 to the coordinate parameters to specify that the effect applies to the entire input bitmap (Default).

Related

_GDIPlus_BitmapApplyEffect, _GDIPlus_EffectCreate

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    Local $iImgW = _GDIPlus_ImageGetWidth($hImage)
    Local $iImgH = _GDIPlus_ImageGetHeight($hImage)

    Local $iWidth = 600
    Local $iHeight = $iImgH * 600 / $iImgW

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    Local $hEffect = _GDIPlus_EffectCreateHueSaturationLightness(0, -100, 0)
    _GDIPlus_BitmapApplyEffectEx($hImage, $hEffect, $iImgW * 0.25, $iImgH * 0.25, $iImgW * 0.5, $iImgH * 0.5)

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


Function _GDIPlus_BitmapCloneArea

Function Reference

_GDIPlus_BitmapCloneArea

Create a clone of a Bitmap object from the coordinates and format specified

#include <GDIPlus.au3>
_GDIPlus_BitmapCloneArea ( $hBitmap, $nLeft, $nTop, $nWidth, $nHeight [, $iFormat = 0x00021808] )

Parameters

$hBitmap | Handle to a Bitmap object
$nLeft | X coordinate of upper left corner of the rectangle to copy
$nTop | Y coordinate of upper left corner of the rectangle to copy
$nWidth | The width of the rectangle that specifies the portion of this bitmap to copy
$nHeight | The height of the rectangle that specifies the portion of this bitmap to copy
$iFormat [optional] Pixel format for the new bitmap:
$GDIP_PXF01INDEXED = 1 bit per pixel, indexed
$GDIP_PXF04INDEXED = 4 bits per pixel, indexed
$GDIP_PXF08INDEXED = 8 bits per pixel, indexed
$GDIP_PXF16GRAYSCALE = 16 bits per pixel, grayscale
$GDIP_PXF16RGB555 = 16 bits per pixel; 5 bits for each RGB component
$GDIP_PXF16RGB565 = 16 bits per pixel; 5 bits for red, 6 bits for green and 5 bits blue
$GDIP_PXF16ARGB1555 = 16 bits per pixel; 1 bit for alpha and 5 bits for each RGB component
$GDIP_PXF24RGB = 24 bits per pixel; 8 bits for each RGB component
$GDIP_PXF32RGB = 32 bits per pixel; 8 bits for each RGB component. No alpha component.
$GDIP_PXF32ARGB = 32 bits per pixel; 8 bits for each RGB and alpha component
$GDIP_PXF32PARGB = 32 bits per pixel; 8 bits for each RGB and alpha component, pre-multiplied
$GDIP_PXF48RGB = 48 bits per pixel; 16 bits for each RGB component
$GDIP_PXF64ARGB = 64 bits per pixel; 16 bits for each RGB and alpha component
$GDIP_PXF64PARGB = 64 bits per pixel; 16 bits for each RGB and alpha component, pre-multiplied

Return Value

Success: | a handle to a new Bitmap object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the Bitmap object, call _GDIPlus_BitmapDispose() to release the resources

Related

_GDIPlus_BitmapDispose, _GDIPlus_ImageGetPixelFormat

See Also

Search GdipCloneBitmapAreaI in MSDN Library.

Example

#include <GDIPlus.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    Local $hBitmap, $hClone, $hImage, $iX, $iY

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture 32 bit bitmap
    $hBitmap = _ScreenCapture_Capture("")
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; Create 24 bit bitmap clone
    $iX = _GDIPlus_ImageGetWidth($hImage)
    $iY = _GDIPlus_ImageGetHeight($hImage)
    $hClone = _GDIPlus_BitmapCloneArea($hImage, 0, 0, $iX, $iY, $GDIP_PXF24RGB)

    ; Save bitmap to file
    _GDIPlus_ImageSaveToFile($hClone, @MyDocumentsDir & "\GDIPlus_Image.bmp")

    ; Clean up resources
    _GDIPlus_ImageDispose($hClone)
    _GDIPlus_ImageDispose($hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
EndFunc   ;==>Example


Function _GDIPlus_BitmapConvertFormat

Function Reference

_GDIPlus_BitmapConvertFormat

Converts a bitmap to a specified pixel format

#include <GDIPlus.au3>
_GDIPlus_BitmapConvertFormat ( $hBitmap, $iPixelFormat, $iDitherType, $iPaletteType, $tPalette [, $fAlphaThresholdPercent = 0.0] )

Parameters

$hBitmap | Handle to a Bitmap to which the effect is applied.
$iPixelFormat | Pixel format constant that specifies the new pixel format ($GDIP_PXF*).
$iDitherType | DitherType constant that specifies the dithering algorithm ($GDIP_DitherType*).
$iPaletteType | PaletteType constant that specifies a standard palette to be used for dithering ($GDIP_PaletteType*).
$tPalette | Structure that specifies the palette whose indexes are stored in the pixel data of the converted bitmap.
$fAlphaThresholdPercent | [optional] Real number in the range 0.0 through 100.0 that specifies which pixels in the source bitmap will map to the transparent color in the converted bitmap.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Remarks

The original pixel data in the bitmap is replaced by the new pixel data.

Related

_GDIPlus_PaletteInitialize

See Also

Search GdipBitmapConvertFormat in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * 600 / _GDIPlus_ImageGetWidth($hImage)

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    ;Convert to a 16-color bitmap (4 bits per pixel) using FixedHalftone27 dithering
    Local $tPalette = _GDIPlus_PaletteInitialize(16, $GDIP_PaletteTypeFixedHalftone27, 16, False, $hImage)
    _GDIPlus_BitmapConvertFormat($hImage, $GDIP_PXF04INDEXED, $GDIP_DitherTypeDualSpiral8x8, $GDIP_PaletteTypeFixedHalftone27, $tPalette)

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


Function _GDIPlus_BitmapCreateApplyEffect

Function Reference

_GDIPlus_BitmapCreateApplyEffect

Creates a new Bitmap by applying a specified effect to an existing Bitmap

#include <GDIPlus.au3>
_GDIPlus_BitmapCreateApplyEffect ( $hBitmap, $hEffect [, $tRECT = Null [, $tOutRECT = Null]] )

Parameters

$hBitmap | Handle to a Bitmap to which the effect is applied.
$hEffect | Handle to an Effect to be applied.
$tRECT | [optional] a $tagRECT structure that specifies the portion of the input bitmap that is used.
$tOutRECT | [optional] a $tagRECT structure that receives the portion of the input bitmap that was used.

Return Value

Success: | a handle to a Bitmap object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Remarks

When you are done with the Effect object, call _GDIPlus_EffectDispose() to release the resources.

Related

$tagRECT, _GDIPlus_BitmapCreateApplyEffectEx, _GDIPlus_EffectCreate

See Also

Search GdipBitmapCreateApplyEffect in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $hEffect = _GDIPlus_EffectCreateBlur()

    Local $tRECT = DllStructCreate($tagRECT)
    Local $hBitmap = _GDIPlus_BitmapCreateApplyEffect($hImage, $hEffect, Null, $tRECT)

    Local $iBmpW = $tRECT.Right - $tRECT.Left
    Local $iBmpH = $tRECT.Bottom - $tRECT.Top

    Local $iWidth = 600
    Local $iHeight = $iBmpH * 600 / $iBmpW

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


Function _GDIPlus_BitmapCreateApplyEffectEx

Function Reference

_GDIPlus_BitmapCreateApplyEffectEx

Creates a new Bitmap by applying a specified effect to an existing Bitmap

#include <GDIPlus.au3>
_GDIPlus_BitmapCreateApplyEffectEx ( $hBitmap, $hEffect [, $iX = 0 [, $iY = 0 [, $iW = 0 [, $iH = 0]]]] )

Parameters

$hBitmap | Handle to a Bitmap to which the effect is applied.
$hEffect | Handle to an Effect to be applied.
$iX | [optional] The X coordinate of the upper left corner of the portion to which the effect is applied.
$iY | [optional] The Y coordinate of the upper left corner of the portion to which the effect is applied.
$iW | [optional] Specifies the width of the portion to which the effect is applied.
$iH | [optional] Specifies the height of the portion to which the effect is applied.

Return Value

Success: | a handle to a Bitmap object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Remarks

When you are done with the Effect object, call _GDIPlus_EffectDispose() to release the resources.

Related

_GDIPlus_BitmapCreateApplyEffect, _GDIPlus_EffectCreate

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    Local $iImgW = _GDIPlus_ImageGetWidth($hImage)
    Local $iImgH = _GDIPlus_ImageGetHeight($hImage)

    Local $iWidth = 600
    Local $iHeight = $iImgH * 600 / $iImgW

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    Local $hEffect = _GDIPlus_EffectCreate($GDIP_BlurEffectGuid)
    Local $tEffectParameters = DllStructCreate($tagGDIP_EFFECTPARAMS_Blur)

    Local $hBitmap
    For $i = 0 To 12
        DllStructSetData($tEffectParameters, "Radius", Abs($i - 6) * 12)
        _GDIPlus_EffectSetParameters($hEffect, $tEffectParameters)

        $hBitmap = _GDIPlus_BitmapCreateApplyEffectEx($hImage, $hEffect, $i * Ceiling($iImgW / 13), 0, Ceiling($iImgW / 13) * 2, $iImgH)

        _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, $i * Ceiling($iWidth / 13), 0, Ceiling($iWidth / 13), $iHeight)
        _GDIPlus_BitmapDispose($hBitmap)
    Next

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


Function _GDIPlus_BitmapCreateDIBFromBitmap

Function Reference

_GDIPlus_BitmapCreateDIBFromBitmap

Creates a DIB Section

#include <GDIPlus.au3>
_GDIPlus_BitmapCreateDIBFromBitmap ( $hBitmap )

Parameters

$hBitmap A handle to a GDI+ bitmap

Return Value

Success: | A handle to a DIB bitmap section.
Failure: | 0.

Remarks

After you are done with the object, call _WinAPI_DeleteObject() to release the object resources.

Related

_WinAPI_DeleteObject

See Also

Search CreateDIBSection in MSDN Library.

Example

; PNG work around by UEZ

#include <GDIPlus.au3>

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

; Create GUI
Local $hMainGUI = GUICreate("Show PNG", 210, 210)

_GUICtrlPic_Create("..\GUI\Torus.png", 10, 10);, 100, 100)

GUISetState(@SW_SHOW)

; Loop until the user exits.
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd

; #INTERNAL_USE_ONLY#=================================================================================================
; Name...........: _GUICtrlPic_Create
; Description ...: Creates a Picture control for the GUI
; Syntax ........: _GUICtrlPic_Create($sFilename, $iLeft, $iTop, $iWidth, $iHeight, $iStyle = -1 , $iExStyle = -1)
; Parameters ....: $sFilename - Path of image file
; Author ........: UEZ
; Modified.......: Melba23, guinness, jpm
; Remarks .......: PNG image can be used.
; ====================================================================================================================
Func _GUICtrlPic_Create($sFilename, $iLeft, $iTop, $iWidth = -1, $iHeight = -1, $iStyle = -1, $iExStyle = -1)
    _GDIPlus_Startup()
    Local $idPic = GUICtrlCreatePic("", $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle)
    Local $hBitmap = _GDIPlus_BitmapCreateFromFile($sFilename)
    If $iWidth = -1 Then $iWidth = _GDIPlus_ImageGetWidth($hBitmap)
    If $iHeight = -1 Then $iHeight = _GDIPlus_ImageGetHeight($hBitmap)
    Local $hBitmap_Resized = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)
    Local $hBMP_Ctxt = _GDIPlus_ImageGetGraphicsContext($hBitmap_Resized)
    _GDIPlus_GraphicsSetInterpolationMode($hBMP_Ctxt, $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC)
    _GDIPlus_GraphicsDrawImageRect($hBMP_Ctxt, $hBitmap, 0, 0, $iWidth, $iHeight)
    Local $hHBitmap = _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap_Resized)
    Local $hPrevImage = GUICtrlSendMsg($idPic, $STM_SETIMAGE, 0, $hHBitmap) ; $STM_SETIMAGE = 0x0172
    _WinAPI_DeleteObject($hPrevImage); Delete Prev image if any
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap_Resized)
    _GDIPlus_GraphicsDispose($hBMP_Ctxt)
    _WinAPI_DeleteObject($hHBitmap)
    _GDIPlus_Shutdown()

    Return $idPic
EndFunc   ;==>_GUICtrlPic_Create


Function _GDIPlus_BitmapCreateFromFile

Function Reference

_GDIPlus_BitmapCreateFromFile

Create a Bitmap object from file

#include <GDIPlus.au3>
_GDIPlus_BitmapCreateFromFile ( $sFileName )

Parameters

$sFileName Path to a bitmap file

Return Value

Success: | a handle to a Bitmap object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the Bitmap object, call _GDIPlus_BitmapDispose() to release the resources.

Related

_GDIPlus_BitmapDispose, _WinAPI_DeleteObject

See Also

Search GdipCreateBitmapFromFile in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    Local $hGUI, $hBMP, $hBitmap, $hGraphic, $hImage, $iX, $iY, $hClone

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture 32 bit bitmap
    $hBMP = _ScreenCapture_Capture("")
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)

    ; Create 24 bit bitmap clone
    $iX = _GDIPlus_ImageGetWidth($hImage)
    $iY = _GDIPlus_ImageGetHeight($hImage)
    $hClone = _GDIPlus_BitmapCloneArea($hImage, 0, 0, $iX, $iY, $GDIP_PXF24RGB)

    ; Save bitmap to file
    _GDIPlus_ImageSaveToFile($hClone, @MyDocumentsDir & "\GDIPlus_Image.bmp")

    ; Clean up resources
    _GDIPlus_BitmapDispose($hClone)
    _GDIPlus_BitmapDispose($hImage)
    _WinAPI_DeleteObject($hBMP)

    ; Draw bitmap to GUI
    $hBitmap = _GDIPlus_BitmapCreateFromFile(@MyDocumentsDir & "\GDIPlus_Image.bmp")
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0)

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_BitmapDispose($hBitmap)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Example 2

; PNG work around by UEZ

#include <GDIPlus.au3>

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

; Create GUI
Local $hMainGUI = GUICreate("Show PNG", 210, 210)

_GUICtrlPic_Create("..\GUI\Torus.png", 10, 10);, 100, 100)

GUISetState(@SW_SHOW)

; Loop until the user exits.
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd

; #INTERNAL_USE_ONLY#=================================================================================================
; Name...........: _GUICtrlPic_Create
; Description ...: Creates a Picture control for the GUI
; Syntax ........: _GUICtrlPic_Create($sFilename, $iLeft, $iTop, $iWidth, $iHeight, $iStyle = -1 , $iExStyle = -1)
; Parameters ....: $sFilename - Path of image file
; Author ........: UEZ
; Modified.......: Melba23, guinness, jpm
; Remarks .......: PNG image can be used.
; ====================================================================================================================
Func _GUICtrlPic_Create($sFilename, $iLeft, $iTop, $iWidth = -1, $iHeight = -1, $iStyle = -1, $iExStyle = -1)
    _GDIPlus_Startup()
    Local $idPic = GUICtrlCreatePic("", $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle)
    Local $hBitmap = _GDIPlus_BitmapCreateFromFile($sFilename)
    If $iWidth = -1 Then $iWidth = _GDIPlus_ImageGetWidth($hBitmap)
    If $iHeight = -1 Then $iHeight = _GDIPlus_ImageGetHeight($hBitmap)
    Local $hBitmap_Resized = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)
    Local $hBMP_Ctxt = _GDIPlus_ImageGetGraphicsContext($hBitmap_Resized)
    _GDIPlus_GraphicsSetInterpolationMode($hBMP_Ctxt, $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC)
    _GDIPlus_GraphicsDrawImageRect($hBMP_Ctxt, $hBitmap, 0, 0, $iWidth, $iHeight)
    Local $hHBitmap = _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap_Resized)
    Local $hPrevImage = GUICtrlSendMsg($idPic, $STM_SETIMAGE, 0, $hHBitmap) ; $STM_SETIMAGE = 0x0172
    _WinAPI_DeleteObject($hPrevImage); Delete Prev image if any
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap_Resized)
    _GDIPlus_GraphicsDispose($hBMP_Ctxt)
    _WinAPI_DeleteObject($hHBitmap)
    _GDIPlus_Shutdown()

    Return $idPic
EndFunc   ;==>_GUICtrlPic_Create


Function _GDIPlus_BitmapCreateFromGraphics

Function Reference

_GDIPlus_BitmapCreateFromGraphics

Creates a Bitmap object based on a Graphics object, a width, and a height

#include <GDIPlus.au3>
_GDIPlus_BitmapCreateFromGraphics ( $iWidth, $iHeight, $hGraphics )

Parameters

$iWidth | Specifies the width, in pixels, of the bitmap
$iHeight | Specifies the height, in pixels, of the bitmap
$hGraphics | Handle to a Graphics object

Return Value

Success: | a handle to a Bitmap object Q .
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the Bitmap object, call _GDIPlus_BitmapDispose() to release the resources.

Related

_GDIPlus_BitmapDispose

See Also

Search GdipCreateBitmapFromGraphics in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Global $g_hGUI, $g_hBrush, $g_hGfx, $g_hGfxCtxt, $g_hBitmap

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    $g_hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $g_hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    ;create buffered graphics frame set for smoother gfx object movements
    $g_hGfx = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle
    $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGfx) ;create a Bitmap object based on a graphics object
    $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap) ;get the graphics context of the image / bitmap to draw on image / bitmap
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)

    $g_hBrush = _GDIPlus_BrushCreateSolid(0xFF8080FF) ;create a solid Brush object

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

    Local Const $iDeg = ACos(-1) / 180 ;ACos(-1) is nearly pi
    Local $iSize = 50, $iX_Center = ($iWidth - $iSize) / 2, $iY_Center = ($iHeight - $iSize) / 2, $iXPos, $iYPos, $iAngle = 0
    Local Const $iDots = 16, $iAngelDist = 360 / $iDots, $iRadius = 200

    Do
        _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ;clear bitmap with given color (AARRGGBB format)
        For $i = 1 To $iDots
            $iXPos = $iX_Center + Cos($iAngle * $iDeg) * $iRadius
            $iYPos = $iY_Center + Sin($iAngle * $iDeg) * $iRadius
            _GDIPlus_GraphicsFillEllipse($g_hGfxCtxt, $iXPos, $iYPos, $iSize, $iSize, $g_hBrush) ;draw dots in a circle
            $iAngle += $iAngelDist ;increase angle to next dot
        Next
        $iAngle += 1 ;increase overall angle
        _GDIPlus_GraphicsDrawImageRect($g_hGfx, $g_hBitmap, 0, 0, $iWidth, $iHeight) ;copy drawn bitmap to GUI
    Until Not Sleep(20) ;Sleep() always returns 1 and Not 1 is 0
EndFunc   ;==>Example

Func _Exit() ;cleanup GDI+ resources
    _GDIPlus_BrushDispose($g_hBrush)
    _GDIPlus_GraphicsDispose($g_hGfxCtxt)
    _GDIPlus_GraphicsDispose($g_hGfx)
    _GDIPlus_BitmapDispose($g_hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_BitmapCreateFromHBITMAP

Function Reference

_GDIPlus_BitmapCreateFromHBITMAP

Create a Bitmap object from a bitmap handle

#include <GDIPlus.au3>
_GDIPlus_BitmapCreateFromHBITMAP ( $hBitmap [, $hPal = 0] )

Parameters

$hBitmap | Handle to a HBITMAP
$hPal | [optional] Handle to a HPALETTE

Return Value

Success: | a handle to a Bitmap object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the Bitmap object, call _GDIPlus_BitmapDispose() to release the resources.

Related

_GDIPlus_BitmapDispose

See Also

Search GdipCreateBitmapFromHBITMAP in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    Local $hGUI, $hBMP, $hBitmap, $hGraphic

    ; Capture upper left corner of screen
    $hBMP = _ScreenCapture_Capture("", 0, 0, 400, 300)

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Draw bitmap to GUI
    $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0)

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_BitmapDispose($hBitmap)
    _WinAPI_DeleteObject($hBMP)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GDIPlus_BitmapCreateFromHICON

Function Reference

_GDIPlus_BitmapCreateFromHICON

Creates a Bitmap object based on an icon

#include <GDIPlus.au3>
_GDIPlus_BitmapCreateFromHICON ( $hIcon )

Parameters

$hIcon Handle to an icon

Return Value

Success: | a handle to a new Bitmap object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the Bitmap object, call _GDIPlus_ImageDispose() to release the resources.

Related

_GDIPlus_ImageDispose, _WinAPI_LoadIcon, _WinAPI_LoadImage

See Also

Search GdipCreateBitmapFromHICON in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIShellEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hIcon, $hBitmap

    ; Create GUI
    $hGUI = GUICreate("GDI+", 168, 168)
    GUISetState()

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 32, 48, 48)

    $hBitmap = _GDIPlus_BitmapCreateFromHICON($hIcon)

    _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 60, 60)

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _WinAPI_DestroyIcon($hIcon)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_BitmapCreateFromHICON32

Function Reference

_GDIPlus_BitmapCreateFromHICON32

Creates a Bitmap object based on a 32bit icon

#include <GDIPlus.au3>
_GDIPlus_BitmapCreateFromHICON32 ( $hIcon )

Parameters

$hIcon Handle to an icon

Return Value

Success: | a handle to a new Bitmap object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the Bitmap object, call _GDIPlus_ImageDispose() to release the resources.

Related

_GDIPlus_ImageDispose, _WinAPI_LoadIcon, _WinAPI_LoadImage

See Also

Search GdipCreateBitmapFromHICON in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIShellEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hIcon, $hBitmap

    ; Create GUI
    $hGUI = GUICreate("GDI+", 168, 168)
    GUISetState()

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 32, 48, 48)

    $hBitmap = _GDIPlus_BitmapCreateFromHICON32($hIcon)

    _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 60, 60)

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _WinAPI_DestroyIcon($hIcon)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_BitmapCreateFromMemory

Function Reference

_GDIPlus_BitmapCreateFromMemory

Loads an image (JPG, BMP, PNG, etc.) which is saved as a binary string and converts it to a bitmap (GDI+) or hbitmap (GDI)

#include <GDIPlus.au3>
_GDIPlus_BitmapCreateFromMemory ( $dImage [, $bHBITMAP = False] )

Parameters

$dImage | The binary string which contains any valid image which is supported by GDI+
$bHBITMAP | [optional] If False a bitmap will be created, if True a hbitmap (GDI) will be created

Return Value

Success: | a handle to bitmap (GDI+ bitmap format) or hbitmap (WinAPI bitmap format).
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $dImage is not a binary string 2 - unable to create stream on HGlobal 3 - unable to create bitmap from stream 4 - unable to allocate moveable memory block 5 - unable to lock moveable memory block 6 - unable to unlock locked moveable memory block

Remarks

After you are done with the object, call _GDIPlus_ImageDispose() to release the object resources.

Related

_GDIPlus_BitmapCreateFromStream, _GDIPlus_BitmapDispose

See Also

Search CreateDIBSection in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 300, $iHeight = 300, $iBgColor = 0xFFE8FF ;$iBgColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    Local $hBitmap = _GDIPlus_BitmapCreateFromMemory(BinGIFImage()) ;load binary saved GIF image and convert it to GDI+ bitmap format
    Local $iW = _GDIPlus_ImageGetWidth($hBitmap), $iH = _GDIPlus_ImageGetHeight($hBitmap)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, ($iWidth - $iW) / 2, ($iHeight - $iH) / 2) ;display image in GUI

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example

Func BinGIFImage() ;test GIF image converted to a binary string
    Local $sBinGIFImage = '0x47494638396144004700F70000FFFFFF1831711C357D182D6D1C3982182D691C35791C3986CACACA1831751C3D9614246118316D14286914357D1835791C398A183575204192142D65C2C2C2BE9296142459203D92AEAAAEC69A9AB2B2B6BAB6B6CACACEBEAA41142D7520398A395D9618358614317DA29E9E1028751C3D8A0C2455797979A27D7918316941699ECEA2A23D4955101C4955595961656100041C86828214358E182861B6A23DEBEBEBBEBEBE142D71E7B2B220419EB28E8E10246D2D3959DFA6AA10245D8E8A8EA29641696969CAB241202D49082065C6C6CA0C1C516165556979927D61616186B2183179AAAAAAC6C6C2969296DBDBDF243D718A71712031591C3582DFAEAE8E7D86A2A6A6314579866969AA828214285D20316910246592928E1031860410353D5D92F3F3F328499A14399A14203D3539497D754986868E0C2059A28282E3E3E3081024AE9A3D967171454545355992494D61AE8A8E7175797D869ED7A2A26555554D4D51B69296DBD7D7394969928A4D555D65D7A6AA8A7D39142855CAA6AA203982EBCACE5D6569AE9A359E9E9E715959183161B6C2DF5186C22D4169928A55414965BABABE615971AE9E9E0C18394559755979AAEBE3DF31498A5179A22439694159A6313128A6964D9EAABEDFBABE314982514924081849495565A696396969610C287D4535352035719682867171557171694571A64D5D861C3D92D2BE41514141DBCACAEFB6BA49393D24459A315586394561082471C6B649614D55B6AA5D1C2D59BE969A3D49717D7959614949CAB2AE514139244186E3C6CAF3EFEB756935797965867D55595D4561758AFBBEC23D659A1C357161551CBAAA49413D456D798A7D8282617DA2141C35000C2820283D24418A79753DE3DFDB24395D9692695D6986283965B2B2B23559968A8279FBFBEF8692AEEFD74D516D96C6B6559A8E45353541A69E5D82615D967D79454531D2BE4D92864561869E14244D554D456D6555393D555D61613159A6B286867592B29E8A351C316DF7FBFBFFC6C665757D1C397D555D7DCECACA1C3979182D71BEC2CE4539206D611C866561FFFFFF21F904010000FF002C00000000440047000008FF00FF091C48B0A0C18308132A5CC8B0A1C38710233E74674CA2C58B08C5E4B8900F16C68F1651697C152011C8930E977DD3A6F100CA970BC5C9C92166D92431307316540149C2AB1CDE64EA1CFA2FDA87483968CE01878E684E246A7E591A9369DBBE664E5F669254E357264BD3BAE2819715243C0A3FAA90DA45CF519518562894FDA8A451851E3DA8E0C0DBA34D3D25733156A0A32990AFC281FED02115F862333AACE6593A24F550183EB71A5BAC42C7579843785A1D7A52435306249A1F12BB1567452B568134E10864184706478C5333248645C70A3E545A151BDE8A'
    $sBinGIFImage &= '0F9F0C59C645D2BD70CE381D192A00C7419DCA0AE851A200669E905B1B1D59A264FFD171A7C29D3869B0544893663BF7834AD2E878A7AE1096FB5892D4D185FCC77B8555E8E0883AAEF0B2CA81AE8812C31F59CCF15F4255E013060241ACE2CA856E7451430DBBA0F6E0418CFC5243183570D0055C4F90D855261F1AC44D586AE0F1C4346AA8F1C41378C818A3832D0E840D1E1C144101214EFC10430C4E60C0880D08E063458F0229C10436D830614A21B75041051F59D47186154C6060857B1FCE51A413419CB0CB1F155470CB1F8EB473C20F3F10D2548F679C70423B31E0C301051B6CC008051CD810449A319C01A529EDB8C00C0708441A24A44D3212840B413003252EE198B2411191861AAA9056B4C303253D9E3204343130C108A8A246FF4A81065604F185212DBA13CB258F04E1043636C03A2A234CFCA0CC1A5FE4F3E03DB598334B1F6EC44008B0C2526003064E9832C4140494100D18DCF522432DDD74534D19A074C1C4061414E1AE0DD88C10831B054860EF0507BC919A0AD1C880CA37D598730509653033EDA0D6128BE6B6537C7081BD074CD258360294708135937821483B32D8F282BA1BD8400123D8101283324B8883CB14164B700104F69C52960A0F5C60732A1008E0413E071C50C60907DBB001B62E4C708F399E784080C33643207156BD9470EF070404208F008094F0801D203342EB093CC8608A397AA4B0440810A4F28A045364E3943153D82B412A5E3CD04002F6007240098604FF31ED06D83861C703105C318B10476CB1C726D5D4A3C0058038958FD46B07014A0A2CE0220001807C00010F3160808D152FC853C20121E4A20A382C60924C300AACDDF650F55CA1B602F5D4D2411FEB94620FE77B2F01C70818FCC043CF3D8B20CCEE8360E2F0BDBDE8D40C2EA9DC1B0D208B00B345289BEBBD770A273001C7143D0302880022E4314C1F1D4002814F1240103D4C9BBC7F2F014B7051C60D09189037F221488420187000F3018200F610C0120AE086580822040FB3D71440F01228340010AF78C5053E20007DF8410AFA08C0037EE73DADF9E0000448E10113688014A4C30709C89A4F2E20002D80EB24D780C11A5A6080541CC00033184201FF18C0800808200421F0DE01A7600F6EA590850C68413A182000089460028F58C31A6E884318E8900706F0C0AA0650800124E00182B84212CD470001B8F1776D34C00306E087474CE0015080C61A74C8459424E20BCEE045387CD0023F04A000050880084C910C35AED08D6E4CA1000C60802D68E11146B0052F44B10632F4112588384521508002657CA100FA2840031409095528220492A42424DD28823DB8800B8F20C328DB0087ACB4860A7480430306708D44DC2014B998C52C1E294B01E4037DA1D0830B88900E72E0E0388A220A12B290811564200EF220A6191251'
    $sBinGIFImage &= '8A0ECC2219BF73A32C45100C458002141D580711E0E0CD1554801CA81A0A12DE91FF810CD4E116A318C004A4C1860E744008C110813A2949497B2842151DA0011086D18834446105B7408153908002D69021035018400358400321084118906428431F600045449406D2684414D8B18238A0603943B1863FB2F38524E0A2003358C0223CE10903A4F4014865E812842104894A610FEC18421AFC5108A750A20E3B8506341800542D34C0032260E94A2380D40788E00542D0831ED8C0834E7CA10EE4488237B2428946D022099C40A416B45080049075AC11202B4BDBF182048C420F7048072D0AA18BB9CEC50EC0E0C43576E003BE06E0AF728C4002361BD80878C00309F040256231047570E21E8808CC30E2818C3E9881053E48A45FCBBAD900FF6CF6B6B5D5470386800C7E78642E8860413FFAF00970B821B60CB02D529790800038D7B9B7752E5787C08974FC762E9740C627CEB10534F035B99BBD022E3C10007DDCE0B9CF256201A4A08E4E5C372B60E0871DCC30081E547688B6F5401E30510912546211E7452F03C8A88572E432302A4807170A60063BA0C102654CAE7E69908B2300C11301962E570B5060673C2230C630C1041A90026A5800C22918803E46E10920B08106A5B80111931B00F572D80816480788455C8009CCC0027C2D803C4A01840EB0E1C87990F18C67ACD774580057733184052640E519F821C80CA8C41ECC70641A80A312FA604098990CD47418410B08DEEB0C66A0852B237269C0B258041BCE710433B840C9649E409BAFA002CDC0020A50D0420BA6FCE61BC0810D89D8C10EE4B1641B4FC0022A482D734E01060BC416913758443B1AA0CA05AC79060D6840507D9082147C48056F28B53C183D80141862132088B5AC63FD069941E9D6B84E484000003B'
    Return Binary($sBinGIFImage)
EndFunc   ;==>BinGIFImage


Function _GDIPlus_BitmapCreateFromResource

Function Reference

_GDIPlus_BitmapCreateFromResource

Creates a Bitmap object based on an icon

#include <GDIPlus.au3>
_GDIPlus_BitmapCreateFromResource ( $hInst, $vResourceName )

Parameters

$hInst | Handle to an instance of a module whose executable file contains a bitmap resource
$vResourceName | The resource name string or identifier

Return Value

Success: | a handle to a new Bitmap object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_ImageDispose() to release the object resources.

Related

_GDIPlus_ImageDispose, _WinAPI_GetModuleHandle

See Also

Search GdipCreateBitmapFromResource in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()

    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 300, $iHeight = 300, $iBgColor = 0x404040 ;$iBgColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $sAut2Exe = StringRegExpReplace(@AutoItExe, "\\\w+.exe", "\\Aut2Exe\\Aut2Exe.exe") ;get path to the Aut2Exe.exe file
    If @AutoItX64 Then $sAut2Exe = StringRegExpReplace(@AutoItExe, "\\\w+.exe", "\\Aut2Exe\\Aut2Exe_X64.exe")

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    Local $hInst = _WinAPI_LoadLibrary($sAut2Exe) ;maps a specified executable module into the address space of the calling process
    Local $hBitmap = _GDIPlus_BitmapCreateFromResource($hInst, "BMP_MAINLOGO") ;load bitmap resource "BMP_MAINLOGO" and convert it to GDI+ bitmap format
    Local $iW = _GDIPlus_ImageGetWidth($hBitmap), $iH = _GDIPlus_ImageGetHeight($hBitmap)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, ($iWidth - $iW) / 2, ($iHeight - $iH) / 2) ;display image in GUI centered

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _WinAPI_FreeLibrary($hInst)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
    Exit
EndFunc   ;==>Example


Function _GDIPlus_BitmapCreateFromScan0

Function Reference

_GDIPlus_BitmapCreateFromScan0

Creates a Bitmap object based on an array of bytes along with size and format information

#include <GDIPlus.au3>
_GDIPlus_BitmapCreateFromScan0 ( $iWidth, $iHeight [, $iPixelFormat = $GDIP_PXF32ARGB [, $iStride = 0 [, $pScan0 = 0]]] )

Parameters

$iWidth | The bitmap width, in pixels.
$iHeight | The bitmap height, in pixels.
$iPixelFormat | [optional] Specifies the format of the pixel data. $GDIP_PXF01INDEXED = 1 bit per pixel, indexed $GDIP_PXF04INDEXED = 4 bits per pixel, indexed $GDIP_PXF08INDEXED = 8 bits per pixel, indexed $GDIP_PXF16GRAYSCALE = 16 bits per pixel, grayscale $GDIP_PXF16RGB555 = 16 bits per pixel; 5 bits for each RGB component $GDIP_PXF16RGB565 = 16 bits per pixel; 5 bits for red, 6 bits for green and 5 bits blue $GDIP_PXF16ARGB1555 = 16 bits per pixel; 1 bit for alpha and 5 bits for each RGB component $GDIP_PXF24RGB = 24 bits per pixel; 8 bits for each RGB component $GDIP_PXF32RGB = 32 bits per pixel; 8 bits for each RGB component. No alpha component. $GDIP_PXF32ARGB = 32 bits per pixel; 8 bits for each RGB and alpha component $GDIP_PXF32PARGB = 32 bits per pixel; 8 bits for each RGB and alpha component, pre-multiplied
$iStride | [optional] Integer that specifies the byte offset between the beginning of one scan line and the next.
$pScan0 | [optional] Pointer to an array of bytes that contains the pixel data.

Return Value

Success: | a handle to a new Bitmap object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_BitmapDispose() to release the object resources.

Related

_GDIPlus_ImageDispose

See Also

Search GdipCreateBitmapFromScan0 in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>

Example()

Func Example()
    _GDIPlus_Startup()
    Local Const $iW = 460, $iH = 100
    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) ;create an empty bitmap
    Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;get the graphics context of the bitmap
    _GDIPlus_GraphicsSetSmoothingMode($hBmpCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hBmpCtxt, 0xFFFFFFFF) ;clear bitmap with color white
    _GDIPlus_GraphicsDrawString($hBmpCtxt, "AutoIt rulez!", 0, 0, "Comic Sans MS", 52) ;draw some text to the bitmap
    Local $sFile = @TempDir & "\Test.jpg"
    _GDIPlus_ImageSaveToFile($hBitmap, $sFile) ;save bitmap to disk
    ;cleanup GDI+ resources
    _GDIPlus_GraphicsDispose($hBmpCtxt)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    ShellExecute($sFile) ;open bitmap with default app
EndFunc   ;==>Example

Example 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup()
    Local Const $iW = 120, $iH = 80

    Local $hGui = GUICreate("", $iW, $iH)
    GUISetState()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)

    Local $tPixel = DllStructCreate("uint[" & $iW * $iH & "];")
    Local $iOffset
    For $y = 0 To $iH - 1
        $iOffset = $y * $iW
        For $x = 0 To $iW - 1
            DllStructSetData($tPixel, 1, BitOR(0xFF000000, BitShift(Random(0, 255, 1), -16), BitShift(Random(0, 255, 1), -8), Random(0, 255, 1)), $iOffset + $x + 1)
        Next
    Next

    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH, $GDIP_PXF32ARGB, $iW, $tPixel)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $GUI_EVENT_RESTORE
                ; to redraw the Bitmap
                _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
        EndSwitch
    WEnd

    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_BitmapCreateFromStream

Function Reference

_GDIPlus_BitmapCreateFromStream

Creates a Bitmap object based on an IStream COM interface

#include <GDIPlus.au3>
_GDIPlus_BitmapCreateFromStream ( $pStream )

Parameters

$pStream Pointer to an IStream COM interface

Return Value

Success: | a handle to a new Bitmap object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_BitmapDispose() to release the object resources.

Related

_GDIPlus_ImageDispose, _WinAPI_CreateStreamOnHGlobal

See Also

Search GdipCreateBitmapFromStream in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup()
    Local Const $iW = @DesktopWidth / 2, $iH = @DesktopHeight / 2
    Local $hGUI = GUICreate("GDI+ test", $iW, $iH, -1, -1)
    GUISetState(@SW_SHOW)

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, @DesktopWidth / 2, @DesktopHeight / 2) ;create a GDI bitmap by capturing 1/4 of desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI bitmap to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore

    Local $sImgCLSID = _GDIPlus_EncodersGetCLSID("jpg") ;create CLSID for a JPG image file type
    Local $tGUID = _WinAPI_GUIDFromString($sImgCLSID) ;convert CLSID GUID to binary form and returns $tagGUID structure
    Local $tParams = _GDIPlus_ParamInit(1) ;initialize an encoder parameter list and return $tagGDIPENCODERPARAMS structure
    Local $tData = DllStructCreate("int Quality") ;create struct to set JPG quality setting
    DllStructSetData($tData, "Quality", 10) ;quality 0-100 (0: lowest, 100: highest)
    Local $pData = DllStructGetPtr($tData) ;get pointer from quality struct
    _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) ;add a value to an encoder parameter list
    Local $pStream = _WinAPI_CreateStreamOnHGlobal() ;create stream
    _GDIPlus_ImageSaveToStream($hBitmap, $pStream, $tGUID, $tParams) ;save the bitmap in JPG format in memory
    Local $hBitmapFromStream = _GDIPlus_BitmapCreateFromStream($pStream) ;create bitmap from a stream (here from the JPG in memory)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmapFromStream, 0, 0) ;display streamed image

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    ;cleanup resources
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_BitmapDispose($hBitmapFromStream)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_BitmapCreateHBITMAPFromBitmap

Function Reference

_GDIPlus_BitmapCreateHBITMAPFromBitmap

Create a handle to a bitmap from a bitmap object

#include <GDIPlus.au3>
_GDIPlus_BitmapCreateHBITMAPFromBitmap ( $hBitmap [, $iARGB = 0xFF000000] )

Parameters

$hBitmap | Handle to a bitmap object
$iARGB | [optional] Color object that specifies the background color

Return Value

Success: | a handle to a HBITMAP.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the Bitmap object, call _WinAPI_DeleteObject() to release the resources.

Related

_WinAPI_DeleteObject

See Also

Search GdipCreateHBITMAPFromBitmap in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    Local $hBMP, $hImage, $iX, $iY, $hClone

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture 32 bit bitmap
    $hBMP = _ScreenCapture_Capture("")
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)

    ; Create 24 bit bitmap clone
    $iX = _GDIPlus_ImageGetWidth($hImage)
    $iY = _GDIPlus_ImageGetHeight($hImage)
    $hClone = _GDIPlus_BitmapCloneArea($hImage, 0, 0, $iX, $iY, $GDIP_PXF24RGB)

    ; Save bitmap to file
    _GDIPlus_ImageSaveToFile($hClone, @TempDir & "\GDIPlus_Image.bmp")

    ; Clean up resources
    _GDIPlus_BitmapDispose($hClone)
    _GDIPlus_BitmapDispose($hImage)
    _WinAPI_DeleteObject($hBMP)

    ; Load image
    $hImage = _GDIPlus_ImageLoadFromFile(@TempDir & "\GDIPlus_Image.bmp")
    $hBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)

    ; Save bitmap to file
    _ScreenCapture_SaveImage(@TempDir & "\Image.bmp", $hBMP, True) ; True -> $hBMP destroyed

    ; Clean up resource
    _GDIPlus_ImageDispose($hImage)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_BitmapDispose

Function Reference

_GDIPlus_BitmapDispose

Release a bitmap object

#include <GDIPlus.au3>
_GDIPlus_BitmapDispose ( $hBitmap )

Parameters

$hBitmap Handle to a bitmap object

Return Value

Success: | True
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipDisposeImage in MSDN Library.

Example

#include <GDIPlus.au3>
#include <MsgBoxConstants.au3>

Global $g_hBitmap

Example()

Func Example()
    Local $sFile = FileOpenDialog("Select an image (non JPG)", "", "Images (*.bmp;*.png;*.gif;*.tif)")
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "Aborted", 30)
        Return False
    EndIf

    _GDIPlus_Startup() ;initialize GDI+

    $g_hBitmap = _GDIPlus_BitmapCreateFromFile($sFile) ;create a bitmap object from file
    If @error Then
        _GDIPlus_Shutdown()
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "An error has occured - unable to load image!", 30)
        Return False
    EndIf

    Local $sNewJPGFile = StringTrimRight($sFile, 3) & "jpg", $iAnswer = 0

    If FileExists($sNewJPGFile) Then
        $iAnswer = MsgBox(BitOR($MB_SYSTEMMODAL, $MB_YESNO, $MB_ICONQUESTION), "", '"' & $sNewJPGFile & '" already exists. Overwrite?')
        If $iAnswer <> $IDYES Then
            _ReleaseResources()
            Return False
        EndIf
    EndIf

    _GDIPlus_ImageSaveToFile($g_hBitmap, $sNewJPGFile) ;save image in JPG format
    If @error Then
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "An error has occured - unable to save image!", 30)
    Else
        ShellExecute($sNewJPGFile)
    EndIf

    _ReleaseResources()
EndFunc   ;==>Example

Func _ReleaseResources()
    _GDIPlus_BitmapDispose($g_hBitmap) ;release a bitmap object
    _GDIPlus_Shutdown()
EndFunc   ;==>_ReleaseResources


Function _GDIPlus_BitmapGetHistogram

Function Reference

_GDIPlus_BitmapGetHistogram

Returns one or more histograms for specified color channels of the specified Bitmap

#include <GDIPlus.au3>
_GDIPlus_BitmapGetHistogram ( $hBitmap, $iHistogramFormat, $iHistogramSize, $tChannel_0 [, $tChannel_1 = 0 [, $tChannel_2 = 0 [, $tChannel_3 = 0]]] )

Parameters

$hBitmap | Handle to a Bitmap to which the effect is applied.
$iHistogramFormat | HistogramFormat constant that specifies the channels for which histograms will be created ($GDIP_HistogramFormat*).
$iHistogramSize | Number of elements in each of the arrays pointed to by $tChannel_0, $tChannel_1, $tChannel_2, and $tChannel_3?
$tChannel_0 | A DLL struct array of UINTs that receives the first histogram.
$tChannel_1 | [optional] A DLL struct array of UINTs that receives the second histogram if there is a second histogram. Pass NULL if there is no second histogram.
$tChannel_2 | [optional] A DLL struct array of UINTs that receives the third histogram if there is a third histogram. Pass NULL if there is no third histogram.
$tChannel_3 | [optional] A DLL struct array of UINTs that receives the fourth histogram if there is a fourth histogram. Pass NULL if there is no fourth histogram.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Remarks

The number of histograms returned depends on the $iHistogramFormat parameter. For example, if format is equal to $GDIP_HistogramFormatRGB, then three histograms are returned: one each for the red, green, and blue channels. In that case, $tChannel_0 receives the red-channel histogram, $tChannel_1 receives the green-channel histogram, and $tChannel_2 receives the blue-channel histogram. For $GDIP_HistogramFormatRGB, $tChannel_3 must be set to NULL because there is no fourth histogram

Related

_GDIPlus_BitmapGetHistogramEx, _GDIPlus_BitmapGetHistogramSize

See Also

Search GdipBitmapGetHistogram in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

Global $g_idCombo, $g_hGfx_Buffer, $g_hGfx_Buffer_H, $g_hGui, $g_hGraphics, $g_hGraphics_H, $g_hBmp_Buffer_H, $g_hImage, $g_hBmp_Buffer, $g_hGui_Histogram
Global $g_tChannel, $g_iMaxLum

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    $g_hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($g_hImage) * 600 / _GDIPlus_ImageGetWidth($g_hImage)

    $g_hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGui)
    $g_hBmp_Buffer = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)
    $g_hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($g_hBmp_Buffer)
    _GDIPlus_GraphicsDrawImageRect($g_hGfx_Buffer, $g_hImage, 0, 0, $iWidth, $iHeight)

    $g_hGui_Histogram = GUICreate("Histogram", 266, 160)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    $g_idCombo = GUICtrlCreateCombo("", 10, 132, 246, 20)
    GUICtrlSetData(-1, "Alpha|Red|Green|Blue|Grey", "Red")
    GUICtrlSetOnEvent(-1, "_CreateHistogram")
    $g_hGraphics_H = _GDIPlus_GraphicsCreateFromHWND($g_hGui_Histogram)
    $g_hBmp_Buffer_H = _GDIPlus_BitmapCreateFromScan0(259, 122)
    $g_hGfx_Buffer_H = _GDIPlus_ImageGetGraphicsContext($g_hBmp_Buffer_H)
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfx_Buffer_H, 2)

    $g_iMaxLum = _GetHistogramMaxLum()
    _CreateHistogram()

    GUIRegisterMsg($WM_PAINT, "WM_PAINT")
    GUIRegisterMsg($WM_ERASEBKGND, "WM_PAINT")
    GUISetState(@SW_SHOW, $g_hGui)
    GUISetState(@SW_SHOW, $g_hGui_Histogram)

    GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "_ToolTip", $g_hGui_Histogram)

    While Sleep(10)
    WEnd

EndFunc   ;==>_Example

Func _ToolTip()
    Local $aInfo = GUIGetCursorInfo($g_hGui_Histogram)
    If IsArray($aInfo) Then
        If $aInfo[0] < 0 Or $aInfo[0] > 266 Or $aInfo[1] < 0 Or $aInfo[1] > 160 Then Return

        Local $iIndex = $aInfo[0] - 5
        If $iIndex < 1 Then
            $iIndex = 1
        ElseIf $iIndex > 256 Then
            $iIndex = 256
        EndIf

        Local $iValue = DllStructGetData($g_tChannel, 1, $iIndex)

        ToolTip("Index: " & $iIndex & ", Value: " & $iValue)
    EndIf
EndFunc   ;==>_ToolTip

Func _GetHistogramMaxLum()
    Local $iSize = _GDIPlus_BitmapGetHistogramSize($GDIP_HistogramFormatGray)
    Local $tChannel_Grey = DllStructCreate("uint[" & $iSize & "];")
    _GDIPlus_BitmapGetHistogram($g_hImage, $GDIP_HistogramFormatGray, $iSize, $tChannel_Grey)

    Local $iMaxLum = 0
    For $i = 1 To $iSize
        If DllStructGetData($tChannel_Grey, 1, $i) > $iMaxLum Then $iMaxLum = DllStructGetData($tChannel_Grey, 1, $i)
    Next
    Return $iMaxLum
EndFunc   ;==>_GetHistogramMaxLum

Func _CreateHistogram()
    Local $iHistogramFormat, $iColor

    Switch GUICtrlRead($g_idCombo)
        Case "Alpha"
            $iHistogramFormat = $GDIP_HistogramFormatA
            $iColor = 0xFFFF00FF
        Case "Red"
            $iHistogramFormat = $GDIP_HistogramFormatR
            $iColor = 0xFFFF0000
        Case "Green"
            $iHistogramFormat = $GDIP_HistogramFormatG
            $iColor = 0xFF00FF00
        Case "Blue"
            $iHistogramFormat = $GDIP_HistogramFormatB
            $iColor = 0xFF0000FF
        Case "Grey"
            $iHistogramFormat = $GDIP_HistogramFormatGray
            $iColor = 0xFFFFFFFF
        Case Else
            Return
    EndSwitch

    Local $iSize = _GDIPlus_BitmapGetHistogramSize($iHistogramFormat)
    $g_tChannel = DllStructCreate("uint[" & $iSize & "];")

    _GDIPlus_BitmapGetHistogram($g_hImage, $iHistogramFormat, $iSize, $g_tChannel)

    Local $fScale = 1 / $g_iMaxLum * 100
    Local $aPoly[$iSize + 3][2] = [[$iSize + 2]]
    For $i = 1 To $iSize
        $aPoly[$i][0] = $i
        $aPoly[$i][1] = 100 - DllStructGetData($g_tChannel, 1, $i) * $fScale
    Next
    $aPoly[$iSize + 1][0] = $iSize + 1
    $aPoly[$iSize + 1][1] = 100
    $aPoly[$iSize + 2][0] = 1
    $aPoly[$iSize + 2][1] = 100

    _GDIPlus_GraphicsClear($g_hGfx_Buffer_H, 0xFFFFFFFF)
    Local $hBrush = _GDIPlus_LineBrushCreate(1, 0, 258, 0, 0xFF000000, $iColor)
    _GDIPlus_GraphicsFillPolygon($g_hGfx_Buffer_H, $aPoly, $hBrush)
    _GDIPlus_GraphicsFillRect($g_hGfx_Buffer_H, 1, 104, 256, 16, $hBrush)
    _GDIPlus_BrushDispose($hBrush)

    Local $hPen = _GDIPlus_PenCreate(0xFF000000)
    _GDIPlus_GraphicsDrawPolygon($g_hGfx_Buffer_H, $aPoly, $hPen)
    _GDIPlus_GraphicsDrawRect($g_hGfx_Buffer_H, 0, 0, 258, 100, $hPen)
    _GDIPlus_GraphicsDrawRect($g_hGfx_Buffer_H, 0, 103, 258, 18, $hPen)
    _GDIPlus_PenDispose($hPen)

    _GDIPlus_GraphicsDrawImage($g_hGraphics_H, $g_hBmp_Buffer_H, 4, 4)
EndFunc   ;==>_CreateHistogram

Func WM_PAINT($hWnd, $iMsgm, $wParam, $lParam)
    #forceref $iMsgm, $wParam, $lParam
    Switch $hWnd
        Case $g_hGui
            _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBmp_Buffer, 0, 0)
        Case $g_hGui_Histogram
            _GDIPlus_GraphicsDrawImage($g_hGraphics_H, $g_hBmp_Buffer_H, 4, 4)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_PAINT

Func _Exit()
    _GDIPlus_ImageDispose($g_hImage)
    _GDIPlus_GraphicsDispose($g_hGfx_Buffer_H)
    _GDIPlus_BitmapDispose($g_hBmp_Buffer_H)
    _GDIPlus_GraphicsDispose($g_hGraphics_H)
    _GDIPlus_GraphicsDispose($g_hGfx_Buffer)
    _GDIPlus_BitmapDispose($g_hBmp_Buffer)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_BitmapGetHistogramEx

Function Reference

_GDIPlus_BitmapGetHistogramEx

Returns histograms for the Bitmap´s color channels: Red, Green, Blue, Alpha and Grey

#include <GDIPlus.au3>
_GDIPlus_BitmapGetHistogramEx ( $hBitmap )

Parameters

$hBitmap Handle to a Bitmap to which the effect is applied.

Return Value

Success: | an histogram structure: Size - UINT number of elements in each of the histogram arrays Red - UINT[Size] struct array of colorchannel RED histogram MaxRed - UINT maximum value of the RED histogram Green - UINT[Size] struct array of colorchannel GREEN histogram MaxGreen - UINT maximum value of the RED histogram Blue - UINT[Size] struct array of colorchannel BLUE histogram MaxBlue - UINT maximum value of the RED histogram Alpha - UINT[Size] struct array of colorchannel ALPHA histogram MaxAlpha - UINT maximum value of the RED histogram Grey - UINT[Size] struct array of colorchannel GREY histogram MaxGrey - UINT maximum value of the RED histogram
Failure: | Sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameter.

Related

_GDIPlus_BitmapGetHistogram

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

Global $g_idCombo, $g_hGfx_Buffer, $g_hGfx_Buffer_H, $g_hGui, $g_hGraphics, $g_hGraphics_H, $g_hBmp_Buffer_H, $g_hImage, $g_hBmp_Buffer, $g_hGui_Histogram

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    $g_hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($g_hImage) * 600 / _GDIPlus_ImageGetWidth($g_hImage)

    $g_hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGui)
    $g_hBmp_Buffer = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)
    $g_hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($g_hBmp_Buffer)
    _GDIPlus_GraphicsDrawImageRect($g_hGfx_Buffer, $g_hImage, 0, 0, $iWidth, $iHeight)

    $g_hGui_Histogram = GUICreate("Histogram", 1029, 140)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    $g_hGraphics_H = _GDIPlus_GraphicsCreateFromHWND($g_hGui_Histogram)
    $g_hBmp_Buffer_H = _GDIPlus_BitmapCreateFromScan0(1029, 140)
    $g_hGfx_Buffer_H = _GDIPlus_ImageGetGraphicsContext($g_hBmp_Buffer_H)
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfx_Buffer_H, 2)

    Local $tHistogram = _GDIPlus_BitmapGetHistogramEx($g_hImage)
    _DrawHistogram($tHistogram)

    GUIRegisterMsg($WM_PAINT, "WM_PAINT")
    GUIRegisterMsg($WM_ERASEBKGND, "WM_PAINT")
    GUISetState(@SW_SHOW, $g_hGui)
    GUISetState(@SW_SHOW, $g_hGui_Histogram)

    While Sleep(10)
    WEnd
EndFunc   ;==>_Example

Func _DrawHistogram($tHistogram)
    _GDIPlus_GraphicsClear($g_hGfx_Buffer_H, 0xFFFFFFFF)

    Local $iValue
    Local $fScale = 1 / $tHistogram.MaxGrey * 100

    Local $aPoly[259][2] = [[258]]
    $aPoly[257][0] = 256
    $aPoly[257][1] = 100
    $aPoly[258][0] = 1
    $aPoly[258][1] = 100

    Local $hBrush = _GDIPlus_LineBrushCreate(1, 0, 256, 0, 0xFF000000, 0xFFFF0000, 3)
    Local $hPen = _GDIPlus_PenCreate(0xBB000000, 1)

    For $i = 1 To 256
        $iValue = DllStructGetData($tHistogram, "Red", $i) * $fScale
        If $iValue > 100 Then $iValue = 100
        $aPoly[$i][0] = $i
        $aPoly[$i][1] = 100 - $iValue
    Next
    _GDIPlus_GraphicsResetTransform($g_hGfx_Buffer_H)
    _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer_H, 0, 20)
    _GDIPlus_GraphicsFillPolygon($g_hGfx_Buffer_H, $aPoly, $hBrush)
    _GDIPlus_GraphicsDrawPolygon($g_hGfx_Buffer_H, $aPoly, $hPen)
    _GDIPlus_GraphicsFillRect($g_hGfx_Buffer_H, 1, 102, 255, 16, $hBrush)
    _GDIPlus_GraphicsDrawRect($g_hGfx_Buffer_H, 1, 102, 255, 16, $hPen)
    _GDIPlus_GraphicsDrawString($g_hGfx_Buffer_H, "Red", 30, -15)

    For $i = 1 To 256
        $iValue = DllStructGetData($tHistogram, "Green", $i) * $fScale
        If $iValue > 100 Then $iValue = 100
        $aPoly[$i][1] = 100 - $iValue
    Next
    _GDIPlus_LineBrushSetColors($hBrush, 0xFF000000, 0xFF00FF00)
    _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer_H, 257, 0)
    _GDIPlus_GraphicsFillPolygon($g_hGfx_Buffer_H, $aPoly, $hBrush)
    _GDIPlus_GraphicsDrawPolygon($g_hGfx_Buffer_H, $aPoly, $hPen)
    _GDIPlus_GraphicsFillRect($g_hGfx_Buffer_H, 1, 102, 255, 16, $hBrush)
    _GDIPlus_GraphicsDrawRect($g_hGfx_Buffer_H, 1, 102, 255, 16, $hPen)
    _GDIPlus_GraphicsDrawString($g_hGfx_Buffer_H, "Green", 30, -15)

    For $i = 1 To 256
        $iValue = DllStructGetData($tHistogram, "Blue", $i) * $fScale
        If $iValue > 100 Then $iValue = 100
        $aPoly[$i][1] = 100 - $iValue
    Next
    _GDIPlus_LineBrushSetColors($hBrush, 0xFF000000, 0xFF0000FF)
    _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer_H, 257, 0)
    _GDIPlus_GraphicsFillPolygon($g_hGfx_Buffer_H, $aPoly, $hBrush)
    _GDIPlus_GraphicsDrawPolygon($g_hGfx_Buffer_H, $aPoly, $hPen)
    _GDIPlus_GraphicsFillRect($g_hGfx_Buffer_H, 1, 102, 255, 16, $hBrush)
    _GDIPlus_GraphicsDrawRect($g_hGfx_Buffer_H, 1, 102, 255, 16, $hPen)
    _GDIPlus_GraphicsDrawString($g_hGfx_Buffer_H, "Blue", 30, -15)

    For $i = 1 To 256
        $iValue = DllStructGetData($tHistogram, "Grey", $i) * $fScale
        If $iValue > 100 Then $iValue = 100
        $aPoly[$i][1] = 100 - $iValue
    Next
    _GDIPlus_LineBrushSetColors($hBrush, 0xFF000000, 0xFFFFFFFF)
    _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer_H, 257, 0)
    _GDIPlus_GraphicsFillPolygon($g_hGfx_Buffer_H, $aPoly, $hBrush)
    _GDIPlus_GraphicsDrawPolygon($g_hGfx_Buffer_H, $aPoly, $hPen)
    _GDIPlus_GraphicsFillRect($g_hGfx_Buffer_H, 1, 102, 255, 16, $hBrush)
    _GDIPlus_GraphicsDrawRect($g_hGfx_Buffer_H, 1, 102, 255, 16, $hPen)
    _GDIPlus_GraphicsDrawString($g_hGfx_Buffer_H, "Grey", 30, -15)

    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
EndFunc   ;==>_DrawHistogram

Func WM_PAINT($hWnd, $iMsgm, $wParam, $lParam)
    #forceref $iMsgm, $wParam, $lParam
    Switch $hWnd
        Case $g_hGui
            _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBmp_Buffer, 0, 0)
        Case $g_hGui_Histogram
            _GDIPlus_GraphicsDrawImage($g_hGraphics_H, $g_hBmp_Buffer_H, 0, 0)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_PAINT

Func _Exit()
    _GDIPlus_ImageDispose($g_hImage)
    _GDIPlus_GraphicsDispose($g_hGfx_Buffer_H)
    _GDIPlus_BitmapDispose($g_hBmp_Buffer_H)
    _GDIPlus_GraphicsDispose($g_hGraphics_H)
    _GDIPlus_GraphicsDispose($g_hGfx_Buffer)
    _GDIPlus_BitmapDispose($g_hBmp_Buffer)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_BitmapGetHistogramSize

Function Reference

_GDIPlus_BitmapGetHistogramSize

Returns the number of elements for allocation by _GDIPlus_BitmapGetHistogramEx()

#include <GDIPlus.au3>
_GDIPlus_BitmapGetHistogramSize ( $iFormat )

Parameters

$iFormat HistogramFormat constant ($GDIP_HistogramFormat*)

Return Value

Success: | the number of elements in each of the arrays that receives the histograms.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid HistogramFormat.

Related

_GDIPlus_BitmapGetHistogramEx

See Also

Search GdipBitmapGetHistogramSize in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

Global $g_idCombo, $g_hGfx_Buffer, $g_hGfx_Buffer_H, $g_hGui, $g_hGraphics, $g_hGraphics_H, $g_hBmp_Buffer_H, $g_hImage, $g_hBmp_Buffer, $g_hGui_Histogram
Global $g_tChannel, $g_iMaxLum

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    $g_hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($g_hImage) * 600 / _GDIPlus_ImageGetWidth($g_hImage)

    $g_hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGui)
    $g_hBmp_Buffer = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)
    $g_hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($g_hBmp_Buffer)
    _GDIPlus_GraphicsDrawImageRect($g_hGfx_Buffer, $g_hImage, 0, 0, $iWidth, $iHeight)

    $g_hGui_Histogram = GUICreate("Histogram", 266, 160)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    $g_idCombo = GUICtrlCreateCombo("", 10, 132, 246, 20)
    GUICtrlSetData(-1, "Alpha|Red|Green|Blue|Grey", "Red")
    GUICtrlSetOnEvent(-1, "_CreateHistogram")
    $g_hGraphics_H = _GDIPlus_GraphicsCreateFromHWND($g_hGui_Histogram)
    $g_hBmp_Buffer_H = _GDIPlus_BitmapCreateFromScan0(259, 122)
    $g_hGfx_Buffer_H = _GDIPlus_ImageGetGraphicsContext($g_hBmp_Buffer_H)
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfx_Buffer_H, 2)

    $g_iMaxLum = _GetHistogramMaxLum()
    _CreateHistogram()

    GUIRegisterMsg($WM_PAINT, "WM_PAINT")
    GUIRegisterMsg($WM_ERASEBKGND, "WM_PAINT")
    GUISetState(@SW_SHOW, $g_hGui)
    GUISetState(@SW_SHOW, $g_hGui_Histogram)

    GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "_ToolTip", $g_hGui_Histogram)

    While Sleep(10)
    WEnd

EndFunc   ;==>_Example

Func _ToolTip()
    Local $aInfo = GUIGetCursorInfo($g_hGui_Histogram)
    If IsArray($aInfo) Then
        If $aInfo[0] < 0 Or $aInfo[0] > 266 Or $aInfo[1] < 0 Or $aInfo[1] > 160 Then Return

        Local $iIndex = $aInfo[0] - 5
        If $iIndex < 1 Then
            $iIndex = 1
        ElseIf $iIndex > 256 Then
            $iIndex = 256
        EndIf

        Local $iValue = DllStructGetData($g_tChannel, 1, $iIndex)

        ToolTip("Index: " & $iIndex & ", Value: " & $iValue)
    EndIf
EndFunc   ;==>_ToolTip

Func _GetHistogramMaxLum()
    Local $iSize = _GDIPlus_BitmapGetHistogramSize($GDIP_HistogramFormatGray)
    Local $tChannel_Grey = DllStructCreate("uint[" & $iSize & "];")
    _GDIPlus_BitmapGetHistogram($g_hImage, $GDIP_HistogramFormatGray, $iSize, $tChannel_Grey)

    Local $iMaxLum = 0
    For $i = 1 To $iSize
        If DllStructGetData($tChannel_Grey, 1, $i) > $iMaxLum Then $iMaxLum = DllStructGetData($tChannel_Grey, 1, $i)
    Next
    Return $iMaxLum
EndFunc   ;==>_GetHistogramMaxLum

Func _CreateHistogram()
    Local $iHistogramFormat, $iColor

    Switch GUICtrlRead($g_idCombo)
        Case "Alpha"
            $iHistogramFormat = $GDIP_HistogramFormatA
            $iColor = 0xFFFF00FF
        Case "Red"
            $iHistogramFormat = $GDIP_HistogramFormatR
            $iColor = 0xFFFF0000
        Case "Green"
            $iHistogramFormat = $GDIP_HistogramFormatG
            $iColor = 0xFF00FF00
        Case "Blue"
            $iHistogramFormat = $GDIP_HistogramFormatB
            $iColor = 0xFF0000FF
        Case "Grey"
            $iHistogramFormat = $GDIP_HistogramFormatGray
            $iColor = 0xFFFFFFFF
        Case Else
            Return
    EndSwitch

    Local $iSize = _GDIPlus_BitmapGetHistogramSize($iHistogramFormat)
    $g_tChannel = DllStructCreate("uint[" & $iSize & "];")

    _GDIPlus_BitmapGetHistogram($g_hImage, $iHistogramFormat, $iSize, $g_tChannel)

    Local $fScale = 1 / $g_iMaxLum * 100
    Local $aPoly[$iSize + 3][2] = [[$iSize + 2]]
    For $i = 1 To $iSize
        $aPoly[$i][0] = $i
        $aPoly[$i][1] = 100 - DllStructGetData($g_tChannel, 1, $i) * $fScale
    Next
    $aPoly[$iSize + 1][0] = $iSize + 1
    $aPoly[$iSize + 1][1] = 100
    $aPoly[$iSize + 2][0] = 1
    $aPoly[$iSize + 2][1] = 100

    _GDIPlus_GraphicsClear($g_hGfx_Buffer_H, 0xFFFFFFFF)
    Local $hBrush = _GDIPlus_LineBrushCreate(1, 0, 258, 0, 0xFF000000, $iColor)
    _GDIPlus_GraphicsFillPolygon($g_hGfx_Buffer_H, $aPoly, $hBrush)
    _GDIPlus_GraphicsFillRect($g_hGfx_Buffer_H, 1, 104, 256, 16, $hBrush)
    _GDIPlus_BrushDispose($hBrush)

    Local $hPen = _GDIPlus_PenCreate(0xFF000000)
    _GDIPlus_GraphicsDrawPolygon($g_hGfx_Buffer_H, $aPoly, $hPen)
    _GDIPlus_GraphicsDrawRect($g_hGfx_Buffer_H, 0, 0, 258, 100, $hPen)
    _GDIPlus_GraphicsDrawRect($g_hGfx_Buffer_H, 0, 103, 258, 18, $hPen)
    _GDIPlus_PenDispose($hPen)

    _GDIPlus_GraphicsDrawImage($g_hGraphics_H, $g_hBmp_Buffer_H, 4, 4)
EndFunc   ;==>_CreateHistogram

Func WM_PAINT($hWnd, $iMsgm, $wParam, $lParam)
    #forceref $iMsgm, $wParam, $lParam
    Switch $hWnd
        Case $g_hGui
            _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBmp_Buffer, 0, 0)
        Case $g_hGui_Histogram
            _GDIPlus_GraphicsDrawImage($g_hGraphics_H, $g_hBmp_Buffer_H, 4, 4)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_PAINT

Func _Exit()
    _GDIPlus_ImageDispose($g_hImage)
    _GDIPlus_GraphicsDispose($g_hGfx_Buffer_H)
    _GDIPlus_BitmapDispose($g_hBmp_Buffer_H)
    _GDIPlus_GraphicsDispose($g_hGraphics_H)
    _GDIPlus_GraphicsDispose($g_hGfx_Buffer)
    _GDIPlus_BitmapDispose($g_hBmp_Buffer)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_BitmapGetPixel

Function Reference

_GDIPlus_BitmapGetPixel

Gets the color of a specified pixel in this bitmap

#include <GDIPlus.au3>
_GDIPlus_BitmapGetPixel ( $hBitmap, $iX, $iY )

Parameters

$hBitmap | Pointer to the Bitmap object
$iX | The X coordinate of the pixel
$iY | The Y coordinate of the pixel

Return Value

Success: | the pixel color of the bitmap.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_BitmapSetPixel

See Also

Search GdipBitmapGetPixel in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 150, $iHeight = 150
    Local $iColor = 0
    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iWidth, $iHeight) ;create a GDI bitmap by capturing an area on desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore

    For $iY = 0 To $iHeight - 1
        For $iX = 0 To $iWidth - 1
            $iColor = _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY) ;get current pixel color
            _GDIPlus_BitmapSetPixel($hBitmap, $iX, $iY, BitXOR(0x00FFFFFF, $iColor)) ;invert RGB pixel color only
        Next
    Next
    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) ;copy negative bitmap to graphics object (GUI)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_BitmapLockBits

Function Reference

_GDIPlus_BitmapLockBits

Locks a portion of a bitmap for reading or writing

#include <GDIPlus.au3>
_GDIPlus_BitmapLockBits ( $hBitmap, $iLeft, $iTop, $iWidth, $iHeight [, $iFlags = $GDIP_ILMREAD [, $iFormat = $GDIP_PXF32RGB]] )

Parameters

$hBitmap | Handle to a bitmap object
$iLeft | X coordinate of the upper-left corner of the rectangle to lock
$iTop | Y coordinate of the upper-left corner of the rectangle to lock
$iWidth | The width of the rectangle to lock
$iHeight | The height of the rectangle to lock
$iFlags | [optional] Set of flags that specify whether the locked portion of the bitmap is available for reading or for writing and whether the caller has already allocated a buffer. Can be a combination of the following: $GDIP_ILMREAD - A portion of the image is locked for reading $GDIP_ILMWRITE - A portion of the image is locked for writing $GDIP_ILMUSERINPUTBUF - The buffer is allocated by the user
$iFormat | [optional] Specifies the format of the pixel data in the temporary buffer. Can be one of the following: $GDIP_PXF01INDEXED - 1 bpp, indexed $GDIP_PXF04INDEXED - 4 bpp, indexed $GDIP_PXF08INDEXED - 8 bpp, indexed $GDIP_PXF16GRAYSCALE - 16 bpp, grayscale $GDIP_PXF16RGB555 - 16 bpp; 5 bits for each RGB $GDIP_PXF16RGB565 - 16 bpp; 5 bits red, 6 bits green, and 5 bits blue $GDIP_PXF16ARGB1555 - 16 bpp; 1 bit for alpha and 5 bits for each RGB component $GDIP_PXF24RGB - 24 bpp; 8 bits for each RGB $GDIP_PXF32RGB - 32 bpp; 8 bits for each RGB. No alpha. $GDIP_PXF32ARGB - 32 bpp; 8 bits for each RGB and alpha $GDIP_PXF32PARGB - 32 bpp; 8 bits for each RGB and alpha, pre-multiplied

Return Value

Success: | a $tagGDIPBITMAPDATA structure.
Failure: | sets the @error flag to non-zero.

Remarks

When you are done with the locked portion, call _GDIPlus_BitmapUnlockBits() to release the locked region.

Related

_GDIPlus_ImageGetPixelFormat, _WinAPI_DeleteObject

See Also

Search GdipBitmapLockBits in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; X64 running support
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"

    ;get AutoIt install dir
    Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt"

    Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif"
    If Not FileExists($sFile) Then
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30)
        Return False
    EndIf

    _GDIPlus_Startup()
    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile) ;create an image object based on a file
    If @error Then
        _GDIPlus_Shutdown()
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "An error has occured - unable to load image!", 30)
        Return False
    EndIf

    Local $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) ;get width and height of the image
    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsDrawImageRect($hContext, $hImage, 0, 0, $iW, $iH)

    Local $tBitmapData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $iW, $iH, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) ;locks a portion of a bitmap for reading and writing. More infor at http://msdn.microsoft.com/en-us/library/windows/desktop/ms536298(v=vs.85).aspx
    Local $iScan0 = DllStructGetData($tBitmapData, "Scan0") ;get scan0 (pixel data) from locked bitmap
    Local $iSearchPixel = Int(0xFF000080), $iReplaceColor = 0x00000000 ;color format 0xAARRGGBB
    Local $tPixel = DllStructCreate("int[" & $iW * $iH & "];", $iScan0)
    Local $iPixel, $iRowOffset

    For $iY = 0 To $iH - 1
        $iRowOffset = $iY * $iW + 1
        For $iX = 0 To $iW - 1 ;get each pixel in each line and row
            $iPixel = DllStructGetData($tPixel, 1, $iRowOffset + $iX) ;get pixel color
            If $iPixel = $iSearchPixel Then DllStructSetData($tPixel, 1, $iReplaceColor, $iRowOffset + $iX) ;compare and replace pixel color (blue with transparent color)
        Next
    Next
    _GDIPlus_BitmapUnlockBits($hBitmap, $tBitmapData) ;unlocks a portion of a bitmap that was locked by _GDIPlus_BitmapLockBits

    ;to save manipulated image just use _GDIPlus_ImageSaveToFile()

    ShellExecute($sFile) ;display original image just to compare with manipulated one

    ;display manipulated image
    Local $hGUI = GUICreate("_GDIPlus_BitmapLockBits Demo", $iW, $iH)
    GUISetState(@SW_SHOW)

    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a Graphics object from a window handle
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH) ;copy manipulated image to graphics handle

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup resources
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_BitmapSetPixel

Function Reference

_GDIPlus_BitmapSetPixel

Sets the color of a specified pixel in this bitmap

#include <GDIPlus.au3>
_GDIPlus_BitmapSetPixel ( $hBitmap, $iX, $iY, $iARGB )

Parameters

$hBitmap | Pointer to the Bitmap object
$iX | The X coordinate of the pixel
$iY | The Y coordinate of the pixel
$iARGB | The new color of the pixel

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_BitmapGetPixel

See Also

Search GdipBitmapSetPixel in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 150, $iHeight = 150
    Local $iColor = 0
    Local $hHBmp = _ScreenCapture_Capture("", 0, @DesktopHeight - $iHeight, $iWidth, @DesktopHeight) ;create a GDI bitmap by capturing an area on desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore
    Local $iR, $iG, $iB, $iGrey
    For $iY = 0 To $iHeight - 1
        For $iX = 0 To $iWidth - 1
            $iColor = _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY) ;get current pixel color
            $iR = BitShift(BitAND($iColor, 0x00FF0000), 16) ;extract red color channel
            $iG = BitShift(BitAND($iColor, 0x0000FF00), 8) ;extract green color channel
            $iB = BitAND($iColor, 0x000000FF) ;;extract blue color channel
            $iGrey = Hex(Int(($iR + $iG + $iB) / 3), 2) ;convert pixels to average greyscale color format
            _GDIPlus_BitmapSetPixel($hBitmap, $iX, $iY, "0xFF" & $iGrey & $iGrey & $iGrey) ;set greyscaled pixel
        Next
    Next
    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) ;copy negative bitmap to graphics object (GUI)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_BitmapUnlockBits

Function Reference

_GDIPlus_BitmapUnlockBits

Unlocks a portion of a bitmap that was locked by _GDIPlus_BitmapLockBits

#include <GDIPlus.au3>
_GDIPlus_BitmapUnlockBits ( $hBitmap, $tBitmapData )

Parameters

$hBitmap | Handle to a bitmap object
$tBitmapData | $tagGDIPBITMAPDATA structure previously passed to _GDIPlus_BitmapLockBits()

Return Value

Success: | True
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the locked portion, call _GDIPlus_BitmapUnlockBits() to release the locked region.

Related

_WinAPI_DeleteObject

See Also

Search GdipBitmapUnlockBits in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; X64 running support
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"

    ;get AutoIt install dir
    Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt"

    Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif"
    If Not FileExists($sFile) Then
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30)
        Return False
    EndIf

    _GDIPlus_Startup()
    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile) ;create an image object based on a file
    If @error Then
        _GDIPlus_Shutdown()
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "An error has occured - unable to load image!", 30)
        Return False
    EndIf

    Local $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) ;get width and height of the image
    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsDrawImageRect($hContext, $hImage, 0, 0, $iW, $iH)

    Local $tBitmapData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $iW, $iH, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB) ;locks a portion of a bitmap for reading and writing. More infor at http://msdn.microsoft.com/en-us/library/windows/desktop/ms536298(v=vs.85).aspx
    Local $iScan0 = DllStructGetData($tBitmapData, "Scan0") ;get scan0 (pixel data) from locked bitmap
    Local $iSearchPixel = Int(0xFF000080), $iReplaceColor = 0xFF000000 ;color format 0xAARRGGBB
    Local $tPixel = DllStructCreate("int[" & $iW * $iH & "];", $iScan0)
    Local $iPixel, $iRowOffset

    For $iY = 0 To $iH - 1
        $iRowOffset = $iY * $iW + 1
        For $iX = 0 To $iW - 1 ;get each pixel in each line and row
            $iPixel = DllStructGetData($tPixel, 1, $iRowOffset + $iX) ;get pixel color
            If $iPixel = $iSearchPixel Then DllStructSetData($tPixel, 1, $iReplaceColor, $iRowOffset + $iX) ;compare and replace pixel color (blue with black color)
        Next
    Next
    _GDIPlus_BitmapUnlockBits($hBitmap, $tBitmapData) ;unlocks a portion of a bitmap that was locked by _GDIPlus_BitmapLockBits

    ;to save manipulated image just use _GDIPlus_ImageSaveToFile()

    ShellExecute($sFile) ;display original image just to compare with manipulated one

    ;display manipulated image
    Local $hGUI = GUICreate("_GDIPlus_BitmapLockBits Demo", $iW, $iH)
    GUISetState(@SW_SHOW)

    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a Graphics object from a window handle
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH) ;copy manipulated image to graphics handle

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup resources
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_HICONCreateFromBitmap

Function Reference

_GDIPlus_HICONCreateFromBitmap

Creates an icon handle from a bitmap object

#include <GDIPlus.au3>
_GDIPlus_HICONCreateFromBitmap ( $hBitmap )

Parameters

$hBitmap Pointer to the Bitmap object

Return Value

Success: | an icon handle.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the object, call _WinAPI_DestroyIcon() to release the resources.

Related

_WinAPI_DestroyIcon

See Also

Search GdipCreateHICONFromBitmap in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <GUIMenu.au3>
#include <WinAPIShellEx.au3>

#NoTrayIcon
Opt('TrayMenuMode', 3)

; Create Bitmap with transparency
_GDIPlus_Startup()
Local $hBitmap = _GDIPlus_BitmapCreateFromScan0(48, 48)
Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

Local $hBrush = _GDIPlus_LineBrushCreate(4, 4, 44, 44, 0xFF00FF00, 0, 3)
_GDIPlus_GraphicsFillRect($hContext, 4, 4, 40, 40, $hBrush)
_GDIPlus_BrushDispose($hBrush)

_GDIPlus_GraphicsDispose($hContext)

; create icon from bitmap
Local $hIcon = _GDIPlus_HICONCreateFromBitmap($hBitmap)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_Shutdown()

Local $hMenu = TrayItemGetHandle(0)
Local $idOptions = TrayCreateItem('Options')
TrayCreateItem('')
Local $idExit = TrayCreateItem('Exit')

_GUICtrlMenu_SetItemBmp($hMenu, 0, _WinAPI_Create32BitHBITMAP($hIcon, 1, 1))

TraySetState()

TrayTip("Information", "Check out tray menu", 30)

Do
Until TrayGetMsg() = $idExit


Function _GDIPlus_PaletteInitialize

Function Reference

_GDIPlus_PaletteInitialize

Initializes a standard, optimal, or custom color palette

#include <GDIPlus.au3>
_GDIPlus_PaletteInitialize ( $iEntries [, $iPaletteType = $GDIP_PaletteTypeOptimal [, $iOptimalColors = 0 [, $bUseTransparentColor = True [, $hBitmap = Null]]]] )

Parameters

$iEntries | Number of Entries.
$iPaletteType | [optional] PaletteType constant that specifies the palette type ($GDIP_PaletteType*).
$iOptimalColors | [optional] Integer that specifies the number of colors you want to have in an optimal palette based on a specified bitmap. If this parameter is greater than 0, the palettetype parameter must be set to PaletteTypeOptimal and the bitmap parameter must point to a Bitmap object.
$bUseTransparentColor | [optional] Boolean value that specifies whether to include the transparent color in the palette. Set to TRUE to include the transparent color; otherwise FALSE.
$hBitmap | [optional] Handle of a Bitmap object for which an optimal palette will be created.

Return Value

Success: | a DllStruct Palette: Flags - $iPaletteFlags Count - $iEntries ARGB - UINT Array of ARGB colors
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Related

_GDIPlus_BitmapConvertFormat

See Also

Search GdipInitializePalette in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * 600 / _GDIPlus_ImageGetWidth($hImage)

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    ;Convert to a 16-color bitmap (4 bits per pixel) using FixedHalftone27 dithering
    Local $tPalette = _GDIPlus_PaletteInitialize(16, $GDIP_PaletteTypeFixedHalftone27, 16, False, $hImage)
    _GDIPlus_BitmapConvertFormat($hImage, $GDIP_PXF04INDEXED, $GDIP_DitherTypeDualSpiral8x8, $GDIP_PaletteTypeFixedHalftone27, $tPalette)

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


User Defined Functions

Brush user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_BrushClone | Clone a Brush object
_GDIPlus_BrushDispose | Release a Brush object
_GDIPlus_BrushGetType | Retrieve the type of Brush object


Function _GDIPlus_BrushClone

Function Reference

_GDIPlus_BrushClone

Clone a Brush object

#include <GDIPlus.au3>
_GDIPlus_BrushClone ( $hBrush )

Parameters

$hBrush Handle to a Brush object

Return Value

Success: | a handle to a new brush object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the Brush object, call _GDIPlus_BrushDispose() to release the resources.

Related

_GDIPlus_BrushDispose

See Also

Search GdipCloneBrush in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hBrush1, $hBrush2

    ; Create GUI
    GUICreate("GDI+", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create brushes
    _GDIPlus_Startup()
    $hBrush1 = _GDIPlus_BrushCreateSolid()
    $hBrush2 = _GDIPlus_BrushClone($hBrush1)

    ; Show brush information
    MemoWrite("Brush 1 handle : 0x" & Hex($hBrush1))
    MemoWrite("Brush 1 type ..: " & _GDIPlus_BrushGetType($hBrush1))
    MemoWrite("Brush 2 handle : 0x" & Hex($hBrush2))
    MemoWrite("Brush 2 type ..: " & _GDIPlus_BrushGetType($hBrush2))

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush2)
    _GDIPlus_BrushDispose($hBrush1)
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GDIPlus_BrushDispose

Function Reference

_GDIPlus_BrushDispose

Release a Brush object

#include <GDIPlus.au3>
_GDIPlus_BrushDispose ( $hBrush )

Parameters

$hBrush Handle to a Brush object

Return Value

Success: | True
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_BrushClone, _GDIPlus_BrushCreateSolid

See Also

Search GdipDeleteBrush in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hBrush1, $hBrush2

    ; Create GUI
    GUICreate("GDI+", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create brushes
    _GDIPlus_Startup()
    $hBrush1 = _GDIPlus_BrushCreateSolid()
    $hBrush2 = _GDIPlus_BrushClone($hBrush1)

    ; Show brush information
    MemoWrite("Brush 1 handle : 0x" & Hex($hBrush1))
    MemoWrite("Brush 1 type ..: " & _GDIPlus_BrushGetType($hBrush1))
    MemoWrite("Brush 2 handle : 0x" & Hex($hBrush2))
    MemoWrite("Brush 2 type ..: " & _GDIPlus_BrushGetType($hBrush2))

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush2)
    _GDIPlus_BrushDispose($hBrush1)
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GDIPlus_BrushGetType

Function Reference

_GDIPlus_BrushGetType

Retrieve the type of Brush object

#include <GDIPlus.au3>
_GDIPlus_BrushGetType ( $hBrush )

Parameters

$hBrush Handle to a Brush object

Return Value

Success: | the brush type: 0 - Solid color 1 - Hatch fill 2 - Texture fill 3 - Path gradient 4 - Linear gradient
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetBrushType in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hBrush1, $hBrush2

    ; Create GUI
    GUICreate("GDI+", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create brushes
    _GDIPlus_Startup()
    $hBrush1 = _GDIPlus_BrushCreateSolid()
    $hBrush2 = _GDIPlus_BrushClone($hBrush1)

    ; Show brush information
    MemoWrite("Brush 1 handle : 0x" & Hex($hBrush1))
    MemoWrite("Brush 1 type ..: " & _GDIPlus_BrushGetType($hBrush1))
    MemoWrite("Brush 2 handle : 0x" & Hex($hBrush2))
    MemoWrite("Brush 2 type ..: " & _GDIPlus_BrushGetType($hBrush2))

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush2)
    _GDIPlus_BrushDispose($hBrush1)
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


User Defined Functions

HashBrush user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_HatchBrushCreate | Creates a HatchBrush object based on a hatch style, a foreground color, and a background color


Function _GDIPlus_HatchBrushCreate

Function Reference

_GDIPlus_HatchBrushCreate

Creates a HatchBrush object based on a hatch style, a foreground color, and a background color

#include <GDIPlus.au3>
_GDIPlus_HatchBrushCreate ( [$iHatchStyle = 0 [, $iARGBForeground = 0xFFFFFFFF [, $iARGBBackground = 0xFFFFFFFF]]] )

Parameters

$iHatchStyle | [optional] Pattern of hatch lines that will be used, see remarks. Default = $GDIP_HATCHSTYLE_HORIZONTAL (0).
$iARGBForeground | [optional] Alpha, Red, Green and Blue components of the hatch lines
$iARGBBackground | [optional] Alpha, Red, Green and Blue components of the hatch background

Return Value

Success: | a pointer to a new HatchBrush object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

The pattern constants are declared in GDIPlusConstants.au3, those that start with $GDIP_HATCHSTYLE_*.
When you are done with the HatchBrush object, call _GDIPlus_BrushDispose() to release the resources.

Related

_GDIPlus_BrushDispose

See Also

Search GdipCreateHatchBrush in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hBrush, $iX, $iY

    ; Create GUI
    Local $hGUI = GUICreate("GDI+", 810, 610)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle

    For $i = 0 To 52
        $iX = 10 + Mod($i, 10) * 80
        $iY = 30 + Floor($i / 10) * 100
        _GDIPlus_GraphicsDrawString($hGraphic, $i, $iX, $iY - 16)

        $hBrush = _GDIPlus_HatchBrushCreate($i, 0xFF00FF00, 0xFF0000FF)
        _GDIPlus_GraphicsFillRect($hGraphic, $iX, $iY, 70, 70, $hBrush)

        _GDIPlus_BrushDispose($hBrush)
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


User Defined Functions

LineBrush user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_LineBrushCreate | Creates a LinearGradientBrush object from a set of boundary points and boundary colors
_GDIPlus_LineBrushCreateFromRect | Creates a LinearGradientBrush object from a rectangle and boundary colors
_GDIPlus_LineBrushCreateFromRectWithAngle | Creates a LinearGradientBrush object from a rectangle, boundary colors and angle of direction
_GDIPlus_LineBrushGetColors | Gets the starting color and ending color of a linear gradient brush
_GDIPlus_LineBrushGetRect | Gets the rectangle that defines the boundaries of a linear gradient brush
_GDIPlus_LineBrushMultiplyTransform | Updates a brush's transformation matrix with the product of itself and another matrix
_GDIPlus_LineBrushResetTransform | Resets the transformation matrix of a linear gradient brush to the identity matrix
_GDIPlus_LineBrushSetBlend | Sets the blend factors and the blend positions of a linear gradient brush to create a custom blend
_GDIPlus_LineBrushSetColors | Sets the starting color and ending color of a linear gradient brush
_GDIPlus_LineBrushSetGammaCorrection | Specifies whether gamma correction is enabled for a linear gradient brush
_GDIPlus_LineBrushSetLinearBlend | Sets the blend shape of a linear gradient brush to create a custom blend based on a triangular shape
_GDIPlus_LineBrushSetPresetBlend | Sets the colors to be interpolated for a linear gradient brush and their corresponding blend positions
_GDIPlus_LineBrushSetSigmaBlend | Sets the blend shape of a linear gradient brush to create a custom blend based on a bell-shaped curve
_GDIPlus_LineBrushSetTransform | Sets the transformation matrix of a linear gradient brush


Function _GDIPlus_LineBrushCreate

Function Reference

_GDIPlus_LineBrushCreate

Creates a LinearGradientBrush object from a set of boundary points and boundary colors

#include <GDIPlus.au3>
_GDIPlus_LineBrushCreate ( $nX1, $nY1, $nX2, $nY2, $iARGBClr1, $iARGBClr2 [, $iWrapMode = 0] )

Parameters

$nX1 | X coordinate of the starting point of the gradient. The starting boundary line passes through the
$nY1 | Y coordinate of the starting point of the gradient. The starting boundary line passes through the
$nX2 | X coordinate of the ending point of the gradient. The ending boundary line passes through the
$nY2 | Y coordinate of the ending point of the gradient. The ending boundary line passes through the
$iARGBClr1 | Alpha, Red, Green and Blue components of the starting color of the line
$iARGBClr2 | Alpha, Red, Green and Blue components of the ending color of the line
$iWrapMode | [optional] Wrap mode that specifies how areas filled with the brush are tiled: 0 - Tiling without flipping 1 - Tiles are flipped horizontally as you move from one tile to the next in a row 2 - Tiles are flipped vertically as you move from one tile to the next in a column 3 - Tiles are flipped horizontally as you move along a row and flipped vertically as you move along a column 4 - No tiling takes place

Return Value

Success: | a pointer to a new LinearGradientBrush object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_BrushDispose() to release the object resources.

Related

_GDIPlus_BrushDispose

See Also

Search GdipCreateLineBrush in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBgColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hBrush = _GDIPlus_LineBrushCreate(0, 0, 280, 500, 0xFFFF0000, 0xFF4020FF, 1) ;create linear gradient brush

    _GDIPlus_GraphicsFillEllipse($hGraphics, 100, 50, 380, 500, $hBrush) ;draw the egg

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_LineBrushCreateFromRect

Function Reference

_GDIPlus_LineBrushCreateFromRect

Creates a LinearGradientBrush object from a rectangle and boundary colors

#include <GDIPlus.au3>
_GDIPlus_LineBrushCreateFromRect ( $tRECTF, $iARGBClr1, $iARGBClr2 [, $iGradientMode = 0 [, $iWrapMode = 0]] )

Parameters

$tRECTF | $tagGDIPRECTF that specifies the starting and ending points of the gradient
$iARGBClr1 | Alpha, Red, Green and Blue components of the starting color of the line
$iARGBClr2 | Alpha, Red, Green and Blue components of the ending color of the line
$iGradientMode | [optional] The direction of the gradient: 0 - Horizontal direction from the left of the display to the right of the display 1 - Vertical direction from the top of the display to the bottom of the display 2 - Forward diagonal direction from the upper-left corner to the lower-right corner of the display 3 - Backward diagonal direction from the upper-right corner to the lower-left corner of the display
$iWrapMode | [optional] Specifies how areas filled with the brush are tiled: 0 - Tiling without flipping 1 - Tiles are flipped horizontally as you move from one tile to the next in a row 2 - Tiles are flipped vertically as you move from one tile to the next in a column 3 - Tiles are flipped horizontally as you move along a row and flipped vertically as you move along a column 4 - No tiling takes place

Return Value

Success: | a pointer to a new LinearGradientBrush object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_BrushDispose() to release the object resources.

Related

_GDIPlus_BrushDispose

See Also

Search GdipCreateLineBrushFromRect in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $tRECTF

    $hGUI = GUICreate("GDI+", 420, 320)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsClear($hGraphic, 0xFF000000)

    $tRECTF = _GDIPlus_RectFCreate(10, 10, 400, 300)
    $hBrush = _GDIPlus_LineBrushCreateFromRect($tRECTF, 0xFF000000, 0xFFFFFFFF, 2)
    _GDIPlus_LineBrushSetSigmaBlend($hBrush, 1)

    _GDIPlus_GraphicsFillRect($hGraphic, 10, 10, 400, 300, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_LineBrushCreateFromRectWithAngle

Function Reference

_GDIPlus_LineBrushCreateFromRectWithAngle

Creates a LinearGradientBrush object from a rectangle, boundary colors and angle of direction

#include <GDIPlus.au3>
_GDIPlus_LineBrushCreateFromRectWithAngle ( $tRECTF, $iARGBClr1, $iARGBClr2, $fAngle [, $bIsAngleScalable = True [, $iWrapMode = 0]] )

Parameters

$tRECTF | $tagGDIPRECTF that specifies the starting and ending points of the gradient
$iARGBClr1 | Alpha, Red, Green and Blue components of the starting color of the line
$iARGBClr2 | Alpha, Red, Green and Blue components of the ending color of the line
$fAngle | Depending the value of $fIsAngleScalable, this is the angle, in degrees (see remarks)
$bIsAngleScalable | [optional] If True, the angle of the directional line is scalable. Not scalable otherwise
$iWrapMode | [optional] Specifies how areas filled with the brush are tiled: 0 - Tiling without flipping 1 - Tiles are flipped horizontally as you move from one tile to the next in a row 2 - Tiles are flipped vertically as you move from one tile to the next in a column 3 - Tiles are flipped horizontally as you move along a row and flipped vertically as you move along a column 4 - No tiling takes place

Return Value

Success: | a pointer to a new LinearGradientBrush object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

If $fIsAngleScalable is True, $iAngle specifies the base angle from which the angle of the directional line is calculated. Otherwise, $iAngle specifies the angle of the directional line. The angle is measured from the top of the rectangle and must be in degrees. The gradient follows the directional line.
After you are done with the object, call _GDIPlus_BrushDispose() to release the object resources.

Related

_GDIPlus_BrushDispose

See Also

Search GdipCreateLineBrushFromRectWithAngle in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $tRECTF, $hPen, $fAngle

    $hGUI = GUICreate("GDI+", 830, 340)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $fAngle = 45

    $tRECTF = _GDIPlus_RectFCreate(10, 10, 400, 300)
    $hBrush = _GDIPlus_LineBrushCreateFromRectWithAngle($tRECTF, 0xFF000000, 0xFFFFFFFF, $fAngle, False)
    _GDIPlus_LineBrushSetSigmaBlend($hBrush, 1)
    _GDIPlus_GraphicsFillRect($hGraphic, 10, 10, 400, 300, $hBrush)

    _GDIPlus_BrushDispose($hBrush)

    $tRECTF = _GDIPlus_RectFCreate(420, 10, 400, 300)
    $hBrush = _GDIPlus_LineBrushCreateFromRectWithAngle($tRECTF, 0xFF000000, 0xFFFFFFFF, $fAngle, True)
    _GDIPlus_LineBrushSetSigmaBlend($hBrush, 1)
    _GDIPlus_GraphicsFillRect($hGraphic, 420, 10, 400, 300, $hBrush)

    $hPen = _GDIPlus_PenCreate(0x6F00007F, 2)
    $fAngle *= 0.01745
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 10, 10 + Cos($fAngle) * 300, 10 + Sin($fAngle) * 300, $hPen)
    _GDIPlus_GraphicsDrawString($hGraphic, "$bIsAngleScalable = False", 10, 320)

    $fAngle = (400 / 300) * ATan($fAngle)
    _GDIPlus_GraphicsDrawLine($hGraphic, 420, 10, 420 + Cos($fAngle) * 300, 10 + Sin($fAngle) * 300, $hPen)
    _GDIPlus_GraphicsDrawString($hGraphic, "IsAngleScalable = True", 420, 320)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_LineBrushGetColors

Function Reference

_GDIPlus_LineBrushGetColors

Gets the starting color and ending color of a linear gradient brush

#include <GDIPlus.au3>
_GDIPlus_LineBrushGetColors ( $hLineGradientBrush )

Parameters

$hLineGradientBrush Pointer to a LinearGradientBrush object

Return Value

Success: | an array containing the starting and ending colors of the LinearGradientBrush: [0] - Starting color [1] - Ending color
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code error code ($GPID_ERR*).

Related

_GDIPlus_LineBrushSetColors

See Also

Search GdipGetLineColors in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $fWidth = 600, $fHeight = 600, $iBgColor = 0x303030 ;$fBGColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $fWidth, $fHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hBrush = _GDIPlus_LineBrushCreate(0, 0, 150, 0, 0xFF000000 + Random(0x111111, 0xFFFFFF, 1), 0xFF000000 + Random(0x111111, 0xFFFFFF, 1), 1) ;create linear gradient flipped brush

    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000 + $iBgColor) ;clear bitmap
    _GDIPlus_GraphicsFillRect($hGraphics, 100, 50, 380, 500, $hBrush) ;draw the egg again

    Local $aColors = _GDIPlus_LineBrushGetColors($hBrush)
    MsgBox($MB_SYSTEMMODAL, "", "Starting hex color: " & Hex($aColors[0], 8) & @CRLF & "End hex color: " & Hex($aColors[1], 8))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_LineBrushGetRect

Function Reference

_GDIPlus_LineBrushGetRect

Gets the rectangle that defines the boundaries of a linear gradient brush

#include <GDIPlus.au3>
_GDIPlus_LineBrushGetRect ( $hLineGradientBrush )

Parameters

$hLineGradientBrush Pointer to a LinearGradientBrush object

Return Value

Success: | an array containing the rectangle boundaries: [0] - X coordinate of the upper-left corner of the rectangle [1] - Y coordinate of the upper-left corner of the rectangle [2] - Width of the rectangle [3] - Height of the rectangle
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetLineRect in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $aRect

    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_LineBrushCreate(10, 10, 390, 290, 0xFF000000, 0xFFFFFFFF)

    $aRect = _GDIPlus_LineBrushGetRect($hBrush)
    _GDIPlus_GraphicsFillRect($hGraphic, $aRect[0], $aRect[1], $aRect[2], $aRect[3], $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_LineBrushMultiplyTransform

Function Reference

_GDIPlus_LineBrushMultiplyTransform

Updates a brush's transformation matrix with the product of itself and another matrix

#include <GDIPlus.au3>
_GDIPlus_LineBrushMultiplyTransform ( $hLineGradientBrush, $hMatrix [, $iOrder = 0] )

Parameters

$hLineGradientBrush | Pointer to a LinearGradientBrush object
$hMatrix | Pointer to a Matrix object that specifies the transformation matrix
$iOrder | [optional] Order of matrices multiplication: 0 - The passed matrix is on the left 1 - The passed matrix is on the right

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code error code ($GPID_ERR*).

See Also

Search GdipMultiplyLineTransform in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hMatrix

    $hGUI = GUICreate("GDI+", 420, 420)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_LineBrushCreate(10, 10, 410, 410, 0xFF000000, 0xFFFFFFFF, 3)
    _GDIPlus_LineBrushSetSigmaBlend($hBrush, 1)

    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, -210, -210)
    _GDIPlus_MatrixRotate($hMatrix, 1, True)
    _GDIPlus_MatrixTranslate($hMatrix, 210, 210, True)

    For $i = 1 To 360
        _GDIPlus_GraphicsFillRect($hGraphic, 10, 10, 400, 400, $hBrush)
        _GDIPlus_LineBrushMultiplyTransform($hBrush, $hMatrix, True)
        Sleep(10)
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_LineBrushResetTransform

Function Reference

_GDIPlus_LineBrushResetTransform

Resets the transformation matrix of a linear gradient brush to the identity matrix

#include <GDIPlus.au3>
_GDIPlus_LineBrushResetTransform ( $hLineGradientBrush )

Parameters

$hLineGradientBrush Pointer to a LinearGradientBrush object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code error code ($GPID_ERR*).

See Also

Search GdipResetLineTransform in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush

    $hGUI = GUICreate("GDI+", 420, 420)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_LineBrushCreate(10, 10, 410, 410, 0xFF000000, 0xFFFFFFFF, 3)
    _GDIPlus_LineBrushSetSigmaBlend($hBrush, 1)

    _GDIPlus_LineBrushResetTransform($hBrush) ;reset angle to zero

    _GDIPlus_GraphicsFillRect($hGraphic, 10, 10, 400, 400, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_LineBrushSetBlend

Function Reference

_GDIPlus_LineBrushSetBlend

Sets the blend factors and the blend positions of a linear gradient brush to create a custom blend

#include <GDIPlus.au3>
_GDIPlus_LineBrushSetBlend ( $hLineGradientBrush, $aBlends )

Parameters

$hLineGradientBrush | Pointer to a LinearGradientBrush object
$aBlends | Array of blend factors and blend positions: [0][0] - Number of blend factors and blend positions, must be at least 2 [1][0] - Factor 1 [1][1] - Position 1 [2][0] - Factor 2 [2][1] - Position 2 [n][0] - Factor n [n][1] - Position n

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

Each factor in the array specifies a percentage of the ending color and should be in the range 0.0 to 1.0.
Each position in the array indicates a percentage of the distance between the starting boundary and the ending boundary and is in the range 0.0 to 1.0, where 0.0 indicates the starting boundary of the gradient and 1.0 indicates the ending boundary.

See Also

Search GdipSetLineBlend in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBgColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hBrush = _GDIPlus_LineBrushCreate(0, 0, 280, 570, 0xFFFFFF00, 0xFF4020FF, 1) ;create linear gradient flipped brush

    Local $aBlends[5][2]
    $aBlends[0][0] = 4 ; Using 4 factors and position
    $aBlends[1][0] = 0 ; Factor
    $aBlends[1][1] = 0 ; Position
    $aBlends[2][0] = 1 ; The percentage of the blending is 100% (red to green is gradually completed in just 20% from the left)
    $aBlends[2][1] = 0.2 ; The distance percentage from the left boundary of the brush is 20%
    $aBlends[3][0] = 0 ; The percentage of the blending is 0% (green to red is gradually completed from 20% to 70% from the left)
    $aBlends[3][1] = 0.7 ; The distance percentage from the left boundary of the brush is 70%
    $aBlends[4][0] = 1 ; The percentage of the blending is 100% (red to green is gradually completed from 70% to 100% from the left)
    $aBlends[4][1] = 1 ; The distance percentage from the left boundary of the brush is 100%

    _GDIPlus_LineBrushSetBlend($hBrush, $aBlends); set the linear gradient brush color positions and factors

    _GDIPlus_GraphicsFillEllipse($hGraphics, 100, 50, 380, 500, $hBrush) ;draw the egg

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_LineBrushSetColors

Function Reference

_GDIPlus_LineBrushSetColors

Sets the starting color and ending color of a linear gradient brush

#include <GDIPlus.au3>
_GDIPlus_LineBrushSetColors ( $hLineGradientBrush, $iARGBStart, $iARGBEnd )

Parameters

$hLineGradientBrush | Pointer to a LinearGradientBrush object
$iARGBStart | Alpha, Red, Green and Blue components of the starting color
$iARGBEnd | Alpha, Red, Green and Blue components of the ending color

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_LineBrushGetColors

See Also

Search GdipSetLineColors in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hBrush = _GDIPlus_LineBrushCreate(0, 0, 280, 570, 0xFFFFFF00, 0xFF4020FF, 1) ;create linear gradient flipped brush

    Local $aBlends[5][2]
    $aBlends[0][0] = 4 ; Using 4 factors and position
    $aBlends[1][0] = 0 ; Factor
    $aBlends[1][1] = 0 ; Position
    $aBlends[2][0] = 1 ; The percentage of the blending is 100% (red to green is gradually completed in just 20% from the left)
    $aBlends[2][1] = 0.2 ; The distance percentage from the left boundary of the brush is 20%
    $aBlends[3][0] = 0 ; The percentage of the blending is 0% (green to red is gradually completed from 20% to 70% from the left)
    $aBlends[3][1] = 0.7 ; The distance percentage from the left boundary of the brush is 70%
    $aBlends[4][0] = 1 ; The percentage of the blending is 100% (red to green is gradually completed from 70% to 100% from the left)
    $aBlends[4][1] = 1 ; The distance percentage from the left boundary of the brush is 100%

    _GDIPlus_LineBrushSetBlend($hBrush, $aBlends); set the linear gradient brush color positions and factors

    _GDIPlus_GraphicsFillEllipse($hGraphics, 100, 50, 380, 500, $hBrush) ;draw the egg

    Sleep(2000)

    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000 + $iBgColor) ;clear bitmap
    _GDIPlus_LineBrushSetColors($hBrush, 0xFFFFFFFF, 0xFF000000) ;change the color values to greyscale

    _GDIPlus_GraphicsFillEllipse($hGraphics, 100, 50, 380, 500, $hBrush) ;draw the egg again

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_LineBrushSetGammaCorrection

Function Reference

_GDIPlus_LineBrushSetGammaCorrection

Specifies whether gamma correction is enabled for a linear gradient brush

#include <GDIPlus.au3>
_GDIPlus_LineBrushSetGammaCorrection ( $hLineGradientBrush [, $bUseGammaCorrection = True] )

Parameters

$hLineGradientBrush | Pointer to a LinearGradientBrush object
$bUseGammaCorrection | [optional] If True, gamma correction is enabled; otherwise gamma correction is disabled

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

By default, gamma correction is disabled during creation of a LinearGradientBrush object.
Gamma correction is often done to match the intensity contrast of the gradient to the ability of the human eye to perceive intensity changes.

See Also

Search GdipSetLineGammaCorrection in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 300, $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hBrush = _GDIPlus_LineBrushCreate(0, 0, 0, 280, 0xFFFFFF00, 0xFF4020FF, 1) ;create linear gradient flipped brush

    _GDIPlus_GraphicsFillRect($hGraphics, 10, 10, 280, 280, $hBrush) ;draw the filled rectangle

    _GDIPlus_LineBrushSetGammaCorrection($hBrush)

    _GDIPlus_GraphicsFillRect($hGraphics, 310, 10, 280, 280, $hBrush) ;draw the filled rectangle

    _GDIPlus_GraphicsDrawString($hGraphics, "w/o gamma correction", 14, 14)
    _GDIPlus_GraphicsDrawString($hGraphics, "w/ gamma correction", 314, 14)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_LineBrushSetLinearBlend

Function Reference

_GDIPlus_LineBrushSetLinearBlend

Sets the blend shape of a linear gradient brush to create a custom blend based on a triangular shape

#include <GDIPlus.au3>
_GDIPlus_LineBrushSetLinearBlend ( $hLineGradientBrush, $fFocus [, $fScale = 1] )

Parameters

$hLineGradientBrush | Pointer to a LinearGradientBrush object
$fFocus | Number in the range 0.0 to 1.0 that specifies the position of the ending color
$fScale | [optional] Number in the range 0.0 to 1.0 that specifies the percentage of the gradient's ending color that gets blended, at the focus position, with the gradient's starting color. The default value is 1, which specifies that the ending color is at full intensity

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_LineBrushSetSigmaBlend

See Also

Search GdipSetLineLinearBlend in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush

    $hGUI = GUICreate("GDI+", 400, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_LineBrushCreate(10, 10, 390, 390, 0xFF000000, 0xFFFFFFFF)

    _GDIPlus_LineBrushSetLinearBlend($hBrush, 0.5)

    _GDIPlus_GraphicsFillRect($hGraphic, 10, 10, 380, 380, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_LineBrushSetPresetBlend

Function Reference

_GDIPlus_LineBrushSetPresetBlend

Sets the colors to be interpolated for a linear gradient brush and their corresponding blend positions

#include <GDIPlus.au3>
_GDIPlus_LineBrushSetPresetBlend ( $hLineGradientBrush, $aInterpolations )

Parameters

$hLineGradientBrush | Pointer to a LinearGradientBrush object
$aInterpolations | Array of blend colors and blend positions: [0][0] - Number of blend colors and blend positions, must be at least 2 [1][0] - Color 1 [1][1] - Position 1 [2][0] - Color 2 [2][1] - Position 2 [n][0] - Color n [n][1] - Position n

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipSetLinePresetBlend in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 300, $iBgColor = 0x303030 ;$iBgColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)

    Local $hBrush = _GDIPlus_LineBrushCreate(0, 0, 580, 280, 0, 0, 1) ;create line brush

    Local $aInterpolations[5][2] ;define the interpolated colors and positions
    $aInterpolations[0][0] = 4
    $aInterpolations[1][0] = 0xFFFF0000 ;Red
    $aInterpolations[1][1] = 0 ;0% from the left
    $aInterpolations[2][0] = 0xFF00FF00 ;Green
    $aInterpolations[2][1] = 0.3 ;To 30% from the left
    $aInterpolations[3][0] = 0xFF0000FF ;Blue
    $aInterpolations[3][1] = 0.7 ;To 70% from the left
    $aInterpolations[4][0] = 0xFFFFFF00 ;Yellow
    $aInterpolations[4][1] = 1 ;To 100% from the left

    _GDIPlus_LineBrushSetPresetBlend($hBrush, $aInterpolations) ;set the linear gradient brush colors and position

    _GDIPlus_GraphicsFillRect($hGraphics, 10, 10, 580, 280, $hBrush) ;draw bitmap to screen

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_LineBrushSetSigmaBlend

Function Reference

_GDIPlus_LineBrushSetSigmaBlend

Sets the blend shape of a linear gradient brush to create a custom blend based on a bell-shaped curve

#include <GDIPlus.au3>
_GDIPlus_LineBrushSetSigmaBlend ( $hLineGradientBrush, $fFocus [, $fScale = 1] )

Parameters

$hLineGradientBrush | Pointer to a LinearGradientBrush object
$fFocus | Number in the range 0.0 to 1.0 that specifies the position of the ending color
$fScale | [optional] Number in the range 0.0 to 1.0 that specifies the percentage of the gradient's ending

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipSetLineSigmaBlend in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 300, $iBgColor = 0x303030 ;$iBgColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)

    Local $hBrush = _GDIPlus_LineBrushCreate(0, 0, 0, 280, 0xFFFFFF00, 0xFF0000FF, 1) ;create line brush

    _GDIPlus_GraphicsFillRect($hGraphics, 10, 10, 280, 280, $hBrush) ;draw the filled rectangle

    _GDIPlus_LineBrushSetSigmaBlend($hBrush, 0.333, .85)

    _GDIPlus_GraphicsFillRect($hGraphics, 310, 10, 280, 280, $hBrush) ;draw the filled rectangle

    _GDIPlus_GraphicsDrawString($hGraphics, "w/o sigma blend", 14, 14)
    _GDIPlus_GraphicsDrawString($hGraphics, "w/ sigma blend", 314, 14)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_LineBrushSetTransform

Function Reference

_GDIPlus_LineBrushSetTransform

Sets the transformation matrix of a linear gradient brush

#include <GDIPlus.au3>
_GDIPlus_LineBrushSetTransform ( $hLineGradientBrush, $hMatrix )

Parameters

$hLineGradientBrush | Pointer to a LinearGradientBrush object
$hMatrix | Pointer to a Matrix object that specifies the transformation matrix

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipSetLineTransform in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hMatrix

    $hGUI = GUICreate("GDI+", 420, 420)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_LineBrushCreate(10, 10, 410, 410, 0xFF000000, 0xFFFFFFFF, 3)
    _GDIPlus_LineBrushSetSigmaBlend($hBrush, 1)

    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixRotate($hMatrix, 45)

    _GDIPlus_LineBrushSetTransform($hBrush, $hMatrix)

    _GDIPlus_GraphicsFillRect($hGraphic, 10, 10, 400, 400, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


User Defined Functions

SolidBrush user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_BrushCreateSolid | Create a solid Brush object
_GDIPlus_BrushGetSolidColor | Get the color of a Solid Brush object
_GDIPlus_BrushSetSolidColor | Set the color of a Solid Brush object


Function _GDIPlus_BrushCreateSolid

Function Reference

_GDIPlus_BrushCreateSolid

Create a solid Brush object

#include <GDIPlus.au3>
_GDIPlus_BrushCreateSolid ( [$iARGB = 0xFF000000] )

Parameters

$iARGB [optional] Alpha, Red, Green and Blue components of brush

Return Value

Success: | a handle to a solid Brush object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the Brush object, call _GDIPlus_BrushDispose() to release the resources.

Related

_GDIPlus_BrushDispose

See Also

Search GdipCreateSolidFill in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hBrush1, $hBrush2

    ; Create GUI
    GUICreate("GDI+", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create brushes
    _GDIPlus_Startup()
    $hBrush1 = _GDIPlus_BrushCreateSolid()
    $hBrush2 = _GDIPlus_BrushClone($hBrush1)

    ; Show brush information
    MemoWrite("Brush 1 handle : 0x" & Hex($hBrush1))
    MemoWrite("Brush 1 type ..: " & _GDIPlus_BrushGetType($hBrush1))
    MemoWrite("Brush 2 handle : 0x" & Hex($hBrush2))
    MemoWrite("Brush 2 type ..: " & _GDIPlus_BrushGetType($hBrush2))

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush2)
    _GDIPlus_BrushDispose($hBrush1)
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GDIPlus_BrushGetSolidColor

Function Reference

_GDIPlus_BrushGetSolidColor

Get the color of a Solid Brush object

#include <GDIPlus.au3>
_GDIPlus_BrushGetSolidColor ( $hBrush )

Parameters

$hBrush Handle to a Brush object

Return Value

Success: | the brush color.
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetSolidFillColor in MSDN Library.

Example

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

Example()

Func Example()
    Local $hGUI, $idLabel1, $idLabel2, $hGraphic, $hBrush1, $iClr1, $iClr2

    ; Create GUI
    $hGUI = GUICreate("GDI+", 345, 150)
    $idLabel1 = GUICtrlCreateLabel("", 2, 2, 150, 20)
    $idLabel2 = GUICtrlCreateLabel("", 202, 2, 150, 20)
    GUISetState(@SW_SHOW)
    Sleep(100)

    ; Start GDIPlus
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)

    ; Create solid brush
    $hBrush1 = _GDIPlus_BrushCreateSolid()

    ; Get solid brush color
    $iClr1 = _GDIPlus_BrushGetSolidColor($hBrush1)

    ; Draw some graphics with the original brush color
    _GDIPlus_GraphicsFillEllipse($hGraphic, 25, 25, 100, 100, $hBrush1)

    ; Set new brush color (0xFFFF0000 = Red)
    _GDIPlus_BrushSetSolidColor($hBrush1, 0xFFFF0000)

    ; Get new solid brush color
    $iClr2 = _GDIPlus_BrushGetSolidColor($hBrush1)

    ; Draw some graphics with the new brush color
    _GDIPlus_GraphicsFillRect($hGraphic, 220, 25, 100, 100, $hBrush1)

    ; Write original brush color to Label1
    GUICtrlSetData($idLabel1, "Brush orignal color: " & Hex($iClr1))

    ; Write the new brush color to Label2
    GUICtrlSetData($idLabel2, "Brush new color: " & Hex($iClr2))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush1)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_BrushSetSolidColor

Function Reference

_GDIPlus_BrushSetSolidColor

Set the color of a Solid Brush object

#include <GDIPlus.au3>
_GDIPlus_BrushSetSolidColor ( $hBrush [, $iARGB = 0xFF000000] )

Parameters

$hBrush | Handle to a Brush object
$iARGB | [optional] Alpha, Red, Green and Blue components of brush

Return Value

Success: | True
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipSetSolidFillColor in MSDN Library.

Example

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

Example()

Func Example()
    Local $hGUI, $idLabel1, $idLabel2, $hGraphic, $hBrush1, $iClr1, $iClr2

    ; Create GUI
    $hGUI = GUICreate("GDI+", 345, 150)
    $idLabel1 = GUICtrlCreateLabel("", 2, 2, 150, 30)
    $idLabel2 = GUICtrlCreateLabel("", 202, 2, 150, 30)
    GUISetState(@SW_SHOW)
    Sleep(100)

    ; Start GDIPlus
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)

    ; Create solid brush
    $hBrush1 = _GDIPlus_BrushCreateSolid()

    ; Get solid brush original color
    $iClr1 = _GDIPlus_BrushGetSolidColor($hBrush1)

    ; Draw some graphics with the original brush color
    _GDIPlus_GraphicsFillEllipse($hGraphic, 25, 35, 100, 100, $hBrush1)

    ; Set new brush color (0xFFFF0000 = Red)
    _GDIPlus_BrushSetSolidColor($hBrush1, 0xFFFF0000)

    ; Get solid brush new color
    $iClr2 = _GDIPlus_BrushGetSolidColor($hBrush1)

    ; Draw some graphics with the new brush color
    _GDIPlus_GraphicsFillRect($hGraphic, 220, 35, 100, 100, $hBrush1)

    ; Write original brush color to Label1
    GUICtrlSetData($idLabel1, "Brush orignal color: " & Hex($iClr1))

    ; Write the new brush color to Label2
    GUICtrlSetData($idLabel2, "Brush new color: " & Hex($iClr2))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush1)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


User Defined Functions

TextureBrush user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_TextureCreate | Creates a TextureBrush object based on an image and a wrap mode
_GDIPlus_TextureCreate2 | Creates a TextureBrush object based on an image, a wrap mode and a defining rectangle
_GDIPlus_TextureCreateIA | Creates a TextureBrush object based on an image, a defining rectangle, and a set of image properties


Function _GDIPlus_TextureCreate

Function Reference

_GDIPlus_TextureCreate

Creates a TextureBrush object based on an image and a wrap mode

#include <GDIPlus.au3>
_GDIPlus_TextureCreate ( $hImage [, $iWrapMode = 0] )

Parameters

$hImage | Pointer to an Image object
$iWrapMode | [optional] Wrap mode that specifies how repeated copies of an image are used to tile an area when it is 0 - Tiling without flipping 1 - Tiles are flipped horizontally as you move from one tile to the next in a row 2 - Tiles are flipped vertically as you move from one tile to the next in a column 3 - Tiles are flipped horizontally as you move along a row and flipped vertically as you move along a column 4 - No tiling takes place

Return Value

Success: | a pointer to a new TextureBrush object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

The size of the brush defaults to the size of the image, so the entire image is used by the brush.
After you are done with the object, call _GDIPlus_BrushDispose() to release the object resources.

Related

_GDIPlus_BrushDispose

See Also

Search GdipCreateTexture in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgboxConstants.au3>

Example()

Func Example()
    ; X64 running support
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"

    ;get AutoIt install dir
    Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt"

    Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif"
    If Not FileExists($sFile) Then
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30)
        Return False
    EndIf

    _GDIPlus_Startup()
    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile) ;create an image object based on a file
    If @error Then
        _GDIPlus_Shutdown()
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "An error has occured - unable to load image!", 30)
        Return False
    EndIf

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", 320, 200)
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a Graphics object from a window handle
    _GDIPlus_GraphicsClear($hGraphics, 0xFF404040) ;clear graphic handle with dark grey (background)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hTexture = _GDIPlus_TextureCreate($hImage)
    _GDIPlus_GraphicsFillEllipse($hGraphics, 10, 40, 300, 120, $hTexture) ;draw ellipse with texture as a brush

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup resources
    _GDIPlus_BrushDispose($hTexture)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_TextureCreate2

Function Reference

_GDIPlus_TextureCreate2

Creates a TextureBrush object based on an image, a wrap mode and a defining rectangle

#include <GDIPlus.au3>
_GDIPlus_TextureCreate2 ( $hImage, $nX, $nY, $nWidth, $nHeight [, $iWrapMode = 0] )

Parameters

$hImage | Pointer to an Image object
$nX | Leftmost coordinate of the image portion to be used by this brush
$nY | Uppermost coordinate of the image portion to be used by this brush
$nWidth | Width of the brush and width of the image portion to be used by the brush
$nHeight | Height of the brush and height of the image portion to be used by the brush
$iWrapMode | [optional] Wrap mode that specifies how repeated copies of an image are used to tile an area when it is 0 - Tiling without flipping 1 - Tiles are flipped horizontally as you move from one tile to the next in a row 2 - Tiles are flipped vertically as you move from one tile to the next in a column 3 - Tiles are flipped horizontally as you move along a row and flipped vertically as you move along a column 4 - No tiling takes place

Return Value

Success: | a pointer to a new TextureBrush object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_BrushDispose() to release the object resources.

Related

_GDIPlus_BrushDispose

See Also

Search GdipCreateTexture2 in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; X64 running support
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"

    ;get AutoIt install dir
    Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt"

    Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif"
    If Not FileExists($sFile) Then
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30)
        Return False
    EndIf

    _GDIPlus_Startup()
    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile) ;create an image object based on a file
    If @error Then
        _GDIPlus_Shutdown()
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "An error has occured - unable to load image!", 30)
        Return False
    EndIf

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", 320, 200)
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a Graphics object from a window handle
    _GDIPlus_GraphicsClear($hGraphics, 0xFF404040) ;clear graphic handle with dark grey (background)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hTexture = _GDIPlus_TextureCreate2($hImage, 5, 4, 59, 59) ;create texture brush only from a defined rectangle
    _GDIPlus_GraphicsFillEllipse($hGraphics, 10, 40, 300, 120, $hTexture) ;draw ellipse with texture as a brush

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup resources
    _GDIPlus_BrushDispose($hTexture)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_TextureCreateIA

Function Reference

_GDIPlus_TextureCreateIA

Creates a TextureBrush object based on an image, a defining rectangle, and a set of image properties

#include <GDIPlus.au3>
_GDIPlus_TextureCreateIA ( $hImage, $nX, $nY, $nWidth, $nHeight [, $pImageAttributes = 0] )

Parameters

$hImage | Pointer to an image object
$nX | Leftmost coordinate of the image portion to be used by this brush
$nY | Uppermost coordinate of the image portion to be used by this brush
$nWidth | Width of the brush and width of the image portion to be used by the brush
$nHeight | Height of the brush and height of the image portion to be used by the brush
$pImageAttributes | [optional] Pointer to an ImageAttributes object that contains properties of the image

Return Value

Success: | a pointer to a new TextureBrush object.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_BrushDispose() to release the object resources.

Related

_GDIPlus_BrushDispose, _GDIPlus_ImageAttributesCreate, _GDIPlus_ImageAttributesDispose

See Also

Search GdipCreateTextureIA in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <Screencapture.au3>

Global $g_hHBitmap, $g_hGfxCtxt, $g_hBMP, $g_hGfx
Global $g_iTiles = 24, $g_a_hBmp_Tiles[$g_iTiles][$g_iTiles]

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    Local $iW = 576, $iH = 576, $iTMP, $iSin = 0, $iMulti = 256 / $g_iTiles, $2Multi = 2 * $iMulti, _
            $hCtxt, $hTextureIA, $fValue, $iFrameTimer = TimerInit()

    _GDIPlus_Startup()
    $g_hHBitmap = _ScreenCapture_Capture("", 0, 0, $g_iTiles ^ 2, $g_iTiles ^ 2) ;capture the desktop and save it in memory in GDI format
    Local $hImage = _GDIPlus_BitmapCreateFromHBITMAP($g_hHBitmap) ;convert the GDI bitmap to GDI+ bitmap
    ; Local $iImgW = _GDIPlus_ImageGetWidth($hImage) ;get the width of the image
    ; Local $iImgH = _GDIPlus_ImageGetHeight($hImage) ;get the height of the image

    Local $hGUI = GUICreate("GDI+ TextureIA", $iW, $iH) ;create a GUI
    $g_hGfx = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphic object for displaying GDI+ graphics
    $g_hBMP = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $g_hGfx) ;create a bitmap object based on a graphic object
    $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBMP) ;get the graphics context of the image / bitmap

    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($g_iTiles ^ 2, $g_iTiles ^ 2) ;create an empty bitmap (needed later for texture creating)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;get the graphic context of the image / bitmap
    _GDIPlus_GraphicsDrawImageRect($hContext, $hImage, 0, 0, $g_iTiles ^ 2, $g_iTiles ^ 2) ;copy the image into the empty bitmap
    _GDIPlus_GraphicsDispose($hContext) ;release graphic context handle
    _GDIPlus_ImageDispose($hImage) ;release image handle

    Local $tCM = _GDIPlus_ColorMatrixCreateScale(0, 0, 0) ;create and initializes a scaling color matrix (5 x 5 homogeneous matrix for a 4-space transformation) -> see http://msdn.microsoft.com/en-us/library/windows/desktop/ms533875(v=vs.85).aspx
    Local $pImgAttr = _GDIPlus_ImageAttributesCreate() ;create an image attribute object (needed for color manipulation)
    Local $fSizeInv = 1 / $g_iTiles

    ;create $g_iTiles * $g_iTiles small bitmaps (tiles) to fill it up with parts of the captured image
    For $iY = 0 To $g_iTiles - 1
        For $iX = 0 To $g_iTiles - 1
            $g_a_hBmp_Tiles[$iY][$iX] = _GDIPlus_BitmapCreateFromScan0($g_iTiles, $g_iTiles) ;create an empty bitmap
            $hCtxt = _GDIPlus_ImageGetGraphicsContext($g_a_hBmp_Tiles[$iY][$iX]) ;get the graphics context of the image / bitmap
            $fValue = BitXOR($iX, $iY) * $fSizeInv
            $tCM.m(1) = 1 - $fValue ; red
            $tCM.m(7) = $fValue ;green
            $tCM.m(19) = 0.4 ;alpha
            _GDIPlus_ImageAttributesSetColorMatrix($pImgAttr, 0, True, $tCM) ;adjust the ImageAttribute color matrix for each bitmap
            $hTextureIA = _GDIPlus_TextureCreateIA($hBitmap, $iX * $g_iTiles, $iY * $g_iTiles, $g_iTiles, $g_iTiles, $pImgAttr) ;creates a texture brush object based on an image with changed image attributes
            _GDIPlus_GraphicsFillRect($hCtxt, 0, 0, $g_iTiles, $g_iTiles, $hTextureIA) ;draw rectangle filled with manipulated tile of the image to the bitmap
            _GDIPlus_GraphicsDispose($hCtxt) ;release graphic context handle
            _GDIPlus_BrushDispose($hTextureIA) ;release texture
        Next
    Next
    _GDIPlus_ImageAttributesDispose($pImgAttr) ;releases the image attributes object

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $hGUI)
    GUISetState(@SW_SHOW, $hGUI)

    While Sleep(10)
        $iSin += 25 / (1000 / TimerDiff($iFrameTimer))
        _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xB0808080) ;Clears a graphic object to a specified color
        For $iX = 0 To $g_iTiles - 1
            $iTMP = 2 * $iX * $iMulti
            For $iY = 0 To $g_iTiles - 1
                ;move each tile to its new position
                _GDIPlus_GraphicsDrawImageRect($g_hGfxCtxt, $g_a_hBmp_Tiles[$iY][$iX], _ ;bitmap handle
                        25 + 15 * Sin($iY * $iMulti / 64 + $iSin) + $iTMP, _ ;x pos
                        15 * Cos($iX * $iMulti / 64 + $iSin) + 25 + $iY * $2Multi, _ ;y pos
                        $2Multi, _ ;width
                        $2Multi) ;height
            Next
        Next
        _GDIPlus_GraphicsDrawImage($g_hGfx, $g_hBMP, 0, 0) ;draw complete drawn image into GUI
        $iFrameTimer = TimerInit()
    WEnd
EndFunc   ;==>Example

Func _Exit() ;clean up resources
    _WinAPI_DeleteObject($g_hHBitmap)
    _GDIPlus_GraphicsDispose($g_hGfxCtxt)
    _GDIPlus_BitmapDispose($g_hBMP)
    _GDIPlus_GraphicsDispose($g_hGfx)
    For $iY = 0 To $g_iTiles - 1
        For $iX = 0 To $g_iTiles - 1
            _GDIPlus_BitmapDispose($g_a_hBmp_Tiles[$iY][$iX])
        Next
    Next
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>_Exit


User Defined Functions

Effect user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_EffectCreate | Creates an Effect object of the type specified by the guid parameter
_GDIPlus_EffectCreateBlur | Creates a Blur class effect object
_GDIPlus_EffectCreateBrightnessContrast | Creates a BrightnessContrast class effect object
_GDIPlus_EffectCreateColorBalance | Creates a ColorBalance class effect object
_GDIPlus_EffectCreateColorCurve | Creates a ColorBalance class effect object
_GDIPlus_EffectCreateColorLUT | Creates a ColorLUT class effect object
_GDIPlus_EffectCreateColorMatrix | Creates a ColorMatrixEffect class effect object
_GDIPlus_EffectCreateHueSaturationLightness | Creates a HueSaturationLightness class effect object
_GDIPlus_EffectCreateLevels | Creates a Levels class effect object
_GDIPlus_EffectCreateRedEyeCorrection | Creates a RedEyeCorrection class effect object
_GDIPlus_EffectCreateSharpen | Creates a Sharpen class effect object
_GDIPlus_EffectCreateTint | Creates a Tint class effect object
_GDIPlus_EffectDispose | Deletes the specified Effect object
_GDIPlus_EffectGetParameters | Returns the parameters for the specified Effect object
_GDIPlus_EffectSetParameters | Sets the parameters for the specified Effect object


Function _GDIPlus_EffectCreate

Function Reference

_GDIPlus_EffectCreate

Creates an Effect object of the type specified by the guid parameter

#include <GDIPlus.au3>
_GDIPlus_EffectCreate ( $sEffectGUID )

Parameters

$sEffectGUID Effect Guid constant that specifies the kind of effect to create.

Return Value

Success: | a handle to an Effect object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameter.

Remarks

When you are done with the Effect object, call _GDIPlus_EffectDispose() to release the resources.

Related

_GDIPlus_EffectDispose, _GDIPlus_EffectGetParameters, _GDIPlus_EffectSetParameters

See Also

Search GdipCreateEffect in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * 600 / _GDIPlus_ImageGetWidth($hImage)

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    Local $hEffect = _GDIPlus_EffectCreate($GDIP_BlurEffectGuid)
    _GDIPlus_BitmapApplyEffect($hImage, $hEffect)

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


Function _GDIPlus_EffectCreateBlur

Function Reference

_GDIPlus_EffectCreateBlur

Creates a Blur class effect object

#include <GDIPlus.au3>
_GDIPlus_EffectCreateBlur ( [$fRadius = 10.0 [, $bExpandEdge = False]] )

Parameters

$fRadius | [optional] Real number that specifies the blur radius (the radius of the Gaussian convolution kernel) in pixels. The radius must be in the range 0.0 through 255.0.
$bExpandEdge | [optional] Boolean value that specifies whether the bitmap expands by an amount equal to the blur radius. If TRUE, the bitmap expands by an amount equal to the radius so that it can have soft edges. If FALSE, the bitmap remains the same size and the soft edges are clipped.

Return Value

Success: | a handle to an Effect object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Remarks

When you are done with the Effect object, call _GDIPlus_EffectDispose() to release the resources.

Related

_GDIPlus_EffectCreate, _GDIPlus_EffectDispose

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * 600 / _GDIPlus_ImageGetWidth($hImage)

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    Local $hEffect = _GDIPlus_EffectCreateBlur()
    _GDIPlus_BitmapApplyEffect($hImage, $hEffect)

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


Function _GDIPlus_EffectCreateBrightnessContrast

Function Reference

_GDIPlus_EffectCreateBrightnessContrast

Creates a BrightnessContrast class effect object

#include <GDIPlus.au3>
_GDIPlus_EffectCreateBrightnessContrast ( [$iBrightnessLevel = 0 [, $iContrastLevel = 0]] )

Parameters

$iBrightnessLevel | [optional] Integer in the range -255 through 255 that specifies the brightness level.
$iContrastLevel | [optional] Integer in the range -100 through 100 that specifies the contrast level.

Return Value

Success: | a handle to an Effect object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Remarks

When you are done with the Effect object, call _GDIPlus_EffectDispose() to release the resources.

Related

_GDIPlus_EffectCreate, _GDIPlus_EffectDispose

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * 600 / _GDIPlus_ImageGetWidth($hImage)

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    Local $hEffect = _GDIPlus_EffectCreateBrightnessContrast(-40, 10)
    _GDIPlus_BitmapApplyEffect($hImage, $hEffect)

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


Function _GDIPlus_EffectCreateColorBalance

Function Reference

_GDIPlus_EffectCreateColorBalance

Creates a ColorBalance class effect object

#include <GDIPlus.au3>
_GDIPlus_EffectCreateColorBalance ( [$iCyanRed = 0 [, $iMagentaGreen = 0 [, $iYellowBlue = 0]]] )

Parameters

$iCyanRed | [optional] Integer in the range -100 through 100 that specifies a change in the amount of red in the image.
$iMagentaGreen | [optional] Integer in the range -100 through 100 that specifies a change in the amount of green in the image.
$iYellowBlue | [optional] Integer in the range -100 through 100 that specifies a change in the amount of blue in the image.

Return Value

Success: | a handle to an Effect object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Remarks

When you are done with the Effect object, call _GDIPlus_EffectDispose() to release the resources.

Related

_GDIPlus_EffectCreate, _GDIPlus_EffectDispose

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * 600 / _GDIPlus_ImageGetWidth($hImage)

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    Local $hEffect = _GDIPlus_EffectCreateColorBalance(-30, 20, 10)
    _GDIPlus_BitmapApplyEffect($hImage, $hEffect)

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


Function _GDIPlus_EffectCreateColorCurve

Function Reference

_GDIPlus_EffectCreateColorCurve

Creates a ColorBalance class effect object

#include <GDIPlus.au3>
_GDIPlus_EffectCreateColorCurve ( $iAdjustment, $iChannel, $iAdjustValue )

Parameters

$iAdjustment | CurveAdjustments constant that specifies the adjustment to be applied ($GDIP_Adjust*).
$iChannel | CurveChannel constant that specifies the color channel to which the adjustment applies ($GDIP_CurveChannel*).
$iAdjustValue | Integer that specifies the intensity of the adjustment. The range of acceptable values depends on which adjustment is being applied (see $GDIP_Adjust* constants).

Return Value

Success: | a handle to an Effect object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Remarks

When you are done with the Effect object, call _GDIPlus_EffectDispose() to release the resources.

Related

_GDIPlus_EffectCreate, _GDIPlus_EffectDispose

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * 600 / _GDIPlus_ImageGetWidth($hImage)

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    Local $hEffect = _GDIPlus_EffectCreateColorCurve($GDIP_AdjustMidtone, $GDIP_CurveChannelRed, 30)
    _GDIPlus_BitmapApplyEffect($hImage, $hEffect)

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


Function _GDIPlus_EffectCreateColorLUT

Function Reference

_GDIPlus_EffectCreateColorLUT

Creates a ColorLUT class effect object

#include <GDIPlus.au3>
_GDIPlus_EffectCreateColorLUT ( $aColorLUT )

Parameters

$aColorLUT An array[256][4] of a color lookup table for the color channels, alpha, red, green, and blue:
[0][0] - first adjustment value for the alpha channel
[0][1] - first adjustment value for the red channel
[0][2] - first adjustment value for the green channel
[0][3] - first adjustment value for the blue channel
[1][0] - second adjustment value for the alpha channel
[1][1] - second adjustment value for the red channel
[1][2] - second adjustment value for the green channel
[1][3] - second adjustment value for the blue channel
...
255][0] - last adjustment value for the alpha channel
[255][1] - last adjustment value for the red channel
[255][2] - last adjustment value for the green channel
[255][3] - last adjustment value for the blue channel

Return Value

Success: | a handle to an Effect object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameter.

Remarks

A lookup table specifies how existing color channel values should be replaced by new values.
A color channel value of j is replaced by the jth entry in the lookup table for that channel.
For example, an existing blue channel value of 25 would be replaced by the value of $aColorLUT[25][3].

When you are done with the Effect object, call _GDIPlus_EffectDispose() to release the resources.

Related

_GDIPlus_EffectCreate, _GDIPlus_EffectDispose

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * 600 / _GDIPlus_ImageGetWidth($hImage)

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    Local $aColorLUT[256][4]
    For $i = 0 To 255
        $aColorLUT[$i][0] = $i
        $aColorLUT[$i][1] = 0
        $aColorLUT[$i][2] = 0
        $aColorLUT[$i][3] = $i
    Next

    Local $hEffect = _GDIPlus_EffectCreateColorLUT($aColorLUT)
    _GDIPlus_BitmapApplyEffect($hImage, $hEffect)

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


Function _GDIPlus_EffectCreateColorMatrix

Function Reference

_GDIPlus_EffectCreateColorMatrix

Creates a ColorMatrixEffect class effect object

#include <GDIPlus.au3>
_GDIPlus_EffectCreateColorMatrix ( $tColorMatrix )

Parameters

$tColorMatrix ColorMatrix structure.

Return Value

Success: | a handle to an Effect object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameter.

Remarks

When you are done with the Effect object, call _GDIPlus_EffectDispose() to release the resources.

Related

_GDIPlus_ColorMatrixCreate, _GDIPlus_ColorMatrixCreateGrayScale, _GDIPlus_EffectCreate, _GDIPlus_EffectDispose

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * 600 / _GDIPlus_ImageGetWidth($hImage)

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    Local $tColorMatrix = _GDIPlus_ColorMatrixCreateGrayScale()

    Local $hEffect = _GDIPlus_EffectCreateColorMatrix($tColorMatrix)
    _GDIPlus_BitmapApplyEffect($hImage, $hEffect)

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


Function _GDIPlus_EffectCreateHueSaturationLightness

Function Reference

_GDIPlus_EffectCreateHueSaturationLightness

Creates a HueSaturationLightness class effect object

#include <GDIPlus.au3>
_GDIPlus_EffectCreateHueSaturationLightness ( [$iHueLevel = 0 [, $iSaturationLevel = 0 [, $iLightnessLevel = 0]]] )

Parameters

$iHueLevel | [optional] Integer in the range -180 through 180 that specifies the change in hue.
$iSaturationLevel | [optional] Integer in the range -100 through 100 that specifies the change in saturation.
$iLightnessLevel | [optional] Integer in the range -100 through 100 that specifies the change in lightness.

Return Value

Success: | a handle to an Effect object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Remarks

When you are done with the Effect object, call _GDIPlus_EffectDispose() to release the resources.

Related

_GDIPlus_EffectCreate, _GDIPlus_EffectDispose

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * 600 / _GDIPlus_ImageGetWidth($hImage)

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    Local $hEffect = _GDIPlus_EffectCreateHueSaturationLightness(20, -60)
    If Not _GDIPlus_BitmapApplyEffect($hImage, $hEffect) Then MsgBox(0, "Error", "Effect not Applied")

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


Function _GDIPlus_EffectCreateLevels

Function Reference

_GDIPlus_EffectCreateLevels

Creates a Levels class effect object

#include <GDIPlus.au3>
_GDIPlus_EffectCreateLevels ( [$iHighlight = 100 [, $iMidtone = 0 [, $iShadow = 0]]] )

Parameters

$iHighlight | [optional] Integer in the range 0 through 100 that specifies which pixels should be lightened.
$iMidtone | [optional] Integer in the range -100 through 100 that specifies how much to lighten or darken an image.
$iShadow | [optional] Integer in the range 0 through 100 that specifies which pixels should be darkened.

Return Value

Success: | a handle to an Effect object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Remarks

When you are done with the Effect object, call _GDIPlus_EffectDispose() to release the resources.

Related

_GDIPlus_EffectCreate, _GDIPlus_EffectDispose

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * 600 / _GDIPlus_ImageGetWidth($hImage)

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    Local $hEffect = _GDIPlus_EffectCreateLevels(60, -50, 20)
    _GDIPlus_BitmapApplyEffect($hImage, $hEffect)

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


Function _GDIPlus_EffectCreateRedEyeCorrection

Function Reference

_GDIPlus_EffectCreateRedEyeCorrection

Creates a RedEyeCorrection class effect object

#include <GDIPlus.au3>
_GDIPlus_EffectCreateRedEyeCorrection ( $aAreas )

Parameters

$aAreas An array of areas of the bitmap to which red eye correction should be applied:
[0][0] - Number of Area rectangles
[1][0] - X coordinate of the upper-left corner of the first rectangle
[1][1] - Y coordinate of the upper-left corner of the first rectangle
[1][2] - Width of the first rectangle
[1][3] - Height of the first rectangle
...
[n][0] - X coordinate of the upper-left corner of the nth rectangle
[n][1] - Y coordinate of the upper-left corner of the nth rectangle
[n][2] - Width of the nth rectangle
[n][3] - Height of the nth rectangle

Return Value

Success: | a handle to an Effect object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Remarks

When you are done with the Effect object, call _GDIPlus_EffectDispose() to release the resources.

Related

_GDIPlus_EffectCreate, _GDIPlus_EffectDispose

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $hBitmap = _GDIPlus_BitmapCreateFromMemory(_RedEye())

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($hBitmap) * 600 / _GDIPlus_ImageGetWidth($hBitmap)

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    Local $aAreas[3][4] = [[2]]
    $aAreas[1][0] = 50
    $aAreas[1][1] = 64
    $aAreas[1][2] = 22
    $aAreas[1][3] = 18

    $aAreas[2][0] = 155
    $aAreas[2][1] = 64
    $aAreas[2][2] = 21
    $aAreas[2][3] = 18

    Local $hEffect = _GDIPlus_EffectCreateRedEyeCorrection($aAreas)
    Local $hBitmap_FX = _GDIPlus_BitmapCreateApplyEffect($hBitmap, $hEffect)

    Local $iTimer = TimerInit(), $iStep = 0
    Do
        If TimerDiff($iTimer) > 400 Then
            Switch Mod($iStep, 2)
                Case 0
                    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight)
                Case Else
                    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap_FX, 0, 0, $iWidth, $iHeight)
            EndSwitch
            $iStep += 1
            $iTimer = TimerInit()
        EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hBitmap_FX)
    _GDIPlus_ImageDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example

; Code below was generated by: 'File to Base64 String' Code Generator v1.11 Build 2012-10-13
Func _RedEye($bSaveBinary = False)
    Local $sRedEye
    $sRedEye &= '/9j/4AAQSkZJRgABAQEBLAEsAAD//gBERmlsZSBzb3VyY2U6IGh0dHA6Ly9jb21tb25zLndpa2ltZWRpYS5vcmcvd2lraS9GaWxlOkJvbGRSZWRFeWUuSlBH/9sAQwAGBAUGBQQGBgUGBwcGCAoQCgoJCQoUDg8MEBcUGBgXFBYWGh0lHxobIxwWFiAsICMmJykqKRkfLTAtKDAlKCko/9sAQwEHBwcKCAoTCgoTKBoWGigoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgo/8AAEQgApgDcAwERAAIRAQMRAf/EABwAAAIDAQEBAQAAAAAAAAAAAAQFAgMGAQcACP/EADoQAAEDAwMCBAQFAwMDBQAAAAECAxEABCESMUEFURMiYXEGMoGhFCORweFCsfAHFdFSYvEkMzRygv/EABsBAAMBAQEBAQAAAAAAAAAAAAABAgMEBQYH/8QALREBAQACAgICAQIFAwUAAAAAAAECEQMhEjEEQVEiYQUGExRxQoGhJDJSkfD/2gAMAwEAAhEDEQA/APz48gpdSFxsNhGKxl3F+jDp6PNrAGpPyzx61GS4eWQyCdRjJ9TWTVorJtRhMDURPtSBkhARhBlXekqdmVqyTGoTUqhm00MYNGj2MbTkE49qcidi29qqQhLfy1chVYlMmno1yEiNvtTkRRCR9OMVWifJmSOx4xRVVIDOFEEcmiRNUPtlbqFJWRpmUjY0rF43UsS0jahG1ZbP6UrFxBYjap0c7VKGPWosAR0CKhUBvNlXBPsYNI9gH0KG8n33/mgwqgDIj3FEKgbgQCAJqoik1+jW04kzkHfjFaRFY/rNuEqSZ8hBTvlOP7U76Tj7S6Q6H7FtTiApQ8pkbRxUZzWSp3NlfU2dQsXW9ID7ZV6T/hrpnW2E9D7JCUNJQkhWZJ7mNvp+9ZVrjDK18ziUjISJ/moW0tpDbSRMqO570aI0tGSrzq+9LRmjIhExjg0aaQSFgQSdIqtBcy4FL8uR60aPQ1tdIaGNbCrkTRA2mq0hagTE5qoVEJG+N6aduhICcCTM5pK7rigUqEiCTikESmRn/wAU9BBKCCe9LRbdKYETnvRo1Lon60rFwO4Y/io0Aj2SeKXiqKVL04IMVPiNKXkpUnM1OgV3TJQdSRijQtLrjzICxmhNJb4lJ1jMferiazfWEA27gI+QggntxVe4i+2et7t2zC220SlStY+tVcZlq0t63FK3tTTLJJPhOK0k8Aj+K0tRIeWbRQ0hIGSMeg5NY1rDG0SUuiEwP7etJTQ9NSXnRGopGJNPSY0TJQ2IJE05D2rd6i0AACYJ37+1Vo5URfs6wVHzRsVAq/ip0qZDbV3xIXq32ANCpls0tipUSPYUlbMWdJAyf1pyooxsmfp+tWiwQhJBM881UTV6Ewc04lfoMSmIGc5ooiBQRvINI9q1JiIGTzQFTuDIG3pSp4oEiJoUqWpINKmCUsKWQCPripP1Aa1gLUkqEnNI/IHcXISSFHTH3oG0W7xonSVZO4najSUnmkuNykgyJ33qLDlI7tstLUDgHY+tLRUhv0ykjOftTG2cvzLQ1n/sVVSpsZ5Q8JxaCkEhUY2qoizd2X9OUXLsFKdzIB4rTJOLYWrfhoBJzGSd6wraReySDrGTskE81Um0ZVp7FTdnZglxOo7kGq0MQd11+1blAfQARmM/f/JoVZSm56yh1ZW04pSThJcHmV7J4H0p6AO1umnipK71SVTBSpMQarVntNu/Qxm6ftilVtdock/0mBjjNKw/KtN0r4pAeQzdtwv/ALgRHrU3D7h45thZ9TZUlGs6Z5UcGonTT36O7d9BkJM+npVypspiyQdiCO1XKzsEoAKfTmqT6XkAI1HcDnOfagoiYkeU95AoNU4kQoxgmAaVOBlYHc/vSMO6tJSok4QYE/c0jlJOodWatwSqcZJMJAqVst1D4muC4U21vrO6ScSO9OYouTOXvxF1'
    $sRedEye &= 'ArOrwSUn5UqkpzzGKeoUpXdfENw2om58QKB3TnApa2qZGHTeutPs6m7htZmdKsKH+fpS8Rv8NH0Prra0Bm4VgGW1k+UzwTx6UrNjejC88N9k6fv3qDrK3xJJ4J78GjRQrubcOoIgeYH9aSmUfa8N0pUClQ3FUWN67C/DzAUouGSoCtOSssJtqm8NxMH+9ZNXC94SmUgAqHnIJwAOSe1aY9dssp5JOKfvguXJbmCSPKPTnFFazroX0z4fLgCglvuVaJMekzSVO2s6V0W1t0yhpQWRlYWZNVImz7GP9FauT+c23qHyuASfrVzSMpSPqHw34eUMp1JyHECJHrTiKXm3ctyfERqCRqMYjfIpUTHY3p9yWXAmAtteyTz/AMVF7bS6aTpnU1hTYDhKTlGrcenrU2aXLuNjZXOpIE+sU5UXExYcgTVyoyglLkgD709lpzVI3A9KNhStUpInAoMK6+EBZ3jIFLehpnOoX5aUGgVKUQVQkx+vae9JWmT6ktakhy71LbSoBDA2KvX0G/3NMr2X+Cp9Di3Z850hCTE9v1/aqlZ2Jo6bc3DgZs7ZCTGVK2SPT/xS/c9dDLb4EaMuXhS4snUQjE/rRTl+nLr4Dt3o8JZZAEAaJI//AFg/ep0ry0Su/C950t8OsvKdRMQ4mCB/9hx7zSqtjLTqJadDa8EQmDiPQ+nY1FgVXjgcccUDJmTRfSZ1dBFIKkkCe/tUNCK/ZL1ypStM7VU7Z3ou6I14bIVEathzFPO7owhykZAAmak8lbDQd6iSDITA/ea1k6Zz20tpbeIpKdIhPv8A806vFpbVpKUpxEdqTTGjUGCRxxmj0L2tQ8EgExSo19Ol9JnjuKPLRXDahbDLypWhOrvFHkVxilfSbc6dKYIyCOKWzjjdiln+kGFBQMRpNK0Q7snCdOoaVIx7ikrZ2w4SBzWkRYKSrA00yT1R6RQkM6uATztRtRY+4daQRMSY79v89Km1Wid61Lzq1KUZOSR3pbO/srPSmSoKckwIAPanLtO3RYMCQRvMnn6dqflpnrYxgMtICUJAA4SKN09L0PoTiYPaKo/FLxEqJ8wPrSGgd22FmFEmeJop4sx1vpwCSUpBAGApUR/naoUQ3aFJW2o6p+RXtxR9IvtE/Kd+1RYuFlxAcIKCT3BiiFZ2VdPTqCEztjHEVWXtOHo2bQCT2p4wsqs6Y2UvOqOBPG5/itERprBIG/alV4myCiDmCPWprWbiDlygEeH+vFTuq9e1RWpTka3M8JEf3pzG0vOOhDqlYdUD2Io8RMtuKcumMrGtPJTvU+j6plYXqX0DSoH3pys7jocqNjzRRK60dJxydqKqG9qvyg80Siz6MmzEHea0iKmv9T3oIFcqgHueKV6VCq4c86lbCKi1QdChpkfSiJyvaq5uUtJ8xg096KSlar515csNlSf+o4FEV46QUu+SCsltATk4JgVXjaPLGJfirpAElBnbBTP96PGiZY1c11HzaHUqQTidwfrS3YfjL6FF0rgpxGfenLsrNB7oJdRCgDI2ImlYW2U6u1oShKZA1YHalE5KFo33ippz0V3A/M3Imp7Mq6Qjyt8mK0vtGPo7aR5ZiqxKrLREL0iqQ0NmkBIJ3FTWmL6/vEoPhiQecR96nW7pr5am2bT1i96i+7b9Fti+oSFOqw2kenetsMHNycmu6cWvwj8QXfhuvdY/DqUBqbayB9e9dE4q48vmYz1Brfwl1W2uE+D8TISBjw3Ugq9fQ1X9CI/vp/4mC7brXT1zeW6b+2UrSH7VPmAjdSTxWOfx/wAOni+Zhlfeg7mj/wCZZLCknKwnZX81x3q6r0sdZQ0tX/xDCVCPpVY9scp4rm3dKomSKV6Vjdmlm8JAqd9qs+zdhcgRvxWsrPS5xY0mDNAK7xyJ9amrxJbh3zRM/WpPKq1O6UnIAA/Sq9M53S0J/FqLrxi2GcmNXqfSp211pNpXUeqEW/R2Ay0tMounmyUkcEAcYIk9q6+PhvuuDm+Rjj+6'
    $sRedEye &= 'xfwaLlKT1rrbiH9/CYc0pSrg5OecRXROH8OLL5t/0wov/gf4iYd1dN+IFPsTKW3RpPtSvF+FY/Ox/wBUIb3rHWOgQx17pgKAIDzapCv2g1z54fTt4uWZfqxvTQ/D/UnblKUOJCNQlIUrUQPcYNc9mq6plModXKPLMZilsmc6qjWeZFCaDKfJP60UT0XXTQU8cpHvS0ZT0lMtJPFVfaMT62bOkEfSqFXWzP5pV3pppwymB2qMmmLMdb8S/vE9ObUorckulJkJTvn1p4S7VnZJtsfg+wtem9NZat0ABIgqjJNdnFO3j/Kzy7hd/qB8VudPSOn2DoZWRLrvIByAP85ro8pj258OPfbz9l952FaFLdUZBcWdR+griy/iEmWp2+p4P5V+Vycc5M85hv6u/wDn8Nj8FfFz/Tbptp951dopzw3WXMlsHkGurj5ZzY7j535nw+X4nLeLlmsp/wAtZ1Doy+mS/YgqbkFaE4EEn7gRmsebinJNz23+N8nLDLxy9VV07Qh0FqQy4dj/AEK5Fef3je3rZXygm8SWnQSc7Vpe2eP7CrJ3MTUr9nVs6YE1UKxc88BEHeneikJ764iRONoqdtJiWt/mrAzJpxhnbtTdNgrIfXotWzKzyr0FTlWmG/r2P6Z0tfVFJXcoKLX5ktHcgbT9q6uDj1+rL24vl89n6MAXx58S/wC2Pf7XYL/DSnW863AO06R2PM12Y2SeTzbhepp5jcXC3HVKcTMkGHFnUec9q8/P+JTHLqWx9n8b+SflcvDMuXlmGV+tW6/y0Pwf8YO2F6i1u3FmzWoNrQ4R+WomAUmu7i5sebGZYvk/nfw/l+FzZcHPNZY//b/xXoHW2GH7J5t5CFIUDvmTHFRyarLh8tx5hYWrvw11YMOJS5ZOHxGXQYUBMFJjeDNcnI9jj/V3G7VcJu7bU0oKBGCKxXOvZZdN6wmRxmmV9hFtwmPtSKF7rKi4rCvpTLeiPpTYDKf+raqKH9umUimDK3ZBGoimh88D4a5kiMBJiTUZNcbpmEWl1b35eZWkrIgoIwoHcDt71WEuzzyljW/DvUmHWlM+IA6N0k5B9a6uPP6rzvkcHflGO/1Csnj1VZDZJfAKD3x/BrbKbxc/Hl4ZzL8FPT+pfh2rgNpZ1Oo8NXiJBU3mTpJyk43FeX8f5HL8K54zHflNP1bD5Xx/n4Y8uOfXvW9f7WL+j2n4q7QEKKluEBKAPmzv6710/Cwy48P1fb4f+ZfmcXy/lT+j3MZrf5e7Xt3a2lm2yt9ouIABGrfHNb+WnjYcdy1NMvZ67rqCnUIUhpeVApgSNiO9cHLlMr09fHD+njoZ1Up1iIJA4oncZzoNYuecZIqXRPTQWypQKuJqT7ko9qKJCW6XKo7GpXfSzp6R+JTMaY3qq5bXOoWqvxCHNK1spB06RPmnBIqMbq7rbCy9HHSet2oUBcr8FwDSdQIB9if3rsxzlntxc/x8pep089/1KsirrN0tCkqD4S43GdUADH6Vpn+rjuMc/wAfk/t/k4c2U3MbL/6rIG9BslMS34Rc8QkpAUCBETvHpXlf3PNh8e/DuM1vfrt+1cfyPi8//V8fJLjr3vr/AH/dDpFn/uPVEeFqUtSkob044gn+/wBBXo/C4Lxcc8v8vyr+Zv4jx/O+dlnwd4ySb/Ovt6/1e5RbWigtQJGxJgD/AIrTkyk9vJ4OO5emPuXFX7qUaQthGE+WdzJ5kb1yZ3b0ePUhtYshlr8txcH+lRkVk1s2LWxqTNUysBOtEoIG4PNI9AXWfzFEg5ziauaiLWb6bHhweTINUmU7YOAaSjW2y2AaBpaW5McUHoFd2X5a1IEGDtxiiXR62Tu2BQlkN6kOYyj5vQD19a1mUqNLL9m6XZJbuh4y5/LbKpMnHzcCKuZfui8WGX0h0/4ctTcrQ6hLqEpLZK25hRnKfUcTV481xu2f9rjfUOWvh9m1W08jxVaP6XDgg4MdjPasM87ft08PBjj9HvT7Jllerw0+nesr'
    $sRedEye &= 'PJvnlqagq9uiG/DQNJJgAcUXGSMZ7KL13Eb4qF4zt3p6ZWJ2pNo0NuSEyBTlLURfX5TH6UWnIT3GSZpG6ypQWCPaqrC46M7K6db8oUdI+v2q8ZuMsvay8CHZDiEzHbB/ztRcdVrheiS66Fb3ykNlspQCVLLatJ9Ej/mrxuvsuTGZTtner/Cdq2VrtluJKIUAtsHBxE8xE/WtvO/ly342G/S2z6Vc27LqrB3wH0K0KWAFKiJMTtNFyv5LHiwxvp1npVzcuOfj7hbzyFSgr+VaT6cVlbG/r16Mek9ONovAIbMphX9Pp7fzWVu1mybYBRIAA5FTo5XfD/LgigX2EfZOk+xiiFSe4BLnlgDsaaKy1h5U5gfvVlDq1OUj+9JR1ZxpBJoPQ1sZncUtq0s8KR3nigac/BIUpJ0kkAxQWkk2SQsL0gkHc96eyoli3DYJTAJOowOaexpZ4BUo+UCOZxS0vyd0aVHWJKe5x7096L31ArpASHAZByDWdu1TH6J31anDzxUr1ox6cjIoVPyfW6Ybmc04m3vSi6SQIpVWN2Uv4XkUGi2SFAfWgriYMiVBSTmnLpllj0PSmQBpCgfmB2NbTLbKTSIa0rOkxicmiz8L312kpHiJOpOoYml2lSLdtJXpABWRI+1G9Jsrn4dCVakoA7UrRJftwtwJgSTmoaSPlIjJ7cUyVuJAB3njtQAbiJ0JOfY0SFSa4SA6dRVPMU0sbbL/ADIwD6VVTicWipVSXD20kjsDS2uQ0aEpmlT0uHptSVpNBV2k7AUxZFqZ2gyc0y0uQmABuKe0Lwny5mPUUtjTjqUpTnkbGptVJSbqSiExsd6nTSQkmVx/hpi3ZzYAhIAHvSXIdshUCmm6V3JMeaJoohRcGFGalVfJAUJHFUUGWg1DP09KBTJsTGPN6U50yuK4gKgqAntVeW0+Nit3IATgU9iREo1wDwZqb2J0ivO9A0iUnMjFBuKACTPOKYDOTp0nE0iCkEmNj7bU4jImu2CXiQmfWJp6Z3Jh2TpeO2eRV0SnFgQVb4qK1h9YqwNqTWQ1ZWCkZPaKS/EQ0JIFB6EIRIx9TRImrktZ82QO5imla2jzegO45pBelHlk/rQX2483KZ3HNKwRlOvPBDhQNzSWW2oLj2ODFB4zfbTWLPlGnehVpqhJ0HNNNDvSqaR60UX6SmTSNRbvAhOaEnNsn5SNt/pTPezBKfMJkH7U7C+ktkwRn0pFrb4pO6TB5FMtflHTiTijQsR0RMgRxT0NRBZgRvS9H4qlCSBMA003pQ7CQdQzxTSBuFqTqEHJ70Ismi19KdcmZIkgHatNMba8+bUA4QJlJkexoohxYEFJqK2w7p/aKgR6Um2JowePtQ0GW5gKJneltVFtkwNMCc0t6Tr8iEnVO5o2nWl7aVGBRoroShsxjviKrSELiAkDgDilQ8+6ss3HUnA2ZAMCkvW/Y7pdvoAKhvSVrTSWbcwR2pxNujBLZKDzVaTsM63pGAB+9TYveyu9RLapk44qauELqVNHUnYGTTgyjR9Bc/EMJ9O/FOM7+TtLeOZqtDaK0ebvilYccclOIkd6Qk2gtWBERz60bPxRK9ScDIp7GtXtUogST2oFgJTyi6RPEAVMt2rLCaQfjSFGP2FWw0AdVEmJIPtTjPPoGsIWokuAe+9aRzW9vPFNli5dgeVUgTuKPoS9mljgwZgYNRXThT+2XEHmpb4wzZWMK2k0mkn0MaOpU8T96VVrQ1lMKKyeMdhUlb9D2cHOYFVEUQggenFOVOl04gnNUNfYS/c8GxcX8sAgVNK91jen22tZcVuTNIzYAIAA4pHDCxcBFVBkfMut/hzqGa0+nPd7Lbp1KcztUVtiWFfiFQJ9qhpeuwz9uFIWRFA2s+FdQfWjiYpxnl1Gq0gYmrKXaI22kzmkdQWBJxP0pU4GVkHSDUrUKGmc79jQr2pUqNvaKCoUu+YgJxsT/anBlj1vat9coAjIJidqbHRY8tXeCREE+u9XjGPJYDui'
    $sRedEye &= 'oLTITOkcxV1zMR1BJS6FxAMggimIMsly4SR8wmKzrp4+4f2sGIial0SmVqrYGY2qdtBzRmOB70KGtqlG+AaQ+xrSpkAZoTYLbO/mTHJO1OJXpOTBFVE0t+I1lVkWxvvS32Un2QdMWE28xsNqkWFfUeq3NoS7cMBNtqjUDn3qpNn3PXZ30q9beZQ60sFKtqXob8jZNwQmAZFVstQLcvApMmKR+iBHV1P3C2unsl7RusmE/Sjx/I8rTZDq120rToPINTs/sR8Np/Mec2BMCnCyaqAU7mYq2c6VE5IzPrSa6UrIB/mkYd0fMQJpKlDrViDgUjCuKIwTjgUGGdUQoJn0kU0++wr64RAPpvimzy6BnJEyMc9j/wAVri4+W/QFweI4olJVBiTRWWmUuwNAK4JCgPrEftNVA7YLMpGCoAZHHvUZN+M+tFQN5/aorqx7NGFYEcZqa0hgyoadJpKHM7gk4FIDkeVKTgmmn2JQdWMGR2pi9C2SNOo04yy36L7/AEuJUk5MVNvasZ0z7P8A6N0hf/tk9tqKLPoTfItL+2DflzxwaXtWONx7L0234BcNAeGdwBgVcZZXsR47mMGPSjQ8ppU6lV2PDJKUH5vbtT9FvdMOmN9PsGilISkRsNgai2NrhllFV04i7XptgVTuRgUvYxxsOumNBhoIMd6acjVpUiqiFTh0qnmitJ2pcURJI47UtqkCrUcgc9zSUoUomR259KAFdgEQJgzQAr51TjmZp+y9AnVaSEJwfWqkY53fYdKwlhzOIjV2EnH1rXH04c72Vu3S2nFJQec6hzWdt2JCfqzBZZ7DVO23b960xLL3YCs1gLMQIzjmlk14z61VpEDPes66cabW7kBIJ42AqWkMrdcAxEdqTTQxo5Sc/WkDBkyQcmmkU3uCKCtWOLCZ3iltGthHDKiRgmltpPWglyylwEKAIjkUHKXL6eEL1sah3AODStVMtTVMha62xr+aKuVz5e1RsztnNPaPGCEWf5agAB60rVToInp7ZXK06ozBqPt0+V9DbdlKT8okbUy2MSdJ2zRtFXtuYHFOVNixyFIJJqhLqh1zsPuaTTc+wroknGIoPYZxXIkwd6DDunyaeIyaC39hn3PmgASPpTRZoA+sgKKonseKqOfkv4C3EJ0TnVkg44n61rXJWavLhX4p0mVEmSRNYZZarfHHoT1R0uWzobSFypQPuMx+la4M+X/vIrQwpBnVM7/tRVYHlooxEzUV0Y2G1uoTvioaymVuoxuZ2E0mko5gmRJwaDM2VTjahmKQ4AN5o2VVOrzMZqbVYqyed6AiZJM8cUz2taQCRjNJGVGttpKIj9KuMrX3hxxinobWBseHPP8Aeke+wbqYXMDNRemsvSl19LbjaVTKsAxTt0vDC5S2LgrO0UqlJK4pbC8Lx6VUqUVq82aez+gziSTj2oPYR48Zg9jTOBFqkiSByZoOhn9iRsMY7U2VoF0AvQSkgEA/Srxc2d6DXylpWYASdMgRtxV2ucht2g+lThVEqxisNb7dmONs6ZD4P6i89069bfWta0veIVkzMiumyS9OG2+W6e4UsGIkgCOPKDtUVthTK0mTxmKixvKaW6sEZxUVriZMrIUJpVriPaOUig9mFucJ9aSbRBUYEUk7cnaeaBKiFSfQUj2mkSByfWmW1rf2EU5E0e2sBkECrnplfbhdEHFGzkSS7qSMR2o9wa0oeTmDzU2HMgq0hwDUNjik2xysfJKisgxAxUn9Jp3PtS2m1NKiFAb0wm4cA0ylDPKg01TsC6rWJ43FNfoK5kCQNJmnCtDkkygGABNNjnfsvcUUztG3rNaRz53ZX1G40NPOpEeQx6YoyvTKTt5v1jrvULbqLrNq8W2kQNMcwKMMJZtr/Uyx6j//2Q=='
    Local $dBinary = Binary(_Base64Decode($sRedEye))
    If $bSaveBinary Then
        Local $hFile = FileOpen(@ScriptDir & "\220px-BoldRedEye.JPG", 18)
        FileWrite($hFile, $dBinary)
        FileClose($hFile)
    EndIf
    Return $dBinary
EndFunc   ;==>_RedEye

Func _Base64Decode($sB64String)
    Local $tStruct = DllStructCreate("int")
    Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $sB64String, "int", 0, "int", 1, "ptr", 0, "struct*", $tStruct, "ptr", 0, "ptr", 0)
    If @error Or Not $a_Call[0] Then Return SetError(1, 0, "")
    Local $tA = DllStructCreate("byte[" & DllStructGetData($tStruct, 1) & "]")
    $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $sB64String, "int", 0, "int", 1, "struct*", $tA, "struct*", $tStruct, "ptr", 0, "ptr", 0)
    If @error Or Not $a_Call[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($tA, 1)
EndFunc   ;==>_Base64Decode


Function _GDIPlus_EffectCreateSharpen

Function Reference

_GDIPlus_EffectCreateSharpen

Creates a Sharpen class effect object

#include <GDIPlus.au3>
_GDIPlus_EffectCreateSharpen ( [$fRadius = 10.0 [, $fAmount = 50.0]] )

Parameters

$fRadius | [optional] Real number that specifies the sharpening radius (the radius of the convolution kernel) in pixels. The radius must be in the range 0.0 through 255.0
$fAmount | [optional] Real number in the range 0.0 through 100.0 that specifies the amount of sharpening to be applied

Return Value

Success: | a handle to an Effect object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Remarks

When you are done with the Effect object, call _GDIPlus_EffectDispose() to release the resources.

Related

_GDIPlus_EffectCreate, _GDIPlus_EffectDispose

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * 600 / _GDIPlus_ImageGetWidth($hImage)

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    Local $hEffect = _GDIPlus_EffectCreateSharpen()
    _GDIPlus_BitmapApplyEffect($hImage, $hEffect)

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


Function _GDIPlus_EffectCreateTint

Function Reference

_GDIPlus_EffectCreateTint

Creates a Tint class effect object

#include <GDIPlus.au3>
_GDIPlus_EffectCreateTint ( [$iHue = 0 [, $iAmount = 0]] )

Parameters

$iHue | [optional] Integer in the range -180 through 180 that specifies the hue to be strengthened or weakened.
$iAmount | [optional] Integer in the range -100 through 100 that specifies how much the hue (given by the hue parameter) is strengthened or weakened.

Return Value

Success: | a handle to an Effect object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Remarks

When you are done with the Effect object, call _GDIPlus_EffectDispose() to release the resources.

Related

_GDIPlus_EffectCreate, _GDIPlus_EffectDispose

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * 600 / _GDIPlus_ImageGetWidth($hImage)

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    Local $hEffect = _GDIPlus_EffectCreateTint(20, 80)
    _GDIPlus_BitmapApplyEffect($hImage, $hEffect)

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


Function _GDIPlus_EffectDispose

Function Reference

_GDIPlus_EffectDispose

Deletes the specified Effect object

#include <GDIPlus.au3>
_GDIPlus_EffectDispose ( $hEffect )

Parameters

$hEffect Handle to an Effect object.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Related

_GDIPlus_EffectCreate

See Also

Search GdipDeleteEffect in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * 600 / _GDIPlus_ImageGetWidth($hImage)

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    Local $hEffect = _GDIPlus_EffectCreate($GDIP_BlurEffectGuid)
    _GDIPlus_BitmapApplyEffect($hImage, $hEffect)

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


Function _GDIPlus_EffectGetParameters

Function Reference

_GDIPlus_EffectGetParameters

Returns the parameters for the specified Effect object

#include <GDIPlus.au3>
_GDIPlus_EffectGetParameters ( $hEffect, $tEffectParameters )

Parameters

$hEffect | Handle to an Effect object.
$tEffectParameters | A DLL structure that receives the effect parameters.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Related

_GDIPlus_EffectCreate, _GDIPlus_EffectSetParameters

See Also

Search GdipGetEffectParameters in MSDN Library.

Example

#include <GDIPlus.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $hEffect = _GDIPlus_EffectCreate($GDIP_SharpenEffectGuid)
    Local $tEffectParameters = DllStructCreate($tagGDIP_EFFECTPARAMS_Sharpen)

    _GDIPlus_EffectGetParameters($hEffect, $tEffectParameters)
    ConsoleWrite("> default value of Sharpen_Radius: " & $tEffectParameters.Radius & @CRLF)
    ConsoleWrite("> default value of Sharpen_Amount: " & $tEffectParameters.Amount & @CRLF)

    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_Shutdown()

EndFunc   ;==>_Example


Function _GDIPlus_EffectSetParameters

Function Reference

_GDIPlus_EffectSetParameters

Sets the parameters for the specified Effect object

#include <GDIPlus.au3>
_GDIPlus_EffectSetParameters ( $hEffect, $tEffectParameters [, $iSizeAdjust = 1] )

Parameters

$hEffect | Handle to an Effect object.
$tEffectParameters | A DLL structure that specifies the parameters.
$iSizeAdjust | [optional] An integer value. Default is 1.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Related

_GDIPlus_EffectCreate, _GDIPlus_EffectGetParameters

See Also

Search GdipSetEffectParameters in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    Local $iImgW = _GDIPlus_ImageGetWidth($hImage)
    Local $iImgH = _GDIPlus_ImageGetHeight($hImage)

    Local $iWidth = 600
    Local $iHeight = $iImgH * 600 / $iImgW

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    Local $hEffect = _GDIPlus_EffectCreate($GDIP_BlurEffectGuid)
    Local $tEffectParameters = DllStructCreate($tagGDIP_EFFECTPARAMS_Blur)

    Local $hBitmap
    For $i = 0 To 12
        DllStructSetData($tEffectParameters, "Radius", Abs($i - 6) * 4)
        _GDIPlus_EffectSetParameters($hEffect, $tEffectParameters)

        $hBitmap = _GDIPlus_BitmapCreateApplyEffectEx($hImage, $hEffect, $i * Ceiling($iImgW / 13), 0, Ceiling($iImgW / 13) * 2, $iImgH)

        _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, $i * Ceiling($iWidth / 13), 0, Ceiling($iWidth / 13), $iHeight)
        _GDIPlus_BitmapDispose($hBitmap)
    Next

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


User Defined Functions

Font user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_FontCreate | Create a Font object
_GDIPlus_FontDispose | Release a Font object
_GDIPlus_FontGetHeight | Gets the line spacing of a font in the current unit of a specified Graphics object


Function _GDIPlus_FontCreate

Function Reference

_GDIPlus_FontCreate

Create a Font object

#include <GDIPlus.au3>
_GDIPlus_FontCreate ( $hFamily, $fSize [, $iStyle = 0 [, $iUnit = 3]] )

Parameters

$hFamily | Handle to a Font Family object
$fSize | The size of the font measured in the units specified in the $iUnit parameter
$iStyle | [optional] The style of the typeface. Can be a combination of the following: 0 - Normal weight or thickness of the typeface 1 - Bold typeface 2 - Italic typeface 4 - Underline 8 - Strikethrough
$iUnit | [optional] Unit of measurement for the font size: 0 - World coordinates, a nonphysical unit 1 - Display units 2 - A unit is 1 pixel 3 - A unit is 1 point or 1/72 inch 4 - A unit is 1 inch 5 - A unit is 1/300 inch 6 - A unit is 1 millimeter

Return Value

Success: | a handle to a Font object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the Font object, call _GDIPlus_FontDispose() to release the resources.

Related

_GDIPlus_FontDispose

See Also

Search GdipCreateFont in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw a string
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBrush = _GDIPlus_BrushCreateSolid(0x7F00007F)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
    $tLayout = _GDIPlus_RectFCreate(140, 110, 100, 20)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Hello world", $hFont, $tLayout, $hFormat, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_FontDispose

Function Reference

_GDIPlus_FontDispose

Release a Font object

#include <GDIPlus.au3>
_GDIPlus_FontDispose ( $hFont )

Parameters

$hFont Handle to a Font object

Return Value

Success: | True
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_FontCreate

See Also

Search GdipDeleteFont in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw a string
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBrush = _GDIPlus_BrushCreateSolid(0x7F00007F)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
    $tLayout = _GDIPlus_RectFCreate(140, 110, 100, 20)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Hello world", $hFont, $tLayout, $hFormat, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_FontGetHeight

Function Reference

_GDIPlus_FontGetHeight

Gets the line spacing of a font in the current unit of a specified Graphics object

#include <GDIPlus.au3>
_GDIPlus_FontGetHeight ( $hFont, $hGraphics )

Parameters

$hFont | Pointer to a Font object
$hGraphics | Pointer to a Graphics object

Return Value

Success: | the line spacing of this font.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

The line spacing is the vertical distance between the base lines of two consecutive lines of text.
Thus, the line spacing includes the blank space between lines along with the height of the character itself.

See Also

Search GdipGetFontHeight in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create GUI
    Local $hGUI = GUICreate("GDI+", 800, 340)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    Local $hPen = _GDIPlus_PenCreate(0xFF0000FF)
    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000)

    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 96, 0)

    Local $sString = ChrW(0x1EF2) & ChrW(0x1EF3)

    Local $iPosX = 50
    Local $iPosY = 50
    Local $aStrDim = _MeasureString($hGraphic, $sString, $hFont, $hFormat, $hFamily)

    _GDIPlus_GraphicsDrawString($hGraphic, "MeasureString", $iPosX, $iPosY - 30)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX, $iPosY - 5, $iPosX, $iPosY + 5, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX - 5, $iPosY, $iPosX + 5, $iPosY, $hPen)
    Local $tLayout = _GDIPlus_RectFCreate($iPosX, $iPosY, $aStrDim[4], $aStrDim[5])
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX, $iPosY, $aStrDim[4], $aStrDim[5], $hPen)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush)

    $iPosX = 300
    _GDIPlus_GraphicsDrawString($hGraphic, "MeasureCharacterRanges", $iPosX, $iPosY - 30)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX, $iPosY - 5, $iPosX, $iPosY + 5, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX - 5, $iPosY, $iPosX + 5, $iPosY, $hPen)
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX + $aStrDim[0], $iPosY + $aStrDim[1], $aStrDim[2], $aStrDim[3], $hPen)
    DllStructSetData($tLayout, "X", $iPosX)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush)

    $iPosX = 550
    _GDIPlus_GraphicsDrawString($hGraphic, "CellAscent / CellDescent", $iPosX, $iPosY - 30)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX, $iPosY - 5, $iPosX, $iPosY + 5, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX - 5, $iPosY, $iPosX + 5, $iPosY, $hPen)
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX + $aStrDim[0], $iPosY + $aStrDim[1], $aStrDim[2], $aStrDim[7], $hPen)
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX + $aStrDim[0], $iPosY + $aStrDim[1] + $aStrDim[7], $aStrDim[2], $aStrDim[8], $hPen)
    DllStructSetData($tLayout, "X", $iPosX)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush)

    $sString = "fontsize goes crazy"
    $iPosX = 50
    $iPosY = 300

    Local $sChar
    For $i = 0 To StringLen($sString)

        $sChar = StringLeft($sString, 1)
        $sString = StringTrimLeft($sString, 1)

        If $sChar = " " Then
            $aStrDim = _MeasureString($hGraphic, "_", $hFont, $hFormat, $hFamily)
            $iPosX += $aStrDim[2]
            ContinueLoop
        EndIf

        _GDIPlus_FontDispose($hFont)
        $hFont = _GDIPlus_FontCreate($hFamily, Random(12, 48), 0)
        $aStrDim = _MeasureString($hGraphic, $sChar, $hFont, $hFormat, $hFamily)

        $tLayout = _GDIPlus_RectFCreate($iPosX - $aStrDim[0], $iPosY - $aStrDim[1] - $aStrDim[7], $aStrDim[4], $aStrDim[5])
        _GDIPlus_GraphicsDrawStringEx($hGraphic, $sChar, $hFont, $tLayout, $hFormat, $hBrush)

        $iPosX += $aStrDim[2]
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Func _MeasureString($hGraphics, $sString, $hFont, $hFormat, $hFamily, $iStyle = 0)
    Local $tLayout = _GDIPlus_RectFCreate()
    Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat)

    Local $aRanges[2][2] = [[1]]
    $aRanges[1][1] = StringLen($sString)
    _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges)
    Local $aRegion = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphics, $sString, $hFont, $aInfo[0], $hFormat)
    Local $aBounds = _GDIPlus_RegionGetBounds($aRegion[1], $hGraphics)
    _GDIPlus_RegionDispose($aRegion[1])

    Local $iFontHeight = _GDIPlus_FontGetHeight($hFont, $hGraphics)
    Local $iLineSpacing = _GDIPlus_FontFamilyGetLineSpacing($hFamily, $iStyle)
    Local $iAscent = $iFontHeight / $iLineSpacing * _GDIPlus_FontFamilyGetCellAscent($hFamily, $iStyle)
    Local $iDescent = $iFontHeight / $iLineSpacing * _GDIPlus_FontFamilyGetCellDescent($hFamily, $iStyle)

    Local $aDim[9]
    $aDim[0] = $aBounds[0]
    $aDim[1] = $aBounds[1]
    $aDim[2] = $aBounds[2]
    $aDim[3] = $aBounds[3]
    $aDim[4] = DllStructGetData($aInfo[0], "Width")
    $aDim[5] = DllStructGetData($aInfo[0], "Height")
    $aDim[6] = $iFontHeight
    $aDim[7] = $iAscent
    $aDim[8] = $iDescent

    Return $aDim
EndFunc   ;==>_MeasureString


User Defined Functions

FontPrivate user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_FontPrivateAddFont | Adds a font file to the private font collection
_GDIPlus_FontPrivateAddMemoryFont | Adds a font that is contained in system memory to a Microsoft® Windows® GDI+ font collection
_GDIPlus_FontPrivateCollectionDispose | Deletes the specified PrivateFontCollection object
_GDIPlus_FontPrivateCreateCollection | Creates a PrivateFont Collection object


Function _GDIPlus_FontPrivateAddFont

Function Reference

_GDIPlus_FontPrivateAddFont

Adds a font file to the private font collection

#include <GDIPlus.au3>
_GDIPlus_FontPrivateAddFont ( $hFontCollection, $sFontFile )

Parameters

$hFontCollection | A handle to the font collection object
$sFontFile | A string value that specifies the name of a font file

Return Value

Success: | True
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_FontPrivateCollectionDispose, _GDIPlus_FontFamilyCreateFromCollection, _GDIPlus_FontPrivateCreateCollection, _GDIPlus_FontCreate

See Also

Search GdipPrivateAddFontFile in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout, $sFontInternalName, $hCollection, $sFontFile = @WindowsDir & "\Fonts\Times.ttf"

    If _WinAPI_DwmIsCompositionEnabled() Then
        If Not @Compiled Then
            $sFontFile = StringRegExpReplace(@AutoItExe, "(.*)\\.*", "$1")
        Else
            $sFontFile = StringRegExpReplace(RegRead("HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\AutoItv3", "DisplayIcon"), "(.*)\\.*", "$1")
        EndIf
        If $sFontFile = "" Then Exit MsgBox(BitOR($MB_ICONERROR, $MB_TOPMOST), "Error", "Unable to locate SF Square Head Bold.ttf in AutoIt sub dir!")
        $sFontFile &= "\Examples\Helpfile\Extras\SF Square Head Bold.ttf"
    EndIf

    $sFontInternalName = _WinAPI_GetFontResourceInfo($sFontFile, Default, 1)

    $hGUI = GUICreate("GDI+", 720, 235)
    GUISetState()

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (anti aliasing)
    _GDIPlus_GraphicsSetTextRenderingHint($hGraphic, $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT) ;set the anti aliasing for fonts

    $hCollection = _GDIPlus_FontPrivateCreateCollection() ;create a PrivateFontCollection object to add fonts later
    _GDIPlus_FontPrivateAddFont($hCollection, $sFontFile) ;add the font to the font collection
    $hFormat = _GDIPlus_StringFormatCreate() ;create a string format object
    $hFamily = _GDIPlus_FontFamilyCreateFromCollection($sFontInternalName, $hCollection) ;create a font family object
    $hFont = _GDIPlus_FontCreate($hFamily, 72) ;create a font object
    $tLayout = _GDIPlus_RectFCreate(0, 0, 720, 235) ;create a $tagGDIPRECTF structure to save x, y position of the text
    _GDIPlus_StringFormatSetAlign($hFormat, 1) ;center text
    _GDIPlus_StringFormatSetLineAlign($hFormat, 1) ;center text
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F) ;create a brush with a defined color for the text
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "AutoIt" & @LF & "forever", $hFont, $tLayout, $hFormat, $hBrush) ;draw the string

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontPrivateCollectionDispose($hCollection)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_FontPrivateAddMemoryFont

Function Reference

_GDIPlus_FontPrivateAddMemoryFont

Adds a font that is contained in system memory to a Microsoft® Windows® GDI+ font collection

#include <GDIPlus.au3>
_GDIPlus_FontPrivateAddMemoryFont ( $hFontCollection, $tFont )

Parameters

$hFontCollection | A handle to the font collection object
$tFont | A dll struct value filled with binary ttf font data

Return Value

Success: | True
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_FontPrivateCreateCollection, _GDIPlus_FontPrivateCollectionDispose, _GDIPlus_FontCreate

See Also

Search GdipPrivateAddMemoryFont in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $bFont = _MemFont() ;load binary data (TTF) to use it later in GDI+
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout, $sFontInternalName
    Local $hCollection, $tFont

    $hGUI = GUICreate("GDI+", 720, 235)
    GUISetState()

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (anti aliasing)
    _GDIPlus_GraphicsSetTextRenderingHint($hGraphic, $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT) ;set the anti aliasing for fonts

    $hCollection = _GDIPlus_FontPrivateCreateCollection() ;create a PrivateFontCollection object to add fonts later
    $tFont = DllStructCreate('byte[' & BinaryLen($bFont) & ']') ;create byte struct to add font to collection
    DllStructSetData($tFont, 1, $bFont)
    _GDIPlus_FontPrivateAddMemoryFont($hCollection, $tFont) ;add font to collection

    $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F) ;create a brush with a defined color for the text
    $hFormat = _GDIPlus_StringFormatCreate() ;create a string format object
    $sFontInternalName = _WinAPI_GetFontMemoryResourceInfo(DllStructGetPtr($tFont)) ;get internal font name
    $hFamily = _GDIPlus_FontFamilyCreate($sFontInternalName, $hCollection) ;create a font family object
    $hFont = _GDIPlus_FontCreate($hFamily, 70) ;create a font object
    $tLayout = _GDIPlus_RectFCreate(0, 0, 720, 235) ;create a $tagGDIPRECTF structure to save x, y position of the text
    _GDIPlus_StringFormatSetAlign($hFormat, 1) ;center text
    _GDIPlus_StringFormatSetLineAlign($hFormat, 1) ;center text
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "AutoIt" & @LF & "forever", $hFont, $tLayout, $hFormat, $hBrush) ;draw the string

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontPrivateCollectionDispose($hCollection)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Func _MemFont($bSaveBinary = False, $sSavePath = @ScriptDir) ;compressed base64 saved TTL font
    Local $vMemFont
    $vMemFont &= '+LpAAAEAAAARAEAEAAAQTFRTSHBEFET0AGDEAKi3T1MALzJjo38vAAAEAZgAPGBWRE1YAGXvbW4AAHRoAAAABeBjbWFwEAm6VAMAgAQAAAAD2GN2dCADpEABxwAAFtwAXhgAZnBnbTJHc2AIAAAUAB4BYmdswHlmdq72hAA+AMYARmhoZG14PSgEGzgAS3wAAAuIAGhlYWTfoV8QJQArHAA/NmgAEAs9FAXeAA9UAA8kaG1AdHhqYhtYAA/4AAAAAsxrZXJugLrOrNgAAF4ArwALZGxvY2H2UEALkgAAXVwAI2gAbWF4cALnCnsFAAt4AD8gbmFtZQCNIdAnAABqKAAAAAodcG9zdFD/fgAUgGdIgQ9wgHJlcKaKyrqATwpAgAeago0CAAAhAEgSSF8PPPUACBkD6IAIALxe9gLnggNfJRz/7P6gvQfJA3AABwOBFQMCAIAbA3D+vQAVxAfggA+NB8mCJAkAArOCCLMBcQAgABZIgL2DDwoBNwjAAIIFgAcCA10BkIAEoAACvAKKgA2PgwPAAcUAMgD6ARYAuQcFAIDABwBMQVJBAABAACAhIgLm/4AcACoDcAFDg0mxAAL0AtaBdIAEnYABAEEANQH2ACECAD4AAQI4ACUCAFMAIgNjAAgAAPwAEwG+AAwCABMALwK1AB4CAKAAHwEsACMCAG8AJgFPADkEIAT/9APcwATzAAAvA7AAGQQlAIAoBCIACQOAwAAA5gAbAyH/9wQALgAkA/4ALgGgMgAsAUTACbfAGQB1ADADa//5AwBP//0DYgAxBACs//oEFAAtAyDJAAMD2cALIAAAEAMWAAcDyACKEcAXOkB9PwNowA4AogANAw3//wUgWAAVA8bAH34AAh/ADA0EswAWBABpABwD8AAPAwho//bAEjIEo/8A7wUlAAEEXgCAEwRKAAUDzkC3AKAADwQA//ABoNIAIAI2wBi0wDZoxAGexh+w/x/ZHwAArgBFBYYAPgAIhAAQwVwC8AF+AAKcAbgC0QFIMANuABTCIdAABq10/+3ADwHCJcgAwCU3C8EmwAAewAAhA///NvHFJdAALMIlyQBXABgFB+DARNUdpP/srAI6wErvDjbkDh1gAI4goWH2Dm0OUwAF4SEABqAAHAamABsBYQEC2AFxAw0BAOYDLQGPATsAAihgACMCQwAoAgAuACMB3wAfBwInYgssAnsAKQIgHAAvAObgADEAEivhAAF2YACCADRf4VgiaR8AHwAUABmBABjL/wQBABVfBBYYgwnhFgFgnQC4CRIEAwUBAAAIAgQFBgYDAAYDCQkECQoKAAgJBwoJAwMJAAYICAgLCQkJAAcHCQkDCAgHAAwJCgkLCgkIIAkLDAoKIAUEBQQJBvcDAg0BAwdQBgYICwIAD6AEB3QHAwAACSAMAQAABwk0ChKkAwSsA4IDCg8EDwrCAgUFBBAKgAcGAgYCAwOhjwQKFOAWBgYGCQMEBAXgAwYDCgoFAAkLCwkKCAsKMAMDCgZAECAQCggICAoKAAoIDgoMBAoMABMKDA0LCwAKBAoFBgkHDIPAAfMDAg4BAwhAGkoMAgARoAQICCETCqYKIwLBEwsUpAMFrANBggMLERELB8ECBpAGBRIM4hYEBOEWkAsWBQTAFgcKoBcACAcDBwQLCwUB4AYKCwkMCwMEGgqgLgogEEAqCwsEQWAgDwsNCw0AEwsADQ4MDAsFCwUwBgoIDcAB8wMCEIABBAgHCAoNAgB6EwEzCcAOYAwjAuEsDBoWpAMGrAOCAwwTE0wMCEA54RYUDQEUA8QEBADBAAwY4BYgMQHiFggEBwQMDAYz4AbAPA0MQAigLgoOFg3gGGAmBMATEAwOCAwODoADDhANDQAMBQwGBwsJDkOhBfIDAhECBDEjDu0CABUiFJEJDDACAQDyCTIYswAUB9wB4wwUFIoN4CIEQCQGFg5zCyIFcQsNGgWBJQgLBAMGICoECAQNDboGkQcN4AogBKEpECAE'
    $vMemFont &= 'CgowEwTgCRINDw0AEA8NCw4PEQ+gDg0FDQYQLRDRAkP/AfABAhMCBHAqCxoQAgAWUAKTCQ0ND3sCAPIJGtQBdgvUAeMMFkAWDgkKCwRgGwbAGA8JCAMI0ThwC5AOHAYFACQIDFAXIYE2BQ4OB3ADDQ7ACw8OBAUNoSkQCBQOCzATBTArEw4QBA4RgAoPERIQDwAOBg4HCA0KEYfRAv8B8AECFAIFoDJ0DBECABhQAlAoAAAO5g6zCuEJEBzUAdI72AFhwgEPGBgPUC5wCwhQBxoQCnMLBnALD4geBgUAJAkNBHAoISA5BQ8PB3ADDQ9oDBAPIAQJoBoQCA8gDAwPDwUwKxUOCBEPEoAKEBIUEQAQDwYPBwgOC5gSEA7/AfIBAxVwC5WwLhICABpQAgwMkQlMDw6zCuEJER7UAQhD3AHCARAZGhBQLgVABQkIBxsRIE4JI5AucQsQIAdxCwoOBAQHoDUFCgUQEJAIDxER4CkRECAEGgqgGhMgBLAbEAUOgA8NFg8SEBOACgARExUSEhAHEGIHkDgTEQ//AfIBAwAXAgUMCwwOEyUCABtQAg0NkQkQD/OzCuEJEiDUASES2QHCAWASGxsSDGEBsEodHBILkVdAROGzIgcFGfFSDwQATwBCBhERAAgQEhIPEQ4SEBEFBhDQIg8UEoAQEQ4NEBEG4AkgFxAUEBSAChIUABYTExEHEQgKDBAM/wH1AQMYAgXJQDsPFAIAHREBK+ASmAYREBMB4QkTItQBBgncAcIBEx0dEwyQDQ4FBTBhHxSRV0NRRHALEiQHBnALCxgQBQjgT3ALExIJABETExASDhMSASAECxAPEBYTEUASDg4REgbgCRkQERURFoAKExUYgZAFBxIIChEN/wEh9QEDGQIGQDsQFo0CAB9QApMJEhEVAgB5cRYUJNQBoR3ZAcIBFAAfHxQNDg8GBj0wViEASXALUERwCxMmHAgGgC9yC6FEBhQTAAkSFBQREw8UChMgBAwwIhcUEhMADw8SEwYREg8AGhIWEhcVExEIFBcZkAUIEwkLDBIN/wH1AQMaAwagDg0OERcCACBQAjoPIAgGsBGzCmEVFSYN1AEL3AHCARUgIBUGDmEBIGQjFg0LBMoLcAsIcAsUKHIL4GoDYFZwCwcVFAoTFUAVEhQQFRQgBA0BYCYYFRMUEBATABQHERMQGxMXABMYFxQRFRgawBYWEwgUCRBE/wEB9QEDHAMGDw0PZBIYAgAiE6E20XwUphOzCmEVFijUAQzcAQHCARYiIhYPEBDEBgawbCUXDZFu0E8hcAsVKgkHADsNEgNwC4BNDQcWFQoUQyAH4B4VBgcUoUAZABYUFRERFBUHAcAMHRQYFBkYFQASFhkcFxcUCWAWCgwUD/8B9QEESB4DB8BGEhkCACRmFKE2kQkVFLMKYRUXHirUAdJS2AHCARckJBgXDxBgAaBvJhgOy4As4IAJcAsWLHALYnYCCqBMBw4HFxYLwhUgBxYSGBYgBKFAEBoXFRYwJxYHEwAUER4VGRUaGSAWExcaHeAJCRcwCgwVEP8B9QEEH6QDB8BGExoCACYgRmQSEpEJFxWzCmEVGNos0wEl0lLRARbTAcIBwBglJRgQEWABwIMUKBlwCwx0CxcuClIHgEYOFHALEHALCAAYFwsWGBgVFwgSGRggBA4UExQAHBgWFxISFhcACBQVEh8WGhaAHBoXFBgbHuAJwAoYCw0WEP8B9QEkBCByCxQcAgAnA7wUFhIAAAgAABgWGkUCABgAABouHAIAJxoNBegXA3QBcBkZJwAnGRESEwcHDQANCyoaDw0FDAAFCQkKAAAAGAAwCggMDg4OFQAGCw0REAcPCAAZGAwXGRkWGAATGhkHCBcPFQAUFR0ZFxgTEwAXGAgVFhMhFwAcFx0bGBUZHAAgGxoXChkLDgQXERcfBCEDCBIQEBEVHQIAKRcTUwAAAZkZFwOrGQAAG2owBB0OBR0YAx0CHBoAKSkaERMU'
    $vMemFont &= 'CAgADg0MLBwPDQYsDQYDtwAAA4MBAtw0AAGCBxyABoAEAeAQAAYBxIAHIADdFACygAgCgAsEAAUAAAYABwAIAAkAAAoACwAMAA0AAA4ADwAQABEAABIAEwAUABUAABYAFwAYABkQABoAG4AlHQAeBAAfgCEhACIAIwAAJAAlACYAJwAAKAApACoAKwAALAAtAC4ALwAAMAAxADIAMwAANAA1ADYANwAAOAA5ADoAOwAAPAA9AD4APwAAQABBAEIAQwAARABFAEYARwAASABJAEoASwAATABNAE4ATwAAUABRAFIAUwAAVABVAFYAV0AAWABZAFqAXVsQAFwAXYADZwBoAABqAGwAdAB5AAB+AIIAgQCDAACFAIQAhgCIAACKAIkAiwCMAACOAI0AjwCQAACSAJQAkwCVAACXAJYAmQCYsACaAJsDSgIAqMAAAIAArACrAK4AiGAAX0ADaQB6yAcBDwCHAKoAYgBeQUgEsACxAKnAAWMAAGYAeACeAJ8BQgWmAKcApAClEcICnQCgwgGtAK8BTBNlAG0AZABuAABrAHAAcQByQABvAHYAd8AFdUAAfAB9AHtAAqFEAKPECqIAYUBs/FVAAjhAYARAZSDAKn4FQAipwi+0ALgAuwQA1sB39gD4AP0AAP8BUwF4AsYAAtoC3CAZIB0AICIgJiA6ISLU//9CgSFAGKHAP0cOoL8A2ADfQA75QA6iUkYOGCAcQg45Qw5A/+D/3/+9QBAFAP/+/6z/qf/2QP+j/6L/oUAGnwD/nv9M/yj92wD9yP3H4IzgigDghuCDAADfjFVAmzjEMDLOUyTUWQ71QgGywGSrQFxBTv8+fx8ffx9/H38ffx9sH7gAAAAsS7gAA1BYsQABAY5ZuAH/hSC4AEQduWB4A18AXi24AAEsICBARWlEsAFggAECEiwAAiohIAEDLCAARrADJUZSWCMAWSCKIIpJZIoAIEYgaGFksAQGJeIAAANlilkvICCwAFNYaaAAVFggIbBAWRtGAWVZdFk64AgE4QhABsAFijpZIAhqJAjgAEICL/0BgAQFLEsgsAMmAFBYUViwgEQbALBARFkbISEgAEWwwFBYsMBE0BshWVmgBAYmFeAAKH1pGGQWB2AWBio1AAEIowhTYAhACFmKAoqjASMhsMCKiowbiuAY5AG4AQANAg5ABAIAHwEIAyVFuAgBgFBCA4AjIRshAQIjISMhwBJZRIFADQksS1NYRQATsCFZLQDAQCCYuuA1QAMAAisBuoBMBEUBAb7AAKIAkeBzUVGgmggrvmCmvuoBBrWglEbgnCegUuEBB+AISiSgTBcgqggrgAUBVYCmGcCpDgICvkCvP1VAByiAqRHiAQOABzGXAgbhAWAQCEAEBysAEqsjJGBBFGBUWOCLIoAGgkEglgAABwLVoASiAiCsAgEYYAEHAAwSD4EYL7rACAsAAwArMDEBFRQHIwAnPQETFAYjIgAmNTQ2MzIWAQAVGa4Z40AxMgBAQDIxQALVwgBh1dVhwv2KKUA0NCkqNDQgCwIAACEB5wH2Ave3ABOhCoBJL6A7YAAAYACEBC/gCgMjESNgAAAB9jytBDutAmD3/vABEGEAYAcBQAEoAj4C+6DFHzegmgA7YAYLYBJhzQMrTrrgyCAsYBsBEOAJ3FPgCuAACdDjAA3gAASt4AAP4ADhAxHgAADgAKoT4AAa4AAV5AEX5AMSHOQFHtBgEgcjB5IzMAAjNzIANzMyACQzBzAADwGgAQI+AClhGGEpYSxpBC1IMABaKVoXWUApWSdpJ0cwAJIARxhIAptlO2WWbgAAYABgAABlO5J0gCUA/QIUAyLQDLIm0G2VukJyAQwMgAd6AgAIDYQKcQABCXEBHqX0ACD0ACrQkBAdkBB6DJAQLLB2kRBAeXIAIKuwdgEFIIACAwADCnAACA7QutAcDAAdEaASObgALBABELQPqhu0DyFwABJwACmzDwIVoB0VFAYrARWEIzWADzUj'
    $vMemFont &= 'IicAHwA3NjsBNTMVB0HgABUUMxc04AEzADICCWNrC1h2AHZYC0DWY3MPAFE3Ojo3UQ9AAEAPGBiWPAsLADwDAYAfWEhIAFUoKIA9JSlCAEEpJSEhnx8QEA+eHj0wHCIA6FACOAMZ0AkXMB4r1VB+H7ANDLANILANcVmeDDALcR6TANAJFAfgJ4HjCDMyFxYHNNIIcDIlASOQKb8BsQEBABZMGBYXGUpKABkXFhhMWR8eAB4fAW7+wrYBCEDBTRABGUlJGRHwAU1aHgAAAp1VAB4JCh9TUx4LiAkeWKCSJP6SwAIyrlABCx5XAbApCACgBQNjAtaQCSlQiXa60B0zKRbQChcZsyYYtfAVGFANA7QWMRcitRY8ByEwC1ILkgthFgciAAcGFRQXFjMTA8AWoQAzA2OGNLoAhv6QZlRgLR4AQEAeLV9UZ8MAhloQTikcIXkAeRsWH1ABxrsATLofI0QsMEgAOjxKMS1FJCAAuwEIIRgLCP5A+UwHChUm8AgTUAHnAPyyOAuUOABlEDgT0Df8PJQ3cgsMQP8oAb4DL5BCG3q6IEkPgAwQDlGdkQ0UV5IN0QuxCRFxCgdhFxEBcRcBvk1tLkppADCNTZZaaWBPAKIDL2sPGUz9ALxWGAxqMjx2oAJEfzUrMgYvMAba4DUGAECjMgYFsD0xBhYQAE4xBiUxHScyN0I20AUnJiMncR0VAAHgaFqWTY0wAGlLLW1NYKNPAF8MdjwyagwYAFYCREwZD2srBDV/YlKqAqUCf9XwS0uwDg+wDgbSTHMyrgNhDfIwsRgIEDIJFgHqERABChABCxQBYTqTAEESGxcjJwcnAUEnADMXNxcHAqVIAIVhpkWiNj+XAEiEU6Y8kzYlAAHdfKV1h4I1QHyNZnuCIBAHH0AAnQKHAjwQBSNVsAgIsAgCsAgL2EsEVVAhC3AABlEhI3E3JwIzwDYzAofH4DsAhsHgQAESdXUIu29vsXwBACP/oMsBDADbfBwlUVQQDDyt23YcJgES8AI4Ac1yAjEPMEhxGwAhJyECOP51h6ABiwESu3ECOXBf+B0AvVACcQKgGLQXmF6IHUAyUV4yQF/GXYAB//QAAwQE8GIBewgJASEBBAT8AP3+8wMLAtX9CC4C0nFgHwAEA6q9sAINkD4TUAYVUgYbUSWTHgEBR+IGOwEyKBYlIlAvFpAANjUANCYjA733vDcAvff1vze/9P4AFl14eF03XXgAeVwBc57R0Z4AnsTECWNNTV8QX01NY3ElAAQBar5wBgUyCQS1EUBmJwAhAb7fKYcBj1gEAhZgD7ACGTAJl72wAh0wCTdUsVJxAAhQSQlyEAchIkUhMjU0LiOwEyEoYSkh4C8dAQADl5D9HF5YgAABGSkp/jeQAgBZeVNYWFN5/gDnIBwnvrryaQBDPh0duzg8ZEBjPDgJDRrxmwHR4HoFA/2wQyhyB4B87fIGITArE0QTExFiBoEGTzAHEDABMKwAFxaxCAMAvUAhLl5TZf4AIJAChiMfLi4AHyP+4ZEBsBwEFyHQ4v4KkAJwAGZSXi4hAWk6gEgzLkEiHrrwQAAVCge7CAwXFwALCLsfI0IvNEJKMBoJAAQE8X8K1VAaN5QqA5AqChHekCpqAhAqBVRlCxAycBIAHggSMmBskgAzTSM1IQA1ASERIzUFBAAYkDDg/ZECPAABE+D+7gGPuwDQ0LYBS/66n6WAzQHxBgNn8AYZchALdRd1GAT0FwEHIRUFRxc3BxARA1GR/gA+ATOEV1tbVwCE/diRAZckHAAjJBsk/fAC1QC7OkBEbGxBPwC6DA4bGw4KAaqvMAwb8AbR8AYUkBZtEQcV4ncXBwVQARIHLrwAByEiByEyFxYAFRQHBiMhIiYANTQ2MwEyNTQAJyYjIRYzA50AkP7CaTsBs3IAQz4+Q3L+8b0A9/W/AQ8vCg4AF/4oLJ0C1bsAOklDYWJDStEAnp7E/ek1FREAFXAAAAAB//cAAAUDIQLVAAsA'
    $vMemFont &= 'AA8AuAAAL7oAAAUAAgADKzBAMSUhASEnBOIBACn+1wHe/qmQAAKOQCsxJwUCgBW7GRwzKy0AQgAAAwAkAAUEBgAC1gAhADMAQQAAGwC6ADQACEEAQ7oAGgAqAgciNAA6AlMBAr4CwCcmCicAwzcBAzY3NjNDAWgBaiUyNzYD1CLABwYVFBcWBuSCBwAzA7pIPzhWSABV/vVVSFY4PgBISCQvXlNlAQALVUlXOUD+qAAcGCAhFxz+yQAcFyEgGBwBNwBQIBYa/skaFgAgUAFpOUpHOQAzGRUVGDQ5RwBKOjtNNTBBIQAdFRo0OkhNIgAIDBcXCwgICwAXFwwI/vkmFUAKBwcKFSaAhC4QAAQD5IBtFAAejYJsBoB3gWgSABeCAxYVgnSAbBQAajchMs43gWyBaYBoFgcBWwJiAAPk9b/+MZEBAD5pOv5NcUQ9AD1EcQEQvffrAC2c/vAvCw0XAAFnn8S7O0lCAGJhQ0vSWXA0CBUSFYGtAgAsACACARAB5IDPFwDaE8AfFcBpwR0JwiHDHREDgzIWEcgCARBACDIyQMkAAYcqNIA0Kik0NP6vAAEGKQADwRcv/+wBGTXCFw9CgA1AgNEWFwMQIxEBF8USAkyewYYTpP7gASDBksB/oGADkwLTwA8VQBIUBi/DkwjABgYREiA5MDEtAUFGJRUADQEDk/zjVVUAAx3+YwGdYOEAGEBBGOHFdXUBwSMwALcCTwIcRUAgB8I7BwAEwjsDQ0GawSQhNSERwAACIE/94QIfwQABiRCT/puTwbL5AF5UA2vGHwTEHwJADgSBwh8nNS0BNQWBoAAHAZ3+YwMdVUBVXsZ1dcUCIACAAv/9AAIDT8DCaBoAJsJ6JMB8wR4XO0B/wQEMwiLBRUGwFSMfQUZAfMSrwsqJTANPZgBbgf7o4EMtAQCdGRgiIhgZ/gBskQIQgFxm/QinQTEBUjFBAfkAaD03QJ0mNwcACRISCQa7Nz4M/f9GZ8FDMQBbAyA3AtwAHcAk67rQABAAGUIRI8B04QAKCkQUAAA4AytBFVQAZkAEdmAAhmAAllVgAKZgALZgAMZgANYVYADmYAD2YAAKXUGiB4BZEAAWYAAmYABAA3FBBQA1AAFFiWAAAnEhTQsAAOAmVYIKI4AKI4AKI4AKI1WACiOACiOACiOACiNVgAojgAojhQojgAoj1YAKI4UKI4AKI4AKYCr2FOAKARYdoCnhAGAM4gAICAAg4AC4AAsQMLgAHtDhPOJoNjtAARUzESEiQH8WCDMhF+SeIQE1IwFDAgM3/mdHKigAUkfSR/7+cpIAknIBH1P+jqsA2dupAYL+y0AAHycnHwEHLSoAPD1VygEPdV8AXnpqrI2Nu/5AhnciGhohYUb6QAAEBKoC12BfF3VgRgrgRQEiEmBHIBEEASARJTchAwEhAQOBlGGUAQFbhwEtALv+u/7rAc4WACcrKCkqJRcBAMMEuwED/kICAIEgGBoaFyH9Kn9hNy1gq+tghx0A6ijiSSGkohYgW2MfgTcdqaIRx0lgiSOiBSEVAaUCA6tAIy9dUgBk/acCbxwYIQAhGBz9kZcBwgBlUlwvI/6x/gBxAY8jHy4uHwABaTpINS9AIQgdAcHjmrseIkHgMDZKmkyAmkCbYXXqA+CasGBdEaJsIgKiij4KY7+gzSMtAAEDLbCQAP6WvPf0vwH6gQABXHh4XL66Ycmgu2NNTGCgByTgCTq64AkT4gngHOIJEQBqDqejEQA5MuAYgxsWAAO697z+HeABAANdeHlc/h2OAAFVv/QBc57RAAHC/vhfTU1j1LvEoRIQ4Aof4tMhKLXlFATEXwhhleMVEUAVAhVhAAMfkP2BAwAPkP5hAgyQ/gCEvroC0btMuqZWIAdgiQMWYAkJYj0eB2A96wngFGMIESMRFAMWBQjggOdMuv6o8ALRoQURYAi+YAjaFeIRCeIb5wgN5CfgCJ1EVjXgguBXgikDvkEnAHl4XQEE/uiTMAKL'
    $vMemFont &= '/hwBKsALY03ATV9Dsv5RASogCdo6YAymZB7jqApimTFNMzEH9HkjEYEKQBURMwADpt/+U+DgAQCt3wQBDf7zAiDR/vcBCVIJPwAoBAEesAQD0AS4AAYCcgSyAzMBHt/fogRADQEAL/AGOTaAgzEwNYABECkBNdInATAGOf4+/rgBSABxMUDgAUz+uEC6GB9XAYkxBg0V8AOb8AMK0Eq4AAXVMAYI9AoD9FcFcESxXE2VAAqUAFGGJRXACBWB0IYDm/6s/qZQDABaAVD9/gTx8UAC0ff3/pJxUAHU//8wBg0wBgUyCnEFAzMXsx8zEQMNkf0kg9/BHv3pkQEV/4D7BTkC3gAYEBDouAAPsAgVNAnxCTEOVgKxBNIICZYAC5YAEhOUALESCwFBXScLAZAjEz4BQEAbARJxAAU59V/KKEYkAEQRy172uwtHAC5HNNzdM0cvAEYMAgF9/rs/ACQbAUX+gwKAACc1VP6ZAWdUBDUncAk5//8DkrFwDBAAJ/QY8R0LMAA2D3QX8wcOlADwBxQjmCInAZAeQWUXAYAYAJJZQDr+WuAzAC89NAGm4GFiADABYf50AnQoQDQr/p8BjXNjH7VwTV9wBg0wJBE5FhQ5EgsXOSsBYik7ATIcFiXjVKAA8TkEX/cEvNkBpNm/9P5NoNldeHhdQAB5wTm5ESrECfEqITq0H8jyMO0xNQbyKRN7EpKK13LJPwAXFgPIaWWV/gCH3wJuLj8/LgD9kpQBxZRlaQABx3pMSLUBcIAuJiYsu0hMcAyqFnAMlnJKIRI3GtQFVgzwBVFaBFBaAFFaIY4nCQ0xqzUNJyEXUg1Alv66GEVQhQ1fBP6skg2mYwFEByAfdwQTE7INnoYIZgGT8Q1TBio1NE5iUiYcMAhxgRcAtiUysnM4BzIyIXkNVILoAgAHNC0n8w5RW/QOABUUBgcET/67ANr+zOACbjklAC+N/ZKSAcepQGl2X1QEtSAPEQAWK1S7QEmHTEZ7cWmwEwQD2TAHI/dSD7MUd0YHcBB1RkCxd8EHEaj1s3SoA8KQ/gIAKSkBb4NYW1wAVoT9bJACBCMAHCQkGyT+kXogUlhYUnoQSB0dAEBEbGtCP7oMAA8aGw4KODxjqGQ8OHE39nAIaHAIRgfyHXc3uAABkBcFCZF6ByPAKSE3A2hAkdjg/teQ0AT9kOoCFrtyOwAy8ANa5fADElAosy4RMAQMAfZFISMgGQEzEQMxsmRG5f4+L/4+gN9WLo5xMEGSRgABSAGJ/ndiHAYQFEdxCe//+QSjfbJcGXIJcxnxJ7FncYswBDEJcTsnASEJAQAEo/4aPD4+PAD+JgEWAUIBRAAC1f11UVICijD+QgG+cwrQowUltALd0ARBNEwxORTyDqgFABQyOQiWAA+WAFoRlgAYlABQDQPBfCITAENyQwMzBEMbAQUgJbsLIiWEQi5HBAu7EkQlQxLKXgEgCYAmGhxUAWcA/plUNiYCgP4AgwFFQCQc/rvUAX3wCRMwKFcyWnEUF7EOMVbxQwXwXAkCIQYLcQ6hDlf+mwFVAP7j9fb+5AFUBP6coIsBAQAC1QD+kf6eAQL+/gABYgFv/vQBDNUwBQUwBUowBQi033MPGgLxBAHQrZADEwRKAP5U4P5HAR4BBA78MAQe7/AB4bD+2wElMhOxcL02f6oTlJwLFNElFCgBBTAABwEhA7386DYAIys2AbH+CY0AAmY1Jisv/k8AAY0EEhYqLi0AAWm7FxkrKygE/pfxL/+6AZYCXphxduEWwUswBhA0BgcBMjcwMQUjIjURNjQDP+A/EVAWgAABUQD+RET+HCkpHAS6ulAARjYCcTfAHBsaHP38UQDzI/DwAAMEUBF0cbEPcQ8BMe8EAP70/PwBUAYDAtJwCCBwCKj1cAgZcQgAQqtwCPMrMT9tdAgUsEfzNjugWqYAMgAVAahF/hwTFgwWE7EIcgD+RRA2Qg1QNg8NAgRzADeBcY4B0AIYApNyhRXzahEw'
    $vMemFont &= 'ABMydLgACQAvuBS8AAAHLzAxARQGICMiLwEHAFAmNQA0PwE2MzIfAQAWAhgrGRESnQCeEhEZKiTADQASFA+/IwIKGAAhCEVGCCEYHwAQVQYHVRAAAQAADP86A7T/9UAAAwALALoACgAAAAMrMDEFITUAIQO0/FgDqMYCuwAkAAEBngLj0AJcA1EETgEADgFOAAEzFyMBnm1REFIDUW4AJv///wD6AAQEqgLXAggGACEBDwAtAAVQA+sC1gAPIgIPAwAABAOwAtUABhQAIwIPJAAPugLVVQAfJAIPEAAPHwIPJVUCDwcADxYCDyYCDxFVAA++Ag8nAg86gAemBYIHKIIHPwAEAR5VggcpggcvgA85ggcqVYIHDYAHm4IHK4JX/xWABw2CByyCDxX/+1AFOQLegActggc5UP//A5KCDy6CBx9VgG9fggcvhifIggcwVYIHFoAPloIHMYIHHFWAB0+CBzKCBw+AF9lVggczgj/2gAdoggc0VYIPMoAH5YIHNYIP71D/+QSjggc2gg8BQP/5BSUC3YAHN1WCBxPAF1fCBzjCAwVVwANKwgM5xku9wgM6AcFxAEX/LABuAxIKwGETugIEAysAgLgAAC+4AALAkgAXIxEzbikp1AAD3gAAIAA+AIAABUgCDAAeQFUASwBVAF0AagAAdwB/AJUAnwAAqQC+AMoA1AAA3AD9ARIBGAEAHAEsATIBOwEAQwFMAVABVAEAWAFeAWQBaAEAbAFwCMC6AVAxApa6ALcAKMABATdEAK3CATwBQMIFx7QAT8IB0wAVwQFXgBbZwQFCAYCcwAkwAF7BA4jVATHCAY0A18IBWB0AkMABADAQADDQEQExugEUwBi3ERJQObgBFIA1A0AFA1YvwAJACAfAAgfABAUBwAIJ0LoAYACtJAE3QQoAYEAFqdywuAFh0MAAwAJNwAIgRNy4AAtADAsvgLoADABNAURCCqpNwA4QQAUQwBREwAJOFMACwBnBAgFIQA0cVUANFsAEFsAEMMAHGKvAAsEJGcABGcAEMcACqhrAHtFAOFdCFNFABYhU3LoAwNEBVEMEtcAIKMALKEAiwQLMwAJWKcEAwAPKwAMqwBjTVcABLGACLGACV2ABLlVgAS7kBTBgATBgAcxVYAExYAEx5AI24BNRteAAOWACOaEOYAE6YAG2OmAB4QI/4APhE0BgAqpA5BdDYAFDZAFFYAFqRWAJ1WABR2AFYQJKtWQGS2ADSyEnYAF4YAGqeGABTOAATOAAT2ACtlMgK2EwX+AF4QBiYBiqqeAAceAAZOAEZOAEqnHgAWhgAWjgDTdgAVptoCJ1ZTSiBpqgBXerYAAhBXwgBXygBpBgAaqBYAGN4ACF4AB34ACqluAAmuAAtOAAtGAEWpvgAJvgAGECsOAHnhXgAZ6gDEDgAaPQulQBYmBBqaIMYiACqFWgA6ikBapgAapgAbCtYAG7oQngAL7gAL5gArVhMMigCcDgAeEywuQAqt3gAN3gA8PgAMPgAKrIYALEYAHU4ADO4ABV4TLQ4CEcYEYrYBzfRcBnK6APugDl4GDHU+IQYAMA52AF52Q+7FVgAewgFitgAfFgDvjV4AHXYAH+4AD+oF7BtKodokdKoAoEoAJH4ACmDeAAYGMBFiAG8eAAVaFQFuAAG6APGyMYASodYAEdYAEqYAEe3Ci6ASOgcCyhEQEoVaBx02IKH2ADLeAELRXgBG1gATNgATMvQYAVAGYBPAB2YACqhmAAlmAApmAAtmAAqsZgANZgAOZgAPZgAEAKXUEHAAYAARYFYAAmYAADcUEFAEo1AAFFYAACccMUTrXACk5ADDlgAQFGU2ABVeECVWABVYAfUGABV1NAGIAxAVtgAlsAH1ywAJoAsIIUoQJdoAJqXaAGpmABXyAFQEwBVmNgAsA6AcBMAcBMAapIYAFlYAFlYAFhYAFWZ0BSYQJpYAJpYAJoVWABamABZ+AAa2AIYK3gAG3gAGEIb+AAHeAA'
    $vMemFont &= 'NHLcwODM4I+hkAoAjgniAIDV4gDQAM2illwxAKGb42OhkwngAA5V4AAO5IASYAESZAEVdWABCuAAF+QAITThAh+15AYi4AAiABthASZgAdYmZAFxQQRwACv0AlAanfIAL7FOcACQGgAzNAaqNrQBOLQBPHAAPHAEqQANAI8QIkJwSUWwC2rQ4hSPUAFGkUBwAEj1kAFL0A7MkgERAbE9EQKqTXQAWJQCXHQAXnQB90EY8S6QVQCRVTEBARnxCFXBFG90DHOwAHO0AHZVNA96cAB6tAt+sAB+q/ABsQWDsADQcACUcADulDQFET+xAZh0BxE/cQCqoHQBovQApbQFrrQQqrJwALJ0B7V0CbkwAaq59FO/sAC/sADNsAB6wbAAwbAAsQexPXEFxVV0Bcf0ANH0ANM0CtXV9ADW9ADYdALadAixQlVxAOFwAOGQZuUwJAdrEkCRCOlQAekQB5EK762wAO+wAJEb+rAA+lQLSxNAsgABUCYBAhMTASoGsAAGswMBcGwBC6mzAwEPsAAPkxQBUSe90AkBUSdxAPFBcQEa0xGrsUEyAyEwAyHANiPVCevSBnAoAXQoAXAoUgdwKF/yAHEokQNxaXEANfABNVvUCPBnAfBnsgA+sAA+NZQJQrAAQnQBkCcBRn10AUrUCLEm8QBgQrEUATpSMAJS9AcgQnEzAVb90FxcNCxxXdUssBxFP7EcN8U+cgTBPmp0AYA+AW0VdAFusABuYJETMzUIMzUjMgAhFSYjACIVFDMyNxUzA8AAMAARIQE1NCMEIgdwAQc1IxUjATABIzU0MzIdASWGABdBATMX8AAVI4AlFTM3NSc1MACoBRUXoQAjUQQzMABFQQEvQAMWMzICBTUsIxdgALEGBcABIwdgFR8BFSMgBFEDL3ABNTMFQgG0A5QAJQAzNj0BIxUUI8YiYgBgChQrAeADwgt9kQk3tgCACIIAcAIiDRdEBhWQBzY1I4DENRA0OwE1YQAzMhe8MyUEAsAEswFBAQGRCBQzIUAAE0IOFzcm2ifyDzOAEZAFBWDIYQjcJzdAAAICpQMFYAoxAIEQDBUTNTczF9ACgVEANzMVIz0BQAABcAE+AUMSEhIBALcHES4wDxAYAAF2IgFo+vYDAGwvGAcJExEKgCATRhMTDzMwAABROCADCTogAwD9+08LCAgLAQALCkMMC0T9ywAmCykPDwteIQEBBA4RGNs3NjYANwLFJgpCCwwAJQonC0ELDSMACvxgGikXJQ0A+BgpFyYM/v8AFTchFBMgLg4ACxwPAf0aGhoAQEAabBgYGD8AJwEWJxVR/poADwsWKxYXASwAFhkPAxYUFAoAChQUEQgPAZsAEAwSMjMkCRAAAxYXFxcCEPwATxYmPAHaJ5oADg4GBgsICRUAChMsyw8i/T4ABg8VFg4GnBYAFRUWbwYOFRYADQb+FhMDDgsA/NQTeQYCBcYABQMEXQsLC90ACwElLxxYHyUALg1NTBMRuBqAGv30AVReNqAIABd3HBw9FxdZABw9FhZZSb16AnohABU+DgMONwAUFJQVFZQUvQBTU0wVAxQxFAAaOAxMTBQSSwBOTkx/JhQUQgAUCSYcKxUVSAAVCCGbRXh4RQQkJFMA1wZBe1sAGhpbVUAIF6QAISMovSokISYAKL2VlZUoKAEABBcaKxsJCRgAKhobEw4SEhEAEBQ0FRpOSzoAFygpG/7Ok70Avb0BIkEUBiEABwEYF5OTH3QAkzIPJisQGSgQKClADoAASFhYAP53dwF1JSX+IKcTMjITMgAvTgYpAAAy5QAQAocAqHoCn8BzEzDIAYE/C/F+MAAGQTcHIycHAfAqFzd6GCEMCgAbFx0ODQKfGAwODiAA8QMCADX+ar2Qx5BgdxNw1ZEDugXwzguS6RM9ATczcBYdARPR8XDx4CgWADUZrhkDQDEyAEBAMjFA/r3CAGHV1WHCAnYqYDQ0Kik04NcwBQGAfgLyApEDSlAEaBcAGyB+'
    $vMemFont &= 'AJDqBcYMjSBGBmJ7kO8yFhWlBQIjuAACXRQgIBQQFSAglXQAA0oZgBMUGBgUExlzANQUGPL0uPD0d/T099cCAfAOAgpSUm0CBuPx9HACSP8sAmyAABgAFQCaurBXFhDACHCTOoAASgAQWrgAAAJxQRUAaQCoEAB5ADCJADCZABiqqQAYuQAYyQAY2QAMCukADPkADApdQQdUAAkAIBkADCkADAMQcboAAQAOBBESEDm6AAIEErgABAAQuAAX3AC4ACAIL7gACgAGAC9RATwIAAACPAoAPA0Q3LoAFQQiMDElADMHFhUUBwYjACInNRYzMjY1ADQmIyIHAew5AC92QDxPJjMhAAwtRjAhCAwYAC4RRC8eHAQZgAIlGxQXAQAAVAAU/ssDZQGeAEAaACYAGwABVBYAAAMrugAeACQRAgcFAAsABzAxFwA0NzYzITUzFQAUBiMhIgcGFQAUFxYzIRchIoAnJgE0NjMygD8BAD8mFGVbggEXAOBCLv5jGRghACEYGQGUkf3wAIBbZgJZQDIxAkCBAVloPTdAnQAmNwcJEhIJBgC7Nz4CASk0NAApKjQ0AP///wD6AAQEqgNRAgAmACEAAAAGAExAHgADkAtgZIkLTqmGC6FakxejiiNKhguUX0aJC3CGC6IKgwuA7QAEBpUC14COACHzAAAHACUDAnaBCwAB/ywDrqQC1cAFI/7BC2GAC1PBBcBwAx/CHSXDL4m50wVgnckFwS/DBaHKBQvBKcMFX8QFNwAEAQoewhEpAAQHAED+KpnCBT/ABULIBWD+asvCBR7ABTHCF8MFodT+rcIFIcAFNMIXwwWIX/6jwAEC//HAHYLdwDUTABcAI8CDiAgAA8KBEQAOwgEiBsKHuAAWAKEV3AgwMQHBgxEzESEBQ50hNyEyFgUhABUhA933vf4eAOABAl14eF3+AB6OAVS/9fwUAAGk/lwBc57RAAHC/vhfTU1jELvEoXDDNTn//1QDksIvLsNrxcMFH3XAZV/CBS/DU8NlzgVgbjLJBcE7wwWhw3fOC6NOFMkFwUHDBV88wwUsQAADBGwC1cEFDanBBQ9TwwUywEflwhHuNcMj5D7tAmDqAuER4wKuoeoC4Q7jAl/kAgXgEWhKA1HgSjnjCOQRD1AABAfJ4k0z4jUzPAPw4jXkXOADITa4AC4QQIUAe2I0AGA0BNABwIM3IQMBIQE2ASB4MhcWFwkBMwAXIwFbhwEtuwD+u/7rAc4WJwArKCkqJRcBwwD9Em1RUgS7AQAD/kICgSAYGgAaFyH9fwNNbguBE28NEn8NCQEjN0IzdA3EUlJtbQ0C6t9qDU5gDRbiUOMM4VBiE+gNuAAT4VB0HCcCB9UcaYJJVDc0QlQuHUpmQUFtHSN34KLgDMCwGP8d4B2BoTNYMjcz4rHhsAZ1LQ8AA1ciZRQhDA8ALxUXImcRFwsCBM4h6mM1NUAZwAs2EwYAA2WXYBKgGwAnACuoIhCkcrWlIhDgABzgAKF0IrEUYeW1NTQ2I2gBNBX5ABQgIBQVICCVA+QA7iZGGRMUGBjIFBMZ4wAUGOESZaqh5BX7uAAogCgpYABqKMASGcATGeEBYAET1aDZA8DiE+LbDCEDoAJUH9yA62YgdHZgAIZVYACWYACmYAC2YADG1WAA1mAA5mAA9mAAgusqBgABFmAAJmAAA3FEQQVgax8ARWAAAlJxI0Ul3IACOkCqSqtgAIT3JYD3JYD3JYD3qiWA9yWA9yWA9yWA96olgPclgPclhfcloBRaJUCmJeAL6i8ccgAiO3wY8RcKUFL/FzcXFyIPwHRUe/8X8hekJTg3ACYmODgmGSMjEBkXJCT+F2wxJQAmMTEmJTEfH6QYGDAAFyAxLOy0a63xF0kwLKGEEzAsGxABbdEKFNB+cQAYQA1RCxu10AoBUAsBMALhGBjiGBYPtAxxABG/JAElBzAhESEHIF8wAAFNAf8LAcMB+ZD9gQADD5D+YQIMkAT+hN0LuroC'
    $vMemFont &= '0bsYTLpWcTewTiwDraVwThEQI5y64BQioAlVQhsiQBsiRRsiQBsiVUAbIkAbIkAbIkAbIlVAGyJAGyJAGyJAGyJ1RRsisAwiQBugBBCXE1tRGhKXFJQAcxopEZcaRSASHOAPCQAKohEA2yAecQAToR6iAhySKWAQtAch4hszcA8THBdfmAHQPwOtkP6WvPcQ9L8B+oAAXHh4BFw5bZm+utGenoDEu2NNTGCmHZr3MRG0g5CYD7AsADIACoUJdgigCnEABJBjcZrZGBOpMFADH7oXNvBdvvQW7AKTs1b+BQ7/Bf8F8QVbsF38BbYwXfYFJfoFTu3wBRJSS7UFDXQoOwaYJre8DPBc7AZlc1wWB5D0W64D9ZMwB3GMM1gHDFAIV18HUBVQBxhwLhJwAB7P3Af/UrMA7AgBCYxShglijA9SAgA2s5zQCgd3kDhQNqS+BrAKkcAwCCMIETMn0Xoe39/oUaF5AtF8QRUC8p5B9bgDBrQDBVGDtwPRd7ADokqhdgLRDrMDHbADujDwGANALnF8cwMHUhB6B9APCdEPlAcxdAAEuREEcwLReSEWAwAgdTAEM/AVA9JFUSNRBATbYjMTzBCwFKHKFtUEPxSLM2fgBR8NZgLRdR8TF7ELdKLwHSQQQrgAAutwD7EPFDAAGXIMMM3SPRYOlADQBxQgOQERI4IRgcoXAREzJU96AAYDkllAOv5aAOAzLz00AabgBP3Q33lhYjABYQD+dAJ0KDQr/vCfAY0Zx3kyJzSmcC3fERGRFaFEEGFyJgsStBKzlCsBkg87YCUlI8JDB6AA8l8QFwRf97zZAL339b/Zv/T+jE3Z8bNAAHn+oPAfA7GzsULECWNNTV/5EbQBNzEdvwcwLL8HvwdvuAexIr8HsgfM4COvB8lqbnYHTnIHIpKaNQcd70F4tgdAU7AgIbAgPwj7DzcQJ28IIxD3UyivCAE0q4M/exAvkpsfkCEkvxAnfwh4CA8iBwZPCV0MuwDZXXh5/qoPAwBXImUUIQwPLwAVFyJnERcLBAABc57R0Z6exADECWNNTV9fTQBNY9RjNTVAGQALNhMGAAQAHwAABARfA0oADQAAGwAnADMAKwAAugAWAAMAA0ArugAcACICDgsEAA4ADrgAHBC4QAAo0LgAIgAOLgDQMDEBFAYrAQAiJjU0NjsBMgAWJSMiBhUUFgEACjY1NCYDMhZQFRQGIwIdIwgLBABf97zZvff1vyDZv/T+TQC0eF0BAblvFCAgFBUgDCCVBAcPtQEwGRNAFBgYFBMZAwcUABgAAAACADIAgAQD5QNRABIAtQAPALgAEy+6ABIMgAsDK4BPECEjACAZATMRFBcWADMyNzY1ETMlADMXIwPl/j4vAP4+31YujnEwAEHg/bltUVIBAEz+uAFIAYn+AHdiHBAYH1cBKIl8bpIvFZwvIzeCM4wv/iVSUm2PL2oOiS9OgC8ZgMCFLbqsABSBwoC5FoC1GIG1CZNlJwcOZ9SCSVQINzRUTxx5ZkFBFcAcA8QcSsAcHgAqtAAjSB0TQCFBHRNAHeofQHoZwAElVB8UeE0/FnhNds4ldQ92AgAFVcClSsBdCMAmKcBdCzAvuAACwF7BBgsRWBI5ukAIRQIKRAIwADEJARUjNQEhCAETJ8BhBEr+VADg/kcBHgEO/ALnwGAC1f4e7/BAAeH+2wElQF8DxcQYSsAYFAAgQMJDGFYJwHnBQAnAPhXAQA+9wAEbwEDHFpW2yBvQTD0TyR7PO///wNoEBo0AAtUAJgAv/QCgAAcAJQPBhwPAhBvDBcPnO0jnQ+W6ACRUACVGihzgFQPgAB1V4AALZDgO4AAhvHUBgAchESEHIRVhAAQEWzJ0A4mQ/YEAAw+Q/mECDJAE/oQPdP6kugLR8LtMulbiFn8rfyt/KwF/KwAAAQFxAugUAoRgbAbgW7oAAZviJ+MkBeEiw2gBueNmBANOw2QAAgHmAiDDAqEDcCAtFwCWzcBwQFAZYAAD'
    $vMemFont &= '3GABFYAHCQAYCeABD9xBqBUAZiAbdmAAhmAAqpZgAKZgALZgAMZgACrWYADmYAD2YAAKXVRBBwARD8KJJsEhcVBBBQA1AAFFYAACEnHjEhXcgAI6ABWkAEpgAAJx4AtpAAGqeWAAiWAAmWAAqWAAqrlgAMlgANlgAOlgAFb5YADiCwkAARlgAClpYAADcWAeEkAOYUUAV6BpIpdIKxcCQTPiQAIARCU4NyYmODgAJhkjIxkXJCQAA3AxJSYxMSZAJTEfHxgYYAAXAiBhIwEBjwLtArrA4HMTIABgFsAgCGAAEgBgAA0v4AsjNjMiMiGFMxQHwQwjIpAHBgGej9MC7mfRAAEAKAIjAREDajPgMwtgCgHiCWAJEQAjAwERrjsDM1D+8AEQYWUj4AQMxeAEB6AZAAJYYoJgB7QCH2IHByISoQcFJBLKBKQIISQJAfelCSIK0gBkCgIa4AcnZApgCxQBDmILAaBXvwHINAJVwCojIAsjCrgAqgbgWQLgKgBikAgkAQAwMRMfAQcXJwAHNyc38D6acwAmhYIhdpkCVQCNCmaVTlKWYgIPYA05AAIG9QAKvcA/DuALJwCyASJP4gAOAuzjAQQ7QeAABwAOBdhiEyyAAAMEbALVAmCDFA0AgUdTYTADAClA//8CVQIr4B0ncABCASRBY2ABYB4tS4BCcQAKAF4DK9IpFFXQKRTQKRTQKRTQKRRV0CkU0CkU0CkU0CkUrdApFNUpwWcU4AkU1SlaFNApFIEoUSkeUCkeVVUpHlApHlApHlApHlVQKR5QKR5QKR5QKR5VUCkeUCkeVSkeUCkeV1ApUAnRA2aACnYwAIZVMACWMACmMAC2MADG1TAA1jAA5jAA9jAAVAmqLVAJLVAJLVUJLVAJSi0yMwowM0TcgC4ZiwJGwWEjcgAwADZyAAZAgG6BLxM0PgIzADIeAhUUDgIjQCIuAjcUHvAAPhACNTQu8AAOAiXToCrkMDcXkCsukAERAwAXKSxLZjk5ZgRLLHUAISdCWjNAM1pDJydDcQBCACcBMBolIyotAYBUDDImSx4zJQAVEyQ0IE4lATYVaQNwADjRAtMDRCcAJ0RaEyQ6MzAAPBEOIj4aLz9AJSVALxpD8R0EAAAvAI4B8wI1wfIdLgA8AONxDQF62LoAMUB8cQAj8g6yFKoFsBQFsBQFsBQFsBSqBbAUBbAUBbAUBbAUqgWwFAW1FAWwFAWwFLoFtRQFsBQQdRMeDxAeq8FIEh4PEB4PEB4PEB6qDxAeDxAeDxAeDxAeeg8QHg8QHnRN4V0RGClRck24ADEEozJwADdE3LpQKRkAI0AyuNQAIxABPgEbCkEmgAyuHqIrcDpAGBVIGQMmGAFDGwMVMzI1NCMcByMAYyBGUEwHFyMAAQ4qQy8ZGS8AQyonRzQfHTMARykxUjwhITwAUjExVD0iIz0AVEkmGBgOGC0AUiAnEhQpMAIADB4wPh8gPjASHgAXJB9wAP6CIwA6TCorTToiIQA5TS0qTDojAQAUNBkbY1TlJmAjFx0NWzJPYA3C0ADFAZvgExVwQNFFBRWJBZM/FxUnNTcAFV9mnJwBLjAgPE07UT7SASsBoAQB+AIbkkmPAWjFw5YLwli6ABHAQ3EAaRAXABHSEREiYDQGDb0wABAwABFN4WaRkBJwB5YG8ARxbAfAAgPQEUh4CQAN9JCTADBKsAEOqzGA8AIPWgERUAERcFEGE3AUkBQVFwcnFQAjETMXNzMRIwCtO0fHzjxCNwBDNTRBOAHk3wDfNjZGmqCeAaAVj4/+634QApJWB3EQ8CNzECc1FxUHZDWPcRAwL3cQcAMB2llyAw0QLdMNDFIUkQ1NlxS6kA08FR8BphUuRegVL1QWAgA0sAVkv7gFMwU1BtcJsQV1CgFzCvQvAWIAAYEFwgU0C6cLAQIAKgBIALABOAABlgHwAgQCNkACZgKsAtSQhfwAAxgDLgNiA3gAA7QEAAQ4BHAABLAE0gVABYAA'
    $vMemFont &= 'BbAF1gX4BhYABjYGgAcwB14AB6wH1AgACCYACEgIegigCLIACNIJBAkcCWgACZwJ0AoACkIACnwKwArgCwwACzQLhAuuC84AC/wMLAxADHQADKYMugzODNYADN4M5gzuDPYADP4NBg0ODRYADR4NJg0uDTYADT4NRg1ODVYADV4NZg1uDXYADX4Nhg2ODZYADZ4NtBPkFAQAFC4UYhR2FOYAFS4VOhVGFVIAFV4VahV2FYIAFY4VmhWmFbIAFb4VyhXWFeIAFe4WKhY2FkIAFk4WWhZmFnIAFn4WihaWFqIAFq4WuhbGFvwAFzIXche8GBQAGNQZLhm4GegAGhgaUhqkGsJAGuAbAhs+EACMABvKHAYcThygAB0AHTAdYB2aAB3sHh4eZB5wAB7MHxIfLh+8AB/mH/ogBCAkACAyIFogciB+ACFuIjYiUiK6ACLWIwQjNCM0UVI2AAtg8IXj4HQIRAVSkB0U/2NQACFE/stQACr95FAAQVWyAEqwAANwAdpQACpU/fVQAEGyAEqwAAcVUgMH0AHvUAAq/qJVUABBsgBKsgBT8EYHBABU0GMIABD/BYlRqv7wUAAW/wlQAIgY/yVQABn/R1AAIiESASL/TFAAI/8iIlAAJP9cUAAn/yIUUAAq/rdQAC3/ig9QAC9yBDD/W1AAKDH/DlAAMlIDM/8RUbA0/2hQADr/XlVQAEEyBULSAUMyBURVMgVHMgVKMgVNMgVPVTIFUDIFUTIFUlIDUxUyBVQyBVowBQwAEea6AP9gAAwANP7wEQBQNv7ZAFA5/sRVAChUAohWAohZAEQNEAAR/0EAFBP+txEAFBf/JgAUIf9dEQAUKv13AAo0/wERAAo2/wIACjj++xEACjn+uAAKOv9JVQAKQQJSSgJSVAJSVlUCUlgCUlkCKVoAKQ5FAGVOAAUU/o4ABTRE/uIABTb+ygAFN0T/ewAFOf62AAVUVQIXVgIXVwIXWQAXD1AAEP9CAAUUAK0PEAAW/0YABRj/dBEABRn/dgAFIf5HEQAFIv9tAAUj/14RAAUn/1AABSr931GAAi3/M4ACL4IgMET/fIACMf9LgAIyVP9ugAJBgh1Cgh1DVYIdR4IdSoIdTYIdT1WCHVCCHVGCHVKAHRAVgGhkgAIhgAsQADhBgLYQADn/XIACQVWCCFiCCFmACBSAFGJRgAIT/0qAAiGAXBQQACr/IoACNP99UYACOP9sgAI5ghE6VP9xgAJBghFKghFUVYIRWIIRWYIRWoARF0WAesiAAir+tYACQVWCBUqABRmANWGAAjhVgGUZwBRaQAFYwgJZFcACGkAHV0ABNP7r1UABNsICOUBbGkBeQQSqVkIEWUAEG0AKVEABFUFqG0AKUUABOf7BW0ABwWgbQApBBFlABB9FwDV7QAEh/whAASpU/fJAAUHCAkrAAiGtwG52QAHBHSFACnhAAaoUwAshwHF6QAEvQgeINP8dQAE2/n9AAYg3/2ZAATn+kEABqk9CB1RCB1ZCB1dCB4pZQAcjwIOvACRCYaokQmEkQmEkQmEkQmGqJEJhJEJhJkBM4EABiCr970ABLf95QAFqQUIERUBHJkArwQVNQcIFT//UACrAFKRBQAFB/4sAK0AxOxFAART+/kABFv8/UUABGP9yQAEjwDUrFcCbSUABL8IIMf9EVUABQ8IFR8IFT8IFUUHCBVn/6gAswCw3EUABFP4MQAEZ/zxRQAEv/7xAATPALCxFwFz9QAE2/r1AAThVQHwsQENwQAFTQgdUVUIHVkIHWEIHWUAHLVVCWC1AalRAATfAJi1VwEE4oABWIgJXIgJZVSACLyImLyImL6AoIqugAOEmL+ImL+ImL+ImKi/iJjCgNnKgACH/ojmgACr/BaAAQWIBqEUAJaAASiACMaIPijGgD1WgADn/JKAAqlZiAVlgATKiAzLgCGJsoAA2/2WgAGETMhdgBGEBoRIzYEDvADRF4CxxoAAU/sagABYVoGA0oDbe'
    $vMemFont &= 'oAAj/84RoAAk/8WgACr+jVWgAC2gaTTgJnCgADAV4Ck0IC95oAAy/xU1oAA0oHg04DthB0UAqhygAEqiBk2iBk+iBppQ4Eo04DKhBlL/oJJFICysoABU/0egAFcQABYANaAejgA2ZaASd6AAFP+gMqASexGgACH+a6AAKv56taAALWCCNiARYQRB4gKoRQAgoABKogNNogOCT6IDUv+KADdgCqpuoAAqYCI3oAbboACiQSICRQA/oABK4gKiT+ICUv/noABW4EaKOGAQa6AAFP9PoADoFv9voAAnIGjgOeICWjFgJTjgTSECTyICUVUgAjmgBmWgABRgNDlFoAZpoAAh/qmgACdE/3OgACr+V6AALa2gVDngCCEFMSAROaAYW2EE4SY5YAohBUoiBU1VIgVPIgVRIAU6IAsQFAA8oAw3oAAR/z5VoAAT4E084AIloAAWFSBfPCBlbqAAI/9TUaAAJ/9FoAAv4gUxFP9AoAA0YBM8ADVE/02gADb+UKAAN1UgvDxgXnigAEOiBkdVogZPogZRogZUogZVVaIGVqIGV6IGWaAGQVVijkGiTkFijkFijkFVYo5BoopBoopBoopBVaKKQaKKQ6KKRGJkRFViYURiYURiYUUgADPUAEbihkYgACJgAOGGikbihkrgBZsAS2KFqktihUtihUtihUtigqpLoipLIoNLIoNLIoOqTGKCTGKCTGKCTOJ9qkzifUzifUzifUzifapNohtNontNontN4miqTyIXTyIXT5ILT5ILqlBSPFCSO1AyO1ESBKpRcjpRcjpSEgFScjpaUtAK11AAkSxS0ArJEVAAT/+6UABR/8OrUACRO1ISB1QyO1QyO+pUMjtUcjdUEjfQCRA3alQSN1QQNy5QABE3VFWwLRVQAFRQD1byNVZV8jVW8jVWcjRWEjRW3RI0VhI08BywJFcyMtAPVZBxWHIxWHIxWHIxWFVSMFhSMFhSMFlSMFlVUjBZUjBZEi5Zsi1ZVbItWbItWbItWbItWhWyLaRQAGNQACH+71FQACr+olAALzBcpF1wIB5QAHBIUABB0gFF1ABJUABGcBGkMAWRAqhN/4dQAE/yAlPwAqql0gSl0gSl0gSlsgNapfICpTQC8VqmkgKmxZACy1AAKv3kUABxB+qmcgemcgemsAPRAXEHuqZyB6bQKJECcQemcgeqpjIFp9IEp9IEp9IECqeyA6fyAgAAGAGYJgABcAAAAAEbQQAZowAADNAAswACAAcEASe0AAMAHgEuFbQABDACTLQABQASVAFYtAAGcAFqtAAIUAALAXa0AAmwAIFBtAAKAT0BjLQACxAAGwLJtAAMABlEAuRQBgEECYAHNgQC/bQAAQAYBTNBtAACAA4FS7QAA1AAPAVZtAAEMAKVQbQABQAkBa20AAYFcAHRtAAIABYF6RW0AAmwAP+0AAoCegQGFbQACwA2CI8BtAAMADIIxakgADE5OTkgUmF5ACBMYXJhYmllAC4gVGhpcyBmEG9udCBxAHJlZQh3YXJgAVJlYWQAIGF0dGFjaGUAZCB0ZXh0IGYIaWxlkAJyIGRlAHRhaWxzLiBJAG5mbyAmIHVwAGRhdGVzIHZpAHNpdCB3d3cuBmzTBWEFcy5jb20ALiBEb25hdGlAb25zIGdywAJmAHVsbHkgYWNjaGVwdPAFYW8DYQMvAmRUAy5odG1sLiAgQWxzb1QGbXkCIAACbWVyY2lhIGwgdHlwoQl1bhxkclAFwwQwAW9kZTBybWljEwiHDndhAnM0C2QgaW4gMgAwMDQuRXRobgBvY2VudHJpY3BSZWd1oAhgElQSOhog6QE6UhQZAVZlcgJzUAogMi4wMDCf8gTqBOcWqABkACBGwQ4JsRdhYuAVdG8gbwBmZmVyIHVuaRxxdTANABlCC3MgdEBocm91Z2hwAGUgIGdlbmXQAHMggHN1cHBvcnRAA+lzEW9ygAJvMgLQAHAcwE1ha2luZyQEUAYDcBOxFy10'
    $vMemFont &= 'aW1lIABqb2IgYW5kIFhldmVwE8UWLEERYQpugBRtEBV0LCBlLm6xCbAD8gljoARpbuGwCXJ1bm6xBcUGogQYY3JlQARQAW5ldwNTB2AiZiB5b3UgAHdvdWxkIGxpfmtiBJULexAvJLUgmidoQHR0cDovL38Cb+ZtqAEbIACpYGCAnRIAUQFhYQB5cABMcAByATAAYgBpAGUALlEQAVQAaLAAc5AAZsAAbwBuAHSQAPUAYnIwAmUAdzID0wJSUXAAYQBkkABhkAJ0VVAAY/ADZRIBdHAAeLXyA2YQBGzQADMFcnAArmTQANECcQFzkgRJsAYF0QEgwLsgAHUAcKswAjEFZbIHdjIIadIEencSAC6QA7kL1QrRBGO1sABtUgVEUgFxBGmSAK2xBGdSA5EFZnAGbBAA65EQkQtjMAFwkgEVDd8GW98G0wYvMAO7Bi6QEHR1kAFskghBkg7xDbkMbauyBxMEbXAFcrAAaTAEAmzyE1m3AHkAcABlACAAAGYAbwB1AG4AIGQAcgB5AHhhAGp0ACh3AgguACwBnG8FAHRlAHxtAGkAYxUAVGMARG0ADiAAVFQAaAAmcwSObgR2YVUCInUAcmQCnmUADiBFAE5uAAoyADAAAjRVAHpFABloABNvAE9lVQI7cgJfUgANZwA9bFUAO3IADWEAg0wCC2HEAGIAIWUAOgBHFT2xARsxADkCARUjVgLNrnOABYFZgUkugkowiE87l06BRyCMSJMKiwYgAF5GhJGBjoOagQ1sgg10dYANIIABZoAAgU6Bn27tgBJxgAOD03KAA4XYhSJ1gVFyguBngASDB4ERZ2+CWYEjgQ2BFHOCx4HlcqOC0oE0IAB2wiFpQh+vQUTFIcURwwZlwnpNQCtaa0JxZ0whwzJtQkBm0UJubAAtwAZpwARBEVpqwApiQjvBmSDABHa7wibBC2TCEUGJQ2MsRorrQQtDpG3EqHRCB0E2xU2/wx3HT0GmwQlBEMNNckIO70FSwy1NNkclY0JYQyLDCq1BUHfKOsFBSUJOecIkq0G7wQFsQhBsQA5rSCP/zVzZg0diR99DwMULSSFD4NdDJsGKwed0QAppwAzBB4poQAN0QB46AC9AAC/lE7MGeYAAAAOBAAAAMP97ABQjAQ4AAQACAQEAAAwA+Aj/AAAIAAj//QAJBAAJoAAKAAr//BAACwALoAAMAAwBoAANAA3/+wAOFAAOoAAPogAQAA9A//oAEQAQoAASBAARoAATABL/+UWgDROgABUAFKAAFkAAFf/4ABeiABgEABagABkAF//3EAAaABigABsAGQGgABwAGv/2AB0UABugAB6iAB8AHBT/9YAnHaAAIQAeEaAAIgAfoAAjACBA//QAJAAhoAAlAaIAJgAi//MAJ0QAI6AAKAAkoAApAAAl//IAKgAmEaAAKwAnoAAsACiM//HAXqEALgApoACgLwAq//CAiSugAAgxACygADIALf8g7wAzAC6gADQAAi+gADUAMP/uAIg2ADGgADcAMqAAKjigAO2AlzOgADoAAjSgADsANf/sAIg8ADagAD0AN6AAgD4AOP/rAD+iAIhAADmgAEEAOqAAAEIAO//qAEMAIjygAEQAPaAARQCoPv/pAE0/oABHogCgSABA/+iAWEGgAAhKAEKgAEsAQ/+K54BTRKAATQBFoACCTqAA5gBPAEagAAhQAEegAFEASf9G5cCcoQBTAEqgAFQAAEv/5ABVAEwRoABWAE2gAFcATkD/4wBYAE+gAFkBogBaAFD/4gBbRABRoABcAFKgAF0AAFP/4QBeAFRRoABfAFWgAGCgAOBFgFJWoABiAFegAGMEAFigAGQAWf/fRUBOWqAAZgBboABnMABc/96AVKEAaQCCXaAAagBe/91AbiJfoABsAGCgAG0A6GH/3MBaYqAAgI6gAKBwAGP/28CoZaAAqHIAZqAAc6AA2sBaYmegAHUAaKAAgG//itmAXWqgAHgAa6AAgHkAbP/Y'
    $vMemFont &= 'AHqiAAh7AG2gAHwAbv8g1wB9AG+gAH4AAnCgAH8Acf/WAIiAAHKgAIEAc6AAAoKiAIMAdP/VAIiEAHWgAIUAdqAAAIYAd//UAIcAonigAIgAeaAAiaAAINMAigB6oACLAAJ7oACMAHz/0gCIjQB9oACOAH6gAICPAH//0QCQogAIkQCAoACSAIL/oNAAkwCDoACUogAAlQCE/88AlgAihaAAlwCGoACYAICH/84AmQCIoAAImgCJoACbAIr/iM0AnKIAnQCLoAAAngCM/8wAnwAijVAAoACOUAChAICP/8sAogCQUAAio1IApACRUAClAICS/8oApgCTUAAIpwCUUACoAJX/oMkAqQCWUACqUgAAqwCX/8gArAAimFAArQCZUACuAICa/8cArwCbUAAIsACcUACxAJ3/IMYAsgCeUACzAAKfUAC0AKD/xQAitVIAtgChUAC3AICi/8QAuACjUAAIuQCkUAC6AKX/IMMAuwCmUAC8AAqnUAC9UADCAL4AIqhQAL8AqVAAwACAqv/BAMEAq1AAiMIArFAAwwCtUACCxFAAwADFAK5QABjGAK9QALAI/78AiMgAsVAAyQCyUACAygCz/74Ay1IACMwAtFAAzQC1/yC9AM4AtlAAzwACt1AA0AC4/7wAiNEAuVAA0gC6UAAA0wC7/7sA1AAivFAA1QC9UADWACC+/7oA11IA2AACv1AA2QDA/7kAiNoAwVAA2wDCUAAA3ADD/7gA3QAKxFAA3lIA3wDF/yC3AOAAxlAA4QAix1AA4gDIUADjAIDJ/7YA5ADKUAAC5VIA5gDL/7UAiOcAzFAA6ADNUAAA6QDO/7QA6gAiz1AA6wDQUADsACDR/7MA7VIA7gAC0lAA7wDT/7IAiPAA1FAA8QDVUAAA8gDW/7EA8wAi11AA9ADYUAD1AIDZ/7AA9gDaUAAo9wDbUAD4UACvAIj5ANxQAPoA3VAAAPsA3v+uAPwAIt9QAP0A4FAA/gAg4f+tAP9RAA=='
    $vMemFont = _WinAPI_Base64Decode($vMemFont)
    Local $tSource = DllStructCreate('byte[' & BinaryLen($vMemFont) & ']')
    DllStructSetData($tSource, 1, $vMemFont)
    Local $tDecompress
    _WinAPI_LZNTDecompress($tSource, $tDecompress, 31304)
    $tSource = 0
    Local $bString = Binary(DllStructGetData($tDecompress, 1))
    If $bSaveBinary Then
        Local $hFile = FileOpen($sSavePath & "\ETHNOCEN.TTF", 18)
        FileWrite($hFile, $bString)
        FileClose($hFile)
    EndIf
    Return $bString
EndFunc   ;==>_MemFont

Func _WinAPI_Base64Decode($sB64String)
    Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "")
    Local $tBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]")
    $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $tBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($tBuffer, 1)
EndFunc   ;==>_WinAPI_Base64Decode

Func _WinAPI_LZNTDecompress(ByRef $tInput, ByRef $tOutput, $iBufferSize)
    $tOutput = DllStructCreate("byte[" & $iBufferSize & "]")
    If @error Then Return SetError(1, 0, 0)
    Local $aRet = DllCall("ntdll.dll", "uint", "RtlDecompressBuffer", "ushort", 0x0002, "struct*", $tOutput, "ulong", $iBufferSize, "struct*", $tInput, "ulong", DllStructGetSize($tInput), "ulong*", 0)
    If @error Then Return SetError(2, 0, 0)
    If $aRet[0] Then Return SetError(3, $aRet[0], 0)
    Return $aRet[6]
EndFunc   ;==>_WinAPI_LZNTDecompress


Function _GDIPlus_FontPrivateCollectionDispose

Function Reference

_GDIPlus_FontPrivateCollectionDispose

Deletes the specified PrivateFontCollection object

#include <GDIPlus.au3>
_GDIPlus_FontPrivateCollectionDispose ( $hFontCollection )

Parameters

$hFontCollection A handle to the font collection object to delete

Return Value

Success: | True
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_FontPrivateCreateCollection, _GDIPlus_FontFamilyCreateFromCollection, _GDIPlus_FontPrivateAddFont

See Also

Search GdipDeletePrivateFontCollection in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout, $sFontInternalName, $hCollection, $sFontFile = @WindowsDir & "\Fonts\Times.ttf"

    If _WinAPI_DwmIsCompositionEnabled() Then
        If Not @Compiled Then
            $sFontFile = StringRegExpReplace(@AutoItExe, "(.*)\\.*", "$1")
        Else
            $sFontFile = StringRegExpReplace(RegRead("HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\AutoItv3", "DisplayIcon"), "(.*)\\.*", "$1")
        EndIf
        If $sFontFile = "" Then Exit MsgBox(BitOR($MB_ICONERROR, $MB_TOPMOST), "Error", "Unable to locate SF Square Head Bold.ttf in AutoIt sub dir!")
        $sFontFile &= "\Examples\Helpfile\Extras\SF Square Head Bold.ttf"
    EndIf

    $sFontInternalName = _WinAPI_GetFontResourceInfo($sFontFile, Default, 1)

    $hGUI = GUICreate("GDI+", 720, 235)
    GUISetState()

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (anti aliasing)
    _GDIPlus_GraphicsSetTextRenderingHint($hGraphic, $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT) ;set the anti aliasing for fonts

    $hCollection = _GDIPlus_FontPrivateCreateCollection() ;create a PrivateFontCollection object to add fonts later
    _GDIPlus_FontPrivateAddFont($hCollection, $sFontFile) ;add the font to the font collection
    $hFormat = _GDIPlus_StringFormatCreate() ;create a string format object
    $hFamily = _GDIPlus_FontFamilyCreateFromCollection($sFontInternalName, $hCollection) ;create a font family object
    $hFont = _GDIPlus_FontCreate($hFamily, 72) ;create a font object
    $tLayout = _GDIPlus_RectFCreate(0, 0, 720, 235) ;create a $tagGDIPRECTF structure to save x, y position of the text
    _GDIPlus_StringFormatSetAlign($hFormat, 1) ;center text
    _GDIPlus_StringFormatSetLineAlign($hFormat, 1) ;center text
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F) ;create a brush with a defined color for the text
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "AutoIt" & @LF & "forever", $hFont, $tLayout, $hFormat, $hBrush) ;draw the string

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontPrivateCollectionDispose($hCollection)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_FontPrivateCreateCollection

Function Reference

_GDIPlus_FontPrivateCreateCollection

Creates a PrivateFont Collection object

#include <GDIPlus.au3>
_GDIPlus_FontPrivateCreateCollection ( )

Return Value

Success: | A handle to the InstalledFontCollection object
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

FontFamily objects belong to the collection, they should not be destroyed.
After you are done with the object, call _GDIPlus_FontPrivateCollectionDispose() to release the object resources

Related

_GDIPlus_FontPrivateCollectionDispose, _GDIPlus_FontPrivateAddFont, _GDIPlus_FontFamilyCreateFromCollection

See Also

Search GdipNewPrivateFontCollection in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout, $sFontInternalName, $hCollection, $sFontFile = @WindowsDir & "\Fonts\Times.ttf"

    If _WinAPI_DwmIsCompositionEnabled() Then
        If Not @Compiled Then
            $sFontFile = StringRegExpReplace(@AutoItExe, "(.*)\\.*", "$1")
        Else
            $sFontFile = StringRegExpReplace(RegRead("HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\AutoItv3", "DisplayIcon"), "(.*)\\.*", "$1")
        EndIf
        If $sFontFile = "" Then Exit MsgBox(BitOR($MB_ICONERROR, $MB_TOPMOST), "Error", "Unable to locate SF Square Head Bold.ttf in AutoIt sub dir!")
        $sFontFile &= "\Examples\Helpfile\Extras\SF Square Head Bold.ttf"
    EndIf

    $sFontInternalName = _WinAPI_GetFontResourceInfo($sFontFile, Default, 1)

    $hGUI = GUICreate("GDI+", 720, 235)
    GUISetState()

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (anti aliasing)
    _GDIPlus_GraphicsSetTextRenderingHint($hGraphic, $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT) ;set the anti aliasing for fonts

    $hCollection = _GDIPlus_FontPrivateCreateCollection() ;create a PrivateFontCollection object to add fonts later
    _GDIPlus_FontPrivateAddFont($hCollection, $sFontFile) ;add the font to the font collection
    $hFormat = _GDIPlus_StringFormatCreate() ;create a string format object
    $hFamily = _GDIPlus_FontFamilyCreateFromCollection($sFontInternalName, $hCollection) ;create a font family object
    $hFont = _GDIPlus_FontCreate($hFamily, 72) ;create a font object
    $tLayout = _GDIPlus_RectFCreate(0, 0, 720, 235) ;create a $tagGDIPRECTF structure to save x, y position of the text
    _GDIPlus_StringFormatSetAlign($hFormat, 1) ;center text
    _GDIPlus_StringFormatSetLineAlign($hFormat, 1) ;center text
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F) ;create a brush with a defined color for the text
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "AutoIt" & @LF & "forever", $hFont, $tLayout, $hFormat, $hBrush) ;draw the string

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontPrivateCollectionDispose($hCollection)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


User Defined Functions

FontFamily user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_FontFamilyCreate | Create a Font Family object
_GDIPlus_FontFamilyCreateFromCollection | Creates a FontFamily object based on a specified font family
_GDIPlus_FontFamilyDispose | Release a Font Family object
_GDIPlus_FontFamilyGetCellAscent | Gets the cell ascent, in design units, of a font family for the specified style or style combination
_GDIPlus_FontFamilyGetCellDescent | Gets the cell descent, in design units, of a font family for the specified style or style combination
_GDIPlus_FontFamilyGetEmHeight | Gets the size (commonly called em size or em height), in design units, of a font family
_GDIPlus_FontFamilyGetLineSpacing | Gets the line spacing, in design units, of this font family for the specified style or style combination


Function _GDIPlus_FontFamilyCreate

Function Reference

_GDIPlus_FontFamilyCreate

Create a Font Family object

#include <GDIPlus.au3>
_GDIPlus_FontFamilyCreate ( $sFamily [, $pCollection = 0] )

Parameters

$sFamily | Name of the Font Family
$pCollection | [optional] Pointer to a FontCollection object that specifies the collection that the font family belongs to.

Return Value

Success: | a handle to a Font Family object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the Font Family object, call _GDIPlus_FontFamilyDispose() to release the resources.

Related

_GDIPlus_FontFamilyDispose

See Also

Search GdipCreateFontFamilyFromName in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw a string
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBrush = _GDIPlus_BrushCreateSolid(0x7F00007F)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
    $tLayout = _GDIPlus_RectFCreate(140, 110, 100, 20)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Hello world", $hFont, $tLayout, $hFormat, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_FontFamilyCreateFromCollection

Function Reference

_GDIPlus_FontFamilyCreateFromCollection

Creates a FontFamily object based on a specified font family

#include <GDIPlus.au3>
_GDIPlus_FontFamilyCreateFromCollection ( $sFontName, $hFontCollection )

Parameters

$sFontName | A string value that specifies the internal name of a font, e.g. Times.ttf has as internal name 'Times New Roman'
$hFontCollection | A handle to the font collection object

Return Value

Success: | A handle to the new FontFamily object
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_FontPrivateCollectionDispose, _GDIPlus_FontPrivateAddFont, _GDIPlus_FontPrivateCreateCollection, _GDIPlus_FontFamilyCreate, _WinAPI_GetFontResourceInfo

See Also

Search GdipCreateFontFamilyFromName in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout, $sFontInternalName, $hCollection, $sFontFile = @WindowsDir & "\Fonts\Times.ttf"

    If _WinAPI_DwmIsCompositionEnabled() Then
        If Not @Compiled Then
            $sFontFile = StringRegExpReplace(@AutoItExe, "(.*)\\.*", "$1")
        Else
            $sFontFile = StringRegExpReplace(RegRead("HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\AutoItv3", "DisplayIcon"), "(.*)\\.*", "$1")
        EndIf
        If $sFontFile = "" Then Exit MsgBox(BitOR($MB_ICONERROR, $MB_TOPMOST), "Error", "Unable to locate SF Square Head Bold.ttf in AutoIt sub dir!")
        $sFontFile &= "\Examples\Helpfile\Extras\SF Square Head Bold.ttf"
    EndIf

    $sFontInternalName = _WinAPI_GetFontResourceInfo($sFontFile, Default, 1)

    $hGUI = GUICreate("GDI+", 720, 235)
    GUISetState()

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (anti aliasing)
    _GDIPlus_GraphicsSetTextRenderingHint($hGraphic, $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT) ;set the anti aliasing for fonts

    $hCollection = _GDIPlus_FontPrivateCreateCollection() ;create a PrivateFontCollection object to add fonts later
    _GDIPlus_FontPrivateAddFont($hCollection, $sFontFile) ;add the font to the font collection
    $hFormat = _GDIPlus_StringFormatCreate() ;create a string format object
    $hFamily = _GDIPlus_FontFamilyCreateFromCollection($sFontInternalName, $hCollection) ;create a font family object
    $hFont = _GDIPlus_FontCreate($hFamily, 72) ;create a font object
    $tLayout = _GDIPlus_RectFCreate(0, 0, 720, 235) ;create a $tagGDIPRECTF structure to save x, y position of the text
    _GDIPlus_StringFormatSetAlign($hFormat, 1) ;center text
    _GDIPlus_StringFormatSetLineAlign($hFormat, 1) ;center text
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F) ;create a brush with a defined color for the text
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "AutoIt" & @LF & "forever", $hFont, $tLayout, $hFormat, $hBrush) ;draw the string

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontPrivateCollectionDispose($hCollection)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_FontFamilyDispose

Function Reference

_GDIPlus_FontFamilyDispose

Release a Font Family object

#include <GDIPlus.au3>
_GDIPlus_FontFamilyDispose ( $hFamily )

Parameters

$hFamily Handle to a Font Family object

Return Value

Success: | True
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_FontFamilyCreate

See Also

Search GdipDeleteFontFamily in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw a string
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBrush = _GDIPlus_BrushCreateSolid(0x7F00007F)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
    $tLayout = _GDIPlus_RectFCreate(140, 110, 100, 20)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Hello world", $hFont, $tLayout, $hFormat, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_FontFamilyGetCellAscent

Function Reference

_GDIPlus_FontFamilyGetCellAscent

Gets the cell ascent, in design units, of a font family for the specified style or style combination

#include <GDIPlus.au3>
_GDIPlus_FontFamilyGetCellAscent ( $hFontFamily [, $iStyle = 0] )

Parameters

$hFontFamily | Pointer to a FontFamily object
$iStyle | [optional] The style of the typeface. Can be a combination of the following: 0 - Normal weight or thickness of the typeface 1 - Bold typeface 2 - Italic typeface 4 - Underline 8 - Strikethrough

Return Value

Success: | the FontFamily cell ascent, in design units.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetCellAscent in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create GUI
    Local $hGUI = GUICreate("GDI+", 800, 340)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    Local $hPen = _GDIPlus_PenCreate(0xFF0000FF)
    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000)

    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 96, 0)

    Local $sString = ChrW(0x1EF2) & ChrW(0x1EF3)

    Local $iPosX = 50
    Local $iPosY = 50
    Local $aStrDim = _MeasureString($hGraphic, $sString, $hFont, $hFormat, $hFamily)

    _GDIPlus_GraphicsDrawString($hGraphic, "MeasureString", $iPosX, $iPosY - 30)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX, $iPosY - 5, $iPosX, $iPosY + 5, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX - 5, $iPosY, $iPosX + 5, $iPosY, $hPen)
    Local $tLayout = _GDIPlus_RectFCreate($iPosX, $iPosY, $aStrDim[4], $aStrDim[5])
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX, $iPosY, $aStrDim[4], $aStrDim[5], $hPen)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush)

    $iPosX = 300
    _GDIPlus_GraphicsDrawString($hGraphic, "MeasureCharacterRanges", $iPosX, $iPosY - 30)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX, $iPosY - 5, $iPosX, $iPosY + 5, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX - 5, $iPosY, $iPosX + 5, $iPosY, $hPen)
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX + $aStrDim[0], $iPosY + $aStrDim[1], $aStrDim[2], $aStrDim[3], $hPen)
    DllStructSetData($tLayout, "X", $iPosX)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush)

    $iPosX = 550
    _GDIPlus_GraphicsDrawString($hGraphic, "CellAscent / CellDescent", $iPosX, $iPosY - 30)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX, $iPosY - 5, $iPosX, $iPosY + 5, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX - 5, $iPosY, $iPosX + 5, $iPosY, $hPen)
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX + $aStrDim[0], $iPosY + $aStrDim[1], $aStrDim[2], $aStrDim[7], $hPen)
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX + $aStrDim[0], $iPosY + $aStrDim[1] + $aStrDim[7], $aStrDim[2], $aStrDim[8], $hPen)
    DllStructSetData($tLayout, "X", $iPosX)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush)

    $sString = "fontsize goes crazy"
    $iPosX = 50
    $iPosY = 300

    Local $sChar
    For $i = 0 To StringLen($sString)

        $sChar = StringLeft($sString, 1)
        $sString = StringTrimLeft($sString, 1)

        If $sChar = " " Then
            $aStrDim = _MeasureString($hGraphic, "_", $hFont, $hFormat, $hFamily)
            $iPosX += $aStrDim[2]
            ContinueLoop
        EndIf

        _GDIPlus_FontDispose($hFont)
        $hFont = _GDIPlus_FontCreate($hFamily, Random(12, 48), 0)
        $aStrDim = _MeasureString($hGraphic, $sChar, $hFont, $hFormat, $hFamily)

        $tLayout = _GDIPlus_RectFCreate($iPosX - $aStrDim[0], $iPosY - $aStrDim[1] - $aStrDim[7], $aStrDim[4], $aStrDim[5])
        _GDIPlus_GraphicsDrawStringEx($hGraphic, $sChar, $hFont, $tLayout, $hFormat, $hBrush)

        $iPosX += $aStrDim[2]
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Func _MeasureString($hGraphics, $sString, $hFont, $hFormat, $hFamily, $iStyle = 0)
    Local $tLayout = _GDIPlus_RectFCreate()
    Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat)

    Local $aRanges[2][2] = [[1]]
    $aRanges[1][1] = StringLen($sString)
    _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges)
    Local $aRegion = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphics, $sString, $hFont, $aInfo[0], $hFormat)
    Local $aBounds = _GDIPlus_RegionGetBounds($aRegion[1], $hGraphics)
    _GDIPlus_RegionDispose($aRegion[1])

    Local $iFontHeight = _GDIPlus_FontGetHeight($hFont, $hGraphics)
    Local $iLineSpacing = _GDIPlus_FontFamilyGetLineSpacing($hFamily, $iStyle)
    Local $iAscent = $iFontHeight / $iLineSpacing * _GDIPlus_FontFamilyGetCellAscent($hFamily, $iStyle)
    Local $iDescent = $iFontHeight / $iLineSpacing * _GDIPlus_FontFamilyGetCellDescent($hFamily, $iStyle)

    Local $aDim[9]
    $aDim[0] = $aBounds[0]
    $aDim[1] = $aBounds[1]
    $aDim[2] = $aBounds[2]
    $aDim[3] = $aBounds[3]
    $aDim[4] = DllStructGetData($aInfo[0], "Width")
    $aDim[5] = DllStructGetData($aInfo[0], "Height")
    $aDim[6] = $iFontHeight
    $aDim[7] = $iAscent
    $aDim[8] = $iDescent

    Return $aDim
EndFunc   ;==>_MeasureString


Function _GDIPlus_FontFamilyGetCellDescent

Function Reference

_GDIPlus_FontFamilyGetCellDescent

Gets the cell descent, in design units, of a font family for the specified style or style combination

#include <GDIPlus.au3>
_GDIPlus_FontFamilyGetCellDescent ( $hFontFamily [, $iStyle = 0] )

Parameters

$hFontFamily | Pointer to a FontFamily object
$iStyle | [optional] The style of the typeface. Can be a combination of the following: 0 - Normal weight or thickness of the typeface 1 - Bold typeface 2 - Italic typeface 4 - Underline 8 - Strikethrough

Return Value

Success: | the FontFamily cell descent, in design units.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetCellDescent in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create GUI
    Local $hGUI = GUICreate("GDI+", 800, 340)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    Local $hPen = _GDIPlus_PenCreate(0xFF0000FF)
    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000)

    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 96, 0)

    Local $sString = ChrW(0x1EF2) & ChrW(0x1EF3)

    Local $iPosX = 50
    Local $iPosY = 50
    Local $aStrDim = _MeasureString($hGraphic, $sString, $hFont, $hFormat, $hFamily)

    _GDIPlus_GraphicsDrawString($hGraphic, "MeasureString", $iPosX, $iPosY - 30)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX, $iPosY - 5, $iPosX, $iPosY + 5, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX - 5, $iPosY, $iPosX + 5, $iPosY, $hPen)
    Local $tLayout = _GDIPlus_RectFCreate($iPosX, $iPosY, $aStrDim[4], $aStrDim[5])
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX, $iPosY, $aStrDim[4], $aStrDim[5], $hPen)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush)

    $iPosX = 300
    _GDIPlus_GraphicsDrawString($hGraphic, "MeasureCharacterRanges", $iPosX, $iPosY - 30)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX, $iPosY - 5, $iPosX, $iPosY + 5, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX - 5, $iPosY, $iPosX + 5, $iPosY, $hPen)
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX + $aStrDim[0], $iPosY + $aStrDim[1], $aStrDim[2], $aStrDim[3], $hPen)
    DllStructSetData($tLayout, "X", $iPosX)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush)

    $iPosX = 550
    _GDIPlus_GraphicsDrawString($hGraphic, "CellAscent / CellDescent", $iPosX, $iPosY - 30)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX, $iPosY - 5, $iPosX, $iPosY + 5, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX - 5, $iPosY, $iPosX + 5, $iPosY, $hPen)
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX + $aStrDim[0], $iPosY + $aStrDim[1], $aStrDim[2], $aStrDim[7], $hPen)
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX + $aStrDim[0], $iPosY + $aStrDim[1] + $aStrDim[7], $aStrDim[2], $aStrDim[8], $hPen)
    DllStructSetData($tLayout, "X", $iPosX)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush)

    $sString = "fontsize goes crazy"
    $iPosX = 50
    $iPosY = 300

    Local $sChar
    For $i = 0 To StringLen($sString)

        $sChar = StringLeft($sString, 1)
        $sString = StringTrimLeft($sString, 1)

        If $sChar = " " Then
            $aStrDim = _MeasureString($hGraphic, "_", $hFont, $hFormat, $hFamily)
            $iPosX += $aStrDim[2]
            ContinueLoop
        EndIf

        _GDIPlus_FontDispose($hFont)
        $hFont = _GDIPlus_FontCreate($hFamily, Random(12, 48), 0)
        $aStrDim = _MeasureString($hGraphic, $sChar, $hFont, $hFormat, $hFamily)

        $tLayout = _GDIPlus_RectFCreate($iPosX - $aStrDim[0], $iPosY - $aStrDim[1] - $aStrDim[7], $aStrDim[4], $aStrDim[5])
        _GDIPlus_GraphicsDrawStringEx($hGraphic, $sChar, $hFont, $tLayout, $hFormat, $hBrush)

        $iPosX += $aStrDim[2]
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Func _MeasureString($hGraphics, $sString, $hFont, $hFormat, $hFamily, $iStyle = 0)
    Local $tLayout = _GDIPlus_RectFCreate()
    Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat)

    Local $aRanges[2][2] = [[1]]
    $aRanges[1][1] = StringLen($sString)
    _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges)
    Local $aRegion = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphics, $sString, $hFont, $aInfo[0], $hFormat)
    Local $aBounds = _GDIPlus_RegionGetBounds($aRegion[1], $hGraphics)
    _GDIPlus_RegionDispose($aRegion[1])

    Local $iFontHeight = _GDIPlus_FontGetHeight($hFont, $hGraphics)
    Local $iLineSpacing = _GDIPlus_FontFamilyGetLineSpacing($hFamily, $iStyle)
    Local $iAscent = $iFontHeight / $iLineSpacing * _GDIPlus_FontFamilyGetCellAscent($hFamily, $iStyle)
    Local $iDescent = $iFontHeight / $iLineSpacing * _GDIPlus_FontFamilyGetCellDescent($hFamily, $iStyle)

    Local $aDim[9]
    $aDim[0] = $aBounds[0]
    $aDim[1] = $aBounds[1]
    $aDim[2] = $aBounds[2]
    $aDim[3] = $aBounds[3]
    $aDim[4] = DllStructGetData($aInfo[0], "Width")
    $aDim[5] = DllStructGetData($aInfo[0], "Height")
    $aDim[6] = $iFontHeight
    $aDim[7] = $iAscent
    $aDim[8] = $iDescent

    Return $aDim
EndFunc   ;==>_MeasureString


Function _GDIPlus_FontFamilyGetEmHeight

Function Reference

_GDIPlus_FontFamilyGetEmHeight

Gets the size (commonly called em size or em height), in design units, of a font family

#include <GDIPlus.au3>
_GDIPlus_FontFamilyGetEmHeight ( $hFontFamily [, $iStyle = 0] )

Parameters

$hFontFamily | Pointer to a FontFamily object
$iStyle | [optional] The style of the typeface. Can be a combination of the following: 0 - Normal weight or thickness of the typeface 1 - Bold typeface 2 - Italic typeface 4 - Underline 8 - Strikethrough

Return Value

Success: | the size, in design units, of this font family.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetEmHeight in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create GUI
    Local $hGUI = GUICreate("GDI+", 800, 340)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    Local $hPen = _GDIPlus_PenCreate(0xFF0000FF)
    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000)

    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 96, 0)

    Local $sString = ChrW(0x1EF2) & ChrW(0x1EF3)

    Local $iPosX = 50
    Local $iPosY = 50
    Local $aStrDim = _MeasureString($hGraphic, $sString, $hFont, $hFormat, $hFamily)

    _GDIPlus_GraphicsDrawString($hGraphic, "MeasureString", $iPosX, $iPosY - 30)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX, $iPosY - 5, $iPosX, $iPosY + 5, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX - 5, $iPosY, $iPosX + 5, $iPosY, $hPen)
    Local $tLayout = _GDIPlus_RectFCreate($iPosX, $iPosY, $aStrDim[4], $aStrDim[5])
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX, $iPosY, $aStrDim[4], $aStrDim[5], $hPen)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush)

    $iPosX = 300
    _GDIPlus_GraphicsDrawString($hGraphic, "MeasureCharacterRanges", $iPosX, $iPosY - 30)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX, $iPosY - 5, $iPosX, $iPosY + 5, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX - 5, $iPosY, $iPosX + 5, $iPosY, $hPen)
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX + $aStrDim[0], $iPosY + $aStrDim[1], $aStrDim[2], $aStrDim[3], $hPen)
    DllStructSetData($tLayout, "X", $iPosX)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush)

    $iPosX = 550
    _GDIPlus_GraphicsDrawString($hGraphic, "CellAscent / CellDescent", $iPosX, $iPosY - 30)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX, $iPosY - 5, $iPosX, $iPosY + 5, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX - 5, $iPosY, $iPosX + 5, $iPosY, $hPen)
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX + $aStrDim[0], $iPosY + $aStrDim[1], $aStrDim[2], $aStrDim[7], $hPen)
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX + $aStrDim[0], $iPosY + $aStrDim[1] + $aStrDim[7], $aStrDim[2], $aStrDim[8], $hPen)
    DllStructSetData($tLayout, "X", $iPosX)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush)

    $sString = "fontsize goes crazy"
    $iPosX = 50
    $iPosY = 300

    Local $sChar
    For $i = 0 To StringLen($sString)

        $sChar = StringLeft($sString, 1)
        $sString = StringTrimLeft($sString, 1)

        If $sChar = " " Then
            $aStrDim = _MeasureString($hGraphic, "_", $hFont, $hFormat, $hFamily)
            $iPosX += $aStrDim[2]
            ContinueLoop
        EndIf

        _GDIPlus_FontDispose($hFont)
        $hFont = _GDIPlus_FontCreate($hFamily, Random(12, 48), 0)
        $aStrDim = _MeasureString($hGraphic, $sChar, $hFont, $hFormat, $hFamily)

        $tLayout = _GDIPlus_RectFCreate($iPosX - $aStrDim[0], $iPosY - $aStrDim[1] - $aStrDim[7], $aStrDim[4], $aStrDim[5])
        _GDIPlus_GraphicsDrawStringEx($hGraphic, $sChar, $hFont, $tLayout, $hFormat, $hBrush)

        $iPosX += $aStrDim[2]
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Func _MeasureString($hGraphics, $sString, $hFont, $hFormat, $hFamily, $iStyle = 0)
    Local $tLayout = _GDIPlus_RectFCreate()
    Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat)

    Local $aRanges[2][2] = [[1]]
    $aRanges[1][1] = StringLen($sString)
    _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges)
    Local $aRegion = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphics, $sString, $hFont, $aInfo[0], $hFormat)
    Local $aBounds = _GDIPlus_RegionGetBounds($aRegion[1], $hGraphics)
    _GDIPlus_RegionDispose($aRegion[1])

    Local $iFontHeight = _GDIPlus_FontGetHeight($hFont, $hGraphics)
    Local $iLineSpacing = _GDIPlus_FontFamilyGetLineSpacing($hFamily, $iStyle)
    Local $iAscent = $iFontHeight / $iLineSpacing * _GDIPlus_FontFamilyGetCellAscent($hFamily, $iStyle)
    Local $iDescent = $iFontHeight / $iLineSpacing * _GDIPlus_FontFamilyGetCellDescent($hFamily, $iStyle)

    Local $aDim[9]
    $aDim[0] = $aBounds[0]
    $aDim[1] = $aBounds[1]
    $aDim[2] = $aBounds[2]
    $aDim[3] = $aBounds[3]
    $aDim[4] = DllStructGetData($aInfo[0], "Width")
    $aDim[5] = DllStructGetData($aInfo[0], "Height")
    $aDim[6] = $iFontHeight
    $aDim[7] = $iAscent
    $aDim[8] = $iDescent

    Return $aDim
EndFunc   ;==>_MeasureString


Function _GDIPlus_FontFamilyGetLineSpacing

Function Reference

_GDIPlus_FontFamilyGetLineSpacing

Gets the line spacing, in design units, of this font family for the specified style or style combination

#include <GDIPlus.au3>
_GDIPlus_FontFamilyGetLineSpacing ( $hFontFamily [, $iStyle = 0] )

Parameters

$hFontFamily | Pointer to a FontFamily object
$iStyle | [optional] The style of the typeface. Can be a combination of the following: 0 - Normal weight or thickness of the typeface 1 - Bold typeface 2 - Italic typeface 4 - Underline 8 - Strikethrough

Return Value

Success: | the line spacing, in design units, of this font family.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetLineSpacing in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create GUI
    Local $hGUI = GUICreate("GDI+", 800, 340)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    Local $hPen = _GDIPlus_PenCreate(0xFF0000FF)
    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000)

    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 96, 0)

    Local $sString = ChrW(0x1EF2) & ChrW(0x1EF3)

    Local $iPosX = 50
    Local $iPosY = 50
    Local $aStrDim = _MeasureString($hGraphic, $sString, $hFont, $hFormat, $hFamily)

    _GDIPlus_GraphicsDrawString($hGraphic, "MeasureString", $iPosX, $iPosY - 30)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX, $iPosY - 5, $iPosX, $iPosY + 5, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX - 5, $iPosY, $iPosX + 5, $iPosY, $hPen)
    Local $tLayout = _GDIPlus_RectFCreate($iPosX, $iPosY, $aStrDim[4], $aStrDim[5])
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX, $iPosY, $aStrDim[4], $aStrDim[5], $hPen)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush)

    $iPosX = 300
    _GDIPlus_GraphicsDrawString($hGraphic, "MeasureCharacterRanges", $iPosX, $iPosY - 30)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX, $iPosY - 5, $iPosX, $iPosY + 5, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX - 5, $iPosY, $iPosX + 5, $iPosY, $hPen)
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX + $aStrDim[0], $iPosY + $aStrDim[1], $aStrDim[2], $aStrDim[3], $hPen)
    DllStructSetData($tLayout, "X", $iPosX)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush)

    $iPosX = 550
    _GDIPlus_GraphicsDrawString($hGraphic, "CellAscent / CellDescent", $iPosX, $iPosY - 30)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX, $iPosY - 5, $iPosX, $iPosY + 5, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX - 5, $iPosY, $iPosX + 5, $iPosY, $hPen)
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX + $aStrDim[0], $iPosY + $aStrDim[1], $aStrDim[2], $aStrDim[7], $hPen)
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX + $aStrDim[0], $iPosY + $aStrDim[1] + $aStrDim[7], $aStrDim[2], $aStrDim[8], $hPen)
    DllStructSetData($tLayout, "X", $iPosX)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush)

    $sString = "fontsize goes crazy"
    $iPosX = 50
    $iPosY = 300

    Local $sChar
    For $i = 0 To StringLen($sString)

        $sChar = StringLeft($sString, 1)
        $sString = StringTrimLeft($sString, 1)

        If $sChar = " " Then
            $aStrDim = _MeasureString($hGraphic, "_", $hFont, $hFormat, $hFamily)
            $iPosX += $aStrDim[2]
            ContinueLoop
        EndIf

        _GDIPlus_FontDispose($hFont)
        $hFont = _GDIPlus_FontCreate($hFamily, Random(12, 48), 0)
        $aStrDim = _MeasureString($hGraphic, $sChar, $hFont, $hFormat, $hFamily)

        $tLayout = _GDIPlus_RectFCreate($iPosX - $aStrDim[0], $iPosY - $aStrDim[1] - $aStrDim[7], $aStrDim[4], $aStrDim[5])
        _GDIPlus_GraphicsDrawStringEx($hGraphic, $sChar, $hFont, $tLayout, $hFormat, $hBrush)

        $iPosX += $aStrDim[2]
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Func _MeasureString($hGraphics, $sString, $hFont, $hFormat, $hFamily, $iStyle = 0)
    Local $tLayout = _GDIPlus_RectFCreate()
    Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat)

    Local $aRanges[2][2] = [[1]]
    $aRanges[1][1] = StringLen($sString)
    _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges)
    Local $aRegion = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphics, $sString, $hFont, $aInfo[0], $hFormat)
    Local $aBounds = _GDIPlus_RegionGetBounds($aRegion[1], $hGraphics)
    _GDIPlus_RegionDispose($aRegion[1])

    Local $iFontHeight = _GDIPlus_FontGetHeight($hFont, $hGraphics)
    Local $iLineSpacing = _GDIPlus_FontFamilyGetLineSpacing($hFamily, $iStyle)
    Local $iAscent = $iFontHeight / $iLineSpacing * _GDIPlus_FontFamilyGetCellAscent($hFamily, $iStyle)
    Local $iDescent = $iFontHeight / $iLineSpacing * _GDIPlus_FontFamilyGetCellDescent($hFamily, $iStyle)

    Local $aDim[9]
    $aDim[0] = $aBounds[0]
    $aDim[1] = $aBounds[1]
    $aDim[2] = $aBounds[2]
    $aDim[3] = $aBounds[3]
    $aDim[4] = DllStructGetData($aInfo[0], "Width")
    $aDim[5] = DllStructGetData($aInfo[0], "Height")
    $aDim[6] = $iFontHeight
    $aDim[7] = $iAscent
    $aDim[8] = $iDescent

    Return $aDim
EndFunc   ;==>_MeasureString


User Defined Functions

Graphics user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_GraphicsClear | Clears a Graphics object to a specified color
_GDIPlus_GraphicsCreateFromHDC | Create a Graphics object from a device context (DC)
_GDIPlus_GraphicsCreateFromHWND | Create a Graphics object from a window handle
_GDIPlus_GraphicsDispose | Release a Graphics object
_GDIPlus_GraphicsDrawArc | Draw an arc
_GDIPlus_GraphicsDrawBezier | Draw a bezier spline
_GDIPlus_GraphicsDrawClosedCurve | Draw a closed cardinal spline
_GDIPlus_GraphicsDrawClosedCurve2 | Draws a closed cardinal spline
_GDIPlus_GraphicsDrawCurve | Draw a cardinal spline
_GDIPlus_GraphicsDrawCurve2 | Draws a cardinal spline
_GDIPlus_GraphicsDrawEllipse | Draw an ellipse
_GDIPlus_GraphicsDrawImage | Draw an Image object
_GDIPlus_GraphicsDrawImagePointsRect | Draws an image
_GDIPlus_GraphicsDrawImageRect | Draws an image at a specified location
_GDIPlus_GraphicsDrawImageRectRect | Draw an Image object
_GDIPlus_GraphicsDrawLine | Draw a line
_GDIPlus_GraphicsDrawPath | Draws a sequence of lines and curves defined by a GraphicsPath object
_GDIPlus_GraphicsDrawPie | Draw a pie
_GDIPlus_GraphicsDrawPolygon | Draw a polygon
_GDIPlus_GraphicsDrawRect | Draw a rectangle
_GDIPlus_GraphicsFillClosedCurve | Fill a closed cardinal spline
_GDIPlus_GraphicsFillClosedCurve2 | Creates a closed cardinal spline from an array of points and uses a brush to fill the interior of the spline
_GDIPlus_GraphicsFillEllipse | Fill an ellipse
_GDIPlus_GraphicsFillPath | Uses a brush to fill the interior of a path
_GDIPlus_GraphicsFillPie | Fill a pie
_GDIPlus_GraphicsFillPolygon | Fill a polygon
_GDIPlus_GraphicsFillRect | Fill a rectangle
_GDIPlus_GraphicsFillRegion | Uses a brush to fill a specified region
_GDIPlus_GraphicsGetCompositingMode | Gets the compositing mode currently set for a Graphics object
_GDIPlus_GraphicsGetCompositingQuality | Gets the compositing quality currently set for a Graphics object
_GDIPlus_GraphicsGetDC | Gets a handle to the device context of the Graphics object
_GDIPlus_GraphicsGetInterpolationMode | Gets the interpolation mode currently set for a Graphics object
_GDIPlus_GraphicsGetSmoothingMode | Gets the graphics object rendering quality
_GDIPlus_GraphicsGetTransform | Gets the world transformation matrix of a Graphics object
_GDIPlus_GraphicsReleaseDC | Releases the device context of the Graphics object
_GDIPlus_GraphicsResetClip | Sets the clipping region of a Graphics object to an infinite region
_GDIPlus_GraphicsResetTransform | Sets the world transformation matrix of a Graphics object to the identity matrix
_GDIPlus_GraphicsRestore | Restores the state of a Graphics object to the state stored by a previous call to the _GDIPlus_GraphicsSave method of the Graphics object
_GDIPlus_GraphicsRotateTransform | Updates the world transformation matrix of a Graphics object with the product of itself and a rotation matrix
_GDIPlus_GraphicsSave | Saves the current state (transformations, clipping region, and quality settings) of a Graphics object
_GDIPlus_GraphicsScaleTransform | Updates a Graphics object's world transformation matrix with the product of itself and a scaling matrix
_GDIPlus_GraphicsSetClipPath | Updates the clipping region of this Graphics object to a region that is the combination of itself and the region specified by a graphics path
_GDIPlus_GraphicsSetClipRect | Updates the clipping region of a Graphics object to a region that is the combination of itself and a rectangle
_GDIPlus_GraphicsSetClipRegion | Updates the clipping region of a Graphics object to a region that is the combination of itself and the region specified by a Region object
_GDIPlus_GraphicsSetCompositingMode | Sets the compositing mode of a Graphics object
_GDIPlus_GraphicsSetCompositingQuality | Sets the compositing quality of a Graphics object
_GDIPlus_GraphicsSetInterpolationMode | Sets the interpolation mode of a Graphics object
_GDIPlus_GraphicsSetPixelOffsetMode | Sets the pixel offset mode of a Graphics object
_GDIPlus_GraphicsSetSmoothingMode | Sets the graphics object rendering quality
_GDIPlus_GraphicsSetTextRenderingHint | Sets the contrast value of a Graphics object
_GDIPlus_GraphicsSetTransform | Sets the world transformation for a graphics object
_GDIPlus_GraphicsTransformPoints | Converts an array of points from one coordinate space to another
_GDIPlus_GraphicsTranslateTransform | Updates a Graphics object's world transformation matrix with the product of itself and a translation matrix


Function _GDIPlus_GraphicsClear

Function Reference

_GDIPlus_GraphicsClear

Clears a Graphics object to a specified color

#include <GDIPlus.au3>
_GDIPlus_GraphicsClear ( $hGraphics [, $iARGB = 0xFF000000] )

Parameters

$hGraphics | Handle to a Graphics object
$iARGB | [optional] Alpha, Red, Green and Blue components of color

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGraphicsClear in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hBitmap, $hImage, $hGraphic

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture screen region
    $hBitmap = _ScreenCapture_Capture("", 0, 0, 400, 300)
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; Clear the screen capture
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
    _GDIPlus_GraphicsClear($hGraphic)

    ; Save resultant image
    _GDIPlus_ImageSaveToFile($hImage, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_ImageDispose($hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
EndFunc   ;==>Example


Function _GDIPlus_GraphicsCreateFromHDC

Function Reference

_GDIPlus_GraphicsCreateFromHDC

Create a Graphics object from a device context (DC)

#include <GDIPlus.au3>
_GDIPlus_GraphicsCreateFromHDC ( $hDC )

Parameters

$hDC Device context

Return Value

Success: | a handle to a Graphics object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the Graphics object, call _GDIPlus_GraphicsDispose() to release the resources.

Related

_GDIPlus_GraphicsDispose

See Also

Search GdipCreateFromHDC in MSDN Library.

Example

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

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout, $hDC

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    $hDC = _WinAPI_GetWindowDC($hGUI)
    GUISetState(@SW_SHOW)

    ; Draw a string
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC)
    $hBrush = _GDIPlus_BrushCreateSolid(0x7F00007F)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
    $tLayout = _GDIPlus_RectFCreate(140, 110, 100, 20)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Hello world", $hFont, $tLayout, $hFormat, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _WinAPI_ReleaseDC($hGUI, $hDC)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_GraphicsCreateFromHWND

Function Reference

_GDIPlus_GraphicsCreateFromHWND

Create a Graphics object from a window handle

#include <GDIPlus.au3>
_GDIPlus_GraphicsCreateFromHWND ( $hWnd )

Parameters

$hWnd Handle to a window

Return Value

Success: | a handle to a Graphics object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the Graphics object, call _GDIPlus_GraphicsDispose() to release the resources.

Related

_GDIPlus_GraphicsDispose

See Also

Search GdipCreateFromHWND in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw a string
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBrush = _GDIPlus_BrushCreateSolid(0x7F00007F)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
    $tLayout = _GDIPlus_RectFCreate(140, 110, 100, 20)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Hello world", $hFont, $tLayout, $hFormat, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_GraphicsDispose

Function Reference

_GDIPlus_GraphicsDispose

Release a Graphics object

#include <GDIPlus.au3>
_GDIPlus_GraphicsDispose ( $hGraphics )

Parameters

$hGraphics Handle to a Graphics object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_GraphicsCreateFromHDC, _GDIPlus_GraphicsCreateFromHWND

See Also

Search GdipDeleteGraphics in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw a string
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBrush = _GDIPlus_BrushCreateSolid(0x7F00007F)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
    $tLayout = _GDIPlus_RectFCreate(140, 110, 100, 20)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Hello world", $hFont, $tLayout, $hFormat, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_GraphicsDrawArc

Function Reference

_GDIPlus_GraphicsDrawArc

Draw an arc

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawArc ( $hGraphics, $nX, $nY, $nWidth, $nHeight, $fStartAngle, $fSweepAngle [, $hPen = 0] )

Parameters

$hGraphics | Handle to a Graphics object
$nX | The X coordinate of the upper left corner of the rectangle that bounds the ellipse in which to draw the arc
$nY | The Y coordinate of the upper left corner of the rectangle that bounds the ellipse in which to draw the arc
$nWidth | The width of the rectangle that bounds the ellipse in which to draw the arc
$nHeight | The height of the rectangle that bounds the ellipse in which to draw the arc
$fStartAngle | The angle between the X axis and the starting point of the arc
$fSweepAngle | The angle between the starting and ending points of the arc
$hPen | [optional] Handle to a pen object that is used to draw the arc. If 0, a solid black pen with a width of 1 will be used.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipDrawArc in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw arcs
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsDrawArc($hGraphic, 160, 100, 10, 10, 180, 360)
    _GDIPlus_GraphicsDrawArc($hGraphic, 180, 100, 10, 10, 180, 360)
    _GDIPlus_GraphicsDrawArc($hGraphic, 160, 104, 30, 30, 160, -140)
    _GDIPlus_GraphicsDrawArc($hGraphic, 140, 80, 70, 70, 180, 360)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Example 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    ;create buffered graphics frame set for smoother gfx object movements
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hPen = _GDIPlus_PenCreate(0xFFFF8080, 32) ;color format AARRGGBB (hex)
    _GDIPlus_GraphicsDrawArc($hGraphics, 100.5, 100.5, 400.25, 400.25, -45.5, 270.5, $hPen)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_GraphicsDrawBezier

Function Reference

_GDIPlus_GraphicsDrawBezier

Draw a bezier spline

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawBezier ( $hGraphics, $nX1, $nY1, $nX2, $nY2, $nX3, $nY3, $nX4, $nY4 [, $hPen = 0] )

Parameters

$hGraphics | Handle to a Graphics object
$nX1 | X coordinate of the starting point
$nY1 | Y coordinate of the starting point
$nX2 | X coordinate of the first control point
$nY2 | Y coordinate of the first control point
$nX3 | X coordinate of the second control point
$nY3 | Y coordinate of the second control point
$nX4 | X coordinate of the ending point
$nY4 | Y coordinate of the ending point
$hPen | [optional] Handle to a pen object that is used to draw the bezier. If 0, a solid black pen with a width of 1 will be used.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

A Bezier spline does not pass through its control points.
The control points act as magnets, pulling the curve in certain directions to influence the way the spline bends.

See Also

Search GdipDrawBezier in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw a Bezier curve
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)

    _GDIPlus_GraphicsDrawBezier($hGraphic, 50, 50, 100, 5, 125, 25, 250, 50)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Example 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hPen = _GDIPlus_PenCreate(0xFFFFFF00, 8) ;color format AARRGGBB (hex)

    _GDIPlus_GraphicsDrawBezier($hGraphics, 50.25, 350.75, 100.5, 5.5, 125.5, 25.5, 550.5, 550.25, $hPen)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_GraphicsDrawClosedCurve

Function Reference

_GDIPlus_GraphicsDrawClosedCurve

Draw a closed cardinal spline

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawClosedCurve ( $hGraphics, $aPoints [, $hPen = 0] )

Parameters

$hGraphics | Handle to a Graphics object
$aPoints | Array that specifies the points of the curve: [0][0] - Number of points [1][0] - Point 1 X position [1][1] - Point 1 Y position [2][0] - Point 2 X position [2][1] - Point 2 Y position [n][0] - Point n X position [n][1] - Point n Y position
$hPen | [optional] Handle to a pen object that is used to draw the spline. If 0, a solid black pen with a width of 1 will be used.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

In a closed cardinal spline, the curve continues through the last point in the points array and connects with the first point in the array.
The array of points must contain a minimum of three elements.

See Also

Search GdipDrawClosedCurve in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $aPoints[8][2]

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw a cardinal spline
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)

    $aPoints[0][0] = 7
    $aPoints[1][0] = 50
    $aPoints[1][1] = 50
    $aPoints[2][0] = 100
    $aPoints[2][1] = 25
    $aPoints[3][0] = 200
    $aPoints[3][1] = 5
    $aPoints[4][0] = 250
    $aPoints[4][1] = 50
    $aPoints[5][0] = 300
    $aPoints[5][1] = 100
    $aPoints[6][0] = 350
    $aPoints[6][1] = 200
    $aPoints[7][0] = 250
    $aPoints[7][1] = 250

    _GDIPlus_GraphicsDrawClosedCurve($hGraphic, $aPoints)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Example 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hPen = _GDIPlus_PenCreate(0xFFFFFFFF, 4) ;color format AARRGGBB (hex)

    Local $aPoints[8][2]
    $aPoints[0][0] = 7
    $aPoints[1][0] = 50.5
    $aPoints[1][1] = 50.5
    $aPoints[2][0] = 100.75
    $aPoints[2][1] = 25.33
    $aPoints[3][0] = 200.66
    $aPoints[3][1] = 5.5
    $aPoints[4][0] = 250.25
    $aPoints[4][1] = 50.75
    $aPoints[5][0] = 300.125
    $aPoints[5][1] = 100.375
    $aPoints[6][0] = 590.8
    $aPoints[6][1] = 200.222
    $aPoints[7][0] = 250.55
    $aPoints[7][1] = 590.45

    _GDIPlus_GraphicsDrawClosedCurve($hGraphics, $aPoints, $hPen)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_GraphicsDrawClosedCurve2

Function Reference

_GDIPlus_GraphicsDrawClosedCurve2

Draws a closed cardinal spline

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawClosedCurve2 ( $hGraphics, $aPoints, $nTension [, $hPen = 0] )

Parameters

$hGraphics | Pointer to a Graphics object
$aPoints | Array of points that specify the coordinates of the closed cardinal spline. The array must [0][0] - Number of points [1][0] - Point 1 X position [1][1] - Point 1 Y position [2][0] - Point 2 X position [2][1] - Point 2 Y position [n][0] - Point n X position [n][1] - Point n Y position
$nTension | Number that specifies how tightly the curve bends through the coordinates of the closed cardinal spline
$hPen | [optional] Handle to a pen object that is used to draw the splines. If 0, a solid black pen with a width of

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_GraphicsDrawClosedCurve

See Also

Search GdipDrawClosedCurve2 in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Global $g_hGUI, $g_hGraphics, $g_hBitmap, $g_hGfxCtxt, $g_hPen

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    $g_hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $g_hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    ;create buffered graphics frame set for smoother gfx object movements
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle
    $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGraphics)
    $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    $g_hPen = _GDIPlus_PenCreate(0xFFFF8060, 2)
    _GDIPlus_GraphicsSetPixelOffsetMode($g_hGfxCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)

    Local $aPoints[11][4], $x, $y
    $aPoints[0][0] = 10

    For $y = 0 To 1
        For $x = 1 To 5
            $aPoints[$y * 5 + $x][0] = 100 + 300 * $y + 50 ;x coordinate of the point
            $aPoints[$y * 5 + $x][1] = 150 + $x * 50 ;y coordinate of the point
            $aPoints[$y * 5 + $x][2] = Random(-2, 2) ;x vector of the point
            $aPoints[$y * 5 + $x][3] = Random(-2, 2) ;y vector of the point
        Next
    Next

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

    Do
        _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ;clear bitmap for repaint
        _GDIPlus_GraphicsDrawClosedCurve2($g_hGfxCtxt, $aPoints, 1.25, $g_hPen) ;draw closed curve
        _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBitmap, 0, 0) ;copy bitmap to graphic handle (GUI)
        For $y = 1 To $aPoints[0][0]
            $aPoints[$y][0] += $aPoints[$y][2] ;calculate new x position
            If $aPoints[$y][0] < 0 Or $aPoints[$y][0] > $iWidth Then $aPoints[$y][2] *= -1 ;if vertical border is reached invert x vector
            $aPoints[$y][1] += $aPoints[$y][3] ;calculate new y position
            If $aPoints[$y][1] < 0 Or $aPoints[$y][1] > $iHeight Then $aPoints[$y][3] *= -1 ;if horizontal border is reached invert y vector
        Next
    Until Not Sleep(30) ;sleep 30 ms to avoid high cpu usage
EndFunc   ;==>Example

Func _Exit()
    ;cleanup GDI+ resources
    _GDIPlus_PenDispose($g_hPen)
    _GDIPlus_GraphicsDispose($g_hGfxCtxt)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_BitmapDispose($g_hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_GraphicsDrawCurve

Function Reference

_GDIPlus_GraphicsDrawCurve

Draw a cardinal spline

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawCurve ( $hGraphics, $aPoints [, $hPen = 0] )

Parameters

$hGraphics | Handle to a Graphics object
$aPoints | Array that specifies the points of the curve: [0][0] - Number of points [1][0] - Point 1 X position [1][1] - Point 1 Y position [2][0] - Point 2 X position [2][1] - Point 2 Y position [n][0] - Point n X position [n][1] - Point n Y position
$hPen | [optional] Handle to a pen object that is used to draw the spline. If 0, a solid black pen with a width of 1 will be used.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

A segment is defined as a curve that connects two consecutive points in the cardinal spline.
The ending point of each segment is the starting point for the next.

See Also

Search GdipDrawCurve in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $aPoints[5][2]

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw a cardinal spline
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)

    $aPoints[0][0] = 4
    $aPoints[1][0] = 0
    $aPoints[1][1] = 100
    $aPoints[2][0] = 50
    $aPoints[2][1] = 50
    $aPoints[3][0] = 100
    $aPoints[3][1] = 100
    $aPoints[4][0] = 150
    $aPoints[4][1] = 50

    _GDIPlus_GraphicsDrawCurve($hGraphic, $aPoints)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Example 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hPen = _GDIPlus_PenCreate(0xFFFFFFFF, 4) ;color format AARRGGBB (hex)

    Local $aPoints[8][2]
    $aPoints[0][0] = 7
    $aPoints[1][0] = 50.5
    $aPoints[1][1] = 50.5
    $aPoints[2][0] = 100.75
    $aPoints[2][1] = 25.33
    $aPoints[3][0] = 200.66
    $aPoints[3][1] = 5.5
    $aPoints[4][0] = 250.25
    $aPoints[4][1] = 50.75
    $aPoints[5][0] = 300.125
    $aPoints[5][1] = 100.375
    $aPoints[6][0] = 590.8
    $aPoints[6][1] = 200.222
    $aPoints[7][0] = 250.55
    $aPoints[7][1] = 590.45

    _GDIPlus_GraphicsDrawCurve($hGraphics, $aPoints, $hPen)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_GraphicsDrawCurve2

Function Reference

_GDIPlus_GraphicsDrawCurve2

Draws a cardinal spline

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawCurve2 ( $hGraphics, $aPoints, $nTension [, $hPen = 0] )

Parameters

$hGraphics | Pointer to a Graphics object
$aPoints | Array of points that specify the coordinates that the cardinal spline passes through: [0][0] - Number of points [1][0] - Point 1 X position [1][1] - Point 1 Y position [2][0] - Point 2 X position [2][1] - Point 2 Y position [n][0] - Point n X position [n][1] - Point n Y position
$nTension | Number that specifies how tightly the curve bends through the coordinates of the closed cardinal spline
$hPen | [optional] Handle to a pen object that is used to draw the splines. If 0, a solid black pen with a width of

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_GraphicsDrawCurve

See Also

Search GdipDrawCurve2 in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Global $g_hGUI, $g_hGraphics, $g_hBitmap, $g_hGfxCtxt, $g_hPen

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    $g_hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $g_hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    ;create buffered graphics frame set for smoother gfx object movements
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle
    $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGraphics)
    $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    $g_hPen = _GDIPlus_PenCreate(0xFFFF8060, 2)
    _GDIPlus_GraphicsSetPixelOffsetMode($g_hGfxCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)

    Local $aPoints[11][4], $x, $y
    $aPoints[0][0] = 10

    For $y = 0 To 1
        For $x = 1 To 5
            $aPoints[$y * 5 + $x][0] = 100 + 300 * $y + 50 ;x coordinate of the point
            $aPoints[$y * 5 + $x][1] = 150 + $x * 50 ;y coordinate of the point
            $aPoints[$y * 5 + $x][2] = Random(-2, 2) ;x vector of the point
            $aPoints[$y * 5 + $x][3] = Random(-2, 2) ;y vector of the point
        Next
    Next

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

    Do
        _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ;clear bitmap for repaint
        _GDIPlus_GraphicsDrawClosedCurve2($g_hGfxCtxt, $aPoints, 1.25, $g_hPen) ;draw closed curve
        _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBitmap, 0, 0) ;copy bitmap to graphic handle (GUI)
        For $y = 1 To $aPoints[0][0]
            $aPoints[$y][0] += $aPoints[$y][2] ;calculate new x position
            If $aPoints[$y][0] < 0 Or $aPoints[$y][0] > $iWidth Then $aPoints[$y][2] *= -1 ;if vertical border is reached invert x vector
            $aPoints[$y][1] += $aPoints[$y][3] ;calculate new y position
            If $aPoints[$y][1] < 0 Or $aPoints[$y][1] > $iHeight Then $aPoints[$y][3] *= -1 ;if horizontal border is reached invert y vector
        Next
    Until Not Sleep(30) ;sleep 30 ms to avoid high cpu usage
EndFunc   ;==>Example

Func _Exit()
    ;cleanup GDI+ resources
    _GDIPlus_PenDispose($g_hPen)
    _GDIPlus_GraphicsDispose($g_hGfxCtxt)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_BitmapDispose($g_hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_GraphicsDrawEllipse

Function Reference

_GDIPlus_GraphicsDrawEllipse

Draw an ellipse

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawEllipse ( $hGraphics, $nX, $nY, $nWidth, $nHeight [, $hPen = 0] )

Parameters

$hGraphics | Handle to a Graphics object
$nX | The X coordinate of the upper left corner of the rectangle that bounds the ellipse
$nY | The Y coordinate of the upper left corner of the rectangle that bounds the ellipse
$nWidth | The width of the rectangle that bounds the ellipse
$nHeight | The height of the rectangle that bounds the ellipse
$hPen | [optional] Handle to a pen object that is used to draw the arc. If 0, a solid black pen with a width of 1 will be used.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipDrawEllipse in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw an ellipse
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsDrawEllipse($hGraphic, 130, 100, 140, 70)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Example 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBgColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hPen = _GDIPlus_PenCreate(0xFFABCDEF, 4) ;color format AARRGGBB (hex)

    _GDIPlus_GraphicsDrawEllipse($hGraphics, 10.5, 50.1, 580.25, 500.75, $hPen)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_GraphicsDrawImage

Function Reference

_GDIPlus_GraphicsDrawImage

Draw an Image object

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawImage ( $hGraphics, $hImage, $nX, $nY )

Parameters

$hGraphics | Handle to a Graphics object
$hImage | Handle to an Image object
$nX | The X coordinate of the upper left corner of the rendered image
$nY | The Y coordinate of the upper left corner of the rendered image

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipDrawImage in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphic

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture full screen
    $hBitmap1 = _ScreenCapture_Capture("")
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1)

    ; Capture screen region
    $hBitmap2 = _ScreenCapture_Capture("", 0, 0, 400, 300)
    $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap2)

    ; Draw one image in another
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hImage2, 100, 100)

    ; Draw a frame around the inserted image
    _GDIPlus_GraphicsDrawRect($hGraphic, 100, 100, 400, 300)

    ; Save resultant image
    _GDIPlus_ImageSaveToFile($hImage1, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _WinAPI_DeleteObject($hBitmap1)
    _WinAPI_DeleteObject($hBitmap2)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
EndFunc   ;==>Example

Example 2

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Global $g_hGUI, $g_hGfxCtxt, $g_hBitmap, $g_hBMP, $g_hGraphics

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    $g_hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $g_hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    ;create buffered graphics frame set for smoother gfx object movements
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle
    $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGraphics)
    $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap)
    Local $iW = 300, $iH = 300
    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iW, $iH) ;create a GDI bitmap by capturing an area on desktop
    $g_hBMP = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore
    Local $iVectorX = Random(1.5, 2.5), $iVectorY = Random(1.5, 2.5) ;define x and y vector
    Local $iX = 0.0, $iY = 0.0 ;define start coordinate

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

    Do
        _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ;clear bitmap for repaint
        _GDIPlus_GraphicsDrawImage($g_hGfxCtxt, $g_hBMP, $iX, $iY) ;draw bitmap to backbuffer
        _GDIPlus_GraphicsDrawImageRect($g_hGraphics, $g_hBitmap, 0, 0, $iWidth, $iHeight) ;copy drawn bitmap to graphics handle (GUI)
        $iX += $iVectorX ;add x vector to current x position
        $iY += $iVectorY ;add y vector to current y position
        If $iX < 0 Or $iX > ($iWidth - $iW) Then $iVectorX *= -1 ;when x border is reached reverse x vector
        If $iY < 0 Or $iY > ($iHeight - $iH) Then $iVectorY *= -1 ;when y border is reached reverse y vector
    Until Not Sleep(10) ;sleep 10 ms to avoid high cpu usage
EndFunc   ;==>Example

Func _Exit()
    ;cleanup GDI+ resources
    _GDIPlus_GraphicsDispose($g_hGfxCtxt)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_BitmapDispose($g_hBitmap)
    _GDIPlus_BitmapDispose($g_hBMP)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_GraphicsDrawImagePointsRect

Function Reference

_GDIPlus_GraphicsDrawImagePointsRect

Draws an image

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawImagePointsRect ( $hGraphics, $hImage, $nULX, $nULY, $nURX, $nURY, $nLLX, $nLLY, $nSrcX, $nSrcY, $nSrcWidth, $nSrcHeight [, $hImageAttributes = 0 [, $iUnit = 2]] )

Parameters

$hGraphics | Pointer to a Graphics object
$hImage | Pointer to an Image object
$nULX | The X coordinate of the upper left corner of the source image
$nULY | The Y coordinate of the upper left corner of the source image
$nURX | The X coordinate of the upper right corner of the source image
$nURY | The Y coordinate of the upper right corner of the source image
$nLLX | The X coordinate of the lower left corner of the source image
$nLLY | The Y coordinate of the lower left corner of the source image
$nSrcX | The X coordinate of the upper-left corner of the portion of the source image to be drawn
$nSrcY | The Y coordinate of the upper-left corner of the portion of the source image to be drawn
$nSrcWidth | The width of the portion of the source image to be drawn
$nSrcHeight | The height of the portion of the source image to be drawn
$hImageAttributes | [optional] Pointer to an ImageAttributes object that specifies the color and size attributes of the image to be drawn
$iUnit | [optional] Unit of measurement: 0 - World coordinates, a nonphysical unit 1 - Display units 2 - A unit is 1 pixel 3 - A unit is 1 point or 1/72 inch 4 - A unit is 1 inch 5 - A unit is 1/300 inch 6 - A unit is 1 millimeter

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_GraphicsDrawImage

See Also

Search GdipDrawImagePointsRect in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; X64 running support
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"

    ;get AutoIt install dir
    Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt"

    Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif"
    If Not FileExists($sFile) Then
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30)
        Return False
    EndIf

    _GDIPlus_Startup()
    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile) ;create an image object based on a file
    If @error Then
        _GDIPlus_Shutdown()
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "An error has occured - unable to load image!", 30)
        Return False
    EndIf

    Local $hGUI, $hGraphic, $iImgW, $iImgH

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 400)
    GUISetState(@SW_SHOW)
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle

    $iImgW = _GDIPlus_ImageGetWidth($hImage)
    $iImgH = _GDIPlus_ImageGetHeight($hImage)

    _GDIPlus_GraphicsDrawImagePointsRect($hGraphic, $hImage, 100, 10, 300, 60, 90, 160, 0, 0, $iImgW * 0.45, $iImgH)
    _GDIPlus_GraphicsDrawImagePointsRect($hGraphic, $hImage, 300, 60, 360, 30, 290, 210, $iImgW * 0.45, 0, $iImgW * 0.2, $iImgH)
    _GDIPlus_GraphicsDrawImagePointsRect($hGraphic, $hImage, 360, 30, 560, 80, 350, 180, $iImgW * 0.65, 0, $iImgW * 0.35, $iImgH)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup resources
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_GraphicsDrawImageRect

Function Reference

_GDIPlus_GraphicsDrawImageRect

Draws an image at a specified location

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawImageRect ( $hGraphics, $hImage, $nX, $nY, $nW, $nH )

Parameters

$hGraphics | Handle to a Graphics object
$hImage | Handle to an Image object
$nX | The X coordinate of the upper left corner of the rendered image
$nY | The Y coordinate of the upper left corner of the rendered image
$nW | Specifies the width of the destination rectangle at which to draw the image
$nH | Specifies the height of the destination rectangle at which to draw the image

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipDrawImageRect in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphic

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture full screen
    $hBitmap1 = _ScreenCapture_Capture("")
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1)

    ; Capture screen region
    $hBitmap2 = _ScreenCapture_Capture("", 0, 0, 400, 300)
    $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap2)

    ; Draw one image in another
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage2, 100, 100, 400, 300)

    ; Draw a frame around the inserted image
    _GDIPlus_GraphicsDrawRect($hGraphic, 100, 100, 400, 300)

    ; Save resultant image
    _GDIPlus_ImageSaveToFile($hImage1, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _WinAPI_DeleteObject($hBitmap1)
    _WinAPI_DeleteObject($hBitmap2)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
EndFunc   ;==>Example

Example 2

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Global $g_hGUI, $g_hGfxCtxt, $g_hBitmap, $g_hBMP, $g_hGraphics

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    $g_hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $g_hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    ;create buffered graphics frame set for smoother gfx object movements
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle
    $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGraphics)
    $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap)
    Local Const $iW = 300, $iH = 300
    Local $hHBmp = _ScreenCapture_Capture("", 0, @DesktopHeight - $iH, $iW, @DesktopHeight) ;create a GDI bitmap by capturing an area on desktop
    $g_hBMP = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore
    Local $iVectorX = Random(1.5, 2.5), $iVectorY = Random(1.5, 2.5) ;define x and y vector
    Local $iX = 0.0, $iY = 0.0 ;define start coordinate

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

    Do
        _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ;clear bitmap for repaint
        _GDIPlus_GraphicsDrawImageRect($g_hGfxCtxt, $g_hBMP, $iX, $iY, $iW, $iH) ;draw bitmap to backbuffer
        _GDIPlus_GraphicsDrawImageRect($g_hGraphics, $g_hBitmap, 0, 0, $iWidth, $iHeight) ;copy drawn bitmap to graphics handle (GUI)
        $iX += $iVectorX ;add x vector to current x position
        $iY += $iVectorY ;add y vector to current y position
        If $iX < 0 Or $iX > ($iWidth - $iW) Then $iVectorX *= -1 ;when x border is reached reverse x vector
        If $iY < 0 Or $iY > ($iHeight - $iH) Then $iVectorY *= -1 ;when y border is reached reverse y vector
    Until Not Sleep(20) ;sleep 20 ms to avoid high cpu usage
EndFunc   ;==>Example

Func _Exit()
    ;cleanup GDI+ resources
    _GDIPlus_GraphicsDispose($g_hGfxCtxt)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_BitmapDispose($g_hBitmap)
    _GDIPlus_BitmapDispose($g_hBMP)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_GraphicsDrawImageRectRect

Function Reference

_GDIPlus_GraphicsDrawImageRectRect

Draw an Image object

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawImageRectRect ( $hGraphics, $hImage, $nSrcX, $nSrcY, $nSrcWidth, $nSrcHeight, $nDstX, $nDstY, $nDstWidth, $nDstHeight [, $pAttributes = 0 [, $iUnit = 2]] )

Parameters

$hGraphics | Handle to a Graphics object
$hImage | Handle to an Image object
$nSrcX | The X coordinate of the upper left corner of the source image
$nSrcY | The Y coordinate of the upper left corner of the source image
$nSrcWidth | Width of the source image
$nSrcHeight | Height of the source image
$nDstX | The X coordinate of the upper left corner of the destination image
$nDstY | The Y coordinate of the upper left corner of the destination image
$nDstWidth | Width of the destination image
$nDstHeight | Height of the destination image
$pAttributes | [optional] Pointer to an ImageAttributes structure that specifies the color and size attributes of the image to be drawn. The default value is NULL.
$iUnit | [optional] Specifies the unit of measure for the image

Return Value

Success: | True
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipDrawImageRectRect in MSDN Library.

Example

Example 1

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    Local $pIA = _GDIPlus_ImageAttributesCreate() ;create an ImageAttribute object

    ;create the color matrix used to adjust the colors of the image
    Local $tColorMatrix = _GDIPlus_ColorMatrixCreateTranslate(-1, -1, 0) ;use translation color matrix to create a blue scaled image

    _GDIPlus_ImageAttributesSetColorMatrix($pIA, 0, True, $tColorMatrix) ;adjust the ImageAttribute color-key color matrix

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iWidth, $iHeight) ;create a GDI bitmap by capturing an area on desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore
    _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $pIA) ;draw the bitmap while applying the color adjustment

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_ImageAttributesDispose($pIA)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example

Example 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Global $g_hGUI, $g_hGfxCtxt, $g_hBitmap, $g_hBMP, $g_hGraphics

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    $g_hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $g_hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    ;create buffered graphics frame set for smoother gfx object movements
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle
    $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGraphics)
    $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap)
    Local Const $iW = 300, $iH = 300
    Local $hHBmp = _ScreenCapture_Capture("", 4, @DesktopHeight - $iH, $iW + 4, @DesktopHeight) ;create a GDI bitmap by capturing an area on desktop
    $g_hBMP = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore
    Local $iVectorX = Random(1.5, 2.5), $iVectorY = Random(1.5, 2.5) ;define x and y vector
    Local $iX = 0.0, $iY = 0.0 ;define start coordinate

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

    Do
        _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ;clear bitmap for repaint
        _GDIPlus_GraphicsDrawImageRectRect($g_hGfxCtxt, $g_hBMP, 0, 0, $iW, $iH, $iX, $iY, $iW / 2, $iH) ;draw bitmap to backbuffer by halving the width
        _GDIPlus_GraphicsDrawImageRect($g_hGraphics, $g_hBitmap, 0, 0, $iWidth, $iHeight) ;copy drawn bitmap to graphics handle (GUI)
        $iX += $iVectorX ;add x vector to current x position
        $iY += $iVectorY ;add y vector to current y position
        If $iX < 0 Or $iX > ($iWidth - $iW / 2) Then $iVectorX *= -1 ;when x border is reached reverse x vector
        If $iY < 0 Or $iY > ($iHeight - $iH) Then $iVectorY *= -1 ;when y border is reached reverse y vector
    Until Not Sleep(20) ;sleep 20 ms to avoid high cpu usage
EndFunc   ;==>Example

Func _Exit()
    ;cleanup GDI+ resources
    _GDIPlus_GraphicsDispose($g_hGfxCtxt)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_BitmapDispose($g_hBitmap)
    _GDIPlus_BitmapDispose($g_hBMP)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_GraphicsDrawLine

Function Reference

_GDIPlus_GraphicsDrawLine

Draw a line

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawLine ( $hGraphics, $nX1, $nY1, $nX2, $nY2 [, $hPen = 0] )

Parameters

$hGraphics | Handle to a Graphics object
$nX1 | The X coordinate of the starting point of the line
$nY1 | The Y coordinate of the starting point of the line
$nX2 | The X coordinate of the ending point of the line
$nY2 | The Y coordinate of the ending point of the line
$hPen | [optional] Handle to a pen object that is used to draw the arc. If 0, a solid black pen with a width of 1 will be used.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipDrawLine in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw line
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate()
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Example 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Global $g_hGUI, $g_hGraphics, $g_hBitmap, $g_hGfxCtxt, $g_hPen

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    _GDIPlus_Startup() ;initialize GDI+
    Local $iW = 600, $iH = 600
    Local Const $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    $g_hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iW, $iH) ;create a test GUI
    GUISetBkColor($iBgColor, $g_hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    ;create buffered graphics frame set for smoother gfx object movements
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle
    $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $g_hGraphics)
    $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    $g_hPen = _GDIPlus_PenCreate(0xFF8080FF, 2)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

    Local Const $fDeg = ACos(-1) / 180, $iRadius = 300, $iWidth = $iW / 2, $iHeight = $iH / 2
    Local $fAngle = 0

    Do
        _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ;clear bitmap for repaint
        _GDIPlus_GraphicsDrawEllipse($g_hGfxCtxt, $iWidth - $iRadius / 2 + $iRadius / 18, $iHeight - $iRadius / 2 + $iRadius / 18, $iRadius - $iRadius / 9, $iRadius - $iRadius / 9, $g_hPen) ;draw ellipse
        _GDIPlus_GraphicsDrawLine($g_hGfxCtxt, $iWidth + Cos($fAngle * $fDeg) * $iRadius, $iHeight + Sin($fAngle * $fDeg) * $iRadius, _ ;draw line
                $iWidth + Cos($fAngle * $fDeg + 180) * $iRadius, $iHeight + Sin($fAngle * $fDeg + 180) * $iRadius, $g_hPen)

        _GDIPlus_GraphicsDrawImageRect($g_hGraphics, $g_hBitmap, 0, 0, $iW, $iH) ;copy drawn bitmap to graphics handle (GUI)
        $fAngle += 0.5
    Until Not Sleep(20) ;sleep 20 ms to avoid high cpu usage
EndFunc   ;==>Example

Func _Exit()
    ;cleanup GDI+ resources
    _GDIPlus_PenDispose($g_hPen)
    _GDIPlus_GraphicsDispose($g_hGfxCtxt)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_BitmapDispose($g_hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_GraphicsDrawPath

Function Reference

_GDIPlus_GraphicsDrawPath

Draws a sequence of lines and curves defined by a GraphicsPath object

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawPath ( $hGraphics, $hPath [, $hPen = 0] )

Parameters

$hGraphics | Pointer to a Graphics object
$hPath | Pointer to a GraphicsPath object that specifies the sequence of lines and curves that make up the path
$hPen | [optional] Handle to a pen object that is used to draw the splines. If 0, a solid black pen with a width of 1 will be used.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathCreate

See Also

Search GdipDrawPath in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hFamily, $tLayout

    ; Create GUI
    $hGUI = GUICreate("GDI+", 420, 160)
    GUISetState(@SW_SHOW)

    ; Draw a string using path
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    $hBrush = _GDIPlus_BrushCreateSolid(0xFFDD2200)
    $hPen = _GDIPlus_PenCreate(0xFFFFBB00, $GDIP_SMOOTHINGMODE_HIGHQUALITY)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    $hFamily = _GDIPlus_FontFamilyCreate("Arial") ;Create font family object
    $tLayout = _GDIPlus_RectFCreate() ;Create string bounding rectangle X=0, Y=0
    _GDIPlus_PathAddString($hPath, "AutoIt rulez!", $tLayout, $hFamily, 0, 72, 0) ;Add the outline of the string to the path

    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFF000000)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_GraphicsDrawPie

Function Reference

_GDIPlus_GraphicsDrawPie

Draw a pie

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawPie ( $hGraphics, $nX, $nY, $nWidth, $nHeight, $fStartAngle, $fSweepAngle [, $hPen = 0] )

Parameters

$hGraphics | Handle to a Graphics object
$nX | The X coordinate of the upper left corner of the rectangle that bounds the ellipse in which to draw the pie
$nY | The Y coordinate of the upper left corner of the rectangle that bounds the ellipse in which to draw the pie
$nWidth | The width of the rectangle that bounds the ellipse in which to draw the pie
$nHeight | The height of the rectangle that bounds the ellipse in which to draw the pie
$fStartAngle | The angle, in degrees, between the X axis and the starting point of the arc that defines the pie. A positive value specifies clockwise rotation.
$fSweepAngle | The angle, in degrees, between the starting and ending points of the arc that defines the pie. A positive value specifies clockwise rotation.
$hPen | [optional] Handle to a pen object that is used to draw the arc. If 0, a solid black pen with a width of 1 will be used.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipDrawPie in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw a pie
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsDrawPie($hGraphic, 150, 80, 100, 100, 45, 90)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Example 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hPen = _GDIPlus_PenCreate(0xFFA08080, 2) ;color format AARRGGBB (hex)
    _GDIPlus_GraphicsDrawPie($hGraphics, 100.5, 0.5, 400.75, 400.125, 45, 90, $hPen)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_GraphicsDrawPolygon

Function Reference

_GDIPlus_GraphicsDrawPolygon

Draw a polygon

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawPolygon ( $hGraphics, $aPoints [, $hPen = 0] )

Parameters

$hGraphics | Handle to a Graphics object
$aPoints | Array that specify the vertices of the polygon: [0][0] - Number of vertices [1][0] - Vertice 1 X position [1][1] - Vertice 1 Y position [2][0] - Vertice 2 X position [2][1] - Vertice 2 Y position [n][0] - Vertice n X position [n][1] - Vertice n Y position
$hPen | [optional] Handle to a pen object that is used to draw the polygon. If 0, a solid black pen with a width of 1 will be used.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

If the first and last points are not identical, a line is drawn between them to close the polygon.

See Also

Search GdipDrawPolygon in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $aPoints[4][2]

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw a polygon
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)

    $aPoints[0][0] = 3
    $aPoints[1][0] = 150
    $aPoints[1][1] = 150
    $aPoints[2][0] = 200
    $aPoints[2][1] = 100
    $aPoints[3][0] = 250
    $aPoints[3][1] = 150

    _GDIPlus_GraphicsDrawPolygon($hGraphic, $aPoints)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Example 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hPen = _GDIPlus_PenCreate(0xFFFFFFFF, 40) ;color format AARRGGBB (hex)

    ;  1 _____ 3
    ;    \   /
    ;     \ /
    ;      2
    Local $aPoints[4][2]
    $aPoints[0][0] = 3
    $aPoints[1][0] = 50.0
    $aPoints[1][1] = 150.0
    $aPoints[2][0] = 300.0
    $aPoints[2][1] = 500.0
    $aPoints[3][0] = 550.0
    $aPoints[3][1] = 150.0

    _GDIPlus_GraphicsDrawPolygon($hGraphics, $aPoints, $hPen) ;draw the triangle

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_GraphicsDrawRect

Function Reference

_GDIPlus_GraphicsDrawRect

Draw a rectangle

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawRect ( $hGraphics, $nX, $nY, $nWidth, $nHeight [, $hPen = 0] )

Parameters

$hGraphics | Handle to a Graphics object
$nX | The X coordinate of the upper left corner of the rectangle
$nY | The Y coordinate of the upper left corner of the rectangle
$nWidth | The width of the rectangle
$nHeight | The height of the rectangle
$hPen | [optional] Handle to a pen object that is used to draw the rectangle. If 0, a solid black pen with a width of 1 will be used

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipDrawRectangle in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphics

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture full screen
    $hBitmap1 = _ScreenCapture_Capture("")
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1)

    ; Capture screen region
    $hBitmap2 = _ScreenCapture_Capture("", 0, 0, 400, 300)
    $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap2)

    ; Draw one image in another
    $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage1)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hImage2, 100, 100)

    ; Draw a frame around the inserted image
    _GDIPlus_GraphicsDrawRect($hGraphics, 100, 100, 400, 300)

    ; Save resultant image
    _GDIPlus_ImageSaveToFile($hImage1, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _WinAPI_DeleteObject($hBitmap1)
    _WinAPI_DeleteObject($hBitmap2)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
EndFunc   ;==>Example

Example 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBgColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hPen = _GDIPlus_PenCreate(0xFFFEDCBA, 4) ;color format AARRGGBB (hex)

    _GDIPlus_GraphicsDrawRect($hGraphics, 150.5, 50.1, 280.25, 500.75, $hPen)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_GraphicsFillClosedCurve

Function Reference

_GDIPlus_GraphicsFillClosedCurve

Fill a closed cardinal spline

#include <GDIPlus.au3>
_GDIPlus_GraphicsFillClosedCurve ( $hGraphics, $aPoints [, $hBrush = 0] )

Parameters

$hGraphics | Handle to a Graphics object
$aPoints | Array that specifies the points of the curve: [0][0] - Number of points [1][0] - Point 1 X position [1][1] - Point 1 Y position [2][0] - Point 2 X position [2][1] - Point 2 Y position [n][0] - Point n X position [n][1] - Point n Y position
$hBrush | [optional] Handle to a brush object that is used to fill the ellipse. If 0, a black brush will be used.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

In a closed cardinal spline, the curve continues through the last point in the points array and connects with the first point in the array.
The array of points must contain a minimum of three elements.

See Also

Search GdipFillClosedCurve in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $aPoints[8][2]

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Fill a cardinal spline
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)

    $aPoints[0][0] = 7
    $aPoints[1][0] = 50
    $aPoints[1][1] = 50
    $aPoints[2][0] = 100
    $aPoints[2][1] = 25
    $aPoints[3][0] = 200
    $aPoints[3][1] = 5
    $aPoints[4][0] = 250
    $aPoints[4][1] = 50
    $aPoints[5][0] = 300
    $aPoints[5][1] = 100
    $aPoints[6][0] = 350
    $aPoints[6][1] = 200
    $aPoints[7][0] = 250
    $aPoints[7][1] = 250

    _GDIPlus_GraphicsFillClosedCurve($hGraphic, $aPoints)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Example 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) ;color format AARRGGBB (hex)

    Local $aPoints[8][2]
    $aPoints[0][0] = 7
    $aPoints[1][0] = 50.5
    $aPoints[1][1] = 50.5
    $aPoints[2][0] = 100.75
    $aPoints[2][1] = 25.33
    $aPoints[3][0] = 200.66
    $aPoints[3][1] = 5.5
    $aPoints[4][0] = 250.25
    $aPoints[4][1] = 50.75
    $aPoints[5][0] = 300.125
    $aPoints[5][1] = 100.375
    $aPoints[6][0] = 590.8
    $aPoints[6][1] = 200.222
    $aPoints[7][0] = 250.55
    $aPoints[7][1] = 590.45

    _GDIPlus_GraphicsFillClosedCurve($hGraphics, $aPoints, $hBrush)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_GraphicsFillClosedCurve2

Function Reference

_GDIPlus_GraphicsFillClosedCurve2

Creates a closed cardinal spline from an array of points and uses a brush to fill the interior of the spline

#include <GDIPlus.au3>
_GDIPlus_GraphicsFillClosedCurve2 ( $hGraphics, $aPoints, $nTension [, $hBrush = 0 [, $iFillMode = 0]] )

Parameters

$hGraphics | Pointer to a Graphics object
$aPoints | Array of points that specify the coordinates of the closed cardinal spline: [0][0] - Number of points [1][0] - Point 1 X position [1][1] - Point 1 Y position [2][0] - Point 2 X position [2][1] - Point 2 Y position [n][0] - Point n X position [n][1] - Point n Y position
$nTension | Number that specifies how tightly the spline bends as it passes through the points
$hBrush | [optional] Handle to a brush object that is used to fill the cardinal spline. If 0, a black brush will be used.
$iFillMode | [optional] Fill mode of the interior of the spline: 0 - The areas are filled according to the even-odd parity rule 1 - The areas are filled according to the nonzero winding rule

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_GraphicsFillClosedCurve

See Also

Search GdipFillClosedCurve2 in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Global $g_hGUI, $g_hGfxCtxt, $g_hBitmap, $g_hGraphics, $g_hBrush

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    $g_hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $g_hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    ;create buffered graphics frame set for smoother gfx object movements
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle
    $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGraphics)
    $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    $g_hBrush = _GDIPlus_BrushCreateSolid(0xFF80FF60)

    Local $aPoints[11][4], $x, $y
    $aPoints[0][0] = 10

    For $y = 0 To 1
        For $x = 1 To 5
            $aPoints[$y * 5 + $x][0] = 100 + 300 * $y + 50 ;x coordinate of the point
            $aPoints[$y * 5 + $x][1] = 150 + $x * 50 ;y coordinate of the point
            $aPoints[$y * 5 + $x][2] = Random(-2, 2) ;x vector of the point
            $aPoints[$y * 5 + $x][3] = Random(-2, 2) ;y vector of the point
        Next
    Next

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

    Do
        _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ;clear bitmap for repaint
        _GDIPlus_GraphicsFillClosedCurve2($g_hGfxCtxt, $aPoints, 0.75, $g_hBrush) ;draw closed curve
        _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBitmap, 0, 0) ;copy bitmap to graphic handle (GUI)
        For $y = 1 To $aPoints[0][0]
            $aPoints[$y][0] += $aPoints[$y][2] ;calculate new x position
            If $aPoints[$y][0] < 0 Or $aPoints[$y][0] > $iWidth Then $aPoints[$y][2] *= -1 ;if vertical border is reached invert x vector
            $aPoints[$y][1] += $aPoints[$y][3] ;calculate new y position
            If $aPoints[$y][1] < 0 Or $aPoints[$y][1] > $iHeight Then $aPoints[$y][3] *= -1 ;if horizontal border is reached invert y vector
        Next
    Until Not Sleep(30) ;sleep 30 ms to avoid high cpu usage
EndFunc   ;==>Example

Func _Exit()
    ;cleanup GDI+ resources
    _GDIPlus_BrushDispose($g_hBrush)
    _GDIPlus_GraphicsDispose($g_hGfxCtxt)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_BitmapDispose($g_hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_GraphicsFillEllipse

Function Reference

_GDIPlus_GraphicsFillEllipse

Fill an ellipse

#include <GDIPlus.au3>
_GDIPlus_GraphicsFillEllipse ( $hGraphics, $nX, $nY, $nWidth, $nHeight [, $hBrush = 0] )

Parameters

$hGraphics | Handle to a Graphics object
$nX | The X coordinate of the upper left corner of the rectangle that bounds the ellipse
$nY | The Y coordinate of the upper left corner of the rectangle that bounds the ellipse
$nWidth | The width of the rectangle that bounds the ellipse
$nHeight | The height of the rectangle that bounds the ellipse
$hBrush | [optional] Handle to a brush object that is used to fill the ellipse. If 0, a black brush will be used.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipFillEllipse in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw an ellipse
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsFillEllipse($hGraphic, 130, 100, 140, 70)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Example 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBgColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFE0A0FF) ;color format AARRGGBB (hex)

    _GDIPlus_GraphicsFillEllipse($hGraphics, 10.5, 50.1, 580.25, 500.75, $hBrush)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_GraphicsFillPath

Function Reference

_GDIPlus_GraphicsFillPath

Uses a brush to fill the interior of a path

#include <GDIPlus.au3>
_GDIPlus_GraphicsFillPath ( $hGraphics, $hPath [, $hBrush = 0] )

Parameters

$hGraphics | Pointer to a Graphics object
$hPath | Pointer to a GraphicsPath object that specifies the path
$hBrush | [optional] Handle to a Brush object that is used to paint the interior of the path. If 0, a black brush will be used.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

If a figure in the path is not closed, this function treats the nonclosed figure as if it were closed by a straight line that connects the figure's starting and ending points.

Related

_GDIPlus_PathCreate

See Also

Search GdipFillPath in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hFamily, $tLayout

    ; Create GUI
    $hGUI = GUICreate("GDI+", 420, 160)
    GUISetState(@SW_SHOW)

    ; Draw a string using path
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    $hBrush = _GDIPlus_BrushCreateSolid(0xFFDD2200)
    $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    $hFamily = _GDIPlus_FontFamilyCreate("Arial") ;Create font family object
    $tLayout = _GDIPlus_RectFCreate() ;Create string bounding rectangle X=0, Y=0
    _GDIPlus_PathAddString($hPath, "AutoIt rulez!", $tLayout, $hFamily, 0, 72, 0) ;Add the outline of the string to the path

    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFF000000)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_GraphicsFillPie

Function Reference

_GDIPlus_GraphicsFillPie

Fill a pie

#include <GDIPlus.au3>
_GDIPlus_GraphicsFillPie ( $hGraphics, $nX, $nY, $nWidth, $nHeight, $fStartAngle, $fSweepAngle [, $hBrush = 0] )

Parameters

$hGraphics | Handle to a Graphics object
$nX | The X coordinate of the upper left corner of the rectangle that bounds the ellipse in which to draw the pie
$nY | The Y coordinate of the upper left corner of the rectangle that bounds the ellipse in which to draw the pie
$nWidth | The width of the rectangle that bounds the ellipse in which to draw the pie
$nHeight | The height of the rectangle that bounds the ellipse in which to draw the pie
$fStartAngle | The angle, in degrees, between the X axis and the starting point of the arc that defines the pie. A positive value specifies clockwise rotation.
$fSweepAngle | The angle, in degrees, between the starting and ending points of the arc that defines the pie. A positive value specifies clockwise rotation.
$hBrush | [optional] Handle to a brush object that is used to fill the pie. If 0, a black brush will be used.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipFillPie in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Fill a pie
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsFillPie($hGraphic, 150, 80, 100, 100, 45, 90)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Example 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF8080A0) ;color format AARRGGBB (hex)
    _GDIPlus_GraphicsFillPie($hGraphics, 100.5, 0.5, 400.75, 400.125, 45, 90, $hBrush)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_PenDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_GraphicsFillPolygon

Function Reference

_GDIPlus_GraphicsFillPolygon

Fill a polygon

#include <GDIPlus.au3>
_GDIPlus_GraphicsFillPolygon ( $hGraphics, $aPoints [, $hBrush = 0] )

Parameters

$hGraphics | Handle to a Graphics object
$aPoints | Array that specify the vertices of the polygon: [0][0] - Number of vertices [1][0] - Vertex 1 X position [1][1] - Vertex 1 Y position [2][0] - Vertex 2 X position [2][1] - Vertex 2 Y position [n][0] - Vertex n X position [n][1] - Vertex n Y position
$hBrush | [optional] Handle to a brush object that is used to fill the polygon.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipFillPolygon in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $aPoints[4][2]

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw a polygon
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)

    $aPoints[0][0] = 3
    $aPoints[1][0] = 150
    $aPoints[1][1] = 150
    $aPoints[2][0] = 200
    $aPoints[2][1] = 100
    $aPoints[3][0] = 250
    $aPoints[3][1] = 150

    MsgBox($MB_SYSTEMMODAL, "Information", "Fill Polygon")

    _GDIPlus_GraphicsFillPolygon($hGraphic, $aPoints)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Example 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) ;color format AARRGGBB (hex)

    ;  1 _____ 3
    ;    \   /
    ;     \ /
    ;      2
    Local $aPoints[4][2]
    $aPoints[0][0] = 3
    $aPoints[1][0] = 50.0
    $aPoints[1][1] = 150.0
    $aPoints[2][0] = 300.0
    $aPoints[2][1] = 500.0
    $aPoints[3][0] = 550.0
    $aPoints[3][1] = 150.0

    _GDIPlus_GraphicsFillPolygon($hGraphics, $aPoints, $hBrush) ;draw the triangle

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_GraphicsFillRect

Function Reference

_GDIPlus_GraphicsFillRect

Fill a rectangle

#include <GDIPlus.au3>
_GDIPlus_GraphicsFillRect ( $hGraphics, $nX, $nY, $nWidth, $nHeight [, $hBrush = 0] )

Parameters

$hGraphics | Handle to a Graphics object
$nX | The X coordinate of the upper left corner of the rectangle
$nY | The Y coordinate of the upper left corner of the rectangle
$nWidth | The width of the rectangle
$nHeight | The height of the rectangle
$hBrush | [optional] Handle to a brush object that is used to fill the rectangle. If 0, a black brush will be used.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipFillRectangle in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Fill a rectangle
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsFillRect($hGraphic, 10, 10, 100, 100)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Example 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBgColor format RRGGBB

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFEE88BB) ;color format AARRGGBB (hex)

    _GDIPlus_GraphicsFillRect($hGraphics, 150.5, 50.1, 280.25, 500.75, $hBrush)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_GraphicsFillRegion

Function Reference

_GDIPlus_GraphicsFillRegion

Uses a brush to fill a specified region

#include <GDIPlus.au3>
_GDIPlus_GraphicsFillRegion ( $hGraphics, $hRegion [, $hBrush = 0] )

Parameters

$hGraphics | Pointer to a Graphics object
$hRegion | Pointer to a region to be filled
$hBrush | [optional] Pointer to a brush that is used to paint the region. If 0, a black brush will be used.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_RegionCreate

See Also

Search GdipFillRegion in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create GUI
    Local $hGUI = GUICreate("GDI+", 640, 220)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    Local $hPen = _GDIPlus_PenCreate(0xFF006600)
    Local $hBrush_Region = _GDIPlus_BrushCreateSolid(0x44FF0000)
    Local $hBrush_Font = _GDIPlus_BrushCreateSolid(0xFFFF0000)

    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")

    Local $sString = "Measure Character Ranges"

    Local $aRanges[4][2] = [[3]]
    $aRanges[1][0] = 0 ;Measure first char (0-based)
    $aRanges[1][1] = 1 ;One char to measure
    $aRanges[2][0] = 4 ;5th char
    $aRanges[2][1] = 5 ;measure 5 chars
    $aRanges[3][0] = 14 ;15th char
    $aRanges[3][1] = 7 ;measure 7 chars

    _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges) ;Set ranges

    ;Measure characters fontsize = 14
    Local $hFont = _GDIPlus_FontCreate($hFamily, 14, 0)
    Local $tLayout = _GDIPlus_RectFCreate(10, 10, 200, 200)
    _GDIPlus_GraphicsDrawRect($hGraphic, 10, 10, 200, 200, $hPen)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush_Font)
    Local $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat) ;get array of regions
    For $i = 1 To $aRegions[0]
        _GDIPlus_GraphicsFillRegion($hGraphic, $aRegions[$i], $hBrush_Region)
        _GDIPlus_RegionDispose($aRegions[$i])
    Next
    _GDIPlus_FontDispose($hFont)

    ;Measure characters fontsize = 28
    $hFont = _GDIPlus_FontCreate($hFamily, 28, 0)
    $tLayout = _GDIPlus_RectFCreate(220, 10, 200, 200)
    _GDIPlus_GraphicsDrawRect($hGraphic, 220, 10, 200, 200, $hPen)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush_Font)
    $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat)
    For $i = 1 To $aRegions[0]
        _GDIPlus_GraphicsFillRegion($hGraphic, $aRegions[$i], $hBrush_Region)
        _GDIPlus_RegionDispose($aRegions[$i])
    Next
    _GDIPlus_FontDispose($hFont)

    ;Measure characters fontsize = 56
    $hFont = _GDIPlus_FontCreate($hFamily, 56, 0)
    $tLayout = _GDIPlus_RectFCreate(430, 10, 200, 200)
    _GDIPlus_GraphicsDrawRect($hGraphic, 430, 10, 200, 200, $hPen)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush_Font)
    $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat)
    For $i = 1 To $aRegions[0]
        _GDIPlus_GraphicsFillRegion($hGraphic, $aRegions[$i], $hBrush_Region)
        _GDIPlus_RegionDispose($aRegions[$i])
    Next
    _GDIPlus_FontDispose($hFont)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush_Font)
    _GDIPlus_BrushDispose($hBrush_Region)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_GraphicsGetCompositingMode

Function Reference

_GDIPlus_GraphicsGetCompositingMode

Gets the compositing mode currently set for a Graphics object

#include <GDIPlus.au3>
_GDIPlus_GraphicsGetCompositingMode ( $hGraphics )

Parameters

$hGraphics Pointer to a Graphics object

Return Value

Success: | the compositing mode: 0 - Specifies that when a color is rendered, it is blended with the background color 1 - Specifies that when a color is rendered, it overwrites the background color
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_GraphicsSetCompositingMode

See Also

Search GdipGetCompositingMode in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBitmap, $hContext, $hBrush, $iMode1, $iMode2

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    $hBitmap = _GDIPlus_BitmapCreateFromScan0(800, 400)
    $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    $hBrush = _GDIPlus_LineBrushCreate(0, 0, 0, 400, 0xFF0000FF, 0)

    _GDIPlus_GraphicsFillRect($hContext, 10, 10, 300, 300, $hBrush)
    _GDIPlus_GraphicsFillRect($hContext, 80, 60, 300, 300, $hBrush)
    $iMode1 = _GDIPlus_GraphicsGetCompositingMode($hContext)

    _GDIPlus_GraphicsSetCompositingMode($hContext, $GDIP_CompositingModeSourceCopy)
    _GDIPlus_GraphicsFillRect($hContext, 420, 10, 300, 300, $hBrush)
    _GDIPlus_GraphicsFillRect($hContext, 490, 60, 300, 300, $hBrush)
    $iMode2 = _GDIPlus_GraphicsGetCompositingMode($hContext)

    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0)

    _GDIPlus_GraphicsDrawString($hGraphic, "CompositingMode = " & $iMode1, 10, 380)
    _GDIPlus_GraphicsDrawString($hGraphic, "CompositingMode = " & $iMode2, 420, 380)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_GraphicsGetCompositingQuality

Function Reference

_GDIPlus_GraphicsGetCompositingQuality

Gets the compositing quality currently set for a Graphics object

#include <GDIPlus.au3>
_GDIPlus_GraphicsGetCompositingQuality ( $hGraphics )

Parameters

$hGraphics Pointer to a Graphics object

Return Value

Success: | the compositing quality: 0 - Gamma correction is not applied. 1 - Gamma correction is not applied. High speed, low quality. 2 - Gamma correction is applied. Composition of high quality and speed. 3 - Gamma correction is applied. 4 - Gamma correction is not applied. Linear values are used.
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_GraphicsSetCompositingQuality

See Also

Search GdipGetCompositingQuality in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $iQuality1, $iQuality2, $hMatrix

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphic, 0xFF6600AA)

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, 10, 10, 380, 360)

    $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFFFF)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, 0)
    _GDIPlus_PathBrushSetSigmaBlend($hBrush, 1)
    _GDIPlus_PathBrushSetFocusScales($hBrush, 0.7, 0.7)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush)

    $iQuality1 = _GDIPlus_GraphicsGetCompositingQuality($hGraphic)

    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, 400, 0)
    _GDIPlus_PathTransform($hPath, $hMatrix)
    _GDIPlus_PathBrushSetTransform($hBrush, $hMatrix)

    _GDIPlus_GraphicsSetCompositingQuality($hGraphic, 3)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush)
    $iQuality2 = _GDIPlus_GraphicsGetCompositingQuality($hGraphic)

    _GDIPlus_GraphicsDrawString($hGraphic, "CompositingQuality = " & $iQuality1, 10, 380)
    _GDIPlus_GraphicsDrawString($hGraphic, "CompositingQuality = " & $iQuality2, 420, 380)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_GraphicsGetDC

Function Reference

_GDIPlus_GraphicsGetDC

Gets a handle to the device context of the Graphics object

#include <GDIPlus.au3>
_GDIPlus_GraphicsGetDC ( $hGraphics )

Parameters

$hGraphics Handle to a Graphics object

Return Value

Success: | a handle DC of the Graphics object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

Each call to the _GDIPlus_GraphicsGetDC() should be paired with a call to the _GDIPlus_GraphicsReleaseDC().
Do not call any methods of the Graphics object between the calls.

Related

_GDIPlus_GraphicsReleaseDC

See Also

Search GdipGetDC in MSDN Library.


Function _GDIPlus_GraphicsGetInterpolationMode

Function Reference

_GDIPlus_GraphicsGetInterpolationMode

Gets the interpolation mode currently set for a Graphics object

#include <GDIPlus.au3>
_GDIPlus_GraphicsGetInterpolationMode ( $hGraphics )

Parameters

$hGraphics Pointer to a Graphics object

Return Value

Success: | the interpolation mode: 0 - Default interpolation mode 1 - Low-quality mode 2 - High-quality mode 3 - Bilinear interpolation. No prefiltering is done 4 - Bicubic interpolation. No prefiltering is done 5 - Nearest-neighbor interpolation 6 - High-quality, bilinear interpolation. Prefiltering is performed to ensure high-quality shrinking 7 - High-quality, bicubic interpolation. Prefiltering is performed to ensure high-quality shrinking
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_GraphicsSetInterpolationMode

See Also

Search GdipGetInterpolationMode in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup()
    Local Const $iW = @DesktopWidth / 4, $iH = @DesktopHeight / 4
    Local $hGUI = GUICreate("GDI+ test", $iW, $iH, -1, 10)
    GUISetState(@SW_SHOW)

    Local $aIM[8] = ["Default", "Low Quality", "High Quality", "Bilinear", "Bicubic", "Nearest Neighbor", "High Quality Bilinear", "High Quality Bicubic"]

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, -1, -1) ;create a GDI bitmap by capturing whole desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    Local $iIM = _GDIPlus_GraphicsGetInterpolationMode($hGraphics)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iW, $iH) ;draw captured bitmap to GUI with default system interpolation mode
    MsgBox($MB_SYSTEMMODAL, "", "Interpolation Mode initial: " & $aIM[$iIM])

    _GDIPlus_GraphicsSetInterpolationMode($hGraphics, $GDIP_INTERPOLATIONMODE_NearestNeighbor) ;change interpolation mode
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iW, $iH) ;draw again same bitmap but with different interpolation mode
    $iIM = _GDIPlus_GraphicsGetInterpolationMode($hGraphics)
    MsgBox($MB_SYSTEMMODAL, "", "Interpolation Mode after: " & $aIM[$iIM])

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    ;cleanup resources
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_GraphicsGetSmoothingMode

Function Reference

_GDIPlus_GraphicsGetSmoothingMode

Gets the graphics object rendering quality

#include <GDIPlus.au3>
_GDIPlus_GraphicsGetSmoothingMode ( $hGraphics )

Parameters

$hGraphics Handle to a Graphics object

Return Value

Success: | the smoothing mode. Can be one of the following: 0 - Smoothing is not applied 1 - Smoothing is applied using an 8 X 4 box filter 2 - Smoothing is applied using an 8 X 8 box filter
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_GraphicsSetSmoothingMode

See Also

Search GdipGetSmoothingMode in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+ test", 640, 480)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Local $hPen = _GDIPlus_PenCreate()
    _GDIPlus_GraphicsDrawLine($hGraphics, 40, 40, 600, 440, $hPen) ;draw a test line to show smoothing effect (default no smoothing)
    MsgBox($MB_SYSTEMMODAL, "", "Smoothing enabled: " & _GDIPlus_GraphicsGetSmoothingMode($hGraphics))

    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;set smoothing mode (8 X 4 box filter)
    _GDIPlus_GraphicsDrawLine($hGraphics, 600, 40, 40, 440, $hPen) ;draw a test line to show smoothing effect

    MsgBox($MB_SYSTEMMODAL, "", "Smoothing enabled: " & _GDIPlus_GraphicsGetSmoothingMode($hGraphics))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    ;cleanup resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_GraphicsGetTransform

Function Reference

_GDIPlus_GraphicsGetTransform

Gets the world transformation matrix of a Graphics object

#include <GDIPlus.au3>
_GDIPlus_GraphicsGetTransform ( $hGraphics, $hMatrix )

Parameters

$hGraphics | Pointer to a Graphics object
$hMatrix | Pointer to a Matrix object that receives the transformation matrix

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

The contrast value is used for antialiasing text.

Related

_GDIPlus_MatrixCreate

See Also

Search GdipGetWorldTransform in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hGUI, $g_hGraphics, $g_hBmp_Buffer, $g_hGfx_Buffer, $g_hImage
Global $g_iMouseX, $g_iMouseY

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    ; X64 running support
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"

    ;get AutoIt install dir
    Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt"

    Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif"
    If Not FileExists($sFile) Then
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30)
        Exit
    EndIf

    $g_hGUI = GUICreate("GDI+", 800, 600)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_ResetGraphicsTransform")
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI)
    $g_hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(800, 600, $g_hGraphics)
    $g_hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($g_hBmp_Buffer)

    $g_hImage = _GDIPlus_ImageLoadFromFile($sFile)

    GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN")
    GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL")
    GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE")
    GUISetState(@SW_SHOW)

    _Draw()

    While Sleep(10)
    WEnd
EndFunc   ;==>Example

Func _ResetGraphicsTransform()
    _GDIPlus_GraphicsResetTransform($g_hGfx_Buffer)
    _Draw()
EndFunc   ;==>_ResetGraphicsTransform

Func WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam

    $g_iMouseX = BitAND($lParam, 0x0000FFFF)
    $g_iMouseY = BitShift($lParam, 16)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_LBUTTONDOWN

Func WM_MOUSEMOVE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg

    Switch BitAND($wParam, 0x0000FFFF)
        Case 1
            Local $iX = BitAND($lParam, 0x0000FFFF)
            Local $iY = BitShift($lParam, 16)

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $iX - $g_iMouseX, $iY - $g_iMouseY, True)

            $g_iMouseX = $iX
            $g_iMouseY = $iY

            _Draw()
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEMOVE

Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam

    Switch BitAND($wParam, 0x0000FFFF)
        Case 1
            Local $iAngle = -3
            If BitShift($wParam, 16) < 0 Then $iAngle = 3

            Local $aMousePos[2][2] = [[1]]
            $aMousePos[1][0] = $g_iMouseX
            $aMousePos[1][1] = $g_iMouseY
            _GDIPlus_GraphicsTransformPoints($g_hGfx_Buffer, $aMousePos)

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $aMousePos[1][0], $aMousePos[1][1])
            _GDIPlus_GraphicsRotateTransform($g_hGfx_Buffer, $iAngle)
            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, -$aMousePos[1][0], -$aMousePos[1][1])

        Case Else
            Local $aInfo = GUIGetCursorInfo($g_hGUI)
            Local $iScale = 1.1
            If BitShift($wParam, 16) < 0 Then $iScale = 0.9

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, -$aInfo[0], -$aInfo[1], True)
            _GDIPlus_GraphicsScaleTransform($g_hGfx_Buffer, $iScale, $iScale, True)
            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $aInfo[0], $aInfo[1], True)
    EndSwitch

    _Draw()
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEWHEEL

Func _Draw()
    _GDIPlus_GraphicsClear($g_hGfx_Buffer, 0xFFFFFFFF)

    _GDIPlus_GraphicsDrawImage($g_hGfx_Buffer, $g_hImage, 316, 266)

    Local $hPen = _GDIPlus_PenCreate(0xFF0000FF)
    _GDIPlus_GraphicsDrawRect($g_hGfx_Buffer, 300, 250, 200, 100, $hPen)
    _GDIPlus_PenDispose($hPen)

    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F)
    Local $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 24, 2)
    Local $tLayout = _GDIPlus_RectFCreate(0, 360, 800)
    _GDIPlus_GraphicsDrawStringEx($g_hGfx_Buffer, "AutoIt rulez!", $hFont, $tLayout, $hFormat, $hBrush)

    _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBmp_Buffer, 0, 0)

    _GDIPlus_FontDispose($hFont)
    $hFont = _GDIPlus_FontCreate($hFamily, 10)
    _GDIPlus_StringFormatSetAlign($hFormat, 0)

    DllStructSetData($tLayout, "X", 10)
    DllStructSetData($tLayout, "Y", 10)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "left mousebutton = move graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 30)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "mousewheel = zoom graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 50)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "mousewheel + left mousebutton = rotate graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 70)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "right mousebutton = reset", $hFont, $tLayout, $hFormat, $hBrush)

    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_GraphicsGetTransform($g_hGfx_Buffer, $hMatrix)
    Local $aMatrix_Values = _GDIPlus_MatrixGetElements($hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)

    DllStructSetData($tLayout, "Y", 110)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "Matrix:", $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "X", 20)
    DllStructSetData($tLayout, "Y", 130)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[0], $aMatrix_Values[1]), $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "Y", 150)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[2], $aMatrix_Values[3]), $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "Y", 170)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[4], $aMatrix_Values[5]), $hFont, $tLayout, $hFormat, $hBrush)

    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
EndFunc   ;==>_Draw

Func _Exit()
    _GDIPlus_ImageDispose($g_hImage)
    _GDIPlus_GraphicsDispose($g_hGfx_Buffer)
    _GDIPlus_BitmapDispose($g_hBmp_Buffer)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_GraphicsReleaseDC

Function Reference

_GDIPlus_GraphicsReleaseDC

Releases the device context of the Graphics object

#include <GDIPlus.au3>
_GDIPlus_GraphicsReleaseDC ( $hGraphics, $hDC )

Parameters

$hGraphics | Handle to a Graphics object
$hDC | Handle to the Graphics device context

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_GraphicsGetDC

See Also

Search GdipReleaseDC in MSDN Library.


Function _GDIPlus_GraphicsResetClip

Function Reference

_GDIPlus_GraphicsResetClip

Sets the clipping region of a Graphics object to an infinite region

#include <GDIPlus.au3>
_GDIPlus_GraphicsResetClip ( $hGraphics )

Parameters

$hGraphics Pointer to a Graphics object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipResetClip in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    Local $hBMP = _ScreenCapture_Capture()

    Local $hGUI = GUICreate("GDI+", 400, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    Local $hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(400, 400, $hGraphics)
    Local $hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($hBmp_Buffer)

    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)

    Local $hMatrix1 = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix1, 200, 200)
    Local $hMatrix2 = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix2, 200, 200)

    Local $hPath = _GDIPlus_PathCreate()
    For $i = 0 To 300 Step 24
        _GDIPlus_PathAddEllipse($hPath, -$i, -$i, $i * 2, $i * 2)
    Next

    Local $hRegion = _GDIPlus_RegionCreate()
    _GDIPlus_RegionCombinePath($hRegion, $hPath, 4)

    Local $hTimer = TimerInit()
    ; Loop until the user exits.
    Do
        If TimerDiff($hTimer) > 20 Then
            _GDIPlus_GraphicsResetClip($hGfx_Buffer)
            _GDIPlus_GraphicsClear($hGfx_Buffer, 0x33FFAA00)

            _GDIPlus_MatrixRotate($hMatrix1, 1)
            _GDIPlus_MatrixRotate($hMatrix2, -1)

            _GDIPlus_GraphicsSetTransform($hGfx_Buffer, $hMatrix1)
            _GDIPlus_GraphicsSetClipRegion($hGfx_Buffer, $hRegion)
            _GDIPlus_GraphicsDrawImage($hGfx_Buffer, $hBitmap, -300, -300)

            _GDIPlus_GraphicsSetTransform($hGfx_Buffer, $hMatrix2)
            _GDIPlus_GraphicsSetClipPath($hGfx_Buffer, $hPath)
            _GDIPlus_GraphicsDrawImage($hGfx_Buffer, $hBitmap, -300, -300)

            _GDIPlus_GraphicsDrawImage($hGraphics, $hBmp_Buffer, 0, 0)
            $hTimer = TimerInit()
        EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_RegionDispose($hRegion)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_MatrixDispose($hMatrix1)
    _GDIPlus_MatrixDispose($hMatrix2)
    _GDIPlus_BitmapDispose($hBitmap)
    _WinAPI_DeleteObject($hBMP)
    _GDIPlus_GraphicsDispose($hGfx_Buffer)
    _GDIPlus_BitmapDispose($hBmp_Buffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_GraphicsResetTransform

Function Reference

_GDIPlus_GraphicsResetTransform

Sets the world transformation matrix of a Graphics object to the identity matrix

#include <GDIPlus.au3>
_GDIPlus_GraphicsResetTransform ( $hGraphics )

Parameters

$hGraphics Pointer to a Graphics object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipResetWorldTransform in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hGUI, $g_hGraphics, $g_hBmp_Buffer, $g_hGfx_Buffer, $g_hImage
Global $g_iMouseX, $g_iMouseY

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    ; X64 running support
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"

    ;get AutoIt install dir
    Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt"

    Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif"
    If Not FileExists($sFile) Then
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30)
        Exit
    EndIf

    $g_hGUI = GUICreate("GDI+", 800, 600)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_ResetGraphicsTransform")
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI)
    $g_hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(800, 600, $g_hGraphics)
    $g_hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($g_hBmp_Buffer)

    $g_hImage = _GDIPlus_ImageLoadFromFile($sFile)

    GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN")
    GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL")
    GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE")
    GUISetState(@SW_SHOW)

    _Draw()

    While Sleep(10)
    WEnd
EndFunc   ;==>Example

Func _ResetGraphicsTransform()
    _GDIPlus_GraphicsResetTransform($g_hGfx_Buffer)
    _Draw()
EndFunc   ;==>_ResetGraphicsTransform

Func WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam

    $g_iMouseX = BitAND($lParam, 0x0000FFFF)
    $g_iMouseY = BitShift($lParam, 16)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_LBUTTONDOWN

Func WM_MOUSEMOVE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg

    Switch BitAND($wParam, 0x0000FFFF)
        Case 1
            Local $iX = BitAND($lParam, 0x0000FFFF)
            Local $iY = BitShift($lParam, 16)

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $iX - $g_iMouseX, $iY - $g_iMouseY, True)

            $g_iMouseX = $iX
            $g_iMouseY = $iY

            _Draw()
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEMOVE

Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam

    Switch BitAND($wParam, 0x0000FFFF)
        Case 1
            Local $iAngle = -3
            If BitShift($wParam, 16) < 0 Then $iAngle = 3

            Local $aMousePos[2][2] = [[1]]
            $aMousePos[1][0] = $g_iMouseX
            $aMousePos[1][1] = $g_iMouseY
            _GDIPlus_GraphicsTransformPoints($g_hGfx_Buffer, $aMousePos)

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $aMousePos[1][0], $aMousePos[1][1])
            _GDIPlus_GraphicsRotateTransform($g_hGfx_Buffer, $iAngle)
            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, -$aMousePos[1][0], -$aMousePos[1][1])

        Case Else
            Local $aInfo = GUIGetCursorInfo($g_hGUI)
            Local $iScale = 1.1
            If BitShift($wParam, 16) < 0 Then $iScale = 0.9

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, -$aInfo[0], -$aInfo[1], True)
            _GDIPlus_GraphicsScaleTransform($g_hGfx_Buffer, $iScale, $iScale, True)
            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $aInfo[0], $aInfo[1], True)
    EndSwitch

    _Draw()
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEWHEEL

Func _Draw()
    _GDIPlus_GraphicsClear($g_hGfx_Buffer, 0xFFFFFFFF)

    _GDIPlus_GraphicsDrawImage($g_hGfx_Buffer, $g_hImage, 316, 266)

    Local $hPen = _GDIPlus_PenCreate(0xFF0000FF)
    _GDIPlus_GraphicsDrawRect($g_hGfx_Buffer, 300, 250, 200, 100, $hPen)
    _GDIPlus_PenDispose($hPen)

    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F)
    Local $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 24, 2)
    Local $tLayout = _GDIPlus_RectFCreate(0, 360, 800)
    _GDIPlus_GraphicsDrawStringEx($g_hGfx_Buffer, "AutoIt rulez!", $hFont, $tLayout, $hFormat, $hBrush)

    _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBmp_Buffer, 0, 0)

    _GDIPlus_FontDispose($hFont)
    $hFont = _GDIPlus_FontCreate($hFamily, 10)
    _GDIPlus_StringFormatSetAlign($hFormat, 0)

    DllStructSetData($tLayout, "X", 10)
    DllStructSetData($tLayout, "Y", 10)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "left mousebutton = move graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 30)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "mousewheel = zoom graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 50)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "mousewheel + left mousebutton = rotate graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 70)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "right mousebutton = reset", $hFont, $tLayout, $hFormat, $hBrush)

    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_GraphicsGetTransform($g_hGfx_Buffer, $hMatrix)
    Local $aMatrix_Values = _GDIPlus_MatrixGetElements($hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)

    DllStructSetData($tLayout, "Y", 110)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "Matrix:", $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "X", 20)
    DllStructSetData($tLayout, "Y", 130)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[0], $aMatrix_Values[1]), $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "Y", 150)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[2], $aMatrix_Values[3]), $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "Y", 170)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[4], $aMatrix_Values[5]), $hFont, $tLayout, $hFormat, $hBrush)

    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
EndFunc   ;==>_Draw

Func _Exit()
    _GDIPlus_ImageDispose($g_hImage)
    _GDIPlus_GraphicsDispose($g_hGfx_Buffer)
    _GDIPlus_BitmapDispose($g_hBmp_Buffer)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_GraphicsRestore

Function Reference

_GDIPlus_GraphicsRestore

Restores the state of a Graphics object to the state stored by a previous call to the _GDIPlus_GraphicsSave method of the Graphics object

#include <GDIPlus.au3>
_GDIPlus_GraphicsRestore ( $hGraphics, $iState )

Parameters

$hGraphics | Pointer to a Graphics object
$iState | Value identifying the block of saved state previously returned by _GDIPlus_GraphicsSave().

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_GraphicsSave

See Also

Search GdipRestoreGraphics in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $iW, $iH, $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hFormat, $hFamily, $tLayout, $fSize, $iGfx_Save

    $iW = 800
    $iH = 300
    $hGUI = GUICreate("GDI+", $iW, $iH)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)

    $hPath = _GDIPlus_PathCreate(1)
    For $i = 1 To 200
        $fSize = Random(10, 30)
        _GDIPlus_PathAddEllipse($hPath, Random(0, $iW), Random(0, $iH), $fSize, $fSize)
    Next

    _GDIPlus_GraphicsSetClipPath($hGraphic, $hPath);set clipping region
    $iGfx_Save = _GDIPlus_GraphicsSave($hGraphic);save clipping region

    _GDIPlus_PathReset($hPath)
    $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    _GDIPlus_StringFormatSetLineAlign($hFormat, 1)
    $hFamily = _GDIPlus_FontFamilyCreate("Arial Black")
    $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH)
    _GDIPlus_PathAddString($hPath, "AutoIt", $tLayout, $hFamily, 1, 200, $hFormat)

    _GDIPlus_GraphicsSetClipPath($hGraphic, $hPath, 3);update clipping region

    $hBrush = _GDIPlus_BrushCreateSolid(0xFF7F00FF)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush)

    _GDIPlus_GraphicsRestore($hGraphic, $iGfx_Save);restore clipping region

    $hPen = _GDIPlus_PenCreate(0xFFFF007F)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_GraphicsRotateTransform

Function Reference

_GDIPlus_GraphicsRotateTransform

Updates the world transformation matrix of a Graphics object with the product of itself and a rotation matrix

#include <GDIPlus.au3>
_GDIPlus_GraphicsRotateTransform ( $hGraphics, $fAngle [, $iOrder = 0] )

Parameters

$hGraphics | Pointer to a Graphics object
$fAngle | The angle, in degrees, of rotation
$iOrder | [optional] Order of matrices multiplication: 0 - The rotation matrix is on the left 1 - The rotation matrix is on the right

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipRotateWorldTransform in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hGUI, $g_hGraphics, $g_hBmp_Buffer, $g_hGfx_Buffer, $g_hImage
Global $g_iMouseX, $g_iMouseY

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    ; X64 running support
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"

    ;get AutoIt install dir
    Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt"

    Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif"
    If Not FileExists($sFile) Then
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30)
        Exit
    EndIf

    $g_hGUI = GUICreate("GDI+", 800, 600)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_ResetGraphicsTransform")
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI)
    $g_hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(800, 600, $g_hGraphics)
    $g_hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($g_hBmp_Buffer)

    $g_hImage = _GDIPlus_ImageLoadFromFile($sFile)

    GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN")
    GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL")
    GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE")
    GUISetState(@SW_SHOW)

    _Draw()

    While Sleep(10)
    WEnd
EndFunc   ;==>Example

Func _ResetGraphicsTransform()
    _GDIPlus_GraphicsResetTransform($g_hGfx_Buffer)
    _Draw()
EndFunc   ;==>_ResetGraphicsTransform

Func WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam

    $g_iMouseX = BitAND($lParam, 0x0000FFFF)
    $g_iMouseY = BitShift($lParam, 16)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_LBUTTONDOWN

Func WM_MOUSEMOVE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg

    Switch BitAND($wParam, 0x0000FFFF)
        Case 1
            Local $iX = BitAND($lParam, 0x0000FFFF)
            Local $iY = BitShift($lParam, 16)

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $iX - $g_iMouseX, $iY - $g_iMouseY, True)

            $g_iMouseX = $iX
            $g_iMouseY = $iY

            _Draw()
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEMOVE

Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam

    Switch BitAND($wParam, 0x0000FFFF)
        Case 1
            Local $iAngle = -3
            If BitShift($wParam, 16) < 0 Then $iAngle = 3

            Local $aMousePos[2][2] = [[1]]
            $aMousePos[1][0] = $g_iMouseX
            $aMousePos[1][1] = $g_iMouseY
            _GDIPlus_GraphicsTransformPoints($g_hGfx_Buffer, $aMousePos)

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $aMousePos[1][0], $aMousePos[1][1])
            _GDIPlus_GraphicsRotateTransform($g_hGfx_Buffer, $iAngle)
            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, -$aMousePos[1][0], -$aMousePos[1][1])

        Case Else
            Local $aInfo = GUIGetCursorInfo($g_hGUI)
            Local $iScale = 1.1
            If BitShift($wParam, 16) < 0 Then $iScale = 0.9

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, -$aInfo[0], -$aInfo[1], True)
            _GDIPlus_GraphicsScaleTransform($g_hGfx_Buffer, $iScale, $iScale, True)
            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $aInfo[0], $aInfo[1], True)
    EndSwitch

    _Draw()
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEWHEEL

Func _Draw()
    _GDIPlus_GraphicsClear($g_hGfx_Buffer, 0xFFFFFFFF)

    _GDIPlus_GraphicsDrawImage($g_hGfx_Buffer, $g_hImage, 316, 266)

    Local $hPen = _GDIPlus_PenCreate(0xFF0000FF)
    _GDIPlus_GraphicsDrawRect($g_hGfx_Buffer, 300, 250, 200, 100, $hPen)
    _GDIPlus_PenDispose($hPen)

    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F)
    Local $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 24, 2)
    Local $tLayout = _GDIPlus_RectFCreate(0, 360, 800)
    _GDIPlus_GraphicsDrawStringEx($g_hGfx_Buffer, "AutoIt rulez!", $hFont, $tLayout, $hFormat, $hBrush)

    _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBmp_Buffer, 0, 0)

    _GDIPlus_FontDispose($hFont)
    $hFont = _GDIPlus_FontCreate($hFamily, 10)
    _GDIPlus_StringFormatSetAlign($hFormat, 0)

    DllStructSetData($tLayout, "X", 10)
    DllStructSetData($tLayout, "Y", 10)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "left mousebutton = move graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 30)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "mousewheel = zoom graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 50)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "mousewheel + left mousebutton = rotate graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 70)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "right mousebutton = reset", $hFont, $tLayout, $hFormat, $hBrush)

    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_GraphicsGetTransform($g_hGfx_Buffer, $hMatrix)
    Local $aMatrix_Values = _GDIPlus_MatrixGetElements($hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)

    DllStructSetData($tLayout, "Y", 110)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "Matrix:", $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "X", 20)
    DllStructSetData($tLayout, "Y", 130)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[0], $aMatrix_Values[1]), $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "Y", 150)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[2], $aMatrix_Values[3]), $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "Y", 170)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[4], $aMatrix_Values[5]), $hFont, $tLayout, $hFormat, $hBrush)

    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
EndFunc   ;==>_Draw

Func _Exit()
    _GDIPlus_ImageDispose($g_hImage)
    _GDIPlus_GraphicsDispose($g_hGfx_Buffer)
    _GDIPlus_BitmapDispose($g_hBmp_Buffer)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_GraphicsSave

Function Reference

_GDIPlus_GraphicsSave

Saves the current state (transformations, clipping region, and quality settings) of a Graphics object

#include <GDIPlus.au3>
_GDIPlus_GraphicsSave ( $hGraphics )

Parameters

$hGraphics Pointer to a Graphics object

Return Value

Success: | a value that identifies the saved state.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_GraphicsRestore

See Also

Search GdipSaveGraphics in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $iW, $iH, $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hFormat, $hFamily, $tLayout, $fSize, $iGfx_Save

    $iW = 800
    $iH = 300
    $hGUI = GUICreate("GDI+", $iW, $iH)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)

    $hPath = _GDIPlus_PathCreate(1)
    For $i = 1 To 200
        $fSize = Random(10, 30)
        _GDIPlus_PathAddEllipse($hPath, Random(0, $iW), Random(0, $iH), $fSize, $fSize)
    Next

    _GDIPlus_GraphicsSetClipPath($hGraphic, $hPath) ;set clipping region
    $iGfx_Save = _GDIPlus_GraphicsSave($hGraphic) ;save clipping region

    _GDIPlus_PathReset($hPath)
    $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    _GDIPlus_StringFormatSetLineAlign($hFormat, 1)
    $hFamily = _GDIPlus_FontFamilyCreate("Arial Black")
    $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH)
    _GDIPlus_PathAddString($hPath, "AutoIt", $tLayout, $hFamily, 1, 200, $hFormat)

    _GDIPlus_GraphicsSetClipPath($hGraphic, $hPath, 3) ;update clipping region

    $hBrush = _GDIPlus_BrushCreateSolid(0xFF7F00FF)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush)

    _GDIPlus_GraphicsRestore($hGraphic, $iGfx_Save);restore clipping region

    $hPen = _GDIPlus_PenCreate(0xFFFF007F)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_GraphicsScaleTransform

Function Reference

_GDIPlus_GraphicsScaleTransform

Updates a Graphics object's world transformation matrix with the product of itself and a scaling matrix

#include <GDIPlus.au3>
_GDIPlus_GraphicsScaleTransform ( $hGraphics, $fScaleX, $fScaleY [, $iOrder = 0] )

Parameters

$hGraphics | Pointer to a Graphics object
$fScaleX | The horizontal scaling factor in the scaling matrix
$fScaleY | The vertical scaling factor in the scaling matrix
$iOrder | [optional] Order of matrices multiplication: 0 - The scaling matrix is on the left 1 - The scaling matrix is on the right

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipScaleWorldTransform in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hGUI, $g_hGraphics, $g_hBmp_Buffer, $g_hGfx_Buffer, $g_hImage
Global $g_iMouseX, $g_iMouseY

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    ; X64 running support
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"

    ;get AutoIt install dir
    Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt"

    Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif"
    If Not FileExists($sFile) Then
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30)
        Exit
    EndIf

    $g_hGUI = GUICreate("GDI+", 800, 600)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_ResetGraphicsTransform")
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI)
    $g_hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(800, 600, $g_hGraphics)
    $g_hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($g_hBmp_Buffer)

    $g_hImage = _GDIPlus_ImageLoadFromFile($sFile)

    GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN")
    GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL")
    GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE")
    GUISetState(@SW_SHOW)

    _Draw()

    While Sleep(10)
    WEnd
EndFunc   ;==>Example

Func _ResetGraphicsTransform()
    _GDIPlus_GraphicsResetTransform($g_hGfx_Buffer)
    _Draw()
EndFunc   ;==>_ResetGraphicsTransform

Func WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam

    $g_iMouseX = BitAND($lParam, 0x0000FFFF)
    $g_iMouseY = BitShift($lParam, 16)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_LBUTTONDOWN

Func WM_MOUSEMOVE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg

    Switch BitAND($wParam, 0x0000FFFF)
        Case 1
            Local $iX = BitAND($lParam, 0x0000FFFF)
            Local $iY = BitShift($lParam, 16)

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $iX - $g_iMouseX, $iY - $g_iMouseY, True)

            $g_iMouseX = $iX
            $g_iMouseY = $iY

            _Draw()
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEMOVE

Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam

    Switch BitAND($wParam, 0x0000FFFF)
        Case 1
            Local $iAngle = -3
            If BitShift($wParam, 16) < 0 Then $iAngle = 3

            Local $aMousePos[2][2] = [[1]]
            $aMousePos[1][0] = $g_iMouseX
            $aMousePos[1][1] = $g_iMouseY
            _GDIPlus_GraphicsTransformPoints($g_hGfx_Buffer, $aMousePos)

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $aMousePos[1][0], $aMousePos[1][1])
            _GDIPlus_GraphicsRotateTransform($g_hGfx_Buffer, $iAngle)
            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, -$aMousePos[1][0], -$aMousePos[1][1])

        Case Else
            Local $aInfo = GUIGetCursorInfo($g_hGUI)
            Local $iScale = 1.1
            If BitShift($wParam, 16) < 0 Then $iScale = 0.9

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, -$aInfo[0], -$aInfo[1], True)
            _GDIPlus_GraphicsScaleTransform($g_hGfx_Buffer, $iScale, $iScale, True)
            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $aInfo[0], $aInfo[1], True)
    EndSwitch

    _Draw()
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEWHEEL

Func _Draw()
    _GDIPlus_GraphicsClear($g_hGfx_Buffer, 0xFFFFFFFF)

    _GDIPlus_GraphicsDrawImage($g_hGfx_Buffer, $g_hImage, 316, 266)

    Local $hPen = _GDIPlus_PenCreate(0xFF0000FF)
    _GDIPlus_GraphicsDrawRect($g_hGfx_Buffer, 300, 250, 200, 100, $hPen)
    _GDIPlus_PenDispose($hPen)

    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F)
    Local $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 24, 2)
    Local $tLayout = _GDIPlus_RectFCreate(0, 360, 800)
    _GDIPlus_GraphicsDrawStringEx($g_hGfx_Buffer, "AutoIt rulez!", $hFont, $tLayout, $hFormat, $hBrush)

    _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBmp_Buffer, 0, 0)

    _GDIPlus_FontDispose($hFont)
    $hFont = _GDIPlus_FontCreate($hFamily, 10)
    _GDIPlus_StringFormatSetAlign($hFormat, 0)

    DllStructSetData($tLayout, "X", 10)
    DllStructSetData($tLayout, "Y", 10)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "left mousebutton = move graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 30)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "mousewheel = zoom graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 50)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "mousewheel + left mousebutton = rotate graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 70)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "right mousebutton = reset", $hFont, $tLayout, $hFormat, $hBrush)

    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_GraphicsGetTransform($g_hGfx_Buffer, $hMatrix)
    Local $aMatrix_Values = _GDIPlus_MatrixGetElements($hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)

    DllStructSetData($tLayout, "Y", 110)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "Matrix:", $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "X", 20)
    DllStructSetData($tLayout, "Y", 130)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[0], $aMatrix_Values[1]), $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "Y", 150)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[2], $aMatrix_Values[3]), $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "Y", 170)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[4], $aMatrix_Values[5]), $hFont, $tLayout, $hFormat, $hBrush)

    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
EndFunc   ;==>_Draw

Func _Exit()
    _GDIPlus_ImageDispose($g_hImage)
    _GDIPlus_GraphicsDispose($g_hGfx_Buffer)
    _GDIPlus_BitmapDispose($g_hBmp_Buffer)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_GraphicsSetClipPath

Function Reference

_GDIPlus_GraphicsSetClipPath

Updates the clipping region of this Graphics object to a region that is the combination of itself and the region specified by a graphics path

#include <GDIPlus.au3>
_GDIPlus_GraphicsSetClipPath ( $hGraphics, $hPath [, $iCombineMode = 0] )

Parameters

$hGraphics | Pointer to a Graphics object
$hPath | Pointer to a GraphicsPath object that specifies the region to be combined with the clipping region of the Graphics object
$iCombineMode | [optional] Regions combination mode: 0 - The existing region is replaced by the new region 1 - The existing region is replaced by the intersection of itself and the new region 2 - The existing region is replaced by the union of itself and the new region 3 - The existing region is replaced by the result of performing an XOR on the two regions 4 - The existing region is replaced by the portion of itself that is outside of the new region 5 - The existing region is replaced by the portion of the new region that is outside of the existing region

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

If a figure in the path is not closed, this method treats the nonclosed figure as if it were closed by a straight line that connects the figure's starting and ending points.

See Also

Search GdipSetClipPath in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    Local $hBMP = _ScreenCapture_Capture()

    Local $hGUI = GUICreate("GDI+", 400, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    Local $hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(400, 400, $hGraphics)
    Local $hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($hBmp_Buffer)

    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)

    Local $hMatrix1 = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix1, 200, 200)
    Local $hMatrix2 = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix2, 200, 200)

    Local $hPath = _GDIPlus_PathCreate()
    For $i = 0 To 300 Step 24
        _GDIPlus_PathAddEllipse($hPath, -$i, -$i, $i * 2, $i * 2)
    Next

    Local $hRegion = _GDIPlus_RegionCreate()
    _GDIPlus_RegionCombinePath($hRegion, $hPath, 4)

    Local $hTimer = TimerInit()
    ; Loop until the user exits.
    Do
        If TimerDiff($hTimer) > 20 Then
            _GDIPlus_GraphicsResetClip($hGfx_Buffer)
            _GDIPlus_GraphicsClear($hGfx_Buffer, 0x33FFAA00)

            _GDIPlus_MatrixRotate($hMatrix1, 1)
            _GDIPlus_MatrixRotate($hMatrix2, -1)

            _GDIPlus_GraphicsSetTransform($hGfx_Buffer, $hMatrix1)
            _GDIPlus_GraphicsSetClipRegion($hGfx_Buffer, $hRegion)
            _GDIPlus_GraphicsDrawImage($hGfx_Buffer, $hBitmap, -300, -300)

            _GDIPlus_GraphicsSetTransform($hGfx_Buffer, $hMatrix2)
            _GDIPlus_GraphicsSetClipPath($hGfx_Buffer, $hPath)
            _GDIPlus_GraphicsDrawImage($hGfx_Buffer, $hBitmap, -300, -300)

            _GDIPlus_GraphicsDrawImage($hGraphics, $hBmp_Buffer, 0, 0)
            $hTimer = TimerInit()
        EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_RegionDispose($hRegion)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_MatrixDispose($hMatrix1)
    _GDIPlus_MatrixDispose($hMatrix2)
    _GDIPlus_BitmapDispose($hBitmap)
    _WinAPI_DeleteObject($hBMP)
    _GDIPlus_GraphicsDispose($hGfx_Buffer)
    _GDIPlus_BitmapDispose($hBmp_Buffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_GraphicsSetClipRect

Function Reference

_GDIPlus_GraphicsSetClipRect

Updates the clipping region of a Graphics object to a region that is the combination of itself and a rectangle

#include <GDIPlus.au3>
_GDIPlus_GraphicsSetClipRect ( $hGraphics, $nX, $nY, $nWidth, $nHeight [, $iCombineMode = 0] )

Parameters

$hGraphics | Pointer to a Graphics object
$nX | X coordinate of the upper-left corner of the rectangle
$nY | Y coordinate of the upper-left corner of the rectangle
$nWidth | Width of the rectangle
$nHeight | Height of the rectangle
$iCombineMode | [optional] Regions combination mode: 0 - The existing region is replaced by the new region 1 - The existing region is replaced by the intersection of itself and the new region 2 - The existing region is replaced by the union of itself and the new region 3 - The existing region is replaced by the result of performing an XOR on the two regions 4 - The existing region is replaced by the portion of itself that is outside of the new region 5 - The existing region is replaced by the portion of the new region that is outside of the existing region

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipSetClipRect in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 320, 240)
    GUICtrlCreateButton("Button", 20, 20, 100, 25)
    GUICtrlCreateSlider(100, 100, 100, 30)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle

    _GDIPlus_GraphicsSetClipRect($hGraphics, 20, 20, 100, 25, 4) ;subtract button-area from clipregion
    _GDIPlus_GraphicsSetClipRect($hGraphics, 100, 100, 100, 30, 4) ;subtract slider-area from clipregion

    Local $iTimer = TimerInit()
    ; Loop until the user exits.
    Do
        If TimerDiff($iTimer) > 100 Then
            _GDIPlus_GraphicsClear($hGraphics, BitOR(0xFF000000, Random(0, 0xFFFFFF, 1)))
            $iTimer = TimerInit()
        EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_GraphicsSetClipRegion

Function Reference

_GDIPlus_GraphicsSetClipRegion

Updates the clipping region of a Graphics object to a region that is the combination of itself and the region specified by a Region object

#include <GDIPlus.au3>
_GDIPlus_GraphicsSetClipRegion ( $hGraphics, $hRegion [, $iCombineMode = 0] )

Parameters

$hGraphics | Pointer to a Graphics object
$hRegion | Pointer to a Region object to be combined with the clipping region of the Graphics object
$iCombineMode | [optional] Regions combination mode: 0 - The existing region is replaced by the new region 1 - The existing region is replaced by the intersection of itself and the new region 2 - The existing region is replaced by the union of itself and the new region 3 - The existing region is replaced by the result of performing an XOR on the two regions 4 - The existing region is replaced by the portion of itself that is outside of the new region 5 - The existing region is replaced by the portion of the new region that is outside of the existing region

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipSetClipRegion in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    Local $hBMP = _ScreenCapture_Capture()

    Local $hGUI = GUICreate("GDI+", 400, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    Local $hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(400, 400, $hGraphics)
    Local $hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($hBmp_Buffer)

    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)

    Local $hMatrix1 = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix1, 200, 200)
    Local $hMatrix2 = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix2, 200, 200)

    Local $hPath = _GDIPlus_PathCreate()
    For $i = 0 To 300 Step 24
        _GDIPlus_PathAddEllipse($hPath, -$i, -$i, $i * 2, $i * 2)
    Next

    Local $hRegion = _GDIPlus_RegionCreate()
    _GDIPlus_RegionCombinePath($hRegion, $hPath, 4)

    Local $hTimer = TimerInit()
    ; Loop until the user exits.
    Do
        If TimerDiff($hTimer) > 20 Then
            _GDIPlus_GraphicsResetClip($hGfx_Buffer)
            _GDIPlus_GraphicsClear($hGfx_Buffer, 0x33FFAA00)

            _GDIPlus_MatrixRotate($hMatrix1, 1)
            _GDIPlus_MatrixRotate($hMatrix2, -1)

            _GDIPlus_GraphicsSetTransform($hGfx_Buffer, $hMatrix1)
            _GDIPlus_GraphicsSetClipRegion($hGfx_Buffer, $hRegion)
            _GDIPlus_GraphicsDrawImage($hGfx_Buffer, $hBitmap, -300, -300)

            _GDIPlus_GraphicsSetTransform($hGfx_Buffer, $hMatrix2)
            _GDIPlus_GraphicsSetClipPath($hGfx_Buffer, $hPath)
            _GDIPlus_GraphicsDrawImage($hGfx_Buffer, $hBitmap, -300, -300)

            _GDIPlus_GraphicsDrawImage($hGraphics, $hBmp_Buffer, 0, 0)
            $hTimer = TimerInit()
        EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_RegionDispose($hRegion)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_MatrixDispose($hMatrix1)
    _GDIPlus_MatrixDispose($hMatrix2)
    _GDIPlus_BitmapDispose($hBitmap)
    _WinAPI_DeleteObject($hBMP)
    _GDIPlus_GraphicsDispose($hGfx_Buffer)
    _GDIPlus_BitmapDispose($hBmp_Buffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_GraphicsSetCompositingMode

Function Reference

_GDIPlus_GraphicsSetCompositingMode

Sets the compositing mode of a Graphics object

#include <GDIPlus.au3>
_GDIPlus_GraphicsSetCompositingMode ( $hGraphics, $iCompositionMode )

Parameters

$hGraphics | Pointer to a Graphics object
$iCompositionMode | Compositing mode: 0 - Specifies that when a color is rendered, it is blended with the background color. 1 - Specifies that when a color is rendered, it overwrites the background color.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_GraphicsGetCompositingMode

See Also

Search GdipSetCompositingMode in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBitmap, $hContext, $hBrush, $iMode1, $iMode2

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    $hBitmap = _GDIPlus_BitmapCreateFromScan0(800, 400)
    $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    $hBrush = _GDIPlus_LineBrushCreate(0, 0, 0, 400, 0xFF0000FF, 0)

    _GDIPlus_GraphicsFillRect($hContext, 10, 10, 300, 300, $hBrush)
    _GDIPlus_GraphicsFillRect($hContext, 80, 60, 300, 300, $hBrush)
    $iMode1 = _GDIPlus_GraphicsGetCompositingMode($hContext)

    _GDIPlus_GraphicsSetCompositingMode($hContext, $GDIP_CompositingModeSourceCopy)
    _GDIPlus_GraphicsFillRect($hContext, 420, 10, 300, 300, $hBrush)
    _GDIPlus_GraphicsFillRect($hContext, 490, 60, 300, 300, $hBrush)
    $iMode2 = _GDIPlus_GraphicsGetCompositingMode($hContext)

    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0)

    _GDIPlus_GraphicsDrawString($hGraphic, "CompositingMode = " & $iMode1, 10, 380)
    _GDIPlus_GraphicsDrawString($hGraphic, "CompositingMode = " & $iMode2, 420, 380)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_GraphicsSetCompositingQuality

Function Reference

_GDIPlus_GraphicsSetCompositingQuality

Sets the compositing quality of a Graphics object

#include <GDIPlus.au3>
_GDIPlus_GraphicsSetCompositingQuality ( $hGraphics, $iCompositionQuality )

Parameters

$hGraphics | Pointer to a Graphics object
$iCompositionQuality | Compositing quality: 0 - Gamma correction is not applied. 1 - Gamma correction is not applied. High speed, low quality. 2 - Gamma correction is applied. Composition of high quality and speed. 3 - Gamma correction is applied. 4 - Gamma correction is not applied. Linear values are used.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_GraphicsGetCompositingQuality

See Also

Search GdipSetCompositingQuality in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $iQuality1, $iQuality2, $hMatrix

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphic, 0xFF6600AA)

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, 10, 10, 380, 360)

    $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFFFF)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, 0)
    _GDIPlus_PathBrushSetSigmaBlend($hBrush, 1)
    _GDIPlus_PathBrushSetFocusScales($hBrush, 0.7, 0.7)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush)

    $iQuality1 = _GDIPlus_GraphicsGetCompositingQuality($hGraphic)

    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, 400, 0)
    _GDIPlus_PathTransform($hPath, $hMatrix)
    _GDIPlus_PathBrushSetTransform($hBrush, $hMatrix)

    _GDIPlus_GraphicsSetCompositingQuality($hGraphic, 3)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush)
    $iQuality2 = _GDIPlus_GraphicsGetCompositingQuality($hGraphic)

    _GDIPlus_GraphicsDrawString($hGraphic, "CompositingQuality = " & $iQuality1, 10, 380)
    _GDIPlus_GraphicsDrawString($hGraphic, "CompositingQuality = " & $iQuality2, 420, 380)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_GraphicsSetInterpolationMode

Function Reference

_GDIPlus_GraphicsSetInterpolationMode

Sets the interpolation mode of a Graphics object

#include <GDIPlus.au3>
_GDIPlus_GraphicsSetInterpolationMode ( $hGraphics, $iInterpolationMode )

Parameters

$hGraphics | Pointer to a Graphics object
$iInterpolationMode | Interpolation mode: 0 - Default interpolation mode 1 - Low-quality mode 2 - High-quality mode 3 - Bilinear interpolation. No prefiltering is done 4 - Bicubic interpolation. No prefiltering is done 5 - Nearest-neighbor interpolation 6 - High-quality, bilinear interpolation. Prefiltering is performed to ensure high-quality shrinking 7 - High-quality, bicubic interpolation. Prefiltering is performed to ensure high-quality shrinking

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

The interpolation mode determines the algorithm that is used when images are scaled or rotated

Related

_GDIPlus_GraphicsGetInterpolationMode

See Also

Search GdipSetInterpolationMode in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup()
    Local Const $iW = @DesktopWidth / 4, $iH = @DesktopHeight / 4
    Local $hGUI = GUICreate("GDI+ test", $iW, $iH, -1, 10)
    GUISetState(@SW_SHOW)

    Local $aIM[8] = ["Default", "Low Quality", "High Quality", "Bilinear", "Bicubic", "Nearest Neighbor", "High Quality Bilinear", "High Quality Bicubic"]

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, -1, -1) ;create a GDI bitmap by capturing whole desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    Local $iIM = _GDIPlus_GraphicsGetInterpolationMode($hGraphics)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iW, $iH) ;draw captured bitmap to GUI with default system interpolation mode
    MsgBox($MB_SYSTEMMODAL, "", "Interpolation Mode initial: " & $aIM[$iIM])

    _GDIPlus_GraphicsSetInterpolationMode($hGraphics, $GDIP_INTERPOLATIONMODE_NearestNeighbor) ;change interpolation mode
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iW, $iH) ;draw again same bitmap but with different interpolation mode
    $iIM = _GDIPlus_GraphicsGetInterpolationMode($hGraphics)
    MsgBox($MB_SYSTEMMODAL, "", "Interpolation Mode after: " & $aIM[$iIM])

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    ;cleanup resources
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_GraphicsSetPixelOffsetMode

Function Reference

_GDIPlus_GraphicsSetPixelOffsetMode

Sets the pixel offset mode of a Graphics object

#include <GDIPlus.au3>
_GDIPlus_GraphicsSetPixelOffsetMode ( $hGraphics, $iPixelOffsetMode )

Parameters

$hGraphics | Pointer to a Graphics object
$iPixelOffsetMode | Pixel offset mode: 0,1,3 - Pixel centers have integer coordinates 2,4 - Pixel centers have coordinates that are half way between integer values (i.e. 0.5, 20, 105.5, etc...)

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipSetPixelOffsetMode in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Global $g_hGUI, $g_hGraphics, $g_hBitmap, $g_hGfxCtxt, $g_hPen

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    $g_hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $g_hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    ;create buffered graphics frame set for smoother gfx object movements
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle
    $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGraphics)
    $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    $g_hPen = _GDIPlus_PenCreate(0xFFFF8060, 2)
    _GDIPlus_GraphicsSetPixelOffsetMode($g_hGfxCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)

    Local $aPoints[11][4], $x, $y
    $aPoints[0][0] = 10

    For $y = 0 To 1
        For $x = 1 To 5
            $aPoints[$y * 5 + $x][0] = 100 + 300 * $y + 50 ;x coordinate of the point
            $aPoints[$y * 5 + $x][1] = 150 + $x * 50 ;y coordinate of the point
            $aPoints[$y * 5 + $x][2] = Random(-2, 2) ;x vector of the point
            $aPoints[$y * 5 + $x][3] = Random(-2, 2) ;y vector of the point
        Next
    Next

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

    Do
        _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ;clear bitmap for repaint
        _GDIPlus_GraphicsDrawClosedCurve2($g_hGfxCtxt, $aPoints, 1.25, $g_hPen) ;draw closed curve
        _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBitmap, 0, 0) ;copy bitmap to graphic handle (GUI)
        For $y = 1 To $aPoints[0][0]
            $aPoints[$y][0] += $aPoints[$y][2] ;calculate new x position
            If $aPoints[$y][0] < 0 Or $aPoints[$y][0] > $iWidth Then $aPoints[$y][2] *= -1 ;if vertical border is reached invert x vector
            $aPoints[$y][1] += $aPoints[$y][3] ;calculate new y position
            If $aPoints[$y][1] < 0 Or $aPoints[$y][1] > $iHeight Then $aPoints[$y][3] *= -1 ;if horizontal border is reached invert y vector
        Next
    Until Not Sleep(30) ;sleep 30 ms to avoid high cpu usage
EndFunc   ;==>Example

Func _Exit()
    ;cleanup GDI+ resources
    _GDIPlus_PenDispose($g_hPen)
    _GDIPlus_GraphicsDispose($g_hGfxCtxt)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_BitmapDispose($g_hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_GraphicsSetSmoothingMode

Function Reference

_GDIPlus_GraphicsSetSmoothingMode

Sets the graphics object rendering quality

#include <GDIPlus.au3>
_GDIPlus_GraphicsSetSmoothingMode ( $hGraphics, $iSmooth )

Parameters

$hGraphics | Handle to a Graphics object
$iSmooth | Smoothing mode: 0 - Smoothing is not applied 1 - Smoothing is applied using an 8 X 4 box filter 2 - Smoothing is applied using an 8 X 8 box filter

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

The Smoothing filter applied using an 8 X 8 box filter requires at minimum the Windows Vista operating system.

Related

_GDIPlus_GraphicsGetSmoothingMode

See Also

Search GdipSetSmoothingMode in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+ test", 640, 480)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Local $hPen = _GDIPlus_PenCreate()
    _GDIPlus_GraphicsDrawLine($hGraphics, 40, 40, 600, 440, $hPen) ;draw a test line to show smoothing effect (default no smoothing)
    MsgBox($MB_SYSTEMMODAL, "", "Smoothing enabled: " & _GDIPlus_GraphicsGetSmoothingMode($hGraphics))

    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;set smoothing mode (8 X 4 box filter)
    _GDIPlus_GraphicsDrawLine($hGraphics, 600, 40, 40, 440, $hPen) ;draw a test line to show smoothing effect

    MsgBox($MB_SYSTEMMODAL, "", "Smoothing enabled: " & _GDIPlus_GraphicsGetSmoothingMode($hGraphics))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    ;cleanup resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_GraphicsSetTextRenderingHint

Function Reference

_GDIPlus_GraphicsSetTextRenderingHint

Sets the contrast value of a Graphics object

#include <GDIPlus.au3>
_GDIPlus_GraphicsSetTextRenderingHint ( $hGraphics, $iTextRenderingHint )

Parameters

$hGraphics | Pointer to a Graphics object
$iTextRenderingHint | Text rendering mode: 0 - Character is drawn using the currently selected system font smoothing mode (also called a rendering hint) 1 - Character is drawn using its glyph bitmap and hinting to improve character appearance on stems and 2 - Character is drawn using its glyph bitmap and no hinting. This results in better performance at the 3 - Character is drawn using its antialiased glyph bitmap and hinting. This results in much better quality 4 - Character is drawn using its antialiased glyph bitmap and no hinting. Stem width differences may be 5 - Character is drawn using its glyph Microsoft ClearType bitmap and hinting. This type of text rendering

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipSetTextRenderingHint in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+ test", 800, 400)
    GUISetState(@SW_SHOW)

    If @OSBuild < 6000 Then MsgBox($MB_SYSTEMMODAL, "", "Antialiasing is automatically turned on for your operating system - no visible differences!")

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsDrawString($hGraphics, "AutoIt rulez!", 0, 0, "Impact", 110)
    _GDIPlus_GraphicsSetTextRenderingHint($hGraphics, $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT)
    _GDIPlus_GraphicsDrawString($hGraphics, "AutoIt rulez!", 0, 200, "Impact", 110)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    ;cleanup resources
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_GraphicsSetTransform

Function Reference

_GDIPlus_GraphicsSetTransform

Sets the world transformation for a graphics object

#include <GDIPlus.au3>
_GDIPlus_GraphicsSetTransform ( $hGraphics, $hMatrix )

Parameters

$hGraphics | Handle to a Graphics object
$hMatrix | Handle to a Matrix object that specifies the world transformation

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipSetWorldTransform in MSDN Library.

Example

#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphic, $iWidth, $iHeight

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture full screen
    $hBitmap1 = _ScreenCapture_Capture("")
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1)

    ; Capture screen region
    $hBitmap2 = _ScreenCapture_Capture("", 0, 0, 400, 300)
    $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap2)

    $iWidth = _GDIPlus_ImageGetWidth($hImage2)
    $iHeight = _GDIPlus_ImageGetHeight($hImage2)

    ; Draw one image in another
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)

    ;DrawInsert($hGraphic, $hImage2, $iX, $iY, $fAngle,    $iWidth,    $iHeight, $iARGB = 0xFF000000, $iPenWidth = 1)
    DrawInsert($hGraphic, $hImage2, 350, 100, 0, $iWidth + 2, $iHeight + 2, 0xFFFF8000, 2)
    DrawInsert($hGraphic, $hImage2, 340, 50, 15, 200, 150, 0xFFFF8000, 4)
    DrawInsert($hGraphic, $hImage2, 310, 30, 35, $iWidth + 4, $iHeight + 4, 0xFFFF00FF, 4)
    DrawInsert($hGraphic, $hImage2, 320, 790, -35, $iWidth, $iHeight)

    ; Save resultant image
    _GDIPlus_ImageSaveToFile($hImage1, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _WinAPI_DeleteObject($hBitmap1)
    _WinAPI_DeleteObject($hBitmap2)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
EndFunc   ;==>Example

; #FUNCTION# ==================================================================================================
; Name...........: DrawInsert
; Description ...: Draw one image in another
; Syntax.........: DrawInsert($hGraphic, $hImage2, $iX, $iY, $fAngle, $iWidth, $iHeight, $iARGB = 0xFF000000, $iPenWidth = 1)
; inserts Graphics $hImage2 into $hGraphic
; Parameters ....: $hGraphics   - Handle to a Graphics object
;                  $hImage      - Handle to an Image object to be inserted
;                  $iX          - The X coordinate of the upper left corner of the inserted image
;                  $iY          - The Y coordinate of the upper left corner of the inserted image
;                  $iWidth      - The width of the rectangle Border around insert
;                  $iHeight     - The height of the rectangle Border around insert
;                  $iARGB       - Alpha, Red, Green and Blue components of pen color - Border color
;                  $iPenWidth      - The width of the pen measured in the units specified in the $iUnit parameter - Border Width

; Return values .: Success      - True
;                  Failure      - False
; ==================================================================================================
Func DrawInsert($hGraphic, $hImage2, $iX, $iY, $fAngle, $iWidth, $iHeight, $iARGB = 0xFF000000, $iPenWidth = 1)
    Local $hMatrix, $hPen2

    ;Rotation Matrix
    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixRotate($hMatrix, $fAngle, "False")
    _GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix)

    _GDIPlus_GraphicsDrawImage($hGraphic, $hImage2, $iX, $iY)

    ;get pen + color
    $hPen2 = _GDIPlus_PenCreate($iARGB, $iPenWidth)

    ; Draw a frame around the inserted image
    _GDIPlus_GraphicsDrawRect($hGraphic, $iX, $iY, $iWidth, $iHeight, $hPen2)

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PenDispose($hPen2)
    Return 1
EndFunc   ;==>DrawInsert


Function _GDIPlus_GraphicsTransformPoints

Function Reference

_GDIPlus_GraphicsTransformPoints

Converts an array of points from one coordinate space to another

#include <GDIPlus.au3>
_GDIPlus_GraphicsTransformPoints ( $hGraphics, ByRef $aPoints [, $iCoordSpaceTo = 0 [, $iCoordSpaceFrom = 1]] )

Parameters

$hGraphics | Pointer to a Graphics object
$aPoints | Array of points to be converted: [0][0] - Number of points [1][0] - Point 1 X position [1][1] - Point 1 Y position [2][0] - Point 2 X position [2][1] - Point 2 Y position [n][0] - Point n X position [n][1] - Point n Y position
$iCoordSpaceTo | [optional] Destination coordinate space
$iCoordSpaceFrom | [optional] Source coordinate space: 0 - World coordinate space, not physical coordinates 1 - Page coordinate space, read-world coordinates 2 - Device coordinate space, physical coordinates

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipTransformPoints in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hGUI, $g_hGraphics, $g_hBmp_Buffer, $g_hGfx_Buffer, $g_hImage
Global $g_iMouseX, $g_iMouseY

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    ; X64 running support
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"

    ;get AutoIt install dir
    Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt"

    Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif"
    If Not FileExists($sFile) Then
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30)
        Exit
    EndIf

    $g_hGUI = GUICreate("GDI+", 800, 600)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_ResetGraphicsTransform")
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI)
    $g_hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(800, 600, $g_hGraphics)
    $g_hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($g_hBmp_Buffer)

    $g_hImage = _GDIPlus_ImageLoadFromFile($sFile)

    GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN")
    GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL")
    GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE")
    GUISetState(@SW_SHOW)

    _Draw()

    While Sleep(10)
    WEnd
EndFunc   ;==>Example

Func _ResetGraphicsTransform()
    _GDIPlus_GraphicsResetTransform($g_hGfx_Buffer)
    _Draw()
EndFunc   ;==>_ResetGraphicsTransform

Func WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam

    $g_iMouseX = BitAND($lParam, 0x0000FFFF)
    $g_iMouseY = BitShift($lParam, 16)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_LBUTTONDOWN

Func WM_MOUSEMOVE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg

    Switch BitAND($wParam, 0x0000FFFF)
        Case 1
            Local $iX = BitAND($lParam, 0x0000FFFF)
            Local $iY = BitShift($lParam, 16)

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $iX - $g_iMouseX, $iY - $g_iMouseY, True)

            $g_iMouseX = $iX
            $g_iMouseY = $iY

            _Draw()
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEMOVE

Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam

    Switch BitAND($wParam, 0x0000FFFF)
        Case 1
            Local $iAngle = -3
            If BitShift($wParam, 16) < 0 Then $iAngle = 3

            Local $aMousePos[2][2] = [[1]]
            $aMousePos[1][0] = $g_iMouseX
            $aMousePos[1][1] = $g_iMouseY
            _GDIPlus_GraphicsTransformPoints($g_hGfx_Buffer, $aMousePos)

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $aMousePos[1][0], $aMousePos[1][1])
            _GDIPlus_GraphicsRotateTransform($g_hGfx_Buffer, $iAngle)
            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, -$aMousePos[1][0], -$aMousePos[1][1])

        Case Else
            Local $aInfo = GUIGetCursorInfo($g_hGUI)
            Local $iScale = 1.1
            If BitShift($wParam, 16) < 0 Then $iScale = 0.9

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, -$aInfo[0], -$aInfo[1], True)
            _GDIPlus_GraphicsScaleTransform($g_hGfx_Buffer, $iScale, $iScale, True)
            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $aInfo[0], $aInfo[1], True)
    EndSwitch

    _Draw()
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEWHEEL

Func _Draw()
    _GDIPlus_GraphicsClear($g_hGfx_Buffer, 0xFFFFFFFF)

    _GDIPlus_GraphicsDrawImage($g_hGfx_Buffer, $g_hImage, 316, 266)

    Local $hPen = _GDIPlus_PenCreate(0xFF0000FF)
    _GDIPlus_GraphicsDrawRect($g_hGfx_Buffer, 300, 250, 200, 100, $hPen)
    _GDIPlus_PenDispose($hPen)

    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F)
    Local $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 24, 2)
    Local $tLayout = _GDIPlus_RectFCreate(0, 360, 800)
    _GDIPlus_GraphicsDrawStringEx($g_hGfx_Buffer, "AutoIt rulez!", $hFont, $tLayout, $hFormat, $hBrush)

    _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBmp_Buffer, 0, 0)

    _GDIPlus_FontDispose($hFont)
    $hFont = _GDIPlus_FontCreate($hFamily, 10)
    _GDIPlus_StringFormatSetAlign($hFormat, 0)

    DllStructSetData($tLayout, "X", 10)
    DllStructSetData($tLayout, "Y", 10)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "left mousebutton = move graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 30)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "mousewheel = zoom graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 50)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "mousewheel + left mousebutton = rotate graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 70)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "right mousebutton = reset", $hFont, $tLayout, $hFormat, $hBrush)

    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_GraphicsGetTransform($g_hGfx_Buffer, $hMatrix)
    Local $aMatrix_Values = _GDIPlus_MatrixGetElements($hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)

    DllStructSetData($tLayout, "Y", 110)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "Matrix:", $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "X", 20)
    DllStructSetData($tLayout, "Y", 130)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[0], $aMatrix_Values[1]), $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "Y", 150)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[2], $aMatrix_Values[3]), $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "Y", 170)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[4], $aMatrix_Values[5]), $hFont, $tLayout, $hFormat, $hBrush)

    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
EndFunc   ;==>_Draw

Func _Exit()
    _GDIPlus_ImageDispose($g_hImage)
    _GDIPlus_GraphicsDispose($g_hGfx_Buffer)
    _GDIPlus_BitmapDispose($g_hBmp_Buffer)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_GraphicsTranslateTransform

Function Reference

_GDIPlus_GraphicsTranslateTransform

Updates a Graphics object's world transformation matrix with the product of itself and a translation matrix

#include <GDIPlus.au3>
_GDIPlus_GraphicsTranslateTransform ( $hGraphics, $nDX, $nDY [, $iOrder = 0] )

Parameters

$hGraphics | Pointer to a Graphics object
$nDX | Horizontal component of the translation
$nDY | Vertical component of the translation
$iOrder | [optional] Order of matrices multiplication: 0 - The translation matrix is on the left 1 - The translation matrix is on the right

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipTranslateWorldTransform in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hGUI, $g_hGraphics, $g_hBmp_Buffer, $g_hGfx_Buffer, $g_hImage
Global $g_iMouseX, $g_iMouseY

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    ; X64 running support
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"

    ;get AutoIt install dir
    Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt"

    Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif"
    If Not FileExists($sFile) Then
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30)
        Exit
    EndIf

    $g_hGUI = GUICreate("GDI+", 800, 600)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_ResetGraphicsTransform")
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI)
    $g_hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(800, 600, $g_hGraphics)
    $g_hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($g_hBmp_Buffer)

    $g_hImage = _GDIPlus_ImageLoadFromFile($sFile)

    GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN")
    GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL")
    GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE")
    GUISetState(@SW_SHOW)

    _Draw()

    While Sleep(10)
    WEnd
EndFunc   ;==>Example

Func _ResetGraphicsTransform()
    _GDIPlus_GraphicsResetTransform($g_hGfx_Buffer)
    _Draw()
EndFunc   ;==>_ResetGraphicsTransform

Func WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam

    $g_iMouseX = BitAND($lParam, 0x0000FFFF)
    $g_iMouseY = BitShift($lParam, 16)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_LBUTTONDOWN

Func WM_MOUSEMOVE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg

    Switch BitAND($wParam, 0x0000FFFF)
        Case 1
            Local $iX = BitAND($lParam, 0x0000FFFF)
            Local $iY = BitShift($lParam, 16)

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $iX - $g_iMouseX, $iY - $g_iMouseY, True)

            $g_iMouseX = $iX
            $g_iMouseY = $iY

            _Draw()
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEMOVE

Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam

    Switch BitAND($wParam, 0x0000FFFF)
        Case 1
            Local $iAngle = -3
            If BitShift($wParam, 16) < 0 Then $iAngle = 3

            Local $aMousePos[2][2] = [[1]]
            $aMousePos[1][0] = $g_iMouseX
            $aMousePos[1][1] = $g_iMouseY
            _GDIPlus_GraphicsTransformPoints($g_hGfx_Buffer, $aMousePos)

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $aMousePos[1][0], $aMousePos[1][1])
            _GDIPlus_GraphicsRotateTransform($g_hGfx_Buffer, $iAngle)
            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, -$aMousePos[1][0], -$aMousePos[1][1])

        Case Else
            Local $aInfo = GUIGetCursorInfo($g_hGUI)
            Local $iScale = 1.1
            If BitShift($wParam, 16) < 0 Then $iScale = 0.9

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, -$aInfo[0], -$aInfo[1], True)
            _GDIPlus_GraphicsScaleTransform($g_hGfx_Buffer, $iScale, $iScale, True)
            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $aInfo[0], $aInfo[1], True)
    EndSwitch

    _Draw()
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEWHEEL

Func _Draw()
    _GDIPlus_GraphicsClear($g_hGfx_Buffer, 0xFFFFFFFF)

    _GDIPlus_GraphicsDrawImage($g_hGfx_Buffer, $g_hImage, 316, 266)

    Local $hPen = _GDIPlus_PenCreate(0xFF0000FF)
    _GDIPlus_GraphicsDrawRect($g_hGfx_Buffer, 300, 250, 200, 100, $hPen)
    _GDIPlus_PenDispose($hPen)

    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F)
    Local $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 24, 2)
    Local $tLayout = _GDIPlus_RectFCreate(0, 360, 800)
    _GDIPlus_GraphicsDrawStringEx($g_hGfx_Buffer, "AutoIt rulez!", $hFont, $tLayout, $hFormat, $hBrush)

    _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBmp_Buffer, 0, 0)

    _GDIPlus_FontDispose($hFont)
    $hFont = _GDIPlus_FontCreate($hFamily, 10)
    _GDIPlus_StringFormatSetAlign($hFormat, 0)

    DllStructSetData($tLayout, "X", 10)
    DllStructSetData($tLayout, "Y", 10)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "left mousebutton = move graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 30)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "mousewheel = zoom graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 50)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "mousewheel + left mousebutton = rotate graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 70)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "right mousebutton = reset", $hFont, $tLayout, $hFormat, $hBrush)

    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_GraphicsGetTransform($g_hGfx_Buffer, $hMatrix)
    Local $aMatrix_Values = _GDIPlus_MatrixGetElements($hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)

    DllStructSetData($tLayout, "Y", 110)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "Matrix:", $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "X", 20)
    DllStructSetData($tLayout, "Y", 130)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[0], $aMatrix_Values[1]), $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "Y", 150)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[2], $aMatrix_Values[3]), $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "Y", 170)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[4], $aMatrix_Values[5]), $hFont, $tLayout, $hFormat, $hBrush)

    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
EndFunc   ;==>_Draw

Func _Exit()
    _GDIPlus_ImageDispose($g_hImage)
    _GDIPlus_GraphicsDispose($g_hGfx_Buffer)
    _GDIPlus_BitmapDispose($g_hBmp_Buffer)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


User Defined Functions

GraphicsCoders user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_Decoders | Get an array of information about the available image decoders
_GDIPlus_DecodersGetCount | Get the number of available image decoders
_GDIPlus_DecodersGetSize | Get the total size of the structure that is returned by _GDIPlus_GetImageDecoders
_GDIPlus_Encoders | Get an array of information about the available image encoders
_GDIPlus_EncodersGetCLSID | Return the encoder CLSID for a specific image file type
_GDIPlus_EncodersGetCount | Get the number of available image encoders
_GDIPlus_EncodersGetParamList | Get the parameter list for a specified image encoder
_GDIPlus_EncodersGetParamListSize | Get the size of the parameter list for a specified image encoder
_GDIPlus_EncodersGetSize | Get the total size of the structure that is returned by _GDIPlus_GetImageEncoders
_GDIPlus_ParamAdd | Add a value to an encoder parameter list
_GDIPlus_ParamInit | Allocate an empty encoder parameter list
_GDIPlus_ParamSize | Get an encoder parameter size


Function _GDIPlus_Decoders

Function Reference

_GDIPlus_Decoders

Get an array of information about the available image decoders

#include <GDIPlus.au3>
_GDIPlus_Decoders ( )

Return Value

Success: | an array with the following format: [0][ 0] - Number of decoders [1][ 1] - Codec identifier [1][ 2] - File format identifier [1][ 3] - Codec name [1][ 4] - DLL in which the code resides [1][ 5] - The name of the file format used by the codec [1][ 6] - Filename extensions associated with the codec [1][ 7] - The mime type of the codec [1][ 8] - Combination of $GDIP_ICF flags [1][ 9] - The version of the codec [1][10] - The number of signatures used by the file format [1][11] - The number of bytes in each signature [1][12] - Pointer to the pattern for each signature [1][13] - Pointer to the mask for each signature
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code (GDIP_ERR*).

Related

_GDIPlus_Encoders

See Also

Search GdipGetImageDecoders in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_aCodex, $g_hImage

Example()

Func Example()
    Local $hBitmap

    ; Create GUI
    GUICreate("GDI+", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Create an image to use for paramater lists
    $hBitmap = _ScreenCapture_Capture("", 0, 0, 1, 1)
    $g_hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; Show encoder parameters
    $g_aCodex = _GDIPlus_Encoders()
    ShowCodex("Encoder")

    ; Show decoder parameters
    $g_aCodex = _GDIPlus_Decoders()
    ShowCodex("Decoder")

    ; Clean up resources
    _GDIPlus_ImageDispose($g_hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Show codex information
Func ShowCodex($sTitle)
    Local $iI, $iJ, $iK, $sCLSID, $tData, $tParam, $tParams, $iParamSize = _GDIPlus_ParamSize()

    For $iI = 1 To $g_aCodex[0][0]
        $sCLSID = _GDIPlus_EncodersGetCLSID($g_aCodex[$iI][5])
        MemoWrite("Image " & $sTitle & " " & $iI)
        MemoWrite("  Codec GUID ............: " & $g_aCodex[$iI][1])
        MemoWrite("  File format GUID ......: " & $g_aCodex[$iI][2])
        MemoWrite("  Codec name ............: " & $g_aCodex[$iI][3])
        MemoWrite("  Codec Dll file name ...: " & $g_aCodex[$iI][4])
        MemoWrite("  Codec file format .....: " & $g_aCodex[$iI][5])
        MemoWrite("  File name extensions ..: " & $g_aCodex[$iI][6])
        MemoWrite("  Mime type .............: " & $g_aCodex[$iI][7])
        MemoWrite("  Flags .................: 0x" & Hex($g_aCodex[$iI][8]))
        MemoWrite("  Version ...............: " & $g_aCodex[$iI][9])
        MemoWrite("  Signature count .......: " & $g_aCodex[$iI][10])
        MemoWrite("  Signature size ........: " & $g_aCodex[$iI][11])
        MemoWrite("  Signature pattern ptr .: 0x" & Hex($g_aCodex[$iI][12]))
        MemoWrite("  Signature mask ptr ....: 0x" & Hex($g_aCodex[$iI][13]))

;~      If $sTitle = "Decoder" Then ContinueLoop

        MemoWrite("  Parameter list size ...: " & _GDIPlus_EncodersGetParamListSize($g_hImage, $sCLSID))

        $tParams = _GDIPlus_EncodersGetParamList($g_hImage, $sCLSID)
        If @error Then
            MemoWrite()
            ContinueLoop
        EndIf

        MemoWrite("  Parameters Count ......: " & DllStructGetData($tParams, "Count"))
        MemoWrite()
        For $iJ = 0 To DllStructGetData($tParams, "Count") - 1
            MemoWrite("  Image " & $sTitle & " " & $iI & " Parameter " & $iJ)
            $tParam = DllStructCreate($tagGDIPENCODERPARAM, DllStructGetPtr($tParams, "GUID") + ($iJ * $iParamSize))
            MemoWrite("    Parameter GUID ......: " & _WinAPI_StringFromGUID(DllStructGetPtr($tParam, "GUID")))
            MemoWrite("    Number of values ....: " & DllStructGetData($tParam, "NumberOfValues"))
            MemoWrite("    Parameter type.......: " & DllStructGetData($tParam, "Type"))
            MemoWrite("    Parameter pointer ...: 0x" & Hex(DllStructGetData($tParam, "Values")))
            Switch DllStructGetData($tParam, "Type")
                Case 4
                    $tData = DllStructCreate("int Data[" & DllStructGetData($tParam, "NumberOfValues") & "]", DllStructGetData($tParam, "Values"))
                    For $iK = 1 To DllStructGetData($tParam, "NumberOfValues")
                        MemoWrite("      Value .............: " & DllStructGetData($tData, 1, $iK))
                    Next
                Case 6
                    $tData = DllStructCreate("int Low;int High", DllStructGetData($tParam, "Values"))
                    MemoWrite("      Low range .........: " & DllStructGetData($tData, "Low"))
                    MemoWrite("      High range ........: " & DllStructGetData($tData, "High"))
            EndSwitch
            MemoWrite()
        Next
    Next
EndFunc   ;==>ShowCodex


Function _GDIPlus_DecodersGetCount

Function Reference

_GDIPlus_DecodersGetCount

Get the number of available image decoders

#include <GDIPlus.au3>
_GDIPlus_DecodersGetCount ( )

Return Value

Success: | the number of image decoders.
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code (GDIP_ERR*).

Related

_GDIPlus_DecodersGetSize

See Also

Search GdipGetImageDecodersSize in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    ; Create GUI
    GUICreate("GDI+", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Show number of decoders/encoders
    MemoWrite("Decoder count : " & _GDIPlus_DecodersGetCount());
    MemoWrite("Decoder size .: " & _GDIPlus_DecodersGetSize());
    MemoWrite("Encoder count : " & _GDIPlus_EncodersGetCount());
    MemoWrite("Encoder size .: " & _GDIPlus_EncodersGetSize());

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GDIPlus_DecodersGetSize

Function Reference

_GDIPlus_DecodersGetSize

Get the total size of the structure that is returned by _GDIPlus_GetImageDecoders

#include <GDIPlus.au3>
_GDIPlus_DecodersGetSize ( )

Return Value

Success: | the total size, in bytes.
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code (GDIP_ERR*).

Related

_GDIPlus_DecodersGetCount

See Also

Search GdipGetImageDecodersSize in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    ; Create GUI
    GUICreate("GDI+", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Show number of decoders/encoders
    MemoWrite("Decoder count : " & _GDIPlus_DecodersGetCount());
    MemoWrite("Decoder size .: " & _GDIPlus_DecodersGetSize());
    MemoWrite("Encoder count : " & _GDIPlus_EncodersGetCount());
    MemoWrite("Encoder size .: " & _GDIPlus_EncodersGetSize());

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GDIPlus_Encoders

Function Reference

_GDIPlus_Encoders

Get an array of information about the available image encoders

#include <GDIPlus.au3>
_GDIPlus_Encoders ( )

Return Value

Success: | an array with the following format: [0][ 0] - Number of decoders [1][ 1] - Codec identifier [1][ 2] - File format identifier [1][ 3] - Codec name [1][ 4] - DLL in which the code resides [1][ 5] - The name of the file format used by the codec [1][ 6] - Filename extensions associated with the codec [1][ 7] - The mime type of the codec [1][ 8] - Combination of $GDIP_ICF flags [1][ 9] - The version of the codec [1][10] - The number of signatures used by the file format [1][11] - The number of bytes in each signature [1][12] - Pointer to the pattern for each signature [1][13] - Pointer to the mask for each signature
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code (GDIP_ERR*).

Related

_GDIPlus_Decoders

See Also

Search GdipGetImageEncoders in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_aCodex, $g_hImage

Example()

Func Example()
    Local $hBitmap

    ; Create GUI
    GUICreate("GDI+", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Create an image to use for paramater lists
    $hBitmap = _ScreenCapture_Capture("", 0, 0, 1, 1)
    $g_hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; Show encoder parameters
    $g_aCodex = _GDIPlus_Encoders()
    ShowCodex("Encoder")

    ; Show decoder parameters
    $g_aCodex = _GDIPlus_Decoders()
    ShowCodex("Decoder")

    ; Clean up resources
    _GDIPlus_ImageDispose($g_hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Show codex information
Func ShowCodex($sTitle)
    Local $iI, $iJ, $iK, $sCLSID, $tData, $tParam, $tParams, $iParamSize = _GDIPlus_ParamSize()

    For $iI = 1 To $g_aCodex[0][0]
        $sCLSID = _GDIPlus_EncodersGetCLSID($g_aCodex[$iI][5])
        MemoWrite("Image " & $sTitle & " " & $iI)
        MemoWrite("  Codec GUID ............: " & $g_aCodex[$iI][1])
        MemoWrite("  File format GUID ......: " & $g_aCodex[$iI][2])
        MemoWrite("  Codec name ............: " & $g_aCodex[$iI][3])
        MemoWrite("  Codec Dll file name ...: " & $g_aCodex[$iI][4])
        MemoWrite("  Codec file format .....: " & $g_aCodex[$iI][5])
        MemoWrite("  File name extensions ..: " & $g_aCodex[$iI][6])
        MemoWrite("  Mime type .............: " & $g_aCodex[$iI][7])
        MemoWrite("  Flags .................: 0x" & Hex($g_aCodex[$iI][8]))
        MemoWrite("  Version ...............: " & $g_aCodex[$iI][9])
        MemoWrite("  Signature count .......: " & $g_aCodex[$iI][10])
        MemoWrite("  Signature size ........: " & $g_aCodex[$iI][11])
        MemoWrite("  Signature pattern ptr .: 0x" & Hex($g_aCodex[$iI][12]))
        MemoWrite("  Signature mask ptr ....: 0x" & Hex($g_aCodex[$iI][13]))

;~      If $sTitle = "Decoder" Then ContinueLoop

        MemoWrite("  Parameter list size ...: " & _GDIPlus_EncodersGetParamListSize($g_hImage, $sCLSID))

        $tParams = _GDIPlus_EncodersGetParamList($g_hImage, $sCLSID)
        If @error Then
            MemoWrite()
            ContinueLoop
        EndIf

        MemoWrite("  Parameters Count ......: " & DllStructGetData($tParams, "Count"))
        MemoWrite()
        For $iJ = 0 To DllStructGetData($tParams, "Count") - 1
            MemoWrite("  Image " & $sTitle & " " & $iI & " Parameter " & $iJ)
            $tParam = DllStructCreate($tagGDIPENCODERPARAM, DllStructGetPtr($tParams, "GUID") + ($iJ * $iParamSize))
            MemoWrite("    Parameter GUID ......: " & _WinAPI_StringFromGUID(DllStructGetPtr($tParam, "GUID")))
            MemoWrite("    Number of values ....: " & DllStructGetData($tParam, "NumberOfValues"))
            MemoWrite("    Parameter type.......: " & DllStructGetData($tParam, "Type"))
            MemoWrite("    Parameter pointer ...: 0x" & Hex(DllStructGetData($tParam, "Values")))
            Switch DllStructGetData($tParam, "Type")
                Case 4
                    $tData = DllStructCreate("int Data[" & DllStructGetData($tParam, "NumberOfValues") & "]", DllStructGetData($tParam, "Values"))
                    For $iK = 1 To DllStructGetData($tParam, "NumberOfValues")
                        MemoWrite("      Value .............: " & DllStructGetData($tData, 1, $iK))
                    Next
                Case 6
                    $tData = DllStructCreate("int Low;int High", DllStructGetData($tParam, "Values"))
                    MemoWrite("      Low range .........: " & DllStructGetData($tData, "Low"))
                    MemoWrite("      High range ........: " & DllStructGetData($tData, "High"))
            EndSwitch
            MemoWrite()
        Next
    Next
EndFunc   ;==>ShowCodex


Function _GDIPlus_EncodersGetCLSID

Function Reference

_GDIPlus_EncodersGetCLSID

Return the encoder CLSID for a specific image file type

#include <GDIPlus.au3>
_GDIPlus_EncodersGetCLSID ( $sFileExtension )

Parameters

$sFileExtension File extension to search for (BMP, JPG, TIF, etc.)

Return Value

Success: | the CLSID of the encoder in string format.
Failure: | an empty string and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetImageEncoders in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_aCodex, $g_hImage

Example()

Func Example()
    Local $hBitmap

    ; Create GUI
    GUICreate("GDI+", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Create an image to use for paramater lists
    $hBitmap = _ScreenCapture_Capture("", 0, 0, 1, 1)
    $g_hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; Show encoder parameters
    $g_aCodex = _GDIPlus_Encoders()
    ShowCodex("Encoder")

    ; Show decoder parameters
    $g_aCodex = _GDIPlus_Decoders()
    ShowCodex("Decoder")

    ; Clean up resources
    _GDIPlus_ImageDispose($g_hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Show codex information
Func ShowCodex($sTitle)
    Local $iI, $iJ, $iK, $sCLSID, $tData, $tParam, $tParams, $iParamSize = _GDIPlus_ParamSize()

    For $iI = 1 To $g_aCodex[0][0]
        $sCLSID = _GDIPlus_EncodersGetCLSID($g_aCodex[$iI][5])
        MemoWrite("Image " & $sTitle & " " & $iI)
        MemoWrite("  Codec GUID ............: " & $g_aCodex[$iI][1])
        MemoWrite("  File format GUID ......: " & $g_aCodex[$iI][2])
        MemoWrite("  Codec name ............: " & $g_aCodex[$iI][3])
        MemoWrite("  Codec Dll file name ...: " & $g_aCodex[$iI][4])
        MemoWrite("  Codec file format .....: " & $g_aCodex[$iI][5])
        MemoWrite("  File name extensions ..: " & $g_aCodex[$iI][6])
        MemoWrite("  Mime type .............: " & $g_aCodex[$iI][7])
        MemoWrite("  Flags .................: 0x" & Hex($g_aCodex[$iI][8]))
        MemoWrite("  Version ...............: " & $g_aCodex[$iI][9])
        MemoWrite("  Signature count .......: " & $g_aCodex[$iI][10])
        MemoWrite("  Signature size ........: " & $g_aCodex[$iI][11])
        MemoWrite("  Signature pattern ptr .: 0x" & Hex($g_aCodex[$iI][12]))
        MemoWrite("  Signature mask ptr ....: 0x" & Hex($g_aCodex[$iI][13]))

;~      If $sTitle = "Decoder" Then ContinueLoop

        MemoWrite("  Parameter list size ...: " & _GDIPlus_EncodersGetParamListSize($g_hImage, $sCLSID))

        $tParams = _GDIPlus_EncodersGetParamList($g_hImage, $sCLSID)
        If @error Then
            MemoWrite()
            ContinueLoop
        EndIf

        MemoWrite("  Parameters Count ......: " & DllStructGetData($tParams, "Count"))
        MemoWrite()
        For $iJ = 0 To DllStructGetData($tParams, "Count") - 1
            MemoWrite("  Image " & $sTitle & " " & $iI & " Parameter " & $iJ)
            $tParam = DllStructCreate($tagGDIPENCODERPARAM, DllStructGetPtr($tParams, "GUID") + ($iJ * $iParamSize))
            MemoWrite("    Parameter GUID ......: " & _WinAPI_StringFromGUID(DllStructGetPtr($tParam, "GUID")))
            MemoWrite("    Number of values ....: " & DllStructGetData($tParam, "NumberOfValues"))
            MemoWrite("    Parameter type.......: " & DllStructGetData($tParam, "Type"))
            MemoWrite("    Parameter pointer ...: 0x" & Hex(DllStructGetData($tParam, "Values")))
            Switch DllStructGetData($tParam, "Type")
                Case 4
                    $tData = DllStructCreate("int Data[" & DllStructGetData($tParam, "NumberOfValues") & "]", DllStructGetData($tParam, "Values"))
                    For $iK = 1 To DllStructGetData($tParam, "NumberOfValues")
                        MemoWrite("      Value .............: " & DllStructGetData($tData, 1, $iK))
                    Next
                Case 6
                    $tData = DllStructCreate("int Low;int High", DllStructGetData($tParam, "Values"))
                    MemoWrite("      Low range .........: " & DllStructGetData($tData, "Low"))
                    MemoWrite("      High range ........: " & DllStructGetData($tData, "High"))
            EndSwitch
            MemoWrite()
        Next
    Next
EndFunc   ;==>ShowCodex


Function _GDIPlus_EncodersGetCount

Function Reference

_GDIPlus_EncodersGetCount

Get the number of available image encoders

#include <GDIPlus.au3>
_GDIPlus_EncodersGetCount ( )

Return Value

Success: | the number of image encoders.
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_EncodersGetSize

See Also

Search GdipGetImageEncodersSize in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    ; Create GUI
    GUICreate("GDI+", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Show number of decoders/encoders
    MemoWrite("Decoder count : " & _GDIPlus_DecodersGetCount());
    MemoWrite("Decoder size .: " & _GDIPlus_DecodersGetSize());
    MemoWrite("Encoder count : " & _GDIPlus_EncodersGetCount());
    MemoWrite("Encoder size .: " & _GDIPlus_EncodersGetSize());

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GDIPlus_EncodersGetParamList

Function Reference

_GDIPlus_EncodersGetParamList

Get the parameter list for a specified image encoder

#include <GDIPlus.au3>
_GDIPlus_EncodersGetParamList ( $hImage, $sEncoder )

Parameters

$hImage | Handle to an image object
$sEncoder | GUID string of encoder to be used

Return Value

Success: | a $tagGDIPENCODERPARAMS structure.
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

See $tagGDIPENCODERPARAMS to understand how a specific $tagGDIPENCODERPARAM entry can be access.
You can also see the example.

Related

$tagGDIPENCODERPARAM, _GDIPlus_EncodersGetParamListSize

See Also

Search GdipGetEncoderParameterList in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_aCodex, $g_hImage

Example()

Func Example()
    Local $hBitmap

    ; Create GUI
    GUICreate("GDI+", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Create an image to use for paramater lists
    $hBitmap = _ScreenCapture_Capture("", 0, 0, 1, 1)
    $g_hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; Show encoder parameters
    $g_aCodex = _GDIPlus_Encoders()
    ShowCodex("Encoder")

    ; Show decoder parameters
    $g_aCodex = _GDIPlus_Decoders()
    ShowCodex("Decoder")

    ; Clean up resources
    _GDIPlus_ImageDispose($g_hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Show codex information
Func ShowCodex($sTitle)
    Local $iI, $iJ, $iK, $sCLSID, $tData, $tParam, $tParams, $iParamSize = _GDIPlus_ParamSize()

    For $iI = 1 To $g_aCodex[0][0]
        $sCLSID = _GDIPlus_EncodersGetCLSID($g_aCodex[$iI][5])
        MemoWrite("Image " & $sTitle & " " & $iI)
        MemoWrite("  Codec GUID ............: " & $g_aCodex[$iI][1])
        MemoWrite("  File format GUID ......: " & $g_aCodex[$iI][2])
        MemoWrite("  Codec name ............: " & $g_aCodex[$iI][3])
        MemoWrite("  Codec Dll file name ...: " & $g_aCodex[$iI][4])
        MemoWrite("  Codec file format .....: " & $g_aCodex[$iI][5])
        MemoWrite("  File name extensions ..: " & $g_aCodex[$iI][6])
        MemoWrite("  Mime type .............: " & $g_aCodex[$iI][7])
        MemoWrite("  Flags .................: 0x" & Hex($g_aCodex[$iI][8]))
        MemoWrite("  Version ...............: " & $g_aCodex[$iI][9])
        MemoWrite("  Signature count .......: " & $g_aCodex[$iI][10])
        MemoWrite("  Signature size ........: " & $g_aCodex[$iI][11])
        MemoWrite("  Signature pattern ptr .: 0x" & Hex($g_aCodex[$iI][12]))
        MemoWrite("  Signature mask ptr ....: 0x" & Hex($g_aCodex[$iI][13]))

;~      If $sTitle = "Decoder" Then ContinueLoop

        MemoWrite("  Parameter list size ...: " & _GDIPlus_EncodersGetParamListSize($g_hImage, $sCLSID))

        $tParams = _GDIPlus_EncodersGetParamList($g_hImage, $sCLSID)
        If @error Then
            MemoWrite()
            ContinueLoop
        EndIf

        MemoWrite("  Parameters Count ......: " & DllStructGetData($tParams, "Count"))
        MemoWrite()
        For $iJ = 0 To DllStructGetData($tParams, "Count") - 1
            MemoWrite("  Image " & $sTitle & " " & $iI & " Parameter " & $iJ)
            $tParam = DllStructCreate($tagGDIPENCODERPARAM, DllStructGetPtr($tParams, "GUID") + ($iJ * $iParamSize))
            MemoWrite("    Parameter GUID ......: " & _WinAPI_StringFromGUID(DllStructGetPtr($tParam, "GUID")))
            MemoWrite("    Number of values ....: " & DllStructGetData($tParam, "NumberOfValues"))
            MemoWrite("    Parameter type.......: " & DllStructGetData($tParam, "Type"))
            MemoWrite("    Parameter pointer ...: 0x" & Hex(DllStructGetData($tParam, "Values")))
            Switch DllStructGetData($tParam, "Type")
                Case 4
                    $tData = DllStructCreate("int Data[" & DllStructGetData($tParam, "NumberOfValues") & "]", DllStructGetData($tParam, "Values"))
                    For $iK = 1 To DllStructGetData($tParam, "NumberOfValues")
                        MemoWrite("      Value .............: " & DllStructGetData($tData, 1, $iK))
                    Next
                Case 6
                    $tData = DllStructCreate("int Low;int High", DllStructGetData($tParam, "Values"))
                    MemoWrite("      Low range .........: " & DllStructGetData($tData, "Low"))
                    MemoWrite("      High range ........: " & DllStructGetData($tData, "High"))
            EndSwitch
            MemoWrite()
        Next
    Next
EndFunc   ;==>ShowCodex


Function _GDIPlus_EncodersGetParamListSize

Function Reference

_GDIPlus_EncodersGetParamListSize

Get the size of the parameter list for a specified image encoder

#include <GDIPlus.au3>
_GDIPlus_EncodersGetParamListSize ( $hImage, $sEncoder )

Parameters

$hImage | Handle to an image object
$sEncoder | GUID string of encoder to be used

Return Value

Success: | the size, in bytes, of the parameter list.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_EncodersGetParamList

See Also

Search GdipGetEncoderParameterListSize in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_aCodex, $g_hImage

Example()

Func Example()
    Local $hBitmap

    ; Create GUI
    GUICreate("GDI+", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Create an image to use for paramater lists
    $hBitmap = _ScreenCapture_Capture("", 0, 0, 1, 1)
    $g_hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; Show encoder parameters
    $g_aCodex = _GDIPlus_Encoders()
    ShowCodex("Encoder")

    ; Show decoder parameters
    $g_aCodex = _GDIPlus_Decoders()
    ShowCodex("Decoder")

    ; Clean up resources
    _GDIPlus_ImageDispose($g_hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Show codex information
Func ShowCodex($sTitle)
    Local $iI, $iJ, $iK, $sCLSID, $tData, $tParam, $tParams, $iParamSize = _GDIPlus_ParamSize()

    For $iI = 1 To $g_aCodex[0][0]
        $sCLSID = _GDIPlus_EncodersGetCLSID($g_aCodex[$iI][5])
        MemoWrite("Image " & $sTitle & " " & $iI)
        MemoWrite("  Codec GUID ............: " & $g_aCodex[$iI][1])
        MemoWrite("  File format GUID ......: " & $g_aCodex[$iI][2])
        MemoWrite("  Codec name ............: " & $g_aCodex[$iI][3])
        MemoWrite("  Codec Dll file name ...: " & $g_aCodex[$iI][4])
        MemoWrite("  Codec file format .....: " & $g_aCodex[$iI][5])
        MemoWrite("  File name extensions ..: " & $g_aCodex[$iI][6])
        MemoWrite("  Mime type .............: " & $g_aCodex[$iI][7])
        MemoWrite("  Flags .................: 0x" & Hex($g_aCodex[$iI][8]))
        MemoWrite("  Version ...............: " & $g_aCodex[$iI][9])
        MemoWrite("  Signature count .......: " & $g_aCodex[$iI][10])
        MemoWrite("  Signature size ........: " & $g_aCodex[$iI][11])
        MemoWrite("  Signature pattern ptr .: 0x" & Hex($g_aCodex[$iI][12]))
        MemoWrite("  Signature mask ptr ....: 0x" & Hex($g_aCodex[$iI][13]))

;~      If $sTitle = "Decoder" Then ContinueLoop

        MemoWrite("  Parameter list size ...: " & _GDIPlus_EncodersGetParamListSize($g_hImage, $sCLSID))

        $tParams = _GDIPlus_EncodersGetParamList($g_hImage, $sCLSID)
        If @error Then
            MemoWrite()
            ContinueLoop
        EndIf

        MemoWrite("  Parameters Count ......: " & DllStructGetData($tParams, "Count"))
        MemoWrite()
        For $iJ = 0 To DllStructGetData($tParams, "Count") - 1
            MemoWrite("  Image " & $sTitle & " " & $iI & " Parameter " & $iJ)
            $tParam = DllStructCreate($tagGDIPENCODERPARAM, DllStructGetPtr($tParams, "GUID") + ($iJ * $iParamSize))
            MemoWrite("    Parameter GUID ......: " & _WinAPI_StringFromGUID(DllStructGetPtr($tParam, "GUID")))
            MemoWrite("    Number of values ....: " & DllStructGetData($tParam, "NumberOfValues"))
            MemoWrite("    Parameter type.......: " & DllStructGetData($tParam, "Type"))
            MemoWrite("    Parameter pointer ...: 0x" & Hex(DllStructGetData($tParam, "Values")))
            Switch DllStructGetData($tParam, "Type")
                Case 4
                    $tData = DllStructCreate("int Data[" & DllStructGetData($tParam, "NumberOfValues") & "]", DllStructGetData($tParam, "Values"))
                    For $iK = 1 To DllStructGetData($tParam, "NumberOfValues")
                        MemoWrite("      Value .............: " & DllStructGetData($tData, 1, $iK))
                    Next
                Case 6
                    $tData = DllStructCreate("int Low;int High", DllStructGetData($tParam, "Values"))
                    MemoWrite("      Low range .........: " & DllStructGetData($tData, "Low"))
                    MemoWrite("      High range ........: " & DllStructGetData($tData, "High"))
            EndSwitch
            MemoWrite()
        Next
    Next
EndFunc   ;==>ShowCodex


Function _GDIPlus_EncodersGetSize

Function Reference

_GDIPlus_EncodersGetSize

Get the total size of the structure that is returned by _GDIPlus_GetImageEncoders

#include <GDIPlus.au3>
_GDIPlus_EncodersGetSize ( )

Return Value

Success: | the total size, in bytes.
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_EncodersGetCount

See Also

Search GdipGetImageEncodersSize in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    ; Create GUI
    GUICreate("GDI+", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Show number of decoders/encoders
    MemoWrite("Decoder count : " & _GDIPlus_DecodersGetCount());
    MemoWrite("Decoder size .: " & _GDIPlus_DecodersGetSize());
    MemoWrite("Encoder count : " & _GDIPlus_EncodersGetCount());
    MemoWrite("Encoder size .: " & _GDIPlus_EncodersGetSize());

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GDIPlus_ParamAdd

Function Reference

_GDIPlus_ParamAdd

Add a value to an encoder parameter list

#include <GDIPlus.au3>
_GDIPlus_ParamAdd ( ByRef $tParams, $sGUID, $iNbOfValues, $iType, $pValues )

Parameters

$tParams | $tagGDIPENCODERPARAMS structure returned from _GDIPlus_ParamInit()
$sGUID | Encoder parameter GUID. Can be one of the following: $GDIP_EPGCHROMINANCETABLE - Chrominance table settings $GDIP_EPGCOLORDEPTH - Color depth settings $GDIP_EPGCOMPRESSION - Compression settings $GDIP_EPGLUMINANCETABLE - Luminance table settings $GDIP_EPGQUALITY - Quality settings $GDIP_EPGRENDERMETHOD - Render method settings $GDIP_EPGSAVEFLAG - Save flag settings $GDIP_EPGSCANMETHOD - Scan mode settings $GDIP_EPGTRANSFORMATION - Transformation settings $GDIP_EPGVERSION - Software version settings
$iNbOfValues | Number of elements in the $pValues array
$iType | Encoder parameter value type. Can be one of the following: $GDIP_EPTBYTE - 8 bit unsigned integer $GDIP_EPTASCII - Null terminated character string $GDIP_EPTSHORT - 16 bit unsigned integer $GDIP_EPTLONG - 32 bit unsigned integer $GDIP_EPTRATIONAL - Two longs (numerator, denominator) $GDIP_EPTLONGRANGE - Two longs (low, high) $GDIP_EPTUNDEFINED - Array of bytes of any type $GDIP_EPTRATIONALRANGE - Two longs (low, high)
$pValues | Pointer to an array of values. Each value has the type specified by the $iType data member.

Return Value

None.

Related

$tagGDIPENCODERPARAMS, _GDIPlus_ParamInit

Example

#include <GDIPlus.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    Local $hImage, $sCLSID, $tData, $tParams

    ; Capture screen
    _ScreenCapture_Capture(@MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Load image
    $hImage = _GDIPlus_ImageLoadFromFile(@MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Get JPEG encoder CLSID
    $sCLSID = _GDIPlus_EncodersGetCLSID("JPG")

    ; Set up parameters for 90 degree rotation
    $tData = DllStructCreate("int Data")
    DllStructSetData($tData, "Data", $GDIP_EVTTRANSFORMROTATE90)
    $tParams = _GDIPlus_ParamInit(1)
    _GDIPlus_ParamAdd($tParams, $GDIP_EPGTRANSFORMATION, 1, $GDIP_EPTLONG, DllStructGetPtr($tData, "Data"))

    ; Save image with rotation
    _GDIPlus_ImageSaveToFileEx($hImage, @MyDocumentsDir & "\GDIPlus_Image2.jpg", $sCLSID, $tParams)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image2.jpg")
EndFunc   ;==>Example


Function _GDIPlus_ParamInit

Function Reference

_GDIPlus_ParamInit

Allocate an empty encoder parameter list

#include <GDIPlus.au3>
_GDIPlus_ParamInit ( $iCount )

Parameters

$iCount The total number of $tagGDIPENCODERPARAM that the list can contain

Return Value

Success: | a $tagGDIPENCODERPARAMS structure.
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

In order to pass parameters to any of the encoder functions, you must use an encoder parameter list.
This function is used to allocate an encoder parameter list that can then be passed to _GDIPlus_ParamAdd() to add the actual parameters.

Related

$tagGDIPENCODERPARAM, $tagGDIPENCODERPARAMS, _GDIPlus_ParamAdd

Example

#include <GDIPlus.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    Local $hImage, $sCLSID, $tData, $tParams

    ; Capture screen
    _ScreenCapture_Capture(@MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Load image
    $hImage = _GDIPlus_ImageLoadFromFile(@MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Get JPEG encoder CLSID
    $sCLSID = _GDIPlus_EncodersGetCLSID("JPG")

    ; Set up parameters for 90 degree rotation
    $tData = DllStructCreate("int Data")
    DllStructSetData($tData, "Data", $GDIP_EVTTRANSFORMROTATE90)
    $tParams = _GDIPlus_ParamInit(1)
    _GDIPlus_ParamAdd($tParams, $GDIP_EPGTRANSFORMATION, 1, $GDIP_EPTLONG, DllStructGetPtr($tData, "Data"))

    ; Save image with rotation
    _GDIPlus_ImageSaveToFileEx($hImage, @MyDocumentsDir & "\GDIPlus_Image2.jpg", $sCLSID, $tParams)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image2.jpg")
EndFunc   ;==>Example


Function _GDIPlus_ParamSize

Function Reference

_GDIPlus_ParamSize

Get an encoder parameter size

#include <GDIPlus.au3>
_GDIPlus_ParamSize ( )

Return Value

Returns the size of $tagGDIPENCODERPARAM structure. Take care of the x86/X64 dependancy.

Remarks

Useful when retrieving entries in a $tagGDIPENCODERPARAMS structure.

Related

$tagGDIPENCODERPARAM, $tagGDIPENCODERPARAMS, _GDIPlus_ParamAdd

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_aCodex, $g_hImage

Example()

Func Example()
    Local $hBitmap

    ; Create GUI
    GUICreate("GDI+", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Create an image to use for paramater lists
    $hBitmap = _ScreenCapture_Capture("", 0, 0, 1, 1)
    $g_hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; Show encoder parameters
    $g_aCodex = _GDIPlus_Encoders()
    ShowCodex("Encoder")

    ; Show decoder parameters
    $g_aCodex = _GDIPlus_Decoders()
    ShowCodex("Decoder")

    ; Clean up resources
    _GDIPlus_ImageDispose($g_hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Show codex information
Func ShowCodex($sTitle)
    Local $iI, $iJ, $iK, $sCLSID, $tData, $tParam, $tParams, $iParamSize = _GDIPlus_ParamSize()

    For $iI = 1 To $g_aCodex[0][0]
        $sCLSID = _GDIPlus_EncodersGetCLSID($g_aCodex[$iI][5])
        MemoWrite("Image " & $sTitle & " " & $iI)
        MemoWrite("  Codec GUID ............: " & $g_aCodex[$iI][1])
        MemoWrite("  File format GUID ......: " & $g_aCodex[$iI][2])
        MemoWrite("  Codec name ............: " & $g_aCodex[$iI][3])
        MemoWrite("  Codec Dll file name ...: " & $g_aCodex[$iI][4])
        MemoWrite("  Codec file format .....: " & $g_aCodex[$iI][5])
        MemoWrite("  File name extensions ..: " & $g_aCodex[$iI][6])
        MemoWrite("  Mime type .............: " & $g_aCodex[$iI][7])
        MemoWrite("  Flags .................: 0x" & Hex($g_aCodex[$iI][8]))
        MemoWrite("  Version ...............: " & $g_aCodex[$iI][9])
        MemoWrite("  Signature count .......: " & $g_aCodex[$iI][10])
        MemoWrite("  Signature size ........: " & $g_aCodex[$iI][11])
        MemoWrite("  Signature pattern ptr .: 0x" & Hex($g_aCodex[$iI][12]))
        MemoWrite("  Signature mask ptr ....: 0x" & Hex($g_aCodex[$iI][13]))

;~      If $sTitle = "Decoder" Then ContinueLoop

        MemoWrite("  Parameter list size ...: " & _GDIPlus_EncodersGetParamListSize($g_hImage, $sCLSID))

        $tParams = _GDIPlus_EncodersGetParamList($g_hImage, $sCLSID)
        If @error Then
            MemoWrite()
            ContinueLoop
        EndIf

        MemoWrite("  Parameters Count ......: " & DllStructGetData($tParams, "Count"))
        MemoWrite()
        For $iJ = 0 To DllStructGetData($tParams, "Count") - 1
            MemoWrite("  Image " & $sTitle & " " & $iI & " Parameter " & $iJ)
            $tParam = DllStructCreate($tagGDIPENCODERPARAM, DllStructGetPtr($tParams, "GUID") + ($iJ * $iParamSize))
            MemoWrite("    Parameter GUID ......: " & _WinAPI_StringFromGUID(DllStructGetPtr($tParam, "GUID")))
            MemoWrite("    Number of values ....: " & DllStructGetData($tParam, "NumberOfValues"))
            MemoWrite("    Parameter type.......: " & DllStructGetData($tParam, "Type"))
            MemoWrite("    Parameter pointer ...: 0x" & Hex(DllStructGetData($tParam, "Values")))
            Switch DllStructGetData($tParam, "Type")
                Case 4
                    $tData = DllStructCreate("int Data[" & DllStructGetData($tParam, "NumberOfValues") & "]", DllStructGetData($tParam, "Values"))
                    For $iK = 1 To DllStructGetData($tParam, "NumberOfValues")
                        MemoWrite("      Value .............: " & DllStructGetData($tData, 1, $iK))
                    Next
                Case 6
                    $tData = DllStructCreate("int Low;int High", DllStructGetData($tParam, "Values"))
                    MemoWrite("      Low range .........: " & DllStructGetData($tData, "Low"))
                    MemoWrite("      High range ........: " & DllStructGetData($tData, "High"))
            EndSwitch
            MemoWrite()
        Next
    Next
EndFunc   ;==>ShowCodex


User Defined Functions

GraphicsPath user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_PathAddArc | Adds an elliptical arc to the current figure of a path
_GDIPlus_PathAddBezier | Adds a bezier spline to the current figure of a path
_GDIPlus_PathAddClosedCurve | Adds a closed cardinal spline to a path
_GDIPlus_PathAddClosedCurve2 | Adds a closed cardinal spline to a path
_GDIPlus_PathAddCurve | Adds a cardinal spline to the current figure of a path
_GDIPlus_PathAddCurve2 | Adds a cardinal spline to the current figure of a path
_GDIPlus_PathAddCurve3 | Adds a cardinal spline to the current figure of a path
_GDIPlus_PathAddEllipse | Adds an ellipse to the current figure a path
_GDIPlus_PathAddLine | Adds a line to the current figure of a path
_GDIPlus_PathAddLine2 | Adds a sequence of lines to the current figure of a path
_GDIPlus_PathAddPath | Adds a path to another path
_GDIPlus_PathAddPie | Adds a pie to a path
_GDIPlus_PathAddPolygon | Adds a polygon to a path
_GDIPlus_PathAddRectangle | Adds a rectangle to a path
_GDIPlus_PathAddString | Adds the outline of a string to a path
_GDIPlus_PathClone | Clones a path
_GDIPlus_PathCloseFigure | Closes the current figure of a path
_GDIPlus_PathCreate | Creates a GraphicsPath object and initializes the fill mode
_GDIPlus_PathCreate2 | Creates a GraphicsPath object based on an array of points, an array of types, and a fill mode
_GDIPlus_PathDispose | Releases a GraphicsPath object
_GDIPlus_PathFlatten | Applies a transformation to a path and converts each curve in the path to a sequence of connected lines
_GDIPlus_PathGetData | Gets an array of points and types from a path
_GDIPlus_PathGetFillMode | Gets the fill mode of a path
_GDIPlus_PathGetLastPoint | Gets the ending point of the last figure in a path
_GDIPlus_PathGetPointCount | Gets the number of points in a path's array of data points
_GDIPlus_PathGetPoints | Gets an array of points from a path
_GDIPlus_PathGetWorldBounds | Gets the bounding rectangle for a path
_GDIPlus_PathIsOutlineVisiblePoint | Determines whether a specified point touches the outline of a path with the specified Graphics and Pen
_GDIPlus_PathIsVisiblePoint | Determines whether a specified point lies in the area that is filled when a path is filled by a specified Graphics object
_GDIPlus_PathReset | Empties a path and sets the fill mode to alternate (0)
_GDIPlus_PathReverse | Reverses the order of the points that define a path's lines and curves
_GDIPlus_PathSetFillMode | Sets the fill mode of a path
_GDIPlus_PathSetMarker | Designates the last point in a path as a marker point
_GDIPlus_PathStartFigure | Starts a new figure without closing the current figure. Subsequent points added to a path are added to the new figure
_GDIPlus_PathTransform | Multiplies each of a path's data points by a specified matrix
_GDIPlus_PathWarp | Applies a warp transformation to a path. The function also flattens (converts to a sequence of straight lines) the path
_GDIPlus_PathWiden | Replaces a path with curves that enclose the area that is filled when the path is drawn by a specified pen. The function also flattens the path
_GDIPlus_PathWindingModeOutline | Transforms and flattens a path, and then converts the path's data points so that they represent only the outline of the path


Function _GDIPlus_PathAddArc

Function Reference

_GDIPlus_PathAddArc

Adds an elliptical arc to the current figure of a path

#include <GDIPlus.au3>
_GDIPlus_PathAddArc ( $hPath, $nX, $nY, $nWidth, $nHeight, $fStartAngle, $fSweepAngle )

Parameters

$hPath | Pointer to a GraphicsPath object
$nX | X coordinate of the upper-left corner of the ellipse that contains the arc
$nY | Y coordinate of the upper-left corner of the ellipse that contains the arc
$nWidth | Width of the bounding rectangle for the ellipse that contains the arc
$nHeight | Height of the bounding rectangle for the ellipse that contains the arc
$fStartAngle | The angle, in degrees, between the X axis and the starting point of the arc
$fSweepAngle | The angle, in degrees, between the starting and ending points of the arc

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipAddPathArc in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPen, $hPath

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)
    $hPen = _GDIPlus_PenCreate(0xFF8800AA, 2)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    _GDIPlus_PathAddArc($hPath, 50, 50, 100, 100, 180, 180)
    _GDIPlus_PathAddArc($hPath, 50, 150, 100, 100, 0, 180)
    _GDIPlus_PathCloseFigure($hPath) ;connect last point of arc2 to first point of arc1

    _GDIPlus_PathAddArc($hPath, 250, 50, 100, 100, 180, 180)
    _GDIPlus_PathCloseFigure($hPath) ;do not connect arcs
    _GDIPlus_PathAddArc($hPath, 250, 150, 100, 100, 0, 180)
    _GDIPlus_PathCloseFigure($hPath) ;connect last point of arc2 to first point of arc2

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathAddBezier

Function Reference

_GDIPlus_PathAddBezier

Adds a bezier spline to the current figure of a path

#include <GDIPlus.au3>
_GDIPlus_PathAddBezier ( $hPath, $nX1, $nY1, $nX2, $nY2, $nX3, $nY3, $nX4, $nY4 )

Parameters

$hPath | Pointer to a GraphicsPath object
$nX1 | X coordinate of the starting point
$nY1 | Y coordinate of the starting point
$nX2 | X coordinate of the first control point
$nY2 | Y coordinate of the first control point
$nX3 | X coordinate of the second control point
$nY3 | Y coordinate of the second control point
$nX4 | X coordinate of the ending point
$nY4 | Y coordinate of the ending point

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

A Bezier spline does not pass through its control points. The control points act as magnets, pulling the curve in certain directions to influence the way the spline bends.

See Also

Search GdipAddPathBezier in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen, $hPath

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hPen = _GDIPlus_PenCreate(0xFF8800AA, 2)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    _GDIPlus_PathAddBezier($hPath, 10, 10, 50, 200, 300, 10, 390, 290)

    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathAddClosedCurve

Function Reference

_GDIPlus_PathAddClosedCurve

Adds a closed cardinal spline to a path

#include <GDIPlus.au3>
_GDIPlus_PathAddClosedCurve ( $hPath, $aPoints )

Parameters

$hPath | Pointer to a GraphicsPath object
$aPoints | Array of points that define the cardinal spline: [0][0] - Number of points [1][0] - Point 1 X position [1][1] - Point 1 Y position [2][0] - Point 2 X position [2][1] - Point 2 Y position [n][0] - Point n X position [n][1] - Point n Y position

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

A cardinal spline is a curve that passes through each point in the array.

See Also

Search GdipAddPathClosedCurve in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPen, $hPen2, $hPath

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 300)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)
    $hPen = _GDIPlus_PenCreate(0xFF8800AA, 2)
    $hPen2 = _GDIPlus_PenCreate(0xFFFF0000, 2)

    Local $aPoints[5][2] = [[4]]
    $aPoints[1][0] = 10
    $aPoints[1][1] = 70
    $aPoints[2][0] = 60
    $aPoints[2][1] = 50
    $aPoints[3][0] = 110
    $aPoints[3][1] = 120
    $aPoints[4][0] = 160
    $aPoints[4][1] = 80

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    _GDIPlus_GraphicsDrawString($hGraphic, "Curve", $aPoints[1][0], 20)
    _GDIPlus_PathAddCurve($hPath, $aPoints)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "ClosedCurve", $aPoints[1][0], 20)
    _GDIPlus_PathAddClosedCurve($hPath, $aPoints)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "Curve2 tension = 0.8", $aPoints[1][0], 20)
    _GDIPlus_PathAddCurve2($hPath, $aPoints, 0.8)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "ClosedCurve2 tension = 0.8", $aPoints[1][0], 20)
    _GDIPlus_PathAddClosedCurve2($hPath, $aPoints, 0.8)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] -= 500
        $aPoints[$i][1] += 140
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "Curve2 tension = 0", $aPoints[1][0], 160)
    _GDIPlus_PathAddCurve2($hPath, $aPoints, 0)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "ClosedCurve2 tension = 0", $aPoints[1][0], 160)
    _GDIPlus_PathAddClosedCurve2($hPath, $aPoints, 0)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "Polygon", $aPoints[1][0], 160)
    _GDIPlus_PathAddPolygon($hPath, $aPoints)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
    Next

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathAddClosedCurve2

Function Reference

_GDIPlus_PathAddClosedCurve2

Adds a closed cardinal spline to a path

#include <GDIPlus.au3>
_GDIPlus_PathAddClosedCurve2 ( $hPath, $aPoints [, $nTension = 0.5] )

Parameters

$hPath | Pointer to a GraphicsPath object
$aPoints | Array of points that define the cardinal spline: [0][0] - Number of points [1][0] - Point 1 X position [1][1] - Point 1 Y position [2][0] - Point 2 X position [2][1] - Point 2 Y position [n][0] - Point n X position [n][1] - Point n Y position
$nTension | [optional] Nonnegative real number that controls the length of the curve and how the curve bends. A value of 0 specifies that the spline is a sequence of straight lines. As the value increases, the curve becomes fuller.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

A cardinal spline is a curve that passes through each point in the array.

Related

_GDIPlus_PathAddClosedCurve

See Also

Search GdipAddPathClosedCurve2 in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPen, $hPen2, $hPath

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 300)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)
    $hPen = _GDIPlus_PenCreate(0xFF8800AA, 2)
    $hPen2 = _GDIPlus_PenCreate(0xFFFF0000, 2)

    Local $aPoints[5][2] = [[4]]
    $aPoints[1][0] = 10
    $aPoints[1][1] = 70
    $aPoints[2][0] = 60
    $aPoints[2][1] = 50
    $aPoints[3][0] = 110
    $aPoints[3][1] = 120
    $aPoints[4][0] = 160
    $aPoints[4][1] = 80

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    _GDIPlus_GraphicsDrawString($hGraphic, "Curve", $aPoints[1][0], 20)
    _GDIPlus_PathAddCurve($hPath, $aPoints)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "ClosedCurve", $aPoints[1][0], 20)
    _GDIPlus_PathAddClosedCurve($hPath, $aPoints)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "Curve2 tension = 0.8", $aPoints[1][0], 20)
    _GDIPlus_PathAddCurve2($hPath, $aPoints, 0.8)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "ClosedCurve2 tension = 0.8", $aPoints[1][0], 20)
    _GDIPlus_PathAddClosedCurve2($hPath, $aPoints, 0.8)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] -= 500
        $aPoints[$i][1] += 140
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "Curve2 tension = 0", $aPoints[1][0], 160)
    _GDIPlus_PathAddCurve2($hPath, $aPoints, 0)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "ClosedCurve2 tension = 0", $aPoints[1][0], 160)
    _GDIPlus_PathAddClosedCurve2($hPath, $aPoints, 0)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "Polygon", $aPoints[1][0], 160)
    _GDIPlus_PathAddPolygon($hPath, $aPoints)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
    Next

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathAddCurve

Function Reference

_GDIPlus_PathAddCurve

Adds a cardinal spline to the current figure of a path

#include <GDIPlus.au3>
_GDIPlus_PathAddCurve ( $hPath, $aPoints )

Parameters

$hPath | Pointer to a GraphicsPath object
$aPoints | Array of points that define the cardinal spline: [0][0] - Number of points [1][0] - Point 1 X position [1][1] - Point 1 Y position [2][0] - Point 2 X position [2][1] - Point 2 Y position [n][0] - Point n X position [n][1] - Point n Y position

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

A cardinal spline is a curve that passes through each point in the array.

Related

_GDIPlus_PathAddCurve2

See Also

Search GdipAddPathCurve in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPen, $hPen2, $hPath

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 300)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)
    $hPen = _GDIPlus_PenCreate(0xFF8800AA, 2)
    $hPen2 = _GDIPlus_PenCreate(0xFFFF0000, 2)

    Local $aPoints[5][2] = [[4]]
    $aPoints[1][0] = 10
    $aPoints[1][1] = 70
    $aPoints[2][0] = 60
    $aPoints[2][1] = 50
    $aPoints[3][0] = 110
    $aPoints[3][1] = 120
    $aPoints[4][0] = 160
    $aPoints[4][1] = 80

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    _GDIPlus_GraphicsDrawString($hGraphic, "Curve", $aPoints[1][0], 20)
    _GDIPlus_PathAddCurve($hPath, $aPoints)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "ClosedCurve", $aPoints[1][0], 20)
    _GDIPlus_PathAddClosedCurve($hPath, $aPoints)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "Curve2 tension = 0.8", $aPoints[1][0], 20)
    _GDIPlus_PathAddCurve2($hPath, $aPoints, 0.8)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "ClosedCurve2 tension = 0.8", $aPoints[1][0], 20)
    _GDIPlus_PathAddClosedCurve2($hPath, $aPoints, 0.8)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] -= 500
        $aPoints[$i][1] += 140
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "Curve2 tension = 0", $aPoints[1][0], 160)
    _GDIPlus_PathAddCurve2($hPath, $aPoints, 0)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "ClosedCurve2 tension = 0", $aPoints[1][0], 160)
    _GDIPlus_PathAddClosedCurve2($hPath, $aPoints, 0)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "Polygon", $aPoints[1][0], 160)
    _GDIPlus_PathAddPolygon($hPath, $aPoints)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
    Next

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathAddCurve2

Function Reference

_GDIPlus_PathAddCurve2

Adds a cardinal spline to the current figure of a path

#include <GDIPlus.au3>
_GDIPlus_PathAddCurve2 ( $hPath, $aPoints [, $nTension = 0.5] )

Parameters

$hPath | Pointer to a GraphicsPath object
$aPoints | Array of points that define the cardinal spline: [0][0] - Number of points [1][0] - Point 1 X position [1][1] - Point 1 Y position [2][0] - Point 2 X position [2][1] - Point 2 Y position [n][0] - Point n X position [n][1] - Point n Y position
$nTension | [optional] Nonnegative real number that controls the length of the curve and how the curve bends. A value of 0 specifies that the spline is a sequence of straight lines. As the value increases, the curve becomes fuller.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

A cardinal spline is a curve that passes through each point in the array.

Related

_GDIPlus_PathAddCurve

See Also

Search GdipAddPathCurve2 in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPen, $hPen2, $hPath

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 300)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)
    $hPen = _GDIPlus_PenCreate(0xFF8800AA, 2)
    $hPen2 = _GDIPlus_PenCreate(0xFFFF0000, 2)

    Local $aPoints[5][2] = [[4]]
    $aPoints[1][0] = 10
    $aPoints[1][1] = 70
    $aPoints[2][0] = 60
    $aPoints[2][1] = 50
    $aPoints[3][0] = 110
    $aPoints[3][1] = 120
    $aPoints[4][0] = 160
    $aPoints[4][1] = 80

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    _GDIPlus_GraphicsDrawString($hGraphic, "Curve", $aPoints[1][0], 20)
    _GDIPlus_PathAddCurve($hPath, $aPoints)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "ClosedCurve", $aPoints[1][0], 20)
    _GDIPlus_PathAddClosedCurve($hPath, $aPoints)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "Curve2 tension = 0.8", $aPoints[1][0], 20)
    _GDIPlus_PathAddCurve2($hPath, $aPoints, 0.8)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "ClosedCurve2 tension = 0.8", $aPoints[1][0], 20)
    _GDIPlus_PathAddClosedCurve2($hPath, $aPoints, 0.8)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] -= 500
        $aPoints[$i][1] += 140
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "Curve2 tension = 0", $aPoints[1][0], 160)
    _GDIPlus_PathAddCurve2($hPath, $aPoints, 0)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "ClosedCurve2 tension = 0", $aPoints[1][0], 160)
    _GDIPlus_PathAddClosedCurve2($hPath, $aPoints, 0)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "Polygon", $aPoints[1][0], 160)
    _GDIPlus_PathAddPolygon($hPath, $aPoints)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
    Next

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathAddCurve3

Function Reference

_GDIPlus_PathAddCurve3

Adds a cardinal spline to the current figure of a path

#include <GDIPlus.au3>
_GDIPlus_PathAddCurve3 ( $hPath, $aPoints, $iOffset, $iNumOfSegments [, $nTension = 0.5] )

Parameters

$hPath | Pointer to a GraphicsPath object
$aPoints | Array of points that define the cardinal spline: [0][0] - Number of points [1][0] - Point 1 X position [1][1] - Point 1 Y position [2][0] - Point 2 X position [2][1] - Point 2 Y position [n][0] - Point n X position [n][1] - Point n Y position
$iOffset | The index of the array element that is used as the first point of the cardinal spline, this is the index of the specific point in the array minus 1
$iNumOfSegments | Number of segments in the cardinal spline. Segments are the curves that connect consecutive points in the array
$nTension | [optional] Nonnegative real number that controls the length of the curve and how the curve bends. As the value increases, the curve becomes fuller.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

The cardinal spline is a curve that passes through a subset (specified by the $iOffset and $iNumOfSegments parameters) of the points in the array

Related

_GDIPlus_PathAddCurve, _GDIPlus_PathAddCurve2

See Also

Search GdipAddPathCurve3 in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Global $g_hGUI, $g_hGraphics, $g_hBmp_Buffer, $g_hGfx_Buffer, $g_hPen, $g_hPen2, $g_hPath, $g_hPath2

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    Local Const $iW = 400, $iH = 400

    $g_hGUI = GUICreate("GDI+", $iW, $iH)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;Create a graphics object from a window handle
    $g_hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $g_hGraphics)
    $g_hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($g_hBmp_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfx_Buffer, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)

    $g_hPen = _GDIPlus_PenCreate(0xFF8800AA, 2)
    $g_hPen2 = _GDIPlus_PenCreate(0xFFFFDD00, 3)

    $g_hPath = _GDIPlus_PathCreate() ;Create new path object

    Local $aPoints[201][2] = [[200]], $iRadius = 0
    For $i = 1 To $aPoints[0][0]
        $aPoints[$i][0] = Cos($i / 3.14) * $iRadius + $iW / 2
        $aPoints[$i][1] = Sin($i / 3.14) * $iRadius + $iH / 2
        $iRadius += 1
    Next

    _GDIPlus_PathAddCurve($g_hPath, $aPoints)

    $g_hPath2 = _GDIPlus_PathCreate() ;Create new path object
    Local $iOff = 1, $iNum = 4
    While Sleep(20)
        _GDIPlus_PathReset($g_hPath2)
        _GDIPlus_PathAddCurve3($g_hPath2, $aPoints, $iOff, $iNum)

        $iOff += 1
        If $iOff > $aPoints[0][0] - $iNum Then $iOff = 1

        _GDIPlus_GraphicsClear($g_hGfx_Buffer, 0xFF000000)
        _GDIPlus_GraphicsDrawPath($g_hGfx_Buffer, $g_hPath, $g_hPen) ;Draw path to graphics handle (GUI)
        _GDIPlus_GraphicsDrawPath($g_hGfx_Buffer, $g_hPath2, $g_hPen2) ;Draw path to graphics handle (GUI)
        _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBmp_Buffer, 0, 0)
    WEnd
EndFunc   ;==>Example

Func _Exit()
    ; Clean up resources
    _GDIPlus_PathDispose($g_hPath)
    _GDIPlus_PathDispose($g_hPath2)
    _GDIPlus_PenDispose($g_hPen)
    _GDIPlus_PenDispose($g_hPen2)
    _GDIPlus_GraphicsDispose($g_hGfx_Buffer)
    _GDIPlus_BitmapDispose($g_hBmp_Buffer)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_PathAddEllipse

Function Reference

_GDIPlus_PathAddEllipse

Adds an ellipse to the current figure a path

#include <GDIPlus.au3>
_GDIPlus_PathAddEllipse ( $hPath, $nX, $nY, $nWidth, $nHeight )

Parameters

$hPath | Pointer to a GraphicsPath object
$nX | The X coordinate of the upper left corner of the rectangle that bounds the ellipse
$nY | The Y coordinate of the upper left corner of the rectangle that bounds the ellipse
$nWidth | The width of the rectangle that bounds the ellipse
$nHeight | The height of the rectangle that bounds the ellipse

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipAddPathEllipse in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen1, $hPen2, $hPath, $aPoints

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hPen1 = _GDIPlus_PenCreate(0xFFFFBB00, 2)
    $hPen2 = _GDIPlus_PenCreate(0xFF0000FF, 2)

    ; original ellipse
    _GDIPlus_GraphicsDrawString($hGraphic, "original ellipse as bezier points", 10, 10)

    $hPath = _GDIPlus_PathCreate() ;Create new path object
    _GDIPlus_PathAddEllipse($hPath, 50, 50, 300, 300)

    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen1) ;Draw path to graphics handle (GUI)

    $aPoints = _GDIPlus_PathGetPoints($hPath)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawEllipse($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
    Next

    ;flattened ellipse
    _GDIPlus_GraphicsDrawString($hGraphic, "flattened ellipse as a sequence of straight lines", 410, 10)

    _GDIPlus_PathReset($hPath)
    _GDIPlus_PathAddEllipse($hPath, 450, 50, 300, 300)
    _GDIPlus_PathFlatten($hPath, 10)

    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen1) ;Draw path to graphics handle (GUI)

    $aPoints = _GDIPlus_PathGetPoints($hPath)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawEllipse($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen1)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathAddLine

Function Reference

_GDIPlus_PathAddLine

Adds a line to the current figure of a path

#include <GDIPlus.au3>
_GDIPlus_PathAddLine ( $hPath, $nX1, $nY1, $nX2, $nY2 )

Parameters

$hPath | Pointer to a GraphicsPath object
$nX1 | The X coordinate of the starting point of the line
$nY1 | The Y coordinate of the starting point of the line
$nX2 | The X coordinate of the ending point of the line
$nY2 | The Y coordinate of the ending point of the line

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipAddPathLine in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hPath_Clone, $hMatrix

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)
    $hPen = _GDIPlus_PenCreate(0xFF8800AA, 2)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    _GDIPlus_PathAddLine($hPath, 106, 330, 200, 40)
    _GDIPlus_PathAddLine($hPath, 294, 330, 48, 151)
    _GDIPlus_PathAddLine($hPath, 352, 151, 106, 330)

    $hPath_Clone = _GDIPlus_PathClone($hPath) ;Create a copy of the path
    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, 400, 0)
    _GDIPlus_PathTransform($hPath_Clone, $hMatrix)

    _GDIPlus_PathWindingModeOutline($hPath_Clone) ;Outline

    _GDIPlus_GraphicsDrawString($hGraphic, "original path of 3 connected lines", 40, 10)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    _GDIPlus_GraphicsDrawString($hGraphic, "WindingModeOutline", 440, 10)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath_Clone, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath_Clone, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PathDispose($hPath_Clone)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathAddLine2

Function Reference

_GDIPlus_PathAddLine2

Adds a sequence of lines to the current figure of a path

#include <GDIPlus.au3>
_GDIPlus_PathAddLine2 ( $hPath, $aPoints )

Parameters

$hPath | Pointer to a GraphicsPath object
$aPoints | Array of points that define the lines: [0][0] - Number of points [1][0] - Point 1 X position [1][1] - Point 1 Y position [2][0] - Point 2 X position [2][1] - Point 2 Y position [n][0] - Point n X position [n][1] - Point n Y position

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathAddLine

See Also

Search GdipAddPathLine2 in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphics, $hPath, $hCustomLineCap, $hClonedLineCap, $hPen
    Local $avPoints[4][2] = [[3], [-15, -15], [0, 0], [15, -15]]

    ; Initialize GDI+
    _GDIPlus_Startup()

    ;create a Graphics object from a window handle
    $hGUI = GUICreate("_GDIPlus_CustomLineCapCreate Example", 400, 200)
    GUISetState(@SW_SHOW)

    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)

    ;sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)

    ; Create GraphicsPath and add two lines to it.
    $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddLine2($hPath, $avPoints)

    ; Create a CustomLineCap object.
    $hCustomLineCap = _GDIPlus_CustomLineCapCreate(0, $hPath)

    ; Create a clone CustomLineCap object.
    $hClonedLineCap = _GDIPlus_CustomLineCapClone($hCustomLineCap)

    ; Create a Pen object, assign cloned cap as the custom end cap, and draw a line.
    $hPen = _GDIPlus_PenCreate(0xFFFF0000)
    _GDIPlus_PenSetCustomEndCap($hPen, $hClonedLineCap)

    _GDIPlus_GraphicsDrawLine($hGraphics, 50, 50, 350, 150, $hPen)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_CustomLineCapDispose($hClonedLineCap)
    _GDIPlus_CustomLineCapDispose($hCustomLineCap)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)

    ; Uninitialize GDI+
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathAddPath

Function Reference

_GDIPlus_PathAddPath

Adds a path to another path

#include <GDIPlus.au3>
_GDIPlus_PathAddPath ( $hPath1, $hPath2 [, $bConnect = True] )

Parameters

$hPath1 | Pointer to a GraphicsPath object
$hPath2 | Pointer to a GraphicsPath object to be added to $hPath1
$bConnect | [optional] Specifies whether the first figure in the added path is part of the last figure in this path: True - The first figure in the added $hPath2 is part of the last figure in the $hPath1 path False - The first figure in the added $hPath2 is separated from the last figure in the $hPath1 path

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

Even if the value of the $bConnect parameter is True, this function might not be able to make the first figure of the added $hPath2 path part of the last figure of the $hPath1 path.
If either of those figures is closed, then they must remain separated figures.

See Also

Search GdipAddPathPath in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPath1, $hPath2, $hMatrix

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 200)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000)

    $hPath1 = _GDIPlus_PathCreate() ;Create new path object
    For $i = 1 To 9
        _GDIPlus_PathAddRectangle($hPath1, 20 * $i, 10, 10, 180)
    Next

    $hPath2 = _GDIPlus_PathCreate() ;Create new path object
    For $i = 1 To 9
        _GDIPlus_PathAddRectangle($hPath2, 10, 20 * $i, 180, 10)
    Next

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath1, $hBrush) ;Draw path1 to graphics handle (GUI)

    _GDIPlus_PathAddPath($hPath1, $hPath2) ;add path2 to path1

    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, 300, 0)
    _GDIPlus_PathTransform($hPath2, $hMatrix) ;move path2 to an offset of 300
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath2, $hBrush) ;Draw path2 to graphics handle (GUI)

    _GDIPlus_MatrixTranslate($hMatrix, 300, 0)
    _GDIPlus_PathTransform($hPath1, $hMatrix) ;move path1+Path2 to an offset of 600
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath1, $hBrush) ;Draw path1 to graphics handle (GUI)

    _GDIPlus_GraphicsDrawString($hGraphic, "+", 180, 10, "Arial Black", 100)
    _GDIPlus_GraphicsDrawString($hGraphic, "=", 480, 10, "Arial Black", 100)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PathDispose($hPath1)
    _GDIPlus_PathDispose($hPath2)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathAddPie

Function Reference

_GDIPlus_PathAddPie

Adds a pie to a path

#include <GDIPlus.au3>
_GDIPlus_PathAddPie ( $hPath, $nX, $nY, $nWidth, $nHeight, $fStartAngle, $fSweepAngle )

Parameters

$hPath | Pointer to a GraphicsPath object
$nX | The X coordinate of the upper left corner of the rectangle that bounds the ellipse that bounds the pie
$nY | The Y coordinate of the upper left corner of the rectangle that bounds the ellipse that bounds the pie
$nWidth | The width of the rectangle that bounds the ellipse that bounds the pie
$nHeight | The height of the rectangle that bounds the ellipse that bounds the pie
$fStartAngle | The angle, in degrees, between the X axis and the starting point of the arc that defines the pie. A positive value specifies clockwise rotation.
$fSweepAngle | The angle, in degrees, between the starting and ending points of the arc that defines the pie. A positive value specifies clockwise rotation.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipAddPathPie in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPen, $hPen2, $hPath

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)
    $hPen = _GDIPlus_PenCreate(0xFF8800AA, 2)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    _GDIPlus_PathAddPie($hPath, 50, 50, 300, 300, 135, 270)
    _GDIPlus_PathAddPie($hPath, 50, 80, 300, 300, 45, 90)

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathAddPolygon

Function Reference

_GDIPlus_PathAddPolygon

Adds a polygon to a path

#include <GDIPlus.au3>
_GDIPlus_PathAddPolygon ( $hPath, $aPoints )

Parameters

$hPath | Pointer to a GraphicsPath object
$aPoints | Array of points that define the vertices of the polygon: [0][0] - Number of points [1][0] - Point 1 X position [1][1] - Point 1 Y position [2][0] - Point 2 X position [2][1] - Point 2 Y position [n][0] - Point n X position [n][1] - Point n Y position

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipAddPathPolygon in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPen, $hPen2, $hPath

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 300)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)
    $hPen = _GDIPlus_PenCreate(0xFF8800AA, 2)
    $hPen2 = _GDIPlus_PenCreate(0xFFFF0000, 2)

    Local $aPoints[5][2] = [[4]]
    $aPoints[1][0] = 10
    $aPoints[1][1] = 70
    $aPoints[2][0] = 60
    $aPoints[2][1] = 50
    $aPoints[3][0] = 110
    $aPoints[3][1] = 120
    $aPoints[4][0] = 160
    $aPoints[4][1] = 80

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    _GDIPlus_GraphicsDrawString($hGraphic, "Curve", $aPoints[1][0], 20)
    _GDIPlus_PathAddCurve($hPath, $aPoints)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "ClosedCurve", $aPoints[1][0], 20)
    _GDIPlus_PathAddClosedCurve($hPath, $aPoints)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "Curve2 tension = 0.8", $aPoints[1][0], 20)
    _GDIPlus_PathAddCurve2($hPath, $aPoints, 0.8)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "ClosedCurve2 tension = 0.8", $aPoints[1][0], 20)
    _GDIPlus_PathAddClosedCurve2($hPath, $aPoints, 0.8)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] -= 500
        $aPoints[$i][1] += 140
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "Curve2 tension = 0", $aPoints[1][0], 160)
    _GDIPlus_PathAddCurve2($hPath, $aPoints, 0)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "ClosedCurve2 tension = 0", $aPoints[1][0], 160)
    _GDIPlus_PathAddClosedCurve2($hPath, $aPoints, 0)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
        $aPoints[$i][0] += 200
    Next

    _GDIPlus_GraphicsDrawString($hGraphic, "Polygon", $aPoints[1][0], 160)
    _GDIPlus_PathAddPolygon($hPath, $aPoints)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
    Next

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathAddRectangle

Function Reference

_GDIPlus_PathAddRectangle

Adds a rectangle to a path

#include <GDIPlus.au3>
_GDIPlus_PathAddRectangle ( $hPath, $nX, $nY, $nWidth, $nHeight )

Parameters

$hPath | Pointer to a GraphicsPath object
$nX | X coordinate of the upper-left corner of the rectangle
$nY | Y coordinate of the upper-left corner of the rectangle
$nWidth | Width of the rectangle
$nHeight | Height of the rectangle

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipAddPathRectangle in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPath1, $hPath2, $hMatrix

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 200)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000)

    $hPath1 = _GDIPlus_PathCreate() ;Create new path object
    For $i = 1 To 9
        _GDIPlus_PathAddRectangle($hPath1, 20 * $i, 10, 10, 180)
    Next

    $hPath2 = _GDIPlus_PathCreate() ;Create new path object
    For $i = 1 To 9
        _GDIPlus_PathAddRectangle($hPath2, 10, 20 * $i, 180, 10)
    Next

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath1, $hBrush) ;Draw path1 to graphics handle (GUI)

    _GDIPlus_PathAddPath($hPath1, $hPath2) ;add path2 to path1

    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, 300, 0)
    _GDIPlus_PathTransform($hPath2, $hMatrix) ;move path2 to an offset of 300
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath2, $hBrush) ;Draw path2 to graphics handle (GUI)

    _GDIPlus_MatrixTranslate($hMatrix, 300, 0)
    _GDIPlus_PathTransform($hPath1, $hMatrix) ;move path1+Path2 to an offset of 600
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath1, $hBrush) ;Draw path1 to graphics handle (GUI)

    _GDIPlus_GraphicsDrawString($hGraphic, "+", 180, 10, "Arial Black", 100)
    _GDIPlus_GraphicsDrawString($hGraphic, "=", 480, 10, "Arial Black", 100)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PathDispose($hPath1)
    _GDIPlus_PathDispose($hPath2)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathAddString

Function Reference

_GDIPlus_PathAddString

Adds the outline of a string to a path

#include <GDIPlus.au3>
_GDIPlus_PathAddString ( $hPath, $sString, $tLayout, $hFamily [, $iStyle = 0 [, $fSize = 8.5 [, $hFormat = 0]]] )

Parameters

$hPath | Pointer to a GraphicsPath object
$sString | String to be drawn
$tLayout | $tagGDIPRECTF structure that bounds the string
$hFamily | Pointer to a FontFamily object that specifies the font family for the string
$iStyle | [optional] The style of the typeface. Can be a combination of the following: 0 - Normal weight or thickness of the typeface 1 - Bold typeface 2 - Italic typeface 4 - Underline 8 - Strikethrough
$fSize | [optional] The em size, in world units, of the string characters
$hFormat | [optional] Pointer to a StringFormat object that specifies layout information for the string

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipAddPathString in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hFamily, $tLayout

    ; Create GUI
    $hGUI = GUICreate("GDI+", 420, 160)
    GUISetState(@SW_SHOW)

    ; Draw a string using path
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    $hBrush = _GDIPlus_BrushCreateSolid(0xFFDD2200)
    $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    $hFamily = _GDIPlus_FontFamilyCreate("Arial") ;Create font family object
    $tLayout = _GDIPlus_RectFCreate() ;Create string bounding rectangle X=0, Y=0
    _GDIPlus_PathAddString($hPath, "AutoIt rulez!", $tLayout, $hFamily, 0, 72, 0) ;Add the outline of the string to the path

    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFF000000)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathClone

Function Reference

_GDIPlus_PathClone

Clones a path

#include <GDIPlus.au3>
_GDIPlus_PathClone ( $hPath )

Parameters

$hPath Pointer to a GraphicsPath object to be cloned

Return Value

Success: | a pointer to a new cloned GraphicsPath object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_PathDispose() to release the object resources.

Related

_GDIPlus_PathDispose

See Also

Search GdipClonePath in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $iW, $iH, $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hPath_Clone, $hMatrix

    ; Create GUI
    $iW = 600
    $iH = 600
    $hGUI = GUICreate("GDI+", $iW, $iH)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)
    $hPen = _GDIPlus_PenCreate(0xFF8800AA, 2)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    ;spiral as a sequence of lines
    Local $iXOld = 0, $iYOld = 0, $iX, $iY, $iAngle = 0, $iRadius = 0
    For $i = 0 To 200
        $iX = Cos($iAngle) * $iRadius
        $iY = Sin($iAngle) * $iRadius
        $iAngle += 0.1
        $iRadius = $iAngle ^ 2 / 2
        _GDIPlus_PathAddLine($hPath, $iXOld, $iYOld, $iX, $iY)
        $iXOld = $iX
        $iYOld = $iY
    Next

    $hPath_Clone = _GDIPlus_PathClone($hPath)
    _GDIPlus_PathReverse($hPath_Clone) ;reverse path => end point of path = start point of cloned path

    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixScale($hMatrix, 1.5, 1.5)
    _GDIPlus_PathTransform($hPath_Clone, $hMatrix) ;zoom cloned path

    _GDIPlus_PathAddPath($hPath, $hPath_Clone) ;add scaled/reversed path to original path

    _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0) ;reset matrix
    _GDIPlus_MatrixTranslate($hMatrix, $iW / 2, $iH / 2, True)
    _GDIPlus_PathTransform($hPath, $hMatrix) ;move path to center of window

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PathDispose($hPath_Clone)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathCloseFigure

Function Reference

_GDIPlus_PathCloseFigure

Closes the current figure of a path

#include <GDIPlus.au3>
_GDIPlus_PathCloseFigure ( $hPath )

Parameters

$hPath Pointer to a GraphicsPath object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipClosePathFigure in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPen, $hPath

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)
    $hPen = _GDIPlus_PenCreate(0xFF8800AA, 2)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    _GDIPlus_PathAddArc($hPath, 50, 50, 100, 100, 180, 180)
    _GDIPlus_PathAddArc($hPath, 50, 150, 100, 100, 0, 180)
    _GDIPlus_PathCloseFigure($hPath) ;connect last point of arc2 to first point of arc1

    _GDIPlus_PathAddArc($hPath, 250, 50, 100, 100, 180, 180)
    _GDIPlus_PathCloseFigure($hPath) ;do not connect arcs
    _GDIPlus_PathAddArc($hPath, 250, 150, 100, 100, 0, 180)
    _GDIPlus_PathCloseFigure($hPath) ;connect last point of arc2 to first point of arc2

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathCreate

Function Reference

_GDIPlus_PathCreate

Creates a GraphicsPath object and initializes the fill mode

#include <GDIPlus.au3>
_GDIPlus_PathCreate ( [$iFillMode = 0] )

Parameters

$iFillMode [optional] Fill mode of the interior of the path figures:
0 - The areas are filled according to the even-odd parity rule
1 - The areas are filled according to the nonzero winding rule

Return Value

Success: | a handle to a new GraphicsPath object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_PathDispose() to release the object resources.

Related

_GDIPlus_PathCreate2, _GDIPlus_PathDispose

See Also

Search GdipCreatePath in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hFamily, $tLayout

    ; Create GUI
    $hGUI = GUICreate("GDI+", 420, 160)
    GUISetState(@SW_SHOW)

    ; Draw a string using path
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    $hBrush = _GDIPlus_BrushCreateSolid(0xFFDD2200)
    $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    $hFamily = _GDIPlus_FontFamilyCreate("Arial") ;Create font family object
    $tLayout = _GDIPlus_RectFCreate() ;Create string bounding rectangle X=0, Y=0
    _GDIPlus_PathAddString($hPath, "AutoIt rulez!", $tLayout, $hFamily, 0, 72, 0) ;Add the outline of the string to the path

    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFF000000)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathCreate2

Function Reference

_GDIPlus_PathCreate2

Creates a GraphicsPath object based on an array of points, an array of types, and a fill mode

#include <GDIPlus.au3>
_GDIPlus_PathCreate2 ( $aPathData [, $iFillMode = 0] )

Parameters

$aPathData | Array of points and types that specifies the endpoints and control points of the lines and bezier splines that are used to draw the path and the points types: [0][0] - Number of points and types [1][0] - Point 1 X position [1][1] - Point 1 Y position [1][2] - Point 1 type [n][0] - Point n X position [n][1] - Point n Y position [1][2] - Point n type Each point type is one of the following values: 0x00 - The point is the start of a figure 0x01 - The point is one of the two endpoints of a line 0x03 - The point is an endpoint or control point of a cubic bezier spline 0x20 - The point is a marker 0x80 - The point is the last point in a closed subpath (figure)
$iFillMode | [optional] Fill mode of the interior of the path figures: 0 - The areas are filled according to the even-odd parity rule 1 - The areas are filled according to the nonzero winding rule

Return Value

Success: | a pointer to a new GraphicsPath object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_PathDispose() to release the object resources.

Related

_GDIPlus_PathCreate, _GDIPlus_PathDispose

See Also

Search GdipCreatePath2 in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 420, 420)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $aPathData[107][3] = [[106, 0, 0], [192.18, 15.75, 0], [226.79, 15.73, 3], [259.23, 24.91, 3], [287.25, 40.92, 3], [294.60, 17.47, 3], [316.50, 0.47, 3], [342.35, 0.47, 3], [374.28, 0.47, 3], [400.13, 26.32, 3], _
            [400.13, 58.25, 3], [400.13, 84.25, 3], [382.94, 106.24, 3], [359.35, 113.49, 3], [374.98, 141.27, 3], [383.93, 173.29, 3], [383.93, 207.43, 3], [383.93, 313.34, 3], [298.08, 399.19, 3], [192.18, 399.19, 3], _
            [86.32, 399.19, 3], [0.47, 313.34, 3], [0.47, 207.43, 3], [0.47, 101.57, 3], [86.32, 15.73, 3], [192.18, 15.73, 131], [192.18, 359.65, 0], [275.76, 359.21, 3], [343.95, 291.02, 3], [343.95, 207.43, 3], _
            [343.95, 123.85, 3], [275.76, 55.71, 3], [192.18, 55.71, 3], [108.59, 55.71, 3], [40.45, 123.85, 3], [40.45, 207.43, 3], [40.45, 291.02, 3], [108.59, 359.21, 3], [192.18, 359.21, 131], [142.45, 263.80, 0], _
            [151.82, 250.76, 3], [161.19, 238.04, 3], [170.52, 225.28, 3], [182.85, 225.28, 3], [222.74, 224.72, 3], [234.98, 225.75, 3], [224.86, 212.85, 3], [201.83, 178.14, 3], [192.79, 164.96, 3], [169.24, 197.78, 3], _
            [145.75, 230.65, 3], [122.25, 263.47, 3], [103.93, 263.47, 3], [85.56, 263.47, 3], [67.25, 263.47, 3], [99.36, 218.74, 3], [131.48, 173.95, 3], [163.59, 129.22, 3], [179.65, 107.08, 3], [207.39, 106.38, 3], _
            [223.30, 129.22, 3], [254.62, 173.95, 3], [285.89, 218.74, 3], [317.20, 263.47, 3], [258.95, 263.47, 3], [200.70, 263.47, 3], [142.45, 263.47, 131], [320.36, 45.92, 0], [331.57, 45.87, 3], [342.77, 45.87, 3], _
            [353.98, 45.87, 3], [360.34, 45.87, 3], [360.53, 52.18, 3], [353.98, 52.18, 3], [344.19, 52.18, 3], [334.34, 52.18, 3], [324.55, 52.18, 3], [327.14, 55.47, 3], [329.78, 58.77, 3], [332.41, 62.02, 3], _
            [336.98, 62.02, 3], [354.69, 61.41, 3], [357.18, 62.68, 3], [358.88, 63.57, 3], [359.87, 68.09, 3], [354.22, 68.09, 3], [340.51, 68.09, 3], [326.81, 68.09, 3], [313.06, 68.09, 3], [316.36, 72.05, 3], _
            [319.61, 76.05, 3], [322.85, 80.05, 3], [330.67, 80.05, 3], [355.25, 80.62, 3], [361.52, 79.25, 3], [376.63, 75.91, 3], [375.22, 60.70, 3], [366.18, 57.69, 3], [376.11, 54.95, 3], [378.04, 38.94, 3], _
            [363.59, 35.08, 3], [356.67, 33.25, 3], [320.22, 34.05, 3], [310.66, 34.05, 3], [313.91, 38.00, 3], [317.11, 41.96, 3], [320.36, 45.87, 131]]

    Local $hPath = _GDIPlus_PathCreate2($aPathData)

    Local $hBrush = _GDIPlus_BrushCreateSolid(0x7F0088AA)
    Local $hPen = _GDIPlus_PenCreate(0xFF0088AA, 2)

    _GDIPlus_GraphicsTranslateTransform($hGraphics, 10, 10)

    _GDIPlus_GraphicsFillPath($hGraphics, $hPath, $hBrush)
    _GDIPlus_GraphicsDrawPath($hGraphics, $hPath, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathDispose

Function Reference

_GDIPlus_PathDispose

Releases a GraphicsPath object

#include <GDIPlus.au3>
_GDIPlus_PathDispose ( $hPath )

Parameters

$hPath Pointer to a GraphicsPath object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathCreate

See Also

Search GdipDeletePath in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hFamily, $tLayout

    ; Create GUI
    $hGUI = GUICreate("GDI+", 420, 160)
    GUISetState(@SW_SHOW)

    ; Draw a string using path
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    $hBrush = _GDIPlus_BrushCreateSolid(0xFFDD2200)
    $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    $hFamily = _GDIPlus_FontFamilyCreate("Arial") ;Create font family object
    $tLayout = _GDIPlus_RectFCreate() ;Create string bounding rectangle X=0, Y=0
    _GDIPlus_PathAddString($hPath, "AutoIt rulez!", $tLayout, $hFamily, 0, 72, 0) ;Add the outline of the string to the path

    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFF000000)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathFlatten

Function Reference

_GDIPlus_PathFlatten

Applies a transformation to a path and converts each curve in the path to a sequence of connected lines

#include <GDIPlus.au3>
_GDIPlus_PathFlatten ( $hPath [, $fFlatness = 0.25 [, $hMatrix = 0]] )

Parameters

$hPath | Pointer to a GraphicsPath object
$fFlatness | [optional] Real number that specifies the maximum error between the path and its flattened approximation. Reducing the flatness increases the number of line segments in the approximation
$hMatrix | [optional] Pointer to a Matrix object that specifies the transformation to be applied to the path's data points

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathWarp

See Also

Search GdipFlattenPath in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen1, $hPen2, $hPath, $aPoints

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hPen1 = _GDIPlus_PenCreate(0xFFFFBB00, 2)
    $hPen2 = _GDIPlus_PenCreate(0xFF0000FF, 2)

    ; original ellipse
    _GDIPlus_GraphicsDrawString($hGraphic, "original ellipse as bezier points", 10, 10)

    $hPath = _GDIPlus_PathCreate() ;Create new path object
    _GDIPlus_PathAddEllipse($hPath, 50, 50, 300, 300)

    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen1) ;Draw path to graphics handle (GUI)

    $aPoints = _GDIPlus_PathGetPoints($hPath)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawEllipse($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
    Next

    ;flattened ellipse
    _GDIPlus_GraphicsDrawString($hGraphic, "flattened ellipse as a sequence of straight lines", 410, 10)

    _GDIPlus_PathReset($hPath)
    _GDIPlus_PathAddEllipse($hPath, 450, 50, 300, 300)
    _GDIPlus_PathFlatten($hPath, 10)

    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen1) ;Draw path to graphics handle (GUI)

    $aPoints = _GDIPlus_PathGetPoints($hPath)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawEllipse($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen1)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathGetData

Function Reference

_GDIPlus_PathGetData

Gets an array of points and types from a path

#include <GDIPlus.au3>
_GDIPlus_PathGetData ( $hPath )

Parameters

$hPath Pointer to a GraphicsPath object

Return Value

Success: | an array of points and types that specifies the endpoints and control points of the lines and bezier splines that are used to draw the path and the points types: [0][0] - Number of points and types [1][0] - Point 1 X position [1][1] - Point 1 Y position [1][2] - Point 1 type [n][0] - Point n X position [n][1] - Point n Y position [1][2] - Point n type Each point type is one of the following values: 0x00 - The point is the start of a figure 0x01 - The point is one of the two endpoints of a line 0x03 - The point is an endpoint or control point of a cubic bezier spline 0x20 - The point is a marker 0x80 - The point is the last point in a closed subpath (figure)
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathCreate2

See Also

Search GdipGetPathData in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $iW, $iH, $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hPath_Clone, $hFamily, $tLayout
    Local $aBounds, $aPathData1, $aPathData2

    $iW = 800
    $iH = 300
    $hGUI = GUICreate("GDI+", $iW, $iH)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphic, 0xFF000000)

    $hBrush = _GDIPlus_BrushCreateSolid(0xFF006600)
    $hPen = _GDIPlus_PenCreate(0xFF00FF00, 2)

    $hPath = _GDIPlus_PathCreate()

    $hFamily = _GDIPlus_FontFamilyCreate("Arial Black")
    $tLayout = _GDIPlus_RectFCreate()
    _GDIPlus_PathAddString($hPath, "AutoIt", $tLayout, $hFamily)
    _GDIPlus_PathFlatten($hPath, 0.01)

    $aBounds = _GDIPlus_PathGetWorldBounds($hPath)
    $hPath_Clone = _GDIPlus_PathClone($hPath)

    Local $aPoints[5][2]
    $aPoints[0][0] = 4
    $aPoints[1][0] = $iW * 0.2
    $aPoints[1][1] = $iH * 0.3
    $aPoints[2][0] = $iW * 0.8
    $aPoints[2][1] = $iH * 0.3
    $aPoints[3][0] = 0
    $aPoints[3][1] = $iH
    $aPoints[4][0] = $iW
    $aPoints[4][1] = $iH

    _GDIPlus_PathWarp($hPath, 0, $aPoints, $aBounds[0], $aBounds[1], $aBounds[2], $aBounds[3] + 2)

    $aPoints[1][1] -= 12
    $aPoints[2][1] -= 12
    $aPoints[3][1] -= 32
    $aPoints[4][1] -= 32

    _GDIPlus_PathWarp($hPath_Clone, 0, $aPoints, $aBounds[0], $aBounds[1], $aBounds[2], $aBounds[3] + 2)

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush)

    $aPathData1 = _GDIPlus_PathGetData($hPath)
    $aPathData2 = _GDIPlus_PathGetData($hPath_Clone)

    Local $aPolyGon[5][2] = [[4]], $iIdx
    For $i = 1 To $aPathData1[0][0]
        If $aPathData1[$i][2] = 0 Then $iIdx = $i

        $aPolyGon[1][0] = $aPathData1[$i][0]
        $aPolyGon[1][1] = $aPathData1[$i][1]
        $aPolyGon[4][0] = $aPathData2[$i][0]
        $aPolyGon[4][1] = $aPathData2[$i][1]

        If BitAND($aPathData1[$i][2], 0x80) Then
            $aPolyGon[2][0] = $aPathData1[$iIdx][0]
            $aPolyGon[2][1] = $aPathData1[$iIdx][1]
            $aPolyGon[3][0] = $aPathData2[$iIdx][0]
            $aPolyGon[3][1] = $aPathData2[$iIdx][1]
        Else
            $aPolyGon[2][0] = $aPathData1[$i + 1][0]
            $aPolyGon[2][1] = $aPathData1[$i + 1][1]
            $aPolyGon[3][0] = $aPathData2[$i + 1][0]
            $aPolyGon[3][1] = $aPathData2[$i + 1][1]
        EndIf

        _GDIPlus_GraphicsFillPolygon($hGraphic, $aPolyGon, $hBrush)
    Next

    _GDIPlus_BrushSetSolidColor($hBrush, 0xFF00AA00)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath_Clone, $hBrush)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath_Clone, $hPen)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PathDispose($hPath_Clone)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathGetFillMode

Function Reference

_GDIPlus_PathGetFillMode

Gets the fill mode of a path

#include <GDIPlus.au3>
_GDIPlus_PathGetFillMode ( $hPath )

Parameters

$hPath Pointer to a GraphicsPath object

Return Value

Success: | the fill mode of the interior of the path figures: 0 - The areas are filled according to the even-odd parity rule 1 - The areas are filled according to the nonzero winding rule
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathSetFillMode

See Also

Search GdipGetPathFillMode in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPen, $hPath

    ; Create GUI
    $hGUI = GUICreate("GDI+", 300, 220)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)

    $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)
    $hPen = _GDIPlus_PenCreate(0xFF8800AA, 2)

    $hPath = _GDIPlus_PathCreate(0) ;Create new path object
    _GDIPlus_PathAddRectangle($hPath, 50, 50, 100, 100)
    _GDIPlus_PathAddRectangle($hPath, 100, 80, 100, 100)
    _GDIPlus_PathAddRectangle($hPath, 120, 30, 100, 100)

    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Local $iTimer = TimerInit()
    Do
        If TimerDiff($iTimer) > 1000 Then
            _GDIPlus_PathSetFillMode($hPath, Not _GDIPlus_PathGetFillMode($hPath))
            _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)
            _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
            _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)
            $iTimer = TimerInit()
        EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathGetLastPoint

Function Reference

_GDIPlus_PathGetLastPoint

Gets the ending point of the last figure in a path

#include <GDIPlus.au3>
_GDIPlus_PathGetLastPoint ( $hPath )

Parameters

$hPath Pointer to a GraphicsPath object

Return Value

Success: | an array containing the point coordinates: [0] - X coordinate of the point [1] - Y coordinate of the point
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetPathLastPoint in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen, $hPath, $aPnt

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hPen = _GDIPlus_PenCreate(0xFF8800AA, 2)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    _GDIPlus_PathAddArc($hPath, 50, 50, 300, 300, Random(0, 360), Random(30, 270))
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    _GDIPlus_PenSetColor($hPen, 0xFF00AA00)

    $aPnt = _GDIPlus_PathGetLastPoint($hPath)
    _GDIPlus_GraphicsDrawRect($hGraphic, $aPnt[0] - 5, $aPnt[1] - 5, 10, 10, $hPen)

    _GDIPlus_PathReverse($hPath)
    $aPnt = _GDIPlus_PathGetLastPoint($hPath)
    _GDIPlus_GraphicsDrawRect($hGraphic, $aPnt[0] - 5, $aPnt[1] - 5, 10, 10, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathGetPointCount

Function Reference

_GDIPlus_PathGetPointCount

Gets the number of points in a path's array of data points

#include <GDIPlus.au3>
_GDIPlus_PathGetPointCount ( $hPath )

Parameters

$hPath Pointer to a GraphicsPath object

Return Value

Success: | the number of points contained in the path.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetPointCount in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen1, $hPen2, $hPath, $aPoints

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hPen1 = _GDIPlus_PenCreate(0xFFFFBB00, 2)
    $hPen2 = _GDIPlus_PenCreate(0xFF0000FF, 2)

    ; original ellipse
    _GDIPlus_GraphicsDrawString($hGraphic, "original ellipse as bezier points", 10, 10)

    $hPath = _GDIPlus_PathCreate() ;Create new path object
    _GDIPlus_PathAddEllipse($hPath, 50, 50, 300, 300)

    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen1) ;Draw path to graphics handle (GUI)

    $aPoints = _GDIPlus_PathGetPoints($hPath)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawEllipse($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
    Next

    ;flattened ellipse
    _GDIPlus_GraphicsDrawString($hGraphic, "flattened ellipse as a sequence of straight lines", 410, 10)

    _GDIPlus_PathReset($hPath)
    _GDIPlus_PathAddEllipse($hPath, 450, 50, 300, 300)
    _GDIPlus_PathFlatten($hPath, 10)

    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen1) ;Draw path to graphics handle (GUI)

    $aPoints = _GDIPlus_PathGetPoints($hPath)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawEllipse($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen1)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathGetPoints

Function Reference

_GDIPlus_PathGetPoints

Gets an array of points from a path

#include <GDIPlus.au3>
_GDIPlus_PathGetPoints ( $hPath )

Parameters

$hPath Pointer to a GraphicsPath object

Return Value

Success: | an array of points that define the path data points [0][0] - Number of points [1][0] - Point 1 X position [1][1] - Point 1 Y position [2][0] - Point 2 X position [2][1] - Point 2 Y position [n][0] - Point n X position [n][1] - Point n Y position
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetPathPoints in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen1, $hPen2, $hPath, $aPoints

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hPen1 = _GDIPlus_PenCreate(0xFFFFBB00, 2)
    $hPen2 = _GDIPlus_PenCreate(0xFF0000FF, 2)

    ; original ellipse
    _GDIPlus_GraphicsDrawString($hGraphic, "original ellipse as bezier points", 10, 10)

    $hPath = _GDIPlus_PathCreate() ;Create new path object
    _GDIPlus_PathAddEllipse($hPath, 50, 50, 300, 300)

    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen1) ;Draw path to graphics handle (GUI)

    $aPoints = _GDIPlus_PathGetPoints($hPath)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawEllipse($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
    Next

    ;flattened ellipse
    _GDIPlus_GraphicsDrawString($hGraphic, "flattened ellipse as a sequence of straight lines", 410, 10)

    _GDIPlus_PathReset($hPath)
    _GDIPlus_PathAddEllipse($hPath, 450, 50, 300, 300)
    _GDIPlus_PathFlatten($hPath, 10)

    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen1) ;Draw path to graphics handle (GUI)

    $aPoints = _GDIPlus_PathGetPoints($hPath)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawEllipse($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen1)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathGetWorldBounds

Function Reference

_GDIPlus_PathGetWorldBounds

Gets the bounding rectangle for a path

#include <GDIPlus.au3>
_GDIPlus_PathGetWorldBounds ( $hPath [, $hMatrix = 0 [, $hPen = 0]] )

Parameters

$hPath | Pointer to a GraphicsPath object
$hMatrix | [optional] Pointer to a Matrix object that specifies a transformation to be applied to this path before the bounding rectangle is calculated. The path is not permanently transformed
$hPen | [optional] Pointer to a Pen object that influences the size of the bounding rectangle. The bounding rectangle bounds will be large enough to enclose the path when the path is drawn with the specified pen.

Return Value

Success: | an array containing the rectangle coordinates and dimensions: [0] - Rectangle X position [1] - Rectangle Y position [2] - Rectangle Width [3] - Rectangle Height
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetPathWorldBounds in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $iW, $iH, $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hFamily, $tLayout, $hMatrix, $aBounds

    ; Create GUI
    $iW = 640
    $iH = 220
    $hGUI = GUICreate("GDI+", $iW, $iH)
    GUISetState(@SW_SHOW)

    ; Draw a string using path
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFF000000)

    $hBrush = _GDIPlus_BrushCreateSolid(0xFFDD2200)
    $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    $hFamily = _GDIPlus_FontFamilyCreate("Arial") ;Create font family object
    $tLayout = _GDIPlus_RectFCreate() ;Create string bounding rectangle X=0, Y=0
    _GDIPlus_PathAddString($hPath, "Fit to Window", $tLayout, $hFamily) ;Add the outline of the string to the path

    ; Tranform Path to fit to window
    $aBounds = _GDIPlus_PathGetWorldBounds($hPath) ;Get bounding rectangle of the path
    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, -$aBounds[0], -$aBounds[1]) ;Translate Matrix to the offset of the bounding rectangle
    _GDIPlus_MatrixScale($hMatrix, $iW / $aBounds[2], $iH / $aBounds[3], True) ;Scale Matrix
    _GDIPlus_PathTransform($hPath, $hMatrix) ;Translate and Scale Path

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Tranform Path to center the path
    _GDIPlus_PathReset($hPath) ;Reset Path (delete previous string)
    _GDIPlus_PathAddString($hPath, "Center", $tLayout, $hFamily, 0, 100, 0) ;Add the outline of the string to the path

    $aBounds = _GDIPlus_PathGetWorldBounds($hPath)
    _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0) ;Reset Matrix
    _GDIPlus_MatrixTranslate($hMatrix, ($iW / 2) - $aBounds[0] - ($aBounds[2] / 2), ($iH / 2) - $aBounds[1] - ($aBounds[3] / 2))
    _GDIPlus_PathTransform($hPath, $hMatrix) ;Translate (offset) Path

    _GDIPlus_BrushSetSolidColor($hBrush, 0x7F004488)
    _GDIPlus_PenSetColor($hPen, 0xFF00AAFF)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathIsOutlineVisiblePoint

Function Reference

_GDIPlus_PathIsOutlineVisiblePoint

Determines whether a specified point touches the outline of a path with the specified Graphics and Pen

#include <GDIPlus.au3>
_GDIPlus_PathIsOutlineVisiblePoint ( $hPath, $nX, $nY [, $hPen = 0 [, $hGraphics = 0]] )

Parameters

$hPath | Pointer to a GraphicsPath object
$nX | X coordinate of the point to test
$nY | Y coordinate of the point to test
$hPen | [optional] Pointer to a Pen object that define the width of point to test. If 0, a solid black pen with a width of 1 will be used
$hGraphics | [optional] Pointer to a Graphics object that specifies a world-to-device transformation. If 0, the test is done in world coordinates; otherwise, the test is done in device coordinates.

Return Value

Success: | True if the point touches the outline of the path, False otherwise.
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipIsOutlineVisiblePathPoint in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Global $g_hGUI
Global $g_hGraphics, $g_hBmp_Buffer, $g_hGfx_Bufffer, $g_hBrush_NA, $g_hBrush_A, $g_hPen_NA, $g_hPen_A
Global $g_hPath, $g_hFormat, $g_hFamily

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    Local Const $iW = 640, $iH = 240
    Local $tLayout

    $g_hGUI = GUICreate("GDI+", $iW, $iH)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "_MouseMove")
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI)
    $g_hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $g_hGraphics)
    $g_hGfx_Bufffer = _GDIPlus_ImageGetGraphicsContext($g_hBmp_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfx_Bufffer, $GDIP_SMOOTHINGMODE_HIGHQUALITY)

    $g_hBrush_NA = _GDIPlus_BrushCreateSolid(0xFF000066)
    $g_hBrush_A = _GDIPlus_BrushCreateSolid(0xFF00FF00)
    $g_hPen_NA = _GDIPlus_PenCreate(0xFF666600, 4)
    $g_hPen_A = _GDIPlus_PenCreate(0xFF00FF00, 4)

    $g_hPath = _GDIPlus_PathCreate()

    $g_hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($g_hFormat, 1)
    $g_hFamily = _GDIPlus_FontFamilyCreate("Arial Black")
    $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH)
    _GDIPlus_PathAddString($g_hPath, "move mouse" & @LF & "over text", $tLayout, $g_hFamily, 0, 72, $g_hFormat)

    _MouseMove()

    While Sleep(10)
    WEnd
EndFunc   ;==>Example

Func _MouseMove()
    Local $sInfo = ""
    Local $aMouse = GUIGetCursorInfo()

    _GDIPlus_GraphicsClear($g_hGfx_Bufffer, 0xFF000000)
    _GDIPlus_GraphicsFillPath($g_hGfx_Bufffer, $g_hPath, $g_hBrush_NA)
    _GDIPlus_GraphicsDrawPath($g_hGfx_Bufffer, $g_hPath, $g_hPen_NA)
    Select
        Case _GDIPlus_PathIsOutlineVisiblePoint($g_hPath, $aMouse[0], $aMouse[1], $g_hPen_A, $g_hGfx_Bufffer)
            _GDIPlus_GraphicsDrawPath($g_hGfx_Bufffer, $g_hPath, $g_hPen_A)
            $sInfo = "mouse cursor touches path outline"
        Case _GDIPlus_PathIsVisiblePoint($g_hPath, $aMouse[0], $aMouse[1], $g_hGraphics)
            _GDIPlus_GraphicsFillPath($g_hGfx_Bufffer, $g_hPath, $g_hBrush_A)
            $sInfo = "mouse cursor in path fill area"
    EndSelect

    ToolTip($sInfo)
    _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBmp_Buffer, 0, 0)
EndFunc   ;==>_MouseMove

Func _Exit()
    _GDIPlus_FontFamilyDispose($g_hFamily)
    _GDIPlus_StringFormatDispose($g_hFormat)
    _GDIPlus_PathDispose($g_hPath)
    _GDIPlus_BrushDispose($g_hBrush_NA)
    _GDIPlus_BrushDispose($g_hBrush_A)
    _GDIPlus_PenDispose($g_hPen_NA)
    _GDIPlus_PenDispose($g_hPen_A)

    _GDIPlus_GraphicsDispose($g_hGfx_Bufffer)
    _GDIPlus_BitmapDispose($g_hBmp_Buffer)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_PathIsVisiblePoint

Function Reference

_GDIPlus_PathIsVisiblePoint

Determines whether a specified point lies in the area that is filled when a path is filled by a specified Graphics object

#include <GDIPlus.au3>
_GDIPlus_PathIsVisiblePoint ( $hPath, $nX, $nY [, $hGraphics = 0] )

Parameters

$hPath | Pointer to a GraphicsPath object
$nX | X coordinate of the point to test
$nY | Y coordinate of the point to test
$hGraphics | [optional] Pointer to a Graphics object that specifies a world-to-device transformation. If 0, the test is done in world coordinates; otherwise, the test is done in device coordinates.

Return Value

Success: | True if the point lies in the interior of the path, False otherwise
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipIsVisiblePathPoint in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Global $g_hGUI
Global $g_hGraphics, $g_hBmp_Buffer, $g_hGfx_Bufffer, $g_hBrush_NA, $g_hBrush_A, $g_hPen_NA, $g_hPen_A
Global $g_hPath, $g_hFormat, $g_hFamily

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    Local Const $iW = 640, $iH = 240
    Local $tLayout

    $g_hGUI = GUICreate("GDI+", $iW, $iH)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "_MouseMove")
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI)
    $g_hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $g_hGraphics)
    $g_hGfx_Bufffer = _GDIPlus_ImageGetGraphicsContext($g_hBmp_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfx_Bufffer, $GDIP_SMOOTHINGMODE_HIGHQUALITY)

    $g_hBrush_NA = _GDIPlus_BrushCreateSolid(0xFF000066)
    $g_hBrush_A = _GDIPlus_BrushCreateSolid(0xFF00FF00)
    $g_hPen_NA = _GDIPlus_PenCreate(0xFF666600, 4)
    $g_hPen_A = _GDIPlus_PenCreate(0xFF00FF00, 4)

    $g_hPath = _GDIPlus_PathCreate()

    $g_hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($g_hFormat, 1)
    $g_hFamily = _GDIPlus_FontFamilyCreate("Arial Black")
    $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH)
    _GDIPlus_PathAddString($g_hPath, "move mouse" & @LF & "over text", $tLayout, $g_hFamily, 0, 72, $g_hFormat)

    _MouseMove()

    While Sleep(10)
    WEnd
EndFunc   ;==>Example

Func _MouseMove()
    Local $sInfo = ""
    Local $aMouse = GUIGetCursorInfo()

    _GDIPlus_GraphicsClear($g_hGfx_Bufffer, 0xFF000000)
    _GDIPlus_GraphicsFillPath($g_hGfx_Bufffer, $g_hPath, $g_hBrush_NA)
    _GDIPlus_GraphicsDrawPath($g_hGfx_Bufffer, $g_hPath, $g_hPen_NA)
    Select
        Case _GDIPlus_PathIsOutlineVisiblePoint($g_hPath, $aMouse[0], $aMouse[1], $g_hPen_A, $g_hGfx_Bufffer)
            _GDIPlus_GraphicsDrawPath($g_hGfx_Bufffer, $g_hPath, $g_hPen_A)
            $sInfo = "mouse cursor touches path outline"
        Case _GDIPlus_PathIsVisiblePoint($g_hPath, $aMouse[0], $aMouse[1], $g_hGraphics)
            _GDIPlus_GraphicsFillPath($g_hGfx_Bufffer, $g_hPath, $g_hBrush_A)
            $sInfo = "mouse cursor in path fill area"
    EndSelect

    ToolTip($sInfo)
    _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBmp_Buffer, 0, 0)
EndFunc   ;==>_MouseMove

Func _Exit()
    _GDIPlus_FontFamilyDispose($g_hFamily)
    _GDIPlus_StringFormatDispose($g_hFormat)
    _GDIPlus_PathDispose($g_hPath)
    _GDIPlus_BrushDispose($g_hBrush_NA)
    _GDIPlus_BrushDispose($g_hBrush_A)
    _GDIPlus_PenDispose($g_hPen_NA)
    _GDIPlus_PenDispose($g_hPen_A)

    _GDIPlus_GraphicsDispose($g_hGfx_Bufffer)
    _GDIPlus_BitmapDispose($g_hBmp_Buffer)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_PathReset

Function Reference

_GDIPlus_PathReset

Empties a path and sets the fill mode to alternate (0)

#include <GDIPlus.au3>
_GDIPlus_PathReset ( $hPath )

Parameters

$hPath Pointer to a GraphicsPath object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipResetPath in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $iW, $iH, $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hFamily, $tLayout, $hMatrix, $aBounds

    ; Create GUI
    $iW = 640
    $iH = 220
    $hGUI = GUICreate("GDI+", $iW, $iH)
    GUISetState(@SW_SHOW)

    ; Draw a string using path
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFF000000)

    $hBrush = _GDIPlus_BrushCreateSolid(0xFFDD2200)
    $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    $hFamily = _GDIPlus_FontFamilyCreate("Arial") ;Create font family object
    $tLayout = _GDIPlus_RectFCreate() ;Create string bounding rectangle X=0, Y=0
    _GDIPlus_PathAddString($hPath, "Fit to Window", $tLayout, $hFamily) ;Add the outline of the string to the path

    ; Tranform Path to fit to window
    $aBounds = _GDIPlus_PathGetWorldBounds($hPath) ;Get bounding rectangle of the path
    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, -$aBounds[0], -$aBounds[1]) ;Translate Matrix to the offset of the bounding rectangle
    _GDIPlus_MatrixScale($hMatrix, $iW / $aBounds[2], $iH / $aBounds[3], True) ;Scale Matrix
    _GDIPlus_PathTransform($hPath, $hMatrix) ;Translate and Scale Path

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Tranform Path to center the path
    _GDIPlus_PathReset($hPath) ;Reset Path (delete previous string)
    _GDIPlus_PathAddString($hPath, "Center", $tLayout, $hFamily, 0, 100, 0) ;Add the outline of the string to the path

    $aBounds = _GDIPlus_PathGetWorldBounds($hPath)
    _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0) ;Reset Matrix
    _GDIPlus_MatrixTranslate($hMatrix, ($iW / 2) - $aBounds[0] - ($aBounds[2] / 2), ($iH / 2) - $aBounds[1] - ($aBounds[3] / 2))
    _GDIPlus_PathTransform($hPath, $hMatrix) ;Translate (offset) Path

    _GDIPlus_BrushSetSolidColor($hBrush, 0x7F004488)
    _GDIPlus_PenSetColor($hPen, 0xFF00AAFF)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathReverse

Function Reference

_GDIPlus_PathReverse

Reverses the order of the points that define a path's lines and curves

#include <GDIPlus.au3>
_GDIPlus_PathReverse ( $hPath )

Parameters

$hPath Pointer to a GraphicsPath object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipReversePath in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $iW, $iH, $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hPath_Clone, $hMatrix

    ; Create GUI
    $iW = 600
    $iH = 600
    $hGUI = GUICreate("GDI+", $iW, $iH)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)
    $hPen = _GDIPlus_PenCreate(0xFF8800AA, 2)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    ;spiral as a sequence of lines
    Local $iXOld = 0, $iYOld = 0, $iX, $iY, $iAngle = 0, $iRadius = 0
    For $i = 0 To 200
        $iX = Cos($iAngle) * $iRadius
        $iY = Sin($iAngle) * $iRadius
        $iAngle += 0.1
        $iRadius = $iAngle ^ 2 / 2
        _GDIPlus_PathAddLine($hPath, $iXOld, $iYOld, $iX, $iY)
        $iXOld = $iX
        $iYOld = $iY
    Next

    $hPath_Clone = _GDIPlus_PathClone($hPath)
    _GDIPlus_PathReverse($hPath_Clone) ;reverse path => end point of path = start point of cloned path

    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixScale($hMatrix, 1.5, 1.5)
    _GDIPlus_PathTransform($hPath_Clone, $hMatrix) ;zoom cloned path

    _GDIPlus_PathAddPath($hPath, $hPath_Clone) ;add scaled/reversed path to original path

    _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0) ;reset matrix
    _GDIPlus_MatrixTranslate($hMatrix, $iW / 2, $iH / 2, True)
    _GDIPlus_PathTransform($hPath, $hMatrix) ;move path to center of window

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PathDispose($hPath_Clone)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathSetFillMode

Function Reference

_GDIPlus_PathSetFillMode

Sets the fill mode of a path

#include <GDIPlus.au3>
_GDIPlus_PathSetFillMode ( $hPath, $iFillMode )

Parameters

$hPath | Pointer to a GraphicsPath object
$iFillMode | Path fill mode: 0 - The areas are filled according to the even-odd parity rule 1 - The areas are filled according to the nonzero winding rule

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathGetFillMode

See Also

Search GdipSetPathFillMode in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPen, $hPath

    ; Create GUI
    $hGUI = GUICreate("GDI+", 300, 220)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)

    $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)
    $hPen = _GDIPlus_PenCreate(0xFF8800AA, 2)

    $hPath = _GDIPlus_PathCreate(0) ;Create new path object
    _GDIPlus_PathAddRectangle($hPath, 50, 50, 100, 100)
    _GDIPlus_PathAddRectangle($hPath, 100, 80, 100, 100)
    _GDIPlus_PathAddRectangle($hPath, 120, 30, 100, 100)

    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Local $iTimer = TimerInit()
    Do
        If TimerDiff($iTimer) > 1000 Then
            _GDIPlus_PathSetFillMode($hPath, Not _GDIPlus_PathGetFillMode($hPath))
            _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)
            _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
            _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)
            $iTimer = TimerInit()
        EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathSetMarker

Function Reference

_GDIPlus_PathSetMarker

Designates the last point in a path as a marker point

#include <GDIPlus.au3>
_GDIPlus_PathSetMarker ( $hPath )

Parameters

$hPath Pointer to a GraphicsPath object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

A path can have markers that divide the path into sections. You can use a GraphicsPathIterator object to isolate one or more of those sections.

Related

_GDIPlus_PathIterNextMarkerPath

See Also

Search GdipSetPathMarker in MSDN Library.


Function _GDIPlus_PathStartFigure

Function Reference

_GDIPlus_PathStartFigure

Starts a new figure without closing the current figure. Subsequent points added to a path are added to the new figure

#include <GDIPlus.au3>
_GDIPlus_PathStartFigure ( $hPath )

Parameters

$hPath Pointer to a GraphicsPath object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathCloseFigure

See Also

Search GdipStartPathFigure in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen, $hPath

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 300)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hPen = _GDIPlus_PenCreate(0xFF8800AA, 2)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    _GDIPlus_PathAddLine($hPath, 40, 100, 140, 200)
    _GDIPlus_PathAddLine($hPath, 240, 100, 340, 200)

    _GDIPlus_PathStartFigure($hPath);next line will not be connected to last point

    _GDIPlus_PathAddLine($hPath, 440, 100, 540, 200)
    _GDIPlus_PathAddLine($hPath, 640, 100, 740, 200)

    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathTransform

Function Reference

_GDIPlus_PathTransform

Multiplies each of a path's data points by a specified matrix

#include <GDIPlus.au3>
_GDIPlus_PathTransform ( $hPath, $hMatrix )

Parameters

$hPath | Pointer to a GraphicsPath object
$hMatrix | Pointer to a Matrix object that specifies the transformation

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipTransformPath in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $iW, $iH, $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hFamily, $tLayout, $hMatrix, $aBounds

    ; Create GUI
    $iW = 640
    $iH = 220
    $hGUI = GUICreate("GDI+", $iW, $iH)
    GUISetState(@SW_SHOW)

    ; Draw a string using path
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFF000000)

    $hBrush = _GDIPlus_BrushCreateSolid(0xFFDD2200)
    $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    $hFamily = _GDIPlus_FontFamilyCreate("Arial") ;Create font family object
    $tLayout = _GDIPlus_RectFCreate() ;Create string bounding rectangle X=0, Y=0
    _GDIPlus_PathAddString($hPath, "Fit to Window", $tLayout, $hFamily) ;Add the outline of the string to the path

    ; Tranform Path to fit to window
    $aBounds = _GDIPlus_PathGetWorldBounds($hPath) ;Get bounding rectangle of the path
    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, -$aBounds[0], -$aBounds[1]) ;Translate Matrix to the offset of the bounding rectangle
    _GDIPlus_MatrixScale($hMatrix, $iW / $aBounds[2], $iH / $aBounds[3], True) ;Scale Matrix
    _GDIPlus_PathTransform($hPath, $hMatrix) ;Translate and Scale Path

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Tranform Path to center the path
    _GDIPlus_PathReset($hPath) ;Reset Path (delete previous string)
    _GDIPlus_PathAddString($hPath, "Center", $tLayout, $hFamily, 0, 100, 0) ;Add the outline of the string to the path

    $aBounds = _GDIPlus_PathGetWorldBounds($hPath)
    _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0) ;Reset Matrix
    _GDIPlus_MatrixTranslate($hMatrix, ($iW / 2) - $aBounds[0] - ($aBounds[2] / 2), ($iH / 2) - $aBounds[1] - ($aBounds[3] / 2))
    _GDIPlus_PathTransform($hPath, $hMatrix) ;Translate (offset) Path

    _GDIPlus_BrushSetSolidColor($hBrush, 0x7F004488)
    _GDIPlus_PenSetColor($hPen, 0xFF00AAFF)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathWarp

Function Reference

_GDIPlus_PathWarp

Applies a warp transformation to a path. The function also flattens (converts to a sequence of straight lines) the path

#include <GDIPlus.au3>
_GDIPlus_PathWarp ( $hPath, $hMatrix, $aPoints, $nX, $nY, $nWidth, $nHeight [, $iWarpMode = 0 [, $fFlatness = 0.25]] )

Parameters

$hPath | Pointer to a GraphicsPath object
$hMatrix | Pointer to a Matrix object that represents a transformation to be applied along with the warp.
$aPoints | Array of parallelogram points that, along with the rectangle parameters, define the wrap mode: [0][0] - Number of points. This number must be 3 or 4 [1][0] - Point 1 X coordinate [1][1] - Point 1 Y coordinate [2][0] - Point 2 X coordinate [2][1] - Point 2 Y coordinate [n][0] - Point n X coordinate [n][1] - Point n Y coordinate
$nX | X coordinate of the upper left corner of the rectangle to be transformed into a parallelogram defined by $aPoints
$nY | Y coordinate of the upper left corner of the rectangle to be transformed into a parallelogram defined by $aPoints
$nWidth | Width of the rectangle to be transformed into a parallelogram defined by $aPoints
$nHeight | Height of the rectangle to be transformed into a parallelogram defined by $aPoints
$iWarpMode | [optional] Kind of warp to be applied: 0 - Specifies the perspective warp mode 1 - Specifies the bilinear warp mode
$fFlatness | [optional] Real number that influences the number of line segments that are used to approximate the original path. Small values specify that many line segments are used, and large values specify that few line segments are used.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathFlatten

See Also

Search GdipWarpPath in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $iW, $iH, $hGUI, $hGraphic, $hBrush, $hPath, $hFormat, $hFamily, $tLayout

    ; Create GUI
    $iW = 600
    $iH = 300
    $hGUI = GUICreate("GDI+", $iW, $iH)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFF000000)

    $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFF00)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1) ;Set alignment to center

    $hFamily = _GDIPlus_FontFamilyCreate("Arial Black") ;Create font family object
    $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH) ;Create string bounding rectangle
    _GDIPlus_PathAddString($hPath, "AutoIt rulez!" & @LF & "and so does" & @LF & "STAR WARS ;)", $tLayout, $hFamily, 0, 64, $hFormat) ;Add the outline of the string to the path

    Local $aPoints[5][2]
    $aPoints[0][0] = 4
    $aPoints[1][0] = $iW * 0.3
    $aPoints[1][1] = $iH * 0.3
    $aPoints[2][0] = $iW * 0.7
    $aPoints[2][1] = $iH * 0.3
    $aPoints[3][0] = 0
    $aPoints[3][1] = $iH
    $aPoints[4][0] = $iW
    $aPoints[4][1] = $iH

    _GDIPlus_PathWarp($hPath, 0, $aPoints, 0, 0, $iW, $iH) ;Warp path

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathWiden

Function Reference

_GDIPlus_PathWiden

Replaces a path with curves that enclose the area that is filled when the path is drawn by a specified pen. The function also flattens the path

#include <GDIPlus.au3>
_GDIPlus_PathWiden ( $hPath, $hPen [, $hMatrix = 0 [, $fFlatness = 0.25]] )

Parameters

$hPath | Pointer to a GraphicsPath object
$hPen | Pointer to a Pen object. The path is made as wide as it would be when drawn by this pen. If 0, a solid black pen with a width of 1 will be used
$hMatrix | [optional] Pointer to a Matrix object that represents a transformation to be applied along with the widening. If 0, no transformation is applied
$fFlatness | [optional] Real number that specifies the maximum error between the path and its flattened approximation. Reducing the flatness increases the number of line segments in the approximation

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathFlatten, _GDIPlus_PathWarp, _GDIPlus_PathWindingModeOutline

See Also

Search GdipWidenPath in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 800, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $hPath = _GDIPlus_PathCreate()
    Local $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, 800, 400)
    _GDIPlus_PathAddString($hPath, "AutoIt rulez!", $tLayout, $hFamily, 0, 160, $hFormat)

    Local $hPen_Widen = _GDIPlus_PenCreate(0, 8)
    _GDIPlus_PenSetLineJoin($hPen_Widen, $GDIP_PENSETLINEJOIN_ROUND)
    _GDIPlus_PathWiden($hPath, $hPen_Widen)

    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF8800AA)
    _GDIPlus_GraphicsFillPath($hGraphics, $hPath, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen_Widen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathWindingModeOutline

Function Reference

_GDIPlus_PathWindingModeOutline

Transforms and flattens a path, and then converts the path's data points so that they represent only the outline of the path

#include <GDIPlus.au3>
_GDIPlus_PathWindingModeOutline ( $hPath [, $hMatrix = 0 [, $fFlatness = 0.25]] )

Parameters

$hPath | Pointer to a GraphicsPath object
$hMatrix | [optional] Pointer to a Matrix object that specifies the transformation. If 0, no transformation is applied
$fFlatness | [optional] Real number that specifies the maximum error between the path and its flattened approximation. Reducing the flatness increases the number of line segments in the approximation.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathFlatten, _GDIPlus_PathWarp

See Also

Search GdipWindingModeOutline in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hPath_Clone, $hMatrix

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)
    $hPen = _GDIPlus_PenCreate(0xFF8800AA, 2)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    _GDIPlus_PathAddLine($hPath, 106, 330, 200, 40)
    _GDIPlus_PathAddLine($hPath, 294, 330, 48, 151)
    _GDIPlus_PathAddLine($hPath, 352, 151, 106, 330)

    $hPath_Clone = _GDIPlus_PathClone($hPath) ;Create a copy of the path
    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, 400, 0)
    _GDIPlus_PathTransform($hPath_Clone, $hMatrix)

    _GDIPlus_PathWindingModeOutline($hPath_Clone) ;Outline

    _GDIPlus_GraphicsDrawString($hGraphic, "original path of 3 connected lines", 40, 10)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    _GDIPlus_GraphicsDrawString($hGraphic, "WindingModeOutline", 440, 10)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath_Clone, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath_Clone, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PathDispose($hPath_Clone)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


User Defined Functions

Image user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_DrawImageFX | Draws a portion of an image after applying a specified effect
_GDIPlus_DrawImageFXEx | Draws a portion of an image after applying a specified effect
_GDIPlus_DrawImagePoints | Draws an image at a specified location
_GDIPlus_ImageDispose | Release an image object
_GDIPlus_ImageGetDimension | Gets the width and height of an image which is supported by GDIPlus
_GDIPlus_ImageGetFlags | Returns enumeration of pixel data attributes contained in an image
_GDIPlus_ImageGetGraphicsContext | Get the graphics context of the image
_GDIPlus_ImageGetHeight | Get the image height
_GDIPlus_ImageGetHorizontalResolution | Returns horizontal resolution in DPI (pixels per inch) of an image
_GDIPlus_ImageGetPixelFormat | Returns pixel format of an image: Bits per pixel, Alpha channels, RGB, Grayscale, Indexed etc
_GDIPlus_ImageGetRawFormat | Returns file format GUID and image format name of an image
_GDIPlus_ImageGetThumbnail | Gets a thumbnail image from this Image object
_GDIPlus_ImageGetType | Returns type (bitmap or metafile) of an image
_GDIPlus_ImageGetVerticalResolution | Returns vertical resolution in DPI (pixels per inch) of an image
_GDIPlus_ImageGetWidth | Get the image width
_GDIPlus_ImageLoadFromFile | Create an image object based on a file
_GDIPlus_ImageLoadFromStream | Creates an Image object based on a stream
_GDIPlus_ImageResize | Resize an image to a new given size
_GDIPlus_ImageRotateFlip | Rotates and flips an image
_GDIPlus_ImageSaveToFile | Save an image to file
_GDIPlus_ImageSaveToFileEx | Save an image to file
_GDIPlus_ImageSaveToStream | Saves an Image object to a stream
_GDIPlus_ImageScale | Scales an image by a given factor


Function _GDIPlus_DrawImageFX

Function Reference

_GDIPlus_DrawImageFX

Draws a portion of an image after applying a specified effect

#include <GDIPlus.au3>
_GDIPlus_DrawImageFX ( $hGraphics, $hImage, $hEffect [, $tRECTF = 0 [, $hMatrix = 0 [, $hImgAttributes = 0 [, $iUnit = 2]]]] )

Parameters

$hGraphics | Handle to a Graphics object.
$hImage | Handle to an Image object.
$hEffect | Handle to an Effect that is applied to the image before rendering. The image is not permanently altered by the effect.
$tRECTF | [optional] $tagGDIPRECTF structure that specifies the portion of the image to be drawn.
$hMatrix | [optional] Handle to a Matrix object that specifies the parallelogram in which the image portion is rendered.
$hImgAttributes | [optional] Handle to an ImageAttributes object that specifies color adjustments to be applied when the image is rendered.
$iUnit | [optional] Specifies the unit of measure for the image.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Related

$tagGDIPRECTF, _GDIPlus_DrawImageFXEx, _GDIPlus_EffectCreate

See Also

Search GdipDrawImageFX in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    Local $iImgW = _GDIPlus_ImageGetWidth($hImage)
    Local $iImgH = _GDIPlus_ImageGetHeight($hImage)

    Local $iWidth = 600
    Local $iHeight = $iImgH * 600 / $iImgW

    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsDrawImageRect($hContext, $hImage, 0, 0, $iWidth, $iHeight)

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)

    Local $hEffect = _GDIPlus_EffectCreateHueSaturationLightness(-90)
    Local $tRECTF = _GDIPlus_RectFCreate($iWidth * 0.25, $iHeight * 0.25, $iWidth * 0.5, $iHeight * 0.5)
    _GDIPlus_DrawImageFX($hGraphics, $hBitmap, $hEffect, $tRECTF)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


Function _GDIPlus_DrawImageFXEx

Function Reference

_GDIPlus_DrawImageFXEx

Draws a portion of an image after applying a specified effect

#include <GDIPlus.au3>
_GDIPlus_DrawImageFXEx ( $hGraphics, $hImage, $hEffect [, $nX = 0 [, $nY = 0 [, $nW = 0 [, $nH = 0 [, $hMatrix = 0 [, $hImgAttributes = 0 [, $iUnit = 2]]]]]]] )

Parameters

$hGraphics | Handle to a Graphics object.
$hImage | Handle to an Image object.
$hEffect | Handle to an Effect that is applied to the image before rendering. The image is not permanently altered by the effect.
$nX | [optional] X coordinate of upper left hand corner of the portion of the image to be drawn.
$nY | [optional] X coordinate of upper left hand corner of the portion of the image to be drawn.
$nW | [optional] Width of the portion rectangle of the image to be drawn.
$nH | [optional] Height of the portion rectangle of the image to be drawn.
$hMatrix | [optional] Handle to a Matrix object that specifies the parallelogram in which the image portion is rendered.
$hImgAttributes | [optional] Handle to an ImageAttributes object that specifies color adjustments to be applied when the image is rendered.
$iUnit | [optional] Specifies the unit of measure for the image.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | -1 - GDIPlus.dll does not support this function. 10 - Invalid parameters.

Related

_GDIPlus_DrawImageFX, _GDIPlus_EffectCreate

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Or @extended < 6 Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * 600 / _GDIPlus_ImageGetWidth($hImage)

    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsDrawImageRect($hContext, $hImage, 0, 0, $iWidth, $iHeight)

    Local $hGui = GUICreate("GDI+ v1.1 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    Local $hEffect = _GDIPlus_EffectCreate($GDIP_HueSaturationLightnessEffectGuid)
    Local $tEffectParameters = DllStructCreate($tagGDIP_EFFECTPARAMS_HueSaturationLightness)

    Local $fW, $fH
    For $i = 1 To 140
        DllStructSetData($tEffectParameters, "HueLevel", Random(-180, 180, 1))
        _GDIPlus_EffectSetParameters($hEffect, $tEffectParameters)
        $fW = Random(20, 100)
        $fH = Random(20, 100)
        _GDIPlus_DrawImageFXEx($hGraphics, $hBitmap, $hEffect, Random(0, $iWidth - $fW), Random(0, $iHeight - $fH), $fW, $fH)
    Next

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example


Function _GDIPlus_DrawImagePoints

Function Reference

_GDIPlus_DrawImagePoints

Draws an image at a specified location

#include <GDIPlus.au3>
_GDIPlus_DrawImagePoints ( $hGraphic, $hImage, $nULX, $nULY, $nURX, $nURY, $nLLX, $nLLY [, $iCount = 3] )

Parameters

$hGraphic | Handle to a Graphics object
$hImage | Handle to an Image object
$nULX | The X coordinate of the upper left corner of the source image
$nULY | The Y coordinate of the upper left corner of the source image
$nURX | The X coordinate of the upper right corner of the source image
$nURY | The Y coordinate of the upper right corner of the source image
$nLLX | The X coordinate of the lower left corner of the source image
$nLLY | The Y coordinate of the lower left corner of the source image
$iCount | [optional] Specifies the number of points (x,y)'s in the structure.

Return Value

Success: | True
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code (GDIP_ERR*).

Remarks

The value of the count parameter must equal 3 to specify the coordinates of the upper-left corner, upper-right corner, and lower-left corner of the parallelogram.
The coordinate of the lower-right corner, the width, and the height of the image, are calculated using the three given coordinates.
The image is scaled to fit the parallelogram.

See Also

Search GdipDrawImagePoints in MSDN Library.

Example

#include <GDIPlus.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphic

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture full screen
    $hBitmap1 = _ScreenCapture_Capture("")
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1)

    ; Capture screen region
    $hBitmap2 = _ScreenCapture_Capture("", 0, 0, 400, 300)
    $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap2)

    ; Draw one image in another
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)

    _GDIPlus_DrawImagePoints($hGraphic, $hImage2, 100, 100, 600, 170, 130, 570)

    ; Draw a frame around the inserted image
    _GDIPlus_GraphicsDrawRect($hGraphic, 100, 100, 400, 300)

    ; Save resultant image
    _GDIPlus_ImageSaveToFile($hImage1, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _WinAPI_DeleteObject($hBitmap1)
    _WinAPI_DeleteObject($hBitmap2)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
EndFunc   ;==>Example


Function _GDIPlus_ImageDispose

Function Reference

_GDIPlus_ImageDispose

Release an image object

#include <GDIPlus.au3>
_GDIPlus_ImageDispose ( $hImage )

Parameters

$hImage Handle to an image object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipDisposeImage in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_aCodex, $g_hImage

Example()

Func Example()
    Local $hBitmap

    ; Create GUI
    GUICreate("GDI+", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Create an image to use for paramater lists
    $hBitmap = _ScreenCapture_Capture("", 0, 0, 1, 1)
    $g_hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; Show encoder parameters
    $g_aCodex = _GDIPlus_Encoders()
    ShowCodex("Encoder")

    ; Show decoder parameters
    $g_aCodex = _GDIPlus_Decoders()
    ShowCodex("Decoder")

    ; Clean up resources
    _GDIPlus_ImageDispose($g_hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Show codex information
Func ShowCodex($sTitle)
    Local $iI, $iJ, $iK, $sCLSID, $tData, $tParam, $tParams, $iParamSize = _GDIPlus_ParamSize()

    For $iI = 1 To $g_aCodex[0][0]
        $sCLSID = _GDIPlus_EncodersGetCLSID($g_aCodex[$iI][5])
        MemoWrite("Image " & $sTitle & " " & $iI)
        MemoWrite("  Codec GUID ............: " & $g_aCodex[$iI][1])
        MemoWrite("  File format GUID ......: " & $g_aCodex[$iI][2])
        MemoWrite("  Codec name ............: " & $g_aCodex[$iI][3])
        MemoWrite("  Codec Dll file name ...: " & $g_aCodex[$iI][4])
        MemoWrite("  Codec file format .....: " & $g_aCodex[$iI][5])
        MemoWrite("  File name extensions ..: " & $g_aCodex[$iI][6])
        MemoWrite("  Mime type .............: " & $g_aCodex[$iI][7])
        MemoWrite("  Flags .................: 0x" & Hex($g_aCodex[$iI][8]))
        MemoWrite("  Version ...............: " & $g_aCodex[$iI][9])
        MemoWrite("  Signature count .......: " & $g_aCodex[$iI][10])
        MemoWrite("  Signature size ........: " & $g_aCodex[$iI][11])
        MemoWrite("  Signature pattern ptr .: 0x" & Hex($g_aCodex[$iI][12]))
        MemoWrite("  Signature mask ptr ....: 0x" & Hex($g_aCodex[$iI][13]))

;~      If $sTitle = "Decoder" Then ContinueLoop

        MemoWrite("  Parameter list size ...: " & _GDIPlus_EncodersGetParamListSize($g_hImage, $sCLSID))

        $tParams = _GDIPlus_EncodersGetParamList($g_hImage, $sCLSID)
        If @error Then
            MemoWrite()
            ContinueLoop
        EndIf

        MemoWrite("  Parameters Count ......: " & DllStructGetData($tParams, "Count"))
        MemoWrite()
        For $iJ = 0 To DllStructGetData($tParams, "Count") - 1
            MemoWrite("  Image " & $sTitle & " " & $iI & " Parameter " & $iJ)
            $tParam = DllStructCreate($tagGDIPENCODERPARAM, DllStructGetPtr($tParams, "GUID") + ($iJ * $iParamSize))
            MemoWrite("    Parameter GUID ......: " & _WinAPI_StringFromGUID(DllStructGetPtr($tParam, "GUID")))
            MemoWrite("    Number of values ....: " & DllStructGetData($tParam, "NumberOfValues"))
            MemoWrite("    Parameter type.......: " & DllStructGetData($tParam, "Type"))
            MemoWrite("    Parameter pointer ...: 0x" & Hex(DllStructGetData($tParam, "Values")))
            Switch DllStructGetData($tParam, "Type")
                Case 4
                    $tData = DllStructCreate("int Data[" & DllStructGetData($tParam, "NumberOfValues") & "]", DllStructGetData($tParam, "Values"))
                    For $iK = 1 To DllStructGetData($tParam, "NumberOfValues")
                        MemoWrite("      Value .............: " & DllStructGetData($tData, 1, $iK))
                    Next
                Case 6
                    $tData = DllStructCreate("int Low;int High", DllStructGetData($tParam, "Values"))
                    MemoWrite("      Low range .........: " & DllStructGetData($tData, "Low"))
                    MemoWrite("      High range ........: " & DllStructGetData($tData, "High"))
            EndSwitch
            MemoWrite()
        Next
    Next
EndFunc   ;==>ShowCodex


Function _GDIPlus_ImageGetDimension

Function Reference

_GDIPlus_ImageGetDimension

Gets the width and height of an image which is supported by GDIPlus

#include <GDIPlus.au3>
_GDIPlus_ImageGetDimension ( $hImage )

Parameters

$hImage A handle to image object

Return Value

Success: | An array with two entries: Array[0] = width of the image object Array[1] = height of the image object.
Failure: | Sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_ImageGetWidth, _GDIPlus_ImageGetHeight

See Also

Search GdipGetImageDimension in MSDN Library.

Example

#include <GDIPlus.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aDim, $hImage, $sFile

    $sFile = FileOpenDialog("Please select an image", "", "Image (*.jpg;*.png;*.bmp;*.gif;*.tif)", BitOR($FD_PATHMUSTEXIST, $FD_FILEMUSTEXIST))
    If @error Then Exit MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "No image file has been selected", 30)

    _GDIPlus_Startup()

    $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    If @error Or Not $hImage Then
        MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "This file isn't supported by GDIPlus!")
    Else
        $aDim = _GDIPlus_ImageGetDimension($hImage)
        MsgBox($MB_ICONINFORMATION, "Information", "Image dimension of " & @CRLF & $sFile & @CRLF & @CRLF & "Width = " & $aDim[0] & " pixel" & @CRLF & "Height = " & $aDim[1] & " pixel")
        _GDIPlus_ImageDispose($hImage)
    EndIf

    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_ImageGetFlags

Function Reference

_GDIPlus_ImageGetFlags

Returns enumeration of pixel data attributes contained in an image

#include <GDIPlus.au3>
_GDIPlus_ImageGetFlags ( $hImage )

Parameters

$hImage Handle to an image object

Return Value

Success: | an array with the following format: [0] - Integer flag set of pixel data attributes [1] - String of pixel data attributes separated by delimiter "|"
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | 10 - Flags cannot be retrieved 11 - Invalid image handle 12 - No pixel data

Remarks

Use BitAND on returned integer flag set with $GDIP_IMAGEFLAGS_* constants.

Related

_GDIPlus_ImageGetPixelFormat

See Also

Search GdipGetImageFlags in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hBitmap, $hImage, $aRet

    ; Create GUI
    GUICreate("GDI+", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture 32 bit bitmap
    $hBitmap = _ScreenCapture_Capture("")
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; Show enumeration of pixel data attributes for screen capture
    $aRet = _GDIPlus_ImageGetFlags($hImage)
    $aRet[1] = @CRLF & StringReplace($aRet[1], "|", @CRLF)
    MemoWrite("Image pixel data attributes of screen capture: " & $aRet[1]);
    MemoWrite();
    MemoWrite("Image flag set of pixel data attributes: " & $aRet[0]);
    MemoWrite();

    ; Save screen capture bitmap to file
    _GDIPlus_ImageSaveToFile($hImage, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Load screen capture bitmap from file
    $hImage = _GDIPlus_ImageLoadFromFile(@MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Show enumeration of pixel data attributes for saved file
    $aRet = _GDIPlus_ImageGetFlags($hImage)
    $aRet[1] = @CRLF & StringReplace($aRet[1], "|", @CRLF)
    MemoWrite("Image pixel data attributes of saved file: " & $aRet[1]);
    MemoWrite();
    MemoWrite("Image flag set of pixel data attributes: " & $aRet[0]);

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GDIPlus_ImageGetGraphicsContext

Function Reference

_GDIPlus_ImageGetGraphicsContext

Get the graphics context of the image

#include <GDIPlus.au3>
_GDIPlus_ImageGetGraphicsContext ( $hImage )

Parameters

$hImage Handle to an image object

Return Value

Success: | a handle to a Graphics object.
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetImageGraphicsContext in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphics

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture full screen
    $hBitmap1 = _ScreenCapture_Capture("")
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1)

    ; Capture screen region
    $hBitmap2 = _ScreenCapture_Capture("", 0, 0, 400, 300)
    $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap2)

    ; Draw one image in another
    $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage1)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hImage2, 100, 100)

    ; Draw a frame around the inserted image
    _GDIPlus_GraphicsDrawRect($hGraphics, 100, 100, 400, 300)

    ; Save resultant image
    _GDIPlus_ImageSaveToFile($hImage1, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _WinAPI_DeleteObject($hBitmap1)
    _WinAPI_DeleteObject($hBitmap2)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
EndFunc   ;==>Example


Function _GDIPlus_ImageGetHeight

Function Reference

_GDIPlus_ImageGetHeight

Get the image height

#include <GDIPlus.au3>
_GDIPlus_ImageGetHeight ( $hImage )

Parameters

$hImage Handle to an image object

Return Value

Success: | the image height, in pixels.
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_ImageGetWidth

See Also

Search GdipGetImageHeight in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hBitmap, $hClone, $hImage, $iX, $iY

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture 32 bit bitmap
    $hBitmap = _ScreenCapture_Capture("")
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; Create 24 bit bitmap clone
    $iX = _GDIPlus_ImageGetWidth($hImage)
    $iY = _GDIPlus_ImageGetHeight($hImage)
    $hClone = _GDIPlus_BitmapCloneArea($hImage, 0, 0, $iX, $iY, $GDIP_PXF24RGB)

    ; Save bitmap to file
    _GDIPlus_ImageSaveToFile($hClone, @MyDocumentsDir & "\GDIPlus_Image.bmp")

    ; Clean up resources
    _GDIPlus_ImageDispose($hClone)
    _GDIPlus_ImageDispose($hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.bmp")
EndFunc   ;==>Example


Function _GDIPlus_ImageGetHorizontalResolution

Function Reference

_GDIPlus_ImageGetHorizontalResolution

Returns horizontal resolution in DPI (pixels per inch) of an image

#include <GDIPlus.au3>
_GDIPlus_ImageGetHorizontalResolution ( $hImage )

Parameters

$hImage Handle to an image object

Return Value

Success: | an integer of DPI (pixels per inch).
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | 10 - DPI cannot be retrieved. 11 - Invalid image handle.

Related

_GDIPlus_ImageGetVerticalResolution

See Also

Search GdipGetImageHorizontalResolution in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hBitmap, $hImage

    ; Create GUI
    GUICreate("GDI+", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture 32 bit bitmap
    $hBitmap = _ScreenCapture_Capture("")
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; Show horizontal resolution in DPI (dots per inch) of image
    MemoWrite("HorizontalResolution DPI : " & _GDIPlus_ImageGetHorizontalResolution($hImage));

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GDIPlus_ImageGetPixelFormat

Function Reference

_GDIPlus_ImageGetPixelFormat

Returns pixel format of an image: Bits per pixel, Alpha channels, RGB, Grayscale, Indexed etc

#include <GDIPlus.au3>
_GDIPlus_ImageGetPixelFormat ( $hImage )

Parameters

$hImage Handle to an image object

Return Value

Success: | an array with the following format: [0] - Integer of pixel format constant [1] - String of pixel format
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | 10 - Invalid pixel format. 11 - Invalid image handle. 12 - Unknown pixel format.

Related

_GDIPlus_BitmapCloneArea, _GDIPlus_BitmapLockBits, _GDIPlus_ImageGetFlags

See Also

Search GdipGetImagePixelFormat in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hBitmap, $hImage, $aRet

    ; Create GUI
    GUICreate("GDI+", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture 32 bit bitmap
    $hBitmap = _ScreenCapture_Capture("")
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; Show pixel format for screen capture
    $aRet = _GDIPlus_ImageGetPixelFormat($hImage)
    MemoWrite("Image pixel format of screen capture: " & $aRet[1]);
    MemoWrite("Image pixel format constant: " & $aRet[0]);
    MemoWrite();

    ; Save screen capture bitmap to file
    _GDIPlus_ImageSaveToFile($hImage, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Load screen capture bitmap from file
    $hImage = _GDIPlus_ImageLoadFromFile(@MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Show pixel format for saved file
    $aRet = _GDIPlus_ImageGetPixelFormat($hImage)
    MemoWrite("Image pixel format of saved file: " & $aRet[1]);
    MemoWrite("Image pixel format constant: " & $aRet[0]);

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GDIPlus_ImageGetRawFormat

Function Reference

_GDIPlus_ImageGetRawFormat

Returns file format GUID and image format name of an image

#include <GDIPlus.au3>
_GDIPlus_ImageGetRawFormat ( $hImage )

Parameters

$hImage Handle to an image object

Return Value

Success: | an array with the following format: [0] - String of file format GUID [1] - String of image format name
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | 10 - Invalid raw format. 11 - Invalid image handle. 12 - Invalid file format GUID. 13 - Unknown file format GUID.

Related

_GDIPlus_ImageGetType

See Also

Search GdipGetImageRawFormat in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hBitmap, $hImage, $aRet

    ; Create GUI
    GUICreate("GDI+", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture 32 bit bitmap
    $hBitmap = _ScreenCapture_Capture("")
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; Show image format for screen capture
    $aRet = _GDIPlus_ImageGetRawFormat($hImage)
    MemoWrite("Image format of screen capture: " & $aRet[1]);
    MemoWrite("GUID: " & $aRet[0]);
    MemoWrite();

    ; Save screen capture bitmap to file
    _GDIPlus_ImageSaveToFile($hImage, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Load screen capture bitmap from file
    $hImage = _GDIPlus_ImageLoadFromFile(@MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Show image format for saved file
    $aRet = _GDIPlus_ImageGetRawFormat($hImage)
    MemoWrite("Image format of saved file: " & $aRet[1]);
    MemoWrite("GUID: " & $aRet[0]);

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GDIPlus_ImageGetThumbnail

Function Reference

_GDIPlus_ImageGetThumbnail

Gets a thumbnail image from this Image object

#include <GDIPlus.au3>
_GDIPlus_ImageGetThumbnail ( $hImage [, $iWidth = 0 [, $iHeight = 0 [, $bKeepRatio = True [, $hCallback = Null [, $hCallbackData = Null]]]]] )

Parameters

$hImage | A handle to image object
$iWidth | [optional] Width, in pixels, of the requested thumbnail image. Default is 0.
$iHeight | [optional] Height, in pixels, of the requested thumbnail image. Default is 0.
$bKeepRatio | [optional] If true destination width and height of the image will be recalculated to keep image aspect ratio. Default is True.
$hCallback | [optional] Callback function that you provide. During the process of creating or retrieving the thumbnail image, Microsoft Windows GDI+ calls this function to give you the opportunity to abort the process. The default value is NULL.
$hCallbackData | [optional] Pointer to a block of memory that contains data to be used by the callback function. The default value is NULL.

Return Value

Success: | Handle to an Image object that contains the thumbnail image.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

A thumbnail image is a small copy of an image. Some image files have a thumbnail image embedded in the file. In such cases, this method retrieves the embedded thumbnail image. If there is no embedded thumbnail image, this method creates a thumbnail image by scaling the main image to the size specified in the thumbWidth and thumbHeight parameters. If both of those parameters are 0, a system-defined size is used.
Don't forget to dispose the thumbnail imgage using _GDIPlus_ImageDispose().

Related

_GDIPlus_GraphicsCreateFromHWND, _GDIPlus_ImageLoadFromFile, _GDIPlus_ImageDispose

See Also

Search GdipGetImageThumbnail in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GuiConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $sFile, $hGUI, $hGraphic, $hThumbnail, $iW_new, $iH_new

    $sFile = FileOpenDialog("Please select an image", "", "Image (*.jpg;*.png;*.bmp;*.gif;*.tif)", BitOR($FD_PATHMUSTEXIST, $FD_FILEMUSTEXIST))
    If @error Then Exit MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "No image file has been selected", 30)

    _GDIPlus_Startup()

    $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    If @error Or Not $hImage Then
        MsgBox(BitOR($MB_TOPMOST, $MB_ICONERROR), "Error", "This file isn't supported by GDIPlus!")
    Else
        $hGUI = GUICreate("GDI+ _GDIPlus_ImageGetThumbnail Demo", 320, 200)
        GUISetBkColor(0x202020)
        GUISetState()

        $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
        $hThumbnail = _GDIPlus_ImageGetThumbnail($hImage, 96, 96)
        $iW_new = _GDIPlus_ImageGetWidth($hThumbnail)
        $iH_new = _GDIPlus_ImageGetHeight($hThumbnail)
        _GDIPlus_GraphicsDrawImageRect($hGraphic, $hThumbnail, (320 - $iW_new) / 2, (200 - $iH_new) / 2, $iW_new, $iH_new) ;center image in GUI

        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

        _GDIPlus_ImageDispose($hImage)
        _GDIPlus_ImageDispose($hThumbnail)
    EndIf

    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_ImageGetType

Function Reference

_GDIPlus_ImageGetType

Returns type (bitmap or metafile) of an image

#include <GDIPlus.au3>
_GDIPlus_ImageGetType ( $hImage )

Parameters

$hImage Handle to an image object

Return Value

Success: | an integer of image type: $GDIP_IMAGETYPE_UNKNOWN - Non bitmap file or not identified as bitmap by GDI+ $GDIP_IMAGETYPE_BITMAP - Bitmap types: BMP, PNG, GIF, JPEG, TIFF, ICO, EXIF $GDIP_IMAGETYPE_METAFILE - Metafile types: EMF, WMF
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | 10 - Invalid image type. 11 - Invalid image handle.

Related

_GDIPlus_ImageGetRawFormat

See Also

Search GdipGetImageType in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hBitmap, $hImage, $iImageType, $sImageType

    ; Create GUI
    GUICreate("GDI+", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture 32 bit bitmap
    $hBitmap = _ScreenCapture_Capture("")
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    $iImageType = _GDIPlus_ImageGetType($hImage)
    Switch $iImageType
        Case $GDIP_IMAGETYPE_UNKNOWN
            $sImageType = "Unrecognized bitmap format or not image file"
        Case $GDIP_IMAGETYPE_BITMAP ; BMP, PNG, GIF, JPEG, TIFF, ICO, EXIF
            $sImageType = "Bitmap"
        Case $GDIP_IMAGETYPE_METAFILE ; EMF, WMF
            $sImageType = "Metafile"
    EndSwitch

    ; Show image type: Unidentified = 0, Bitmap = 1, Metafile = 2)
    MemoWrite("Image type: " & $sImageType);

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GDIPlus_ImageGetVerticalResolution

Function Reference

_GDIPlus_ImageGetVerticalResolution

Returns vertical resolution in DPI (pixels per inch) of an image

#include <GDIPlus.au3>
_GDIPlus_ImageGetVerticalResolution ( $hImage )

Parameters

$hImage Handle to an image object

Return Value

Success: | an integer of DPI (pixels per inch).
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).
@error: | 11 - Invalid DPI. 10 - Invalid image handle.

Related

_GDIPlus_ImageGetHorizontalResolution

See Also

Search GdipGetImageVerticalResolution in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hBitmap, $hImage

    ; Create GUI
    GUICreate("GDI+", 600, 400)
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture 32 bit bitmap
    $hBitmap = _ScreenCapture_Capture("")
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; Show vertical resolution in DPI (dots per inch) of image
    MemoWrite("VerticalResolution DPI : " & _GDIPlus_ImageGetVerticalResolution($hImage));

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage = '')
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GDIPlus_ImageGetWidth

Function Reference

_GDIPlus_ImageGetWidth

Get the image width

#include <GDIPlus.au3>
_GDIPlus_ImageGetWidth ( $hImage )

Parameters

$hImage Handle to an image object

Return Value

Success: | an image width, in pixels.
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_ImageGetHeight

See Also

Search GdipGetImageWidth in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hBitmap, $hClone, $hImage, $iX, $iY

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture 32 bit bitmap
    $hBitmap = _ScreenCapture_Capture("")
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    ; Create 24 bit bitmap clone
    $iX = _GDIPlus_ImageGetWidth($hImage)
    $iY = _GDIPlus_ImageGetHeight($hImage)
    $hClone = _GDIPlus_BitmapCloneArea($hImage, 0, 0, $iX, $iY, $GDIP_PXF24RGB)

    ; Save bitmap to file
    _GDIPlus_ImageSaveToFile($hClone, @MyDocumentsDir & "\GDIPlus_Image.bmp")

    ; Clean up resources
    _GDIPlus_ImageDispose($hClone)
    _GDIPlus_ImageDispose($hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.bmp")
EndFunc   ;==>Example


Function _GDIPlus_ImageLoadFromFile

Function Reference

_GDIPlus_ImageLoadFromFile

Create an image object based on a file

#include <GDIPlus.au3>
_GDIPlus_ImageLoadFromFile ( $sFileName )

Parameters

$sFileName Fully qualified image file name

Return Value

Success: | a handle to the new image object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_ImageSaveToFile, _GDIPlus_ImageSaveToFileEx

See Also

Search GdipLoadImageFromFile in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    Local $hImage, $sCLSID, $tData, $tParams

    ; Screen Capture
    _ScreenCapture_Capture(@MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Load image
    $hImage = _GDIPlus_ImageLoadFromFile(@MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Get JPEG encoder CLSID
    $sCLSID = _GDIPlus_EncodersGetCLSID("JPG")

    ; Set up parameters for 90 degree rotation
    $tData = DllStructCreate("int Data")
    DllStructSetData($tData, "Data", $GDIP_EVTTRANSFORMROTATE90)
    $tParams = _GDIPlus_ParamInit(1)
    _GDIPlus_ParamAdd($tParams, $GDIP_EPGTRANSFORMATION, 1, $GDIP_EPTLONG, DllStructGetPtr($tData, "Data"))

    ; Save image with rotation
    _GDIPlus_ImageSaveToFileEx($hImage, @MyDocumentsDir & "\GDIPlus_Image2.jpg", $sCLSID, $tParams)

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image2.jpg")
EndFunc   ;==>Example

Example 2

; PNG work around by Zedna

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

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

; Create GUI
Global $g_hGUI = GUICreate("Show PNG", 250, 250)

; Load PNG image
_GDIPlus_Startup()
Global $g_hImage = _GDIPlus_ImageLoadFromFile("..\GUI\Torus.png")
Global $g_hGraphic = _GDIPlus_GraphicsCreateFromHWND($g_hGUI)

GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT")
GUISetState(@SW_SHOW)

; Loop until the user exits.
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd

; Clean up resources
_GDIPlus_GraphicsDispose($g_hGraphic)
_GDIPlus_ImageDispose($g_hImage)
_GDIPlus_Shutdown()

; Draw PNG image
Func MY_WM_PAINT($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam
    _WinAPI_RedrawWindow($g_hGUI, 0, 0, $RDW_UPDATENOW)
    _GDIPlus_GraphicsDrawImage($g_hGraphic, $g_hImage, 0, 0)
    _WinAPI_RedrawWindow($g_hGUI, 0, 0, $RDW_VALIDATE)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_PAINT


Function _GDIPlus_ImageLoadFromStream

Function Reference

_GDIPlus_ImageLoadFromStream

Creates an Image object based on a stream

#include <GDIPlus.au3>
_GDIPlus_ImageLoadFromStream ( $pStream )

Parameters

$pStream Pointer to an IStream interface

Return Value

Success: | a pointer to a new Image object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_ImageDispose() to release the object resources.

Related

_GDIPlus_ImageDispose

See Also

Search GdipLoadImageFromStream in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup()
    Local Const $iW = @DesktopWidth / 2, $iH = @DesktopHeight / 2
    Local $hGUI = GUICreate("GDI+ test", $iW, $iH, -1, -1)
    GUISetState(@SW_SHOW)

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, @DesktopWidth / 2, @DesktopHeight / 2) ;create a GDI bitmap by capturing 1/4 of desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI bitmap to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore

    Local $sImgCLSID = _GDIPlus_EncodersGetCLSID("jpg") ;create CLSID for a JPG image file type
    Local $tGUID = _WinAPI_GUIDFromString($sImgCLSID) ;convert CLSID GUID to binary form and returns $tagGUID structure
    Local $tParams = _GDIPlus_ParamInit(1) ;initialize an encoder parameter list and return $tagGDIPENCODERPARAMS structure
    Local $tData = DllStructCreate("int Quality") ;create struct to set JPG quality setting
    DllStructSetData($tData, "Quality", 10) ;quality 0-100 (0: lowest, 100: highest)
    Local $pData = DllStructGetPtr($tData) ;get pointer from quality struct
    _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) ;add a value to an encoder parameter list
    Local $pParams = DllStructGetPtr($tParams) ;get pointer of encoder parameter list
    Local $pStream = _WinAPI_CreateStreamOnHGlobal() ;create stream
    _GDIPlus_ImageSaveToStream($hBitmap, $pStream, $tGUID, $pParams) ;save the bitmap in JPG format in memory
    Local $hImageFromStream = _GDIPlus_ImageLoadFromStream($pStream) ;create bitmap from a stream (here from the JPG in memory)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsDrawImage($hGraphics, $hImageFromStream, 0, 0) ;display streamed image

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    ;cleanup resources
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_ImageDispose($hImageFromStream)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_ImageResize

Function Reference

_GDIPlus_ImageResize

Resize an image to a new given size

#include <GDIPlus.au3>
_GDIPlus_ImageResize ( $hImage, $iNewWidth, $iNewHeight [, $iInterpolationMode = $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC] )

Parameters

$hImage | A handle value
$iNewWidth | An integer value
$iNewHeight | An integer value
$iInterpolationMode | [optional] An integer value. Default is $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC.

Return Value

Success: | a handle to a new Bitmap object
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - unable to create new bitmap 2 - unable to create graphics context 3 - unable to set interpolation mode on graphics context 4 - unable to copy image to scaled bitmap

Related

_GDIPlus_BitmapCreateFromScan0, _GDIPlus_GraphicsDrawImageRect, _GDIPlus_GraphicsSetInterpolationMode, _GDIPlus_ImageGetGraphicsContext

Example

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup()
    Local Const $iW = @DesktopWidth, $iH = @DesktopHeight

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iW, $iH) ;create a GDI bitmap by capturing full screen of the desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI bitmap to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore

    Local $hBitmap_Scaled = _GDIPlus_ImageResize($hBitmap, $iW / 4, $iH / 4) ;resize image

    Local $hGUI = GUICreate("GDI+ test", $iW / 4, $iH / 4, -1, -1) ;create a test gui to display the resized image
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, 0, 0) ;display scaled image

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    ;cleanup resources
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap_Scaled)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_ImageRotateFlip

Function Reference

_GDIPlus_ImageRotateFlip

Rotates and flips an image

#include <GDIPlus.au3>
_GDIPlus_ImageRotateFlip ( $hImage, $iRotateFlipType )

Parameters

$hImage | Pointer to an Image object
$iRotateFlipType | Type of rotation and flip: 0 - No rotation and no flipping (A 180-degree rotation, a horizontal flip and then a vertical flip) 1 - A 90-degree rotation without flipping (A 270-degree rotation, a horizontal flip and then a vertical flip) 2 - A 180-degree rotation without flipping (No rotation, a horizontal flip followed by a vertical flip) 3 - A 270-degree rotation without flipping (A 90-degree rotation, a horizontal flip and then a vertical flip) 4 - No rotation and a horizontal flip (A 180-degree rotation followed by a vertical flip) 5 - A 90-degree rotation followed by a horizontal flip (A 270-degree rotation followed by a vertical flip) 6 - A 180-degree rotation followed by a horizontal flip (No rotation and a vertical flip) 7 - A 270-degree rotation followed by a horizontal flip (A 90-degree rotation followed by a vertical flip)

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipImageRotateFlip in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup()
    Local Const $iW = @DesktopWidth / 2, $iH = @DesktopHeight / 2

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, @DesktopWidth / 2, @DesktopHeight / 2) ;create a GDI bitmap by capturing 1/4 of desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI bitmap to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore
    _GDIPlus_ImageRotateFlip($hBitmap, 1) ;rotate image by 90 degrees without flipping

    Local $hGUI = GUICreate("GDI+ test", $iH, $iW, -1, -1) ;create a test gui to display the rotated image
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) ;display rotated image

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    ;cleanup resources
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_ImageSaveToFile

Function Reference

_GDIPlus_ImageSaveToFile

Save an image to file

#include <GDIPlus.au3>
_GDIPlus_ImageSaveToFile ( $hImage, $sFileName )

Parameters

$hImage | Handle to an image object
$sFileName | Fully qualified image file name

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_ImageLoadFromFile, _GDIPlus_ImageSaveToFileEx

See Also

Search GdipSaveImageToFile in MSDN Library.

Example

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

Example()

Func Example()
    Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphics

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture full screen
    $hBitmap1 = _ScreenCapture_Capture("")
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1)

    ; Capture screen region
    $hBitmap2 = _ScreenCapture_Capture("", 0, 0, 400, 300)
    $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap2)

    ; Draw one image in another
    $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage1)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hImage2, 100, 100)

    ; Draw a frame around the inserted image
    _GDIPlus_GraphicsDrawRect($hGraphics, 100, 100, 400, 300)

    ; Save resultant image
    _GDIPlus_ImageSaveToFile($hImage1, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _WinAPI_DeleteObject($hBitmap1)
    _WinAPI_DeleteObject($hBitmap2)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
EndFunc   ;==>Example


Function _GDIPlus_ImageSaveToFileEx

Function Reference

_GDIPlus_ImageSaveToFileEx

Save an image to file

#include <GDIPlus.au3>
_GDIPlus_ImageSaveToFileEx ( $hImage, $sFileName, $sEncoder [, $tParams = 0] )

Parameters

$hImage | Handle to an image object
$sFileName | Fully qualified image file name
$sEncoder | GUID string of encoder to be used
$tParams | [optional] a $tagGDIPENCODERPARAMS structure or a pointer to it

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

$tagGDIPENCODERPARAMS, _GDIPlus_ImageLoadFromFile, _GDIPlus_ImageSaveToFile

See Also

Search GdipSaveImageToFile in MSDN Library.

Example

#include <GDIPlus.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    Local $hImage, $sCLSID, $tData, $tParams

    ; Capture screen
    _ScreenCapture_Capture(@MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Load image
    $hImage = _GDIPlus_ImageLoadFromFile(@MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Get JPEG encoder CLSID
    $sCLSID = _GDIPlus_EncodersGetCLSID("JPG")

    ; Set up parameters for 90 degree rotation
    $tData = DllStructCreate("int Data")
    DllStructSetData($tData, "Data", $GDIP_EVTTRANSFORMROTATE90)
    $tParams = _GDIPlus_ParamInit(1)
    _GDIPlus_ParamAdd($tParams, $GDIP_EPGTRANSFORMATION, 1, $GDIP_EPTLONG, DllStructGetPtr($tData, "Data"))

    ; Save image with rotation
    _GDIPlus_ImageSaveToFileEx($hImage, @MyDocumentsDir & "\GDIPlus_Image2.jpg", $sCLSID, $tParams)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image2.jpg")
EndFunc   ;==>Example


Function _GDIPlus_ImageSaveToStream

Function Reference

_GDIPlus_ImageSaveToStream

Saves an Image object to a stream

#include <GDIPlus.au3>
_GDIPlus_ImageSaveToStream ( $hImage, $pStream, $tEncoder [, $tParams = 0] )

Parameters

$hImage | Pointer to an Image object
$pStream | Pointer to an IStream interface
$tEncoder | a $tagGUID structure that defines the image encoder GUID
$tParams | [optional] a $tagGDIPENCODERPARAMS structure or a pointer to it

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

Use this function to save selected frames from a multiple-frame image to another multiple-frame image.

Related

$tagGDIPENCODERPARAMS, _GDIPlus_EncodersGetCLSID, _GDIPlus_ImageLoadFromStream, _GDIPlus_ImageSaveToFile

See Also

Search GdipSaveImageToStream in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup()
    Local Const $iW = @DesktopWidth / 2, $iH = @DesktopHeight / 2
    Local $hGUI = GUICreate("GDI+ test", $iW, $iH, -1, -1)
    GUISetState(@SW_SHOW)

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, @DesktopWidth / 2, @DesktopHeight / 2) ;create a GDI bitmap by capturing 1/4 of desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI bitmap to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore

    Local $sImgCLSID = _GDIPlus_EncodersGetCLSID("jpg") ;create CLSID for a JPG image file type
    Local $tGUID = _WinAPI_GUIDFromString($sImgCLSID) ;convert CLSID GUID to binary form and returns $tagGUID structure
    Local $tParams = _GDIPlus_ParamInit(1) ;initialize an encoder parameter list and return $tagGDIPENCODERPARAMS structure
    Local $tData = DllStructCreate("int Quality") ;create struct to set JPG quality setting
    DllStructSetData($tData, "Quality", 10) ;quality 0-100 (0: lowest, 100: highest)
    Local $pData = DllStructGetPtr($tData) ;get pointer from quality struct
    _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) ;add a value to an encoder parameter list
    Local $pStream = _WinAPI_CreateStreamOnHGlobal() ;create stream
    _GDIPlus_ImageSaveToStream($hBitmap, $pStream, $tGUID, $tParams) ;save the bitmap in JPG format in memory
    Local $hBitmapFromStream = _GDIPlus_BitmapCreateFromStream($pStream) ;create bitmap from a stream (here from the JPG in memory)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmapFromStream, 0, 0) ;display streamed image

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    ;cleanup resources
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_BitmapDispose($hBitmapFromStream)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_ImageScale

Function Reference

_GDIPlus_ImageScale

Scales an image by a given factor

#include <GDIPlus.au3>
_GDIPlus_ImageScale ( $hImage, $iScaleW, $iScaleH [, $iInterpolationMode = $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC] )

Parameters

$hImage | A handle value
$iScaleW | A floating point value
$iScaleH | A floating point value
$iInterpolationMode | [optional] An integer value. Default is $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC.

Return Value

Success: | Returns a handle to a new Bitmap object
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - unable to get width of image 2 - unable to get height of image 3 - unable to create new bitmap 4 - unable to create graphics context 5 - unable to set interpolation mode on graphics context 6 - unable to copy image to scaled bitmap

Remarks

Scale factor greater than 1 means enlarging the image whereas smaller than 1 means decrease the size.

Related

_GDIPlus_BitmapCreateFromScan0, _GDIPlus_GraphicsDrawImageRect, _GDIPlus_GraphicsSetInterpolationMode, _GDIPlus_ImageGetGraphicsContext

Example

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup()
    Local Const $iW = @DesktopWidth / 4, $iH = @DesktopHeight / 4

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iW, $iH) ;create a GDI bitmap by capturing 1/16 of desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI bitmap to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore

    Local $iScale = 2.75 ;1.0 is without any scaling
    Local $hBitmap_Scaled = _GDIPlus_ImageScale($hBitmap, $iScale, $iScale, $GDIP_INTERPOLATIONMODE_NEARESTNEIGHBOR) ;scale image by 275% (magnify)

    Local $hGUI = GUICreate("GDI+ test", $iW * $iScale, $iH * $iScale, -1, -1) ;create a test gui to display the resized image
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, 0, 0) ;display scaled image

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    ;cleanup resources
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap_Scaled)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


User Defined Functions

ImageAttributes user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_ImageAttributesCreate | Creates an ImageAttributes object
_GDIPlus_ImageAttributesDispose | Releases an ImageAttributes object
_GDIPlus_ImageAttributesSetColorKeys | Sets or clears the color key (transparency range) for a specified category
_GDIPlus_ImageAttributesSetColorMatrix | Sets or clears the color- and grayscale-adjustment matrices for a specified category


Function _GDIPlus_ImageAttributesCreate

Function Reference

_GDIPlus_ImageAttributesCreate

Creates an ImageAttributes object

#include <GDIPlus.au3>
_GDIPlus_ImageAttributesCreate ( )

Return Value

Success: | a pointer to a new ImageAttribute object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_ImageAttributesDispose() to release the object resources.

Related

_GDIPlus_ImageAttributesDispose

See Also

Search GdipCreateImageAttributes in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    Local $hIA = _GDIPlus_ImageAttributesCreate() ;create an ImageAttribute object

    ;create the color matrix used to adjust the colors of the image
    Local $tColorMatrix = _GDIPlus_ColorMatrixCreateTranslate(0.25, .33, 0.5) ;use translation color matrix to change the image brightness

    _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $tColorMatrix) ;adjust the ImageAttribute color-key color matrix

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iWidth, $iHeight) ;create a GDI bitmap by capturing an area on desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore
    _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA) ;draw the bitmap while applying the color adjustment

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_ImageAttributesDispose($hIA)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_ImageAttributesDispose

Function Reference

_GDIPlus_ImageAttributesDispose

Releases an ImageAttributes object

#include <GDIPlus.au3>
_GDIPlus_ImageAttributesDispose ( $hImageAttributes )

Parameters

$hImageAttributes Pointer to an ImageAttribute object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_ImageAttributesCreate

See Also

Search GdipDisposeImageAttributes in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    Local $hIA = _GDIPlus_ImageAttributesCreate() ;create an ImageAttribute object

    ;create the color matrix used to adjust the colors of the image
    Local $tColorMatrix = _GDIPlus_ColorMatrixCreateTranslate(-0.5, -0.5, -0.5) ;use translation color matrix to change the image brightness

    _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $tColorMatrix) ;adjust the ImageAttribute color-key color matrix

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iWidth, $iHeight) ;create a GDI bitmap by capturing an area on desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore
    _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA) ;draw the bitmap while applying the color adjustment

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_ImageAttributesDispose($hIA)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_ImageAttributesSetColorKeys

Function Reference

_GDIPlus_ImageAttributesSetColorKeys

Sets or clears the color key (transparency range) for a specified category

#include <GDIPlus.au3>
_GDIPlus_ImageAttributesSetColorKeys ( $hImageAttributes [, $iColorAdjustType = 0 [, $bEnable = False [, $iARGBLow = 0 [, $iARGBHigh = 0]]]] )

Parameters

$hImageAttributes | Pointer to an ImageAttribute object
$iColorAdjustType | [optional] The category for which the color key is set or cleared: 0 - Color adjustment applies to all categories that do not have adjustment settings of their own 1 - Color adjustment applies to bitmapped images 2 - Color adjustment applies to brush operations in metafiles 3 - Color adjustment applies to pen operations in metafiles 4 - Color adjustment applies to text drawn in metafiles
$bEnable | [optional] If True, transparency range for the specified category is applied; otherwise, transparency
$iARGBLow | [optional] Alpha, Red, Green and Blue components of a color that specifies the low color-key value
$iARGBHigh | [optional] Alpha, Red, Green and Blue components of a color that specifies the high color-key value

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

Any color that has each of its three components (red, green, blue) between the corresponding components of the high and low color keys is made transparent.

See Also

Search GdipSetImageAttributesColorKeys in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    Local $hIA = _GDIPlus_ImageAttributesCreate() ;create an ImageAttribute object

    _GDIPlus_ImageAttributesSetColorKeys($hIA, 0, True, 0x00000000, 0x00F7F7F7) ;make a range of colors transparent

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iWidth, $iHeight) ;create a GDI bitmap by capturing an area on desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore

    _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA) ;draw the bitmap while applying the color adjustment

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_ImageAttributesDispose($hIA)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_ImageAttributesSetColorMatrix

Function Reference

_GDIPlus_ImageAttributesSetColorMatrix

Sets or clears the color- and grayscale-adjustment matrices for a specified category

#include <GDIPlus.au3>
_GDIPlus_ImageAttributesSetColorMatrix ( $hImageAttributes [, $iColorAdjustType = 0 [, $bEnable = False [, $tClrMatrix = 0 [, $tGrayMatrix = 0 [, $iColorMatrixFlags = 0]]]]] )

Parameters

$hImageAttributes | Pointer to an ImageAttribute object
$iColorAdjustType | [optional] The category for which the color- and grayscale-adjustment matrices are set or cleared: 0 - Color or grayscale adjustment applies to all categories that do not have adjustment settings of their own 1 - Color or grayscale adjustment applies to bitmapped images 2 - Color or grayscale adjustment applies to brush operations in metafiles 3 - Color or grayscale adjustment applies to pen operations in metafiles 4 - Color or grayscale adjustment applies to text drawn in metafiles
$bEnable | [optional] If True, the specified matrices (color, grayscale or both) adjustments for the specified
$tClrMatrix | [optional] $tagGDIPCOLORMATRIX structure that specifies a color-adjustment matrix
$tGrayMatrix | [optional] $tagGDIPCOLORMATRIX structure that specifies a grayscale-adjustment matrix
$iColorMatrixFlags | [optional] Type of image and color that will be affected by the adjustment matrices: 0 - All color values (including grays) are adjusted by the same color-adjustment matrix 1 - Colors are adjusted but gray shades are not adjusted. 2 - Colors are adjusted by one matrix and gray shades are adjusted by another matrix

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

$tagGDIPCOLORMATRIX, _GDIPlus_ColorMatrixCreate, _GDIPlus_ColorMatrixCreateGrayScale

See Also

Search GdipSetImageAttributesColorMatrix in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    Local $hIA = _GDIPlus_ImageAttributesCreate() ;create an ImageAttribute object

    Local $tColorMatrix = _GDIPlus_ColorMatrixCreateTranslate(0.5, 0.5, 0.5) ;create the brightness color matrix

    _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $tColorMatrix) ;adjust the image brightness to be 50% brighter

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iWidth, $iHeight) ;create a GDI bitmap by capturing an area on desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore

    _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA) ;draw the bitmap while applying the color adjustment

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_ImageAttributesDispose($hIA)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


User Defined Functions

Matrix user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_MatrixClone | Clones a Matrix object
_GDIPlus_MatrixCreate | Creates and initializes a Matrix object that represents the identity matrix
_GDIPlus_MatrixDispose | Release a matrix object
_GDIPlus_MatrixGetElements | Gets the elements of a matrix
_GDIPlus_MatrixInvert | Replaces the elements of a matrix with the elements of its inverse
_GDIPlus_MatrixMultiply | Updates a matrix with the product of itself and another matrix
_GDIPlus_MatrixRotate | Updates a matrix with the product of itself and a rotation matrix
_GDIPlus_MatrixScale | Updates a matrix with the product of itself and a scaling matrix
_GDIPlus_MatrixSetElements | Sets the elements of a matrix
_GDIPlus_MatrixShear | Updates a matrix with the product of itself and another matrix
_GDIPlus_MatrixTransformPoints | Multiplies each point in an array by a matrix
_GDIPlus_MatrixTranslate | Updates a matrix with the product of itself and a translation matrix


Function _GDIPlus_MatrixClone

Function Reference

_GDIPlus_MatrixClone

Clones a Matrix object

#include <GDIPlus.au3>
_GDIPlus_MatrixClone ( $hMatrix )

Parameters

$hMatrix Pointer to a Matrix object

Return Value

Success: | a handle to a new cloned Matrix object
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_MatrixDispose() to release the object resources

Related

_GDIPlus_MatrixDispose

See Also

Search GdipCloneMatrix in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen, $hPath, $hMatrix_Scale, $hMatrix_Clone, $hMatrix_Rotate

    ; Create GUI
    $hGUI = GUICreate("GDI+", 600, 600)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFF000000)

    $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)

    $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddArc($hPath, 0, 0, 600, 600, 0, 45)

    $hMatrix_Scale = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix_Scale, -300, -300)
    _GDIPlus_MatrixScale($hMatrix_Scale, 0.9, 0.9, True)

    $hMatrix_Rotate = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixRotate($hMatrix_Rotate, 40, True)

    For $i = 1 To 32
        $hMatrix_Clone = _GDIPlus_MatrixClone($hMatrix_Scale)
        _GDIPlus_MatrixMultiply($hMatrix_Clone, $hMatrix_Rotate, 1)
        _GDIPlus_MatrixTranslate($hMatrix_Clone, 300, 300, True)

        _GDIPlus_PathTransform($hPath, $hMatrix_Clone)
        _GDIPlus_MatrixDispose($hMatrix_Clone)

        _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen)
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix_Rotate)
    _GDIPlus_MatrixDispose($hMatrix_Scale)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_MatrixCreate

Function Reference

_GDIPlus_MatrixCreate

Creates and initializes a Matrix object that represents the identity matrix

#include <GDIPlus.au3>
_GDIPlus_MatrixCreate ( )

Return Value

Success: | a handle to a Matrix object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the matrix, call _GDIPlus_MatrixDispose() to release the resources.

Related

_GDIPlus_MatrixDispose

See Also

Search GdipCreateMatrix in MSDN Library.

Example

#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphic, $iWidth, $iHeight

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture full screen
    $hBitmap1 = _ScreenCapture_Capture("")
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1)

    ; Capture screen region
    $hBitmap2 = _ScreenCapture_Capture("", 0, 0, 400, 300)
    $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap2)

    $iWidth = _GDIPlus_ImageGetWidth($hImage2)
    $iHeight = _GDIPlus_ImageGetHeight($hImage2)

    ; Draw one image in another
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)

    ;DrawInsert($hGraphic, $hImage2, $iX, $iY, $fAngle,    $iWidth,    $iHeight, $iARGB = 0xFF000000, $iPenWidth = 1)
    DrawInsert($hGraphic, $hImage2, 350, 100, 0, $iWidth + 2, $iHeight + 2, 0xFFFF8000, 2)
    DrawInsert($hGraphic, $hImage2, 340, 50, 15, 200, 150, 0xFFFF8000, 4)
    DrawInsert($hGraphic, $hImage2, 310, 30, 35, $iWidth + 4, $iHeight + 4, 0xFFFF00FF, 4)
    DrawInsert($hGraphic, $hImage2, 320, 790, -35, $iWidth, $iHeight)

    ; Save resultant image
    _GDIPlus_ImageSaveToFile($hImage1, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _WinAPI_DeleteObject($hBitmap1)
    _WinAPI_DeleteObject($hBitmap2)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
EndFunc   ;==>Example

; #FUNCTION# ==================================================================================================
; Name...........: DrawInsert
; Description ...: Draw one image in another
; Syntax.........: DrawInsert($hGraphic, $hImage2, $iX, $iY, $fAngle, $iWidth, $iHeight, $iARGB = 0xFF000000, $iPenWidth = 1)
; inserts Graphics $hImage2 into $hGraphic
; Parameters ....: $hGraphics   - Handle to a Graphics object
;                  $hImage      - Handle to an Image object to be inserted
;                  $iX          - The X coordinate of the upper left corner of the inserted image
;                  $iY          - The Y coordinate of the upper left corner of the inserted image
;                  $iWidth      - The width of the rectangle Border around insert
;                  $iHeight     - The height of the rectangle Border around insert
;                  $iARGB       - Alpha, Red, Green and Blue components of pen color - Border color
;                  $iPenWidth      - The width of the pen measured in the units specified in the $iUnit parameter - Border Width

; Return values .: Success      - True
;                  Failure      - False
; ==================================================================================================
Func DrawInsert($hGraphic, $hImage2, $iX, $iY, $fAngle, $iWidth, $iHeight, $iARGB = 0xFF000000, $iPenWidth = 1)
    Local $hMatrix, $hPen2

    ;Rotation Matrix
    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixRotate($hMatrix, $fAngle, "False")
    _GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix)

    _GDIPlus_GraphicsDrawImage($hGraphic, $hImage2, $iX, $iY)

    ;get pen + color
    $hPen2 = _GDIPlus_PenCreate($iARGB, $iPenWidth)

    ; Draw a frame around the inserted image
    _GDIPlus_GraphicsDrawRect($hGraphic, $iX, $iY, $iWidth, $iHeight, $hPen2)

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PenDispose($hPen2)
    Return 1
EndFunc   ;==>DrawInsert


Function _GDIPlus_MatrixDispose

Function Reference

_GDIPlus_MatrixDispose

Release a matrix object

#include <GDIPlus.au3>
_GDIPlus_MatrixDispose ( $hMatrix )

Parameters

$hMatrix Handle to a Matrix object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_MatrixCreate

See Also

Search GdipDeleteMatrix in MSDN Library.

Example

#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphic, $iWidth, $iHeight

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture full screen
    $hBitmap1 = _ScreenCapture_Capture("")
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1)

    ; Capture screen region
    $hBitmap2 = _ScreenCapture_Capture("", 0, 0, 400, 300)
    $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap2)

    $iWidth = _GDIPlus_ImageGetWidth($hImage2)
    $iHeight = _GDIPlus_ImageGetHeight($hImage2)

    ; Draw one image in another
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)

    ;DrawInsert($hGraphic, $hImage2, $iX, $iY, $fAngle,    $iWidth,    $iHeight, $iARGB = 0xFF000000, $iPenWidth = 1)
    DrawInsert($hGraphic, $hImage2, 350, 100, 0, $iWidth + 2, $iHeight + 2, 0xFFFF8000, 2)
    DrawInsert($hGraphic, $hImage2, 340, 50, 15, 200, 150, 0xFFFF8000, 4)
    DrawInsert($hGraphic, $hImage2, 310, 30, 35, $iWidth + 4, $iHeight + 4, 0xFFFF00FF, 4)
    DrawInsert($hGraphic, $hImage2, 320, 790, -35, $iWidth, $iHeight)

    ; Save resultant image
    _GDIPlus_ImageSaveToFile($hImage1, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _WinAPI_DeleteObject($hBitmap1)
    _WinAPI_DeleteObject($hBitmap2)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
EndFunc   ;==>Example

; #FUNCTION# ==================================================================================================
; Name...........: DrawInsert
; Description ...: Draw one image in another
; Syntax.........: DrawInsert($hGraphic, $hImage2, $iX, $iY, $fAngle, $iWidth, $iHeight, $iARGB = 0xFF000000, $iPenWidth = 1)
; inserts Graphics $hImage2 into $hGraphic
; Parameters ....: $hGraphics   - Handle to a Graphics object
;                  $hImage      - Handle to an Image object to be inserted
;                  $iX          - The X coordinate of the upper left corner of the inserted image
;                  $iY          - The Y coordinate of the upper left corner of the inserted image
;                  $iWidth      - The width of the rectangle Border around insert
;                  $iHeight     - The height of the rectangle Border around insert
;                  $iARGB       - Alpha, Red, Green and Blue components of pen color - Border color
;                  $iPenWidth      - The width of the pen measured in the units specified in the $iUnit parameter - Border Width

; Return values .: Success      - True
;                  Failure      - False
; ==================================================================================================
Func DrawInsert($hGraphic, $hImage2, $iX, $iY, $fAngle, $iWidth, $iHeight, $iARGB = 0xFF000000, $iPenWidth = 1)
    Local $hMatrix, $hPen2

    ;Rotation Matrix
    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixRotate($hMatrix, $fAngle, "False")
    _GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix)

    _GDIPlus_GraphicsDrawImage($hGraphic, $hImage2, $iX, $iY)

    ;get pen + color
    $hPen2 = _GDIPlus_PenCreate($iARGB, $iPenWidth)

    ; Draw a frame around the inserted image
    _GDIPlus_GraphicsDrawRect($hGraphic, $iX, $iY, $iWidth, $iHeight, $hPen2)

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PenDispose($hPen2)
    Return 1
EndFunc   ;==>DrawInsert


Function _GDIPlus_MatrixGetElements

Function Reference

_GDIPlus_MatrixGetElements

Gets the elements of a matrix

#include <GDIPlus.au3>
_GDIPlus_MatrixGetElements ( $hMatrix )

Parameters

$hMatrix Pointer to a Matrix object

Return Value

Success: | an array of the elements of the matrix: [0] - Row 1, column 1 [1] - Row 1, column 2 [2] - Row 2, column 1 [3] - Row 2, column 2 [4] - Row 3, column 1 [5] - Row 3, column 2
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetMatrixElements in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hGUI, $g_hGraphics, $g_hBmp_Buffer, $g_hGfx_Buffer, $g_hImage
Global $g_iMouseX, $g_iMouseY

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    ; X64 running support
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"

    ;get AutoIt install dir
    Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt"

    Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif"
    If Not FileExists($sFile) Then
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30)
        Exit
    EndIf

    $g_hGUI = GUICreate("GDI+", 800, 600)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_ResetGraphicsTransform")
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI)
    $g_hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(800, 600, $g_hGraphics)
    $g_hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($g_hBmp_Buffer)

    $g_hImage = _GDIPlus_ImageLoadFromFile($sFile)

    GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN")
    GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL")
    GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE")
    GUISetState(@SW_SHOW)

    _Draw()

    While Sleep(10)
    WEnd
EndFunc   ;==>Example

Func _ResetGraphicsTransform()
    _GDIPlus_GraphicsResetTransform($g_hGfx_Buffer)
    _Draw()
EndFunc   ;==>_ResetGraphicsTransform

Func WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam

    $g_iMouseX = BitAND($lParam, 0x0000FFFF)
    $g_iMouseY = BitShift($lParam, 16)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_LBUTTONDOWN

Func WM_MOUSEMOVE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg

    Switch BitAND($wParam, 0x0000FFFF)
        Case 1
            Local $iX = BitAND($lParam, 0x0000FFFF)
            Local $iY = BitShift($lParam, 16)

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $iX - $g_iMouseX, $iY - $g_iMouseY, True)

            $g_iMouseX = $iX
            $g_iMouseY = $iY

            _Draw()
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEMOVE

Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam

    Switch BitAND($wParam, 0x0000FFFF)
        Case 1
            Local $iAngle = -3
            If BitShift($wParam, 16) < 0 Then $iAngle = 3

            Local $aMousePos[2][2] = [[1]]
            $aMousePos[1][0] = $g_iMouseX
            $aMousePos[1][1] = $g_iMouseY
            _GDIPlus_GraphicsTransformPoints($g_hGfx_Buffer, $aMousePos)

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $aMousePos[1][0], $aMousePos[1][1])
            _GDIPlus_GraphicsRotateTransform($g_hGfx_Buffer, $iAngle)
            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, -$aMousePos[1][0], -$aMousePos[1][1])

        Case Else
            Local $aInfo = GUIGetCursorInfo($g_hGUI)
            Local $iScale = 1.1
            If BitShift($wParam, 16) < 0 Then $iScale = 0.9

            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, -$aInfo[0], -$aInfo[1], True)
            _GDIPlus_GraphicsScaleTransform($g_hGfx_Buffer, $iScale, $iScale, True)
            _GDIPlus_GraphicsTranslateTransform($g_hGfx_Buffer, $aInfo[0], $aInfo[1], True)
    EndSwitch

    _Draw()
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEWHEEL

Func _Draw()
    _GDIPlus_GraphicsClear($g_hGfx_Buffer, 0xFFFFFFFF)

    _GDIPlus_GraphicsDrawImage($g_hGfx_Buffer, $g_hImage, 316, 266)

    Local $hPen = _GDIPlus_PenCreate(0xFF0000FF)
    _GDIPlus_GraphicsDrawRect($g_hGfx_Buffer, 300, 250, 200, 100, $hPen)
    _GDIPlus_PenDispose($hPen)

    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F)
    Local $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 24, 2)
    Local $tLayout = _GDIPlus_RectFCreate(0, 360, 800)
    _GDIPlus_GraphicsDrawStringEx($g_hGfx_Buffer, "AutoIt rulez!", $hFont, $tLayout, $hFormat, $hBrush)

    _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBmp_Buffer, 0, 0)

    _GDIPlus_FontDispose($hFont)
    $hFont = _GDIPlus_FontCreate($hFamily, 10)
    _GDIPlus_StringFormatSetAlign($hFormat, 0)

    DllStructSetData($tLayout, "X", 10)
    DllStructSetData($tLayout, "Y", 10)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "left mousebutton = move graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 30)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "mousewheel = zoom graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 50)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "mousewheel + left mousebutton = rotate graphic", $hFont, $tLayout, $hFormat, $hBrush)

    DllStructSetData($tLayout, "Y", 70)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "right mousebutton = reset", $hFont, $tLayout, $hFormat, $hBrush)

    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_GraphicsGetTransform($g_hGfx_Buffer, $hMatrix)
    Local $aMatrix_Values = _GDIPlus_MatrixGetElements($hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)

    DllStructSetData($tLayout, "Y", 110)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, "Matrix:", $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "X", 20)
    DllStructSetData($tLayout, "Y", 130)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[0], $aMatrix_Values[1]), $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "Y", 150)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[2], $aMatrix_Values[3]), $hFont, $tLayout, $hFormat, $hBrush)
    DllStructSetData($tLayout, "Y", 170)
    _GDIPlus_GraphicsDrawStringEx($g_hGraphics, StringFormat("%.2f  %.2f", $aMatrix_Values[4], $aMatrix_Values[5]), $hFont, $tLayout, $hFormat, $hBrush)

    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
EndFunc   ;==>_Draw

Func _Exit()
    _GDIPlus_ImageDispose($g_hImage)
    _GDIPlus_GraphicsDispose($g_hGfx_Buffer)
    _GDIPlus_BitmapDispose($g_hBmp_Buffer)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_MatrixInvert

Function Reference

_GDIPlus_MatrixInvert

Replaces the elements of a matrix with the elements of its inverse

#include <GDIPlus.au3>
_GDIPlus_MatrixInvert ( $hMatrix )

Parameters

$hMatrix Pointer to a Matrix object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipInvertMatrix in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    AutoItSetOption("MouseCoordMode", $OPT_COORDSCLIENT)

    ; X64 running support
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"

    ;get AutoIt install dir
    Local $sRegPath = "HKLM\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt"

    Local $sFile = RegRead($sRegPath, "InstallDir") & "\Examples\GUI\logo4.gif"
    If Not FileExists($sFile) Then
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", $sFile & " not found!", 30)
        Return 0
    EndIf

    Local $hGUI = GUICreate("GDI+ move mouse over transformed image and watch green cursor", 800, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    Local $hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(800, 400, $hGraphics)
    Local $hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($hBmp_Buffer)
    _GDIPlus_GraphicsClear($hGfx_Buffer, 0xFF000000)

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)

    _GDIPlus_GraphicsDrawImage($hGfx_Buffer, $hImage, 550, 100)

    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixScale($hMatrix, 2, 2)
    _GDIPlus_MatrixRotate($hMatrix, 20)
    _GDIPlus_MatrixTranslate($hMatrix, 50, 20)
    _GDIPlus_GraphicsSetTransform($hGfx_Buffer, $hMatrix)

    _GDIPlus_GraphicsDrawImage($hGfx_Buffer, $hImage, 0, 0)

    _GDIPlus_MatrixInvert($hMatrix) ;Invert matrix

    Local $hPen = _GDIPlus_PenCreate(0xFF00FF00, 2)
    Local $aMouse[2][2] = [[1]]
    Local $hTimer = TimerInit()
    ; Loop until the user exits.
    Do
        If TimerDiff($hTimer) > 100 Then
            $aMouse[1][0] = MouseGetPos(0)
            $aMouse[1][1] = MouseGetPos(1)
            _GDIPlus_MatrixTransformPoints($hMatrix, $aMouse) ;Transform Mouseposition by inverted matrix back to original image

            _GDIPlus_GraphicsDrawImage($hGraphics, $hBmp_Buffer, 0, 0)
            _GDIPlus_GraphicsDrawLine($hGraphics, 550 + $aMouse[1][0] - 5, 100 + $aMouse[1][1], 550 + $aMouse[1][0] + 5, 100 + $aMouse[1][1], $hPen)
            _GDIPlus_GraphicsDrawLine($hGraphics, 550 + $aMouse[1][0], 100 + $aMouse[1][1] - 5, 550 + $aMouse[1][0], 100 + $aMouse[1][1] + 5, $hPen)

            $hTimer = TimerInit()
        EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGfx_Buffer)
    _GDIPlus_BitmapDispose($hBmp_Buffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_MatrixMultiply

Function Reference

_GDIPlus_MatrixMultiply

Updates a matrix with the product of itself and another matrix

#include <GDIPlus.au3>
_GDIPlus_MatrixMultiply ( $hMatrix1, $hMatrix2 [, $iOrder = 0] )

Parameters

$hMatrix1 | Pointer to a Matrix object
$hMatrix2 | Pointer to a Matrix object that will be multiplied by the first matrix
$iOrder | [optional] Order of matrices multiplication: 0 - The second matrix is on the left 1 - The second matrix is on the right

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipMultiplyMatrix in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen, $hPath, $hMatrix_Scale, $hMatrix_Clone, $hMatrix_Rotate

    ; Create GUI
    $hGUI = GUICreate("GDI+", 600, 600)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFF000000)

    $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)

    $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddArc($hPath, 0, 0, 600, 600, 0, 45)

    $hMatrix_Scale = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix_Scale, -300, -300)
    _GDIPlus_MatrixScale($hMatrix_Scale, 0.9, 0.9, True)

    $hMatrix_Rotate = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixRotate($hMatrix_Rotate, 40, True)

    For $i = 1 To 32
        $hMatrix_Clone = _GDIPlus_MatrixClone($hMatrix_Scale)
        _GDIPlus_MatrixMultiply($hMatrix_Clone, $hMatrix_Rotate, 1)
        _GDIPlus_MatrixTranslate($hMatrix_Clone, 300, 300, True)

        _GDIPlus_PathTransform($hPath, $hMatrix_Clone)
        _GDIPlus_MatrixDispose($hMatrix_Clone)

        _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen)
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix_Rotate)
    _GDIPlus_MatrixDispose($hMatrix_Scale)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_MatrixRotate

Function Reference

_GDIPlus_MatrixRotate

Updates a matrix with the product of itself and a rotation matrix

#include <GDIPlus.au3>
_GDIPlus_MatrixRotate ( $hMatrix, $fAngle [, $bAppend = False] )

Parameters

$hMatrix | Handle to a Matrix object
$fAngle | The angle of rotation in degrees. Positive values specify clockwise rotation.
$bAppend | [optional] Specifies the order of the multiplication: True - Specifies that the rotation matrix is on the left False - Specifies that the rotation matrix is on the right

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipRotateMatrix in MSDN Library.

Example

#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphic, $iWidth, $iHeight

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture full screen
    $hBitmap1 = _ScreenCapture_Capture("")
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1)

    ; Capture screen region
    $hBitmap2 = _ScreenCapture_Capture("", 0, 0, 400, 300)
    $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap2)

    $iWidth = _GDIPlus_ImageGetWidth($hImage2)
    $iHeight = _GDIPlus_ImageGetHeight($hImage2)

    ; Draw one image in another
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)

    ;DrawInsert($hGraphic, $hImage2, $iX, $iY, $fAngle,    $iWidth,    $iHeight, $iARGB = 0xFF000000, $iPenWidth = 1)
    DrawInsert($hGraphic, $hImage2, 350, 100, 0, $iWidth + 2, $iHeight + 2, 0xFFFF8000, 2)
    DrawInsert($hGraphic, $hImage2, 340, 50, 15, 200, 150, 0xFFFF8000, 4)
    DrawInsert($hGraphic, $hImage2, 310, 30, 35, $iWidth + 4, $iHeight + 4, 0xFFFF00FF, 4)
    DrawInsert($hGraphic, $hImage2, 320, 790, -35, $iWidth, $iHeight)

    ; Save resultant image
    _GDIPlus_ImageSaveToFile($hImage1, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _WinAPI_DeleteObject($hBitmap1)
    _WinAPI_DeleteObject($hBitmap2)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
EndFunc   ;==>Example

; #FUNCTION# ==================================================================================================
; Name...........: DrawInsert
; Description ...: Draw one image in another
; Syntax.........: DrawInsert($hGraphic, $hImage2, $iX, $iY, $fAngle, $iWidth, $iHeight, $iARGB = 0xFF000000, $iPenWidth = 1)
; inserts Graphics $hImage2 into $hGraphic
; Parameters ....: $hGraphics   - Handle to a Graphics object
;                  $hImage      - Handle to an Image object to be inserted
;                  $iX          - The X coordinate of the upper left corner of the inserted image
;                  $iY          - The Y coordinate of the upper left corner of the inserted image
;                  $iWidth      - The width of the rectangle Border around insert
;                  $iHeight     - The height of the rectangle Border around insert
;                  $iARGB       - Alpha, Red, Green and Blue components of pen color - Border color
;                  $iPenWidth      - The width of the pen measured in the units specified in the $iUnit parameter - Border Width

; Return values .: Success      - True
;                  Failure      - False
; ==================================================================================================
Func DrawInsert($hGraphic, $hImage2, $iX, $iY, $fAngle, $iWidth, $iHeight, $iARGB = 0xFF000000, $iPenWidth = 1)
    Local $hMatrix, $hPen2

    ;Rotation Matrix
    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixRotate($hMatrix, $fAngle, "False")
    _GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix)

    _GDIPlus_GraphicsDrawImage($hGraphic, $hImage2, $iX, $iY)

    ;get pen + color
    $hPen2 = _GDIPlus_PenCreate($iARGB, $iPenWidth)

    ; Draw a frame around the inserted image
    _GDIPlus_GraphicsDrawRect($hGraphic, $iX, $iY, $iWidth, $iHeight, $hPen2)

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PenDispose($hPen2)
    Return 1
EndFunc   ;==>DrawInsert


Function _GDIPlus_MatrixScale

Function Reference

_GDIPlus_MatrixScale

Updates a matrix with the product of itself and a scaling matrix

#include <GDIPlus.au3>
_GDIPlus_MatrixScale ( $hMatrix, $fScaleX, $fScaleY [, $bOrder = False] )

Parameters

$hMatrix | Handle to a Matrix object
$fScaleX | Multiplier to scale the x-axis
$fScaleY | Multiplier to scale the y-axis
$bOrder | [optional] Specifies the order of the multiplication: True - Specifies that the scaling matrix is on the left False - Specifies that the scaling matrix is on the right

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipScaleMatrix in MSDN Library.

Example

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

; Create GUI
Local $hWnd = GUICreate("GDI+ Example (" & @ScriptName & ")", 500, 500)
GUISetState(@SW_SHOW)

; Start GDI+
_GDIPlus_Startup()
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
_GDIPlus_GraphicsClear($hGraphics)

; Take Screenshot at bottom left of screen
Local $hScreenCap_hBitmap = _ScreenCapture_Capture("", 0, @DesktopHeight - 500, 500, @DesktopHeight)
Local $hScreenCap_Bitmap = _GDIPlus_BitmapCreateFromHBITMAP($hScreenCap_hBitmap)

Local $hMatrix = _GDIPlus_MatrixCreate()
; Scale the matrix by 2 (everything will get 2x larger)
_GDIPlus_MatrixScale($hMatrix, 2.0, 2.0)

_GDIPlus_GraphicsSetTransform($hGraphics, $hMatrix)
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hScreenCap_Bitmap, 0, 0, 500, 500)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

; Clean up resources
_WinAPI_DeleteObject($hScreenCap_hBitmap)
_GDIPlus_BitmapDispose($hScreenCap_Bitmap)
_GDIPlus_MatrixDispose($hMatrix)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()


Function _GDIPlus_MatrixSetElements

Function Reference

_GDIPlus_MatrixSetElements

Sets the elements of a matrix

#include <GDIPlus.au3>
_GDIPlus_MatrixSetElements ( $hMatrix [, $nM11 = 1 [, $nM12 = 0 [, $nM21 = 0 [, $nM22 = 1 [, $nDX = 0 [, $nDY = 0]]]]]] )

Parameters

$hMatrix | A handle value
$nM11 | [optional] A floating point number value. Default is 1
$nM12 | [optional] A floating point number value. Default is 0
$nM21 | [optional] A floating point number value. Default is 0
$nM22 | [optional] A floating point number value. Default is 1
$nDX | [optional] A floating point number value. Default is 0
$nDY | [optional] A floating point number value. Default is 0

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_MatrixGetElements

See Also

Search GdipSetMatrixElements in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $iW, $iH, $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hFamily, $tLayout, $hMatrix, $aBounds

    ; Create GUI
    $iW = 640
    $iH = 220
    $hGUI = GUICreate("GDI+", $iW, $iH)
    GUISetState(@SW_SHOW)

    ; Draw a string using path
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFF000000)

    $hBrush = _GDIPlus_BrushCreateSolid(0xFFDD2200)
    $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    $hFamily = _GDIPlus_FontFamilyCreate("Arial") ;Create font family object
    $tLayout = _GDIPlus_RectFCreate() ;Create string bounding rectangle X=0, Y=0
    _GDIPlus_PathAddString($hPath, "Fit to Window", $tLayout, $hFamily) ;Add the outline of the string to the path

    ; Tranform Path to fit to window
    $aBounds = _GDIPlus_PathGetWorldBounds($hPath) ;Get bounding rectangle of the path
    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, -$aBounds[0], -$aBounds[1]) ;Translate Matrix to the offset of the bounding rectangle
    _GDIPlus_MatrixScale($hMatrix, $iW / $aBounds[2], $iH / $aBounds[3], True) ;Scale Matrix
    _GDIPlus_PathTransform($hPath, $hMatrix) ;Translate and Scale Path

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Tranform Path to center the path
    _GDIPlus_PathReset($hPath) ;Reset Path (delete previous string)
    _GDIPlus_PathAddString($hPath, "Center", $tLayout, $hFamily, 0, 100, 0) ;Add the outline of the string to the path

    $aBounds = _GDIPlus_PathGetWorldBounds($hPath)
    _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0) ;Reset Matrix
    _GDIPlus_MatrixTranslate($hMatrix, ($iW / 2) - $aBounds[0] - ($aBounds[2] / 2), ($iH / 2) - $aBounds[1] - ($aBounds[3] / 2))
    _GDIPlus_PathTransform($hPath, $hMatrix) ;Translate (offset) Path

    _GDIPlus_BrushSetSolidColor($hBrush, 0x7F004488)
    _GDIPlus_PenSetColor($hPen, 0xFF00AAFF)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_MatrixShear

Function Reference

_GDIPlus_MatrixShear

Updates a matrix with the product of itself and another matrix

#include <GDIPlus.au3>
_GDIPlus_MatrixShear ( $hMatrix, $fShearX, $fShearY [, $iOrder = 0] )

Parameters

$hMatrix | Pointer to a Matrix object
$fShearX | Real number that specifies the horizontal shear factor
$fShearY | Real number that specifies the vertical shear factor
$iOrder | [optional] Order of matrices multiplication: 0 - The passed matrix is on the left 1 - The passed matrix is on the right

Return Value

Success: | True.
Failure: | False.

See Also

Search GdipShearMatrix in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hFamily, $tLayout, $hMatrix

    ; Create GUI
    $hGUI = GUICreate("GDI+", 520, 160)
    GUISetState(@SW_SHOW)

    ; Draw a string using path
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    $hBrush = _GDIPlus_BrushCreateSolid(0xFFDD2200)
    $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    $hFamily = _GDIPlus_FontFamilyCreate("Arial") ;Create font family object
    $tLayout = _GDIPlus_RectFCreate() ;Create string bounding rectangle X=0, Y=0
    _GDIPlus_PathAddString($hPath, "AutoIt rulez!", $tLayout, $hFamily, 0, 72, 0) ;Add the outline of the string to the path

    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixShear($hMatrix, 0.8, 0.1)
    _GDIPlus_PathTransform($hPath, $hMatrix)

    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFF000000)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ;Fill path to graphics handle (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_MatrixTransformPoints

Function Reference

_GDIPlus_MatrixTransformPoints

Multiplies each point in an array by a matrix

#include <GDIPlus.au3>
_GDIPlus_MatrixTransformPoints ( $hMatrix, ByRef $aPoints )

Parameters

$hMatrix | Pointer to a Matrix object
$aPoints | Array of points to be transformed: [0][0] - Number of points [1][0] - Point 1 X coordinate [1][1] - Point 1 Y coordinate [2][0] - Point 2 X coordinate [2][1] - Point 2 Y coordinate [n][0] - Point n X coordinate [n][1] - Point n Y coordinate

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

Each point in the array is treated as a row matrix.
The multiplication is performed with the row matrix on the left and the matrix on the right.

See Also

Search GdipTransformMatrixPoints in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create GUI

    Local $aGui[6]
    Local $aPoints[6][2] = [[5]]
    For $i = 1 To 5
        $aPoints[$i][0] = Cos(6.28 * $i / 5) * @DesktopHeight / 3 + @DesktopWidth / 2
        $aPoints[$i][1] = Sin(6.28 * $i / 5) * @DesktopHeight / 3 + @DesktopHeight / 2
        $aGui[$i] = GUICreate($i, 120, 100, $aPoints[$i][0] - 60, $aPoints[$i][1] - 50)
        GUISetBkColor(0x55)
        GUISetState(@SW_SHOW)
    Next

    _GDIPlus_Startup()
    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, -@DesktopWidth / 2, -@DesktopHeight / 2)
    _GDIPlus_MatrixRotate($hMatrix, 1, True)
    _GDIPlus_MatrixTranslate($hMatrix, @DesktopWidth / 2, @DesktopHeight / 2, True)

    ; Loop until the user exits.
    Local $iTimer = TimerInit()
    Do
        If TimerDiff($iTimer) > 40 Then
            _GDIPlus_MatrixTransformPoints($hMatrix, $aPoints)
            For $i = 1 To 5
                WinMove($aGui[$i], "", $aPoints[$i][0] - 60, $aPoints[$i][1] - 50)
            Next
            $iTimer = TimerInit()
        EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_MatrixTranslate

Function Reference

_GDIPlus_MatrixTranslate

Updates a matrix with the product of itself and a translation matrix

#include <GDIPlus.au3>
_GDIPlus_MatrixTranslate ( $hMatrix, $fOffsetX, $fOffsetY [, $bAppend = False] )

Parameters

$hMatrix | Handle to a Matrix object
$fOffsetX | Amount of pixels to add along the x-axis
$fOffsetY | Amount of pixels to add along the y-axis
$bAppend | [optional] Specifies the order of the multiplication: True - Specifies that the translation matrix is on the left False - Specifies that the translation matrix is on the right

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipTranslateMatrix in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

; Create GUI
Local $hWnd = GUICreate("GDI+ Example (" & @ScriptName & ")", 400, 300)
GUISetState(@SW_SHOW)

; Start GDI+
_GDIPlus_Startup()
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)

Local $hMatrix = _GDIPlus_MatrixCreate()
; Move the matrix half the width and helf the height towards the center
_GDIPlus_MatrixTranslate($hMatrix, 200, 150)
_GDIPlus_MatrixRotate($hMatrix, 45)
_GDIPlus_GraphicsSetTransform($hGraphics, $hMatrix)

Local $hPen = _GDIPlus_PenCreate(0xFF00FF00, 10)

_GDIPlus_GraphicsClear($hGraphics)
; Draw around upper left corner of the GUI, but since we have translated the matrix the object will appear at the center of GUI
_GDIPlus_GraphicsDrawRect($hGraphics, -50, -50, 100, 100, $hPen)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

; Clean up resources
_GDIPlus_PenDispose($hPen)
_GDIPlus_MatrixDispose($hMatrix)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()


User Defined Functions

ColorMatrix user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_ColorMatrixCreate | Creates and initializes an identity color matrix
_GDIPlus_ColorMatrixCreateGrayScale | Creates and initializes a gray-scaling color matrix
_GDIPlus_ColorMatrixCreateNegative | Creates and initializes a negative color matrix
_GDIPlus_ColorMatrixCreateSaturation | Creates and initializes a saturation color matrix
_GDIPlus_ColorMatrixCreateScale | Creates and initializes a scaling color matrix
_GDIPlus_ColorMatrixCreateTranslate | Creates and initializes a translation color matrix


Function _GDIPlus_ColorMatrixCreate

Function Reference

_GDIPlus_ColorMatrixCreate

Creates and initializes an identity color matrix

#include <GDIPlus.au3>
_GDIPlus_ColorMatrixCreate ( )

Return Value

Returns a $tagGDIPCOLORMATRIX structure.

Remarks

An identity color matrix is a color matrix that does nothing. No color transformation, shearing, scaling, ...

Related

$tagGDIPCOLORMATRIX

See Also

Search ColorMatrix in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+

    Local Const $iWidth = 600, $iHeight = 600

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iWidth, $iHeight) ;create a GDI bitmap by capturing an area on desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    Local $hIA = _GDIPlus_ImageAttributesCreate() ;create an ImageAttribute object

    Local $tColorMatrix = _GDIPlus_ColorMatrixCreate() ;create color matrix

    Local $iX, $iY
    For $iX = 0 To 3 ;manipulate some values in the color matrix
        For $iY = 0 To 3
            DllStructSetData($tColorMatrix, "m", Random(0, 0.5), $iY * 5 + $iX + 1)
        Next
    Next

    _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $tColorMatrix) ;adapt the modified color matrix

    _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA) ;draw the bitmap while applying the color adjustment

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_ImageAttributesDispose($hIA)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_ColorMatrixCreateGrayScale

Function Reference

_GDIPlus_ColorMatrixCreateGrayScale

Creates and initializes a gray-scaling color matrix

#include <GDIPlus.au3>
_GDIPlus_ColorMatrixCreateGrayScale ( )

Return Value

Returns a $tagGDIPCOLORMATRIX structure defining a gray-scaling color matrix.

Related

$tagGDIPCOLORMATRIX

See Also

Search ColorMatrix in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    Local $hIA = _GDIPlus_ImageAttributesCreate() ;create an ImageAttribute object

    Local $tColorMatrix = _GDIPlus_ColorMatrixCreateGrayScale() ;create greyscale color matrix

    _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $tColorMatrix) ;set greyscale color matrix

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iWidth, $iHeight) ;create a GDI bitmap by capturing an area on desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore

    _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA) ;draw the bitmap while applying the color adjustment

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_ImageAttributesDispose($hIA)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_ColorMatrixCreateNegative

Function Reference

_GDIPlus_ColorMatrixCreateNegative

Creates and initializes a negative color matrix

#include <GDIPlus.au3>
_GDIPlus_ColorMatrixCreateNegative ( )

Return Value

Returns a $tagGDIPCOLORMATRIX structure.

Related

$tagGDIPCOLORMATRIX

See Also

Search ColorMatrix in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    Local $hIA = _GDIPlus_ImageAttributesCreate() ;create an ImageAttribute object

    Local $tColorMatrix = _GDIPlus_ColorMatrixCreateNegative() ;create negative color matrix

    _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $tColorMatrix) ;set negative color matrix

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iWidth, $iHeight) ;create a GDI bitmap by capturing an area on desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore

    _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA) ;draw the bitmap while applying the color adjustment

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_ImageAttributesDispose($hIA)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_ColorMatrixCreateSaturation

Function Reference

_GDIPlus_ColorMatrixCreateSaturation

Creates and initializes a saturation color matrix

#include <GDIPlus.au3>
_GDIPlus_ColorMatrixCreateSaturation ( $fSat )

Parameters

$fSat Color saturation factor

Return Value

Returns a $tagGDIPCOLORMATRIX structure that contains a saturation color matrix.

Remarks

A saturation factor of 0 produces a gray-scaled image.

Related

$tagGDIPCOLORMATRIX

See Also

Search ColorMatrix in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    Local $hIA = _GDIPlus_ImageAttributesCreate() ;create an ImageAttribute object

    Local $tColorMatrix = _GDIPlus_ColorMatrixCreateSaturation(15.0) ;create saturation color matrix

    _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $tColorMatrix) ;set saturation color matrix

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iWidth, $iHeight) ;create a GDI bitmap by capturing an area on desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore

    _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA) ;draw the bitmap while applying the color adjustment

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_ImageAttributesDispose($hIA)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_ColorMatrixCreateScale

Function Reference

_GDIPlus_ColorMatrixCreateScale

Creates and initializes a scaling color matrix

#include <GDIPlus.au3>
_GDIPlus_ColorMatrixCreateScale ( $fRed, $fGreen, $fBlue [, $fAlpha = 1] )

Parameters

$fRed | Red component scaling factor
$fGreen | Green component scaling factor
$fBlue | Blue component scaling factor
$fAlpha | [optional] Alpha component scaling factor

Return Value

Returns a $tagGDIPCOLORMATRIX structure that contains a scaling color matrix.

Remarks

A scaling color matrix is used to multiply components of a color by multiplier factors.

Related

$tagGDIPCOLORMATRIX

See Also

Search ColorMatrix in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    Local $hIA = _GDIPlus_ImageAttributesCreate() ;create an ImageAttribute object

    Local $tColorMatrix = _GDIPlus_ColorMatrixCreateScale(0.5, 0.5, 0.5) ;create the scale factor color matrix for RGB color channel

    _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $tColorMatrix) ;decrease each color (RGB) level by 50% (darken)

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iWidth, $iHeight) ;create a GDI bitmap by capturing an area on desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore

    _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA) ;draw the bitmap while applying the color adjustment

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_ImageAttributesDispose($hIA)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_ColorMatrixCreateTranslate

Function Reference

_GDIPlus_ColorMatrixCreateTranslate

Creates and initializes a translation color matrix

#include <GDIPlus.au3>
_GDIPlus_ColorMatrixCreateTranslate ( $fRed, $fGreen, $fBlue [, $fAlpha = 0] )

Parameters

$fRed | Red component translation factor
$fGreen | Green component translation factor
$fBlue | Blue component translation factor
$fAlpha | [optional] Alpha component translation factor

Return Value

Returns a $tagGDIPCOLORMATRIX structure that contains a translation color matrix.

Remarks

A translation color matrix is used to increase or decrease components of a color by addition factors.

Related

$tagGDIPCOLORMATRIX

See Also

Search ColorMatrix in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    Local $hIA = _GDIPlus_ImageAttributesCreate() ;create an ImageAttribute object

    Local $tColorMatrix = _GDIPlus_ColorMatrixCreateTranslate(0.75, 0.75, 0.75) ;create the brightness color matrix (RGB)

    _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $tColorMatrix) ;adjust the image brightness to be 75% brighter

    Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iWidth, $iHeight) ;create a GDI bitmap by capturing an area on desktop
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI to GDI+ bitmap
    _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore

    _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight, 0, 0, $iWidth, $iHeight, $hIA) ;draw the bitmap while applying the color adjustment

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_ImageAttributesDispose($hIA)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


User Defined Functions

PathGradientBrush user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_PathBrushCreate | Creates a PathGradientBrush object based on an array of points and initializes the wrap mode of the brush
_GDIPlus_PathBrushCreateFromPath | Creates a PathGradientBrush object based on a GraphicsPath object
_GDIPlus_PathBrushGetCenterPoint | Gets the center point of a path gradient brush
_GDIPlus_PathBrushGetFocusScales | Gets the focus scales of a path gradient brush
_GDIPlus_PathBrushGetPointCount | Gets the number of points in the array of points that defines a brush's boundary path
_GDIPlus_PathBrushGetRect | Gets the smallest rectangle that encloses the boundary path of a path gradient brush
_GDIPlus_PathBrushGetWrapMode | Gets the wrap mode currently set for a path gradient brush
_GDIPlus_PathBrushMultiplyTransform | Updates a brush's transformation matrix with the product of itself and another matrix
_GDIPlus_PathBrushResetTransform | Resets the transformation matrix of a path gradient brush to the identity matrix
_GDIPlus_PathBrushSetBlend | Sets the blend factors and the blend positions of a path gradient brush
_GDIPlus_PathBrushSetCenterColor | Sets the color of the center point of a path gradient brush
_GDIPlus_PathBrushSetCenterPoint | Sets the center point of a path gradient brush
_GDIPlus_PathBrushSetFocusScales | Sets the focus scales of a path gradient brush
_GDIPlus_PathBrushSetGammaCorrection | Specifies whether gamma correction is enabled for a path gradient brush
_GDIPlus_PathBrushSetLinearBlend | Sets the blend shape of a path gradient brush to create a custom blend based on a triangular shape
_GDIPlus_PathBrushSetPresetBlend | Sets the preset colors and the blend positions of a path gradient brush
_GDIPlus_PathBrushSetSigmaBlend | Sets the blend shape of a path gradient brush to create a custom blend based on a bell-shaped curve
_GDIPlus_PathBrushSetSurroundColor | Sets the surround color for a path gradient brush
_GDIPlus_PathBrushSetSurroundColorsWithCount | Sets the surround colors currently specified for a path gradient brush
_GDIPlus_PathBrushSetTransform | Sets the transformation matrix of a path gradient brush
_GDIPlus_PathBrushSetWrapMode | Sets the wrap mode of a path gradient brush


Function _GDIPlus_PathBrushCreate

Function Reference

_GDIPlus_PathBrushCreate

Creates a PathGradientBrush object based on an array of points and initializes the wrap mode of the brush

#include <GDIPlus.au3>
_GDIPlus_PathBrushCreate ( $aPoints [, $iWrapMode = 0] )

Parameters

$aPoints | Array of points that specify the boundary path of the path gradient brush [0][0] - Number of points [1][0] - Point 1 X coordinate [1][1] - Point 1 Y coordinate [2][0] - Point 2 X coordinate [2][1] - Point 2 Y coordinate [n][0] - Point n X coordinate [n][1] - Point n Y coordinate
$iWrapMode | [optional] Wrap mode that specifies how areas filled with the brush are tiled: 0 - Tiling without flipping 1 - Tiles are flipped horizontally as you move from one tile to the next in a row 2 - Tiles are flipped vertically as you move from one tile to the next in a column 3 - Tiles are flipped horizontally as you move along a row and flipped vertically as you move along a column 4 - No tiling takes place

Return Value

Success: | a pointer to a new PathGradientBrush object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_BrushDispose() to release the object resources.

Related

_GDIPlus_BrushDispose

See Also

Search GdipCreatePathGradient in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 600, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $aPoints[4][2] = [[3]]
    $aPoints[1][0] = 0
    $aPoints[1][1] = 0
    $aPoints[2][0] = 100
    $aPoints[2][1] = 30
    $aPoints[3][0] = 50
    $aPoints[3][1] = 80

    Local $hBrush = _GDIPlus_PathBrushCreate($aPoints, 3)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFFFF)

    Local $aColors[4] = [3]
    $aColors[1] = 0xFFFF0000
    $aColors[2] = 0xFF00FF00
    $aColors[3] = 0xFF0000FF
    _GDIPlus_PathBrushSetSurroundColorsWithCount($hBrush, $aColors)

    _GDIPlus_GraphicsFillRect($hGraphics, 0, 0, 600, 400, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushCreateFromPath

Function Reference

_GDIPlus_PathBrushCreateFromPath

Creates a PathGradientBrush object based on a GraphicsPath object

#include <GDIPlus.au3>
_GDIPlus_PathBrushCreateFromPath ( $hPath )

Parameters

$hPath Pointer to a GraphicsPath object that specifies the boundary path of the path gradient brush

Return Value

Success: | a pointer to a new PathGradientBrush object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_BrushDispose() to release the object resources.

Related

_GDIPlus_BrushDispose

See Also

Search GdipCreatePathGradientFromPath in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 200, 180)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, 10, 10, 180, 160)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFF00)
    _GDIPlus_PathBrushSetCenterPoint($hBrush, 90, 80)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, 0xFF0000FF)

    _GDIPlus_PathBrushSetGammaCorrection($hBrush, True)

    Local $aRect = _GDIPlus_PathBrushGetRect($hBrush)
    _GDIPlus_GraphicsFillRect($hGraphics, $aRect[0], $aRect[1], $aRect[2], $aRect[3], $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushGetCenterPoint

Function Reference

_GDIPlus_PathBrushGetCenterPoint

Gets the center point of a path gradient brush

#include <GDIPlus.au3>
_GDIPlus_PathBrushGetCenterPoint ( $hPathGradientBrush )

Parameters

$hPathGradientBrush Pointer to a PathGradientBrush object

Return Value

Success: | an array containing the point coordinates: [0] - Center point X coordinate [1] - Center point Y coordinate
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathBrushSetCenterPoint

See Also

Search GdipGetPathGradientCenterPoint in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 200, 180, -1, 50)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, 10, 10, 180, 160)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFF00)
    _GDIPlus_PathBrushSetCenterPoint($hBrush, 90, 80)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, 0xFF0000FF)

    _GDIPlus_PathBrushSetGammaCorrection($hBrush, True)

    Local $aRect = _GDIPlus_PathBrushGetRect($hBrush)
    _GDIPlus_GraphicsFillRect($hGraphics, $aRect[0], $aRect[1], $aRect[2], $aRect[3], $hBrush)

    Local $aCoord = _GDIPlus_PathBrushGetCenterPoint($hBrush)
    MsgBox($MB_SYSTEMMODAL, "", "Center point X coordinate: " & $aCoord[0] & @CRLF & "Center point Y coordinate: " & $aCoord[1])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushGetFocusScales

Function Reference

_GDIPlus_PathBrushGetFocusScales

Gets the focus scales of a path gradient brush

#include <GDIPlus.au3>
_GDIPlus_PathBrushGetFocusScales ( $hPathGradientBrush )

Parameters

$hPathGradientBrush Pointer to a PathGradientBrush object

Return Value

Success: | an array containing the focus scales: [0] - X focus scale [1] - Y focus scale
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathBrushSetFocusScales

See Also

Search GdipGetPathGradientFocusScales in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 200, 180, -1, 50)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, 10, 10, 180, 160)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetFocusScales($hBrush, 0.25, 0.75)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFF00)
    _GDIPlus_PathBrushSetCenterPoint($hBrush, 90, 80)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, 0xFF0000FF)
    _GDIPlus_PathBrushSetGammaCorrection($hBrush, True)
    _GDIPlus_GraphicsFillPath($hGraphics, $hPath, $hBrush)

    Local $aValue = _GDIPlus_PathBrushGetFocusScales($hBrush)
    MsgBox($MB_SYSTEMMODAL, "", "X focus scale: " & $aValue[0] & @CRLF & "Y focus scale: " & $aValue[1])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushGetPointCount

Function Reference

_GDIPlus_PathBrushGetPointCount

Gets the number of points in the array of points that defines a brush's boundary path

#include <GDIPlus.au3>
_GDIPlus_PathBrushGetPointCount ( $hPathGradientBrush )

Parameters

$hPathGradientBrush Pointer to a PathGradientBrush object

Return Value

Success: | the number of point in the array of points that defines the brush's boundary path.
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetPathGradientPointCount in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 200, 180, -1, 50)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, 10, 10, 180, 160)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFF00)
    _GDIPlus_PathBrushSetCenterPoint($hBrush, 90, 80)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, 0xFF303000)

    _GDIPlus_PathBrushSetGammaCorrection($hBrush, True)

    Local $aRect = _GDIPlus_PathBrushGetRect($hBrush)
    _GDIPlus_GraphicsFillRect($hGraphics, $aRect[0], $aRect[1], $aRect[2], $aRect[3], $hBrush)

    Local $iPoints = _GDIPlus_PathBrushGetPointCount($hBrush)
    MsgBox($MB_SYSTEMMODAL, "", "Number of point in the array of points that defines the brush's boundary path: " & $iPoints)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushGetRect

Function Reference

_GDIPlus_PathBrushGetRect

Gets the smallest rectangle that encloses the boundary path of a path gradient brush

#include <GDIPlus.au3>
_GDIPlus_PathBrushGetRect ( $hPathGradientBrush )

Parameters

$hPathGradientBrush Pointer to a PathGradientBrush object

Return Value

Success: | an array containing the rectangle boundaries: [0] - X coordinate of the upper-left corner of the rectangle [1] - Y coordinate of the upper-left corner of the rectangle [2] - Width of the rectangle [3] - Height of the rectangle
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetPathGradientRect in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 200, 180)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, 10, 10, 180, 160)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFF00)
    _GDIPlus_PathBrushSetCenterPoint($hBrush, 90, 80)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, 0xFF0000FF)

    _GDIPlus_PathBrushSetGammaCorrection($hBrush, True)

    Local $aRect = _GDIPlus_PathBrushGetRect($hBrush)
    _GDIPlus_GraphicsFillRect($hGraphics, $aRect[0], $aRect[1], $aRect[2], $aRect[3], $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushGetWrapMode

Function Reference

_GDIPlus_PathBrushGetWrapMode

Gets the wrap mode currently set for a path gradient brush

#include <GDIPlus.au3>
_GDIPlus_PathBrushGetWrapMode ( $hPathGradientBrush )

Parameters

$hPathGradientBrush Pointer to a PathGradientBrush object

Return Value

Success: | the wrap mode that specifies how an area is tiled when it is painted with a brush: 0 - Tiling without flipping 1 - Tiles are flipped horizontally as you move from one tile to the next in a row 2 - Tiles are flipped vertically as you move from one tile to the next in a column 3 - Tiles are flipped horizontally as you move along a row and flipped vertically as you move along a column
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathBrushSetWrapMode

See Also

Search GdipGetPathGradientWrapMode in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 600, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $aPoints[4][2] = [[3]]
    $aPoints[1][0] = 0
    $aPoints[1][1] = 0
    $aPoints[2][0] = 100
    $aPoints[2][1] = 30
    $aPoints[3][0] = 50
    $aPoints[3][1] = 80

    Local $hBrush = _GDIPlus_PathBrushCreate($aPoints, 3)
    _GDIPlus_PathBrushSetWrapMode($hBrush, 0)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFFFF)

    Local $aColors[4] = [3]
    $aColors[1] = 0xFFFF0000
    $aColors[2] = 0xFF00FF00
    $aColors[3] = 0xFF0000FF
    _GDIPlus_PathBrushSetSurroundColorsWithCount($hBrush, $aColors)

    _GDIPlus_GraphicsFillRect($hGraphics, 0, 0, 600, 400, $hBrush)

    Local $iWrapMode = _GDIPlus_PathBrushGetPointCount($hBrush), $sWarpMode
    Switch $iWrapMode
        Case 0
            $sWarpMode = "Tiling without flipping"
        Case 1
            $sWarpMode = "Tiles are flipped horizontally as you move from one tile to the next in a row"
        Case 2
            $sWarpMode = "Tiles are flipped vertically as you move from one tile to the next in a column"
        Case 3
            $sWarpMode = "Tiles are flipped horizontally as you move along a row and flipped vertically as you move along a column"
        Case 4
            $sWarpMode = "No tiling takes place"
    EndSwitch

    MsgBox($MB_SYSTEMMODAL, "", "Wrap mode: " & $sWarpMode)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushMultiplyTransform

Function Reference

_GDIPlus_PathBrushMultiplyTransform

Updates a brush's transformation matrix with the product of itself and another matrix

#include <GDIPlus.au3>
_GDIPlus_PathBrushMultiplyTransform ( $hPathGradientBrush, $hMatrix [, $iOrder = 0] )

Parameters

$hPathGradientBrush | Pointer to a PathGradientBrush object
$hMatrix | Pointer to a matrix to be multiplied by the brush's current transformation matrix
$iOrder | [optional] Order of matrices multiplication: 0 - The passed matrix is on the left 1 - The passed matrix is on the right

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipMultiplyPathGradientTransform in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPath, $hMatrix

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hPath = _GDIPlus_PathCreate() ;Create new path object
    _GDIPlus_PathAddEllipse($hPath, 10, 10, 380, 380)

    $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterPoint($hBrush, 200, 100)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFFFF)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, 0xFFAA00FF)
    _GDIPlus_PathBrushSetSigmaBlend($hBrush, 1)
    _GDIPlus_PathBrushSetGammaCorrection($hBrush, True)

    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, -200, -200)
    _GDIPlus_MatrixRotate($hMatrix, 1, True)
    _GDIPlus_MatrixTranslate($hMatrix, 200, 200, True)

    For $i = 1 To 360
        _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush)
        _GDIPlus_PathBrushMultiplyTransform($hBrush, $hMatrix, True)
        Sleep(10)
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushResetTransform

Function Reference

_GDIPlus_PathBrushResetTransform

Resets the transformation matrix of a path gradient brush to the identity matrix

#include <GDIPlus.au3>
_GDIPlus_PathBrushResetTransform ( $hPathGradientBrush )

Parameters

$hPathGradientBrush Pointer to a PathGradientBrush object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipResetPathGradientTransform in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 200, 200)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF404040)

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, 10, 10, 180, 180)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xF0404080)

    _GDIPlus_PathBrushResetTransform($hBrush)
    _GDIPlus_PathAddEllipse($hPath, 55, 10, 180, 180)

    _GDIPlus_GraphicsFillPath($hGraphics, $hPath, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushSetBlend

Function Reference

_GDIPlus_PathBrushSetBlend

Sets the blend factors and the blend positions of a path gradient brush

#include <GDIPlus.au3>
_GDIPlus_PathBrushSetBlend ( $hPathGradientBrush, $aBlends )

Parameters

$hPathGradientBrush | Pointer to a PathGradientBrush object
$aBlends | Array of blend factors and blend positions: [0][0] - Number of blend factors and blend positions [1][0] - Factor 1 [1][1] - Position 1 [2][0] - Factor 2 [2][1] - Position 2 [n][0] - Factor n [n][1] - Position n

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

Each factor and position in the array should be in the range 0.0 to 1.0.

See Also

Search GdipSetPathGradientBlend in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 200, 180)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, 10, 10, 180, 160)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterPoint($hBrush, 100, 90)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFF0000)

    Local $aBlend[4][2] = [[3]]
    $aBlend[1][0] = 0 ;0% center color
    $aBlend[1][1] = 0 ;position = boundary
    $aBlend[2][0] = 0.7 ;70% center color
    $aBlend[2][1] = 0.1 ;10% of distance boundary->center point
    $aBlend[3][0] = 1 ;100% center color
    $aBlend[3][1] = 1 ;center point
    _GDIPlus_PathBrushSetBlend($hBrush, $aBlend)

    Local $aRect = _GDIPlus_PathBrushGetRect($hBrush)
    _GDIPlus_GraphicsFillRect($hGraphics, $aRect[0], $aRect[1], $aRect[2], $aRect[3], $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushSetCenterColor

Function Reference

_GDIPlus_PathBrushSetCenterColor

Sets the color of the center point of a path gradient brush

#include <GDIPlus.au3>
_GDIPlus_PathBrushSetCenterColor ( $hPathGradientBrush, $iARGB )

Parameters

$hPathGradientBrush | Pointer to a PathGradientBrush object
$iARGB | Alpha, Red, Green and Blue components of the new center color

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipSetPathGradientCenterColor in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 200, 180)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, 10, 10, 180, 160)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFF00)
    _GDIPlus_PathBrushSetCenterPoint($hBrush, 90, 80)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, 0xFF0000FF)

    _GDIPlus_PathBrushSetGammaCorrection($hBrush, True)

    Local $aRect = _GDIPlus_PathBrushGetRect($hBrush)
    _GDIPlus_GraphicsFillRect($hGraphics, $aRect[0], $aRect[1], $aRect[2], $aRect[3], $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushSetCenterPoint

Function Reference

_GDIPlus_PathBrushSetCenterPoint

Sets the center point of a path gradient brush

#include <GDIPlus.au3>
_GDIPlus_PathBrushSetCenterPoint ( $hPathGradientBrush, $nX, $nY )

Parameters

$hPathGradientBrush | Pointer to a PathGradientBrush object
$nX | X coordinate of the new center point
$nY | Y coordinate of the new center point

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathBrushGetCenterPoint

See Also

Search GdipSetPathGradientCenterPoint in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 200, 180)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, 10, 10, 180, 160)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFF00)
    _GDIPlus_PathBrushSetCenterPoint($hBrush, 90, 80)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, 0xFF0000FF)

    _GDIPlus_PathBrushSetGammaCorrection($hBrush, True)

    Local $aRect = _GDIPlus_PathBrushGetRect($hBrush)
    _GDIPlus_GraphicsFillRect($hGraphics, $aRect[0], $aRect[1], $aRect[2], $aRect[3], $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushSetFocusScales

Function Reference

_GDIPlus_PathBrushSetFocusScales

Sets the focus scales of a path gradient brush

#include <GDIPlus.au3>
_GDIPlus_PathBrushSetFocusScales ( $hPathGradientBrush, $fScaleX, $fScaleY )

Parameters

$hPathGradientBrush | Pointer to a PathGradientBrush object
$fScaleX | Real number that specifies the X focus scale
$fScaleY | Real number that specifies the Y focus scale

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathBrushGetFocusScales

See Also

Search GdipSetPathGradientFocusScales in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 200, 180)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, 10, 10, 180, 160)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetFocusScales($hBrush, 0.25, 0.9)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFF00)
    _GDIPlus_PathBrushSetCenterPoint($hBrush, 90, 80)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, 0xFF0000FF)
    _GDIPlus_PathBrushSetGammaCorrection($hBrush, True)
    _GDIPlus_GraphicsFillPath($hGraphics, $hPath, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushSetGammaCorrection

Function Reference

_GDIPlus_PathBrushSetGammaCorrection

Specifies whether gamma correction is enabled for a path gradient brush

#include <GDIPlus.au3>
_GDIPlus_PathBrushSetGammaCorrection ( $hPathGradientBrush, $bUseGammaCorrection )

Parameters

$hPathGradientBrush | Pointer to a PathGradientBrush object
$bUseGammaCorrection | If True, gamma correction is enabled; otherwise, gamma correction is disabled

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipSetPathGradientGammaCorrection in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 200, 180)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, 10, 10, 180, 160)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFF00)
    _GDIPlus_PathBrushSetCenterPoint($hBrush, 90, 80)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, 0xFF0000FF)

    _GDIPlus_PathBrushSetGammaCorrection($hBrush, True)

    Local $aRect = _GDIPlus_PathBrushGetRect($hBrush)
    _GDIPlus_GraphicsFillRect($hGraphics, $aRect[0], $aRect[1], $aRect[2], $aRect[3], $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushSetLinearBlend

Function Reference

_GDIPlus_PathBrushSetLinearBlend

Sets the blend shape of a path gradient brush to create a custom blend based on a triangular shape

#include <GDIPlus.au3>
_GDIPlus_PathBrushSetLinearBlend ( $hPathGradientBrush, $fFocus [, $fScale = 1] )

Parameters

$hPathGradientBrush | Pointer to a PathGradientBrush object
$fFocus | Number in the range 0.0 to 1.0 that specifies where the center color will be at its highest intensity
$fScale | [optional] Number in the range 0.0 to 1.0 that specifies the maximum intensity of center color that gets blended with the boundary color

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathBrushSetSigmaBlend

See Also

Search GdipSetPathGradientLinearBlend in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 200, 180)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, 10, 10, 180, 160)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterPoint($hBrush, 100, 90)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFF0000FF)
    _GDIPlus_PathBrushSetLinearBlend($hBrush, 0.25, 0.75)
    _GDIPlus_GraphicsFillPath($hGraphics, $hPath, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushSetPresetBlend

Function Reference

_GDIPlus_PathBrushSetPresetBlend

Sets the preset colors and the blend positions of a path gradient brush

#include <GDIPlus.au3>
_GDIPlus_PathBrushSetPresetBlend ( $hPathGradientBrush, $aInterpolations )

Parameters

$hPathGradientBrush | Pointer to a PathGradientBrush object
$aInterpolations | Array of blend colors and blend positions: [0][0] - Number of preset colors and blend positions [1][0] - Color 1 [1][1] - Position 1 [2][0] - Color 2 [2][1] - Position 2 [n][0] - Color n [n][1] - Position n

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipSetPathGradientPresetBlend in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 200, 180)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, 10, 10, 180, 160)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterPoint($hBrush, 100, 90)

    Local $aBlend[4][2] = [[3]]
    $aBlend[1][0] = 0xFFFF0000 ;red
    $aBlend[1][1] = 0 ;position = boundary
    $aBlend[2][0] = 0xFF00FF00 ;green
    $aBlend[2][1] = 0.7 ;70% of distance boundary->center point
    $aBlend[3][0] = 0xFF0000FF ;blue
    $aBlend[3][1] = 1 ;center point
    _GDIPlus_PathBrushSetPresetBlend($hBrush, $aBlend)

    Local $aRect = _GDIPlus_PathBrushGetRect($hBrush)
    _GDIPlus_GraphicsFillRect($hGraphics, $aRect[0], $aRect[1], $aRect[2], $aRect[3], $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushSetSigmaBlend

Function Reference

_GDIPlus_PathBrushSetSigmaBlend

Sets the blend shape of a path gradient brush to create a custom blend based on a bell-shaped curve

#include <GDIPlus.au3>
_GDIPlus_PathBrushSetSigmaBlend ( $hPathGradientBrush, $fFocus [, $fScale = 1] )

Parameters

$hPathGradientBrush | Pointer to a PathGradientBrush object
$fFocus | Number in the range 0.0 to 1.0 that specifies where the center color will be at its highest intensity
$fScale | [optional] Number in the range 0.0 to 1.0 that specifies the maximum intensity of center color that gets blended with the boundary color

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathBrushSetLinearBlend

See Also

Search GdipSetPathGradientSigmaBlend in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 200, 180)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, 10, 10, 180, 160)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFF00A000)
    _GDIPlus_PathBrushSetSigmaBlend($hBrush, 0.25, 0.50)
    _GDIPlus_GraphicsFillPath($hGraphics, $hPath, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushSetSurroundColor

Function Reference

_GDIPlus_PathBrushSetSurroundColor

Sets the surround color for a path gradient brush

#include <GDIPlus.au3>
_GDIPlus_PathBrushSetSurroundColor ( $hPathGradientBrush, $iARGB )

Parameters

$hPathGradientBrush | Pointer to a PathGradientBrush object
$iARGB | Alpha, Red, Green and Blue components of the new surrounding colors

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathBrushSetSurroundColorsWithCount

See Also

Search GdipSetPathGradientSurroundColorsWithCount in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 200, 180)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, 10, 10, 180, 160)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFF00)
    _GDIPlus_PathBrushSetCenterPoint($hBrush, 90, 80)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, 0xFF0000FF)

    _GDIPlus_PathBrushSetGammaCorrection($hBrush, True)

    Local $aRect = _GDIPlus_PathBrushGetRect($hBrush)
    _GDIPlus_GraphicsFillRect($hGraphics, $aRect[0], $aRect[1], $aRect[2], $aRect[3], $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushSetSurroundColorsWithCount

Function Reference

_GDIPlus_PathBrushSetSurroundColorsWithCount

Sets the surround colors currently specified for a path gradient brush

#include <GDIPlus.au3>
_GDIPlus_PathBrushSetSurroundColorsWithCount ( $hPathGradientBrush, $aColors )

Parameters

$hPathGradientBrush | Pointer to a PathGradientBrush object
$aColors | Array containing the surrounding colors: [0] - Number of colors [1] - Color 1 [2] - Color 2 [n] - Color n

Return Value

Success: | the number of surround colors set.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

The surround colors are colors specified for discrete points on the brush's boundary path.

See Also

Search GdipSetPathGradientSurroundColorsWithCount in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 400, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddLine($hPath, 106, 330, 200, 40)
    _GDIPlus_PathAddLine($hPath, 294, 330, 48, 151)
    _GDIPlus_PathAddLine($hPath, 352, 151, 106, 330)
    _GDIPlus_PathWindingModeOutline($hPath)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)

    Local $aColors[11] = [10]
    $aColors[1] = 0xFFFF0000
    $aColors[2] = 0xFF000000
    $aColors[3] = 0xFFFFFF00
    $aColors[4] = 0xFF000000
    $aColors[5] = 0xFF00FF00
    $aColors[6] = 0xFF000000
    $aColors[7] = 0xFF00FFFF
    $aColors[8] = 0xFF000000
    $aColors[9] = 0xFF0000FF
    $aColors[10] = 0xFF000000

    _GDIPlus_PathBrushSetSurroundColorsWithCount($hBrush, $aColors)

    _GDIPlus_GraphicsFillPath($hGraphics, $hPath, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushSetTransform

Function Reference

_GDIPlus_PathBrushSetTransform

Sets the transformation matrix of a path gradient brush

#include <GDIPlus.au3>
_GDIPlus_PathBrushSetTransform ( $hPathGradientBrush, $hMatrix )

Parameters

$hPathGradientBrush | Pointer to a PathGradientBrush object
$hMatrix | Pointer to a Matrix object that specifies the transformation matrix

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipSetPathGradientTransform in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 200, 180)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF)

    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, 10, 10, 180, 160)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xF08080A0)

    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixScale($hMatrix, 0.75, 1.25)
    _GDIPlus_PathBrushSetTransform($hBrush, $hMatrix)

    _GDIPlus_GraphicsFillPath($hGraphics, $hPath, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathBrushSetWrapMode

Function Reference

_GDIPlus_PathBrushSetWrapMode

Sets the wrap mode of a path gradient brush

#include <GDIPlus.au3>
_GDIPlus_PathBrushSetWrapMode ( $hPathGradientBrush, $iWrapMode )

Parameters

$hPathGradientBrush | Pointer to a PathGradientBrush object
$iWrapMode | Wrap mode that specifies how an area is tiled when it is painted with a brush: 0 - Tiling without flipping 1 - Tiles are flipped horizontally as you move from one tile to the next in a row 2 - Tiles are flipped vertically as you move from one tile to the next in a column 3 - Tiles are flipped horizontally as you move along a row and flipped vertically as you move along a column

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipSetPathGradientWrapMode in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 600, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)

    Local $aPoints[4][2] = [[3]]
    $aPoints[1][0] = 0
    $aPoints[1][1] = 0
    $aPoints[2][0] = 100
    $aPoints[2][1] = 30
    $aPoints[3][0] = 50
    $aPoints[3][1] = 80

    Local $hBrush = _GDIPlus_PathBrushCreate($aPoints, 3)
    _GDIPlus_PathBrushSetWrapMode($hBrush, 0)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFFFF)

    Local $aColors[4] = [3]
    $aColors[1] = 0xFFFF0000
    $aColors[2] = 0xFF00FF00
    $aColors[3] = 0xFF0000FF
    _GDIPlus_PathBrushSetSurroundColorsWithCount($hBrush, $aColors)

    _GDIPlus_GraphicsFillRect($hGraphics, 0, 0, 600, 400, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


User Defined Functions

PathIterator user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_PathIterCreate | Creates a new GraphicsPathIterator object and associates it with a GraphicsPath object
_GDIPlus_PathIterDispose | Releases a GraphicsPathIterator object
_GDIPlus_PathIterGetSubpathCount | Gets the number of subpaths (also called figures) in the path
_GDIPlus_PathIterNextMarkerPath | Gets the next marker-delimited section of an iterator's associated path
_GDIPlus_PathIterNextSubpathPath | Gets the next figure (subpath) from an iterator's associated path
_GDIPlus_PathIterRewind | Rewinds an iterator to the beginning of its associated path


Function _GDIPlus_PathIterCreate

Function Reference

_GDIPlus_PathIterCreate

Creates a new GraphicsPathIterator object and associates it with a GraphicsPath object

#include <GDIPlus.au3>
_GDIPlus_PathIterCreate ( $hPath )

Parameters

$hPath Pointer to a GraphicsPath object that will be associated with this GraphicsPathIterator object

Return Value

Success: | a pointer to a new GraphicsPathIterator object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_PathIterDispose() to release the object resources.

Related

_GDIPlus_PathIterDispose

See Also

Search GdipCreatePathIter in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 600, 300)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Local $hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(600, 300, $hGraphics)
    Local $hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($hBmp_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx_Buffer, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGfx_Buffer, 0xFF000000)

    Local $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)

    Local $hPath = _GDIPlus_PathCreate()
    Local $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, 600, 300)
    _GDIPlus_PathAddString($hPath, "AutoIt freaks out!", $tLayout, $hFamily, 0, 112, $hFormat)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontFamilyDispose($hFamily)

    Local $hIter = _GDIPlus_PathIterCreate($hPath)
    Local $iIterCnt = _GDIPlus_PathIterGetSubpathCount($hIter)
    Local $hSubPath = _GDIPlus_PathCreate();Path to get the subpath figure
    Local $hMatrix = _GDIPlus_MatrixCreate()

    Local $hTimer = TimerInit(), $aBounds = 0
    ; Loop until the user exits.
    Do
        If TimerDiff($hTimer) > 40 Then
            _GDIPlus_GraphicsClear($hGfx_Buffer, 0xFF000000)
            For $i = 1 To $iIterCnt
                _GDIPlus_PathReset($hSubPath);reset path transformation
                _GDIPlus_PathIterNextSubpathPath($hIter, $hSubPath)

                $aBounds = _GDIPlus_PathGetWorldBounds($hSubPath)
                _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0);reset matrix
                _GDIPlus_MatrixTranslate($hMatrix, -($aBounds[0] + $aBounds[2] / 2), -($aBounds[1] + $aBounds[3] / 2))
                _GDIPlus_MatrixRotate($hMatrix, Random(-24, 24), True)
                _GDIPlus_MatrixTranslate($hMatrix, $aBounds[0] + $aBounds[2] / 2, $aBounds[1] + $aBounds[3] / 2, True)
                _GDIPlus_PathTransform($hSubPath, $hMatrix)

                _GDIPlus_GraphicsDrawPath($hGfx_Buffer, $hSubPath, $hPen)
            Next
            _GDIPlus_PathIterRewind($hIter)

            _GDIPlus_GraphicsDrawImage($hGraphics, $hBmp_Buffer, 0, 0)
            $hTimer = TimerInit()
        EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PathDispose($hSubPath)
    _GDIPlus_PathIterDispose($hIter)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGfx_Buffer)
    _GDIPlus_BitmapDispose($hBmp_Buffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathIterDispose

Function Reference

_GDIPlus_PathIterDispose

Releases a GraphicsPathIterator object

#include <GDIPlus.au3>
_GDIPlus_PathIterDispose ( $hPathIter )

Parameters

$hPathIter Pointer to a GraphicsPath object that will be associated with this GraphicsPathIterator object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathIterCreate

See Also

Search GdipDeletePathIter in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 600, 300)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Local $hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(600, 300, $hGraphics)
    Local $hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($hBmp_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx_Buffer, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGfx_Buffer, 0xFF000000)

    Local $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)

    Local $hPath = _GDIPlus_PathCreate()
    Local $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, 600, 300)
    _GDIPlus_PathAddString($hPath, "AutoIt freaks out!", $tLayout, $hFamily, 0, 112, $hFormat)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontFamilyDispose($hFamily)

    Local $hIter = _GDIPlus_PathIterCreate($hPath)
    Local $iIterCnt = _GDIPlus_PathIterGetSubpathCount($hIter)
    Local $hSubPath = _GDIPlus_PathCreate();Path to get the subpath figure
    Local $hMatrix = _GDIPlus_MatrixCreate()

    Local $hTimer = TimerInit(), $aBounds = 0
    ; Loop until the user exits.
    Do
        If TimerDiff($hTimer) > 40 Then
            _GDIPlus_GraphicsClear($hGfx_Buffer, 0xFF000000)
            For $i = 1 To $iIterCnt
                _GDIPlus_PathReset($hSubPath);reset path transformation
                _GDIPlus_PathIterNextSubpathPath($hIter, $hSubPath)

                $aBounds = _GDIPlus_PathGetWorldBounds($hSubPath)
                _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0);reset matrix
                _GDIPlus_MatrixTranslate($hMatrix, -($aBounds[0] + $aBounds[2] / 2), -($aBounds[1] + $aBounds[3] / 2))
                _GDIPlus_MatrixRotate($hMatrix, Random(-24, 24), True)
                _GDIPlus_MatrixTranslate($hMatrix, $aBounds[0] + $aBounds[2] / 2, $aBounds[1] + $aBounds[3] / 2, True)
                _GDIPlus_PathTransform($hSubPath, $hMatrix)

                _GDIPlus_GraphicsDrawPath($hGfx_Buffer, $hSubPath, $hPen)
            Next
            _GDIPlus_PathIterRewind($hIter)

            _GDIPlus_GraphicsDrawImage($hGraphics, $hBmp_Buffer, 0, 0)
            $hTimer = TimerInit()
        EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PathDispose($hSubPath)
    _GDIPlus_PathIterDispose($hIter)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGfx_Buffer)
    _GDIPlus_BitmapDispose($hBmp_Buffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathIterGetSubpathCount

Function Reference

_GDIPlus_PathIterGetSubpathCount

Gets the number of subpaths (also called figures) in the path

#include <GDIPlus.au3>
_GDIPlus_PathIterGetSubpathCount ( $hPathIter )

Parameters

$hPathIter Pointer to a GraphicsPathIterator object

Return Value

Success: | the number of subpaths in the path.
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PathIterNextSubpathPath

See Also

Search GdipPathIterGetSubpathCount in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 600, 300)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Local $hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(600, 300, $hGraphics)
    Local $hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($hBmp_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx_Buffer, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGfx_Buffer, 0xFF000000)

    Local $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)

    Local $hPath = _GDIPlus_PathCreate()
    Local $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, 600, 300)
    _GDIPlus_PathAddString($hPath, "AutoIt freaks out!", $tLayout, $hFamily, 0, 112, $hFormat)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontFamilyDispose($hFamily)

    Local $hIter = _GDIPlus_PathIterCreate($hPath)
    Local $iIterCnt = _GDIPlus_PathIterGetSubpathCount($hIter)
    Local $hSubPath = _GDIPlus_PathCreate();Path to get the subpath figure
    Local $hMatrix = _GDIPlus_MatrixCreate()

    Local $hTimer = TimerInit(), $aBounds = 0
    ; Loop until the user exits.
    Do
        If TimerDiff($hTimer) > 40 Then
            _GDIPlus_GraphicsClear($hGfx_Buffer, 0xFF000000)
            For $i = 1 To $iIterCnt
                _GDIPlus_PathReset($hSubPath);reset path transformation
                _GDIPlus_PathIterNextSubpathPath($hIter, $hSubPath)

                $aBounds = _GDIPlus_PathGetWorldBounds($hSubPath)
                _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0);reset matrix
                _GDIPlus_MatrixTranslate($hMatrix, -($aBounds[0] + $aBounds[2] / 2), -($aBounds[1] + $aBounds[3] / 2))
                _GDIPlus_MatrixRotate($hMatrix, Random(-24, 24), True)
                _GDIPlus_MatrixTranslate($hMatrix, $aBounds[0] + $aBounds[2] / 2, $aBounds[1] + $aBounds[3] / 2, True)
                _GDIPlus_PathTransform($hSubPath, $hMatrix)

                _GDIPlus_GraphicsDrawPath($hGfx_Buffer, $hSubPath, $hPen)
            Next
            _GDIPlus_PathIterRewind($hIter)

            _GDIPlus_GraphicsDrawImage($hGraphics, $hBmp_Buffer, 0, 0)
            $hTimer = TimerInit()
        EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PathDispose($hSubPath)
    _GDIPlus_PathIterDispose($hIter)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGfx_Buffer)
    _GDIPlus_BitmapDispose($hBmp_Buffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathIterNextMarkerPath

Function Reference

_GDIPlus_PathIterNextMarkerPath

Gets the next marker-delimited section of an iterator's associated path

#include <GDIPlus.au3>
_GDIPlus_PathIterNextMarkerPath ( $hPathIter, $hPath )

Parameters

$hPathIter | Pointer to a GraphicsPathIterator object
$hPath | Pointer to a GraphicsPath object

Return Value

Success: | the number of point in the retrieved section or 0 if no more sections to be retrieved
Failure: | -1 and sets the @error flag to non-zero, @extended may contains GPSTATUS error code ($GDI_ERR*).

Remarks

This function sets the data points of the specified GraphicsPath object to match the data points of the retrieved section.

Related

_GDIPlus_PathIterRewind, _GDIPlus_PathSetMarker

See Also

Search GdipPathIterNextMarkerPath in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 600, 300)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Local $hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(600, 300, $hGraphics)
    Local $hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($hBmp_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx_Buffer, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGfx_Buffer, 0xFF000000)

    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFAA00FF)
    Local $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)

    Local $hPath = _GDIPlus_PathCreate()
    Local $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, 600, 300)
    _GDIPlus_PathAddString($hPath, "AutoIt rulez!", $tLayout, $hFamily, 0, 112, $hFormat)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontFamilyDispose($hFamily)

    Local $hIter = _GDIPlus_PathIterCreate($hPath)
    Local $hSubPath = _GDIPlus_PathCreate();Path to get the subpath figure

    Local $iPointCount
    While 1
        _GDIPlus_PathReset($hSubPath)

        ;e.g. The letter A is composed of two sub-paths - compare with _GDIPlus_PathIterNextSubpathPath
        $iPointCount = _GDIPlus_PathIterNextMarkerPath($hIter, $hSubPath)
        If $iPointCount <= 0 Then ExitLoop ;No more figures

        _GDIPlus_PenSetColor($hPen, BitOR(0xFF000000, Random(0xFF, 0xFFFFFF, 1)))
        _GDIPlus_BrushSetSolidColor($hBrush, BitOR(0xFF000000, Random(0xFF, 0xFFFFFF, 1)))

        _GDIPlus_GraphicsFillPath($hGfx_Buffer, $hSubPath, $hBrush)
        _GDIPlus_GraphicsDrawPath($hGfx_Buffer, $hSubPath, $hPen)
    WEnd

    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmp_Buffer, 0, 0)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hSubPath)
    _GDIPlus_PathIterDispose($hIter)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGfx_Buffer)
    _GDIPlus_BitmapDispose($hBmp_Buffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathIterNextSubpathPath

Function Reference

_GDIPlus_PathIterNextSubpathPath

Gets the next figure (subpath) from an iterator's associated path

#include <GDIPlus.au3>
_GDIPlus_PathIterNextSubpathPath ( $hPathIter, $hPath )

Parameters

$hPathIter | Pointer to a GraphicsPathIterator object
$hPath | Pointer to a GraphicsPath object

Return Value

Success: | an array containing the number of points in the retrieved figure: [0] - Number of point in the retrieved figure or 0 if no more figures to be retrieved [1] - If True, the figure is closed, False otherwise
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

This function sets the data points of the specified GraphicsPath object to match the data points of the retrieved figure.

Related

_GDIPlus_PathIterRewind

See Also

Search GdipPathIterNextSubpathPath in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 600, 300)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Local $hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(600, 300, $hGraphics)
    Local $hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($hBmp_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx_Buffer, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGfx_Buffer, 0xFF000000)

    Local $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)

    Local $hPath = _GDIPlus_PathCreate()
    Local $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, 600, 300)
    _GDIPlus_PathAddString($hPath, "AutoIt freaks out!", $tLayout, $hFamily, 0, 112, $hFormat)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontFamilyDispose($hFamily)

    Local $hIter = _GDIPlus_PathIterCreate($hPath)
    Local $iIterCnt = _GDIPlus_PathIterGetSubpathCount($hIter)
    Local $hSubPath = _GDIPlus_PathCreate();Path to get the subpath figure
    Local $hMatrix = _GDIPlus_MatrixCreate()

    Local $hTimer = TimerInit(), $aBounds = 0
    ; Loop until the user exits.
    Do
        If TimerDiff($hTimer) > 40 Then
            _GDIPlus_GraphicsClear($hGfx_Buffer, 0xFF000000)
            For $i = 1 To $iIterCnt
                _GDIPlus_PathReset($hSubPath);reset path transformation
                _GDIPlus_PathIterNextSubpathPath($hIter, $hSubPath)

                $aBounds = _GDIPlus_PathGetWorldBounds($hSubPath)
                _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0);reset matrix
                _GDIPlus_MatrixTranslate($hMatrix, -($aBounds[0] + $aBounds[2] / 2), -($aBounds[1] + $aBounds[3] / 2))
                _GDIPlus_MatrixRotate($hMatrix, Random(-24, 24), True)
                _GDIPlus_MatrixTranslate($hMatrix, $aBounds[0] + $aBounds[2] / 2, $aBounds[1] + $aBounds[3] / 2, True)
                _GDIPlus_PathTransform($hSubPath, $hMatrix)

                _GDIPlus_GraphicsDrawPath($hGfx_Buffer, $hSubPath, $hPen)
            Next
            _GDIPlus_PathIterRewind($hIter)

            _GDIPlus_GraphicsDrawImage($hGraphics, $hBmp_Buffer, 0, 0)
            $hTimer = TimerInit()
        EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PathDispose($hSubPath)
    _GDIPlus_PathIterDispose($hIter)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGfx_Buffer)
    _GDIPlus_BitmapDispose($hBmp_Buffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PathIterRewind

Function Reference

_GDIPlus_PathIterRewind

Rewinds an iterator to the beginning of its associated path

#include <GDIPlus.au3>
_GDIPlus_PathIterRewind ( $hPathIter )

Parameters

$hPathIter Pointer to a GraphicsPathIterator object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipPathIterRewind in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 600, 300)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Local $hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(600, 300, $hGraphics)
    Local $hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($hBmp_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx_Buffer, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGfx_Buffer, 0xFF000000)

    Local $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)

    Local $hPath = _GDIPlus_PathCreate()
    Local $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, 600, 300)
    _GDIPlus_PathAddString($hPath, "AutoIt freaks out!", $tLayout, $hFamily, 0, 112, $hFormat)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontFamilyDispose($hFamily)

    Local $hIter = _GDIPlus_PathIterCreate($hPath)
    Local $iIterCnt = _GDIPlus_PathIterGetSubpathCount($hIter)
    Local $hSubPath = _GDIPlus_PathCreate();Path to get the subpath figure
    Local $hMatrix = _GDIPlus_MatrixCreate()

    Local $hTimer = TimerInit(), $aBounds = 0
    ; Loop until the user exits.
    Do
        If TimerDiff($hTimer) > 40 Then
            _GDIPlus_GraphicsClear($hGfx_Buffer, 0xFF000000)
            For $i = 1 To $iIterCnt
                _GDIPlus_PathReset($hSubPath);reset path transformation
                _GDIPlus_PathIterNextSubpathPath($hIter, $hSubPath)

                $aBounds = _GDIPlus_PathGetWorldBounds($hSubPath)
                _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0);reset matrix
                _GDIPlus_MatrixTranslate($hMatrix, -($aBounds[0] + $aBounds[2] / 2), -($aBounds[1] + $aBounds[3] / 2))
                _GDIPlus_MatrixRotate($hMatrix, Random(-24, 24), True)
                _GDIPlus_MatrixTranslate($hMatrix, $aBounds[0] + $aBounds[2] / 2, $aBounds[1] + $aBounds[3] / 2, True)
                _GDIPlus_PathTransform($hSubPath, $hMatrix)

                _GDIPlus_GraphicsDrawPath($hGfx_Buffer, $hSubPath, $hPen)
            Next
            _GDIPlus_PathIterRewind($hIter)

            _GDIPlus_GraphicsDrawImage($hGraphics, $hBmp_Buffer, 0, 0)
            $hTimer = TimerInit()
        EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PathDispose($hSubPath)
    _GDIPlus_PathIterDispose($hIter)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGfx_Buffer)
    _GDIPlus_BitmapDispose($hBmp_Buffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


User Defined Functions

Pen user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_PenCreate | Create a pen object
_GDIPlus_PenCreate2 | Creates a Pen object that uses the attributes of a brush
_GDIPlus_PenDispose | Release a pen object
_GDIPlus_PenGetAlignment | Gets the pen alignment
_GDIPlus_PenGetColor | Gets the pen color
_GDIPlus_PenGetCustomEndCap | Gets the custom end cap for the pen
_GDIPlus_PenGetDashCap | Gets the pen dash cap style
_GDIPlus_PenGetDashStyle | Gets the pen dash style
_GDIPlus_PenGetEndCap | Gets the pen end cap
_GDIPlus_PenGetMiterLimit | Gets the miter length currently set for a Pen object
_GDIPlus_PenGetWidth | Retrieve the width of a pen
_GDIPlus_PenSetAlignment | Sets the pen alignment
_GDIPlus_PenSetColor | Sets the pen color
_GDIPlus_PenSetCustomEndCap | Sets the custom end cap for the pen
_GDIPlus_PenSetDashCap | Sets the pen dash cap style
_GDIPlus_PenSetDashStyle | Sets the pen dash style
_GDIPlus_PenSetEndCap | Sets the pen end cap
_GDIPlus_PenSetLineCap | Sets the cap styles for the start, end, and dashes in a line drawn with the pen
_GDIPlus_PenSetLineJoin | Sets the line join for a Pen object
_GDIPlus_PenSetMiterLimit | Sets the miter limit of a Pen object
_GDIPlus_PenSetStartCap | Sets the start cap for a Pen object
_GDIPlus_PenSetWidth | Sets the width of a pen


Function _GDIPlus_PenCreate

Function Reference

_GDIPlus_PenCreate

Create a pen object

#include <GDIPlus.au3>
_GDIPlus_PenCreate ( [$iARGB = 0xFF000000 [, $nWidth = 1 [, $iUnit = 2]]] )

Parameters

$iARGB | [optional] Alpha, Red, Green and Blue components of pen color
$nWidth | [optional] The width of the pen measured in the units specified in the $iUnit parameter
$iUnit | [optional] Unit of measurement for the pen size: 0 - World coordinates, a nonphysical unit 1 - Display units 2 - A unit is 1 pixel 3 - A unit is 1 point or 1/72 inch 4 - A unit is 1 inch 5 - A unit is 1/300 inch 6 - A unit is 1 millimeter

Return Value

Success: | a handle to a pen object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the pen, call _GDIPlus_PenDispose() to release the resources.

Related

_GDIPlus_PenDispose

See Also

Search GdipCreatePen1 in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw line
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate()
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Example 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Global $g_hGUI, $g_hGraphics, $g_hBitmap, $g_hGfxCtxt, $g_hPen

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    _GDIPlus_Startup() ;initialize GDI+
    Local $iW = 600, $iH = 600
    Local Const $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    $g_hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iW, $iH) ;create a test GUI
    GUISetBkColor($iBgColor, $g_hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    ;create buffered graphics frame set for smoother gfx object movements
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle
    $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $g_hGraphics)
    $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    $g_hPen = _GDIPlus_PenCreate(0xFF8080FF, 2)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

    Local Const $fDeg = ACos(-1) / 180, $iRadius = 300, $iWidth = $iW / 2, $iHeight = $iH / 2
    Local $fAngle = 0

    Do
        _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ;clear bitmap for repaint
        _GDIPlus_GraphicsDrawEllipse($g_hGfxCtxt, $iWidth - $iRadius / 2 + $iRadius / 18, $iHeight - $iRadius / 2 + $iRadius / 18, $iRadius - $iRadius / 9, $iRadius - $iRadius / 9, $g_hPen) ;draw ellipse
        _GDIPlus_GraphicsDrawLine($g_hGfxCtxt, $iWidth + Cos($fAngle * $fDeg) * $iRadius, $iHeight + Sin($fAngle * $fDeg) * $iRadius, _ ;draw line
                $iWidth + Cos($fAngle * $fDeg + 180) * $iRadius, $iHeight + Sin($fAngle * $fDeg + 180) * $iRadius, $g_hPen)

        _GDIPlus_GraphicsDrawImageRect($g_hGraphics, $g_hBitmap, 0, 0, $iW, $iH) ;copy drawn bitmap to graphics handle (GUI)
        $fAngle += 0.5
    Until Not Sleep(20) ;sleep 20 ms to avoid high cpu usage
EndFunc   ;==>Example

Func _Exit()
    ;cleanup GDI+ resources
    _GDIPlus_PenDispose($g_hPen)
    _GDIPlus_GraphicsDispose($g_hGfxCtxt)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_BitmapDispose($g_hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_PenCreate2

Function Reference

_GDIPlus_PenCreate2

Creates a Pen object that uses the attributes of a brush

#include <GDIPlus.au3>
_GDIPlus_PenCreate2 ( $hBrush [, $nWidth = 1 [, $iUnit = 2]] )

Parameters

$hBrush | Pointer to a brush object to base this pen on
$nWidth | [optional] The width of the pen measured in the units specified in the $iUnit parameter
$iUnit | [optional] Unit of measurement for the pen size: 0 - World coordinates, a nonphysical unit 1 - Display units 2 - A unit is 1 pixel 3 - A unit is 1 point or 1/72 inch 4 - A unit is 1 inch 5 - A unit is 1/300 inch 6 - A unit is 1 millimeter

Return Value

Success: | a pointer to a new Pen object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_PenDispose() to release the object resources.

Related

_GDIPlus_PenDispose

See Also

Search GdipCreatePen2 in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 800, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Local $hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(800, 400, $hGraphics)
    Local $hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($hBmp_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx_Buffer, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGfx_Buffer, 0xFF000000)

    Local $hPath = _GDIPlus_PathCreate()
    Local $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, 800, 400)
    _GDIPlus_PathAddString($hPath, "AutoIt rulez!", $tLayout, $hFamily, 0, 140, $hFormat)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontFamilyDispose($hFamily)

    Local $aPoints[5][2] = [[4]]
    $aPoints[1][0] = 0
    $aPoints[1][1] = 0
    $aPoints[2][0] = 20
    $aPoints[2][1] = 0
    $aPoints[3][0] = 20
    $aPoints[3][1] = 20
    $aPoints[4][0] = 0
    $aPoints[4][1] = 20

    Local $aColors[4] = [3]
    $aColors[1] = 0xFFFF0000
    $aColors[2] = 0xFF00FF00
    $aColors[3] = 0xFF0000FF

    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixRotate($hMatrix, 1, True)

    Local $hBrush, $hPen

    Local $hTimer = TimerInit()
    ; Loop until the user exits.
    Do
        If TimerDiff($hTimer) > 40 Then
            _GDIPlus_MatrixTransformPoints($hMatrix, $aPoints)

            $hBrush = _GDIPlus_PathBrushCreate($aPoints, 3)
            _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFFFF)
            _GDIPlus_PathBrushSetSurroundColorsWithCount($hBrush, $aColors)
            $hPen = _GDIPlus_PenCreate2($hBrush, 6)
            _GDIPlus_PenSetLineJoin($hPen, $GDIP_PENSETLINEJOIN_ROUND)
            _GDIPlus_BrushDispose($hBrush)

            _GDIPlus_GraphicsClear($hGfx_Buffer, 0xFF000000)
            _GDIPlus_GraphicsDrawPath($hGfx_Buffer, $hPath, $hPen)
            _GDIPlus_PenDispose($hPen)

            _GDIPlus_GraphicsDrawImage($hGraphics, $hBmp_Buffer, 0, 0)
            $hTimer = TimerInit()
        EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_GraphicsDispose($hGfx_Buffer)
    _GDIPlus_BitmapDispose($hBmp_Buffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PenDispose

Function Reference

_GDIPlus_PenDispose

Release a pen object

#include <GDIPlus.au3>
_GDIPlus_PenDispose ( $hPen )

Parameters

$hPen Handle to a pen object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PenCreate

See Also

Search GdipDeletePen in MSDN Library.

Example

Example 1

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw line
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate()
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Example 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Global $g_hGUI, $g_hGraphics, $g_hBitmap, $g_hGfxCtxt, $g_hPen

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    _GDIPlus_Startup() ;initialize GDI+
    Local $iW = 600, $iH = 600
    Local Const $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    $g_hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iW, $iH) ;create a test GUI
    GUISetBkColor($iBgColor, $g_hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    ;create buffered graphics frame set for smoother gfx object movements
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle
    $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $g_hGraphics)
    $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    $g_hPen = _GDIPlus_PenCreate(0xFF8080FF, 2)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

    Local Const $fDeg = ACos(-1) / 180, $iRadius = 300, $iWidth = $iW / 2, $iHeight = $iH / 2
    Local $fAngle = 0

    Do
        _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ;clear bitmap for repaint
        _GDIPlus_GraphicsDrawEllipse($g_hGfxCtxt, $iWidth - $iRadius / 2 + $iRadius / 18, $iHeight - $iRadius / 2 + $iRadius / 18, $iRadius - $iRadius / 9, $iRadius - $iRadius / 9, $g_hPen) ;draw ellipse
        _GDIPlus_GraphicsDrawLine($g_hGfxCtxt, $iWidth + Cos($fAngle * $fDeg) * $iRadius, $iHeight + Sin($fAngle * $fDeg) * $iRadius, _ ;draw line
                $iWidth + Cos($fAngle * $fDeg + 180) * $iRadius, $iHeight + Sin($fAngle * $fDeg + 180) * $iRadius, $g_hPen)

        _GDIPlus_GraphicsDrawImageRect($g_hGraphics, $g_hBitmap, 0, 0, $iW, $iH) ;copy drawn bitmap to graphics handle (GUI)
        $fAngle += 0.5
    Until Not Sleep(20) ;sleep 20 ms to avoid high cpu usage
EndFunc   ;==>Example

Func _Exit()
    ;cleanup GDI+ resources
    _GDIPlus_PenDispose($g_hPen)
    _GDIPlus_GraphicsDispose($g_hGfxCtxt)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_BitmapDispose($g_hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _GDIPlus_PenGetAlignment

Function Reference

_GDIPlus_PenGetAlignment

Gets the pen alignment

#include <GDIPlus.au3>
_GDIPlus_PenGetAlignment ( $hPen )

Parameters

$hPen Handle to a pen object

Return Value

Success: | the alignment type: 0 - Specifies that the pen is aligned on the center of the line that is drawn 1 - Specifies, when drawing a polygon, that the pen is aligned on the inside of the edge of the polygon
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PenSetAlignment

See Also

Search GdipGetPenMode in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 4)
    _GDIPlus_PenSetEndCap($hPen, $GDIP_LINECAPARROWANCHOR)
    _GDIPlus_PenSetAlignment($hPen, 1)

    ; Show pen alignment
    MsgBox($MB_SYSTEMMODAL, "Information", "Pen alignment: " & _GDIPlus_PenGetAlignment($hPen))

    ; Draw arrows
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 130, 390, 130, $hPen)
    _GDIPlus_PenSetWidth($hPen, 6)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)
    _GDIPlus_PenSetWidth($hPen, 8)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 170, 390, 170, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PenGetColor

Function Reference

_GDIPlus_PenGetColor

Gets the pen color

#include <GDIPlus.au3>
_GDIPlus_PenGetColor ( $hPen )

Parameters

$hPen Handle to a pen object

Return Value

Success: | the pen color.
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PenSetColor

See Also

Search GdipGetPenColor in MSDN Library.


Function _GDIPlus_PenGetCustomEndCap

Function Reference

_GDIPlus_PenGetCustomEndCap

Gets the custom end cap for the pen

#include <GDIPlus.au3>
_GDIPlus_PenGetCustomEndCap ( $hPen )

Parameters

$hPen Handle to a pen object

Return Value

Success: | a handle to a CustomLineCap object that specifies the pen custom end cap.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PenSetCustomEndCap

See Also

Search GdipGetPenCustomEndCap in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen, $hEndCap

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 4)
    $hEndCap = _GDIPlus_ArrowCapCreate(3, 6)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)

    ; Show pen end cap
    MsgBox($MB_SYSTEMMODAL, "Information", "Pen end cap: " & _GDIPlus_PenGetCustomEndCap($hPen))

    ; Draw arrows
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 120, 390, 120, $hPen)
    _GDIPlus_PenSetWidth($hPen, 6)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)
    _GDIPlus_PenSetWidth($hPen, 8)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 200, 390, 200, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PenGetDashCap

Function Reference

_GDIPlus_PenGetDashCap

Gets the pen dash cap style

#include <GDIPlus.au3>
_GDIPlus_PenGetDashCap ( $hPen )

Parameters

$hPen Handle to a pen object

Return Value

Success: | the dash cap style: $GDIP_DASHCAPFLAT - A square cap that squares off both ends of each dash $GDIP_DASHCAPROUND - A circular cap that rounds off both ends of each dash $GDIP_DASHCAPTRIANGLE - A triangular cap that points both ends of each dash
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PenSetDashCap

See Also

Search GdipGetPenDashCap197819 in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 8)
    _GDIPlus_PenSetDashStyle($hPen, $GDIP_DASHSTYLEDASHDOT)
    _GDIPlus_PenSetDashCap($hPen, $GDIP_DASHCAPTRIANGLE)

    ; Show pen dash cap
    MsgBox($MB_SYSTEMMODAL, "Information", "Pen dash cap: " & _GDIPlus_PenGetDashCap($hPen))

    ; Draw line
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PenGetDashStyle

Function Reference

_GDIPlus_PenGetDashStyle

Gets the pen dash style

#include <GDIPlus.au3>
_GDIPlus_PenGetDashStyle ( $hPen )

Parameters

$hPen Handle to a pen object

Return Value

Success: | the dash style: $GDIP_DASHSTYLESOLID - A solid line $GDIP_DASHSTYLEDASH - A dashed line $GDIP_DASHSTYLEDOT - A dotted line $GDIP_DASHSTYLEDASHDOT - An alternating dash-dot line $GDIP_DASHSTYLEDASHDOTDOT - An alternating dash-dot-dot line $GDIP_DASHSTYLECUSTOM - A a user-defined, custom dashed line
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PenSetDashStyle

See Also

Search GdipGetPenDashStyle in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 8)
    _GDIPlus_PenSetDashStyle($hPen, $GDIP_DASHSTYLEDASHDOT)

    ; Show pen dash style
    MsgBox($MB_SYSTEMMODAL, "Information", "Pen dash style: " & _GDIPlus_PenGetDashStyle($hPen))

    ; Draw line
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PenGetEndCap

Function Reference

_GDIPlus_PenGetEndCap

Gets the pen end cap

#include <GDIPlus.au3>
_GDIPlus_PenGetEndCap ( $hPen )

Parameters

$hPen Handle to a pen object

Return Value

Success: | the end cap type: $GDIP_LINECAPFLAT - Specifies a flat cap $GDIP_LINECAPSQUARE - Specifies a square cap $GDIP_LINECAPROUND - Specifies a circular cap $GDIP_LINECAPTRIANGLE - Specifies a triangular cap $GDIP_LINECAPNOANCHOR - Specifies that the line ends are not anchored $GDIP_LINECAPSQUAREANCHOR - Specifies that the line ends are anchored with a square $GDIP_LINECAPROUNDANCHOR - Specifies that the line ends are anchored with a circle $GDIP_LINECAPDIAMONDANCHOR - Specifies that the line ends are anchored with a diamond $GDIP_LINECAPARROWANCHOR - Specifies that the line ends are anchored with arrowheads $GDIP_LINECAPCUSTOM - Specifies that the line ends are made from a CustomLineCap
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PenSetEndCap

See Also

Search GdipGetPenEndCap in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 8)
    _GDIPlus_PenSetEndCap($hPen, $GDIP_LINECAPARROWANCHOR)

    ; Show pen end cap
    MsgBox($MB_SYSTEMMODAL, "Information", "Pen end cap type: " & _GDIPlus_PenGetEndCap($hPen))

    ; Draw arrows
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 130, 390, 130, $hPen)
    _GDIPlus_PenSetWidth($hPen, 6)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)
    _GDIPlus_PenSetWidth($hPen, 8)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 170, 390, 170, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PenGetMiterLimit

Function Reference

_GDIPlus_PenGetMiterLimit

Gets the miter length currently set for a Pen object

#include <GDIPlus.au3>
_GDIPlus_PenGetMiterLimit ( $hPen )

Parameters

$hPen Pointer to a Pen object

Return Value

Success: | the miter limit of the Pen object.
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

The miter length is the distance from the intersection of the line walls on the inside of the join to the intersection of the line walls outside of the join.
The miter length can be large when the angle between two lines is small.
The miter limit is the maximum allowed ratio of miter length to line width.

Related

_GDIPlus_PenSetMiterLimit

See Also

Search GdipGetPenMiterLimit in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen, $fPenWidth, $hPath

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 600)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hPath = _GDIPlus_PathCreate() ;Create new path object
    _GDIPlus_PathAddLine($hPath, 30, 550, 70, 200)
    _GDIPlus_PathAddLine($hPath, 70, 200, 110, 550)

    $fPenWidth = 32

    Local $hPen1 = _GDIPlus_PenCreate(0xFF00FF00, 1)
    For $i = 0 To 6
        _GDIPlus_GraphicsDrawLine($hGraphic, 0, 200 - $fPenWidth * 0.5 * $i, 800, 200 - $fPenWidth * 0.5 * $i, $hPen1)
    Next

    $hPen = _GDIPlus_PenCreate(0xFF8800AA, $fPenWidth)
    For $i = 1 To 6
        _GDIPlus_PenSetMiterLimit($hPen, $i)
        _GDIPlus_GraphicsDrawString($hGraphic, "MiterLimit: " & StringFormat("%.1f", _GDIPlus_PenGetMiterLimit($hPen)), 10, 10)
        _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen)
        _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen1)
        _GDIPlus_GraphicsTranslateTransform($hGraphic, 130, 0)
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PenDispose($hPen1)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PenGetWidth

Function Reference

_GDIPlus_PenGetWidth

Retrieve the width of a pen

#include <GDIPlus.au3>
_GDIPlus_PenGetWidth ( $hPen )

Parameters

$hPen Handle to a pen object

Return Value

Success: | the width of pen.
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PenSetWidth

See Also

Search GdipGetPenWidth in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw line
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 8)
    _GDIPlus_PenSetWidth($hPen, 4)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 10, 390, 10, $hPen)

    ; Show pen width
    MsgBox($MB_SYSTEMMODAL, "Information", "Pen Width: " & _GDIPlus_PenGetWidth($hPen))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PenSetAlignment

Function Reference

_GDIPlus_PenSetAlignment

Sets the pen alignment

#include <GDIPlus.au3>
_GDIPlus_PenSetAlignment ( $hPen [, $iAlignment = 0] )

Parameters

$hPen | Handle to a pen object
$iAlignment | [optional] Pen alignment. Can be one of the following: 0 - Specifies that the pen is aligned on the center of the line that is drawn 1 - Specifies, when drawing a polygon, that the pen is aligned on the inside of the edge of the polygon

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PenGetAlignment

See Also

Search GdipSetPenMode in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 4)
    _GDIPlus_PenSetEndCap($hPen, $GDIP_LINECAPARROWANCHOR)
    _GDIPlus_PenSetAlignment($hPen, 1)

    ; Show pen alignment
    MsgBox($MB_SYSTEMMODAL, "Information", "Pen alignment: " & _GDIPlus_PenGetAlignment($hPen))

    ; Draw arrows
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 130, 390, 130, $hPen)
    _GDIPlus_PenSetWidth($hPen, 6)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)
    _GDIPlus_PenSetWidth($hPen, 8)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 170, 390, 170, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PenSetColor

Function Reference

_GDIPlus_PenSetColor

Sets the pen color

#include <GDIPlus.au3>
_GDIPlus_PenSetColor ( $hPen, $iARGB )

Parameters

$hPen | Handle to a pen object
$iARGB | Alpha, Red, Green and Blue components of pen color

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PenGetColor

See Also

Search GdipSetPenColor in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+ test", 640, 480)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Local $hPen = _GDIPlus_PenCreate(0xFF101010)
    _GDIPlus_GraphicsDrawLine($hGraphics, 40, 40, 600, 440, $hPen) ;draw a test line to show smoothing effect (default no smoothing)
    MsgBox($MB_SYSTEMMODAL, "", "Smoothing enabled: " & _GDIPlus_GraphicsGetSmoothingMode($hGraphics))

    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;set smoothing mode (8 X 4 box filter)
    _GDIPlus_PenSetColor($hPen, 0xFF000080)
    _GDIPlus_GraphicsDrawLine($hGraphics, 600, 40, 40, 440, $hPen) ;draw a test line to show smoothing effect
    MsgBox($MB_SYSTEMMODAL, "", "Smoothing enabled: " & _GDIPlus_GraphicsGetSmoothingMode($hGraphics))

    If @OSBuild > 5999 Then
        _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_ANTIALIAS8X8) ;set smoothing mode (8 X 8 box filter)
        _GDIPlus_GraphicsDrawEllipse($hGraphics, 220, 140, 200, 200, $hPen) ;draw a test line to show smoothing effect
        MsgBox($MB_SYSTEMMODAL, "", "Smoothing enabled: " & _GDIPlus_GraphicsGetSmoothingMode($hGraphics))
    EndIf

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    ;cleanup resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GDIPlus_PenSetCustomEndCap

Function Reference

_GDIPlus_PenSetCustomEndCap

Sets the custom end cap for the pen

#include <GDIPlus.au3>
_GDIPlus_PenSetCustomEndCap ( $hPen, $hEndCap )

Parameters

$hPen | Handle to a pen object
$hEndCap | Handle to a CustomLineCap object that specifies the pen custom end cap

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PenGetCustomEndCap

See Also

Search GdipSetPenCustomEndCap in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen, $hEndCap

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 4)
    $hEndCap = _GDIPlus_ArrowCapCreate(3, 6)
    _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap)

    ; Show pen end cap
    MsgBox($MB_SYSTEMMODAL, "Information", "Pen end cap: " & _GDIPlus_PenGetCustomEndCap($hPen))

    ; Draw arrows
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 120, 390, 120, $hPen)
    _GDIPlus_PenSetWidth($hPen, 6)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)
    _GDIPlus_PenSetWidth($hPen, 8)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 200, 390, 200, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PenSetDashCap

Function Reference

_GDIPlus_PenSetDashCap

Sets the pen dash cap style

#include <GDIPlus.au3>
_GDIPlus_PenSetDashCap ( $hPen [, $iDash = 0] )

Parameters

$hPen | Handle to a pen object
$iDash | [optional] Dash cap style. Can be one of the following: $GDIP_DASHCAPFLAT - A square cap that squares off both ends of each dash $GDIP_DASHCAPROUND - A circular cap that rounds off both ends of each dash $GDIP_DASHCAPTRIANGLE - A triangular cap that points both ends of each dash

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PenGetDashCap

See Also

Search GdipSetPenDashCap197819 in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 8)
    _GDIPlus_PenSetDashStyle($hPen, $GDIP_DASHSTYLEDASHDOT)
    _GDIPlus_PenSetDashCap($hPen, $GDIP_DASHCAPTRIANGLE)

    ; Show pen dash cap
    MsgBox($MB_SYSTEMMODAL, "Information", "Pen dash cap: " & _GDIPlus_PenGetDashCap($hPen))

    ; Draw line
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PenSetDashStyle

Function Reference

_GDIPlus_PenSetDashStyle

Sets the pen dash style

#include <GDIPlus.au3>
_GDIPlus_PenSetDashStyle ( $hPen [, $iStyle = 0] )

Parameters

$hPen | Handle to a pen object
$iStyle | [optional] Dash style. Can be one of the following: $GDIP_DASHSTYLESOLID - A solid line $GDIP_DASHSTYLEDASH - A dashed line $GDIP_DASHSTYLEDOT - A dotted line $GDIP_DASHSTYLEDASHDOT - An alternating dash-dot line $GDIP_DASHSTYLEDASHDOTDOT - An alternating dash-dot-dot line $GDIP_DASHSTYLECUSTOM - A a user-defined, custom dashed line

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PenGetDashStyle

See Also

Search GdipSetPenDashStyle in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 8)
    _GDIPlus_PenSetDashStyle($hPen, $GDIP_DASHSTYLEDASHDOT)

    ; Show pen dash style
    MsgBox($MB_SYSTEMMODAL, "Information", "Pen dash style: " & _GDIPlus_PenGetDashStyle($hPen))

    ; Draw line
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PenSetEndCap

Function Reference

_GDIPlus_PenSetEndCap

Sets the pen end cap

#include <GDIPlus.au3>
_GDIPlus_PenSetEndCap ( $hPen, $iEndCap )

Parameters

$hPen | Handle to a pen object
$iEndCap | End cap type. Can be one of the following: $GDIP_LINECAPFLAT - Specifies a flat cap $GDIP_LINECAPSQUARE - Specifies a square cap $GDIP_LINECAPROUND - Specifies a circular cap $GDIP_LINECAPTRIANGLE - Specifies a triangular cap $GDIP_LINECAPNOANCHOR - Specifies that the line ends are not anchored $GDIP_LINECAPSQUAREANCHOR - Specifies that the line ends are anchored with a square $GDIP_LINECAPROUNDANCHOR - Specifies that the line ends are anchored with a circle $GDIP_LINECAPDIAMONDANCHOR - Specifies that the line ends are anchored with a diamond $GDIP_LINECAPARROWANCHOR - Specifies that the line ends are anchored with arrowheads $GDIP_LINECAPCUSTOM - Specifies that the line ends are made from a CustomLineCap

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PenGetEndCap

See Also

Search GdipSetPenEndCap in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create resources
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 8)
    _GDIPlus_PenSetEndCap($hPen, $GDIP_LINECAPARROWANCHOR)

    ; Show pen end cap
    MsgBox($MB_SYSTEMMODAL, "Information", "Pen end cap type: " & _GDIPlus_PenGetEndCap($hPen))

    ; Draw arrows
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 130, 390, 130, $hPen)
    _GDIPlus_PenSetWidth($hPen, 6)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)
    _GDIPlus_PenSetWidth($hPen, 8)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 170, 390, 170, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PenSetLineCap

Function Reference

_GDIPlus_PenSetLineCap

Sets the cap styles for the start, end, and dashes in a line drawn with the pen

#include <GDIPlus.au3>
_GDIPlus_PenSetLineCap ( $hPen, $iStartCap, $iEndCap, $iDashCap )

Parameters

$hPen | Pointer to a Pen object
$iStartCap Line cap style for the start cap:
0x00 - Line ends at the last point. The end is squared off
0x01 - Square cap. The center of the square is the last point in the line.
The height and width of the square are the line width.
0x02 - Circular cap. The center of the circle is the last point in the line.
The diameter of the circle is the line width.
0x03 - Triangular cap.
The base of the triangle is the last point in the line.
The base of the triangle is the line width.
0x10 - Line ends are not anchored.
0x11 - Line ends are anchored with a square.
The center of the square is the last point in the line.
The height and width of the square are the line width.
0x12 - Line ends are anchored with a circle.
The center of the circle is at the last point in the line.
The circle is wider than the line.
0x13 - Line ends are anchored with a diamond (a square turned at 45 degrees).
The center of the diamond is at the last point in the line.
The diamond is wider than the line.
0x14 - Line ends are anchored with arrowheads.
The arrowhead point is located at the last point in the line.
The arrowhead is wider than the line.
0xff - Line ends are made from a CustomLineCap object
$iEndCap | Line cap style for the end cap (same values as $iStartCap)
$iDashCap Start and end caps for a dashed line:
0 - A square cap that squares off both ends of each dash
2 - A circular cap that rounds off both ends of each dash
3 - A triangular cap that points both ends of each dash

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PenSetDashCap, _GDIPlus_PenSetEndCap, _GDIPlus_PenSetStartCap

See Also

Search GdipSetPenLineCap197819 in MSDN Library.


Function _GDIPlus_PenSetLineJoin

Function Reference

_GDIPlus_PenSetLineJoin

Sets the line join for a Pen object

#include <GDIPlus.au3>
_GDIPlus_PenSetLineJoin ( $hPen, $iLineJoin )

Parameters

$hPen | Pointer to a Pen object
$iLineJoin | Line join style: 0 - Line join produces a sharp corner or a clipped corner 1 - Line join produces a diagonal corner. 2 - Line join produces a smooth, circular arc between the lines. 3 - Line join produces a sharp corner or a clipped corner

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipSetPenLineJoin in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 800, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Local $hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(800, 400, $hGraphics)
    Local $hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($hBmp_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx_Buffer, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGfx_Buffer, 0xFF000000)

    Local $hPath = _GDIPlus_PathCreate()
    Local $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, 800, 400)
    _GDIPlus_PathAddString($hPath, "AutoIt rulez!", $tLayout, $hFamily, 0, 140, $hFormat)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontFamilyDispose($hFamily)

    Local $aPoints[5][2] = [[4]]
    $aPoints[1][0] = 0
    $aPoints[1][1] = 0
    $aPoints[2][0] = 20
    $aPoints[2][1] = 0
    $aPoints[3][0] = 20
    $aPoints[3][1] = 20
    $aPoints[4][0] = 0
    $aPoints[4][1] = 20

    Local $aColors[4] = [3]
    $aColors[1] = 0xFFFF0000
    $aColors[2] = 0xFF00FF00
    $aColors[3] = 0xFF0000FF

    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixRotate($hMatrix, 1, True)

    Local $hBrush, $hPen

    Local $hTimer = TimerInit()
    ; Loop until the user exits.
    Do
        If TimerDiff($hTimer) > 40 Then
            _GDIPlus_MatrixTransformPoints($hMatrix, $aPoints)

            $hBrush = _GDIPlus_PathBrushCreate($aPoints, 3)
            _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFFFF)
            _GDIPlus_PathBrushSetSurroundColorsWithCount($hBrush, $aColors)
            $hPen = _GDIPlus_PenCreate2($hBrush, 6)
            _GDIPlus_PenSetLineJoin($hPen, $GDIP_PENSETLINEJOIN_ROUND)
            _GDIPlus_BrushDispose($hBrush)

            _GDIPlus_GraphicsClear($hGfx_Buffer, 0xFF000000)
            _GDIPlus_GraphicsDrawPath($hGfx_Buffer, $hPath, $hPen)
            _GDIPlus_PenDispose($hPen)

            _GDIPlus_GraphicsDrawImage($hGraphics, $hBmp_Buffer, 0, 0)
            $hTimer = TimerInit()
        EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_GraphicsDispose($hGfx_Buffer)
    _GDIPlus_BitmapDispose($hBmp_Buffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PenSetMiterLimit

Function Reference

_GDIPlus_PenSetMiterLimit

Sets the miter limit of a Pen object

#include <GDIPlus.au3>
_GDIPlus_PenSetMiterLimit ( $hPen, $fMiterLimit )

Parameters

$hPen | Pointer to a Pen object
$fMiterLimit | Real number that specifies the miter limit of the Pen object. A real number value that is less than 1.0 will be replaced with 1.0.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

The miter length is the distance from the intersection of the line walls on the inside of the join to the intersection of the line walls outside of the join.
The miter length can be large when the angle between two lines is small.
The miter limit is the maximum allowed ratio of miter length to stroke width. The default value is 10.0.
If the miter length of the join of the intersection exceeds the limit of the join, then the join will be beveled to keep it within the limit of the join of the intersection.

Related

_GDIPlus_PenGetMiterLimit

See Also

Search GdipSetPenMiterLimit in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen, $fPenWidth, $hPath

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 600)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hPath = _GDIPlus_PathCreate() ;Create new path object
    _GDIPlus_PathAddLine($hPath, 30, 550, 70, 200)
    _GDIPlus_PathAddLine($hPath, 70, 200, 110, 550)

    $fPenWidth = 32

    Local $hPen1 = _GDIPlus_PenCreate(0xFF00FF00, 1)
    For $i = 0 To 6
        _GDIPlus_GraphicsDrawLine($hGraphic, 0, 200 - $fPenWidth * 0.5 * $i, 800, 200 - $fPenWidth * 0.5 * $i, $hPen1)
    Next

    $hPen = _GDIPlus_PenCreate(0xFF8800AA, $fPenWidth)
    For $i = 1 To 6
        _GDIPlus_PenSetMiterLimit($hPen, $i)
        _GDIPlus_GraphicsDrawString($hGraphic, "MiterLimit: " & StringFormat("%.1f", _GDIPlus_PenGetMiterLimit($hPen)), 10, 10)
        _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen)
        _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen1)
        _GDIPlus_GraphicsTranslateTransform($hGraphic, 130, 0)
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PenDispose($hPen1)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PenSetStartCap

Function Reference

_GDIPlus_PenSetStartCap

Sets the start cap for a Pen object

#include <GDIPlus.au3>
_GDIPlus_PenSetStartCap ( $hPen, $iLineCap )

Parameters

$hPen Pointer to a Pen object
$iLineCap Line cap style:
0x00 - Line ends at the last point. The end is squared off
0x01 - Square cap. The center of the square is the last point in the line. The height and width of the square are the line width.
0x02 - Circular cap. The center of the circle is the last point in the line. The diameter of the circle is the line width.
0x03 - Triangular cap. The base of the triangle is the last point in the line. The base of the triangle is the line width.
0x10 - Line ends are not anchored.
0x11 - Line ends are anchored with a square. The center of the square is the last point in the line. The height and width of the square are the line width.
0x12 - Line ends are anchored with a circle. The center of the circle is at the last point in the line. The circle is wider than the line.
0x13 - Line ends are anchored with a diamond (a square turned at 45 degrees). The center of the diamond is at the last point in the line. The diamond is wider than the line.
0x14 - Line ends are anchored with arrowheads. The arrowhead point is located at the last point in the line. The arrowhead is wider than the line.
0xff - Line ends are made from a CustomLineCap object.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipSetPenStartCap in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (antialiasing)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hPen = _GDIPlus_PenCreate(0xFFAA00FF, 40)
    _GDIPlus_PenSetStartCap($hPen, $GDIP_LINECAPROUND)
    _GDIPlus_PenSetEndCap($hPen, $GDIP_LINECAPROUND)

    _GDIPlus_GraphicsDrawArc($hGraphic, 60, 60, 280, 280, 135, 270, $hPen)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_PenSetWidth

Function Reference

_GDIPlus_PenSetWidth

Sets the width of a pen

#include <GDIPlus.au3>
_GDIPlus_PenSetWidth ( $hPen, $fWidth )

Parameters

$hPen | Handle to a pen object
$fWidth | Width of pen

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_PenGetWidth

See Also

Search GdipSetPenWidth in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw line
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate(0xFF000000, 8)
    _GDIPlus_PenSetWidth($hPen, 4)
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 10, 390, 10, $hPen)

    ; Show pen width
    MsgBox($MB_SYSTEMMODAL, "Information", "Pen Width: " & _GDIPlus_PenGetWidth($hPen))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


User Defined Functions

Region user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_RegionClone | Clones a Region object
_GDIPlus_RegionCombinePath | Updates a region to the portion of itself that intersects the specified path's interior
_GDIPlus_RegionCombineRect | Updates a region to the portion of itself that intersects the specified rectangle's interior
_GDIPlus_RegionCombineRegion | Updates a region to the portion of itself that intersects another region
_GDIPlus_RegionCreate | Creates a region that is infinite
_GDIPlus_RegionCreateFromPath | Creates a region that is defined by a path object and has a fill mode that is contained in the path object
_GDIPlus_RegionCreateFromRect | Creates a region that is defined by a rectangle
_GDIPlus_RegionDispose | Releases a Region object
_GDIPlus_RegionGetBounds | Gets a rectangle that encloses a region
_GDIPlus_RegionGetHRgn | Creates a GDI region from a GDI+ Region object
_GDIPlus_RegionTransform | Tansforms a region by multiplying each of its data points by a specified matrix
_GDIPlus_RegionTranslate | Offsets a region by specified amounts in the horizontal and vertical directions


Function _GDIPlus_RegionClone

Function Reference

_GDIPlus_RegionClone

Clones a Region object

#include <GDIPlus.au3>
_GDIPlus_RegionClone ( $hRegion )

Parameters

$hRegion Pointer to a Region object to be cloned

Return Value

Success: | a pointer to a new cloned Region object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_RegionDispose() to release the object resources.

Related

_GDIPlus_RegionDispose

See Also

Search GdipCloneRegion in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hRegion, $hRegion1, $hRegion2, $hPath

    ; Create GUI
    $hGUI = GUICreate("GDI+", 600, 480)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)

    $hPath = _GDIPlus_PathCreate() ;Create new path object
    _GDIPlus_PathAddEllipse($hPath, 80, 60, 80, 60)

    $hRegion1 = _GDIPlus_RegionCreateFromRect(30, 80, 80, 60)
    $hRegion2 = _GDIPlus_RegionCreateFromPath($hPath)

    _GDIPlus_GraphicsDrawString($hGraphic, "2 regions", 50, 30)
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion1, $hBrush)
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion2, $hBrush)

    _GDIPlus_GraphicsDrawString($hGraphic, "intersection", 50, 180)
    _GDIPlus_RegionTranslate($hRegion1, 0, 150)
    _GDIPlus_RegionTranslate($hRegion2, 0, 150)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 1) ;intersection
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "union", 250, 180)
    _GDIPlus_RegionTranslate($hRegion1, 200, 0)
    _GDIPlus_RegionTranslate($hRegion2, 200, 0)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 2) ;union
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "xor", 450, 180)
    _GDIPlus_RegionTranslate($hRegion1, 200, 0)
    _GDIPlus_RegionTranslate($hRegion2, 200, 0)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 3) ;xor
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "region1 sub region2", 50, 330)
    _GDIPlus_RegionTranslate($hRegion1, -400, 150)
    _GDIPlus_RegionTranslate($hRegion2, -400, 150)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 4) ;1 sub 2
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "region2 sub region1", 250, 330)
    _GDIPlus_RegionTranslate($hRegion1, 200, 0)
    _GDIPlus_RegionTranslate($hRegion2, 200, 0)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 5) ;2 sub 1
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_RegionDispose($hRegion1)
    _GDIPlus_RegionDispose($hRegion2)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_RegionCombinePath

Function Reference

_GDIPlus_RegionCombinePath

Updates a region to the portion of itself that intersects the specified path's interior

#include <GDIPlus.au3>
_GDIPlus_RegionCombinePath ( $hRegion, $hPath [, $iCombineMode = 2] )

Parameters

$hRegion | Pointer to a Region object
$hPath | Pointer to a GraphicsPath object that specifies the path to use to update the region
$iCombineMode | [optional] Combine mode that specifies how the region is combined with the path: 0 - The existing region is replaced by the new region 1 - The existing region is replaced by the intersection of itself and the new region 2 - The existing region is replaced by the union of itself and the new region 3 - The existing region is replaced by the result of performing an XOR on the two regions. A point is in the XOR of two regions if it is in one region or the other but not in both regions 4 - The existing region is replaced by the portion of itself that is outside of the new region 5 - The existing region is replaced by the portion of the new region that is outside of the existing region

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_RegionCombineRect, _GDIPlus_RegionCombineRegion

See Also

Search GdipCombineRegionPath in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hPath, $hFamily, $tLayout, $aSize, $hRegion, $hRGN

    _GDIPlus_Startup()

    $hGUI = GUICreate("GDI+", 620, 100)
    GUISetBkColor(0x80) ;Set window background color to blue
    GUISetState(@SW_SHOW)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    $hFamily = _GDIPlus_FontFamilyCreate("Arial Black") ;Create font family object
    $tLayout = _GDIPlus_RectFCreate() ;Create string bounding rectangle X=0, Y=0
    _GDIPlus_PathAddString($hPath, "AutoIt rulez!", $tLayout, $hFamily, 0, 85, 0) ;Add the outline of the string to the path

    $aSize = WinGetPos($hGUI) ;Get windowsize

    $hRegion = _GDIPlus_RegionCreateFromRect(0, 0, 110, $aSize[3]) ;Create region from a rectangle
    _GDIPlus_RegionCombineRect($hRegion, $aSize[2] - 110, 0, 110, $aSize[3], 2) ;Combine rectangle_left AND rectangle_right
    _GDIPlus_RegionCombinePath($hRegion, $hPath, 3) ;Combine rectangles XOR string

    $hRGN = _GDIPlus_RegionGetHRgn($hRegion, 0) ;Create GDI region from GDI+ region
    _WinAPI_SetWindowRgn($hGUI, $hRGN) ;Set window region

    ;Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;Clean up resources
    _GDIPlus_FontFamilyDispose($hFamily)
    _WinAPI_DeleteObject($hRGN)
    _GDIPlus_RegionDispose($hRegion)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_RegionCombineRect

Function Reference

_GDIPlus_RegionCombineRect

Updates a region to the portion of itself that intersects the specified rectangle's interior

#include <GDIPlus.au3>
_GDIPlus_RegionCombineRect ( $hRegion, $nX, $nY, $nWidth, $nHeight [, $iCombineMode = 2] )

Parameters

$hRegion | Pointer to a Region object
$nX | The X coordinate of the upper left corner of the rectangle
$nY | The Y coordinate of the upper left corner of the rectangle
$nWidth | The width of the rectangle
$nHeight | The height of the rectangle
$iCombineMode | [optional] Combine mode that specifies how the region is combined with the rectangle: 0 - The existing region is replaced by the new region 1 - The existing region is replaced by the intersection of itself and the new region 2 - The existing region is replaced by the union of itself and the new region 3 - The existing region is replaced by the result of performing an XOR on the two regions. A point is in the XOR of two regions if it is in one region or the other but not in both regions 4 - The existing region is replaced by the portion of itself that is outside of the new region 5 - The existing region is replaced by the portion of the new region that is outside of the existing region

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_RegionCombinePath, _GDIPlus_RegionCombineRegion

See Also

Search GdipCombineRegionRect in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hPath, $hFamily, $tLayout, $aSize, $hRegion, $hRGN

    _GDIPlus_Startup()

    $hGUI = GUICreate("GDI+", 620, 100)
    GUISetBkColor(0x80) ;Set window background color to blue
    GUISetState(@SW_SHOW)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    $hFamily = _GDIPlus_FontFamilyCreate("Arial Black") ;Create font family object
    $tLayout = _GDIPlus_RectFCreate() ;Create string bounding rectangle X=0, Y=0
    _GDIPlus_PathAddString($hPath, "AutoIt rulez!", $tLayout, $hFamily, 0, 85, 0) ;Add the outline of the string to the path

    $aSize = WinGetPos($hGUI) ;Get windowsize

    $hRegion = _GDIPlus_RegionCreateFromRect(0, 0, 110, $aSize[3]) ;Create region from a rectangle
    _GDIPlus_RegionCombineRect($hRegion, $aSize[2] - 110, 0, 110, $aSize[3], 2) ;Combine rectangle_left AND rectangle_right
    _GDIPlus_RegionCombinePath($hRegion, $hPath, 3) ;Combine rectangles XOR string

    $hRGN = _GDIPlus_RegionGetHRgn($hRegion, 0) ;Create GDI region from GDI+ region
    _WinAPI_SetWindowRgn($hGUI, $hRGN) ;Set window region

    ;Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;Clean up resources
    _GDIPlus_FontFamilyDispose($hFamily)
    _WinAPI_DeleteObject($hRGN)
    _GDIPlus_RegionDispose($hRegion)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_RegionCombineRegion

Function Reference

_GDIPlus_RegionCombineRegion

Updates a region to the portion of itself that intersects another region

#include <GDIPlus.au3>
_GDIPlus_RegionCombineRegion ( $hRegionDst, $hRegionSrc [, $iCombineMode = 2] )

Parameters

$hRegionDst | Pointer to a Region object
$hRegionSrc | Pointer to a Region object to use to update the $hRegionDst Region object
$iCombineMode | [optional] Combine mode that specifies how the regions are combined: 0 - The existing region is replaced by the new region 1 - The existing region is replaced by the intersection of itself and the new region 2 - The existing region is replaced by the union of itself and the new region 3 - The existing region is replaced by the result of performing an XOR on the two regions. A point is in the XOR of two regions if it is in one region or the other but not in both regions 4 - The existing region is replaced by the portion of itself that is outside of the new region 5 - The existing region is replaced by the portion of the new region that is outside of the existing region

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_RegionCombinePath, _GDIPlus_RegionCombineRect

See Also

Search GdipCombineRegionRegion in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hRegion, $hRegion1, $hRegion2, $hPath

    ; Create GUI
    $hGUI = GUICreate("GDI+", 600, 480)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)

    $hPath = _GDIPlus_PathCreate() ;Create new path object
    _GDIPlus_PathAddEllipse($hPath, 80, 60, 80, 60)

    $hRegion1 = _GDIPlus_RegionCreateFromRect(30, 80, 80, 60)
    $hRegion2 = _GDIPlus_RegionCreateFromPath($hPath)

    _GDIPlus_GraphicsDrawString($hGraphic, "2 regions", 50, 30)
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion1, $hBrush)
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion2, $hBrush)

    _GDIPlus_GraphicsDrawString($hGraphic, "intersection", 50, 180)
    _GDIPlus_RegionTranslate($hRegion1, 0, 150)
    _GDIPlus_RegionTranslate($hRegion2, 0, 150)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 1) ;intersection
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "union", 250, 180)
    _GDIPlus_RegionTranslate($hRegion1, 200, 0)
    _GDIPlus_RegionTranslate($hRegion2, 200, 0)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 2) ;union
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "xor", 450, 180)
    _GDIPlus_RegionTranslate($hRegion1, 200, 0)
    _GDIPlus_RegionTranslate($hRegion2, 200, 0)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 3) ;xor
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "region1 sub region2", 50, 330)
    _GDIPlus_RegionTranslate($hRegion1, -400, 150)
    _GDIPlus_RegionTranslate($hRegion2, -400, 150)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 4) ;1 sub 2
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "region2 sub region1", 250, 330)
    _GDIPlus_RegionTranslate($hRegion1, 200, 0)
    _GDIPlus_RegionTranslate($hRegion2, 200, 0)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 5) ;2 sub 1
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_RegionDispose($hRegion1)
    _GDIPlus_RegionDispose($hRegion2)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_RegionCreate

Function Reference

_GDIPlus_RegionCreate

Creates a region that is infinite

#include <GDIPlus.au3>
_GDIPlus_RegionCreate ( )

Return Value

Success: | a pointer to a new Region object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_RegionDispose() to release the object resources.

Related

_GDIPlus_RegionDispose

See Also

Search GdipCreateRegion in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    Local $hBMP = _ScreenCapture_Capture()

    Local $hGUI = GUICreate("GDI+", 400, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    Local $hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(400, 400, $hGraphics)
    Local $hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($hBmp_Buffer)

    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)

    Local $hMatrix1 = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix1, 200, 200)
    Local $hMatrix2 = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix2, 200, 200)

    Local $hPath = _GDIPlus_PathCreate()
    For $i = 0 To 300 Step 24
        _GDIPlus_PathAddEllipse($hPath, -$i, -$i, $i * 2, $i * 2)
    Next

    Local $hRegion = _GDIPlus_RegionCreate()
    _GDIPlus_RegionCombinePath($hRegion, $hPath, 4)

    Local $hTimer = TimerInit()
    ; Loop until the user exits.
    Do
        If TimerDiff($hTimer) > 20 Then
            _GDIPlus_GraphicsResetClip($hGfx_Buffer)
            _GDIPlus_GraphicsClear($hGfx_Buffer, 0x33FFAA00)

            _GDIPlus_MatrixRotate($hMatrix1, 1)
            _GDIPlus_MatrixRotate($hMatrix2, -1)

            _GDIPlus_GraphicsSetTransform($hGfx_Buffer, $hMatrix1)
            _GDIPlus_GraphicsSetClipRegion($hGfx_Buffer, $hRegion)
            _GDIPlus_GraphicsDrawImage($hGfx_Buffer, $hBitmap, -300, -300)

            _GDIPlus_GraphicsSetTransform($hGfx_Buffer, $hMatrix2)
            _GDIPlus_GraphicsSetClipPath($hGfx_Buffer, $hPath)
            _GDIPlus_GraphicsDrawImage($hGfx_Buffer, $hBitmap, -300, -300)

            _GDIPlus_GraphicsDrawImage($hGraphics, $hBmp_Buffer, 0, 0)
            $hTimer = TimerInit()
        EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_RegionDispose($hRegion)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_MatrixDispose($hMatrix1)
    _GDIPlus_MatrixDispose($hMatrix2)
    _GDIPlus_BitmapDispose($hBitmap)
    _WinAPI_DeleteObject($hBMP)
    _GDIPlus_GraphicsDispose($hGfx_Buffer)
    _GDIPlus_BitmapDispose($hBmp_Buffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_RegionCreateFromPath

Function Reference

_GDIPlus_RegionCreateFromPath

Creates a region that is defined by a path object and has a fill mode that is contained in the path object

#include <GDIPlus.au3>
_GDIPlus_RegionCreateFromPath ( $hPath )

Parameters

$hPath Pointer to a GraphicsPath object that specifies the path

Return Value

Success: | a pointer to a new Region object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_RegionDispose() to release the object resources.

Related

_GDIPlus_RegionDispose

See Also

Search GdipCreateRegionPath in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hRegion, $hRegion1, $hRegion2, $hPath

    ; Create GUI
    $hGUI = GUICreate("GDI+", 600, 480)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)

    $hPath = _GDIPlus_PathCreate() ;Create new path object
    _GDIPlus_PathAddEllipse($hPath, 80, 60, 80, 60)

    $hRegion1 = _GDIPlus_RegionCreateFromRect(30, 80, 80, 60)
    $hRegion2 = _GDIPlus_RegionCreateFromPath($hPath)

    _GDIPlus_GraphicsDrawString($hGraphic, "2 regions", 50, 30)
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion1, $hBrush)
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion2, $hBrush)

    _GDIPlus_GraphicsDrawString($hGraphic, "intersection", 50, 180)
    _GDIPlus_RegionTranslate($hRegion1, 0, 150)
    _GDIPlus_RegionTranslate($hRegion2, 0, 150)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 1) ;intersection
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "union", 250, 180)
    _GDIPlus_RegionTranslate($hRegion1, 200, 0)
    _GDIPlus_RegionTranslate($hRegion2, 200, 0)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 2) ;union
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "xor", 450, 180)
    _GDIPlus_RegionTranslate($hRegion1, 200, 0)
    _GDIPlus_RegionTranslate($hRegion2, 200, 0)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 3) ;xor
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "region1 sub region2", 50, 330)
    _GDIPlus_RegionTranslate($hRegion1, -400, 150)
    _GDIPlus_RegionTranslate($hRegion2, -400, 150)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 4) ;1 sub 2
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "region2 sub region1", 250, 330)
    _GDIPlus_RegionTranslate($hRegion1, 200, 0)
    _GDIPlus_RegionTranslate($hRegion2, 200, 0)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 5) ;2 sub 1
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_RegionDispose($hRegion1)
    _GDIPlus_RegionDispose($hRegion2)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_RegionCreateFromRect

Function Reference

_GDIPlus_RegionCreateFromRect

Creates a region that is defined by a rectangle

#include <GDIPlus.au3>
_GDIPlus_RegionCreateFromRect ( $nX, $nY, $nWidth, $nHeight )

Parameters

$nX | The X coordinate of the upper left corner of the rectangle
$nY | The Y coordinate of the upper left corner of the rectangle
$nWidth | The width of the rectangle
$nHeight | The height of the rectangle

Return Value

Success: | a handle to a new Region object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

After you are done with the object, call _GDIPlus_RegionDispose() to release the object resources.

Related

_GDIPlus_RegionDispose

See Also

Search GdipCreateRegionRect in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hPath, $hFamily, $tLayout, $aSize, $hRegion, $hRGN

    _GDIPlus_Startup()

    $hGUI = GUICreate("GDI+", 620, 100)
    GUISetBkColor(0x80) ;Set window background color to blue
    GUISetState(@SW_SHOW)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    $hFamily = _GDIPlus_FontFamilyCreate("Arial Black") ;Create font family object
    $tLayout = _GDIPlus_RectFCreate() ;Create string bounding rectangle X=0, Y=0
    _GDIPlus_PathAddString($hPath, "AutoIt rulez!", $tLayout, $hFamily, 0, 85, 0) ;Add the outline of the string to the path

    $aSize = WinGetPos($hGUI) ;Get windowsize

    $hRegion = _GDIPlus_RegionCreateFromRect(0, 0, 110, $aSize[3]) ;Create region from a rectangle
    _GDIPlus_RegionCombineRect($hRegion, $aSize[2] - 110, 0, 110, $aSize[3], 2) ;Combine rectangle_left AND rectangle_right
    _GDIPlus_RegionCombinePath($hRegion, $hPath, 3) ;Combine rectangles XOR string

    $hRGN = _GDIPlus_RegionGetHRgn($hRegion, 0) ;Create GDI region from GDI+ region
    _WinAPI_SetWindowRgn($hGUI, $hRGN) ;Set window region

    ;Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;Clean up resources
    _GDIPlus_FontFamilyDispose($hFamily)
    _WinAPI_DeleteObject($hRGN)
    _GDIPlus_RegionDispose($hRegion)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_RegionDispose

Function Reference

_GDIPlus_RegionDispose

Releases a Region object

#include <GDIPlus.au3>
_GDIPlus_RegionDispose ( $hRegion )

Parameters

$hRegion Pointer to a Region object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipDeleteRegion in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hPath, $hFamily, $tLayout, $aSize, $hRegion, $hRGN

    _GDIPlus_Startup()

    $hGUI = GUICreate("GDI+", 620, 100)
    GUISetBkColor(0x80) ;Set window background color to blue
    GUISetState(@SW_SHOW)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    $hFamily = _GDIPlus_FontFamilyCreate("Arial Black") ;Create font family object
    $tLayout = _GDIPlus_RectFCreate() ;Create string bounding rectangle X=0, Y=0
    _GDIPlus_PathAddString($hPath, "AutoIt rulez!", $tLayout, $hFamily, 0, 85, 0) ;Add the outline of the string to the path

    $aSize = WinGetPos($hGUI) ;Get windowsize

    $hRegion = _GDIPlus_RegionCreateFromRect(0, 0, 110, $aSize[3]) ;Create region from a rectangle
    _GDIPlus_RegionCombineRect($hRegion, $aSize[2] - 110, 0, 110, $aSize[3], 2) ;Combine rectangle_left AND rectangle_right
    _GDIPlus_RegionCombinePath($hRegion, $hPath, 3) ;Combine rectangles XOR string

    $hRGN = _GDIPlus_RegionGetHRgn($hRegion, 0) ;Create GDI region from GDI+ region
    _WinAPI_SetWindowRgn($hGUI, $hRGN) ;Set window region

    ;Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;Clean up resources
    _GDIPlus_FontFamilyDispose($hFamily)
    _WinAPI_DeleteObject($hRGN)
    _GDIPlus_RegionDispose($hRegion)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_RegionGetBounds

Function Reference

_GDIPlus_RegionGetBounds

Gets a rectangle that encloses a region

#include <GDIPlus.au3>
_GDIPlus_RegionGetBounds ( $hRegion, $hGraphics )

Parameters

$hRegion | Pointer to a Region object
$hGraphics | Pointer to a Graphics object that contains the world and page transformations required to calculate the device coordinates of the region and the rectangle

Return Value

Success: | an array containing the rectangle coordinates and dimensions: [0] - X coordinate of the upper-left corner of the rectangle [1] - Y coordinate of the upper-left corner of the rectangle [2] - Width of the rectangle [3] - Height of the rectangle
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetRegionBounds in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create GUI
    Local $hGUI = GUICreate("GDI+", 800, 340)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    Local $hPen = _GDIPlus_PenCreate(0xFF0000FF)
    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000)

    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 96, 0)

    Local $sString = ChrW(0x1EF2) & ChrW(0x1EF3)

    Local $iPosX = 50
    Local $iPosY = 50
    Local $aStrDim = _MeasureString($hGraphic, $sString, $hFont, $hFormat, $hFamily)

    _GDIPlus_GraphicsDrawString($hGraphic, "MeasureString", $iPosX, $iPosY - 30)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX, $iPosY - 5, $iPosX, $iPosY + 5, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX - 5, $iPosY, $iPosX + 5, $iPosY, $hPen)
    Local $tLayout = _GDIPlus_RectFCreate($iPosX, $iPosY, $aStrDim[4], $aStrDim[5])
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX, $iPosY, $aStrDim[4], $aStrDim[5], $hPen)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush)

    $iPosX = 300
    _GDIPlus_GraphicsDrawString($hGraphic, "MeasureCharacterRanges", $iPosX, $iPosY - 30)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX, $iPosY - 5, $iPosX, $iPosY + 5, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX - 5, $iPosY, $iPosX + 5, $iPosY, $hPen)
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX + $aStrDim[0], $iPosY + $aStrDim[1], $aStrDim[2], $aStrDim[3], $hPen)
    DllStructSetData($tLayout, "X", $iPosX)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush)

    $iPosX = 550
    _GDIPlus_GraphicsDrawString($hGraphic, "CellAscent / CellDescent", $iPosX, $iPosY - 30)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX, $iPosY - 5, $iPosX, $iPosY + 5, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iPosX - 5, $iPosY, $iPosX + 5, $iPosY, $hPen)
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX + $aStrDim[0], $iPosY + $aStrDim[1], $aStrDim[2], $aStrDim[7], $hPen)
    _GDIPlus_GraphicsDrawRect($hGraphic, $iPosX + $aStrDim[0], $iPosY + $aStrDim[1] + $aStrDim[7], $aStrDim[2], $aStrDim[8], $hPen)
    DllStructSetData($tLayout, "X", $iPosX)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush)

    $sString = "fontsize goes crazy"
    $iPosX = 50
    $iPosY = 300

    Local $sChar
    For $i = 0 To StringLen($sString)

        $sChar = StringLeft($sString, 1)
        $sString = StringTrimLeft($sString, 1)

        If $sChar = " " Then
            $aStrDim = _MeasureString($hGraphic, "_", $hFont, $hFormat, $hFamily)
            $iPosX += $aStrDim[2]
            ContinueLoop
        EndIf

        _GDIPlus_FontDispose($hFont)
        $hFont = _GDIPlus_FontCreate($hFamily, Random(12, 48), 0)
        $aStrDim = _MeasureString($hGraphic, $sChar, $hFont, $hFormat, $hFamily)

        $tLayout = _GDIPlus_RectFCreate($iPosX - $aStrDim[0], $iPosY - $aStrDim[1] - $aStrDim[7], $aStrDim[4], $aStrDim[5])
        _GDIPlus_GraphicsDrawStringEx($hGraphic, $sChar, $hFont, $tLayout, $hFormat, $hBrush)

        $iPosX += $aStrDim[2]
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Func _MeasureString($hGraphics, $sString, $hFont, $hFormat, $hFamily, $iStyle = 0)
    Local $tLayout = _GDIPlus_RectFCreate()
    Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat)

    Local $aRanges[2][2] = [[1]]
    $aRanges[1][1] = StringLen($sString)
    _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges)
    Local $aRegion = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphics, $sString, $hFont, $aInfo[0], $hFormat)
    Local $aBounds = _GDIPlus_RegionGetBounds($aRegion[1], $hGraphics)
    _GDIPlus_RegionDispose($aRegion[1])

    Local $iFontHeight = _GDIPlus_FontGetHeight($hFont, $hGraphics)
    Local $iLineSpacing = _GDIPlus_FontFamilyGetLineSpacing($hFamily, $iStyle)
    Local $iAscent = $iFontHeight / $iLineSpacing * _GDIPlus_FontFamilyGetCellAscent($hFamily, $iStyle)
    Local $iDescent = $iFontHeight / $iLineSpacing * _GDIPlus_FontFamilyGetCellDescent($hFamily, $iStyle)

    Local $aDim[9]
    $aDim[0] = $aBounds[0]
    $aDim[1] = $aBounds[1]
    $aDim[2] = $aBounds[2]
    $aDim[3] = $aBounds[3]
    $aDim[4] = DllStructGetData($aInfo[0], "Width")
    $aDim[5] = DllStructGetData($aInfo[0], "Height")
    $aDim[6] = $iFontHeight
    $aDim[7] = $iAscent
    $aDim[8] = $iDescent

    Return $aDim
EndFunc   ;==>_MeasureString


Function _GDIPlus_RegionGetHRgn

Function Reference

_GDIPlus_RegionGetHRgn

Creates a GDI region from a GDI+ Region object

#include <GDIPlus.au3>
_GDIPlus_RegionGetHRgn ( $hRegion [, $hGraphics = 0] )

Parameters

$hRegion | Pointer to a Region object
$hGraphics | [optional] Pointer to a Graphics object that contains the world and page transformations required to calculate the device coordinates of the region

Return Value

Success: | a handle to a GDI region (HRGN) object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipGetRegionHRgn in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hPath, $hFamily, $tLayout, $aSize, $hRegion, $hRGN

    _GDIPlus_Startup()

    $hGUI = GUICreate("GDI+", 620, 100)
    GUISetBkColor(0x80) ;Set window background color to blue
    GUISetState(@SW_SHOW)

    $hPath = _GDIPlus_PathCreate() ;Create new path object

    $hFamily = _GDIPlus_FontFamilyCreate("Arial Black") ;Create font family object
    $tLayout = _GDIPlus_RectFCreate() ;Create string bounding rectangle X=0, Y=0
    _GDIPlus_PathAddString($hPath, "AutoIt rulez!", $tLayout, $hFamily, 0, 85, 0) ;Add the outline of the string to the path

    $aSize = WinGetPos($hGUI) ;Get windowsize

    $hRegion = _GDIPlus_RegionCreateFromRect(0, 0, 110, $aSize[3]) ;Create region from a rectangle
    _GDIPlus_RegionCombineRect($hRegion, $aSize[2] - 110, 0, 110, $aSize[3], 2) ;Combine rectangle_left AND rectangle_right
    _GDIPlus_RegionCombinePath($hRegion, $hPath, 3) ;Combine rectangles XOR string

    $hRGN = _GDIPlus_RegionGetHRgn($hRegion, 0) ;Create GDI region from GDI+ region
    _WinAPI_SetWindowRgn($hGUI, $hRGN) ;Set window region

    ;Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;Clean up resources
    _GDIPlus_FontFamilyDispose($hFamily)
    _WinAPI_DeleteObject($hRGN)
    _GDIPlus_RegionDispose($hRegion)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_RegionTransform

Function Reference

_GDIPlus_RegionTransform

Tansforms a region by multiplying each of its data points by a specified matrix

#include <GDIPlus.au3>
_GDIPlus_RegionTransform ( $hRegion, $hMatrix )

Parameters

$hRegion | Pointer to a Region object
$hMatrix | Pointer to a matrix that specifies the transformation

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipTransformRegion in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hRegion, $hRegion1, $hRegion2, $hPath

    ; Create GUI
    $hGUI = GUICreate("GDI+", 600, 480)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)

    $hPath = _GDIPlus_PathCreate() ;Create new path object
    _GDIPlus_PathAddEllipse($hPath, 80, 60, 80, 60)

    $hRegion1 = _GDIPlus_RegionCreateFromRect(30, 80, 80, 60)
    $hRegion2 = _GDIPlus_RegionCreateFromPath($hPath)

    _GDIPlus_GraphicsDrawString($hGraphic, "2 regions", 50, 30)
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion1, $hBrush)
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion2, $hBrush)

    _GDIPlus_GraphicsDrawString($hGraphic, "intersection", 50, 180)
    _GDIPlus_RegionTranslate($hRegion1, 0, 150)
    _GDIPlus_RegionTranslate($hRegion2, 0, 150)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 1) ;intersection
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "union", 250, 180)
    _GDIPlus_RegionTranslate($hRegion1, 200, 0)
    _GDIPlus_RegionTranslate($hRegion2, 200, 0)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 2) ;union
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "xor", 450, 180)
    _GDIPlus_RegionTranslate($hRegion1, 200, 0)
    _GDIPlus_RegionTranslate($hRegion2, 200, 0)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 3) ;xor
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "region1 sub region2", 50, 330)
    _GDIPlus_RegionTranslate($hRegion1, -400, 150)
    _GDIPlus_RegionTranslate($hRegion2, -400, 150)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 4) ;1 sub 2
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "region2 sub region1", 250, 330)
    _GDIPlus_RegionTranslate($hRegion1, 200, 0)
    _GDIPlus_RegionTranslate($hRegion2, 200, 0)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 5) ;2 sub 1
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_RegionDispose($hRegion1)
    _GDIPlus_RegionDispose($hRegion2)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_RegionTranslate

Function Reference

_GDIPlus_RegionTranslate

Offsets a region by specified amounts in the horizontal and vertical directions

#include <GDIPlus.au3>
_GDIPlus_RegionTranslate ( $hRegion, $nDX, $nDY )

Parameters

$hRegion | Pointer to a Region object
$nDX | Real number that specifies the amount to shift the region in the X direction
$nDY | Real number that specifies the amount to shift the region in the Y direction

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

See Also

Search GdipTranslateRegion in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hRegion, $hRegion1, $hRegion2, $hPath

    ; Create GUI
    $hGUI = GUICreate("GDI+", 600, 480)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA)

    $hPath = _GDIPlus_PathCreate() ;Create new path object
    _GDIPlus_PathAddEllipse($hPath, 80, 60, 80, 60)

    $hRegion1 = _GDIPlus_RegionCreateFromRect(30, 80, 80, 60)
    $hRegion2 = _GDIPlus_RegionCreateFromPath($hPath)

    _GDIPlus_GraphicsDrawString($hGraphic, "2 regions", 50, 30)
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion1, $hBrush)
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion2, $hBrush)

    _GDIPlus_GraphicsDrawString($hGraphic, "intersection", 50, 180)
    _GDIPlus_RegionTranslate($hRegion1, 0, 150)
    _GDIPlus_RegionTranslate($hRegion2, 0, 150)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 1) ;intersection
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "union", 250, 180)
    _GDIPlus_RegionTranslate($hRegion1, 200, 0)
    _GDIPlus_RegionTranslate($hRegion2, 200, 0)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 2) ;union
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "xor", 450, 180)
    _GDIPlus_RegionTranslate($hRegion1, 200, 0)
    _GDIPlus_RegionTranslate($hRegion2, 200, 0)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 3) ;xor
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "region1 sub region2", 50, 330)
    _GDIPlus_RegionTranslate($hRegion1, -400, 150)
    _GDIPlus_RegionTranslate($hRegion2, -400, 150)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 4) ;1 sub 2
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    _GDIPlus_GraphicsDrawString($hGraphic, "region2 sub region1", 250, 330)
    _GDIPlus_RegionTranslate($hRegion1, 200, 0)
    _GDIPlus_RegionTranslate($hRegion2, 200, 0)
    $hRegion = _GDIPlus_RegionClone($hRegion1)
    _GDIPlus_RegionCombineRegion($hRegion, $hRegion2, 5) ;2 sub 1
    _GDIPlus_GraphicsFillRegion($hGraphic, $hRegion, $hBrush)
    _GDIPlus_RegionDispose($hRegion)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_RegionDispose($hRegion1)
    _GDIPlus_RegionDispose($hRegion2)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


User Defined Functions

StringFormat user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_StringFormatCreate | Create a String Format object
_GDIPlus_StringFormatDispose | Release a String Format object
_GDIPlus_StringFormatGetMeasurableCharacterRangeCount | Gets the number of measurable character ranges that are currently set for a StringFormat object
_GDIPlus_StringFormatSetAlign | Sets the text alignment of a string format object
_GDIPlus_StringFormatSetLineAlign | Sets the line alignment of a StringFormat object in relation to the origin of a layout rectangle
_GDIPlus_StringFormatSetMeasurableCharacterRanges | Sets a series of character ranges for a StringFormat object that, when in a string, can be measured


Function _GDIPlus_StringFormatCreate

Function Reference

_GDIPlus_StringFormatCreate

Create a String Format object

#include <GDIPlus.au3>
_GDIPlus_StringFormatCreate ( [$iFormat = 0 [, $iLangID = 0]] )

Parameters

$iFormat | [optional] Format flags. Can be one or more of the following: 0x0001 - Specifies that reading order is right to left 0x0002 - Specifies that individual lines of text are drawn vertically on the display device 0x0004 - Specifies that parts of characters are allowed to overhang the string's layout rectangle 0x0020 - Specifies that Unicode layout control characters are displayed with a representative character 0x0400 - Specifies that an alternate font is used for characters that are not supported in the requested font 0x0800 - Specifies that the space at the end of each line is included in a string measurement 0x1000 - Specifies that the wrapping of text to the next line is disabled 0x2000 - Specifies that only entire lines are laid out in the layout rectangle 0x4000 - Specifies that characters overhanging the layout rectangle and text extending outside the layout rectangle are allowed to show
$iLangID | [optional] The language to use

Return Value

Success: | a handle to a string format object.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the String Format object, call _GDIPlus_StringFormatDispose() to release the resources.

Related

_GDIPlus_StringFormatDispose, _GDIPlus_StringFormatSetAlign

See Also

Search GdipCreateStringFormat in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw a string
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
    $tLayout = _GDIPlus_RectFCreate(140, 110, 100, 20)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Hello world", $hFont, $tLayout, $hFormat, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)

    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_StringFormatDispose

Function Reference

_GDIPlus_StringFormatDispose

Release a String Format object

#include <GDIPlus.au3>
_GDIPlus_StringFormatDispose ( $hFormat )

Parameters

$hFormat Handle to a String Format object

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_StringFormatCreate

See Also

Search GdipDeleteStringFormat in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw a string
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
    $tLayout = _GDIPlus_RectFCreate(140, 110, 100, 20)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Hello world", $hFont, $tLayout, $hFormat, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)

    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_StringFormatGetMeasurableCharacterRangeCount

Function Reference

_GDIPlus_StringFormatGetMeasurableCharacterRangeCount

Gets the number of measurable character ranges that are currently set for a StringFormat object

#include <GDIPlus.au3>
_GDIPlus_StringFormatGetMeasurableCharacterRangeCount ( $hStringFormat )

Parameters

$hStringFormat Pointer to a StringFormat object

Return Value

Success: | the number of character ranges that can be measured.
Failure: | -1 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_GraphicsMeasureCharacterRanges, _GDIPlus_StringFormatSetMeasurableCharacterRanges

See Also

Search GdipGetStringFormatMeasurableCharacterRangeCount in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create GUI
    Local $hGUI = GUICreate("GDI+", 640, 220)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    Local $hPen = _GDIPlus_PenCreate(0xFF006600)
    Local $hBrush_Region = _GDIPlus_BrushCreateSolid(0x44FF0000)
    Local $hBrush_Font = _GDIPlus_BrushCreateSolid(0xFFFF0000)

    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")

    Local $sString = "Measure Character Ranges"

    Local $aRanges[4][2] = [[3]]
    $aRanges[1][0] = 0 ;Measure first char (0-ased)
    $aRanges[1][1] = 1 ;One char to measure
    $aRanges[2][0] = 4 ;5th char
    $aRanges[2][1] = 5 ;measure 5 chars
    $aRanges[3][0] = 14 ;15th char
    $aRanges[3][1] = 7 ;measure 7 chars

    _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges) ;Set ranges

    ;Measure characters fontsize = 14
    Local $hFont = _GDIPlus_FontCreate($hFamily, 14, 0)
    Local $tLayout = _GDIPlus_RectFCreate(10, 10, 200, 200)
    _GDIPlus_GraphicsDrawRect($hGraphic, 10, 10, 200, 200, $hPen)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush_Font)
    Local $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat) ;get array of regions
    For $i = 1 To $aRegions[0]
        _GDIPlus_GraphicsFillRegion($hGraphic, $aRegions[$i], $hBrush_Region)
        _GDIPlus_RegionDispose($aRegions[$i])
    Next
    _GDIPlus_FontDispose($hFont)

    ;Measure characters fontsize = 28
    $hFont = _GDIPlus_FontCreate($hFamily, 28, 0)
    $tLayout = _GDIPlus_RectFCreate(220, 10, 200, 200)
    _GDIPlus_GraphicsDrawRect($hGraphic, 220, 10, 200, 200, $hPen)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush_Font)
    $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat)
    For $i = 1 To $aRegions[0]
        _GDIPlus_GraphicsFillRegion($hGraphic, $aRegions[$i], $hBrush_Region)
        _GDIPlus_RegionDispose($aRegions[$i])
    Next
    _GDIPlus_FontDispose($hFont)

    ;Measure characters fontsize = 56
    $hFont = _GDIPlus_FontCreate($hFamily, 56, 0)
    $tLayout = _GDIPlus_RectFCreate(430, 10, 200, 200)
    _GDIPlus_GraphicsDrawRect($hGraphic, 430, 10, 200, 200, $hPen)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush_Font)
    $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat)
    For $i = 1 To $aRegions[0]
        _GDIPlus_GraphicsFillRegion($hGraphic, $aRegions[$i], $hBrush_Region)
        _GDIPlus_RegionDispose($aRegions[$i])
    Next
    _GDIPlus_FontDispose($hFont)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush_Font)
    _GDIPlus_BrushDispose($hBrush_Region)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_StringFormatSetAlign

Function Reference

_GDIPlus_StringFormatSetAlign

Sets the text alignment of a string format object

#include <GDIPlus.au3>
_GDIPlus_StringFormatSetAlign ( $hStringFormat, $iFlag )

Parameters

$hStringFormat | The string format object which is aligned
$iFlag | The alignment can be one of the following: 0 - The text is aligned to the left 1 - The text is centered 2 - The text is aligned to the right

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_StringFormatCreate

See Also

Search GdipSetStringFormatAlign in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Local $hWnd = GUICreate("GDI+ Example (" & @ScriptName & ")", 400, 300)
GUISetState(@SW_SHOW)

_GDIPlus_Startup()
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
_GDIPlus_GraphicsClear($hGraphics)

Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF009900)
Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
Local $hFont = _GDIPlus_FontCreate($hFamily, 36)
Local $hLayout = _GDIPlus_RectFCreate(0, 0, 400, 300)
Local $hStringFormat = _GDIPlus_StringFormatCreate()
_GDIPlus_StringFormatSetAlign($hStringFormat, 1)
_GDIPlus_GraphicsDrawStringEx($hGraphics, "AutoIt Rocks", $hFont, $hLayout, $hStringFormat, $hBrush)

Local $iMsg = 0
Do
    $iMsg = GUIGetMsg()
Until $iMsg = $GUI_EVENT_CLOSE

_GDIPlus_BrushDispose($hBrush)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_FontDispose($hFont)
_GDIPlus_StringFormatDispose($hStringFormat)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()


Function _GDIPlus_StringFormatSetLineAlign

Function Reference

_GDIPlus_StringFormatSetLineAlign

Sets the line alignment of a StringFormat object in relation to the origin of a layout rectangle

#include <GDIPlus.au3>
_GDIPlus_StringFormatSetLineAlign ( $hStringFormat, $iStringAlign )

Parameters

$hStringFormat | Pointer to a StringFormat object
$iStringAlign | Type of line alignment to use: 0 - Alignment is towards the origin of the bounding rectangle 1 - Alignment is centered between origin and the height of the formatting rectangle 2 - Alignment is to the far extent (right side) of the formatting rectangle

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

The line alignment setting specifies how to align the string vertically in the layout rectangle.
The layout rectangle is used to position the displayed string.

Related

_GDIPlus_StringFormatSetAlign

See Also

Search GdipSetStringFormatLineAlign in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hWnd = GUICreate("GDI+ Example (" & @ScriptName & ")", 400, 300)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    _GDIPlus_GraphicsClear($hGraphics)

    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF009900)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 36)
    Local $hLayout = _GDIPlus_RectFCreate(0, 0, 400, 300)
    Local $hStringFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hStringFormat, 1)
    _GDIPlus_StringFormatSetLineAlign($hStringFormat, 1)
    _GDIPlus_GraphicsDrawStringEx($hGraphics, "AutoIt Rocks", $hFont, $hLayout, $hStringFormat, $hBrush)

    Do
        Local $iMsg = GUIGetMsg()
    Until $iMsg = $GUI_EVENT_CLOSE

    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_StringFormatDispose($hStringFormat)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_StringFormatSetMeasurableCharacterRanges

Function Reference

_GDIPlus_StringFormatSetMeasurableCharacterRanges

Sets a series of character ranges for a StringFormat object that, when in a string, can be measured

#include <GDIPlus.au3>
_GDIPlus_StringFormatSetMeasurableCharacterRanges ( $hStringFormat, $aRanges )

Parameters

$hStringFormat | Pointer to a StringFormat object
$aRanges | Array of character ranges: [0][0] - Number of character ranges [1][0] - Character range 1 specifying the first position of range 1 [1][1] - Character range 1 specifying the number of positions in range 1 [2][0] - Character range 2 specifying the first position of range 2 [2][1] - Character range 2 specifying the number of positions in range 2 [n][0] - Character range n specifying the first position of range n [n][1] - Character range n specifying the number of positions in range n

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_GraphicsMeasureCharacterRanges, _GDIPlus_StringFormatGetMeasurableCharacterRangeCount

See Also

Search GdipSetStringFormatMeasurableCharacterRanges in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create GUI
    Local $hGUI = GUICreate("GDI+", 640, 220)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    Local $hPen = _GDIPlus_PenCreate(0xFF006600)
    Local $hBrush_Region = _GDIPlus_BrushCreateSolid(0x44FF0000)
    Local $hBrush_Font = _GDIPlus_BrushCreateSolid(0xFFFF0000)

    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")

    Local $sString = "Measure Character Ranges"

    Local $aRanges[4][2] = [[3]]
    $aRanges[1][0] = 0 ;Measure first char (0-based)
    $aRanges[1][1] = 1 ;One char to measure
    $aRanges[2][0] = 4 ;5th char
    $aRanges[2][1] = 5 ;measure 5 chars
    $aRanges[3][0] = 14 ;15th char
    $aRanges[3][1] = 7 ;measure 7 chars

    _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges) ;Set ranges

    ;Measure characters fontsize = 14
    Local $hFont = _GDIPlus_FontCreate($hFamily, 14, 0)
    Local $tLayout = _GDIPlus_RectFCreate(10, 10, 200, 200)
    _GDIPlus_GraphicsDrawRect($hGraphic, 10, 10, 200, 200, $hPen)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush_Font)
    Local $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat) ;get array of regions
    For $i = 1 To $aRegions[0]
        _GDIPlus_GraphicsFillRegion($hGraphic, $aRegions[$i], $hBrush_Region)
        _GDIPlus_RegionDispose($aRegions[$i])
    Next
    _GDIPlus_FontDispose($hFont)

    ;Measure characters fontsize = 28
    $hFont = _GDIPlus_FontCreate($hFamily, 28, 0)
    $tLayout = _GDIPlus_RectFCreate(220, 10, 200, 200)
    _GDIPlus_GraphicsDrawRect($hGraphic, 220, 10, 200, 200, $hPen)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush_Font)
    $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat)
    For $i = 1 To $aRegions[0]
        _GDIPlus_GraphicsFillRegion($hGraphic, $aRegions[$i], $hBrush_Region)
        _GDIPlus_RegionDispose($aRegions[$i])
    Next
    _GDIPlus_FontDispose($hFont)

    ;Measure characters fontsize = 56
    $hFont = _GDIPlus_FontCreate($hFamily, 56, 0)
    $tLayout = _GDIPlus_RectFCreate(430, 10, 200, 200)
    _GDIPlus_GraphicsDrawRect($hGraphic, 430, 10, 200, 200, $hPen)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush_Font)
    $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat)
    For $i = 1 To $aRegions[0]
        _GDIPlus_GraphicsFillRegion($hGraphic, $aRegions[$i], $hBrush_Region)
        _GDIPlus_RegionDispose($aRegions[$i])
    Next
    _GDIPlus_FontDispose($hFont)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush_Font)
    _GDIPlus_BrushDispose($hBrush_Region)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


User Defined Functions

Text user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_GDIPlus_GraphicsDrawString | Draw a string
_GDIPlus_GraphicsDrawStringEx | Draw a string
_GDIPlus_GraphicsMeasureCharacterRanges | Gets a set of region objects each of which bounds a range of character positions within a string
_GDIPlus_GraphicsMeasureString | Measures the size of a string


Function _GDIPlus_GraphicsDrawString

Function Reference

_GDIPlus_GraphicsDrawString

Draw a string

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawString ( $hGraphics, $sString, $nX, $nY [, $sFont = "Arial" [, $fSize = 10 [, $iFormat = 0]]] )

Parameters

$hGraphics | Handle to a Graphics object
$sString | String to be drawn
$nX | X coordinate where the string will be drawn
$nY | Y coordinate where the string will be drawn
$sFont | [optional] Name of the font to use for drawing
$fSize | [optional] Font size to use for drawing
$iFormat | [optional] Format flags. Can be one or more of the following: 0x0001 - Specifies that reading order is right to left 0x0002 - Specifies that individual lines of text are drawn vertically on the display device 0x0004 - Specifies that parts of characters are allowed to overhang the string's layout rectangle 0x0020 - Specifies that Unicode layout control characters are displayed with a representative character 0x0400 - Specifies that an alternate font is used for characters that are not supported in the requested font 0x0800 - Specifies that the space at the end of each line is included in a string measurement 0x1000 - Specifies that the wrapping of text to the next line is disabled 0x2000 - Specifies that only entire lines are laid out in the layout rectangle 0x4000 - Specifies that characters overhanging the layout rectangle and text extending outside the layout rectangle are allowed to show

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

_GDIPlus_GraphicsDrawStringEx

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw a string
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsDrawString($hGraphic, "Hello world", 140, 110)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_GraphicsDrawStringEx

Function Reference

_GDIPlus_GraphicsDrawStringEx

Draw a string

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawStringEx ( $hGraphics, $sString, $hFont, $tLayout, $hFormat, $hBrush )

Parameters

$hGraphics | Handle to a Graphics object
$sString | String to be drawn
$hFont | Handle to the font to use to draw the string
$tLayout | $tagGDIPRECTF structure that bounds the string
$hFormat | Handle to the string format to draw the string
$hBrush | Handle to the brush to draw the string

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

$tagGDIPRECTF, _GDIPlus_GraphicsDrawString

See Also

Search GdipDrawString in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout
    Local $sString = "Hello world", $aInfo

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw a string
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
    $tLayout = _GDIPlus_RectFCreate(140, 110, 0, 0)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_GraphicsMeasureCharacterRanges

Function Reference

_GDIPlus_GraphicsMeasureCharacterRanges

Gets a set of region objects each of which bounds a range of character positions within a string

#include <GDIPlus.au3>
_GDIPlus_GraphicsMeasureCharacterRanges ( $hGraphics, $sString, $hFont, $tLayout, $hStringFormat )

Parameters

$hGraphics | Pointer to a Graphics object
$sString | The string to measure
$hFont | Pointer to a Font object that specifies the font characteristics
$tLayout | $tagGDIPRECTF structure that defines the string boundaries
$hStringFormat | Pointer to a StringFormat object that specifies the character ranges and layout information, such as alignment, trimming, tab stops, and so forth

Return Value

Success: | an array of region objects: [0] - Number of regions [1] - Region 1 [2] - Region 2 [3] - Region 3
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

If the function succeeds, it's the responsibility of the user to release these regions.

Related

$tagGDIPRECTF, _GDIPlus_GraphicsMeasureString, _GDIPlus_RegionDispose

See Also

Search GdipMeasureCharacterRanges in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create GUI
    Local $hGUI = GUICreate("GDI+", 640, 220)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    Local $hPen = _GDIPlus_PenCreate(0xFF006600)
    Local $hBrush_Region = _GDIPlus_BrushCreateSolid(0x44FF0000)
    Local $hBrush_Font = _GDIPlus_BrushCreateSolid(0xFFFF0000)

    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")

    Local $sString = "Measure Character Ranges"

    Local $aRanges[4][2] = [[3]]
    $aRanges[1][0] = 0 ;Measure first char (0-based)
    $aRanges[1][1] = 1 ;One char to measure
    $aRanges[2][0] = 4 ;5th char
    $aRanges[2][1] = 5 ;measure 5 chars
    $aRanges[3][0] = 14 ;15th char
    $aRanges[3][1] = 7 ;measure 7 chars

    _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges) ;Set ranges

    ;Measure characters fontsize = 14
    Local $hFont = _GDIPlus_FontCreate($hFamily, 14, 0)
    Local $tLayout = _GDIPlus_RectFCreate(10, 10, 200, 200)
    _GDIPlus_GraphicsDrawRect($hGraphic, 10, 10, 200, 200, $hPen)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush_Font)
    Local $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat) ;get array of regions
    For $i = 1 To $aRegions[0]
        _GDIPlus_GraphicsFillRegion($hGraphic, $aRegions[$i], $hBrush_Region)
        _GDIPlus_RegionDispose($aRegions[$i])
    Next
    _GDIPlus_FontDispose($hFont)

    ;Measure characters fontsize = 28
    $hFont = _GDIPlus_FontCreate($hFamily, 28, 0)
    $tLayout = _GDIPlus_RectFCreate(220, 10, 200, 200)
    _GDIPlus_GraphicsDrawRect($hGraphic, 220, 10, 200, 200, $hPen)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush_Font)
    $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat)
    For $i = 1 To $aRegions[0]
        _GDIPlus_GraphicsFillRegion($hGraphic, $aRegions[$i], $hBrush_Region)
        _GDIPlus_RegionDispose($aRegions[$i])
    Next
    _GDIPlus_FontDispose($hFont)

    ;Measure characters fontsize = 56
    $hFont = _GDIPlus_FontCreate($hFamily, 56, 0)
    $tLayout = _GDIPlus_RectFCreate(430, 10, 200, 200)
    _GDIPlus_GraphicsDrawRect($hGraphic, 430, 10, 200, 200, $hPen)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush_Font)
    $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat)
    For $i = 1 To $aRegions[0]
        _GDIPlus_GraphicsFillRegion($hGraphic, $aRegions[$i], $hBrush_Region)
        _GDIPlus_RegionDispose($aRegions[$i])
    Next
    _GDIPlus_FontDispose($hFont)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush_Font)
    _GDIPlus_BrushDispose($hBrush_Region)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Function _GDIPlus_GraphicsMeasureString

Function Reference

_GDIPlus_GraphicsMeasureString

Measures the size of a string

#include <GDIPlus.au3>
_GDIPlus_GraphicsMeasureString ( $hGraphics, $sString, $hFont, $tLayout, $hFormat )

Parameters

$hGraphics | Handle to a Graphics object
$sString | String to be drawn
$hFont | Handle to the font to use to draw the string
$tLayout | $tagGDIPRECTF structure that bounds the string
$hFormat | Handle to the string format to draw the string

Return Value

Success: | an array with the following format: [0] - $tagGDIPRECTF structure that receives the rectangle that bounds the string [1] - The number of characters that actually fit into the layout rectangle [2] - The number of lines that fit into the layout rectangle
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Related

$tagGDIPRECTF

See Also

Search GdipMeasureString in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout, $aInfo
    Local $sString = "Hello world"

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw a string
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
    $tLayout = _GDIPlus_RectFCreate(140, 110, 0, 0)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


GUI Reference

  • GuiAVI Management
  • GuiButton Management
  • GuiComboBox Management
  • GuiComboBoxEx Management
  • GuiDateTimePicker Management
  • GuiEdit Management
  • GuiHeader Management
  • GuiImageList Management
  • GuiIPAddress Management
  • GuiListBox Management
  • GuiListView Management
  • GuiMenu Management
  • GuiMonthCal Management
  • GuiReBar Management
  • GuiRichEdit Management
  • GuiScrollBars Management
  • GuiSlider Management
  • GuiStatusBar Management
  • GuiTab Management
  • GuiToolbar Management
  • GuiToolTip Management
  • GuiTreeView Management


User Defined Functions

GuiAVI user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiAVI.au3>.

User Defined Function | Description
_GUICtrlAVI_Close | Closes an AVI clip
_GUICtrlAVI_Create | Creates an AVI control
_GUICtrlAVI_Destroy | Delete the control
_GUICtrlAVI_IsPlaying | Checks whether an Audio-Video Interleaved (AVI) clip is playing
_GUICtrlAVI_Open | Opens an AVI clip and displays its first frame in an animation control
_GUICtrlAVI_OpenEx | Opens an AVI clip and displays its first frame in an animation control
_GUICtrlAVI_Play | Plays an AVI clip in an animation control
_GUICtrlAVI_Seek | Directs an AVI control to display a particular frame of an AVI clip
_GUICtrlAVI_Show | Show/Hide the AVI control
_GUICtrlAVI_Stop | Stops playing an AVI clip


Function _GUICtrlAVI_Close

Function Reference

_GUICtrlAVI_Close

Closes an AVI clip

#include <GuiAVI.au3>
_GUICtrlAVI_Close ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlAVI_Open

Example

#include <GuiAVI.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $hGUI, $hAVI, $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\SampleAVI.avi"

    ; Create GUI
    $hGUI = GUICreate("(External) AVI Close", 300, 100)
    $hAVI = _GUICtrlAVI_Create($hGUI, $sFile, -1, 10, 10)
    GUISetState(@SW_SHOW)

    ; Play the sample AutoIt AVI
    _GUICtrlAVI_Play($hAVI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Close AVI clip
    _GUICtrlAVI_Close($hAVI)

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlAVI_Create

Function Reference

_GUICtrlAVI_Create

Creates an AVI control

#include <GuiAVI.au3>
_GUICtrlAVI_Create ( $hWnd [, $sFilePath = "" [, $iSubFileID = -1 [, $iX = 0 [, $iY = 0 [, $iWidth = 0 [, $iHeight = 0 [, $iStyle = 0x00000006 [, $iExStyle = 0x00000000]]]]]]]] )

Parameters

$hWnd | Handle to parent or owner window
$sFilePath | [optional] The filename of the video. Only .avi files are supported
$iSubFileID | [optional] id of the subfile to be used.
$iX | [optional] Horizontal position of the control
$iY | [optional] Vertical position of the control
$iWidth | [optional] Control width
$iHeight | [optional] Control height
$iStyle | [optional] Control styles: $ACS_CENTER - Centers the animation in the animation control's window $ACS_TRANSPARENT - Creates the control with a transparent background $ACS_AUTOPLAY - Starts playing the animation as soon as the AVI clip is opened $ACS_TIMER - The control plays the clip without creating a thread Default: $ACS_TRANSPARENT, $ACS_AUTOPLAY Forced: $WS_CHILD, $WS_VISIBLE
$iExStyle | [optional] Control extended style. These correspond to the standard $WS_EX_* constants. See Extended Style Table.

Return Value

Success: | the handle of the animation control.
Failure: | 0.

Remarks

This function is for Advanced users and for learning how the control works.

Related

_GUICtrlAVI_Destroy

Example

Example 1

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

Global $g_hAVI

Example()

Func Example()
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $hGUI, $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\SampleAVI.avi"

    ; Create GUI
    $hGUI = GUICreate("(External 1) AVI Create", 300, 100)
    $g_hAVI = _GUICtrlAVI_Create($hGUI, $sFile, -1, 10, 10)
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    ; Play the sample AutoIt AVI
    _GUICtrlAVI_Play($g_hAVI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Close AVI clip
    _GUICtrlAVI_Close($g_hAVI)

    GUIDelete()
EndFunc   ;==>Example

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode
    $hWndFrom = $lParam
    $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word
    $iCode = BitShift($wParam, 16) ; Hi Word
    Switch $hWndFrom
        Case $g_hAVI
            Switch $iCode
                Case $ACN_START ; Notifies an animation control's parent window that the associated AVI clip has started playing
                    _DebugPrint("$ACN_START" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $ACN_STOP ; Notifies the parent window of an animation control that the associated AVI clip has stopped playing
                    _DebugPrint("$ACN_STOP" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint

Example 2

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

Global $g_hAVI

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("(External 2) AVI Create", 300, 100)
    $g_hAVI = _GUICtrlAVI_Create($hGUI, @SystemDir & "\Shell32.dll", 150, 10, 10)
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    ; Play the sample AutoIt AVI
    _GUICtrlAVI_Play($g_hAVI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Close AVI clip
    _GUICtrlAVI_Close($g_hAVI)

    GUIDelete()
EndFunc   ;==>Example

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode
    $hWndFrom = $lParam
    $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word
    $iCode = BitShift($wParam, 16) ; Hi Word
    Switch $hWndFrom
        Case $g_hAVI
            Switch $iCode
                Case $ACN_START ; Notifies an animation control's parent window that the associated AVI clip has started playing
                    _DebugPrint("$ACN_START" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $ACN_STOP ; Notifies the parent window of an animation control that the associated AVI clip has stopped playing
                    _DebugPrint("$ACN_STOP" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlAVI_Destroy

Function Reference

_GUICtrlAVI_Destroy

Delete the control

#include <GuiAVI.au3>
_GUICtrlAVI_Destroy ( ByRef $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True, $hWnd is set to 0.
Failure: | False.

Remarks

Restricted to only be used on AVI controls created with _GUICtrlAVI_Create().

Related

_GUICtrlAVI_Create

Example

#include <GuiAVI.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $hGUI, $hAVI, $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\SampleAVI.avi"

    ; Create GUI
    $hGUI = GUICreate("(External) AVI Destroy", 300, 100)
    $hAVI = _GUICtrlAVI_Create($hGUI, "", -1, 10, 10)
    GUISetState(@SW_SHOW)

    ; Play the sample AutoIt AVI
    _GUICtrlAVI_Open($hAVI, $sFile)

    ; Play the sample AutoIt AVI
    _GUICtrlAVI_Play($hAVI)

    Sleep(3000)

    ; Stop AVI clip after 3 seconds
    _GUICtrlAVI_Stop($hAVI)

    ; Close AVI clip
    _GUICtrlAVI_Close($hAVI)

    MsgBox($MB_SYSTEMMODAL, "Information", "Destroy AVI Control")
    _GUICtrlAVI_Destroy($hAVI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlAVI_IsPlaying

Function Reference

_GUICtrlAVI_IsPlaying

Checks whether an Audio-Video Interleaved (AVI) clip is playing

#include <GuiAVI.au3>
_GUICtrlAVI_IsPlaying ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Remarks

Windows Vista or later

See Also

Search ACM_ISPLAYING in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $hGUI, $hAVI, $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\SampleAVI.avi"
    Local $id_StartStop

    ; Create GUI
    $hGUI = GUICreate("(External) AVI Open", 300, 200)
    $hAVI = _GUICtrlAVI_Create($hGUI, "", -1, 10, 10)
    $id_StartStop = GUICtrlCreateButton("Start", 50, 10, 75, 25)
    $g_idMemo = GUICtrlCreateEdit("", 10, 50, 276, 144, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Play the sample AutoIt AVI
    _GUICtrlAVI_Open($hAVI, $sFile)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $id_StartStop
                If GUICtrlRead($id_StartStop) = "Start" Then
                    _GUICtrlAVI_Play($hAVI)
                    GUICtrlSetData($id_StartStop, "Stop")
                Else
                    _GUICtrlAVI_Stop($hAVI)
                    GUICtrlSetData($id_StartStop, "Start")
                EndIf
                MemoWrite("Is Playing: " & _GUICtrlAVI_IsPlaying($hAVI))

            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    ; Close AVI clip
    _GUICtrlAVI_Close($hAVI)

    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlAVI_Open

Function Reference

_GUICtrlAVI_Open

Opens an AVI clip and displays its first frame in an animation control

#include <GuiAVI.au3>
_GUICtrlAVI_Open ( $hWnd, $sFileName )

Parameters

$hWnd | Control ID/Handle to the control
$sFileName | Fully qualified path to the AVI file

Return Value

Success: | True.
Failure: | False.

Remarks

You can only open silent AVI clips.

Related

_GUICtrlAVI_Close, _GUICtrlAVI_OpenEx

Example

#include <GuiAVI.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $hGUI, $hAVI, $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\SampleAVI.avi"

    ; Create GUI
    $hGUI = GUICreate("(External) AVI Open", 300, 100)
    $hAVI = _GUICtrlAVI_Create($hGUI, "", -1, 10, 10)
    GUISetState(@SW_SHOW)

    ; Play the sample AutoIt AVI
    _GUICtrlAVI_Open($hAVI, $sFile)

    ; Play the sample AutoIt AVI
    _GUICtrlAVI_Play($hAVI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Close AVI clip
    _GUICtrlAVI_Close($hAVI)

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlAVI_OpenEx

Function Reference

_GUICtrlAVI_OpenEx

Opens an AVI clip and displays its first frame in an animation control

#include <GuiAVI.au3>
_GUICtrlAVI_OpenEx ( $hWnd, $sFileName, $iResourceID )

Parameters

$hWnd | Control ID/Handle to the control
$sFileName | Fully qualified path to resource file
$iResourceID | AVI resource identifier

Return Value

Success: | True.
Failure: | False.

Remarks

You can only open silent AVI clips.

Related

_GUICtrlAVI_Open

Example

#include <GuiAVI.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hAVI

    ; Create GUI
    $hGUI = GUICreate("(External) AVI OpenEx", 300, 100)
    $hAVI = _GUICtrlAVI_Create($hGUI, "", -1, 10, 10)
    GUISetState(@SW_SHOW)

    ; Play the sample AutoIt AVI
    _GUICtrlAVI_OpenEx($hAVI, @SystemDir & "\Shell32.dll", 150)

    ; Play the sample AutoIt AVI
    _GUICtrlAVI_Play($hAVI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Close AVI clip
    _GUICtrlAVI_Close($hAVI)

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlAVI_Play

Function Reference

_GUICtrlAVI_Play

Plays an AVI clip in an animation control

#include <GuiAVI.au3>
_GUICtrlAVI_Play ( $hWnd [, $iFrom = 0 [, $iTo = -1 [, $iRepeat = -1]]] )

Parameters

$hWnd | Control ID/Handle to the control
$iFrom | [optional] 0-based index of the frame where playing begins. The value must be less than 65,536. A value of 0 means begin with the first frame in the clip.
$iTo | [optional] 0-based index of the frame where playing ends. The value must be less than 65,536. A value of -1 means end with the last frame in the clip.
$iRepeat | [optional] Number of times to replay the AVI clip. A value of -1 means replay the clip indefinitely.

Return Value

Success: | True.
Failure: | False.

Remarks

The control plays the clip in the background while the thread continues executing.

Related

_GUICtrlAVI_Seek, _GUICtrlAVI_Stop

Example

Example 1

; using AutoIt Function

#include <GuiAVI.au3>
#include <GUIConstantsEx.au3>

_Example_Internal()

Func _Example_Internal()
    Local $idAVI, $id_Start, $id_Stop

    ; Create GUI
    GUICreate("(Internal) AVI Play/Stop", 300, 200)
    $idAVI = GUICtrlCreateAvi(@SystemDir & "\shell32.dll", 160, 10, 10)
    $id_Start = GUICtrlCreateButton("start", 50, 150, 70, 22)
    $id_Stop = GUICtrlCreateButton("stop", 150, 150, 70, 22)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $id_Start
                ; Play part of the AVI clip
                _GUICtrlAVI_Play($idAVI)
            Case $id_Stop
                ; Stop AVI clip
                _GUICtrlAVI_Stop($idAVI)
        EndSwitch
    WEnd

    ; Close AVI clip
    _GUICtrlAVI_Close($idAVI)

    GUIDelete()
EndFunc   ;==>_Example_Internal

Example 2

; using UDF

#include <GuiAVI.au3>
#include <GUIConstantsEx.au3>

_Example_External()

Func _Example_External()
    Local $hGUI, $hAVI, $id_Start, $id_Stop

    ; Create GUI
    $hGUI = GUICreate("(External) AVI Play/Stop", 300, 200)
    $hAVI = _GUICtrlAVI_Create($hGUI, @SystemDir & "\Shell32.dll", 160, 10, 10)
    $id_Start = GUICtrlCreateButton("start", 50, 150, 70, 22)
    $id_Stop = GUICtrlCreateButton("stop", 150, 150, 70, 22)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $id_Start
                ; Play part of the AVI clip
                _GUICtrlAVI_Play($hAVI)
            Case $id_Stop
                ; Stop AVI clip
                _GUICtrlAVI_Stop($hAVI)
        EndSwitch
    WEnd

    ; Close AVI clip
    _GUICtrlAVI_Close($hAVI)

    GUIDelete()
EndFunc   ;==>_Example_External


Function _GUICtrlAVI_Seek

Function Reference

_GUICtrlAVI_Seek

Directs an AVI control to display a particular frame of an AVI clip

#include <GuiAVI.au3>
_GUICtrlAVI_Seek ( $hWnd, $iFrame )

Parameters

$hWnd | Control ID/Handle to the control
$iFrame | 0-based index of the frame to display

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlAVI_Play

Example

Example 1

; usinf AutoIt Function

#include <GuiAVI.au3>
#include <GUIConstantsEx.au3>

_Example_Internal()

Func _Example_Internal()
    ; Create GUI
    GUICreate("(Internal) AVI Seek", 300, 100)
    Local $idAVI = GUICtrlCreateAvi(@SystemDir & "\shell32.dll", 160, 10, 10)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    Do
        Sleep(100)
        ; Seek to a random frame in the AVI Clip
        _GUICtrlAVI_Seek($idAVI, Random(1, 30, 1))
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Close AVI clip
    _GUICtrlAVI_Close($idAVI)

    GUIDelete()
EndFunc   ;==>_Example_Internal

Example 2

; using standard UDF

#include <GuiAVI.au3>
#include <GUIConstantsEx.au3>

_Example_External()

Func _Example_External()
    Local $hGUI, $hAVI

    ; Create GUI
    $hGUI = GUICreate("(External) AVI Seek", 300, 100)
    $hAVI = _GUICtrlAVI_Create($hGUI, @SystemDir & "\Shell32.dll", 160, 10, 10)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    Do
        Sleep(100)
        ; Seek to a random frame in the AVI Clip
        _GUICtrlAVI_Seek($hAVI, Random(1, 30, 1))
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Close AVI clip
    _GUICtrlAVI_Close($hAVI)

    GUIDelete()
EndFunc   ;==>_Example_External


Function _GUICtrlAVI_Show

Function Reference

_GUICtrlAVI_Show

Show/Hide the AVI control

#include <GuiAVI.au3>
_GUICtrlAVI_Show ( $hWnd, $iState )

Parameters

$hWnd | Control ID/Handle to the control
$iState | State of the AVI, can be the following values:

Return Value

Success: | True - the control was previously visible. False - the control was previously hidden.
Failure: | sets the @error flag to non-zero.

Example

Example 1

; using AutoIt Function

#include <GuiAVI.au3>
#include <GUIConstantsEx.au3>

_Example_Internal()

Func _Example_Internal()
    Local $id_AVI, $id_Start, $id_Stop, $id_Show

    ; Create GUI
    GUICreate("(Internal) AVI Play", 350, 200)
    $id_AVI = GUICtrlCreateAvi(@SystemDir & "\shell32.dll", 160, 10, 10)
    $id_Start = GUICtrlCreateButton("start", 25, 150, 70, 22)
    $id_Stop = GUICtrlCreateButton("stop", 125, 150, 70, 22)
    $id_Show = GUICtrlCreateButton("hide", 225, 150, 70, 22)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $id_Start
                ; Play part of the AVI clip
                _GUICtrlAVI_Play($id_AVI)
            Case $id_Stop
                ; Stop AVI clip
                _GUICtrlAVI_Stop($id_AVI)
            Case $id_Show
                If GUICtrlRead($id_Show) = "hide" Then
                    _GUICtrlAVI_Show($id_AVI, @SW_HIDE)
                    GUICtrlSetData($id_Show, "show")
                Else
                    _GUICtrlAVI_Show($id_AVI, @SW_SHOW)
                    GUICtrlSetData($id_Show, "hide")
                EndIf
        EndSwitch
    WEnd

    ; Close AVI clip
    _GUICtrlAVI_Close($id_AVI)

    GUIDelete()
EndFunc   ;==>_Example_Internal

Example 2

#include <GuiAVI.au3>
#include <GUIConstantsEx.au3>

_Example_External()

Func _Example_External()
    Local $hGUI, $hAVI, $id_Start, $id_Stop, $id_Show

    ; Create GUI
    $hGUI = GUICreate("(External) AVI Play", 350, 200)
    $hAVI = _GUICtrlAVI_Create($hGUI, @SystemDir & "\Shell32.dll", 160, 10, 10)
    $id_Start = GUICtrlCreateButton("start", 25, 150, 70, 22)
    $id_Stop = GUICtrlCreateButton("stop", 125, 150, 70, 22)
    $id_Show = GUICtrlCreateButton("hide", 225, 150, 70, 22)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $id_Start
                ; Play part of the AVI clip
                _GUICtrlAVI_Play($hAVI)
            Case $id_Stop
                ; Stop AVI clip
                _GUICtrlAVI_Stop($hAVI)
            Case $id_Show
                If GUICtrlRead($id_Show) = "hide" Then
                    _GUICtrlAVI_Show($hAVI, @SW_HIDE)
                    GUICtrlSetData($id_Show, "show")
                Else
                    _GUICtrlAVI_Show($hAVI, @SW_SHOW)
                    GUICtrlSetData($id_Show, "hide")
                EndIf
        EndSwitch
    WEnd

    ; Close AVI clip
    _GUICtrlAVI_Close($hAVI)

    GUIDelete()
EndFunc   ;==>_Example_External


Function _GUICtrlAVI_Stop

Function Reference

_GUICtrlAVI_Stop

Stops playing an AVI clip

#include <GuiAVI.au3>
_GUICtrlAVI_Stop ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlAVI_Play

Example

Example 1

; using AutoIt Function

#include <GuiAVI.au3>
#include <GUIConstantsEx.au3>

_Example_Internal()

Func _Example_Internal()
    Local $idAVI, $id_Start, $id_Stop

    ; Create GUI
    GUICreate("(Internal) AVI Play/Stop", 300, 200)
    $idAVI = GUICtrlCreateAvi(@SystemDir & "\shell32.dll", 160, 10, 10)
    $id_Start = GUICtrlCreateButton("start", 50, 150, 70, 22)
    $id_Stop = GUICtrlCreateButton("stop", 150, 150, 70, 22)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $id_Start
                ; Play part of the AVI clip
                _GUICtrlAVI_Play($idAVI)
            Case $id_Stop
                ; Stop AVI clip
                _GUICtrlAVI_Stop($idAVI)
        EndSwitch
    WEnd

    ; Close AVI clip
    _GUICtrlAVI_Close($idAVI)

    GUIDelete()
EndFunc   ;==>_Example_Internal

Example 2

; using UDF

#include <GuiAVI.au3>
#include <GUIConstantsEx.au3>

_Example_External()

Func _Example_External()
    Local $hGUI, $hAVI, $id_Start, $id_Stop

    ; Create GUI
    $hGUI = GUICreate("(External) AVI Play/Stop", 300, 200)
    $hAVI = _GUICtrlAVI_Create($hGUI, @SystemDir & "\Shell32.dll", 160, 10, 10)
    $id_Start = GUICtrlCreateButton("start", 50, 150, 70, 22)
    $id_Stop = GUICtrlCreateButton("stop", 150, 150, 70, 22)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $id_Start
                ; Play part of the AVI clip
                _GUICtrlAVI_Play($hAVI)
            Case $id_Stop
                ; Stop AVI clip
                _GUICtrlAVI_Stop($hAVI)
        EndSwitch
    WEnd

    ; Close AVI clip
    _GUICtrlAVI_Close($hAVI)

    GUIDelete()
EndFunc   ;==>_Example_External


User Defined Functions

GuiButton user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiButton.au3>.

User Defined Function | Description
_GUICtrlButton_Click | Simulates the user clicking a button
_GUICtrlButton_Create | Creates a Button control
_GUICtrlButton_Destroy | Delete the Button control
_GUICtrlButton_Enable | Enables or disables mouse and keyboard input to the specified button
_GUICtrlButton_GetCheck | Gets the check state of a radio button or check box
_GUICtrlButton_GetFocus | Retrieves if the button has keyboard focus
_GUICtrlButton_GetIdealSize | Gets the size of the button that best fits its text and image, if an image list is present
_GUICtrlButton_GetImage | Retrieves a handle to the image (icon or bitmap) associated with the button
_GUICtrlButton_GetImageList | Retrieves an array that describes the image list assigned to a button control
_GUICtrlButton_GetNote | Gets the text of the note associated with the Command Link button
_GUICtrlButton_GetNoteLength | Gets the length of the note text that may be displayed in the description for a command link button
_GUICtrlButton_GetSplitInfo | Gets information for a split button control
_GUICtrlButton_GetState | Determines the state of a button or check box
_GUICtrlButton_GetText | Retrieve the text of the button
_GUICtrlButton_GetTextMargin | Gets the margins used to draw text in a button control
_GUICtrlButton_SetCheck | Sets the check state of a radio button or check box
_GUICtrlButton_SetDontClick | Sets the state of $BST_DONTCLICK flag on a button
_GUICtrlButton_SetFocus | Sets the keyboard focus to the specified button
_GUICtrlButton_SetImage | Sets the image of a button
_GUICtrlButton_SetImageList | Assigns an image list to a button control
_GUICtrlButton_SetNote | Sets the text of the note associated with a command link button
_GUICtrlButton_SetShield | Sets the elevation required state for a specified button or command link to display an elevated icon
_GUICtrlButton_SetSize | Sets the size of the button
_GUICtrlButton_SetSplitInfo | Gets information for a split button control
_GUICtrlButton_SetState | Sets the highlight state of a button. The highlight state indicates whether the button is highlighted as if the user had pushed it
_GUICtrlButton_SetStyle | Sets the style of a button
_GUICtrlButton_SetText | Sets the text of the button
_GUICtrlButton_SetTextMargin | Sets the margins for drawing text in a button control
_GUICtrlButton_Show | Show/Hide button


Function _GUICtrlButton_Click

Function Reference

_GUICtrlButton_Click

Simulates the user clicking a button

#include <GuiButton.au3>
_GUICtrlButton_Click ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

None.

Remarks

If the button is in a dialog box and the dialog box is not active, the _GUICtrlButton_Click() might fail.
To ensure success in this situation, call the WinActivate() function to activate the dialog box before sending the _GUICtrlButton_Click() to the button.

See Also

Search BM_CLICK in MSDN Library.

Example

#include <GuiButton.au3>
#include <GUIConstantsEx.au3>

Global $g_aidBtn[6], $g_idMemo, $g_iRand

HotKeySet("!b", "Clickit")

Example()

Func Example()
    Local $y = 70

    GUICreate("Buttons", 510, 400)
    $g_idMemo = GUICtrlCreateEdit("", 119, 10, 376, 374, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")

    MemoWrite("Press Alt+b to Click Button")

    $g_aidBtn[0] = GUICtrlCreateButton("Button1", 10, 10, 100, 50)

    For $x = 1 To 5
        $g_aidBtn[$x] = GUICtrlCreateButton("Button" & $x + 1, 10, $y, 100, 50)
        $y += 60
    Next

    $g_iRand = Random(0, 5, 1)
    _GUICtrlButton_SetText($g_aidBtn[$g_iRand], "New Text" & $g_iRand + 1)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $g_aidBtn[$g_iRand]
                MemoWrite(_GUICtrlButton_GetText($g_aidBtn[$g_iRand]) & " Clicked")
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

Func Clickit()
    $g_iRand = Random(0, 5, 1)
    _GUICtrlButton_Click($g_aidBtn[$g_iRand])
EndFunc   ;==>Clickit

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlButton_Create

Function Reference

_GUICtrlButton_Create

Creates a Button control

#include <GuiButton.au3>
_GUICtrlButton_Create ( $hWnd, $sText, $iX, $iY, $iWidth, $iHeight [, $iStyle = -1 [, $iExStyle = -1]] )

Parameters

$hWnd | Handle to parent or owner window
$sText | Text to add to Button
$iX | Horizontal position of the control
$iY | Vertical position of the control
$iWidth | Control width
$iHeight | Control height
$iStyle [optional] Control style:
$BS_AUTO3STATE - Creates a three-state check box in which the state cycles through selected, unavailable, and cleared each time the user selects the check box.
$BS_AUTOCHECKBOX - Creates a check box in which the check state switches between selected and cleared each time the user selects the check box.
$BS_AUTORADIOBUTTON - Same as a radio button, except that when the user selects it, the button automatically highlights itself and removes the selection from any other radio buttons with the same style in the same group.
$BS_FLAT - Specifies that the button is two-dimensional; it does not use the default shading to create a 3-D image.
$BS_GROUPBOX - Creates a rectangle in which other buttons can be grouped. Any text associated with this style is displayed in the rectangle’s upper-left corner.
$BS_PUSHLIKE - Makes a button (such as a check box, three-state check box, or radio button) look and act like a push button. The button looks raised when it isn't pushed or checked, and sunken when it is pushed or checked.

$BS_DEFPUSHBUTTON - Creates a push button with a heavy black border. If the button is in a dialog box, the user can select the button by pressing the ENTER key, even when the button does not have the input focus. This style is useful for enabling the user to quickly select the most likely option, or default.

$BS_BOTTOM - Places the text at the bottom of the button rectangle.
$BS_CENTER - Centers the text horizontally in the button rectangle.
$BS_LEFT - Left-aligns the text in the button rectangle on the right side of the check box.
$BS_MULTILINE - Wraps the button text to multiple lines if the text string is too long to fit on a single line in the button rectangle.
$BS_RIGHT - Right-aligns text in the button rectangle on the right side of the check box.
$BS_RIGHTBUTTON - Positions a check box square on the right side of the button rectangle.
$BS_TOP - Places text at the top of the button rectangle.
$BS_VCENTER - Vertically centers text in the button rectangle.

$BS_ICON - Specifies that the button displays an icon.
$BS_BITMAP - Specifies that the button displays a bitmap.

$BS_NOTIFY - Enables a button to send BN_KILLFOCUS and BN_SETFOCUS notification messages to its parent window. Note that buttons send the BN_CLICKED notification message regardless of whether it has this style. To get BN_DBLCLK notification messages, the button must have the BS_RADIOBUTTON or BS_OWNERDRAW style.

Vista Sytles:
$BS_SPLITBUTTON - Creates a split button. A split button has a drop down arrow
$BS_DEFSPLITBUTTON - Creates a split button that behaves like a $BS_PUSHBUTTON style button, but also has a distinctive appearance.
$BS_COMMANDLINK - Creates a command link button
$BS_DEFCOMMANDLINK - Creates a command link button that behaves like a $BS_PUSHBUTTON style button.

Default: ( -1) : none
Forced : $WS_CHILD, $WS_TABSTOP, $WS_VISIBLE, $BS_NOTIFY
$iExStyle | [optional] Control extended style. These correspond to the standard $WS_EX_* constants. See Extended Style Table.

Return Value

Success: | the handle to the Button control.
Failure: | 0.

Remarks

Above constants require #include <ButtonConstants.au3>.

This function is for Advanced users and for learning how the control works.

Related

_GUICtrlButton_Destroy

Example

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

Global $g_idBtn, $g_idRdo, $g_idChk, $g_idMemo

; Note the controlID from these buttons can NOT be read with GUICtrlRead

Example()

Func Example()
    Local $hGUI

    $hGUI = GUICreate("Buttons", 400, 400)
    $g_idMemo = GUICtrlCreateEdit("", 119, 10, 276, 374, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")

    $g_idBtn = _GUICtrlButton_Create($hGUI, "Button1", 10, 10, 90, 50)

    $g_idRdo = _GUICtrlButton_Create($hGUI, "Radio1", 10, 60, 90, 50, $BS_AUTORADIOBUTTON)

    $g_idChk = _GUICtrlButton_Create($hGUI, "Check1", 10, 120, 90, 50, $BS_AUTO3STATE)

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    GUISetState(@SW_SHOW)

    MemoWrite("$g_idBtn handle: " & $g_idBtn)
    MemoWrite("$g_idRdo handle: " & $g_idRdo)
    MemoWrite("$g_idChk handle: " & $g_idChk & @CRLF)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local Const $BCN_HOTITEMCHANGE = -1249
    Local $tNMBHOTITEM = DllStructCreate("hwnd hWndFrom;int IDFrom;int Code;dword dwFlags", $lParam)
    Local $nNotifyCode = DllStructGetData($tNMBHOTITEM, "Code")
    Local $nID = DllStructGetData($tNMBHOTITEM, "IDFrom")
    Local $hCtrl = DllStructGetData($tNMBHOTITEM, "hWndFrom")
    Local $iFlags = DllStructGetData($tNMBHOTITEM, "dwFlags")
    Local $sText = ""

    Switch $nNotifyCode
        Case $BCN_HOTITEMCHANGE ; Win XP and Above
            If BitAND($iFlags, 0x10) = 0x10 Then
                $sText = "$BCN_HOTITEMCHANGE - Entering: " & @CRLF

            ElseIf BitAND($iFlags, 0x20) = 0x20 Then
                $sText = "$BCN_HOTITEMCHANGE - Leaving: " & @CRLF
            EndIf
            MemoWrite($sText & _
                    "-----------------------------" & @CRLF & _
                    "WM_NOTIFY - Infos:" & @CRLF & _
                    "-----------------------------" & @CRLF & _
                    "Code" & @TAB & ":" & $nNotifyCode & @CRLF & _
                    "CtrlID" & @TAB & ":" & $nID & @CRLF & _
                    "CtrlHWnd:" & $hCtrl & @CRLF & _
                    _GUICtrlButton_GetText($hCtrl) & @CRLF)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

; React on a button click
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    Local $nNotifyCode = BitShift($wParam, 16)
    Local $nID = BitAND($wParam, 0x0000FFFF)
    Local $hCtrl = $lParam
    Local $sText = ""

    Switch $hCtrl
        Case $g_idBtn, $g_idRdo, $g_idChk
            Switch $nNotifyCode
                Case $BN_CLICKED
                    $sText = "$BN_CLICKED" & @CRLF
                Case $BN_PAINT
                    $sText = "$BN_PAINT" & @CRLF
                Case $BN_PUSHED, $BN_HILITE
                    $sText = "$BN_PUSHED, $BN_HILITE" & @CRLF
                Case $BN_UNPUSHED, $BN_UNHILITE
                    $sText = "$BN_UNPUSHED" & @CRLF
                Case $BN_DISABLE
                    $sText = "$BN_DISABLE" & @CRLF
                Case $BN_DBLCLK, $BN_DOUBLECLICKED
                    $sText = "$BN_DBLCLK, $BN_DOUBLECLICKED" & @CRLF
                Case $BN_SETFOCUS
                    $sText = "$BN_SETFOCUS" & @CRLF
                Case $BN_KILLFOCUS
                    $sText = "$BN_KILLFOCUS" & @CRLF
            EndSwitch
            MemoWrite($sText & _
                    "-----------------------------" & @CRLF & _
                    "WM_COMMAND - Infos:" & @CRLF & _
                    "-----------------------------" & @CRLF & _
                    "Code" & @TAB & ":" & $nNotifyCode & @CRLF & _
                    "CtrlID" & @TAB & ":" & $nID & @CRLF & _
                    "CtrlHWnd:" & $hCtrl & @CRLF & _
                    _GUICtrlButton_GetText($hCtrl) & @CRLF)
            Return 0 ; Only workout clicking on the button
    EndSwitch
    ; Proceed the default AutoIt3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default AutoIt3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND


Function _GUICtrlButton_Destroy

Function Reference

_GUICtrlButton_Destroy

Delete the Button control

#include <GuiButton.au3>
_GUICtrlButton_Destroy ( ByRef $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True, $hWnd is set to 0.
Failure: | False.

Remarks

Restricted to only be used on Button controls created with _GUICtrlButton_Create().

Related

_GUICtrlButton_Create

Example

#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $idBtn, $idRdo, $idChk

    $hGUI = GUICreate("Buttons", 400, 400)
    $g_idMemo = GUICtrlCreateEdit("", 119, 10, 276, 374, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")

    $idBtn = _GUICtrlButton_Create($hGUI, "Button1", 10, 10, 90, 50)

    $idRdo = _GUICtrlButton_Create($hGUI, "Radio1", 10, 60, 90, 50, BitOR($BS_AUTORADIOBUTTON, $BS_NOTIFY))

    $idChk = _GUICtrlButton_Create($hGUI, "Check1", 10, 120, 90, 50, BitOR($BS_AUTO3STATE, $BS_NOTIFY))

    GUISetState(@SW_SHOW)

    MemoWrite("$idBtn handle: " & $idBtn)
    MemoWrite("$idRdo handle: " & $idRdo)
    MemoWrite("$idChk handle: " & $idChk & @CRLF)

    MsgBox($MB_SYSTEMMODAL, "Information", "About to Destroy Buttons")

    Send("^{END}")

    MemoWrite("Destroyed $idBtn: " & _GUICtrlButton_Destroy($idBtn))
    MemoWrite("Destroyed $idRdo: " & _GUICtrlButton_Destroy($idRdo))
    MemoWrite("Destroyed $idChk: " & _GUICtrlButton_Destroy($idChk) & @CRLF)

    MemoWrite("$idBtn handle: " & $idBtn)
    MemoWrite("$idRdo handle: " & $idRdo)
    MemoWrite("$idChk handle: " & $idChk & @CRLF)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlButton_Enable

Function Reference

_GUICtrlButton_Enable

Enables or disables mouse and keyboard input to the specified button

#include <GuiButton.au3>
_GUICtrlButton_Enable ( $hWnd [, $bEnable = True] )

Parameters

$hWnd | Control ID/Handle to the control
$bEnable | [optional] Specifies whether to enable or disable the button: True - The button is enabled False - The button is disabled

Return Value

Success: | True.
Failure: | False.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idRdo, $idRdo2, $idChk

    GUICreate("Buttons", 400, 400)
    $g_idMemo = GUICtrlCreateEdit("", 119, 10, 276, 374, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")

    $idRdo = GUICtrlCreateRadio("Radio1", 10, 10, 90, 50)

    $idRdo2 = GUICtrlCreateRadio("Radio2", 10, 60, 90, 50)
    _GUICtrlButton_SetCheck($idRdo2)

    $idChk = GUICtrlCreateCheckbox("Check1", 10, 120, 90, 50, BitOR($BS_AUTO3STATE, $BS_NOTIFY))
    _GUICtrlButton_SetCheck($idChk, $BST_INDETERMINATE)

    GUISetState(@SW_SHOW)

    MemoWrite("Disabled Button: " & _GUICtrlButton_Enable($idRdo2, False))
    Sleep(1000)
    MemoWrite("Enabled Button: " & _GUICtrlButton_Enable($idRdo2))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idRdo
                MemoWrite("Clicked $idRdo")
            Case $idRdo2
                MemoWrite("Clicked $idRdo2")
            Case $idChk
                MemoWrite("Clicked $idChk")
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlButton_GetCheck

Function Reference

_GUICtrlButton_GetCheck

Gets the check state of a radio button or check box

#include <GuiButton.au3>
_GUICtrlButton_GetCheck ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | The return value from a button created with the $BS_AUTOCHECKBOX, $BS_AUTORADIOBUTTON, $BS_AUTO3STATE, $BS_CHECKBOX, $BS_RADIOBUTTON, or $BS_3STATE style can be one of the following: $BST_CHECKED - Button is checked. $BST_INDETERMINATE - Button is grayed, indicating an indeterminate state (applies only if the button has the $BS_3STATE or $BS_AUTO3STATE style). $BST_UNCHECKED Button is cleared
Failure: | 0.

Remarks

If the button has a style other than those listed, the return value is zero.

Related

_GUICtrlButton_GetState, _GUICtrlButton_SetCheck

See Also

Search BM_GETCHECK in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idRdo, $idRdo2, $idChk

    GUICreate("Buttons", 400, 400)
    $g_idMemo = GUICtrlCreateEdit("", 119, 10, 276, 374, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")

    $idRdo = GUICtrlCreateRadio("Radio1", 10, 10, 90, 50)

    $idRdo2 = GUICtrlCreateRadio("Radio2", 10, 60, 90, 50)
    _GUICtrlButton_SetCheck($idRdo2)
    _GUICtrlButton_SetFocus($idRdo2) ; set focus, shows this doesn't affect _GUICtrlButton_GetCheck

    $idChk = GUICtrlCreateCheckbox("Check1", 10, 120, 90, 50, BitOR($BS_AUTO3STATE, $BS_NOTIFY))
    _GUICtrlButton_SetCheck($idChk, $BST_INDETERMINATE)

    GUISetState(@SW_SHOW)

    MemoWrite("$idRdo checked status.: " & @CRLF & @TAB & _ExplainCheckState(_GUICtrlButton_GetCheck($idRdo)) & @CRLF)
    MemoWrite("$idRdo2 checked status: " & @CRLF & @TAB & _ExplainCheckState(_GUICtrlButton_GetCheck($idRdo2)) & @CRLF)
    MemoWrite("$idChk checked status.: " & @CRLF & @TAB & _ExplainCheckState(_GUICtrlButton_GetCheck($idChk)) & @CRLF)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func _ExplainCheckState($iState)
    Switch $iState
        Case $BST_CHECKED
            Return "Button is checked."
        Case $BST_INDETERMINATE
            Return "Button is grayed, indicating an indeterminate state (applies only if the button has the $BS_3STATE or $BS_AUTO3STATE style)."
        Case $BST_UNCHECKED
            Return "Button is cleared"
    EndSwitch
EndFunc   ;==>_ExplainCheckState


Function _GUICtrlButton_GetFocus

Function Reference

_GUICtrlButton_GetFocus

Retrieves if the button has keyboard focus

#include <GuiButton.au3>
_GUICtrlButton_GetFocus ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

True: | Button has focus.
False: | Button does not have focus.

Related

_GUICtrlButton_SetFocus

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idRdo, $idRdo2, $idChk

    GUICreate("Buttons", 400, 400)
    $g_idMemo = GUICtrlCreateEdit("", 119, 10, 276, 374, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")

    $idRdo = GUICtrlCreateRadio("Radio1", 10, 10, 90, 50)
    _GUICtrlButton_SetFocus($idRdo)

    $idRdo2 = GUICtrlCreateRadio("Radio2", 10, 60, 90, 50)
    _GUICtrlButton_SetCheck($idRdo2)

    $idChk = GUICtrlCreateCheckbox("Check1", 10, 120, 90, 50, BitOR($BS_AUTO3STATE, $BS_NOTIFY))
    _GUICtrlButton_SetCheck($idChk, $BST_INDETERMINATE)

    GUISetState(@SW_SHOW)

    MemoWrite(StringFormat("$idRdo focus status.: %s", _GUICtrlButton_GetFocus($idRdo)))
    MemoWrite(StringFormat("$idRdo2 focus status: %s", _GUICtrlButton_GetFocus($idRdo2)))
    MemoWrite(StringFormat("$idChk focus status.: %s", _GUICtrlButton_GetFocus($idChk)))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlButton_GetIdealSize

Function Reference

_GUICtrlButton_GetIdealSize

Gets the size of the button that best fits its text and image, if an image list is present

#include <GuiButton.au3>
_GUICtrlButton_GetIdealSize ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an array containing the following:
[0] - Ideal width
[1] - Ideal height

Related

_GUICtrlButton_SetSize

See Also

Search BCM_GETIDEALSIZE in MSDN Library.

Example

#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hImage, $idBtn, $aIdealSize

    GUICreate("Buttons", 400, 400)
    $g_idMemo = GUICtrlCreateEdit("", 119, 10, 276, 374, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")

    $hImage = _GUIImageList_Create(32, 32, 5, 3, 6)
    For $x = 6 To 11
        _GUIImageList_AddIcon($hImage, "shell32.dll", $x, True)
    Next

    $idBtn = GUICtrlCreateButton("Button1", 10, 10, 90, 50)
    _GUICtrlButton_SetImageList($idBtn, $hImage)

    GUISetState(@SW_SHOW)

    $aIdealSize = _GUICtrlButton_GetIdealSize($idBtn)
    MemoWrite("Button1 Ideal width: " & $aIdealSize[0] & " height: " & $aIdealSize[1])

    Sleep(3000)

    MemoWrite(StringFormat("Set Size: %s", _GUICtrlButton_SetSize($idBtn, $aIdealSize[0], $aIdealSize[1])))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlButton_GetImage

Function Reference

_GUICtrlButton_GetImage

Retrieves a handle to the image (icon or bitmap) associated with the button

#include <GuiButton.au3>
_GUICtrlButton_GetImage ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the handle to the image.
Failure: | 0.

Related

_GUICtrlButton_SetImage

See Also

Search BM_GETIMAGE in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idBtn, $idChk, $idRdo, $iMsg
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images"

    GUICreate("Buttons", 300, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 60, 296, 236, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $idBtn = GUICtrlCreateButton("Button1", 10, 10, 40, 40, $BS_BITMAP)
    _GUICtrlButton_SetImage($idBtn, $sPath & "\blue.bmp")

    $idChk = GUICtrlCreateCheckbox("Check1", 60, 10, 50, 32, $BS_ICON)
    _GUICtrlButton_SetImage($idChk, "shell32.dll", 14, True)

    $idRdo = GUICtrlCreateRadio("Radio1", 120, 10, 50, 32, $BS_ICON)
    _GUICtrlButton_SetImage($idRdo, "shell32.dll", 21, True)

    MemoWrite("Button1 Image Handle: " & _GUICtrlButton_GetImage($idBtn))
    MemoWrite("Check1 Image Handle: " & _GUICtrlButton_GetImage($idChk))
    MemoWrite("Radio1 Image Handle: " & _GUICtrlButton_GetImage($idRdo))

    While 1
        $iMsg = GUIGetMsg()
        If $iMsg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlButton_GetImageList

Function Reference

_GUICtrlButton_GetImageList

Retrieves an array that describes the image list assigned to a button control

#include <GuiButton.au3>
_GUICtrlButton_GetImageList ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an array containing the following:
[0] - Image list handle
[1] - Left margin of the icon
[2] - Top margin of the icon
[3] - Right margin of the icon
[4] - Bottom margin of the icon
[5] - Specifies the alignment. This will be one of the following values:
0 - Image aligned with the left margin.
1 - Image aligned with the right margin.
2 - Image aligned with the top margin.
3 - Image aligned with the bottom margin.
4 - Image centered.

Related

_GUICtrlButton_SetImageList

See Also

Search BCM_GETIMAGELIST in MSDN Library.

Example

#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hImage, $y = 70, $iIcon = 125, $a_idBtn[6], $aImageListInfo

    GUICreate("Buttons", 510, 400)
    $g_idMemo = GUICtrlCreateEdit("", 119, 10, 376, 374, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(32, 32, 5, 3, 6)
    For $x = 6 To 11
        _GUIImageList_AddIcon($hImage, "shell32.dll", $x, True)
    Next

    $a_idBtn[0] = GUICtrlCreateButton("Button1", 10, 10, 90, 50)
    _GUICtrlButton_SetImageList($a_idBtn[0], $hImage)

    For $x = 1 To 5
        $a_idBtn[$x] = GUICtrlCreateButton("Button" & $x + 1, 10, $y, 90, 50)
        _GUICtrlButton_SetImageList($a_idBtn[$x], _GetImageListHandle("shell32.dll", $iIcon + $x, True), $x)
        $y += 60
    Next

    For $x = 0 To 5
        $aImageListInfo = _GUICtrlButton_GetImageList($a_idBtn[$x])
        MemoWrite("Button" & $x + 1 & " Imagelist Info" & @CRLF & "--------------------------------")
        MemoWrite("Image list handle........: " & $aImageListInfo[0])
        MemoWrite("Left margin of the icon..: " & $aImageListInfo[1])
        MemoWrite("Top margin of the icon...: " & $aImageListInfo[2])
        MemoWrite("Right margin of the icon.: " & $aImageListInfo[3])
        MemoWrite("Bottom margin of the icon: " & $aImageListInfo[4])
        MemoWrite("Alignment: " & _ExplainAlignment($aImageListInfo[5]))
        MemoWrite("--------------------------------" & @CRLF)
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; using image list to set 1 image and have text on button
Func _GetImageListHandle($sFile, $nIconID = 0, $bLarge = False)
    Local $iSize = 16
    If $bLarge Then $iSize = 32

    Local $hImage = _GUIImageList_Create($iSize, $iSize, 5, 3)
    If StringUpper(StringMid($sFile, StringLen($sFile) - 2)) = "BMP" Then
        _GUIImageList_AddBitmap($hImage, $sFile)
    Else
        _GUIImageList_AddIcon($hImage, $sFile, $nIconID, $bLarge)
    EndIf
    Return $hImage
EndFunc   ;==>_GetImageListHandle

Func _ExplainAlignment($iAlign)
    Switch $iAlign
        Case 0
            Return "Image aligned with the left margin."
        Case 1
            Return "Image aligned with the right margin."
        Case 2
            Return "Image aligned with the top margin."
        Case 3
            Return "Image aligned with the bottom margin."
        Case 4
            Return "Image centered."
    EndSwitch
EndFunc   ;==>_ExplainAlignment


Function _GUICtrlButton_GetNote

Function Reference

_GUICtrlButton_GetNote

Gets the text of the note associated with the Command Link button

#include <GuiButton.au3>
_GUICtrlButton_GetNote ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the text associated with the Command Link Button.
Failure: | an empty string.

Remarks

This function works only with the $BS_COMMANDLINK and $BS_DEFCOMMANDLINK button styles.

Windows Vista or later.

Related

_GUICtrlButton_GetNoteLength, _GUICtrlButton_SetNote

See Also

Search BCM_GETNOTE in MSDN Library.

Example

#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

; Note the controlID from these button(s) can NOT be read with GUICtrlRead.

Example()

Func Example()
    Local $hButton, $hGUI

    $hGUI = GUICreate("Buttons", 400, 400)
    $g_idMemo = GUICtrlCreateEdit("", 10, 75, 390, 315, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")

    $hButton = _GUICtrlButton_Create($hGUI, "Button1", 10, 10, 160, 60, BitOR($BS_COMMANDLINK, $BS_DEFCOMMANDLINK))
    _GUICtrlButton_SetNote($hButton, "This is a test of Vista")

    GUISetState(@SW_SHOW)

    MemoWrite("Note: " & _GUICtrlButton_GetNote($hButton))
    MemoWrite("Note Length: " & _GUICtrlButton_GetNoteLength($hButton))
    MemoWrite("Button Text: " & _GUICtrlButton_GetText($hButton))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control.
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlButton_GetNoteLength

Function Reference

_GUICtrlButton_GetNoteLength

Gets the length of the note text that may be displayed in the description for a command link button

#include <GuiButton.au3>
_GUICtrlButton_GetNoteLength ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the length of the note text in WCHARs—not including any terminating NULL WCHAR.
Failure: | 0.

Remarks

This function works only with the $BS_COMMANDLINK and $BS_DEFCOMMANDLINK button styles.

Windows Vista or later.

Related

_GUICtrlButton_GetNote, _GUICtrlButton_SetNote

See Also

Search BCM_GETNOTELENGTH in MSDN Library.

Example

#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

; Note the controlID from these button(s) can NOT be read with GUICtrlRead

Example()

Func Example()
    Local $hGUI

    $hGUI = GUICreate("Buttons", 400, 400)
    $g_idMemo = GUICtrlCreateEdit("", 10, 65, 390, 325, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")

    Local $idBtn = _GUICtrlButton_Create($hGUI, "Button1", 10, 10, 160, 40, BitOR($BS_COMMANDLINK, $BS_DEFPUSHBUTTON, $BS_PUSHLIKE))
    _GUICtrlButton_SetNote($idBtn, "This is a test of Vista")

    GUISetState(@SW_SHOW)

    MemoWrite("Note: " & _GUICtrlButton_GetNote($idBtn))
    MemoWrite("Note Length: " & _GUICtrlButton_GetNoteLength($idBtn))
    MemoWrite("Button Text: " & _GUICtrlButton_GetText($idBtn))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlButton_GetSplitInfo

Function Reference

_GUICtrlButton_GetSplitInfo

Gets information for a split button control

#include <GuiButton.au3>
_GUICtrlButton_GetSplitInfo ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | an array of the following [0] - A handle to the image list [1] - The split button style, can be one or more of the following: $BCSS_ALIGNLEFT - Align the image or glyph horizontally with the left margin $BCSS_IMAGE - Draw an icon image as the glyph $BCSS_NOSPLIT - No split $BCSS_STRETCH - Stretch glyph, but try to retain aspect ratio [2] - Width of the glyph [3] - Height of the glyph
Failure: | sets the @error flag to non-zero.

Remarks

This function works only with the $BS_SPLITBUTTON and $BS_DEFSPLITBUTTON button styles.

Windows Vista or later.

Related

_GUICtrlButton_SetSplitInfo

See Also

Search BCM_GETSPLITINFO in MSDN Library.

Example

#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <WindowsConstants.au3>

Global $g_idBtn, $g_idMemo, $g_idBtn2

; Note the controlID from these buttons can NOT be read with GUICtrlRead

Example()

Func Example()
    Local $hGUI, $aInfo

    $hGUI = GUICreate("Buttons", 400, 400)
    $g_idMemo = GUICtrlCreateEdit("", 10, 100, 390, 284, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")

    $g_idBtn = _GUICtrlButton_Create($hGUI, "Split Button", 10, 10, 120, 30, $BS_SPLITBUTTON)
    _GUICtrlButton_SetSplitInfo($g_idBtn)
    $g_idBtn2 = _GUICtrlButton_Create($hGUI, "Split Button 2", 10, 50, 120, 30, $BS_SPLITBUTTON)

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    GUISetState(@SW_SHOW)

    $aInfo = _GUICtrlButton_GetSplitInfo($g_idBtn)
    MemoWrite("Split Info" & @CRLF & "----------------")
    For $x = 0 To 3
        MemoWrite("$ainfo[" & $x & "] = " & $aInfo[$x])
    Next
    MemoWrite("Split Info" & @CRLF & "----------------")

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local Const $BCN_HOTITEMCHANGE = -1249
    Local $tNMBHOTITEM = DllStructCreate("hwnd hWndFrom;int IDFrom;int Code;dword dwFlags", $lParam)
    Local $nNotifyCode = DllStructGetData($tNMBHOTITEM, "Code")
    Local $nID = DllStructGetData($tNMBHOTITEM, "IDFrom")
    Local $hCtrl = DllStructGetData($tNMBHOTITEM, "hWndFrom")
    Local $iFlags = DllStructGetData($tNMBHOTITEM, "dwFlags")
    Local $sText = ""

    Switch $nNotifyCode
        Case $BCN_HOTITEMCHANGE ; Win XP and Above
            If BitAND($iFlags, 0x10) = 0x10 Then
                $sText = "$BCN_HOTITEMCHANGE - Entering: " & @CRLF

            ElseIf BitAND($iFlags, 0x20) = 0x20 Then
                $sText = "$BCN_HOTITEMCHANGE - Leaving: " & @CRLF
            EndIf
            MemoWrite($sText & _
                    "-----------------------------" & @CRLF & _
                    "WM_NOTIFY - Infos:" & @CRLF & _
                    "-----------------------------" & @CRLF & _
                    "Code" & @TAB & ":" & $nNotifyCode & @CRLF & _
                    "CtrlID" & @TAB & ":" & $nID & @CRLF & _
                    "CtrlHWnd:" & $hCtrl & @CRLF & _
                    _GUICtrlButton_GetText($hCtrl) & @CRLF)
        Case $BCN_DROPDOWN
            MemoWrite("$BCN_DROPDOWN")
            _Popup_Menu($hCtrl)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _Popup_Menu($hCtrl)
    Local $hMenu
    Local Enum $e_idOpen = 1000, $e_idSave, $e_idInfo
    $hMenu = _GUICtrlMenu_CreatePopup()
    _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $e_idInfo)
    Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hCtrl, -1, -1, 1, 1, 2)
        Case $e_idOpen
            MemoWrite("Open - Selected")
        Case $e_idSave
            MemoWrite("Save - Selected")
        Case $e_idInfo
            MemoWrite("Info - Selected")
    EndSwitch
    _GUICtrlMenu_DestroyMenu($hMenu)
EndFunc   ;==>_Popup_Menu

; React on a button click
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    Local $nNotifyCode = BitShift($wParam, 16)
    Local $nID = BitAND($wParam, 0x0000FFFF)
    Local $hCtrl = $lParam
    Local $sText = ""

    Switch $hCtrl
        Case $g_idBtn, $g_idBtn2
            Switch $nNotifyCode
                Case $BN_CLICKED
                    $sText = "$BN_CLICKED" & @CRLF
                Case $BN_PAINT
                    $sText = "$BN_PAINT" & @CRLF
                Case $BN_PUSHED, $BN_HILITE
                    $sText = "$BN_PUSHED, $BN_HILITE" & @CRLF
                Case $BN_UNPUSHED, $BN_UNHILITE
                    $sText = "$BN_UNPUSHED" & @CRLF
                Case $BN_DISABLE
                    $sText = "$BN_DISABLE" & @CRLF
                Case $BN_DBLCLK, $BN_DOUBLECLICKED
                    $sText = "$BN_DBLCLK, $BN_DOUBLECLICKED" & @CRLF
                Case $BN_SETFOCUS
                    $sText = "$BN_SETFOCUS" & @CRLF
                Case $BN_KILLFOCUS
                    $sText = "$BN_KILLFOCUS" & @CRLF
            EndSwitch
            MemoWrite($sText & _
                    "-----------------------------" & @CRLF & _
                    "WM_COMMAND - Infos:" & @CRLF & _
                    "-----------------------------" & @CRLF & _
                    "Code" & @TAB & ":" & $nNotifyCode & @CRLF & _
                    "CtrlID" & @TAB & ":" & $nID & @CRLF & _
                    "CtrlHWnd:" & $hCtrl & @CRLF & _
                    _GUICtrlButton_GetText($hCtrl) & @CRLF)
            Return 0 ; Only workout clicking on the button
    EndSwitch
    ; Proceed the default AutoIt3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default AutoIt3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND


Function _GUICtrlButton_GetState

Function Reference

_GUICtrlButton_GetState

Determines the state of a button or check box

#include <GuiButton.au3>
_GUICtrlButton_GetState ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the current state of the button. This can be a combination of the following values, which can be retrieved using BitAND:
$BST_CHECKED - Indicates the button is checked.
$BST_FOCUS - Specifies the focus state. A nonzero value indicates that the button has the keyboard focus.
$BST_INDETERMINATE - Indicates the button is grayed because the state of the button is indeterminate.
This value applies only if the button has the $BS_3STATE or $BS_AUTO3STATE style.
$BST_PUSHED - Specifies the highlight state. A nonzero value indicates that the button is highlighted.
A button is automatically highlighted when the user positions the cursor over it and presses and holds the left mouse button.
The highlighting is removed when the user releases the mouse button.
$BST_UNCHECKED - Indicates the button is cleared. Same as a return value of zero.

Related

_GUICtrlButton_GetCheck, _GUICtrlButton_SetCheck, _GUICtrlButton_SetState

See Also

Search BM_GETSTATE in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idRdo, $idRdo2, $idChk, $idChk2, $idChk3, $idBtn, $idBtn2

    GUICreate("Buttons", 400, 400)
    $g_idMemo = GUICtrlCreateEdit("", 119, 10, 276, 374, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")

    $idBtn = GUICtrlCreateButton("Button1", 10, 10, 90, 25)
    _GUICtrlButton_SetState($idBtn)

    $idBtn2 = GUICtrlCreateButton("Button2", 10, 60, 90, 25)

    $idRdo = GUICtrlCreateRadio("Radio1", 10, 110, 90, 25)
    _GUICtrlButton_SetFocus($idRdo)

    $idRdo2 = GUICtrlCreateRadio("Radio2", 10, 170, 90, 25)
    _GUICtrlButton_SetCheck($idRdo2)

    $idChk = GUICtrlCreateCheckbox("Check1", 10, 230, 90, 25, BitOR($BS_AUTO3STATE, $BS_NOTIFY))
    _GUICtrlButton_SetCheck($idChk, $BST_INDETERMINATE)

    $idChk2 = GUICtrlCreateCheckbox("Check2", 10, 290, 90, 25, BitOR($BS_AUTO3STATE, $BS_NOTIFY))

    $idChk3 = GUICtrlCreateCheckbox("Check3", 10, 350, 90, 25, BitOR($BS_AUTO3STATE, $BS_NOTIFY))
    _GUICtrlButton_SetCheck($idChk3, $BST_CHECKED)

    GUISetState(@SW_SHOW)

    MemoWrite("Button1 status:" & @CRLF & "--------------------------------" & _
            _ExplainState(_GUICtrlButton_GetState($idBtn), True))
    MemoWrite("Button2 status:" & @CRLF & "--------------------------------" & _
            _ExplainState(_GUICtrlButton_GetState($idBtn2), True))
    MemoWrite("Radio1 status: " & @CRLF & "--------------------------------" & _
            _ExplainState(_GUICtrlButton_GetState($idRdo)))
    MemoWrite("Radio2 status: " & @CRLF & "--------------------------------" & _
            _ExplainState(_GUICtrlButton_GetState($idRdo2)))
    MemoWrite("Check1 status: " & @CRLF & "--------------------------------" & _
            _ExplainState(_GUICtrlButton_GetState($idChk)))
    MemoWrite("Check2 status: " & @CRLF & "--------------------------------" & _
            _ExplainState(_GUICtrlButton_GetState($idChk2)))
    MemoWrite("Check3 status: " & @CRLF & "--------------------------------" & _
            _ExplainState(_GUICtrlButton_GetState($idChk3)))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func _ExplainState($iState, $bPushButton = False)
    Local $sText = ""
    If Not $bPushButton And Not $iState Then Return _
            @CRLF & "Indicates the button is cleared. Same as a return value of zero." & @CRLF
    If BitAND($iState, $BST_CHECKED) = $BST_CHECKED Then _
            $sText &= @CRLF & "Indicates the button is checked." & @CRLF
    If BitAND($iState, $BST_FOCUS) = $BST_FOCUS Then _
            $sText &= @CRLF & "Specifies the focus state. A nonzero value indicates that the button has the keyboard focus." & @CRLF
    If BitAND($iState, $BST_INDETERMINATE) = $BST_INDETERMINATE Then _
            $sText &= @CRLF & "Indicates the button is grayed because the state of the button is indeterminate." & @CRLF
    If $bPushButton Then
        If BitAND($iState, $BST_PUSHED) = $BST_PUSHED Then
            $sText &= @CRLF & "Specifies the highlight state." & @CRLF
        Else
            $sText &= @CRLF & "Specifies not highlighted state." & @CRLF
        EndIf
    EndIf
    Return $sText
EndFunc   ;==>_ExplainState


Function _GUICtrlButton_GetText

Function Reference

_GUICtrlButton_GetText

Retrieve the text of the button

#include <GuiButton.au3>
_GUICtrlButton_GetText ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the text of the button.
Failure: | an empty string ""

Related

_GUICtrlButton_SetText

Example

#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $y = 70, $a_idBtn[6], $iRand

    GUICreate("Buttons", 510, 400)
    $g_idMemo = GUICtrlCreateEdit("", 119, 10, 276, 374, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $a_idBtn[0] = GUICtrlCreateButton("Button1", 10, 10, 90, 50)

    For $x = 1 To 5
        $a_idBtn[$x] = GUICtrlCreateButton("Button" & $x + 1, 10, $y, 90, 50)
        $y += 60
    Next

    $iRand = Random(0, 5, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Button" & $iRand + 1 & " Text")
    _GUICtrlButton_SetText($a_idBtn[$iRand], "New Text" & $iRand + 1)

    For $x = 0 To 5
        MemoWrite("$a_idBtn[" & $x & "] Text: " & _GUICtrlButton_GetText($a_idBtn[$x]))
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlButton_GetTextMargin

Function Reference

_GUICtrlButton_GetTextMargin

Gets the margins used to draw text in a button control

#include <GuiButton.au3>
_GUICtrlButton_GetTextMargin ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an array with the following format:
[0] - Left margin to use for drawing text
[1] - Top margin to use for drawing text
[2] - Right margin to use for drawing text
[3] - Bottom margin to use for drawing text

Related

_GUICtrlButton_SetTextMargin

See Also

Search BCM_GETTEXTMARGIN in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $y = 70, $a_idBtn[6], $aMargins

    GUICreate("Buttons", 510, 400)
    $g_idMemo = GUICtrlCreateEdit("", 119, 10, 276, 374, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $a_idBtn[0] = GUICtrlCreateButton("Button1", 10, 10, 90, 50)
    _GUICtrlButton_SetTextMargin($a_idBtn[0], 10, 5, 10, 5)

    For $x = 1 To 5
        $a_idBtn[$x] = GUICtrlCreateButton("Button" & $x + 1, 10, $y, 90, 50)
        $y += 60
    Next

    For $x = 0 To 5
        $aMargins = _GUICtrlButton_GetTextMargin($a_idBtn[$x])
        MemoWrite("Button" & $x + 1 & " Margins:" & @CRLF & @TAB & _
                "Left.: " & $aMargins[0] & @TAB & "Top...: " & $aMargins[1] & @CRLF & @TAB & _
                "Right: " & $aMargins[2] & @TAB & "Bottom: " & $aMargins[3] & @CRLF)
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlButton_SetCheck

Function Reference

_GUICtrlButton_SetCheck

Sets the check state of a radio button or check box

#include <GuiButton.au3>
_GUICtrlButton_SetCheck ( $hWnd [, $iState = $BST_CHECKED] )

Parameters

$hWnd | Control ID/Handle to the control
$iState | [optional] The check state. This parameter can be one of the following values: $BST_CHECKED - Sets the button state to checked. $BST_INDETERMINATE - Sets the button state to grayed, indicating an indeterminate state. Use this value only if the button has the $BS_3STATE or $BS_AUTO3STATE style. $BST_UNCHECKED - Sets the button state to cleared.

Return Value

None.

Remarks

_GUICtrlButton_SetCheck() has no effect on push buttons.

Related

_GUICtrlButton_GetCheck, _GUICtrlButton_GetState, _GUICtrlButton_SetState

See Also

Search BCM_GETTEXTMARGIN in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idRdo, $idRdo2, $idChk

    GUICreate("Buttons", 400, 400)
    $g_idMemo = GUICtrlCreateEdit("", 119, 10, 276, 374, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")

    $idRdo = GUICtrlCreateRadio("Radio1", 10, 10, 90, 50)

    $idRdo2 = GUICtrlCreateRadio("Radio2", 10, 60, 90, 50)
    _GUICtrlButton_SetCheck($idRdo2)
    _GUICtrlButton_SetFocus($idRdo2) ; set focus, shows this doesn't affect _GUICtrlButton_GetCheck

    $idChk = GUICtrlCreateCheckbox("Check1", 10, 120, 90, 50, BitOR($BS_AUTO3STATE, $BS_NOTIFY))
    _GUICtrlButton_SetCheck($idChk, $BST_INDETERMINATE)

    GUISetState(@SW_SHOW)

    MemoWrite("$idRdo checked status.: " & @CRLF & @TAB & _ExplainCheckState(_GUICtrlButton_GetCheck($idRdo)) & @CRLF)
    MemoWrite("$idRdo2 checked status: " & @CRLF & @TAB & _ExplainCheckState(_GUICtrlButton_GetCheck($idRdo2)) & @CRLF)
    MemoWrite("$idChk checked status.: " & @CRLF & @TAB & _ExplainCheckState(_GUICtrlButton_GetCheck($idChk)) & @CRLF)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func _ExplainCheckState($iState)
    Switch $iState
        Case $BST_CHECKED
            Return "Button is checked."
        Case $BST_INDETERMINATE
            Return "Button is grayed, indicating an indeterminate state (applies only if the button has the $BS_3STATE or $BS_AUTO3STATE style)."
        Case $BST_UNCHECKED
            Return "Button is cleared"
    EndSwitch
EndFunc   ;==>_ExplainCheckState


Function _GUICtrlButton_SetDontClick

Function Reference

_GUICtrlButton_SetDontClick

Sets the state of $BST_DONTCLICK flag on a button

#include <GuiButton.au3>
_GUICtrlButton_SetDontClick ( $hWnd [, $bState = True] )

Parameters

$hWnd | Control ID/Handle to the control
$bState | [optional] The state. True to set the $BST_DONTCLICK, otherwise False

Return Value

None.

Remarks

Windows Vista or later.

See Also

Search BM_SETDONTCLICK in MSDN Library.

Example

#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <WindowsConstants.au3>

Global $g_hBtn, $g_idMemo, $g_hBtn2

; Note the controlID from these buttons can NOT be read with GUICtrlRead

Example()

Func Example()
    Local $hGUI

    $hGUI = GUICreate("Buttons", 400, 400)
    $g_idMemo = GUICtrlCreateEdit("", 10, 100, 390, 284, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")

    $g_hBtn = _GUICtrlButton_Create($hGUI, "Button1", 10, 10, 160, 40)
    _GUICtrlButton_SetDontClick($g_hBtn)

    $g_hBtn2 = _GUICtrlButton_Create($hGUI, "Button2", 10, 55, 160, 40)

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; React on a button click
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    Local $iNotifyCode = BitShift($wParam, 16)
    Local $iID = BitAND($wParam, 0x0000FFFF)
    Local $hCtrl = $lParam
    Local $sText = ""

    Switch $hCtrl
        Case $g_hBtn, $g_hBtn2
            Switch $iNotifyCode
                Case $BN_CLICKED
                    If BitAND(_GUICtrlButton_GetState($hCtrl), $BST_DONTCLICK) = $BST_DONTCLICK Then
                        $sText = "$BST_DONTCLICK" & @CRLF
                    Else
                        $sText = "$BN_CLICKED" & @CRLF
                    EndIf
                    MemoWrite($sText & _
                            "-----------------------------" & @CRLF & _
                            "WM_COMMAND - Infos:" & @CRLF & _
                            "-----------------------------" & @CRLF & _
                            "Code" & @TAB & ":" & $iNotifyCode & @CRLF & _
                            "CtrlID" & @TAB & ":" & $iID & @CRLF & _
                            "CtrlHWnd:" & $hCtrl & @CRLF & _
                            _GUICtrlButton_GetText($hCtrl) & @CRLF)
                Case $BN_PAINT
                    $sText = "$BN_PAINT" & @CRLF
                Case $BN_PUSHED, $BN_HILITE
                    $sText = "$BN_PUSHED, $BN_HILITE" & @CRLF
                Case $BN_UNPUSHED, $BN_UNHILITE
                    $sText = "$BN_UNPUSHED" & @CRLF
                Case $BN_DISABLE
                    $sText = "$BN_DISABLE" & @CRLF
                Case $BN_DBLCLK, $BN_DOUBLECLICKED
                    $sText = "$BN_DBLCLK, $BN_DOUBLECLICKED" & @CRLF
                Case $BN_SETFOCUS
                    $sText = "$BN_SETFOCUS" & @CRLF
                Case $BN_KILLFOCUS
                    $sText = "$BN_KILLFOCUS" & @CRLF
            EndSwitch
            Return 0 ; Only workout clicking on the button
    EndSwitch
    ; Proceed the default AutoIt3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default AutoIt3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND


Function _GUICtrlButton_SetFocus

Function Reference

_GUICtrlButton_SetFocus

Sets the keyboard focus to the specified button

#include <GuiButton.au3>
_GUICtrlButton_SetFocus ( $hWnd [, $bFocus = True] )

Parameters

$hWnd | Control ID/Handle to the control
$bFocus | [optional] This parameter can be one of the following values: True - Sets the keyboard focus to the button False - Removes the keyboard focus from the button

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlButton_GetFocus

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idRdo, $idRdo2, $idChk

    GUICreate("Buttons", 400, 400)
    $g_idMemo = GUICtrlCreateEdit("", 119, 10, 276, 374, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")

    $idRdo = GUICtrlCreateRadio("Radio1", 10, 10, 90, 50)
    _GUICtrlButton_SetFocus($idRdo)

    $idRdo2 = GUICtrlCreateRadio("Radio2", 10, 60, 90, 50)
    _GUICtrlButton_SetCheck($idRdo2)

    $idChk = GUICtrlCreateCheckbox("Check1", 10, 120, 90, 50, BitOR($BS_AUTO3STATE, $BS_NOTIFY))
    _GUICtrlButton_SetCheck($idChk, $BST_INDETERMINATE)

    GUISetState(@SW_SHOW)

    MemoWrite(StringFormat("$idRdo focus status.: %s", _GUICtrlButton_GetFocus($idRdo)))
    MemoWrite(StringFormat("$idRdo2 focus status: %s", _GUICtrlButton_GetFocus($idRdo2)))
    MemoWrite(StringFormat("$idChk focus status.: %s", _GUICtrlButton_GetFocus($idChk)))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlButton_SetImage

Function Reference

_GUICtrlButton_SetImage

Sets the image of a button

#include <GuiButton.au3>
_GUICtrlButton_SetImage ( $hWnd, $sImageFile [, $iIconID = -1 [, $bLarge = False]] )

Parameters

$hWnd | Control ID/Handle to the control
$sImageFile | File containing the Image
$iIconID | [optional] Specifies the 0-based index of the icon to extract
$bLarge | [optional] Extract Large Icon

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlButton_GetImage

See Also

Search BM_SETIMAGE in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idBtn, $idChk, $idRdo, $iMsg
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images"

    GUICreate("Buttons", 300, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 60, 296, 236, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $idBtn = GUICtrlCreateButton("Button1", 10, 10, 40, 40, $BS_BITMAP)
    _GUICtrlButton_SetImage($idBtn, $sPath & "\blue.bmp")

    $idChk = GUICtrlCreateCheckbox("Check1", 60, 10, 50, 32, $BS_ICON)
    _GUICtrlButton_SetImage($idChk, "shell32.dll", 14, True)

    $idRdo = GUICtrlCreateRadio("Radio1", 120, 10, 50, 32, $BS_ICON)
    _GUICtrlButton_SetImage($idRdo, "shell32.dll", 21, True)

    MemoWrite("Button1 Image Handle: " & _GUICtrlButton_GetImage($idBtn))
    MemoWrite("Check1 Image Handle: " & _GUICtrlButton_GetImage($idChk))
    MemoWrite("Radio1 Image Handle: " & _GUICtrlButton_GetImage($idRdo))

    While 1
        $iMsg = GUIGetMsg()
        If $iMsg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlButton_SetImageList

Function Reference

_GUICtrlButton_SetImageList

Assigns an image list to a button control

#include <GuiButton.au3>
_GUICtrlButton_SetImageList ( $hWnd, $hImage [, $iAlign = 0 [, $iLeft = 1 [, $iTop = 1 [, $iRight = 1 [, $iBottom = 1]]]]] )

Parameters

$hWnd | Control ID/Handle to the control
$hImage | A handle to the image list. Should contain either a single image to be used for all states or individual images for each state listed in the following: 1 - Normal 2 - Hot 3 - Pressed 4 - Disabled 5 - Defaulted 6 - Stylus Hot (tablet computers only)
$iAlign | [optional] Specifies the alignment to use. This parameter can be one of the following values: 0 - Align the image with the left margin. 1 - Align the image with the right margin. 2 - Align the image with the top margin. 3 - Align the image with the bottom margin. 4 - Center the image.
$iLeft | [optional] Left margin of the icon
$iTop | [optional] Top margin of the icon
$iRight | [optional] Right margin of the icon
$iBottom | [optional] Bottom margin of the icon

Return Value

Success: | True.
Failure: | False.

Remarks

Image list with multiple images will only show the images other than the 1st image when Themes is being used.

Related

_GUICtrlButton_GetImageList

See Also

Search BCM_SETIMAGELIST in MSDN Library.

Example

#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>

Example()

Func Example()
    Local $hImage, $y = 70, $iIcon = 125, $a_idBtn[6], $a_idRdo[6], $a_idChk[6], $hImageSmall

    GUICreate("Buttons", 510, 400)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(32, 32, 5, 3, 6)
    For $x = 6 To 11
        _GUIImageList_AddIcon($hImage, "shell32.dll", $x, True)
    Next

    $hImageSmall = _GUIImageList_Create(16, 16, 5, 3, 6)
    For $x = 6 To 11
        _GUIImageList_AddIcon($hImageSmall, "shell32.dll", $x)
    Next

    $a_idBtn[0] = GUICtrlCreateButton("Button1", 10, 10, 90, 50)
    _GUICtrlButton_SetImageList($a_idBtn[0], $hImage)

    $a_idRdo[0] = GUICtrlCreateRadio("Radio Button1", 120, 10, 120, 25)
    _GUICtrlButton_SetImageList($a_idRdo[0], $hImageSmall)

    $a_idChk[0] = GUICtrlCreateCheckbox("Check Button1", 260, 10, 120, 25)
    _GUICtrlButton_SetImageList($a_idChk[0], $hImageSmall)

    For $x = 1 To 5
        $a_idBtn[$x] = GUICtrlCreateButton("Button" & $x + 1, 10, $y, 90, 50)
        _GUICtrlButton_SetImageList($a_idBtn[$x], _GetImageListHandle("shell32.dll", $iIcon + $x, True), $x)
        $a_idRdo[$x] = GUICtrlCreateRadio("Radio Button" & $x + 1, 120, $y, 120, 25)
        _GUICtrlButton_SetImageList($a_idRdo[$x], _GetImageListHandle("shell32.dll", $iIcon + $x), $x)
        $a_idChk[$x] = GUICtrlCreateCheckbox("Check Button" & $x + 1, 260, $y, 120, 25)
        _GUICtrlButton_SetImageList($a_idChk[$x], _GetImageListHandle("shell32.dll", $iIcon + $x), $x)
        $y += 60
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; using image list to set 1 image and have text on button
Func _GetImageListHandle($sFile, $nIconID = 0, $bLarge = False)
    Local $iSize = 16
    If $bLarge Then $iSize = 32

    Local $hImage = _GUIImageList_Create($iSize, $iSize, 5, 3)
    If StringUpper(StringMid($sFile, StringLen($sFile) - 2)) = "BMP" Then
        _GUIImageList_AddBitmap($hImage, $sFile)
    Else
        _GUIImageList_AddIcon($hImage, $sFile, $nIconID, $bLarge)
    EndIf
    Return $hImage
EndFunc   ;==>_GetImageListHandle


Function _GUICtrlButton_SetNote

Function Reference

_GUICtrlButton_SetNote

Sets the text of the note associated with a command link button

#include <GuiButton.au3>
_GUICtrlButton_SetNote ( $hWnd, $sNote )

Parameters

$hWnd | Control ID/Handle to the control
$sNote | String that contains the note

Return Value

Success: | True.
Failure: | False.

Remarks

Windows Vista or later.

Related

_GUICtrlButton_GetNote, _GUICtrlButton_GetNoteLength

See Also

Search BCM_SETNOTE in MSDN Library.

Example

#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

; Note the controlID from these button(s) can NOT be read with GUICtrlRead

Example()

Func Example()
    Local $hGUI

    $hGUI = GUICreate("Buttons", 400, 400)
    $g_idMemo = GUICtrlCreateEdit("", 10, 65, 390, 325, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")

    Local $hBtn = _GUICtrlButton_Create($hGUI, "Button1", 10, 10, 160, 40, BitOR($BS_COMMANDLINK, $BS_DEFPUSHBUTTON, $BS_PUSHLIKE))
    _GUICtrlButton_SetNote($hBtn, "This is a test of Vista")

    GUISetState(@SW_SHOW)

    MemoWrite("Note: " & _GUICtrlButton_GetNote($hBtn))
    MemoWrite("Note Length: " & _GUICtrlButton_GetNoteLength($hBtn))
    MemoWrite("Button Text: " & _GUICtrlButton_GetText($hBtn))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlButton_SetShield

Function Reference

_GUICtrlButton_SetShield

Sets the elevation required state for a specified button or command link to display an elevated icon

#include <GuiButton.au3>
_GUICtrlButton_SetShield ( $hWnd [, $bRequired = True] )

Parameters

$hWnd | Control ID/Handle to the control
$bRequired | [optional] True to draw an elevated icon, or False otherwise

Return Value

Success: | True.
Failure: | False.

Remarks

Windows Vista or later.

See Also

Search BCM_SETSHIELD in MSDN Library.

Example

#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <WindowsConstants.au3>

; Note the controlID from these buttons can NOT be read with GUICtrlRead

Example()

Func Example()
    Local $hGUI, $hBtn, $hBtn2

    $hGUI = GUICreate("Buttons", 400, 400)

    $hBtn = _GUICtrlButton_Create($hGUI, "Button1", 10, 10, 90, 30)
    _GUICtrlButton_SetShield($hBtn)

    $hBtn2 = _GUICtrlButton_Create($hGUI, "Button2", 10, 60, 90, 30, $BS_SPLITBUTTON)
    _GUICtrlButton_SetShield($hBtn2)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example


Function _GUICtrlButton_SetSize

Function Reference

_GUICtrlButton_SetSize

Sets the size of the button

#include <GuiButton.au3>
_GUICtrlButton_SetSize ( $hWnd, $iWidth, $iHeight )

Parameters

$hWnd | Control ID/Handle to the control
$iWidth | New width of the button
$iHeight | New height of the button

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlButton_GetIdealSize

Example

#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hImage, $idBtn, $aIdealSize

    GUICreate("Buttons", 400, 400)
    $g_idMemo = GUICtrlCreateEdit("", 119, 10, 276, 374, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")

    $hImage = _GUIImageList_Create(32, 32, 5, 3, 6)
    For $x = 6 To 11
        _GUIImageList_AddIcon($hImage, "shell32.dll", $x, True)
    Next

    $idBtn = GUICtrlCreateButton("Button1", 10, 10, 90, 50)
    _GUICtrlButton_SetImageList($idBtn, $hImage)

    GUISetState(@SW_SHOW)

    $aIdealSize = _GUICtrlButton_GetIdealSize($idBtn)
    MemoWrite("Button1 Ideal width: " & $aIdealSize[0] & " height: " & $aIdealSize[1])

    Sleep(3000)

    MemoWrite(StringFormat("Set Size: %s", _GUICtrlButton_SetSize($idBtn, $aIdealSize[0], $aIdealSize[1])))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlButton_SetSplitInfo

Function Reference

_GUICtrlButton_SetSplitInfo

Gets information for a split button control

#include <GuiButton.au3>
_GUICtrlButton_SetSplitInfo ( $hWnd [, $hImlGlyph = -1 [, $iSplitStyle = $BCSS_ALIGNLEFT [, $iWidth = 0 [, $iHeight = 0]]]] )

Parameters

$hWnd | Control ID/Handle to the control
$hImlGlyph | [optional] Handle to the image list
$iSplitStyle | [optional] The split button style. Value must be one or more of the following flags. $BCSS_ALIGNLEFT - Align the image or glyph horizontally with the left margin $BCSS_IMAGE - Draw an icon image as the glyph $BCSS_NOSPLIT - No split $BCSS_STRETCH - Stretch glyph, but try to retain aspect ratio
$iWidth | [optional] Width of the glyph
$iHeight | [optional] Height of the glyph

Return Value

Success: | True.
Failure: | False.

Remarks

This function works only with the $BS_SPLITBUTTON and $BS_DEFSPLITBUTTON button styles.

Windows Vista or later.

Related

_GUICtrlButton_GetSplitInfo

See Also

Search BCM_SETSPLITINFO in MSDN Library.

Example

#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <WindowsConstants.au3>

Global $g_idBtn, $g_idMemo, $g_idBtn2

; Note the controlID from these buttons can NOT be read with GUICtrlRead

Example()

Func Example()
    Local $hGUI, $aInfo

    $hGUI = GUICreate("Buttons", 400, 400)
    $g_idMemo = GUICtrlCreateEdit("", 10, 100, 390, 284, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")

    $g_idBtn = _GUICtrlButton_Create($hGUI, "Split Button", 10, 10, 120, 30, $BS_SPLITBUTTON)
    _GUICtrlButton_SetSplitInfo($g_idBtn)
    $g_idBtn2 = _GUICtrlButton_Create($hGUI, "Split Button 2", 10, 50, 120, 30, $BS_SPLITBUTTON)

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    GUISetState(@SW_SHOW)

    $aInfo = _GUICtrlButton_GetSplitInfo($g_idBtn)
    MemoWrite("Split Info" & @CRLF & "----------------")
    For $x = 0 To 3
        MemoWrite("$ainfo[" & $x & "] = " & $aInfo[$x])
    Next
    MemoWrite("Split Info" & @CRLF & "----------------")

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local Const $BCN_HOTITEMCHANGE = -1249
    Local $tNMBHOTITEM = DllStructCreate("hwnd hWndFrom;int IDFrom;int Code;dword dwFlags", $lParam)
    Local $nNotifyCode = DllStructGetData($tNMBHOTITEM, "Code")
    Local $nID = DllStructGetData($tNMBHOTITEM, "IDFrom")
    Local $hCtrl = DllStructGetData($tNMBHOTITEM, "hWndFrom")
    Local $iFlags = DllStructGetData($tNMBHOTITEM, "dwFlags")
    Local $sText = ""

    Switch $nNotifyCode
        Case $BCN_HOTITEMCHANGE ; Win XP and Above
            If BitAND($iFlags, 0x10) = 0x10 Then
                $sText = "$BCN_HOTITEMCHANGE - Entering: " & @CRLF

            ElseIf BitAND($iFlags, 0x20) = 0x20 Then
                $sText = "$BCN_HOTITEMCHANGE - Leaving: " & @CRLF
            EndIf
            MemoWrite($sText & _
                    "-----------------------------" & @CRLF & _
                    "WM_NOTIFY - Infos:" & @CRLF & _
                    "-----------------------------" & @CRLF & _
                    "Code" & @TAB & ":" & $nNotifyCode & @CRLF & _
                    "CtrlID" & @TAB & ":" & $nID & @CRLF & _
                    "CtrlHWnd:" & $hCtrl & @CRLF & _
                    _GUICtrlButton_GetText($hCtrl) & @CRLF)
        Case $BCN_DROPDOWN
            MemoWrite("$BCN_DROPDOWN")
            _Popup_Menu($hCtrl)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _Popup_Menu($hCtrl)
    Local $hMenu
    Local Enum $e_idOpen = 1000, $e_idSave, $e_idInfo
    $hMenu = _GUICtrlMenu_CreatePopup()
    _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $e_idInfo)
    Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hCtrl, -1, -1, 1, 1, 2)
        Case $e_idOpen
            MemoWrite("Open - Selected")
        Case $e_idSave
            MemoWrite("Save - Selected")
        Case $e_idInfo
            MemoWrite("Info - Selected")
    EndSwitch
    _GUICtrlMenu_DestroyMenu($hMenu)
EndFunc   ;==>_Popup_Menu

; React on a button click
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    Local $nNotifyCode = BitShift($wParam, 16)
    Local $nID = BitAND($wParam, 0x0000FFFF)
    Local $hCtrl = $lParam
    Local $sText = ""

    Switch $hCtrl
        Case $g_idBtn, $g_idBtn2
            Switch $nNotifyCode
                Case $BN_CLICKED
                    $sText = "$BN_CLICKED" & @CRLF
                Case $BN_PAINT
                    $sText = "$BN_PAINT" & @CRLF
                Case $BN_PUSHED, $BN_HILITE
                    $sText = "$BN_PUSHED, $BN_HILITE" & @CRLF
                Case $BN_UNPUSHED, $BN_UNHILITE
                    $sText = "$BN_UNPUSHED" & @CRLF
                Case $BN_DISABLE
                    $sText = "$BN_DISABLE" & @CRLF
                Case $BN_DBLCLK, $BN_DOUBLECLICKED
                    $sText = "$BN_DBLCLK, $BN_DOUBLECLICKED" & @CRLF
                Case $BN_SETFOCUS
                    $sText = "$BN_SETFOCUS" & @CRLF
                Case $BN_KILLFOCUS
                    $sText = "$BN_KILLFOCUS" & @CRLF
            EndSwitch
            MemoWrite($sText & _
                    "-----------------------------" & @CRLF & _
                    "WM_COMMAND - Infos:" & @CRLF & _
                    "-----------------------------" & @CRLF & _
                    "Code" & @TAB & ":" & $nNotifyCode & @CRLF & _
                    "CtrlID" & @TAB & ":" & $nID & @CRLF & _
                    "CtrlHWnd:" & $hCtrl & @CRLF & _
                    _GUICtrlButton_GetText($hCtrl) & @CRLF)
            Return 0 ; Only workout clicking on the button
    EndSwitch
    ; Proceed the default AutoIt3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default AutoIt3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND


Function _GUICtrlButton_SetState

Function Reference

_GUICtrlButton_SetState

Sets the highlight state of a button. The highlight state indicates whether the button is highlighted as if the user had pushed it

#include <GuiButton.au3>
_GUICtrlButton_SetState ( $hWnd [, $bHighlighted = True] )

Parameters

$hWnd | Control ID/Handle to the control
$bHighlighted | [optional] Specifies whether the button is highlighted.

Return Value

None.

Remarks

Highlighting affects only the appearance of a button. It has no effect on the check state of a radio button or check box.

A button is automatically highlighted when the user positions the cursor over it and presses and holds the left mouse button.
The highlighting is removed when the user releases the mouse button.

Related

_GUICtrlButton_GetState, _GUICtrlButton_SetCheck

See Also

Search BM_SETSTATE in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idRdo, $idRdo2, $idChk, $idChk2, $idChk3, $idBtn, $idBtn2

    GUICreate("Buttons", 400, 400)
    $g_idMemo = GUICtrlCreateEdit("", 119, 10, 276, 374, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")

    $idBtn = GUICtrlCreateButton("Button1", 10, 10, 90, 25)
    _GUICtrlButton_SetState($idBtn)

    $idBtn2 = GUICtrlCreateButton("Button2", 10, 60, 90, 25)

    $idRdo = GUICtrlCreateRadio("Radio1", 10, 110, 90, 25)
    _GUICtrlButton_SetFocus($idRdo)

    $idRdo2 = GUICtrlCreateRadio("Radio2", 10, 170, 90, 25)
    _GUICtrlButton_SetCheck($idRdo2)

    $idChk = GUICtrlCreateCheckbox("Check1", 10, 230, 90, 25, BitOR($BS_AUTO3STATE, $BS_NOTIFY))
    _GUICtrlButton_SetCheck($idChk, $BST_INDETERMINATE)

    $idChk2 = GUICtrlCreateCheckbox("Check2", 10, 290, 90, 25, BitOR($BS_AUTO3STATE, $BS_NOTIFY))

    $idChk3 = GUICtrlCreateCheckbox("Check3", 10, 350, 90, 25, BitOR($BS_AUTO3STATE, $BS_NOTIFY))
    _GUICtrlButton_SetCheck($idChk3, $BST_CHECKED)

    GUISetState(@SW_SHOW)

    MemoWrite("Button1 status:" & @CRLF & "--------------------------------" & _
            _ExplainState(_GUICtrlButton_GetState($idBtn), True))
    MemoWrite("Button2 status:" & @CRLF & "--------------------------------" & _
            _ExplainState(_GUICtrlButton_GetState($idBtn2), True))
    MemoWrite("Radio1 status: " & @CRLF & "--------------------------------" & _
            _ExplainState(_GUICtrlButton_GetState($idRdo)))
    MemoWrite("Radio2 status: " & @CRLF & "--------------------------------" & _
            _ExplainState(_GUICtrlButton_GetState($idRdo2)))
    MemoWrite("Check1 status: " & @CRLF & "--------------------------------" & _
            _ExplainState(_GUICtrlButton_GetState($idChk)))
    MemoWrite("Check2 status: " & @CRLF & "--------------------------------" & _
            _ExplainState(_GUICtrlButton_GetState($idChk2)))
    MemoWrite("Check3 status: " & @CRLF & "--------------------------------" & _
            _ExplainState(_GUICtrlButton_GetState($idChk3)))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func _ExplainState($iState, $bPushButton = False)
    Local $sText = ""
    If Not $bPushButton And Not $iState Then Return _
            @CRLF & "Indicates the button is cleared. Same as a return value of zero." & @CRLF
    If BitAND($iState, $BST_CHECKED) = $BST_CHECKED Then _
            $sText &= @CRLF & "Indicates the button is checked." & @CRLF
    If BitAND($iState, $BST_FOCUS) = $BST_FOCUS Then _
            $sText &= @CRLF & "Specifies the focus state. A nonzero value indicates that the button has the keyboard focus." & @CRLF
    If BitAND($iState, $BST_INDETERMINATE) = $BST_INDETERMINATE Then _
            $sText &= @CRLF & "Indicates the button is grayed because the state of the button is indeterminate." & @CRLF
    If $bPushButton Then
        If BitAND($iState, $BST_PUSHED) = $BST_PUSHED Then
            $sText &= @CRLF & "Specifies the highlight state." & @CRLF
        Else
            $sText &= @CRLF & "Specifies not highlighted state." & @CRLF
        EndIf
    EndIf
    Return $sText
EndFunc   ;==>_ExplainState


Function _GUICtrlButton_SetStyle

Function Reference

_GUICtrlButton_SetStyle

Sets the style of a button

#include <GuiButton.au3>
_GUICtrlButton_SetStyle ( $hWnd, $iStyle )

Parameters

$hWnd | Control ID/Handle to the control
$iStyle | Can be a combination of button styles

Return Value

None.

See Also

Search BM_SETSTYLE in MSDN Library.

Example

#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idBtn, $idBtn2

    GUICreate("Buttons", 400, 400)
    GUISetState(@SW_SHOW)

    $idBtn = GUICtrlCreateButton("Button1", 10, 10, 90, 50)

    $idBtn2 = GUICtrlCreateButton("Button2", 10, 70, 90, 50)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Button Style")
    _GUICtrlButton_SetStyle($idBtn, $BS_AUTORADIOBUTTON)
    _GUICtrlButton_SetStyle($idBtn2, $BS_AUTOCHECKBOX)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example


Function _GUICtrlButton_SetText

Function Reference

_GUICtrlButton_SetText

Sets the text of the button

#include <GuiButton.au3>
_GUICtrlButton_SetText ( $hWnd, $sText )

Parameters

$hWnd | Control ID/Handle to the control
$sText | New text

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlButton_GetText

Example

#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $y = 70, $a_idBtn[6], $iRand

    GUICreate("Buttons", 510, 400)
    $g_idMemo = GUICtrlCreateEdit("", 119, 10, 276, 374, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $a_idBtn[0] = GUICtrlCreateButton("Button1", 10, 10, 90, 50)

    For $x = 1 To 5
        $a_idBtn[$x] = GUICtrlCreateButton("Button" & $x + 1, 10, $y, 90, 50)
        $y += 60
    Next

    $iRand = Random(0, 5, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Button" & $iRand + 1 & " Text")
    _GUICtrlButton_SetText($a_idBtn[$iRand], "New Text" & $iRand + 1)

    For $x = 0 To 5
        MemoWrite("$a_idBtn[" & $x & "] Text: " & _GUICtrlButton_GetText($a_idBtn[$x]))
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlButton_SetTextMargin

Function Reference

_GUICtrlButton_SetTextMargin

Sets the margins for drawing text in a button control

#include <GuiButton.au3>
_GUICtrlButton_SetTextMargin ( $hWnd [, $iLeft = 1 [, $iTop = 1 [, $iRight = 1 [, $iBottom = 1]]]] )

Parameters

$hWnd | Control ID/Handle to the control
$iLeft | [optional] Left margin to use for drawing text
$iTop | [optional] Top margin to use for drawing text
$iRight | [optional] Right margin to use for drawing text
$iBottom | [optional] Bottom margin to use for drawing text

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlButton_GetTextMargin

See Also

Search BCM_SETTEXTMARGIN in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $y = 70, $a_idBtn[6], $aMargins

    GUICreate("Buttons", 510, 400)
    $g_idMemo = GUICtrlCreateEdit("", 119, 10, 276, 374, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $a_idBtn[0] = GUICtrlCreateButton("Button1", 10, 10, 90, 50)
    _GUICtrlButton_SetTextMargin($a_idBtn[0], 10, 5, 10, 5)

    For $x = 1 To 5
        $a_idBtn[$x] = GUICtrlCreateButton("Button" & $x + 1, 10, $y, 90, 50)
        $y += 60
    Next

    For $x = 0 To 5
        $aMargins = _GUICtrlButton_GetTextMargin($a_idBtn[$x])
        MemoWrite("Button" & $x + 1 & " Margins:" & @CRLF & @TAB & _
                "Left.: " & $aMargins[0] & @TAB & "Top...: " & $aMargins[1] & @CRLF & @TAB & _
                "Right: " & $aMargins[2] & @TAB & "Bottom: " & $aMargins[3] & @CRLF)
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlButton_Show

Function Reference

_GUICtrlButton_Show

Show/Hide button

#include <GuiButton.au3>
_GUICtrlButton_Show ( $hWnd [, $bShow = True] )

Parameters

$hWnd | Control ID/Handle to the control
$bShow | [optional] One of the following: True - Show button False - Hide button

Return Value

Returns one of the Following:
1 - If the button was previously visible
0 - If the button was previously hidden

Example

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

Example()

Func Example()
    Local $y = 70, $a_idBtn[6], $a_idRdo[6], $a_idChk[6]

    GUICreate("Buttons", 510, 400)
    GUISetState(@SW_SHOW)

    $a_idBtn[0] = GUICtrlCreateButton("Button1", 10, 10, 90, 50)

    $a_idRdo[0] = GUICtrlCreateRadio("Radio Button1", 120, 10, 120, 25)

    $a_idChk[0] = GUICtrlCreateCheckbox("Check Button1", 260, 10, 120, 25)

    For $x = 1 To 5
        $a_idBtn[$x] = GUICtrlCreateButton("Button" & $x + 1, 10, $y, 90, 50)
        $a_idRdo[$x] = GUICtrlCreateRadio("Radio Button" & $x + 1, 120, $y, 120, 25)
        $a_idChk[$x] = GUICtrlCreateCheckbox("Check Button" & $x + 1, 260, $y, 120, 25)
        $y += 60
    Next

    ; Hide the buttons
    For $x = 0 To 5
        _GUICtrlButton_Show($a_idBtn[$x], False)
        _GUICtrlButton_Show($a_idRdo[$x], False)
        _GUICtrlButton_Show($a_idChk[$x], False)
        Sleep(500)
    Next

    ; Show the buttons
    For $x = 5 To 0 Step -1
        _GUICtrlButton_Show($a_idChk[$x])
        _GUICtrlButton_Show($a_idRdo[$x])
        _GUICtrlButton_Show($a_idBtn[$x])
        Sleep(500)
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example


User Defined Functions

GuiComboBox user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiComboBox.au3>.

User Defined Function | Description
_GUICtrlComboBox_AddDir | Adds the names of directories and files
_GUICtrlComboBox_AddString | Add a string
_GUICtrlComboBox_AutoComplete | AutoComplete a ComboBox edit control
_GUICtrlComboBox_BeginUpdate | Prevents updating of the control until the EndUpdate function is called
_GUICtrlComboBox_Create | Create a ComboBox control
_GUICtrlComboBox_DeleteString | Delete a string
_GUICtrlComboBox_Destroy | Delete the control
_GUICtrlComboBox_EndUpdate | Enables screen repainting that was turned off with the BeginUpdate function
_GUICtrlComboBox_FindString | Search for a string
_GUICtrlComboBox_FindStringExact | Search for a string
_GUICtrlComboBox_GetComboBoxInfo | Gets information about the specified ComboBox
_GUICtrlComboBox_GetCount | Retrieve the number of items
_GUICtrlComboBox_GetCueBanner | Gets the cue banner text displayed in the edit control of a combo box
_GUICtrlComboBox_GetCurSel | Retrieve the index of the currently selected item
_GUICtrlComboBox_GetDroppedControlRect | Retrieve the screen coordinates of a combo box in its dropped-down state
_GUICtrlComboBox_GetDroppedControlRectEx | Retrieve the screen coordinates of a combo box in its dropped-down state
_GUICtrlComboBox_GetDroppedState | Determines whether the ListBox of a ComboBox is dropped down
_GUICtrlComboBox_GetDroppedWidth | Retrieve the minimum allowable width, of the ListBox of a ComboBox
_GUICtrlComboBox_GetEditSel | Gets the starting and ending character positions of the current selection in the edit control of a ComboBox
_GUICtrlComboBox_GetEditText | Get the text from the edit control of a ComboBox
_GUICtrlComboBox_GetExtendedUI | Determines whether a ComboBox has the default user interface or the extended user interface
_GUICtrlComboBox_GetHorizontalExtent | Gets the width, in pixels, that the ListBox of a ComboBox control can be scrolled horizontally
_GUICtrlComboBox_GetItemHeight | Determines the height of list items or the selection field in a ComboBox
_GUICtrlComboBox_GetLBText | Retrieve a string from the list of a ComboBox
_GUICtrlComboBox_GetLBTextLen | Gets the length, in characters, of a string in the list of a combo box
_GUICtrlComboBox_GetList | Retrieves all items from the list portion of a ComboBox control
_GUICtrlComboBox_GetListArray | Retrieves all items from the list portion of a ComboBox control
_GUICtrlComboBox_GetLocale | Retrieves the current locale
_GUICtrlComboBox_GetLocaleCountry | Retrieves the current country code
_GUICtrlComboBox_GetLocaleLang | Retrieves the current language identifier
_GUICtrlComboBox_GetLocalePrimLang | Extract primary language id from a language id
_GUICtrlComboBox_GetLocaleSubLang | Extract sublanguage id from a language id
_GUICtrlComboBox_GetMinVisible | Retrieve the minimum number of visible items in the drop-down list of a ComboBox
_GUICtrlComboBox_GetTopIndex | Retrieve the 0-based index of the first visible item in the ListBox portion of a ComboBox
_GUICtrlComboBox_InitStorage | Allocates memory for storing ListBox items
_GUICtrlComboBox_InsertString | Insert a string
_GUICtrlComboBox_LimitText | Limits the length of the text the user may type into the edit control of a ComboBox
_GUICtrlComboBox_ReplaceEditSel | Replace text selected in edit box
_GUICtrlComboBox_ResetContent | Remove all items from the ListBox and edit control of a ComboBox
_GUICtrlComboBox_SelectString | Searches the ListBox of a ComboBox for an item that begins with the characters in a specified string
_GUICtrlComboBox_SetCueBanner | Sets the cue banner text that is displayed for the edit control of a combo box
_GUICtrlComboBox_SetCurSel | Select a string in the list of a ComboBox
_GUICtrlComboBox_SetDroppedWidth | Set the maximum allowable width, in pixels, of the ListBox of a ComboBox
_GUICtrlComboBox_SetEditSel | Select characters in the edit control of a ComboBox
_GUICtrlComboBox_SetEditText | Set the text of the edit control of the ComboBox
_GUICtrlComboBox_SetExtendedUI | Select either the default user interface or the extended user interface
_GUICtrlComboBox_SetHorizontalExtent | Set the width, in pixels, by which a list box can be scrolled horizontally
_GUICtrlComboBox_SetItemHeight | Set the height of list items or the selection field in a ComboBox
_GUICtrlComboBox_SetMinVisible | Set the minimum number of visible items in the drop-down list of a ComboBox
_GUICtrlComboBox_SetTopIndex | Ensure that a particular item is visible in the ListBox of a ComboBox
_GUICtrlComboBox_ShowDropDown | Show or hide the ListBox of a ComboBox


Function _GUICtrlComboBox_AddDir

Function Reference

_GUICtrlComboBox_AddDir

Adds the names of directories and files

#include <GuiComboBox.au3>
_GUICtrlComboBox_AddDir ( $hWnd, $sFilePath [, $iAttributes = 0 [, $bBrackets = True]] )

Parameters

$hWnd | Control ID/Handle to the control
$sFilePath | Specifies an absolute path, relative path, or filename
$iAttributes | [optional] Specifies the attributes of the files or directories to be added: $DDL_READWRITE - Includes read-write files with no additional attributes $DDL_READONLY - Includes read-only files $DDL_HIDDEN - Includes hidden files $DDL_SYSTEM - Includes system files $DDL_DIRECTORY - Includes directories $DDL_ARCHIVE - Includes archived files $DDL_DRIVES - All mapped drives are added to the list $DDL_EXCLUSIVE - Includes only files with the specified attributes
$bBrackets | [optional] include/exclude brackets when $DDL_DRIVES is used

Return Value

Success: | a 0-based index of the last name added.
Failure: | -1.

Remarks

If there is insufficient space to store the new strings, the return value is $CB_ERRSPACE.

Above constants require #include <DirConstants.au3>

Related

_GUICtrlComboBox_InitStorage

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Add Dir", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_AddString

Function Reference

_GUICtrlComboBox_AddString

Add a string

#include <GuiComboBox.au3>
_GUICtrlComboBox_AddString ( $hWnd, $sText )

Parameters

$hWnd | Control ID/Handle to the control
$sText | String to add

Return Value

Success: | the index of the new item.
Failure: | -1.

Related

_GUICtrlComboBox_DeleteString, _GUICtrlComboBox_InitStorage, _GUICtrlComboBox_InsertString, _GUICtrlComboBox_ResetContent

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Add String", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_AddDir($idCombo, "", $DDL_DRIVES, False)

    ; Add string
    _GUICtrlComboBox_AddString($idCombo, "This string has been added")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_AutoComplete

Function Reference

_GUICtrlComboBox_AutoComplete

AutoComplete a ComboBox edit control

#include <GuiComboBox.au3>
_GUICtrlComboBox_AutoComplete ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

None.

Example

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

Global $g_idCombo

Example()

Func Example()
    ; Create GUI
    GUICreate("ComboBox Auto Complete", 400, 296)
    $g_idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($g_idCombo)
    _GUICtrlComboBox_AddDir($g_idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($g_idCombo)

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _Edit_Changed()
    _GUICtrlComboBox_AutoComplete($g_idCombo)
EndFunc   ;==>_Edit_Changed

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode, $hWndCombo
    If Not IsHWnd($g_idCombo) Then $hWndCombo = GUICtrlGetHandle($g_idCombo)
    $hWndFrom = $lParam
    $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word
    $iCode = BitShift($wParam, 16) ; Hi Word
    Switch $hWndFrom
        Case $g_idCombo, $hWndCombo
            Switch $iCode
                Case $CBN_CLOSEUP ; Sent when the list box of a combo box has been closed
                    _DebugPrint("$CBN_CLOSEUP" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_DBLCLK ; Sent when the user double-clicks a string in the list box of a combo box
                    _DebugPrint("$CBN_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_DROPDOWN ; Sent when the list box of a combo box is about to be made visible
                    _DebugPrint("$CBN_DROPDOWN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_EDITCHANGE ; Sent after the user has taken an action that may have altered the text in the edit control portion of a combo box
                    _DebugPrint("$CBN_EDITCHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    _Edit_Changed()
                    ; no return value
                Case $CBN_EDITUPDATE ; Sent when the edit control portion of a combo box is about to display altered text
                    _DebugPrint("$CBN_EDITUPDATE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_ERRSPACE ; Sent when a combo box cannot allocate enough memory to meet a specific request
                    _DebugPrint("$CBN_ERRSPACE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_KILLFOCUS ; Sent when a combo box loses the keyboard focus
                    _DebugPrint("$CBN_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_SELCHANGE ; Sent when the user changes the current selection in the list box of a combo box
                    _DebugPrint("$CBN_SELCHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_SELENDCANCEL ; Sent when the user selects an item, but then selects another control or closes the dialog box
                    _DebugPrint("$CBN_SELENDCANCEL" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_SELENDOK ; Sent when the user selects a list item, or selects an item and then closes the list
                    _DebugPrint("$CBN_SELENDOK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_SETFOCUS ; Sent when a combo box receives the keyboard focus
                    _DebugPrint("$CBN_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlComboBox_BeginUpdate

Function Reference

_GUICtrlComboBox_BeginUpdate

Prevents updating of the control until the EndUpdate function is called

#include <GuiComboBox.au3>
_GUICtrlComboBox_BeginUpdate ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlComboBox_EndUpdate

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Begin Update", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_Create

Function Reference

_GUICtrlComboBox_Create

Create a ComboBox control

#include <GuiComboBox.au3>
_GUICtrlComboBox_Create ( $hWnd, $sText, $iX, $iY [, $iWidth = 100 [, $iHeight = 120 [, $iStyle = 0x00200042 [, $iExStyle = 0x00000000]]]] )

Parameters

$hWnd | Handle to parent or owner window
$sText | Delimited string to add to the combobox
$iX | Horizontal position of the control
$iY | Vertical position of the control
$iWidth | [optional] Control width
$iHeight | [optional] Control height
$iStyle [optional] Control style:
$CBS_AUTOHSCROLL - Automatically scrolls the text in an edit control to the right when the user types a character at the end of the line.
$CBS_DISABLENOSCROLL - Shows a disabled vertical scroll bar
$CBS_DROPDOWN - Similar to $CBS_SIMPLE, except that the list box is not displayed unless the user selects an icon next to the edit control
$CBS_DROPDOWNLIST - Similar to $CBS_DROPDOWN, except that the edit control is replaced by a static text item that displays the current selection in the list box
$CBS_LOWERCASE - Converts to lowercase all text in both the selection field and the list
$CBS_NOINTEGRALHEIGHT - Specifies that the size of the combo box is exactly the size specified by the application when it created the combo box
$CBS_OEMCONVERT - Converts text entered in the combo box edit control from the Windows character set to the OEM character set and then back to the Windows character set
$CBS_OWNERDRAWFIXED - Specifies that the owner of the list box is responsible for drawing its contents and that the items in the list box are all the same height
$CBS_OWNERDRAWVARIABLE - Specifies that the owner of the list box is responsible for drawing its contents and that the items in the list box are variable in height
$CBS_SIMPLE - Displays the list box at all times
$CBS_SORT - Automatically sorts strings added to the list box
$CBS_UPPERCASE - Converts to uppercase all text in both the selection field and the list

Default: $CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL
Forced : $WS_CHILD, $WS_TABSTOP, $WS_VISIBLE
$iExStyle | [optional] Control extended style. These correspond to the standard $WS_EX_* constants. See Extended Style Table.

Return Value

Success: | the handle to the Listbox control.
Failure: | 0.

Remarks

This function is for Advanced users and for learning how the control works.

Related

_GUICtrlComboBox_Destroy

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hCombo

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("(UDF) ComboBox Create", 400, 296)
    $g_hCombo = _GUICtrlComboBox_Create($hGUI, "", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($g_hCombo)
    _GUICtrlComboBox_AddDir($g_hCombo, "", $DDL_DRIVES, False)
    _GUICtrlComboBox_EndUpdate($g_hCombo)

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode
    $hWndFrom = $lParam
    $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word
    $iCode = BitShift($wParam, 16) ; Hi Word
    Switch $hWndFrom
        Case $g_hCombo
            Switch $iCode
                Case $CBN_CLOSEUP ; Sent when the list box of a combo box has been closed
                    _DebugPrint("$CBN_CLOSEUP" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_DBLCLK ; Sent when the user double-clicks a string in the list box of a combo box
                    _DebugPrint("$CBN_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_DROPDOWN ; Sent when the list box of a combo box is about to be made visible
                    _DebugPrint("$CBN_DROPDOWN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_EDITCHANGE ; Sent after the user has taken an action that may have altered the text in the edit control portion of a combo box
                    _DebugPrint("$CBN_EDITCHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_EDITUPDATE ; Sent when the edit control portion of a combo box is about to display altered text
                    _DebugPrint("$CBN_EDITUPDATE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_ERRSPACE ; Sent when a combo box cannot allocate enough memory to meet a specific request
                    _DebugPrint("$CBN_ERRSPACE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_KILLFOCUS ; Sent when a combo box loses the keyboard focus
                    _DebugPrint("$CBN_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_SELCHANGE ; Sent when the user changes the current selection in the list box of a combo box
                    _DebugPrint("$CBN_SELCHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_SELENDCANCEL ; Sent when the user selects an item, but then selects another control or closes the dialog box
                    _DebugPrint("$CBN_SELENDCANCEL" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_SELENDOK ; Sent when the user selects a list item, or selects an item and then closes the list
                    _DebugPrint("$CBN_SELENDOK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $CBN_SETFOCUS ; Sent when a combo box receives the keyboard focus
                    _DebugPrint("$CBN_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlComboBox_DeleteString

Function Reference

_GUICtrlComboBox_DeleteString

Delete a string

#include <GuiComboBox.au3>
_GUICtrlComboBox_DeleteString ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of string

Return Value

Success: | the count of the strings remaining.
Failure: | -1.

Related

_GUICtrlComboBox_AddString, _GUICtrlComboBox_ResetContent

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Delete String", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add drives
    _GUICtrlComboBox_AddDir($idCombo, "", $DDL_DRIVES, False)

    ;Delete string
    MsgBox($MB_SYSTEMMODAL, "Information", "Deleting string at index 1")
    _GUICtrlComboBox_DeleteString($idCombo, 1)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_Destroy

Function Reference

_GUICtrlComboBox_Destroy

Delete the control

#include <GuiComboBox.au3>
_GUICtrlComboBox_Destroy ( ByRef $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True, $hWnd is set to 0.
Failure: | False.

Remarks

Restricted to only be used on ComboBox controls created with _GUICtrlComboBox_Create().

Related

_GUICtrlComboBox_Create

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hCombo

    ; Create GUI
    $hGUI = GUICreate("(UDF Created) ComboBox Destroy", 400, 296)
    $hCombo = _GUICtrlComboBox_Create($hGUI, "", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($hCombo)
    _GUICtrlComboBox_AddDir($hCombo, "", $DDL_DRIVES, False)
    _GUICtrlComboBox_EndUpdate($hCombo)

    ; Destroy ComboBox
    MsgBox($MB_SYSTEMMODAL, "Information", "Destroy ComboBox")
    MsgBox($MB_SYSTEMMODAL, "Information", "Destroyed: " & _GUICtrlComboBox_Destroy($hCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_EndUpdate

Function Reference

_GUICtrlComboBox_EndUpdate

Enables screen repainting that was turned off with the BeginUpdate function

#include <GuiComboBox.au3>
_GUICtrlComboBox_EndUpdate ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlComboBox_BeginUpdate

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox End Update", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_FindString

Function Reference

_GUICtrlComboBox_FindString

Search for a string

#include <GuiComboBox.au3>
_GUICtrlComboBox_FindString ( $hWnd, $sText [, $iIndex = -1] )

Parameters

$hWnd | Control ID/Handle to the control
$sText | String to search for
$iIndex | [optional] 0-based index of the item preceding the first item to be searched

Return Value

Success: | a 0-based index of the matching item.
Failure: | -1.

Remarks

Finds the first string beginning with the characters specified in $sText.

When the search reaches the bottom of the ListBox, it continues from the top of the ListBox back to the item specified by $iIndex.

If $iIndex is –1, the entire ListBox is searched from the beginning.

Related

_GUICtrlComboBox_SelectString

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Find String", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, "", $DDL_DRIVES, False)
    _GUICtrlComboBox_AddString($idCombo, "This is a test")
    _GUICtrlComboBox_AddDir($idCombo, "", $DDL_DRIVES)
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Find string
    MsgBox($MB_SYSTEMMODAL, "Information", "Find String: " & _GUICtrlComboBox_FindString($idCombo, "this"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_FindStringExact

Function Reference

_GUICtrlComboBox_FindStringExact

Search for a string

#include <GuiComboBox.au3>
_GUICtrlComboBox_FindStringExact ( $hWnd, $sText [, $iIndex = -1] )

Parameters

$hWnd | Control ID/Handle to the control
$sText | String to search for
$iIndex | [optional] 0-based index of the item preceding the first item to be searched

Return Value

Success: | a 0-based index of the matching item.
Failure: | -1.

Remarks

Find the first string that matches the string specified in the $sText parameter.

When the search reaches the bottom of the ListBox, it continues from the top of the ListBox back to the item specified by $iIndex.

If $iIndex is –1, the entire ListBox is searched from the beginning.

Related

_GUICtrlComboBox_SelectString

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Find String Exact", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, "", $DDL_DRIVES, False)
    _GUICtrlComboBox_AddString($idCombo, "This is a test")
    _GUICtrlComboBox_AddDir($idCombo, "", $DDL_DRIVES)
    _GUICtrlComboBox_AddString($idCombo, "This is eXact")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Find string
    MsgBox($MB_SYSTEMMODAL, "Information", "Find String: " & _GUICtrlComboBox_FindStringExact($idCombo, "This is eXact"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_GetComboBoxInfo

Function Reference

_GUICtrlComboBox_GetComboBoxInfo

Gets information about the specified ComboBox

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetComboBoxInfo ( $hWnd, ByRef $tInfo )

Parameters

$hWnd | Control ID/Handle to the control
$tInfo | infos as defined by $tagCOMBOBOXINFO

Return Value

Success: | True.
Failure: | False.

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $tInfo, $idCombo

    ; Create GUI
    GUICreate("ComboBox Get ComboBox Info", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    If _GUICtrlComboBox_GetComboBoxInfo($idCombo, $tInfo) Then
        MemoWrite("Handle to the ComboBox .....: " & DllStructGetData($tInfo, "hCombo"))
        MemoWrite("Handle to the Edit Box .....: " & DllStructGetData($tInfo, "hEdit"))
        MemoWrite("Handle to the drop-down list: " & DllStructGetData($tInfo, "hList"))
    EndIf

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBox_GetCount

Function Reference

_GUICtrlComboBox_GetCount

Retrieve the number of items

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetCount ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the number of items.
Failure: | -1.

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Get Count", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Get Count
    MsgBox($MB_SYSTEMMODAL, "Information", "Count: " & _GUICtrlComboBox_GetCount($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_GetCueBanner

Function Reference

_GUICtrlComboBox_GetCueBanner

Gets the cue banner text displayed in the edit control of a combo box

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetCueBanner ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the cue banner text.
Failure: | an empty string "".

Remarks

The cue banner is text that is displayed in the edit control of a combo box when there is no selection.

Windows Vista or later.

Related

_GUICtrlComboBox_SetCueBanner

Example

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

Global $g_idMemo
Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Get Count", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    _GUICtrlComboBox_SetCueBanner($idCombo, "Select an Item")
    $g_idMemo = GUICtrlCreateEdit("", 10, 50, 376, 234, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    MemoWrite("Cue Banner: " & _GUICtrlComboBox_GetCueBanner($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBox_GetCurSel

Function Reference

_GUICtrlComboBox_GetCurSel

Retrieve the index of the currently selected item

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetCurSel ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the 0-based index of the currently selected item.
Failure: | -1.

Related

_GUICtrlComboBox_SetCurSel

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Get Cur Sel", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Select Item
    _GUICtrlComboBox_SetCurSel($idCombo, 2)

    ; Get Cur Sel
    MsgBox($MB_SYSTEMMODAL, "Information", "Cur Sel: " & _GUICtrlComboBox_GetCurSel($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_GetDroppedControlRect

Function Reference

_GUICtrlComboBox_GetDroppedControlRect

Retrieve the screen coordinates of a combo box in its dropped-down state

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetDroppedControlRect ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an array with the following format:
[0] - X coordinate of the upper left corner of the rectangle
[1] - Y coordinate of the upper left corner of the rectangle
[2] - X coordinate of the lower right corner of the rectangle
[3] - Y coordinate of the lower right corner of the rectangle

Related

_GUICtrlComboBox_GetDroppedControlRectEx

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $aRect, $idCombo

    ; Create GUI
    GUICreate("ComboBox Get Dropped Control Rect", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Get Dropped Control Rect
    $aRect = _GUICtrlComboBox_GetDroppedControlRect($idCombo)

    MemoWrite("X coordinate of the upper left corner ......: " & $aRect[0])
    MemoWrite("Y coordinate of the upper left corner ......: " & $aRect[1])
    MemoWrite("X coordinate of the lower right corner .....: " & $aRect[2])
    MemoWrite("Y coordinate of the lower right corner .....: " & $aRect[3])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBox_GetDroppedControlRectEx

Function Reference

_GUICtrlComboBox_GetDroppedControlRectEx

Retrieve the screen coordinates of a combo box in its dropped-down state

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetDroppedControlRectEx ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns a $tagRECT structure that receives the screen coordinates.

Related

$tagRECT, _GUICtrlComboBox_GetDroppedControlRect

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $tRECT, $idCombo

    ; Create GUI
    GUICreate("ComboBox Get Dropped Control RectEx", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Get Dropped Control Rect
    $tRECT = _GUICtrlComboBox_GetDroppedControlRectEx($idCombo)

    MemoWrite("X coordinate of the upper left corner ......: " & DllStructGetData($tRECT, "Left"))
    MemoWrite("Y coordinate of the upper left corner ......: " & DllStructGetData($tRECT, "Top"))
    MemoWrite("X coordinate of the lower right corner .....: " & DllStructGetData($tRECT, "Right"))
    MemoWrite("Y coordinate of the lower right corner .....: " & DllStructGetData($tRECT, "Bottom"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBox_GetDroppedState

Function Reference

_GUICtrlComboBox_GetDroppedState

Determines whether the ListBox of a ComboBox is dropped down

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetDroppedState ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

True: | Is dropped down.
False: | Not dropped down.

Related

_GUICtrlComboBox_ShowDropDown, _GUICtrlComboBoxEx_GetDroppedWidth

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Get Dropped Stated", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; get dropped state
    MemoWrite("Dropped Down State......: " & _GUICtrlComboBox_GetDroppedState($idCombo))

    Sleep(500)

    ; show drop down
    _GUICtrlComboBox_ShowDropDown($idCombo, True)

    Sleep(500)

    ; get dropped state
    MemoWrite("Dropped Down State......: " & _GUICtrlComboBox_GetDroppedState($idCombo))

    Sleep(500)

    ; hide drop down
    _GUICtrlComboBox_ShowDropDown($idCombo)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBox_GetDroppedWidth

Function Reference

_GUICtrlComboBox_GetDroppedWidth

Retrieve the minimum allowable width, of the ListBox of a ComboBox

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetDroppedWidth ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the width, in pixels.
Failure: | -1.

Remarks

The ComboBox must have $CBS_DROPDOWN or $CBS_DROPDOWNLIST style.

Related

_GUICtrlComboBox_SetDroppedWidth, _GUICtrlComboBoxEx_GetDroppedState

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Get Dropped Width", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Get Dropped Width
    MsgBox($MB_SYSTEMMODAL, "Information", "Dropped Width: " & _GUICtrlComboBox_GetDroppedWidth($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_GetEditSel

Function Reference

_GUICtrlComboBox_GetEditSel

Gets the starting and ending character positions of the current selection in the edit control of a ComboBox

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetEditSel ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | an array in the following format: [0] - Starting position [1] - Ending position
Failure: | sets the @error flag to non-zero.

Remarks

If the message is sent to a ComboBox with the $CBS_DROPDOWN or $CBS_DROPDOWNLIST style the Function will fail.

Related

_GUICtrlComboBox_SetEditSel, _GUICtrlComboBoxEx_SetEditSel

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>

Global $g_idMemo

Example()

Func Example()
    Local $aSel, $idCombo

    ; Create GUI
    GUICreate("ComboBox Get Edit Sel", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Select Item
    _GUICtrlComboBox_SetCurSel($idCombo, 2)

    ; Set Edit Sel
    _GUICtrlComboBox_SetEditSel($idCombo, 0, 4)

    ; Get Edit Sel
    $aSel = _GUICtrlComboBox_GetEditSel($idCombo)
    MemoWrite(StringFormat("Edit Sel: %d - %d", $aSel[0], $aSel[1]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBox_GetEditText

Function Reference

_GUICtrlComboBox_GetEditText

Get the text from the edit control of a ComboBox

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetEditText ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | a string from the edit control.
Failure: | an empty string.

Remarks

If the message is sent to a ComboBox with the $CBS_DROPDOWN or $CBS_DROPDOWNLIST style the Function will fail.

Related

_GUICtrlComboBox_SetEditText, _GUICtrlComboBoxEx_SetEditText

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>

Global $g_idMemo

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Get Edit Text", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Set Edit Text
    _GUICtrlComboBox_SetEditText($idCombo, StringFormat("%d - Some New Text", Random(1, 20, 1)))

    ; Get Edit Text
    MemoWrite("Edit Text: " & _GUICtrlComboBox_GetEditText($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBox_GetExtendedUI

Function Reference

_GUICtrlComboBox_GetExtendedUI

Determines whether a ComboBox has the default user interface or the extended user interface

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetExtendedUI ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

True: | the ComboBox has the extended user interface.
False: | the ComboBox does "NOT" have the extended user interface.

Remarks

By default, the F4 key opens or closes the list and the DOWN ARROW changes the current selection.

In a ComboBox with the extended user interface, the F4 key is disabled and pressing the DOWN ARROW key opens the drop-down list

Related

_GUICtrlComboBox_SetExtendedUI

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>

Global $g_idMemo

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Get Extended UI", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Get Extended UI
    MemoWrite("Extended UI: " & _GUICtrlComboBox_GetExtendedUI($idCombo))

    ; Set Extended UI
    _GUICtrlComboBox_SetExtendedUI($idCombo, True)

    ; Get Extended UI
    MemoWrite("Extended UI: " & _GUICtrlComboBox_GetExtendedUI($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBox_GetHorizontalExtent

Function Reference

_GUICtrlComboBox_GetHorizontalExtent

Gets the width, in pixels, that the ListBox of a ComboBox control can be scrolled horizontally

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetHorizontalExtent ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the scrollable width, in pixels.

Related

_GUICtrlComboBox_SetHorizontalExtent

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Get Horizontal Extent", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296, BitOR($CBS_SIMPLE, $CBS_DISABLENOSCROLL, $WS_HSCROLL))
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Get Horizontal Extent
    MsgBox($MB_SYSTEMMODAL, "Information", "Horizontal Extent: " & _GUICtrlComboBox_GetHorizontalExtent($idCombo))

    ; Set Horizontal Extent
    _GUICtrlComboBox_SetHorizontalExtent($idCombo, 500)

    ; Get Horizontal Extent
    MsgBox($MB_SYSTEMMODAL, "Information", "Horizontal Extent: " & _GUICtrlComboBox_GetHorizontalExtent($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_GetItemHeight

Function Reference

_GUICtrlComboBox_GetItemHeight

Determines the height of list items or the selection field in a ComboBox

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetItemHeight ( $hWnd [, $iIndex = -1] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | [optional] Determines which height to get: –1 - Retrieve the height of the selection field 0 - Retrieve the height of list items

Return Value

Success: | the height, in pixels.
Failure: | -1.

Related

_GUICtrlComboBox_SetItemHeight

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>

Global $g_idMemo

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Get Item Height", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Get Item Height (selection field)
    MemoWrite("Item Height (selection field): " & _GUICtrlComboBox_GetItemHeight($idCombo))

    ; Get Item Height (list items)
    MemoWrite("Item Height (list items): " & _GUICtrlComboBox_GetItemHeight($idCombo, 0))

    ; Set Item Height (selection field)
    _GUICtrlComboBox_SetItemHeight($idCombo, 18)

    ; Set Item Height (selection field)
    _GUICtrlComboBox_SetItemHeight($idCombo, 20, 0)

    ; Get Item Height (selection field)
    MemoWrite("Item Height (selection field): " & _GUICtrlComboBox_GetItemHeight($idCombo))

    ; Get Item Height (list items)
    MemoWrite("Item Height (list items): " & _GUICtrlComboBox_GetItemHeight($idCombo, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBox_GetLBText

Function Reference

_GUICtrlComboBox_GetLBText

Retrieve a string from the list of a ComboBox

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetLBText ( $hWnd, $iIndex, ByRef $sText )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index to Retrieve from
$sText | Variable that will receive the string

Return Value

Success: | the text of the string.
Failure: | -1.

Related

_GUICtrlComboBox_GetLBTextLen

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $sText, $idCombo

    ; Create GUI
    GUICreate("ComboBox Get LB Text", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Get LB Text
    _GUICtrlComboBox_GetLBText($idCombo, 2, $sText)
    MsgBox($MB_SYSTEMMODAL, "Information", "LB Text: " & $sText)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_GetLBTextLen

Function Reference

_GUICtrlComboBox_GetLBTextLen

Gets the length, in characters, of a string in the list of a combo box

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetLBTextLen ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | index of the required entry

Return Value

Success: | the length of the string.
Failure: | -1.

Related

_GUICtrlComboBox_GetLBText

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Get LB Text Len", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Get LB Text Len
    MsgBox($MB_SYSTEMMODAL, "Information", "LB Text Len: " & _GUICtrlComboBox_GetLBTextLen($idCombo, 2))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_GetList

Function Reference

_GUICtrlComboBox_GetList

Retrieves all items from the list portion of a ComboBox control

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetList ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns a delimited string of all ComboBox items.

Remarks

Default delimiter is "|" this can be change using the Opt("GUIDataSeparatorChar", "new delimiter")

Related

_GUICtrlComboBox_GetListArray

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $aList, $idCombo
    Opt("GUIDataSeparatorChar", ",") ; set seperator char to char we want to use

    ; Create GUI
    GUICreate("ComboBox Get List", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_AddDir($idCombo, "", $DDL_DRIVES, False)

    ; Get List
    $aList = StringSplit(_GUICtrlComboBox_GetList($idCombo), ",")
    For $x = 1 To $aList[0]
        MemoWrite($aList[$x])
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBox_GetListArray

Function Reference

_GUICtrlComboBox_GetListArray

Retrieves all items from the list portion of a ComboBox control

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetListArray ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an array in the following format:
[0] - Number of items
[1] - Item 1
[2] - Item 2
[n] - Item n

Related

_GUICtrlComboBox_GetList

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $aList, $idCombo

    ; Create GUI
    GUICreate("ComboBox Get List Array", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_AddDir($idCombo, "", $DDL_DRIVES, False)

    ; Get List
    $aList = _GUICtrlComboBox_GetListArray($idCombo)
    For $x = 1 To $aList[0]
        MemoWrite($aList[$x])
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBox_GetLocale

Function Reference

_GUICtrlComboBox_GetLocale

Retrieves the current locale

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetLocale ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the high order word contains the country code and the low order word contains the language identifier.

Related

_GUICtrlComboBox_GetLocaleCountry, _GUICtrlComboBox_GetLocaleLang, _GUICtrlComboBox_GetLocalePrimLang, _GUICtrlComboBox_GetLocaleSubLang

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Get Locale", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Show locale, country code, language identifier, primary language id, sub-language id
    MsgBox($MB_SYSTEMMODAL, "Information", _
            "Locale .................: " & _GUICtrlComboBox_GetLocale($idCombo) & @CRLF & _
            "Country code ........: " & _GUICtrlComboBox_GetLocaleCountry($idCombo) & @CRLF & _
            "Language identifier..: " & _GUICtrlComboBox_GetLocaleLang($idCombo) & @CRLF & _
            "Primary Language id : " & _GUICtrlComboBox_GetLocalePrimLang($idCombo) & @CRLF & _
            "Sub-Language id ....: " & _GUICtrlComboBox_GetLocaleSubLang($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_GetLocaleCountry

Function Reference

_GUICtrlComboBox_GetLocaleCountry

Retrieves the current country code

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetLocaleCountry ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the country code of the ComboBox.

Related

_GUICtrlComboBox_GetLocale

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Get Locale Country Code", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Show locale, country code, language identifier, primary language id, sub-language id
    MsgBox($MB_SYSTEMMODAL, "Information", _
            "Locale .................: " & _GUICtrlComboBox_GetLocale($idCombo) & @CRLF & _
            "Country code ........: " & _GUICtrlComboBox_GetLocaleCountry($idCombo) & @CRLF & _
            "Language identifier..: " & _GUICtrlComboBox_GetLocaleLang($idCombo) & @CRLF & _
            "Primary Language id : " & _GUICtrlComboBox_GetLocalePrimLang($idCombo) & @CRLF & _
            "Sub-Language id ....: " & _GUICtrlComboBox_GetLocaleSubLang($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_GetLocaleLang

Function Reference

_GUICtrlComboBox_GetLocaleLang

Retrieves the current language identifier

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetLocaleLang ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the language code of the ComboBox.

Related

_GUICtrlComboBox_GetLocale

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Get Locale Country Language id", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Show locale, country code, language identifier, primary language id, sub-language id
    MsgBox($MB_SYSTEMMODAL, "Information", _
            "Locale .................: " & _GUICtrlComboBox_GetLocale($idCombo) & @CRLF & _
            "Country code ........: " & _GUICtrlComboBox_GetLocaleCountry($idCombo) & @CRLF & _
            "Language identifier..: " & _GUICtrlComboBox_GetLocaleLang($idCombo) & @CRLF & _
            "Primary Language id : " & _GUICtrlComboBox_GetLocalePrimLang($idCombo) & @CRLF & _
            "Sub-Language id ....: " & _GUICtrlComboBox_GetLocaleSubLang($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_GetLocalePrimLang

Function Reference

_GUICtrlComboBox_GetLocalePrimLang

Extract primary language id from a language id

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetLocalePrimLang ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns a primary language id.

Related

_GUICtrlComboBox_GetLocale

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Get Locale Primary Language id", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Show locale, country code, language identifier, primary language id, sub-language id
    MsgBox($MB_SYSTEMMODAL, "Information", _
            "Locale .................: " & _GUICtrlComboBox_GetLocale($idCombo) & @CRLF & _
            "Country code ........: " & _GUICtrlComboBox_GetLocaleCountry($idCombo) & @CRLF & _
            "Language identifier..: " & _GUICtrlComboBox_GetLocaleLang($idCombo) & @CRLF & _
            "Primary Language id : " & _GUICtrlComboBox_GetLocalePrimLang($idCombo) & @CRLF & _
            "Sub-Language id ....: " & _GUICtrlComboBox_GetLocaleSubLang($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_GetLocaleSubLang

Function Reference

_GUICtrlComboBox_GetLocaleSubLang

Extract sublanguage id from a language id

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetLocaleSubLang ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns a sub-Language id.

Related

_GUICtrlComboBox_GetLocale

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Get Locale Sub-Language id", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Show locale, country code, language identifier, primary language id, sub-language id
    MsgBox($MB_SYSTEMMODAL, "Information", _
            "Locale .................: " & _GUICtrlComboBox_GetLocale($idCombo) & @CRLF & _
            "Country code ........: " & _GUICtrlComboBox_GetLocaleCountry($idCombo) & @CRLF & _
            "Language identifier..: " & _GUICtrlComboBox_GetLocaleLang($idCombo) & @CRLF & _
            "Primary Language id : " & _GUICtrlComboBox_GetLocalePrimLang($idCombo) & @CRLF & _
            "Sub-Language id ....: " & _GUICtrlComboBox_GetLocaleSubLang($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_GetMinVisible

Function Reference

_GUICtrlComboBox_GetMinVisible

Retrieve the minimum number of visible items in the drop-down list of a ComboBox

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetMinVisible ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the minimal number of visible items.
Failure: | 0.

Remarks

When the number of items in the drop-down list is greater than the minimum, the combo box uses a scrollbar.

This Function is ignored if the ComboBox control has style $CBS_NOINTEGRALHEIGHT.

Related

_GUICtrlComboBox_SetMinVisible

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Get Min Visible", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Get Min Visible
    MsgBox($MB_SYSTEMMODAL, "Information", "Min Visible:" & @TAB & _GUICtrlComboBox_GetMinVisible($idCombo), 3)

    ; show drop down
    _GUICtrlComboBox_ShowDropDown($idCombo, True)

    Sleep(500)

    ; Set Min Visible
    _GUICtrlComboBox_SetMinVisible($idCombo, 50)

    ; show drop down
    _GUICtrlComboBox_ShowDropDown($idCombo)

    Sleep(500)

    _GUICtrlComboBox_ShowDropDown($idCombo, True)

    Sleep(500)

    ; Get Min Visible
    MsgBox($MB_SYSTEMMODAL, "Information", "Min Visible:" & @TAB & _GUICtrlComboBox_GetMinVisible($idCombo), 3)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_GetTopIndex

Function Reference

_GUICtrlComboBox_GetTopIndex

Retrieve the 0-based index of the first visible item in the ListBox portion of a ComboBox

#include <GuiComboBox.au3>
_GUICtrlComboBox_GetTopIndex ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the index of the first visible item in the ListBox of the ComboBox.
Failure: | -1.

Related

_GUICtrlComboBox_SetTopIndex

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Get Top Index", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296, BitOR($CBS_SIMPLE, $CBS_DISABLENOSCROLL, $WS_VSCROLL))
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Set Top Index
    _GUICtrlComboBox_SetTopIndex($idCombo, 10)

    ; Get Top Index
    MsgBox($MB_SYSTEMMODAL, "Information", "Top Index:" & @TAB & _GUICtrlComboBox_GetTopIndex($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_InitStorage

Function Reference

_GUICtrlComboBox_InitStorage

Allocates memory for storing ListBox items

#include <GuiComboBox.au3>
_GUICtrlComboBox_InitStorage ( $hWnd, $iNum, $iBytes )

Parameters

$hWnd | Control ID/Handle to the control
$iNum | Number of items to add
$iBytes | The amount of memory to allocate for item strings, in bytes

Return Value

Success: | The total number of items for which memory has been pre-allocated.
Failure: | $CB_ERRSPACE.

Remarks

Helps speed up the initialization of ComboBoxes that have a large number of items (over 100).

You can use estimates for the $iNum and $iBytes parameters.
If you overestimate, the extra memory is allocated.
If you underestimate, the normal allocation is used for items that exceed the requested amount.

Related

_GUICtrlComboBox_AddDir, _GUICtrlComboBox_AddString, _GUICtrlComboBox_InsertString

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Init Storage", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Init Storaged
    MsgBox($MB_SYSTEMMODAL, "Information", "Pre-Allocated Memory For: " & _GUICtrlComboBox_InitStorage($idCombo, 50, 500) & " items")

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_InsertString

Function Reference

_GUICtrlComboBox_InsertString

Insert a string

#include <GuiComboBox.au3>
_GUICtrlComboBox_InsertString ( $hWnd, $sText [, $iIndex = -1] )

Parameters

$hWnd | Control ID/Handle to the control
$sText | Text string to be inserted
$iIndex | [optional] Specifies the 0-based index of the position at which to insert the string.

Return Value

Success: | a 0-based index of the position at which the string was inserted.
Failure: | -1.

Remarks

If the $iIndex parameter is –1, the string is added to the end of the list.

If the ComboBox has $WS_HSCROLL style and you insert a string wider than the ComboBox, you should use the _GUICtrlComboBox_SetHorizontalExtent() function to ensure the horizontal scrollbar appears.

Related

_GUICtrlComboBox_AddString, _GUICtrlComboBox_InitStorage, _GUICtrlComboBox_SetHorizontalExtent

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Insert String", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Insert string
    _GUICtrlComboBox_InsertString($idCombo, "Some Inserted string", 0)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_LimitText

Function Reference

_GUICtrlComboBox_LimitText

Limits the length of the text the user may type into the edit control of a ComboBox

#include <GuiComboBox.au3>
_GUICtrlComboBox_LimitText ( $hWnd [, $iLimit = 0] )

Parameters

$hWnd | Control ID/Handle to the control
$iLimit | [optional] limit length of the text

Return Value

None.

Remarks

If the $iLimit parameter is zero, the text length is limited to 0x7FFFFFFE characters.

If the ComboBox does not have the $CBS_AUTOHSCROLL style, setting the text limit to be larger than the size of the edit control has no effect.

The _GUICtrlComboBox_LimitText() function limits only the text the user can enter.
It has no effect on any text already in the edit control when the message is sent, nor does it affect the length of the text copied to the edit control when a string in the ListBox is selected.

The default limit to the text a user can enter in the edit control is 30,000 characters.

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Limit Text", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Limit text in edit box
    _GUICtrlComboBox_LimitText($idCombo, 10)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_ReplaceEditSel

Function Reference

_GUICtrlComboBox_ReplaceEditSel

Replace text selected in edit box

#include <GuiComboBox.au3>
_GUICtrlComboBox_ReplaceEditSel ( $hWnd, $sText )

Parameters

$hWnd | Control ID/Handle to the control
$sText | String containing the replacement text

Return Value

None.

Remarks

If the message is sent to a ComboBox with the $CBS_DROPDOWN or $CBS_DROPDOWNLIST style the Function will fail.

Related

_GUICtrlComboBox_SetEditSel, _GUICtrlComboBox_SetEditText

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Replace Edit Sel", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Set Edit Text
    _GUICtrlComboBox_SetEditText($idCombo, "Old Edit Text")

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    Sleep(500)

    ; Set selected text in edit box
    _GUICtrlComboBox_SetEditSel($idCombo, 0, -1)

    Sleep(500)

    ; Replace the text in the edit box
    _GUICtrlComboBox_ReplaceEditSel($idCombo, "New Edit Text")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_ResetContent

Function Reference

_GUICtrlComboBox_ResetContent

Remove all items from the ListBox and edit control of a ComboBox

#include <GuiComboBox.au3>
_GUICtrlComboBox_ResetContent ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

None.

Related

_GUICtrlComboBox_AddString, _GUICtrlComboBox_DeleteString

Example

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

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Reset Content", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296, BitOR($CBS_SIMPLE, $CBS_DISABLENOSCROLL, $WS_VSCROLL))
    GUISetState(@SW_SHOW)

    ; Set Edit Text
    _GUICtrlComboBox_SetEditText($idCombo, "Edit Text")

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    Sleep(500)

    ; Reset content
    _GUICtrlComboBox_ResetContent($idCombo)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_SelectString

Function Reference

_GUICtrlComboBox_SelectString

Searches the ListBox of a ComboBox for an item that begins with the characters in a specified string

#include <GuiComboBox.au3>
_GUICtrlComboBox_SelectString ( $hWnd, $sText [, $iIndex = -1] )

Parameters

$hWnd | Control ID/Handle to the control
$sText | String that contains the characters for which to search
$iIndex | [optional] Specifies the 0-based index of the item preceding the first item to be searched

Return Value

Success: | the index of the selected item.
Failure: | -1.

Remarks

When the search reaches the bottom of the list, it continues from the top of the list back to the item specified by the wParam parameter.

If $iIndex is –1, the entire list is searched from the beginning.
A string is selected only if the characters from the starting point match the characters in the prefix string

If a matching item is found, it is selected and copied to the edit control.

Related

_GUICtrlComboBox_FindString, _GUICtrlComboBox_FindStringExact, _GUICtrlComboBoxEx_FindStringExact

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Select String", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296, BitOR($CBS_SIMPLE, $CBS_DISABLENOSCROLL, $WS_VSCROLL))
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    ; Add string
    _GUICtrlComboBox_AddString($idCombo, "This string has been added")
    ; Add files
    _GUICtrlComboBox_AddDir($idCombo, "", $DDL_DRIVES, False)
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; select string
    _GUICtrlComboBox_SelectString($idCombo, "This")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_SetCueBanner

Function Reference

_GUICtrlComboBox_SetCueBanner

Sets the cue banner text that is displayed for the edit control of a combo box

#include <GuiComboBox.au3>
_GUICtrlComboBox_SetCueBanner ( $hWnd, $sText )

Parameters

$hWnd | Control ID/Handle to the control
$sText | String that contains the text

Return Value

Success: | True.
Failure: | False.

Remarks

The cue banner is text that is displayed in the edit control of a combo box when there is no selection.

Windows Vista or later.

Related

_GUICtrlComboBox_GetCueBanner

Example

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

Global $g_idMemo
Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Set Cue Banner", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    _GUICtrlComboBox_SetCueBanner($idCombo, "Select an Item")
    $g_idMemo = GUICtrlCreateEdit("", 10, 50, 376, 234, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    MemoWrite("Cue Banner: " & _GUICtrlComboBox_GetCueBanner($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBox_SetCurSel

Function Reference

_GUICtrlComboBox_SetCurSel

Select a string in the list of a ComboBox

#include <GuiComboBox.au3>
_GUICtrlComboBox_SetCurSel ( $hWnd [, $iIndex = -1] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | [optional] Specifies the 0-based index of the string to select

Return Value

Success: | the index of the item selected.
Failure: | -1.

Remarks

If $iIndex is –1, any current selection in the list is removed and the edit control is cleared.

If $iIndex is greater than the number of items in the list or if $iIndex is –1, the return value is -1 and the selection is cleared.

Related

_GUICtrlComboBox_GetCurSel

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Set Cur Sel", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Select Item
    _GUICtrlComboBox_SetCurSel($idCombo, 2)

    ; Get Cur Sel
    MsgBox($MB_SYSTEMMODAL, "Information", "Cur Sel: " & _GUICtrlComboBox_GetCurSel($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_SetDroppedWidth

Function Reference

_GUICtrlComboBox_SetDroppedWidth

Set the maximum allowable width, in pixels, of the ListBox of a ComboBox

#include <GuiComboBox.au3>
_GUICtrlComboBox_SetDroppedWidth ( $hWnd, $iWidth )

Parameters

$hWnd | Control ID/Handle to the control
$iWidth | The width of the ListBox, in pixels

Return Value

Success: | the new width of the ListBox.
Failure: | -1.

Remarks

By default, the minimum allowable width of the drop-down ListBox is zero.
The width of the ListBox is either the minimum allowable width or the ComboBox width, whichever is larger.

Use $CBS_DROPDOWN or $CBS_DROPDOWNLIST style.

Related

_GUICtrlComboBox_GetDroppedWidth, _GUICtrlComboBoxEx_GetDroppedState

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Set Dropped Width", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Set Dropped Width
    _GUICtrlComboBox_SetDroppedWidth($idCombo, 500)

    ; Get Dropped Width
    MsgBox($MB_SYSTEMMODAL, "Information", "Dropped Width: " & _GUICtrlComboBox_GetDroppedWidth($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_SetEditSel

Function Reference

_GUICtrlComboBox_SetEditSel

Select characters in the edit control of a ComboBox

#include <GuiComboBox.au3>
_GUICtrlComboBox_SetEditSel ( $hWnd, $iStart, $iStop )

Parameters

$hWnd | Control ID/Handle to the control
$iStart | Starting position
$iStop | Ending postions

Return Value

Success: | True.
Failure: | False, if the message is sent to a ComboBox with the $CBS_DROPDOWN or $CBS_DROPDOWNLIST style.

Remarks

The positions are 0-based. The first character of the edit control is in the zero position.
If $iStop is –1, all text from the starting position to the last character in the edit control is selected.

The first character after the last selected character is in the ending position.

For example, to select the first four characters of the edit control, use a starting position of 0 and an ending position of 4.

Related

_GUICtrlComboBox_GetEditSel, _GUICtrlComboBox_ReplaceEditSel

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>

Global $g_idMemo

Example()

Func Example()
    Local $aSel, $idCombo

    ; Create GUI
    GUICreate("ComboBox Set Edit Sel", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Select Item
    _GUICtrlComboBox_SetCurSel($idCombo, 2)

    ; Set Edit Sel
    _GUICtrlComboBox_SetEditSel($idCombo, 0, 4)

    ; Get Edit Sel
    $aSel = _GUICtrlComboBox_GetEditSel($idCombo)
    MemoWrite(StringFormat("Edit Sel: %d - %d", $aSel[0], $aSel[1]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBox_SetEditText

Function Reference

_GUICtrlComboBox_SetEditText

Set the text of the edit control of the ComboBox

#include <GuiComboBox.au3>
_GUICtrlComboBox_SetEditText ( $hWnd, $sText )

Parameters

$hWnd | Control ID/Handle to the control
$sText | Text to be set

Return Value

None.

Remarks

If the message is sent to a ComboBox with the $CBS_DROPDOWN or $CBS_DROPDOWNLIST style the Function will fail.

Related

_GUICtrlComboBox_GetEditText, _GUICtrlComboBox_ReplaceEditSel

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>

Global $g_idMemo

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Set Edit Text", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Set Edit Text
    _GUICtrlComboBox_SetEditText($idCombo, StringFormat("%d - Some New Text", Random(1, 20, 1)))

    ; Get Edit Text
    MemoWrite("Edit Text: " & _GUICtrlComboBox_GetEditText($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBox_SetExtendedUI

Function Reference

_GUICtrlComboBox_SetExtendedUI

Select either the default user interface or the extended user interface

#include <GuiComboBox.au3>
_GUICtrlComboBox_SetExtendedUI ( $hWnd [, $bExtended = False] )

Parameters

$hWnd | Control ID/Handle to the control
$bExtended | [optional] Specifies whether the combo box uses the extended

Return Value

Success: | True.
Failure: | False.

Remarks

By default, the F4 key opens or closes the list and the DOWN ARROW changes the current selection.

In a ComboBox with the extended user interface, the F4 key is disabled and pressing the DOWN ARROW key opens the drop-down list.

Related

_GUICtrlComboBox_GetExtendedUI

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>

Global $g_idMemo

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Set Extended UI", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Get Extended UI
    MemoWrite("Extended UI: " & _GUICtrlComboBox_GetExtendedUI($idCombo))

    ; Set Extended UI
    _GUICtrlComboBox_SetExtendedUI($idCombo, True)

    ; Get Extended UI
    MemoWrite("Extended UI: " & _GUICtrlComboBox_GetExtendedUI($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBox_SetHorizontalExtent

Function Reference

_GUICtrlComboBox_SetHorizontalExtent

Set the width, in pixels, by which a list box can be scrolled horizontally

#include <GuiComboBox.au3>
_GUICtrlComboBox_SetHorizontalExtent ( $hWnd, $iWidth )

Parameters

$hWnd | Control ID/Handle to the control
$iWidth | Specifies the scrollable width of the list box, in pixels

Return Value

None.

Remarks

If the width of the ListBox is smaller than $iWidth, the horizontal scroll bar horizontally scrolls items in the list box.

If the width of the ListBox is equal to or greater than $iWidth, the horizontal scroll bar is hidden or, if the ComboBox has the $CBS_DISABLENOSCROLL style, disabled.

Related

_GUICtrlComboBox_GetHorizontalExtent

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Set Horizontal Extent", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296, BitOR($CBS_SIMPLE, $CBS_DISABLENOSCROLL, $WS_HSCROLL))
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Get Horizontal Extent
    MsgBox($MB_SYSTEMMODAL, "Information", "Horizontal Extent: " & _GUICtrlComboBox_GetHorizontalExtent($idCombo))

    ; Set Horizontal Extent
    _GUICtrlComboBox_SetHorizontalExtent($idCombo, 500)

    ; Get Horizontal Extent
    MsgBox($MB_SYSTEMMODAL, "Information", "Horizontal Extent: " & _GUICtrlComboBox_GetHorizontalExtent($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_SetItemHeight

Function Reference

_GUICtrlComboBox_SetItemHeight

Set the height of list items or the selection field in a ComboBox

#include <GuiComboBox.au3>
_GUICtrlComboBox_SetItemHeight ( $hWnd, $iHeight [, $iComponent = -1] )

Parameters

$hWnd | Control ID/Handle to the control
$iHeight | The height, in pixels, of the combo box component identified by $iComponent
$iComponent | [optional] Use the following values: –1 - Set the height of the selection field 0 - Set the height of list items

Return Value

Success: | 0.
Failure: | -1 if height is invalid.

Related

_GUICtrlComboBox_GetItemHeight

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>

Global $g_idMemo

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Set Item Height", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Get Item Height (selection field)
    MemoWrite("Item Height (selection field): " & _GUICtrlComboBox_GetItemHeight($idCombo))

    ; Get Item Height (list items)
    MemoWrite("Item Height (list items): " & _GUICtrlComboBox_GetItemHeight($idCombo, 0))

    ; Set Item Height (selection field)
    _GUICtrlComboBox_SetItemHeight($idCombo, 18)

    ; Set Item Height (selection field)
    _GUICtrlComboBox_SetItemHeight($idCombo, 20, 0)

    ; Get Item Height (selection field)
    MemoWrite("Item Height (selection field): " & _GUICtrlComboBox_GetItemHeight($idCombo))

    ; Get Item Height (list items)
    MemoWrite("Item Height (list items): " & _GUICtrlComboBox_GetItemHeight($idCombo, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBox_SetMinVisible

Function Reference

_GUICtrlComboBox_SetMinVisible

Set the minimum number of visible items in the drop-down list of a ComboBox

#include <GuiComboBox.au3>
_GUICtrlComboBox_SetMinVisible ( $hWnd, $iMinimum )

Parameters

$hWnd | Control ID/Handle to the control
$iMinimum | Specifies the minimum number of visible items

Return Value

Success: | True.
Failure: | False.

Remarks

When the number of items in the drop-down list is greater than the minimum,the ComboBox uses a scrollbar.
By default, 30 is the minimum number of visible items.

This message is ignored if the combo box control has style $CBS_NOINTEGRALHEIGHT.

Related

_GUICtrlComboBox_GetMinVisible

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Set Min Visible", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Get Min Visible
    MsgBox($MB_SYSTEMMODAL, "Information", "Min Visible:" & @TAB & _GUICtrlComboBox_GetMinVisible($idCombo), 3)

    ; show drop down
    _GUICtrlComboBox_ShowDropDown($idCombo, True)

    Sleep(500)

    ; Set Min Visible
    _GUICtrlComboBox_SetMinVisible($idCombo, 50)

    ; show drop down
    _GUICtrlComboBox_ShowDropDown($idCombo)

    Sleep(500)

    _GUICtrlComboBox_ShowDropDown($idCombo, True)

    Sleep(500)

    ; Get Min Visible
    MsgBox($MB_SYSTEMMODAL, "Information", "Min Visible:" & @TAB & _GUICtrlComboBox_GetMinVisible($idCombo), 3)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_SetTopIndex

Function Reference

_GUICtrlComboBox_SetTopIndex

Ensure that a particular item is visible in the ListBox of a ComboBox

#include <GuiComboBox.au3>
_GUICtrlComboBox_SetTopIndex ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Specifies the 0-based index of the list item

Return Value

Success: | True.
Failure: | False.

Remarks

The system scrolls the ListBox contents so that either the specified item appears at the top of the list box or the maximum scroll range has been reached.

Related

_GUICtrlComboBox_GetTopIndex

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Set Top Index", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296, BitOR($CBS_SIMPLE, $CBS_DISABLENOSCROLL, $WS_VSCROLL))
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; Set Top Index
    _GUICtrlComboBox_SetTopIndex($idCombo, 10)

    ; Get Top Index
    MsgBox($MB_SYSTEMMODAL, "Information", "Top Index:" & @TAB & _GUICtrlComboBox_GetTopIndex($idCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlComboBox_ShowDropDown

Function Reference

_GUICtrlComboBox_ShowDropDown

Show or hide the ListBox of a ComboBox

#include <GuiComboBox.au3>
_GUICtrlComboBox_ShowDropDown ( $hWnd [, $bShow = False] )

Parameters

$hWnd | Control ID/Handle to the control
$bShow | [optional] Specifies whether the drop-down ListBox is to be shown or hidden: True - Show ListBox False - Hide ListBox

Return Value

None.

Remarks

This function has no effect on a ComboBox created with the $CBS_SIMPLE style.

Related

_GUICtrlComboBox_GetDroppedState, _GUICtrlComboBoxEx_GetDroppedState

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $idCombo

    ; Create GUI
    GUICreate("ComboBox Show Drop Down", 400, 296)
    $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBox_BeginUpdate($idCombo)
    _GUICtrlComboBox_AddDir($idCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($idCombo)

    ; get dropped state
    MemoWrite("Dropped Down State......: " & _GUICtrlComboBox_GetDroppedState($idCombo))

    Sleep(500)

    ; show drop down
    _GUICtrlComboBox_ShowDropDown($idCombo, True)

    Sleep(500)

    ; get dropped state
    MemoWrite("Dropped Down State......: " & _GUICtrlComboBox_GetDroppedState($idCombo))

    Sleep(500)

    ; hide drop down
    _GUICtrlComboBox_ShowDropDown($idCombo)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


User Defined Functions

GuiComboBoxEx user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiComboBoxEx.au3>.

User Defined Function | Description
_GUICtrlComboBoxEx_AddDir | Adds the names of directories and files
_GUICtrlComboBoxEx_AddString | Add a string
_GUICtrlComboBoxEx_BeginUpdate | Prevents updating of the control until the EndUpdate function is called
_GUICtrlComboBoxEx_Create | Create a ComboBoxEx control
_GUICtrlComboBoxEx_CreateSolidBitMap | Creates a solid color bitmap
_GUICtrlComboBoxEx_DeleteString | Removes an item from a ComboBoxEx control
_GUICtrlComboBoxEx_Destroy | Delete the control
_GUICtrlComboBoxEx_EndUpdate | Enables screen repainting that was turned off with the BeginUpdate function
_GUICtrlComboBoxEx_FindStringExact | Search for a string
_GUICtrlComboBoxEx_GetComboBoxInfo | Gets information about the specified ComboBox
_GUICtrlComboBoxEx_GetComboControl | Gets the handle to the child combo box control
_GUICtrlComboBoxEx_GetCount | Retrieve the number of items
_GUICtrlComboBoxEx_GetCurSel | Retrieve the index of the currently selected item
_GUICtrlComboBoxEx_GetDroppedControlRect | Retrieve the screen coordinates of a combo box in its dropped-down state
_GUICtrlComboBoxEx_GetDroppedControlRectEx | Retrieve the screen coordinates of a combo box in its dropped-down state
_GUICtrlComboBoxEx_GetDroppedState | Determines whether the ListBox of a ComboBox is dropped down
_GUICtrlComboBoxEx_GetDroppedWidth | Retrieve the minimum allowable width, of the ListBox of a ComboBox
_GUICtrlComboBoxEx_GetEditControl | Gets the handle to the edit control portion of a ComboBoxEx control
_GUICtrlComboBoxEx_GetEditSel | Gets the starting and ending character positions of the current selection in the edit control of a ComboBox
_GUICtrlComboBoxEx_GetEditText | Get the text from the edit control of a ComboBoxEx
_GUICtrlComboBoxEx_GetExtendedStyle | Gets the extended styles that are in use for a ComboBoxEx control
_GUICtrlComboBoxEx_GetExtendedUI | Determines whether a ComboBox has the default user interface or the extended user interface
_GUICtrlComboBoxEx_GetImageList | Retrieves the handle to an image list assigned to a ComboBoxEx control
_GUICtrlComboBoxEx_GetItem | Retrieves an item's attributes
_GUICtrlComboBoxEx_GetItemEx | Retrieves some or all of an item's attributes
_GUICtrlComboBoxEx_GetItemHeight | Determines the height of list items or the selection field in a ComboBox
_GUICtrlComboBoxEx_GetItemImage | Retrieves the index of the item's icon
_GUICtrlComboBoxEx_GetItemIndent | Retrieves the number of image widths the item is indented
_GUICtrlComboBoxEx_GetItemOverlayImage | Retrieves the index of the item's overlay image icon
_GUICtrlComboBoxEx_GetItemParam | Retrieves the application specific value of the item
_GUICtrlComboBoxEx_GetItemSelectedImage | Retrieves the index of the item's selected image icon
_GUICtrlComboBoxEx_GetItemText | Retrieve a string from the list of a ComboBox
_GUICtrlComboBoxEx_GetItemTextLen | Gets the length, in characters, of a string in the list of a combo box
_GUICtrlComboBoxEx_GetList | Retrieves all items from the list portion of a ComboBox control
_GUICtrlComboBoxEx_GetListArray | Retrieves all items from the list portion of a ComboBox control
_GUICtrlComboBoxEx_GetLocale | Retrieves the current locale
_GUICtrlComboBoxEx_GetLocaleCountry | Retrieves the current country code
_GUICtrlComboBoxEx_GetLocaleLang | Retrieves the current language identifier
_GUICtrlComboBoxEx_GetLocalePrimLang | Extract primary language id from a language id
_GUICtrlComboBoxEx_GetLocaleSubLang | Extract sublanguage id from a language id
_GUICtrlComboBoxEx_GetMinVisible | Retrieve the minimum number of visible items in the drop-down list of a ComboBox
_GUICtrlComboBoxEx_GetTopIndex | Retrieve the 0-based index of the first visible item in the ListBox portion of a ComboBox
_GUICtrlComboBoxEx_GetUnicode | Retrieves if control is using Unicode
_GUICtrlComboBoxEx_InitStorage | Allocates memory for storing ListBox items
_GUICtrlComboBoxEx_InsertString | Inserts a new item in the control
_GUICtrlComboBoxEx_LimitText | Limits the length of the text the user may type into the edit control of a ComboBox
_GUICtrlComboBoxEx_ReplaceEditSel | Replace text selected in edit box
_GUICtrlComboBoxEx_ResetContent | Removes all items
_GUICtrlComboBoxEx_SetCurSel | Select a string in the list of a ComboBox
_GUICtrlComboBoxEx_SetDroppedWidth | Set the maximum allowable width, in pixels, of the ListBox of a ComboBox
_GUICtrlComboBoxEx_SetEditSel | Select characters in the edit control of a ComboBox
_GUICtrlComboBoxEx_SetEditText | Set the text of the edit control of the ComboBox
_GUICtrlComboBoxEx_SetExtendedStyle | Sets extended styles within a ComboBoxEx control
_GUICtrlComboBoxEx_SetExtendedUI | Select either the default user interface or the extended user interface
_GUICtrlComboBoxEx_SetImageList | Sets an image list for a ComboBoxEx control
_GUICtrlComboBoxEx_SetItem | Sets some or all of a item's attributes
_GUICtrlComboBoxEx_SetItemEx | Sets some or all of a item's attributes
_GUICtrlComboBoxEx_SetItemHeight | Set the height of list items or the selection field in a ComboBox
_GUICtrlComboBoxEx_SetItemImage | Sets the index of the item's icon in the control's image list
_GUICtrlComboBoxEx_SetItemIndent | Sets the number of image widths to indent the item
_GUICtrlComboBoxEx_SetItemOverlayImage | Sets the index of the item's overlay icon in the control's image list
_GUICtrlComboBoxEx_SetItemParam | Sets the value specific to the item
_GUICtrlComboBoxEx_SetItemSelectedImage | Sets the index of the item's overlay icon in the control's image list
_GUICtrlComboBoxEx_SetMinVisible | Set the minimum number of visible items in the drop-down list of a ComboBox
_GUICtrlComboBoxEx_SetTopIndex | Ensure that a particular item is visible in the ListBox of a ComboBox
_GUICtrlComboBoxEx_SetUnicode | Sets if control is using Unicode
_GUICtrlComboBoxEx_ShowDropDown | Show or hide the ListBox of a ComboBox


Function _GUICtrlComboBoxEx_AddDir

Function Reference

_GUICtrlComboBoxEx_AddDir

Adds the names of directories and files

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_AddDir ( $hWnd, $sFilePath [, $iAttributes = 0 [, $bBrackets = True]] )

Parameters

$hWnd | Handle to the control
$sFilePath | Specifies an absolute path, relative path, or filename
$iAttributes | [optional] Specifies the attributes of the files or directories to be added: $DDL_READWRITE - Includes read-write files with no additional attributes $DDL_READONLY - Includes read-only files $DDL_HIDDEN - Includes hidden files $DDL_SYSTEM - Includes system files $DDL_DIRECTORY - Includes subdirectories $DDL_ARCHIVE - Includes archived files $DDL_DRIVES - All mapped drives are added to the list $DDL_EXCLUSIVE - Includes only files with the specified attributes
$bBrackets | [optional] include/exclude brackets when $DDL_DRIVES is used

Return Value

Success: | a 0-based index of the last name added.
Failure: | -1.

Remarks

If there is insufficient space to store the new strings, the return value is $CB_ERRSPACE.

Above constants require #include <DirConstants.au3>

Related

_GUICtrlComboBoxEx_InitStorage

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Add Dir", 400, 300, -1, -1, -1)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUICtrlCreateInput("Input control", 2, 30, 120)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    _GUICtrlComboBoxEx_AddDir($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_AddString

Function Reference

_GUICtrlComboBoxEx_AddString

Add a string

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_AddString ( $hWnd, $sText [, $iImage = -1 [, $iSelectedImage = -1 [, $iOverlayImage = -1 [, $iIndent = -1 [, $iParam = -1]]]]] )

Parameters

$hWnd | Handle to the control
$sText | Item text. If set to -1, the item set is set via the $CBEN_GETDISPINFO notification message.
$iImage | [optional] 0-based index of the item's icon in the control's image list
$iSelectedImage | [optional] 0-based index of the item's icon in the control's image list
$iOverlayImage | [optional] 0-based index of the item's icon in the control's image list
$iIndent | [optional] Number of image widths to indent the item. A single indentation equals the width of an image.
$iParam | [optional] Value specific to the item

Return Value

Success: | the index of the new item.
Failure: | -1.

Related

_GUICtrlComboBoxEx_DeleteString, _GUICtrlComboBoxEx_InitStorage

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Add String", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    For $x = 0 To 146
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", $x)
    Next
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_InitStorage($hCombo, 150, 300)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 149
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 200, 1)), $x, $x)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_BeginUpdate

Function Reference

_GUICtrlComboBoxEx_BeginUpdate

Prevents updating of the control until the EndUpdate function is called

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_BeginUpdate ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlComboBoxEx_EndUpdate

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Begin Update", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    For $x = 0 To 146
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", $x)
    Next
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_InitStorage($hCombo, 150, 300)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 149
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 200, 1)), $x, $x)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_Create

Function Reference

_GUICtrlComboBoxEx_Create

Create a ComboBoxEx control

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_Create ( $hWnd, $sText, $iX, $iY [, $iWidth = 100 [, $iHeight = 200 [, $iStyle = 0x00200002 [, $iExStyle = 0x00000000]]]] )

Parameters

$hWnd | Handle to parent or owner window
$sText | Delimited text to add to ComboBox
$iX | Horizontal position of the control
$iY | Vertical position of the control
$iWidth | [optional] Control width
$iHeight | [optional] Control height
$iStyle | [optional] Control style: $CBS_DROPDOWN - Similar to $CBS_SIMPLE, except that the list box is not displayed unless the user selects an icon next to the edit control $CBS_DROPDOWNLIST - Similar to $CBS_DROPDOWN, except that the edit control is replaced by a static text item that displays the current selection in the list box $CBS_SIMPLE - Displays the list box at all times Default: $CBS_DROPDOWN, $WS_VSCROLL Forced : $WS_CHILD, $WS_TABSTOP, $WS_VISIBLE
$iExStyle | [optional] Control extended style: $CBES_EX_CASESENSITIVE - Searches in the list will be case sensitive $CBES_EX_NOEDITIMAGE - The edit box and the dropdown list will not display item images $CBES_EX_NOEDITIMAGEINDENT - The edit box and the dropdown list will not display item images $CBES_EX_NOSIZELIMIT - Allows the ComboBoxEx control to be vertically sized smaller than its contained combo box control

Return Value

Success: | the handle to the Listbox control.
Failure: | 0.

Related

_GUICtrlComboBoxEx_Destroy

Example

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

Global $g_hCombo

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Create", 400, 300)
    $g_hCombo = _GUICtrlComboBoxEx_Create($hGUI, "This is a test|Line 2", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    _GUICtrlComboBoxEx_AddString($g_hCombo, "Some More Text")
    _GUICtrlComboBoxEx_InsertString($g_hCombo, "Inserted Text", 1)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hCombo
            Switch $iCode
                Case $CBEN_BEGINEDIT ; Sent when the user activates the drop-down list or clicks in the control's edit box.
                    _DebugPrint("$CBEN_BEGINEDIT" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    Return 0
                Case $CBEN_DELETEITEM
                    _DebugPrint("$CBEN_DELETEITEM" & _GetComboBoxEx($lParam))
                    Return 0
                Case $CBEN_DRAGBEGINA, $CBEN_DRAGBEGINW
                    $tInfo = DllStructCreate($tagNMCBEDRAGBEGIN, $lParam)
                    If DllStructGetData($tInfo, "ItemID") Then _DebugPrint("$CBEN_DRAGBEGIN" & _GetComboBoxEx($lParam))
                    _DebugPrint("$CBEN_DRAGBEGIN" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @CRLF & _
                            "-->ItemID:" & @TAB & DllStructGetData($tInfo, "ItemID") & @CRLF & _
                            "-->Text:" & @TAB & DllStructGetData($tInfo, "Text"))
                    ; return is ignored
                Case $CBEN_ENDEDITA, $CBEN_ENDEDITW ; Sent when the user has concluded an operation within the edit box or has selected an item from the control's drop-down list.
                    $tInfo = DllStructCreate($tagNMCBEENDEDIT, $lParam)
                    _DebugPrint("$CBEN_ENDEDIT" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @CRLF & _
                            "-->fChanged:" & @TAB & DllStructGetData($tInfo, "fChanged") & @CRLF & _
                            "-->NewSelection:" & @TAB & DllStructGetData($tInfo, "NewSelection") & @CRLF & _
                            "-->Text:" & @TAB & DllStructGetData($tInfo, "Text") & @CRLF & _
                            "-->Why:" & @TAB & DllStructGetData($tInfo, "Why"))
                    Return False ; accept the notification and allow the control to display the selected item
                    ; Return True  ; otherwise
                Case $CBEN_GETDISPINFOA, $CBEN_GETDISPINFOW ; Sent to retrieve display information about a callback item
                    _DebugPrint("$CBEN_GETDISPINFO" & _GetComboBoxEx($lParam))
                    Return 0
                Case $CBEN_INSERTITEM
                    $tInfo = DllStructCreate($tagNMCOMBOBOXEX, $lParam)
                    Local $tBuffer = DllStructCreate("wchar Text[" & DllStructGetData($tInfo, "TextMax") & "]", DllStructGetData($tInfo, "Text"))
                    _DebugPrint("$CBEN_INSERTITEM" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @CRLF & _
                            "-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                            "-->Text:" & @TAB & DllStructGetData($tBuffer, "Text") & @CRLF & _
                            "-->TextMax:" & @TAB & DllStructGetData($tInfo, "TextMax") & @CRLF & _
                            "-->Indent:" & @TAB & DllStructGetData($tInfo, "Indent") & @CRLF & _
                            "-->Image:" & @TAB & DllStructGetData($tInfo, "Image") & @CRLF & _
                            "-->SelectedImage:" & @TAB & DllStructGetData($tInfo, "SelectedImage") & @CRLF & _
                            "-->OverlayImage:" & @TAB & DllStructGetData($tInfo, "OverlayImage") & @CRLF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    Return 0
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _GetComboBoxEx($lParam)
    Local $tInfo = DllStructCreate($tagNMCOMBOBOXEX, $lParam)
    Local $aItem = _GUICtrlComboBoxEx_GetItem($g_hCombo, DllStructGetData($tInfo, "Item"))
    Return @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @CRLF & _
            "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @CRLF & _
            "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @CRLF & _
            "-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @CRLF & _
            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
            "-->Text:" & @TAB & $aItem[0] & @CRLF & _
            "-->TextMax:" & @TAB & $aItem[1] & @CRLF & _
            "-->Indent:" & @TAB & $aItem[2] & @CRLF & _
            "-->Image:" & @TAB & $aItem[3] & @CRLF & _
            "-->SelectedImage:" & @TAB & $aItem[4] & @CRLF & _
            "-->OverlayImage:" & @TAB & $aItem[5] & @CRLF & _
            "-->Param:" & @TAB & $aItem[5]
EndFunc   ;==>_GetComboBoxEx

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlComboBoxEx_CreateSolidBitMap

Function Reference

_GUICtrlComboBoxEx_CreateSolidBitMap

Creates a solid color bitmap

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_CreateSolidBitMap ( $hWnd, $iColor, $iWidth, $iHeight )

Parameters

$hWnd | Handle to the window where the bitmap will be displayed
$iColor | The color of the bitmap, stated in RGB
$iWidth | The width of the bitmap
$iHeight | The height of the bitmap

Return Value

Returns a handle to the bitmap.

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Create Solid BitMap", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 2
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 200, 1)), $x, $x)
    Next

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_DeleteString

Function Reference

_GUICtrlComboBoxEx_DeleteString

Removes an item from a ComboBoxEx control

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_DeleteString ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based index of the Item to delete

Return Value

Returns the number of items remaining in the control.

Related

_GUICtrlComboBoxEx_AddString

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Delete String", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100, $CBS_SIMPLE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 2
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next

    ; Delete String
    MsgBox($MB_SYSTEMMODAL, "Information", "Delete String")
    _GUICtrlComboBoxEx_DeleteString($hCombo, 1)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_Destroy

Function Reference

_GUICtrlComboBoxEx_Destroy

Delete the control

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_Destroy ( ByRef $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True, $hWnd is set to 0.
Failure: | False.

Remarks

Restricted to only be used on ComboBoxEx controls created with _GUICtrlComboBoxEx_Create().

Related

_GUICtrlComboBoxEx_Create

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Destroy", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "This is a test|Line 2", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    _GUICtrlComboBoxEx_AddString($hCombo, "Some More Text")
    _GUICtrlComboBoxEx_InsertString($hCombo, "Inserted Text", 1)

    ;Destroy control
    MsgBox($MB_SYSTEMMODAL, "Information", "Destroy the control")
    _GUICtrlComboBoxEx_Destroy($hCombo)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_EndUpdate

Function Reference

_GUICtrlComboBoxEx_EndUpdate

Enables screen repainting that was turned off with the BeginUpdate function

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_EndUpdate ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlComboBoxEx_BeginUpdate

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx End Update", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    For $x = 0 To 146
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", $x)
    Next
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_InitStorage($hCombo, 150, 300)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 149
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 200, 1)), $x, $x)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_FindStringExact

Function Reference

_GUICtrlComboBoxEx_FindStringExact

Search for a string

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_FindStringExact ( $hWnd, $sText [, $iIndex = -1] )

Parameters

$hWnd | Handle to the control
$sText | String to search for
$iIndex | [optional] 0-based index of the item preceding the first item to be searched

Return Value

Success: | a 0-based index of the matching item.
Failure: | -1.

Remarks

Find the first string that matches the string specified in the $sText parameter.

When the search reaches the bottom of the ListBox, it continues from the top of the ListBox back to the item specified by $iIndex.

If $iIndex is –1, the entire ListBox is searched from the beginning.

Related

_GUICtrlComboBox_SelectString

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $sDelimiter = ";", $hCombo

    Opt("GUIDataSeparatorChar", $sDelimiter)

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Find String Exact", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "This is;mY tExT", 2, 2, 394, 100, $CBS_SIMPLE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    ; Find exact string
    MsgBox($MB_SYSTEMMODAL, "Information", "Found at: " & _GUICtrlComboBoxEx_FindStringExact($hCombo, "mY tExT"))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetComboBoxInfo

Function Reference

_GUICtrlComboBoxEx_GetComboBoxInfo

Gets information about the specified ComboBox

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetComboBoxInfo ( $hWnd, ByRef $tInfo )

Parameters

$hWnd | Handle to the control
$tInfo | The information about the ComboBox.

Return Value

Success: | True.
Failure: | False.

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $tInfo, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get ComboBox Info", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBoxEx_AddDir($hCombo, "", $DDL_DRIVES, False)
    _GUICtrlComboBoxEx_AddDir($hCombo, "", $DDL_DRIVES)
    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    _GUICtrlComboBoxEx_AddDir($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    If _GUICtrlComboBoxEx_GetComboBoxInfo($hCombo, $tInfo) Then _
            MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Edit Rect [%d][%d][%d][%d]", _
            DllStructGetData($tInfo, "EditLeft"), DllStructGetData($tInfo, "EditTop"), _
            DllStructGetData($tInfo, "EditRight"), DllStructGetData($tInfo, "EditBottom")))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetComboControl

Function Reference

_GUICtrlComboBoxEx_GetComboControl

Gets the handle to the child combo box control

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetComboControl ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns a handle to the combo box control within the ComboBoxEx control.

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Combo Control", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 5
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x)
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", _
            "Combo Control Handle: " & _GUICtrlComboBoxEx_GetComboControl($hCombo) & @CRLF & _
            "Edit Control Handle: " & _GUICtrlComboBoxEx_GetEditControl($hCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetCount

Function Reference

_GUICtrlComboBoxEx_GetCount

Retrieve the number of items

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetCount ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the number of items.
Failure: | -1.

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Count", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 5
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x)
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Count: " & _GUICtrlComboBoxEx_GetCount($hCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetCurSel

Function Reference

_GUICtrlComboBoxEx_GetCurSel

Retrieve the index of the currently selected item

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetCurSel ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the index of the item selected.
Failure: | -1.

Related

_GUICtrlComboBoxEx_SetCurSel

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Cur Sel", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100, BitOR($CBS_SIMPLE, $WS_VSCROLL, $WS_BORDER))
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_InitStorage($hCombo, 100, 320)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 99
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", $x), Random(0, 8, 1), Random(0, 8, 1), Random(0, 8, 1))
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    ; Set Cur Sel
    _GUICtrlComboBoxEx_SetCurSel($hCombo, Random(0, 99, 1))

    ; Get Cur Sel
    MsgBox($MB_SYSTEMMODAL, "Information", "Current Sel: " & _GUICtrlComboBoxEx_GetCurSel($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetDroppedControlRect

Function Reference

_GUICtrlComboBoxEx_GetDroppedControlRect

Retrieve the screen coordinates of a combo box in its dropped-down state

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetDroppedControlRect ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns an array with the following format:
[0] - X coordinate of the upper left corner of the rectangle
[1] - Y coordinate of the upper left corner of the rectangle
[2] - X coordinate of the lower right corner of the rectangle
[3] - Y coordinate of the lower right corner of the rectangle

Related

_GUICtrlComboBoxEx_GetDroppedControlRectEx

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $aRect, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Dropped Control Rect", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    _GUICtrlComboBoxEx_AddDir($hCombo, "", $DDL_DRIVES, False)
    _GUICtrlComboBoxEx_AddDir($hCombo, "", $DDL_DRIVES)
    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    _GUICtrlComboBoxEx_AddDir($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBoxEx_EndUpdate($hCombo)
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    ; Get Dropped Control Rect
    $aRect = _GUICtrlComboBoxEx_GetDroppedControlRect($hCombo)
    MsgBox($MB_SYSTEMMODAL, "Information", "Dropped Control Rect: " & StringFormat("[%d][%d][%d][%d]", $aRect[0], $aRect[1], $aRect[2], $aRect[3]))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetDroppedControlRectEx

Function Reference

_GUICtrlComboBoxEx_GetDroppedControlRectEx

Retrieve the screen coordinates of a combo box in its dropped-down state

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetDroppedControlRectEx ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns a $tagRECT structure that receives the screen coordinates.

Related

$tagRECT, _GUICtrlComboBoxEx_GetDroppedControlRect

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $tRECT, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Dropped Control RectEx", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    _GUICtrlComboBoxEx_AddDir($hCombo, "", $DDL_DRIVES, False)
    _GUICtrlComboBoxEx_AddDir($hCombo, "", $DDL_DRIVES)
    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    _GUICtrlComboBoxEx_AddDir($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBoxEx_EndUpdate($hCombo)
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    ; Get Dropped Control Rect
    $tRECT = _GUICtrlComboBoxEx_GetDroppedControlRectEx($hCombo)
    MsgBox($MB_SYSTEMMODAL, "Information", "Dropped Control Rect: " & _
            StringFormat("[%d][%d][%d][%d]", DllStructGetData($tRECT, "Left"), DllStructGetData($tRECT, "Top"), _
            DllStructGetData($tRECT, "Right"), DllStructGetData($tRECT, "Bottom")))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetDroppedState

Function Reference

_GUICtrlComboBoxEx_GetDroppedState

Determines whether the ListBox of a ComboBox is dropped down

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetDroppedState ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

True: | Is dropped down.
False: | Not dropped down.

Related

_GUICtrlComboBox_GetDroppedWidth, _GUICtrlComboBox_SetDroppedWidth, _GUICtrlComboBox_ShowDropDown, _GUICtrlComboBoxEx_ShowDropDown

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Dropped State", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next

    ; get dropped state
    MemoWrite("Dropped Down State......: " & _GUICtrlComboBoxEx_GetDroppedState($hCombo))

    Sleep(500)

    ; show drop down
    _GUICtrlComboBoxEx_ShowDropDown($hCombo, True)

    Sleep(500)

    ; get dropped state
    MemoWrite("Dropped Down State......: " & _GUICtrlComboBoxEx_GetDroppedState($hCombo))

    Sleep(500)

    ; hide drop down
    _GUICtrlComboBoxEx_ShowDropDown($hCombo)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBoxEx_GetDroppedWidth

Function Reference

_GUICtrlComboBoxEx_GetDroppedWidth

Retrieve the minimum allowable width, of the ListBox of a ComboBox

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetDroppedWidth ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the width, in pixels.
Failure: | -1.

Remarks

The ComboBox must have $CBS_DROPDOWN or $CBS_DROPDOWNLIST style.

Related

_GUICtrlComboBox_GetDroppedState, _GUICtrlComboBoxEx_SetDroppedWidth

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Dropped Width", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next

    ; get dropped width
    MemoWrite("Dropped Width......: " & _GUICtrlComboBoxEx_GetDroppedWidth($hCombo))

    Sleep(500)

    ; show drop down
    _GUICtrlComboBoxEx_ShowDropDown($hCombo, True)

    Sleep(500)

    ; hide drop down
    _GUICtrlComboBoxEx_ShowDropDown($hCombo)

    ; set Dropped Width
    _GUICtrlComboBoxEx_SetDroppedWidth($hCombo, 500)

    Sleep(500)

    ; get dropped width
    MemoWrite("Dropped Width......: " & _GUICtrlComboBoxEx_GetDroppedWidth($hCombo))

    Sleep(500)

    ; show drop down
    _GUICtrlComboBoxEx_ShowDropDown($hCombo, True)

    Sleep(500)

    ; hide drop down
    _GUICtrlComboBoxEx_ShowDropDown($hCombo)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBoxEx_GetEditControl

Function Reference

_GUICtrlComboBoxEx_GetEditControl

Gets the handle to the edit control portion of a ComboBoxEx control

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetEditControl ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns the handle to the edit control within the ComboBoxEx control if it uses the $CBS_DROPDOWN style.

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Edit Control", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 5
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x)
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", _
            "Combo Control Handle: " & _GUICtrlComboBoxEx_GetComboControl($hCombo) & @CRLF & _
            "Edit Control Handle: " & _GUICtrlComboBoxEx_GetEditControl($hCombo))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetEditSel

Function Reference

_GUICtrlComboBoxEx_GetEditSel

Gets the starting and ending character positions of the current selection in the edit control of a ComboBox

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetEditSel ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | an array in the following format: [0] - Starting position [1] - Ending position
Failure: | sets the @error flag to non-zero.

Remarks

If the message is sent to a ComboBox with the $CBS_DROPDOWN or $CBS_DROPDOWNLIST style the Function will fail.

Related

_GUICtrlComboBoxEx_SetEditSel

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hImage, $aSel, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Edit Sel", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 70, BitOR($CBS_SIMPLE, $WS_VSCROLL, $WS_BORDER))
    $g_idMemo = GUICtrlCreateEdit("", 2, 72, 396, 226, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    ; Add strings
    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next

    ;Set Cur Sel
    _GUICtrlComboBoxEx_SetCurSel($hCombo, Random(0, 8, 1))

    ;Set Edit Sel
    _GUICtrlComboBoxEx_SetEditSel($hCombo, 0, 4)

    ;Get Edit Sel
    $aSel = _GUICtrlComboBoxEx_GetEditSel($hCombo)
    MemoWrite(StringFormat("Selected: [%d][%d]", $aSel[0], $aSel[1]))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBoxEx_GetEditText

Function Reference

_GUICtrlComboBoxEx_GetEditText

Get the text from the edit control of a ComboBoxEx

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetEditText ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | a string from the edit control.
Failure: | an empty string.

Remarks

If the message is sent to a ComboBox with the $CBS_DROPDOWN or $CBS_DROPDOWNLIST style the Function will fail.

Related

_GUICtrlComboBoxEx_SetEditText

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Edit Text", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100, $CBS_SIMPLE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next

    ;Set Edit Text
    _GUICtrlComboBoxEx_SetEditText($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)))

    ;Get Edit Text
    MsgBox($MB_SYSTEMMODAL, "Information", "Edit Text: " & _GUICtrlComboBoxEx_GetEditText($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetExtendedStyle

Function Reference

_GUICtrlComboBoxEx_GetExtendedStyle

Gets the extended styles that are in use for a ComboBoxEx control

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetExtendedStyle ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns a DWORD value that contains the ComboBoxEx control extended styles in use for the control.

Related

_GUICtrlComboBoxEx_SetExtendedStyle

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Extended Style", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    ;Set Extended Style
    _GUICtrlComboBoxEx_SetExtendedStyle($hCombo, $CBES_EX_CASESENSITIVE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next

    ;Get Extended Style
    MsgBox($MB_SYSTEMMODAL, "Information", "Extend Styles found: " & _DisplayExtendStringList($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func _DisplayExtendStringList($hCombo)
    Local $sStyles = @CRLF & @CRLF & @TAB
    If (BitAND(_GUICtrlComboBoxEx_GetExtendedStyle($hCombo), $CBES_EX_CASESENSITIVE) = $CBES_EX_CASESENSITIVE) Then $sStyles &= "$CBES_EX_CASESENSITIVE" & @CRLF & @TAB
    If (BitAND(_GUICtrlComboBoxEx_GetExtendedStyle($hCombo), $CBES_EX_NOEDITIMAGE) = $CBES_EX_NOEDITIMAGE) Then $sStyles &= "$CBES_EX_NOEDITIMAGE" & @CRLF & @TAB
    If (BitAND(_GUICtrlComboBoxEx_GetExtendedStyle($hCombo), $CBES_EX_NOEDITIMAGEINDENT) = $CBES_EX_NOEDITIMAGEINDENT) Then $sStyles &= "$CBES_EX_NOEDITIMAGEINDENT" & @CRLF & @TAB
    If (BitAND(_GUICtrlComboBoxEx_GetExtendedStyle($hCombo), $CBES_EX_NOSIZELIMIT) = $CBES_EX_NOSIZELIMIT) Then $sStyles &= "$CBES_EX_NOSIZELIMIT" & @CRLF & @TAB
    ; If (BitAND(_GUICtrlComboBoxEx_GetExtendedStyle ($hCombo), $CBES_EX_PATHWORDBREAKPROC) = $CBES_EX_PATHWORDBREAKPROC) Then $sStyles &= "$CBES_EX_PATHWORDBREAKPROC"
    Return $sStyles
EndFunc   ;==>_DisplayExtendStringList


Function _GUICtrlComboBoxEx_GetExtendedUI

Function Reference

_GUICtrlComboBoxEx_GetExtendedUI

Determines whether a ComboBox has the default user interface or the extended user interface

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetExtendedUI ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

True: | the comboBox has the extended user interface.
False: | the comboBox does "NOT" have the extended user interface.

Remarks

By default, the F4 key opens or closes the list and the DOWN ARROW changes the current selection.

In a ComboBox with the extended user interface, the F4 key is disabled and pressing the DOWN ARROW key opens the drop-down list

Related

_GUICtrlComboBoxEx_SetExtendedUI

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Extended UI", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next

    ; Get Extended UI
    MemoWrite("Extended UI: " & _GUICtrlComboBoxEx_GetExtendedUI($hCombo))

    ; Set Extended UI
    _GUICtrlComboBoxEx_SetExtendedUI($hCombo, True)

    ; Get Extended UI
    MemoWrite("Extended UI: " & _GUICtrlComboBoxEx_GetExtendedUI($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBoxEx_GetImageList

Function Reference

_GUICtrlComboBoxEx_GetImageList

Retrieves the handle to an image list assigned to a ComboBoxEx control

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetImageList ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the handle to the image list.
Failure: | 0.

Related

_GUICtrlComboBoxEx_SetImageList

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Image List", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next

    ;Get Image List
    MemoWrite("ImageList Handle: " & _GUICtrlComboBoxEx_GetImageList($hCombo) & _
            " IsPtr = " & IsPtr(_GUICtrlComboBoxEx_GetImageList($hCombo)) & _
            " IsHWnd = " & IsHWnd(_GUICtrlComboBoxEx_GetImageList($hCombo)))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBoxEx_GetItem

Function Reference

_GUICtrlComboBoxEx_GetItem

Retrieves an item's attributes

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetItem ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Returns an array with the following format:
[0] - Item text
[1] - Length of Item text
[2] - Number of image widths to indent the item
[3] - 0-based item image index
[4] - 0-based item state image index
[5] - 0-based item image overlay index
[6] - Item application defined value

Related

_GUICtrlComboBoxEx_GetItemEx, _GUICtrlComboBoxEx_SetItem

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hImage, $aItem, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Item", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next

    ;Set Item indent
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 1, 1)

    $aItem = _GUICtrlComboBoxEx_GetItem($hCombo, 1)
    MemoWrite("Item Text : " & $aItem[0])
    MemoWrite("Item Len ..........................: " & $aItem[1])
    MemoWrite("# image widths to indent ..........: " & $aItem[2])
    MemoWrite("0-based item image index .......: " & $aItem[3])
    MemoWrite("0-based item state image index .: " & $aItem[4])
    MemoWrite("0-based item image overlay index: " & $aItem[5])
    MemoWrite("Item application defined value ....: " & $aItem[6])

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBoxEx_GetItemEx

Function Reference

_GUICtrlComboBoxEx_GetItemEx

Retrieves some or all of an item's attributes

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetItemEx ( $hWnd, ByRef $tItem )

Parameters

$hWnd | Handle to the control
$tItem | $tagCOMBOBOXEXITEM structure that specifies the information to retrieve

Return Value

Success: | True.
Failure: | False.

Related

$tagCOMBOBOXEXITEM, _GUICtrlComboBoxEx_GetItem, _GUICtrlComboBoxEx_SetItemEx

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hImage, $tItem, $sText, $iLen, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get ItemEx", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next

    ;Set Item indent
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 1, 1)

    ;Create Structure
    $tItem = DllStructCreate($tagCOMBOBOXEXITEM)
    ;Set Mask for what to retrieve
    DllStructSetData($tItem, "Mask", BitOR($CBEIF_IMAGE, $CBEIF_INDENT, $CBEIF_LPARAM, $CBEIF_SELECTEDIMAGE, $CBEIF_OVERLAY))
    ;Set Index of item to retrieve
    DllStructSetData($tItem, "Item", 1)

    _GUICtrlComboBoxEx_GetItemEx($hCombo, $tItem)
    $iLen = _GUICtrlComboBoxEx_GetItemText($hCombo, 1, $sText)
    MemoWrite("Item Text : " & $sText)
    MemoWrite("Item Len ..........................: " & $iLen)
    MemoWrite("# image widths to indent ..........: " & DllStructGetData($tItem, "Indent"))
    MemoWrite("0-based item image index .......: " & DllStructGetData($tItem, "Image"))
    MemoWrite("0-based item state image index .: " & DllStructGetData($tItem, "SelectedImage"))
    MemoWrite("0-based item image overlay index: " & DllStructGetData($tItem, "OverlayImage"))
    MemoWrite("Item application defined value ....: " & DllStructGetData($tItem, "Param"))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBoxEx_GetItemHeight

Function Reference

_GUICtrlComboBoxEx_GetItemHeight

Determines the height of list items or the selection field in a ComboBox

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetItemHeight ( $hWnd [, $iComponent = -1] )

Parameters

$hWnd | Handle to the control
$iComponent | [optional] Use the following values: –1 - Get the height of the selection field 0 - Get the height of list items

Return Value

Success: | the height, in pixels.
Failure: | -1.

Related

_GUICtrlComboBoxEx_SetItemHeight

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Item Height", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next

    MemoWrite("Set Item Height: " & _GUICtrlComboBoxEx_SetItemHeight($hCombo, -1, 18))
    MemoWrite("Item Height: " & _GUICtrlComboBoxEx_GetItemHeight($hCombo, -1))
    MemoWrite("Set Item Height: " & _GUICtrlComboBoxEx_SetItemHeight($hCombo, 0, 20))
    MemoWrite("Item Height: " & _GUICtrlComboBoxEx_GetItemHeight($hCombo, 0))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBoxEx_GetItemImage

Function Reference

_GUICtrlComboBoxEx_GetItemImage

Retrieves the index of the item's icon

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetItemImage ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Success: | a 0-based item image index.
Failure: | -1.

Related

_GUICtrlComboBoxEx_SetItemImage

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $iImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Item Image", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 149
        $iImage = Random(0, 8, 1)
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $iImage, $iImage)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)
    _GUICtrlComboBoxEx_SetItemImage($hCombo, 0, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 1, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 2, 2)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item Image: " & _GUICtrlComboBoxEx_GetItemImage($hCombo, 0))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetItemIndent

Function Reference

_GUICtrlComboBoxEx_GetItemIndent

Retrieves the number of image widths the item is indented

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetItemIndent ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Returns the item indention.

Related

_GUICtrlComboBoxEx_SetItemIndent

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $iImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Item Indent", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 149
        $iImage = Random(0, 8, 1)
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $iImage, $iImage)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    _GUICtrlComboBoxEx_SetItemImage($hCombo, 0, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 1, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 2, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item Indent: " & _GUICtrlComboBoxEx_GetItemIndent($hCombo, 2))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetItemOverlayImage

Function Reference

_GUICtrlComboBoxEx_GetItemOverlayImage

Retrieves the index of the item's overlay image icon

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetItemOverlayImage ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Success: | a 0-based item overlay image index.
Failure: | -1.

Related

_GUICtrlComboBoxEx_SetItemOverlayImage

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $iImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Item Overlay Image", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 149
        $iImage = Random(0, 8, 1)
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $iImage, $iImage)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    _GUICtrlComboBoxEx_SetItemImage($hCombo, 0, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 1, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 2, 1)
    _GUICtrlComboBoxEx_SetItemOverlayImage($hCombo, 2, 6)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item Overlay Image: " & _GUICtrlComboBoxEx_GetItemOverlayImage($hCombo, 2))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetItemParam

Function Reference

_GUICtrlComboBoxEx_GetItemParam

Retrieves the application specific value of the item

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetItemParam ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Returns an application specific value.

Related

_GUICtrlComboBoxEx_SetItemParam

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $iImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Item Param", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 149
        $iImage = Random(0, 8, 1)
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $iImage, $iImage)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    _GUICtrlComboBoxEx_SetItemImage($hCombo, 0, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 1, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 2, 1)
    _GUICtrlComboBoxEx_SetItemParam($hCombo, 2, 54321)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item Param: " & _GUICtrlComboBoxEx_GetItemParam($hCombo, 2))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetItemSelectedImage

Function Reference

_GUICtrlComboBoxEx_GetItemSelectedImage

Retrieves the index of the item's selected image icon

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetItemSelectedImage ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Success: | a 0-based item selected image index.
Failure: | -1.

Related

_GUICtrlComboBoxEx_SetItemSelectedImage

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $iImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Item Selected Image", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 149
        $iImage = Random(0, 8, 1)
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $iImage, $iImage)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    _GUICtrlComboBoxEx_SetItemImage($hCombo, 0, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 1, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 2, 1)
    _GUICtrlComboBoxEx_SetItemSelectedImage($hCombo, 0, 3)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item Selected Image: " & _GUICtrlComboBoxEx_GetItemSelectedImage($hCombo, 0))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetItemText

Function Reference

_GUICtrlComboBoxEx_GetItemText

Retrieve a string from the list of a ComboBox

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetItemText ( $hWnd, $iIndex, ByRef $sText )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based index to Retrieve from
$sText | Variable that will receive the string

Return Value

Success: | the length of the string.
Failure: | -1.

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $iImage, $sText, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Item Text", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 149
        $iImage = Random(0, 8, 1)
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $iImage, $iImage)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)
    _GUICtrlComboBoxEx_SetItemImage($hCombo, 0, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 1, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 2, 1)
    _GUICtrlComboBoxEx_SetItemSelectedImage($hCombo, 0, 3)

    ; Get Item Text
    _GUICtrlComboBoxEx_GetItemText($hCombo, 0, $sText)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item Text: " & $sText)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetItemTextLen

Function Reference

_GUICtrlComboBoxEx_GetItemTextLen

Gets the length, in characters, of a string in the list of a combo box

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetItemTextLen ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | index item

Return Value

Success: | the length of the string.
Failure: | -1.

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $iImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Item Text Len", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 149
        $iImage = Random(0, 8, 1)
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $iImage, $iImage)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)
    _GUICtrlComboBoxEx_SetItemImage($hCombo, 0, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 1, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 2, 1)
    _GUICtrlComboBoxEx_SetItemSelectedImage($hCombo, 0, 3)

    ; Get Item Text Len
    MsgBox($MB_SYSTEMMODAL, "Information", "Item Text Len: " & _GUICtrlComboBoxEx_GetItemTextLen($hCombo, 0))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetList

Function Reference

_GUICtrlComboBoxEx_GetList

Retrieves all items from the list portion of a ComboBox control

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetList ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns a delimited string of all ComboBox items.

Remarks

Default delimiter is "|" this can be change using the Opt("GUIDataSeparatorChar", "new delimiter").

Related

_GUICtrlComboBoxEx_GetListArray

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $aItem, $sDelimiter = ";", $hCombo

    Opt("GUIDataSeparatorChar", $sDelimiter)

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get List", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBoxEx_AddDir($hCombo, "", $DDL_DRIVES, False)

    ; Get List
    $aItem = StringSplit(_GUICtrlComboBoxEx_GetList($hCombo), $sDelimiter)

    For $x = 1 To $aItem[0]
        MemoWrite($aItem[$x])
    Next

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBoxEx_GetListArray

Function Reference

_GUICtrlComboBoxEx_GetListArray

Retrieves all items from the list portion of a ComboBox control

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetListArray ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns an array in the following format:
[0] - Number of items
[1] - Item 1
[2] - Item 2
[n] - Item n

Related

_GUICtrlComboBoxEx_GetList

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $aItem, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get List Array", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBoxEx_AddDir($hCombo, "", $DDL_DRIVES, False)

    ; Get List
    $aItem = _GUICtrlComboBoxEx_GetListArray($hCombo)

    For $x = 1 To $aItem[0]
        MemoWrite($aItem[$x])
    Next

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBoxEx_GetLocale

Function Reference

_GUICtrlComboBoxEx_GetLocale

Retrieves the current locale

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetLocale ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns the high order word contains the country code and the low order word contains the language identifier.

Related

_GUICtrlComboBoxEx_GetLocaleCountry, _GUICtrlComboBoxEx_GetLocaleLang, _GUICtrlComboBoxEx_GetLocalePrimLang, _GUICtrlComboBoxEx_GetLocaleSubLang

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Locale", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBoxEx_AddDir($hCombo, "", $DDL_DRIVES, False)

    ; Show locale, country code, language identifier, primary language id, sub-language id
    MsgBox($MB_SYSTEMMODAL, "Information", _
            "Locale .................: " & _GUICtrlComboBoxEx_GetLocale($hCombo) & @CRLF & _
            "Country code ........: " & _GUICtrlComboBoxEx_GetLocaleCountry($hCombo) & @CRLF & _
            "Language identifier..: " & _GUICtrlComboBoxEx_GetLocaleLang($hCombo) & @CRLF & _
            "Primary Language id : " & _GUICtrlComboBoxEx_GetLocalePrimLang($hCombo) & @CRLF & _
            "Sub-Language id ....: " & _GUICtrlComboBoxEx_GetLocaleSubLang($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetLocaleCountry

Function Reference

_GUICtrlComboBoxEx_GetLocaleCountry

Retrieves the current country code

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetLocaleCountry ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns the country code of the ComboBox.

Related

_GUICtrlComboBoxEx_GetLocale

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Locale Country code", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBoxEx_AddDir($hCombo, "", $DDL_DRIVES, False)

    ; Show locale, country code, language identifier, primary language id, sub-language id
    MsgBox($MB_SYSTEMMODAL, "Information", _
            "Locale .................: " & _GUICtrlComboBoxEx_GetLocale($hCombo) & @CRLF & _
            "Country code ........: " & _GUICtrlComboBoxEx_GetLocaleCountry($hCombo) & @CRLF & _
            "Language identifier..: " & _GUICtrlComboBoxEx_GetLocaleLang($hCombo) & @CRLF & _
            "Primary Language id : " & _GUICtrlComboBoxEx_GetLocalePrimLang($hCombo) & @CRLF & _
            "Sub-Language id ....: " & _GUICtrlComboBoxEx_GetLocaleSubLang($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetLocaleLang

Function Reference

_GUICtrlComboBoxEx_GetLocaleLang

Retrieves the current language identifier

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetLocaleLang ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns the language code of the ComboBox.

Related

_GUICtrlComboBoxEx_GetLocale

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Locale Country Language id", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBoxEx_AddDir($hCombo, "", $DDL_DRIVES, False)

    ; Show locale, country code, language identifier, primary language id, sub-language id
    MsgBox($MB_SYSTEMMODAL, "Information", _
            "Locale .................: " & _GUICtrlComboBoxEx_GetLocale($hCombo) & @CRLF & _
            "Country code ........: " & _GUICtrlComboBoxEx_GetLocaleCountry($hCombo) & @CRLF & _
            "Language identifier..: " & _GUICtrlComboBoxEx_GetLocaleLang($hCombo) & @CRLF & _
            "Primary Language id : " & _GUICtrlComboBoxEx_GetLocalePrimLang($hCombo) & @CRLF & _
            "Sub-Language id ....: " & _GUICtrlComboBoxEx_GetLocaleSubLang($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetLocalePrimLang

Function Reference

_GUICtrlComboBoxEx_GetLocalePrimLang

Extract primary language id from a language id

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetLocalePrimLang ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns the primary language id.

Related

_GUICtrlComboBoxEx_GetLocale

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Locale Country Primary Language id", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBoxEx_AddDir($hCombo, "", $DDL_DRIVES, False)

    ; Show locale, country code, language identifier, primary language id, sub-language id
    MsgBox($MB_SYSTEMMODAL, "Information", _
            "Locale .................: " & _GUICtrlComboBoxEx_GetLocale($hCombo) & @CRLF & _
            "Country code ........: " & _GUICtrlComboBoxEx_GetLocaleCountry($hCombo) & @CRLF & _
            "Language identifier..: " & _GUICtrlComboBoxEx_GetLocaleLang($hCombo) & @CRLF & _
            "Primary Language id : " & _GUICtrlComboBoxEx_GetLocalePrimLang($hCombo) & @CRLF & _
            "Sub-Language id ....: " & _GUICtrlComboBoxEx_GetLocaleSubLang($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetLocaleSubLang

Function Reference

_GUICtrlComboBoxEx_GetLocaleSubLang

Extract sublanguage id from a language id

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetLocaleSubLang ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns the Sub-Language id.

Related

_GUICtrlComboBoxEx_GetLocale

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Locale Country Sub-Language id", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBoxEx_AddDir($hCombo, "", $DDL_DRIVES, False)

    ; Show locale, country code, language identifier, primary language id, sub-language id
    MsgBox($MB_SYSTEMMODAL, "Information", _
            "Locale .................: " & _GUICtrlComboBoxEx_GetLocale($hCombo) & @CRLF & _
            "Country code ........: " & _GUICtrlComboBoxEx_GetLocaleCountry($hCombo) & @CRLF & _
            "Language identifier..: " & _GUICtrlComboBoxEx_GetLocaleLang($hCombo) & @CRLF & _
            "Primary Language id : " & _GUICtrlComboBoxEx_GetLocalePrimLang($hCombo) & @CRLF & _
            "Sub-Language id ....: " & _GUICtrlComboBoxEx_GetLocaleSubLang($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetMinVisible

Function Reference

_GUICtrlComboBoxEx_GetMinVisible

Retrieve the minimum number of visible items in the drop-down list of a ComboBox

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetMinVisible ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True.
Failure: | False.

Remarks

When the number of items in the drop-down list is greater than the minimum, the combo box uses a scrollbar.

This Function is ignored if the ComboBox control has style $CBS_NOINTEGRALHEIGHT.

Related

_GUICtrlComboBoxEx_SetMinVisible

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $iImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Min Visible", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_InitStorage($hCombo, 150, 300)
    _GUICtrlComboBoxEx_BeginUpdate($hCombo)

    For $x = 0 To 149
        $iImage = Random(0, 8, 1)
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $iImage, $iImage)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)
    MsgBox($MB_SYSTEMMODAL, "Information", "Min Vis.: " & _GUICtrlComboBoxEx_GetMinVisible($hCombo))
    MsgBox($MB_SYSTEMMODAL, "Information", "Set Min Vis: " & _GUICtrlComboBoxEx_SetMinVisible($hCombo, 50))
    MsgBox($MB_SYSTEMMODAL, "Information", "Min Vis.: " & _GUICtrlComboBoxEx_GetMinVisible($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetTopIndex

Function Reference

_GUICtrlComboBoxEx_GetTopIndex

Retrieve the 0-based index of the first visible item in the ListBox portion of a ComboBox

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetTopIndex ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the index of the first visible item in the ListBox of the ComboBox.
Failure: | -1.

Related

_GUICtrlComboBoxEx_SetTopIndex

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Top Index", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100, $CBS_SIMPLE)
    GUISetState(@SW_SHOW)

    _GUICtrlComboBoxEx_InitStorage($hCombo, 150, 300)
    _GUICtrlComboBoxEx_BeginUpdate($hCombo)

    For $x = 0 To 149
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    ;Set Top Index
    MsgBox($MB_SYSTEMMODAL, "Information", "Set Top Index: " & _GUICtrlComboBoxEx_SetTopIndex($hCombo, Random(50, 149, 1)))
    MsgBox($MB_SYSTEMMODAL, "Information", "Top Index: " & _GUICtrlComboBoxEx_GetTopIndex($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_GetUnicode

Function Reference

_GUICtrlComboBoxEx_GetUnicode

Retrieves if control is using Unicode

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_GetUnicode ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

True: | Using Unicode.
False: | Not using Unicode.

Related

_GUICtrlComboBoxEx_SetUnicode

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get/Set Unicode", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100, $CBS_SIMPLE)
    GUISetState(@SW_SHOW)

    _GUICtrlComboBoxEx_InitStorage($hCombo, 150, 300)
    _GUICtrlComboBoxEx_BeginUpdate($hCombo)

    For $x = 0 To 149
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    ;Set/Get Unicode
    MsgBox($MB_SYSTEMMODAL, "Information", "Set Unicode: " & _GUICtrlComboBoxEx_SetUnicode($hCombo, False))
    MsgBox($MB_SYSTEMMODAL, "Information", "Get Unicode: " & _GUICtrlComboBoxEx_GetUnicode($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_InitStorage

Function Reference

_GUICtrlComboBoxEx_InitStorage

Allocates memory for storing ListBox items

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_InitStorage ( $hWnd, $iNum, $iBytes )

Parameters

$hWnd | Handle to the control
$iNum | Number of items to add
$iBytes | The amount of memory to allocate for item strings, in bytes

Return Value

Success: | the total number of items for which memory has been pre-allocated.
Failure: | $CB_ERRSPACE.

Remarks

Helps speed up the initialization of ComboBoxes that have a large number of items (over 100).

You can use estimates for the $iNum and $iBytes parameters.
If you overestimate, the extra memory is allocated.
If you underestimate, the normal allocation is used for items that exceed the requested amount.

Related

_GUICtrlComboBoxEx_AddDir, _GUICtrlComboBoxEx_AddString, _GUICtrlComboBoxEx_InsertString

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Init Storage", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 396, 296, $CBS_SIMPLE)
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Init Storage Pre-Allocated Memory For: " & _GUICtrlComboBoxEx_InitStorage($hCombo, 150, 300) & " Items")
    _GUICtrlComboBoxEx_BeginUpdate($hCombo)

    For $x = 0 To 149
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_InsertString

Function Reference

_GUICtrlComboBoxEx_InsertString

Inserts a new item in the control

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_InsertString ( $hWnd, $sText [, $iIndex = -1 [, $iImage = -1 [, $iSelectedImage = -1 [, $iOverlayImage = -1 [, $iIndent = -1 [, $iParam = -1]]]]]] )

Parameters

$hWnd | Handle to the control
$sText | Item text. If set to -1, the item set is set via the $CBEN_GETDISPINFO notification message.
$iIndex | [optional] 0-based index at which the new string should be inserted. To insert an item at the end of the list, set the $iIndex member to -1
$iImage | [optional] 0-based index of the item's icon in the control's image list
$iSelectedImage | [optional] 0-based index of the item's icon in the control's image list
$iOverlayImage | [optional] 0-based index of the item's icon in the control's image list
$iIndent | [optional] Number of image widths to indent the item. A single indentation equals the width of an image.
$iParam | [optional] Value specific to the item

Return Value

Success: | the index of the new item.
Failure: | -1.

Related

_GUICtrlComboBoxEx_InitStorage

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Insert String", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    _GUICtrlComboBoxEx_AddDir($hCombo, "", $DDL_DRIVES, False)
    _GUICtrlComboBoxEx_AddDir($hCombo, "", $DDL_DRIVES)
    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    _GUICtrlComboBoxEx_AddDir($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBoxEx_EndUpdate($hCombo)
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    ; Insert string
    _GUICtrlComboBoxEx_InsertString($hCombo, "Text inserted", 1)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_LimitText

Function Reference

_GUICtrlComboBoxEx_LimitText

Limits the length of the text the user may type into the edit control of a ComboBox

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_LimitText ( $hWnd [, $iLimit = 0] )

Parameters

$hWnd | Handle to the control
$iLimit | [optional] Limit length of the text

Return Value

None.

Remarks

If the $iLimit parameter is zero, the text length is limited to 0x7FFFFFFE characters.

If the ComboBox does not have the $CBS_AUTOHSCROLL style, setting the text limit to be larger than the size of the edit control has no effect.

The _GUICtrlComboBox_LimitText() function limits only the text the user can enter.
It has no effect on any text already in the edit control when the message is sent, nor does it affect the length of the text copied to the edit control when a string in the ListBox is selected.

The default limit to the text a user can enter in the edit control is 30,000 characters.

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Limit Text", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    _GUICtrlComboBoxEx_AddDir($hCombo, "", $DDL_DRIVES, False)
    _GUICtrlComboBoxEx_AddDir($hCombo, "", $DDL_DRIVES)
    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    _GUICtrlComboBoxEx_AddDir($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBoxEx_EndUpdate($hCombo)
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    ; Limit Text in Edit control
    _GUICtrlComboBoxEx_LimitText($hCombo, 10)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_ReplaceEditSel

Function Reference

_GUICtrlComboBoxEx_ReplaceEditSel

Replace text selected in edit box

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_ReplaceEditSel ( $hWnd, $sText )

Parameters

$hWnd | Handle to the control
$sText | String containing the replacement text

Return Value

None.

Remarks

If the message is sent to a ComboBox with the $CBS_DROPDOWN or $CBS_DROPDOWNLIST style the Function will fail.

Related

_GUICtrlComboBoxEx_SetEditText

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Replace Edit Sel", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100, BitOR($CBS_SIMPLE, $WS_VSCROLL, $WS_BORDER))
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_InitStorage($hCombo, 150, 300)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 149
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), Random(0, 8, 1), Random(0, 8, 1), Random(0, 8, 1))
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    ; Set Cur Sel
    _GUICtrlComboBoxEx_SetCurSel($hCombo, Random(0, 149, 1))

    ;Set Edit Sel
    _GUICtrlComboBoxEx_SetEditSel($hCombo, 0, 4)

    Sleep(500)

    ; Replace Edit Sel
    _GUICtrlComboBoxEx_ReplaceEditSel($hCombo, "Replaced")

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_ResetContent

Function Reference

_GUICtrlComboBoxEx_ResetContent

Removes all items

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_ResetContent ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

None.

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Reset Content", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100, BitOR($CBS_SIMPLE, $WS_VSCROLL, $WS_BORDER))
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_InitStorage($hCombo, 150, 300)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 149
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), Random(0, 8, 1), Random(0, 8, 1), Random(0, 8, 1))
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    ; Reset Content
    MsgBox($MB_SYSTEMMODAL, "Information", "Reset Content")
    _GUICtrlComboBoxEx_ResetContent($hCombo)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_SetCurSel

Function Reference

_GUICtrlComboBoxEx_SetCurSel

Select a string in the list of a ComboBox

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_SetCurSel ( $hWnd [, $iIndex = -1] )

Parameters

$hWnd | Handle to the control
$iIndex | [optional] Specifies the 0-based index of the string to select

Return Value

Success: | True.
Failure: | False.

Remarks

If $iIndex is –1, any current selection in the list is removed and the edit control is cleared.

If $iIndex is greater than the number of items in the list or if $iIndex is –1, the return value is -1 and the selection is cleared.

Related

_GUICtrlComboBoxEx_GetCurSel

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Set Cur Sel", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100, BitOR($CBS_SIMPLE, $WS_VSCROLL, $WS_BORDER))
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_InitStorage($hCombo, 100, 200)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 99
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", $x), Random(0, 8, 1), Random(0, 8, 1), Random(0, 8, 1))
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    ; Set Cur Sel
    _GUICtrlComboBoxEx_SetCurSel($hCombo, Random(0, 99, 1))

    ; Get Cur Sel
    MsgBox($MB_SYSTEMMODAL, "Information", "Current Sel: " & _GUICtrlComboBoxEx_GetCurSel($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_SetDroppedWidth

Function Reference

_GUICtrlComboBoxEx_SetDroppedWidth

Set the maximum allowable width, in pixels, of the ListBox of a ComboBox

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_SetDroppedWidth ( $hWnd, $iWidth )

Parameters

$hWnd | Handle to the control
$iWidth | The width of the ListBox, in pixels

Return Value

Success: | the new width of the ListBox.
Failure: | -1.

Remarks

By default, the minimum allowable width of the drop-down ListBox is zero.
The width of the ListBox is either the minimum allowable width or the ComboBox width, whichever is larger.

Use $CBS_DROPDOWN or $CBS_DROPDOWNLIST style.

Related

_GUICtrlComboBoxEx_GetDroppedWidth

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Set Dropped Width", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next

    ; get dropped width
    MemoWrite("Dropped Width......: " & _GUICtrlComboBoxEx_GetDroppedWidth($hCombo))

    Sleep(500)

    ; show drop down
    _GUICtrlComboBoxEx_ShowDropDown($hCombo, True)

    Sleep(500)

    ; hide drop down
    _GUICtrlComboBoxEx_ShowDropDown($hCombo)

    ; set Dropped Width
    _GUICtrlComboBoxEx_SetDroppedWidth($hCombo, 500)

    Sleep(500)

    ; get dropped width
    MemoWrite("Dropped Width......: " & _GUICtrlComboBoxEx_GetDroppedWidth($hCombo))

    Sleep(500)

    ; show drop down
    _GUICtrlComboBoxEx_ShowDropDown($hCombo, True)

    Sleep(500)

    ; hide drop down
    _GUICtrlComboBoxEx_ShowDropDown($hCombo)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBoxEx_SetEditSel

Function Reference

_GUICtrlComboBoxEx_SetEditSel

Select characters in the edit control of a ComboBox

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_SetEditSel ( $hWnd, $iStart, $iStop )

Parameters

$hWnd | Handle to the control
$iStart | Starting position
$iStop | Ending postions

Return Value

Success: | True.
Failure: | False, if the message is sent to a ComboBox with the $CBS_DROPDOWN or $CBS_DROPDOWNLIST style.

Remarks

The positions are 0-based. The first character of the edit control is in the zero position.
If $iStop is –1, all text from the starting position to the last character in the edit control is selected.

The first character after the last selected character is in the ending position.

For example, to select the first four characters of the edit control, use a starting position of 0 and an ending position of 4.

Related

_GUICtrlComboBox_GetEditSel, _GUICtrlComboBoxEx_GetEditSel

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hImage, $aSel, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Set Edit Sel", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 70, BitOR($CBS_SIMPLE, $WS_VSCROLL, $WS_BORDER))
    $g_idMemo = GUICtrlCreateEdit("", 2, 72, 396, 226, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    ; Add strings
    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next

    ;Set Cur Sel
    _GUICtrlComboBoxEx_SetCurSel($hCombo, Random(0, 8, 1))

    ;Set Edit Sel
    _GUICtrlComboBoxEx_SetEditSel($hCombo, 0, 4)

    ;Get Edit Sel
    $aSel = _GUICtrlComboBoxEx_GetEditSel($hCombo)
    MemoWrite(StringFormat("Selected: [%d][%d]", $aSel[0], $aSel[1]))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBoxEx_SetEditText

Function Reference

_GUICtrlComboBoxEx_SetEditText

Set the text of the edit control of the ComboBox

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_SetEditText ( $hWnd, $sText )

Parameters

$hWnd | Handle to the control
$sText | Text to be set

Return Value

None.

Remarks

If the message is sent to a ComboBox with the $CBS_DROPDOWN or $CBS_DROPDOWNLIST style the Function will fail.

Related

_GUICtrlComboBox_GetEditText, _GUICtrlComboBoxEx_GetEditText, _GUICtrlComboBoxEx_ReplaceEditSel

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Set Edit Text", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100, $CBS_SIMPLE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next

    ;Set Edit Text
    _GUICtrlComboBoxEx_SetEditText($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)))

    ;Get Edit Text
    MsgBox($MB_SYSTEMMODAL, "Information", "Edit Text: " & _GUICtrlComboBoxEx_GetEditText($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_SetExtendedStyle

Function Reference

_GUICtrlComboBoxEx_SetExtendedStyle

Sets extended styles within a ComboBoxEx control

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_SetExtendedStyle ( $hWnd, $iExStyle [, $iExMask = 0] )

Parameters

$hWnd | Handle to the control
$iExStyle | Extended control styles: $CBES_EX_CASESENSITIVE - Searches in the list will be case sensitive $CBES_EX_NOEDITIMAGE - The edit box and the dropdown list will not display item images $CBES_EX_NOEDITIMAGEINDENT - The edit box and the dropdown list will not display item images $CBES_EX_NOSIZELIMIT - Allows the ComboBoxEx control to be vertically sized smaller than its contained combo box control
$iExMask | [optional] Specifies which styles in $iExStyle are to be affected. This parameter can be a combination of extended styles. Only the extended styles in $iExMask will be changed. All other styles will be maintained as they are. If this parameter is zero, all of the styles in $iExStyle will be affected.

Return Value

Returns the previous extended styles.

Related

_GUICtrlComboBoxEx_GetExtendedStyle

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Set Extended Style", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    ;Set Extended Style
    _GUICtrlComboBoxEx_SetExtendedStyle($hCombo, $CBES_EX_CASESENSITIVE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next

    ;Get Extended Style
    MsgBox($MB_SYSTEMMODAL, "Information", "Extend Styles found: " & _DisplayExtendStringList($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func _DisplayExtendStringList($hCombo)
    Local $sStyles = @CRLF & @CRLF & @TAB
    If (BitAND(_GUICtrlComboBoxEx_GetExtendedStyle($hCombo), $CBES_EX_CASESENSITIVE) = $CBES_EX_CASESENSITIVE) Then $sStyles &= "$CBES_EX_CASESENSITIVE" & @CRLF & @TAB
    If (BitAND(_GUICtrlComboBoxEx_GetExtendedStyle($hCombo), $CBES_EX_NOEDITIMAGE) = $CBES_EX_NOEDITIMAGE) Then $sStyles &= "$CBES_EX_NOEDITIMAGE" & @CRLF & @TAB
    If (BitAND(_GUICtrlComboBoxEx_GetExtendedStyle($hCombo), $CBES_EX_NOEDITIMAGEINDENT) = $CBES_EX_NOEDITIMAGEINDENT) Then $sStyles &= "$CBES_EX_NOEDITIMAGEINDENT" & @CRLF & @TAB
    If (BitAND(_GUICtrlComboBoxEx_GetExtendedStyle($hCombo), $CBES_EX_NOSIZELIMIT) = $CBES_EX_NOSIZELIMIT) Then $sStyles &= "$CBES_EX_NOSIZELIMIT" & @CRLF & @TAB
    ; If (BitAND(_GUICtrlComboBoxEx_GetExtendedStyle ($hCombo), $CBES_EX_PATHWORDBREAKPROC) = $CBES_EX_PATHWORDBREAKPROC) Then $sStyles &= "$CBES_EX_PATHWORDBREAKPROC"
    Return $sStyles
EndFunc   ;==>_DisplayExtendStringList


Function _GUICtrlComboBoxEx_SetExtendedUI

Function Reference

_GUICtrlComboBoxEx_SetExtendedUI

Select either the default user interface or the extended user interface

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_SetExtendedUI ( $hWnd [, $bExtended = False] )

Parameters

$hWnd | Handle to the control
$bExtended | [optional] Specifies whether the combo box uses the extended

Return Value

Success: | True.
Failure: | False.

Remarks

By default, the F4 key opens or closes the list and the DOWN ARROW changes the current selection.

In a ComboBox with the extended user interface, the F4 key is disabled and pressing the DOWN ARROW key opens the drop-down list.

Related

_GUICtrlComboBoxEx_GetExtendedUI

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Set Extended UI", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next

    ; Get Extended UI
    MemoWrite("Extended UI: " & _GUICtrlComboBoxEx_GetExtendedUI($hCombo))

    ; Set Extended UI
    _GUICtrlComboBoxEx_SetExtendedUI($hCombo, True)

    ; Get Extended UI
    MemoWrite("Extended UI: " & _GUICtrlComboBoxEx_GetExtendedUI($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBoxEx_SetImageList

Function Reference

_GUICtrlComboBoxEx_SetImageList

Sets an image list for a ComboBoxEx control

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_SetImageList ( $hWnd, $hHandle )

Parameters

$hWnd | Handle to the control
$hHandle | A handle to the image list to be set for the control

Return Value

Returns the handle to the image list previously associated with the control, or returns NULL if no image list was previously set.

Related

_GUICtrlComboBoxEx_GetImageList

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Set Image List", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    ;Set Image List
    Local $hPrevlist = _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)
    MemoWrite("Previous ImageList Handle: " & $hPrevlist & _
            " IsPtr = " & IsPtr($hPrevlist) & " IsHWnd = " & IsHWnd($hPrevlist))

    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next

    ;Get Image List
    MemoWrite("ImageList Handle: " & _GUICtrlComboBoxEx_GetImageList($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBoxEx_SetItem

Function Reference

_GUICtrlComboBoxEx_SetItem

Sets some or all of a item's attributes

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_SetItem ( $hWnd, $sText [, $iIndex = 0 [, $iImage = -1 [, $iSelectedImage = -1 [, $iOverlayImage = -1 [, $iIndent = -1 [, $iParam = -1]]]]]] )

Parameters

$hWnd | Handle to the control
$sText | Item text. See remark.
$iIndex | [optional] The 0-based index of the item
$iImage | [optional] 0-based index of the item's icon in the control's image list
$iSelectedImage | [optional] 0-based index of the item's icon in the control's image list
$iOverlayImage | [optional] 0-based index of the item's icon in the control's image list
$iIndent | [optional] Number of image widths to indent the item. A single indentation equals the width of an image.
$iParam | [optional] Value specific to the item

Return Value

Success: | True.
Failure: | False.

Remarks

If a notification callback is needed, you have to specify $sText = -1 (LPSTR_TEXTCALLBACK).

Related

_GUICtrlComboBoxEx_GetItem, _GUICtrlComboBoxEx_SetItemEx

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $iImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Set Item", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_InitStorage($hCombo, 150, 300)
    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 149
        $iImage = Random(0, 8, 1)
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $iImage, $iImage)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    ; Change item 2
    MsgBox($MB_SYSTEMMODAL, "Information", "Changing item 2")
    _GUICtrlComboBoxEx_SetItem($hCombo, "New Item 2", 1)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_SetItemEx

Function Reference

_GUICtrlComboBoxEx_SetItemEx

Sets some or all of a item's attributes

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_SetItemEx ( $hWnd, ByRef $tItem )

Parameters

$hWnd | Handle to the control
$tItem | $tagCOMBOBOXEXITEM structure

Return Value

Success: | True.
Failure: | False.

Remarks

To set the attributes of an item set the Item member of the $tagCOMBOBOXEXITEM structure to the index of the item.
For an item, you can set the Image, SelectedImage, OverlayImage, Ident, and Param members of the $tagCOMBOBOXEXITEM structure.

Related

$tagCOMBOBOXEXITEM, _GUICtrlComboBoxEx_GetItemEx, _GUICtrlComboBoxEx_SetItem

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $iImage, $tItem, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Set ItemEx", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_InitStorage($hCombo, 150, 300)
    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 149
        $iImage = Random(0, 8, 1)
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $iImage, $iImage)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    ; Change item 2
    MsgBox($MB_SYSTEMMODAL, "Information", "Changing item 2")
    $tItem = DllStructCreate($tagCOMBOBOXEXITEM)
    DllStructSetData($tItem, "Mask", $CBEIF_INDENT)
    DllStructSetData($tItem, "Item", 1)
    DllStructSetData($tItem, "Indent", 2)

    _GUICtrlComboBoxEx_SetItemEx($hCombo, $tItem)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_SetItemHeight

Function Reference

_GUICtrlComboBoxEx_SetItemHeight

Set the height of list items or the selection field in a ComboBox

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_SetItemHeight ( $hWnd, $iComponent, $iHeight )

Parameters

$hWnd | Handle to the control
$iComponent | Use the following values: –1 - Set the height of the selection field 0 - Set the height of list items
$iHeight | The height, in pixels, of the combo box component identified by $iComponent

Return Value

Success: | 0.
Failure: | -1 if height is invalid.

Related

_GUICtrlComboBoxEx_GetItemHeight

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Set Item Height", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next

    MemoWrite("Set Item Height: " & _GUICtrlComboBoxEx_SetItemHeight($hCombo, -1, 18))
    MemoWrite("Item Height: " & _GUICtrlComboBoxEx_GetItemHeight($hCombo, -1))
    MemoWrite("Set Item Height: " & _GUICtrlComboBoxEx_SetItemHeight($hCombo, 0, 20))
    MemoWrite("Item Height: " & _GUICtrlComboBoxEx_GetItemHeight($hCombo, 0))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlComboBoxEx_SetItemImage

Function Reference

_GUICtrlComboBoxEx_SetItemImage

Sets the index of the item's icon in the control's image list

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_SetItemImage ( $hWnd, $iIndex, $iImage )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based index of the item
$iImage | 0-based index into the control's image list

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlComboBoxEx_GetItemImage

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $iImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Set Item Image", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 149
        $iImage = Random(0, 8, 1)
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $iImage, $iImage)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    _GUICtrlComboBoxEx_SetItemImage($hCombo, 0, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 1, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 2, 2)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item Image: " & _GUICtrlComboBoxEx_GetItemImage($hCombo, 0))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_SetItemIndent

Function Reference

_GUICtrlComboBoxEx_SetItemIndent

Sets the number of image widths to indent the item

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_SetItemIndent ( $hWnd, $iIndex, $iIndent )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based index of the item
$iIndent | Indention value

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlComboBoxEx_GetItemIndent

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $iImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Set Item Indent", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 149
        $iImage = Random(0, 8, 1)
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $iImage, $iImage)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    _GUICtrlComboBoxEx_SetItemImage($hCombo, 0, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 1, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 2, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item Indent: " & _GUICtrlComboBoxEx_GetItemIndent($hCombo, 2))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_SetItemOverlayImage

Function Reference

_GUICtrlComboBoxEx_SetItemOverlayImage

Sets the index of the item's overlay icon in the control's image list

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_SetItemOverlayImage ( $hWnd, $iIndex, $iImage )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based index of the item
$iImage | 0-based index into the control's image list

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlComboBoxEx_GetItemOverlayImage

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $iImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Set Item Overlay Image", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 149
        $iImage = Random(0, 8, 1)
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $iImage, $iImage)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    _GUICtrlComboBoxEx_SetItemImage($hCombo, 0, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 1, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 2, 1)
    _GUICtrlComboBoxEx_SetItemOverlayImage($hCombo, 2, 6)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item Overlay Image: " & _GUICtrlComboBoxEx_GetItemOverlayImage($hCombo, 2))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_SetItemParam

Function Reference

_GUICtrlComboBoxEx_SetItemParam

Sets the value specific to the item

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_SetItemParam ( $hWnd, $iIndex, $iParam )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based index of the item
$iParam | Item specific value

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlComboBoxEx_GetItemParam

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $iImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Set Item Param", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 149
        $iImage = Random(0, 8, 1)
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $iImage, $iImage)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    _GUICtrlComboBoxEx_SetItemImage($hCombo, 0, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 1, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 2, 1)
    _GUICtrlComboBoxEx_SetItemParam($hCombo, 2, 54321)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item Param: " & _GUICtrlComboBoxEx_GetItemParam($hCombo, 2))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_SetItemSelectedImage

Function Reference

_GUICtrlComboBoxEx_SetItemSelectedImage

Sets the index of the item's overlay icon in the control's image list

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_SetItemSelectedImage ( $hWnd, $iIndex, $iImage )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based index of the item
$iImage | 0-based index into the control's image list

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlComboBoxEx_GetItemSelectedImage

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $iImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Set Item Selected Image", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_BeginUpdate($hCombo)
    For $x = 0 To 149
        $iImage = Random(0, 8, 1)
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $iImage, $iImage)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    _GUICtrlComboBoxEx_SetItemImage($hCombo, 0, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 1, 1)
    _GUICtrlComboBoxEx_SetItemIndent($hCombo, 2, 1)
    _GUICtrlComboBoxEx_SetItemSelectedImage($hCombo, 0, 3)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item Selected Image: " & _GUICtrlComboBoxEx_GetItemSelectedImage($hCombo, 0))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_SetMinVisible

Function Reference

_GUICtrlComboBoxEx_SetMinVisible

Set the minimum number of visible items in the drop-down list of a ComboBox

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_SetMinVisible ( $hWnd, $iMinimum )

Parameters

$hWnd | Handle to the control
$iMinimum | Specifies the minimum number of visible items

Return Value

Success: | True.
Failure: | False.

Remarks

When the number of items in the drop-down list is greater than the minimum, the Combobbox uses a scrollbar. By default, 30 is the minimum number of visible items.

This message is ignored if the combo box control has style $CBS_NOINTEGRALHEIGHT.

Related

_GUICtrlComboBoxEx_GetMinVisible

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $iImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Set Min Visible", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    _GUICtrlComboBoxEx_InitStorage($hCombo, 150, 300)
    _GUICtrlComboBoxEx_BeginUpdate($hCombo)

    For $x = 0 To 149
        $iImage = Random(0, 8, 1)
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $iImage, $iImage)
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    MsgBox($MB_SYSTEMMODAL, "Information", "Min Vis.: " & _GUICtrlComboBoxEx_GetMinVisible($hCombo))
    MsgBox($MB_SYSTEMMODAL, "Information", "Set Min Vis: " & _GUICtrlComboBoxEx_SetMinVisible($hCombo, 50))
    MsgBox($MB_SYSTEMMODAL, "Information", "Min Vis.: " & _GUICtrlComboBoxEx_GetMinVisible($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_SetTopIndex

Function Reference

_GUICtrlComboBoxEx_SetTopIndex

Ensure that a particular item is visible in the ListBox of a ComboBox

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_SetTopIndex ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | Specifies the 0-based index of the list item

Return Value

Success: | True.
Failure: | False.

Remarks

The system scrolls the ListBox contents so that either the specified item appears at the top of the list box or the maximum scroll range has been reached.

Related

_GUICtrlComboBoxEx_GetTopIndex

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Set Top Index", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100, $CBS_SIMPLE)
    GUISetState(@SW_SHOW)

    _GUICtrlComboBoxEx_InitStorage($hCombo, 150, 300)
    _GUICtrlComboBoxEx_BeginUpdate($hCombo)

    For $x = 0 To 149
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    ;Set Top Index
    MsgBox($MB_SYSTEMMODAL, "Information", "Set Top Index: " & _GUICtrlComboBoxEx_SetTopIndex($hCombo, Random(50, 149, 1)))
    MsgBox($MB_SYSTEMMODAL, "Information", "Top Index: " & _GUICtrlComboBoxEx_GetTopIndex($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_SetUnicode

Function Reference

_GUICtrlComboBoxEx_SetUnicode

Sets if control is using Unicode

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_SetUnicode ( $hWnd [, $bUnicode = True] )

Parameters

$hWnd | Handle to the control
$bUnicode | [optional] May be one of the following: True - Turn on Unicode False - Turn off Unicode

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlComboBoxEx_GetUnicode

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get/Set Unicode", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100, $CBS_SIMPLE)
    GUISetState(@SW_SHOW)

    _GUICtrlComboBoxEx_InitStorage($hCombo, 150, 300)
    _GUICtrlComboBoxEx_BeginUpdate($hCombo)

    For $x = 0 To 149
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlComboBoxEx_EndUpdate($hCombo)

    ;Set/Get Unicode
    MsgBox($MB_SYSTEMMODAL, "Information", "Set Unicode: " & _GUICtrlComboBoxEx_SetUnicode($hCombo, False))
    MsgBox($MB_SYSTEMMODAL, "Information", "Get Unicode: " & _GUICtrlComboBoxEx_GetUnicode($hCombo))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlComboBoxEx_ShowDropDown

Function Reference

_GUICtrlComboBoxEx_ShowDropDown

Show or hide the ListBox of a ComboBox

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_ShowDropDown ( $hWnd [, $bShow = False] )

Parameters

$hWnd | Handle to the control
$bShow | [optional] Specifies whether the drop-down ListBox is to be shown or hidden: True - Show ListBox False - Hide ListBox

Return Value

None.

Remarks

This function has no effect on a ComboBox created with the $CBS_SIMPLE style.

Related

_GUICtrlComboBoxEx_GetDroppedState

Example

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hCombo

    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Show Drop Down", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 100)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    Next

    ; show drop down
    _GUICtrlComboBoxEx_ShowDropDown($hCombo, True)

    Sleep(500)

    ; hide drop down
    _GUICtrlComboBoxEx_ShowDropDown($hCombo)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


User Defined Functions

GuiDateTimePicker user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiDateTimePicker.au3>.

User Defined Function | Description
_GUICtrlDTP_Create | Create a DTP control
_GUICtrlDTP_Destroy | Delete the control
_GUICtrlDTP_GetMCColor | Retrieves the specified color
_GUICtrlDTP_GetMCFont | Retrieves the month calendar font handle
_GUICtrlDTP_GetMonthCal | Retrieves the handle to child month calendar control
_GUICtrlDTP_GetRange | Retrieves the current minimum and maximum allowable system times
_GUICtrlDTP_GetRangeEx | Retrieves the current minimum and maximum allowable system times
_GUICtrlDTP_GetSystemTime | Retrieves the currently selected date and time
_GUICtrlDTP_GetSystemTimeEx | Retrieves the currently selected date and time
_GUICtrlDTP_SetFormat | Sets the display based on a given format string
_GUICtrlDTP_SetMCColor | Sets the color for a given portion of the month calendar
_GUICtrlDTP_SetMCFont | Sets the month calendar font
_GUICtrlDTP_SetRange | Sets the current minimum and maximum allowable system times
_GUICtrlDTP_SetRangeEx | Sets the current minimum and maximum allowable system times
_GUICtrlDTP_SetSystemTime | Sets the currently selected date and time
_GUICtrlDTP_SetSystemTimeEx | Sets the currently selected date and time


Function _GUICtrlDTP_Create

Function Reference

_GUICtrlDTP_Create

Create a DTP control

#include <GuiDateTimePicker.au3>
_GUICtrlDTP_Create ( $hWnd, $iX, $iY [, $iWidth = 120 [, $iHeight = 21 [, $iStyle = 0x00000000 [, $iExStyle = 0x00000000]]]] )

Parameters

$hWnd | Handle to parent or owner window
$iX | Horizontal position of the control
$iY | Vertical position of the control
$iWidth | [optional] Control width
$iHeight | [optional] Control height
$iStyle | [optional] Control styles: $DTS_APPCANPARSE - Allows the owner to parse user input and take action $DTS_LONGDATEFORMAT - Displays the date in long format $DTS_RIGHTALIGN - The calendar will be right-aligned $DTS_SHOWNONE - Displays a check box that can be checked once a date is entered $DTS_SHORTDATEFORMAT - Displays the date in short format $DTS_SHORTDATECENTURYFORMAT - The year is a four-digit field $DTS_TIMEFORMAT - Displays the time $DTS_UPDOWN - Places an up-down control to the right of the control Forced: $WS_CHILD, $WS_VISIBLE
$iExStyle | [optional] Control extended style. These correspond to the standard $WS_EX_* constants. See Extended Style Table.

Return Value

Success: | the handle to the DTP control.
Failure: | 0.

Remarks

This function is for Advanced users and for learning how the control works.

Related

_GUICtrlDTP_Destroy

Example

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

Global $g_hDTP

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("(UDF Created) DateTimePick Create", 400, 300)
    $g_hDTP = _GUICtrlDTP_Create($hGUI, 2, 6, 190)
    GUISetState(@SW_SHOW)

    ; Set the display format
    _GUICtrlDTP_SetFormat($g_hDTP, "ddd MMM dd, yyyy hh:mm ttt")

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo, $tBuffer, $tBuffer2

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hDTP
            Switch $iCode
                Case $DTN_CLOSEUP ; Sent by a date and time picker (DTP) control when the user closes the drop-down month calendar
                    _DebugPrint("$DTN_CLOSEUP" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; The return value for this notification is not used
                Case $DTN_DATETIMECHANGE ; Sent by a date and time picker (DTP) control whenever a change occurs
                    $tInfo = DllStructCreate($tagNMDATETIMECHANGE, $lParam)
                    _DebugPrint("$DTN_DATETIMECHANGE" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @CRLF & _
                            "-->Flag:" & @TAB & DllStructGetData($tInfo, "Flag") & @CRLF & _
                            "-->Year:" & @TAB & DllStructGetData($tInfo, "Year") & @CRLF & _
                            "-->Month:" & @TAB & DllStructGetData($tInfo, "Month") & @CRLF & _
                            "-->DOW:" & @TAB & DllStructGetData($tInfo, "DOW") & @CRLF & _
                            "-->Day:" & @TAB & DllStructGetData($tInfo, "Day") & @CRLF & _
                            "-->Hour:" & @TAB & DllStructGetData($tInfo, "Hour") & @CRLF & _
                            "-->Minute:" & @TAB & DllStructGetData($tInfo, "Minute") & @CRLF & _
                            "-->Second:" & @TAB & DllStructGetData($tInfo, "Second") & @CRLF & _
                            "-->MSecond:" & @TAB & DllStructGetData($tInfo, "MSecond"))
                    Return 0
                Case $DTN_DROPDOWN ; Sent by a date and time picker (DTP) control when the user activates the drop-down month calendar
                    _DebugPrint("$DTN_DROPDOWN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; The return value for this notification is not used
                Case $DTN_FORMAT ; Sent by a date and time picker (DTP) control to request text to be displayed in a callback field
                    $tInfo = DllStructCreate($tagNMDATETIMEFORMAT, $lParam)
                    $tBuffer = DllStructCreate("char Format[128]", DllStructGetData($tInfo, "Format"))
                    $tBuffer2 = DllStructCreate("char Display[64]", DllStructGetData($tInfo, "pDisplay"))
                    _DebugPrint("$DTN_FORMAT" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @CRLF & _
                            "-->Format:" & @TAB & DllStructGetData($tBuffer, "Format") & @CRLF & _
                            "-->Year:" & @TAB & DllStructGetData($tInfo, "Year") & @CRLF & _
                            "-->Month:" & @TAB & DllStructGetData($tInfo, "Month") & @CRLF & _
                            "-->DOW:" & @TAB & DllStructGetData($tInfo, "DOW") & @CRLF & _
                            "-->Day:" & @TAB & DllStructGetData($tInfo, "Day") & @CRLF & _
                            "-->Hour:" & @TAB & DllStructGetData($tInfo, "Hour") & @CRLF & _
                            "-->Minute:" & @TAB & DllStructGetData($tInfo, "Minute") & @CRLF & _
                            "-->Second:" & @TAB & DllStructGetData($tInfo, "Second") & @CRLF & _
                            "-->MSecond:" & @TAB & DllStructGetData($tInfo, "MSecond") & @CRLF & _
                            "-->Display:" & @TAB & DllStructGetData($tBuffer2, "Display"))
                    Return 0
                Case $DTN_FORMATQUERY ; Sent by a date and time picker (DTP) control to retrieve the maximum allowable size of the string that will be displayed in a callback field
                    $tInfo = DllStructCreate($tagNMDATETIMEFORMATQUERY, $lParam)
                    $tBuffer = DllStructCreate("char Format[128]", DllStructGetData($tInfo, "Format"))
                    _DebugPrint("$DTN_FORMATQUERY" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @CRLF & _
                            "-->Format:" & @TAB & DllStructGetData($tBuffer, "Format") & @CRLF & _
                            "-->SizeX:" & @TAB & DllStructGetData($tInfo, "SizeX") & @CRLF & _
                            "-->SizeY:" & @TAB & DllStructGetData($tBuffer2, "SizeY"))
                    DllStructSetData($tInfo, "SizeX", 64)
                    DllStructSetData($tInfo, "SizeY", 10)
                    Return 0
                Case $DTN_USERSTRING ; Sent by a date and time picker (DTP) control when a user finishes editing a string in the control
                    $tInfo = DllStructCreate($tagNMDATETIMESTRING, $lParam)
                    $tBuffer = DllStructCreate("char UserString[128]", DllStructGetData($tInfo, "UserString"))
                    _DebugPrint("$DTN_USERSTRING" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @CRLF & _
                            "-->UserString:" & @TAB & DllStructGetData($tBuffer, "UserString") & @CRLF & _
                            "-->Year:" & @TAB & DllStructGetData($tInfo, "Year") & @CRLF & _
                            "-->Month:" & @TAB & DllStructGetData($tInfo, "Month") & @CRLF & _
                            "-->DOW:" & @TAB & DllStructGetData($tInfo, "DOW") & @CRLF & _
                            "-->Day:" & @TAB & DllStructGetData($tInfo, "Day") & @CRLF & _
                            "-->Hour:" & @TAB & DllStructGetData($tInfo, "Hour") & @CRLF & _
                            "-->Minute:" & @TAB & DllStructGetData($tInfo, "Minute") & @CRLF & _
                            "-->Second:" & @TAB & DllStructGetData($tInfo, "Second") & @CRLF & _
                            "-->MSecond:" & @TAB & DllStructGetData($tInfo, "MSecond") & @CRLF & _
                            "-->Flags:" & @TAB & DllStructGetData($tInfo, "Flags"))
                    Return 0
                Case $DTN_WMKEYDOWN ; Sent by a date and time picker (DTP) control when the user types in a callback field
                    $tInfo = DllStructCreate($tagNMDATETIMEFORMATQUERY, $lParam)
                    $tBuffer = DllStructCreate("char Format[128]", DllStructGetData($tInfo, "Format"))
                    _DebugPrint("$DTN_WMKEYDOWN" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @CRLF & _
                            "-->VirtKey:" & @TAB & DllStructGetData($tInfo, "VirtKey") & @CRLF & _
                            "-->Format:" & @TAB & DllStructGetData($tBuffer, "Format") & @CRLF & _
                            "-->Year:" & @TAB & DllStructGetData($tInfo, "Year") & @CRLF & _
                            "-->Month:" & @TAB & DllStructGetData($tInfo, "Month") & @CRLF & _
                            "-->DOW:" & @TAB & DllStructGetData($tInfo, "DOW") & @CRLF & _
                            "-->Day:" & @TAB & DllStructGetData($tInfo, "Day") & @CRLF & _
                            "-->Hour:" & @TAB & DllStructGetData($tInfo, "Hour") & @CRLF & _
                            "-->Minute:" & @TAB & DllStructGetData($tInfo, "Minute") & @CRLF & _
                            "-->Second:" & @TAB & DllStructGetData($tInfo, "Second") & @CRLF & _
                            "-->MSecond:" & @TAB & DllStructGetData($tInfo, "MSecond"))
                    Return 0
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlDTP_Destroy

Function Reference

_GUICtrlDTP_Destroy

Delete the control

#include <GuiDateTimePicker.au3>
_GUICtrlDTP_Destroy ( ByRef $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True, $hWnd is set to 0.
Failure: | False.

Remarks

Restricted to only be used on Date Time Picker controls created with _GUICtrlDTP_Create().

Related

_GUICtrlDTP_Create

Example

#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hHandleBefore, $hDTP

    ; Create GUI
    $hGUI = GUICreate("(UDF Created) DateTimePick Destroy", 400, 300)
    $hDTP = _GUICtrlDTP_Create($hGUI, 2, 6, 190)
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Destroying the Control for Handle: " & $hDTP)
    $hHandleBefore = $hDTP
    MsgBox($MB_SYSTEMMODAL, "Information", "Control Destroyed: " & _GUICtrlDTP_Destroy($hDTP) & @CRLF & _
            "Handel Before Destroy: " & $hHandleBefore & @CRLF & _
            "Handle After Destroy: " & $hDTP)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlDTP_GetMCColor

Function Reference

_GUICtrlDTP_GetMCColor

Retrieves the specified color

#include <GuiDateTimePicker.au3>
_GUICtrlDTP_GetMCColor ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | Indicates which month calendar color to retrieve: 0 - Background color displayed between months 1 - Color used to display text within a month 2 - Background color displayed in the calendar title 3 - Color used to display text within the calendar title 4 - Background color displayed within the month 5 - Color used to display header day and trailing day text

Return Value

Success: | the color setting for the specified portion of the control.
Failure: | -1.

Related

_GUICtrlDTP_SetMCColor

Example

#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>
#include <MsgBoxConstants.au3>

Global $g_idMemo

Example() ;use autoit built-in control

Func Example()
    Local $hDTP

    ; Create GUI
    GUICreate("DateTimePick Get Month Calendar Color", 400, 300)
    $hDTP = GUICtrlGetHandle(GUICtrlCreateDate("", 2, 6, 190))
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set the display format
    _GUICtrlDTP_SetFormat($hDTP, "ddd MMM dd, yyyy hh:mm ttt")

    ; Set month calendar background color
    _GUICtrlDTP_SetMCColor($hDTP, 2, $CLR_MONEYGREEN)

    ; Get DTP colors
    MemoWrite("Background between months: " & "0x" & Hex(_GUICtrlDTP_GetMCColor($hDTP, 0), 6))
    MemoWrite("Text within months ......: " & "0x" & Hex(_GUICtrlDTP_GetMCColor($hDTP, 1), 6))
    MemoWrite("Title background ........: " & "0x" & Hex(_GUICtrlDTP_GetMCColor($hDTP, 2), 6))
    MemoWrite("Title text ..............: " & "0x" & Hex(_GUICtrlDTP_GetMCColor($hDTP, 3), 6))
    MemoWrite("Background within months : " & "0x" & Hex(_GUICtrlDTP_GetMCColor($hDTP, 4), 6))
    MemoWrite("Header trailing .........: " & "0x" & Hex(_GUICtrlDTP_GetMCColor($hDTP, 5), 6))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlDTP_GetMCFont

Function Reference

_GUICtrlDTP_GetMCFont

Retrieves the month calendar font handle

#include <GuiDateTimePicker.au3>
_GUICtrlDTP_GetMCFont ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the font handle.
Failure: | 0.

Related

_GUICtrlDTP_SetMCFont

Example

#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $tLOGFONT, $hFont, $hDTP

    ; Create GUI
    $hGui = GUICreate("DateTimePick Get Month Calendar Font", 400, 300)
    $hDTP = _GUICtrlDTP_Create($hGui, 2, 6, 190)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set the display format
    _GUICtrlDTP_SetFormat($hDTP, "ddd MMM dd, yyyy hh:mm ttt")

    ; Create a new font for the month control
    $tLOGFONT = DllStructCreate($tagLOGFONT)
    DllStructSetData($tLOGFONT, "Height", 13)
    DllStructSetData($tLOGFONT, "Weight", 400)
    DllStructSetData($tLOGFONT, "FaceName", "Verdana")
    $hFont = _WinAPI_CreateFontIndirect($tLOGFONT)
    _GUICtrlDTP_SetMCFont($hDTP, $hFont)

    ; Get month control font handle
    GUICtrlSetData($g_idMemo, "Font Handle: " & "0x" & Hex(_GUICtrlDTP_GetMCFont($hDTP), 6), 1)
    GUICtrlSetData($g_idMemo, " IsPtr=" & IsPtr(_GUICtrlDTP_GetMCFont($hDTP)), 1)
    GUICtrlSetData($g_idMemo, " IsHWnd=" & IsHWnd(_GUICtrlDTP_GetMCFont($hDTP)) & @CRLF, 1)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlDTP_GetMonthCal

Function Reference

_GUICtrlDTP_GetMonthCal

Retrieves the handle to child month calendar control

#include <GuiDateTimePicker.au3>
_GUICtrlDTP_GetMonthCal ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the month calendar handle.
Failure: | 0

Remarks

DTP controls create a child month calendar control when the user clicks the drop down arrow ($DTN_DROPDOWN notification).
When the month calendar is no longer needed, it is destroyed (a $DTN_CLOSEUP notification is sent on destruction).
So your application must not rely on a static handle to the DTP control's child month calendar.

Example

#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $hDTP

    ; Create GUI
    $hGui = GUICreate("DateTimePick Get Month Calendar Child Handle", 400, 300)
    $hDTP = _GUICtrlDTP_Create($hGui, 2, 6, 190)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set the display format
    _GUICtrlDTP_SetFormat($hDTP, "ddd MMM dd, yyyy hh:mm ttt")

    ; Get month control child handle
    GUICtrlSetData($g_idMemo, "MonthCal child Handle: " & "0x" & Hex(_GUICtrlDTP_GetMonthCal($hDTP)), 1)
    GUICtrlSetData($g_idMemo, " IsPtr=" & IsPtr(_GUICtrlDTP_GetMonthCal($hDTP)), 1)
    GUICtrlSetData($g_idMemo, " IsHWnd=" & IsHWnd(_GUICtrlDTP_GetMonthCal($hDTP)) & @CRLF, 1)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlDTP_GetRange

Function Reference

_GUICtrlDTP_GetRange

Retrieves the current minimum and maximum allowable system times

#include <GuiDateTimePicker.au3>
_GUICtrlDTP_GetRange ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns an array with the following format:
[ 0] - True if Min data is valid, otherwise False
[ 1] - Min Year
[ 2] - Min Month
[ 3] - Min Day
[ 4] - Min Hour
[ 5] - Min Minute
[ 6] - Min Second
[ 7] - True if Max data is valid, otherwise False
[ 8] - Max Year
[ 9] - Max Month
[10] - Max Day
[11] - Max Hour
[12] - Max Minute
[13] - Max Second

Related

_GUICtrlDTP_SetRange

Example

#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>

Global $g_idMemo, $g_aRange[14] = [True, @YEAR, 1, 1, 21, 45, 32, True, @YEAR, 12, 31, 23, 59, 59]

Example()

Func Example()
    Local $hDTP

    ; Create GUI
    GUICreate("DateTimePick Get Range", 400, 300)
    $hDTP = GUICtrlGetHandle(GUICtrlCreateDate("", 2, 6, 190))
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set the display format
    _GUICtrlDTP_SetFormat($hDTP, "ddd MMM dd, yyyy hh:mm ttt")

    ; Set date range
    _GUICtrlDTP_SetRange($hDTP, $g_aRange)

    ; Display date range
    $g_aRange = _GUICtrlDTP_GetRange($hDTP)
    MemoWrite("Minimum date: " & GetDateStr())
    MemoWrite("Maximum date: " & GetDateStr(7))
    MemoWrite("Minimum time: " & GetTimeStr(4))
    MemoWrite("Maximum time: " & GetTimeStr(11))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Returns the date portion
Func GetDateStr($iOff = 0)
    Return StringFormat("%02d/%02d/%04d", $g_aRange[$iOff + 2], $g_aRange[$iOff + 3], $g_aRange[$iOff + 1])
EndFunc   ;==>GetDateStr

; Returns the time portion
Func GetTimeStr($iOff = 0)
    Return StringFormat("%02d:%02d:%02d", $g_aRange[$iOff], $g_aRange[$iOff + 1], $g_aRange[$iOff + 2])
EndFunc   ;==>GetTimeStr

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlDTP_GetRangeEx

Function Reference

_GUICtrlDTP_GetRangeEx

Retrieves the current minimum and maximum allowable system times

#include <GuiDateTimePicker.au3>
_GUICtrlDTP_GetRangeEx ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | a $tagDTPRANGE structure.
Failure: | 0.

Related

$tagDTPRANGE, _GUICtrlDTP_SetRangeEx

Example

#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>

Global $g_idMemo, $g_tRange

Example()

Func Example()
    Local $hDTP

    ; Create GUI
    GUICreate("DateTimePick Get RangeEx", 400, 300)
    $hDTP = GUICtrlGetHandle(GUICtrlCreateDate("", 2, 6, 190))
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set the display format
    _GUICtrlDTP_SetFormat($hDTP, "ddd MMM dd, yyyy hh:mm ttt")

    ; Set date range
    $g_tRange = DllStructCreate($tagDTPRANGE)
    DllStructSetData($g_tRange, "MinValid", True)
    DllStructSetData($g_tRange, "MinYear", @YEAR)
    DllStructSetData($g_tRange, "MinMonth", 1)
    DllStructSetData($g_tRange, "MinDay", 1)
    DllStructSetData($g_tRange, "MinHour", 0)
    DllStructSetData($g_tRange, "MinMinute", 0)
    DllStructSetData($g_tRange, "MinSecond", 1)
    DllStructSetData($g_tRange, "MaxValid", True)
    DllStructSetData($g_tRange, "MaxYear", @YEAR)
    DllStructSetData($g_tRange, "MaxMonth", 12)
    DllStructSetData($g_tRange, "MaxDay", 31)
    DllStructSetData($g_tRange, "MaxHour", 12)
    DllStructSetData($g_tRange, "MaxMinute", 59)
    DllStructSetData($g_tRange, "MaxSecond", 59)
    _GUICtrlDTP_SetRangeEx($hDTP, $g_tRange)

    ; Display date range
    $g_tRange = _GUICtrlDTP_GetRangeEx($hDTP)
    MemoWrite("Minimum date: " & GetDateStr("Min"))
    MemoWrite("Maximum date: " & GetDateStr("Max"))
    MemoWrite("Minimum time: " & GetTimeStr("Min"))
    MemoWrite("Maximum time: " & GetTimeStr("Max"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Returns the date portion
Func GetDateStr($sPrefix)
    If $sPrefix = "Min" Then
        Return StringFormat("%02d/%02d/%04d", DllStructGetData($g_tRange, "MinMonth"), DllStructGetData($g_tRange, "MinDay"), DllStructGetData($g_tRange, "MinYear"))
    Else
        Return StringFormat("%02d/%02d/%04d", DllStructGetData($g_tRange, "MaxMonth"), DllStructGetData($g_tRange, "MaxDay"), DllStructGetData($g_tRange, "MaxYear"))
    EndIf
EndFunc   ;==>GetDateStr

; Returns the time portion
Func GetTimeStr($sPrefix)
    If $sPrefix = "Min" Then
        Return StringFormat("%02d:%02d:%02d", DllStructGetData($g_tRange, "MinHour"), DllStructGetData($g_tRange, "MinMinute"), DllStructGetData($g_tRange, "MinSecond"))
    Else
        Return StringFormat("%02d:%02d:%02d", DllStructGetData($g_tRange, "MaxHour"), DllStructGetData($g_tRange, "MaxMinute"), DllStructGetData($g_tRange, "MaxSecond"))
    EndIf
EndFunc   ;==>GetTimeStr

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlDTP_GetSystemTime

Function Reference

_GUICtrlDTP_GetSystemTime

Retrieves the currently selected date and time

#include <GuiDateTimePicker.au3>
_GUICtrlDTP_GetSystemTime ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns an array with the following format:
[0] - Year
[1] - Month
[2] - Day
[3] - Hour
[4] - Minute
[5] - Second

Related

_GUICtrlDTP_GetSystemTimeEx, _GUICtrlDTP_SetSystemTime

Example

#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>

Global $g_idMemo, $g_aDate

Example()

Func Example()
    Local $hDTP, $a_Date[7] = [False, @YEAR, 8, 19, 21, 57, 34]

    ; Create GUI
    GUICreate("DateTimePick Get System Time", 400, 300)
    $hDTP = GUICtrlGetHandle(GUICtrlCreateDate("", 2, 6, 190))
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set the display format
    _GUICtrlDTP_SetFormat($hDTP, "ddd MMM dd, yyyy hh:mm ttt")

    ; Set system time
    _GUICtrlDTP_SetSystemTime($hDTP, $a_Date)

    ; Display system time
    $g_aDate = _GUICtrlDTP_GetSystemTime($hDTP)
    MemoWrite("Selected date: " & GetDateStr())
    MemoWrite("Selected time: " & GetTimeStr())

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Returns the date portion
Func GetDateStr()
    Return StringFormat("%02d/%02d/%04d", $g_aDate[1], $g_aDate[2], $g_aDate[0])
EndFunc   ;==>GetDateStr

; Returns the time portion
Func GetTimeStr()
    Return StringFormat("%02d:%02d:%02d", $g_aDate[3], $g_aDate[4], $g_aDate[5])
EndFunc   ;==>GetTimeStr

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlDTP_GetSystemTimeEx

Function Reference

_GUICtrlDTP_GetSystemTimeEx

Retrieves the currently selected date and time

#include <GuiDateTimePicker.au3>
_GUICtrlDTP_GetSystemTimeEx ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | a $tagSYSTEMTIME structure.
Failure: | sets the @error flag to non-zero.
@error: | $GDT_NONE - if the control was set to the $DTS_SHOWNONE style and the control check box was not selected $GDT_ERROR - if an error occured.

Related

$tagSYSTEMTIME, _GUICtrlDTP_GetSystemTime, _GUICtrlDTP_SetSystemTimeEx

Example

#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>

Global $g_idMemo, $g_tDate

Example()

Func Example()
    Local $hDTP

    ; Create GUI
    GUICreate("DateTimePick Get System TimeEx", 400, 300)
    $hDTP = GUICtrlGetHandle(GUICtrlCreateDate("", 2, 6, 190))
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set the display format
    _GUICtrlDTP_SetFormat($hDTP, "ddd MMM dd, yyyy hh:mm ttt")

    ; Set system time
    $g_tDate = DllStructCreate($tagSYSTEMTIME)
    DllStructSetData($g_tDate, "Year", @YEAR)
    DllStructSetData($g_tDate, "Month", 8)
    DllStructSetData($g_tDate, "Day", 19)
    DllStructSetData($g_tDate, "Hour", 21)
    DllStructSetData($g_tDate, "Minute", 57)
    DllStructSetData($g_tDate, "Second", 34)
    _GUICtrlDTP_SetSystemTimeEx($hDTP, $g_tDate)

    ; Display system time
    $g_tDate = _GUICtrlDTP_GetSystemTimeEx($hDTP)
    MemoWrite("Selected date: " & GetDateStr())
    MemoWrite("Selected time: " & GetTimeStr())

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Returns the date portion
Func GetDateStr()
    Return StringFormat("%02d/%02d/%04d", DllStructGetData($g_tDate, "Month"), DllStructGetData($g_tDate, "Day"), DllStructGetData($g_tDate, "Year"))
EndFunc   ;==>GetDateStr

; Returns the time portion
Func GetTimeStr()
    Return StringFormat("%02d:%02d:%02d", DllStructGetData($g_tDate, "Hour"), DllStructGetData($g_tDate, "Minute"), DllStructGetData($g_tDate, "Second"))
EndFunc   ;==>GetTimeStr

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlDTP_SetFormat

Function Reference

_GUICtrlDTP_SetFormat

Sets the display based on a given format string

#include <GuiDateTimePicker.au3>
_GUICtrlDTP_SetFormat ( $hWnd, $sFormat )

Parameters

$hWnd | Handle to the control
$sFormat | String that defines the desired format. Setting this to blank will reset the control to the default format string for the current style. You can use the following format strings: "d" - The one or two digit day "dd" - The two digit day. Single digit day values are preceded by a zero "ddd" - The three character weekday abbreviation "dddd" - The full weekday name "h" - The one or two digit hour in 12-hour format "hh" - The two digit hour in 12-hour format "H" - The one or two digit hour in 24-hour format "HH" - The two digit hour in 24 hour format "m" - The one or two digit minute "mm" - The two digit minute "M" - The one or two digit month number "MM" - The two digit month number "MMM" - The three-character month abbreviation "MMMM" - The full month name "t" - The one letter AM/PM abbreviation "tt" - The two letter AM/PM abbreviation "yy" - The last two digits of the year "yyyy" - The full year

Return Value

Success: | True.
Failure: | False.

Remarks

It is acceptable to include extra characters within the format string to produce a more rich display.
However, any nonformat characters must be enclosed within single quotes.
For example, the format string "'Today is:
'hh':'m':'s ddddMMMdd', 'yyy" would produce output like "Today is: 04:22:31 Tuesday Mar 23, 1996".

Note: A DTP control tracks locale changes when it is using the default format string.
If you set a custom format string, it will not be updated in response to locale changes.

Example

#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>

Example()

Func Example()
    Local $hDTP

    ; Create GUI
    GUICreate("DateTimePick Set Format", 400, 300)
    $hDTP = GUICtrlGetHandle(GUICtrlCreateDate("", 2, 6, 190))

    GUISetState(@SW_SHOW)

    ; Set the display format
    _GUICtrlDTP_SetFormat($hDTP, "ddd MMM dd, yyyy hh:mm ttt")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlDTP_SetMCColor

Function Reference

_GUICtrlDTP_SetMCColor

Sets the color for a given portion of the month calendar

#include <GuiDateTimePicker.au3>
_GUICtrlDTP_SetMCColor ( $hWnd, $iIndex, $iColor )

Parameters

$hWnd | Handle to the control
$iIndex | Indicates which month calendar color to set: 0 - Background color displayed between months 1 - Color used to display text within a month 2 - Background color displayed in the calendar title 3 - Color used to display text within the calendar title 4 - Background color displayed within the month 5 - Color used to display header day and trailing day text
$iColor | The color that will be set for the specified area

Return Value

Success: | the previous color for the given portion.
Failure: | -1.

Related

_GUICtrlDTP_GetMCColor

Example

#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>
#include <MsgBoxConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hDTP

    ; Create GUI
    GUICreate("DateTimePick Set Month Calendar Color", 400, 300)
    $hDTP = GUICtrlGetHandle(GUICtrlCreateDate("", 2, 6, 190))
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set the display format
    _GUICtrlDTP_SetFormat($hDTP, "ddd MMM dd, yyyy hh:mm ttt")

    ; Set month calendar background color
    _GUICtrlDTP_SetMCColor($hDTP, 2, $CLR_MONEYGREEN)

    ; Get DTP colors
    MemoWrite("Background between months: " & "0x" & Hex(_GUICtrlDTP_GetMCColor($hDTP, 0), 6))
    MemoWrite("Text within months ......: " & "0x" & Hex(_GUICtrlDTP_GetMCColor($hDTP, 1), 6))
    MemoWrite("Title background ........: " & "0x" & Hex(_GUICtrlDTP_GetMCColor($hDTP, 2), 6))
    MemoWrite("Title text ..............: " & "0x" & Hex(_GUICtrlDTP_GetMCColor($hDTP, 3), 6))
    MemoWrite("Background within months : " & "0x" & Hex(_GUICtrlDTP_GetMCColor($hDTP, 4), 6))
    MemoWrite("Header trailing .........: " & "0x" & Hex(_GUICtrlDTP_GetMCColor($hDTP, 5), 6))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlDTP_SetMCFont

Function Reference

_GUICtrlDTP_SetMCFont

Sets the month calendar font

#include <GuiDateTimePicker.au3>
_GUICtrlDTP_SetMCFont ( $hWnd, $hFont [, $bRedraw = True] )

Parameters

$hWnd | Handle to the control
$hFont | Handle to the font that will be set
$bRedraw | [optional] Specifies whether the control should be redrawn immediately

Return Value

None.

Related

_GUICtrlDTP_GetMCFont

Example

#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $tLOGFONT, $hFont, $hDTP

    ; Create GUI
    $hGui = GUICreate("DateTimePick Set Month Calendar Font", 400, 300)
    $hDTP = _GUICtrlDTP_Create($hGui, 2, 6, 190)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set the display format
    _GUICtrlDTP_SetFormat($hDTP, "ddd MMM dd, yyyy hh:mm ttt")

    ; Create a new font for the month control
    $tLOGFONT = DllStructCreate($tagLOGFONT)
    DllStructSetData($tLOGFONT, "Height", 13)
    DllStructSetData($tLOGFONT, "Weight", 400)
    DllStructSetData($tLOGFONT, "FaceName", "Verdana")
    $hFont = _WinAPI_CreateFontIndirect($tLOGFONT)
    _GUICtrlDTP_SetMCFont($hDTP, $hFont)

    ; Get month control font handle
    MemoWrite("Font Handle: " & "0x" & Hex(_GUICtrlDTP_GetMCFont($hDTP), 6))
    MemoWrite("IsPtr  = " & IsPtr(_GUICtrlDTP_GetMCFont($hDTP)) & " IsHWnd  = " & IsHWnd(_GUICtrlDTP_GetMCFont($hDTP)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlDTP_SetRange

Function Reference

_GUICtrlDTP_SetRange

Sets the current minimum and maximum allowable system times

#include <GuiDateTimePicker.au3>
_GUICtrlDTP_SetRange ( $hWnd, ByRef $aRange )

Parameters

$hWnd | Handle to the control
$aRange | Array formatted as follows: [ 0] - True if Min data is to be set, otherwise False [ 1] - Min Year [ 2] - Min Month [ 3] - Min Day [ 4] - Min Hour [ 5] - Min Minute [ 6] - Min Second [ 7] - True if Max data is to be set, otherwise False [ 8] - Max Year [ 9] - Max Month [10] - Max Day [11] - Max Hour [12] - Max Minute [13] - Max Second

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlDTP_GetRange

Example

#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>

Global $g_idMemo, $g_aRange[14] = [True, @YEAR, 1, 1, 21, 45, 32, True, @YEAR, 12, 31, 23, 59, 59]

Example()

Func Example()
    Local $hDTP

    ; Create GUI
    GUICreate("DateTimePick Set Range", 400, 300)
    $hDTP = GUICtrlGetHandle(GUICtrlCreateDate("", 2, 6, 190))
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set the display format
    _GUICtrlDTP_SetFormat($hDTP, "ddd MMM dd, yyyy hh:mm ttt")

    ; Set date range
    _GUICtrlDTP_SetRange($hDTP, $g_aRange)

    ; Display date range
    $g_aRange = _GUICtrlDTP_GetRange($hDTP)
    MemoWrite("Minimum date: " & GetDateStr(0))
    MemoWrite("Maximum date: " & GetDateStr(7))
    MemoWrite("Minimum time: " & GetTimeStr(4))
    MemoWrite("Maximum time: " & GetTimeStr(11))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Returns the date portion
Func GetDateStr($iOff = 0)
    Return StringFormat("%02d/%02d/%04d", $g_aRange[$iOff + 2], $g_aRange[$iOff + 3], $g_aRange[$iOff + 1])
EndFunc   ;==>GetDateStr

; Returns the time portion
Func GetTimeStr($iOff = 0)
    Return StringFormat("%02d:%02d:%02d", $g_aRange[$iOff], $g_aRange[$iOff + 1], $g_aRange[$iOff + 2])
EndFunc   ;==>GetTimeStr

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlDTP_SetRangeEx

Function Reference

_GUICtrlDTP_SetRangeEx

Sets the current minimum and maximum allowable system times

#include <GuiDateTimePicker.au3>
_GUICtrlDTP_SetRangeEx ( $hWnd, ByRef $tRange )

Parameters

$hWnd | Handle to the control
$tRange | $tagDTPRANGE structure

Return Value

Success: | True.
Failure: | False.

Related

$tagDTPRANGE, _GUICtrlDTP_GetRangeEx

Example

#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>

Global $g_idMemo, $g_tRange

Example()

Func Example()
    Local $hDTP

    ; Create GUI
    GUICreate("DateTimePick Set RangeEx", 400, 300)
    $hDTP = GUICtrlGetHandle(GUICtrlCreateDate("", 2, 6, 190))
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set the display format
    _GUICtrlDTP_SetFormat($hDTP, "ddd MMM dd, yyyy hh:mm ttt")

    ; Set date range
    $g_tRange = DllStructCreate($tagDTPRANGE)
    DllStructSetData($g_tRange, "MinValid", True)
    DllStructSetData($g_tRange, "MinYear", @YEAR)
    DllStructSetData($g_tRange, "MinMonth", 1)
    DllStructSetData($g_tRange, "MinDay", 1)
    DllStructSetData($g_tRange, "MaxValid", True)
    DllStructSetData($g_tRange, "MaxYear", @YEAR)
    DllStructSetData($g_tRange, "MaxMonth", 12)
    DllStructSetData($g_tRange, "MaxDay", 31)
    DllStructSetData($g_tRange, "MaxHour", 12)
    DllStructSetData($g_tRange, "MaxMinute", 59)
    DllStructSetData($g_tRange, "MaxSecond", 59)
    _GUICtrlDTP_SetRangeEx($hDTP, $g_tRange)

    ; Display date range
    $g_tRange = _GUICtrlDTP_GetRangeEx($hDTP)
    MemoWrite("Minimum date: " & GetDateStr("Min"))
    MemoWrite("Maximum date: " & GetDateStr("Max"))
    MemoWrite("Minimum time: " & GetTimeStr("Min"))
    MemoWrite("Maximum time: " & GetTimeStr("Max"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Returns the date portion
Func GetDateStr($sPrefix)
    If $sPrefix = "Min" Then
        Return StringFormat("%02d/%02d/%04d", DllStructGetData($g_tRange, "MinMonth"), DllStructGetData($g_tRange, "MinDay"), DllStructGetData($g_tRange, "MinYear"))
    Else
        Return StringFormat("%02d/%02d/%04d", DllStructGetData($g_tRange, "MaxMonth"), DllStructGetData($g_tRange, "MaxDay"), DllStructGetData($g_tRange, "MaxYear"))
    EndIf
EndFunc   ;==>GetDateStr

; Returns the time portion
Func GetTimeStr($sPrefix)
    If $sPrefix = "Min" Then
        Return StringFormat("%02d:%02d:%02d", DllStructGetData($g_tRange, "MinHour"), DllStructGetData($g_tRange, "MinMinute"), DllStructGetData($g_tRange, "MinSecond"))
    Else
        Return StringFormat("%02d:%02d:%02d", DllStructGetData($g_tRange, "MaxHour"), DllStructGetData($g_tRange, "MaxMinute"), DllStructGetData($g_tRange, "MaxSecond"))
    EndIf
EndFunc   ;==>GetTimeStr

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlDTP_SetSystemTime

Function Reference

_GUICtrlDTP_SetSystemTime

Sets the currently selected date and time

#include <GuiDateTimePicker.au3>
_GUICtrlDTP_SetSystemTime ( $hWnd, ByRef $aDate )

Parameters

$hWnd | Handle to the control
$aDate | Array formatted as follows: [0] - If True, the control will is set to "no date" [1] - Year [2] - Month [3] - Day [4] - Hour [5] - Minute [6] - Second

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlDTP_GetSystemTime

Example

#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>

Global $g_idMemo, $g_aDate

Example()

Func Example()
    Local $hDTP, $a_Date[7] = [False, @YEAR, 8, 19, 21, 57, 34]

    ; Create GUI
    GUICreate("DateTimePick Set System Time", 400, 300)
    $hDTP = GUICtrlGetHandle(GUICtrlCreateDate("", 2, 6, 190))
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set the display format
    _GUICtrlDTP_SetFormat($hDTP, "ddd MMM dd, yyyy hh:mm ttt")

    ; Set system time
    _GUICtrlDTP_SetSystemTime($hDTP, $a_Date)

    ; Display system time
    $g_aDate = _GUICtrlDTP_GetSystemTime($hDTP)
    MemoWrite("Selected date: " & GetDateStr())
    MemoWrite("Selected time: " & GetTimeStr())

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Returns the date portion
Func GetDateStr()
    Return StringFormat("%02d/%02d/%04d", $g_aDate[1], $g_aDate[2], $g_aDate[0])
EndFunc   ;==>GetDateStr

; Returns the time portion
Func GetTimeStr()
    Return StringFormat("%02d:%02d:%02d", $g_aDate[3], $g_aDate[4], $g_aDate[5])
EndFunc   ;==>GetTimeStr

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlDTP_SetSystemTimeEx

Function Reference

_GUICtrlDTP_SetSystemTimeEx

Sets the currently selected date and time

#include <GuiDateTimePicker.au3>
_GUICtrlDTP_SetSystemTimeEx ( $hWnd, ByRef $tDate [, $bFlag = False] )

Parameters

$hWnd | Handle to the control
$tDate | $tagSYSTEMTIME structure
$bFlag | [optional] No date setting: True - Control will be set to "no date" False - Control is set to date and time value

Return Value

Success: | True.
Failure: | False.

Related

$tagSYSTEMTIME, _GUICtrlDTP_GetSystemTimeEx

Example

#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>

Global $g_idMemo, $g_tDate

Example()

Func Example()
    Local $hDTP

    ; Create GUI
    GUICreate("DateTimePick Set System TimeEx", 400, 300)
    $hDTP = GUICtrlGetHandle(GUICtrlCreateDate("", 2, 6, 190))
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set the display format
    _GUICtrlDTP_SetFormat($hDTP, "ddd MMM dd, yyyy hh:mm ttt")

    ; Set system time
    $g_tDate = DllStructCreate($tagSYSTEMTIME)
    DllStructSetData($g_tDate, "Year", @YEAR)
    DllStructSetData($g_tDate, "Month", 8)
    DllStructSetData($g_tDate, "Day", 19)
    DllStructSetData($g_tDate, "Hour", 21)
    DllStructSetData($g_tDate, "Minute", 57)
    DllStructSetData($g_tDate, "Second", 34)
    _GUICtrlDTP_SetSystemTimeEx($hDTP, $g_tDate)

    ; Display system time
    $g_tDate = _GUICtrlDTP_GetSystemTimeEx($hDTP)
    MemoWrite("Selected date: " & GetDateStr())
    MemoWrite("Selected time: " & GetTimeStr())

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Returns the date portion
Func GetDateStr()
    Return StringFormat("%02d/%02d/%04d", DllStructGetData($g_tDate, "Month"), DllStructGetData($g_tDate, "Day"), DllStructGetData($g_tDate, "Year"))
EndFunc   ;==>GetDateStr

; Returns the time portion
Func GetTimeStr()
    Return StringFormat("%02d:%02d:%02d", DllStructGetData($g_tDate, "Hour"), DllStructGetData($g_tDate, "Minute"), DllStructGetData($g_tDate, "Second"))
EndFunc   ;==>GetTimeStr

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


User Defined Functions

GuiEdit user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiEdit.au3>.

User Defined Function | Description
_GUICtrlEdit_AppendText | Append text
_GUICtrlEdit_BeginUpdate | Prevents updating of the control until the _GUICtrlEdit_EndUpdate function is called
_GUICtrlEdit_CanUndo | Determines whether there are any actions in an edit control's undo queue
_GUICtrlEdit_CharFromPos | Retrieve information about the character closest to a specified point in the client area
_GUICtrlEdit_Create | Create an Edit control
_GUICtrlEdit_Destroy | Delete the Edit control
_GUICtrlEdit_EmptyUndoBuffer | Resets the undo flag of an edit control
_GUICtrlEdit_EndUpdate | Enables screen repainting that was turned off with the _GUICtrlEdit_BeginUpdate function
_GUICtrlEdit_Find | Initiates a find dialog
_GUICtrlEdit_FmtLines | Determines whether an edit control includes soft line-break characters
_GUICtrlEdit_GetCueBanner | Gets the cue banner text displayed in the edit control
_GUICtrlEdit_GetFirstVisibleLine | Retrieves the 0-based index of the uppermost visible line in a multiline edit control
_GUICtrlEdit_GetLimitText | Gets the current text limit for an edit control
_GUICtrlEdit_GetLine | Retrieves a line of text from an edit control
_GUICtrlEdit_GetLineCount | Retrieves the number of lines
_GUICtrlEdit_GetMargins | Retrieves the widths of the left and right margins
_GUICtrlEdit_GetModify | Retrieves the state of an edit control's modification flag
_GUICtrlEdit_GetPasswordChar | Gets the password character that an edit control displays when the user enters text
_GUICtrlEdit_GetRECT | Retrieves the formatting rectangle of an edit control
_GUICtrlEdit_GetRECTEx | Retrieves the formatting rectangle of an edit control
_GUICtrlEdit_GetSel | Retrieves the starting and ending character positions of the current selection
_GUICtrlEdit_GetText | Get the text from the edit control
_GUICtrlEdit_GetTextLen | Get the length of all the text from the edit control
_GUICtrlEdit_HideBalloonTip | Hides any balloon tip associated with an edit control
_GUICtrlEdit_InsertText | Insert text
_GUICtrlEdit_LineFromChar | Retrieves the index of the line that contains the specified character index
_GUICtrlEdit_LineIndex | Retrieves the character index of the first character of a specified line
_GUICtrlEdit_LineLength | Retrieves the length, in characters, of a line
_GUICtrlEdit_LineScroll | Scrolls the text
_GUICtrlEdit_PosFromChar | Retrieves the client area coordinates of a specified character in an edit control
_GUICtrlEdit_ReplaceSel | Replaces the current selection
_GUICtrlEdit_Scroll | Scrolls the text vertically
_GUICtrlEdit_SetCueBanner | Sets the cue banner text that is displayed for the edit control
_GUICtrlEdit_SetLimitText | Sets the text limit
_GUICtrlEdit_SetMargins | Sets the widths of the left and right margins
_GUICtrlEdit_SetModify | Sets or clears the modification flag
_GUICtrlEdit_SetPasswordChar | Sets or removes the password character for an edit control
_GUICtrlEdit_SetReadOnly | Sets or removes the read-only style ($ES_READONLY)
_GUICtrlEdit_SetRECT | Sets the formatting rectangle of a multiline edit control
_GUICtrlEdit_SetRECTEx | Sets the formatting rectangle of a multiline edit control
_GUICtrlEdit_SetRECTNP | Sets the formatting rectangle of a multiline edit control
_GUICtrlEdit_SetRectNPEx | Sets the formatting rectangle of a multiline edit control
_GUICtrlEdit_SetSel | Selects a range of characters
_GUICtrlEdit_SetTabStops | Sets the tab stops
_GUICtrlEdit_SetText | Set the text
_GUICtrlEdit_ShowBalloonTip | Displays a balloon tip associated with an edit control
_GUICtrlEdit_Undo | Undoes the last edit control operation in the control's undo queue


Function _GUICtrlEdit_AppendText

Function Reference

_GUICtrlEdit_AppendText

Append text

#include <GuiEdit.au3>
_GUICtrlEdit_AppendText ( $hWnd, $sText )

Parameters

$hWnd | Control ID/Handle to the control
$sText | String to append

Return Value

None.

Related

_GUICtrlEdit_GetText, _GUICtrlEdit_InsertText, _GUICtrlEdit_SetText

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>

Example()

Func Example()
    Local $idEdit

    ; Create GUI
    GUICreate("Edit Append Text", 400, 300)
    $idEdit = GUICtrlCreateEdit("This is a test" & @CRLF & "Another Line", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    _GUICtrlEdit_AppendText($idEdit, @CRLF & "Append to the end?")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_BeginUpdate

Function Reference

_GUICtrlEdit_BeginUpdate

Prevents updating of the control until the _GUICtrlEdit_EndUpdate function is called

#include <GuiEdit.au3>
_GUICtrlEdit_BeginUpdate ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlEdit_EndUpdate

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>

Example()

Func Example()
    Local $idEdit, $hStatusBar, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"

    ; Create GUI
    $hGUI = GUICreate("Edit Begin Update", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268)
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, -1)
    GUISetState(@SW_SHOW)

    _GUICtrlEdit_BeginUpdate($idEdit)
    _GUICtrlEdit_SetText($idEdit, FileRead($sFile))
    _GUICtrlEdit_EndUpdate($idEdit)

    _GUICtrlStatusBar_SetText($hStatusBar, @TAB & "Lines: " & _GUICtrlEdit_GetLineCount($idEdit))
    _GUICtrlStatusBar_SetIcon($hStatusBar, 0, 97, "shell32.dll")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_CanUndo

Function Reference

_GUICtrlEdit_CanUndo

Determines whether there are any actions in an edit control's undo queue

#include <GuiEdit.au3>
_GUICtrlEdit_CanUndo ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

True: | If there are actions in the control's undo queue.
False: | If the undo queue is empty.

Remarks

If the undo queue is not empty, you can call the _GUICtrlEdit_Undo() to undo the most recent operation.

Related

_GUICtrlEdit_EmptyUndoBuffer, _GUICtrlEdit_GetModify, _GUICtrlEdit_SetModify, _GUICtrlEdit_Undo

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idEdit

    ; Create GUI
    GUICreate("Edit Can Undo", 400, 300)
    $idEdit = GUICtrlCreateEdit("This is a test" & @CRLF & "Another Line", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Can Undo: " & _GUICtrlEdit_CanUndo($idEdit))

    _GUICtrlEdit_AppendText($idEdit, @CRLF & "Append to the end?")

    MsgBox($MB_SYSTEMMODAL, "Information", "Can Undo: " & _GUICtrlEdit_CanUndo($idEdit))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_CharFromPos

Function Reference

_GUICtrlEdit_CharFromPos

Retrieve information about the character closest to a specified point in the client area

#include <GuiEdit.au3>
_GUICtrlEdit_CharFromPos ( $hWnd, $iX, $iY )

Parameters

$hWnd | Control ID/Handle to the control
$iX | horizontal position
$iY | vertical position

Return Value

Returns an array in the following format:
[0] - 0-based index of the character nearest the specified point
[1] - 0-based index of the line that contains the character

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aCharPos[2], $idEdit

    ; Create GUI
    GUICreate("Edit Char From Pos", 400, 300)
    $idEdit = GUICtrlCreateEdit("This is a test" & @CRLF & "Another Line", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    _GUICtrlEdit_AppendText($idEdit, @CRLF & "Append to the end?")

    $aCharPos = _GUICtrlEdit_CharFromPos($idEdit, 100, 20)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Char Nearsest Point: [%2d]", $aCharPos[0]) & @CRLF & _
            StringFormat("Line Nearest Point: [%2d]", $aCharPos[1]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_Create

Function Reference

_GUICtrlEdit_Create

Create an Edit control

#include <GuiEdit.au3>
_GUICtrlEdit_Create ( $hWnd, $sText, $iX, $iY [, $iWidth = 150 [, $iHeight = 150 [, $iStyle = 0x003010C4 [, $iExStyle = 0x00000200]]]] )

Parameters

$hWnd | Handle to parent or owner window
$sText | Text to be displayed in the control
$iX | Horizontal position of the control
$iY | Vertical position of the control
$iWidth | [optional] Control width
$iHeight | [optional] Control height
$iStyle [optional] Control styles:
$ES_AUTOHSCROLL - Automatically scrolls text to the right by 10 characters when the user types a character at the end of the line.
$ES_AUTOVSCROLL - Automatically scrolls text up one page when the user presses the ENTER key on the last line.
$ES_CENTER - Centers text in an edit control.
$ES_LEFT - Aligns text with the left margin.
$ES_LOWERCASE - Converts all characters to lowercase as they are typed into the edit control.
$ES_MULTILINE - Designates a multiline edit control.
$ES_NOHIDESEL - The selected text is inverted, even if the control does not have the focus.
$ES_NUMBER - Allows only digits to be entered into the edit control.
$ES_OEMCONVERT - Converts text entered in the edit control.
$ES_READONLY - Prevents the user from typing or editing text in the edit control.
$ES_RIGHT - Right-aligns text edit control.
$ES_UPPERCASE - Converts all characters to uppercase as they are typed into the edit control.
$ES_WANTRETURN - Specifies that a carriage return be inserted when the user presses the ENTER key.
$ES_PASSWORD - Displays an asterisk (*) for each character that is typed into the edit control

Default: $ES_MULTILINE, $ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL
Forced : WS_CHILD, $WS_VISIBLE, $WS_TABSTOP only if not using $ES_READONLY
$iExStyle | [optional] Control extended style. These correspond to the standard $WS_EX_* constants. See Extended Style Table.

Return Value

Success: | the handle to the Edit control.
Failure: | 0.

Remarks

This function is for Advanced users and for learning how the control works.

Related

_GUICtrlEdit_Destroy

Example

Example 1

#include <GUIConstantsEx.au3>
#include <WinAPI.au3> ; used for Lo/Hi word
#include <GuiEdit.au3>
#include <WindowsConstants.au3>

Global $g_hEdit

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Edit Create", 400, 300)
    $g_hEdit = _GUICtrlEdit_Create($hGUI, "This is a test" & @CRLF & "Another Line", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    _GUICtrlEdit_AppendText($g_hEdit, @CRLF & "Append to the end?")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit
    If Not IsHWnd($g_hEdit) Then $hWndEdit = GUICtrlGetHandle($g_hEdit)
    $hWndFrom = $lParam
    $iIDFrom = _WinAPI_LoWord($wParam)
    $iCode = _WinAPI_HiWord($wParam)
    Switch $hWndFrom
        Case $g_hEdit, $hWndEdit
            Switch $iCode
                Case $EN_ALIGN_LTR_EC ; Sent when the user has changed the edit control direction to left-to-right
                    _DebugPrint("$EN_ALIGN_LTR_EC" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $EN_ALIGN_RTL_EC ; Sent when the user has changed the edit control direction to right-to-left
                    _DebugPrint("$EN_ALIGN_RTL_EC" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control
                    _DebugPrint("$EN_CHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $EN_ERRSPACE ; Sent when an edit control cannot allocate enough memory to meet a specific request
                    _DebugPrint("$EN_ERRSPACE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $EN_HSCROLL ; Sent when the user clicks an edit control's horizontal scroll bar
                    _DebugPrint("$EN_HSCROLL" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $EN_KILLFOCUS ; Sent when an edit control loses the keyboard focus
                    _DebugPrint("$EN_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $EN_MAXTEXT ; Sent when the current text insertion has exceeded the specified number of characters for the edit control
                    _DebugPrint("$EN_MAXTEXT" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; This message is also sent when an edit control does not have the $ES_AUTOHSCROLL style and the number of characters to be
                    ; inserted would exceed the width of the edit control.
                    ; This message is also sent when an edit control does not have the $ES_AUTOVSCROLL style and the total number of lines resulting
                    ; from a text insertion would exceed the height of the edit control

                    ; no return value
                Case $EN_SETFOCUS ; Sent when an edit control receives the keyboard focus
                    _DebugPrint("$EN_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $EN_UPDATE ; Sent when an edit control is about to redraw itself
                    _DebugPrint("$EN_UPDATE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $EN_VSCROLL ; Sent when the user clicks an edit control's vertical scroll bar or when the user scrolls the mouse wheel over the edit control
                    _DebugPrint("$EN_VSCROLL" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint

Example 2

#include <GUIConstantsEx.au3>
#include <WinAPI.au3> ; used for Lo/Hi word
#include <GuiEdit.au3>
#include <WindowsConstants.au3>

Global $g_hEdit

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Edit Create", 400, 300)
    $g_hEdit = _GUICtrlEdit_Create($hGUI, "", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    _GUICtrlEdit_SetText($g_hEdit, "This is a test" & @CRLF & "Another Line")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit
    If Not IsHWnd($g_hEdit) Then $hWndEdit = GUICtrlGetHandle($g_hEdit)
    $hWndFrom = $lParam
    $iIDFrom = _WinAPI_LoWord($wParam)
    $iCode = _WinAPI_HiWord($wParam)
    Switch $hWndFrom
        Case $g_hEdit, $hWndEdit
            Switch $iCode
                Case $EN_ALIGN_LTR_EC ; Sent when the user has changed the edit control direction to left-to-right
                    _DebugPrint("$EN_ALIGN_LTR_EC" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $EN_ALIGN_RTL_EC ; Sent when the user has changed the edit control direction to right-to-left
                    _DebugPrint("$EN_ALIGN_RTL_EC" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control
                    _DebugPrint("$EN_CHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $EN_ERRSPACE ; Sent when an edit control cannot allocate enough memory to meet a specific request
                    _DebugPrint("$EN_ERRSPACE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $EN_HSCROLL ; Sent when the user clicks an edit control's horizontal scroll bar
                    _DebugPrint("$EN_HSCROLL" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $EN_KILLFOCUS ; Sent when an edit control loses the keyboard focus
                    _DebugPrint("$EN_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $EN_MAXTEXT ; Sent when the current text insertion has exceeded the specified number of characters for the edit control
                    _DebugPrint("$EN_MAXTEXT" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; This message is also sent when an edit control does not have the $ES_AUTOHSCROLL style and the number of characters to be
                    ; inserted would exceed the width of the edit control.
                    ; This message is also sent when an edit control does not have the $ES_AUTOVSCROLL style and the total number of lines resulting
                    ; from a text insertion would exceed the height of the edit control

                    ; no return value
                Case $EN_SETFOCUS ; Sent when an edit control receives the keyboard focus
                    _DebugPrint("$EN_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $EN_UPDATE ; Sent when an edit control is about to redraw itself
                    _DebugPrint("$EN_UPDATE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $EN_VSCROLL ; Sent when the user clicks an edit control's vertical scroll bar or when the user scrolls the mouse wheel over the edit control
                    _DebugPrint("$EN_VSCROLL" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlEdit_Destroy

Function Reference

_GUICtrlEdit_Destroy

Delete the Edit control

#include <GuiEdit.au3>
_GUICtrlEdit_Destroy ( ByRef $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True, $hWnd is set to 0.
Failure: | False.

Remarks

Restricted to only be used on Edit controls created with _GUICtrlEdit_Create().

Related

_GUICtrlEdit_Create

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hEdit

    ; Create GUI
    $hGUI = GUICreate("Edit Destroy", 400, 300)
    $hEdit = _GUICtrlEdit_Create($hGUI, "This is a test" & @CRLF & "Another Line", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    _GUICtrlEdit_AppendText($hEdit, @CRLF & "Append to the end?")

    MsgBox($MB_SYSTEMMODAL, "Information", "Destroy Edit Control")
    _GUICtrlEdit_Destroy($hEdit)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_EmptyUndoBuffer

Function Reference

_GUICtrlEdit_EmptyUndoBuffer

Resets the undo flag of an edit control

#include <GuiEdit.au3>
_GUICtrlEdit_EmptyUndoBuffer ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

None.

Remarks

The undo flag is automatically reset whenever the edit control receives a _GUICtrlEdit_SetText().

Related

_GUICtrlEdit_CanUndo, _GUICtrlEdit_Undo

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idEdit

    ; Create GUI
    GUICreate("Edit Empty Undo Buffer", 400, 300)
    $idEdit = GUICtrlCreateEdit("This is a test" & @CRLF & "Another Line", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    _GUICtrlEdit_AppendText($idEdit, @CRLF & "Append to the end?")

    MsgBox($MB_SYSTEMMODAL, "Information", "Can Undo: " & _GUICtrlEdit_CanUndo($idEdit))

    _GUICtrlEdit_EmptyUndoBuffer($idEdit)

    MsgBox($MB_SYSTEMMODAL, "Information", "Can Undo: " & _GUICtrlEdit_CanUndo($idEdit))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_EndUpdate

Function Reference

_GUICtrlEdit_EndUpdate

Enables screen repainting that was turned off with the _GUICtrlEdit_BeginUpdate function

#include <GuiEdit.au3>
_GUICtrlEdit_EndUpdate ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlEdit_BeginUpdate

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"

    ; Create GUI
    $hGUI = GUICreate("Edit End Update", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268)
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, -1)
    GUISetState(@SW_SHOW)

    _GUICtrlEdit_BeginUpdate($idEdit)
    _GUICtrlEdit_SetText($idEdit, FileRead($sFile))
    _GUICtrlEdit_EndUpdate($idEdit)

    _GUICtrlStatusBar_SetIcon($hStatusBar, 0, 97, "shell32.dll")
    _GUICtrlStatusBar_SetText($hStatusBar, @TAB & "Lines: " & _GUICtrlEdit_GetLineCount($idEdit))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_Find

Function Reference

_GUICtrlEdit_Find

Initiates a find dialog

#include <GuiEdit.au3>
_GUICtrlEdit_Find ( $hWnd [, $bReplace = False] )

Parameters

$hWnd | Control ID/Handle to the control
$bReplace | [optional] Replace Option: True - Show option False - Hide option

Return Value

None.

Remarks

If you use text from the edit control and that text gets replaced the function will no longer function correctly.

Example

Example 1

; using AutoIt Function

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

Example_Internal()

Func Example_Internal()
    Local $s_Text = "this is a test" & @CRLF & _
            "this is only a test" & @CRLF & _
            "this testing should work for you as well as it does for me"
    Local $idButton1, $idButton2, $iMsg, $idEdit

    GUICreate('Find And Replace Example with AutoIt ' & FileGetVersion(@AutoItExe), 622, 448, 192, 125)
    $idEdit = GUICtrlCreateEdit($s_Text, 64, 24, 505, 233, _
            BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE, $WS_HSCROLL, $ES_NOHIDESEL))
    $idButton1 = GUICtrlCreateButton("Find", 176, 288, 121, 33, 0)
    $idButton2 = GUICtrlCreateButton("Find And Replace", 368, 288, 121, 33, 0)
    GUISetState(@SW_SHOW)

    While 1
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $iMsg = $idButton1
                _GUICtrlEdit_Find($idEdit)
            Case $iMsg = $idButton2
                _GUICtrlEdit_Find($idEdit, True)
            Case Else
                ;;;;;;;
        EndSelect
    WEnd
    GUIDelete()
EndFunc   ;==>Example_Internal

Example 2

; using Standard UDF

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example_External()

Func Example_External()
    Local $s_Text = 'Find And Replace Example with AutoIt ' & FileGetVersion(@AutoItExe) & @CRLF & _
            "this is a test" & @CRLF & _
            "this is only a test" & @CRLF & _
            "this testing should work for you as well as it does for me"
    Local $hTitle, $hHandle
    Local $sTitle = "[CLASS:Notepad]"

    Run("notepad.exe", "", @SW_MAXIMIZE)
    ;Wait for the window "Untitled" to exist
    WinWait($sTitle)

    ; Get the handle of a notepad window
    $hTitle = WinGetHandle($sTitle)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "Error", "Could not find the correct window")
    Else
        $hHandle = ControlGetHandle($hTitle, "", "Edit1")
        If @error Then
            MsgBox($MB_SYSTEMMODAL, "Error", "Could not find the correct control")
        Else
            ; Send some text directly to this window's edit control
            ControlSend($hTitle, "", "Edit1", $s_Text)
            _GUICtrlEdit_Find($hHandle, True)
        EndIf
    EndIf
EndFunc   ;==>Example_External


Function _GUICtrlEdit_FmtLines

Function Reference

_GUICtrlEdit_FmtLines

Determines whether an edit control includes soft line-break characters

#include <GuiEdit.au3>
_GUICtrlEdit_FmtLines ( $hWnd [, $bSoftBreak = False] )

Parameters

$hWnd | Control ID/Handle to the control
$bSoftBreak | [optional] Specifies whether soft line-break characters are to be inserted: True - Inserts the characters False - Removes them

Return Value

Returns identical to the $bSoftBreak parameter.

Remarks

A soft line break consists of two carriage returns and a line feed and is inserted at the end of a line that is broken because of wordwrapping.

This function affects only the text returned by the _GUICtrlEdit_GetText() function.

It has no effect on the display of the text within the edit control.

The _GUICtrlEdit_FmtLines() function does not affect a line that ends with a hard line break.
A hard line break consists of one carriage return and a line feed.

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idEdit
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
    Local $sBefore, $sAfter

    ; Create GUI
    GUICreate("Edit FmtLines", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    GUISetState(@SW_SHOW)

    ; Set Text
    _GUICtrlEdit_SetText($idEdit, FileRead($sFile, 500))

    ; Text retrieved in default format
    $sBefore = _GUICtrlEdit_GetText($idEdit)

    ; insert soft line-breaks
    _GUICtrlEdit_FmtLines($idEdit, True)

    ; Text with soft line breaks
    $sAfter = _GUICtrlEdit_GetText($idEdit)

    MsgBox($MB_SYSTEMMODAL, "Information", "Before:" & @CRLF & @CRLF & $sBefore & @CRLF & _
            '--------------------------------------------------------------' & @CRLF & _
            "After:" & @CRLF & @CRLF & $sAfter)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_GetCueBanner

Function Reference

_GUICtrlEdit_GetCueBanner

Gets the cue banner text displayed in the edit control

#include <GuiEdit.au3>
_GUICtrlEdit_GetCueBanner ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the cue banner text.
Failure: | an empty string "".

Remarks

The cue banner is text that is displayed in the edit control when there is no selection.

Windows Vista or later.

Related

_GUICtrlEdit_SetCueBanner

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate('Example', 300, 150)
    GUISetFont(9, 400, 0, 'Segoe UI')

    Local $idUsername = GUICtrlCreateInput('', 10, 10, 125, 25)
    _GUICtrlEdit_SetCueBanner($idUsername, "Search folder")

    Local $idPassword = GUICtrlCreateInput('', 10, 40, 125, 25)
    _GUICtrlEdit_SetCueBanner($idPassword, "Search...")

    Local $idClose = GUICtrlCreateButton("Close", 210, 120, 85, 25)
    ControlFocus($hGUI, "", $idClose)

    GUISetState(@SW_SHOW, $hGUI)

    MsgBox($MB_SYSTEMMODAL, "", _GUICtrlEdit_GetCueBanner($idPassword))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idClose
                ExitLoop

        EndSwitch
    WEnd

    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUICtrlEdit_GetFirstVisibleLine

Function Reference

_GUICtrlEdit_GetFirstVisibleLine

Retrieves the 0-based index of the uppermost visible line in a multiline edit control

#include <GuiEdit.au3>
_GUICtrlEdit_GetFirstVisibleLine ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns a 0-based index of the uppermost visible line in a multiline edit control.

Remarks

The number of lines and the length of the lines in an edit control depend on the width of the control and the current Wordwrap setting.

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idEdit

    ; Create GUI
    GUICreate("Edit Get First Visible Line", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    For $x = 0 To 20
        _GUICtrlEdit_AppendText($idEdit, StringFormat("[%02d] Append to the end?", $x) & @CRLF)
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "First Visible Line: " & _GUICtrlEdit_GetFirstVisibleLine($idEdit))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_GetLimitText

Function Reference

_GUICtrlEdit_GetLimitText

Gets the current text limit for an edit control

#include <GuiEdit.au3>
_GUICtrlEdit_GetLimitText ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the text limit.

Remarks

The text limit is the maximum amount of text, in TCHARs, that the control can contain.
For ANSI text, this is the number of bytes; for Unicode text, this is the number of characters.
Two documents with the same character limit will yield the same text limit, even if one is ANSI and the other is Unicode.

Related

_GUICtrlEdit_SetLimitText

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idEdit

    ; Create GUI
    GUICreate("Edit Get Limit Text", 400, 300)
    $idEdit = GUICtrlCreateEdit("This is a test" & @CRLF & "Another Line", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Text Limit: " & _GUICtrlEdit_GetLimitText($idEdit))

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Text Limit")
    _GUICtrlEdit_SetLimitText($idEdit, 64000)

    MsgBox($MB_SYSTEMMODAL, "Information", "Text Limit: " & _GUICtrlEdit_GetLimitText($idEdit))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_GetLine

Function Reference

_GUICtrlEdit_GetLine

Retrieves a line of text from an edit control

#include <GuiEdit.au3>
_GUICtrlEdit_GetLine ( $hWnd, $iLine )

Parameters

$hWnd | Control ID/Handle to the control
$iLine | 0-based line index to get

Return Value

Success: | the line of text.
Failure: | an empty string.

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idEdit
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"

    ; Create GUI
    GUICreate("Edit Get Line", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    _GUICtrlEdit_SetText($idEdit, FileRead($sFile))

    MsgBox($MB_SYSTEMMODAL, "Information", _GUICtrlEdit_GetLine($idEdit, 2))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_GetLineCount

Function Reference

_GUICtrlEdit_GetLineCount

Retrieves the number of lines

#include <GuiEdit.au3>
_GUICtrlEdit_GetLineCount ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the total number of text lines.
Failure: | 1.

Remarks

If the control has no text, the return value is 1.
The return value will never be less than 1.

The _GUICtrlEdit_GetLineCount() retrieves the total number of text lines, not just the number of lines that are currently visible.

If the Wordwrap feature is enabled, the number of lines can change when the dimensions of the editing window change.

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"

    ; Create GUI
    $hGUI = GUICreate("Edit Get Line Count", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268)
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, -1)
    GUISetState(@SW_SHOW)

    _GUICtrlEdit_SetText($idEdit, FileRead($sFile))
    _GUICtrlStatusBar_SetIcon($hStatusBar, 0, 97, "shell32.dll")
    _GUICtrlStatusBar_SetText($hStatusBar, @TAB & "Lines: " & _GUICtrlEdit_GetLineCount($idEdit))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_GetMargins

Function Reference

_GUICtrlEdit_GetMargins

Retrieves the widths of the left and right margins

#include <GuiEdit.au3>
_GUICtrlEdit_GetMargins ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an array in the following format:
[0] - The width of the left margin
[1] - The width of the right margin

Related

_GUICtrlEdit_SetMargins

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
    Local $aPartRightSide[3] = [190, 378, -1], $aMargins

    ; Create GUI
    $hGUI = GUICreate("Edit Get Margins", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 2, 97, "shell32.dll")
    GUISetState(@SW_SHOW)

    ; Set Margins
    _GUICtrlEdit_SetMargins($idEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10)

    ; Set Text
    _GUICtrlEdit_SetText($idEdit, FileRead($sFile))

    ; Get Margins
    $aMargins = _GUICtrlEdit_GetMargins($idEdit)
    _GUICtrlStatusBar_SetText($hStatusBar, "Left Margin: " & $aMargins[0])
    _GUICtrlStatusBar_SetText($hStatusBar, "Right Margin: " & $aMargins[1], 1)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_GetModify

Function Reference

_GUICtrlEdit_GetModify

Retrieves the state of an edit control's modification flag

#include <GuiEdit.au3>
_GUICtrlEdit_GetModify ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

True: | Edit control contents have been modified.
False: | Edit control contents have not been modified.

Remarks

The system automatically clears the modification flag to zero when the control is created.
If the user changes the control's text, the system sets the flag to True.
You can call _GUICtrlEdit_SetModify() to set or clear the flag.

Related

_GUICtrlEdit_CanUndo, _GUICtrlEdit_SetModify, _GUICtrlEdit_Undo

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
    Local $aPartRightSide[4] = [120, 248, 378, -1]

    ; Create GUI
    $hGUI = GUICreate("Edit Get Modify", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268)
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 3, 97, "shell32.dll")
    GUISetState(@SW_SHOW)

    ; Set Margins
    _GUICtrlEdit_SetMargins($idEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10)

    ; Add Text
    _GUICtrlEdit_AppendText($idEdit, FileRead($sFile))
    _GUICtrlEdit_LineScroll($idEdit, 0, _GUICtrlEdit_GetLineCount($idEdit) * -1)

    ; Get Modified Flag
    _GUICtrlStatusBar_SetText($hStatusBar, "Modified: " & _GUICtrlEdit_GetModify($idEdit), 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_GetPasswordChar

Function Reference

_GUICtrlEdit_GetPasswordChar

Gets the password character that an edit control displays when the user enters text

#include <GuiEdit.au3>
_GUICtrlEdit_GetPasswordChar ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the character to be displayed in place of any characters typed by the user.

If the return value is 0, there is no password character, and the control displays the characters typed by the user.

Related

_GUICtrlEdit_SetPasswordChar

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idEdit

    ; Create GUI
    GUICreate("Edit Get Password Char", 400, 300)
    $idEdit = GUICtrlCreateInput("Test of build-in control", 2, 2, 394, 25, $ES_PASSWORD)
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Password Char: " & _GUICtrlEdit_GetPasswordChar($idEdit))

    _GUICtrlEdit_SetPasswordChar($idEdit, "$") ; change password char to $

    MsgBox($MB_SYSTEMMODAL, "Information", "Password Char: " & _GUICtrlEdit_GetPasswordChar($idEdit))

    _GUICtrlEdit_SetPasswordChar($idEdit) ; display characters typed by the user.

    MsgBox($MB_SYSTEMMODAL, "Information", "Password Char: " & _GUICtrlEdit_GetPasswordChar($idEdit))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_GetRECT

Function Reference

_GUICtrlEdit_GetRECT

Retrieves the formatting rectangle of an edit control

#include <GuiEdit.au3>
_GUICtrlEdit_GetRECT ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an array containing the RECT in the following format:
[0] - X coordinate of the upper left corner of the rectangle
[1] - Y coordinate of the upper left corner of the rectangle
[2] - X coordinate of the lower right corner of the rectangle
[3] - Y coordinate of the lower right corner of the rectangle

Remarks

Under certain conditions, _GUICtrlEdit_GetRECT() might not return the exact values that
_GUICtrlEdit_SetRECT() set—it will be approximately correct, but it can be off by a few pixels.

Related

_GUICtrlEdit_GetRECTEx

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
    Local $aPartRightSide[6] = [50, 130, 210, 290, 378, -1], $aRect

    ; Create GUI
    $hGUI = GUICreate("Edit Get RECT", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 5, 97, "shell32.dll")
    _GUICtrlStatusBar_SetText($hStatusBar, "Rect")
    GUISetState(@SW_SHOW)

    ; Get Rect
    $aRect = _GUICtrlEdit_GetRECT($idEdit)
    $aRect[0] += 10
    $aRect[1] += 10
    $aRect[2] -= 10
    $aRect[3] -= 10

    ; Set Rect
    _GUICtrlEdit_SetRECT($idEdit, $aRect)

    ; Add Text
    _GUICtrlEdit_AppendText($idEdit, FileRead($sFile))
    _GUICtrlEdit_LineScroll($idEdit, 0, _GUICtrlEdit_GetLineCount($idEdit) * -1)

    ; Get Rect
    $aRect = _GUICtrlEdit_GetRECT($idEdit)
    _GUICtrlStatusBar_SetText($hStatusBar, "Left: " & $aRect[0], 1)
    _GUICtrlStatusBar_SetText($hStatusBar, "Topt: " & $aRect[1], 2)
    _GUICtrlStatusBar_SetText($hStatusBar, "Right: " & $aRect[2], 3)
    _GUICtrlStatusBar_SetText($hStatusBar, "Bottom: " & $aRect[3], 4)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_GetRECTEx

Function Reference

_GUICtrlEdit_GetRECTEx

Retrieves the formatting rectangle of an edit control

#include <GuiEdit.au3>
_GUICtrlEdit_GetRECTEx ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns a $tagRECT structure that recieves formatting rectangle of an edit control.

Remarks

Under certain conditions, _GUICtrlEdit_GetRECT() might not return the exact values that
_GUICtrlEdit_SetRECTEx() set—it will be approximately correct, but it can be off by a few pixels.

Related

$tagRECT, _GUICtrlEdit_GetRECT

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
    Local $aPartRightSide[6] = [50, 130, 210, 290, 378, -1], $tRECT

    ; Create GUI
    $hGUI = GUICreate("Edit Get RECTEx", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 5, 97, "shell32.dll")
    _GUICtrlStatusBar_SetText($hStatusBar, "Rect")
    GUISetState(@SW_SHOW)

    ; Get RectEx
    $tRECT = _GUICtrlEdit_GetRECTEx($idEdit)
    DllStructSetData($tRECT, "Left", DllStructGetData($tRECT, "Left") + 10)
    DllStructSetData($tRECT, "Top", DllStructGetData($tRECT, "Top") + 10)
    DllStructSetData($tRECT, "Right", DllStructGetData($tRECT, "Right") - 10)
    DllStructSetData($tRECT, "Bottom", DllStructGetData($tRECT, "Bottom") - 10)

    ; Set RectEx
    _GUICtrlEdit_SetRECTEx($idEdit, $tRECT)

    ; Add Text
    _GUICtrlEdit_AppendText($idEdit, FileRead($sFile))
    _GUICtrlEdit_LineScroll($idEdit, 0, _GUICtrlEdit_GetLineCount($idEdit) * -1)

    ; Get RectEx
    $tRECT = _GUICtrlEdit_GetRECTEx($idEdit)
    _GUICtrlStatusBar_SetText($hStatusBar, "Left: " & DllStructGetData($tRECT, "Left"), 1)
    _GUICtrlStatusBar_SetText($hStatusBar, "Topt: " & DllStructGetData($tRECT, "Top"), 2)
    _GUICtrlStatusBar_SetText($hStatusBar, "Right: " & DllStructGetData($tRECT, "Right"), 3)
    _GUICtrlStatusBar_SetText($hStatusBar, "Bottom: " & DllStructGetData($tRECT, "Bottom"), 4)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_GetSel

Function Reference

_GUICtrlEdit_GetSel

Retrieves the starting and ending character positions of the current selection

#include <GuiEdit.au3>
_GUICtrlEdit_GetSel ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an array in the following format:
[0] - Starting position
[1] - Ending position

Related

_GUICtrlEdit_ReplaceSel, _GUICtrlEdit_SetSel

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
    Local $aPartRightSide[3] = [190, 378, -1], $aSel

    ; Create GUI
    $hGUI = GUICreate("Edit Get Sel", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 2, 97, "shell32.dll")
    GUISetState(@SW_SHOW)

    ; Set Margins
    _GUICtrlEdit_SetMargins($idEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10)

    ; Set Text
    _GUICtrlEdit_SetText($idEdit, FileRead($sFile))

    ; Set Sel
    _GUICtrlEdit_SetSel($idEdit, 15, 20)

    ; Get Sel
    $aSel = _GUICtrlEdit_GetSel($idEdit)
    _GUICtrlStatusBar_SetText($hStatusBar, "Start: " & $aSel[0])
    _GUICtrlStatusBar_SetText($hStatusBar, "End: " & $aSel[1], 1)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_GetText

Function Reference

_GUICtrlEdit_GetText

Get the text from the edit control

#include <GuiEdit.au3>
_GUICtrlEdit_GetText ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | a string from the edit control.
Failure: | an empty string.

Related

_GUICtrlEdit_AppendText, _GUICtrlEdit_GetTextLen, _GUICtrlEdit_SetText

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idEdit

    ; Create GUI
    GUICreate("Edit Get Text", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Set Text
    _GUICtrlEdit_SetText($idEdit, "This is a test" & @CRLF & "Another Line" & @CRLF & "Append to the end?")

    ; Get Text
    MsgBox($MB_SYSTEMMODAL, "Information", _GUICtrlEdit_GetText($idEdit))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_GetTextLen

Function Reference

_GUICtrlEdit_GetTextLen

Get the length of all the text from the edit control

#include <GuiEdit.au3>
_GUICtrlEdit_GetTextLen ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the length of text in edit control.

Related

_GUICtrlEdit_GetText

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
    Local $aPartRightSide[2] = [378, -1]

    ; Create GUI
    $hGUI = GUICreate("Edit Get Text Len", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 1, 97, "shell32.dll")
    GUISetState(@SW_SHOW)

    ; Set Margins
    _GUICtrlEdit_SetMargins($idEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10)

    ; Set Text
    _GUICtrlEdit_SetText($idEdit, FileRead($sFile))

    ; Get Text Len
    _GUICtrlStatusBar_SetText($hStatusBar, "Text Len: " & _GUICtrlEdit_GetTextLen($idEdit) & " chars")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_HideBalloonTip

Function Reference

_GUICtrlEdit_HideBalloonTip

Hides any balloon tip associated with an edit control

#include <GuiEdit.au3>
_GUICtrlEdit_HideBalloonTip ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlEdit_ShowBalloonTip

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>

Example()

Func Example()
    Local $hGui, $hEdit, $sTitle = "ShowBalloonTip", $sText = "Displays a balloon tip associated with an edit control"

    ; Create GUI
    $hGui = GUICreate("Edit ShowBalloonTip", 400, 300)
    $hEdit = _GUICtrlEdit_Create($hGui, "", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Set Text
    _GUICtrlEdit_SetText($hEdit, "This is a test" & @CRLF & "Another Line" & @CRLF & "Append to the end?" & @CRLF & @CRLF)

    _GUICtrlEdit_ShowBalloonTip($hEdit, $sTitle, $sText, $TTI_INFO)
    Sleep(1000)
    Local $idBalloon = _GUICtrlEdit_HideBalloonTip($hEdit)
    _GUICtrlEdit_AppendText($hEdit, "HideBalloonTip = " & $idBalloon & @CRLF)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_InsertText

Function Reference

_GUICtrlEdit_InsertText

Insert text

#include <GuiEdit.au3>
_GUICtrlEdit_InsertText ( $hWnd, $sText [, $iIndex = -1] )

Parameters

$hWnd | Control ID/Handle to the control
$sText | String to insert
$iIndex | [optional] Character position to insert

Return Value

None.

Related

_GUICtrlEdit_AppendText

Example

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

Example()

Func Example()
    Local $idEdit
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"

    ; Create GUI
    GUICreate("Edit Insert Text", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    GUISetState(@SW_SHOW)

    ; Set Margins
    _GUICtrlEdit_SetMargins($idEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10)

    ; Set Text
    _GUICtrlEdit_SetText($idEdit, FileRead($sFile))

    ; Insert text
    _GUICtrlEdit_InsertText($idEdit, "*** Excellent UDFs ***" & @CRLF & @CRLF, 0)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_LineFromChar

Function Reference

_GUICtrlEdit_LineFromChar

Retrieves the index of the line that contains the specified character index

#include <GuiEdit.au3>
_GUICtrlEdit_LineFromChar ( $hWnd [, $iIndex = -1] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | [optional] The character index of the character contained in the line whose number is to be retrieved

Return Value

Returns the 0-based line number of the line containing the character index specified by $iIndex.

Remarks

If $iIndex is –1, _GUICtrlEdit_LineFromChar() retrieves either the line number of the current line (the line containing the caret) or, if there is a selection, the line number of the line containing the beginning of the selection.

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI, $iRandom
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"

    ; Create GUI
    $hGUI = GUICreate("Edit Line From Char", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Set Text
    _GUICtrlEdit_SetText($idEdit, FileRead($sFile))

    ; Line From Char
    $iRandom = Random(0, _GUICtrlEdit_GetTextLen($idEdit) - 1, 1)
    _GUICtrlEdit_SetSel($idEdit, $iRandom - 1, $iRandom)
    _GUICtrlStatusBar_SetText($hStatusBar, "Character  " & $iRandom & " is in a line: " & _GUICtrlEdit_LineFromChar($idEdit, $iRandom))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_LineIndex

Function Reference

_GUICtrlEdit_LineIndex

Retrieves the character index of the first character of a specified line

#include <GuiEdit.au3>
_GUICtrlEdit_LineIndex ( $hWnd [, $iIndex = -1] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | [optional] Specifies the 0-based line number

Return Value

Success: | the character index of the line specified in the $iIndex parameter.
Failure: | –1 if the specified line number is greater than the number of lines in the edit control.

Remarks

$iIndex = –1 specifies the current line number (the line that contains the caret).

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
    Local $aPartRightSide[2] = [378, -1], $iRandom

    ; Create GUI
    $hGUI = GUICreate("Edit Line Index", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 1, 97, "shell32.dll")
    GUISetState(@SW_SHOW)

    ; Set Margins
    _GUICtrlEdit_SetMargins($idEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10)

    ; Set Text
    _GUICtrlEdit_SetText($idEdit, FileRead($sFile))

    ; Line Index
    $iRandom = Random(0, _GUICtrlEdit_GetLineCount($idEdit) - 1, 1)
    _GUICtrlStatusBar_SetText($hStatusBar, "Char Index: " & _GUICtrlEdit_LineIndex($idEdit, $iRandom) & " from Line: " & $iRandom)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_LineLength

Function Reference

_GUICtrlEdit_LineLength

Retrieves the length, in characters, of a line

#include <GuiEdit.au3>
_GUICtrlEdit_LineLength ( $hWnd [, $iIndex = -1] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | [optional] Specifies the 0-based line index of the line whose length is to be retrieved

Return Value

Success: | the length, in TCHARs, of the line specified by the $iIndex parameter.
Failure: | 0, if $iIndex is greater than the number of characters in the control.

Remarks

$iIndex = –1 specifies the current line number (the line that contains the caret).

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
    Local $aPartRightSide[2] = [378, -1], $iRandom

    ; Create GUI
    $hGUI = GUICreate("Edit Line Length", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 1, 97, "shell32.dll")
    GUISetState(@SW_SHOW)

    ; Set Margins
    _GUICtrlEdit_SetMargins($idEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10)

    ; Set Text
    _GUICtrlEdit_SetText($idEdit, FileRead($sFile))

    ; Line Length
    $iRandom = Random(0, 7, 1)
    _GUICtrlStatusBar_SetText($hStatusBar, "Length: " & _GUICtrlEdit_LineLength($idEdit, $iRandom) & " chars on Line Index: " & $iRandom)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_LineScroll

Function Reference

_GUICtrlEdit_LineScroll

Scrolls the text

#include <GuiEdit.au3>
_GUICtrlEdit_LineScroll ( $hWnd, $iHoriz, $iVert )

Parameters

$hWnd | Control ID/Handle to the control
$iHoriz | Specifies the number of characters to scroll horizontally.
$iVert | Specifies the number of lines to scroll vertically.

Return Value

Success: | True.
Failure: | False.

Remarks

The control does not scroll vertically past the last line of text in the edit control.

If the current line plus the number of lines specified by the $iVert parameter exceeds the total number of lines in the edit control, the value is adjusted so that the last line of the edit control is scrolled to the top of the edit-control window.

_GUICtrlEdit_LineScroll() scrolls the text vertically or horizontally.
_GUICtrlEdit_LineScroll() can be used to scroll horizontally past the last character of any line.

Related

_GUICtrlEdit_Scroll

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI, $sText

    ; Create GUI
    $hGUI = GUICreate("Edit Line Scroll", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Set Text
    For $i = 1 To 50
        $sText &= $i & @CRLF
    Next
    _GUICtrlEdit_SetText($idEdit, $sText)

    ; Scroll
    _GUICtrlStatusBar_SetText($hStatusBar, "Scrolled: " & _GUICtrlEdit_LineScroll($idEdit, 0, _GUICtrlEdit_GetLineCount($idEdit)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_PosFromChar

Function Reference

_GUICtrlEdit_PosFromChar

Retrieves the client area coordinates of a specified character in an edit control

#include <GuiEdit.au3>
_GUICtrlEdit_PosFromChar ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | The 0-based index of the character

Return Value

Returns an array in the following format:
[0] - The horizontal coordinate
[1] - The vertical coordinate

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI, $iIndex
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
    Local $aPartRightSide[2] = [80, -1], $aPos

    ; Create GUI
    $hGUI = GUICreate("Edit Pos From Char", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_NOHIDESEL))
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
    GUISetState(@SW_SHOW)

    ; Set Margins
    _GUICtrlEdit_SetMargins($idEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10)

    ; Set Text
    _GUICtrlEdit_SetText($idEdit, FileRead($sFile))

    ; Pos From Char
    $iIndex = 100
    $aPos = _GUICtrlEdit_PosFromChar($idEdit, $iIndex)
    _GUICtrlEdit_SetSel($idEdit, $iIndex, $iIndex + 1)
    _GUICtrlStatusBar_SetText($hStatusBar, "X = " & $aPos[0])
    _GUICtrlStatusBar_SetText($hStatusBar, "Y = " & $aPos[1], 1)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_ReplaceSel

Function Reference

_GUICtrlEdit_ReplaceSel

Replaces the current selection

#include <GuiEdit.au3>
_GUICtrlEdit_ReplaceSel ( $hWnd, $sText [, $bUndo = True] )

Parameters

$hWnd | Control ID/Handle to the control
$sText | String containing the replacement text.
$bUndo | [optional] Specifies whether the replacement operation can be undone: True - The operation can be undone. False - The operation cannot be undone.

Return Value

None.

Remarks

Use the _GUICtrlEdit_ReplaceSel() to replace only a portion of the text in an edit control.
If there is no current selection, the replacement text is inserted at the current location of the caret.

Related

_GUICtrlEdit_GetSel, _GUICtrlEdit_SetSel

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
    Local $aPartRightSide[3] = [200, 378, -1]

    ; Create GUI
    $hGUI = GUICreate("Edit Replace Sel", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 2, 97, "shell32.dll")
    GUISetState(@SW_SHOW)

    ; Set Margins
    _GUICtrlEdit_SetMargins($idEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10)

    ; Set Text
    _GUICtrlEdit_SetText($idEdit, FileRead($sFile))

    ; Set Sel
    _GUICtrlEdit_SetSel($idEdit, 0, 8)

    MsgBox($MB_SYSTEMMODAL, "Information", "Replace Sel")
    _GUICtrlEdit_ReplaceSel($idEdit, StringFormat("%d/%2d/%4d", @MON, @MDAY, @YEAR))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_Scroll

Function Reference

_GUICtrlEdit_Scroll

Scrolls the text vertically

#include <GuiEdit.au3>
_GUICtrlEdit_Scroll ( $hWnd, $iDirection )

Parameters

$hWnd | Control ID/Handle to the control
$iDirection | This parameter can be one of the following values: $SB_LINEDOWN - Scrolls down one line $SB_LINEUP - Scrolls up one line $SB_PAGEDOWN - Scrolls down one page $SB_PAGEUP - Scrolls up one page $SB_SCROLLCARET - Scrolls the caret into view

Return Value

Success: | The high-order word of the return value is 1. The low-order word is the number of lines that the command scrolls.
Failure: | 0.

Remarks

$SB_xxxxx require #include <ScrollBarsConstants.au3>

Related

_GUICtrlEdit_LineScroll

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <MsgBoxConstants.au3>
#include <ScrollBarsConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idEdit, $sText, $iLen

    ; Create GUI
    GUICreate("Edit Scroll", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    GUISetState(@SW_SHOW)

    ; Set Text
    For $i = 1 To 50
        $sText &= $i & @CRLF
    Next
    _GUICtrlEdit_SetText($idEdit, $sText)

    MsgBox($MB_SYSTEMMODAL, "Information", "Scroll Line Down")
    _GUICtrlEdit_Scroll($idEdit, $SB_LINEDOWN)

    MsgBox($MB_SYSTEMMODAL, "Information", "Scroll Line Up")
    _GUICtrlEdit_Scroll($idEdit, $SB_LINEUP)

    MsgBox($MB_SYSTEMMODAL, "Information", "Scroll Page Down")
    _GUICtrlEdit_Scroll($idEdit, $SB_PAGEDOWN)

    MsgBox($MB_SYSTEMMODAL, "Information", "Scroll Page Up")
    _GUICtrlEdit_Scroll($idEdit, $SB_PAGEUP)

    $iLen = _GUICtrlEdit_GetTextLen($idEdit)
    _GUICtrlEdit_SetSel($idEdit, $iLen, $iLen)

    MsgBox($MB_SYSTEMMODAL, "Information", "Scroll Caret")
    _GUICtrlEdit_Scroll($idEdit, $SB_SCROLLCARET)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_SetCueBanner

Function Reference

_GUICtrlEdit_SetCueBanner

Sets the cue banner text that is displayed for the edit control

#include <GuiEdit.au3>
_GUICtrlEdit_SetCueBanner ( $hWnd, $sText [, $bOnFocus = False] )

Parameters

$hWnd | Control ID/Handle to the control
$sText | String that contains the text
$bOnFocus | [optional] True - if the cue banner should show even when the edit control has focus. False (Default) - the cue banner disappears when the user clicks in the control.

Return Value

Success: | True.
Failure: | False.

Remarks

The cue banner is text that is displayed in the edit control when there is no selection.

Windows Vista or later.

Related

_GUICtrlEdit_GetCueBanner

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate('Example', 300, 150)
    GUISetFont(9, 400, 0, 'Segoe UI')

    Local $idUsername = GUICtrlCreateInput('', 10, 10, 125, 25)
    _GUICtrlEdit_SetCueBanner($idUsername, "Search folder")

    Local $idPassword = GUICtrlCreateInput('', 10, 40, 125, 25)
    _GUICtrlEdit_SetCueBanner($idPassword, "Search...")

    Local $idClose = GUICtrlCreateButton("Close", 210, 120, 85, 25)
    ControlFocus($hGUI, "", $idClose)

    GUISetState(@SW_SHOW, $hGUI)

    MsgBox($MB_SYSTEMMODAL, "", _GUICtrlEdit_GetCueBanner($idPassword))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idClose
                ExitLoop

        EndSwitch
    WEnd

    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUICtrlEdit_SetLimitText

Function Reference

_GUICtrlEdit_SetLimitText

Sets the text limit

#include <GuiEdit.au3>
_GUICtrlEdit_SetLimitText ( $hWnd, $iLimit )

Parameters

$hWnd | Control ID/Handle to the control
$iLimit | The maximum number of TCHARs the user can enter

Return Value

None.

Remarks

The _GUICtrlEdit_SetLimitText() function limits only the text the user can enter.
It does not affect any text already in the edit control when the message is sent, nor does it affect the length of the text copied to the edit control by the _GUICtrlEdit_SetText() function.
If an application uses the _GUICtrlEdit_SetText() function to place more text into an edit control than is specified in the _GUICtrlEdit_SetLimitText() function, the user can edit the entire contents of the edit control.

Related

_GUICtrlEdit_GetLimitText

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idEdit

    ; Create GUI
    GUICreate("Edit Set Limit Text", 400, 300)
    $idEdit = GUICtrlCreateEdit("This is a test" & @CRLF & "Another Line", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Text Limit: " & _GUICtrlEdit_GetLimitText($idEdit))

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Text Limit")
    _GUICtrlEdit_SetLimitText($idEdit, 64000)

    MsgBox($MB_SYSTEMMODAL, "Information", "Text Limit: " & _GUICtrlEdit_GetLimitText($idEdit))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_SetMargins

Function Reference

_GUICtrlEdit_SetMargins

Sets the widths of the left and right margins

#include <GuiEdit.au3>
_GUICtrlEdit_SetMargins ( $hWnd [, $iMargin = 0x1 [, $iLeft = 0xFFFF [, $iRight = 0xFFFF]]] )

Parameters

$hWnd | Control ID/Handle to the control
$iMargin | [optional] Can be one or more of the following $EC_LEFTMARGIN - Sets the left margin $EC_RIGHTMARGIN - Sets the right margin Default: $EC_LEFTMARGIN
$iLeft | [optional] The new width of the left margin Default: $EC_USEFONTINFO
$iRight | [optional] The new width of the right margin Default: $EC_USEFONTINFO

Return Value

Returns an array in the following format:
[0] - The width of the left margin
[1] - The width of the right margin

Related

_GUICtrlEdit_GetMargins

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
    Local $aPartRightSide[3] = [190, 378, -1], $aMargins

    ; Create GUI
    $hGUI = GUICreate("Edit Set Margins", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 2, 97, "shell32.dll")
    GUISetState(@SW_SHOW)

    ; Set Margins
    _GUICtrlEdit_SetMargins($idEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10)

    ; Set Text
    _GUICtrlEdit_SetText($idEdit, FileRead($sFile))

    ; Get Margins
    $aMargins = _GUICtrlEdit_GetMargins($idEdit)
    _GUICtrlStatusBar_SetText($hStatusBar, "Left Margin: " & $aMargins[0])
    _GUICtrlStatusBar_SetText($hStatusBar, "Right Margin: " & $aMargins[1], 1)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_SetModify

Function Reference

_GUICtrlEdit_SetModify

Sets or clears the modification flag

#include <GuiEdit.au3>
_GUICtrlEdit_SetModify ( $hWnd, $bModified )

Parameters

$hWnd | Control ID/Handle to the control
$bModified | Specifies the new value for the modification flag: True - Indicates the text has been modified. False - Indicates it has not been modified.

Return Value

None.

Remarks

The system automatically clears the modification flag to zero when the control is created.
If the user changes the control's text, the system sets the flag to nonzero.
You can use the _GUICtrlEdit_GetModify() to retrieve the current state of the flag.

Related

_GUICtrlEdit_CanUndo, _GUICtrlEdit_GetModify

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
    Local $aPartRightSide[4] = [120, 248, 378, -1]

    ; Create GUI
    $hGUI = GUICreate("Edit Set Modify", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268)
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 3, 97, "shell32.dll")
    GUISetState(@SW_SHOW)

    ; Set Margins
    _GUICtrlEdit_SetMargins($idEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10)

    ; Add Text
    _GUICtrlEdit_SetText($idEdit, FileRead($sFile))
    _GUICtrlEdit_LineScroll($idEdit, 0, _GUICtrlEdit_GetLineCount($idEdit) * -1)

    ; Get Modified Flag
    _GUICtrlStatusBar_SetText($hStatusBar, "Modified: " & _GUICtrlEdit_GetModify($idEdit), 2)

    MsgBox($MB_SYSTEMMODAL, "Information", "Set Modify Flag")
    ; Set Modified Flag
    _GUICtrlEdit_SetModify($idEdit, True)

    ; Get Modified Flag
    _GUICtrlStatusBar_SetText($hStatusBar, "Modified: " & _GUICtrlEdit_GetModify($idEdit), 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_SetPasswordChar

Function Reference

_GUICtrlEdit_SetPasswordChar

Sets or removes the password character for an edit control

#include <GuiEdit.au3>
_GUICtrlEdit_SetPasswordChar ( $hWnd [, $sDisplayChar = "0"] )

Parameters

$hWnd | Control ID/Handle to the control
$sDisplayChar | [optional] The character to be displayed in place of the characters typed by the user If this parameter is zero, the control removes the current password character and displays the characters typed by the user

Return Value

None.

Related

_GUICtrlEdit_GetPasswordChar

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idEdit

    ; Create GUI
    GUICreate("(Internal) Edit Get Password Char", 400, 300)
    $idEdit = GUICtrlCreateInput("Test of build-in control", 2, 2, 394, 25, $ES_PASSWORD)
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Password Char: " & _GUICtrlEdit_GetPasswordChar($idEdit))

    _GUICtrlEdit_SetPasswordChar($idEdit, "$") ; change password char to $

    MsgBox($MB_SYSTEMMODAL, "Information", "Password Char: " & _GUICtrlEdit_GetPasswordChar($idEdit))

    _GUICtrlEdit_SetPasswordChar($idEdit) ; display characters typed by the user.

    MsgBox($MB_SYSTEMMODAL, "Information", "Password Char: " & _GUICtrlEdit_GetPasswordChar($idEdit))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_SetReadOnly

Function Reference

_GUICtrlEdit_SetReadOnly

Sets or removes the read-only style ($ES_READONLY)

#include <GuiEdit.au3>
_GUICtrlEdit_SetReadOnly ( $hWnd, $bReadOnly )

Parameters

$hWnd | Control ID/Handle to the control
$bReadOnly | Following values: True - Sets the $ES_READONLY style False - Removes the $ES_READONLY style

Return Value

Success: | True.
Failure: | False.

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
    Local $aPartRightSide[4] = [120, 248, 378, -1]

    ; Create GUI
    $hGUI = GUICreate("Edit Set Read Only", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268)
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 3, 97, "shell32.dll")
    GUISetState(@SW_SHOW)

    ; Set Margins
    _GUICtrlEdit_SetMargins($idEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10)

    ; Add Text
    _GUICtrlEdit_SetText($idEdit, FileRead($sFile))
    _GUICtrlEdit_LineScroll($idEdit, 0, _GUICtrlEdit_GetLineCount($idEdit) * -1)

    ; Get Modified Flag
    _GUICtrlStatusBar_SetText($hStatusBar, "Modified: " & _GUICtrlEdit_GetModify($idEdit), 2)

    ; Set Read Only
    _GUICtrlEdit_SetReadOnly($idEdit, True)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_SetRECT

Function Reference

_GUICtrlEdit_SetRECT

Sets the formatting rectangle of a multiline edit control

#include <GuiEdit.au3>
_GUICtrlEdit_SetRECT ( $hWnd, $aRect )

Parameters

$hWnd | Control ID/Handle to the control
$aRect | Array in the following format: [0] - Specifies the x-coordinate of the upper-left corner of the rectangle. [1] - Specifies the y-coordinate of the upper-left corner of the rectangle. [2] - Specifies the x-coordinate of the lower-right corner of the rectangle. [3] - Specifies the y-coordinate of the lower-right corner of the rectangle.

Return Value

None.

Related

_GUICtrlEdit_SetRECTEx

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
    Local $aPartRightSide[6] = [50, 130, 210, 290, 378, -1], $aRect

    ; Create GUI
    $hGUI = GUICreate("Edit Set RECT", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 5, 97, "shell32.dll")
    _GUICtrlStatusBar_SetText($hStatusBar, "Rect")
    GUISetState(@SW_SHOW)

    ; Get Rect
    $aRect = _GUICtrlEdit_GetRECT($idEdit)
    $aRect[0] += 10
    $aRect[1] += 10
    $aRect[2] -= 10
    $aRect[3] -= 10

    ; Add Text
    _GUICtrlEdit_AppendText($idEdit, FileRead($sFile))
    _GUICtrlEdit_LineScroll($idEdit, 0, _GUICtrlEdit_GetLineCount($idEdit) * -1)

    ; Set Rect
    _GUICtrlEdit_SetRECT($idEdit, $aRect)

    ; Get Rect
    $aRect = _GUICtrlEdit_GetRECT($idEdit)
    _GUICtrlStatusBar_SetText($hStatusBar, "Left: " & $aRect[0], 1)
    _GUICtrlStatusBar_SetText($hStatusBar, "Topt: " & $aRect[1], 2)
    _GUICtrlStatusBar_SetText($hStatusBar, "Right: " & $aRect[2], 3)
    _GUICtrlStatusBar_SetText($hStatusBar, "Bottom: " & $aRect[3], 4)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_SetRECTEx

Function Reference

_GUICtrlEdit_SetRECTEx

Sets the formatting rectangle of a multiline edit control

#include <GuiEdit.au3>
_GUICtrlEdit_SetRECTEx ( $hWnd, $tRECT )

Parameters

$hWnd | Control ID/Handle to the control
$tRECT | $tagRECT structure that contains formatting rectangle of an edit control

Return Value

None.

Related

$tagRECT, _GUICtrlEdit_SetRECT

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
    Local $aPartRightSide[6] = [50, 130, 210, 290, 378, -1], $tRECT

    ; Create GUI
    $hGUI = GUICreate("Edit Set RECTEx", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 5, 97, "shell32.dll")
    _GUICtrlStatusBar_SetText($hStatusBar, "Rect")
    GUISetState(@SW_SHOW)

    ; Get RectEx
    $tRECT = _GUICtrlEdit_GetRECTEx($idEdit)
    DllStructSetData($tRECT, "Left", DllStructGetData($tRECT, "Left") + 10)
    DllStructSetData($tRECT, "Top", DllStructGetData($tRECT, "Top") + 10)
    DllStructSetData($tRECT, "Right", DllStructGetData($tRECT, "Right") - 10)
    DllStructSetData($tRECT, "Bottom", DllStructGetData($tRECT, "Bottom") - 10)

    ; Add Text
    _GUICtrlEdit_AppendText($idEdit, FileRead($sFile))
    _GUICtrlEdit_LineScroll($idEdit, 0, _GUICtrlEdit_GetLineCount($idEdit) * -1)

    ; Set RectEx
    _GUICtrlEdit_SetRECTEx($idEdit, $tRECT)

    ; Get RectEx
    $tRECT = _GUICtrlEdit_GetRECTEx($idEdit)
    _GUICtrlStatusBar_SetText($hStatusBar, "Left: " & DllStructGetData($tRECT, "Left"), 1)
    _GUICtrlStatusBar_SetText($hStatusBar, "Topt: " & DllStructGetData($tRECT, "Top"), 2)
    _GUICtrlStatusBar_SetText($hStatusBar, "Right: " & DllStructGetData($tRECT, "Right"), 3)
    _GUICtrlStatusBar_SetText($hStatusBar, "Bottom: " & DllStructGetData($tRECT, "Bottom"), 4)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_SetRECTNP

Function Reference

_GUICtrlEdit_SetRECTNP

Sets the formatting rectangle of a multiline edit control

#include <GuiEdit.au3>
_GUICtrlEdit_SetRECTNP ( $hWnd, $aRect )

Parameters

$hWnd | Control ID/Handle to the control
$aRect | Array in the following format: [0] - Specifies the x-coordinate of the upper-left corner of the rectangle. [1] - Specifies the y-coordinate of the upper-left corner of the rectangle. [2] - Specifies the x-coordinate of the lower-right corner of the rectangle. [3] - Specifies the y-coordinate of the lower-right corner of the rectangle.

Return Value

None.

Remarks

The _GUICtrlEdit_SetRECTNP() function is identical to the _GUICtrlEdit_SetRECT() function, except that _GUICtrlEdit_SetRECTNP() does not redraw the edit control window.

Related

_GUICtrlEdit_SetRectNPEx

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
    Local $aPartRightSide[6] = [50, 130, 210, 290, 378, -1], $aRect

    ; Create GUI
    $hGUI = GUICreate("Edit Set RECTNP", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 5, 97, "shell32.dll")
    _GUICtrlStatusBar_SetText($hStatusBar, "Rect")
    GUISetState(@SW_SHOW)

    ; Get Rect
    $aRect = _GUICtrlEdit_GetRECT($idEdit)
    $aRect[0] += 10
    $aRect[1] += 10
    $aRect[2] -= 10
    $aRect[3] -= 10

    ; Add Text
    _GUICtrlEdit_AppendText($idEdit, FileRead($sFile))
    _GUICtrlEdit_LineScroll($idEdit, 0, _GUICtrlEdit_GetLineCount($idEdit) * -1)

    ; Set Rect
    _GUICtrlEdit_SetRECTNP($idEdit, $aRect)

    ; Get Rect
    $aRect = _GUICtrlEdit_GetRECT($idEdit)
    _GUICtrlStatusBar_SetText($hStatusBar, "Left: " & $aRect[0], 1)
    _GUICtrlStatusBar_SetText($hStatusBar, "Topt: " & $aRect[1], 2)
    _GUICtrlStatusBar_SetText($hStatusBar, "Right: " & $aRect[2], 3)
    _GUICtrlStatusBar_SetText($hStatusBar, "Bottom: " & $aRect[3], 4)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_SetRectNPEx

Function Reference

_GUICtrlEdit_SetRectNPEx

Sets the formatting rectangle of a multiline edit control

#include <GuiEdit.au3>
_GUICtrlEdit_SetRectNPEx ( $hWnd, $tRECT )

Parameters

$hWnd | Control ID/Handle to the control
$tRECT | $tagRECT structure that contains formatting rectangle of an edit control

Return Value

None.

Remarks

The _GUICtrlEdit_SetRectNPEx() is identical to the _GUICtrlEdit_SetRECTEx(), except that _GUICtrlEdit_SetRectNPEx() does not redraw the edit control window.

Related

$tagRECT, _GUICtrlEdit_SetRECTNP

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
    Local $aPartRightSide[6] = [50, 130, 210, 290, 378, -1], $tRECT

    ; Create GUI
    $hGUI = GUICreate("Edit Set RECTNPEx", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 5, 97, "shell32.dll")
    _GUICtrlStatusBar_SetText($hStatusBar, "Rect")
    GUISetState(@SW_SHOW)

    ; Get RectEx
    $tRECT = _GUICtrlEdit_GetRECTEx($idEdit)
    DllStructSetData($tRECT, "Left", DllStructGetData($tRECT, "Left") + 10)
    DllStructSetData($tRECT, "Top", DllStructGetData($tRECT, "Top") + 10)
    DllStructSetData($tRECT, "Right", DllStructGetData($tRECT, "Right") - 10)
    DllStructSetData($tRECT, "Bottom", DllStructGetData($tRECT, "Bottom") - 10)

    ; Add Text
    _GUICtrlEdit_AppendText($idEdit, FileRead($sFile))
    _GUICtrlEdit_LineScroll($idEdit, 0, _GUICtrlEdit_GetLineCount($idEdit) * -1)

    ; Set RectEx
    _GUICtrlEdit_SetRectNPEx($idEdit, $tRECT)

    ; Get RectEx
    $tRECT = _GUICtrlEdit_GetRECTEx($idEdit)
    _GUICtrlStatusBar_SetText($hStatusBar, "Left: " & DllStructGetData($tRECT, "Left"), 1)
    _GUICtrlStatusBar_SetText($hStatusBar, "Topt: " & DllStructGetData($tRECT, "Top"), 2)
    _GUICtrlStatusBar_SetText($hStatusBar, "Right: " & DllStructGetData($tRECT, "Right"), 3)
    _GUICtrlStatusBar_SetText($hStatusBar, "Bottom: " & DllStructGetData($tRECT, "Bottom"), 4)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_SetSel

Function Reference

_GUICtrlEdit_SetSel

Selects a range of characters

#include <GuiEdit.au3>
_GUICtrlEdit_SetSel ( $hWnd, $iStart, $iEnd )

Parameters

$hWnd | Control ID/Handle to the control
$iStart | Specifies the starting character position of the selection.
$iEnd | Specifies the ending character position of the selection.

Return Value

None.

Remarks

The start value can be greater than the end value.
The lower of the two values specifies the character position of the first character in the selection.
The higher value specifies the position of the first character beyond the selection.

The start value is the anchor point of the selection, and the end value is the active end.
If the user uses the SHIFT key to adjust the size of the selection, the active end can move but the anchor point remains the same.

If the $iStart is 0 and the $iEnd is –1, all the text in the edit control is selected.
If the $iStart is –1, any current selection is deselected.

The control displays a flashing caret at the $iEnd position regardless of the relative values of $iStart and $iEnd.

Related

_GUICtrlEdit_GetSel, _GUICtrlEdit_ReplaceSel

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
    Local $aPartRightSide[3] = [190, 378, -1], $aSel

    ; Create GUI
    $hGUI = GUICreate("Edit Set Sel", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 2, 97, "shell32.dll")
    GUISetState(@SW_SHOW)

    ; Set Margins
    _GUICtrlEdit_SetMargins($idEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10)

    ; Set Text
    _GUICtrlEdit_SetText($idEdit, FileRead($sFile))

    ; Set Sel
    _GUICtrlEdit_SetSel($idEdit, 15, 20)

    ; Get Sel
    $aSel = _GUICtrlEdit_GetSel($idEdit)
    _GUICtrlStatusBar_SetText($hStatusBar, "Start: " & $aSel[0])
    _GUICtrlStatusBar_SetText($hStatusBar, "End: " & $aSel[1], 1)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_SetTabStops

Function Reference

_GUICtrlEdit_SetTabStops

Sets the tab stops

#include <GuiEdit.au3>
_GUICtrlEdit_SetTabStops ( $hWnd, $aTabStops )

Parameters

$hWnd | Control ID/Handle to the control
$aTabStops | Array of tab stops in the following format: [0] - Tab stop 1 [2] - Tab stop 2 [n] - Tab stop n

Return Value

True: | All the tabs are set.
False: | All the tabs are not set.

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hStatusBar, $idEdit, $hGUI
    Local $aPartRightSide[3] = [190, 378, -1], $aTabStops[3] = [10, 30, 50]

    ; Create GUI
    $hGUI = GUICreate("Edit Set Tab Stops", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
    $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
    _GUICtrlStatusBar_SetIcon($hStatusBar, 2, 97, "shell32.dll")
    GUISetState(@SW_SHOW)

    ; Set Margins
    _GUICtrlEdit_SetMargins($idEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10)

    ; Set Text
    _GUICtrlEdit_SetText($idEdit, @TAB & "1st" & @TAB & "2nd" & @TAB & "3rd")

    MsgBox($MB_SYSTEMMODAL, "Information", "Set Tab Stops")
    ; Set Tab Stops
    _GUICtrlEdit_SetTabStops($idEdit, $aTabStops)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_SetText

Function Reference

_GUICtrlEdit_SetText

Set the text

#include <GuiEdit.au3>
_GUICtrlEdit_SetText ( $hWnd, $sText )

Parameters

$hWnd | Control ID/Handle to the control
$sText | String to place in edit control

Return Value

None.

Related

_GUICtrlEdit_AppendText, _GUICtrlEdit_GetText

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idEdit

    ; Create GUI
    GUICreate("Edit Set Text", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Set Text
    _GUICtrlEdit_SetText($idEdit, "This is a test" & @CRLF & "Another Line" & @CRLF & "Append to the end?")

    ; Get Text
    MsgBox($MB_SYSTEMMODAL, "Information", _GUICtrlEdit_GetText($idEdit))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_ShowBalloonTip

Function Reference

_GUICtrlEdit_ShowBalloonTip

Displays a balloon tip associated with an edit control

#include <GuiEdit.au3>
_GUICtrlEdit_ShowBalloonTip ( $hWnd, $sTitle, $sText, $iIcon )

Parameters

$hWnd | Control ID/Handle to the control
$sTitle | String for title of ToolTip (Unicode)
$sText | String for text of ToolTip (Unicode)
$iIcon | Icon can be one of the following: $TTI_ERROR - Use the error icon $TTI_INFO - Use the information icon $TTI_NONE - Use no icon $TTI_WARNING - Use the warning icon The following for Windows Vista or later $TTI_ERROR_LARGE - Use the error icon $TTI_INFO_LARGE - Use the information icon $TTI_WARNING_LARGE - Use the warning icon

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlEdit_HideBalloonTip

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>

Example()

Func Example()
    Local $idEdit, $sTitle = "ShowBalloonTip", $sText = "Displays a balloon tip associated with an edit control"

    ; Create GUI
    GUICreate("Edit ShowBalloonTip", 400, 300)
    $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Set Text
    _GUICtrlEdit_SetText($idEdit, "This is a test" & @CRLF & "Another Line" & @CRLF & "Append to the end?")

    _GUICtrlEdit_ShowBalloonTip($idEdit, $sTitle, $sText, $TTI_INFO)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlEdit_Undo

Function Reference

_GUICtrlEdit_Undo

Undoes the last edit control operation in the control's undo queue

#include <GuiEdit.au3>
_GUICtrlEdit_Undo ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Remarks

An undo operation can also be undone.
For example, you can restore deleted text with the first _GUICtrlEdit_Undo(), and remove the text again with a second _GUICtrlEdit_Undo() as long as there is no intervening edit operation.

Related

_GUICtrlEdit_CanUndo, _GUICtrlEdit_EmptyUndoBuffer, _GUICtrlEdit_GetModify

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idEdit

    ; Create GUI
    GUICreate("Edit Undo", 400, 300)
    $idEdit = GUICtrlCreateEdit("This is a test" & @CRLF & "Another Line", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    _GUICtrlEdit_AppendText($idEdit, @CRLF & "Append to the end?")

    ; Undo
    MsgBox($MB_SYSTEMMODAL, "Information", "Undo")
    _GUICtrlEdit_Undo($idEdit)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


User Defined Functions

GuiHeader user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiHeader.au3>.

User Defined Function | Description
_GUICtrlHeader_AddItem | Adds a new header item
_GUICtrlHeader_ClearFilter | Clears the filter
_GUICtrlHeader_ClearFilterAll | Clears all of the filters
_GUICtrlHeader_Create | Creates a Header control
_GUICtrlHeader_CreateDragImage | Creates a semi-transparent version of an item's image for use as a dragging image
_GUICtrlHeader_DeleteItem | Deletes a header item
_GUICtrlHeader_Destroy | Delete the Header control
_GUICtrlHeader_EditFilter | Starts editing the specified filter
_GUICtrlHeader_GetBitmapMargin | Retrieves the width of the bitmap margin
_GUICtrlHeader_GetImageList | Retrieves the handle to the image list
_GUICtrlHeader_GetItem | Retrieves information about an item
_GUICtrlHeader_GetItemAlign | Retrieves the item text alignment
_GUICtrlHeader_GetItemBitmap | Retrieves the item bitmap handle
_GUICtrlHeader_GetItemCount | Retrieves a count of the items
_GUICtrlHeader_GetItemDisplay | Returns the item display information
_GUICtrlHeader_GetItemFlags | Returns the item flag information
_GUICtrlHeader_GetItemFormat | Returns the format of the item
_GUICtrlHeader_GetItemImage | Retrieves the index of an image within the image list
_GUICtrlHeader_GetItemOrder | Retrieves the order in which the item appears
_GUICtrlHeader_GetItemParam | Retrieves the param value of the item
_GUICtrlHeader_GetItemRect | Retrieves the bounding rectangle for a given item
_GUICtrlHeader_GetItemRectEx | Retrieves the bounding rectangle for a given item
_GUICtrlHeader_GetItemText | Retrieves the item text
_GUICtrlHeader_GetItemWidth | Retrieves the item's width
_GUICtrlHeader_GetOrderArray | Retrieves the current left-to-right order of items in a header control
_GUICtrlHeader_GetUnicodeFormat | Retrieves the Unicode character format flag for the control
_GUICtrlHeader_HitTest | Tests a point to determine which item is at the specified point
_GUICtrlHeader_InsertItem | Inserts a new header item
_GUICtrlHeader_Layout | Retrieves the correct size and position of the control
_GUICtrlHeader_OrderToIndex | Retrieves an index value for an item based on its order
_GUICtrlHeader_SetBitmapMargin | Sets the width of the margin, specified in pixels, of a bitmap
_GUICtrlHeader_SetFilterChangeTimeout | Sets the filter change timeout interval
_GUICtrlHeader_SetHotDivider | Changes the hot divider color
_GUICtrlHeader_SetImageList | Assigns an image list
_GUICtrlHeader_SetItem | Sets information about an item
_GUICtrlHeader_SetItemAlign | Sets the item text alignment
_GUICtrlHeader_SetItemBitmap | Sets the item bitmap handle
_GUICtrlHeader_SetItemDisplay | Returns the item display information
_GUICtrlHeader_SetItemFlags | Returns the item flag information
_GUICtrlHeader_SetItemFormat | Sets the format of the item
_GUICtrlHeader_SetItemImage | Sets the index of an image within the image list
_GUICtrlHeader_SetItemOrder | Sets the order in which the item appears
_GUICtrlHeader_SetItemParam | Sets the param value of the item
_GUICtrlHeader_SetItemText | Sets the item text
_GUICtrlHeader_SetItemWidth | Sets the item's width
_GUICtrlHeader_SetOrderArray | Sets the current left-to-right order of items
_GUICtrlHeader_SetUnicodeFormat | Sets the Unicode character format flag for the control


Function _GUICtrlHeader_AddItem

Function Reference

_GUICtrlHeader_AddItem

Adds a new header item

#include <GuiHeader.au3>
_GUICtrlHeader_AddItem ( $hWnd, $sText [, $iWidth = 50 [, $iAlign = 0 [, $iImage = -1 [, $bOnRight = False]]]] )

Parameters

$hWnd | Handle to the control
$sText | Item text
$iWidth | [optional] Item width
$iAlign | [optional] Text alignment: 0 - Text is left-aligned 1 - Text is right-aligned 2 - Text is centered
$iImage | [optional] 0-based index of an image within the image list
$bOnRight | [optional] If True, the column image appears to the right of text

Return Value

Success: | the index of the new item.
Failure: | -1.

Related

_GUICtrlHeader_DeleteItem, _GUICtrlHeader_InsertItem

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlHeader_ClearFilter

Function Reference

_GUICtrlHeader_ClearFilter

Clears the filter

#include <GuiHeader.au3>
_GUICtrlHeader_ClearFilter ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlHeader_ClearFilterAll, _GUICtrlHeader_EditFilter

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set up filters
    _GUICtrlHeader_EditFilter($hHeader, 0)
    Send("Filter 1")
    Sleep(1000)
    Send("{ENTER}")
    _GUICtrlHeader_EditFilter($hHeader, 1)
    Send("Filter 2")
    Sleep(1000)
    Send("{ENTER}")

    ; Clear first filter
    _GUICtrlHeader_ClearFilter($hHeader, 0)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlHeader_ClearFilterAll

Function Reference

_GUICtrlHeader_ClearFilterAll

Clears all of the filters

#include <GuiHeader.au3>
_GUICtrlHeader_ClearFilterAll ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlHeader_ClearFilter, _GUICtrlHeader_EditFilter

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set up filters
    _GUICtrlHeader_EditFilter($hHeader, 0)
    Send("Filter 1")
    Sleep(1000)
    Send("{ENTER}")
    _GUICtrlHeader_EditFilter($hHeader, 1)
    Send("Filter 2")
    Sleep(1000)
    Send("{ENTER}")

    ; Clear all filters
    _GUICtrlHeader_ClearFilterAll($hHeader)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlHeader_Create

Function Reference

_GUICtrlHeader_Create

Creates a Header control

#include <GuiHeader.au3>
_GUICtrlHeader_Create ( $hWnd [, $iStyle = 0x00000046] )

Parameters

$hWnd | Handle to parent or owner window
$iStyle | [optional] Control styles: $HDS_BUTTONS - Each item in the control looks and behaves like a push button $HDS_DRAGDROP - Allows drag-and-drop reordering of header items $HDS_FILTERBAR - Include a filter bar as part of the standard header control $HDS_FLAT - Causes the header control to be drawn flat $HDS_FULLDRAG - Causes the header control to display column contents $HDS_HIDDEN - Indicates a header control that is intended to be hidden $HDS_HORZ - Creates a header control with a horizontal orientation $HDS_HOTTRACK - Enables hot tracking Default: $HDS_BUTTONS, $HDS_HOTTRACK, $HDS_DRAGDROP Forced : $WS_CHILD, $WS_VISIBLE

Return Value

Success: | Handle to the Header control
Failure: | 0

Related

_GUICtrlHeader_Destroy

Example

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

Global $g_hHeader

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $g_hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($g_hHeader, True)
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Add columns
    _GUICtrlHeader_AddItem($g_hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($g_hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($g_hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($g_hHeader, "Column 4", 100)

    ; Clear all filters
    _GUICtrlHeader_ClearFilterAll($g_hHeader)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iCode
    Local $tNMHDR, $tNMHEADER, $tNMHDFILTERBTNCLICK, $tNMHDDISPINFO

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hHeader
            Switch $iCode
                Case $HDN_BEGINDRAG ; Sent by a header control when a drag operation has begun on one of its items
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_BEGINDRAG" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    Return False ; To allow the header control to automatically manage drag-and-drop operations
                    ; Return True  ; To indicate external (manual) drag-and-drop management allows the owner of the
                    ; control to provide custom services as part of the drag-and-drop process
                Case $HDN_BEGINTRACK, $HDN_BEGINTRACKW ; Notifies a header control's parent window that the user has begun dragging a divider in the control
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_BEGINTRACK" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    Return False ; To allow tracking of the divider
                    ; Return True  ; To prevent tracking
                Case $HDN_DIVIDERDBLCLICK, $HDN_DIVIDERDBLCLICKW ; Notifies a header control's parent window that the user double-clicked the divider area of the control
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_DIVIDERDBLCLICK" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    ; no return value
                Case $HDN_ENDDRAG ; Sent by a header control when a drag operation has ended on one of its items
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_ENDDRAG" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    Return False ; To allow the control to automatically place and reorder the item
                    ; Return True  ; To prevent the item from being placed
                Case $HDN_ENDTRACK, $HDN_ENDTRACKW ; Notifies a header control's parent window that the user has finished dragging a divider
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_ENDTRACK" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    ; no return value
                Case $HDN_FILTERBTNCLICK ; Notifies the header control's parent window when the filter button is clicked or in response to an $HDM_SETITEM message
                    $tNMHDFILTERBTNCLICK = DllStructCreate($tagNMHDFILTERBTNCLICK, $lParam)
                    _DebugPrint("$HDN_FILTERBTNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHDFILTERBTNCLICK, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHDFILTERBTNCLICK, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHDFILTERBTNCLICK, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHDFILTERBTNCLICK, "Item") & @CRLF & _
                            "-->Left:" & @TAB & DllStructGetData($tNMHDFILTERBTNCLICK, "Left") & @CRLF & _
                            "-->Top:" & @TAB & DllStructGetData($tNMHDFILTERBTNCLICK, "Top") & @CRLF & _
                            "-->Right:" & @TAB & DllStructGetData($tNMHDFILTERBTNCLICK, "Right") & @CRLF & _
                            "-->Bottom:" & @TAB & DllStructGetData($tNMHDFILTERBTNCLICK, "Bottom"))
                    ; Return True  ; An $HDN_FILTERCHANGE notification will be sent to the header control's parent window
                    ; This notification gives the parent window an opportunity to synchronize its user interface elements
                    Return False ; If you do not want the notification sent
                Case $HDN_FILTERCHANGE ; Notifies the header control's parent window that the attributes of a header control filter are being changed or edited
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_FILTERCHANGE" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    ; no return value
                Case $HDN_GETDISPINFO, $HDN_GETDISPINFOW ; Sent to the owner of a header control when the control needs information about a callback header item
                    $tNMHDDISPINFO = DllStructCreate($tagNMHDDISPINFO, $lParam)
                    _DebugPrint("$HDN_GETDISPINFO" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHDDISPINFO, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHDDISPINFO, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHDDISPINFO, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHDDISPINFO, "Item"))
                    ; Return LRESULT
                Case $HDN_ITEMCHANGED, $HDN_ITEMCHANGEDW ; Notifies a header control's parent window that the attributes of a header item have changed
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_ITEMCHANGED" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    ; no return value
                Case $HDN_ITEMCHANGING, $HDN_ITEMCHANGINGW ; Notifies a header control's parent window that the attributes of a header item are about to change
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_ITEMCHANGING" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    Return False ; To allow the changes
                    ; Return True  ; To prevent them
                Case $HDN_ITEMCLICK, $HDN_ITEMCLICKW ; Notifies a header control's parent window that the user clicked the control
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_ITEMCLICK" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    ; no return value
                Case $HDN_ITEMDBLCLICK, $HDN_ITEMDBLCLICKW ; Notifies a header control's parent window that the user double-clicked the control
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_ITEMDBLCLICK" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    ; no return value
                Case $HDN_TRACK, $HDN_TRACKW ; Notifies a header control's parent window that the user is dragging a divider in the header control
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_TRACK" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    Return False ; To continue tracking the divider
                    ; Return True  ; To end tracking
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlHeader_CreateDragImage

Function Reference

_GUICtrlHeader_CreateDragImage

Creates a semi-transparent version of an item's image for use as a dragging image

#include <GuiHeader.au3>
_GUICtrlHeader_CreateDragImage ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index. The image assigned to the item is the basis for the transparent image.

Return Value

Success: | the handle to an image list that contains the new image as its only element.
Failure: | 0.

Related

_GUICtrlHeader_GetImageList

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>

Global $g_idMemo
Example()

Func Example()
    Local $hGUI, $hHeader, $hImage, $iMsg, $aSize, $tPos, $tRECT, $hDC

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Create a drag image
    $hImage = _GUICtrlHeader_CreateDragImage($hHeader, 1)
    $aSize = _GUIImageList_GetIconSize($hImage)
    $hDC = _WinAPI_GetDC($hGUI)

    MemoWrite("Image drag Handle: " & "0x" & Hex($hImage))
    MemoWrite("IsPtr  = " & IsPtr($hImage) & " IsHWnd  = " & IsHWnd($hImage))

    ; Show drag image at cursor position until user exits
    Do
        $iMsg = GUIGetMsg()
        If $iMsg = $GUI_EVENT_MOUSEMOVE Then
            If $tPos <> 0 Then
                $tRECT = DllStructCreate($tagRECT)
                DllStructSetData($tRECT, "Left", DllStructGetData($tPos, "X"))
                DllStructSetData($tRECT, "Top", DllStructGetData($tPos, "Y"))
                DllStructSetData($tRECT, "Right", DllStructGetData($tPos, "X") + $aSize[0])
                DllStructSetData($tRECT, "Bottom", DllStructGetData($tPos, "Y") + $aSize[1])
                _WinAPI_InvalidateRect($hGUI, $tRECT)
            EndIf
            $tRECT = _WinAPI_GetClientRect($hGUI)
            $tPos = _WinAPI_GetMousePos(True, $hGUI)
            If _WinAPI_PtInRect($tRECT, $tPos) Then
                _GUIImageList_Draw($hImage, 0, $hDC, DllStructGetData($tPos, "X"), DllStructGetData($tPos, "Y"))
            EndIf
        EndIf
    Until $iMsg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_DeleteItem

Function Reference

_GUICtrlHeader_DeleteItem

Deletes a header item

#include <GuiHeader.au3>
_GUICtrlHeader_DeleteItem ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlHeader_AddItem, _GUICtrlHeader_InsertItem

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Delete column 3
    MsgBox($MB_SYSTEMMODAL, "Information", "Deleting Column 3")
    _GUICtrlHeader_DeleteItem($hHeader, 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlHeader_Destroy

Function Reference

_GUICtrlHeader_Destroy

Delete the Header control

#include <GuiHeader.au3>
_GUICtrlHeader_Destroy ( ByRef $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True, $hWnd is set to 0.
Failure: | False.

Remarks

Restricted to only be used on Header controls created with _GUICtrlHeader_Create().

Related

_GUICtrlHeader_Create

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hHeader

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $g_hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($g_hHeader, True)
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Add columns
    _GUICtrlHeader_AddItem($g_hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($g_hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($g_hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($g_hHeader, "Column 4", 100)

    ; Clear all filters
    _GUICtrlHeader_ClearFilterAll($g_hHeader)

    MsgBox($MB_SYSTEMMODAL, "Information", "About to Destroy Header")

    _GUICtrlHeader_Destroy($g_hHeader)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iCode
    Local $tNMHDR, $tNMHEADER, $tNMHDFILTERBTNCLICK, $tNMHDDISPINFO

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hHeader
            Switch $iCode
                Case $HDN_BEGINDRAG ; Sent by a header control when a drag operation has begun on one of its items
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_BEGINDRAG" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    Return False ; To allow the header control to automatically manage drag-and-drop operations
                    ; Return True  ; To indicate external (manual) drag-and-drop management allows the owner of the
                    ; control to provide custom services as part of the drag-and-drop process
                Case $HDN_BEGINTRACK, $HDN_BEGINTRACKW ; Notifies a header control's parent window that the user has begun dragging a divider in the control
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_BEGINTRACK" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    Return False ; To allow tracking of the divider
                    ; Return True  ; To prevent tracking
                Case $HDN_DIVIDERDBLCLICK, $HDN_DIVIDERDBLCLICKW ; Notifies a header control's parent window that the user double-clicked the divider area of the control
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_DIVIDERDBLCLICK" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    ; no return value
                Case $HDN_ENDDRAG ; Sent by a header control when a drag operation has ended on one of its items
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_ENDDRAG" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    Return False ; To allow the control to automatically place and reorder the item
                    ; Return True  ; To prevent the item from being placed
                Case $HDN_ENDTRACK, $HDN_ENDTRACKW ; Notifies a header control's parent window that the user has finished dragging a divider
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_ENDTRACK" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    ; no return value
                Case $HDN_FILTERBTNCLICK ; Notifies the header control's parent window when the filter button is clicked or in response to an $HDM_SETITEM message
                    $tNMHDFILTERBTNCLICK = DllStructCreate($tagNMHDFILTERBTNCLICK, $lParam)
                    _DebugPrint("$HDN_FILTERBTNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHDFILTERBTNCLICK, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHDFILTERBTNCLICK, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHDFILTERBTNCLICK, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHDFILTERBTNCLICK, "Item") & @CRLF & _
                            "-->Left:" & @TAB & DllStructGetData($tNMHDFILTERBTNCLICK, "Left") & @CRLF & _
                            "-->Top:" & @TAB & DllStructGetData($tNMHDFILTERBTNCLICK, "Top") & @CRLF & _
                            "-->Right:" & @TAB & DllStructGetData($tNMHDFILTERBTNCLICK, "Right") & @CRLF & _
                            "-->Bottom:" & @TAB & DllStructGetData($tNMHDFILTERBTNCLICK, "Bottom"))
                    ; Return True  ; An $HDN_FILTERCHANGE notification will be sent to the header control's parent window
                    ; This notification gives the parent window an opportunity to synchronize its user interface elements
                    Return False ; If you do not want the notification sent
                Case $HDN_FILTERCHANGE ; Notifies the header control's parent window that the attributes of a header control filter are being changed or edited
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_FILTERCHANGE" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    ; no return value
                Case $HDN_GETDISPINFO, $HDN_GETDISPINFOW ; Sent to the owner of a header control when the control needs information about a callback header item
                    $tNMHDDISPINFO = DllStructCreate($tagNMHDDISPINFO, $lParam)
                    _DebugPrint("$HDN_GETDISPINFO" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHDDISPINFO, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHDDISPINFO, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHDDISPINFO, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHDDISPINFO, "Item"))
                    ; Return LRESULT
                Case $HDN_ITEMCHANGED, $HDN_ITEMCHANGEDW ; Notifies a header control's parent window that the attributes of a header item have changed
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_ITEMCHANGED" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    ; no return value
                Case $HDN_ITEMCHANGING, $HDN_ITEMCHANGINGW ; Notifies a header control's parent window that the attributes of a header item are about to change
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_ITEMCHANGING" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    Return False ; To allow the changes
                    ; Return True  ; To prevent them
                Case $HDN_ITEMCLICK, $HDN_ITEMCLICKW ; Notifies a header control's parent window that the user clicked the control
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_ITEMCLICK" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    ; no return value
                Case $HDN_ITEMDBLCLICK, $HDN_ITEMDBLCLICKW ; Notifies a header control's parent window that the user double-clicked the control
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_ITEMDBLCLICK" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    ; no return value
                Case $HDN_TRACK, $HDN_TRACKW ; Notifies a header control's parent window that the user is dragging a divider in the header control
                    $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    _DebugPrint("$HDN_TRACK" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMHEADER, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMHEADER, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMHEADER, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tNMHEADER, "Item") & @CRLF & _
                            "-->Button:" & @TAB & DllStructGetData($tNMHEADER, "Button"))
                    Return False ; To continue tracking the divider
                    ; Return True  ; To end tracking
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlHeader_EditFilter

Function Reference

_GUICtrlHeader_EditFilter

Starts editing the specified filter

#include <GuiHeader.au3>
_GUICtrlHeader_EditFilter ( $hWnd, $iIndex [, $bDiscard = True] )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index
$bDiscard | [optional] Flag that specifies how to handle the user's editing changes. Use this flag to specify what to do if the user is in the process of editing the filter when the message is sent: True - Discard the changes made by the user False - Accept the changes made by the user

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlHeader_ClearFilter, _GUICtrlHeader_ClearFilterAll

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set up filters
    _GUICtrlHeader_EditFilter($hHeader, 0)
    Send("Filter 1")
    Sleep(1000)
    Send("{ENTER}")
    _GUICtrlHeader_EditFilter($hHeader, 1)
    Send("Filter 2")
    Sleep(1000)
    Send("{ENTER}")

    ; Clear first filter
    _GUICtrlHeader_ClearFilter($hHeader, 0)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlHeader_GetBitmapMargin

Function Reference

_GUICtrlHeader_GetBitmapMargin

Retrieves the width of the bitmap margin

#include <GuiHeader.au3>
_GUICtrlHeader_GetBitmapMargin ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | The width of the bitmap margin in pixels. If the bitmap margin was not previously specified, the default value of 3 * GetSystemMetrics(SM_CXEDGE) is returned.
Failure: | 0.

Related

_GUICtrlHeader_SetBitmapMargin

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Show current bitmap margin
    MemoWrite("Current margin .: " & _GUICtrlHeader_GetBitmapMargin($hHeader))

    ; Set new bitmap margin
    _GUICtrlHeader_SetBitmapMargin($hHeader, 8)

    ; Show new bitmap margin
    MemoWrite("New margin .....: " & _GUICtrlHeader_GetBitmapMargin($hHeader))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_GetImageList

Function Reference

_GUICtrlHeader_GetImageList

Retrieves the handle to the image list

#include <GuiHeader.au3>
_GUICtrlHeader_GetImageList ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the handle to the image list set for the header control.
Failure: | 0.

Related

_GUICtrlHeader_CreateDragImage, _GUICtrlHeader_SetImageList

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader, $hImage

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create an image list with images
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 11, 11))
    _GUICtrlHeader_SetImageList($hHeader, $hImage)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100, 0, 0)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100, 0, 1)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100, 0, 2)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Show header information
    MemoWrite("Image list handle ....: " & "0x" & Hex(_GUICtrlHeader_GetImageList($hHeader)))
    MemoWrite("IsPtr = " & IsPtr(_GUICtrlHeader_GetImageList($hHeader)) & " IsHWnd = " & IsHWnd(_GUICtrlHeader_GetImageList($hHeader)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_GetItem

Function Reference

_GUICtrlHeader_GetItem

Retrieves information about an item

#include <GuiHeader.au3>
_GUICtrlHeader_GetItem ( $hWnd, $iIndex, ByRef $tItem )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index
$tItem | $tagHDITEM structure

Return Value

Success: | True.
Failure: | False.

Remarks

When the message is sent, the mask member indicates the type of information being requested.
When the message returns, the other members receive the requested information.
If the mask member specifies zero, the message returns True but copies no information to the structure.

Related

$tagHDITEM, _GUICtrlHeader_SetItem

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader, $hImage, $tItem

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create an image list with images
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 11, 11))
    _GUICtrlHeader_SetImageList($hHeader, $hImage)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100, 0, 0)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100, 0, 1)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100, 0, 2)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Show column 3 image index
    $tItem = DllStructCreate($tagHDITEM)
    DllStructSetData($tItem, "Mask", $HDI_IMAGE)
    _GUICtrlHeader_GetItem($hHeader, 2, $tItem)
    MemoWrite("Column 3 image index: " & DllStructGetData($tItem, "Image"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_GetItemAlign

Function Reference

_GUICtrlHeader_GetItemAlign

Retrieves the item text alignment

#include <GuiHeader.au3>
_GUICtrlHeader_GetItemAlign ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Success: | Item text alignment: 0 - Left 1 - Right 2 - Center
Failure: | -1.

Related

_GUICtrlHeader_SetItemAlign

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set column 1 alignment
    _GUICtrlHeader_SetItemAlign($hHeader, 0, 2)

    ; Show column 1 alignment
    MemoWrite("Column 1 alignment: " & _GUICtrlHeader_GetItemAlign($hHeader, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_GetItemBitmap

Function Reference

_GUICtrlHeader_GetItemBitmap

Retrieves the item bitmap handle

#include <GuiHeader.au3>
_GUICtrlHeader_GetItemBitmap ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Success: | the item bitmap handle.
Failure: | 0.

Related

_GUICtrlHeader_SetItemBitmap

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader, $hImage

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create an image list with images
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 11, 11))
    _GUICtrlHeader_SetImageList($hHeader, $hImage)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100, 0, 0)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100, 0, 1)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100, 0, 2)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set column 4 bitmap
    _GUICtrlHeader_SetItemBitmap($hHeader, 3, _WinAPI_CreateSolidBitmap($hGUI, 0xFF00FF, 11, 11))
    _GUICtrlHeader_SetItemDisplay($hHeader, 3, 1 + 8)

    ; Show column 4 bitmap handle
    MemoWrite("Column 4 bitmap handle: " & "0x" & Hex(_GUICtrlHeader_GetItemBitmap($hHeader, 3)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_GetItemCount

Function Reference

_GUICtrlHeader_GetItemCount

Retrieves a count of the items

#include <GuiHeader.au3>
_GUICtrlHeader_GetItemCount ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the number of items.
Failure: | -1.

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Show column count
    MemoWrite("Column count: " & _GUICtrlHeader_GetItemCount($hHeader))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_GetItemDisplay

Function Reference

_GUICtrlHeader_GetItemDisplay

Returns the item display information

#include <GuiHeader.au3>
_GUICtrlHeader_GetItemDisplay ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Returns the item display information:
1 - The item displays a bitmap
2 - The bitmap appears to the right of text
4 - The control's owner draws the item
8 - The item displays a string

Related

_GUICtrlHeader_SetItemDisplay

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader, $hImage

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create an image list with images
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 11, 11))
    _GUICtrlHeader_SetImageList($hHeader, $hImage)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100, 0)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100, 0, 1)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100, 0, 2)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set column 1 bitmap
    _GUICtrlHeader_SetItemBitmap($hHeader, 0, _WinAPI_CreateSolidBitmap($hGUI, 0xFF00FF, 11, 11))

    ; Set column 1 display
    _GUICtrlHeader_SetItemDisplay($hHeader, 0, 1 + 2 + 8)

    ; Show column 1 display
    MemoWrite("Column 1 display: " & _GUICtrlHeader_GetItemDisplay($hHeader, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_GetItemFlags

Function Reference

_GUICtrlHeader_GetItemFlags

Returns the item flag information

#include <GuiHeader.au3>
_GUICtrlHeader_GetItemFlags ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Returns the item flag information:
1 - Displays an image from an image list
2 - Text reads in the opposite direction from the text in the parent window
4 - Draws a down arrow on this item
8 - Draws a up arrow on this item

Related

_GUICtrlHeader_SetItemFlags

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set column 1 flags
    _GUICtrlHeader_SetItemFlags($hHeader, 0, 4)

    ; Show column 1 flags
    MemoWrite("Column 1 flags: " & _GUICtrlHeader_GetItemFlags($hHeader, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_GetItemFormat

Function Reference

_GUICtrlHeader_GetItemFormat

Returns the format of the item

#include <GuiHeader.au3>
_GUICtrlHeader_GetItemFormat ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Returns the item format:
HDF_CENTER - The item's contents are centered
HDF_LEFT - The item's contents are left-aligned.
HDF_RIGHT - The item's contents are right-aligned.
HDF_BITMAP - The item displays a bitmap.
HDF_BITMAP_ON_RIGHT - The bitmap appears to the right of text.
HDF_OWNERDRAW - The control's owner draws the item.
HDF_STRING - The item displays a string.
HDF_IMAGE - Display an image from an image list
HDF_RTLREADING - Text will read in the opposite direction
HDF_SORTDOWN - Draw a down-arrow on this item
HDF_SORTUP - Draw an up-arrow on this item

Related

_GUICtrlHeader_SetItemFormat

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader, $hImage

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create an image list with images
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 11, 11))
    _GUICtrlHeader_SetImageList($hHeader, $hImage)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100, 0, 0)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100, 0, 1)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100, 0, 2)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set column 1 format
    _GUICtrlHeader_SetItemFormat($hHeader, 0, BitOR($HDF_CENTER, $HDF_STRING))

    ; Show column 1 format
    MemoWrite("Column 1 format: " & "0x" & Hex(_GUICtrlHeader_GetItemFormat($hHeader, 0)))

    Sleep(1000)

    ; Set column 1 format
    _GUICtrlHeader_SetItemFormat($hHeader, 0, BitOR($HDF_LEFT, $HDF_STRING, $HDF_IMAGE))

    ; Show column 1 format
    MemoWrite("Column 1 format: " & "0x" & Hex(_GUICtrlHeader_GetItemFormat($hHeader, 0)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_GetItemImage

Function Reference

_GUICtrlHeader_GetItemImage

Retrieves the index of an image within the image list

#include <GuiHeader.au3>
_GUICtrlHeader_GetItemImage ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Returns the 0-based index of the image.

Related

_GUICtrlHeader_SetItemImage

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader, $hImage

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create an image list with images
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 11, 11))
    _GUICtrlHeader_SetImageList($hHeader, $hImage)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100, 0, 0)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100, 0, 1)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100, 0, 2)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Show column 1 image
    MemoWrite("Column 1 image: " & _GUICtrlHeader_GetItemImage($hHeader, 0))

    Sleep(1000)

    ; Set column 1 image
    _GUICtrlHeader_SetItemImage($hHeader, 0, 2)

    ; Show column 1 image
    MemoWrite("Column 1 image: " & _GUICtrlHeader_GetItemImage($hHeader, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_GetItemOrder

Function Reference

_GUICtrlHeader_GetItemOrder

Retrieves the order in which the item appears

#include <GuiHeader.au3>
_GUICtrlHeader_GetItemOrder ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Returns the 0-based item order.

Related

_GUICtrlHeader_SetItemOrder

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set column 1 order
    _GUICtrlHeader_SetItemOrder($hHeader, 0, 3)

    ; Show column 1 order
    MemoWrite("Column 1 order: " & _GUICtrlHeader_GetItemOrder($hHeader, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_GetItemParam

Function Reference

_GUICtrlHeader_GetItemParam

Retrieves the param value of the item

#include <GuiHeader.au3>
_GUICtrlHeader_GetItemParam ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Returns the item param value.

Related

_GUICtrlHeader_SetItemParam

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set column 1 param
    _GUICtrlHeader_SetItemParam($hHeader, 0, 1234)

    ; Show column 1 param
    MemoWrite("Column 1 param: " & _GUICtrlHeader_GetItemParam($hHeader, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_GetItemRect

Function Reference

_GUICtrlHeader_GetItemRect

Retrieves the bounding rectangle for a given item

#include <GuiHeader.au3>
_GUICtrlHeader_GetItemRect ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Returns an array with the following format:
[0] - X coordinate of the upper left corner of the rectangle
[1] - Y coordinate of the upper left corner of the rectangle
[2] - X coordinate of the lower right corner of the rectangle
[3] - Y coordinate of the lower right corner of the rectangle

Related

_GUICtrlHeader_GetItemRectEx

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader, $aRect

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Show column 1 rectangle
    $aRect = _GUICtrlHeader_GetItemRect($hHeader, 0)
    MemoWrite("Column 1 left .: " & $aRect[0])
    MemoWrite("Column 1 top ..: " & $aRect[1])
    MemoWrite("Column 1 right : " & $aRect[2])
    MemoWrite("Column 1 bottom: " & $aRect[3])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_GetItemRectEx

Function Reference

_GUICtrlHeader_GetItemRectEx

Retrieves the bounding rectangle for a given item

#include <GuiHeader.au3>
_GUICtrlHeader_GetItemRectEx ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Returns a $tagRECT structure that receives the bounding rectangle.

Related

_GUICtrlHeader_GetItemRect

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader, $tRECT

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Show column 1 rectangle
    $tRECT = _GUICtrlHeader_GetItemRectEx($hHeader, 0)
    MemoWrite("Column 1 left .: " & DllStructGetData($tRECT, "Left"))
    MemoWrite("Column 1 top ..: " & DllStructGetData($tRECT, "Top"))
    MemoWrite("Column 1 right : " & DllStructGetData($tRECT, "Right"))
    MemoWrite("Column 1 bottom: " & DllStructGetData($tRECT, "Bottom"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_GetItemText

Function Reference

_GUICtrlHeader_GetItemText

Retrieves the item text

#include <GuiHeader.au3>
_GUICtrlHeader_GetItemText ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Returns the item text.

Related

_GUICtrlHeader_SetItemText

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set column 1 text
    _GUICtrlHeader_SetItemText($hHeader, 0, "Column X")

    ; Show column 1 text
    MemoWrite("Column 1 text: " & _GUICtrlHeader_GetItemText($hHeader, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_GetItemWidth

Function Reference

_GUICtrlHeader_GetItemWidth

Retrieves the item's width

#include <GuiHeader.au3>
_GUICtrlHeader_GetItemWidth ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index

Return Value

Returns the width of the item.

Related

_GUICtrlHeader_SetItemWidth

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set column 1 width
    _GUICtrlHeader_SetItemWidth($hHeader, 0, 80)

    ; Show column 1 width
    MemoWrite("Column 1 width: " & _GUICtrlHeader_GetItemWidth($hHeader, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_GetOrderArray

Function Reference

_GUICtrlHeader_GetOrderArray

Retrieves the current left-to-right order of items in a header control

#include <GuiHeader.au3>
_GUICtrlHeader_GetOrderArray ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns an array with the following format:
[0] - Number of items in array
[1] - Item index 1
[2] - Item index 2
[n] - Item index n

Related

_GUICtrlHeader_SetOrderArray

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader, $aOrder[5] = [4, 3, 1, 2, 0]

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set order array
    _GUICtrlHeader_SetOrderArray($hHeader, $aOrder)

    ; Show order array
    $aOrder = _GUICtrlHeader_GetOrderArray($hHeader)
    For $iI = 1 To $aOrder[0]
        MemoWrite("Index: " & $iI - 1 & ", Order: " & $aOrder[$iI] & ' (' & _GUICtrlHeader_GetItemText($hHeader, $iI - 1) & ')')
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_GetUnicodeFormat

Function Reference

_GUICtrlHeader_GetUnicodeFormat

Retrieves the Unicode character format flag for the control

#include <GuiHeader.au3>
_GUICtrlHeader_GetUnicodeFormat ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

True: | the control uses Unicode characters.
False: | the control uses ANSI characters.

Related

_GUICtrlHeader_SetUnicodeFormat

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Show Unicode format
    MemoWrite("Using Unicode characters: " & _GUICtrlHeader_GetUnicodeFormat($hHeader))

    ; Set Unicode format
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)

    ; Show Unicode format
    MemoWrite("Using Unicode characters: " & _GUICtrlHeader_GetUnicodeFormat($hHeader))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_HitTest

Function Reference

_GUICtrlHeader_HitTest

Tests a point to determine which item is at the specified point

#include <GuiHeader.au3>
_GUICtrlHeader_HitTest ( $hWnd, $iX, $iY )

Parameters

$hWnd | Handle to the control
$iX | X position to test
$iY | Y position to text

Return Value

Returns an array with the following format:
[ 0] - 0-based index of the item at the specified position, or -1 if no item was found
[ 1] - If True, position is in control's client window but not on an item
[ 2] - If True, position is in the control's bounding rectangle
[ 3] - If True, position is on the divider between two items
[ 4] - If True, position is on the divider of an item that has a zero width
[ 5] - If True, position is over the filter area
[ 6] - If True, position is on the filter button
[ 7] - If True, position is above the control's bounding rectangle
[ 8] - If True, position is below the control's bounding rectangle
[ 9] - If True, position is to the right of the control's bounding rectangle
[10] - If True, position is to the left of the control's bounding rectangle

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader, $aHT

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Do a hit test on column 2
    $aHT = _GUICtrlHeader_HitTest($hHeader, 110, 10)
    MemoWrite("Item index ...................: " & $aHT[0])
    MemoWrite("In client window .............: " & $aHT[1])
    MemoWrite("In control rectangle .........: " & $aHT[2])
    MemoWrite("On divider ...................: " & $aHT[3])
    MemoWrite("On zero width divider ........: " & $aHT[4])
    MemoWrite("Over filter area .............: " & $aHT[5])
    MemoWrite("Over filter button ...........: " & $aHT[6])
    MemoWrite("Above bounding rectangle .....: " & $aHT[7])
    MemoWrite("Below bounding rectangle .....: " & $aHT[8])
    MemoWrite("To right of bounding rectangle: " & $aHT[9])
    MemoWrite("To left of bounding rectangle : " & $aHT[10])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_InsertItem

Function Reference

_GUICtrlHeader_InsertItem

Inserts a new header item

#include <GuiHeader.au3>
_GUICtrlHeader_InsertItem ( $hWnd, $iIndex, $sText [, $iWidth = 50 [, $iAlign = 0 [, $iImage = -1 [, $bOnRight = False]]]] )

Parameters

$hWnd | Handle to the control
$iIndex | Index of the item after which the new item is to be inserted. The new item is inserted at the end of the control if index is greater than or equal to the number of items in the control. If index is zero, the new item is inserted at the beginning of the control.
$sText | Item text. See remark.
$iWidth | [optional] Item width
$iAlign | [optional] Text alignment: 0 - Text is left-aligned 1 - Text is right-aligned 2 - Text is centered
$iImage | [optional] 0-based index of an image within the image list
$bOnRight | [optional] If True, the column image appears to the right of text

Return Value

Success: | the index of the new item.
Failure: | -1.

Remarks

If a notification callback is needed, you have to specify $sText = -1 (LPSTR_TEXTCALLBACK).

Related

_GUICtrlHeader_AddItem, _GUICtrlHeader_DeleteItem

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)

    ; Insert new column
    _GUICtrlHeader_InsertItem($hHeader, 1, "Column X", 100, 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlHeader_Layout

Function Reference

_GUICtrlHeader_Layout

Retrieves the correct size and position of the control

#include <GuiHeader.au3>
_GUICtrlHeader_Layout ( $hWnd, ByRef $tRECT )

Parameters

$hWnd | Handle to the control
$tRECT | $tagRECT structure that contains the rectangle the control will occupy.

Return Value

Returns a $tagWINDOWPOS structure that contains the control size and position.

Related

$tagRECT, $tagWINDOWPOS

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader, $tRECT, $tPos

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Get header layout
    $tRECT = _WinAPI_GetClientRect($hGUI)
    $tPos = _GUICtrlHeader_Layout($hHeader, $tRECT)

    ; Show header layout
    MemoWrite("Window handle .....: " & DllStructGetData($tPos, "hWnd"))
    MemoWrite("Z order handle ....: " & DllStructGetData($tPos, "InsertAfter"))
    MemoWrite("Horizontal position: " & DllStructGetData($tPos, "X"))
    MemoWrite("Vertical position .: " & DllStructGetData($tPos, "Y"))
    MemoWrite("Width .............: " & DllStructGetData($tPos, "CX"))
    MemoWrite("Height ............: " & DllStructGetData($tPos, "CY"))
    MemoWrite("Flags .............: " & DllStructGetData($tPos, "Flags"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_OrderToIndex

Function Reference

_GUICtrlHeader_OrderToIndex

Retrieves an index value for an item based on its order

#include <GuiHeader.au3>
_GUICtrlHeader_OrderToIndex ( $hWnd, $iOrder )

Parameters

$hWnd | Handle to the control
$iOrder | Order in which the item appears within the header control, from left to right

Return Value

Success: | the item index.
Failure: | $iOrder.

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Show the index for order 3
    MemoWrite("Order 3 index: " & _GUICtrlHeader_OrderToIndex($hHeader, 2))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_SetBitmapMargin

Function Reference

_GUICtrlHeader_SetBitmapMargin

Sets the width of the margin, specified in pixels, of a bitmap

#include <GuiHeader.au3>
_GUICtrlHeader_SetBitmapMargin ( $hWnd, $iWidth )

Parameters

$hWnd | Handle to the control
$iWidth | Width, specified in pixels, of the bitmap margin

Return Value

Success: | the previous bitmap margin width.
Failure: | 0.

Related

_GUICtrlHeader_GetBitmapMargin

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Show current bitmap margin
    MemoWrite("Current margin .: " & _GUICtrlHeader_GetBitmapMargin($hHeader))

    ; Set new bitmap margin
    _GUICtrlHeader_SetBitmapMargin($hHeader, 8)

    ; Show new bitmap margin
    MemoWrite("New margin .....: " & _GUICtrlHeader_GetBitmapMargin($hHeader))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_SetFilterChangeTimeout

Function Reference

_GUICtrlHeader_SetFilterChangeTimeout

Sets the filter change timeout interval

#include <GuiHeader.au3>
_GUICtrlHeader_SetFilterChangeTimeout ( $hWnd, $iTimeOut )

Parameters

$hWnd | Handle to the control
$iTimeOut | Timeout value, in milliseconds

Return Value

Success: | the index of the filter control being modified.
Failure: | 0.

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set filter change timeout
    _GUICtrlHeader_SetFilterChangeTimeout($hHeader, 3000)

    ; Set up filters
    _GUICtrlHeader_EditFilter($hHeader, 0)
    Send("Filter 1")
    Sleep(1000)
    Send("{ENTER}")
    _GUICtrlHeader_EditFilter($hHeader, 1)
    Send("Filter 2")
    Sleep(1000)
    Send("{ENTER}")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlHeader_SetHotDivider

Function Reference

_GUICtrlHeader_SetHotDivider

Changes the hot divider color

#include <GuiHeader.au3>
_GUICtrlHeader_SetHotDivider ( $hWnd, $iFlag, $iInputValue )

Parameters

$hWnd | Handle to the control
$iFlag | Value specifying the type of value represented by $iInputValue. This value can be one of the following: True - Indicates that $iInputValue holds the client coordinates of the pointer False - Indicates that $iInputValue holds a divider index value
$iInputValue | Value interpreted by $iFlag

Return Value

Returns a value equal to the index of the divider that the control highlighted.

Remarks

This function creates an effect that a header control automatically produces when it has the $HDS_DRAGDROP style.
It is intended to be used when the owner of the control handles drag-and-drop operations manually.

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Example()

Func Example()
    Local $hGUI, $hHeader, $iIndex, $hBegin

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Loop until the user exits.
    Do
        If TimerDiff($hBegin) > 500 Then
            $iIndex = Mod($iIndex + 1, 4)
            _GUICtrlHeader_SetHotDivider($hHeader, False, $iIndex)
            $hBegin = TimerInit()
        EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlHeader_SetImageList

Function Reference

_GUICtrlHeader_SetImageList

Assigns an image list

#include <GuiHeader.au3>
_GUICtrlHeader_SetImageList ( $hWnd, $hImage )

Parameters

$hWnd | Handle to the control
$hImage | Handle to an image list

Return Value

Success: | the handle to the image list previously associated with the control.
Failure: | 0.

Related

_GUICtrlHeader_GetImageList

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader, $hImage

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create an image list with images
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 11, 11))
    Local $hPrevImageList = _GUICtrlHeader_SetImageList($hHeader, $hImage)

    MemoWrite("Previous Image list handle ....: " & "0x" & Hex($hPrevImageList))
    MemoWrite("IsPtr = " & IsPtr($hPrevImageList) & " IsHWnd = " & IsHWnd($hPrevImageList))

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100, 0, 0)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100, 0, 1)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100, 0, 2)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Show header information
    MemoWrite("Image list handle ....: " & "0x" & Hex(_GUICtrlHeader_GetImageList($hHeader)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_SetItem

Function Reference

_GUICtrlHeader_SetItem

Sets information about an item

#include <GuiHeader.au3>
_GUICtrlHeader_SetItem ( $hWnd, $iIndex, ByRef $tItem )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index
$tItem | DllStructCreate($tagHDITEM) structure

Return Value

Success: | True.
Failure: | False.

Related

$tagHDITEM, _GUICtrlHeader_GetItem

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader, $hImage, $tItem

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create an image list with images
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 11, 11))
    _GUICtrlHeader_SetImageList($hHeader, $hImage)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100, 0, 0)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100, 0, 1)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100, 0, 2)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set column 3 image index
    $tItem = DllStructCreate($tagHDITEM)
    DllStructSetData($tItem, "Mask", $HDI_IMAGE)
    DllStructSetData($tItem, "Image", 0)
    _GUICtrlHeader_SetItem($hHeader, 2, $tItem)

    ; Show column 3 image index
    $tItem = DllStructCreate($tagHDITEM)
    DllStructSetData($tItem, "Mask", $HDI_IMAGE)
    _GUICtrlHeader_GetItem($hHeader, 2, $tItem)
    MemoWrite("Column 3 image index: " & DllStructGetData($tItem, "Image"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_SetItemAlign

Function Reference

_GUICtrlHeader_SetItemAlign

Sets the item text alignment

#include <GuiHeader.au3>
_GUICtrlHeader_SetItemAlign ( $hWnd, $iIndex, $iAlign )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index
$iAlign | Text alignment: 0 - Text is left-aligned 1 - Text is right-aligned 2 - Text is centered

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlHeader_GetItemAlign

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set column 1 alignment
    _GUICtrlHeader_SetItemAlign($hHeader, 0, 2)

    ; Show column 1 alignment
    MemoWrite("Column 1 alignment: " & _GUICtrlHeader_GetItemAlign($hHeader, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_SetItemBitmap

Function Reference

_GUICtrlHeader_SetItemBitmap

Sets the item bitmap handle

#include <GuiHeader.au3>
_GUICtrlHeader_SetItemBitmap ( $hWnd, $iIndex, $hBitmap )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index
$hBitmap | Item bitmap handle

Return Value

Success: | True.
Failure: | False.

Remarks

After calling this function, make sure you call _GUICtrlHeader_SetItemDisplay() to set the items display information.

Related

_GUICtrlHeader_GetItemBitmap, _GUICtrlHeader_SetItemDisplay

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader, $hImage

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create an image list with images
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 11, 11))
    _GUICtrlHeader_SetImageList($hHeader, $hImage)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100, 0, 0)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100, 0, 1)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100, 0, 2)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set column 4 bitmap
    _GUICtrlHeader_SetItemBitmap($hHeader, 3, _WinAPI_CreateSolidBitmap($hGUI, 0xFF00FF, 11, 11))
    _GUICtrlHeader_SetItemDisplay($hHeader, 3, 1 + 8)

    ; Show column 4 bitmap handle
    MemoWrite("Column 4 bitmap handle: " & "0x" & Hex(_GUICtrlHeader_GetItemBitmap($hHeader, 3)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_SetItemDisplay

Function Reference

_GUICtrlHeader_SetItemDisplay

Returns the item display information

#include <GuiHeader.au3>
_GUICtrlHeader_SetItemDisplay ( $hWnd, $iIndex, $iDisplay )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index
$iDisplay | Item display information. Can be a combination of the following: 1 - The item displays a bitmap 2 - The bitmap appears to the right of text 4 - The control's owner draws the item 8 - The item displays a string

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlHeader_GetItemDisplay, _GUICtrlHeader_SetItemBitmap

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader, $hImage

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create an image list with images
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 11, 11))
    _GUICtrlHeader_SetImageList($hHeader, $hImage)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100, 0)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100, 0, 1)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100, 0, 2)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set column 1 bitmap
    _GUICtrlHeader_SetItemBitmap($hHeader, 0, _WinAPI_CreateSolidBitmap($hGUI, 0xFF00FF, 11, 11))

    ; Set column 1 display
    _GUICtrlHeader_SetItemDisplay($hHeader, 0, 1 + 2 + 8)

    ; Show column 1 display
    MemoWrite("Column 1 display: " & _GUICtrlHeader_GetItemDisplay($hHeader, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_SetItemFlags

Function Reference

_GUICtrlHeader_SetItemFlags

Returns the item flag information

#include <GuiHeader.au3>
_GUICtrlHeader_SetItemFlags ( $hWnd, $iIndex, $iFlags )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index
$iFlags | Item flag information. Can be a combination of the following: 1 - Displays an image from an image list 2 - Text reads in the opposite direction from the text in the parent window 4 - Draws a down arrow on this item 8 - Draws a up arrow on this item

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlHeader_GetItemFlags

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set column 1 flags
    _GUICtrlHeader_SetItemFlags($hHeader, 0, 4)

    ; Show column 1 flags
    MemoWrite("Column 1 flags: " & _GUICtrlHeader_GetItemFlags($hHeader, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_SetItemFormat

Function Reference

_GUICtrlHeader_SetItemFormat

Sets the format of the item

#include <GuiHeader.au3>
_GUICtrlHeader_SetItemFormat ( $hWnd, $iIndex, $iFormat )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index
$iFormat | Combination of the following format identifiers: $HDF_CENTER - The item's contents are centered $HDF_LEFT - The item's contents are left-aligned $HDF_RIGHT - The item's contents are right-aligned $HDF_BITMAP - The item displays a bitmap $HDF_BITMAP_ON_RIGHT - The bitmap appears to the right of text $HDF_OWNERDRAW - The header control's owner draws the item $HDF_STRING - The item displays a string $HDF_IMAGE - Display an image from an image list $HDF_RTLREADING - Text will read in the opposite direction from the text in the parent window $HDF_SORTDOWN - Draws a down-arrow on this item $HDF_SORTUP - Draws an up-arrow on this item

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlHeader_GetItemFormat

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader, $hImage

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create an image list with images
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 11, 11))
    _GUICtrlHeader_SetImageList($hHeader, $hImage)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100, 0, 0)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100, 0, 1)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100, 0, 2)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set column 1 format
    _GUICtrlHeader_SetItemFormat($hHeader, 0, BitOR($HDF_CENTER, $HDF_STRING))

    ; Show column 1 format
    MemoWrite("Column 1 format: " & "0x" & Hex(_GUICtrlHeader_GetItemFormat($hHeader, 0)))

    Sleep(1000)

    ; Set column 1 format
    _GUICtrlHeader_SetItemFormat($hHeader, 0, BitOR($HDF_LEFT, $HDF_STRING, $HDF_IMAGE))

    ; Show column 1 format
    MemoWrite("Column 1 format: " & "0x" & Hex(_GUICtrlHeader_GetItemFormat($hHeader, 0)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_SetItemImage

Function Reference

_GUICtrlHeader_SetItemImage

Sets the index of an image within the image list

#include <GuiHeader.au3>
_GUICtrlHeader_SetItemImage ( $hWnd, $iIndex, $iImage )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index
$iImage | 0-based image index

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlHeader_GetItemImage

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader, $hImage

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create an image list with images
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 11, 11))
    _GUICtrlHeader_SetImageList($hHeader, $hImage)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100, 0, 0)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100, 0, 1)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100, 0, 2)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Show column 1 image
    MemoWrite("Column 1 image: " & _GUICtrlHeader_GetItemImage($hHeader, 0))

    Sleep(1000)

    ; Set column 1 image
    _GUICtrlHeader_SetItemImage($hHeader, 0, 2)

    ; Show column 1 image
    MemoWrite("Column 1 image: " & _GUICtrlHeader_GetItemImage($hHeader, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_SetItemOrder

Function Reference

_GUICtrlHeader_SetItemOrder

Sets the order in which the item appears

#include <GuiHeader.au3>
_GUICtrlHeader_SetItemOrder ( $hWnd, $iIndex, $iOrder )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index
$iOrder | 0-based item order

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlHeader_GetItemOrder

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set column 1 order
    _GUICtrlHeader_SetItemOrder($hHeader, 0, 3)

    ; Show column 1 order
    MemoWrite("Column 1 order: " & _GUICtrlHeader_GetItemOrder($hHeader, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_SetItemParam

Function Reference

_GUICtrlHeader_SetItemParam

Sets the param value of the item

#include <GuiHeader.au3>
_GUICtrlHeader_SetItemParam ( $hWnd, $iIndex, $iParam )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index
$iParam | Item param value

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlHeader_GetItemParam

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set column 1 param
    _GUICtrlHeader_SetItemParam($hHeader, 0, 1234)

    ; Show column 1 param
    MemoWrite("Column 1 param: " & _GUICtrlHeader_GetItemParam($hHeader, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_SetItemText

Function Reference

_GUICtrlHeader_SetItemText

Sets the item text

#include <GuiHeader.au3>
_GUICtrlHeader_SetItemText ( $hWnd, $iIndex, $sText )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index
$sText | New item text. See remark.

Return Value

Success: | True.
Failure: | False.

Remarks

If a notification callback is needed, you have to specify $sText = -1 (LPSTR_TEXTCALLBACK).

Related

_GUICtrlHeader_GetItemText

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set column 1 text
    _GUICtrlHeader_SetItemText($hHeader, 0, "Column X")

    ; Show column 1 text
    MemoWrite("Column 1 text: " & _GUICtrlHeader_GetItemText($hHeader, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_SetItemWidth

Function Reference

_GUICtrlHeader_SetItemWidth

Sets the item's width

#include <GuiHeader.au3>
_GUICtrlHeader_SetItemWidth ( $hWnd, $iIndex, $iWidth )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based item index
$iWidth | New width for item

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlHeader_GetItemWidth

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set column 1 width
    _GUICtrlHeader_SetItemWidth($hHeader, 0, 80)

    ; Show column 1 width
    MemoWrite("Column 1 width: " & _GUICtrlHeader_GetItemWidth($hHeader, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_SetOrderArray

Function Reference

_GUICtrlHeader_SetOrderArray

Sets the current left-to-right order of items

#include <GuiHeader.au3>
_GUICtrlHeader_SetOrderArray ( $hWnd, ByRef $aOrder )

Parameters

$hWnd | Handle to the control
$aOrder | Array that specifies the index values for items in the header: [0] - Number of items in array [1] - Item index 1 [2] - Item index 2 [n] - Item index n

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlHeader_GetOrderArray

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader, $aOrder[5] = [4, 3, 1, 2, 0]

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Set order array
    _GUICtrlHeader_SetOrderArray($hHeader, $aOrder)

    ; Show order array
    $aOrder = _GUICtrlHeader_GetOrderArray($hHeader)
    For $iI = 1 To $aOrder[0]
        MemoWrite("Index: " & $iI - 1 & ", Order: " & $aOrder[$iI] & ' (' & _GUICtrlHeader_GetItemText($hHeader, $iI - 1) & ')')
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlHeader_SetUnicodeFormat

Function Reference

_GUICtrlHeader_SetUnicodeFormat

Sets the Unicode character format flag for the control

#include <GuiHeader.au3>
_GUICtrlHeader_SetUnicodeFormat ( $hWnd, $bUnicode )

Parameters

$hWnd | Handle to the control
$bUnicode | Unicode flag: True - Control uses Unicode characters False - Control uses ANSI characters

Return Value

Returns the previous Unicode format flag.

Related

_GUICtrlHeader_GetUnicodeFormat

Example

#include <GUIConstantsEx.au3>
#include <GuiHeader.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hHeader

    ; Create GUI
    $hGUI = GUICreate("Header", 400, 300)
    $hHeader = _GUICtrlHeader_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 24, 396, 274, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlHeader_AddItem($hHeader, "Column 1", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 2", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 3", 100)
    _GUICtrlHeader_AddItem($hHeader, "Column 4", 100)

    ; Show Unicode format
    MemoWrite("Using Unicode characters: " & _GUICtrlHeader_GetUnicodeFormat($hHeader))

    ; Set Unicode format
    _GUICtrlHeader_SetUnicodeFormat($hHeader, True)

    ; Show Unicode format
    MemoWrite("Using Unicode characters: " & _GUICtrlHeader_GetUnicodeFormat($hHeader))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


User Defined Functions

GuiImageList user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiImageList.au3>.

User Defined Function | Description
_GUIImageList_Add | Adds an image or images to an image list
_GUIImageList_AddBitmap | Adds a bitmap to an image list
_GUIImageList_AddIcon | Adds an icon to an image list
_GUIImageList_AddMasked | Adds an image or images to an image list, generating a mask from the specified bitmap
_GUIImageList_BeginDrag | Begins dragging an image
_GUIImageList_Copy | Source image is copied to the destination image's index
_GUIImageList_Create | Create an ImageList control
_GUIImageList_Destroy | Destroys an image list
_GUIImageList_DestroyIcon | Destroys an icon and frees any memory the icon occupied
_GUIImageList_DragEnter | Displays the drag image at the specified position within the window
_GUIImageList_DragLeave | Unlocks the specified window and hides the drag image, allowing the window to be updated
_GUIImageList_DragMove | Moves the image that is being dragged during a drag-and-drop operation
_GUIImageList_Draw | Draws an image list item in the specified device context
_GUIImageList_DrawEx | Draws an image list item in the specified device context
_GUIImageList_Duplicate | Creates a duplicate of an existing image list
_GUIImageList_EndDrag | Ends a drag operation
_GUIImageList_GetBkColor | Retrieves the current background color for an image list
_GUIImageList_GetIcon | Creates an icon from an image and mask in an image list
_GUIImageList_GetIconHeight | Retrieves the height of the images in an image list
_GUIImageList_GetIconSize | Retrieves the dimensions of images in an image list
_GUIImageList_GetIconSizeEx | Retrieves the dimensions of images in an image list
_GUIImageList_GetIconWidth | Retrieves the width of the images in an image list
_GUIImageList_GetImageCount | Retrieves the number of images in an image list
_GUIImageList_GetImageInfoEx | Retrieves information about an image
_GUIImageList_Remove | Remove Image(s) from the ImageList
_GUIImageList_ReplaceIcon | Replaces an image with an icon or cursor
_GUIImageList_SetBkColor | Sets the background color for an image list
_GUIImageList_SetIconSize | Sets the dimensions of images in an image list and removes all images from the list
_GUIImageList_SetImageCount | Resizes an existing image list
_GUIImageList_Swap | Swap image between Source and Destination image's index


Function _GUIImageList_Add

Function Reference

_GUIImageList_Add

Adds an image or images to an image list

#include <GuiImageList.au3>
_GUIImageList_Add ( $hWnd, $hImage [, $hMask = 0] )

Parameters

$hWnd | Handle to the imagelist
$hImage | Handle to the bitmap that contains the image or images. The number of images is inferred from the width of the bitmap.
$hMask | [optional] Handle to the bitmap that contains the mask

Return Value

Success: | the index of the first new image.
Failure: | -1.

Remarks

This function copies the bitmap to an internal data structure.
Be sure to use the _WinAPI_DeleteObject() function to delete $hImage and $hMask after the function returns.

Related

_GUIImageList_AddBitmap, _GUIImageList_AddIcon, _GUIImageList_AddMasked, _WinAPI_DeleteObject

Example

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

Example()

Func Example()
    Local $idListview, $hImage
    Local $iStylesEx = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    GUICreate("ImageList Add", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iStylesEx)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 11, 11))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 11, 11))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 11, 11))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 120)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUIImageList_AddBitmap

Function Reference

_GUIImageList_AddBitmap

Adds a bitmap to an image list

#include <GuiImageList.au3>
_GUIImageList_AddBitmap ( $hWnd, $sImage [, $sMask = ""] )

Parameters

$hWnd | Handle to the imagelist
$sImage | Path to the bitmap that contains the image
$sMask | [optional] Path to the bitmap that contains the mask

Return Value

Success: | the index of the image.
Failure: | -1.

Related

_GUIImageList_Add, _GUIImageList_AddIcon

Example

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

Example()

Func Example()
    Local $idListview, $hImage
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images"

    GUICreate("ImageList AddBitmap", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(16, 32)
    _GUIImageList_AddBitmap($hImage, $sPath & "\Red.bmp")
    _GUIImageList_AddBitmap($hImage, $sPath & "\Green.bmp")
    _GUIImageList_AddBitmap($hImage, $sPath & "\Blue.bmp")
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 120)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUIImageList_AddIcon

Function Reference

_GUIImageList_AddIcon

Adds an icon to an image list

#include <GuiImageList.au3>
_GUIImageList_AddIcon ( $hWnd, $sFilePath [, $iIndex = 0 [, $bLarge = False]] )

Parameters

$hWnd | Handle to the imagelist
$sFilePath | Path to the icon that contains the image
$iIndex | [optional] Specifies the 0-based index of the icon to extract
$bLarge | [optional] Extract Large Icon

Return Value

Success: | the index of the image.
Failure: | -1.

Related

_GUIImageList_Add, _GUIImageList_AddBitmap

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGui, $idListview, $hImage
    Local $iStylesEx = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    $hGui = GUICreate("ImageList AddIcon", 400, 300)
    $idListview = _GUICtrlListView_Create($hGui, "", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iStylesEx)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 120)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)
    _GUICtrlListView_AddItem($idListview, "Row 4: Col 1", 3)
    _GUICtrlListView_AddItem($idListview, "Row 5: Col 1", 4)
    _GUICtrlListView_AddSubItem($idListview, 4, "Row 5: Col 2", 1, 3)
    _GUICtrlListView_AddItem($idListview, "Row 6: Col 1", 5)
    _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 2", 1, 4)
    _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 3", 2, 3)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUIImageList_AddMasked

Function Reference

_GUIImageList_AddMasked

Adds an image or images to an image list, generating a mask from the specified bitmap

#include <GuiImageList.au3>
_GUIImageList_AddMasked ( $hWnd, $hImage [, $iMask = 0] )

Parameters

$hWnd | Handle to the imagelist
$hImage | Handle to the bitmap that contains the image or images. The number of images is inferred from the width of the bitmap.
$iMask | [optional] Color used to generate the mask. Each pixel of this color in the specified bitmap is changed to black, and the corresponding bit in the mask is set to 1.

Return Value

Success: | the index of the first new image.
Failure: | -1.

Remarks

This function copies the bitmap to an internal data structure.
Be sure to use the _WinAPI_DeleteObject() function to delete $hImage after the function returns.
Bitmaps with color depth greater than 8 bpp are not supported.

Related

_GUIImageList_Add, _WinAPI_DeleteObject

Example

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

Example()

Func Example()
    Local $idListview, $hImage

    GUICreate("ImageList AddMasked", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_AddMasked($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 11, 11))
    _GUIImageList_AddMasked($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 11, 11))
    _GUIImageList_AddMasked($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 11, 11))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 120)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUIImageList_BeginDrag

Function Reference

_GUIImageList_BeginDrag

Begins dragging an image

#include <GuiImageList.au3>
_GUIImageList_BeginDrag ( $hWnd, $iTrack, $iXHotSpot, $iYHotSpot )

Parameters

$hWnd | Handle to the imagelist
$iTrack | Index of the image to drag
$iXHotSpot | X coordinate of the location of the drag position relative to image upper left corner
$iYHotSpot | Y coordinate of the location of the drag position relative to image upper left corner

Return Value

Success: | True.
Failure: | False.

Remarks

This function creates a temporary image list that is used for dragging.
In response to subsequent WM_MOUSEMOVE messages, you can move the drag image by using the _GUIImageList_DragMove() function.
To end the drag operation, you can use the _GUIImageList_EndDrag() function.

Related

_GUIImageList_DragEnter, _GUIImageList_EndDrag

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

#Region Globals *************************************************************************
Global $g_ahDragImageList, $g_hListView, $g_bDragging = False, $g_iLV_Height
Global $g_aIndex[2] ; from and to

Global Const $g_iDebugIt = 1

#EndRegion Globals *************************************************************************

Opt("WinTitleMatchMode", 2)

Example()

Func Example()
    Local Const $iImage_width = 20
    Local Const $iImage_height = 20
    Local $hImages, $hMain_GUI, $iIndex

    $hMain_GUI = GUICreate("GuiImageList Begin Drag", 225, 400)

    $g_hListView = _GUICtrlListView_Create($hMain_GUI, "Entry Name|Category", 5, 75, 220, 280, -1, BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE))
    $g_iLV_Height = 280 - 75
    _GUICtrlListView_SetColumnWidth($g_hListView, 0, 100)
    _GUICtrlListView_SetColumnWidth($g_hListView, 1, 100)
    _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
    ;------------------------------------------------------
    ; Using subitem images
    ;------------------------------------------------------
    _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_SUBITEMIMAGES))

    ;------------------------------------------------------
    ; create the image list
    ;------------------------------------------------------
    $hImages = _GUIImageList_Create($iImage_width, $iImage_height, 5, 1)
    For $x = 1 To 21
        _GUIImageList_AddIcon($hImages, @SystemDir & "\shell32.dll", $x)
    Next

    _GUICtrlListView_SetImageList($g_hListView, $hImages, $LVSIL_SMALL)

    ;------------------------------------------------------
    ;Register event functions
    ;------------------------------------------------------
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    GUIRegisterMsg($WM_LBUTTONUP, "WM_LBUTTONUP")
    GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE")

    ;------------------------------------------------------
    ; add listview items with images
    ;------------------------------------------------------
    Local $y = 1
    For $x = 0 To 9
        $iIndex = _GUICtrlListView_AddItem($g_hListView, "Name " & $x + 1, $y) ; handle, string, image index
        _GUICtrlListView_AddSubItem($g_hListView, $iIndex, "Category " & $x + 1, 1, $y + 1) ; handle, index, string, subitem, image index
        $y += 2
    Next

    GUISetState(@SW_SHOW)

    While 1

        Switch GUIGetMsg()

            ;-----------------------------------------------------------------------------------------
            ;This case statement exits and updates code if needed
            Case $GUI_EVENT_CLOSE
                ExitLoop
                ;-----------------------------------------------------------------------------------------
                ;put all the misc. stuff here
            Case Else
                ;;;
        EndSwitch
    WEnd

    _GUIImageList_Destroy($hImages)
    GUIDelete()
EndFunc   ;==>Example

#Region Item Function(s) **********************************************************************************************
Func _LVInsertItem($i_FromItem, $i_ToItem)
    Local $iItem_state, $i_NewIndex
    Local $tStruct_LVITEM = DllStructCreate($tagLVITEM)
    Local $tStruct_String = DllStructCreate("wchar Buffer[4096]")

    ; Insert item into new position
    DllStructSetData($tStruct_LVITEM, "Mask", BitOR($LVIF_STATE, $LVIF_IMAGE, $LVIF_INDENT, $LVIF_PARAM, $LVIF_TEXT))
    DllStructSetData($tStruct_LVITEM, "StateMask", $LVIS_STATEIMAGEMASK)
    DllStructSetData($tStruct_LVITEM, "Item", $i_FromItem)
    DllStructSetData($tStruct_LVITEM, "SubItem", 0)
    DllStructSetData($tStruct_LVITEM, "TextMax", 4096)
    DllStructSetData($tStruct_LVITEM, "Text", DllStructGetPtr($tStruct_String))
    _GUICtrlListView_GetItemEx($g_hListView, $tStruct_LVITEM)
    If @error Then Return SetError(-1, -1, -1)
    $iItem_state = DllStructGetData($tStruct_LVITEM, "State")
    DllStructSetData($tStruct_LVITEM, "Item", $i_ToItem)
    $i_NewIndex = _GUICtrlListView_InsertItem($g_hListView, DllStructGetData($tStruct_String, "Buffer"), $i_ToItem, DllStructGetData($tStruct_LVITEM, "Image"))
    If @error Then Return SetError(-1, -1, -1)

    ; restore previous state
    _DebugPrint("$i_NewIndex = " & $i_NewIndex)
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_STATE)
    DllStructSetData($tStruct_LVITEM, "Item", $i_NewIndex)
    DllStructSetData($tStruct_LVITEM, "State", $iItem_state)
    DllStructSetData($tStruct_LVITEM, "StateMask", $LVIS_STATEIMAGEMASK)
    _GUICtrlListView_SetItemState($g_hListView, $i_NewIndex, $iItem_state, $LVIS_STATEIMAGEMASK)
    If @error Then Return SetError(-1, -1, -1)
    Return $i_NewIndex
EndFunc   ;==>_LVInsertItem

; ------------------------------------------------------
Func _LVCopyItem($i_FromItem, $i_ToItem, $i_SubItem = 0)
    Local $tStruct_LVITEM = DllStructCreate($tagLVITEM)
    Local $tStruct_String = DllStructCreate("wchar Buffer[4096]")

    ; get from item info
    DllStructSetData($tStruct_LVITEM, "Mask", BitOR($LVIF_STATE, $LVIF_IMAGE, $LVIF_INDENT, $LVIF_PARAM, $LVIF_TEXT))
    DllStructSetData($tStruct_LVITEM, "StateMask", $LVIS_STATEIMAGEMASK)
    DllStructSetData($tStruct_LVITEM, "Item", $i_FromItem)
    DllStructSetData($tStruct_LVITEM, "SubItem", $i_SubItem)
    DllStructSetData($tStruct_LVITEM, "TextMax", 4096)
    DllStructSetData($tStruct_LVITEM, "Text", DllStructGetPtr($tStruct_String))
    _GUICtrlListView_GetItemEx($g_hListView, $tStruct_LVITEM)

    ; set to
    DllStructSetData($tStruct_LVITEM, "Item", $i_ToItem)
    ; set text
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_TEXT)
    DllStructSetData($tStruct_LVITEM, "Text", DllStructGetPtr($tStruct_String))
    DllStructSetData($tStruct_LVITEM, "TextMax", 4096)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    If @error Then Return SetError(@error, @error, @error)
    ; set status
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_STATE)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set image
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_IMAGE)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_IMAGE)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set state
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_STATE)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_STATE)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set indent
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_INDENT)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_INDENT)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set Param
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_PARAM)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_PARAM)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
EndFunc   ;==>_LVCopyItem
#EndRegion Item Function(s) **********************************************************************************************

#Region Event Function(s) **********************************************************************************************

; WM_MOUSEMOVE event handler
; ------------------------------------------------------
Func WM_MOUSEMOVE($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $iMsgID, $wParam
    ;------------------------------------------------------
    ; not dragging item we are done here
    ;------------------------------------------------------
    If $g_bDragging = False Then Return $GUI_RUNDEFMSG

    ;------------------------------------------------------
    ; update the image move
    ;------------------------------------------------------
    Local $aPos = ControlGetPos($hWndGUI, "", $g_hListView)
    Local $x = BitAND($lParam, 0xFFFF) - $aPos[0]
    Local $y = BitShift($lParam, 16) - $aPos[1]
    If $y > $g_iLV_Height - 20 Then
        _GUICtrlListView_Scroll($g_hListView, 0, $y)
    ElseIf $y < 20 Then
        _GUICtrlListView_Scroll($g_hListView, 0, $y * -1)
    EndIf
    _GUIImageList_DragMove($x, $y)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEMOVE

; WM_LBUTTONUP event handler
; ------------------------------------------------------
Func WM_LBUTTONUP($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $iMsgID, $wParam
    $g_bDragging = False
    Local $aPos = ControlGetPos($hWndGUI, "", $g_hListView)
    Local $x = BitAND($lParam, 0xFFFF) - $aPos[0]
    Local $y = BitShift($lParam, 16) - $aPos[1]
    _DebugPrint("$x = " & $x)
    _DebugPrint("$y = " & $y)
    ;------------------------------------------------------
    ; done dragging
    ;------------------------------------------------------
    _GUIImageList_DragLeave($g_hListView)
    _GUIImageList_EndDrag()
    _GUIImageList_Destroy($g_ahDragImageList[0])
    _WinAPI_ReleaseCapture()
    ;------------------------------------------------------
    ; do hit test see if drag ended in the listview
    ;------------------------------------------------------
    Local $tStruct_LVHITTESTINFO = DllStructCreate($tagLVHITTESTINFO)

    DllStructSetData($tStruct_LVHITTESTINFO, "X", $x)
    DllStructSetData($tStruct_LVHITTESTINFO, "Y", $y)
    $g_aIndex[1] = _SendMessage($g_hListView, $LVM_HITTEST, 0, DllStructGetPtr($tStruct_LVHITTESTINFO), 0, "wparam", "ptr")
    Local $iFlags = DllStructGetData($tStruct_LVHITTESTINFO, "Flags")
    _DebugPrint("$iFlags: " & $iFlags)
    ;------------------------------------------------------
    ; // Out of the ListView?
    ;------------------------------------------------------
    If $g_aIndex[1] == -1 Then Return $GUI_RUNDEFMSG
    ;------------------------------------------------------
    ; // Not in an item?
    ;------------------------------------------------------
    If BitAND($iFlags, $LVHT_ONITEMLABEL) == 0 And BitAND($iFlags, $LVHT_ONITEMSTATEICON) == 0 And BitAND($iFlags, $LVHT_ONITEMICON) = 0 Then Return $GUI_RUNDEFMSG
    ;------------------------------------------------------
    ; make sure insert is at least 2 items above or below, don't want to create a duplicate
    ;------------------------------------------------------
    If $g_aIndex[0] < $g_aIndex[1] - 1 Or $g_aIndex[0] > $g_aIndex[1] + 1 Then
        _DebugPrint("To = " & $g_aIndex[1])
        Local $i_NewIndex = _LVInsertItem($g_aIndex[0], $g_aIndex[1])
        If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)
        Local $iFrom_index = $g_aIndex[0]
        If $g_aIndex[0] > $g_aIndex[1] Then $iFrom_index = $g_aIndex[0] + 1
        ;------------------------------------------------------
        ; copy item and subitem(s) images, text, and state
        ;------------------------------------------------------
        For $x = 1 To _GUICtrlListView_GetColumnCount($g_hListView) - 1
            _LVCopyItem($iFrom_index, $i_NewIndex, $x)
            If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)
        Next
        ;------------------------------------------------------
        ; delete from
        ;------------------------------------------------------
        _GUICtrlListView_DeleteItem($g_hListView, $iFrom_index)
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_LBUTTONUP

; WM_NOTIFY event handler
; ------------------------------------------------------
Func WM_NOTIFY($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $hWndGUI, $iMsgID, $wParam
    Local $tNMHDR, $iCode, $x, $y, $tNMLISTVIEW, $hWndFrom, $tDraw, $iDrawStage, $iItemSpec
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam) ;NMHDR (hwndFrom, idFrom, code)
    If @error Then Return
    $iCode = DllStructGetData($tNMHDR, "Code")
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    Switch $hWndFrom
        Case $g_hListView
            Switch $iCode
                Case $LVN_BEGINDRAG
                    _DebugPrint("$LVN_BEGINDRAG")
                    $x = BitAND($lParam, 0xFFFF)
                    $y = BitShift($lParam, 16)
                    $tNMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam)
                    $g_aIndex[0] = DllStructGetData($tNMLISTVIEW, "Item")
                    $g_ahDragImageList = _GUICtrlListView_CreateDragImage($g_hListView, $g_aIndex[0])
                    If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)

                    _GUIImageList_BeginDrag($g_ahDragImageList[0], 0, 0, 0)

                    If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)
                    _DebugPrint("From = " & $g_aIndex[0])
                    _GUIImageList_DragEnter($g_hListView, $x, $y)
                    _WinAPI_SetCapture($hWndGUI)
                    $g_bDragging = True
                Case $NM_CUSTOMDRAW
                    _DebugPrint("$NM_CUSTOMDRAW")
                    $tDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
                    $iDrawStage = DllStructGetData($tDraw, "dwDrawStage")
                    $iItemSpec = DllStructGetData($tDraw, "dwItemSpec")
                    Switch $iDrawStage
                        Case $CDDS_PREPAINT
                            _DebugPrint("$CDDS_PREPAINT")
                            Return $CDRF_NOTIFYITEMDRAW
                        Case $CDDS_ITEMPREPAINT
                            _DebugPrint("$CDDS_ITEMPREPAINT")
                            If BitAND($iItemSpec, 1) = 1 Then
                                DllStructSetData($tDraw, "clrTextBk", $CLR_AQUA)
                            Else
                                DllStructSetData($tDraw, "clrTextBk", $CLR_WHITE)
                            EndIf
                            Return $CDRF_NEWFONT
                    EndSwitch
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
#EndRegion Event Function(s) **********************************************************************************************

Func _DebugPrint($s_Text)
    If Not $g_iDebugIt Then Return
    $s_Text = StringReplace($s_Text, @CRLF, @CRLF & "-->")
    ConsoleWrite("!===========================================================" & @CRLF & _
            "+===========================================================" & @CRLF & _
            "-->" & $s_Text & @CRLF & _
            "+===========================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUIImageList_Copy

Function Reference

_GUIImageList_Copy

Source image is copied to the destination image's index

#include <GuiImageList.au3>
_GUIImageList_Copy ( $hWnd, $iSource, $iDestination )

Parameters

$hWnd | Handle to the imagelist
$iSource | The 0-based index of the image to be used as the source of the copy operation
$iDestination | The 0-based index of the image to be used as the destination of the copy operation. The image index must exist

Return Value

Success: | True.
Failure: | False.

Related

_GUIImageList_Swap

Example

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

Example()

Func Example()
    Local $idListview, $hImage
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sAutoItDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir")

    GUICreate("ImageList Copy", 410, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 404, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    GUISetState(@SW_SHOW)

    ; Create an image list with images
    $hImage = _GUIImageList_Create(11, 11)
    ConsoleWrite(_GUIImageList_AddIcon($hImage, $sAutoItDir & "\Icons\filetype1.ico") & @CRLF)
    ConsoleWrite(_GUIImageList_AddIcon($hImage, $sAutoItDir & "\Icons\filetype2.ico") & @CRLF)
    ConsoleWrite(_GUIImageList_AddIcon($hImage, $sAutoItDir & "\Icons\filetype3.ico") & @CRLF)
    ConsoleWrite(_GUIImageList_AddIcon($hImage, $sAutoItDir & "\Icons\filetype3.ico") & @CRLF)
    _GUIImageList_Copy($hImage, 0, 3)
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100, 1, 0, True)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100, 0, 1, True)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100, 2, 2, True)
    _GUICtrlListView_AddColumn($idListview, "Column 4", 100, 0, 3)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUIImageList_Create

Function Reference

_GUIImageList_Create

Create an ImageList control

#include <GuiImageList.au3>
_GUIImageList_Create ( [$iCX = 16 [, $iCY = 16 [, $iColor = 4 [, $iOptions = 0 [, $iInitial = 4 [, $iGrow = 4]]]]]] )

Parameters

$iCX | [optional] Width, in pixels, of each image
$iCY | [optional] Height, in pixels, of each image
$iColor | [optional] Image color depth: 0 - Use the default behavior 1 - Use a 4 bit DIB section 2 - Use a 8 bit DIB section 3 - Use a 16 bit DIB section 4 - Use a 24 bit DIB section 5 - Use a 32 bit DIB section 6 - Use a device-dependent bitmap
$iOptions | [optional] Option flags. Can be a combination of the following: 1 - Use a mask 2 - The images in the lists are mirrored 4 - The image list contains a strip of images
$iInitial | [optional] Number of images that the image list initially contains
$iGrow | [optional] Number of images by which the image list can grow when the system needs to make room for new images. This parameter represents the number of new images that the resized image list can contain.

Return Value

Success: | a handle to the new control.
Failure: | 0.

Related

_GUIImageList_Destroy

Example

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

Example()

Func Example()
    Local $idListview, $hImage
    Local $iStylesEx = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    GUICreate("ImageList Create", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iStylesEx)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap(GUICtrlGetHandle($idListview), 0xFF0000, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap(GUICtrlGetHandle($idListview), 0x00FF00, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap(GUICtrlGetHandle($idListview), 0x0000FF, 11, 11))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 120)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUIImageList_Destroy

Function Reference

_GUIImageList_Destroy

Destroys an image list

#include <GuiImageList.au3>
_GUIImageList_Destroy ( $hWnd )

Parameters

$hWnd Handle to the imagelist

Return Value

Success: | True.
Failure: | False.

Related

_GUIImageList_Create

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idListview, $hImage1, $hImage2
    Local $iStylesEx = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    GUICreate("ImageList Destroy", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iStylesEx)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage1 = _GUIImageList_Create(11, 11)
    _GUIImageList_Add($hImage1, _WinAPI_CreateSolidBitmap(GUICtrlGetHandle($idListview), 0xFF0000, 11, 11))
    _GUIImageList_Add($hImage1, _WinAPI_CreateSolidBitmap(GUICtrlGetHandle($idListview), 0x00FF00, 11, 11))
    _GUIImageList_Add($hImage1, _WinAPI_CreateSolidBitmap(GUICtrlGetHandle($idListview), 0x0000FF, 11, 11))
    _GUICtrlListView_SetImageList($idListview, $hImage1, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 120)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    MsgBox($MB_SYSTEMMODAL, "Information", "Creating new image list")

    ; Create a new image list
    $hImage2 = _GUIImageList_Create(11, 11)
    _GUIImageList_Add($hImage2, _WinAPI_CreateSolidBitmap(GUICtrlGetHandle($idListview), 0x0000FF, 11, 11))
    _GUIImageList_Add($hImage2, _WinAPI_CreateSolidBitmap(GUICtrlGetHandle($idListview), 0x00FF00, 11, 11))
    _GUIImageList_Add($hImage2, _WinAPI_CreateSolidBitmap(GUICtrlGetHandle($idListview), 0xFF0000, 11, 11))
    _GUICtrlListView_SetImageList($idListview, $hImage2, 1)

    MsgBox($MB_SYSTEMMODAL, "Information", "Destroying 1st image list")

    ; Free first image list
    _GUIImageList_Destroy($hImage1)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUIImageList_DestroyIcon

Function Reference

_GUIImageList_DestroyIcon

Destroys an icon and frees any memory the icon occupied

#include <GuiImageList.au3>
_GUIImageList_DestroyIcon ( $hIcon )

Parameters

$hIcon Handle to the icon

Return Value

Success: | True.
Failure: | False.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiStatusBar.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global $g_hStatus, $g_idMemo

Example()

Func Example()
    Local $hGUI, $ahIcons[2], $hImage
    Local $aParts[4] = [75, 150, 300, 400]

    ; Create GUI
    $hGUI = GUICreate("ImageList Destroy Icon", 400, 300)
    $g_hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Set parts
    _GUICtrlStatusBar_SetParts($g_hStatus, $aParts)
    _GUICtrlStatusBar_SetText($g_hStatus, "Part 1")
    _GUICtrlStatusBar_SetText($g_hStatus, "Part 2", 1)

    ; Load images
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($g_hStatus, 0xFF0000, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($g_hStatus, 0x00FF00, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($g_hStatus, 0x0000FF, 11, 11))

    ; Set icons
    $ahIcons[0] = _GUIImageList_GetIcon($hImage, 1)
    $ahIcons[1] = _GUIImageList_GetIcon($hImage, 2)
    _GUICtrlStatusBar_SetIcon($g_hStatus, 0, $ahIcons[0])
    _GUICtrlStatusBar_SetIcon($g_hStatus, 1, $ahIcons[1])

    ; Show icon handles
    MemoWrite("Part 1 icon handle .: 0x" & Hex($ahIcons[0]))
    MemoWrite("Part 2 icon handle .: 0x" & Hex($ahIcons[1]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    ; Free icons
    MsgBox($MB_SYSTEMMODAL, "Information", "Icon 1 Destroyed? " & _GUIImageList_DestroyIcon($ahIcons[0]))
    MsgBox($MB_SYSTEMMODAL, "Information", "Icon 2 Destroyed? " & _GUIImageList_DestroyIcon($ahIcons[1]))
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Local $tInfo
    Switch $hWndFrom
        Case $g_hStatus
            Switch $iCode
                Case $NM_CLICK ; The user has clicked the left mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_RCLICK ; The user has clicked the right mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_RDBLCLK ; The user has double-clicked the right mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $SBN_SIMPLEMODECHANGE ; Simple mode changes
                    _DebugPrint("$SBN_SIMPLEMODECHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUIImageList_DragEnter

Function Reference

_GUIImageList_DragEnter

Displays the drag image at the specified position within the window

#include <GuiImageList.au3>
_GUIImageList_DragEnter ( $hWnd, $iX, $iY )

Parameters

$hWnd | Handle to the imagelist
$iX | The x-coordinate at which to display the drag image. The coordinate is relative to the upper-left corner of the window, not the client area.
$iY | The y-coordinate at which to display the drag image. The coordinate is relative to the upper-left corner of the window, not the client area.

Return Value

Success: | True.
Failure: | False.

Related

_GUIImageList_BeginDrag

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

#Region Globals *************************************************************************
Global $g_ahDragImageList, $g_hListView, $g_bDragging = False, $g_iLV_Height
Global $g_aIndex[2] ; from and to

Global Const $g_iDebugIt = 1

#EndRegion Globals *************************************************************************

Opt("WinTitleMatchMode", 2)

Example()

Func Example()
    Local Const $iImage_width = 20
    Local Const $iImage_height = 20
    Local $hImages, $hMain_GUI, $iIndex

    $hMain_GUI = GUICreate("GuiImageList Begin Drag", 225, 400)

    $g_hListView = _GUICtrlListView_Create($hMain_GUI, "Entry Name|Category", 5, 75, 220, 280, -1, BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE))
    $g_iLV_Height = 280 - 75
    _GUICtrlListView_SetColumnWidth($g_hListView, 0, 100)
    _GUICtrlListView_SetColumnWidth($g_hListView, 1, 100)
    _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
    ;------------------------------------------------------
    ; Using subitem images
    ;------------------------------------------------------
    _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_SUBITEMIMAGES))

    ;------------------------------------------------------
    ; create the image list
    ;------------------------------------------------------
    $hImages = _GUIImageList_Create($iImage_width, $iImage_height, 5, 1)
    For $x = 1 To 21
        _GUIImageList_AddIcon($hImages, @SystemDir & "\shell32.dll", $x)
    Next

    _GUICtrlListView_SetImageList($g_hListView, $hImages, $LVSIL_SMALL)

    ;------------------------------------------------------
    ;Register event functions
    ;------------------------------------------------------
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    GUIRegisterMsg($WM_LBUTTONUP, "WM_LBUTTONUP")
    GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE")

    ;------------------------------------------------------
    ; add listview items with images
    ;------------------------------------------------------
    Local $y = 1
    For $x = 0 To 9
        $iIndex = _GUICtrlListView_AddItem($g_hListView, "Name " & $x + 1, $y) ; handle, string, image index
        _GUICtrlListView_AddSubItem($g_hListView, $iIndex, "Category " & $x + 1, 1, $y + 1) ; handle, index, string, subitem, image index
        $y += 2
    Next

    GUISetState(@SW_SHOW)

    While 1

        Switch GUIGetMsg()

            ;-----------------------------------------------------------------------------------------
            ;This case statement exits and updates code if needed
            Case $GUI_EVENT_CLOSE
                ExitLoop
                ;-----------------------------------------------------------------------------------------
                ;put all the misc. stuff here
            Case Else
                ;;;
        EndSwitch
    WEnd

    _GUIImageList_Destroy($hImages)
    GUIDelete()
EndFunc   ;==>Example

#Region Item Function(s) **********************************************************************************************
Func _LVInsertItem($i_FromItem, $i_ToItem)
    Local $iItem_state, $i_NewIndex
    Local $tStruct_LVITEM = DllStructCreate($tagLVITEM)
    Local $tStruct_String = DllStructCreate("wchar Buffer[4096]")

    ; Insert item into new position
    DllStructSetData($tStruct_LVITEM, "Mask", BitOR($LVIF_STATE, $LVIF_IMAGE, $LVIF_INDENT, $LVIF_PARAM, $LVIF_TEXT))
    DllStructSetData($tStruct_LVITEM, "StateMask", $LVIS_STATEIMAGEMASK)
    DllStructSetData($tStruct_LVITEM, "Item", $i_FromItem)
    DllStructSetData($tStruct_LVITEM, "SubItem", 0)
    DllStructSetData($tStruct_LVITEM, "TextMax", 4096)
    DllStructSetData($tStruct_LVITEM, "Text", DllStructGetPtr($tStruct_String))
    _GUICtrlListView_GetItemEx($g_hListView, $tStruct_LVITEM)
    If @error Then Return SetError(-1, -1, -1)
    $iItem_state = DllStructGetData($tStruct_LVITEM, "State")
    DllStructSetData($tStruct_LVITEM, "Item", $i_ToItem)
    $i_NewIndex = _GUICtrlListView_InsertItem($g_hListView, DllStructGetData($tStruct_String, "Buffer"), $i_ToItem, DllStructGetData($tStruct_LVITEM, "Image"))
    If @error Then Return SetError(-1, -1, -1)

    ; restore previous state
    _DebugPrint("$i_NewIndex = " & $i_NewIndex)
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_STATE)
    DllStructSetData($tStruct_LVITEM, "Item", $i_NewIndex)
    DllStructSetData($tStruct_LVITEM, "State", $iItem_state)
    DllStructSetData($tStruct_LVITEM, "StateMask", $LVIS_STATEIMAGEMASK)
    _GUICtrlListView_SetItemState($g_hListView, $i_NewIndex, $iItem_state, $LVIS_STATEIMAGEMASK)
    If @error Then Return SetError(-1, -1, -1)
    Return $i_NewIndex
EndFunc   ;==>_LVInsertItem

; ------------------------------------------------------
Func _LVCopyItem($i_FromItem, $i_ToItem, $i_SubItem = 0)
    Local $tStruct_LVITEM = DllStructCreate($tagLVITEM)
    Local $tStruct_String = DllStructCreate("wchar Buffer[4096]")

    ; get from item info
    DllStructSetData($tStruct_LVITEM, "Mask", BitOR($LVIF_STATE, $LVIF_IMAGE, $LVIF_INDENT, $LVIF_PARAM, $LVIF_TEXT))
    DllStructSetData($tStruct_LVITEM, "StateMask", $LVIS_STATEIMAGEMASK)
    DllStructSetData($tStruct_LVITEM, "Item", $i_FromItem)
    DllStructSetData($tStruct_LVITEM, "SubItem", $i_SubItem)
    DllStructSetData($tStruct_LVITEM, "TextMax", 4096)
    DllStructSetData($tStruct_LVITEM, "Text", DllStructGetPtr($tStruct_String))
    _GUICtrlListView_GetItemEx($g_hListView, $tStruct_LVITEM)

    ; set to
    DllStructSetData($tStruct_LVITEM, "Item", $i_ToItem)
    ; set text
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_TEXT)
    DllStructSetData($tStruct_LVITEM, "Text", DllStructGetPtr($tStruct_String))
    DllStructSetData($tStruct_LVITEM, "TextMax", 4096)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    If @error Then Return SetError(@error, @error, @error)
    ; set status
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_STATE)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set image
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_IMAGE)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_IMAGE)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set state
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_STATE)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_STATE)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set indent
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_INDENT)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_INDENT)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set Param
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_PARAM)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_PARAM)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
EndFunc   ;==>_LVCopyItem
#EndRegion Item Function(s) **********************************************************************************************

#Region Event Function(s) **********************************************************************************************

; WM_MOUSEMOVE event handler
; ------------------------------------------------------
Func WM_MOUSEMOVE($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $iMsgID, $wParam
    ;------------------------------------------------------
    ; not dragging item we are done here
    ;------------------------------------------------------
    If $g_bDragging = False Then Return $GUI_RUNDEFMSG

    ;------------------------------------------------------
    ; update the image move
    ;------------------------------------------------------
    Local $aPos = ControlGetPos($hWndGUI, "", $g_hListView)
    Local $x = BitAND($lParam, 0xFFFF) - $aPos[0]
    Local $y = BitShift($lParam, 16) - $aPos[1]
    If $y > $g_iLV_Height - 20 Then
        _GUICtrlListView_Scroll($g_hListView, 0, $y)
    ElseIf $y < 20 Then
        _GUICtrlListView_Scroll($g_hListView, 0, $y * -1)
    EndIf
    _GUIImageList_DragMove($x, $y)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEMOVE

; WM_LBUTTONUP event handler
; ------------------------------------------------------
Func WM_LBUTTONUP($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $iMsgID, $wParam
    $g_bDragging = False
    Local $aPos = ControlGetPos($hWndGUI, "", $g_hListView)
    Local $x = BitAND($lParam, 0xFFFF) - $aPos[0]
    Local $y = BitShift($lParam, 16) - $aPos[1]
    _DebugPrint("$x = " & $x)
    _DebugPrint("$y = " & $y)
    ;------------------------------------------------------
    ; done dragging
    ;------------------------------------------------------
    _GUIImageList_DragLeave($g_hListView)
    _GUIImageList_EndDrag()
    _GUIImageList_Destroy($g_ahDragImageList[0])
    _WinAPI_ReleaseCapture()
    ;------------------------------------------------------
    ; do hit test see if drag ended in the listview
    ;------------------------------------------------------
    Local $tStruct_LVHITTESTINFO = DllStructCreate($tagLVHITTESTINFO)

    DllStructSetData($tStruct_LVHITTESTINFO, "X", $x)
    DllStructSetData($tStruct_LVHITTESTINFO, "Y", $y)
    $g_aIndex[1] = _SendMessage($g_hListView, $LVM_HITTEST, 0, DllStructGetPtr($tStruct_LVHITTESTINFO), 0, "wparam", "ptr")
    Local $iFlags = DllStructGetData($tStruct_LVHITTESTINFO, "Flags")
    _DebugPrint("$iFlags: " & $iFlags)
    ;------------------------------------------------------
    ; // Out of the ListView?
    ;------------------------------------------------------
    If $g_aIndex[1] == -1 Then Return $GUI_RUNDEFMSG
    ;------------------------------------------------------
    ; // Not in an item?
    ;------------------------------------------------------
    If BitAND($iFlags, $LVHT_ONITEMLABEL) == 0 And BitAND($iFlags, $LVHT_ONITEMSTATEICON) == 0 And BitAND($iFlags, $LVHT_ONITEMICON) = 0 Then Return $GUI_RUNDEFMSG
    ;------------------------------------------------------
    ; make sure insert is at least 2 items above or below, don't want to create a duplicate
    ;------------------------------------------------------
    If $g_aIndex[0] < $g_aIndex[1] - 1 Or $g_aIndex[0] > $g_aIndex[1] + 1 Then
        _DebugPrint("To = " & $g_aIndex[1])
        Local $i_NewIndex = _LVInsertItem($g_aIndex[0], $g_aIndex[1])
        If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)
        Local $iFrom_index = $g_aIndex[0]
        If $g_aIndex[0] > $g_aIndex[1] Then $iFrom_index = $g_aIndex[0] + 1
        ;------------------------------------------------------
        ; copy item and subitem(s) images, text, and state
        ;------------------------------------------------------
        For $x = 1 To _GUICtrlListView_GetColumnCount($g_hListView) - 1
            _LVCopyItem($iFrom_index, $i_NewIndex, $x)
            If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)
        Next
        ;------------------------------------------------------
        ; delete from
        ;------------------------------------------------------
        _GUICtrlListView_DeleteItem($g_hListView, $iFrom_index)
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_LBUTTONUP

; WM_NOTIFY event handler
; ------------------------------------------------------
Func WM_NOTIFY($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $hWndGUI, $iMsgID, $wParam
    Local $tNMHDR, $iCode, $x, $y, $tNMLISTVIEW, $hWndFrom, $tDraw, $iDrawStage, $iItemSpec
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam) ;NMHDR (hwndFrom, idFrom, code)
    If @error Then Return
    $iCode = DllStructGetData($tNMHDR, "Code")
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    Switch $hWndFrom
        Case $g_hListView
            Switch $iCode
                Case $LVN_BEGINDRAG
                    _DebugPrint("$LVN_BEGINDRAG")
                    $x = BitAND($lParam, 0xFFFF)
                    $y = BitShift($lParam, 16)
                    $tNMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam)
                    $g_aIndex[0] = DllStructGetData($tNMLISTVIEW, "Item")
                    $g_ahDragImageList = _GUICtrlListView_CreateDragImage($g_hListView, $g_aIndex[0])
                    If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)

                    _GUIImageList_BeginDrag($g_ahDragImageList[0], 0, 0, 0)

                    If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)
                    _DebugPrint("From = " & $g_aIndex[0])
                    _GUIImageList_DragEnter($g_hListView, $x, $y)
                    _WinAPI_SetCapture($hWndGUI)
                    $g_bDragging = True
                Case $NM_CUSTOMDRAW
                    _DebugPrint("$NM_CUSTOMDRAW")
                    $tDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
                    $iDrawStage = DllStructGetData($tDraw, "dwDrawStage")
                    $iItemSpec = DllStructGetData($tDraw, "dwItemSpec")
                    Switch $iDrawStage
                        Case $CDDS_PREPAINT
                            _DebugPrint("$CDDS_PREPAINT")
                            Return $CDRF_NOTIFYITEMDRAW
                        Case $CDDS_ITEMPREPAINT
                            _DebugPrint("$CDDS_ITEMPREPAINT")
                            If BitAND($iItemSpec, 1) = 1 Then
                                DllStructSetData($tDraw, "clrTextBk", $CLR_AQUA)
                            Else
                                DllStructSetData($tDraw, "clrTextBk", $CLR_WHITE)
                            EndIf
                            Return $CDRF_NEWFONT
                    EndSwitch
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
#EndRegion Event Function(s) **********************************************************************************************

Func _DebugPrint($s_Text)
    If Not $g_iDebugIt Then Return
    $s_Text = StringReplace($s_Text, @CRLF, @CRLF & "-->")
    ConsoleWrite("!===========================================================" & @CRLF & _
            "+===========================================================" & @CRLF & _
            "-->" & $s_Text & @CRLF & _
            "+===========================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUIImageList_DragLeave

Function Reference

_GUIImageList_DragLeave

Unlocks the specified window and hides the drag image, allowing the window to be updated

#include <GuiImageList.au3>
_GUIImageList_DragLeave ( $hWnd )

Parameters

$hWnd Handle to the imagelist

Return Value

Success: | True.
Failure: | False.

Related

_GUIImageList_EndDrag

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

#Region Globals *************************************************************************
Global $g_ahDragImageList, $g_hListView, $g_bDragging = False, $g_iLV_Height
Global $g_aIndex[2] ; from and to

Global Const $g_iDebugIt = 1

#EndRegion Globals *************************************************************************

Opt("WinTitleMatchMode", 2)

Example()

Func Example()
    Local Const $iImage_width = 20
    Local Const $iImage_height = 20
    Local $hImages, $hMain_GUI, $iIndex

    $hMain_GUI = GUICreate("GuiImageList Begin Drag", 225, 400)

    $g_hListView = _GUICtrlListView_Create($hMain_GUI, "Entry Name|Category", 5, 75, 220, 280, -1, BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE))
    $g_iLV_Height = 280 - 75
    _GUICtrlListView_SetColumnWidth($g_hListView, 0, 100)
    _GUICtrlListView_SetColumnWidth($g_hListView, 1, 100)
    _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
    ;------------------------------------------------------
    ; Using subitem images
    ;------------------------------------------------------
    _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_SUBITEMIMAGES))

    ;------------------------------------------------------
    ; create the image list
    ;------------------------------------------------------
    $hImages = _GUIImageList_Create($iImage_width, $iImage_height, 5, 1)
    For $x = 1 To 21
        _GUIImageList_AddIcon($hImages, @SystemDir & "\shell32.dll", $x)
    Next

    _GUICtrlListView_SetImageList($g_hListView, $hImages, $LVSIL_SMALL)

    ;------------------------------------------------------
    ;Register event functions
    ;------------------------------------------------------
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    GUIRegisterMsg($WM_LBUTTONUP, "WM_LBUTTONUP")
    GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE")

    ;------------------------------------------------------
    ; add listview items with images
    ;------------------------------------------------------
    Local $y = 1
    For $x = 0 To 9
        $iIndex = _GUICtrlListView_AddItem($g_hListView, "Name " & $x + 1, $y) ; handle, string, image index
        _GUICtrlListView_AddSubItem($g_hListView, $iIndex, "Category " & $x + 1, 1, $y + 1) ; handle, index, string, subitem, image index
        $y += 2
    Next

    GUISetState(@SW_SHOW)

    While 1

        Switch GUIGetMsg()

            ;-----------------------------------------------------------------------------------------
            ;This case statement exits and updates code if needed
            Case $GUI_EVENT_CLOSE
                ExitLoop
                ;-----------------------------------------------------------------------------------------
                ;put all the misc. stuff here
            Case Else
                ;;;
        EndSwitch
    WEnd

    _GUIImageList_Destroy($hImages)
    GUIDelete()
EndFunc   ;==>Example

#Region Item Function(s) **********************************************************************************************
Func _LVInsertItem($i_FromItem, $i_ToItem)
    Local $iItem_state, $i_NewIndex
    Local $tStruct_LVITEM = DllStructCreate($tagLVITEM)
    Local $tStruct_String = DllStructCreate("wchar Buffer[4096]")

    ; Insert item into new position
    DllStructSetData($tStruct_LVITEM, "Mask", BitOR($LVIF_STATE, $LVIF_IMAGE, $LVIF_INDENT, $LVIF_PARAM, $LVIF_TEXT))
    DllStructSetData($tStruct_LVITEM, "StateMask", $LVIS_STATEIMAGEMASK)
    DllStructSetData($tStruct_LVITEM, "Item", $i_FromItem)
    DllStructSetData($tStruct_LVITEM, "SubItem", 0)
    DllStructSetData($tStruct_LVITEM, "TextMax", 4096)
    DllStructSetData($tStruct_LVITEM, "Text", DllStructGetPtr($tStruct_String))
    _GUICtrlListView_GetItemEx($g_hListView, $tStruct_LVITEM)
    If @error Then Return SetError(-1, -1, -1)
    $iItem_state = DllStructGetData($tStruct_LVITEM, "State")
    DllStructSetData($tStruct_LVITEM, "Item", $i_ToItem)
    $i_NewIndex = _GUICtrlListView_InsertItem($g_hListView, DllStructGetData($tStruct_String, "Buffer"), $i_ToItem, DllStructGetData($tStruct_LVITEM, "Image"))
    If @error Then Return SetError(-1, -1, -1)

    ; restore previous state
    _DebugPrint("$i_NewIndex = " & $i_NewIndex)
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_STATE)
    DllStructSetData($tStruct_LVITEM, "Item", $i_NewIndex)
    DllStructSetData($tStruct_LVITEM, "State", $iItem_state)
    DllStructSetData($tStruct_LVITEM, "StateMask", $LVIS_STATEIMAGEMASK)
    _GUICtrlListView_SetItemState($g_hListView, $i_NewIndex, $iItem_state, $LVIS_STATEIMAGEMASK)
    If @error Then Return SetError(-1, -1, -1)
    Return $i_NewIndex
EndFunc   ;==>_LVInsertItem

; ------------------------------------------------------
Func _LVCopyItem($i_FromItem, $i_ToItem, $i_SubItem = 0)
    Local $tStruct_LVITEM = DllStructCreate($tagLVITEM)
    Local $tStruct_String = DllStructCreate("wchar Buffer[4096]")

    ; get from item info
    DllStructSetData($tStruct_LVITEM, "Mask", BitOR($LVIF_STATE, $LVIF_IMAGE, $LVIF_INDENT, $LVIF_PARAM, $LVIF_TEXT))
    DllStructSetData($tStruct_LVITEM, "StateMask", $LVIS_STATEIMAGEMASK)
    DllStructSetData($tStruct_LVITEM, "Item", $i_FromItem)
    DllStructSetData($tStruct_LVITEM, "SubItem", $i_SubItem)
    DllStructSetData($tStruct_LVITEM, "TextMax", 4096)
    DllStructSetData($tStruct_LVITEM, "Text", DllStructGetPtr($tStruct_String))
    _GUICtrlListView_GetItemEx($g_hListView, $tStruct_LVITEM)

    ; set to
    DllStructSetData($tStruct_LVITEM, "Item", $i_ToItem)
    ; set text
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_TEXT)
    DllStructSetData($tStruct_LVITEM, "Text", DllStructGetPtr($tStruct_String))
    DllStructSetData($tStruct_LVITEM, "TextMax", 4096)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    If @error Then Return SetError(@error, @error, @error)
    ; set status
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_STATE)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set image
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_IMAGE)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_IMAGE)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set state
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_STATE)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_STATE)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set indent
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_INDENT)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_INDENT)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set Param
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_PARAM)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_PARAM)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
EndFunc   ;==>_LVCopyItem
#EndRegion Item Function(s) **********************************************************************************************

#Region Event Function(s) **********************************************************************************************

; WM_MOUSEMOVE event handler
; ------------------------------------------------------
Func WM_MOUSEMOVE($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $iMsgID, $wParam
    ;------------------------------------------------------
    ; not dragging item we are done here
    ;------------------------------------------------------
    If $g_bDragging = False Then Return $GUI_RUNDEFMSG

    ;------------------------------------------------------
    ; update the image move
    ;------------------------------------------------------
    Local $aPos = ControlGetPos($hWndGUI, "", $g_hListView)
    Local $x = BitAND($lParam, 0xFFFF) - $aPos[0]
    Local $y = BitShift($lParam, 16) - $aPos[1]
    If $y > $g_iLV_Height - 20 Then
        _GUICtrlListView_Scroll($g_hListView, 0, $y)
    ElseIf $y < 20 Then
        _GUICtrlListView_Scroll($g_hListView, 0, $y * -1)
    EndIf
    _GUIImageList_DragMove($x, $y)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEMOVE

; WM_LBUTTONUP event handler
; ------------------------------------------------------
Func WM_LBUTTONUP($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $iMsgID, $wParam
    $g_bDragging = False
    Local $aPos = ControlGetPos($hWndGUI, "", $g_hListView)
    Local $x = BitAND($lParam, 0xFFFF) - $aPos[0]
    Local $y = BitShift($lParam, 16) - $aPos[1]
    _DebugPrint("$x = " & $x)
    _DebugPrint("$y = " & $y)
    ;------------------------------------------------------
    ; done dragging
    ;------------------------------------------------------
    _GUIImageList_DragLeave($g_hListView)
    _GUIImageList_EndDrag()
    _GUIImageList_Destroy($g_ahDragImageList[0])
    _WinAPI_ReleaseCapture()
    ;------------------------------------------------------
    ; do hit test see if drag ended in the listview
    ;------------------------------------------------------
    Local $tStruct_LVHITTESTINFO = DllStructCreate($tagLVHITTESTINFO)

    DllStructSetData($tStruct_LVHITTESTINFO, "X", $x)
    DllStructSetData($tStruct_LVHITTESTINFO, "Y", $y)
    $g_aIndex[1] = _SendMessage($g_hListView, $LVM_HITTEST, 0, DllStructGetPtr($tStruct_LVHITTESTINFO), 0, "wparam", "ptr")
    Local $iFlags = DllStructGetData($tStruct_LVHITTESTINFO, "Flags")
    _DebugPrint("$iFlags: " & $iFlags)
    ;------------------------------------------------------
    ; // Out of the ListView?
    ;------------------------------------------------------
    If $g_aIndex[1] == -1 Then Return $GUI_RUNDEFMSG
    ;------------------------------------------------------
    ; // Not in an item?
    ;------------------------------------------------------
    If BitAND($iFlags, $LVHT_ONITEMLABEL) == 0 And BitAND($iFlags, $LVHT_ONITEMSTATEICON) == 0 And BitAND($iFlags, $LVHT_ONITEMICON) = 0 Then Return $GUI_RUNDEFMSG
    ;------------------------------------------------------
    ; make sure insert is at least 2 items above or below, don't want to create a duplicate
    ;------------------------------------------------------
    If $g_aIndex[0] < $g_aIndex[1] - 1 Or $g_aIndex[0] > $g_aIndex[1] + 1 Then
        _DebugPrint("To = " & $g_aIndex[1])
        Local $i_NewIndex = _LVInsertItem($g_aIndex[0], $g_aIndex[1])
        If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)
        Local $iFrom_index = $g_aIndex[0]
        If $g_aIndex[0] > $g_aIndex[1] Then $iFrom_index = $g_aIndex[0] + 1
        ;------------------------------------------------------
        ; copy item and subitem(s) images, text, and state
        ;------------------------------------------------------
        For $x = 1 To _GUICtrlListView_GetColumnCount($g_hListView) - 1
            _LVCopyItem($iFrom_index, $i_NewIndex, $x)
            If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)
        Next
        ;------------------------------------------------------
        ; delete from
        ;------------------------------------------------------
        _GUICtrlListView_DeleteItem($g_hListView, $iFrom_index)
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_LBUTTONUP

; WM_NOTIFY event handler
; ------------------------------------------------------
Func WM_NOTIFY($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $hWndGUI, $iMsgID, $wParam
    Local $tNMHDR, $iCode, $x, $y, $tNMLISTVIEW, $hWndFrom, $tDraw, $iDrawStage, $iItemSpec
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam) ;NMHDR (hwndFrom, idFrom, code)
    If @error Then Return
    $iCode = DllStructGetData($tNMHDR, "Code")
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    Switch $hWndFrom
        Case $g_hListView
            Switch $iCode
                Case $LVN_BEGINDRAG
                    _DebugPrint("$LVN_BEGINDRAG")
                    $x = BitAND($lParam, 0xFFFF)
                    $y = BitShift($lParam, 16)
                    $tNMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam)
                    $g_aIndex[0] = DllStructGetData($tNMLISTVIEW, "Item")
                    $g_ahDragImageList = _GUICtrlListView_CreateDragImage($g_hListView, $g_aIndex[0])
                    If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)

                    _GUIImageList_BeginDrag($g_ahDragImageList[0], 0, 0, 0)

                    If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)
                    _DebugPrint("From = " & $g_aIndex[0])
                    _GUIImageList_DragEnter($g_hListView, $x, $y)
                    _WinAPI_SetCapture($hWndGUI)
                    $g_bDragging = True
                Case $NM_CUSTOMDRAW
                    _DebugPrint("$NM_CUSTOMDRAW")
                    $tDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
                    $iDrawStage = DllStructGetData($tDraw, "dwDrawStage")
                    $iItemSpec = DllStructGetData($tDraw, "dwItemSpec")
                    Switch $iDrawStage
                        Case $CDDS_PREPAINT
                            _DebugPrint("$CDDS_PREPAINT")
                            Return $CDRF_NOTIFYITEMDRAW
                        Case $CDDS_ITEMPREPAINT
                            _DebugPrint("$CDDS_ITEMPREPAINT")
                            If BitAND($iItemSpec, 1) = 1 Then
                                DllStructSetData($tDraw, "clrTextBk", $CLR_AQUA)
                            Else
                                DllStructSetData($tDraw, "clrTextBk", $CLR_WHITE)
                            EndIf
                            Return $CDRF_NEWFONT
                    EndSwitch
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
#EndRegion Event Function(s) **********************************************************************************************

Func _DebugPrint($s_Text)
    If Not $g_iDebugIt Then Return
    $s_Text = StringReplace($s_Text, @CRLF, @CRLF & "-->")
    ConsoleWrite("!===========================================================" & @CRLF & _
            "+===========================================================" & @CRLF & _
            "-->" & $s_Text & @CRLF & _
            "+===========================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUIImageList_DragMove

Function Reference

_GUIImageList_DragMove

Moves the image that is being dragged during a drag-and-drop operation

#include <GuiImageList.au3>
_GUIImageList_DragMove ( $iX, $iY )

Parameters

$iX | The x-coordinate at which to display the drag image. The coordinate is relative to the upper-left corner of the window, not the client area.
$iY | The y-coordinate at which to display the drag image. The coordinate is relative to the upper-left corner of the window, not the client area.

Return Value

Success: | True.
Failure: | False.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

#Region Globals *************************************************************************
Global $g_ahDragImageList, $g_hListView, $g_bDragging = False, $g_iLV_Height
Global $g_aIndex[2] ; from and to

Global Const $g_iDebugIt = 1

#EndRegion Globals *************************************************************************

Opt("WinTitleMatchMode", 2)

Example()

Func Example()
    Local Const $iImage_width = 20
    Local Const $iImage_height = 20
    Local $hImages, $hMain_GUI, $iIndex

    $hMain_GUI = GUICreate("GuiImageList Begin Drag", 225, 400)

    $g_hListView = _GUICtrlListView_Create($hMain_GUI, "Entry Name|Category", 5, 75, 220, 280, -1, BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE))
    $g_iLV_Height = 280 - 75
    _GUICtrlListView_SetColumnWidth($g_hListView, 0, 100)
    _GUICtrlListView_SetColumnWidth($g_hListView, 1, 100)
    _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
    ;------------------------------------------------------
    ; Using subitem images
    ;------------------------------------------------------
    _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_SUBITEMIMAGES))

    ;------------------------------------------------------
    ; create the image list
    ;------------------------------------------------------
    $hImages = _GUIImageList_Create($iImage_width, $iImage_height, 5, 1)
    For $x = 1 To 21
        _GUIImageList_AddIcon($hImages, @SystemDir & "\shell32.dll", $x)
    Next

    _GUICtrlListView_SetImageList($g_hListView, $hImages, $LVSIL_SMALL)

    ;------------------------------------------------------
    ;Register event functions
    ;------------------------------------------------------
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    GUIRegisterMsg($WM_LBUTTONUP, "WM_LBUTTONUP")
    GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE")

    ;------------------------------------------------------
    ; add listview items with images
    ;------------------------------------------------------
    Local $y = 1
    For $x = 0 To 9
        $iIndex = _GUICtrlListView_AddItem($g_hListView, "Name " & $x + 1, $y) ; handle, string, image index
        _GUICtrlListView_AddSubItem($g_hListView, $iIndex, "Category " & $x + 1, 1, $y + 1) ; handle, index, string, subitem, image index
        $y += 2
    Next

    GUISetState(@SW_SHOW)

    While 1

        Switch GUIGetMsg()

            ;-----------------------------------------------------------------------------------------
            ;This case statement exits and updates code if needed
            Case $GUI_EVENT_CLOSE
                ExitLoop
                ;-----------------------------------------------------------------------------------------
                ;put all the misc. stuff here
            Case Else
                ;;;
        EndSwitch
    WEnd

    _GUIImageList_Destroy($hImages)
    GUIDelete()
EndFunc   ;==>Example

#Region Item Function(s) **********************************************************************************************
Func _LVInsertItem($i_FromItem, $i_ToItem)
    Local $iItem_state, $i_NewIndex
    Local $tStruct_LVITEM = DllStructCreate($tagLVITEM)
    Local $tStruct_String = DllStructCreate("wchar Buffer[4096]")

    ; Insert item into new position
    DllStructSetData($tStruct_LVITEM, "Mask", BitOR($LVIF_STATE, $LVIF_IMAGE, $LVIF_INDENT, $LVIF_PARAM, $LVIF_TEXT))
    DllStructSetData($tStruct_LVITEM, "StateMask", $LVIS_STATEIMAGEMASK)
    DllStructSetData($tStruct_LVITEM, "Item", $i_FromItem)
    DllStructSetData($tStruct_LVITEM, "SubItem", 0)
    DllStructSetData($tStruct_LVITEM, "TextMax", 4096)
    DllStructSetData($tStruct_LVITEM, "Text", DllStructGetPtr($tStruct_String))
    _GUICtrlListView_GetItemEx($g_hListView, $tStruct_LVITEM)
    If @error Then Return SetError(-1, -1, -1)
    $iItem_state = DllStructGetData($tStruct_LVITEM, "State")
    DllStructSetData($tStruct_LVITEM, "Item", $i_ToItem)
    $i_NewIndex = _GUICtrlListView_InsertItem($g_hListView, DllStructGetData($tStruct_String, "Buffer"), $i_ToItem, DllStructGetData($tStruct_LVITEM, "Image"))
    If @error Then Return SetError(-1, -1, -1)

    ; restore previous state
    _DebugPrint("$i_NewIndex = " & $i_NewIndex)
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_STATE)
    DllStructSetData($tStruct_LVITEM, "Item", $i_NewIndex)
    DllStructSetData($tStruct_LVITEM, "State", $iItem_state)
    DllStructSetData($tStruct_LVITEM, "StateMask", $LVIS_STATEIMAGEMASK)
    _GUICtrlListView_SetItemState($g_hListView, $i_NewIndex, $iItem_state, $LVIS_STATEIMAGEMASK)
    If @error Then Return SetError(-1, -1, -1)
    Return $i_NewIndex
EndFunc   ;==>_LVInsertItem

; ------------------------------------------------------
Func _LVCopyItem($i_FromItem, $i_ToItem, $i_SubItem = 0)
    Local $tStruct_LVITEM = DllStructCreate($tagLVITEM)
    Local $tStruct_String = DllStructCreate("wchar Buffer[4096]")

    ; get from item info
    DllStructSetData($tStruct_LVITEM, "Mask", BitOR($LVIF_STATE, $LVIF_IMAGE, $LVIF_INDENT, $LVIF_PARAM, $LVIF_TEXT))
    DllStructSetData($tStruct_LVITEM, "StateMask", $LVIS_STATEIMAGEMASK)
    DllStructSetData($tStruct_LVITEM, "Item", $i_FromItem)
    DllStructSetData($tStruct_LVITEM, "SubItem", $i_SubItem)
    DllStructSetData($tStruct_LVITEM, "TextMax", 4096)
    DllStructSetData($tStruct_LVITEM, "Text", DllStructGetPtr($tStruct_String))
    _GUICtrlListView_GetItemEx($g_hListView, $tStruct_LVITEM)

    ; set to
    DllStructSetData($tStruct_LVITEM, "Item", $i_ToItem)
    ; set text
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_TEXT)
    DllStructSetData($tStruct_LVITEM, "Text", DllStructGetPtr($tStruct_String))
    DllStructSetData($tStruct_LVITEM, "TextMax", 4096)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    If @error Then Return SetError(@error, @error, @error)
    ; set status
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_STATE)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set image
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_IMAGE)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_IMAGE)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set state
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_STATE)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_STATE)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set indent
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_INDENT)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_INDENT)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set Param
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_PARAM)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_PARAM)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
EndFunc   ;==>_LVCopyItem
#EndRegion Item Function(s) **********************************************************************************************

#Region Event Function(s) **********************************************************************************************

; WM_MOUSEMOVE event handler
; ------------------------------------------------------
Func WM_MOUSEMOVE($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $iMsgID, $wParam
    ;------------------------------------------------------
    ; not dragging item we are done here
    ;------------------------------------------------------
    If $g_bDragging = False Then Return $GUI_RUNDEFMSG

    ;------------------------------------------------------
    ; update the image move
    ;------------------------------------------------------
    Local $aPos = ControlGetPos($hWndGUI, "", $g_hListView)
    Local $x = BitAND($lParam, 0xFFFF) - $aPos[0]
    Local $y = BitShift($lParam, 16) - $aPos[1]
    If $y > $g_iLV_Height - 20 Then
        _GUICtrlListView_Scroll($g_hListView, 0, $y)
    ElseIf $y < 20 Then
        _GUICtrlListView_Scroll($g_hListView, 0, $y * -1)
    EndIf
    _GUIImageList_DragMove($x, $y)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEMOVE

; WM_LBUTTONUP event handler
; ------------------------------------------------------
Func WM_LBUTTONUP($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $iMsgID, $wParam
    $g_bDragging = False
    Local $aPos = ControlGetPos($hWndGUI, "", $g_hListView)
    Local $x = BitAND($lParam, 0xFFFF) - $aPos[0]
    Local $y = BitShift($lParam, 16) - $aPos[1]
    _DebugPrint("$x = " & $x)
    _DebugPrint("$y = " & $y)
    ;------------------------------------------------------
    ; done dragging
    ;------------------------------------------------------
    _GUIImageList_DragLeave($g_hListView)
    _GUIImageList_EndDrag()
    _GUIImageList_Destroy($g_ahDragImageList[0])
    _WinAPI_ReleaseCapture()
    ;------------------------------------------------------
    ; do hit test see if drag ended in the listview
    ;------------------------------------------------------
    Local $tStruct_LVHITTESTINFO = DllStructCreate($tagLVHITTESTINFO)

    DllStructSetData($tStruct_LVHITTESTINFO, "X", $x)
    DllStructSetData($tStruct_LVHITTESTINFO, "Y", $y)
    $g_aIndex[1] = _SendMessage($g_hListView, $LVM_HITTEST, 0, DllStructGetPtr($tStruct_LVHITTESTINFO), 0, "wparam", "ptr")
    Local $iFlags = DllStructGetData($tStruct_LVHITTESTINFO, "Flags")
    _DebugPrint("$iFlags: " & $iFlags)
    ;------------------------------------------------------
    ; // Out of the ListView?
    ;------------------------------------------------------
    If $g_aIndex[1] == -1 Then Return $GUI_RUNDEFMSG
    ;------------------------------------------------------
    ; // Not in an item?
    ;------------------------------------------------------
    If BitAND($iFlags, $LVHT_ONITEMLABEL) == 0 And BitAND($iFlags, $LVHT_ONITEMSTATEICON) == 0 And BitAND($iFlags, $LVHT_ONITEMICON) = 0 Then Return $GUI_RUNDEFMSG
    ;------------------------------------------------------
    ; make sure insert is at least 2 items above or below, don't want to create a duplicate
    ;------------------------------------------------------
    If $g_aIndex[0] < $g_aIndex[1] - 1 Or $g_aIndex[0] > $g_aIndex[1] + 1 Then
        _DebugPrint("To = " & $g_aIndex[1])
        Local $i_NewIndex = _LVInsertItem($g_aIndex[0], $g_aIndex[1])
        If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)
        Local $iFrom_index = $g_aIndex[0]
        If $g_aIndex[0] > $g_aIndex[1] Then $iFrom_index = $g_aIndex[0] + 1
        ;------------------------------------------------------
        ; copy item and subitem(s) images, text, and state
        ;------------------------------------------------------
        For $x = 1 To _GUICtrlListView_GetColumnCount($g_hListView) - 1
            _LVCopyItem($iFrom_index, $i_NewIndex, $x)
            If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)
        Next
        ;------------------------------------------------------
        ; delete from
        ;------------------------------------------------------
        _GUICtrlListView_DeleteItem($g_hListView, $iFrom_index)
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_LBUTTONUP

; WM_NOTIFY event handler
; ------------------------------------------------------
Func WM_NOTIFY($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $hWndGUI, $iMsgID, $wParam
    Local $tNMHDR, $iCode, $x, $y, $tNMLISTVIEW, $hWndFrom, $tDraw, $iDrawStage, $iItemSpec
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam) ;NMHDR (hwndFrom, idFrom, code)
    If @error Then Return
    $iCode = DllStructGetData($tNMHDR, "Code")
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    Switch $hWndFrom
        Case $g_hListView
            Switch $iCode
                Case $LVN_BEGINDRAG
                    _DebugPrint("$LVN_BEGINDRAG")
                    $x = BitAND($lParam, 0xFFFF)
                    $y = BitShift($lParam, 16)
                    $tNMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam)
                    $g_aIndex[0] = DllStructGetData($tNMLISTVIEW, "Item")
                    $g_ahDragImageList = _GUICtrlListView_CreateDragImage($g_hListView, $g_aIndex[0])
                    If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)

                    _GUIImageList_BeginDrag($g_ahDragImageList[0], 0, 0, 0)

                    If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)
                    _DebugPrint("From = " & $g_aIndex[0])
                    _GUIImageList_DragEnter($g_hListView, $x, $y)
                    _WinAPI_SetCapture($hWndGUI)
                    $g_bDragging = True
                Case $NM_CUSTOMDRAW
                    _DebugPrint("$NM_CUSTOMDRAW")
                    $tDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
                    $iDrawStage = DllStructGetData($tDraw, "dwDrawStage")
                    $iItemSpec = DllStructGetData($tDraw, "dwItemSpec")
                    Switch $iDrawStage
                        Case $CDDS_PREPAINT
                            _DebugPrint("$CDDS_PREPAINT")
                            Return $CDRF_NOTIFYITEMDRAW
                        Case $CDDS_ITEMPREPAINT
                            _DebugPrint("$CDDS_ITEMPREPAINT")
                            If BitAND($iItemSpec, 1) = 1 Then
                                DllStructSetData($tDraw, "clrTextBk", $CLR_AQUA)
                            Else
                                DllStructSetData($tDraw, "clrTextBk", $CLR_WHITE)
                            EndIf
                            Return $CDRF_NEWFONT
                    EndSwitch
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
#EndRegion Event Function(s) **********************************************************************************************

Func _DebugPrint($s_Text)
    If Not $g_iDebugIt Then Return
    $s_Text = StringReplace($s_Text, @CRLF, @CRLF & "-->")
    ConsoleWrite("!===========================================================" & @CRLF & _
            "+===========================================================" & @CRLF & _
            "-->" & $s_Text & @CRLF & _
            "+===========================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUIImageList_Draw

Function Reference

_GUIImageList_Draw

Draws an image list item in the specified device context

#include <GuiImageList.au3>
_GUIImageList_Draw ( $hWnd, $iIndex, $hDC, $iX, $iY [, $iStyle = 0] )

Parameters

$hWnd | Handle to the imagelist
$iIndex | 0-based index of the image to draw
$hDC | Handle to the destination device context
$iX | X coordinate where the image will be drawn
$iY | Y coordinate where the image will be drawn
$iStyle | [optional] Drawing style and overlay image: 1 - Draws the image transparently using the mask, regardless of the background color 2 - Draws the image, blending 25 percent with the system highlight color 4 - Draws the image, blending 50 percent with the system highlight color 8 - Draws the mask

Return Value

Success: | True.
Failure: | False.

Related

_GUIImageList_DrawEx

Example

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

Example()

Func Example()
    Local $hImage, $hGUI, $hDC

    $hGUI = GUICreate("ImageList Draw", 400, 300)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 32, 24))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 32, 24))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 32, 24))

    ; Draw images
    $hDC = _WinAPI_GetDC($hGUI)
    _GUIImageList_Draw($hImage, 0, $hDC, 4, 4)
    _GUIImageList_Draw($hImage, 1, $hDC, 40, 4)
    _GUIImageList_Draw($hImage, 2, $hDC, 76, 4)

    _WinAPI_ReleaseDC($hGUI, $hDC)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUIImageList_DrawEx

Function Reference

_GUIImageList_DrawEx

Draws an image list item in the specified device context

#include <GuiImageList.au3>
_GUIImageList_DrawEx ( $hWnd, $iIndex, $hDC, $iX, $iY [, $iDX = 0 [, $iDY = 0 [, $iRGBBk = 0xFFFFFFFF [, $iRGBFg = 0xFFFFFFFF [, $iStyle = 0]]]]] )

Parameters

$hWnd | Handle to the imagelist
$iIndex | 0-based index of the image to draw
$hDC | Handle to the destination device context
$iX | X coordinate where the image will be drawn
$iY | Y coordinate where the image will be drawn
$iDX | [optional] The width of the portion of the image to draw relative to the upper-left corner of the image. If $iDX and $iDY are zero, the function draws the entire image. The function does not ensure that the parameters are valid.
$iDY | [optional] The height of the portion of the image to draw, relative to the upper-left corner of the image. If $iDX and $iDY are zero, the function draws the entire image. The function does not ensure that the parameters are valid.
$iRGBBk | [optional] The background color of the image. This parameter can be an application-defined RGB value or one of the following values: $CLR_NONE - No background color. The image is drawn transparently. $CLR_DEFAULT - The default background color. The image is drawn using the background color of the image list.
$iRGBFg | [optional] The foreground color of the image. This parameter can be an application-defined RGB value or one of the following values: $CLR_NONE - No blend color. The image is blended with the color of the destination device context. $CLR_DEFAULT - The default foreground color. The image is drawn using the system highlight color as the foreground color.
$iStyle | [optional] Drawing style and overlay image: 1 - Draws the image transparently using the mask, regardless of the background color 2 - Draws the image, blending 25 percent with the system highlight color 4 - Draws the image, blending 50 percent with the system highlight color 8 - Draws the mask

Return Value

Success: | True.
Failure: | False.

Related

_GUIImageList_Draw

Example

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

Example()

Func Example()
    Local $hImage, $hGUI, $hDC

    $hGUI = GUICreate("ImageList DrawEx", 400, 300)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 32, 24))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 32, 24))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 32, 24))

    ; Draw images
    $hDC = _WinAPI_GetDC($hGUI)
    _GUIImageList_DrawEx($hImage, 0, $hDC, 4, 4)
    _GUIImageList_DrawEx($hImage, 1, $hDC, 40, 4)
    _GUIImageList_DrawEx($hImage, 2, $hDC, 76, 4)

    _WinAPI_ReleaseDC($hGUI, $hDC)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUIImageList_Duplicate

Function Reference

_GUIImageList_Duplicate

Creates a duplicate of an existing image list

#include <GuiImageList.au3>
_GUIImageList_Duplicate ( $hWnd )

Parameters

$hWnd Handle to the imagelist

Return Value

Success: | the handle to the new duplicate image list.
Failure: | 0.

Remarks

All information contained in the original image list for normal images is copied to the new image list.
Overlay images are not copied.

Example

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

Example()

Func Example()
    Local $idListview, $hImage
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sAutoItDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir")
    Local $hImage2

    GUICreate("ImageList Duplicate", 410, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 404, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    GUISetState(@SW_SHOW)

    ; Create an image list with images
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_AddIcon($hImage, $sAutoItDir & "\Icons\filetype1.ico")
    _GUIImageList_AddIcon($hImage, $sAutoItDir & "\Icons\filetype2.ico")
    _GUIImageList_AddIcon($hImage, $sAutoItDir & "\Icons\filetype3.ico")
    $hImage2 = _GUIImageList_Duplicate($hImage)
    _GUICtrlListView_SetImageList($idListview, $hImage2, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100, "Left", 0)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100, "Left", 1)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100, "Left", 2)
    _GUICtrlListView_AddColumn($idListview, "Column 4", 100)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUIImageList_EndDrag

Function Reference

_GUIImageList_EndDrag

Ends a drag operation

#include <GuiImageList.au3>
_GUIImageList_EndDrag ( )

Return Value

None.

Related

_GUIImageList_BeginDrag, _GUIImageList_DragLeave

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

#Region Globals *************************************************************************
Global $g_ahDragImageList, $g_hListView, $g_bDragging = False, $g_iLV_Height
Global $g_aIndex[2] ; from and to

Global Const $g_iDebugIt = 1

#EndRegion Globals *************************************************************************

Opt("WinTitleMatchMode", 2)

Example()

Func Example()
    Local Const $iImage_width = 20
    Local Const $iImage_height = 20
    Local $hImages, $hMain_GUI, $iIndex

    $hMain_GUI = GUICreate("GuiImageList Begin Drag", 225, 400)

    $g_hListView = _GUICtrlListView_Create($hMain_GUI, "Entry Name|Category", 5, 75, 220, 280, -1, BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE))
    $g_iLV_Height = 280 - 75
    _GUICtrlListView_SetColumnWidth($g_hListView, 0, 100)
    _GUICtrlListView_SetColumnWidth($g_hListView, 1, 100)
    _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
    ;------------------------------------------------------
    ; Using subitem images
    ;------------------------------------------------------
    _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_SUBITEMIMAGES))

    ;------------------------------------------------------
    ; create the image list
    ;------------------------------------------------------
    $hImages = _GUIImageList_Create($iImage_width, $iImage_height, 5, 1)
    For $x = 1 To 21
        _GUIImageList_AddIcon($hImages, @SystemDir & "\shell32.dll", $x)
    Next

    _GUICtrlListView_SetImageList($g_hListView, $hImages, $LVSIL_SMALL)

    ;------------------------------------------------------
    ;Register event functions
    ;------------------------------------------------------
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    GUIRegisterMsg($WM_LBUTTONUP, "WM_LBUTTONUP")
    GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE")

    ;------------------------------------------------------
    ; add listview items with images
    ;------------------------------------------------------
    Local $y = 1
    For $x = 0 To 9
        $iIndex = _GUICtrlListView_AddItem($g_hListView, "Name " & $x + 1, $y) ; handle, string, image index
        _GUICtrlListView_AddSubItem($g_hListView, $iIndex, "Category " & $x + 1, 1, $y + 1) ; handle, index, string, subitem, image index
        $y += 2
    Next

    GUISetState(@SW_SHOW)

    While 1

        Switch GUIGetMsg()

            ;-----------------------------------------------------------------------------------------
            ;This case statement exits and updates code if needed
            Case $GUI_EVENT_CLOSE
                ExitLoop
                ;-----------------------------------------------------------------------------------------
                ;put all the misc. stuff here
            Case Else
                ;;;
        EndSwitch
    WEnd

    _GUIImageList_Destroy($hImages)
    GUIDelete()
EndFunc   ;==>Example

#Region Item Function(s) **********************************************************************************************
Func _LVInsertItem($i_FromItem, $i_ToItem)
    Local $iItem_state, $i_NewIndex
    Local $tStruct_LVITEM = DllStructCreate($tagLVITEM)
    Local $tStruct_String = DllStructCreate("wchar Buffer[4096]")

    ; Insert item into new position
    DllStructSetData($tStruct_LVITEM, "Mask", BitOR($LVIF_STATE, $LVIF_IMAGE, $LVIF_INDENT, $LVIF_PARAM, $LVIF_TEXT))
    DllStructSetData($tStruct_LVITEM, "StateMask", $LVIS_STATEIMAGEMASK)
    DllStructSetData($tStruct_LVITEM, "Item", $i_FromItem)
    DllStructSetData($tStruct_LVITEM, "SubItem", 0)
    DllStructSetData($tStruct_LVITEM, "TextMax", 4096)
    DllStructSetData($tStruct_LVITEM, "Text", DllStructGetPtr($tStruct_String))
    _GUICtrlListView_GetItemEx($g_hListView, $tStruct_LVITEM)
    If @error Then Return SetError(-1, -1, -1)
    $iItem_state = DllStructGetData($tStruct_LVITEM, "State")
    DllStructSetData($tStruct_LVITEM, "Item", $i_ToItem)
    $i_NewIndex = _GUICtrlListView_InsertItem($g_hListView, DllStructGetData($tStruct_String, "Buffer"), $i_ToItem, DllStructGetData($tStruct_LVITEM, "Image"))
    If @error Then Return SetError(-1, -1, -1)

    ; restore previous state
    _DebugPrint("$i_NewIndex = " & $i_NewIndex)
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_STATE)
    DllStructSetData($tStruct_LVITEM, "Item", $i_NewIndex)
    DllStructSetData($tStruct_LVITEM, "State", $iItem_state)
    DllStructSetData($tStruct_LVITEM, "StateMask", $LVIS_STATEIMAGEMASK)
    _GUICtrlListView_SetItemState($g_hListView, $i_NewIndex, $iItem_state, $LVIS_STATEIMAGEMASK)
    If @error Then Return SetError(-1, -1, -1)
    Return $i_NewIndex
EndFunc   ;==>_LVInsertItem

; ------------------------------------------------------
Func _LVCopyItem($i_FromItem, $i_ToItem, $i_SubItem = 0)
    Local $tStruct_LVITEM = DllStructCreate($tagLVITEM)
    Local $tStruct_String = DllStructCreate("wchar Buffer[4096]")

    ; get from item info
    DllStructSetData($tStruct_LVITEM, "Mask", BitOR($LVIF_STATE, $LVIF_IMAGE, $LVIF_INDENT, $LVIF_PARAM, $LVIF_TEXT))
    DllStructSetData($tStruct_LVITEM, "StateMask", $LVIS_STATEIMAGEMASK)
    DllStructSetData($tStruct_LVITEM, "Item", $i_FromItem)
    DllStructSetData($tStruct_LVITEM, "SubItem", $i_SubItem)
    DllStructSetData($tStruct_LVITEM, "TextMax", 4096)
    DllStructSetData($tStruct_LVITEM, "Text", DllStructGetPtr($tStruct_String))
    _GUICtrlListView_GetItemEx($g_hListView, $tStruct_LVITEM)

    ; set to
    DllStructSetData($tStruct_LVITEM, "Item", $i_ToItem)
    ; set text
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_TEXT)
    DllStructSetData($tStruct_LVITEM, "Text", DllStructGetPtr($tStruct_String))
    DllStructSetData($tStruct_LVITEM, "TextMax", 4096)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    If @error Then Return SetError(@error, @error, @error)
    ; set status
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_STATE)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set image
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_IMAGE)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_IMAGE)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set state
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_STATE)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_STATE)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set indent
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_INDENT)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_INDENT)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
    ; set Param
    DllStructSetData($tStruct_LVITEM, "Mask", $LVIF_PARAM)
    DllStructSetData($tStruct_LVITEM, "State", $LVIF_PARAM)
    _GUICtrlListView_SetItemEx($g_hListView, $tStruct_LVITEM)
EndFunc   ;==>_LVCopyItem
#EndRegion Item Function(s) **********************************************************************************************

#Region Event Function(s) **********************************************************************************************

; WM_MOUSEMOVE event handler
; ------------------------------------------------------
Func WM_MOUSEMOVE($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $iMsgID, $wParam
    ;------------------------------------------------------
    ; not dragging item we are done here
    ;------------------------------------------------------
    If $g_bDragging = False Then Return $GUI_RUNDEFMSG

    ;------------------------------------------------------
    ; update the image move
    ;------------------------------------------------------
    Local $aPos = ControlGetPos($hWndGUI, "", $g_hListView)
    Local $x = BitAND($lParam, 0xFFFF) - $aPos[0]
    Local $y = BitShift($lParam, 16) - $aPos[1]
    If $y > $g_iLV_Height - 20 Then
        _GUICtrlListView_Scroll($g_hListView, 0, $y)
    ElseIf $y < 20 Then
        _GUICtrlListView_Scroll($g_hListView, 0, $y * -1)
    EndIf
    _GUIImageList_DragMove($x, $y)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_MOUSEMOVE

; WM_LBUTTONUP event handler
; ------------------------------------------------------
Func WM_LBUTTONUP($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $iMsgID, $wParam
    $g_bDragging = False
    Local $aPos = ControlGetPos($hWndGUI, "", $g_hListView)
    Local $x = BitAND($lParam, 0xFFFF) - $aPos[0]
    Local $y = BitShift($lParam, 16) - $aPos[1]
    _DebugPrint("$x = " & $x)
    _DebugPrint("$y = " & $y)
    ;------------------------------------------------------
    ; done dragging
    ;------------------------------------------------------
    _GUIImageList_DragLeave($g_hListView)
    _GUIImageList_EndDrag()
    _GUIImageList_Destroy($g_ahDragImageList[0])
    _WinAPI_ReleaseCapture()
    ;------------------------------------------------------
    ; do hit test see if drag ended in the listview
    ;------------------------------------------------------
    Local $tStruct_LVHITTESTINFO = DllStructCreate($tagLVHITTESTINFO)

    DllStructSetData($tStruct_LVHITTESTINFO, "X", $x)
    DllStructSetData($tStruct_LVHITTESTINFO, "Y", $y)
    $g_aIndex[1] = _SendMessage($g_hListView, $LVM_HITTEST, 0, DllStructGetPtr($tStruct_LVHITTESTINFO), 0, "wparam", "ptr")
    Local $iFlags = DllStructGetData($tStruct_LVHITTESTINFO, "Flags")
    _DebugPrint("$iFlags: " & $iFlags)
    ;------------------------------------------------------
    ; // Out of the ListView?
    ;------------------------------------------------------
    If $g_aIndex[1] == -1 Then Return $GUI_RUNDEFMSG
    ;------------------------------------------------------
    ; // Not in an item?
    ;------------------------------------------------------
    If BitAND($iFlags, $LVHT_ONITEMLABEL) == 0 And BitAND($iFlags, $LVHT_ONITEMSTATEICON) == 0 And BitAND($iFlags, $LVHT_ONITEMICON) = 0 Then Return $GUI_RUNDEFMSG
    ;------------------------------------------------------
    ; make sure insert is at least 2 items above or below, don't want to create a duplicate
    ;------------------------------------------------------
    If $g_aIndex[0] < $g_aIndex[1] - 1 Or $g_aIndex[0] > $g_aIndex[1] + 1 Then
        _DebugPrint("To = " & $g_aIndex[1])
        Local $i_NewIndex = _LVInsertItem($g_aIndex[0], $g_aIndex[1])
        If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)
        Local $iFrom_index = $g_aIndex[0]
        If $g_aIndex[0] > $g_aIndex[1] Then $iFrom_index = $g_aIndex[0] + 1
        ;------------------------------------------------------
        ; copy item and subitem(s) images, text, and state
        ;------------------------------------------------------
        For $x = 1 To _GUICtrlListView_GetColumnCount($g_hListView) - 1
            _LVCopyItem($iFrom_index, $i_NewIndex, $x)
            If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)
        Next
        ;------------------------------------------------------
        ; delete from
        ;------------------------------------------------------
        _GUICtrlListView_DeleteItem($g_hListView, $iFrom_index)
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_LBUTTONUP

; WM_NOTIFY event handler
; ------------------------------------------------------
Func WM_NOTIFY($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $hWndGUI, $iMsgID, $wParam
    Local $tNMHDR, $iCode, $x, $y, $tNMLISTVIEW, $hWndFrom, $tDraw, $iDrawStage, $iItemSpec
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam) ;NMHDR (hwndFrom, idFrom, code)
    If @error Then Return
    $iCode = DllStructGetData($tNMHDR, "Code")
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    Switch $hWndFrom
        Case $g_hListView
            Switch $iCode
                Case $LVN_BEGINDRAG
                    _DebugPrint("$LVN_BEGINDRAG")
                    $x = BitAND($lParam, 0xFFFF)
                    $y = BitShift($lParam, 16)
                    $tNMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam)
                    $g_aIndex[0] = DllStructGetData($tNMLISTVIEW, "Item")
                    $g_ahDragImageList = _GUICtrlListView_CreateDragImage($g_hListView, $g_aIndex[0])
                    If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)

                    _GUIImageList_BeginDrag($g_ahDragImageList[0], 0, 0, 0)

                    If @error Then Return SetError(-1, -1, $GUI_RUNDEFMSG)
                    _DebugPrint("From = " & $g_aIndex[0])
                    _GUIImageList_DragEnter($g_hListView, $x, $y)
                    _WinAPI_SetCapture($hWndGUI)
                    $g_bDragging = True
                Case $NM_CUSTOMDRAW
                    _DebugPrint("$NM_CUSTOMDRAW")
                    $tDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
                    $iDrawStage = DllStructGetData($tDraw, "dwDrawStage")
                    $iItemSpec = DllStructGetData($tDraw, "dwItemSpec")
                    Switch $iDrawStage
                        Case $CDDS_PREPAINT
                            _DebugPrint("$CDDS_PREPAINT")
                            Return $CDRF_NOTIFYITEMDRAW
                        Case $CDDS_ITEMPREPAINT
                            _DebugPrint("$CDDS_ITEMPREPAINT")
                            If BitAND($iItemSpec, 1) = 1 Then
                                DllStructSetData($tDraw, "clrTextBk", $CLR_AQUA)
                            Else
                                DllStructSetData($tDraw, "clrTextBk", $CLR_WHITE)
                            EndIf
                            Return $CDRF_NEWFONT
                    EndSwitch
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
#EndRegion Event Function(s) **********************************************************************************************

Func _DebugPrint($s_Text)
    If Not $g_iDebugIt Then Return
    $s_Text = StringReplace($s_Text, @CRLF, @CRLF & "-->")
    ConsoleWrite("!===========================================================" & @CRLF & _
            "+===========================================================" & @CRLF & _
            "-->" & $s_Text & @CRLF & _
            "+===========================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUIImageList_GetBkColor

Function Reference

_GUIImageList_GetBkColor

Retrieves the current background color for an image list

#include <GuiImageList.au3>
_GUIImageList_GetBkColor ( $hWnd )

Parameters

$hWnd Handle to the imagelist

Return Value

Returns the background color.

Related

_GUIImageList_SetBkColor

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idListview, $hImage
    Local $iStylesEx = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    GUICreate("ImageList GetBkColor", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iStylesEx)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    MsgBox($MB_SYSTEMMODAL, "Information", "BackColor: " & _GUIImageList_GetBkColor($hImage))
    _GUIImageList_SetBkColor($hImage, 0x0000FF)
    MsgBox($MB_SYSTEMMODAL, "Information", "BackColor: " & _GUIImageList_GetBkColor($hImage))

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 120)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)
    _GUICtrlListView_AddItem($idListview, "Row 4: Col 1", 3)
    _GUICtrlListView_AddItem($idListview, "Row 5: Col 1", 4)
    _GUICtrlListView_AddSubItem($idListview, 4, "Row 5: Col 2", 1, 3)
    _GUICtrlListView_AddItem($idListview, "Row 6: Col 1", 5)
    _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 2", 1, 4)
    _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 3", 2, 3)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUIImageList_GetIcon

Function Reference

_GUIImageList_GetIcon

Creates an icon from an image and mask in an image list

#include <GuiImageList.au3>
_GUIImageList_GetIcon ( $hWnd, $iIndex [, $iStyle = 0] )

Parameters

$hWnd | Handle to the imagelist
$iIndex | 0-based index of the image
$iStyle | [optional] Drawing style and overlay image: 1 - Draws the image transparently using the mask, regardless of the background color 2 - Draws the image, blending 25 percent with the system highlight color 4 - Draws the image, blending 50 percent with the system highlight color 8 - Draws the mask

Return Value

Success: | the handle to the icon if successful.
Failure: | 0.

Remarks

It is the responsibility of the calling application to destroy the icon returned from this function using _GUIImageList_DestroyIcon().

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiStatusBar.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global $g_hStatus, $g_idMemo

Example()

Func Example()
    Local $hGUI, $ahIcons[2], $hImage
    Local $aParts[4] = [75, 150, 300, 400]

    ; Create GUI
    $hGUI = GUICreate("ImageList Get Icon", 400, 300)
    $g_hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Set parts
    _GUICtrlStatusBar_SetParts($g_hStatus, $aParts)
    _GUICtrlStatusBar_SetText($g_hStatus, "Part 1")
    _GUICtrlStatusBar_SetText($g_hStatus, "Part 2", 1)

    ; Load images
    $hImage = _GUIImageList_Create(11, 11)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($g_hStatus, 0xFF0000, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($g_hStatus, 0x00FF00, 11, 11))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($g_hStatus, 0x0000FF, 11, 11))

    ; Set icons
    $ahIcons[0] = _GUIImageList_GetIcon($hImage, 1)
    $ahIcons[1] = _GUIImageList_GetIcon($hImage, 2)
    _GUICtrlStatusBar_SetIcon($g_hStatus, 0, $ahIcons[0])
    _GUICtrlStatusBar_SetIcon($g_hStatus, 1, $ahIcons[1])

    ; Show icon handles
    MemoWrite("Part 1 icon handle .: 0x" & Hex($ahIcons[0]))
    MemoWrite("Part 2 icon handle .: 0x" & Hex($ahIcons[1]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    ; Free icons
    MsgBox($MB_SYSTEMMODAL, "Information", "Icon 1 Destroyed? " & _GUIImageList_DestroyIcon($ahIcons[0]))
    MsgBox($MB_SYSTEMMODAL, "Information", "Icon 2 Destroyed? " & _GUIImageList_DestroyIcon($ahIcons[1]))
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Local $tInfo
    Switch $hWndFrom
        Case $g_hStatus
            Switch $iCode
                Case $NM_CLICK ; The user has clicked the left mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_RCLICK ; The user has clicked the right mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_RDBLCLK ; The user has double-clicked the right mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $SBN_SIMPLEMODECHANGE ; Simple mode changes
                    _DebugPrint("$SBN_SIMPLEMODECHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUIImageList_GetIconHeight

Function Reference

_GUIImageList_GetIconHeight

Retrieves the height of the images in an image list

#include <GuiImageList.au3>
_GUIImageList_GetIconHeight ( $hWnd )

Parameters

$hWnd Handle to the imagelist

Return Value

Success: | the height, in pixels, of each image.
Failure: | 0.

Related

_GUIImageList_GetIconSize, _GUIImageList_GetIconSizeEx, _GUIImageList_GetIconWidth

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hImage, $hGUI, $hDC

    $hGUI = GUICreate("ImageList Get Icon Height", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 32, 24))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 32, 24))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 32, 24))

    ; Draw images
    $hDC = _WinAPI_GetDC($hGUI)
    _GUIImageList_Draw($hImage, 0, $hDC, 4, 4)
    _GUIImageList_Draw($hImage, 1, $hDC, 40, 4)
    _GUIImageList_Draw($hImage, 2, $hDC, 76, 4)

    _WinAPI_ReleaseDC($hGUI, $hDC)

    ; Show image list icon size
    MemoWrite("Image width : " & _GUIImageList_GetIconWidth($hImage))
    MemoWrite("Image height: " & _GUIImageList_GetIconHeight($hImage))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIImageList_GetIconSize

Function Reference

_GUIImageList_GetIconSize

Retrieves the dimensions of images in an image list

#include <GuiImageList.au3>
_GUIImageList_GetIconSize ( $hWnd )

Parameters

$hWnd Handle to the imagelist

Return Value

Returns an array with the following format:
[0] - Width, in pixels, of each image
[1] - Height, in pixels, of each image

Related

_GUIImageList_GetIconHeight, _GUIImageList_GetIconSizeEx, _GUIImageList_GetIconWidth, _GUIImageList_SetIconSize

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hImage, $aSize, $idListview

    GUICreate("ImageList Get Icon Size", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 199, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    $g_idMemo = GUICtrlCreateEdit("", 2, 200, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(32, 32, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 120)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)

    ; Show image list icon size
    $aSize = _GUIImageList_GetIconSize($hImage)
    MemoWrite("Image width : " & $aSize[0])
    MemoWrite("Image height: " & $aSize[1])

    MsgBox($MB_SYSTEMMODAL, "Information", "Changing Icon Size")

    _GUIImageList_SetIconSize($hImage, 16, 16)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    $aSize = _GUIImageList_GetIconSize($hImage)
    MemoWrite("Image width : " & $aSize[0])
    MemoWrite("Image height: " & $aSize[1])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIImageList_GetIconSizeEx

Function Reference

_GUIImageList_GetIconSizeEx

Retrieves the dimensions of images in an image list

#include <GuiImageList.au3>
_GUIImageList_GetIconSizeEx ( $hWnd )

Parameters

$hWnd Handle to the imagelist

Return Value

Returns a $tagPOINT structure.

Related

_GUIImageList_GetIconHeight, _GUIImageList_GetIconSize, _GUIImageList_GetIconWidth

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hImage, $hGUI, $hDC, $tSize

    $hGUI = GUICreate("ImageList Get Icon SizeEx", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 32, 24))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 32, 24))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 32, 24))

    ; Draw images
    $hDC = _WinAPI_GetDC($hGUI)
    _GUIImageList_Draw($hImage, 0, $hDC, 4, 4)
    _GUIImageList_Draw($hImage, 1, $hDC, 40, 4)
    _GUIImageList_Draw($hImage, 2, $hDC, 76, 4)

    _WinAPI_ReleaseDC($hGUI, $hDC)

    ; Show image list icon size
    $tSize = _GUIImageList_GetIconSizeEx($hImage)
    MemoWrite("Image width : " & DllStructGetData($tSize, "X"))
    MemoWrite("Image height: " & DllStructGetData($tSize, "Y"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIImageList_GetIconWidth

Function Reference

_GUIImageList_GetIconWidth

Retrieves the width of the images in an image list

#include <GuiImageList.au3>
_GUIImageList_GetIconWidth ( $hWnd )

Parameters

$hWnd Handle to the imagelist

Return Value

Success: | the width, in pixels, of each image.
Failure: | 0.

Related

_GUIImageList_GetIconHeight, _GUIImageList_GetIconSize, _GUIImageList_GetIconSizeEx

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hImage, $hGUI, $hDC

    $hGUI = GUICreate("ImageList Get Icon Width", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 32, 24))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 32, 24))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 32, 24))

    ; Draw images
    $hDC = _WinAPI_GetDC($hGUI)
    _GUIImageList_Draw($hImage, 0, $hDC, 4, 4)
    _GUIImageList_Draw($hImage, 1, $hDC, 40, 4)
    _GUIImageList_Draw($hImage, 2, $hDC, 76, 4)

    _WinAPI_ReleaseDC($hGUI, $hDC)

    ; Show image list icon size
    MemoWrite("Image width : " & _GUIImageList_GetIconWidth($hImage))
    MemoWrite("Image height: " & _GUIImageList_GetIconHeight($hImage))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIImageList_GetImageCount

Function Reference

_GUIImageList_GetImageCount

Retrieves the number of images in an image list

#include <GuiImageList.au3>
_GUIImageList_GetImageCount ( $hWnd )

Parameters

$hWnd Handle to the imagelist

Return Value

Returns the number of images.

Related

_GUIImageList_SetImageCount

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idListview, $hImage, $iRandom
    Local $iStylesEx = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    GUICreate("ImageList Get Image Count", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iStylesEx)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    $iRandom = Random(6, 20, 1)
    For $x = 1 To $iRandom
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", $x)
    Next
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 120)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)
    _GUICtrlListView_AddItem($idListview, "Row 4: Col 1", 3)
    _GUICtrlListView_AddItem($idListview, "Row 5: Col 1", 4)
    _GUICtrlListView_AddSubItem($idListview, 4, "Row 5: Col 2", 1, 3)
    _GUICtrlListView_AddItem($idListview, "Row 6: Col 1", 5)
    _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 2", 1, 4)
    _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 3", 2, 3)

    MsgBox($MB_SYSTEMMODAL, "Information", "Image Count: " & _GUIImageList_GetImageCount($hImage))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUIImageList_GetImageInfoEx

Function Reference

_GUIImageList_GetImageInfoEx

Retrieves information about an image

#include <GuiImageList.au3>
_GUIImageList_GetImageInfoEx ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the imagelist
$iIndex | Index of the image

Return Value

Returns a $tagIMAGEINFO structure that receives information about the image.

Related

$tagIMAGEINFO

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hImage, $hGUI, $hDC, $tInfo

    $hGUI = GUICreate("ImageList Get Icon InfoEx", 400, 300)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 32, 24))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 32, 24))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 32, 24))

    ; Draw images
    $hDC = _WinAPI_GetDC($hGUI)
    _GUIImageList_Draw($hImage, 0, $hDC, 4, 4)
    _GUIImageList_Draw($hImage, 1, $hDC, 40, 4)
    _GUIImageList_Draw($hImage, 2, $hDC, 76, 4)

    _WinAPI_ReleaseDC($hGUI, $hDC)

    ; Show information for second image
    $tInfo = _GUIImageList_GetImageInfoEx($hImage, 1)
    MemoWrite("Image handle .: 0x" & Hex(DllStructGetData($tInfo, "hBitmap")))
    MemoWrite("Mask handle ..: " & DllStructGetData($tInfo, "hMask"))
    MemoWrite("Image Left ...: " & DllStructGetData($tInfo, "Left"))
    MemoWrite("Image Top ....: " & DllStructGetData($tInfo, "Top"))
    MemoWrite("Image Right ..: " & DllStructGetData($tInfo, "Right"))
    MemoWrite("Image Bottom .: " & DllStructGetData($tInfo, "Bottom"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIImageList_Remove

Function Reference

_GUIImageList_Remove

Remove Image(s) from the ImageList

#include <GuiImageList.au3>
_GUIImageList_Remove ( $hWnd [, $iIndex = -1] )

Parameters

$hWnd | Handle to the imagelist
$iIndex | [optional] The index of the image to remove. If this parameter is -1, the function removes all images

Return Value

Success: | True.
Failure: | False.

Remarks

When an image is removed, the indexes of the remaining images are adjusted so that the image indexes always range from zero to one less than the number of images in the image list.
For example, if you remove the image at index 0, then image 1 becomes image 0, image 2 becomes image 1, and so on.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idListview, $hImage
    Local $iStylesEx = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    GUICreate("ImageList Remove", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iStylesEx)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 120)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)
    _GUICtrlListView_AddItem($idListview, "Row 4: Col 1", 3)
    _GUICtrlListView_AddItem($idListview, "Row 5: Col 1", 4)
    _GUICtrlListView_AddSubItem($idListview, 4, "Row 5: Col 2", 1, 3)
    _GUICtrlListView_AddItem($idListview, "Row 6: Col 1", 5)
    _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 2", 1, 4)
    _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 3", 2, 3)

    MsgBox($MB_SYSTEMMODAL, "Information", "Removing Image Index 0")
    _GUIImageList_Remove($hImage, 0)

    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($idListview))

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)
    _GUICtrlListView_AddItem($idListview, "Row 4: Col 1", 3)
    _GUICtrlListView_AddItem($idListview, "Row 5: Col 1", 4)
    _GUICtrlListView_AddSubItem($idListview, 4, "Row 5: Col 2", 1, 3)
    _GUICtrlListView_AddItem($idListview, "Row 6: Col 1", 5)
    _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 2", 1, 4)
    _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 3", 2, 3)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUIImageList_ReplaceIcon

Function Reference

_GUIImageList_ReplaceIcon

Replaces an image with an icon or cursor

#include <GuiImageList.au3>
_GUIImageList_ReplaceIcon ( $hWnd, $iIndex, $hIcon )

Parameters

$hWnd | Handle to the imagelist
$iIndex | Index of the image to replace. If -1, the function appends the image to the end of the list.
$hIcon | Handle to the icon or cursor that contains the bitmap and mask for the new image

Return Value

Success: | the index of the image.
Failure: | -1.

Remarks

Because the system does not save $hIcon you can destroy it after the function returns if the icon or cursor was created by the CreateIcon function.
You do not need to destroy $hIcon if it was loaded by the LoadIcon function the system automatically frees an icon resource when it is no longer needed.

Example

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

Example()

Func Example()
    Local $idListview, $hImage
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sAutoItDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir")

    GUICreate("ImageList AddIcon", 410, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 404, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    GUISetState(@SW_SHOW)

    ; Create an image list with images
    $hImage = _GUIImageList_Create(11, 11)
    AddIcon($hImage, $sAutoItDir & "\Icons\au3.ico")
    AddIcon($hImage, $sAutoItDir & "\Icons\au3script_v9.ico")
    AddIcon($hImage, $sAutoItDir & "\Icons\au3script_v10.ico")
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100, 0, 0)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100, 1, 1)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100, 2, 2)
    _GUICtrlListView_AddColumn($idListview, "Column 4", 100)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; This is the long way to add an icon. Use _GUIImageList_AddIcon instead
Func AddIcon($hWnd, $sFile, $iIndex = 0)
    Local $tIcon, $hIcon

    $tIcon = DllStructCreate("int Icon")
    _WinAPI_ExtractIconEx($sFile, $iIndex, 0, $tIcon, 1)
    $hIcon = DllStructGetData($tIcon, "Icon")
    _GUIImageList_ReplaceIcon($hWnd, -1, $hIcon)
    _WinAPI_DestroyIcon($hIcon)
EndFunc   ;==>AddIcon


Function _GUIImageList_SetBkColor

Function Reference

_GUIImageList_SetBkColor

Sets the background color for an image list

#include <GuiImageList.au3>
_GUIImageList_SetBkColor ( $hWnd, $iClrBk )

Parameters

$hWnd | Handle to the imagelist
$iClrBk | The background color to set. This parameter can be the $CLR_NONE value; in that case, images are drawn transparently using the mask.

Return Value

Success: | the previous background color if successful.
Failure: | $CLR_NONE.

Related

_GUIImageList_GetBkColor

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idListview, $hImage
    Local $iStylesEx = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    GUICreate("ImageList SetBkColor", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iStylesEx)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    MsgBox($MB_SYSTEMMODAL, "Information", "BackColor: " & _GUIImageList_GetBkColor($hImage))
    _GUIImageList_SetBkColor($hImage, 0x0000FF)
    MsgBox($MB_SYSTEMMODAL, "Information", "BackColor: " & _GUIImageList_GetBkColor($hImage))

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 120)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)
    _GUICtrlListView_AddItem($idListview, "Row 4: Col 1", 3)
    _GUICtrlListView_AddItem($idListview, "Row 5: Col 1", 4)
    _GUICtrlListView_AddSubItem($idListview, 4, "Row 5: Col 2", 1, 3)
    _GUICtrlListView_AddItem($idListview, "Row 6: Col 1", 5)
    _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 2", 1, 4)
    _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 3", 2, 3)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUIImageList_SetIconSize

Function Reference

_GUIImageList_SetIconSize

Sets the dimensions of images in an image list and removes all images from the list

#include <GuiImageList.au3>
_GUIImageList_SetIconSize ( $hWnd, $iCX, $iCY )

Parameters

$hWnd | Handle to the imagelist
$iCX | The width, in pixels, of the images in the image list
$iCY | The height, in pixels, of the images in the image list

Return Value

Success: | True.
Failure: | False.

Remarks

All images in an image list have the same dimensions.

Related

_GUIImageList_GetIconSize

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hImage, $aSize, $idListview

    GUICreate("ImageList Set Icon Size", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 199, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    $g_idMemo = GUICtrlCreateEdit("", 2, 200, 396, 266, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(32, 32, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110, True)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131, True)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165, True)
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 120)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)

    ; Show image list icon size
    $aSize = _GUIImageList_GetIconSize($hImage)
    MemoWrite("Image width : " & $aSize[0])
    MemoWrite("Image height: " & $aSize[1])

    MsgBox($MB_SYSTEMMODAL, "Information", "Changing Icon Size")

    _GUIImageList_SetIconSize($hImage, 16, 16)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    $aSize = _GUIImageList_GetIconSize($hImage)
    MemoWrite("Image width : " & $aSize[0])
    MemoWrite("Image height: " & $aSize[1])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIImageList_SetImageCount

Function Reference

_GUIImageList_SetImageCount

Resizes an existing image list

#include <GuiImageList.au3>
_GUIImageList_SetImageCount ( $hWnd, $iNewCount )

Parameters

$hWnd | Handle to the imagelist
$iNewCount | The new size of the image list

Return Value

Success: | True.
Failure: | False.

Remarks

If an application expands an image list with this function, it must add new images by using the GUIImageList_Replace() function.
If your application does not add valid images at the new indexes, draw operations that use the new indexes will be unpredictable.

If you decrease the size of an image list by using this function, the truncated images are freed.

Related

_GUIImageList_GetImageCount

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idListview, $hImage
    Local $iStylesEx = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    GUICreate("ImageList Set Image Count", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iStylesEx)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 120)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)
    _GUICtrlListView_AddItem($idListview, "Row 4: Col 1", 3)
    _GUICtrlListView_AddItem($idListview, "Row 5: Col 1", 4)
    _GUICtrlListView_AddSubItem($idListview, 4, "Row 5: Col 2", 1, 3)
    _GUICtrlListView_AddItem($idListview, "Row 6: Col 1", 5)
    _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 2", 1, 4)
    _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 3", 2, 3)

    GUISetState(@SW_LOCK)
    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Image Count")
    _GUIImageList_SetImageCount($hImage, 3)
    GUISetState(@SW_UNLOCK)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUIImageList_Swap

Function Reference

_GUIImageList_Swap

Swap image between Source and Destination image's index

#include <GuiImageList.au3>
_GUIImageList_Swap ( $hWnd, $iSource, $iDestination )

Parameters

$hWnd | Handle to the imagelist
$iSource | The 0-based index of the image to be used as the source of the swap operation
$iDestination | The 0-based index of the image to be used as the destination of the swap operation

Return Value

Success: | True.
Failure: | False.

Related

_GUIImageList_Copy

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idListview, $hImage
    Local $iStylesEx = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    GUICreate("ImageList Swap", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iStylesEx)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 120)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)
    _GUICtrlListView_AddItem($idListview, "Row 4: Col 1", 3)
    _GUICtrlListView_AddItem($idListview, "Row 5: Col 1", 4)
    _GUICtrlListView_AddSubItem($idListview, 4, "Row 5: Col 2", 1, 3)
    _GUICtrlListView_AddItem($idListview, "Row 6: Col 1", 5)
    _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 2", 1, 4)
    _GUICtrlListView_AddSubItem($idListview, 5, "Row 6: Col 3", 2, 3)

    GUISetState(@SW_LOCK)
    MsgBox($MB_SYSTEMMODAL, "Information", "Swapping 1st and Last Images")
    _GUIImageList_Swap($hImage, 0, 5)
    GUISetState(@SW_UNLOCK)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


User Defined Functions

GuiIPAddress user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiIPAddress.au3>.

User Defined Function | Description
_GUICtrlIpAddress_ClearAddress | Clears the contents of the IP address control
_GUICtrlIpAddress_Create | Create a GUI IP Address Control
_GUICtrlIpAddress_Destroy | Delete the IP Address control
_GUICtrlIpAddress_Get | Retrieves the address from the IP address control
_GUICtrlIpAddress_GetArray | Retrieves the address from the IP address control
_GUICtrlIpAddress_GetEx | Retrieves the address from the IP address control
_GUICtrlIpAddress_IsBlank | Determines if all fields in the IP address control are blank
_GUICtrlIpAddress_Set | Sets the address in the IP address control
_GUICtrlIpAddress_SetArray | Sets the address in the IP address control
_GUICtrlIpAddress_SetEx | Sets the address in the IP address control
_GUICtrlIpAddress_SetFocus | Sets the keyboard focus to the specified field in the IP address control
_GUICtrlIpAddress_SetFont | Set font of the control
_GUICtrlIpAddress_SetRange | Sets the valid range for the specified field in the IP address control
_GUICtrlIpAddress_ShowHide | Shows/Hides the IP address control


Function _GUICtrlIpAddress_ClearAddress

Function Reference

_GUICtrlIpAddress_ClearAddress

Clears the contents of the IP address control

#include <GuiIPAddress.au3>
_GUICtrlIpAddress_ClearAddress ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

None.

Related

_GUICtrlIpAddress_IsBlank, _GUICtrlIpAddress_Set

Example

#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGui, $hIPAddress

    $hGui = GUICreate("IP Address Control Clear Example", 400, 300)
    $hIPAddress = _GUICtrlIpAddress_Create($hGui, 10, 10)
    GUISetState(@SW_SHOW)

    _GUICtrlIpAddress_Set($hIPAddress, "24.168.2.128")

    ; Clear the IP Address
    MsgBox($MB_SYSTEMMODAL, "Information", "Clear IP Address")
    _GUICtrlIpAddress_ClearAddress($hIPAddress)

    ; Wait for user to close GUI
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlIpAddress_Create

Function Reference

_GUICtrlIpAddress_Create

Create a GUI IP Address Control

#include <GuiIPAddress.au3>
_GUICtrlIpAddress_Create ( $hWnd, $iX, $iY [, $iWidth = 125 [, $iHeight = 25 [, $iStyles = 0x00000000 [, $iExstyles = 0x00000000]]]] )

Parameters

$hWnd | Handle to parent or owner window
$iX | Horizontal position of the control
$iY | Vertical position of the control
$iWidth | [optional] Control width
$iHeight | [optional] Control height
$iStyles | [optional] Control styles: Forced : $WS_CHILD, $WS_VISIBLE, $WS_TABSTOP
$iExStyles | [optional] Control extended style. These correspond to the standard $WS_EX_* constants. See Extended Style Table.

Return Value

Success: | the handle to the IP Address control.
Failure: | 0.

Related

_GUICtrlIpAddress_Destroy

Example

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

Global $g_hIPAddress

Example()

Func Example()
    Local $hGui

    $hGui = GUICreate("IP Address Control Create Example", 400, 300)
    $g_hIPAddress = _GUICtrlIpAddress_Create($hGui, 10, 10)
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    _GUICtrlIpAddress_Set($g_hIPAddress, "24.168.2.128")

    ; Wait for user to close GUI
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR
    Local $tInfo

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hIPAddress
            Switch $iCode
                Case $IPN_FIELDCHANGED ; Sent when the user changes a field in the control or moves from one field to another
                    $tInfo = DllStructCreate($tagNMIPADDRESS, $lParam)
                    _DebugPrint("$IPN_FIELDCHANGED" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @CRLF & _
                            "-->Field:" & @TAB & DllStructGetData($tInfo, "Field") & @CRLF & _
                            "-->Value:" & @TAB & DllStructGetData($tInfo, "Value"))
                    ; The return value is ignored
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlIpAddress_Destroy

Function Reference

_GUICtrlIpAddress_Destroy

Delete the IP Address control

#include <GuiIPAddress.au3>
_GUICtrlIpAddress_Destroy ( ByRef $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True, $hWnd is set to 0.
Failure: | False.

Remarks

Restricted to only be used on IP Address controls created with _GUICtrlIpAddress_Create().

Related

_GUICtrlIpAddress_Create

Example

#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGui, $hIPAddress

    $hGui = GUICreate("IP Address Destroy Control Example", 400, 300)
    $hIPAddress = _GUICtrlIpAddress_Create($hGui, 10, 10, 125, 30, $WS_THICKFRAME)
    GUISetState(@SW_SHOW)

    ; Clear the IP Address
    MsgBox($MB_SYSTEMMODAL, "Information", "Destroy IP Address Control")
    _GUICtrlIpAddress_Destroy($hIPAddress)

    ; Wait for user to close GUI
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlIpAddress_Get

Function Reference

_GUICtrlIpAddress_Get

Retrieves the address from the IP address control

#include <GuiIPAddress.au3>
_GUICtrlIpAddress_Get ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns an IP address string.

Related

_GUICtrlIpAddress_GetEx, _GUICtrlIpAddress_Set

Example

#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGui, $hIPAddress

    $hGui = GUICreate("IP Address Control Get (String) Example", 400, 300)
    $hIPAddress = _GUICtrlIpAddress_Create($hGui, 10, 10)
    GUISetState(@SW_SHOW)

    _GUICtrlIpAddress_Set($hIPAddress, "24.168.2.128")

    MsgBox($MB_SYSTEMMODAL, "Information", "IP Address: " & _GUICtrlIpAddress_Get($hIPAddress))

    ; Wait for user to close GUI
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlIpAddress_GetArray

Function Reference

_GUICtrlIpAddress_GetArray

Retrieves the address from the IP address control

#include <GuiIPAddress.au3>
_GUICtrlIpAddress_GetArray ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns an array formatted as follows:
[0] - 1st address field
[1] - 2nd address field
[2] - 3rd address field
[3] - 4th address field

Related

_GUICtrlIpAddress_GetEx, _GUICtrlIpAddress_SetArray

Example

#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $aIP[4] = [24, 168, 2, 128], $hIPAddress

    $hGui = GUICreate("IP Address Control Get (Array) Example", 400, 300)
    $hIPAddress = _GUICtrlIpAddress_Create($hGui, 2, 4, 125, 20)
    $g_idMemo = GUICtrlCreateEdit("", 2, 28, 396, 270, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    _GUICtrlIpAddress_SetArray($hIPAddress, $aIP)

    $aIP = _GUICtrlIpAddress_GetArray($hIPAddress)

    MemoWrite("Field 1 .....: " & $aIP[0])
    MemoWrite("Field 2 .....: " & $aIP[1])
    MemoWrite("Field 3 .....: " & $aIP[2])
    MemoWrite("Field 4 .....: " & $aIP[3])

    ; Wait for user to close GUI
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlIpAddress_GetEx

Function Reference

_GUICtrlIpAddress_GetEx

Retrieves the address from the IP address control

#include <GuiIPAddress.au3>
_GUICtrlIpAddress_GetEx ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns a $tagGetIPAddress structure that receives the ip address.

Related

_GUICtrlIpAddress_Get, _GUICtrlIpAddress_GetArray, _GUICtrlIpAddress_SetEx

Example

#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $tIP = DllStructCreate($tagGetIPAddress), $aIP[4] = [24, 168, 2, 128], $hIPAddress

    $hGui = GUICreate("IP Address Control GetEx Example", 400, 300)
    $hIPAddress = _GUICtrlIpAddress_Create($hGui, 2, 4, 125, 20)
    $g_idMemo = GUICtrlCreateEdit("", 2, 28, 396, 270, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    For $x = 0 To 3
        DllStructSetData($tIP, "Field" & $x + 1, $aIP[$x])
    Next

    _GUICtrlIpAddress_SetEx($hIPAddress, $tIP)

    $tIP = _GUICtrlIpAddress_GetEx($hIPAddress)

    For $x = 0 To 3
        MemoWrite("Field " & $x + 1 & " .....: " & DllStructGetData($tIP, "Field" & $x + 1))
    Next

    ; Wait for user to close GUI
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlIpAddress_IsBlank

Function Reference

_GUICtrlIpAddress_IsBlank

Determines if all fields in the IP address control are blank

#include <GuiIPAddress.au3>
_GUICtrlIpAddress_IsBlank ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

True: | IP address is blank.
False: | IP address is not blank.

Related

_GUICtrlIpAddress_ClearAddress

Example

#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $hIPAddress

    $hGui = GUICreate("IP Address Control IsBlank Example", 400, 300)
    $hIPAddress = _GUICtrlIpAddress_Create($hGui, 2, 4)
    $g_idMemo = GUICtrlCreateEdit("", 2, 28, 396, 270, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; See if IP Address is blank
    MemoWrite("Blank: " & _GUICtrlIpAddress_IsBlank($hIPAddress))

    Sleep(1000)

    _GUICtrlIpAddress_Set($hIPAddress, "24.168.2.128")

    ; See if IP Address is blank
    MemoWrite("Blank: " & _GUICtrlIpAddress_IsBlank($hIPAddress))

    ; Wait for user to close GUI
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlIpAddress_Set

Function Reference

_GUICtrlIpAddress_Set

Sets the address in the IP address control

#include <GuiIPAddress.au3>
_GUICtrlIpAddress_Set ( $hWnd, $sAddress )

Parameters

$hWnd | Handle to the control
$sAddress | IP Address string

Return Value

None.

Related

_GUICtrlIpAddress_ClearAddress, _GUICtrlIpAddress_Get

Example

#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGui, $hIPAddress

    $hGui = GUICreate("IP Address Control Set (String) Example", 400, 300)
    $hIPAddress = _GUICtrlIpAddress_Create($hGui, 10, 10)
    GUISetState(@SW_SHOW)

    _GUICtrlIpAddress_Set($hIPAddress, "24.168.2.128")

    MsgBox($MB_SYSTEMMODAL, "Information", "IP Address: " & _GUICtrlIpAddress_Get($hIPAddress))

    ; Wait for user to close GUI
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlIpAddress_SetArray

Function Reference

_GUICtrlIpAddress_SetArray

Sets the address in the IP address control

#include <GuiIPAddress.au3>
_GUICtrlIpAddress_SetArray ( $hWnd, $aAddress )

Parameters

$hWnd | Handle to the control
$aAddress | Array formatted as follows: [0] - 1st address field [1] - 2nd address field [2] - 3rd address field [3] - 4th address field

Return Value

None.

Related

_GUICtrlIpAddress_GetArray

Example

#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $aIP[4] = [24, 168, 2, 128], $hIPAddress

    $hGui = GUICreate("IP Address Control Set (Array) Example", 400, 300)
    $hIPAddress = _GUICtrlIpAddress_Create($hGui, 2, 4, 125, 20)
    $g_idMemo = GUICtrlCreateEdit("", 2, 28, 396, 270, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    _GUICtrlIpAddress_SetArray($hIPAddress, $aIP)

    $aIP = _GUICtrlIpAddress_GetArray($hIPAddress)

    MemoWrite("Field 1 .....: " & $aIP[0])
    MemoWrite("Field 2 .....: " & $aIP[1])
    MemoWrite("Field 3 .....: " & $aIP[2])
    MemoWrite("Field 4 .....: " & $aIP[3])

    ; Wait for user to close GUI
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlIpAddress_SetEx

Function Reference

_GUICtrlIpAddress_SetEx

Sets the address in the IP address control

#include <GuiIPAddress.au3>
_GUICtrlIpAddress_SetEx ( $hWnd, $tIP )

Parameters

$hWnd | Handle to the control
$tIP | $tagGetIPAddress structure containing new ip address for the control

Return Value

None.

Related

$tagGetIPAddress, _GUICtrlIpAddress_GetEx

Example

#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $tIP = DllStructCreate($tagGetIPAddress), $aIP[4] = [24, 168, 2, 128], $hIPAddress

    $hGui = GUICreate("IP Address Control SetEx Example", 400, 300)
    $hIPAddress = _GUICtrlIpAddress_Create($hGui, 2, 4, 125, 20)
    $g_idMemo = GUICtrlCreateEdit("", 2, 28, 396, 270, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    For $x = 0 To 3
        DllStructSetData($tIP, "Field" & $x + 1, $aIP[$x])
    Next

    _GUICtrlIpAddress_SetEx($hIPAddress, $tIP)

    $tIP = _GUICtrlIpAddress_GetEx($hIPAddress)

    For $x = 0 To 3
        MemoWrite("Field " & $x + 1 & " .....: " & DllStructGetData($tIP, "Field" & $x + 1))
    Next

    ; Wait for user to close GUI
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlIpAddress_SetFocus

Function Reference

_GUICtrlIpAddress_SetFocus

Sets the keyboard focus to the specified field in the IP address control

#include <GuiIPAddress.au3>
_GUICtrlIpAddress_SetFocus ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based field index to which the focus should be set. If this value is greater than the number of fields, focus is set to the first blank field. If all fields are nonblank, focus is set to the first field.

Return Value

None.

Example

#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>

Example()

Func Example()
    Local $hGui, $hIPAddress

    $hGui = GUICreate("IP Address Control Set Focus Example", 400, 300)
    $hIPAddress = _GUICtrlIpAddress_Create($hGui, 2, 4)
    GUISetState(@SW_SHOW)

    _GUICtrlIpAddress_Set($hIPAddress, "24.168.2.128")

    _GUICtrlIpAddress_SetFocus($hIPAddress, 1)
    ; Wait for user to close GUI
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlIpAddress_SetFont

Function Reference

_GUICtrlIpAddress_SetFont

Set font of the control

#include <GuiIPAddress.au3>
_GUICtrlIpAddress_SetFont ( $hWnd [, $sFaceName = "Arial" [, $iFontSize = 12 [, $iFontWeight = 400 [, $bFontItalic = False]]]] )

Parameters

$hWnd | Handle to the control
$sFaceName | [optional] The Font Name of the font to use
$iFontSize | [optional] The Font Size
$iFontWeight | [optional] The Font Weight
$bFontItalic | [optional] Use Italic Attribute

Return Value

None.

Example

#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>

Example()

Func Example()
    Local $hGui, $hIPAddress, $hIPAddress2

    $hGui = GUICreate("IP Address Control Set Font Example", 300, 150)
    $hIPAddress = _GUICtrlIpAddress_Create($hGui, 10, 10, 150, 30)
    $hIPAddress2 = _GUICtrlIpAddress_Create($hGui, 10, 50, 150, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlIpAddress_Set($hIPAddress, "24.168.2.128")
    _GUICtrlIpAddress_SetFont($hIPAddress, "Times New Roman", 14, 800, True)
    _GUICtrlIpAddress_Set($hIPAddress2, "24.168.2.128")
    _GUICtrlIpAddress_SetFont($hIPAddress2, "Arial", 10, 300)

    ; Wait for user to close GUI
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlIpAddress_SetRange

Function Reference

_GUICtrlIpAddress_SetRange

Sets the valid range for the specified field in the IP address control

#include <GuiIPAddress.au3>
_GUICtrlIpAddress_SetRange ( $hWnd, $iIndex [, $iLowRange = 0 [, $iHighRange = 255]] )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based field index to which the range will be applied
$iLowRange | [optional] Lower limit of the range
$iHighRange | [optional] Upper limit of the range

Return Value

Success: | True.
Failure: | False.

Example

#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>

Example()

Func Example()
    Local $hGui, $hIPAddress

    $hGui = GUICreate("IP Address Control Set Range Example", 300, 150)
    $hIPAddress = _GUICtrlIpAddress_Create($hGui, 10, 10)
    GUISetState(@SW_SHOW)

    _GUICtrlIpAddress_Set($hIPAddress, "24.168.2.128")

    ; set range on 1st field
    _GUICtrlIpAddress_SetRange($hIPAddress, 0, 198, 200)

    ; Wait for user to close GUI
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlIpAddress_ShowHide

Function Reference

_GUICtrlIpAddress_ShowHide

Shows/Hides the IP address control

#include <GuiIPAddress.au3>
_GUICtrlIpAddress_ShowHide ( $hWnd, $iState )

Parameters

$hWnd | Handle to the control
$iState | State of the IP Address control, can be the following values:

Return Value

True: | the control was previously visible.
False: | the control was previously hidden.

Example

#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>

Example()

Func Example()
    Local $hGui, $hIPAddress

    $hGui = GUICreate("IP Address Control Show/Hide Example", 300, 150)
    $hIPAddress = _GUICtrlIpAddress_Create($hGui, 10, 10)
    GUISetState(@SW_SHOW)

    _GUICtrlIpAddress_Set($hIPAddress, "24.168.2.128")

    Sleep(1000)
    _GUICtrlIpAddress_ShowHide($hIPAddress, @SW_HIDE)
    Sleep(1000)
    _GUICtrlIpAddress_ShowHide($hIPAddress, @SW_SHOW)

    ; Wait for user to close GUI
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


User Defined Functions

GuiListBox user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiListBox.au3>.

User Defined Function | Description
_GUICtrlListBox_AddFile | Adds the specified filename that contains a directory listing
_GUICtrlListBox_AddString | Add a string
_GUICtrlListBox_BeginUpdate | Prevents updating of the control until the EndUpdate function is called
_GUICtrlListBox_ClickItem | Clicks an item
_GUICtrlListBox_Create | Create a Listbox control
_GUICtrlListBox_DeleteString | Delete a string
_GUICtrlListBox_Destroy | Delete the control
_GUICtrlListBox_Dir | Adds the names of directories and files
_GUICtrlListBox_EndUpdate | Enables screen repainting that was turned off with the BeginUpdate function
_GUICtrlListBox_FindInText | Searches for an item that contains the specified text anywhere in its text
_GUICtrlListBox_FindString | Search for a string
_GUICtrlListBox_GetAnchorIndex | Retrieves the index of the anchor item
_GUICtrlListBox_GetCaretIndex | Return index of item that has the focus rectangle
_GUICtrlListBox_GetCount | Retrieves the number of items
_GUICtrlListBox_GetCurSel | Retrieve the index of the currently selected item
_GUICtrlListBox_GetHorizontalExtent | Retrieve from a list box the the scrollable width
_GUICtrlListBox_GetItemData | Retrieves the application defined value associated with an item
_GUICtrlListBox_GetItemHeight | Retrieves the height of items
_GUICtrlListBox_GetItemRect | Retrieves the rectangle that bounds an item
_GUICtrlListBox_GetItemRectEx | Retrieves the rectangle that bounds an item
_GUICtrlListBox_GetListBoxInfo | Retrieve the number of items per column in a specified list box
_GUICtrlListBox_GetLocale | Retrieves the current locale
_GUICtrlListBox_GetLocaleCountry | Retrieves the current country code
_GUICtrlListBox_GetLocaleLang | Retrieves the current language identifier
_GUICtrlListBox_GetLocalePrimLang | Extract primary language id from a language id
_GUICtrlListBox_GetLocaleSubLang | Extract sublanguage id from a language id
_GUICtrlListBox_GetSel | Retrieves the selection state of an item
_GUICtrlListBox_GetSelCount | Retrieves the total number of selected items
_GUICtrlListBox_GetSelItems | Fills a buffer with an array of selected items
_GUICtrlListBox_GetSelItemsText | Retrieves the text of selected items
_GUICtrlListBox_GetText | Returns the item (string) at the specified index
_GUICtrlListBox_GetTextLen | Gets the length of a string in a list box
_GUICtrlListBox_GetTopIndex | Retrieve the index of the first visible item in a list
_GUICtrlListBox_InitStorage | This message allocates memory for storing items
_GUICtrlListBox_InsertString | Insert a string into the list
_GUICtrlListBox_ItemFromPoint | Retrieves the 0-based index of the item nearest the specified point
_GUICtrlListBox_ReplaceString | Replaces the text of an item
_GUICtrlListBox_ResetContent | Remove all items from the list box
_GUICtrlListBox_SelectString | Searchs for an item that begins with the specified string
_GUICtrlListBox_SelItemRange | Select one or more consecutive items in a multiple-selection list box
_GUICtrlListBox_SelItemRangeEx | Select one or more consecutive items in a multiple-selection list box
_GUICtrlListBox_SetAnchorIndex | Set the anchor item—that is, the item from which a multiple selection starts
_GUICtrlListBox_SetCaretIndex | Set the focus rectangle to the item at the specified index in a multiple-selection list box
_GUICtrlListBox_SetColumnWidth | Set the width, in pixels, of all columns
_GUICtrlListBox_SetCurSel | Select a string and scroll it into view, if necessary
_GUICtrlListBox_SetHorizontalExtent | Set the width, in pixels, by which a list box can be scrolled horizontally
_GUICtrlListBox_SetItemData | Sets the value associated with the specified item
_GUICtrlListBox_SetItemHeight | Sets the height, in pixels, of items
_GUICtrlListBox_SetLocale | Set the current locale
_GUICtrlListBox_SetSel | Select a string(s) in a multiple-selection list box
_GUICtrlListBox_SetTabStops | Sets the tab-stop positions
_GUICtrlListBox_SetTopIndex | Ensure that a particular item in a list box is visible
_GUICtrlListBox_Sort | Re-sorts list box if it has the $LBS_SORT style
_GUICtrlListBox_SwapString | Swaps the text of two items at the specified indices
_GUICtrlListBox_UpdateHScroll | Update the horizontal scroll bar based on the longest string


Function _GUICtrlListBox_AddFile

Function Reference

_GUICtrlListBox_AddFile

Adds the specified filename that contains a directory listing

#include <GuiListBox.au3>
_GUICtrlListBox_AddFile ( $hWnd, $sFilePath )

Parameters

$hWnd | Control ID/Handle to the control
$sFilePath | Name of the file to add

Return Value

Success: | a 0-based index of the file that was added.
Failure: | -1.

Related

_GUICtrlListBox_AddString, _GUICtrlListBox_DeleteString, _GUICtrlListBox_InitStorage

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Add File", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add file
    _GUICtrlListBox_AddFile($idListBox, @WindowsDir & "\notepad.exe")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_AddString

Function Reference

_GUICtrlListBox_AddString

Add a string

#include <GuiListBox.au3>
_GUICtrlListBox_AddString ( $hWnd, $sText )

Parameters

$hWnd | Control ID/Handle to the control
$sText | String that is to be added

Return Value

Success: | a 0-based index of string.
Failure: | -1.

Remarks

If there is insufficient space to store the new string, the return value is $LB_ERRSPACE.

If the list box does not have the $LBS_SORT style, the string is added to the end of the list.
Otherwise, the string is inserted into the list and the list is sorted.

Related

_GUICtrlListBox_AddFile, _GUICtrlListBox_DeleteString, _GUICtrlListBox_InitStorage, _GUICtrlListBox_InsertString

Example

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

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Add String", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_DISABLENOSCROLL, $WS_HSCROLL))

    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_InsertString($idListBox, "Exact teXt", 3)
    _GUICtrlListBox_InsertString($idListBox, "This is the string that we're looking for", 6)
    _GUICtrlListBox_InsertString($idListBox, _
            "Let's add one really long line of text so that we can set the horizontal scroll bar and " & _
            "show that, unless we dynamically update the scroll bar, it won't show the full line.", 9)
    _GUICtrlListBox_UpdateHScroll($idListBox)
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_BeginUpdate

Function Reference

_GUICtrlListBox_BeginUpdate

Prevents updating of the control until the EndUpdate function is called

#include <GuiListBox.au3>
_GUICtrlListBox_BeginUpdate ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListBox_EndUpdate

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Begin Update", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlListBox_BeginUpdate($idListBox)
    _GUICtrlListBox_ResetContent($idListBox)
    _GUICtrlListBox_InitStorage($idListBox, 100, 4096)
    _GUICtrlListBox_Dir($idListBox, @WindowsDir & "\win*.exe")
    _GUICtrlListBox_AddFile($idListBox, @WindowsDir & "\notepad.exe")
    _GUICtrlListBox_Dir($idListBox, "", $DDL_DRIVES)
    _GUICtrlListBox_Dir($idListBox, "", $DDL_DRIVES, False)
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_ClickItem

Function Reference

_GUICtrlListBox_ClickItem

Clicks an item

#include <GuiListBox.au3>
_GUICtrlListBox_ClickItem ( $hWnd, $iIndex [, $sButton = "left" [, $bMove = False [, $iClicks = 1 [, $iSpeed = 0]]]] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Specifies the 0-based index of the item
$sButton | [optional] Button to click with
$bMove | [optional] If True, the mouse will be moved. If False, the mouse does not move.
$iClicks | [optional] Number of clicks
$iSpeed | [optional] Mouse movement speed

Return Value

None.

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Click Item_GUICtrlListBox_ClickItem", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Click an item
    _GUICtrlListBox_ClickItem($idListBox, 4, "left", True)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_Create

Function Reference

_GUICtrlListBox_Create

Create a Listbox control

#include <GuiListBox.au3>
_GUICtrlListBox_Create ( $hWnd, $sText, $iX, $iY [, $iWidth = 100 [, $iHeight = 200 [, $iStyle = 0x00B00002 [, $iExStyle = 0x00000200]]]] )

Parameters

$hWnd | Handle to parent or owner window
$sText | String to add to the combobox
$iX | Horizontal position of the control
$iY | Vertical position of the control
$iWidth | [optional] Control width
$iHeight | [optional] Control height
$iStyle [optional] Control style:
$LBS_COMBOBOX - Notifies a list box that it is part of a combo box
$LBS_DISABLENOSCROLL - Shows a disabled vertical scroll bar
$LBS_EXTENDEDSEL - Allows multiple items to be selected
$LBS_HASSTRINGS - Specifies that a list box contains items consisting of strings
$LBS_MULTICOLUMN - Specifies a multi columnn list box that will be scrolled horizontally
$LBS_MULTIPLESEL - Turns string selection on or off each time the user clicks a string
$LBS_NODATA - Specifies a no-data list box
$LBS_NOINTEGRALHEIGHT - Specifies that the size is exactly the size set by the application
$LBS_NOREDRAW - Specifies that the list box's appearance is not updated when changes are made
$LBS_NOSEL - Specifies that the list box contains items that can be viewed but not selected
$LBS_NOTIFY - Notifies whenever the user clicks or double clicks a string
$LBS_OWNERDRAWFIXED - Specifies that the list box is owner drawn
$LBS_OWNERDRAWVARIABLE - Specifies that the list box is owner drawn with variable height
$LBS_SORT - Sorts strings in the list box alphabetically
$LBS_STANDARD - Standard list box style
$LBS_USETABSTOPS - Enables a list box to recognize and expand tab characters
$LBS_WANTKEYBOARDINPUT - Specifies that the owner receives WM_VKEYTOITEM messages

Default: $LBS_SORT, $WS_HSCROLL, $WS_VSCROLL, $WS_BORDER
Forced : $WS_CHILD, $WS_TABSTOP, $WS_VISIBLE, $LBS_NOTIFY
$iExStyle [optional] Control extended style. These correspond to the standard $WS_EX_* constants. See Extended Style Table.
Default: $WS_EX_CLIENTEDGE

Return Value

Success: | the handle to the Listbox control.
Failure: | 0.

Remarks

This function is for Advanced users and for learning how the control works.

Related

_GUICtrlListBox_Destroy

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hListBox

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("(UDF Created) List Box Create", 400, 296)
    $g_hListBox = _GUICtrlListBox_Create($hGUI, "String upon creation", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Adding Items")

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    ; Add files
    _GUICtrlListBox_BeginUpdate($g_hListBox)
    _GUICtrlListBox_ResetContent($g_hListBox)
    _GUICtrlListBox_InitStorage($g_hListBox, 100, 4096)
    _GUICtrlListBox_Dir($g_hListBox, @WindowsDir & "\win*.exe")
    _GUICtrlListBox_AddFile($g_hListBox, @WindowsDir & "\notepad.exe")
    _GUICtrlListBox_Dir($g_hListBox, "", $DDL_DRIVES)
    _GUICtrlListBox_Dir($g_hListBox, "", $DDL_DRIVES, False)
    _GUICtrlListBox_EndUpdate($g_hListBox)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg
    Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox
    If Not IsHWnd($g_hListBox) Then $hWndListBox = GUICtrlGetHandle($g_hListBox)
    $hWndFrom = $lParam
    $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word
    $iCode = BitShift($wParam, 16) ; Hi Word

    Switch $hWndFrom
        Case $g_hListBox, $hWndListBox
            Switch $iCode
                Case $LBN_DBLCLK ; Sent when the user double-clicks a string in a list box
                    _DebugPrint("$LBN_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $LBN_ERRSPACE ; Sent when a list box cannot allocate enough memory to meet a specific request
                    _DebugPrint("$LBN_ERRSPACE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $LBN_KILLFOCUS ; Sent when a list box loses the keyboard focus
                    _DebugPrint("$LBN_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $LBN_SELCANCEL ; Sent when the user cancels the selection in a list box
                    _DebugPrint("$LBN_SELCANCEL" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $LBN_SELCHANGE ; Sent when the selection in a list box has changed
                    _DebugPrint("$LBN_SELCHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
                Case $LBN_SETFOCUS ; Sent when a list box receives the keyboard focus
                    _DebugPrint("$LBN_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; no return value
            EndSwitch
    EndSwitch
    ; Proceed the default AutoIt3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default AutoIt3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func _DebugPrint($s_Text)
    $s_Text = StringReplace($s_Text, @CRLF, @CRLF & "-->")
    ConsoleWrite("!===========================================================" & @CRLF & _
            "+===========================================================" & @CRLF & _
            "-->" & $s_Text & @CRLF & _
            "+===========================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlListBox_DeleteString

Function Reference

_GUICtrlListBox_DeleteString

Delete a string

#include <GuiListBox.au3>
_GUICtrlListBox_DeleteString ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the string to be deleted

Return Value

Success: | the count of strings remaining.
Failure: | -1.

Related

_GUICtrlListBox_AddFile, _GUICtrlListBox_AddString, _GUICtrlListBox_InsertString, _GUICtrlListBox_ResetContent

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Delete String", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)

    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%d : List box string", $iI))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Delete middle string
    _GUICtrlListBox_DeleteString($idListBox, 4)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_Destroy

Function Reference

_GUICtrlListBox_Destroy

Delete the control

#include <GuiListBox.au3>
_GUICtrlListBox_Destroy ( ByRef $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True, $hWnd is set to 0.
Failure: | False.

Remarks

Restricted to only be used on Listbox controls created with _GUICtrlListBox_Create().

Related

_GUICtrlListBox_Create

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $idListBox

    ; Create GUI
    $hGUI = GUICreate("(UDF Created) List Box Destroy", 400, 296)
    $idListBox = _GUICtrlListBox_Create($hGUI, "", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlListBox_BeginUpdate($idListBox)
    _GUICtrlListBox_ResetContent($idListBox)
    _GUICtrlListBox_InitStorage($idListBox, 100, 4096)
    _GUICtrlListBox_Dir($idListBox, @WindowsDir & "\win*.exe")
    _GUICtrlListBox_AddFile($idListBox, @WindowsDir & "\notepad.exe")
    _GUICtrlListBox_Dir($idListBox, "", $DDL_DRIVES)
    _GUICtrlListBox_Dir($idListBox, "", $DDL_DRIVES, False)
    _GUICtrlListBox_EndUpdate($idListBox)

    MsgBox($MB_SYSTEMMODAL, "Information", "Destroying ListBox")
    _GUICtrlListBox_Destroy($idListBox)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlListBox_Dir

Function Reference

_GUICtrlListBox_Dir

Adds the names of directories and files

#include <GuiListBox.au3>
_GUICtrlListBox_Dir ( $hWnd, $sFilePath [, $iAttributes = 0 [, $bBrackets = True]] )

Parameters

$hWnd | Control ID/Handle to the control
$sFilePath | Specifies an absolute path, relative path, or filename
$iAttributes | [optional] Specifies the attributes of the files or directories to be added: $DDL_READWRITE - Includes read-write files with no additional attributes $DDL_READONLY - Includes read-only files $DDL_HIDDEN - Includes hidden files $DDL_SYSTEM - Includes system files $DDL_DIRECTORY - Includes subdirectories $DDL_ARCHIVE - Includes archived files $DDL_DRIVES - All mapped drives are added to the list $DDL_EXCLUSIVE - Includes only files with the specified attributes
$bBrackets | [optional] include/exclude brackets when $DDL_DRIVES is used

Return Value

Success: | a 0-based index of the last name added.
Failure: | -1.

Remarks

If there is insufficient space to store the new strings, the return value is $LB_ERRSPACE.

Related

_GUICtrlListBox_InitStorage

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Dir", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlListBox_BeginUpdate($idListBox)
    _GUICtrlListBox_ResetContent($idListBox)
    _GUICtrlListBox_InitStorage($idListBox, 100, 4096)
    _GUICtrlListBox_Dir($idListBox, @WindowsDir & "\win*.exe")
    _GUICtrlListBox_AddFile($idListBox, @WindowsDir & "\notepad.exe")
    _GUICtrlListBox_Dir($idListBox, "", $DDL_DRIVES)
    _GUICtrlListBox_Dir($idListBox, "", $DDL_DRIVES, False)
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_EndUpdate

Function Reference

_GUICtrlListBox_EndUpdate

Enables screen repainting that was turned off with the BeginUpdate function

#include <GuiListBox.au3>
_GUICtrlListBox_EndUpdate ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListBox_BeginUpdate

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box End Update", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlListBox_BeginUpdate($idListBox)
    _GUICtrlListBox_ResetContent($idListBox)
    _GUICtrlListBox_InitStorage($idListBox, 100, 4096)
    _GUICtrlListBox_Dir($idListBox, @WindowsDir & "\win*.exe")
    _GUICtrlListBox_AddFile($idListBox, @WindowsDir & "\notepad.exe")
    _GUICtrlListBox_Dir($idListBox, "", $DDL_DRIVES)
    _GUICtrlListBox_Dir($idListBox, "", $DDL_DRIVES, False)
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_FindInText

Function Reference

_GUICtrlListBox_FindInText

Searches for an item that contains the specified text anywhere in its text

#include <GuiListBox.au3>
_GUICtrlListBox_FindInText ( $hWnd, $sText [, $iStart = -1 [, $bWrapOK = True]] )

Parameters

$hWnd | Control ID/Handle to the control
$sText | Text to match
$iStart | [optional] 0-based index of the item to begin the search with or -1 to start from the beginning. The specified item is itself excluded from the search.
$bWrapOK | [optional] If True, the search will continue with the first item if no match is found

Return Value

Success: | the 0-based index of the item.
Failure: | -1.

Remarks

The search is case insensitive.

Related

_GUICtrlListBox_FindString, _GUICtrlListBox_SelectString

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>

Example()

Func Example()
    Local $iIndex, $idListBox

    ; Create GUI
    GUICreate("List Box Find In Text", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)

    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_InsertString($idListBox, "eXaCt tExT", 3)
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Find an item
    $iIndex = _GUICtrlListBox_FindInText($idListBox, "exa")
    _GUICtrlListBox_SetCurSel($idListBox, $iIndex)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_FindString

Function Reference

_GUICtrlListBox_FindString

Search for a string

#include <GuiListBox.au3>
_GUICtrlListBox_FindString ( $hWnd, $sText [, $bExact = False] )

Parameters

$hWnd | Control ID/Handle to the control
$sText | String to search for
$bExact | [optional] Exact match or not

Return Value

Success: | the 0-based index of the item.
Failure: | -1.

Remarks

Find the first string in a list box that begins with the specified string.

If exact is specified find the first list box string that exactly matches the specified string, except that the search is not case sensitive.

Related

_GUICtrlListBox_FindInText, _GUICtrlListBox_SelectString

Example

Example 1

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>

Example()

Func Example()
    Local $iIndex, $idListBox

    ; Create GUI
    GUICreate("List Box Find String", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)

    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_InsertString($idListBox, "eXaCt tExT", 3)
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Find an item
    $iIndex = _GUICtrlListBox_FindString($idListBox, "exa")
    _GUICtrlListBox_SetCurSel($idListBox, $iIndex)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Example 2

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>

Example()

Func Example()
    Local $iIndex, $idListBox

    ; Create GUI
    GUICreate("List Box Find String Exact", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)

    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_InsertString($idListBox, "eXa", 2)
    _GUICtrlListBox_InsertString($idListBox, "eXaCt tExT", 3)
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Find an item
    $iIndex = _GUICtrlListBox_FindString($idListBox, "exact text", True)
    _GUICtrlListBox_SetCurSel($idListBox, $iIndex)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetAnchorIndex

Function Reference

_GUICtrlListBox_GetAnchorIndex

Retrieves the index of the anchor item

#include <GuiListBox.au3>
_GUICtrlListBox_GetAnchorIndex ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the 0-based index of the item.

Related

_GUICtrlListBox_SetAnchorIndex

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>

Example()

Func Example()
    Local $iIndex, $idListBox

    ; Create GUI
    GUICreate("List Box Get Anchor Index", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)

    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Set anchor index
    _GUICtrlListBox_SetAnchorIndex($idListBox, 2)

    ; Read anchor index
    $iIndex = _GUICtrlListBox_GetAnchorIndex($idListBox)
    _GUICtrlListBox_SetCurSel($idListBox, $iIndex)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetCaretIndex

Function Reference

_GUICtrlListBox_GetCaretIndex

Return index of item that has the focus rectangle

#include <GuiListBox.au3>
_GUICtrlListBox_GetCaretIndex ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the 0-based index of the selected item.
Failure: | -1 if nothing is selected.

Related

_GUICtrlListBox_SetCaretIndex

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>

Example()

Func Example()
    Local $iIndex, $idListBox

    ; Create GUI
    GUICreate("List Box Get Caret Index", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)

    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Set caret index
    _GUICtrlListBox_SetCaretIndex($idListBox, 2)

    ; Read caret index
    $iIndex = _GUICtrlListBox_GetCaretIndex($idListBox)
    _GUICtrlListBox_SetCurSel($idListBox, $iIndex)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetCount

Function Reference

_GUICtrlListBox_GetCount

Retrieves the number of items

#include <GuiListBox.au3>
_GUICtrlListBox_GetCount ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the number of items in the list box.
Failure: | -1.

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Get Count", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)

    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Get item count
    MsgBox($MB_SYSTEMMODAL, "Information", "Item count: " & _GUICtrlListBox_GetCount($idListBox))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetCurSel

Function Reference

_GUICtrlListBox_GetCurSel

Retrieve the index of the currently selected item

#include <GuiListBox.au3>
_GUICtrlListBox_GetCurSel ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the 0-based index of the currently selected item.
Failure: | -1 if there is no selection.

Remarks

Do not use this with a multiple-selection list box.

Related

_GUICtrlListBox_SetCurSel

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Get Cur Sel", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Select an item
    _GUICtrlListBox_SetCurSel($idListBox, 4)

    ; Get currently selected item
    _WinAPI_ShowMsg("Current selection: " & _GUICtrlListBox_GetCurSel($idListBox))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetHorizontalExtent

Function Reference

_GUICtrlListBox_GetHorizontalExtent

Retrieve from a list box the the scrollable width

#include <GuiListBox.au3>
_GUICtrlListBox_GetHorizontalExtent ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the scrollable width, in pixels, of the list box.

Remarks

The list box must have been defined with the $WS_HSCROLL style.

Related

_GUICtrlListBox_SetHorizontalExtent

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Get Horizontal Extent", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_DISABLENOSCROLL, $WS_HSCROLL))
    GUISetState(@SW_SHOW)

    ; Add long string
    _GUICtrlListBox_AddString($idListBox, "AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI.")

    ; Show current horizontal extent
    MsgBox($MB_SYSTEMMODAL, "Information", "Horizontal Extent: " & _GUICtrlListBox_GetHorizontalExtent($idListBox))

    _GUICtrlListBox_SetHorizontalExtent($idListBox, 500)

    ; Show current horizontal extent
    MsgBox($MB_SYSTEMMODAL, "Information", "Horizontal Extent: " & _GUICtrlListBox_GetHorizontalExtent($idListBox))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetItemData

Function Reference

_GUICtrlListBox_GetItemData

Retrieves the application defined value associated with an item

#include <GuiListBox.au3>
_GUICtrlListBox_GetItemData ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Specifies the 0-based index of the item

Return Value

Success: | the application defined value.
Failure: | -1.

Related

_GUICtrlListBox_SetItemData

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

; Warning this should not be used on items created using built-in functions
; Item data is the controlID for each string

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Get Item Data", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Set item data
    _GUICtrlListBox_SetItemData($idListBox, 4, 1234)

    ; Get item data
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 5 Data: " & _GUICtrlListBox_GetItemData($idListBox, 4))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetItemHeight

Function Reference

_GUICtrlListBox_GetItemHeight

Retrieves the height of items

#include <GuiListBox.au3>
_GUICtrlListBox_GetItemHeight ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the height, in pixels, of each item in the list box.
Failure: | 0.

Related

_GUICtrlListBox_SetItemHeight

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Get Item Height", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Show item height
    MsgBox($MB_SYSTEMMODAL, "Information", "Item height: " & _GUICtrlListBox_GetItemHeight($idListBox))

    ; Set item height
    _GUICtrlListBox_SetItemHeight($idListBox, 26)

    ; Show item height
    MsgBox($MB_SYSTEMMODAL, "Information", "Item height: " & _GUICtrlListBox_GetItemHeight($idListBox))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetItemRect

Function Reference

_GUICtrlListBox_GetItemRect

Retrieves the rectangle that bounds an item

#include <GuiListBox.au3>
_GUICtrlListBox_GetItemRect ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Specifies the 0-based index of the item

Return Value

Returns an array with the following format:
[0] - X coordinate of the upper left corner of the rectangle
[1] - Y coordinate of the upper left corner of the rectangle
[2] - X coordinate of the lower right corner of the rectangle
[3] - Y coordinate of the lower right corner of the rectangle

Related

_GUICtrlListBox_GetItemRectEx

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aRect, $idListBox

    ; Create GUI
    GUICreate("List Box Get Item Rect", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Show item rectangle
    $aRect = _GUICtrlListBox_GetItemRect($idListBox, 4)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 5 Rectangle: " & $aRect[0] & ", " & $aRect[1] & ", " & $aRect[2] & ", " & $aRect[3])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetItemRectEx

Function Reference

_GUICtrlListBox_GetItemRectEx

Retrieves the rectangle that bounds an item

#include <GuiListBox.au3>
_GUICtrlListBox_GetItemRectEx ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Specifies the 0-based index of the item

Return Value

Returns a $tagRECT structure that receives the client coordinates for the item.

Related

$tagRECT, _GUICtrlListBox_GetItemRect

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $tRECT, $idListBox

    ; Create GUI
    GUICreate("List Box Get Item RectEx", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Show item rectangle
    $tRECT = _GUICtrlListBox_GetItemRectEx($idListBox, 4)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 5 Rectangle: " & _
            DllStructGetData($tRECT, "Left") & ", " & _
            DllStructGetData($tRECT, "Top") & ", " & _
            DllStructGetData($tRECT, "Right") & ", " & _
            DllStructGetData($tRECT, "Bottom"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetListBoxInfo

Function Reference

_GUICtrlListBox_GetListBoxInfo

Retrieve the number of items per column in a specified list box

#include <GuiListBox.au3>
_GUICtrlListBox_GetListBoxInfo ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the number of items per column.

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Get ListBox Info", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Show items per column
    MsgBox($MB_SYSTEMMODAL, "Information", "Items per column: " & _GUICtrlListBox_GetListBoxInfo($idListBox))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetLocale

Function Reference

_GUICtrlListBox_GetLocale

Retrieves the current locale

#include <GuiListBox.au3>
_GUICtrlListBox_GetLocale ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the high order word contains the country code and the low order word contains the language identifier.

Related

_GUICtrlListBox_GetLocaleCountry, _GUICtrlListBox_GetLocaleLang, _GUICtrlListBox_GetLocalePrimLang, _GUICtrlListBox_GetLocaleSubLang, _GUICtrlListBox_SetLocale

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Get Locale", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Show locale, country code, language identifier, primary language id, sub-language id
    MsgBox($MB_SYSTEMMODAL, "Information", _
            "Locale .................: " & _GUICtrlListBox_GetLocale($idListBox) & @CRLF & _
            "Country code ........: " & _GUICtrlListBox_GetLocaleCountry($idListBox) & @CRLF & _
            "Language identifier..: " & _GUICtrlListBox_GetLocaleLang($idListBox) & @CRLF & _
            "Primary Language id : " & _GUICtrlListBox_GetLocalePrimLang($idListBox) & @CRLF & _
            "Sub-Language id ....: " & _GUICtrlListBox_GetLocaleSubLang($idListBox))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetLocaleCountry

Function Reference

_GUICtrlListBox_GetLocaleCountry

Retrieves the current country code

#include <GuiListBox.au3>
_GUICtrlListBox_GetLocaleCountry ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the country code of the list box.

Related

_GUICtrlListBox_GetLocale

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Get Locale Country Code", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Show locale, country code, language identifier, primary language id, sub-language id
    MsgBox($MB_SYSTEMMODAL, "Information", _
            "Locale .................: " & _GUICtrlListBox_GetLocale($idListBox) & @CRLF & _
            "Country code ........: " & _GUICtrlListBox_GetLocaleCountry($idListBox) & @CRLF & _
            "Language identifier..: " & _GUICtrlListBox_GetLocaleLang($idListBox) & @CRLF & _
            "Primary Language id : " & _GUICtrlListBox_GetLocalePrimLang($idListBox) & @CRLF & _
            "Sub-Language id ....: " & _GUICtrlListBox_GetLocaleSubLang($idListBox))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetLocaleLang

Function Reference

_GUICtrlListBox_GetLocaleLang

Retrieves the current language identifier

#include <GuiListBox.au3>
_GUICtrlListBox_GetLocaleLang ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the language identifier of the list box.

Related

_GUICtrlListBox_GetLocale

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Get Locale Language identifier", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Show locale, country code, language identifier, primary language id, sub-language id
    MsgBox($MB_SYSTEMMODAL, "Information", _
            "Locale .................: " & _GUICtrlListBox_GetLocale($idListBox) & @CRLF & _
            "Country code ........: " & _GUICtrlListBox_GetLocaleCountry($idListBox) & @CRLF & _
            "Language identifier..: " & _GUICtrlListBox_GetLocaleLang($idListBox) & @CRLF & _
            "Primary Language id : " & _GUICtrlListBox_GetLocalePrimLang($idListBox) & @CRLF & _
            "Sub-Language id ....: " & _GUICtrlListBox_GetLocaleSubLang($idListBox))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetLocalePrimLang

Function Reference

_GUICtrlListBox_GetLocalePrimLang

Extract primary language id from a language id

#include <GuiListBox.au3>
_GUICtrlListBox_GetLocalePrimLang ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the primary language id.

Related

_GUICtrlListBox_GetLocale

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Get Locale Primary Language id", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Show locale, country code, language identifier, primary language id, sub-language id
    MsgBox($MB_SYSTEMMODAL, "Information", _
            "Locale .................: " & _GUICtrlListBox_GetLocale($idListBox) & @CRLF & _
            "Country code ........: " & _GUICtrlListBox_GetLocaleCountry($idListBox) & @CRLF & _
            "Language identifier..: " & _GUICtrlListBox_GetLocaleLang($idListBox) & @CRLF & _
            "Primary Language id : " & _GUICtrlListBox_GetLocalePrimLang($idListBox) & @CRLF & _
            "Sub-Language id ....: " & _GUICtrlListBox_GetLocaleSubLang($idListBox))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetLocaleSubLang

Function Reference

_GUICtrlListBox_GetLocaleSubLang

Extract sublanguage id from a language id

#include <GuiListBox.au3>
_GUICtrlListBox_GetLocaleSubLang ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the Sub-Language id.

Related

_GUICtrlListBox_GetLocale

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Get Locale Sub-Language id", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Show locale, country code, language identifier, primary language id, sub-language id
    MsgBox($MB_SYSTEMMODAL, "Information", _
            "Locale .................: " & _GUICtrlListBox_GetLocale($idListBox) & @CRLF & _
            "Country code ........: " & _GUICtrlListBox_GetLocaleCountry($idListBox) & @CRLF & _
            "Language identifier..: " & _GUICtrlListBox_GetLocaleLang($idListBox) & @CRLF & _
            "Primary Language id : " & _GUICtrlListBox_GetLocalePrimLang($idListBox) & @CRLF & _
            "Sub-Language id ....: " & _GUICtrlListBox_GetLocaleSubLang($idListBox))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetSel

Function Reference

_GUICtrlListBox_GetSel

Retrieves the selection state of an item

#include <GuiListBox.au3>
_GUICtrlListBox_GetSel ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Specifies the 0-based index of the item

Return Value

True: | Item is selected.
False: | Item is not selected.

Related

_GUICtrlListBox_SetSel

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Get Sel", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL))
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Select a few items
    _GUICtrlListBox_SetSel($idListBox, 3)
    _GUICtrlListBox_SetSel($idListBox, 4)
    _GUICtrlListBox_SetSel($idListBox, 5)

    ; Show the item selection state
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 5 Selected: " & _GUICtrlListBox_GetSel($idListBox, 4))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetSelCount

Function Reference

_GUICtrlListBox_GetSelCount

Retrieves the total number of selected items

#include <GuiListBox.au3>
_GUICtrlListBox_GetSelCount ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the count of selected items.
Failure: | -1 if no items are selected.

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Get Sel Count", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL))
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Select a few items
    _GUICtrlListBox_SetSel($idListBox, 3)
    _GUICtrlListBox_SetSel($idListBox, 4)
    _GUICtrlListBox_SetSel($idListBox, 5)

    ; Show the item selection count
    MsgBox($MB_SYSTEMMODAL, "Information", "Items Selected: " & _GUICtrlListBox_GetSelCount($idListBox))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetSelItems

Function Reference

_GUICtrlListBox_GetSelItems

Fills a buffer with an array of selected items

#include <GuiListBox.au3>
_GUICtrlListBox_GetSelItems ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an array with the following format:
[0] - Total items in array
[1] - Index of the selected item
[2] - Index of the selected item
[n] - Index of the selected item

Related

_GUICtrlListBox_GetSelItemsText

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $sItems, $aItems, $idListBox

    ; Create GUI
    GUICreate("List Box Get Sel Items", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL))
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Select a few items
    _GUICtrlListBox_SetSel($idListBox, 3)
    _GUICtrlListBox_SetSel($idListBox, 4)
    _GUICtrlListBox_SetSel($idListBox, 5)

    ; Get indexes of selected items
    $aItems = _GUICtrlListBox_GetSelItems($idListBox)
    For $iI = 1 To $aItems[0]
        If $iI > 1 Then $sItems &= ", "
        $sItems &= $aItems[$iI]
    Next
    MsgBox($MB_SYSTEMMODAL, "Information", "Items Selected: " & $sItems)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetSelItemsText

Function Reference

_GUICtrlListBox_GetSelItemsText

Retrieves the text of selected items

#include <GuiListBox.au3>
_GUICtrlListBox_GetSelItemsText ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an array with the following format:
[0] - Total items in array
[1] - Text of the selected item
[2] - Text of the selected item
[n] - Text of the selected item

Related

_GUICtrlListBox_GetSelItems

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $sItems, $aItems, $idListBox

    ; Create GUI
    GUICreate("List Box Get Sel Items Text", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL))
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Select a few items
    _GUICtrlListBox_SetSel($idListBox, 3)
    _GUICtrlListBox_SetSel($idListBox, 4)
    _GUICtrlListBox_SetSel($idListBox, 5)

    ; Get text of selected items
    $aItems = _GUICtrlListBox_GetSelItemsText($idListBox)
    For $iI = 1 To $aItems[0]
        $sItems &= @CRLF & $aItems[$iI]
    Next
    MsgBox($MB_SYSTEMMODAL, "Information", "Items Selected: " & $sItems)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetText

Function Reference

_GUICtrlListBox_GetText

Returns the item (string) at the specified index

#include <GuiListBox.au3>
_GUICtrlListBox_GetText ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Specifies the 0-based index of the string to retrieve

Return Value

Returns the item (string).

Related

_GUICtrlListBox_GetTextLen

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Get Text", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL))
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Show item text
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 5 Text: " & _GUICtrlListBox_GetText($idListBox, 4))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetTextLen

Function Reference

_GUICtrlListBox_GetTextLen

Gets the length of a string in a list box

#include <GuiListBox.au3>
_GUICtrlListBox_GetTextLen ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Specifies the 0-based index of the item

Return Value

Returns the length of the string.

Related

_GUICtrlListBox_GetText

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $sText, $idListBox

    ; Create GUI
    GUICreate("List Box Get Text Len", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL))
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        $sText = StringFormat("%03d : Random string ", Random(1, 100, 1))
        For $iX = 1 To Random(1, 20, 1)
            $sText &= Chr(Random(65, 90, 1))
        Next
        _GUICtrlListBox_AddString($idListBox, $sText)
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Show item text length
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 5 Text Length: " & _GUICtrlListBox_GetTextLen($idListBox, 4))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_GetTopIndex

Function Reference

_GUICtrlListBox_GetTopIndex

Retrieve the index of the first visible item in a list

#include <GuiListBox.au3>
_GUICtrlListBox_GetTopIndex ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the index of the first visible item.

Related

_GUICtrlListBox_SetTopIndex

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $sText, $idListBox

    ; Create GUI
    GUICreate("List Box Get Top Index", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 100
        $sText = StringFormat("%03d : Random string ", $iI)
        For $iX = 1 To Random(1, 20, 1)
            $sText &= Chr(Random(65, 90, 1))
        Next
        _GUICtrlListBox_AddString($idListBox, $sText)
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Show top index
    MsgBox($MB_SYSTEMMODAL, "Information", "Top Index: " & _GUICtrlListBox_GetTopIndex($idListBox))

    ; Set top index
    _GUICtrlListBox_SetTopIndex($idListBox, 50)

    ; Show top index
    MsgBox($MB_SYSTEMMODAL, "Information", "Top Index: " & _GUICtrlListBox_GetTopIndex($idListBox))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_InitStorage

Function Reference

_GUICtrlListBox_InitStorage

This message allocates memory for storing items

#include <GuiListBox.au3>
_GUICtrlListBox_InitStorage ( $hWnd, $iItems, $iBytes )

Parameters

$hWnd | Control ID/Handle to the control
$iItems | The total amount of items that you intend to add
$iBytes | The total amount of memory your strings will consume

Return Value

Returns the total number of items for which memory has been pre-allocated.

Related

_GUICtrlListBox_AddFile, _GUICtrlListBox_AddString, _GUICtrlListBox_Dir, _GUICtrlListBox_InsertString

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Init Storage", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add files
    _GUICtrlListBox_BeginUpdate($idListBox)
    _GUICtrlListBox_ResetContent($idListBox)
    MsgBox($MB_SYSTEMMODAL, "Information", "Storage Allocated: " & _GUICtrlListBox_InitStorage($idListBox, 100, 4096))
    _GUICtrlListBox_Dir($idListBox, @WindowsDir & "\win*.exe")
    _GUICtrlListBox_AddFile($idListBox, @WindowsDir & "\notepad.exe")
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_InsertString

Function Reference

_GUICtrlListBox_InsertString

Insert a string into the list

#include <GuiListBox.au3>
_GUICtrlListBox_InsertString ( $hWnd, $sText [, $iIndex = -1] )

Parameters

$hWnd | Control ID/Handle to the control
$sText | Text string to be inserted
$iIndex | [optional] Specifies the 0-based index of the position at which to insert the string. If this parameter is -1 the string is added to the end of the list.

Return Value

Success: | the 0-based index of the item position.
Failure: | -1.

Remarks

If $iIndex is -1 then string is added to end of list. Unlike the _GUICtrlListBox_AddString(), this function does not cause a list with the $LBS_SORT style to be sorted.

Related

_GUICtrlListBox_AddString, _GUICtrlListBox_DeleteString, _GUICtrlListBox_InitStorage

Example

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

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Insert String", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($WS_BORDER, $LBS_NOTIFY, $LBS_DISABLENOSCROLL, $WS_HSCROLL))
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_InsertString($idListBox, "Let's add one really long line of text so that we can set the horizontal scroll bar and " & _
            "show that, unless we dynamically update the scroll bar, it won't show the full line.", 4)
    _GUICtrlListBox_UpdateHScroll($idListBox)
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_ItemFromPoint

Function Reference

_GUICtrlListBox_ItemFromPoint

Retrieves the 0-based index of the item nearest the specified point

#include <GuiListBox.au3>
_GUICtrlListBox_ItemFromPoint ( $hWnd, $iX, $iY )

Parameters

$hWnd | Control ID/Handle to the control
$iX | X coordinate, relative to the upper-left corner of the client area
$iY | Y coordinate, relative to the upper-left corner of the client area

Return Value

Success: | the index of the nearest item.
Failure: | -1 if the point is outside of the client area.

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Item From Point", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Item closest to point
    MsgBox($MB_SYSTEMMODAL, "Information", "Item Closest to 30, 30: " & _GUICtrlListBox_ItemFromPoint($idListBox, 30, 30))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_ReplaceString

Function Reference

_GUICtrlListBox_ReplaceString

Replaces the text of an item

#include <GuiListBox.au3>
_GUICtrlListBox_ReplaceString ( $hWnd, $iIndex, $sText )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Specifies the 0-based index of the item
$sText | String to replace old string

Return Value

Success: | True.
Failure: | False.

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $sText, $idListBox

    ; Create GUI
    GUICreate("List Box Replace String", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL))
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        $sText = StringFormat("%03d : Random string ", Random(1, 100, 1))
        For $iX = 1 To Random(1, 20, 1)
            $sText &= Chr(Random(65, 90, 1))
        Next
        _GUICtrlListBox_AddString($idListBox, $sText)
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Replace string
    MsgBox($MB_SYSTEMMODAL, "Information", "Replacing String at Index 3")
    _GUICtrlListBox_ReplaceString($idListBox, 3, "gone")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_ResetContent

Function Reference

_GUICtrlListBox_ResetContent

Remove all items from the list box

#include <GuiListBox.au3>
_GUICtrlListBox_ResetContent ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

None.

Related

_GUICtrlListBox_DeleteString

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Reset Content", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_DISABLENOSCROLL, $WS_HSCROLL))
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    MsgBox($MB_SYSTEMMODAL, "Information", "Resetting Content")
    _GUICtrlListBox_ResetContent($idListBox)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_SelectString

Function Reference

_GUICtrlListBox_SelectString

Searchs for an item that begins with the specified string

#include <GuiListBox.au3>
_GUICtrlListBox_SelectString ( $hWnd, $sText [, $iIndex = -1] )

Parameters

$hWnd | Control ID/Handle to the control
$sText | String that contains the string for which to search.
$iIndex | [optional] Specifies the 0-based index of the item before the first item to be searched. When the search reaches the bottom of the list box, it continues searching from the top of the list box back to the item specified by $iIndex. If $iIndex is –1, the entire list box is searched from the beginning.

Return Value

Success: | the 0-based index of the selected item.
Failure: | -1.

Remarks

The list box is scrolled, if necessary, to bring the selected item into view.
Do not use this message with a list box that has the $LBS_MULTIPLESEL or the $LBS_EXTENDEDSEL styles.

Related

_GUICtrlListBox_FindInText, _GUICtrlListBox_FindString

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $sText, $idListBox

    ; Create GUI
    GUICreate("List Box Select String", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 10
        $sText = StringFormat("%03d : Random string ", Random(1, 100, 1))
        For $iX = 1 To Random(1, 20, 1)
            $sText &= Chr(Random(65, 90, 1))
        Next
        _GUICtrlListBox_AddString($idListBox, $sText)
    Next
    _GUICtrlListBox_AddString($idListBox, "020 : Target string")
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Select string
    MsgBox($MB_SYSTEMMODAL, "Information", "Target String Index: " & _GUICtrlListBox_SelectString($idListBox, "020 : T"));

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_SelItemRange

Function Reference

_GUICtrlListBox_SelItemRange

Select one or more consecutive items in a multiple-selection list box

#include <GuiListBox.au3>
_GUICtrlListBox_SelItemRange ( $hWnd, $iFirst, $iLast [, $bSelect = True] )

Parameters

$hWnd | Control ID/Handle to the control
$iFirst | 0-based index of the first item to select
$iLast | 0-based index of the last item to select
$bSelect | [optional] Specifies how to set the selection. If this parameter is True, the string is selected and highlighted. If it is False, the highlight is removed and the string is no longer selected.

Return Value

Success: | True.
Failure: | False.

Remarks

Use this message only with multiple-selection list boxes.
This message can select a range only within the first 65,536 items.

Related

_GUICtrlListBox_SelItemRangeEx

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>

Example()

Func Example()
    Local $sText, $idListBox

    ; Create GUI
    GUICreate("List Box Sel Item Range", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL))
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 10
        $sText = StringFormat("%03d : Random string ", Random(1, 100, 1))
        For $iX = 1 To Random(1, 20, 1)
            $sText &= Chr(Random(65, 90, 1))
        Next
        _GUICtrlListBox_AddString($idListBox, $sText)
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Select a few items
    _GUICtrlListBox_SelItemRange($idListBox, 3, 5)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_SelItemRangeEx

Function Reference

_GUICtrlListBox_SelItemRangeEx

Select one or more consecutive items in a multiple-selection list box

#include <GuiListBox.au3>
_GUICtrlListBox_SelItemRangeEx ( $hWnd, $iFirst, $iLast )

Parameters

$hWnd | Control ID/Handle to the control
$iFirst | 0-based index of the first item to select
$iLast | 0-based index of the last item to select

Return Value

Success: | True.
Failure: | False.

Remarks

If the $iFirst is less than the $iLast, the specified range of items is selected.
If $iFirst is greater than or equal to $iLast, the range is removed from the specified range of items.
To select only one item, select two items and then deselect the unwanted item.

Use this message only with multiple-selection list boxes.
This message can select a range only within the first 65,536 items.

Related

_GUICtrlListBox_SelItemRange

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>

Example()

Func Example()
    Local $sText, $idListBox

    ; Create GUI
    GUICreate("List Box Sel Item RangeEx", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL))
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 10
        $sText = StringFormat("%03d : Random string ", Random(1, 100, 1))
        For $iX = 1 To Random(1, 20, 1)
            $sText &= Chr(Random(65, 90, 1))
        Next
        _GUICtrlListBox_AddString($idListBox, $sText)
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Select a few items
    _GUICtrlListBox_SelItemRangeEx($idListBox, 3, 5)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_SetAnchorIndex

Function Reference

_GUICtrlListBox_SetAnchorIndex

Set the anchor item—that is, the item from which a multiple selection starts

#include <GuiListBox.au3>
_GUICtrlListBox_SetAnchorIndex ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Specifies the 0-based index of the item

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListBox_GetAnchorIndex

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>

Example()

Func Example()
    Local $iIndex, $idListBox

    ; Create GUI
    GUICreate("List Box Set Anchor Index", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Set anchor index
    _GUICtrlListBox_SetAnchorIndex($idListBox, 2)

    ; Read anchor index
    $iIndex = _GUICtrlListBox_GetAnchorIndex($idListBox)
    _GUICtrlListBox_SetCurSel($idListBox, $iIndex)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_SetCaretIndex

Function Reference

_GUICtrlListBox_SetCaretIndex

Set the focus rectangle to the item at the specified index in a multiple-selection list box

#include <GuiListBox.au3>
_GUICtrlListBox_SetCaretIndex ( $hWnd, $iIndex [, $bPartial = False] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Specifies the 0-based index of the item
$bPartial | [optional] If False, the item is scrolled until it is fully visible. If it is True, the item is scrolled until it is at least partially visible.

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListBox_GetCaretIndex

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>

Example()

Func Example()
    Local $iIndex, $idListBox

    ; Create GUI
    GUICreate("List Box Set Caret Index", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Set caret index
    _GUICtrlListBox_SetCaretIndex($idListBox, 2)

    ; Read caret index
    $iIndex = _GUICtrlListBox_GetCaretIndex($idListBox)
    _GUICtrlListBox_SetCurSel($idListBox, $iIndex)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_SetColumnWidth

Function Reference

_GUICtrlListBox_SetColumnWidth

Set the width, in pixels, of all columns

#include <GuiListBox.au3>
_GUICtrlListBox_SetColumnWidth ( $hWnd, $iWidth )

Parameters

$hWnd | Control ID/Handle to the control
$iWidth | Specifies the width, in pixels, of all columns

Return Value

None.

Remarks

For use on controls created with the $LBS_MULTICOLUMN style.

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Set Column Width", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($LBS_STANDARD, $LBS_MULTICOLUMN))
    GUISetState(@SW_SHOW)

    ; Set the width of the columns
    _GUICtrlListBox_SetColumnWidth($idListBox, 100)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 50
        _GUICtrlListBox_AddString($idListBox, StringFormat("Item %03d", $iI))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_SetCurSel

Function Reference

_GUICtrlListBox_SetCurSel

Select a string and scroll it into view, if necessary

#include <GuiListBox.au3>
_GUICtrlListBox_SetCurSel ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Specifies the 0-based index of the string that is selected. If this parameter is -1 the list box is set to have no selection.

Return Value

Success: | True.
Failure: | False.

Remarks

Use this message only with single-selection list boxes.
You cannot use it to set or remove a selection in a multiple-selection list box.

Related

_GUICtrlListBox_GetCurSel

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Set Cur Sel", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Select an item
    _GUICtrlListBox_SetCurSel($idListBox, 4)

    ; Get currently selected item
    MsgBox($MB_SYSTEMMODAL, "Information", "Current selction: " & _GUICtrlListBox_GetCurSel($idListBox))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_SetHorizontalExtent

Function Reference

_GUICtrlListBox_SetHorizontalExtent

Set the width, in pixels, by which a list box can be scrolled horizontally

#include <GuiListBox.au3>
_GUICtrlListBox_SetHorizontalExtent ( $hWnd, $iWidth )

Parameters

$hWnd | Control ID/Handle to the control
$iWidth | Specifies the number of pixels the list box can be scrolled

Return Value

None.

Remarks

To respond to the _GUICtrlListBox_SetHorizontalExtent(), the list box must have been defined with the $WS_HSCROLL style.

Related

_GUICtrlListBox_GetHorizontalExtent

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Set Horizontal Extent", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_DISABLENOSCROLL, $WS_HSCROLL))
    GUISetState(@SW_SHOW)

    ; Add long string
    _GUICtrlListBox_AddString($idListBox, "AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI.")

    ; Show current horizontal extent
    MsgBox($MB_SYSTEMMODAL, "Information", "Horizontal Extent: " & _GUICtrlListBox_GetHorizontalExtent($idListBox))

    _GUICtrlListBox_SetHorizontalExtent($idListBox, 500)

    ; Show current horizontal extent
    MsgBox($MB_SYSTEMMODAL, "Information", "Horizontal Extent: " & _GUICtrlListBox_GetHorizontalExtent($idListBox))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_SetItemData

Function Reference

_GUICtrlListBox_SetItemData

Sets the value associated with the specified item

#include <GuiListBox.au3>
_GUICtrlListBox_SetItemData ( $hWnd, $iIndex, $iValue )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Specifies the 0-based index of the item
$iValue | Specifies the value to be associated with the item

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListBox_GetItemData

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

; Warning this should not be used on items created using built-in functions
; Item data is the controlID for each string

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Set Item Data", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Set item data
    _GUICtrlListBox_SetItemData($idListBox, 4, 1234)

    ; Get item data
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 5 Data: " & _GUICtrlListBox_GetItemData($idListBox, 4))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_SetItemHeight

Function Reference

_GUICtrlListBox_SetItemHeight

Sets the height, in pixels, of items

#include <GuiListBox.au3>
_GUICtrlListBox_SetItemHeight ( $hWnd, $iHeight [, $iIndex = 0] )

Parameters

$hWnd | Control ID/Handle to the control
$iHeight | Specifies the height, in pixels, of the item
$iIndex | [optional] Specifies the 0-based index of the item in the list box. Use this only if the control has the LBS_OWNERDRAWVARIABLE style otherwise, set it to zero.

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListBox_GetItemHeight

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Set Item Height", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Show item height
    MsgBox($MB_SYSTEMMODAL, "Information", "Item height: " & _GUICtrlListBox_GetItemHeight($idListBox))

    ; Set item height
    _GUICtrlListBox_SetItemHeight($idListBox, 26)

    ; Show item height
    MsgBox($MB_SYSTEMMODAL, "Information", "Item height: " & _GUICtrlListBox_GetItemHeight($idListBox))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_SetLocale

Function Reference

_GUICtrlListBox_SetLocale

Set the current locale

#include <GuiListBox.au3>
_GUICtrlListBox_SetLocale ( $hWnd, $iLocal )

Parameters

$hWnd | Control ID/Handle to the control
$iLocal | Specifies the locale identifier that the list box will use for sorting when adding text

Return Value

Success: | the previous locale identifier.
Failure: | -1.

Related

_GUICtrlListBox_GetLocale

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPILangConstants.au3>

Example()

Func Example()
    Local $iLocale, $idListBox

    ; Create GUI
    GUICreate("List Box Set Locale", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    $iLocale = _WinAPI_MAKELCID(_WinAPI_MAKELANGID($LANG_DUTCH, $SUBLANG_DUTCH), $SORT_DEFAULT)

    MsgBox($MB_SYSTEMMODAL, "Information", "Previous Locale: " & _GUICtrlListBox_SetLocale($idListBox, $iLocale))

    $iLocale = _WinAPI_MAKELCID(_WinAPI_MAKELANGID($LANG_ENGLISH, $SUBLANG_ENGLISH_US), $SORT_DEFAULT)

    MsgBox($MB_SYSTEMMODAL, "Information", "Previous Locale: " & _GUICtrlListBox_SetLocale($idListBox, $iLocale))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_SetSel

Function Reference

_GUICtrlListBox_SetSel

Select a string(s) in a multiple-selection list box

#include <GuiListBox.au3>
_GUICtrlListBox_SetSel ( $hWnd [, $iIndex = -1 [, $iSelect = -1]] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | [optional] Specifies the 0-based index of the item
$iSelect | [optional] Specifies how to set the selection.

Return Value

Success: | True.
Failure: | False.

Remarks

An $iIndex of -1 means to toggle select/unselect of all items (ignores the $iSelect).

Related

_GUICtrlListBox_GetSel

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Set Sel", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL))
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        _GUICtrlListBox_AddString($idListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Select a few items
    _GUICtrlListBox_SetSel($idListBox, 3)
    _GUICtrlListBox_SetSel($idListBox, 4)
    _GUICtrlListBox_SetSel($idListBox, 5)

    ; Show the item selection state
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 5 Selected: " & _GUICtrlListBox_GetSel($idListBox, 4))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_SetTabStops

Function Reference

_GUICtrlListBox_SetTabStops

Sets the tab-stop positions

#include <GuiListBox.au3>
_GUICtrlListBox_SetTabStops ( $hWnd, $aTabStops )

Parameters

$hWnd | Control ID/Handle to the control
$aTabStops | Array with the following format: [0] - Number of tab stops in the array (n) [1] - First tab stop [2] - Second tab stop [n] - Nth tab stop

Return Value

Success: | True.
Failure: | False.

Remarks

The integers in $aTabStops represent the number of quarters of the average character width for the font that is selected into the list box.
For example, a tab stop of 4 is placed at 1.0 character units, and a tab stop of 6 is placed at 1.5 average character units.
However, if the list box is part of a dialog box, the integers are in dialog template units.
The tab stops must be sorted in ascending order; backward tabs are not allowed.

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>

Example()

Func Example()
    Local $aTabs[4] = [3, 100, 200, 300], $idListBox

    ; Create GUI
    GUICreate("List Box Set Tab Stops", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($LBS_STANDARD, $LBS_USETABSTOPS))
    GUISetState(@SW_SHOW)

    ; Set tab stops
    _GUICtrlListBox_SetTabStops($idListBox, $aTabs)

    ; Add tabbed string
    _GUICtrlListBox_AddString($idListBox, "Column 1" & @TAB & "Column 2" & @TAB & "Column 3")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_SetTopIndex

Function Reference

_GUICtrlListBox_SetTopIndex

Ensure that a particular item in a list box is visible

#include <GuiListBox.au3>
_GUICtrlListBox_SetTopIndex ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Specifies the 0-based index of the item

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListBox_GetTopIndex

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $sText, $idListBox

    ; Create GUI
    GUICreate("List Box Set Top Index", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 100
        $sText = StringFormat("%03d : Random string ", $iI)
        For $iX = 1 To Random(1, 20, 1)
            $sText &= Chr(Random(65, 90, 1))
        Next
        _GUICtrlListBox_AddString($idListBox, $sText)
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Show top index
    MsgBox($MB_SYSTEMMODAL, "Information", "Top Index: " & _GUICtrlListBox_GetTopIndex($idListBox))

    ; Set top index
    _GUICtrlListBox_SetTopIndex($idListBox, 50)

    ; Show top index
    MsgBox($MB_SYSTEMMODAL, "Information", "Top Index: " & _GUICtrlListBox_GetTopIndex($idListBox))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_Sort

Function Reference

_GUICtrlListBox_Sort

Re-sorts list box if it has the $LBS_SORT style

#include <GuiListBox.au3>
_GUICtrlListBox_Sort ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Remarks

Re-sorts list box if it has the $LBS_SORT style.
Might be useful if you use _GUICtrlListBox_InsertString().

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $sText, $idListBox

    ; Create GUI
    GUICreate("List Box Sort", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL, $LBS_SORT))
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        $sText = StringFormat("%03d : Random string ", Random(1, 100, 1))
        For $iX = 1 To Random(1, 20, 1)
            $sText &= Chr(Random(65, 90, 1))
        Next
        _GUICtrlListBox_AddString($idListBox, $sText)
    Next
    _GUICtrlListBox_InsertString($idListBox, "This is a test", 0) ; doesn't auto sort when using insert
    _GUICtrlListBox_EndUpdate($idListBox)

    ; Sort'em
    MsgBox($MB_SYSTEMMODAL, "Information", "Sort Data")
    _GUICtrlListBox_Sort($idListBox)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_SwapString

Function Reference

_GUICtrlListBox_SwapString

Swaps the text of two items at the specified indices

#include <GuiListBox.au3>
_GUICtrlListBox_SwapString ( $hWnd, $iIndexA, $iIndexB )

Parameters

$hWnd | Control ID/Handle to the control
$iIndexA | 0-based index item to swap
$iIndexB | 0-based index item to swap

Return Value

Success: | True.
Failure: | False.

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $sText, $idListBox

    ; Create GUI
    GUICreate("List Box Swap String", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
    GUISetState(@SW_SHOW)

    ; Add strings
    _GUICtrlListBox_BeginUpdate($idListBox)
    For $iI = 1 To 9
        $sText = StringFormat("%03d : Random string ", Random(1, 100, 1))
        For $iX = 1 To Random(1, 20, 1)
            $sText &= Chr(Random(65, 90, 1))
        Next
        _GUICtrlListBox_AddString($idListBox, $sText)
    Next
    _GUICtrlListBox_EndUpdate($idListBox)

    ; swap the strings
    MsgBox($MB_SYSTEMMODAL, "Information", "Swapping Strings (3:5)")
    _GUICtrlListBox_SwapString($idListBox, 3, 5)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListBox_UpdateHScroll

Function Reference

_GUICtrlListBox_UpdateHScroll

Update the horizontal scroll bar based on the longest string

#include <GuiListBox.au3>
_GUICtrlListBox_UpdateHScroll ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

None.

Example

#include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idListBox

    ; Create GUI
    GUICreate("List Box Update HScroll", 400, 296)
    $idListBox = GUICtrlCreateList("", 2, 2, 396, 296, BitOR($LBS_NOTIFY, $LBS_SORT, $WS_HSCROLL, $WS_VSCROLL))
    GUISetState(@SW_SHOW)

    ; Add long string
    _GUICtrlListBox_AddString($idListBox, "AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI.")

    ; Show current horizontal extent
    MsgBox($MB_SYSTEMMODAL, "Information", "Horizontal Extent: " & _GUICtrlListBox_GetHorizontalExtent($idListBox))

    ; Adjust horizontal scroll bars
    _GUICtrlListBox_UpdateHScroll($idListBox)

    ; Show current horizontal extent
    MsgBox($MB_SYSTEMMODAL, "Information", "Horizontal Extent: " & _GUICtrlListBox_GetHorizontalExtent($idListBox))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


User Defined Functions

GuiListView user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiListView.au3>.

User Defined Function | Description
_GUICtrlListView_AddArray | Adds items from an array to the control
_GUICtrlListView_AddColumn | Adds a new column in the control
_GUICtrlListView_AddItem | Adds a new item to the end of the list
_GUICtrlListView_AddSubItem | Adds a new subitem to the control
_GUICtrlListView_ApproximateViewHeight | Calculates the approximate height required to display a given number of items
_GUICtrlListView_ApproximateViewRect | Calculates the approximate size required to display a given number of items
_GUICtrlListView_ApproximateViewWidth | Calculates the approximate width required to display a given number of items
_GUICtrlListView_Arrange | Arranges items in icon view
_GUICtrlListView_BeginUpdate | Prevents updating of the control until the _GUICtrlListView_EndUpdate() function is called
_GUICtrlListView_CancelEditLabel | Cancels an item text editing operation
_GUICtrlListView_ClickItem | Clicks an item
_GUICtrlListView_CopyItems | Copy Items between 2 list-view controls
_GUICtrlListView_Create | Create a ListView control
_GUICtrlListView_CreateDragImage | Creates a drag image list for the specified item
_GUICtrlListView_CreateSolidBitMap | Creates a solid color bitmap
_GUICtrlListView_DeleteAllItems | Removes all items from a list-view control
_GUICtrlListView_DeleteColumn | Removes a column from a list-view control
_GUICtrlListView_DeleteItem | Removes an item from a list-view control
_GUICtrlListView_DeleteItemsSelected | Deletes item(s) selected
_GUICtrlListView_Destroy | Delete the listview control
_GUICtrlListView_DrawDragImage | Draw the Drag Image
_GUICtrlListView_EditLabel | Begins in place editing of the specified item text
_GUICtrlListView_EnableGroupView | Enables or disables whether the items in the control display as a group
_GUICtrlListView_EndUpdate | Enables screen repainting that was turned off with the _GUICtrlListView_BeginUpdate() function
_GUICtrlListView_EnsureVisible | Ensures that a list-view item is either entirely or partially visible
_GUICtrlListView_FindInText | Searches for an item that contains the specified text anywhere in its text
_GUICtrlListView_FindItem | Searches for an item with the specified characteristics
_GUICtrlListView_FindNearest | Finds the item nearest to the position specified
_GUICtrlListView_FindParam | Searches for an item with the specified lParam
_GUICtrlListView_FindText | Searches for an item with the specified text
_GUICtrlListView_GetBkColor | Retrieves the background color of a list-view control
_GUICtrlListView_GetBkImage | Retrieves the background image in the control
_GUICtrlListView_GetCallbackMask | Retrieves the callback mask for the control
_GUICtrlListView_GetColumn | Retrieves the attributes of a column
_GUICtrlListView_GetColumnCount | Retrieve the number of columns
_GUICtrlListView_GetColumnOrder | Retrieves the current left-to-right order of columns
_GUICtrlListView_GetColumnOrderArray | Retrieves the current left-to-right order of columns in the control
_GUICtrlListView_GetColumnWidth | Retrieves the width of a column in report or list view
_GUICtrlListView_GetCounterPage | Calculates the number of items that can fit vertically in the visible area
_GUICtrlListView_GetEditControl | Retrieves the handle to the edit control being used to edit an item's text
_GUICtrlListView_GetExtendedListViewStyle | Retrieves the extended styles that are currently in use
_GUICtrlListView_GetFocusedGroup | Gets the group that has the focus
_GUICtrlListView_GetGroupCount | Gets the number of groups
_GUICtrlListView_GetGroupInfo | Retrieves group information
_GUICtrlListView_GetGroupInfoByIndex | Retrieves group information
_GUICtrlListView_GetGroupRect | Gets the rectangle for a specified group
_GUICtrlListView_GetGroupViewEnabled | Checks whether the control has group view enabled
_GUICtrlListView_GetHeader | Retrieves the handle to the header control
_GUICtrlListView_GetHotCursor | Retrieves the HCURSOR value used when the pointer is over an item while hot tracking is enabled
_GUICtrlListView_GetHotItem | Retrieves the index of the hot item
_GUICtrlListView_GetHoverTime | Retrieves the amount of time that the mouse cursor must hover over an item before it is selected
_GUICtrlListView_GetImageList | Retrieves the handle to an image list used for drawing listview items
_GUICtrlListView_GetISearchString | Retrieves the incremental search string of the control
_GUICtrlListView_GetItem | Retrieves an item's attributes
_GUICtrlListView_GetItemChecked | Returns the check state for a list-view control item
_GUICtrlListView_GetItemCount | Retrieves the number of items in a list-view control
_GUICtrlListView_GetItemCut | Determines whether the item is marked for a cut and paste operation
_GUICtrlListView_GetItemDropHilited | Determines whether the item is highlighted as a drag-and-drop target
_GUICtrlListView_GetItemEx | Retrieves some or all of an item's attributes
_GUICtrlListView_GetItemFocused | Determines whether the item is highlighted as a drag-and-drop target
_GUICtrlListView_GetItemGroupID | Gets the item group ID
_GUICtrlListView_GetItemImage | Retrieves the index of the item's icon
_GUICtrlListView_GetItemIndent | Retrieves the number of image widths the item is indented
_GUICtrlListView_GetItemParam | Retrieves the application specific value of the item
_GUICtrlListView_GetItemPosition | Retrieves the position of an item
_GUICtrlListView_GetItemPositionX | Retrieves the X position of an item
_GUICtrlListView_GetItemPositionY | Retrieves the Y position of an item
_GUICtrlListView_GetItemRect | Retrieves the bounding rectangle for all or part of an item
_GUICtrlListView_GetItemRectEx | Retrieves the bounding rectangle for all or part of an item
_GUICtrlListView_GetItemSelected | Determines whether the item is selected
_GUICtrlListView_GetItemSpacing | Determines the spacing between items in the control
_GUICtrlListView_GetItemSpacingX | Determines the horizontal spacing between items in the control
_GUICtrlListView_GetItemSpacingY | Determines the vertical spacing between items in the control
_GUICtrlListView_GetItemState | Retrieves the state of a listview item
_GUICtrlListView_GetItemStateImage | Gets the state image that is displayed
_GUICtrlListView_GetItemText | Retrieves the text of an item or subitem
_GUICtrlListView_GetItemTextArray | Retrieves all of a list-view item
_GUICtrlListView_GetItemTextString | Retrieves all of a list-view item
_GUICtrlListView_GetNextItem | Searches for an item that has the specified properties
_GUICtrlListView_GetNumberOfWorkAreas | Retrieves the number of working areas in the control
_GUICtrlListView_GetOrigin | Retrieves the current view origin for the control
_GUICtrlListView_GetOriginX | Retrieves the current horizontal view origin for the control
_GUICtrlListView_GetOriginY | Retrieves the current vertical view origin for the control
_GUICtrlListView_GetOutlineColor | Retrieves the color of the border of the control
_GUICtrlListView_GetSelectedColumn | Retrieves the index of the selected column
_GUICtrlListView_GetSelectedCount | Determines the number of selected items
_GUICtrlListView_GetSelectedIndices | Retrieve indices of selected item(s)
_GUICtrlListView_GetSelectionMark | Retrieves the selection mark from the control
_GUICtrlListView_GetStringWidth | Determines the width of a specified string
_GUICtrlListView_GetSubItemRect | Retrieves information about an item bounding rectangle
_GUICtrlListView_GetTextBkColor | Retrieves the text background color of the control
_GUICtrlListView_GetTextColor | Retrieves the text color of the control
_GUICtrlListView_GetToolTips | Retrieves the ToolTip control handle
_GUICtrlListView_GetTopIndex | Retrieves the index of the topmost visible item when in list or report view
_GUICtrlListView_GetUnicodeFormat | Retrieves the Unicode character format flag for the control
_GUICtrlListView_GetView | Retrieves the current view of the control
_GUICtrlListView_GetViewDetails | Determines whether the view mode is in detail mode
_GUICtrlListView_GetViewLarge | Determines whether the view mode is in large icon mode
_GUICtrlListView_GetViewList | Determines whether the view mode is in list mode
_GUICtrlListView_GetViewRect | Retrieves the bounding rectangle of all items in the control
_GUICtrlListView_GetViewSmall | Determines whether the view mode is in small icon mode
_GUICtrlListView_GetViewTile | Determines whether the view mode is in tile mode
_GUICtrlListView_HideColumn | Hides the column "sets column width to zero"
_GUICtrlListView_HitTest | Determines which item is at a specified position
_GUICtrlListView_InsertColumn | Inserts a new column in the control
_GUICtrlListView_InsertGroup | Inserts a group
_GUICtrlListView_InsertItem | Inserts a new item in the control
_GUICtrlListView_JustifyColumn | Set Justification of a column for a list-view control
_GUICtrlListView_MapIDToIndex | Maps the ID of an item to an index
_GUICtrlListView_MapIndexToID | Maps an index to an item ID
_GUICtrlListView_RedrawItems | Forces the control to redraw a range of items
_GUICtrlListView_RegisterSortCallBack | Register the Simple Sort callback function
_GUICtrlListView_RemoveAllGroups | Removes all groups from the control
_GUICtrlListView_RemoveGroup | Removes a group from the control
_GUICtrlListView_Scroll | Scrolls the content of a list-view
_GUICtrlListView_SetBkColor | Sets the background color of the control
_GUICtrlListView_SetBkImage | Sets the background image in the control
_GUICtrlListView_SetCallBackMask | Changes the callback mask for the control
_GUICtrlListView_SetColumn | Sets the attributes of a column
_GUICtrlListView_SetColumnOrder | Sets the left-to-right order of columns
_GUICtrlListView_SetColumnOrderArray | Sets the left-to-right order of columns in the control
_GUICtrlListView_SetColumnWidth | Changes the width of a column
_GUICtrlListView_SetExtendedListViewStyle | Sets extended styles
_GUICtrlListView_SetGroupInfo | Sets group information
_GUICtrlListView_SetHotItem | Sets the hot item
_GUICtrlListView_SetHoverTime | Sets the amount of time which the mouse cursor must hover over an item before it is selected
_GUICtrlListView_SetIconSpacing | Sets the spacing between icons where the style is large icon
_GUICtrlListView_SetImageList | Assigns an image list to the control
_GUICtrlListView_SetItem | Sets some or all of a item's attributes
_GUICtrlListView_SetItemChecked | Sets the checked state
_GUICtrlListView_SetItemCount | Causes the list-view control to allocate memory for the specified number of items
_GUICtrlListView_SetItemCut | Sets whether the item is marked for a cut-and-paste operation
_GUICtrlListView_SetItemDropHilited | Sets whether the item is highlighted as a drag-and-drop target
_GUICtrlListView_SetItemEx | Sets some or all of a item's attributes
_GUICtrlListView_SetItemFocused | Sets whether the item has the focus
_GUICtrlListView_SetItemGroupID | Sets the item group ID
_GUICtrlListView_SetItemImage | Sets the index of the item's icon in the control's image list
_GUICtrlListView_SetItemIndent | Sets the number of image widths to indent the item
_GUICtrlListView_SetItemParam | Sets the value specific to the item
_GUICtrlListView_SetItemPosition | Moves an item to a specified position in the control
_GUICtrlListView_SetItemPosition32 | Moves an item to a specified position in the control
_GUICtrlListView_SetItemSelected | Sets whether the item is selected
_GUICtrlListView_SetItemState | Changes the state of an item in the control
_GUICtrlListView_SetItemStateImage | Sets the state image that is displayed
_GUICtrlListView_SetItemText | Changes the text of an item or subitem
_GUICtrlListView_SetOutlineColor | Sets the color of the border
_GUICtrlListView_SetSelectedColumn | Sets the index of the selected column
_GUICtrlListView_SetSelectionMark | Sets the selection mark in the control
_GUICtrlListView_SetTextBkColor | Sets the background color of text in the control
_GUICtrlListView_SetTextColor | Sets the color of text in the control
_GUICtrlListView_SetToolTips | Sets the ToolTip control that the control will use to display ToolTips
_GUICtrlListView_SetUnicodeFormat | Sets the UNICODE character format flag for the control
_GUICtrlListView_SetView | Sets the view of the control
_GUICtrlListView_SetWorkAreas | Creates a work area within the control
_GUICtrlListView_SimpleSort | Sorts a list-view control (limited)
_GUICtrlListView_SortItems | Starts the sort call back, also sets the Arrow in the Header
_GUICtrlListView_SubItemHitTest | Determines which listview item or subitem is at a given position
_GUICtrlListView_UnRegisterSortCallBack | UnRegister the Sort callback function


Function _GUICtrlListView_AddArray

Function Reference

_GUICtrlListView_AddArray

Adds items from an array to the control

#include <GuiListView.au3>
_GUICtrlListView_AddArray ( $hWnd, ByRef $aItems )

Parameters

$hWnd | Control ID/Handle to the control
$aItems | Array with the following format: [0][0] - Item 1 Text [0][1] - Item 1 Subitem 1 text [0][2] - Item 1 Subitem 2 text [0][n] - Item 1 Subitem n text [1][0] - Item 2 Text [1][1] - Item 2 Subitem 1 text [1][2] - Item 2 Subitem 2 text [1][n] - Item 2 Subitem n text

Return Value

None.

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iI, $iTimer, $idListview

    ; Create GUI
    GUICreate("ListView Add Array", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)
    _GUICtrlListView_AddColumn($idListview, "SubItems 1", 100)
    _GUICtrlListView_AddColumn($idListview, "SubItems 2", 100)
    _GUICtrlListView_AddColumn($idListview, "SubItems 3", 100)

    _GUICtrlListView_SetItemCount($idListview, 5000)

    ; One column load
    Local $aItems[5000][1]
    For $iI = 0 To UBound($aItems) - 1
        $aItems[$iI][0] = "Item " & $iI
    Next
    $iTimer = TimerInit()
    _GUICtrlListView_AddArray($idListview, $aItems)
    MsgBox($MB_SYSTEMMODAL, "Information", "Load time: " & TimerDiff($iTimer) / 1000 & " seconds")

    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($idListview)) ; items added with UDF function can be deleted using UDF function

    ; Four column load
    Local $aItems[5000][4]
    For $iI = 0 To UBound($aItems) - 1
        $aItems[$iI][0] = "Item " & $iI
        $aItems[$iI][1] = "Item " & $iI & "-1"
        $aItems[$iI][2] = "Item " & $iI & "-2"
        $aItems[$iI][3] = "Item " & $iI & "-3"
    Next
    $iTimer = TimerInit()
    _GUICtrlListView_AddArray($idListview, $aItems)
    MsgBox($MB_SYSTEMMODAL, "Information", "Load time: " & TimerDiff($iTimer) / 1000 & " seconds")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_AddColumn

Function Reference

_GUICtrlListView_AddColumn

Adds a new column in the control

#include <GuiListView.au3>
_GUICtrlListView_AddColumn ( $hWnd, $sText [, $iWidth = 50 [, $iAlign = -1 [, $iImage = -1 [, $bOnRight = False]]]] )

Parameters

$hWnd | Control ID/Handle to the control
$sText | Column header text
$iWidth | [optional] Width of the column, in pixels
$iAlign | [optional] Alignment of the column header and the subitem text in the column: 0 - Text is left aligned 1 - Text is right aligned 2 - Text is centered
$iImage | [optional] 0-based index of an image within the image list
$bOnRight | [optional] If True, the column image appears to the right of text

Return Value

Success: | the index of the new column.
Failure: | -1.

Remarks

The alignment of the leftmost column is always left justified.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>

Example()

Func Example()
    Local $hImage, $idListview

    ; Create GUI
    GUICreate("ListView Add Column", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)

    ; Enable extended control styles
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 110)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 110)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 110)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_AddItem

Function Reference

_GUICtrlListView_AddItem

Adds a new item to the end of the list

#include <GuiListView.au3>
_GUICtrlListView_AddItem ( $hWnd, $sText [, $iImage = -1 [, $iParam = 0]] )

Parameters

$hWnd | Control ID/Handle to the control
$sText | Item text. If set to -1, the item set is set via the $LVN_GETDISPINFO notification message.
$iImage | [optional] 0-based index of the item's icon in the control's image list
$iParam | [optional] Application Defined data

Return Value

Success: | the index of the new item.
Failure: | -1

Remarks

You can not use this function to insert subitems. Use _GUICtrlListView_AddSubItem() to insert subitems.

As AutoIt uses the $iParam parameter to store the controlID of native-created ListView items, this value should be set sufficiently high for UDF-created items to avoid possible conflict with any existing controls - a starting value of 1000 is recommended.

Related

_GUICtrlListView_AddSubItem

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>

Example()

Func Example()
    Local $hImage, $idListview

    ; Create GUI
    GUICreate("ListView Add Item", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($idListview, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($idListview, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($idListview, 2, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_AddSubItem

Function Reference

_GUICtrlListView_AddSubItem

Adds a new subitem to the control

#include <GuiListView.au3>
_GUICtrlListView_AddSubItem ( $hWnd, $iIndex, $sText, $iSubItem [, $iImage = -1] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item
$sText | Item or subitem text
$iSubItem | 1-based index of the subitem
$iImage | [optional] 0-based index of the icon in the control's image list

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_AddItem

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>

Example()

Func Example()
    Local $hImage, $idListview

    ; Create GUI
    GUICreate("ListView Add SubItem", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, -1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($idListview, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($idListview, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($idListview, 2, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_ApproximateViewHeight

Function Reference

_GUICtrlListView_ApproximateViewHeight

Calculates the approximate height required to display a given number of items

#include <GuiListView.au3>
_GUICtrlListView_ApproximateViewHeight ( $hWnd [, $iCount = -1 [, $iCX = -1 [, $iCY = -1]]] )

Parameters

$hWnd | Control ID/Handle to the control
$iCount | [optional] Number of items to be displayed in the control. If this parameter is set to -1 the message uses the total number of items in the control.
$iCX | [optional] Proposed X dimension of the control, in pixels. This parameter can be set to -1 to allow the message to use the current width value.
$iCY | [optional] Proposed Y dimension of the control, in pixels. This parameter can be set to -1 to allow the message to use the current height value.

Return Value

Returns the Approximate height, in pixels, needed to display the items.

Remarks

Setting the size of the control based on the dimensions provided by this message can optimize redraw and reduce flicker.

Related

_GUICtrlListView_ApproximateViewRect, _GUICtrlListView_ApproximateViewWidth

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iY, $idListview

    GUICreate("ListView Approximate View Height", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add column
    _GUICtrlListView_InsertColumn($idListview, 0, "Column 1", 100)

    ; Add items
    For $iI = 0 To 9
        _GUICtrlListView_AddItem($idListview, "Row " & $iI)
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Approximate View Height")
    ; Resize view height
    $iY = _GUICtrlListView_ApproximateViewHeight($idListview)
    _WinAPI_SetWindowPos(GUICtrlGetHandle($idListview), 0, 2, 2, 394, $iY, $SWP_NOZORDER)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_ApproximateViewRect

Function Reference

_GUICtrlListView_ApproximateViewRect

Calculates the approximate size required to display a given number of items

#include <GuiListView.au3>
_GUICtrlListView_ApproximateViewRect ( $hWnd [, $iCount = -1 [, $iCX = -1 [, $iCY = -1]]] )

Parameters

$hWnd | Control ID/Handle to the control
$iCount | [optional] Number of items to be displayed in the control. If this parameter is set to -1 the message uses the total number of items in the control.
$iCX | [optional] Proposed X dimension of the control, in pixels. This parameter can be set to -1 to allow the message to use the current width value.
$iCY | [optional] Proposed Y dimension of the control, in pixels. This parameter can be set to -1 to allow the message to use the current height value.

Return Value

Returns an array with the following format:
[0] - Approximate width, in pixels, needed to display the items
[1] - Approximate height, in pixels, needed to display the items

Remarks

Setting the size of the control based on the dimensions provided by this message can optimize redraw and reduce flicker.

Related

_GUICtrlListView_ApproximateViewHeight, _GUICtrlListView_ApproximateViewWidth

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aXY, $idListview

    GUICreate("ListView Approximate View Rect", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add column
    _GUICtrlListView_InsertColumn($idListview, 0, "Column 1", 100)

    ; Add items
    For $iI = 0 To 9
        _GUICtrlListView_AddItem($idListview, "Row " & $iI)
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Approximate View Rect")
    ; Resize view
    $aXY = _GUICtrlListView_ApproximateViewRect($idListview)
    _WinAPI_SetWindowPos(GUICtrlGetHandle($idListview), 0, 2, 2, $aXY[0], $aXY[1], $SWP_NOZORDER)
    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_ApproximateViewWidth

Function Reference

_GUICtrlListView_ApproximateViewWidth

Calculates the approximate width required to display a given number of items

#include <GuiListView.au3>
_GUICtrlListView_ApproximateViewWidth ( $hWnd [, $iCount = -1 [, $iCX = -1 [, $iCY = -1]]] )

Parameters

$hWnd | Control ID/Handle to the control
$iCount | [optional] Number of items to be displayed in the control. If this parameter is set to -1 the message uses the total number of items in the control
$iCX | [optional] Proposed X dimension of the control, in pixels. This parameter can be set to -1 to allow the message to use the current width value.
$iCY | [optional] Proposed Y dimension of the control, in pixels. This parameter can be set to -1 to allow the message to use the current height value.

Return Value

Return the Approximate width, in pixels, needed to display the items.

Remarks

Setting the size of the control based on the dimensions provided by this message can optimize redraw and reduce flicker.

Related

_GUICtrlListView_ApproximateViewHeight, _GUICtrlListView_ApproximateViewRect

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iX, $idListview

    GUICreate("ListView Approximate View Width", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add column
    _GUICtrlListView_InsertColumn($idListview, 0, "Column 1", 100)

    ; Add items
    For $iI = 0 To 9
        _GUICtrlListView_AddItem($idListview, "Row " & $iI)
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Approximate View Width")
    ; Resize view width
    $iX = _GUICtrlListView_ApproximateViewWidth($idListview)
    _WinAPI_SetWindowPos(GUICtrlGetHandle($idListview), 0, 2, 2, $iX, 268, $SWP_NOZORDER)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_Arrange

Function Reference

_GUICtrlListView_Arrange

Arranges items in icon view

#include <GuiListView.au3>
_GUICtrlListView_Arrange ( $hWnd [, $iArrange = 0] )

Parameters

$hWnd | Control ID/Handle to the control
$iArrange | [optional] Alignment. This can be one of the following values: 0 - Aligns items according to the controls default value 1 - Aligns items along the left edge of the window 2 - Aligns items along the top edge of the window 3 - Snaps all icons to the nearest grid position.

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_SetItemPosition

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Arrange", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_InsertColumn($idListview, 0, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Move item 2
    _GUICtrlListView_SetView($idListview, 3)
    _GUICtrlListView_SetItemPosition($idListview, 1, 100, 100)

    MsgBox($MB_SYSTEMMODAL, "Information", "Arranging items")
    _GUICtrlListView_Arrange($idListview)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_BeginUpdate

Function Reference

_GUICtrlListView_BeginUpdate

Prevents updating of the control until the _GUICtrlListView_EndUpdate() function is called

#include <GuiListView.au3>
_GUICtrlListView_BeginUpdate ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_EndUpdate

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Begin Update", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUICtrlSetStyle($idListview, $LVS_ICON)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(32, 32)
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0xFF0000, 32, 32))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x00FF00, 32, 32))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x0000FF, 32, 32))
    _GUICtrlListView_SetImageList($idListview, $hImage, 0)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Red", 0)
        _GUICtrlListView_AddItem($idListview, "Green", 1)
        _GUICtrlListView_AddItem($idListview, "Blue", 2)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_CancelEditLabel

Function Reference

_GUICtrlListView_CancelEditLabel

Cancels an item text editing operation

#include <GuiListView.au3>
_GUICtrlListView_CancelEditLabel ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

None.

Related

_GUICtrlListView_EditLabel, _GUICtrlListView_GetEditControl

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Global $g_idListView

Example()

Func Example()
    Local $hImage, $iTime

    GUICreate("ListView Cancel Edit", 392, 322)
    $g_idListView = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_EDITLABELS, $LVS_REPORT))
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($g_idListView), 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($g_idListView), 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($g_idListView), 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($g_idListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($g_idListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($g_idListView, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($g_idListView, 2, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($g_idListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($g_idListView, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($g_idListView, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($g_idListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($g_idListView, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($g_idListView, "Row 3: Col 1", 2)

    ; Edit item 0 label with time out
    _GUICtrlListView_EditLabel($g_idListView, 0)
    $iTime = TimerInit()

    ; Loop until the user exits.
    Do
        If _GUICtrlListView_GetEditControl($g_idListView) <> 0 Then
            If TimerDiff($iTime) > 3000 Then _GUICtrlListView_CancelEditLabel($g_idListView)
        EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    $hWndListView = $g_idListView
    If Not IsHWnd($g_idListView) Then $hWndListView = GUICtrlGetHandle($g_idListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $LVN_COLUMNCLICK ; A column was clicked
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    _DebugPrint("$LVN_COLUMNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    ; No return value
                Case $LVN_ITEMCHANGING ; An item is changing
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    _DebugPrint("$LVN_ITEMCHANGING" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    Return True ; prevent the change
                    ;Return False ; allow the change
                Case $LVN_KEYDOWN ; A key has been pressed
                    $tInfo = DllStructCreate($tagNMLVKEYDOWN, $lParam)
                    _DebugPrint("$LVN_KEYDOWN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->VKey:" & @TAB & DllStructGetData($tInfo, "VKey") & @CRLF & _
                            "-->Flags:" & @TAB & DllStructGetData($tInfo, "Flags"))
                    ; No return value
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_KILLFOCUS ; The control has lost the input focus
                    _DebugPrint("$NM_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ;Return 1 ; not to allow the default processing
                    Return 0 ; allow the default processing
                Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
                    _DebugPrint("$NM_RETURN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_SETFOCUS ; The control has received the input focus
                    _DebugPrint("$NM_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlListView_ClickItem

Function Reference

_GUICtrlListView_ClickItem

Clicks an item

#include <GuiListView.au3>
_GUICtrlListView_ClickItem ( $hWnd, $iIndex [, $sButton = "left" [, $bMove = False [, $iClicks = 1 [, $iSpeed = 1]]]] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item
$sButton | [optional] Button to click
$bMove | [optional] If True, the mouse will be moved. If False, the mouse does not move.
$iClicks | [optional] Number of clicks
$iSpeed | [optional] Delay between clicks

Return Value

None.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Global $g_idListView

Example()

Func Example()
    Local $hImage

    ; Create GUI
    GUICreate("ListView Click Item", 400, 300)
    $g_idListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($g_idListView), 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($g_idListView), 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($g_idListView), 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($g_idListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($g_idListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($g_idListView, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($g_idListView, 2, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($g_idListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddItem($g_idListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddItem($g_idListView, "Row 3: Col 1", 2)

    _GUICtrlListView_ClickItem($g_idListView, 1, "left", False, 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    $hWndListView = $g_idListView
    If Not IsHWnd($g_idListView) Then $hWndListView = GUICtrlGetHandle($g_idListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ;Return 1 ; not to allow the default processing
                    Return 0 ; allow the default processing
                Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlListView_CopyItems

Function Reference

_GUICtrlListView_CopyItems

Copy Items between 2 list-view controls

#include <GuiListView.au3>
_GUICtrlListView_CopyItems ( $hWnd_Source, $hWnd_Destination [, $bDelFlag = False] )

Parameters

$hWnd_Source | Control ID/Handle to the control of the source
$hWnd_Destination | Control ID/Handle to the control of the destination
$bDelFlag | [optional] Delete after copying

Return Value

None.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
Global $g_hListView, $g_hListView2, $g_hGUI1, $g_hGUI2, $g_iRun = 1
Global $g_iDock = 1, $g_iDock_Location = 1, $g_iX1, $g_iX2, $g_iY1, $g_iY2
Global $g_idOptionsItem2, $g_idOptionsItem3, $g_idOptionsItem4
Global $g_idOptions2Item2, $g_idOptions2Item3, $g_idOptions2Item4

Example()

Func Example()
    $g_iRun = 1
    Local $idOptionsMenu, $idOptionsItem1, $idOptions2Menu, $idOptions2Item1, $iWidth = 450
    Local $id_MoveLeft, $id_MoveRight, $id_Exit1, $id_Exit2
    Local $id_CopyRight, $id_CopyLeft, $hImage
    Local $iStylesEx = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_SUBITEMIMAGES)

    $g_hGUI1 = GUICreate("(External) ListView Copy Items", $iWidth, 300, 10, 10)
    $idOptionsMenu = GUICtrlCreateMenu("Options")
    $idOptionsItem1 = GUICtrlCreateMenu("Docking", $idOptionsMenu)

    $g_idOptionsItem2 = GUICtrlCreateMenuItem("Docked", $idOptionsItem1)
    GUICtrlCreateMenuItem("", $idOptionsItem1)
    $g_idOptionsItem3 = GUICtrlCreateMenuItem("Side By Side", $idOptionsItem1)
    $g_idOptionsItem4 = GUICtrlCreateMenuItem("Top And Bottom", $idOptionsItem1)
    GUICtrlSetState($g_idOptionsItem2, $GUI_CHECKED)
    GUICtrlSetState($g_idOptionsItem3, $GUI_CHECKED)
    GUICtrlSetOnEvent($g_idOptionsItem2, "_SetDocking")
    GUICtrlSetOnEvent($g_idOptionsItem3, "_SetDockSideBySide")
    GUICtrlSetOnEvent($g_idOptionsItem4, "_SetDockTopAndBottom")

    GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
    GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
    GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")

    ; need the handle because UDF function(s) are used to create the items
    $g_hListView = GUICtrlGetHandle(GUICtrlCreateListView("", 2, 2, $iWidth - 100, 268, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE))
    _GUICtrlListView_SetExtendedListViewStyle($g_hListView, $iStylesEx)

    $id_MoveRight = GUICtrlCreateButton("Move", $iWidth - 95, 35, 90, 20)
    GUICtrlSetOnEvent($id_MoveRight, "_MoveRight")

    $id_CopyRight = GUICtrlCreateButton("Copy", $iWidth - 95, 60, 90, 20)
    GUICtrlSetOnEvent($id_CopyRight, "_CopyRight")

    $id_Exit1 = GUICtrlCreateButton("Exit", $iWidth - 95, 140, 90, 25)
    GUICtrlSetOnEvent($id_Exit1, "_Exit")

    $g_hGUI2 = GUICreate("Right/Bottom Window", $iWidth, 300, $iWidth + 15, 10)

    $idOptions2Menu = GUICtrlCreateMenu("Options")
    $idOptions2Item1 = GUICtrlCreateMenu("Docking", $idOptions2Menu)
    $g_idOptions2Item2 = GUICtrlCreateMenuItem("Docked", $idOptions2Item1)
    GUICtrlCreateMenuItem("", $idOptions2Item1)
    $g_idOptions2Item3 = GUICtrlCreateMenuItem("Side By Side", $idOptions2Item1)
    $g_idOptions2Item4 = GUICtrlCreateMenuItem("Top And Bottom", $idOptions2Item1)
    GUICtrlSetState($g_idOptions2Item2, $GUI_CHECKED)
    GUICtrlSetState($g_idOptions2Item3, $GUI_CHECKED)
    GUICtrlSetOnEvent($g_idOptions2Item2, "_SetDocking2")
    GUICtrlSetOnEvent($g_idOptions2Item3, "_SetDockSideBySide2")
    GUICtrlSetOnEvent($g_idOptions2Item4, "_SetDockTopAndBottom2")

    GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
    GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
    GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")

    $g_hListView2 = GUICtrlGetHandle(GUICtrlCreateListView("", 2, 2, $iWidth - 100, 268, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE))
    _GUICtrlListView_SetExtendedListViewStyle($g_hListView2, $iStylesEx)

    $id_MoveLeft = GUICtrlCreateButton("Move", $iWidth - 95, 35, 90, 20)
    GUICtrlSetOnEvent($id_MoveLeft, "_MoveLeft")

    $id_CopyLeft = GUICtrlCreateButton("Copy", $iWidth - 95, 60, 90, 20)
    GUICtrlSetOnEvent($id_CopyLeft, "_CopyLeft")

    $id_Exit2 = GUICtrlCreateButton("Exit", $iWidth - 95, 140, 90, 25)
    GUICtrlSetOnEvent($id_Exit2, "_Exit")

    GUISetState(@SW_SHOW, $g_hGUI2)
    GUISetState(@SW_SHOW, $g_hGUI1)

    ; Load images
    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 13)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 14)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 15)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 16)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 17)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 18)
    _GUICtrlListView_SetImageList($g_hListView, $hImage, 1)
    _GUICtrlListView_SetImageList($g_hListView2, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($g_hListView, "Column 1", 120)
    _GUICtrlListView_AddColumn($g_hListView, "Column 2", 100)
    _GUICtrlListView_AddColumn($g_hListView, "Column 3", 100)

    ; Add columns
    _GUICtrlListView_AddColumn($g_hListView2, "Column 1", 120)
    _GUICtrlListView_AddColumn($g_hListView2, "Column 2", 100)
    _GUICtrlListView_AddColumn($g_hListView2, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($g_hListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($g_hListView, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($g_hListView, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($g_hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($g_hListView, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($g_hListView, "Row 3: Col 1", 2)
    _GUICtrlListView_AddItem($g_hListView, "Row 4: Col 1", 3)
    _GUICtrlListView_AddItem($g_hListView, "Row 5: Col 1", 4)
    _GUICtrlListView_AddSubItem($g_hListView, 4, "Row 5: Col 2", 1, 3)
    _GUICtrlListView_AddItem($g_hListView, "Row 6: Col 1", 5)
    _GUICtrlListView_AddSubItem($g_hListView, 5, "Row 6: Col 2", 1, 4)
    _GUICtrlListView_AddSubItem($g_hListView, 5, "Row 6: Col 3", 2, 3)

    While $g_iRun
        If $g_iDock Then _KeepWindowsDocked()
        Sleep(10)
    WEnd
EndFunc   ;==>Example

Func _SetDocking()
    If BitAND(GUICtrlRead($g_idOptionsItem2), $GUI_CHECKED) = $GUI_CHECKED Then
        GUICtrlSetState($g_idOptionsItem2, $GUI_UNCHECKED)
        GUICtrlSetState($g_idOptions2Item2, $GUI_UNCHECKED)
        $g_iDock = 0
    Else
        GUICtrlSetState($g_idOptionsItem2, $GUI_CHECKED)
        GUICtrlSetState($g_idOptions2Item2, $GUI_CHECKED)
        $g_iDock = 2
    EndIf
    If $g_iDock Then _KeepWindowsDocked()
EndFunc   ;==>_SetDocking

Func _SetDocking2()
    If BitAND(GUICtrlRead($g_idOptions2Item2), $GUI_CHECKED) = $GUI_CHECKED Then
        GUICtrlSetState($g_idOptionsItem2, $GUI_UNCHECKED)
        GUICtrlSetState($g_idOptions2Item2, $GUI_UNCHECKED)
        $g_iDock = 0
    Else
        GUICtrlSetState($g_idOptionsItem2, $GUI_CHECKED)
        GUICtrlSetState($g_idOptions2Item2, $GUI_CHECKED)
        $g_iDock = 2
    EndIf
    If $g_iDock Then _KeepWindowsDocked()
EndFunc   ;==>_SetDocking2

Func _SetDockSideBySide()
    If BitAND(GUICtrlRead($g_idOptionsItem3), $GUI_CHECKED) = $GUI_CHECKED Then
        GUICtrlSetState($g_idOptionsItem3, $GUI_UNCHECKED)
        GUICtrlSetState($g_idOptionsItem4, $GUI_CHECKED)
        GUICtrlSetState($g_idOptions2Item3, $GUI_UNCHECKED)
        GUICtrlSetState($g_idOptions2Item4, $GUI_CHECKED)
        $g_iDock_Location = 2
    Else
        GUICtrlSetState($g_idOptionsItem3, $GUI_CHECKED)
        GUICtrlSetState($g_idOptionsItem4, $GUI_UNCHECKED)
        GUICtrlSetState($g_idOptions2Item3, $GUI_CHECKED)
        GUICtrlSetState($g_idOptions2Item4, $GUI_UNCHECKED)
        $g_iDock_Location = 1
        If $g_iDock Then $g_iDock = 2
    EndIf
    If $g_iDock Then _KeepWindowsDocked()
EndFunc   ;==>_SetDockSideBySide

Func _SetDockSideBySide2()
    If BitAND(GUICtrlRead($g_idOptions2Item3), $GUI_CHECKED) = $GUI_CHECKED Then
        GUICtrlSetState($g_idOptionsItem3, $GUI_UNCHECKED)
        GUICtrlSetState($g_idOptionsItem4, $GUI_CHECKED)
        GUICtrlSetState($g_idOptions2Item3, $GUI_UNCHECKED)
        GUICtrlSetState($g_idOptions2Item4, $GUI_CHECKED)
        $g_iDock_Location = 2
    Else
        GUICtrlSetState($g_idOptionsItem3, $GUI_CHECKED)
        GUICtrlSetState($g_idOptionsItem4, $GUI_UNCHECKED)
        GUICtrlSetState($g_idOptions2Item3, $GUI_CHECKED)
        GUICtrlSetState($g_idOptions2Item4, $GUI_UNCHECKED)
        $g_iDock_Location = 1
        If $g_iDock Then $g_iDock = 2
    EndIf
    If $g_iDock Then _KeepWindowsDocked()
EndFunc   ;==>_SetDockSideBySide2

Func _SetDockTopAndBottom()
    If BitAND(GUICtrlRead($g_idOptionsItem4), $GUI_CHECKED) = $GUI_CHECKED Then
        GUICtrlSetState($g_idOptionsItem4, $GUI_UNCHECKED)
        GUICtrlSetState($g_idOptionsItem3, $GUI_CHECKED)
        GUICtrlSetState($g_idOptions2Item4, $GUI_UNCHECKED)
        GUICtrlSetState($g_idOptions2Item3, $GUI_CHECKED)
        $g_iDock_Location = 1
    Else
        GUICtrlSetState($g_idOptionsItem4, $GUI_CHECKED)
        GUICtrlSetState($g_idOptionsItem3, $GUI_UNCHECKED)
        GUICtrlSetState($g_idOptions2Item4, $GUI_CHECKED)
        GUICtrlSetState($g_idOptions2Item3, $GUI_UNCHECKED)
        $g_iDock_Location = 2
        If $g_iDock Then $g_iDock = 2
    EndIf
    If $g_iDock Then _KeepWindowsDocked()
EndFunc   ;==>_SetDockTopAndBottom

Func _SetDockTopAndBottom2()
    If BitAND(GUICtrlRead($g_idOptions2Item4), $GUI_CHECKED) = $GUI_CHECKED Then
        GUICtrlSetState($g_idOptionsItem4, $GUI_UNCHECKED)
        GUICtrlSetState($g_idOptionsItem3, $GUI_CHECKED)
        GUICtrlSetState($g_idOptions2Item4, $GUI_UNCHECKED)
        GUICtrlSetState($g_idOptions2Item3, $GUI_CHECKED)
        $g_iDock_Location = 1
    Else
        GUICtrlSetState($g_idOptionsItem4, $GUI_CHECKED)
        GUICtrlSetState($g_idOptionsItem3, $GUI_UNCHECKED)
        GUICtrlSetState($g_idOptions2Item4, $GUI_CHECKED)
        GUICtrlSetState($g_idOptions2Item3, $GUI_UNCHECKED)
        $g_iDock_Location = 2
        If $g_iDock Then $g_iDock = 2
    EndIf
    If $g_iDock Then _KeepWindowsDocked()
EndFunc   ;==>_SetDockTopAndBottom2

Func _KeepWindowsDocked()
    Local $a_PosWin1 = WinGetPos($g_hGUI1)
    Local $a_PosWin2 = WinGetPos($g_hGUI2)
    If $g_iDock_Location == 1 Then
        If (($a_PosWin1[0] <> $g_iX1 Or $a_PosWin1[1] <> $g_iY1) And BitAND(WinGetState($g_hGUI1), 8) Or $g_iDock = 2) Then
            $g_iX1 = $a_PosWin1[0]
            $g_iY1 = $a_PosWin1[1]
            $g_iX2 = $a_PosWin1[2] + $g_iX1
            $g_iY2 = $g_iY1
            WinMove($g_hGUI2, "", $g_iX2, $g_iY2)
            $g_iDock = 1
        ElseIf (($a_PosWin2[0] <> $g_iX2 Or $a_PosWin2[1] <> $g_iY2) And BitAND(WinGetState($g_hGUI2), 8)) Then
            $g_iX2 = $a_PosWin2[0]
            $g_iY2 = $a_PosWin2[1]
            $g_iX1 = $a_PosWin2[0] - $a_PosWin1[2]
            $g_iY1 = $g_iY2
            WinMove($g_hGUI1, "", $g_iX1, $g_iY1)
        EndIf
    Else
        If (($a_PosWin1[0] <> $g_iX1 Or $a_PosWin1[1] <> $g_iY1) And BitAND(WinGetState($g_hGUI1), 8) Or $g_iDock = 2) Then
            $g_iX1 = $a_PosWin1[0]
            $g_iY1 = $a_PosWin1[1]
            $g_iX2 = $g_iX1
            $g_iY2 = $a_PosWin1[3] + $g_iY1
            WinMove($g_hGUI2, "", $g_iX2, $g_iY2)
            $g_iDock = 1
        ElseIf (($a_PosWin2[0] <> $g_iX2 Or $a_PosWin2[1] <> $g_iY2) And BitAND(WinGetState($g_hGUI2), 8)) Then
            $g_iX2 = $a_PosWin2[0]
            $g_iY2 = $a_PosWin2[1]
            $g_iX1 = $g_iX2
            $g_iY1 = $a_PosWin2[1] - $a_PosWin1[3]
            WinMove($g_hGUI1, "", $g_iX1, $g_iY1)
        EndIf
    EndIf
EndFunc   ;==>_KeepWindowsDocked

Func _CopyRight()
    _GUICtrlListView_CopyItems($g_hListView, $g_hListView2)
EndFunc   ;==>_CopyRight

Func _MoveRight()
    _GUICtrlListView_CopyItems($g_hListView, $g_hListView2, 1)
EndFunc   ;==>_MoveRight

Func _CopyLeft()
    _GUICtrlListView_CopyItems($g_hListView2, $g_hListView)
EndFunc   ;==>_CopyLeft

Func _MoveLeft()
    _GUICtrlListView_CopyItems($g_hListView2, $g_hListView, 1)
EndFunc   ;==>_MoveLeft

Func _Exit()
    $g_iRun = 0
    GUIDelete($g_hGUI2)
    GUIDelete($g_hGUI1)
EndFunc   ;==>_Exit

Func SpecialEvents()
    Select
        Case @GUI_CtrlId = $GUI_EVENT_CLOSE
            _Exit()
    EndSelect
EndFunc   ;==>SpecialEvents


Function _GUICtrlListView_Create

Function Reference

_GUICtrlListView_Create

Create a ListView control

#include <GuiListView.au3>
_GUICtrlListView_Create ( $hWnd, $sHeaderText, $iX, $iY [, $iWidth = 150 [, $iHeight = 150 [, $iStyle = 0x0000000D [, $iExStyle = 0x00000000 [, $bCoInit = False]]]]] )

Parameters

$hWnd | Handle to parent or owner window
$sHeaderText | Text to be displayed in the header. Pipe "|" delimited.
$iX | Horizontal position of the control
$iY | Vertical position of the control
$iWidth | [optional] Control width
$iHeight | [optional] Control height
$iStyle [optional] Control styles:
$LVS_ALIGNLEFT - Items are left aligned in icon and small icon view
$LVS_ALIGNTOP - Items are aligned with the top of the control in icon and small icon view
$LVS_AUTOARRANGE - Icons are automatically kept arranged in icon and small icon view
$LVS_EDITLABELS - Item text can be edited in place
$LVS_ICON - This style specifies icon view
$LVS_LIST - This style specifies list view
$LVS_NOCOLUMNHEADER - Column headers are not displayed in report view
$LVS_NOLABELWRAP - Item text is displayed on a single line in icon view
$LVS_NOSCROLL - Scrolling is disabled
$LVS_NOSORTHEADER - Column headers do not work like buttons
$LVS_OWNERDATA - This style specifies a virtual control
$LVS_OWNERDRAWFIXED - The owner window can paint items in report view
$LVS_REPORT - This style specifies report view
$LVS_SHAREIMAGELISTS - The image list will not be deleted
$LVS_SHOWSELALWAYS - The selection, if any, is always shown
$LVS_SINGLESEL - Only one item at a time can be selected
$LVS_SMALLICON - This style specifies small icon view
$LVS_SORTASCENDING - Item indexes are sorted in ascending order
$LVS_SORTDESCENDING - Item indexes are sorted in descending order

Default: $LVS_REPORT, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS
Forced : $WS_CHILD, $WS_VISIBLE
$iExStyle [optional] Extended control styles. Can be a combination of the following:
$LVS_EX_BORDERSELECT - When an item is selected the border color of the item changes
$LVS_EX_CHECKBOXES - Enables check boxes for items in a list-view control
$LVS_EX_DOUBLEBUFFER - Paints via double-buffering, which reduces flicker
$LVS_EX_FLATSB - Enables flat scroll bars in the list view
$LVS_EX_FULLROWSELECT - When an item is selected, the item and all its subitems are highlighted
$LVS_EX_GRIDLINES - Displays gridlines around items and subitems
$LVS_EX_HEADERDRAGDROP - Enables drag-and-drop reordering of columns
$LVS_EX_INFOTIP - The $LVN_GETINFOTIP notification message is sent before displaying a ToolTip
$LVS_EX_LABELTIP - If not set, the unfolds partly hidden labels only for the large icon mode
$LVS_EX_MULTIWORKAREAS - The control will not autoarrange its icons until one or more work areas are defined
$LVS_EX_ONECLICKACTIVATE - The control sends an $LVN_ITEMACTIVATE messages when the user clicks an item
$LVS_EX_REGIONAL - Sets the control region to include only the item icons and text
$LVS_EX_SIMPLESELECT - In icon view moves the state image of the control to the top right
$LVS_EX_SUBITEMIMAGES - Allows images to be displayed for subitems
$LVS_EX_TRACKSELECT - Enables hot-track selection in the control
$LVS_EX_TWOCLICKACTIVATE - The control sends an $LVN_ITEMACTIVATE message when the user double-clicks an item
$LVS_EX_UNDERLINECOLD - Causes non-hot items that may be activated to be displayed with underlined text
$LVS_EX_UNDERLINEHOT - Causes hot items that may be activated to be displayed with underlined text
$bCoInit | [optional] Initializes the COM library for use by the calling thread.

Return Value

Success: | the handle to the ListView control.
Failure: | 0 and set the @error flag to non-zero.
@error: | 1 - Invalid Window handle 2 - Header text is not a string

Remarks

This function is for Advanced users and for learning how the control works.

Related

_GUICtrlListView_Destroy, _GUICtrlListView_SetBkImage

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Global $g_hListView

Example()

Func Example()
    Local $hGUI, $hImage
    $hGUI = GUICreate("(UDF Created) ListView Create", 400, 300)

    $g_hListView = _GUICtrlListView_Create($hGUI, "", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($g_hListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($g_hListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($g_hListView, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($g_hListView, 2, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($g_hListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($g_hListView, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($g_hListView, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($g_hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($g_hListView, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($g_hListView, "Row 3: Col 1", 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    ; Local $tBuffer
    $hWndListView = $g_hListView
    If Not IsHWnd($g_hListView) Then $hWndListView = GUICtrlGetHandle($g_hListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                ; Case $LVN_BEGINDRAG ; A drag-and-drop operation involving the left mouse button is being initiated
                ; $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                ; _DebugPrint("$LVN_BEGINDRAG" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                ; "-->Code:" & @TAB & $iCode & @CRLF & _
                ; "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                ; "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                ; "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                ; "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                ; "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                ; "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                ; "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                ; "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                ; ; No return value
                ; Case $LVN_BEGINLABELEDIT ; Start of label editing for an item
                ; $tInfo = DllStructCreate($tagNMLVDISPINFO, $lParam)
                ; _DebugPrint("$LVN_BEGINLABELEDIT" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                ; "-->Code:" & @TAB & $iCode & @CRLF & _
                ; "-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @CRLF & _
                ; "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                ; "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                ; "-->State:" & @TAB & DllStructGetData($tInfo, "State") & @CRLF & _
                ; "-->StateMask:" & @TAB & DllStructGetData($tInfo, "StateMask") & @CRLF & _
                ; "-->Image:" & @TAB & DllStructGetData($tInfo, "Image") & @CRLF & _
                ; "-->Param:" & @TAB & DllStructGetData($tInfo, "Param") & @CRLF & _
                ; "-->Indent:" & @TAB & DllStructGetData($tInfo, "Indent") & @CRLF & _
                ; "-->GroupID:" & @TAB & DllStructGetData($tInfo, "GroupID") & @CRLF & _
                ; "-->Columns:" & @TAB & DllStructGetData($tInfo, "Columns") & @CRLF & _
                ; "-->pColumns:" & @TAB & DllStructGetData($tInfo, "pColumns"))
                ; Return False ; Allow the user to edit the label
                ; ;Return True  ; Prevent the user from editing the label
                ; Case $LVN_BEGINRDRAG ; A drag-and-drop operation involving the right mouse button is being initiated
                ; $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                ; _DebugPrint("$LVN_BEGINRDRAG" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                ; "-->Code:" & @TAB & $iCode & @CRLF & _
                ; "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                ; "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                ; "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                ; "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                ; "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                ; "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                ; "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                ; "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                ; ; No return value
                ; Case $LVN_BEGINSCROLL ; A scrolling operation starts, Minium OS WinXP
                ; $tInfo = DllStructCreate($tagNMLVSCROLL, $lParam)
                ; _DebugPrint("$LVN_BEGINSCROLL" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                ; "-->Code:" & @TAB & $iCode & @CRLF & _
                ; "-->DX:" & @TAB & DllStructGetData($tInfo, "DX") & @CRLF & _
                ; "-->DY:" & @TAB & DllStructGetData($tInfo, "DY"))
                ; ; No return value
                Case $LVN_COLUMNCLICK ; A column was clicked
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    _DebugPrint("$LVN_COLUMNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    ; No return value
                    ; Case $LVN_DELETEALLITEMS ; All items in the control are about to be deleted
                    ; $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    ; _DebugPrint("$LVN_DELETEALLITEMS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                    ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                    ; "-->Code:" & @TAB & $iCode & @CRLF & _
                    ; "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                    ; "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                    ; "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                    ; "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                    ; "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                    ; "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                    ; "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                    ; "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    ; Return True ; To suppress subsequent $LVN_DELETEITEM messages
                    ; ;Return False ; To receive subsequent $LVN_DELETEITEM messages
                    ; Case $LVN_DELETEITEM ; An item is about to be deleted
                    ; $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    ; _DebugPrint("$LVN_DELETEITEM" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                    ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                    ; "-->Code:" & @TAB & $iCode & @CRLF & _
                    ; "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                    ; "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                    ; "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                    ; "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                    ; "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                    ; "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                    ; "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                    ; "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    ; ; No return value
                    ; Case $LVN_ENDLABELEDIT ; The end of label editing for an item
                    ; $tInfo = DllStructCreate($tagNMLVDISPINFO, $lParam)
                    ; $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", DllStructGetData($tInfo, "Text"))
                    ; _DebugPrint("$LVN_ENDLABELEDIT" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                    ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                    ; "-->Code:" & @TAB & $iCode & @CRLF & _
                    ; "-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @CRLF & _
                    ; "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                    ; "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                    ; "-->State:" & @TAB & DllStructGetData($tInfo, "State") & @CRLF & _
                    ; "-->StateMask:" & @TAB & DllStructGetData($tInfo, "StateMask") & @CRLF & _
                    ; "-->Text:" & @TAB & DllStructGetData($tBuffer, "Text") & @CRLF & _
                    ; "-->TextMax:" & @TAB & DllStructGetData($tInfo, "TextMax") & @CRLF & _
                    ; "-->Image:" & @TAB & DllStructGetData($tInfo, "Image") & @CRLF & _
                    ; "-->Param:" & @TAB & DllStructGetData($tInfo, "Param") & @CRLF & _
                    ; "-->Indent:" & @TAB & DllStructGetData($tInfo, "Indent") & @CRLF & _
                    ; "-->GroupID:" & @TAB & DllStructGetData($tInfo, "GroupID") & @CRLF & _
                    ; "-->Columns:" & @TAB & DllStructGetData($tInfo, "Columns") & @CRLF & _
                    ; "-->pColumns:" & @TAB & DllStructGetData($tInfo, "pColumns"))
                    ; ; If Text is not empty, return True to set the item's label to the edited text, return false to reject it
                    ; ; If Text is empty the return value is ignored
                    ; Return True
                    ; Case $LVN_ENDSCROLL ; A scrolling operation ends, Minium OS WinXP
                    ; $tInfo = DllStructCreate($tagNMLVSCROLL, $lParam)
                    ; _DebugPrint("$LVN_ENDSCROLL" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                    ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                    ; "-->Code:" & @TAB & $iCode & @CRLF & _
                    ; "-->DX:" & @TAB & DllStructGetData($tInfo, "DX") & @CRLF & _
                    ; "-->DY:" & @TAB & DllStructGetData($tInfo, "DY"))
                    ; ; No return value
                    ; Case $LVN_GETDISPINFO ; Provide information needed to display or sort a list-view item
                    ; $tInfo = DllStructCreate($tagNMLVDISPINFO, $lParam)
                    ; $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", DllStructGetData($tInfo, "Text"))
                    ; _DebugPrint("$LVN_GETDISPINFO" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                    ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                    ; "-->Code:" & @TAB & $iCode & @CRLF & _
                    ; "-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @CRLF & _
                    ; "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                    ; "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                    ; "-->State:" & @TAB & DllStructGetData($tInfo, "State") & @CRLF & _
                    ; "-->StateMask:" & @TAB & DllStructGetData($tInfo, "StateMask") & @CRLF & _
                    ; "-->Text:" & @TAB & DllStructGetData($tBuffer, "Text") & @CRLF & _
                    ; "-->TextMax:" & @TAB & DllStructGetData($tInfo, "TextMax") & @CRLF & _
                    ; "-->Image:" & @TAB & DllStructGetData($tInfo, "Image") & @CRLF & _
                    ; "-->Param:" & @TAB & DllStructGetData($tInfo, "Param") & @CRLF & _
                    ; "-->Indent:" & @TAB & DllStructGetData($tInfo, "Indent") & @CRLF & _
                    ; "-->GroupID:" & @TAB & DllStructGetData($tInfo, "GroupID") & @CRLF & _
                    ; "-->Columns:" & @TAB & DllStructGetData($tInfo, "Columns") & @CRLF & _
                    ; "-->pColumns:" & @TAB & DllStructGetData($tInfo, "pColumns"))
                    ; ; No return value
                    ; Case $LVN_GETINFOTIP ; Sent by a large icon view list-view control that has the $LVS_EX_INFOTIP extended style
                    ; $tInfo = DllStructCreate($tagNMLVGETINFOTIP, $lParam)
                    ; $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", DllStructGetData($tInfo, "Text"))
                    ; _DebugPrint("$LVN_GETINFOTIP" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                    ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                    ; "-->Code:" & @TAB & $iCode & @CRLF & _
                    ; "-->Flags:" & @TAB & DllStructGetData($tInfo, "Flags") & @CRLF & _
                    ; "-->Text:" & @TAB & DllStructGetData($tBuffer, "Text") & @CRLF & _
                    ; "-->TextMax:" & @TAB & DllStructGetData($tInfo, "TextMax") & @CRLF & _
                    ; "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                    ; "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                    ; "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam"))
                    ; ; No return value
                    ; Case $LVN_HOTTRACK ; Sent by a list-view control when the user moves the mouse over an item
                    ; $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    ; _DebugPrint("$LVN_HOTTRACK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                    ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                    ; "-->Code:" & @TAB & $iCode & @CRLF & _
                    ; "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                    ; "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                    ; "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                    ; "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                    ; "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                    ; "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                    ; "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                    ; "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    ; Return 0 ; allow the list view to perform its normal track select processing.
                    ; ;Return 1 ; the item will not be selected.
                    ; Case $LVN_INSERTITEM ; A new item was inserted
                    ; $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    ; _DebugPrint("$LVN_INSERTITEM" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                    ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                    ; "-->Code:" & @TAB & $iCode & @CRLF & _
                    ; "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                    ; "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                    ; "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                    ; "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                    ; "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                    ; "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                    ; "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                    ; "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    ; ; No return value
                    ; Case $LVN_ITEMACTIVATE ; Sent by a list-view control when the user activates an item
                    ; $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    ; _DebugPrint("$LVN_ITEMACTIVATE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                    ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                    ; "-->Code:" & @TAB & $iCode & @CRLF & _
                    ; "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                    ; "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                    ; "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                    ; "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                    ; "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                    ; "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                    ; "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                    ; "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                    ; "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; Return 0
                    ; Case $LVN_ITEMCHANGED ; An item has changed
                    ; $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    ; _DebugPrint("$LVN_ITEMCHANGED" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                    ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                    ; "-->Code:" & @TAB & $iCode & @CRLF & _
                    ; "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                    ; "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                    ; "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                    ; "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                    ; "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                    ; "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                    ; "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                    ; "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    ; ; No return value
                    ; Case $LVN_ITEMCHANGING ; An item is changing
                    ; $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    ; _DebugPrint("$LVN_ITEMCHANGING" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                    ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                    ; "-->Code:" & @TAB & $iCode & @CRLF & _
                    ; "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                    ; "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                    ; "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                    ; "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                    ; "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                    ; "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                    ; "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                    ; "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    ; Return True ; prevent the change
                    ; ;Return False ; allow the change
                Case $LVN_KEYDOWN ; A key has been pressed
                    $tInfo = DllStructCreate($tagNMLVKEYDOWN, $lParam)
                    _DebugPrint("$LVN_KEYDOWN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->VKey:" & @TAB & DllStructGetData($tInfo, "VKey") & @CRLF & _
                            "-->Flags:" & @TAB & DllStructGetData($tInfo, "Flags"))
                    ; No return value
                    ; Case $LVN_MARQUEEBEGIN ; A bounding box (marquee) selection has begun
                    ; _DebugPrint("$LVN_MARQUEEBEGIN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                    ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                    ; "-->Code:" & @TAB & $iCode)
                    ; Return 0 ; accept the message
                    ; ;Return 1 ; quit the bounding box selection
                    ; Case $LVN_SETDISPINFO ; Update the information it maintains for an item
                    ; $tInfo = DllStructCreate($tagNMLVDISPINFO, $lParam)
                    ; $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", DllStructGetData($tInfo, "Text"))
                    ; _DebugPrint("$LVN_SETDISPINFO" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                    ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                    ; "-->Code:" & @TAB & $iCode & @CRLF & _
                    ; "-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @CRLF & _
                    ; "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                    ; "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                    ; "-->State:" & @TAB & DllStructGetData($tInfo, "State") & @CRLF & _
                    ; "-->StateMask:" & @TAB & DllStructGetData($tInfo, "StateMask") & @CRLF & _
                    ; "-->Text:" & @TAB & DllStructGetData($tBuffer, "Text") & @CRLF & _
                    ; "-->TextMax:" & @TAB & DllStructGetData($tInfo, "TextMax") & @CRLF & _
                    ; "-->Image:" & @TAB & DllStructGetData($tInfo, "Image") & @CRLF & _
                    ; "-->Param:" & @TAB & DllStructGetData($tInfo, "Param") & @CRLF & _
                    ; "-->Indent:" & @TAB & DllStructGetData($tInfo, "Indent") & @CRLF & _
                    ; "-->GroupID:" & @TAB & DllStructGetData($tInfo, "GroupID") & @CRLF & _
                    ; "-->Columns:" & @TAB & DllStructGetData($tInfo, "Columns") & @CRLF & _
                    ; "-->pColumns:" & @TAB & DllStructGetData($tInfo, "pColumns"))
                    ; ; No return value
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                    ; Case $NM_HOVER ; Sent by a list-view control when the mouse hovers over an item
                    ; _DebugPrint("$NM_HOVER" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                    ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                    ; "-->Code:" & @TAB & $iCode)
                    ; Return 0 ; process the hover normally
                    ; ;Return 1 ; prevent the hover from being processed
                Case $NM_KILLFOCUS ; The control has lost the input focus
                    _DebugPrint("$NM_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ;Return 1 ; not to allow the default processing
                    Return 0 ; allow the default processing
                Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
                    _DebugPrint("$NM_RETURN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_SETFOCUS ; The control has received the input focus
                    _DebugPrint("$NM_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlListView_CreateDragImage

Function Reference

_GUICtrlListView_CreateDragImage

Creates a drag image list for the specified item

#include <GuiListView.au3>
_GUICtrlListView_CreateDragImage ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item

Return Value

Returns an array with the following format:
[0] - Handle to the drag image list if successful, otherwise 0
[1] - X coordinate of the upper left corner of the image
[2] - Y coordinate of the upper left corner of the image

Remarks

You are responsible for destroying the image list when it is no longer needed.

Related

_GUICtrlListView_DrawDragImage

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hImage, $aDrag, $hListView

    $hGUI = GUICreate("(UDF Created) ListView Create Drag Image", 400, 300)

    $hListView = _GUICtrlListView_Create($hGUI, "", 2, 2, 394, 118)
    $g_idMemo = GUICtrlCreateEdit("", 2, 124, 396, 174, 0)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($hListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($hListView, "Red", 0)
    _GUICtrlListView_AddItem($hListView, "Green", 1)
    _GUICtrlListView_AddItem($hListView, "Blue", 2)

    ; Create drag image
    $aDrag = _GUICtrlListView_CreateDragImage($hListView, 0)
    _GUICtrlListView_DrawDragImage($hListView, $aDrag)

    MemoWrite("Drag Image Handle = 0x" & Hex($aDrag[0]) & " IsPtr = " & IsPtr($aDrag[0]) & " IsHWnd = " & IsHWnd($aDrag[0]))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_MOUSEMOVE
                _GUICtrlListView_DrawDragImage($hListView, $aDrag)
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    ; Destory image list
    _GUIImageList_Destroy($aDrag[0])

    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlListView_CreateSolidBitMap

Function Reference

_GUICtrlListView_CreateSolidBitMap

Creates a solid color bitmap

#include <GuiListView.au3>
_GUICtrlListView_CreateSolidBitMap ( $hWnd, $iColor, $iWidth, $iHeight )

Parameters

$hWnd | Control ID/Handle to the control
$iColor | The color of the bitmap, stated in RGB
$iWidth | The width of the bitmap
$iHeight | The height of the bitmap

Return Value

Returns an handle to the bitmap.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Create Solid BitMap", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    ; Indent items
    _GUICtrlListView_SetItemIndent($idListview, 1, 1)
    _GUICtrlListView_SetItemIndent($idListview, 2, 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_DeleteAllItems

Function Reference

_GUICtrlListView_DeleteAllItems

Removes all items from a list-view control

#include <GuiListView.au3>
_GUICtrlListView_DeleteAllItems ( $hWnd )

Parameters

$hWnd Control ID/Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Remarks

Deleting all items from a native-created ListView can take some time - it is recommended to enclose this command in a _GUICtrlListView_Begin/EndUpdate pairing if this is the case.

Related

_GUICtrlListView_DeleteItem, _GUICtrlListView_DeleteItemsSelected

Example

Example 1

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    GUICreate("ListView Item Deletion", 400, 500)
    Local $idListview = GUICtrlCreateListView("Col 1               |Col 2      |Col 3      ", 10, 10, 380, 480, $LVS_SHOWSELALWAYS)

    ; Display the GUI.
    GUISetState(@SW_SHOW)

    For $i = 0 To 9
        GUICtrlCreateListViewItem("Native Item " & $i & "|Item " & $i & "-1|Item " & $i & "-2", $idListview)
    Next
    For $i = 10 To 20
        _GUICtrlListView_AddItem($idListview, "UDF Item " & $i, -1, 1000 + $i)
        _GUICtrlListView_AddSubItem($idListview, $i, "Item " & $i & "-1", 1)
        _GUICtrlListView_AddSubItem($idListview, $i, "Item " & $i & "-2", 2)
    Next

    MsgBox($MB_SYSTEMMODAL, "Delete all", "Deleting both native and UDF Items")

    ; Pass the controlID of a native-created ListView
    _GUICtrlListView_DeleteAllItems($idListview)

    ; Loop until the user exits
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete()
EndFunc   ;==>Example

Example 2

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example() ; A ListView control created with the ListView UDF.

Func Example()
    Local $aItems[10][3]

    Local $hGUI = GUICreate("(UDF Created) ListView Delete All Items", 400, 300)
    Local $hListView = _GUICtrlListView_Create($hGUI, "col1|col2|col3", 10, 10, 380, 280)

    ; Display the GUI.
    GUISetState(@SW_SHOW)

    ; 3 column load
    For $i = 0 To UBound($aItems) - 1
        $aItems[$i][0] = "Item " & $i
        $aItems[$i][1] = "Item " & $i & "-1"
        $aItems[$i][2] = "Item " & $i & "-2"
    Next

    _GUICtrlListView_AddArray($hListView, $aItems)

    MsgBox($MB_SYSTEMMODAL, "Delete all", "Delete all items")

    ; Pass the handle of a UDF-created ListView
    _GUICtrlListView_DeleteAllItems($hListView)

    ; Loop until the user exits
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_DeleteColumn

Function Reference

_GUICtrlListView_DeleteColumn

Removes a column from a list-view control

#include <GuiListView.au3>
_GUICtrlListView_DeleteColumn ( $hWnd, $iCol )

Parameters

$hWnd | Control ID/Handle to the control
$iCol | Index of the column to delete

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_InsertColumn

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Delete Column", 400, 300)

    $idListview = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 268)
    GUICtrlCreateListViewItem("line1|data1|more1", $idListview)
    GUICtrlCreateListViewItem("line2|data2|more2", $idListview)
    GUICtrlCreateListViewItem("line3|data3|more3", $idListview)
    GUICtrlCreateListViewItem("line4|data4|more4", $idListview)
    GUICtrlCreateListViewItem("line5|data5|more5", $idListview)
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Delete Column")
    _GUICtrlListView_DeleteColumn($idListview, 1)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_DeleteItem

Function Reference

_GUICtrlListView_DeleteItem

Removes an item from a list-view control

#include <GuiListView.au3>
_GUICtrlListView_DeleteItem ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the list-view item to delete

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_DeleteAllItems, _GUICtrlListView_DeleteItemsSelected

Example

Example 1

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    GUICreate("ListView Item Deletion", 400, 500)
    Local $idListview = GUICtrlCreateListView("Col 1               |Col 2      |Col 3      ", 10, 10, 380, 480, $LVS_SHOWSELALWAYS)
    GUISetState(@SW_SHOW)

    For $i = 0 To 9
        GUICtrlCreateListViewItem("Native Item " & $i & "|Item " & $i & "-1|Item " & $i & "-2", $idListview)
    Next
    For $i = 10 To 20
        _GUICtrlListView_AddItem($idListview, "UDF Item " & $i, -1, 1000 + $i)
        _GUICtrlListView_AddSubItem($idListview, $i, "Item " & $i & "-1", 1)
        _GUICtrlListView_AddSubItem($idListview, $i, "Item " & $i & "-2", 2)
    Next

    ; Pass the controlID of a native-created ListView to delete both native- and UDF-created Items
    MsgBox($MB_SYSTEMMODAL, "Delete item", "Deleting UDF-created Item 12")
    _GUICtrlListView_DeleteItem($idListview, 12)

    MsgBox($MB_SYSTEMMODAL, "Single", "Deleting native-created Item 5")
    _GUICtrlListView_DeleteItem($idListview, 5)

    ; Loop until the user exits
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete()
EndFunc   ;==>Example

Example 2

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example_UDF_Created()

Func Example_UDF_Created()
    Local $aItems[10][3]

    Local $hGUI = GUICreate("(UDF Created) ListView Delete All Items", 400, 300)
    Local $hListView = _GUICtrlListView_Create($hGUI, "col1|col2|col3", 10, 10, 380, 280)
    GUISetState(@SW_SHOW)

    ; 3 column load
    For $i = 0 To UBound($aItems) - 1
        $aItems[$i][0] = "Item " & $i
        $aItems[$i][1] = "Item " & $i & "-1"
        $aItems[$i][2] = "Item " & $i & "-2"
    Next

    _GUICtrlListView_AddArray($hListView, $aItems)

    MsgBox($MB_SYSTEMMODAL, "Delete item", "Deleting Item 7")
    ; Pass the handle of a native-created ListView
    _GUICtrlListView_DeleteItem($hListView, 7)

    ; Loop until the user exits
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete()
EndFunc   ;==>Example_UDF_Created


Function _GUICtrlListView_DeleteItemsSelected

Function Reference

_GUICtrlListView_DeleteItemsSelected

Deletes item(s) selected

#include <GuiListView.au3>
_GUICtrlListView_DeleteItemsSelected ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Remarks

Deleting multiple items from a native-created ListView can take some time - it is recommended to enclose this command in a _GUICtrlListView_Begin/EndUpdate pairing if this is the case.

Related

_GUICtrlListView_DeleteAllItems, _GUICtrlListView_DeleteItem

Example

Example 1

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    GUICreate("ListView Delete Items Selected", 400, 500)
    Local $idListview = GUICtrlCreateListView("Col 1               |Col 2      |Col 3      ", 10, 10, 380, 480, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
    GUISetState(@SW_SHOW)

    For $i = 0 To 9
        GUICtrlCreateListViewItem("Native Item " & $i & "|Item " & $i & "-1|Item " & $i & "-2", $idListview)
    Next
    For $i = 10 To 20
        _GUICtrlListView_AddItem($idListview, "UDF Item " & $i, -1, 1000 + $i)
        _GUICtrlListView_AddSubItem($idListview, $i, "Item " & $i & "-1", 1)
        _GUICtrlListView_AddSubItem($idListview, $i, "Item " & $i & "-2", 2)
    Next

    MsgBox($MB_SYSTEMMODAL, "Selected", "Select one or more Items" & @CRLF & "Then press 'OK'")
    ; Pass the controlID of a native-created ListView to delete both native- and UDF-created Items
    _GUICtrlListView_DeleteItemsSelected($idListview)

    ; Loop until the user exits
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete()
EndFunc   ;==>Example

Example 2

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example() ; A ListView control created with the ListView UDF.

Func Example()
    Local $aItems[10][3]

    Local $hGUI = GUICreate("(UDF Created) ListView Delete Items Selected", 400, 300)
    Local $hListView = _GUICtrlListView_Create($hGUI, "col1|col2|col3", 10, 10, 380, 280, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
    GUISetState(@SW_SHOW)

    ; 3 column load
    For $i = 0 To UBound($aItems) - 1
        $aItems[$i][0] = "Item " & $i
        $aItems[$i][1] = "Item " & $i & "-1"
        $aItems[$i][2] = "Item " & $i & "-2"
    Next

    _GUICtrlListView_AddArray($hListView, $aItems)

    MsgBox($MB_SYSTEMMODAL, "Selected", "Select one or more Items" & @CRLF & "Then press 'OK'")
    ; Pass the handle of a UDF-created ListView
    _GUICtrlListView_DeleteItemsSelected($hListView)

    ; Loop until the user exits
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_Destroy

Function Reference

_GUICtrlListView_Destroy

Delete the listview control

#include <GuiListView.au3>
_GUICtrlListView_Destroy ( ByRef $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True, $hWnd is set to 0.
Failure: | False.

Remarks

Restricted to only be used on ListView controls created with _GUICtrlListView_Create().

Related

_GUICtrlListView_Create

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hHandleBefore, $hListView

    $hGUI = GUICreate("(UDF Created) ListView Destroy", 400, 300)

    $hListView = _GUICtrlListView_Create($hGUI, "", 2, 2, 394, 268)
    $hHandleBefore = $hListView
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($hListView, "Row 1: Col 1")
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($hListView, "Row 2: Col 1")
    _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($hListView, "Row 3: Col 1")

    MsgBox($MB_SYSTEMMODAL, "Information", "Destroying the Control for Handle: " & $hListView)
    MsgBox($MB_SYSTEMMODAL, "Information", "Control Destroyed: " & _GUICtrlListView_Destroy($hListView) & @CRLF & _
            "Handel Before Destroy: " & $hHandleBefore & @CRLF & _
            "Handle After Destroy: " & $hListView)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_DrawDragImage

Function Reference

_GUICtrlListView_DrawDragImage

Draw the Drag Image

#include <GuiListView.au3>
_GUICtrlListView_DrawDragImage ( ByRef $hWnd, ByRef $aDrag )

Parameters

$hWnd | Handle to the control
$aDrag | Array with the following format: [0] - Handle to the drag image list [1] - X coordinate of the upper left corner of the image [2] - Y coordinate of the upper left corner of the image

Return Value

None.

Remarks

Creates a drag image from an image list.

Related

_GUICtrlListView_CreateDragImage

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>

Example_UDF_Created()

Func Example_UDF_Created()
    Local $hGUI, $hImage, $aDrag, $hListView

    $hGUI = GUICreate("(UDF Created) ListView Draw Drag Image", 400, 300)

    $hListView = _GUICtrlListView_Create($hGUI, "", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($hListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($hListView, "Red", 0)
    _GUICtrlListView_AddItem($hListView, "Green", 1)
    _GUICtrlListView_AddItem($hListView, "Blue", 2)

    ; Create drag image
    $aDrag = _GUICtrlListView_CreateDragImage($hListView, 0)
    _GUICtrlListView_DrawDragImage($hListView, $aDrag)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_MOUSEMOVE
                _GUICtrlListView_DrawDragImage($hListView, $aDrag)
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    ; Destory image list
    _GUIImageList_Destroy($aDrag[0])

    GUIDelete()
EndFunc   ;==>Example_UDF_Created


Function _GUICtrlListView_EditLabel

Function Reference

_GUICtrlListView_EditLabel

Begins in place editing of the specified item text

#include <GuiListView.au3>
_GUICtrlListView_EditLabel ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item to edit

Return Value

Success: | the handle to the edit control that is used to edit the item.
Failure: | 0.

Remarks

When the user completes or cancels editing, the edit control is destroyed and the handle is no longer valid.
You can subclass the edit control, but you should not destroy it.

Related

_GUICtrlListView_CancelEditLabel

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Global $g_hListView, $g_idMemo

Example()

Func Example()
    Local $hGui, $hImage

    $hGui = GUICreate("ListView Edit Label", 400, 300, Default, Default, Default, $WS_EX_CLIENTEDGE)
    $g_hListView = _GUICtrlListView_Create($hGui, "", 2, 2, 394, 118, BitOR($LVS_EDITLABELS, $LVS_REPORT))
    $g_idMemo = GUICtrlCreateEdit("", 2, 124, 396, 174, 0)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($g_hListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($g_hListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($g_hListView, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($g_hListView, 2, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($g_hListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($g_hListView, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($g_hListView, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($g_hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($g_hListView, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($g_hListView, "Row 3: Col 1", 2)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Edit item 0 label with time out
    Local $hEditLabel = _GUICtrlListView_EditLabel($g_hListView, 0)
    MemoWrite("Edit Label Handle = 0x" & Hex($hEditLabel) & " IsPtr = " & IsPtr($hEditLabel) & " IsHWnd = " & IsHWnd($hEditLabel))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    $hWndListView = $g_hListView
    If Not IsHWnd($g_hListView) Then $hWndListView = GUICtrlGetHandle($g_hListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $LVN_BEGINLABELEDITA, $LVN_BEGINLABELEDITW ; Start of label editing for an item
                    $tInfo = DllStructCreate($tagNMLVDISPINFO, $lParam)
                    _DebugPrint("$LVN_BEGINLABELEDIT" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->State:" & @TAB & DllStructGetData($tInfo, "State") & @CRLF & _
                            "-->StateMask:" & @TAB & DllStructGetData($tInfo, "StateMask") & @CRLF & _
                            "-->Image:" & @TAB & DllStructGetData($tInfo, "Image") & @CRLF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param") & @CRLF & _
                            "-->Indent:" & @TAB & DllStructGetData($tInfo, "Indent") & @CRLF & _
                            "-->GroupID:" & @TAB & DllStructGetData($tInfo, "GroupID") & @CRLF & _
                            "-->Columns:" & @TAB & DllStructGetData($tInfo, "Columns") & @CRLF & _
                            "-->pColumns:" & @TAB & DllStructGetData($tInfo, "pColumns"))
                    Return False ; Allow the user to edit the label
                    ;Return True  ; Prevent the user from editing the label
                Case $LVN_COLUMNCLICK ; A column was clicked
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    _DebugPrint("$LVN_COLUMNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    ; No return value
                Case $LVN_DELETEITEM ; An item is about to be deleted
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    _DebugPrint("$LVN_DELETEITEM" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    ; No return value
                Case $LVN_ENDLABELEDITA, $LVN_ENDLABELEDITW ; The end of label editing for an item
                    $tInfo = DllStructCreate($tagNMLVDISPINFO, $lParam)
                    Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", DllStructGetData($tInfo, "Text"))
                    _DebugPrint("$LVN_ENDLABELEDIT" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->State:" & @TAB & DllStructGetData($tInfo, "State") & @CRLF & _
                            "-->StateMask:" & @TAB & DllStructGetData($tInfo, "StateMask") & @CRLF & _
                            "-->Text:" & @TAB & DllStructGetData($tBuffer, "Text") & @CRLF & _
                            "-->TextMax:" & @TAB & DllStructGetData($tInfo, "TextMax") & @CRLF & _
                            "-->Image:" & @TAB & DllStructGetData($tInfo, "Image") & @CRLF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param") & @CRLF & _
                            "-->Indent:" & @TAB & DllStructGetData($tInfo, "Indent") & @CRLF & _
                            "-->GroupID:" & @TAB & DllStructGetData($tInfo, "GroupID") & @CRLF & _
                            "-->Columns:" & @TAB & DllStructGetData($tInfo, "Columns") & @CRLF & _
                            "-->pColumns:" & @TAB & DllStructGetData($tInfo, "pColumns"))
                    ; If Text is not empty, return True to set the item's label to the edited text, return false to reject it
                    ; If Text is empty the return value is ignored
                    If StringLen(DllStructGetData($tBuffer, "Text")) Then Return True
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_KILLFOCUS ; The control has lost the input focus
                    _DebugPrint("$NM_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ;Return 1 ; not to allow the default processing
                    Return 0 ; allow the default processing
                Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
                    _DebugPrint("$NM_RETURN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_SETFOCUS ; The control has received the input focus
                    _DebugPrint("$NM_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlListView_EnableGroupView

Function Reference

_GUICtrlListView_EnableGroupView

Enables or disables whether the items in the control display as a group

#include <GuiListView.au3>
_GUICtrlListView_EnableGroupView ( $hWnd [, $bEnable = True] )

Parameters

$hWnd | Control ID/Handle to the control
$bEnable | [optional] Indicates whether to enable group displayed items True - Enable group view False - Disable group view

Return Value

0: | the ability to display listview items as a group is already enabled or disabled.
1: | the state of the control was successfully changed.

Remarks

This function is not supported under the $LVS_OWNERDATA style.

Related

_GUICtrlListView_GetGroupViewEnabled

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Enable Group View", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($idListview, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($idListview, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($idListview, 2, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Build groups
    _GUICtrlListView_EnableGroupView($idListview)
    _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1")
    _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2")
    _GUICtrlListView_SetItemGroupID($idListview, 0, 1)
    _GUICtrlListView_SetItemGroupID($idListview, 1, 2)
    _GUICtrlListView_SetItemGroupID($idListview, 2, 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_EndUpdate

Function Reference

_GUICtrlListView_EndUpdate

Enables screen repainting that was turned off with the _GUICtrlListView_BeginUpdate() function

#include <GuiListView.au3>
_GUICtrlListView_EndUpdate ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_BeginUpdate

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView End Update", 400, 300)

    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUICtrlSetStyle($idListview, $LVS_ICON)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(32, 32)
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0xFF0000, 32, 32))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x00FF00, 32, 32))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x0000FF, 32, 32))
    _GUICtrlListView_SetImageList($idListview, $hImage, 0)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Red", 0)
        _GUICtrlListView_AddItem($idListview, "Green", 1)
        _GUICtrlListView_AddItem($idListview, "Blue", 2)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_EnsureVisible

Function Reference

_GUICtrlListView_EnsureVisible

Ensures that a list-view item is either entirely or partially visible

#include <GuiListView.au3>
_GUICtrlListView_EnsureVisible ( $hWnd, $iIndex [, $bPartialOK = False] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Index of the list-view item
$bPartialOK | [optional] Value specifying whether the item must be entirely visible

Return Value

Success: | True.
Failure: | False.

Remarks

If $bPartialOK parameter is True, no scrolling occurs if the item is at least partially visible.

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Ensure Visible", 400, 300)
    $idListview = GUICtrlCreateListView("Items", 2, 2, 394, 268)
    _GUICtrlListView_SetColumnWidth($idListview, 0, 100)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
    GUISetState(@SW_SHOW)

    _GUICtrlListView_BeginUpdate($idListview)
    For $i = 1 To 100
        GUICtrlCreateListViewItem("Item " & $i, $idListview)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    MsgBox($MB_SYSTEMMODAL, "Information", "Making item 50 visible")
    _GUICtrlListView_EnsureVisible($idListview, 49)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_FindInText

Function Reference

_GUICtrlListView_FindInText

Searches for an item that contains the specified text anywhere in its text

#include <GuiListView.au3>
_GUICtrlListView_FindInText ( $hWnd, $sText [, $iStart = -1 [, $bWrapOK = True [, $bReverse = False]]] )

Parameters

$hWnd | Control ID/Handle to the control
$sText | Text to match
$iStart | [optional] 0-based index of the item to begin the search with or -1 to start from the beginning. The specified item is itself excluded from the search.
$bWrapOK | [optional] If True, the search will continue with the first item if no match is found
$bReverse | [optional] If True, the search will start at $iStart - 1 to Zero. If $bWrapOK = True search will continue

Return Value

Success: | the 0-based index of the item.
Failure: | -1.

Remarks

The search is case insensitive. Unlike _GUICtrlListView_FindText(), this function will search all subitems for the text as well.

Related

_GUICtrlListView_FindText

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iI, $idListview

    GUICreate("ListView Find In Text", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_InsertColumn($idListview, 0, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 49
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_AddItem($idListview, "Target item")
    For $iI = 51 To 100
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Search for target item
    $iI = _GUICtrlListView_FindInText($idListview, "tArGeT")
    MsgBox($MB_SYSTEMMODAL, "Information", "Target Item Index: " & $iI)
    _GUICtrlListView_EnsureVisible($idListview, $iI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_FindItem

Function Reference

_GUICtrlListView_FindItem

Searches for an item with the specified characteristics

#include <GuiListView.au3>
_GUICtrlListView_FindItem ( $hWnd, $iStart, ByRef $tFindInfo [, $sText = ""] )

Parameters

$hWnd | Control ID/Handle to the control
$iStart | 0-based index of the item to begin the search with or -1 to start from the beginning. The specified item is itself excluded from the search.
$tFindInfo | $tagLVFINDINFO structure that contains the search information.
$sText | [optional] String to compare with the item text. It is valid if $LVFI_STRING or $LVFI_PARTIAL is set in the Flags member.

Return Value

Success: | the 0-based index of the item.
Failure: | -1.

Related

$tagLVFINDINFO, _GUICtrlListView_FindNearest, _GUICtrlListView_FindParam

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $tInfo, $iI, $idListview

    GUICreate("ListView Find Item", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 100
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Set item 50 parameter value
    _GUICtrlListView_SetItemParam($idListview, 49, 1234)

    ; Search for target item
    $tInfo = DllStructCreate($tagLVFINDINFO)
    DllStructSetData($tInfo, "Flags", $LVFI_PARAM)
    DllStructSetData($tInfo, "Param", 1234)
    $iI = _GUICtrlListView_FindItem($idListview, -1, $tInfo)
    MsgBox($MB_SYSTEMMODAL, "Information", "Target Item Index: " & $iI)
    _GUICtrlListView_EnsureVisible($idListview, $iI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_FindNearest

Function Reference

_GUICtrlListView_FindNearest

Finds the item nearest to the position specified

#include <GuiListView.au3>
_GUICtrlListView_FindNearest ( $hWnd, $iX, $iY [, $iDir = 0 [, $iStart = -1 [, $bWrapOK = True]]] )

Parameters

$hWnd | Control ID/Handle to the control
$iX | X position
$iY | Y position
$iDir | [optional] Specifies which direction to search: 0 - Left 1 - Right 2 - Up 3 - Down 4 - From start 5 - From end 6 - From prior item 7 - From next item
$iStart | [optional] 0-based index of the item to begin the search with or -1 to start from the beginning. The specified item is itself excluded from the search.
$bWrapOK | [optional] If True, the search will continue with the first item if no match is found

Return Value

Success: | the 0-based index of the item.
Failure: | -1.

Remarks

This function is supported only by large icon and small icon modes.

Related

_GUICtrlListView_FindItem

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $iIndex, $idListview

    ; Create GUI
    GUICreate("ListView Find Nearest", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUICtrlSetStyle($idListview, $LVS_ICON)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 0)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    ; Find nearest items
    $iIndex = _GUICtrlListView_FindNearest($idListview, 100, 10)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item nearest [100, 10]: " & $iIndex)

    $iIndex = _GUICtrlListView_FindNearest($idListview, 200, 10)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item nearest [200, 10]: " & $iIndex)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_FindParam

Function Reference

_GUICtrlListView_FindParam

Searches for an item with the specified lParam

#include <GuiListView.au3>
_GUICtrlListView_FindParam ( $hWnd, $iParam [, $iStart = -1] )

Parameters

$hWnd | Control ID/Handle to the control
$iParam | Param value to search for
$iStart | [optional] 0-based index of the item to begin the search with or -1 to start from the beginning. The specified item is itself excluded from the search.

Return Value

Success: | the 0-based index of the item.
Failure: | -1.

Related

_GUICtrlListView_FindItem

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

; Warning should not use SetItemParam on items created with GUICtrlCreateListViewItem
; Param is the controlID of the item

Example()

Func Example()
    Local $hGUI, $iI, $hListView

    ; Create GUI
    $hGUI = GUICreate("(UDF Created) ListView Find Param", 400, 300)
    $hListView = _GUICtrlListView_Create($hGUI, "", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($hListView, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($hListView)
    For $iI = 1 To 100
        _GUICtrlListView_AddItem($hListView, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($hListView)

    ; Set item 50 parameter value
    _GUICtrlListView_SetItemParam($hListView, 49, 1234)

    ; Search for target item
    $iI = _GUICtrlListView_FindParam($hListView, 1234)
    MsgBox($MB_SYSTEMMODAL, "Information", "Target Item Index: " & $iI)
    _GUICtrlListView_EnsureVisible($hListView, $iI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_FindText

Function Reference

_GUICtrlListView_FindText

Searches for an item with the specified text

#include <GuiListView.au3>
_GUICtrlListView_FindText ( $hWnd, $sText [, $iStart = -1 [, $bPartialOK = True [, $bWrapOK = True]]] )

Parameters

$hWnd | Control ID/Handle to the control
$sText | Text to match
$iStart | [optional] 0-based index of the item to begin the search with or -1 to start from the beginning. The specified item is itself excluded from the search.
$bPartialOK | [optional] If True, a match will occur if the item text begins with the text
$bWrapOK | [optional] If True, the search will continue with the first item if no match is found

Return Value

Success: | the 0-based index of the item.
Failure: | -1.

Remarks

The search is case insensitive. The search is performed on the item only.
Use _GUICtrlListView_FindInText() if you want to search for the text in subitems.

Related

_GUICtrlListView_FindInText

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iI, $idListview

    ; Create GUI
    GUICreate("ListView Find Text", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 49
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_AddItem($idListview, "Target item")
    For $iI = 51 To 100
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Search for target item
    $iI = _GUICtrlListView_FindText($idListview, "tArGeT")
    MsgBox($MB_SYSTEMMODAL, "Information", "Target Item Index: " & $iI)
    _GUICtrlListView_EnsureVisible($idListview, $iI)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetBkColor

Function Reference

_GUICtrlListView_GetBkColor

Retrieves the background color of a list-view control

#include <GuiListView.au3>
_GUICtrlListView_GetBkColor ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an hex RGB background color.

Related

_GUICtrlListView_SetBkColor

Example

#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get BkColor", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Set colors
    _GUICtrlListView_SetBkColor($idListview, $CLR_MONEYGREEN)
    _GUICtrlListView_SetTextColor($idListview, $CLR_BLACK)
    _GUICtrlListView_SetTextBkColor($idListview, $CLR_MONEYGREEN)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Show colors
    MsgBox($MB_SYSTEMMODAL, "Information", "Back Color ....: " & _GUICtrlListView_GetBkColor($idListview) & @CRLF & _
            "Text Color ....: " & _GUICtrlListView_GetTextColor($idListview) & @CRLF & _
            "Text Back Color: " & _GUICtrlListView_GetTextBkColor($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetBkImage

Function Reference

_GUICtrlListView_GetBkImage

Retrieves the background image in the control

#include <GuiListView.au3>
_GUICtrlListView_GetBkImage ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an array with the following format:
[0] - One or more of the following flags:
0 - The control has no background
1 - The background is from a bitmap
2 - The background is from a URL
[1] - URL of the background image
[2] - Percentage of the client area that the image should be X offset
[3] - Percentage of the client area that the image should be Y offset

Related

_GUICtrlListView_SetBkImage

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example_UDF_Created() ;use UDF built listview

Func Example_UDF_Created()
    Local $hGUI, $hImage, $aImage, $hListView
    Local $iStylesEx = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)

    $hGUI = GUICreate("(UDF Created) ListView Set Background Image", 600, 550)

    $hListView = _GUICtrlListView_Create($hGUI, "", 2, 2, 596, 500, -1, -1, True) ; Last option Calls CoInitializeEx
    _GUICtrlListView_SetExtendedListViewStyle($hListView, $iStylesEx)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($hListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)

    ; Build groups
    _GUICtrlListView_EnableGroupView($hListView)
    _GUICtrlListView_InsertGroup($hListView, -1, 1, "Group 1")
    _GUICtrlListView_InsertGroup($hListView, -1, 2, "Group 2")
    _GUICtrlListView_SetItemGroupID($hListView, 0, 1)
    _GUICtrlListView_SetItemGroupID($hListView, 1, 2)
    _GUICtrlListView_SetItemGroupID($hListView, 2, 2)

    ; Get the Image
    Local $sURL = "http://www.autoitscript.com/autoit3/files/graphics/autoit9_wall_grey_800x600.jpg"
    Local $sFilePath = @ScriptDir & "\AutoIt.jpg"
    InetGet($sURL, $sFilePath)

    ; Set the Background Image
    _GUICtrlListView_SetBkImage($hListView, $sFilePath)
    $aImage = _GUICtrlListView_GetBkImage($hListView)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Background Image: " & $aImage[1])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    DllCall('ole32.dll', 'long', 'CoUinitialize') ; Must call for each CoInitializeEx call made
    GUIDelete()
    FileDelete($sFilePath)
EndFunc   ;==>Example_UDF_Created


Function _GUICtrlListView_GetCallbackMask

Function Reference

_GUICtrlListView_GetCallbackMask

Retrieves the callback mask for the control

#include <GuiListView.au3>
_GUICtrlListView_GetCallbackMask ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns an Value of the callback mask. The bits of the mask indicate the item states or images for which the application stores the current state data. This value can be any combination of the following:
1 - The item is marked for a cut-and-paste operation
2 - The item is highlighted as a drag-and-drop target
4 - The item has the focus
8 - The item is selected
16 - The application stores the image list index of the current overlay image
32 - The application stores the image list index of the current state image

Remarks

The callback mask is a set of bit flags that specify the item states for which the application, rather than the control, stores the current data.

The callback mask applies to all of the control's items, unlike the callback item designation, which applies to a specific item.
The callback mask is zero by default, meaning that the control stores all item state information.

Related

_GUICtrlListView_SetCallBackMask

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example_UDF_Created()

Func Example_UDF_Created()
    Local $hGUI, $hImage, $hListView

    $hGUI = GUICreate("(UDF Created) ListView Get CallBack Mask", 400, 300)

    $hListView = _GUICtrlListView_Create($hGUI, "", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    _GUICtrlListView_SetCallBackMask($hListView, 32)
    MsgBox($MB_SYSTEMMODAL, "Information", "CallBackMask: " & _GUICtrlListView_GetCallbackMask($hListView))

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xC0C0C0, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF00FF, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFFFF00, 16, 16))
    _GUICtrlListView_SetImageList($hListView, $hImage, 1)
    _GUICtrlListView_SetImageList($hListView, $hImage, 2)

    ; Add columns
    _GUICtrlListView_AddColumn($hListView, "Column 1", 100)
    _GUICtrlListView_AddColumn($hListView, "Column 2", 100)
    _GUICtrlListView_AddColumn($hListView, "Column 3", 100)

    ; Add items with callback for item text
    _GUICtrlListView_AddItem($hListView, -1, 0)
    _GUICtrlListView_AddItem($hListView, -1, 1)
    _GUICtrlListView_AddItem($hListView, -1, 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example_UDF_Created


Function _GUICtrlListView_GetColumn

Function Reference

_GUICtrlListView_GetColumn

Retrieves the attributes of a column

#include <GuiListView.au3>
_GUICtrlListView_GetColumn ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of column

Return Value

Returns an array with the following format:
[0] - Alignment of the column header and the subitem text in the column:
0 - Text is left-aligned
1 - Text is right-aligned
2 - Text is centered
[1] - True if item displays an image from an image list
[2] - True if bitmap appears to the right of text
[3] - True header contains an image
[4] - Width of the column, in pixels
[5] - Column header text
[6] - Index of subitem associated with the column
[7] - 0-based index of an image within the image list
[8] - 0-based column order

Related

_GUICtrlListView_JustifyColumn, _GUICtrlListView_SetColumn

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aInfo, $idListview

    GUICreate("ListView Get Column", 400, 300)
    $idListview = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
    _GUICtrlListView_SetColumnWidth($idListview, 0, 100)
    GUISetState(@SW_SHOW)

    GUICtrlCreateListViewItem("index 0|data1|more1", $idListview)
    GUICtrlCreateListViewItem("index 1|data2|more2", $idListview)
    GUICtrlCreateListViewItem("index 2|data3|more3", $idListview)
    GUICtrlCreateListViewItem("index 3|data4|more4", $idListview)
    GUICtrlCreateListViewItem("index 4|data5|more5", $idListview)

    ; Change column
    $aInfo = _GUICtrlListView_GetColumn($idListview, 0)
    MsgBox($MB_SYSTEMMODAL, "Information", "Column 1 Width: " & $aInfo[4])
    _GUICtrlListView_SetColumn($idListview, 0, "New Column 1", 150)
    $aInfo = _GUICtrlListView_GetColumn($idListview, 0)
    MsgBox($MB_SYSTEMMODAL, "Information", "Column 1 Width: " & $aInfo[4])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetColumnCount

Function Reference

_GUICtrlListView_GetColumnCount

Retrieve the number of columns

#include <GuiListView.au3>
_GUICtrlListView_GetColumnCount ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the number of columns.

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Column Count", 400, 300)
    $idListview = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Column Count: " & _GUICtrlListView_GetColumnCount($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetColumnOrder

Function Reference

_GUICtrlListView_GetColumnOrder

Retrieves the current left-to-right order of columns

#include <GuiListView.au3>
_GUICtrlListView_GetColumnOrder ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns a delimited string.

Related

_GUICtrlListView_SetColumnOrder, _GUICtrlListView_SetColumnOrderArray

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $a_Order, $idListview

    GUICreate("ListView Get Column Order", 400, 300)
    $idListview = GUICtrlCreateListView("Column 1|Column 2|Column 3|Column 4", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $LVS_EX_HEADERDRAGDROP)
    _GUICtrlListView_SetColumnWidth($idListview, 0, 100)
    _GUICtrlListView_SetColumnWidth($idListview, 1, 100)
    _GUICtrlListView_SetColumnWidth($idListview, 2, 100)
    _GUICtrlListView_SetColumnWidth($idListview, 3, 100)
    GUISetState(@SW_SHOW)

    _GUICtrlListView_SetColumnOrder($idListview, "3|2|0|1")

    $a_Order = StringSplit(_GUICtrlListView_GetColumnOrder($idListview), "|")
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Column order: [%d, %d, %d, %d]", $a_Order[1], $a_Order[2], $a_Order[3], $a_Order[4]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetColumnOrderArray

Function Reference

_GUICtrlListView_GetColumnOrderArray

Retrieves the current left-to-right order of columns in the control

#include <GuiListView.au3>
_GUICtrlListView_GetColumnOrderArray ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an array with the following format:
[0] - Number of items in array (n)
[1] - First column index
[2] - First column index
[n] - Last column index

Related

_GUICtrlListView_SetColumnOrderArray

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $a_Order[5] = [4, 3, 2, 0, 1], $idListview

    GUICreate("(Internal) ListView Get Column Order Array", 400, 325)
    $idListview = GUICtrlCreateListView("Column 1|Column 2|Column 3|Column 4", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $LVS_EX_HEADERDRAGDROP)
    _GUICtrlListView_SetColumnWidth($idListview, 0, 100)
    _GUICtrlListView_SetColumnWidth($idListview, 1, 100)
    _GUICtrlListView_SetColumnWidth($idListview, 2, 100)
    _GUICtrlListView_SetColumnWidth($idListview, 3, 100)
    GUISetState(@SW_SHOW)

    _GUICtrlListView_SetColumnOrderArray($idListview, $a_Order)

    $a_Order = _GUICtrlListView_GetColumnOrderArray($idListview)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Column order: [%d, %d, %d, %d]", $a_Order[1], $a_Order[2], $a_Order[3], $a_Order[4]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetColumnWidth

Function Reference

_GUICtrlListView_GetColumnWidth

Retrieves the width of a column in report or list view

#include <GuiListView.au3>
_GUICtrlListView_GetColumnWidth ( $hWnd, $iCol )

Parameters

$hWnd | Control ID/Handle to the control
$iCol | The index of the column. This parameter is ignored in list view.

Return Value

Success: | the column width.
Failure: | 0.

Remarks

If this message is sent to a list-view control with the $LVS_REPORT style and the specified column doesn't exist, the return value is undefined.

Related

_GUICtrlListView_SetColumnWidth

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Column Width", 400, 300)
    $idListview = GUICtrlCreateListView("Column 1|Column 2|Column 3", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    _GUICtrlListView_SetColumnWidth($idListview, 0, 100)

    ; Change column 1 width
    MsgBox($MB_SYSTEMMODAL, "Information", "Column 1 Width: " & _GUICtrlListView_GetColumnWidth($idListview, 0))
    _GUICtrlListView_SetColumnWidth($idListview, 0, 150)
    MsgBox($MB_SYSTEMMODAL, "Information", "Column 1 Width: " & _GUICtrlListView_GetColumnWidth($idListview, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetCounterPage

Function Reference

_GUICtrlListView_GetCounterPage

Calculates the number of items that can fit vertically in the visible area

#include <GuiListView.au3>
_GUICtrlListView_GetCounterPage ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Return the number of fully visible items.

Remarks

If the current view is icon or small icon view, the return value is the total number of items in the list-view control.

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Counter Page", 400, 300)
    $idListview = GUICtrlCreateListView("Column 1|Column 2|Column 3", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES))
    GUISetState(@SW_SHOW)

    ; Show item count per page
    MsgBox($MB_SYSTEMMODAL, "Information", "Items per page: " & _GUICtrlListView_GetCounterPage($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetEditControl

Function Reference

_GUICtrlListView_GetEditControl

Retrieves the handle to the edit control being used to edit an item's text

#include <GuiListView.au3>
_GUICtrlListView_GetEditControl ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the handle to the edit control.
Failure: | 0.

Remarks

When label editing begins, an edit control is created, positioned, and initialized.
Before displayed, the control sends its parent window an $LVN_BEGINLABELEDIT notification message.

If you want to customize label editing implement a handler for $LVN_BEGINLABELEDITA, $LVN_BEGINLABELEDITAW and have it send an $LVM_GETEDITCONTROL message to the control.
If a label is being edited, the return value will be a handle to the edit control.
Use this handle to customize the edit control by sending the usual EM_XXX messages.

When the user completes or cancels editing, the edit control is destroyed and the handle is no longer valid.
You can subclass the edit control, but you should not destroy it.
To cancel editing, send the control a $WM_CANCELMODE message.

The control item being edited is the currently focused item.
To find an item based on its state, use the $LVM_GETNEXTITEM message.

Related

_GUICtrlListView_CancelEditLabel

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Global $g_hListView, $g_idMemo

Example()

Func Example()
    Local $hGui, $hImage

    $hGui = GUICreate("ListView Get Edit Control", 400, 300, Default, Default, Default, $WS_EX_CLIENTEDGE)
    $g_hListView = _GUICtrlListView_Create($hGui, "", 2, 2, 394, 118, BitOR($LVS_EDITLABELS, $LVS_REPORT))
    $g_idMemo = GUICtrlCreateEdit("", 2, 124, 396, 174, 0)
    _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($g_hListView), 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($g_hListView), 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($g_hListView), 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($g_hListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($g_hListView, "Column 1", 100)
    _GUICtrlListView_AddColumn($g_hListView, "Column 2", 100)
    _GUICtrlListView_AddColumn($g_hListView, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($g_hListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($g_hListView, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($g_hListView, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($g_hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($g_hListView, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($g_hListView, "Row 3: Col 1", 2)

    ; Monitor the WM_NOTIFY message.
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    _GUICtrlListView_EditLabel($g_hListView, 0)
    MemoWrite("Edit Handle: 0x" & Hex(_GUICtrlListView_GetEditControl($g_hListView)) & _
            " IsPtr = " & IsPtr(_GUICtrlListView_GetEditControl($g_hListView)) & " IsHWnd = " & IsHWnd(_GUICtrlListView_GetEditControl($g_hListView)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo, $hWndListView = $g_hListView
    If Not IsHWnd($g_hListView) Then $hWndListView = GUICtrlGetHandle($g_hListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $LVN_BEGINLABELEDITA, $LVN_BEGINLABELEDITW ; Start of label editing for an item
                    $tInfo = DllStructCreate($tagNMLVDISPINFO, $lParam)
                    _DebugPrint("$LVN_BEGINLABELEDIT" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->State:" & @TAB & DllStructGetData($tInfo, "State") & @CRLF & _
                            "-->StateMask:" & @TAB & DllStructGetData($tInfo, "StateMask") & @CRLF & _
                            "-->Image:" & @TAB & DllStructGetData($tInfo, "Image") & @CRLF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param") & @CRLF & _
                            "-->Indent:" & @TAB & DllStructGetData($tInfo, "Indent") & @CRLF & _
                            "-->GroupID:" & @TAB & DllStructGetData($tInfo, "GroupID") & @CRLF & _
                            "-->Columns:" & @TAB & DllStructGetData($tInfo, "Columns") & @CRLF & _
                            "-->pColumns:" & @TAB & DllStructGetData($tInfo, "pColumns"))
                    Return False ; Allow the user to edit the label
                    ; ;Return True  ; Prevent the user from editing the label
                Case $LVN_COLUMNCLICK ; A column was clicked
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    _DebugPrint("$LVN_COLUMNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    ; No return value
                Case $LVN_ENDLABELEDITA, $LVN_ENDLABELEDITW ; The end of label editing for an item
                    $tInfo = DllStructCreate($tagNMLVDISPINFO, $lParam)
                    If (DllStructGetData($tInfo, "Text") <> 0) Then
                        Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", DllStructGetData($tInfo, "Text"))
                        _DebugPrint("$LVN_ENDLABELEDIT" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                                "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                                "-->Code:" & @TAB & $iCode & @CRLF & _
                                "-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @CRLF & _
                                "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                                "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                                "-->State:" & @TAB & DllStructGetData($tInfo, "State") & @CRLF & _
                                "-->StateMask:" & @TAB & DllStructGetData($tInfo, "StateMask") & @CRLF & _
                                "-->Text:" & @TAB & DllStructGetData($tBuffer, "Text") & @CRLF & _
                                "-->TextMax:" & @TAB & DllStructGetData($tInfo, "TextMax") & @CRLF & _
                                "-->Image:" & @TAB & DllStructGetData($tInfo, "Image") & @CRLF & _
                                "-->Param:" & @TAB & DllStructGetData($tInfo, "Param") & @CRLF & _
                                "-->Indent:" & @TAB & DllStructGetData($tInfo, "Indent") & @CRLF & _
                                "-->GroupID:" & @TAB & DllStructGetData($tInfo, "GroupID") & @CRLF & _
                                "-->Columns:" & @TAB & DllStructGetData($tInfo, "Columns") & @CRLF & _
                                "-->pColumns:" & @TAB & DllStructGetData($tInfo, "pColumns"))
                        Return True ; If Text is empty the return value is ignored
                    EndIf
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_KILLFOCUS ; The control has lost the input focus
                    _DebugPrint("$NM_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ;Return 1 ; not to allow the default processing
                    Return 0 ; allow the default processing
                Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
                    _DebugPrint("$NM_RETURN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_SETFOCUS ; The control has received the input focus
                    _DebugPrint("$NM_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlListView_GetExtendedListViewStyle

Function Reference

_GUICtrlListView_GetExtendedListViewStyle

Retrieves the extended styles that are currently in use

#include <GuiListView.au3>
_GUICtrlListView_GetExtendedListViewStyle ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns a DWORD that represents the styles currently in use for a given list-view.

Related

_GUICtrlListView_SetExtendedListViewStyle

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Get Extended List View Style", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    _GUICtrlListView_InsertItem($idListview, "Row 1: Col 1", -1, 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_InsertItem($idListview, "Row 2: Col 1", -1, 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_InsertItem($idListview, "Row 3: Col 1", -1, 2)

    MsgBox($MB_SYSTEMMODAL, "Information", "Extended List View Style(s): 0x" & _GUICtrlListView_GetExtendedListViewStyle($idListview) & @CRLF & _
            _DisplayExtendStringList($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _DisplayExtendStringList($idListview)
    Local $sStyles = @CRLF & @CRLF & @TAB
    If (BitAND(_GUICtrlListView_GetExtendedListViewStyle($idListview), $LVS_EX_BORDERSELECT) = $LVS_EX_BORDERSELECT) Then $sStyles &= "$LVS_EX_BORDERSELECT" & @CRLF & @TAB
    If (BitAND(_GUICtrlListView_GetExtendedListViewStyle($idListview), $LVS_EX_CHECKBOXES) = $LVS_EX_CHECKBOXES) Then $sStyles &= "$LVS_EX_CHECKBOXES" & @CRLF & @TAB
    If (BitAND(_GUICtrlListView_GetExtendedListViewStyle($idListview), $LVS_EX_DOUBLEBUFFER) = $LVS_EX_DOUBLEBUFFER) Then $sStyles &= "$LVS_EX_DOUBLEBUFFER" & @CRLF & @TAB
    If (BitAND(_GUICtrlListView_GetExtendedListViewStyle($idListview), $LVS_EX_FLATSB) = $LVS_EX_FLATSB) Then $sStyles &= "$LVS_EX_FLATSB" & @CRLF & @TAB
    If (BitAND(_GUICtrlListView_GetExtendedListViewStyle($idListview), $LVS_EX_FULLROWSELECT) = $LVS_EX_FULLROWSELECT) Then $sStyles &= "$LVS_EX_FULLROWSELECT" & @CRLF & @TAB
    If (BitAND(_GUICtrlListView_GetExtendedListViewStyle($idListview), $LVS_EX_GRIDLINES) = $LVS_EX_GRIDLINES) Then $sStyles &= "$LVS_EX_GRIDLINES" & @CRLF & @TAB
    If (BitAND(_GUICtrlListView_GetExtendedListViewStyle($idListview), $LVS_EX_HEADERDRAGDROP) = $LVS_EX_HEADERDRAGDROP) Then $sStyles &= "$LVS_EX_HEADERDRAGDROP" & @CRLF & @TAB
    If (BitAND(_GUICtrlListView_GetExtendedListViewStyle($idListview), $LVS_EX_INFOTIP) = $LVS_EX_INFOTIP) Then $sStyles &= "$LVS_EX_INFOTIP" & @CRLF & @TAB
    If (BitAND(_GUICtrlListView_GetExtendedListViewStyle($idListview), $LVS_EX_LABELTIP) = $LVS_EX_LABELTIP) Then $sStyles &= "$LVS_EX_LABELTIP" & @CRLF & @TAB
    If (BitAND(_GUICtrlListView_GetExtendedListViewStyle($idListview), $LVS_EX_MULTIWORKAREAS) = $LVS_EX_MULTIWORKAREAS) Then $sStyles &= "$LVS_EX_MULTIWORKAREAS" & @CRLF & @TAB
    If (BitAND(_GUICtrlListView_GetExtendedListViewStyle($idListview), $LVS_EX_ONECLICKACTIVATE) = $LVS_EX_ONECLICKACTIVATE) Then $sStyles &= "$LVS_EX_ONECLICKACTIVATE" & @CRLF & @TAB
    If (BitAND(_GUICtrlListView_GetExtendedListViewStyle($idListview), $LVS_EX_REGIONAL) = $LVS_EX_REGIONAL) Then $sStyles &= "$LVS_EX_REGIONAL" & @CRLF & @TAB
    If (BitAND(_GUICtrlListView_GetExtendedListViewStyle($idListview), $LVS_EX_SIMPLESELECT) = $LVS_EX_SIMPLESELECT) Then $sStyles &= "$LVS_EX_SIMPLESELECT" & @CRLF & @TAB
    If (BitAND(_GUICtrlListView_GetExtendedListViewStyle($idListview), $LVS_EX_SUBITEMIMAGES) = $LVS_EX_SUBITEMIMAGES) Then $sStyles &= "$LVS_EX_SUBITEMIMAGES" & @CRLF & @TAB
    If (BitAND(_GUICtrlListView_GetExtendedListViewStyle($idListview), $LVS_EX_TRACKSELECT) = $LVS_EX_TRACKSELECT) Then $sStyles &= "$LVS_EX_TRACKSELECT" & @CRLF & @TAB
    If (BitAND(_GUICtrlListView_GetExtendedListViewStyle($idListview), $LVS_EX_TWOCLICKACTIVATE) = $LVS_EX_TWOCLICKACTIVATE) Then $sStyles &= "$LVS_EX_TWOCLICKACTIVATE" & @CRLF & @TAB
    If (BitAND(_GUICtrlListView_GetExtendedListViewStyle($idListview), $LVS_EX_UNDERLINECOLD) = $LVS_EX_UNDERLINECOLD) Then $sStyles &= "$LVS_EX_UNDERLINECOLD" & @CRLF & @TAB
    If (BitAND(_GUICtrlListView_GetExtendedListViewStyle($idListview), $LVS_EX_UNDERLINEHOT) = $LVS_EX_UNDERLINEHOT) Then $sStyles &= "$LVS_EX_UNDERLINEHOT" & @CRLF & @TAB
    Return $sStyles
EndFunc   ;==>_DisplayExtendStringList


Function _GUICtrlListView_GetFocusedGroup

Function Reference

_GUICtrlListView_GetFocusedGroup

Gets the group that has the focus

#include <GuiListView.au3>
_GUICtrlListView_GetFocusedGroup ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the index of the group with state of $LVGS_FOCUSED, or -1 if there is no group with state of $LVGS_FOCUSED.

Remarks

Windows Vista or later ?

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Set Group Info", 400, 300)

    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Build groups
    _GUICtrlListView_EnableGroupView($idListview)
    _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1", 1)
    _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2")
    _GUICtrlListView_SetItemGroupID($idListview, 0, 1)
    _GUICtrlListView_SetItemGroupID($idListview, 1, 2)
    _GUICtrlListView_SetItemGroupID($idListview, 2, 2)

    If @OSVersion = "WIN_XP" Then
        MsgBox($MB_SYSTEMMODAL, "Information", "The function does not work in WinXP")
    Else
        _GUICtrlListView_SetGroupInfo($idListview, 1, "New Group 1", 0, $LVGS_FOCUSED)
        MsgBox($MB_SYSTEMMODAL, "Information", "Group has focus at Index: " & _GUICtrlListView_GetFocusedGroup($idListview))
    EndIf

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetGroupCount

Function Reference

_GUICtrlListView_GetGroupCount

Gets the number of groups

#include <GuiListView.au3>
_GUICtrlListView_GetGroupCount ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the number of groups.

Remarks

Windows Vista or later

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Set Group Info", 400, 300)

    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Build groups
    _GUICtrlListView_EnableGroupView($idListview)
    _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1", 1)
    _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2")
    _GUICtrlListView_SetItemGroupID($idListview, 0, 1)
    _GUICtrlListView_SetItemGroupID($idListview, 1, 2)
    _GUICtrlListView_SetItemGroupID($idListview, 2, 2)

    If @OSVersion = "WIN_XP" Then
        MsgBox($MB_SYSTEMMODAL, "Information", "The function does not work in WinXP")
    Else
        MsgBox($MB_SYSTEMMODAL, "Information", "Group Count: " & _GUICtrlListView_GetGroupCount($idListview))
    EndIf

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetGroupInfo

Function Reference

_GUICtrlListView_GetGroupInfo

Retrieves group information

#include <GuiListView.au3>
_GUICtrlListView_GetGroupInfo ( $hWnd, $iGroupID )

Parameters

$hWnd | Control ID/Handle to the control
$iGroupID | ID that specifies the group whose information is retrieved

Return Value

Returns an array with the following format:
[0] - Header text
[1] - Header alignment:
0 - Left
1 - Center
2 - Right

Related

_GUICtrlListView_GetGroupInfoByIndex, _GUICtrlListView_SetGroupInfo

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aInfo, $hImage, $idListview

    GUICreate("ListView Get Group Info", 400, 300)

    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Build groups
    _GUICtrlListView_EnableGroupView($idListview)
    _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1", 1)
    _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2")
    _GUICtrlListView_SetItemGroupID($idListview, 0, 1)
    _GUICtrlListView_SetItemGroupID($idListview, 1, 2)
    _GUICtrlListView_SetItemGroupID($idListview, 2, 2)

    ; Change group information
    $aInfo = _GUICtrlListView_GetGroupInfo($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Group 1 Text: " & $aInfo[0])
    _GUICtrlListView_SetGroupInfo($idListview, 1, "New Group 1")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetGroupInfoByIndex

Function Reference

_GUICtrlListView_GetGroupInfoByIndex

Retrieves group information

#include <GuiListView.au3>
_GUICtrlListView_GetGroupInfoByIndex ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index that specifies the group whose information is retrieved

Return Value

Returns an array with the following format:
[0] - Header text
[1] - Header alignment:
0 - Left
1 - Center
2 - Right
[2] - Group ID

Remarks

Windows Vista or later

Related

_GUICtrlListView_GetGroupInfo, _GUICtrlListView_SetGroupInfo

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aInfo, $hImage, $idListview

    GUICreate("ListView Get Group Info", 400, 300)

    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Build groups
    _GUICtrlListView_EnableGroupView($idListview)
    _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1", 1)
    _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2")
    _GUICtrlListView_SetItemGroupID($idListview, 0, 1)
    _GUICtrlListView_SetItemGroupID($idListview, 1, 2)
    _GUICtrlListView_SetItemGroupID($idListview, 2, 2)

    If @OSVersion = "WIN_XP" Then
        MsgBox($MB_SYSTEMMODAL, "Information", "The function does not work in WinXP")
    Else
        ; Change group information
        For $x = 0 To _GUICtrlListView_GetGroupCount($idListview) - 1
            $aInfo = _GUICtrlListView_GetGroupInfoByIndex($idListview, $x)
            MsgBox($MB_SYSTEMMODAL, "Information", "Index " & $x + 1 & @CRLF & "Text: " & $aInfo[0] & @CRLF & "Group ID: " & $aInfo[2])
        Next
    EndIf
    _GUICtrlListView_SetGroupInfo($idListview, 1, "New Group 1 (Minimum OS: Vista)")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetGroupRect

Function Reference

_GUICtrlListView_GetGroupRect

Gets the rectangle for a specified group

#include <GuiListView.au3>
_GUICtrlListView_GetGroupRect ( $hWnd, $iGroupID [, $iGet = $LVGGR_GROUP] )

Parameters

$hWnd | Control ID/Handle to the control
$iGroupID | ID that specifies the group whose information is retrieved
$iGet | [optional] Flag to specify the coordinates of the rectangle to get, can be one of the following: $LVGGR_GROUP - Coordinates of the entire expanded group $LVGGR_HEADER - Coordinates of the header only (collapsed group) $LVGGR_LABEL - Coordinates of the label only $LVGGR_SUBSETLINK - Coordinates of the subset link only (markup subset)

Return Value

Returns an array with the following format:
[0] - Specifies the x-coordinate of the upper-left corner of the rectangle
[1] - Specifies the y-coordinate of the upper-left corner of the rectangle
[2] - Specifies the x-coordinate of the lower-right corner of the rectangle
[3] - Specifies the y-coordinate of the lower-right corner of the rectangle

Remarks

Windows Vista or later

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aInfo, $hImage, $idListview

    GUICreate("ListView Get Group Info", 400, 300)

    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Build groups
    _GUICtrlListView_EnableGroupView($idListview)
    _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1", 1)
    _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2")
    _GUICtrlListView_SetItemGroupID($idListview, 0, 1)
    _GUICtrlListView_SetItemGroupID($idListview, 1, 2)
    _GUICtrlListView_SetItemGroupID($idListview, 2, 2)

    ; Get rect of Group ID 2
    $aInfo = _GUICtrlListView_GetGroupRect($idListview, 2)
    MsgBox($MB_SYSTEMMODAL, "Information", "Rect: " & @CRLF & _
            @TAB & "Left..: " & $aInfo[0] & @CRLF & _
            @TAB & "Top...: " & $aInfo[1] & @CRLF & _
            @TAB & "Right.: " & $aInfo[2] & @CRLF & _
            @TAB & "Bottom: " & $aInfo[3])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetGroupViewEnabled

Function Reference

_GUICtrlListView_GetGroupViewEnabled

Checks whether the control has group view enabled

#include <GuiListView.au3>
_GUICtrlListView_GetGroupViewEnabled ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

True: | the group view is enabled.
False: | the group view is not enabled.

Related

_GUICtrlListView_EnableGroupView

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Get Group View Enabled", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $LVS_EX_FULLROWSELECT)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Build groups
    _GUICtrlListView_EnableGroupView($idListview)
    _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1")
    _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2")
    _GUICtrlListView_SetItemGroupID($idListview, 0, 1)
    _GUICtrlListView_SetItemGroupID($idListview, 1, 2)
    _GUICtrlListView_SetItemGroupID($idListview, 2, 2)

    ; Is group view enabled
    MsgBox($MB_SYSTEMMODAL, "Information", "Group View Enabled: " & _GUICtrlListView_GetGroupViewEnabled($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetHeader

Function Reference

_GUICtrlListView_GetHeader

Retrieves the handle to the header control

#include <GuiListView.au3>
_GUICtrlListView_GetHeader ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the handle to the header control.

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Header", 400, 300)
    $idListview = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "ListView Header Handle: 0x" & Hex(_GUICtrlListView_GetHeader($idListview)) & @CRLF & _
            "IsPtr = " & IsPtr(_GUICtrlListView_GetHeader($idListview)) & " IsHWnd = " & IsHWnd(_GUICtrlListView_GetHeader($idListview)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetHotCursor

Function Reference

_GUICtrlListView_GetHotCursor

Retrieves the HCURSOR value used when the pointer is over an item while hot tracking is enabled

#include <GuiListView.au3>
_GUICtrlListView_GetHotCursor ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns a HCURSOR value that is the handle to the cursor that the list-view control uses when hot tracking is enabled.

Remarks

A list-view control uses hot tracking and hover selection when the $LVS_EX_TRACKSELECT style is set.

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Hot Cursor", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Show hot cursor handle
    MsgBox($MB_SYSTEMMODAL, "Information", "Hot Cursor Handle: 0x" & Hex(_GUICtrlListView_GetHotCursor($idListview)) & @CRLF & _
            "IsPtr = " & IsPtr(_GUICtrlListView_GetHotCursor($idListview)) & " IsHWnd = " & IsHWnd(_GUICtrlListView_GetHotCursor($idListview)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetHotItem

Function Reference

_GUICtrlListView_GetHotItem

Retrieves the index of the hot item

#include <GuiListView.au3>
_GUICtrlListView_GetHotItem ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the index of the item that is hot.

Related

_GUICtrlListView_SetHotItem

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Global $g_idListView, $g_hStatus

Example()

Func Example()
    Local $hGUI

    $hGUI = GUICreate("ListView Get Hot Item", 392, 322)

    $g_idListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    $g_idListView = GUICtrlGetHandle($g_idListView)
    _GUICtrlListView_SetExtendedListViewStyle($g_idListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_TRACKSELECT))
    $g_hStatus = _GUICtrlStatusBar_Create($hGUI)
    _GUICtrlStatusBar_SetSimple($g_hStatus, True)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($g_idListView, "Column 1", 100)
    _GUICtrlListView_AddColumn($g_idListView, "Column 2", 100)
    _GUICtrlListView_AddColumn($g_idListView, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($g_idListView, "Row 1: Col 1")
    _GUICtrlListView_AddSubItem($g_idListView, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($g_idListView, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($g_idListView, "Row 2: Col 1")
    _GUICtrlListView_AddSubItem($g_idListView, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($g_idListView, "Row 3: Col 1")

    ;Register WM_NOTIFY  events
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func ListView_HOTTRACK($iSubItem)
    Local $iHotItem = _GUICtrlListView_GetHotItem($g_idListView)
    If $iHotItem <> -1 Then _GUICtrlStatusBar_SetText($g_hStatus, "Hot Item: " & $iHotItem & " SubItem: " & $iSubItem)
EndFunc   ;==>ListView_HOTTRACK

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    $hWndListView = $g_idListView
    If Not IsHWnd($g_idListView) Then $hWndListView = GUICtrlGetHandle($g_idListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $LVN_COLUMNCLICK ; A column was clicked
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    _DebugPrint("$LVN_COLUMNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    ; No return value
                Case $LVN_DELETEITEM ; An item is about to be deleted
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    _DebugPrint("$LVN_DELETEITEM" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    ; No return value
                Case $LVN_HOTTRACK ; Sent by a list-view control when the user moves the mouse over an item
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    ListView_HOTTRACK(DllStructGetData($tInfo, "SubItem"))
                    ; _DebugPrint("$LVN_HOTTRACK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                    ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                    ; "-->Code:" & @TAB & $iCode & @CRLF & _
                    ; "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                    ; "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                    ; "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                    ; "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                    ; "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                    ; "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                    ; "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                    ; "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    Return 0 ; allow the list view to perform its normal track select processing.
                    ;Return 1 ; the item will not be selected.
                Case $LVN_KEYDOWN ; A key has been pressed
                    $tInfo = DllStructCreate($tagNMLVKEYDOWN, $lParam)
                    _DebugPrint("$LVN_KEYDOWN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->VKey:" & @TAB & DllStructGetData($tInfo, "VKey") & @CRLF & _
                            "-->Flags:" & @TAB & DllStructGetData($tInfo, "Flags"))
                    ; No return value
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_KILLFOCUS ; The control has lost the input focus
                    _DebugPrint("$NM_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ;Return 1 ; not to allow the default processing
                    Return 0 ; allow the default processing
                Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
                    _DebugPrint("$NM_RETURN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_SETFOCUS ; The control has received the input focus
                    _DebugPrint("$NM_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlListView_GetHoverTime

Function Reference

_GUICtrlListView_GetHoverTime

Retrieves the amount of time that the mouse cursor must hover over an item before it is selected

#include <GuiListView.au3>
_GUICtrlListView_GetHoverTime ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the amount of time, in milliseconds, that the mouse cursor must hover over an item before it is selected. If the return value is (DWORD)-1, then the hover time is the default hover time.

Remarks

The hover time only affects list-view controls that have the $LVS_EX_TRACKSELECT, $LVS_EX_ONECLICKACTIVATE or $LVS_EX_TWOCLICKACTIVATE extended list-view style.

Related

_GUICtrlListView_SetHoverTime

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiStatusBar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idListView, $g_hStatus

Example()

Func Example()
    Local $hGUI

    $hGUI = GUICreate("ListView Get Hover Time", 400, 300)
    $g_idListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($g_idListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_TRACKSELECT))
    $g_hStatus = _GUICtrlStatusBar_Create($hGUI)
    _GUICtrlStatusBar_SetSimple($g_hStatus, True)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($g_idListView, "Column 1", 100)
    _GUICtrlListView_AddColumn($g_idListView, "Column 2", 100)
    _GUICtrlListView_AddColumn($g_idListView, "Column 3", 100)

    _GUICtrlListView_InsertItem($g_idListView, "Row 1: Col 1", -1)
    _GUICtrlListView_AddSubItem($g_idListView, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($g_idListView, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_InsertItem($g_idListView, "Row 2: Col 1", -1)
    _GUICtrlListView_AddSubItem($g_idListView, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_InsertItem($g_idListView, "Row 3: Col 1", -1)

    ; Set hover time
    _GUICtrlListView_SetHoverTime($g_idListView, 1234)
    MsgBox($MB_SYSTEMMODAL, "Information", "Hover Time (milliseconds): " & _GUICtrlListView_GetHoverTime($g_idListView))

    ;Register WM_NOTIFY  events
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func ListView_HOTTRACK($iSubItem)
    Local $iHotItem = _GUICtrlListView_GetHotItem($g_idListView)
    If $iHotItem <> -1 Then _GUICtrlStatusBar_SetText($g_hStatus, "Hot Item: " & $iHotItem & " SubItem: " & $iSubItem)
EndFunc   ;==>ListView_HOTTRACK

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    $hWndListView = $g_idListView
    If Not IsHWnd($g_idListView) Then $hWndListView = GUICtrlGetHandle($g_idListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $LVN_COLUMNCLICK ; A column was clicked
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    _DebugPrint("$LVN_COLUMNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    ; No return value
                Case $LVN_DELETEITEM ; An item is about to be deleted
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    _DebugPrint("$LVN_DELETEITEM" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    ; No return value
                Case $LVN_HOTTRACK ; Sent by a list-view control when the user moves the mouse over an item
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    ListView_HOTTRACK(DllStructGetData($tInfo, "SubItem"))
                    ; _DebugPrint("$LVN_HOTTRACK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                    ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                    ; "-->Code:" & @TAB & $iCode & @CRLF & _
                    ; "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                    ; "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                    ; "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                    ; "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                    ; "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                    ; "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                    ; "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                    ; "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    Return 0 ; allow the list view to perform its normal track select processing.
                    ;Return 1 ; the item will not be selected.
                Case $LVN_KEYDOWN ; A key has been pressed
                    $tInfo = DllStructCreate($tagNMLVKEYDOWN, $lParam)
                    _DebugPrint("$LVN_KEYDOWN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->VKey:" & @TAB & DllStructGetData($tInfo, "VKey") & @CRLF & _
                            "-->Flags:" & @TAB & DllStructGetData($tInfo, "Flags"))
                    ; No return value
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_KILLFOCUS ; The control has lost the input focus
                    _DebugPrint("$NM_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ;Return 1 ; not to allow the default processing
                    Return 0 ; allow the default processing
                Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
                    _DebugPrint("$NM_RETURN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_SETFOCUS ; The control has received the input focus
                    _DebugPrint("$NM_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlListView_GetImageList

Function Reference

_GUICtrlListView_GetImageList

Retrieves the handle to an image list used for drawing listview items

#include <GuiListView.au3>
_GUICtrlListView_GetImageList ( $hWnd, $iImageList )

Parameters

$hWnd | Control ID/Handle to the control
$iImageList | Image list to retrieve: 0 - Image list with large icons 1 - Image list with small icons 2 - Image list with state images

Return Value

Success: | the handle to the specified image list.
Failure: | 0.

Related

_GUICtrlListView_SetImageList

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Get Image List", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    ; Get image list handle
    MsgBox($MB_SYSTEMMODAL, "Information", "Image List Handle: 0x" & Hex(_GUICtrlListView_GetImageList($idListview, 1)) & @CRLF & _
            "IsPtr = " & IsPtr(_GUICtrlListView_GetImageList($idListview, 1)) & " IsHWnd = " & IsHWnd(_GUICtrlListView_GetImageList($idListview, 1)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetISearchString

Function Reference

_GUICtrlListView_GetISearchString

Retrieves the incremental search string of the control

#include <GuiListView.au3>
_GUICtrlListView_GetISearchString ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an Incremental search string or an empty string if no search string exists.

Remarks

The incremental search string is the character sequence that the user types while the list view has the input focus.
Each time the user types a character, the system appends the character to the search string and then searches for a matching item.
If the system finds a match, it selects the item and, if necessary, scrolls it into view.

A time-out period is associated with each character that the user types.
If the time-out period elapses before the user types another character, the incremental search string is reset.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Get ISearch", 400, 300)

    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUICtrlSetStyle($idListview, $LVS_ICON)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 0)

    _GUICtrlListView_BeginUpdate($idListview)
    For $x = 1 To 10
        _GUICtrlListView_InsertItem($idListview, "Item " & $x, -1, 0)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    Send("Item 1")

    ; Get incremental search string
    MsgBox($MB_SYSTEMMODAL, "Information", "Incremental Search String: " & _GUICtrlListView_GetISearchString($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItem

Function Reference

_GUICtrlListView_GetItem

Retrieves an item's attributes

#include <GuiListView.au3>
_GUICtrlListView_GetItem ( $hWnd, $iIndex [, $iSubItem = 0] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index
$iSubItem | [optional] 1-based subitem index

Return Value

Returns an array with the following format:
[0] - Item state, which can be a combination of the following:
1 - The item is marked for a cut-and-paste operation
2 - The item is highlighted as a drag-and-drop target
4 - The item has the focus
8 - The item is selected
[1] - 1-based item image overlay index
[2] - 1-based item state image index
[3] - Item text
[4] - 0-based item image index
[5] - Item application defined value
[6] - Number of image widths to indent the item
[7] - Identifier of the tile view group that receives the item

Related

_GUICtrlListView_GetItemEx, _GUICtrlListView_SetItem

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aItem, $idListview

    GUICreate("ListView Get Item", 400, 300)

    $idListview = GUICtrlCreateListView("Items", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    GUICtrlCreateListViewItem("Row 1", $idListview)
    GUICtrlCreateListViewItem("Row 2", $idListview)
    GUICtrlCreateListViewItem("Row 3", $idListview)

    ; Show item 2 text
    $aItem = _GUICtrlListView_GetItem($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Text: " & $aItem[3])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemChecked

Function Reference

_GUICtrlListView_GetItemChecked

Returns the check state for a list-view control item

#include <GuiListView.au3>
_GUICtrlListView_GetItemChecked ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index to retrieve item check state from

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_SetItemChecked

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Item Checked State", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Check item 2
    _GUICtrlListView_SetItemChecked($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Checked: " & _GUICtrlListView_GetItemChecked($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemCount

Function Reference

_GUICtrlListView_GetItemCount

Retrieves the number of items in a list-view control

#include <GuiListView.au3>
_GUICtrlListView_GetItemCount ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the number of items.

Related

_GUICtrlListView_SetItemCount

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Item Count", 400, 300)
    $idListview = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    GUICtrlCreateListViewItem("line1|data1|more1", $idListview)
    GUICtrlCreateListViewItem("line2|data2|more2", $idListview)
    GUICtrlCreateListViewItem("line3|data3|more3", $idListview)
    GUICtrlCreateListViewItem("line4|data4|more4", $idListview)
    GUICtrlCreateListViewItem("line5|data5|more5", $idListview)

    MsgBox($MB_SYSTEMMODAL, "Information", "Item Count: " & _GUICtrlListView_GetItemCount($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemCut

Function Reference

_GUICtrlListView_GetItemCut

Determines whether the item is marked for a cut and paste operation

#include <GuiListView.au3>
_GUICtrlListView_GetItemCut ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item

Return Value

True: | the item is marked for a cut and paste operation.
False: | the item is not marked for a cut and paste operation.

Related

_GUICtrlListView_SetItemCut

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Item Cut", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Cut item 2
    _GUICtrlListView_SetItemCut($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Cut: " & _GUICtrlListView_GetItemCut($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemDropHilited

Function Reference

_GUICtrlListView_GetItemDropHilited

Determines whether the item is highlighted as a drag-and-drop target

#include <GuiListView.au3>
_GUICtrlListView_GetItemDropHilited ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_SetItemDropHilited

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Item Drop Hilited", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Hilight item 2
    _GUICtrlListView_SetItemDropHilited($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Drop Hilited: " & _GUICtrlListView_GetItemDropHilited($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemEx

Function Reference

_GUICtrlListView_GetItemEx

Retrieves some or all of an item's attributes

#include <GuiListView.au3>
_GUICtrlListView_GetItemEx ( $hWnd, ByRef $tItem )

Parameters

$hWnd | Control ID/Handle to the control
$tItem | $tagLVITEM structure that specifies the information to retrieve

Return Value

Success: | True.
Failure: | False.

Related

$tagLVITEM, _GUICtrlListView_GetItem

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $tItem, $idListview

    GUICreate("ListView Get ItemEX", 400, 300)

    $idListview = GUICtrlCreateListView("Items", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    GUICtrlCreateListViewItem("Item 1", $idListview)
    GUICtrlCreateListViewItem("Item 2", $idListview)
    GUICtrlCreateListViewItem("Item 3", $idListview)

    ; Show item 1 raw state
    $tItem = DllStructCreate($tagLVITEM)
    DllStructSetData($tItem, "Mask", $LVIF_STATE)
    DllStructSetData($tItem, "Item", 1)
    DllStructSetData($tItem, "StateMask", -1)
    _GUICtrlListView_GetItemEx($idListview, $tItem)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 State: " & DllStructGetData($tItem, "State"))

    ; Select item 2
    _GUICtrlListView_SetItemSelected($idListview, 1)

    ; Show item 1 raw state
    _GUICtrlListView_GetItemEx($idListview, $tItem)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 State: " & DllStructGetData($tItem, "State"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemFocused

Function Reference

_GUICtrlListView_GetItemFocused

Determines whether the item is highlighted as a drag-and-drop target

#include <GuiListView.au3>
_GUICtrlListView_GetItemFocused ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_SetItemFocused

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Item Focused", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Focus item 2
    _GUICtrlListView_SetItemFocused($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Focused: " & _GUICtrlListView_GetItemFocused($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemGroupID

Function Reference

_GUICtrlListView_GetItemGroupID

Gets the item group ID

#include <GuiListView.au3>
_GUICtrlListView_GetItemGroupID ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item

Return Value

Returns the item group ID.

Related

_GUICtrlListView_SetItemGroupID

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Get Item Group ID", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Build groups
    _GUICtrlListView_EnableGroupView($idListview)
    _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1")
    _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2")
    _GUICtrlListView_SetItemGroupID($idListview, 0, 1)
    _GUICtrlListView_SetItemGroupID($idListview, 1, 2)
    _GUICtrlListView_SetItemGroupID($idListview, 2, 2)

    ; Display Item 3 group ID
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 3 Group ID: " & _GUICtrlListView_GetItemGroupID($idListview, 2))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemImage

Function Reference

_GUICtrlListView_GetItemImage

Retrieves the index of the item's icon

#include <GuiListView.au3>
_GUICtrlListView_GetItemImage ( $hWnd, $iIndex [, $iSubItem = 0] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index
$iSubItem | [optional] 1-based item sub item index

Return Value

Success: | the 0-based item image index.
Failure: | -1.

Related

_GUICtrlListView_SetItemImage

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview, $iStylesEx = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    GUICreate("ListView Get Item Image", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iStylesEx)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Set item 1, subitem 1 image
    _GUICtrlListView_SetItemImage($idListview, 1, 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 1, SubItem 1 Image: " & _GUICtrlListView_GetItemImage($idListview, 1, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemIndent

Function Reference

_GUICtrlListView_GetItemIndent

Retrieves the number of image widths the item is indented

#include <GuiListView.au3>
_GUICtrlListView_GetItemIndent ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index

Return Value

Returns the item indention.

Related

_GUICtrlListView_SetItemIndent

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Get Item Indent", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    ; Indent items
    _GUICtrlListView_SetItemIndent($idListview, 1, 1)
    _GUICtrlListView_SetItemIndent($idListview, 2, 2)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Indent: " & _GUICtrlListView_GetItemIndent($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemParam

Function Reference

_GUICtrlListView_GetItemParam

Retrieves the application specific value of the item

#include <GuiListView.au3>
_GUICtrlListView_GetItemParam ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index

Return Value

Returns the application specific value.

Related

_GUICtrlListView_SetItemParam

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

; Warning do not use SetItemParam on items created with GUICtrlCreateListViewItem
; Param is the controlID for items created with built-in function

Example_UDF_Created()

Func Example_UDF_Created()
    Local $hGUI, $hListView

    $hGUI = GUICreate("(UDF Created) ListView Get Item Param", 400, 300)
    $hListView = _GUICtrlListView_Create($hGUI, "", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($hListView, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($hListView, "Item 1")
    _GUICtrlListView_AddItem($hListView, "Item 2")
    _GUICtrlListView_AddItem($hListView, "Item 3")

    ; Set item 2 parameter
    _GUICtrlListView_SetItemParam($hListView, 1, 1234)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Parameter: " & _GUICtrlListView_GetItemParam($hListView, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example_UDF_Created


Function _GUICtrlListView_GetItemPosition

Function Reference

_GUICtrlListView_GetItemPosition

Retrieves the position of an item

#include <GuiListView.au3>
_GUICtrlListView_GetItemPosition ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item

Return Value

Returns an array with the following format:
[0] - X position of item
[1] - Y position of item

Related

_GUICtrlListView_GetItemPositionX, _GUICtrlListView_GetItemPositionY, _GUICtrlListView_SetItemPosition

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aPos, $idListview

    GUICreate("ListView Get Item Position", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Get item 2 position
    $aPos = _GUICtrlListView_GetItemPosition($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item 2 Position : [%d, %d]", $aPos[0], $aPos[1]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemPositionX

Function Reference

_GUICtrlListView_GetItemPositionX

Retrieves the X position of an item

#include <GuiListView.au3>
_GUICtrlListView_GetItemPositionX ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item

Return Value

Returns the X position of item.

Related

_GUICtrlListView_GetItemPosition

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iX, $iY, $idListview

    GUICreate("ListView Get Item Position X", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Get item 2 position
    $iX = _GUICtrlListView_GetItemPositionX($idListview, 1)
    $iY = _GUICtrlListView_GetItemPositionY($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item 2 Position : [%d, %d]", $iX, $iY))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemPositionY

Function Reference

_GUICtrlListView_GetItemPositionY

Retrieves the Y position of an item

#include <GuiListView.au3>
_GUICtrlListView_GetItemPositionY ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item

Return Value

Return the Y position of item.

Related

_GUICtrlListView_GetItemPosition

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iX, $iY, $idListview

    GUICreate("ListView Get Item Position Y", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Get item 2 position
    $iX = _GUICtrlListView_GetItemPositionX($idListview, 1)
    $iY = _GUICtrlListView_GetItemPositionY($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item 2 Position : [%d, %d]", $iX, $iY))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemRect

Function Reference

_GUICtrlListView_GetItemRect

Retrieves the bounding rectangle for all or part of an item

#include <GuiListView.au3>
_GUICtrlListView_GetItemRect ( $hWnd, $iIndex [, $iPart = 3] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item
$iPart | [optional] The portion of the item to retrieve: 0 - The bounding rectangle of the entire item 1 - The bounding rectangle of the icon or small icon 2 - The bounding rectangle of the item text 3 - The union of 1 and 2, but excludes columns in report view

Return Value

Returns an array with the following format:
[0] - X coordinate of the upper left corner of the rectangle
[1] - Y coordinate of the upper left corner of the rectangle
[2] - X coordinate of the lower right corner of the rectangle
[3] - Y coordinate of the lower right corner of the rectangle

Related

_GUICtrlListView_GetItemRectEx

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aRect, $idListview

    GUICreate("ListView Get Item Rectangle", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Get item 2 rectangle
    $aRect = _GUICtrlListView_GetItemRect($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item 2 Rectangle : [%d, %d, %d, %d]", $aRect[0], $aRect[1], $aRect[2], $aRect[3]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemRectEx

Function Reference

_GUICtrlListView_GetItemRectEx

Retrieves the bounding rectangle for all or part of an item

#include <GuiListView.au3>
_GUICtrlListView_GetItemRectEx ( $hWnd, $iIndex [, $iPart = 3] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item
$iPart | [optional] The portion of the item to retrieve: $LVIR_BOUNDS - Returns the bounding rectangle of the entire item, including the icon and label $LVIR_ICON - Returns the bounding rectangle of the icon or small icon $LVIR_LABEL - Returns the bounding rectangle of the item text $LVIR_SELECTBOUNDS - Returns the union of the $LVIR_ICON and $LVIR_LABEL rectangles, but excludes columns in report view.

Return Value

Returns a $tagRECT structure.

Related

$tagRECT, _GUICtrlListView_GetItemRect

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $tRECT, $idListview

    GUICreate("ListView Get Item Rectangle Ex", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Get item 2 rectangle
    $tRECT = _GUICtrlListView_GetItemRectEx($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item 2 Rectangle : [%d, %d, %d, %d]", DllStructGetData($tRECT, "Left"), _
            DllStructGetData($tRECT, "Top"), DllStructGetData($tRECT, "Right"), DllStructGetData($tRECT, "Bottom")))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemSelected

Function Reference

_GUICtrlListView_GetItemSelected

Determines whether the item is selected

#include <GuiListView.au3>
_GUICtrlListView_GetItemSelected ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_SetItemSelected

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Item Selected", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Select item 2
    _GUICtrlListView_SetItemSelected($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Selected: " & _GUICtrlListView_GetItemSelected($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemSpacing

Function Reference

_GUICtrlListView_GetItemSpacing

Determines the spacing between items in the control

#include <GuiListView.au3>
_GUICtrlListView_GetItemSpacing ( $hWnd [, $bSmall = False] )

Parameters

$hWnd | Control ID/Handle to the control
$bSmall | [optional] View for which to retrieve the item spacing: True - Small icon view False - Icon view

Return Value

Returns an array with the following format:
[0] - Horizontal spacing
[1] - Vertical spacing

Related

_GUICtrlListView_GetItemSpacingX, _GUICtrlListView_GetItemSpacingY

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aSpace, $idListview

    GUICreate("ListView Get Item Spacing", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Show item spacing
    $aSpace = _GUICtrlListView_GetItemSpacing($idListview)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item Spacing: X=%d, Y=%d", $aSpace[0], $aSpace[1]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemSpacingX

Function Reference

_GUICtrlListView_GetItemSpacingX

Determines the horizontal spacing between items in the control

#include <GuiListView.au3>
_GUICtrlListView_GetItemSpacingX ( $hWnd [, $bSmall = False] )

Parameters

$hWnd | Control ID/Handle to the control
$bSmall | [optional] View for which to retrieve the item spacing: True - Small icon view False - Icon view

Return Value

Returns the horizontal spacing.

Related

_GUICtrlListView_GetItemSpacing

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iX, $iY, $idListview

    GUICreate("ListView Get Item Spacing X", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Show item spacing
    $iX = _GUICtrlListView_GetItemSpacingX($idListview)
    $iY = _GUICtrlListView_GetItemSpacingY($idListview)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item Spacing: X=%d, Y=%d", $iX, $iY))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemSpacingY

Function Reference

_GUICtrlListView_GetItemSpacingY

Determines the vertical spacing between items in the control

#include <GuiListView.au3>
_GUICtrlListView_GetItemSpacingY ( $hWnd [, $bSmall = False] )

Parameters

$hWnd | Control ID/Handle to the control
$bSmall | [optional] View for which to retrieve the item spacing: True - Small icon view False - Icon view

Return Value

Returns the vertical spacing.

Related

_GUICtrlListView_GetItemSpacing

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iX, $iY, $idListview

    GUICreate("ListView Get Item Spacing Y", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Show item spacing
    $iX = _GUICtrlListView_GetItemSpacingX($idListview)
    $iY = _GUICtrlListView_GetItemSpacingY($idListview)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item Spacing: X=%d, Y=%d", $iX, $iY))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemState

Function Reference

_GUICtrlListView_GetItemState

Retrieves the state of a listview item

#include <GuiListView.au3>
_GUICtrlListView_GetItemState ( $hWnd, $iIndex, $iMask )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item
$iMask | State information to retrieve. This can be a combination of: $LVIS_CUT - The item is marked for a cut-and-paste operation $LVIS_DROPHILITED - The item is highlighted as a drag-and-drop target $LVIS_FOCUSED - The item has the focus, so it is surrounded by a standard focus rectangle $LVIS_SELECTED - The item is selected $LVIS_OVERLAYMASK - Use this mask to retrieve the item's overlay image index $LVIS_STATEIMAGEMASK - Use this mask to retrieve the item's state image index

Return Value

Returns the current state for the specified item.

Remarks

An items state information includes a set of bit flags as well as image list indexes that indicate the item's state image and overlay image

Related

_GUICtrlListView_SetItemState

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Get Item State", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Get item 1 state
    _GUICtrlListView_SetItemState($idListview, 0, $LVIS_FOCUSED, $LVIS_FOCUSED)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 1 State: " & _GUICtrlListView_GetItemState($idListview, 0, $LVIS_FOCUSED))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemStateImage

Function Reference

_GUICtrlListView_GetItemStateImage

Gets the state image that is displayed

#include <GuiListView.au3>
_GUICtrlListView_GetItemStateImage ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item

Return Value

Returns the 1-based overlay image index.

Related

_GUICtrlListView_SetItemStateImage

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Get Item State", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)
    _GUICtrlListView_SetImageList($idListview, $hImage, 2)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 120)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Set item 2 state image
    _GUICtrlListView_SetItemStateImage($idListview, 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 State Image: " & _GUICtrlListView_GetItemStateImage($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemText

Function Reference

_GUICtrlListView_GetItemText

Retrieves the text of an item or subitem

#include <GuiListView.au3>
_GUICtrlListView_GetItemText ( $hWnd, $iIndex [, $iSubItem = 0] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item
$iSubItem | [optional] 1-based sub item index

Return Value

Returns the item or subitem text.

Remarks

To retrieve the item text, set $iSubItem to 0.
To retrieve the text of a subitem, set $iSubItem to the 1-based subitem's index.

Related

_GUICtrlListView_GetItemTextArray, _GUICtrlListView_GetItemTextString, _GUICtrlListView_SetItemText

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Item Text", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Set item 2 text
    _GUICtrlListView_SetItemText($idListview, 1, "New Item 2")
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Text: " & _GUICtrlListView_GetItemText($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemTextArray

Function Reference

_GUICtrlListView_GetItemTextArray

Retrieves all of a list-view item

#include <GuiListView.au3>
_GUICtrlListView_GetItemTextArray ( $hWnd [, $iItem = -1] )

Parameters

$hWnd | Control ID/Handle to the control
$iItem | [optional] 0-based index of item to retrieve

Return Value

Success: | an array with the following format: [0] - Number of Columns in array (n) [1] - First column subitem [2] - Second column subitem [n] - Last column subitem
Failure: | Array with the following format: [0] - Number of Columns in array (0)

Remarks

If $iItem = -1 then will attempt to get the Currently Selected item.

Related

_GUICtrlListView_GetItemText, _GUICtrlListView_GetItemTextString, _GUICtrlListView_SetItemText

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aItem, $sText, $idListview

    GUICreate("ListView Get Item Text Array", 400, 300)

    $idListview = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 268)
    GUICtrlCreateListViewItem("line1|data1|more1", $idListview)
    GUICtrlCreateListViewItem("line2|data2|more2", $idListview)
    GUICtrlCreateListViewItem("line3|data3|more3", $idListview)
    GUICtrlCreateListViewItem("line4|data4|more4", $idListview)
    GUICtrlCreateListViewItem("line5|data5|more5", $idListview)

    GUISetState(@SW_SHOW)

    ; Get item 2 text
    $aItem = _GUICtrlListView_GetItemTextArray($idListview, 1)
    For $i = 1 To $aItem[0]
        $sText &= StringFormat("Column[%2d] %s", $i, $aItem[$i]) & @CRLF
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 (All Columns) Text: " & @CRLF & @CRLF & $sText)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetItemTextString

Function Reference

_GUICtrlListView_GetItemTextString

Retrieves all of a list-view item

#include <GuiListView.au3>
_GUICtrlListView_GetItemTextString ( $hWnd [, $iItem = -1] )

Parameters

$hWnd | Control ID/Handle to the control
$iItem | [optional] 0-based index of item to retrieve

Return Value

Success: | a delimited string.
Failure: | an empty string.

Remarks

If $iItem = -1 then will attempt to get the Currently Selected item.

Related

_GUICtrlListView_GetItemText, _GUICtrlListView_GetItemTextArray, _GUICtrlListView_SetItemText

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Item Text String", 400, 300)

    $idListview = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 268)
    GUICtrlCreateListViewItem("line1|data1|more1", $idListview)
    GUICtrlCreateListViewItem("line2|data2|more2", $idListview)
    GUICtrlCreateListViewItem("line3|data3|more3", $idListview)
    GUICtrlCreateListViewItem("line4|data4|more4", $idListview)
    GUICtrlCreateListViewItem("line5|data5|more5", $idListview)
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Text: " & @CRLF & @CRLF & _GUICtrlListView_GetItemTextString($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetNextItem

Function Reference

_GUICtrlListView_GetNextItem

Searches for an item that has the specified properties

#include <GuiListView.au3>
_GUICtrlListView_GetNextItem ( $hWnd [, $iStart = -1 [, $iSearch = 0 [, $iState = 8]]] )

Parameters

$hWnd | Control ID/Handle to the control
$iStart | [optional] Index of the item to begin the search with, or -1 to find the first item that matches the specified flags. The specified item itself is excluded from the search.
$iSearch | [optional] Relationship to the index of the item where the search is to begin: 0 - Searches for a subsequent item by index 1 - Searches for an item that is above the specified item 2 - Searches for an item that is below the specified item 3 - Searches for an item to the left of the specified item 4 - Searches for an item to the right of the specified item
$iState | [optional] State of the item to find. Can be a combination of: 1 - The item is cut 2 - The item is highlighted 4 - The item is focused 8 - The item is selected

Return Value

Success: | the 0-based index of the next item.
Failure: | -1.

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Next Item", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Select item 2
    _GUICtrlListView_SetItemSelected($idListview, 1)

    ; Find selected item
    MsgBox($MB_SYSTEMMODAL, "Information", "Selected Item: " & _GUICtrlListView_GetNextItem($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetNumberOfWorkAreas

Function Reference

_GUICtrlListView_GetNumberOfWorkAreas

Retrieves the number of working areas in the control

#include <GuiListView.au3>
_GUICtrlListView_GetNumberOfWorkAreas ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the number of working areas.

Related

_GUICtrlListView_SetWorkAreas

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Get # of Work Areas", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUICtrlSetStyle($idListview, $LVS_ICON)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 0)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, 0, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    ; Create work area
    _GUICtrlListView_SetWorkAreas($idListview, 0, 0, 100, 100)
    MsgBox($MB_SYSTEMMODAL, "Information", "Work Areas: " & _GUICtrlListView_GetNumberOfWorkAreas($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetOrigin

Function Reference

_GUICtrlListView_GetOrigin

Retrieves the current view origin for the control

#include <GuiListView.au3>
_GUICtrlListView_GetOrigin ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an array with the following format:
[0] - View X position
[1] - View Y position

Related

_GUICtrlListView_GetOriginX, _GUICtrlListView_GetOriginY

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aOrigin, $hImage, $idListview

    GUICreate("ListView Get Origin", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUICtrlSetStyle($idListview, $LVS_ICON)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 0)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    ; Get current origin
    $aOrigin = _GUICtrlListView_GetOrigin($idListview)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Success: %s Origin: X=%d, Y=%d", @extended = 1, $aOrigin[0], $aOrigin[1]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetOriginX

Function Reference

_GUICtrlListView_GetOriginX

Retrieves the current horizontal view origin for the control

#include <GuiListView.au3>
_GUICtrlListView_GetOriginX ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the view X position.

Related

_GUICtrlListView_GetOrigin

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iX, $iY, $hImage, $idListview

    GUICreate("ListView Get Origin X", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUICtrlSetStyle($idListview, $LVS_ICON)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 0)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    ; Get current origin
    $iX = _GUICtrlListView_GetOriginX($idListview)
    $iY = _GUICtrlListView_GetOriginY($idListview)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Origin: X=%d, Y=%d", $iX, $iY))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetOriginY

Function Reference

_GUICtrlListView_GetOriginY

Retrieves the current vertical view origin for the control

#include <GuiListView.au3>
_GUICtrlListView_GetOriginY ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the view Y position.

Related

_GUICtrlListView_GetOrigin

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iX, $iY, $hImage, $idListview

    GUICreate("ListView Get Origin Y", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUICtrlSetStyle($idListview, $LVS_ICON)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 0)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    ; Get current origin
    $iX = _GUICtrlListView_GetOriginX($idListview)
    $iY = _GUICtrlListView_GetOriginY($idListview)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Origin: X=%d, Y=%d", $iX, $iY))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetOutlineColor

Function Reference

_GUICtrlListView_GetOutlineColor

Retrieves the color of the border of the control

#include <GuiListView.au3>
_GUICtrlListView_GetOutlineColor ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the border color of the control.

Remarks

Control must have the $LVS_EX_BORDERSELECT extended window style set.

Related

_GUICtrlListView_SetOutlineColor

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Get Outline Color", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUICtrlSetStyle($idListview, $LVS_ICON)
    ; Enable extended control styles
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $LVS_EX_BORDERSELECT)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 0)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    ; Set outline color
    _GUICtrlListView_SetOutlineColor($idListview, 0x0000FF)
    MsgBox($MB_SYSTEMMODAL, "Information", "Outline Color: " & Hex(_GUICtrlListView_GetOutlineColor($idListview)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetSelectedColumn

Function Reference

_GUICtrlListView_GetSelectedColumn

Retrieves the index of the selected column

#include <GuiListView.au3>
_GUICtrlListView_GetSelectedColumn ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the 0-based index of the selected column.
Failure: | -1.

Related

_GUICtrlListView_SetSelectedColumn

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Selected Column", 400, 300)
    $idListview = GUICtrlCreateListView("Column 1|Column 2|Column 3", 2, 2, 394, 268)
    GUICtrlCreateListViewItem("line1|data1|more1", $idListview)
    GUICtrlCreateListViewItem("line2|data2|more2", $idListview)
    GUICtrlCreateListViewItem("line3|data3|more3", $idListview)
    GUICtrlCreateListViewItem("line4|data4|more4", $idListview)
    GUICtrlCreateListViewItem("line5|data5|more5", $idListview)
    GUISetState(@SW_SHOW)

    ; Select column 2
    _GUICtrlListView_SetSelectedColumn($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Selected Column: " & _GUICtrlListView_GetSelectedColumn($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetSelectedCount

Function Reference

_GUICtrlListView_GetSelectedCount

Determines the number of selected items

#include <GuiListView.au3>
_GUICtrlListView_GetSelectedCount ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the number of selected items.

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Selected Count", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT))
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Select multiple items
    _GUICtrlListView_SetItemSelected($idListview, 1)
    _GUICtrlListView_SetItemSelected($idListview, 2)
    MsgBox($MB_SYSTEMMODAL, "Information", "Selected Count: " & _GUICtrlListView_GetSelectedCount($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetSelectedIndices

Function Reference

_GUICtrlListView_GetSelectedIndices

Retrieve indices of selected item(s)

#include <GuiListView.au3>
_GUICtrlListView_GetSelectedIndices ( $hWnd [, $bArray = False] )

Parameters

$hWnd | Control ID/Handle to the control
$bArray | [optional] Return string or Array True - Returns array False - Returns pipe "|" delimited string

Return Value

Success: | Selected indices Based on $bArray: Array - With the following format [0] - Number of Items in array (n) [1] - First item index [2] - Second item index [n] - Last item index String - With the following format "0|1|2|n"
Failure: | Based on $bArray Array - With the following format [0] - Number of Items in array (0) String - Empty ("")

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Selected Indices", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT))
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Select multiple items
    _GUICtrlListView_SetItemSelected($idListview, 1)
    _GUICtrlListView_SetItemSelected($idListview, 2)
    MsgBox($MB_SYSTEMMODAL, "Information", "Selected Indices: " & _GUICtrlListView_GetSelectedIndices($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetSelectionMark

Function Reference

_GUICtrlListView_GetSelectionMark

Retrieves the selection mark from the control

#include <GuiListView.au3>
_GUICtrlListView_GetSelectionMark ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the 0-based selection mark.
Failure: | -1.

Remarks

The selection mark is the item index from which a multiple selection starts.

Related

_GUICtrlListView_SetSelectionMark

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Selection Mark", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT))
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Select item 1
    _GUICtrlListView_SetSelectionMark($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Selected Mark: " & _GUICtrlListView_GetSelectionMark($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetStringWidth

Function Reference

_GUICtrlListView_GetStringWidth

Determines the width of a specified string

#include <GuiListView.au3>
_GUICtrlListView_GetStringWidth ( $hWnd, $sString )

Parameters

$hWnd | Control ID/Handle to the control
$sString | String for which the width will be calculated

Return Value

Success: | the string width.
Failure: | 0

Remarks

This function returns the exact width, in pixels, of the specified string.
If you use the returned string width as the column width in the _GUICtrlListView_SetColumnWidth() function the string will be truncated.
To retrieve the column width that can contain the string without truncating it, you must add padding to the returned string width.

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get String Width", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT))
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Get width of string
    MsgBox($MB_SYSTEMMODAL, "Information", 'Width of "Test": ' & _GUICtrlListView_GetStringWidth($idListview, "Test"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetSubItemRect

Function Reference

_GUICtrlListView_GetSubItemRect

Retrieves information about an item bounding rectangle

#include <GuiListView.au3>
_GUICtrlListView_GetSubItemRect ( $hWnd, $iIndex, $iSubItem [, $iPart = 0] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the subitem's parent item
$iSubItem | 1-based index of the subitem
$iPart | [optional] The portion of the subitem item to retrieve: 0 - The rectangle of the entire subitem, including the icon and label 1 - The rectangle of the icon or small icon

Return Value

Returns an array with the following format:
[0] - X coordinate of the upper left corner of the rectangle
[1] - Y coordinate of the upper left corner of the rectangle
[2] - X coordinate of the lower right corner of the rectangle
[3] - Y coordinate of the lower right corner of the rectangle

Remarks

This function is used only with controls that use the $LVS_REPORT style.

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aRect, $idListview

    GUICreate("ListView Get SubItem Rect", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1")
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1")
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1")

    ; Show item 2 sub item rect
    $aRect = _GUICtrlListView_GetSubItemRect($idListview, 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Subitem Rectangle : [%d, %d, %d, %d]", $aRect[0], $aRect[1], $aRect[2], $aRect[3]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetTextBkColor

Function Reference

_GUICtrlListView_GetTextBkColor

Retrieves the text background color of the control

#include <GuiListView.au3>
_GUICtrlListView_GetTextBkColor ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the text background color.

Related

_GUICtrlListView_SetTextBkColor

Example

#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Text BkColor", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Set colors
    _GUICtrlListView_SetBkColor($idListview, $CLR_MONEYGREEN)
    _GUICtrlListView_SetTextColor($idListview, $CLR_BLACK)
    _GUICtrlListView_SetTextBkColor($idListview, $CLR_MONEYGREEN)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Show colors
    MsgBox($MB_SYSTEMMODAL, "Information", "Back Color ....: " & _GUICtrlListView_GetBkColor($idListview) & @CRLF & _
            "Text Color ....: " & _GUICtrlListView_GetTextColor($idListview) & @CRLF & _
            "Text Back Color: " & _GUICtrlListView_GetTextBkColor($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetTextColor

Function Reference

_GUICtrlListView_GetTextColor

Retrieves the text color of the control

#include <GuiListView.au3>
_GUICtrlListView_GetTextColor ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the text color.

Related

_GUICtrlListView_SetTextColor

Example

#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Text Color", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Set colors
    _GUICtrlListView_SetBkColor($idListview, $CLR_MONEYGREEN)
    _GUICtrlListView_SetTextColor($idListview, $CLR_BLACK)
    _GUICtrlListView_SetTextBkColor($idListview, $CLR_MONEYGREEN)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Show colors
    MsgBox($MB_SYSTEMMODAL, "Information", "Back Color ....: " & _GUICtrlListView_GetBkColor($idListview) & @CRLF & _
            "Text Color ....: " & _GUICtrlListView_GetTextColor($idListview) & @CRLF & _
            "Text Back Color: " & _GUICtrlListView_GetTextBkColor($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetToolTips

Function Reference

_GUICtrlListView_GetToolTips

Retrieves the ToolTip control handle

#include <GuiListView.au3>
_GUICtrlListView_GetToolTips ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the handle of the ToolTip control.

Related

_GUICtrlListView_SetToolTips

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGui, $hToolTip, $hListView

    $hGui = GUICreate("ListView Get ToolTips", 400, 300)
    $hListView = _GUICtrlListView_Create($hGui, "", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($hListView, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($hListView, "Item 1")
    _GUICtrlListView_AddItem($hListView, "Item 2")
    _GUICtrlListView_AddItem($hListView, "Item 3")

    ; Show tooltip handle
    $hToolTip = _GUICtrlListView_GetToolTips($hListView)
    MsgBox($MB_SYSTEMMODAL, "Information", "ToolTip Handle: 0x" & Hex($hToolTip) & @CRLF & _
            "IsPtr = " & IsPtr($hToolTip) & " IsHWnd = " & IsHWnd($hToolTip))

    _GUICtrlListView_SetToolTips($hListView, $hToolTip)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetTopIndex

Function Reference

_GUICtrlListView_GetTopIndex

Retrieves the index of the topmost visible item when in list or report view

#include <GuiListView.au3>
_GUICtrlListView_GetTopIndex ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the 0-based index of the item.
Zero if the list-view control is in icon or small icon view.

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Top Index", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 100
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Select item 50
    _GUICtrlListView_SetItemSelected($idListview, 49)
    _GUICtrlListView_EnsureVisible($idListview, 49)
    MsgBox($MB_SYSTEMMODAL, "Information", "Top Index: " & _GUICtrlListView_GetTopIndex($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetUnicodeFormat

Function Reference

_GUICtrlListView_GetUnicodeFormat

Retrieves the Unicode character format flag for the control

#include <GuiListView.au3>
_GUICtrlListView_GetUnicodeFormat ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

True: | using Unicode characters.
False: | using ANSI characters.

Related

_GUICtrlListView_SetUnicodeFormat

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Unicode Format", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Set Unicode format
    MsgBox($MB_SYSTEMMODAL, "Information", "Unicode: " & _GUICtrlListView_GetUnicodeFormat($idListview))
    _GUICtrlListView_SetUnicodeFormat($idListview, True)
    MsgBox($MB_SYSTEMMODAL, "Information", "Unicode: " & _GUICtrlListView_GetUnicodeFormat($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetView

Function Reference

_GUICtrlListView_GetView

Retrieves the current view of the control

#include <GuiListView.au3>
_GUICtrlListView_GetView ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | The current view: 0 - Large Icon 1 - Details 2 - List 3 - Small Icon 4 - Tile
Failure: | -1.

Related

_GUICtrlListView_GetViewDetails, _GUICtrlListView_GetViewLarge, _GUICtrlListView_GetViewList, _GUICtrlListView_GetViewSmall, _GUICtrlListView_GetViewTile, _GUICtrlListView_SetView

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get View", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Set view
    MsgBox($MB_SYSTEMMODAL, "Information", "View: " & _GUICtrlListView_GetView($idListview))
    _GUICtrlListView_SetView($idListview, 4)
    MsgBox($MB_SYSTEMMODAL, "Information", "View: " & _GUICtrlListView_GetView($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetViewDetails

Function Reference

_GUICtrlListView_GetViewDetails

Determines whether the view mode is in detail mode

#include <GuiListView.au3>
_GUICtrlListView_GetViewDetails ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

True: | view is in detail mode.
False: | view is not in detail mode.

Related

_GUICtrlListView_GetView

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Details", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Set view
    _GUICtrlListView_SetView($idListview, 0)
    MsgBox($MB_SYSTEMMODAL, "Information", "View Details: " & _GUICtrlListView_GetViewDetails($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetViewLarge

Function Reference

_GUICtrlListView_GetViewLarge

Determines whether the view mode is in large icon mode

#include <GuiListView.au3>
_GUICtrlListView_GetViewLarge ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

True: | view is in large icon mode.
False: | view is not in large icon mode.

Related

_GUICtrlListView_GetView

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get View Large Icon", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Set view
    _GUICtrlListView_SetView($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "View Large: " & _GUICtrlListView_GetViewLarge($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetViewList

Function Reference

_GUICtrlListView_GetViewList

Determines whether the view mode is in list mode

#include <GuiListView.au3>
_GUICtrlListView_GetViewList ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

True: | view is in list mode.
False: | view is not in list mode.

Related

_GUICtrlListView_GetView

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get View List", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Set view
    _GUICtrlListView_SetView($idListview, 2)
    MsgBox($MB_SYSTEMMODAL, "Information", "View List: " & _GUICtrlListView_GetViewList($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetViewRect

Function Reference

_GUICtrlListView_GetViewRect

Retrieves the bounding rectangle of all items in the control

#include <GuiListView.au3>
_GUICtrlListView_GetViewRect ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an array with the following format:
[0] - X coordinate of the upper left corner of the rectangle
[1] - Y coordinate of the upper left corner of the rectangle
[2] - X coordinate of the lower right corner of the rectangle
[3] - Y coordinate of the lower right corner of the rectangle

Remarks

The control must be in icon or small icon view.

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aRect, $idListview

    GUICreate("ListView Get View Rect", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Set view
    _GUICtrlListView_SetView($idListview, 3)

    ; Get view rectangle
    $aRect = _GUICtrlListView_GetViewRect($idListview)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("View Tile: [%d, %d, %d, %d]", $aRect[0], $aRect[1], $aRect[2], $aRect[3]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetViewSmall

Function Reference

_GUICtrlListView_GetViewSmall

Determines whether the view mode is in small icon mode

#include <GuiListView.au3>
_GUICtrlListView_GetViewSmall ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

True: | view is in small icon mode.
False: | view is not in small icon mode.

Related

_GUICtrlListView_GetView

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get View Small Icon", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Set view
    _GUICtrlListView_SetView($idListview, 3)
    MsgBox($MB_SYSTEMMODAL, "Information", "View Small: " & _GUICtrlListView_GetViewSmall($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_GetViewTile

Function Reference

_GUICtrlListView_GetViewTile

Determines whether the view mode is in tile mode

#include <GuiListView.au3>
_GUICtrlListView_GetViewTile ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

True: | view is in tile mode.
False: | view is not in tile mode.

Related

_GUICtrlListView_GetView

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get View Tile", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Set view
    _GUICtrlListView_SetView($idListview, 4)
    MsgBox($MB_SYSTEMMODAL, "Information", "View Tile: " & _GUICtrlListView_GetViewTile($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_HideColumn

Function Reference

_GUICtrlListView_HideColumn

Hides the column "sets column width to zero"

#include <GuiListView.au3>
_GUICtrlListView_HideColumn ( $hWnd, $iCol )

Parameters

$hWnd | Control ID/Handle to the control
$iCol | Column to hide

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_SetColumnWidth

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Hide Column", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    MsgBox($MB_SYSTEMMODAL, "Information", "Hiding Column 2")
    MsgBox($MB_SYSTEMMODAL, "Information", "Column 2 Hid: " & _GUICtrlListView_HideColumn($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_HitTest

Function Reference

_GUICtrlListView_HitTest

Determines which item is at a specified position

#include <GuiListView.au3>
_GUICtrlListView_HitTest ( $hWnd [, $iX = -1 [, $iY = -1]] )

Parameters

$hWnd | Control ID/Handle to the control
$iX | [optional] X position, in client coordinates, to be tested or -1 to use the current mouse position
$iY | [optional] Y position, in client coordinates, to be tested or -1 to use the current mouse position

Return Value

Success: | an array with the following format: [0] - 0-based index of the item at the specified position, or -1 [1] - If True, position is in control's client window but not on an item [2] - If True, position is over item icon [3] - If True, position is over item text [4] - If True, position is over item state image [5] - If True, position is somewhere on the item [6] - If True, position is above the control's client area [7] - If True, position is below the control's client area [8] - If True, position is to the left of the client area [9] - If True, position is to the right of the client area
Failure: | sets the @error flag to non-zero.

Related

_GUICtrlListView_SubItemHitTest

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Global $g_idListView, $g_hStatusBar, $g_iIndex = -1

Example()

Func Example()
    Local $hImage, $hGUI

    ; Create GUI
    $hGUI = GUICreate("ListView Hit Test", 400, 300)
    $g_idListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    $g_idListView = GUICtrlGetHandle($g_idListView) ; get the handle for use in the notify events
    $g_hStatusBar = _GUICtrlStatusBar_Create($hGUI, -1, "")

    ; Enable extended control styles
    _GUICtrlListView_SetExtendedListViewStyle($g_idListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_idListView, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_idListView, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_idListView, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($g_idListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($g_idListView, "Column 1", 100)
    _GUICtrlListView_AddColumn($g_idListView, "Column 2", 100)
    _GUICtrlListView_AddColumn($g_idListView, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($g_idListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($g_idListView, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($g_idListView, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($g_idListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($g_idListView, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($g_idListView, "Row 3: Col 1", 2)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete()
EndFunc   ;==>Example

Func _ListView_Click()
    Local $aHit

    $aHit = _GUICtrlListView_HitTest($g_idListView)
    If ($aHit[0] <> -1) And ($aHit[0] <> $g_iIndex) Then
        _GUICtrlStatusBar_SetText($g_hStatusBar, @TAB & StringFormat("HitTest Item: %d", $aHit[0]))
        $g_iIndex = $aHit[0]
    EndIf
EndFunc   ;==>_ListView_Click

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    $hWndListView = $g_idListView
    If Not IsHWnd($g_idListView) Then $hWndListView = GUICtrlGetHandle($g_idListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $LVN_COLUMNCLICK ; A column was clicked
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    _DebugPrint("$LVN_COLUMNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    ; No return value
                Case $LVN_KEYDOWN ; A key has been pressed
                    $tInfo = DllStructCreate($tagNMLVKEYDOWN, $lParam)
                    _DebugPrint("$LVN_KEYDOWN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->VKey:" & @TAB & DllStructGetData($tInfo, "VKey") & @CRLF & _
                            "-->Flags:" & @TAB & DllStructGetData($tInfo, "Flags"))
                    ; No return value
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    _ListView_Click()
                    ; No return value
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_KILLFOCUS ; The control has lost the input focus
                    _DebugPrint("$NM_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ;Return 1 ; not to allow the default processing
                    Return 0 ; allow the default processing
                Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
                    _DebugPrint("$NM_RETURN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_SETFOCUS ; The control has received the input focus
                    _DebugPrint("$NM_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlListView_InsertColumn

Function Reference

_GUICtrlListView_InsertColumn

Inserts a new column in the control

#include <GuiListView.au3>
_GUICtrlListView_InsertColumn ( $hWnd, $iIndex, $sText [, $iWidth = 50 [, $iAlign = -1 [, $iImage = -1 [, $bOnRight = False]]]] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of new column
$sText | Column header text
$iWidth | [optional] Width of the column, in pixels
$iAlign | [optional] Alignment of the column header and the subitem text in the column: 0 - Text is left aligned 1 - Text is right aligned 2 - Text is centered
$iImage | [optional] 0-based index of an image within the image list
$bOnRight | [optional] If True, the column image appears to the right of text

Return Value

Success: | the index of the new column.
Failure: | -1.

Remarks

The alignment of the leftmost column is always left-justified; it cannot be changed.

Related

_GUICtrlListView_DeleteColumn

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Insert Column", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Insert columns
    _GUICtrlListView_InsertColumn($idListview, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($idListview, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($idListview, 2, "Column 3", 100)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_InsertGroup

Function Reference

_GUICtrlListView_InsertGroup

Inserts a group

#include <GuiListView.au3>
_GUICtrlListView_InsertGroup ( $hWnd, $iIndex, $iGroupID, $sHeader [, $iAlign = 0] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Index where the group is to be added. If this is -1, the group is added at the end of the list.
$iGroupID | ID of the group
$sHeader | Header text
$iAlign | [optional] Alignment of the header text for the group: 0 - Left 1 - Center 2 - Right

Return Value

Success: | the index of the item that the group was added to.
Failure: | -1.

Remarks

A group cannot be inserted into an empty control.

Related

_GUICtrlListView_SetItemGroupID

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Insert Group", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    ; Enable extended control styles
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Build groups
    _GUICtrlListView_EnableGroupView($idListview)
    _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1")
    _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2")
    _GUICtrlListView_SetItemGroupID($idListview, 0, 1)
    _GUICtrlListView_SetItemGroupID($idListview, 1, 2)
    _GUICtrlListView_SetItemGroupID($idListview, 2, 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_InsertItem

Function Reference

_GUICtrlListView_InsertItem

Inserts a new item in the control

#include <GuiListView.au3>
_GUICtrlListView_InsertItem ( $hWnd, $sText [, $iIndex = -1 [, $iImage = -1 [, $iParam = 0]]] )

Parameters

$hWnd | Control ID/Handle to the control
$sText | Item text. If set to -1, the item text is set via the $LVN_GETDISPINFO notification message.
$iIndex | [optional] 0-based index at which the new item should be inserted. If this value is greater than the number of items currently contained by the control, the new item will be appended to the end of the list and assigned the correct index.
$iImage | [optional] 0-based index of the item's icon in the control's image list
$iParam | [optional] Application Defined Data

Return Value

Success: | the index of the new item.
Failure: | -1.

Remarks

You can not use this function to insert subitems. Use _GUICtrlListView_SetItemText() to insert subitems.

As AutoIt uses the $iParam parameter to store the controlID of native-created ListView items, this value should be set sufficiently high for UDF-created items to avoid possible conflict with any existing controls - a starting value of 1000 is recommended.

Related

_GUICtrlListView_SetItemText

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Insert Item", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Insert columns
    _GUICtrlListView_InsertColumn($idListview, 0, "Column 1", 100)

    ; Add items
    _GUICtrlListView_InsertItem($idListview, "Item 1", 0)
    _GUICtrlListView_InsertItem($idListview, "Item 2", 1)
    _GUICtrlListView_InsertItem($idListview, "Item 3", 1)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_JustifyColumn

Function Reference

_GUICtrlListView_JustifyColumn

Set Justification of a column for a list-view control

#include <GuiListView.au3>
_GUICtrlListView_JustifyColumn ( $hWnd, $iIndex [, $iAlign = -1] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of new column
$iAlign | [optional] Alignment of the column header and the subitem text in the column: 0 - Text is left aligned 1 - Text is right aligned 2 - Text is centered

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_GetColumn, _GUICtrlListView_SetColumn

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aInfo, $idListview

    GUICreate("ListView Justify Column", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Change column
    $aInfo = _GUICtrlListView_GetColumn($idListview, 0)
    MsgBox($MB_SYSTEMMODAL, "Information", "Column 1 Justification: " & $aInfo[0])
    _GUICtrlListView_JustifyColumn($idListview, 0, 2)
    $aInfo = _GUICtrlListView_GetColumn($idListview, 0)
    MsgBox($MB_SYSTEMMODAL, "Information", "Column 1 Justification: " & $aInfo[0])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_MapIDToIndex

Function Reference

_GUICtrlListView_MapIDToIndex

Maps the ID of an item to an index

#include <GuiListView.au3>
_GUICtrlListView_MapIDToIndex ( $hWnd, $iID )

Parameters

$hWnd | Control ID/Handle to the control
$iID | ID of an item

Return Value

Returns the most current index.

Remarks

ListView controls internally track items by index.
This can present problems because indexes can change during the control's lifetime.

The ListView control can tag an item with an ID when the item is created.
You can use this ID to guarantee uniqueness during the lifetime of the control.

Related

_GUICtrlListView_MapIndexToID

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iID, $idListview

    GUICreate("ListView Map ID To Index", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add column
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Show ID for item 2
    $iID = _GUICtrlListView_MapIndexToID($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Index to ID: " & $iID)
    MsgBox($MB_SYSTEMMODAL, "Information", "ID to Index: " & _GUICtrlListView_MapIDToIndex($idListview, $iID))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_MapIndexToID

Function Reference

_GUICtrlListView_MapIndexToID

Maps an index to an item ID

#include <GuiListView.au3>
_GUICtrlListView_MapIndexToID ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of an item

Return Value

Returns the ID of the item.

Remarks

ListView controls internally track items by index.
This can present problems because indexes can change during the control's lifetime.

The ListView control can tag an item with an ID when the item is created.
You can use this ID to guarantee uniqueness during the lifetime of the control.

Related

_GUICtrlListView_MapIDToIndex

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iID, $idListview

    GUICreate("ListView Map Index  To ID", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add column
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Show ID for item 2
    $iID = _GUICtrlListView_MapIndexToID($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Index to ID: " & $iID)
    MsgBox($MB_SYSTEMMODAL, "Information", "ID to Index: " & _GUICtrlListView_MapIDToIndex($idListview, $iID))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_RedrawItems

Function Reference

_GUICtrlListView_RedrawItems

Forces the control to redraw a range of items

#include <GuiListView.au3>
_GUICtrlListView_RedrawItems ( $hWnd, $iFirst, $iLast )

Parameters

$hWnd | Control ID/Handle to the control
$iFirst | 0-based index of the first item to redraw
$iLast | 0-based index of the last item to redraw

Return Value

Success: | True.
Failure: | False.

Remarks

The specified items are not actually redrawn until the control receives a $WM_PAINT message to repaint.

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Redraw Items", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add column
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Redraw items
    _GUICtrlListView_RedrawItems($idListview, 0, 9)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_RegisterSortCallBack

Function Reference

_GUICtrlListView_RegisterSortCallBack

Register the Simple Sort callback function

#include <GuiListView.au3>
_GUICtrlListView_RegisterSortCallBack ( $hWnd [, $bNumbers = True [, $bArrows = True]] )

Parameters

$hWnd | Handle of the control
$bNumbers | [optional] Treat number strings as numbers
$bArrows | [optional] Draws a down-arrow/up-arrow on column selected

Return Value

Success: | True.
Failure: | False.

Remarks

For each call to _GUICtrlListView_RegisterSortCallBack() there must be a call to _GUICtrlListView_UnRegisterSortCallBack() when done (before exit).

It is up to the user to call _GUICtrlListView_UnRegisterSortCallBack() for each _GUICtrlListView_RegisterSortCallBack() call made.

This is an alternative to the _GUICtrlListView_SimpleSort().

This function will sort listviews that have icons, checkboxes, sub-item icons.

Related

_GUICtrlListView_SortItems, _GUICtrlListView_UnRegisterSortCallBack

Example

Example 1

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Global $g_idListView

Example()

Func Example()
    Local $hImage, $aIcons[3] = [0, 3, 6]
    Local $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE)
    Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER)

    GUICreate("ListView Sort", 300, 200)

    $g_idListView = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180, -1, $iExWindowStyle)
    _GUICtrlListView_SetExtendedListViewStyle($g_idListView, $iExListViewStyle)

    ; Load images
    $hImage = _GUIImageList_Create(18, 18, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -7)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -12)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -4)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -5)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -6)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -9)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -10)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -11)
    _GUICtrlListView_SetImageList($g_idListView, $hImage, 1)

    _AddRow($g_idListView, "ABC|000666|10.05.2004", $aIcons)
    _AddRow($g_idListView, "DEF|444|11.05.2005", $aIcons, 1)
    _AddRow($g_idListView, "CDE|555|12.05.2004", $aIcons, 2)

    GUISetState(@SW_SHOW)

    _GUICtrlListView_RegisterSortCallBack($g_idListView)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $g_idListView
                ; Kick off the sort callback
                _GUICtrlListView_SortItems($g_idListView, GUICtrlGetState($g_idListView))
        EndSwitch
    WEnd

    _GUICtrlListView_UnRegisterSortCallBack($g_idListView)
    GUIDelete()
EndFunc   ;==>Example

Func _AddRow($hWnd, $sItem, $aIcons, $iPlus = 0)
    Local $aItem = StringSplit($sItem, "|")
    Local $iIndex = _GUICtrlListView_AddItem($hWnd, $aItem[1], $aIcons[0] + $iPlus, _GUICtrlListView_GetItemCount($hWnd) + 9999)
    _GUICtrlListView_SetColumnWidth($hWnd, 0, $LVSCW_AUTOSIZE_USEHEADER)

    For $x = 2 To $aItem[0]
        _GUICtrlListView_AddSubItem($hWnd, $iIndex, $aItem[$x], $x - 1, $aIcons[$x - 1] + $iPlus)
        _GUICtrlListView_SetColumnWidth($hWnd, $x - 1, $LVSCW_AUTOSIZE)
    Next
EndFunc   ;==>_AddRow

Example 2

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Global $g_idListView, $g_idListView2

Example()

Func Example()
    Local $hImage, $aIcons[3] = [0, 3, 6]
    Local $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE)
    Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER)

    GUICreate("ListView Sort Treat Numbers as Strings", 300, 200, 100)

    $g_idListView = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180, -1, $iExWindowStyle)
    _GUICtrlListView_SetExtendedListViewStyle($g_idListView, $iExListViewStyle)

    ; Load images
    $hImage = _GUIImageList_Create(18, 18, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -7)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -12)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -4)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -5)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -6)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -9)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -10)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -11)
    _GUICtrlListView_SetImageList($g_idListView, $hImage, 1)

    _AddRow($g_idListView, "ABC|000666|10.05.2004", $aIcons)
    _AddRow($g_idListView, "DEF|444|11.05.2005", $aIcons, 1)
    _AddRow($g_idListView, "CDE|555|12.05.2004", $aIcons, 2)

    GUISetState(@SW_SHOW)

    GUICreate("ListView Sort Treat Numbers as Numbers", 300, 200, 400)

    $g_idListView2 = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180, -1, $iExWindowStyle)
    _GUICtrlListView_SetExtendedListViewStyle($g_idListView2, $iExListViewStyle)
    _GUICtrlListView_SetImageList($g_idListView2, $hImage, 1)

    _AddRow($g_idListView2, "ABC|000666|10.05.2004", $aIcons)
    _AddRow($g_idListView2, "DEF|444|11.05.2005", $aIcons, 1)
    _AddRow($g_idListView2, "CDE|555|12.05.2004", $aIcons, 2)

    GUISetState(@SW_SHOW)

    _GUICtrlListView_RegisterSortCallBack($g_idListView, False)
    _GUICtrlListView_RegisterSortCallBack($g_idListView2)
    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    _GUICtrlListView_UnRegisterSortCallBack($g_idListView)
    _GUICtrlListView_UnRegisterSortCallBack($g_idListView2)
    GUIRegisterMsg($WM_NOTIFY, "")
EndFunc   ;==>Example

Func _AddRow($hWnd, $sItem, $aIcons, $iPlus = 0)
    Local $aItem = StringSplit($sItem, "|")
    Local $iIndex = _GUICtrlListView_AddItem($hWnd, $aItem[1], $aIcons[0] + $iPlus, _GUICtrlListView_GetItemCount($hWnd) + 9999)
    _GUICtrlListView_SetColumnWidth($hWnd, 0, $LVSCW_AUTOSIZE_USEHEADER)

    For $x = 2 To $aItem[0]
        _GUICtrlListView_AddSubItem($hWnd, $iIndex, $aItem[$x], $x - 1, $aIcons[$x - 1] + $iPlus)
        _GUICtrlListView_SetColumnWidth($hWnd, $x - 1, $LVSCW_AUTOSIZE)
    Next
EndFunc   ;==>_AddRow

Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $hWndListView, $hWndListView2

    $hWndListView = $g_idListView
    $hWndListView2 = $g_idListView2
    If Not IsHWnd($g_idListView) Then $hWndListView = GUICtrlGetHandle($g_idListView)
    If Not IsHWnd($g_idListView2) Then $hWndListView2 = GUICtrlGetHandle($g_idListView2)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $hWndFrom
        Case $hWndListView, $hWndListView2
            Switch $iCode
                Case $LVN_COLUMNCLICK ; A column was clicked
                    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)

                    ; Kick off the sort callback
                    _GUICtrlListView_SortItems($hWndFrom, DllStructGetData($tInfo, "SubItem"))
                    ; No return value
            EndSwitch
    EndSwitch
    Return $__LISTVIEWCONSTANT_GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY


Function _GUICtrlListView_RemoveAllGroups

Function Reference

_GUICtrlListView_RemoveAllGroups

Removes all groups from the control

#include <GuiListView.au3>
_GUICtrlListView_RemoveAllGroups ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

None.

Related

_GUICtrlListView_RemoveGroup

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Remove All Groups", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    ; Enable extended control styles
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Build groups
    _GUICtrlListView_EnableGroupView($idListview)
    _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1")
    _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2")
    _GUICtrlListView_SetItemGroupID($idListview, 0, 1)
    _GUICtrlListView_SetItemGroupID($idListview, 1, 2)
    _GUICtrlListView_SetItemGroupID($idListview, 2, 2)

    ; Remove all groups
    MsgBox($MB_SYSTEMMODAL, "Information", "Removing groups")
    _GUICtrlListView_RemoveAllGroups($idListview)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_RemoveGroup

Function Reference

_GUICtrlListView_RemoveGroup

Removes a group from the control

#include <GuiListView.au3>
_GUICtrlListView_RemoveGroup ( $hWnd, $iGroupID )

Parameters

$hWnd | Control ID/Handle to the control
$iGroupID | ID that specifies the group to remove

Return Value

Success: | the index of the group.
Failure: | -1.

Related

_GUICtrlListView_RemoveAllGroups

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Remove Group", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    ; Enable extended control styles
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Build groups
    _GUICtrlListView_EnableGroupView($idListview)
    _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1")
    _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2")
    _GUICtrlListView_SetItemGroupID($idListview, 0, 1)
    _GUICtrlListView_SetItemGroupID($idListview, 1, 2)
    _GUICtrlListView_SetItemGroupID($idListview, 2, 2)

    ; Remove group
    MsgBox($MB_SYSTEMMODAL, "Information", "Removing group 1")
    _GUICtrlListView_RemoveGroup($idListview, 1)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_Scroll

Function Reference

_GUICtrlListView_Scroll

Scrolls the content of a list-view

#include <GuiListView.au3>
_GUICtrlListView_Scroll ( $hWnd, $iDX, $iDY )

Parameters

$hWnd | Control ID/Handle to the control
$iDX | Value of type int that specifies the amount of horizontal scrolling in pixels. If the list-view control is in list-view, this value specifies the number of columns to scroll.
$iDY | Value of type int that specifies the amount of vertical scrolling in pixels

Return Value

Success: | True.
Failure: | False.

Remarks

When the list-view control is in report view, the control can only be scrolled vertically in whole line increments.
Therefore, the $iDY parameter will be rounded to the nearest number of pixels that form a whole line increment.
For example, if the height of a line is 16 pixels and 8 is passed for $iDY, the list will be scrolled by 16 pixels (1 line).
If 7 is passed for $iDY, the list will be scrolled 0 pixels (0 lines).

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Scroll", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add column
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 100
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Scroll control 500 pixels
    _GUICtrlListView_Scroll($idListview, 0, 500)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetBkColor

Function Reference

_GUICtrlListView_SetBkColor

Sets the background color of the control

#include <GuiListView.au3>
_GUICtrlListView_SetBkColor ( $hWnd, $iColor )

Parameters

$hWnd | Control ID/Handle to the control
$iColor | Background color to set or CLR_NONE value for no background color

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_GetBkColor

Example

#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set BkColor", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Set colors
    _GUICtrlListView_SetBkColor($idListview, $CLR_MONEYGREEN)
    _GUICtrlListView_SetTextColor($idListview, $CLR_BLACK)
    _GUICtrlListView_SetTextBkColor($idListview, $CLR_MONEYGREEN)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Show colors
    MsgBox($MB_SYSTEMMODAL, "Information", "Back Color ....: " & _GUICtrlListView_GetBkColor($idListview) & @CRLF & _
            "Text Color ....: " & _GUICtrlListView_GetTextColor($idListview) & @CRLF & _
            "Text Back Color: " & _GUICtrlListView_GetTextBkColor($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetBkImage

Function Reference

_GUICtrlListView_SetBkImage

Sets the background image in the control

#include <GuiListView.au3>
_GUICtrlListView_SetBkImage ( $hWnd [, $sURL = "" [, $iStyle = 0 [, $iXOffset = 0 [, $iYOffset = 0]]]] )

Parameters

$hWnd | Control ID/Handle to the control
$sURL | [optional] URL of the background image. If blank, the control has no background
$iStyle | [optional] Determines the background image style: 0 - Normal 1 - Tiled
$iXOffset | [optional] Percentage of the control's client area that the image should be offset horizontally. Only valid when 0 is used in $iStyle.
$iYOffset | [optional] Percentage of the control's client area that the image should be offset vertically. Only valid when 0 is used in $iStyle.

Return Value

Success: | True.
Failure: | False.

Remarks

Call CoUninitialize when the application is terminating.
At this time this function only works with _GUICtrlListView_Create() or External ListViews.

Related

_GUICtrlListView_Create, _GUICtrlListView_GetBkImage

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example_UDF_Created() ;use UDF built listview

Func Example_UDF_Created()
    Local $hGUI, $hImage, $aImage, $hListView
    Local $iStylesEx = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)

    $hGUI = GUICreate("(UDF Created) ListView Set Background Image", 600, 550)

    $hListView = _GUICtrlListView_Create($hGUI, "", 2, 2, 596, 500, -1, -1, True) ; Last option Calls CoInitializeEx
    _GUICtrlListView_SetExtendedListViewStyle($hListView, $iStylesEx)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($hListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)

    ; Build groups
    _GUICtrlListView_EnableGroupView($hListView)
    _GUICtrlListView_InsertGroup($hListView, -1, 1, "Group 1")
    _GUICtrlListView_InsertGroup($hListView, -1, 2, "Group 2")
    _GUICtrlListView_SetItemGroupID($hListView, 0, 1)
    _GUICtrlListView_SetItemGroupID($hListView, 1, 2)
    _GUICtrlListView_SetItemGroupID($hListView, 2, 2)

    ; Get the Image
    Local $sURL = "http://www.autoitscript.com/autoit3/files/graphics/autoit9_wall_grey_800x600.jpg"
    Local $sFilePath = @ScriptDir & "\AutoIt.jpg"
    InetGet($sURL, $sFilePath)

    ; Set the Background Image
    _GUICtrlListView_SetBkImage($hListView, $sFilePath)
    $aImage = _GUICtrlListView_GetBkImage($hListView)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Background Image: " & $aImage[1])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    DllCall('ole32.dll', 'long', 'CoUinitialize') ; Must call for each CoInitializeEx call made
    GUIDelete()
    FileDelete($sFilePath)
EndFunc   ;==>Example_UDF_Created


Function _GUICtrlListView_SetCallBackMask

Function Reference

_GUICtrlListView_SetCallBackMask

Changes the callback mask for the control

#include <GuiListView.au3>
_GUICtrlListView_SetCallBackMask ( $hWnd, $iMask )

Parameters

$hWnd | Control ID/Handle to the control
$iMask | Value of the callback mask. The bits of the mask indicate the item states or images for which the application stores the current state data. This value can be any combination of the following: 1 - The item is marked for a cut-and-paste operation 2 - The item is highlighted as a drag-and-drop target 4 - The item has the focus 8 - The item is selected 16 - The application stores the image list index of the current overlay image 32 - The application stores the image list index of the current state image

Return Value

Success: | True.
Failure: | False.

Remarks

The callback mask is a set of bit flags that specify the item states for which the application, rather than the control, stores the current data.
The callback mask applies to all of the control's items, unlike the callback item designation, which applies to a specific item.
The callback mask is zero by default, meaning that the control stores all item state information.

Related

_GUICtrlListView_GetCallbackMask

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example_UDF_Created()

Func Example_UDF_Created()
    Local $hGUI, $hImage, $hListView

    $hGUI = GUICreate("(UDF Created) ListView Set CallBack Mask", 400, 300)

    $hListView = _GUICtrlListView_Create($hGUI, "", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    _GUICtrlListView_SetCallBackMask($hListView, 32)
    MsgBox($MB_SYSTEMMODAL, "Information", "CallBackMask: " & _GUICtrlListView_GetCallbackMask($hListView))

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xC0C0C0, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF00FF, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFFFF00, 16, 16))
    _GUICtrlListView_SetImageList($hListView, $hImage, 1)
    _GUICtrlListView_SetImageList($hListView, $hImage, 2)

    ; Add columns
    _GUICtrlListView_AddColumn($hListView, "Column 1", 100)
    _GUICtrlListView_AddColumn($hListView, "Column 2", 100)
    _GUICtrlListView_AddColumn($hListView, "Column 3", 100)

    ; Add items with callback for item text
    _GUICtrlListView_AddItem($hListView, -1, 0)
    _GUICtrlListView_AddItem($hListView, -1, 1)
    _GUICtrlListView_AddItem($hListView, -1, 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example_UDF_Created


Function _GUICtrlListView_SetColumn

Function Reference

_GUICtrlListView_SetColumn

Sets the attributes of a column

#include <GuiListView.au3>
_GUICtrlListView_SetColumn ( $hWnd, $iIndex, $sText [, $iWidth = -1 [, $iAlign = -1 [, $iImage = -1 [, $bOnRight = False]]]] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of new column
$sText | Column header text
$iWidth | [optional] Width of the column, in pixels
$iAlign | [optional] Alignment of the column header and the subitem text in the column: 0 - Text is left aligned 1 - Text is right aligned 2 - Text is centered
$iImage | [optional] 0-based index of an image within the image list
$bOnRight | [optional] If True, the column image appears to the right of text

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_GetColumn, _GUICtrlListView_JustifyColumn

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aInfo, $idListview

    GUICreate("ListView Set Column", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Change column
    $aInfo = _GUICtrlListView_GetColumn($idListview, 0)
    MsgBox($MB_SYSTEMMODAL, "Information", "Column 1 Width: " & $aInfo[4])
    _GUICtrlListView_SetColumn($idListview, 0, "New Column 1", 150, 1)
    $aInfo = _GUICtrlListView_GetColumn($idListview, 0)
    MsgBox($MB_SYSTEMMODAL, "Information", "Column 1 Width: " & $aInfo[4])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetColumnOrder

Function Reference

_GUICtrlListView_SetColumnOrder

Sets the left-to-right order of columns

#include <GuiListView.au3>
_GUICtrlListView_SetColumnOrder ( $hWnd, $sOrder )

Parameters

$hWnd | Control ID/Handle to the control
$sOrder | Use Opt('GUIDataSeparatorChar', param) to set Separator Char, delimited column order, must be formated as follows: "2|0|3|1"

Return Value

None.

Remarks

Columns are 0-based.

Related

_GUICtrlListView_GetColumnOrder, _GUICtrlListView_SetColumnOrderArray

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $a_Order, $idListview

    GUICreate("ListView Set Column Order", 400, 300)
    $idListview = GUICtrlCreateListView("Column 1|Column 2|Column 3|Column 4", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Set column order
    MsgBox($MB_SYSTEMMODAL, "Information", "Changing column order")
    _GUICtrlListView_SetColumnOrder($idListview, "3|2|0|1")

    ; Show column order
    $a_Order = _GUICtrlListView_GetColumnOrderArray($idListview)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Column order: [%d, %d, %d, %d]", $a_Order[1], $a_Order[2], $a_Order[3], $a_Order[4]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetColumnOrderArray

Function Reference

_GUICtrlListView_SetColumnOrderArray

Sets the left-to-right order of columns in the control

#include <GuiListView.au3>
_GUICtrlListView_SetColumnOrderArray ( $hWnd, $aOrder )

Parameters

$hWnd | Control ID/Handle to the control
$aOrder | Array of integers that holds the index values of the columns in the control. The array must be formatted as follows: [0] - Number of items in array [1] - First column index [2] - Second column index [n] - Last column index

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_GetColumnOrder, _GUICtrlListView_GetColumnOrderArray, _GUICtrlListView_SetColumnOrder

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $a_Order[5] = [4, 3, 2, 0, 1], $idListview

    GUICreate("ListView Set Column Order Array", 400, 300)
    $idListview = GUICtrlCreateListView("Column 1|Column 2|Column 3|Column 4", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Set column order
    MsgBox($MB_SYSTEMMODAL, "Information", "Changing column order")
    _GUICtrlListView_SetColumnOrderArray($idListview, $a_Order)

    ; Show column order
    $a_Order = _GUICtrlListView_GetColumnOrderArray($idListview)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Column order: [%d, %d, %d, %d]", $a_Order[1], $a_Order[2], $a_Order[3], $a_Order[4]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetColumnWidth

Function Reference

_GUICtrlListView_SetColumnWidth

Changes the width of a column

#include <GuiListView.au3>
_GUICtrlListView_SetColumnWidth ( $hWnd, $iCol, $iWidth )

Parameters

$hWnd | Control ID/Handle to the control
$iCol | 0-based index of a valid column. For list-view mode, this parameter must be set to zero
$iWidth | New width of the column, in pixels. For report-view mode, the following special values are supported: $LVSCW_AUTOSIZE - Automatically sizes the column. $LVSCW_AUTOSIZE_USEHEADER - Automatically sizes the column to fit the header text. If you use this value with the last column, its width is set to fill the remaining width of the list-view control.

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_GetColumnWidth, _GUICtrlListView_HideColumn

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Column Width", 400, 300)
    $idListview = GUICtrlCreateListView("Column 1|Column 2|Column 3|Column 4", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Change column 1 width
    MsgBox($MB_SYSTEMMODAL, "Information", "Column 1 Width: " & _GUICtrlListView_GetColumnWidth($idListview, 0))
    _GUICtrlListView_SetColumnWidth($idListview, 0, 150)
    MsgBox($MB_SYSTEMMODAL, "Information", "Column 1 Width: " & _GUICtrlListView_GetColumnWidth($idListview, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetExtendedListViewStyle

Function Reference

_GUICtrlListView_SetExtendedListViewStyle

Sets extended styles

#include <GuiListView.au3>
_GUICtrlListView_SetExtendedListViewStyle ( $hWnd, $iExStyle [, $iExMask = 0] )

Parameters

$hWnd Control ID/Handle to the control
$iExStyle Extended control styles:
$LVS_EX_BORDERSELECT - When an item is selected the border color of the item changes
$LVS_EX_CHECKBOXES - Enables check boxes for items in a list-view control
$LVS_EX_DOUBLEBUFFER - Paints via double-buffering, which reduces flicker
$LVS_EX_FLATSB - Enables flat scroll bars in the list view
$LVS_EX_FULLROWSELECT - When an item is selected, the item and all its subitems are highlighted
$LVS_EX_GRIDLINES - Displays gridlines around items and subitems
$LVS_EX_HEADERDRAGDROP - Enables drag-and-drop reordering of columns
$LVS_EX_INFOTIP - The $LVN_GETINFOTIP notification message is sent before displaying a ToolTip
$LVS_EX_LABELTIP - If not set, the unfolds partly hidden labels only for the large icon mode
$LVS_EX_MULTIWORKAREAS - The control will not autoarrange its icons until one or more work areas are defined
$LVS_EX_ONECLICKACTIVATE - The control sends an $LVN_ITEMACTIVATE messages when the user clicks an item
$LVS_EX_REGIONAL - Sets the control region to include only the item icons and text
$LVS_EX_SIMPLESELECT - In icon view moves the state image of the control to the top right
$LVS_EX_SUBITEMIMAGES - Allows images to be displayed for subitems
$LVS_EX_TRACKSELECT - Enables hot-track selection in the control
$LVS_EX_TWOCLICKACTIVATE - The control sends an $LVN_ITEMACTIVATE message when the user double-clicks an item
$LVS_EX_UNDERLINECOLD - Causes non-hot items that may be activated to be displayed with underlined text
$LVS_EX_UNDERLINEHOT - Causes hot items that may be activated to be displayed with underlined text
$iExMask [optional] Specifies which styles in $iExStyle are to be affected.
This parameter can be a combination of extended styles. Only the extended styles in $iExMask will be changed.
All other styles will be maintained as they are.
If this parameter is zero, all of the styles in $iExStyle will be affected.

Return Value

Returns the previous extended styles.

Related

_GUICtrlListView_GetExtendedListViewStyle

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>

Example()

Func Example()
    Local $hImage, $idListview

    ; Create GUI
    GUICreate("ListView Set Extended Style", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_InsertColumn($idListview, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($idListview, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($idListview, 2, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetGroupInfo

Function Reference

_GUICtrlListView_SetGroupInfo

Sets group information

#include <GuiListView.au3>
_GUICtrlListView_SetGroupInfo ( $hWnd, $iGroupID, $sHeader [, $iAlign = 0 [, $iState = $LVGS_NORMAL]] )

Parameters

$hWnd | Control ID/Handle to the control
$iGroupID | ID of the group
$sHeader | Header text
$iAlign | [optional] Alignment of the header text for the group: 0 - Left 1 - Center 2 - Right
$iState | [optional] Windows Vista or later can have one of the following values: $LVGS_NORMAL - Groups are expanded, the group name is displayed, and all items in the group are displayed. $LVGS_COLLAPSED - The group is collapsed. $LVGS_HIDDEN - The group is hidden. $LVGS_NOHEADER - The group does not display a header. $LVGS_COLLAPSIBLE - The group can be collapsed. $LVGS_FOCUSED - The group has keyboard focus. $LVGS_SELECTED - The group is selected. $LVGS_SUBSETED - The group displays only a portion of its items. $LVGS_SUBSETLINKFOCUSED - The subset link of the group has keyboard focus

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_GetGroupInfo, _GUICtrlListView_GetGroupInfoByIndex

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aInfo, $hImage, $idListview

    GUICreate("ListView Set Group Info", 400, 300)

    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Build groups
    _GUICtrlListView_EnableGroupView($idListview)
    _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1", 1)
    _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2")
    _GUICtrlListView_SetItemGroupID($idListview, 0, 1)
    _GUICtrlListView_SetItemGroupID($idListview, 1, 2)
    _GUICtrlListView_SetItemGroupID($idListview, 2, 2)

    ; Change group information
    $aInfo = _GUICtrlListView_GetGroupInfo($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Group 1 Text: " & $aInfo[0])
    _GUICtrlListView_SetGroupInfo($idListview, 1, "New Group 1")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetHotItem

Function Reference

_GUICtrlListView_SetHotItem

Sets the hot item

#include <GuiListView.au3>
_GUICtrlListView_SetHotItem ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item to be set as the hot item

Return Value

Success: | the index of the item that was previously hot.
Failure: | -1.

Related

_GUICtrlListView_GetHotItem

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iStylesEx = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES), $idListview

    GUICreate("ListView Set Hot Item", 400, 300)

    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    $idListview = GUICtrlGetHandle($idListview)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iStylesEx)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1")
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1")
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1")

    ; Set hot item
    _GUICtrlListView_SetHotItem($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Hot Item: " & _GUICtrlListView_GetHotItem($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetHoverTime

Function Reference

_GUICtrlListView_SetHoverTime

Sets the amount of time which the mouse cursor must hover over an item before it is selected

#include <GuiListView.au3>
_GUICtrlListView_SetHoverTime ( $hWnd, $iTime )

Parameters

$hWnd | Control ID/Handle to the control
$iTime | The new amount of time, in milliseconds, that the mouse cursor must hover over an item before it is selected. If this value is (DWORD)-1, then the hover time is set to the default hover time.

Return Value

Returns the previous hover time.

Remarks

The hover time only affects list-view controls that have the $LVS_EX_TRACKSELECT,
$LVS_EX_ONECLICKACTIVATE, or $LVS_EX_TWOCLICKACTIVATE extended list-view style.

Related

_GUICtrlListView_GetHoverTime

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiStatusBar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idListView, $g_hStatus

Example()

Func Example()
    Local $hGUI
    Local $iStylesEX = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_TRACKSELECT)

    $hGUI = GUICreate("ListView Set Hover Time", 400, 300)
    $g_idListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    _GUICtrlListView_SetHoverTime($g_idListView, 1000)
    _GUICtrlListView_SetExtendedListViewStyle($g_idListView, $iStylesEX)
    $g_idListView = GUICtrlGetHandle($g_idListView)
    $g_hStatus = _GUICtrlStatusBar_Create($hGUI, -1, "")
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Add columns
    _GUICtrlListView_AddColumn($g_idListView, "Column 1", 100)
    _GUICtrlListView_AddColumn($g_idListView, "Column 2", 100)
    _GUICtrlListView_AddColumn($g_idListView, "Column 3", 100)

    _GUICtrlListView_InsertItem($g_idListView, "Row 1: Col 1")
    _GUICtrlListView_AddSubItem($g_idListView, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($g_idListView, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_InsertItem($g_idListView, "Row 2: Col 1")
    _GUICtrlListView_AddSubItem($g_idListView, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_InsertItem($g_idListView, "Row 3: Col 1")

    ; Get hover time
    MsgBox($MB_SYSTEMMODAL, "Information", "Previous Hover Time (milliseconds): " & _GUICtrlListView_GetHoverTime($g_idListView))

    ; Set hover time
    _GUICtrlListView_SetHoverTime($g_idListView, 500)
    MsgBox($MB_SYSTEMMODAL, "Information", "Hover Time (milliseconds): " & _GUICtrlListView_GetHoverTime($g_idListView))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete()
EndFunc   ;==>Example

Func ListView_HOTTRACK($iSubItem)
    Local $iHotItem = _GUICtrlListView_GetHotItem($g_idListView)
    If $iHotItem <> -1 Then _GUICtrlStatusBar_SetText($g_hStatus, @TAB & "Hot Item: " & $iHotItem & " SubItem: " & $iSubItem)
EndFunc   ;==>ListView_HOTTRACK

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    $hWndListView = $g_idListView
    If Not IsHWnd($g_idListView) Then $hWndListView = GUICtrlGetHandle($g_idListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $LVN_COLUMNCLICK ; A column was clicked
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    _DebugPrint("$LVN_COLUMNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    ; No return value
                Case $LVN_HOTTRACK ; Sent by a list-view control when the user moves the mouse over an item
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    _DebugPrint("$LVN_HOTTRACK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    ListView_HOTTRACK(DllStructGetData($tInfo, "SubItem"))
                    Return 0 ; allow the list view to perform its normal track select processing.
                    ;Return 1 ; the item will not be selected.
                Case $LVN_KEYDOWN ; A key has been pressed
                    $tInfo = DllStructCreate($tagNMLVKEYDOWN, $lParam)
                    _DebugPrint("$LVN_KEYDOWN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->VKey:" & @TAB & DllStructGetData($tInfo, "VKey") & @CRLF & _
                            "-->Flags:" & @TAB & DllStructGetData($tInfo, "Flags"))
                    ; No return value
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_KILLFOCUS ; The control has lost the input focus
                    _DebugPrint("$NM_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ;Return 1 ; not to allow the default processing
                    Return 0 ; allow the default processing
                Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
                    _DebugPrint("$NM_RETURN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_SETFOCUS ; The control has received the input focus
                    _DebugPrint("$NM_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlListView_SetIconSpacing

Function Reference

_GUICtrlListView_SetIconSpacing

Sets the spacing between icons where the style is large icon

#include <GuiListView.au3>
_GUICtrlListView_SetIconSpacing ( $hWnd, $iCX, $iCY )

Parameters

$hWnd | Control ID/Handle to the control
$iCX | Distance, in pixels, to set between icons on the x-axis
$iCY | Distance, in pixels, to set between icons on the y-axis

Return Value

Returns an array with the following format:
[0] - Previous CX value
[1] - Previous CY value

Remarks

Values for $iCX and $iCY are relative to the upper-left corner of an icon bitmap. To set spacing between icons that do not overlap, the $iCX or $iCY values must include the size of the icon, plus the amount of empty space desired between icons.
Values that do not include the width of the icon will result in overlaps.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    ; Create GUI
    GUICreate("ListView Set Icon Spacing", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUICtrlSetStyle($idListview, $LVS_ICON)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 0)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    ; Change item spacing
    MsgBox($MB_SYSTEMMODAL, "Information", "Changing icon spacing")
    _GUICtrlListView_SetIconSpacing($idListview, 32, 32)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetImageList

Function Reference

_GUICtrlListView_SetImageList

Assigns an image list to the control

#include <GuiListView.au3>
_GUICtrlListView_SetImageList ( $hWnd, $hHandle [, $iType = 0] )

Parameters

$hWnd | Control ID/Handle to the control
$hHandle | Handle to the image list to assign
$iType | [optional] Type of image list: 0 - Image list with large icons 1 - Image list with small icons 2 - Image list with state images

Return Value

Success: | the handle to the previous image list.
Failure: | 0.

Remarks

The current image list will be destroyed when the control is destroyed unless you set the $LVS_SHAREIMAGELISTS style.
If you use this message to replace one image list with another your application must explicitly destroy all image lists other than the current one.

Related

_GUICtrlListView_GetImageList

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Set Image List", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    Local $hPrevImageList = _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    MsgBox($MB_SYSTEMMODAL, "Information", "Previous Image List Handle: 0x" & Hex($hPrevImageList) & @CRLF & _
            "IsPtr = " & IsPtr($hPrevImageList) & " IsHWnd = " & IsHWnd($hPrevImageList))

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    ; Get image list handle
    MsgBox($MB_SYSTEMMODAL, "Information", "Image List Handle: 0x" & Hex(_GUICtrlListView_GetImageList($idListview, 1)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetItem

Function Reference

_GUICtrlListView_SetItem

Sets some or all of a item's attributes

#include <GuiListView.au3>
_GUICtrlListView_SetItem ( $hWnd, $sText [, $iIndex = 0 [, $iSubItem = 0 [, $iImage = -1 [, $iParam = -1 [, $iIndent = -1]]]]] )

Parameters

$hWnd | Control ID/Handle to the control
$sText | Item text. See remark.
$iIndex | [optional] The 0-based index of the item
$iSubItem | [optional] 1-based index of the subitem or zero if this refers to an item
$iImage | [optional] 0-base index of the item's icon in the control's image list
$iParam | [optional] Value specific to the item
$iIndent | [optional] Number of image widths to indent the item. A single indentation equals the width of an image.

Return Value

Success: | True.
Failure: | False.

Remarks

If a notification callback is needed, you have to specify $sText = -1 (LPSTR_TEXTCALLBACK).

As AutoIt uses the $iParam parameter to store the controlID of native-created ListView items, this value should be set sufficiently high for UDF-created items to avoid possible conflict with any existing controls - a starting value of 1000 is recommended.

Related

_GUICtrlListView_GetItem, _GUICtrlListView_SetItemEx

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Item", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    GUICtrlCreateListViewItem("Item 1", $idListview)
    GUICtrlCreateListViewItem("Item 2", $idListview)
    GUICtrlCreateListViewItem("Item 3", $idListview)

    ; Change item 2
    MsgBox($MB_SYSTEMMODAL, "Information", "Changing item 2")
    _GUICtrlListView_SetItem($idListview, "New Item 2", 1)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetItemChecked

Function Reference

_GUICtrlListView_SetItemChecked

Sets the checked state

#include <GuiListView.au3>
_GUICtrlListView_SetItemChecked ( $hWnd, $iIndex [, $bCheck = True] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item, -1 sets all items
$bCheck | [optional] Value to set checked state to: True - Checked False - Not checked

Return Value

Success: | True.
Failure: | False.

Remarks

Use only on controls that have the $LVS_EX_CHECKBOXES extended style.

Related

_GUICtrlListView_GetItemChecked

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iStylesEx = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES), $idListview

    GUICreate("ListView Set Item Checked State", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iStylesEx)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Check item 2
    _GUICtrlListView_SetItemChecked($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Checked: " & _GUICtrlListView_GetItemChecked($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetItemCount

Function Reference

_GUICtrlListView_SetItemCount

Causes the list-view control to allocate memory for the specified number of items

#include <GuiListView.au3>
_GUICtrlListView_SetItemCount ( $hWnd, $iItems )

Parameters

$hWnd | Control ID/Handle to the control
$iItems | Number of items that the list-view control will ultimately contain

Return Value

Success: | True.
Failure: | False.

Remarks

Causes the control to allocate its internal data structures for the specified number of items.
This prevents the control from having to allocate the data structures every time an item is added.

Related

_GUICtrlListView_GetItemCount

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Item Count", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_SetItemCount($idListview, 100)
    _GUICtrlListView_BeginUpdate($idListview)
    For $x = 1 To 100
        GUICtrlCreateListViewItem("Item " & $x, $idListview)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetItemCut

Function Reference

_GUICtrlListView_SetItemCut

Sets whether the item is marked for a cut-and-paste operation

#include <GuiListView.au3>
_GUICtrlListView_SetItemCut ( $hWnd, $iIndex [, $bEnabled = True] )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based index of the item
$bEnabled | [optional] If True the item state is set, otherwise it is not set.

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_GetItemCut

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Item Cut", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Cut item 2
    _GUICtrlListView_SetItemCut($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Cut: " & _GUICtrlListView_GetItemCut($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetItemDropHilited

Function Reference

_GUICtrlListView_SetItemDropHilited

Sets whether the item is highlighted as a drag-and-drop target

#include <GuiListView.au3>
_GUICtrlListView_SetItemDropHilited ( $hWnd, $iIndex [, $bEnabled = True] )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based index of the item
$bEnabled | [optional] If True the item state is set, otherwise it is not set.

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_GetItemDropHilited

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Item Drop Hilited", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Hilight item 2
    _GUICtrlListView_SetItemDropHilited($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Drop Hilited: " & _GUICtrlListView_GetItemDropHilited($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetItemEx

Function Reference

_GUICtrlListView_SetItemEx

Sets some or all of a item's attributes

#include <GuiListView.au3>
_GUICtrlListView_SetItemEx ( $hWnd, ByRef $tItem )

Parameters

$hWnd | Control ID/Handle to the control
$tItem | $tagLVITEM structure

Return Value

Success: | True.
Failure: | False.

Remarks

To set the attributes of an item set the Item member of the $tagLVITEM structure to the index of the item, and set the SubItem member to zero.
For an item, you can set the State, Text, Image, and Param members of the $tagLVITEM structure.

To set the text of a subitem, set the Item and SubItem members to indicate the specific subitem, and use the Text member to specify the text.
You cannot set the State or Param members for subitems because subitems do not have these attributes.

Related

$tagLVITEM, _GUICtrlListView_SetItem

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $tText, $tItem, $idListview

    GUICreate("ListView Set Item Ex", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    GUICtrlCreateListViewItem("Item 1", $idListview)
    GUICtrlCreateListViewItem("Item 2", $idListview)
    GUICtrlCreateListViewItem("Item 3", $idListview)

    ; Change item 2
    MsgBox($MB_SYSTEMMODAL, "Information", "Changing item 2")
    $tText = DllStructCreate("wchar Text[11]")
    $tItem = DllStructCreate($tagLVITEM)
    DllStructSetData($tText, "Text", "New Item 2")
    DllStructSetData($tItem, "Mask", $LVIF_TEXT)
    DllStructSetData($tItem, "Item", 1)
    DllStructSetData($tItem, "Text", DllStructGetPtr($tText))
    _GUICtrlListView_SetItemEx($idListview, $tItem)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetItemFocused

Function Reference

_GUICtrlListView_SetItemFocused

Sets whether the item has the focus

#include <GuiListView.au3>
_GUICtrlListView_SetItemFocused ( $hWnd, $iIndex [, $bEnabled = True] )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based index of the item
$bEnabled | [optional] If True the item state is set, otherwise it is not set.

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_GetItemFocused

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Item Focused", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Focus item 2
    _GUICtrlListView_SetItemFocused($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Focused: " & _GUICtrlListView_GetItemFocused($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetItemGroupID

Function Reference

_GUICtrlListView_SetItemGroupID

Sets the item group ID

#include <GuiListView.au3>
_GUICtrlListView_SetItemGroupID ( $hWnd, $iIndex, $iGroupID )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based index of the item
$iGroupID | Group ID

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_GetItemGroupID, _GUICtrlListView_InsertGroup

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Set Item Group ID", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Build groups
    _GUICtrlListView_EnableGroupView($idListview)
    _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1")
    _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2")
    _GUICtrlListView_SetItemGroupID($idListview, 0, 1)
    _GUICtrlListView_SetItemGroupID($idListview, 1, 2)
    _GUICtrlListView_SetItemGroupID($idListview, 2, 2)

    ; Display Item 3 group ID
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 3 Group ID: " & _GUICtrlListView_GetItemGroupID($idListview, 2))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetItemImage

Function Reference

_GUICtrlListView_SetItemImage

Sets the index of the item's icon in the control's image list

#include <GuiListView.au3>
_GUICtrlListView_SetItemImage ( $hWnd, $iIndex, $iImage [, $iSubItem = 0] )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based index of the item
$iImage | 0-based index into the control's image list
$iSubItem | [optional] 1-based index of the subitem

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_GetItemImage

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview, $iStylesEx = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    GUICreate("ListView Set Item Image", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iStylesEx)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Set item 1, subitem 1 image
    _GUICtrlListView_SetItemImage($idListview, 1, 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 1, SubItem 1 Image: " & _GUICtrlListView_GetItemImage($idListview, 1, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetItemIndent

Function Reference

_GUICtrlListView_SetItemIndent

Sets the number of image widths to indent the item

#include <GuiListView.au3>
_GUICtrlListView_SetItemIndent ( $hWnd, $iIndex, $iIndent )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based index of the item
$iIndent | Indention value

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_GetItemIndent

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Set Item Indent", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    ; Indent items
    _GUICtrlListView_SetItemIndent($idListview, 1, 1)
    _GUICtrlListView_SetItemIndent($idListview, 2, 2)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Indent: " & _GUICtrlListView_GetItemIndent($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetItemParam

Function Reference

_GUICtrlListView_SetItemParam

Sets the value specific to the item

#include <GuiListView.au3>
_GUICtrlListView_SetItemParam ( $hWnd, $iIndex, $iParam )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based index of the item
$iParam | A value to associate with the item

Return Value

Success: | True.
Failure: | False.

Remarks

As AutoIt uses the $iParam parameter to store the controlID of native-created ListView items, this value should be set sufficiently high for UDF-created items to avoid possible conflict with any existing controls - a starting value of 1000 is recommended.

Related

_GUICtrlListView_GetItemParam

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Item Param", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Set item 2 parameter
    _GUICtrlListView_SetItemParam($idListview, 1, 1234)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Parameter: " & _GUICtrlListView_GetItemParam($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetItemPosition

Function Reference

_GUICtrlListView_SetItemPosition

Moves an item to a specified position in the control

#include <GuiListView.au3>
_GUICtrlListView_SetItemPosition ( $hWnd, $iIndex, $iCX, $iCY )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item
$iCX | New x-position of the item's upper-left corner, in view coordinates
$iCY | New y-position of the item's upper-left corner, in view coordinates

Return Value

Success: | True.
Failure: | False.

Remarks

If the control has the $LVS_AUTOARRANGE style, the items in the control are arranged after the position of the item is set.
The control must be in icon or small icon view mode.

Related

_GUICtrlListView_Arrange, _GUICtrlListView_GetItemPosition, _GUICtrlListView_SetItemPosition32

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Item Position", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Set icon view
    _GUICtrlListView_SetView($idListview, 3)
    MsgBox($MB_SYSTEMMODAL, "Information", "Moving item 2")
    _GUICtrlListView_SetItemPosition($idListview, 1, 100, 100)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetItemPosition32

Function Reference

_GUICtrlListView_SetItemPosition32

Moves an item to a specified position in the control

#include <GuiListView.au3>
_GUICtrlListView_SetItemPosition32 ( $hWnd, $iIndex, $iCX, $iCY )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item
$iCX | New x-position of the item's upper-left corner, in view coordinates
$iCY | New y-position of the item's upper-left corner, in view coordinates

Return Value

Success: | True.
Failure: | False.

Remarks

If the control has the $LVS_AUTOARRANGE style, the items in the control are arranged after the position of the item is set.
The control must be in icon or small icon view mode.

This message differs from the _GUICtrlListView_SetItemPosition() function in that it uses 32-bit coordinates.

Related

_GUICtrlListView_SetItemPosition

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Item Position32", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Set icon view
    _GUICtrlListView_SetView($idListview, 3)
    MsgBox($MB_SYSTEMMODAL, "Information", "Moving item 2")
    _GUICtrlListView_SetItemPosition32($idListview, 1, 100, 100)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetItemSelected

Function Reference

_GUICtrlListView_SetItemSelected

Sets whether the item is selected

#include <GuiListView.au3>
_GUICtrlListView_SetItemSelected ( $hWnd, $iIndex [, $bSelected = True [, $bFocused = False]] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item, -1 to set selected state of all items
$bSelected | [optional] If True the item(s) are selected, otherwise not.
$bFocused | [optional] If True the item has focus, otherwise not.

Return Value

Success: | True.
Failure: | False.

Remarks

If the listview is using the control style $LVS_SINGLESEL, setting $iIndex to -1 will not select all of the items.

Related

_GUICtrlListView_GetItemSelected

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Item Selected", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Select item 2
    _GUICtrlListView_SetItemSelected($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Selected: " & _GUICtrlListView_GetItemSelected($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetItemState

Function Reference

_GUICtrlListView_SetItemState

Changes the state of an item in the control

#include <GuiListView.au3>
_GUICtrlListView_SetItemState ( $hWnd, $iIndex, $iState, $iStateMask )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item
$iState | Item state to be changed
$iStateMask | Bits that determine whether state is active or inactive

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_GetItemState

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $iStylesEx = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES), $idListview

    GUICreate("ListView Set Item State", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $iStylesEx)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Get item 1 state
    _GUICtrlListView_SetItemState($idListview, 0, $LVIS_FOCUSED, $LVIS_FOCUSED)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 1 State: " & _GUICtrlListView_GetItemState($idListview, 0, $LVIS_FOCUSED))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetItemStateImage

Function Reference

_GUICtrlListView_SetItemStateImage

Sets the state image that is displayed

#include <GuiListView.au3>
_GUICtrlListView_SetItemStateImage ( $hWnd, $iIndex, $iImage )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item
$iImage | 1-based overlay image index

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_GetItemStateImage

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Set Item State", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 1)
    _GUICtrlListView_SetImageList($idListview, $hImage, 2)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 120)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

    ; Set item 2 state image
    _GUICtrlListView_SetItemStateImage($idListview, 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 State Image: " & _GUICtrlListView_GetItemStateImage($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetItemText

Function Reference

_GUICtrlListView_SetItemText

Changes the text of an item or subitem

#include <GuiListView.au3>
_GUICtrlListView_SetItemText ( $hWnd, $iIndex, $sText [, $iSubItem = 0] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item
$sText | Item or subitem text
$iSubItem | [optional] 1-based index of the subitem or 0 to set the item

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_GetItemText, _GUICtrlListView_GetItemTextArray, _GUICtrlListView_GetItemTextString, _GUICtrlListView_InsertItem

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Item Text", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Set item 2 text
    _GUICtrlListView_SetItemText($idListview, 1, "New Item 2")
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Text: " & _GUICtrlListView_GetItemText($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetOutlineColor

Function Reference

_GUICtrlListView_SetOutlineColor

Sets the color of the border

#include <GuiListView.au3>
_GUICtrlListView_SetOutlineColor ( $hWnd, $iColor )

Parameters

$hWnd | Control ID/Handle to the control
$iColor | Color to set the border

Return Value

Returns the previous outline color.

Remarks

Control must have the $LVS_EX_BORDERSELECT extended window style set

Related

_GUICtrlListView_GetOutlineColor

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Set Outline Color", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUICtrlSetStyle($idListview, $LVS_ICON)
    ; Enable extended control styles
    _GUICtrlListView_SetExtendedListViewStyle($idListview, $LVS_EX_BORDERSELECT)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 0)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    ; Set outline color
    _GUICtrlListView_SetOutlineColor($idListview, 0x0000FF)
    MsgBox($MB_SYSTEMMODAL, "Information", "Outline Color: " & Hex(_GUICtrlListView_GetOutlineColor($idListview)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetSelectedColumn

Function Reference

_GUICtrlListView_SetSelectedColumn

Sets the index of the selected column

#include <GuiListView.au3>
_GUICtrlListView_SetSelectedColumn ( $hWnd, $iCol )

Parameters

$hWnd | Control ID/Handle to the control
$iCol | Specifies the column index

Return Value

None.

Remarks

Columns are 0-based index.

Related

_GUICtrlListView_GetSelectedColumn

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Selected Column", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
    _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Select column 2
    _GUICtrlListView_SetSelectedColumn($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Selected Column: " & _GUICtrlListView_GetSelectedColumn($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetSelectionMark

Function Reference

_GUICtrlListView_SetSelectionMark

Sets the selection mark in the control

#include <GuiListView.au3>
_GUICtrlListView_SetSelectionMark ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the new selection mark. If -1, the selection mark is removed.

Return Value

Success: | the previous selection mark.
Failure: | -1 if there is no previous selection mark.

Remarks

The selection mark is the item index from which a multiple selection starts.
This message does not affect the selection state of the item.

Related

_GUICtrlListView_GetSelectionMark

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Selection Mark", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT))
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Column 1", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1")
    _GUICtrlListView_AddItem($idListview, "Item 2")
    _GUICtrlListView_AddItem($idListview, "Item 3")

    ; Select item 1
    _GUICtrlListView_SetSelectionMark($idListview, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Selected Mark: " & _GUICtrlListView_GetSelectionMark($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetTextBkColor

Function Reference

_GUICtrlListView_SetTextBkColor

Sets the background color of text in the control

#include <GuiListView.au3>
_GUICtrlListView_SetTextBkColor ( $hWnd, $iColor )

Parameters

$hWnd | Control ID/Handle to the control
$iColor | Text color

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_GetTextBkColor

Example

#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Text BkColor", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Set colors
    _GUICtrlListView_SetBkColor($idListview, $CLR_MONEYGREEN)
    _GUICtrlListView_SetTextColor($idListview, $CLR_BLACK)
    _GUICtrlListView_SetTextBkColor($idListview, $CLR_MONEYGREEN)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Show colors
    MsgBox($MB_SYSTEMMODAL, "Information", "Back Color ....: " & _GUICtrlListView_GetBkColor($idListview) & @CRLF & _
            "Text Color ....: " & _GUICtrlListView_GetTextColor($idListview) & @CRLF & _
            "Text Back Color: " & _GUICtrlListView_GetTextBkColor($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetTextColor

Function Reference

_GUICtrlListView_SetTextColor

Sets the color of text in the control

#include <GuiListView.au3>
_GUICtrlListView_SetTextColor ( $hWnd, $iColor )

Parameters

$hWnd | Control ID/Handle to the control
$iColor | Text color

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_GetTextColor

Example

#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Text Color", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Set colors
    _GUICtrlListView_SetBkColor($idListview, $CLR_MONEYGREEN)
    _GUICtrlListView_SetTextColor($idListview, $CLR_BLACK)
    _GUICtrlListView_SetTextBkColor($idListview, $CLR_MONEYGREEN)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Show colors
    MsgBox($MB_SYSTEMMODAL, "Information", "Back Color ....: " & _GUICtrlListView_GetBkColor($idListview) & @CRLF & _
            "Text Color ....: " & _GUICtrlListView_GetTextColor($idListview) & @CRLF & _
            "Text Back Color: " & _GUICtrlListView_GetTextBkColor($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetToolTips

Function Reference

_GUICtrlListView_SetToolTips

Sets the ToolTip control that the control will use to display ToolTips

#include <GuiListView.au3>
_GUICtrlListView_SetToolTips ( $hWnd, $hToolTip )

Parameters

$hWnd | Control ID/Handle to the control
$hToolTip | Handle to the ToolTip control to be set

Return Value

Returns the handle to the previous ToolTip control.

Related

_GUICtrlListView_GetToolTips

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hToolTip, $idListView

    GUICreate("ListView Set ToolTips", 400, 300)
    $idListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    ; $idListView = _GUICtrlListView_Create($hGui, "", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListView, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListView, "Item 1")
    _GUICtrlListView_AddItem($idListView, "Item 2")
    _GUICtrlListView_AddItem($idListView, "Item 3")

    ; Show tooltip handle
    $hToolTip = _GUICtrlListView_GetToolTips($idListView)
    MsgBox($MB_SYSTEMMODAL, "Information", "ToolTip Handle: 0x" & Hex($hToolTip))
    Local $hPrevTooltips = _GUICtrlListView_SetToolTips($idListView, $hToolTip)
    MsgBox($MB_SYSTEMMODAL, "Information", "Previous ToolTip Handle: 0x" & Hex($hPrevTooltips) & @CRLF & _
            "IsPtr = " & IsPtr($hPrevTooltips) & " IsHWnd = " & IsHWnd($hPrevTooltips))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetUnicodeFormat

Function Reference

_GUICtrlListView_SetUnicodeFormat

Sets the UNICODE character format flag for the control

#include <GuiListView.au3>
_GUICtrlListView_SetUnicodeFormat ( $hWnd, $bUnicode )

Parameters

$hWnd | Control ID/Handle to the control
$bUnicode | Determines the character set that is used by the control. True - the control will use Unicode False - the control will use ANSI characters.

Return Value

Returns the previous Unicode format flag for the control.

Related

_GUICtrlListView_GetUnicodeFormat

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Unicode Format", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Set Unicode format
    _GUICtrlListView_SetUnicodeFormat($idListview, False)
    MsgBox($MB_SYSTEMMODAL, "Information", "Unicode: " & _GUICtrlListView_GetUnicodeFormat($idListview))
    _GUICtrlListView_SetUnicodeFormat($idListview, True)
    MsgBox($MB_SYSTEMMODAL, "Information", "Unicode: " & _GUICtrlListView_GetUnicodeFormat($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetView

Function Reference

_GUICtrlListView_SetView

Sets the view of the control

#include <GuiListView.au3>
_GUICtrlListView_SetView ( $hWnd, $iView )

Parameters

$hWnd | Control ID/Handle to the control
$iView | View state for the control: 0 - Large Icon 1 - Details 2 - List 3 - Small Icon 4 - Tile

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlListView_GetView

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get View", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($idListview)

    ; Set view
    MsgBox($MB_SYSTEMMODAL, "Information", "View: " & _GUICtrlListView_GetView($idListview))
    _GUICtrlListView_SetView($idListview, 4)
    MsgBox($MB_SYSTEMMODAL, "Information", "View: " & _GUICtrlListView_GetView($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SetWorkAreas

Function Reference

_GUICtrlListView_SetWorkAreas

Creates a work area within the control

#include <GuiListView.au3>
_GUICtrlListView_SetWorkAreas ( $hWnd, $iLeft, $iTop, $iRight, $iBottom )

Parameters

$hWnd | Control ID/Handle to the control
$iLeft | X coordinate of the upper left corner of the rectangle
$iTop | Y coordinate of the upper left corner of the rectangle
$iRight | X coordinate of the lower right corner of the rectangle
$iBottom | Y coordinate of the lower right corner of the rectangle

Return Value

None.

Related

_GUICtrlListView_GetNumberOfWorkAreas

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Set Work Areas", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUICtrlSetStyle($idListview, $LVS_ICON)
    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, 0)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, 0, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListview, "Item 1", 0)
    _GUICtrlListView_AddItem($idListview, "Item 2", 1)
    _GUICtrlListView_AddItem($idListview, "Item 3", 2)

    ; Create work area
    _GUICtrlListView_SetWorkAreas($idListview, 0, 0, 100, 100)
    MsgBox($MB_SYSTEMMODAL, "Information", "Work Areas: " & _GUICtrlListView_GetNumberOfWorkAreas($idListview))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlListView_SimpleSort

Function Reference

_GUICtrlListView_SimpleSort

Sorts a list-view control (limited)

#include <GuiListView.au3>
_GUICtrlListView_SimpleSort ( $hWnd, ByRef $vSortSense, $iCol [, $bToggleSense = True] )

Parameters

$hWnd | Handle to the control
$vSortSense | Sets the defined sort order True - Sort Descending False - Sort Ascending Use a simple variable for a single column ListView Use an array for multicolumn ListViews: $aArray[0] - Order for first Column $aArray[1] - Order for second Column $aArray[n] - Order for last Column
$iCol | Column number
$bToggleSense | [optional] Toggle sort sense True - Toggle sort sense after sort (default) False - Sort sense unchanged after sort

Return Value

None.

Remarks

This is a basic sort fuction, for advanced sort see GUICtrlRegisterListViewSort().

Toggling sort sense is normal behaviour when sorting is initiated by a click on the column header.
The user can prevent this toggle by setting $bToggleSense to False when calling the function from elsewhere.

If the function is called from within several functions and the sort sense is to be toggled, it is important that $vSortSense be Global in scope.
Otherwise the sense will be reset each time that $vSortSense is created and toggling will be ineffective.

Example

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

Global $g_idListView, $g_bSortSense = False ; Set initial ascending sort

Example()

Func Example()
    GUICreate("SimpleSort", 300, 300)
    $g_idListView = GUICtrlCreateListView("Item", 10, 10, 280, 240)
    _GUICtrlListView_SetColumnWidth($g_idListView, 0, 260)
    Local $idButton_Add = GUICtrlCreateButton("Add Item", 10, 260, 80, 30)
    Local $idButton_Set = GUICtrlCreateButton("Reset Ascending Sort Order", 110, 260, 180, 30)

    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idButton_Add
                Local $sData = Chr(Random(65, 90, 1))
                GUICtrlCreateListViewItem($sData, $g_idListView)
                _GUICtrlListView_SimpleSort($g_idListView, $g_bSortSense, 0, False) ; Prevent sort direction toggling for next insertion
            Case $idButton_Set
                $g_bSortSense = False ; Reset for ascending sort when next sorted
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam

    Local $hWndListView = $g_idListView
    If Not IsHWnd($g_idListView) Then $hWndListView = GUICtrlGetHandle($g_idListView)
    Local $tNMHDR = DllStructCreate($tagNMLISTVIEW, $lParam)
    Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    Local $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $LVN_COLUMNCLICK ; A column was clicked
                    _GUICtrlListView_SimpleSort($hWndListView, $g_bSortSense, DllStructGetData($tNMHDR, "SubItem")) ; Sort direction for next sort toggled by default
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY


Function _GUICtrlListView_SortItems

Function Reference

_GUICtrlListView_SortItems

Starts the sort call back, also sets the Arrow in the Header

#include <GuiListView.au3>
_GUICtrlListView_SortItems ( $hWnd, $iCol )

Parameters

$hWnd | Handle of the control
$iCol | Column clicked

Return Value

None.

Remarks

For use only in conjunction with _GUICtrlListView_RegisterSortCallBack().

A down-arrow/up-arrow is drawn on column selected if the option was set when calling _GUICtrlListView_RegisterSortCallBack().

Related

_GUICtrlListView_RegisterSortCallBack

Example

Example 1

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Global $g_idListView

Example()

Func Example()
    Local $hImage, $aIcons[3] = [0, 3, 6]
    Local $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE)
    Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER)

    GUICreate("ListView Sort", 300, 200)

    $g_idListView = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180, -1, $iExWindowStyle)
    _GUICtrlListView_SetExtendedListViewStyle($g_idListView, $iExListViewStyle)

    ; Load images
    $hImage = _GUIImageList_Create(18, 18, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -7)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -12)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -4)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -5)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -6)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -9)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -10)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -11)
    _GUICtrlListView_SetImageList($g_idListView, $hImage, 1)

    _AddRow($g_idListView, "ABC|000666|10.05.2004", $aIcons)
    _AddRow($g_idListView, "DEF|444|11.05.2005", $aIcons, 1)
    _AddRow($g_idListView, "CDE|555|12.05.2004", $aIcons, 2)

    GUISetState(@SW_SHOW)

    _GUICtrlListView_RegisterSortCallBack($g_idListView)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $g_idListView
                ; Kick off the sort callback
                _GUICtrlListView_SortItems($g_idListView, GUICtrlGetState($g_idListView))
        EndSwitch
    WEnd

    _GUICtrlListView_UnRegisterSortCallBack($g_idListView)
    GUIDelete()
EndFunc   ;==>Example

Func _AddRow($hWnd, $sItem, $aIcons, $iPlus = 0)
    Local $aItem = StringSplit($sItem, "|")
    Local $iIndex = _GUICtrlListView_AddItem($hWnd, $aItem[1], $aIcons[0] + $iPlus, _GUICtrlListView_GetItemCount($hWnd) + 9999)
    _GUICtrlListView_SetColumnWidth($hWnd, 0, $LVSCW_AUTOSIZE_USEHEADER)

    For $x = 2 To $aItem[0]
        _GUICtrlListView_AddSubItem($hWnd, $iIndex, $aItem[$x], $x - 1, $aIcons[$x - 1] + $iPlus)
        _GUICtrlListView_SetColumnWidth($hWnd, $x - 1, $LVSCW_AUTOSIZE)
    Next
EndFunc   ;==>_AddRow

Example 2

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Global $g_idListView, $g_idListView2

Example()

Func Example()
    Local $hImage, $aIcons[3] = [0, 3, 6]
    Local $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE)
    Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER)

    GUICreate("ListView Sort Treat Numbers as Strings", 300, 200, 100)

    $g_idListView = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180, -1, $iExWindowStyle)
    _GUICtrlListView_SetExtendedListViewStyle($g_idListView, $iExListViewStyle)

    ; Load images
    $hImage = _GUIImageList_Create(18, 18, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -7)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -12)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -4)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -5)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -6)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -9)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -10)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -11)
    _GUICtrlListView_SetImageList($g_idListView, $hImage, 1)

    _AddRow($g_idListView, "ABC|000666|10.05.2004", $aIcons)
    _AddRow($g_idListView, "DEF|444|11.05.2005", $aIcons, 1)
    _AddRow($g_idListView, "CDE|555|12.05.2004", $aIcons, 2)

    GUISetState(@SW_SHOW)

    GUICreate("ListView Sort Treat Numbers as Numbers", 300, 200, 400)

    $g_idListView2 = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180, -1, $iExWindowStyle)
    _GUICtrlListView_SetExtendedListViewStyle($g_idListView2, $iExListViewStyle)
    _GUICtrlListView_SetImageList($g_idListView2, $hImage, 1)

    _AddRow($g_idListView2, "ABC|000666|10.05.2004", $aIcons)
    _AddRow($g_idListView2, "DEF|444|11.05.2005", $aIcons, 1)
    _AddRow($g_idListView2, "CDE|555|12.05.2004", $aIcons, 2)

    GUISetState(@SW_SHOW)

    _GUICtrlListView_RegisterSortCallBack($g_idListView, False)
    _GUICtrlListView_RegisterSortCallBack($g_idListView2)
    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    _GUICtrlListView_UnRegisterSortCallBack($g_idListView)
    _GUICtrlListView_UnRegisterSortCallBack($g_idListView2)
    GUIRegisterMsg($WM_NOTIFY, "")
EndFunc   ;==>Example

Func _AddRow($hWnd, $sItem, $aIcons, $iPlus = 0)
    Local $aItem = StringSplit($sItem, "|")
    Local $iIndex = _GUICtrlListView_AddItem($hWnd, $aItem[1], $aIcons[0] + $iPlus, _GUICtrlListView_GetItemCount($hWnd) + 9999)
    _GUICtrlListView_SetColumnWidth($hWnd, 0, $LVSCW_AUTOSIZE_USEHEADER)

    For $x = 2 To $aItem[0]
        _GUICtrlListView_AddSubItem($hWnd, $iIndex, $aItem[$x], $x - 1, $aIcons[$x - 1] + $iPlus)
        _GUICtrlListView_SetColumnWidth($hWnd, $x - 1, $LVSCW_AUTOSIZE)
    Next
EndFunc   ;==>_AddRow

Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $hWndListView, $hWndListView2

    $hWndListView = $g_idListView
    $hWndListView2 = $g_idListView2
    If Not IsHWnd($g_idListView) Then $hWndListView = GUICtrlGetHandle($g_idListView)
    If Not IsHWnd($g_idListView2) Then $hWndListView2 = GUICtrlGetHandle($g_idListView2)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $hWndFrom
        Case $hWndListView, $hWndListView2
            Switch $iCode
                Case $LVN_COLUMNCLICK ; A column was clicked
                    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)

                    ; Kick off the sort callback
                    _GUICtrlListView_SortItems($hWndFrom, DllStructGetData($tInfo, "SubItem"))
                    ; No return value
            EndSwitch
    EndSwitch
    Return $__LISTVIEWCONSTANT_GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY


Function _GUICtrlListView_SubItemHitTest

Function Reference

_GUICtrlListView_SubItemHitTest

Determines which listview item or subitem is at a given position

#include <GuiListView.au3>
_GUICtrlListView_SubItemHitTest ( $hWnd [, $iX = -1 [, $iY = -1]] )

Parameters

$hWnd | Control ID/Handle to the control
$iX | [optional] X position to test or -1 to use the current mouse position
$iY | [optional] Y position to test or -1 to use the current mouse position

Return Value

Returns an array with the following format:
[ 0] - 0-based index of the item at the specified position, or -1
[ 1] - 0-based index of the subitem at the specified position, or -1
[ 2] - If True, position is in control's client window but not on an item
[ 3] - If True, position is over item icon
[ 4] - If True, position is over item text
[ 5] - If True, position is over item state image
[ 6] - If True, position is somewhere on the item
[ 7] - If True, the position is above the control's client area
[ 8] - If True, the position is below the control's client area
[ 9] - If True, the position is to the left of the client area
[10] - If True, the position is to the right of the client area

Related

_GUICtrlListView_HitTest

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Global $g_idListView, $g_hStatusBar, $g_iIndex = -1, $g_iSubIndex = -1

Example()

Func Example()
    Local $hImage, $hGUI

    ; Create GUI
    $hGUI = GUICreate("ListView SubItem Hit Test", 400, 300)
    $g_idListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    $g_idListView = GUICtrlGetHandle($g_idListView) ; get the handle for use in the notify events
    $g_hStatusBar = _GUICtrlStatusBar_Create($hGUI, -1, "")

    ; Enable extended control styles
    _GUICtrlListView_SetExtendedListViewStyle($g_idListView, $LVS_EX_SUBITEMIMAGES)
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_idListView, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_idListView, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_idListView, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList($g_idListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn($g_idListView, "Column 1", 100)
    _GUICtrlListView_AddColumn($g_idListView, "Column 2", 100)
    _GUICtrlListView_AddColumn($g_idListView, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($g_idListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($g_idListView, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($g_idListView, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($g_idListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($g_idListView, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($g_idListView, "Row 3: Col 1", 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func ListView_Click()
    Local $aHit

    $aHit = _GUICtrlListView_SubItemHitTest($g_idListView)
    If ($aHit[0] <> -1) And (($aHit[0] <> $g_iIndex) Or ($aHit[1] <> $g_iSubIndex)) Then
        _GUICtrlStatusBar_SetText($g_hStatusBar, @TAB & StringFormat("HitTest Item: %d, SubItem: %d", $aHit[0], $aHit[1]))
        $g_iIndex = $aHit[0]
        $g_iSubIndex = $aHit[1]
    EndIf
EndFunc   ;==>ListView_Click

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    $hWndListView = $g_idListView
    If Not IsHWnd($g_idListView) Then $hWndListView = GUICtrlGetHandle($g_idListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $LVN_COLUMNCLICK ; A column was clicked
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    _DebugPrint("$LVN_COLUMNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    ; No return value
                Case $LVN_KEYDOWN ; A key has been pressed
                    $tInfo = DllStructCreate($tagNMLVKEYDOWN, $lParam)
                    _DebugPrint("$LVN_KEYDOWN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->VKey:" & @TAB & DllStructGetData($tInfo, "VKey") & @CRLF & _
                            "-->Flags:" & @TAB & DllStructGetData($tInfo, "Flags"))
                    ; No return value
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ListView_Click()
                    ; No return value
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_KILLFOCUS ; The control has lost the input focus
                    _DebugPrint("$NM_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ;Return 1 ; not to allow the default processing
                    Return 0 ; allow the default processing
                Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                    ; No return value
                Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
                    _DebugPrint("$NM_RETURN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_SETFOCUS ; The control has received the input focus
                    _DebugPrint("$NM_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlListView_UnRegisterSortCallBack

Function Reference

_GUICtrlListView_UnRegisterSortCallBack

UnRegister the Sort callback function

#include <GuiListView.au3>
_GUICtrlListView_UnRegisterSortCallBack ( $hWnd )

Parameters

$hWnd Handle of the control

Return Value

None.

Related

_GUICtrlListView_RegisterSortCallBack

Example

Example 1

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Global $g_idListView

Example()

Func Example()
    Local $hImage, $aIcons[3] = [0, 3, 6]
    Local $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE)
    Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER)

    GUICreate("ListView Sort", 300, 200)

    $g_idListView = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180, -1, $iExWindowStyle)
    _GUICtrlListView_SetExtendedListViewStyle($g_idListView, $iExListViewStyle)

    ; Load images
    $hImage = _GUIImageList_Create(18, 18, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -7)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -12)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -4)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -5)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -6)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -9)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -10)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -11)
    _GUICtrlListView_SetImageList($g_idListView, $hImage, 1)

    _AddRow($g_idListView, "ABC|000666|10.05.2004", $aIcons)
    _AddRow($g_idListView, "DEF|444|11.05.2005", $aIcons, 1)
    _AddRow($g_idListView, "CDE|555|12.05.2004", $aIcons, 2)

    GUISetState(@SW_SHOW)

    _GUICtrlListView_RegisterSortCallBack($g_idListView)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $g_idListView
                ; Kick off the sort callback
                _GUICtrlListView_SortItems($g_idListView, GUICtrlGetState($g_idListView))
        EndSwitch
    WEnd

    _GUICtrlListView_UnRegisterSortCallBack($g_idListView)
    GUIDelete()
EndFunc   ;==>Example

Func _AddRow($hWnd, $sItem, $aIcons, $iPlus = 0)
    Local $aItem = StringSplit($sItem, "|")
    Local $iIndex = _GUICtrlListView_AddItem($hWnd, $aItem[1], $aIcons[0] + $iPlus, _GUICtrlListView_GetItemCount($hWnd) + 9999)
    _GUICtrlListView_SetColumnWidth($hWnd, 0, $LVSCW_AUTOSIZE_USEHEADER)

    For $x = 2 To $aItem[0]
        _GUICtrlListView_AddSubItem($hWnd, $iIndex, $aItem[$x], $x - 1, $aIcons[$x - 1] + $iPlus)
        _GUICtrlListView_SetColumnWidth($hWnd, $x - 1, $LVSCW_AUTOSIZE)
    Next
EndFunc   ;==>_AddRow

Example 2

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Global $g_idListView, $g_idListView2

Example()

Func Example()
    Local $hImage, $aIcons[3] = [0, 3, 6]
    Local $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE)
    Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER)

    GUICreate("ListView Sort Treat Numbers as Strings", 300, 200, 100)

    $g_idListView = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180, -1, $iExWindowStyle)
    _GUICtrlListView_SetExtendedListViewStyle($g_idListView, $iExListViewStyle)

    ; Load images
    $hImage = _GUIImageList_Create(18, 18, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -7)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -12)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -4)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -5)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -6)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -9)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -10)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", -11)
    _GUICtrlListView_SetImageList($g_idListView, $hImage, 1)

    _AddRow($g_idListView, "ABC|000666|10.05.2004", $aIcons)
    _AddRow($g_idListView, "DEF|444|11.05.2005", $aIcons, 1)
    _AddRow($g_idListView, "CDE|555|12.05.2004", $aIcons, 2)

    GUISetState(@SW_SHOW)

    GUICreate("ListView Sort Treat Numbers as Numbers", 300, 200, 400)

    $g_idListView2 = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180, -1, $iExWindowStyle)
    _GUICtrlListView_SetExtendedListViewStyle($g_idListView2, $iExListViewStyle)
    _GUICtrlListView_SetImageList($g_idListView2, $hImage, 1)

    _AddRow($g_idListView2, "ABC|000666|10.05.2004", $aIcons)
    _AddRow($g_idListView2, "DEF|444|11.05.2005", $aIcons, 1)
    _AddRow($g_idListView2, "CDE|555|12.05.2004", $aIcons, 2)

    GUISetState(@SW_SHOW)

    _GUICtrlListView_RegisterSortCallBack($g_idListView, False)
    _GUICtrlListView_RegisterSortCallBack($g_idListView2)
    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    _GUICtrlListView_UnRegisterSortCallBack($g_idListView)
    _GUICtrlListView_UnRegisterSortCallBack($g_idListView2)
    GUIRegisterMsg($WM_NOTIFY, "")
EndFunc   ;==>Example

Func _AddRow($hWnd, $sItem, $aIcons, $iPlus = 0)
    Local $aItem = StringSplit($sItem, "|")
    Local $iIndex = _GUICtrlListView_AddItem($hWnd, $aItem[1], $aIcons[0] + $iPlus, _GUICtrlListView_GetItemCount($hWnd) + 9999)
    _GUICtrlListView_SetColumnWidth($hWnd, 0, $LVSCW_AUTOSIZE_USEHEADER)

    For $x = 2 To $aItem[0]
        _GUICtrlListView_AddSubItem($hWnd, $iIndex, $aItem[$x], $x - 1, $aIcons[$x - 1] + $iPlus)
        _GUICtrlListView_SetColumnWidth($hWnd, $x - 1, $LVSCW_AUTOSIZE)
    Next
EndFunc   ;==>_AddRow

Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $hWndListView, $hWndListView2

    $hWndListView = $g_idListView
    $hWndListView2 = $g_idListView2
    If Not IsHWnd($g_idListView) Then $hWndListView = GUICtrlGetHandle($g_idListView)
    If Not IsHWnd($g_idListView2) Then $hWndListView2 = GUICtrlGetHandle($g_idListView2)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $hWndFrom
        Case $hWndListView, $hWndListView2
            Switch $iCode
                Case $LVN_COLUMNCLICK ; A column was clicked
                    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)

                    ; Kick off the sort callback
                    _GUICtrlListView_SortItems($hWndFrom, DllStructGetData($tInfo, "SubItem"))
                    ; No return value
            EndSwitch
    EndSwitch
    Return $__LISTVIEWCONSTANT_GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY


User Defined Functions

GuiMenu user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiMenu.au3>.

User Defined Function | Description
_GUICtrlMenu_AddMenuItem | Adds a new menu item to the end of the menu
_GUICtrlMenu_AppendMenu | Appends a new item to the end of the specified menu bar, drop-down menu, submenu, or shortcut menu
_GUICtrlMenu_CalculatePopupWindowPosition | Calculates an appropriate pop-up window position
_GUICtrlMenu_CheckMenuItem | Sets the state of the specified menu item's check mark attribute to either selected or clear
_GUICtrlMenu_CheckRadioItem | Checks a specified menu item and makes it a radio item
_GUICtrlMenu_CreateMenu | Creates a menu
_GUICtrlMenu_CreatePopup | Creates a drop down menu, submenu, or shortcut menu
_GUICtrlMenu_DeleteMenu | Deletes an item from the specified menu
_GUICtrlMenu_DestroyMenu | Destroys the specified menu and frees any memory that the menu occupies
_GUICtrlMenu_DrawMenuBar | Redraws the menu bar of the specified window
_GUICtrlMenu_EnableMenuItem | Enables, disables, or grays the specified menu item
_GUICtrlMenu_FindItem | Retrieves a menu item based on it's text
_GUICtrlMenu_FindParent | Retrieves the window to which a menu belongs
_GUICtrlMenu_GetItemBmp | Retrieves the bitmap displayed for the item
_GUICtrlMenu_GetItemBmpChecked | Retrieves the bitmap displayed if the item is selected
_GUICtrlMenu_GetItemBmpUnchecked | Retrieves the bitmap displayed if the item is not selected
_GUICtrlMenu_GetItemChecked | Retrieves the status of the menu item checked state
_GUICtrlMenu_GetItemCount | Retrieves the number of items in the specified menu
_GUICtrlMenu_GetItemData | Retrieves the application defined value associated with the menu item
_GUICtrlMenu_GetItemDefault | Retrieves the status of the menu item default state
_GUICtrlMenu_GetItemDisabled | Retrieves the status of the menu item disabled state
_GUICtrlMenu_GetItemEnabled | Retrieves the status of the menu item enabled state
_GUICtrlMenu_GetItemGrayed | Retrieves the status of the menu item grayed state
_GUICtrlMenu_GetItemHighlighted | Retrieves the status of the menu item highlighted state
_GUICtrlMenu_GetItemID | Retrieves the menu item ID
_GUICtrlMenu_GetItemInfo | Retrieves information about a menu item
_GUICtrlMenu_GetItemRect | Retrieves the bounding rectangle for the specified menu item
_GUICtrlMenu_GetItemRectEx | Retrieves the bounding rectangle for the specified menu item
_GUICtrlMenu_GetItemState | Retrieves the menu item state
_GUICtrlMenu_GetItemStateEx | Retrieves the menu flags associated with the specified menu item
_GUICtrlMenu_GetItemSubMenu | Retrieves a the submenu activated by a specified item
_GUICtrlMenu_GetItemText | Retrieves the text of the specified menu item
_GUICtrlMenu_GetItemType | Retrieves the menu item type
_GUICtrlMenu_GetMenu | Retrieves the handle of the menu assigned to the given window
_GUICtrlMenu_GetMenuBackground | Retrieves the brush to use for the menu's background
_GUICtrlMenu_GetMenuBarInfo | Retrieves information about the specified menu bar
_GUICtrlMenu_GetMenuContextHelpID | Retrieves the context help identifier
_GUICtrlMenu_GetMenuData | Retrieves the application defined value
_GUICtrlMenu_GetMenuDefaultItem | Retrieves the default menu item on the specified menu
_GUICtrlMenu_GetMenuHeight | Retrieves the maximum height of a menu
_GUICtrlMenu_GetMenuInfo | Retrieves information about a specified menu
_GUICtrlMenu_GetMenuStyle | Retrieves the style information for a menu
_GUICtrlMenu_GetSystemMenu | Allows the application to access the window menu for copying and modifying
_GUICtrlMenu_InsertMenuItem | Inserts a new menu item at the specified position
_GUICtrlMenu_InsertMenuItemEx | Inserts a new menu item at the specified position in a menu
_GUICtrlMenu_IsMenu | Determines whether a handle is a menu handle
_GUICtrlMenu_LoadMenu | Loads the specified menu resource from the executable file associated with an application instance
_GUICtrlMenu_MapAccelerator | Maps a menu accelerator key to it's position in the menu
_GUICtrlMenu_MenuItemFromPoint | Determines which menu item is at the specified location
_GUICtrlMenu_RemoveMenu | Deletes a menu item or detaches a submenu from the specified menu
_GUICtrlMenu_SetItemBitmaps | Associates the specified bitmap with a menu item
_GUICtrlMenu_SetItemBmp | Sets the bitmap displayed for the item
_GUICtrlMenu_SetItemBmpChecked | Sets the bitmap displayed if the item is selected
_GUICtrlMenu_SetItemBmpUnchecked | Sets the bitmap displayed if the item is not selected
_GUICtrlMenu_SetItemChecked | Sets the checked state of a menu item
_GUICtrlMenu_SetItemData | Sets the application defined value for a menu item
_GUICtrlMenu_SetItemDefault | Sets the status of the menu item default state
_GUICtrlMenu_SetItemDisabled | Sets the disabled state of a menu item
_GUICtrlMenu_SetItemEnabled | Sets the enabled state of a menu item
_GUICtrlMenu_SetItemGrayed | Sets the grayed state of a menu item
_GUICtrlMenu_SetItemHighlighted | Sets the highlighted state of a menu item
_GUICtrlMenu_SetItemID | Sets the menu item ID
_GUICtrlMenu_SetItemInfo | Changes information about a menu item
_GUICtrlMenu_SetItemState | Sets the state of a menu item
_GUICtrlMenu_SetItemSubMenu | Sets the drop down menu or submenu associated with the menu item
_GUICtrlMenu_SetItemText | Sets the text for a menu item
_GUICtrlMenu_SetItemType | Sets the menu item type
_GUICtrlMenu_SetMenu | Assigns a new menu to the specified window
_GUICtrlMenu_SetMenuBackground | Sets the background brush for the menu
_GUICtrlMenu_SetMenuContextHelpID | Sets the context help identifier for the menu
_GUICtrlMenu_SetMenuData | Sets the application defined for the menu
_GUICtrlMenu_SetMenuDefaultItem | Sets the default menu item
_GUICtrlMenu_SetMenuHeight | Sets the maximum height of the menu
_GUICtrlMenu_SetMenuInfo | Sets information for a specified menu
_GUICtrlMenu_SetMenuStyle | Sets the menu style
_GUICtrlMenu_TrackPopupMenu | Displays a shortcut menu at the specified location


Function _GUICtrlMenu_AddMenuItem

Function Reference

_GUICtrlMenu_AddMenuItem

Adds a new menu item to the end of the menu

#include <GuiMenu.au3>
_GUICtrlMenu_AddMenuItem ( $hMenu, $sText [, $iCmdID = 0 [, $hSubMenu = 0]] )

Parameters

$hMenu | Handle of the menu
$sText | Menu item text. If blank, a separator will be added.
$iCmdID | [optional] Command ID to assign to the item
$hSubMenu | [optional] Handle to the submenu associated with the menu item

Return Value

Success: | a 0-based menu item index.
Failure: | -1.

Related

_GUICtrlMenu_InsertMenuItem

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>

Example()

Func Example()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste, $e_idAbout

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_AddMenuItem($hFile, "&New", $e_idNew)
    _GUICtrlMenu_AddMenuItem($hFile, "&Open", $e_idOpen)
    _GUICtrlMenu_AddMenuItem($hFile, "&Save", $e_idSave)
    _GUICtrlMenu_AddMenuItem($hFile, "", 0)
    _GUICtrlMenu_AddMenuItem($hFile, "E&xit", $e_idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_AddMenuItem($hEdit, "&Cut", $e_idCut)
    _GUICtrlMenu_AddMenuItem($hEdit, "C&opy", $e_idCopy)
    _GUICtrlMenu_AddMenuItem($hEdit, "&Paste", $e_idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_AddMenuItem($hHelp, "&About", $e_idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_AddMenuItem($hMain, "&File", 0, $hFile)
    _GUICtrlMenu_AddMenuItem($hMain, "&Edit", 0, $hEdit)
    _GUICtrlMenu_AddMenuItem($hMain, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlMenu_AppendMenu

Function Reference

_GUICtrlMenu_AppendMenu

Appends a new item to the end of the specified menu bar, drop-down menu, submenu, or shortcut menu

#include <GuiMenu.au3>
_GUICtrlMenu_AppendMenu ( $hMenu, $iFlags, $iNewItem, $vNewItem )

Parameters

$hMenu | Handle of the menu
$iFlags Specifies flags to control the appearance and behavior of the new menu item:
$MF_BITMAP - Uses a bitmap as the menu item
$MF_CHECKED - Places a check mark next to the menu item. If the application provides check-mark bitmaps, this flag displays the check-mark bitmap next to the menu item.
$MF_DISABLED - Disables the menu item so that it cannot be selected, but the flag does not gray it.
$MF_ENABLED - Enables the menu item so that it can be selected, and restores it from its grayed state.
$MF_GRAYED - Disables the menu item and grays it so that it cannot be selected.
$MF_MENUBARBREAK - Functions the same as $MF_MENUBREAK for a menu bar. For a drop down menu, submenu, or shortcut menu, the new column is separated from the old column by a vertical line.
$MF_MENUBREAK - Places the item on a new line (for a menu bar) or in a new column (for a drop down menu, submenu, or shortcut menu) without separating columns.
$MF_OWNERDRAW - Specifies that the item is an owner drawn item.
Before the menu is displayed for the first time, the window that owns the menu receives a $WM_MEASUREITEM message to retrieve the width and height of the menu item.
The $WM_DRAWITEM message is then sent to the window procedure of the owner window whenever the appearance of the menu item must be updated.
$MF_POPUP - Specifies that the menu item opens a drop down menu or submenu.
The $iNewItem parameter specifies a handle to the drop down menu or submenu.
This flag is used to add a menu name to a menu bar, or a menu item that opens a submenu to a drop down menu, submenu, or shortcut menu.
$MF_SEPARATOR - Draws a horizontal dividing line. This flag is used only in a drop down menu, submenu, or shortcut menu.
The line cannot be grayed, disabled, or highlighted. The $vNewItem and $iNewItem parameters are ignored.
$MF_STRING - Specifies that the menu item is a text string. The $vNewItem parameter is a string.
$MF_UNCHECKED - Does not place a check mark next to the item. If the application supplies check mark bitmaps, this flag displays the clear bitmap next to the menu item.
$iNewItem | Specifies either the identifier of the new menu item or, if the $iFlags parameter is set to a popup, a handle to the drop down menu or submenu.
$vNewItem Specifies the content of the new menu item. The interpretation of $vNewItem depends on whether the $iFlags parameter includes the $MF_BITMAP, $MF_OWNERDRAW, or $MF_STRING flag:
$MF_BITMAP - Contains a bitmap handle
$MF_OWNERDRAW - Contains an application supplied value that can be used to maintain additional data related to the menu item.
The value is in the ItemData member of the structure pointed to by the lParam parameter of the $WM_MEASUREITEM or $WM_DRAWITEM message sent when the menu is created or its appearance is updated.
$MF_STRING - Contains a string

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_InsertMenuItem

See Also

Search AppendMenu in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>

Example()

Func Example()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste, $e_idAbout

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $e_idCut)
    _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $e_idCopy)
    _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $e_idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit)
    _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)
    GUISetState(@SW_SHOW)

    ; Add About menu item
    _GUICtrlMenu_AppendMenu($hHelp, $MF_STRING, $e_idAbout, "&About")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlMenu_CalculatePopupWindowPosition

Function Reference

_GUICtrlMenu_CalculatePopupWindowPosition

Calculates an appropriate pop-up window position

#include <GuiMenu.au3>
_GUICtrlMenu_CalculatePopupWindowPosition ( $iX, $iY, $iWidth, $iHeight [, $iFlags = 0 [, $tExclude = 0]] )

Parameters

$iX | The x-coordinate, in logical units, of the specified anchor point.
$iY | The y-coordinate, in logical units, of the specified anchor point.
$iWidth | The width, in logical units, of the specified window.
$iHeight | The height, in logical units, of the specified window.
$iFlags | [optional] The flags that specify how the function positions the pop-up window horizontally and vertically. $TPM_CENTERALIGN $TPM_LEFTALIGN (Default) $TPM_RIGHTALIGN $TPM_BOTTOMALIGN $TPM_TOPALIGN (Default) $TPM_VCENTERALIGN $TPM_HORIZONTAL (Default) $TPM_VERTICAL $TPM_WORKAREA
$tExclude | [optional] $tagRECT structure that specifies the exclude rectangle.

Return Value

Success: | a $tagRECT structure that contains the pop-up window position.
Failure: | sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

This function requires Windows 7 or later.

See Also

Search CalculatePopupWindowPosition in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <MsgBoxConstants.au3>

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idButton = GUICtrlCreateButton('New Window', 145, 366, 110, 23)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            _PopupDlg($hForm)
    EndSwitch
WEnd

Func _PopupDlg($hParent)
    GUISetState(@SW_DISABLE, $hParent)

    Local $tPOINT = DllStructCreate($tagPOINT)
    For $i = 1 To 2
        DllStructSetData($tPOINT, $i, 0)
    Next
    _WinAPI_ClientToScreen($hParent, $tPOINT)
    Local $hDlg = GUICreate('New Window', 400, 400)
    Local $idButton = GUICtrlCreateButton('Close', 165, 366, 70, 23)
    Local $tRECT = _GUICtrlMenu_CalculatePopupWindowPosition(DllStructGetData($tPOINT, 1), DllStructGetData($tPOINT, 2), _WinAPI_GetWindowWidth($hDlg), _WinAPI_GetWindowHeight($hDlg))
    If @error Then
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows 7 or later.')
        Exit
    EndIf
    WinMove($hDlg, '', DllStructGetData($tRECT, 1), DllStructGetData($tRECT, 2))
    GUISetState(@SW_SHOW, $hDlg)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idButton
                ExitLoop
        EndSwitch
    WEnd

    GUISetState(@SW_ENABLE, $hParent)
    GUIDelete($hDlg)
EndFunc   ;==>_PopupDlg


Function _GUICtrlMenu_CheckMenuItem

Function Reference

_GUICtrlMenu_CheckMenuItem

Sets the state of the specified menu item's check mark attribute to either selected or clear

#include <GuiMenu.au3>
_GUICtrlMenu_CheckMenuItem ( $hMenu, $iItem [, $bCheck = True [, $bByPos = True]] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item to check
$bCheck | [optional] True to set the check mark, False to remove it
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | the previous state of the menu item (either $MF_CHECKED or $MF_UNCHECKED).
Failure: | -1.

Remarks

An item in a menu bar cannot have a check mark. The $iItem parameter identifies a item that opens a submenu or a command item.
For an item that opens a submenu, the $Item parameter must specify the position of the item.
For a command item, the $Item parameter can specify either the item's position or its identifier.

Related

_GUICtrlMenu_CheckRadioItem

See Also

Search CheckMenuItem in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>

Example()

Func Example()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste, $e_idAbout

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $e_idCut)
    _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $e_idCopy)
    _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $e_idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hHelp, 0, "&About", $e_idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit)
    _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)
    GUISetState(@SW_SHOW)

    ; Check About menu item
    _GUICtrlMenu_CheckMenuItem($hHelp, 0)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlMenu_CheckRadioItem

Function Reference

_GUICtrlMenu_CheckRadioItem

Checks a specified menu item and makes it a radio item

#include <GuiMenu.au3>
_GUICtrlMenu_CheckRadioItem ( $hMenu, $iFirst, $iLast, $iCheck [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iFirst | Identifier or position of the first menu item in the group
$iLast | Identifier or position of the last menu item in the group
$iCheck | Identifier or position of the menu item to check
$bByPos | [optional] Menu identifier flag: True - $iFirst, $iLast and $iCheck are a 0-based item position False - $iFirst, $iLast and $iCheck are a menu item identifier

Return Value

Success: | True.
Failure: | False.

Remarks

This function sets the $MFT_RADIOCHECK type flag and the $MFS_CHECKED state for the item specified by $iCheck and, at the same time, clears both flags for all other items in the group. The checked item is displayed using a bullet bitmap instead of a check-mark bitmap.

Related

_GUICtrlMenu_CheckMenuItem

See Also

Search CheckMenuRadioItem in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>

Example()

Func Example()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste, $e_idAbout

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $e_idCut)
    _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $e_idCopy)
    _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $e_idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hHelp, 0, "&About", $e_idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit)
    _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)
    GUISetState(@SW_SHOW)

    ; Check Open menu item
    _GUICtrlMenu_CheckRadioItem($hFile, 0, 4, 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlMenu_CreateMenu

Function Reference

_GUICtrlMenu_CreateMenu

Creates a menu

#include <GuiMenu.au3>
_GUICtrlMenu_CreateMenu ( [$iStyle = $MNS_CHECKORBMP] )

Parameters

$iStyle [optional] Style of the menu. It can be one or more of the following values:
$MNS_AUTODISMISS - Menu automatically ends when mouse is outside the menu for 10 seconds
$MNS_CHECKORBMP - The same space is reserved for the check mark and the bitmap (default)
$MNS_DRAGDROP - Menu items are OLE drop targets or drag sources
$MNS_MODELESS - Menu is modeless
$MNS_NOCHECK - No space is reserved to the left of an item for a check mark
$MNS_NOTIFYBYPOS - Menu owner receives a WM_MENUCOMMAND message instead of a WM_COMMAND message for selections

Return Value

Success: | The handle to the newly created menu.
Failure: | 0.

Remarks

Menu resources that are assigned to a window are freed automatically. If the menu is not assigned to a window, an application must free system resources associated with the menu before closing.
An application frees menu resources by calling the _GUICtrlMenu_DestroyMenu() function.
$MNS_NOTIFYBYPOS is a menu header style and has no effect when applied to individual sub menus

Related

_GUICtrlMenu_CreatePopup, _GUICtrlMenu_DestroyMenu

See Also

Search CreateMenu in MSDN Library.

Example

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

Global $g_idMemo
Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste, $e_idAbout

Example()

Func Example()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $e_idCut)
    _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $e_idCopy)
    _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $e_idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hHelp, 0, "&About", $e_idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit)
    _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 276, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Handle menu commands
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam
    Switch _WinAPI_LoWord($wParam)
        Case $e_idNew
            MemoWrite("New")
        Case $e_idOpen
            MemoWrite("Open")
        Case $e_idSave
            MemoWrite("Save")
        Case $e_idExit
            Exit
        Case $e_idCut
            MemoWrite("Cut")
        Case $e_idCopy
            MemoWrite("Copy")
        Case $e_idPaste
            MemoWrite("Paste")
        Case $e_idAbout
            MemoWrite("About")
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMenu_CreatePopup

Function Reference

_GUICtrlMenu_CreatePopup

Creates a drop down menu, submenu, or shortcut menu

#include <GuiMenu.au3>
_GUICtrlMenu_CreatePopup ( [$iStyle = $MNS_CHECKORBMP] )

Parameters

$iStyle [optional] Style of the menu. It can be one or more of the following values:
$MNS_AUTODISMISS - Menu automatically ends when mouse is outside the menu for 10 seconds
$MNS_CHECKORBMP - The same space is reserved for the check mark and the bitmap (default)
$MNS_DRAGDROP - Menu items are OLE drop targets or drag sources
$MNS_MODELESS - Menu is modeless
$MNS_NOCHECK - No space is reserved to the left of an item for a check mark
$MNS_NOTIFYBYPOS - Menu owner receives a WM_MENUCOMMAND message instead of a WM_COMMAND message for selections

Return Value

Success: | The handle to the newly created menu.
Failure: | 0.

Remarks

Menu resources that are assigned to a window are freed automatically. If the menu is not assigned to a window, an application must free system resources associated with the menu before closing.
An application frees menu resources by calling the _GUICtrlMenu_DestroyMenu() function.
$MNS_NOTIFYBYPOS is a menu header style and has no effect when applied to individual sub menus

Related

_GUICtrlMenu_CreateMenu, _GUICtrlMenu_DestroyMenu

See Also

Search CreatePopupMenu in MSDN Library.

Example

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

Global Enum $e_idOpen = 1000, $e_idSave, $e_idInfo

Example()

Func Example()
    ; Create GUI
    GUICreate("Menu", 400, 300)
    GUISetState(@SW_SHOW)

    ; Register message handlers
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Handle WM_COMMAND messages
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam
    Switch $wParam
        Case $e_idOpen
            _WinAPI_ShowMsg("Open")
        Case $e_idSave
            _WinAPI_ShowMsg("Save")
        Case $e_idInfo
            _WinAPI_ShowMsg("Info")
    EndSwitch
EndFunc   ;==>WM_COMMAND

; Handle WM_CONTEXTMENU messages
Func WM_CONTEXTMENU($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam
    Local $hMenu

    $hMenu = _GUICtrlMenu_CreatePopup()
    _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $e_idInfo)
    _GUICtrlMenu_TrackPopupMenu($hMenu, $wParam)
    _GUICtrlMenu_DestroyMenu($hMenu)
    Return True
EndFunc   ;==>WM_CONTEXTMENU


Function _GUICtrlMenu_DeleteMenu

Function Reference

_GUICtrlMenu_DeleteMenu

Deletes an item from the specified menu

#include <GuiMenu.au3>
_GUICtrlMenu_DeleteMenu ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu | Menu handle
$iItem | Identifier or position of the menu item
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_DestroyMenu

See Also

Search DeleteMenu in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>

Example()

Func Example()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste, $e_idAbout

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $e_idCut)
    _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $e_idCopy)
    _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $e_idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hHelp, 0, "&About", $e_idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit)
    _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)
    GUISetState(@SW_SHOW)

    ; Delete About menu item
    _GUICtrlMenu_DeleteMenu($hHelp, 0)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlMenu_DestroyMenu

Function Reference

_GUICtrlMenu_DestroyMenu

Destroys the specified menu and frees any memory that the menu occupies

#include <GuiMenu.au3>
_GUICtrlMenu_DestroyMenu ( $hMenu )

Parameters

$hMenu Menu handle

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_CreateMenu, _GUICtrlMenu_CreatePopup, _GUICtrlMenu_DeleteMenu

See Also

Search DestroyMenu in MSDN Library.

Example

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

Global Enum $e_idOpen = 1000, $e_idSave, $e_idInfo

Example()

Func Example()
    ; Create GUI
    GUICreate("Menu", 400, 300)
    GUISetState(@SW_SHOW)

    ; Register message handlers
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Handle WM_COMMAND messages
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam
    Switch $wParam
        Case $e_idOpen
            _WinAPI_ShowMsg("Open")
        Case $e_idSave
            _WinAPI_ShowMsg("Save")
        Case $e_idInfo
            _WinAPI_ShowMsg("Info")
    EndSwitch
EndFunc   ;==>WM_COMMAND

; Handle WM_CONTEXTMENU messages
Func WM_CONTEXTMENU($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam
    Local $hMenu

    $hMenu = _GUICtrlMenu_CreatePopup()
    _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $e_idInfo)
    _GUICtrlMenu_TrackPopupMenu($hMenu, $wParam)
    _GUICtrlMenu_DestroyMenu($hMenu)
    Return True
EndFunc   ;==>WM_CONTEXTMENU


Function _GUICtrlMenu_DrawMenuBar

Function Reference

_GUICtrlMenu_DrawMenuBar

Redraws the menu bar of the specified window

#include <GuiMenu.au3>
_GUICtrlMenu_DrawMenuBar ( $hWnd )

Parameters

$hWnd Handle to the window whose menu bar needs redrawing

Return Value

Success: | True.
Failure: | False.

Remarks

If the menu bar changes after Windows has created the window, this function must be called to draw the menu bar.

See Also

Search DrawMenuBar in MSDN Library.

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hItem1, $hItem2

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)

    ; Create subitem menu
    $hItem1 = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hItem1, 0, "SubItem &1", 0x1000)
    _GUICtrlMenu_InsertMenuItem($hItem1, 1, "SubItem &2", 0x1001)

    ; Create menu
    $hItem2 = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hItem2, 0, "Item &1", 0x2000, $hItem1)
    _GUICtrlMenu_InsertMenuItem($hItem2, 1, "Item &2", 0x2001)
    _GUICtrlMenu_InsertMenuItem($hItem2, 2, "", 0)
    _GUICtrlMenu_InsertMenuItem($hItem2, 3, "Item &3", 0x2002)
    _GUICtrlMenu_InsertMenuItem($hItem2, 4, "Item &4", 0x2003)

    ; Insert new menu into Notepad
    _GUICtrlMenu_InsertMenuItem($hMain, 6, "&AutoIt", 0, $hItem2)
    _GUICtrlMenu_DrawMenuBar($hWnd)
EndFunc   ;==>Example


Function _GUICtrlMenu_EnableMenuItem

Function Reference

_GUICtrlMenu_EnableMenuItem

Enables, disables, or grays the specified menu item

#include <GuiMenu.au3>
_GUICtrlMenu_EnableMenuItem ( $hMenu, $iItem [, $iState = 0 [, $bByPos = True]] )

Parameters

$hMenu | Menu handle
$iItem | Identifier or position of the menu item
$iState | [optional] Indicates whether the menu item is enabled, disabled, or grayed: 0 - Enabled 1 - Grayed 2 - Disabled
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

See Also

Search EnableMenuItem in MSDN Library.

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain

    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)

    ; Disable/Gray Help menu
    _GUICtrlMenu_EnableMenuItem($hMain, 4, 3)
EndFunc   ;==>Example


Function _GUICtrlMenu_FindItem

Function Reference

_GUICtrlMenu_FindItem

Retrieves a menu item based on it's text

#include <GuiMenu.au3>
_GUICtrlMenu_FindItem ( $hMenu, $sText [, $bInStr = False [, $iStart = 0]] )

Parameters

$hMenu | Menu handle
$sText | Text to search for
$bInStr | [optional] If True, the text can be anywhere in the item's text.
$iStart | [optional] Item to start searching from

Return Value

Success: | the 0-based index of the first item that contains the text.
Failure: | -1.

Remarks

The search is case insensitive.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain, $iIndex
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste, $e_idAbout

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)
    GUISetState(@SW_SHOW)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $e_idCut)
    _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $e_idCopy)
    _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $e_idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hHelp, 0, "&About", $e_idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit)
    _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)

    ; Click Help menu item
    $iIndex = _GUICtrlMenu_FindItem($hMain, "Help")
    MsgBox($MB_SYSTEMMODAL, "Information", "Index for Help Menu: " & $iIndex)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlMenu_FindParent

Function Reference

_GUICtrlMenu_FindParent

Retrieves the window to which a menu belongs

#include <GuiMenu.au3>
_GUICtrlMenu_FindParent ( $hMenu )

Parameters

$hMenu Menu handle

Return Value

Success: | the window handle.
Failure: | 0.

Related

_GUICtrlMenu_GetMenu

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain

    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)

    ; Show that Menu handle belongs to Notepad
    Writeln("Notepad handle: 0x" & Hex($hWnd))
    Writeln("Menu Parent ..: 0x" & Hex(_GUICtrlMenu_FindParent($hMain)))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetItemBmp

Function Reference

_GUICtrlMenu_GetItemBmp

Retrieves the bitmap displayed for the item

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemBmp ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Returns the handle to the bitmap to be displayed.

Related

_GUICtrlMenu_SetItemBmp

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste, $e_idAbout

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $e_idCut)
    _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $e_idCopy)
    _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $e_idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hHelp, 0, "&About", $e_idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit)
    _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 276, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set New menu item to have a bitmap
    _GUICtrlMenu_SetItemBmp($hFile, 0, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11))
    MemoWrite("Item bitmap handle: 0x" & Hex(_GUICtrlMenu_GetItemBmp($hFile, 0)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMenu_GetItemBmpChecked

Function Reference

_GUICtrlMenu_GetItemBmpChecked

Retrieves the bitmap displayed if the item is selected

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemBmpChecked ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Returns the handle to the bitmap to display next to the item if it is selected.

Related

_GUICtrlMenu_SetItemBmpChecked

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain, $hBmp1, $hBmp2
    Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste, $e_idAbout

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $e_idCut)
    _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $e_idCopy)
    _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $e_idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hHelp, 0, "&About", $e_idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit)
    _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 276, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set File menu checked/unchecked bitmaps
    $hBmp1 = _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11)
    $hBmp2 = _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 11, 11)
    _GUICtrlMenu_SetItemBmpChecked($hFile, 0, $hBmp1)
    _GUICtrlMenu_SetItemBmpChecked($hFile, 1, $hBmp1)
    _GUICtrlMenu_SetItemBmpChecked($hFile, 2, $hBmp1)
    _GUICtrlMenu_SetItemBmpUnchecked($hFile, 0, $hBmp2)
    _GUICtrlMenu_SetItemBmpUnchecked($hFile, 1, $hBmp2)
    _GUICtrlMenu_SetItemBmpUnchecked($hFile, 2, $hBmp2)

    ; Check Open menu item
    _GUICtrlMenu_CheckMenuItem($hFile, 1)

    ; Show that bitmap handles match
    MemoWrite("Checked handle ......: 0x" & Hex($hBmp1))
    MemoWrite("Unchecked handle ....: 0x" & Hex($hBmp2))
    MemoWrite("Open checked handle .: 0x" & Hex(_GUICtrlMenu_GetItemBmpChecked($hFile, 0)))
    MemoWrite("Open unchecked handle: 0x" & Hex(_GUICtrlMenu_GetItemBmpUnchecked($hFile, 0)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMenu_GetItemBmpUnchecked

Function Reference

_GUICtrlMenu_GetItemBmpUnchecked

Retrieves the bitmap displayed if the item is not selected

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemBmpUnchecked ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Returns the handle to the bitmap to display next to the item if it is not selected.

Related

_GUICtrlMenu_SetItemBmpUnchecked

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain, $hBmp1, $hBmp2
    Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste, $e_idAbout

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $e_idCut)
    _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $e_idCopy)
    _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $e_idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hHelp, 0, "&About", $e_idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit)
    _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 276, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set File menu checked/unchecked bitmaps
    $hBmp1 = _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11)
    $hBmp2 = _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 11, 11)
    _GUICtrlMenu_SetItemBmpChecked($hFile, 0, $hBmp1)
    _GUICtrlMenu_SetItemBmpChecked($hFile, 1, $hBmp1)
    _GUICtrlMenu_SetItemBmpChecked($hFile, 2, $hBmp1)
    _GUICtrlMenu_SetItemBmpUnchecked($hFile, 0, $hBmp2)
    _GUICtrlMenu_SetItemBmpUnchecked($hFile, 1, $hBmp2)
    _GUICtrlMenu_SetItemBmpUnchecked($hFile, 2, $hBmp2)

    ; Check Open menu item
    _GUICtrlMenu_CheckMenuItem($hFile, 1)

    ; Show that bitmap handles match
    MemoWrite("Checked handle ......: 0x" & Hex($hBmp1))
    MemoWrite("Unchecked handle ....: 0x" & Hex($hBmp2))
    MemoWrite("Open checked handle .: 0x" & Hex(_GUICtrlMenu_GetItemBmpChecked($hFile, 0)))
    MemoWrite("Open unchecked handle: 0x" & Hex(_GUICtrlMenu_GetItemBmpUnchecked($hFile, 0)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMenu_GetItemChecked

Function Reference

_GUICtrlMenu_GetItemChecked

Retrieves the status of the menu item checked state

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemChecked ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

True: | the item is checked.
False: | the item is not checked.

Related

_GUICtrlMenu_SetItemChecked

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Check Open menu item
    Writeln("Open is checked: " & _GUICtrlMenu_GetItemChecked($hFile, 1))
    _GUICtrlMenu_SetItemChecked($hFile, 1)
    Writeln("Open is checked: " & _GUICtrlMenu_GetItemChecked($hFile, 1))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetItemCount

Function Reference

_GUICtrlMenu_GetItemCount

Retrieves the number of items in the specified menu

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemCount ( $hMenu )

Parameters

$hMenu Handle of the menu

Return Value

Success: | the number of items in the menu.
Failure: | -1.

See Also

Search GetMenuItemCount in MSDN Library.

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)

    ; Show Main menu item count
    Writeln("Main menu item count: " & _GUICtrlMenu_GetItemCount($hMain))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetItemData

Function Reference

_GUICtrlMenu_GetItemData

Retrieves the application defined value associated with the menu item

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemData ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Returns the application defined value associated with the menu item.

Related

_GUICtrlMenu_SetItemData

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)

    ; Get/Set File menu item data
    Writeln("File menu item data: " & _GUICtrlMenu_GetItemData($hMain, 0))
    _GUICtrlMenu_SetItemData($hMain, 0, 1234)
    Writeln("File menu item data: " & _GUICtrlMenu_GetItemData($hMain, 0))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetItemDefault

Function Reference

_GUICtrlMenu_GetItemDefault

Retrieves the status of the menu item default state

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemDefault ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

True: | $iItem is the default item.
False: | $iItem is not the default item.

Related

_GUICtrlMenu_SetItemDefault

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set File default item
    Writeln("Open is default: " & _GUICtrlMenu_GetItemDefault($hFile, 1))
    _GUICtrlMenu_SetItemDefault($hFile, 1)
    Writeln("Open is default: " & _GUICtrlMenu_GetItemDefault($hFile, 1))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetItemDisabled

Function Reference

_GUICtrlMenu_GetItemDisabled

Retrieves the status of the menu item disabled state

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemDisabled ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

True: | $iItem is disabled.
False: | $iItem is not disabled.

Related

_GUICtrlMenu_SetItemDisabled

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set Open enabled
    Writeln("Open is disabled: " & _GUICtrlMenu_GetItemDisabled($hFile, 1))
    _GUICtrlMenu_SetItemDisabled($hFile, 1)
    Writeln("Open is disabled: " & _GUICtrlMenu_GetItemDisabled($hFile, 1))
    _GUICtrlMenu_SetItemEnabled($hFile, 1)
    Writeln("Open is enabled : " & _GUICtrlMenu_GetItemEnabled($hFile, 1))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetItemEnabled

Function Reference

_GUICtrlMenu_GetItemEnabled

Retrieves the status of the menu item enabled state

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemEnabled ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

True: | $iItem is enabled.
False: | $iItem is not enabled

Related

_GUICtrlMenu_SetItemEnabled

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set Open enabled
    Writeln("Open is disabled: " & _GUICtrlMenu_GetItemDisabled($hFile, 1))
    _GUICtrlMenu_SetItemDisabled($hFile, 1)
    Writeln("Open is disabled: " & _GUICtrlMenu_GetItemDisabled($hFile, 1))
    _GUICtrlMenu_SetItemEnabled($hFile, 1)
    Writeln("Open is enabled : " & _GUICtrlMenu_GetItemEnabled($hFile, 1))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetItemGrayed

Function Reference

_GUICtrlMenu_GetItemGrayed

Retrieves the status of the menu item grayed state

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemGrayed ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

True: | $iItem is grayed.
False: | $iItem is not grayed.

Related

_GUICtrlMenu_SetItemGrayed

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set Open grayed
    Writeln("Open is grayed: " & _GUICtrlMenu_GetItemGrayed($hFile, 1))
    _GUICtrlMenu_SetItemGrayed($hFile, 1)
    Writeln("Open is grayed: " & _GUICtrlMenu_GetItemGrayed($hFile, 1))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetItemHighlighted

Function Reference

_GUICtrlMenu_GetItemHighlighted

Retrieves the status of the menu item highlighted state

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemHighlighted ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

True: | $iItem is highlighted.
False: | $iItem is not highlighted.

Related

_GUICtrlMenu_SetItemHighlighted

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set Open highlighted
    Writeln("Open is highlighted: " & _GUICtrlMenu_GetItemHighlighted($hFile, 1))
    _GUICtrlMenu_SetItemHighlighted($hFile, 1)
    Writeln("Open is highlighted: " & _GUICtrlMenu_GetItemHighlighted($hFile, 1))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetItemID

Function Reference

_GUICtrlMenu_GetItemID

Retrieves the menu item ID

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemID ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Returns the application defined value associated with the menu item.

Related

_GUICtrlMenu_SetItemID

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set Open command ID
    Writeln("Open command ID: " & _GUICtrlMenu_GetItemID($hFile, 1))
    _GUICtrlMenu_SetItemID($hFile, 1, 0)
    Writeln("Open command ID: " & _GUICtrlMenu_GetItemID($hFile, 1))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetItemInfo

Function Reference

_GUICtrlMenu_GetItemInfo

Retrieves information about a menu item

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemInfo ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | a $tagMENUITEMINFO structure.
Failure: | sets the @error flag to non-zero.

Related

$tagMENUITEMINFO, _GUICtrlMenu_SetItemInfo

See Also

Search GetMenuItemInfo in MSDN Library.

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile, $tInfo

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set Open command ID
    $tInfo = _GUICtrlMenu_GetItemInfo($hFile, 1)
    Writeln("Open command ID: " & DllStructGetData($tInfo, "ID"))
    DllStructSetData($tInfo, "ID", 0)
    _GUICtrlMenu_SetItemInfo($hFile, 1, $tInfo)
    $tInfo = _GUICtrlMenu_GetItemInfo($hFile, 1)
    Writeln("Open command ID: " & DllStructGetData($tInfo, "ID"))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetItemRect

Function Reference

_GUICtrlMenu_GetItemRect

Retrieves the bounding rectangle for the specified menu item

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemRect ( $hWnd, $hMenu, $iItem )

Parameters

$hWnd | Handle to the window containing the menu
$hMenu | Handle of the menu
$iItem | 0-based position of the menu item

Return Value

Returns an array with the following format:
[0] = X coordinate of the upper left corner of the rectangle
[1] = Y coordinate of the upper left corner of the rectangle
[2] = X coordinate of the lower right corner of the rectangle
[3] = Y coordinate of the lower right corner of the rectangle

Related

_GUICtrlMenu_GetItemRectEx

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $aRect

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)

    ; Get File menu rectangle
    $aRect = _GUICtrlMenu_GetItemRect($hWnd, $hMain, 0)

    Writeln("File X1: " & $aRect[0])
    Writeln("File Y1: " & $aRect[1])
    Writeln("File X2: " & $aRect[2])
    Writeln("File Y2: " & $aRect[3])
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetItemRectEx

Function Reference

_GUICtrlMenu_GetItemRectEx

Retrieves the bounding rectangle for the specified menu item

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemRectEx ( $hWnd, $hMenu, $iItem )

Parameters

$hWnd | Handle to the window containing the menu
$hMenu | Handle of the menu
$iItem | 0-based position of the menu item

Return Value

Success: | a $tagRECT structure.
Failure: | sets the @error flag to non-zero.

Related

_GUICtrlMenu_GetItemRect

See Also

Search GetMenuItemRect in MSDN Library.

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $tRECT

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)

    ; Get File menu rectangle
    $tRECT = _GUICtrlMenu_GetItemRectEx($hWnd, $hMain, 0)

    Writeln("File X1: " & DllStructGetData($tRECT, "Left"))
    Writeln("File Y1: " & DllStructGetData($tRECT, "Top"))
    Writeln("File X2: " & DllStructGetData($tRECT, "Right"))
    Writeln("File Y2: " & DllStructGetData($tRECT, "Bottom"))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetItemState

Function Reference

_GUICtrlMenu_GetItemState

Retrieves the menu item state

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemState ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Returns the Menu item type. Can be one or more of the following:
1 - Item is checked
2 - Item is the default item
4 - Item is disabled
8 - Item is grayed
16 - Item is highlighted

Related

_GUICtrlMenu_GetItemStateEx, _GUICtrlMenu_SetItemState

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get Open item state
    _GUICtrlMenu_SetItemChecked($hFile, 1)
    Writeln("Open item state: " & _GUICtrlMenu_GetItemState($hFile, 1))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetItemStateEx

Function Reference

_GUICtrlMenu_GetItemStateEx

Retrieves the menu flags associated with the specified menu item

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemStateEx ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | If the menu item opens a submenu the low-order byte of the return value contains the menu flags associated with the item, and the high-order byte contains the number of items in the submenu opened by the item. Otherwise, the return value is a mask of the menu flags.
Failure: | -1

Related

_GUICtrlMenu_GetItemState, _GUICtrlMenu_SetItemState

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get Open item state
    _GUICtrlMenu_SetItemState($hFile, 1, $MFS_CHECKED)
    Writeln("Open item state: " & _GUICtrlMenu_GetItemStateEx($hFile, 1))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetItemSubMenu

Function Reference

_GUICtrlMenu_GetItemSubMenu

Retrieves a the submenu activated by a specified item

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemSubMenu ( $hMenu, $iItem )

Parameters

$hMenu | Handle of the menu
$iItem | 0-based position of the menu item

Return Value

Success: | a handle to the drop down menu or submenu activated by the menu item.
Failure: | 0.

Related

_GUICtrlMenu_RemoveMenu, _GUICtrlMenu_SetItemSubMenu

See Also

Search GetSubMenu in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste, $e_idAbout

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $e_idCut)
    _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $e_idCopy)
    _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $e_idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hHelp, 0, "&About", $e_idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit)
    _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, 0)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 276, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set Help menu
    MemoWrite("Help submenu handle: " & _GUICtrlMenu_GetItemSubMenu($hMain, 2))
    _GUICtrlMenu_SetItemSubMenu($hMain, 2, $hHelp)
    MemoWrite("Help submenu handle: " & _GUICtrlMenu_GetItemSubMenu($hMain, 2))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMenu_GetItemText

Function Reference

_GUICtrlMenu_GetItemText

Retrieves the text of the specified menu item

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemText ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | the menu item text.
Failure: | sets the @error flag to non-zero.

Related

_GUICtrlMenu_SetItemText

See Also

Search GetMenuString in MSDN Library.

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set Open item text
    Writeln("Open item text: " & _GUICtrlMenu_GetItemText($hFile, 1))
    _GUICtrlMenu_SetItemText($hFile, 1, "&Closed")
    Writeln("Open item text: " & _GUICtrlMenu_GetItemText($hFile, 1))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetItemType

Function Reference

_GUICtrlMenu_GetItemType

Retrieves the menu item type

#include <GuiMenu.au3>
_GUICtrlMenu_GetItemType ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Returns the Menu item type. Can be one or more of the following:
$MFT_BITMAP - Item is displayed using a bitmap
$MFT_MENUBARBREAK - Item is placed on a new line. A vertical line separates the new column from the old.
$MFT_MENUBREAK - Item is placed on a new line. The columns are not separated by a vertical line.
$MFT_OWNERDRAW - Item is owner drawn
$MFT_RADIOCHECK - Item is displayed using a radio button mark
$MFT_RIGHTJUSTIFY - Item is right justified
$MFT_RIGHTORDER - Item cascades from right to left
$MFT_SEPARATOR - Item is a separator

Related

_GUICtrlMenu_SetItemType

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Change Open item type
    Writeln("Open item type: 0x" & Hex(_GUICtrlMenu_GetItemType($hFile, 1)))
    _GUICtrlMenu_SetItemType($hFile, 1, $MFT_RADIOCHECK)
    _GUICtrlMenu_CheckRadioItem($hFile, 0, 8, 1)
    Writeln("Open item type: 0x" & Hex(_GUICtrlMenu_GetItemType($hFile, 1)))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetMenu

Function Reference

_GUICtrlMenu_GetMenu

Retrieves the handle of the menu assigned to the given window

#include <GuiMenu.au3>
_GUICtrlMenu_GetMenu ( $hWnd )

Parameters

$hWnd Identifies the window whose menu handle is retrieved

Return Value

Success: | the handle of the menu.
Failure: | 0.

Remarks

_GUICtrlMenu_GetMenu() does not work on floating menu bars.
Floating menu bars are custom controls that mimic standard menus, but are not menus.

Related

_GUICtrlMenu_FindParent, _GUICtrlMenu_SetMenu

See Also

Search GetMenu in MSDN Library.

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hItem1, $hItem2

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)

    ; Create subitem menu
    $hItem1 = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hItem1, 0, "SubItem &1", 0x1000)
    _GUICtrlMenu_InsertMenuItem($hItem1, 1, "SubItem &2", 0x1001)

    ; Create menu
    $hItem2 = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hItem2, 0, "Item &1", 0x2000, $hItem1)
    _GUICtrlMenu_InsertMenuItem($hItem2, 1, "Item &2", 0x2001)
    _GUICtrlMenu_InsertMenuItem($hItem2, 2, "", 0)
    _GUICtrlMenu_InsertMenuItem($hItem2, 3, "Item &3", 0x2002)
    _GUICtrlMenu_InsertMenuItem($hItem2, 4, "Item &4", 0x2003)

    ; Insert new menu into Notepad
    _GUICtrlMenu_InsertMenuItem($hMain, 6, "&AutoIt", 0, $hItem2)
    _GUICtrlMenu_DrawMenuBar($hWnd)
EndFunc   ;==>Example


Function _GUICtrlMenu_GetMenuBackground

Function Reference

_GUICtrlMenu_GetMenuBackground

Retrieves the brush to use for the menu's background

#include <GuiMenu.au3>
_GUICtrlMenu_GetMenuBackground ( $hMenu )

Parameters

$hMenu Handle of the menu

Return Value

Returns the brush used for the menu's background.

Related

_GUICtrlMenu_SetMenuBackground

Example

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

Example()

Func Example()
    Local $hWnd, $hMain, $hFile, $hBrush

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; File menu background
    Writeln("File menu background: 0x" & Hex(_GUICtrlMenu_GetMenuBackground($hFile)))
    $hBrush = _WinAPI_GetSysColorBrush($COLOR_INFOBK)
    _GUICtrlMenu_SetMenuBackground($hFile, $hBrush)
    Writeln("File menu background: 0x" & Hex(_GUICtrlMenu_GetMenuBackground($hFile)))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetMenuBarInfo

Function Reference

_GUICtrlMenu_GetMenuBarInfo

Retrieves information about the specified menu bar

#include <GuiMenu.au3>
_GUICtrlMenu_GetMenuBarInfo ( $hWnd [, $iItem = 0 [, $iObject = 1]] )

Parameters

$hWnd | Handle to the window whose information is to be retrieved
$iItem | [optional] Specifies the item for which to retrieve information. If 0, the function retrieves information about the menu itself. If 1, the function retrieves information about the first item on the menu, and so on.
$iObject | [optional] Specifies the menu object: 0 - The popup menu associated with the window 1 - The menu bar associated with the window 2 - The system menu associated with the window

Return Value

Success: | an array with the following format: [0] - X coordinate of the upper left corner of the rectangle [1] - Y coordinate of the upper left corner of the rectangle [2] - X coordinate of the lower right corner of the rectangle [3] - Y coordinate of the lower right corner of the rectangle [4] - Handle to the menu bar or popup menu [5] - Handle to the submenu [6] - True if the menu bar has focus, otherwise False [7] - True if the menu item has focus, otherwise False
Failure: | sets the @error flag to non-zero.

See Also

Search GetMenuBarInfo in MSDN Library.

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $aInfo

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")

    ; Get menu bar info
    $aInfo = _GUICtrlMenu_GetMenuBarInfo($hWnd)
    Writeln("Left ............: " & $aInfo[0])
    Writeln("Top .............: " & $aInfo[1])
    Writeln("Right ...........: " & $aInfo[2])
    Writeln("Bottom ..........: " & $aInfo[3])
    Writeln("Menu handle .....: 0x" & Hex($aInfo[4]))
    Writeln("Submenu Handle ..: 0x" & Hex($aInfo[5]))
    Writeln("Menu bar focused : " & $aInfo[6])
    Writeln("Menu item focused: " & $aInfo[7])
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetMenuContextHelpID

Function Reference

_GUICtrlMenu_GetMenuContextHelpID

Retrieves the context help identifier

#include <GuiMenu.au3>
_GUICtrlMenu_GetMenuContextHelpID ( $hMenu )

Parameters

$hMenu Handle of the menu

Return Value

Returns the context help identifier.

Related

_GUICtrlMenu_SetMenuContextHelpID

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set File menu help context ID
    Writeln("File help context ID: " & _GUICtrlMenu_GetMenuContextHelpID($hFile))
    _GUICtrlMenu_SetMenuContextHelpID($hFile, 1234)
    Writeln("File help context ID: " & _GUICtrlMenu_GetMenuContextHelpID($hFile))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetMenuData

Function Reference

_GUICtrlMenu_GetMenuData

Retrieves the application defined value

#include <GuiMenu.au3>
_GUICtrlMenu_GetMenuData ( $hMenu )

Parameters

$hMenu Handle of the menu

Return Value

Returns the application defined value.

Related

_GUICtrlMenu_SetMenuData

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set File menu data
    Writeln("File data: " & _GUICtrlMenu_GetMenuData($hFile))
    _GUICtrlMenu_SetMenuData($hFile, 1234)
    Writeln("File data: " & _GUICtrlMenu_GetMenuData($hFile))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetMenuDefaultItem

Function Reference

_GUICtrlMenu_GetMenuDefaultItem

Retrieves the default menu item on the specified menu

#include <GuiMenu.au3>
_GUICtrlMenu_GetMenuDefaultItem ( $hMenu [, $bByPos = True [, $iFlags = 0]] )

Parameters

$hMenu | Handle of the menu
$bByPos | [optional] Determines whether to retrive the menu items's identifer of it's position: True - Return menu item position False - Return menu item identifier
$iFlags | [optional] Specifies how the function searches for menu items: 0 - No special search parameters 1 - Specifies that the function will return a default item even if it is disabled 2 - Specifies that if the default item is one that opens a submenu the function is to search recursively in the corresponding submenu.

Return Value

Success: | the identifier or position of the menu item.
Failure: | -1.

Related

_GUICtrlMenu_SetMenuDefaultItem

See Also

Search GetMenuDefaultItem in MSDN Library.

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set File menu default item
    Writeln("File menu default item: " & _GUICtrlMenu_GetMenuDefaultItem($hFile))
    _GUICtrlMenu_SetMenuDefaultItem($hFile, 1)
    Writeln("File menu default item: " & _GUICtrlMenu_GetMenuDefaultItem($hFile))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetMenuHeight

Function Reference

_GUICtrlMenu_GetMenuHeight

Retrieves the maximum height of a menu

#include <GuiMenu.au3>
_GUICtrlMenu_GetMenuHeight ( $hMenu )

Parameters

$hMenu Handle of the menu

Return Value

Returns the maximum height of the menu in pixels.

Remarks

When the menu items exceed the space available, scroll bars are automatically used. The default (0) is the screen height.

Related

_GUICtrlMenu_SetMenuHeight

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set File menu max height
    Writeln("File menu max height: " & _GUICtrlMenu_GetMenuHeight($hFile))
    _GUICtrlMenu_SetMenuHeight($hFile, 100)
    Writeln("File menu max height: " & _GUICtrlMenu_GetMenuHeight($hFile))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetMenuInfo

Function Reference

_GUICtrlMenu_GetMenuInfo

Retrieves information about a specified menu

#include <GuiMenu.au3>
_GUICtrlMenu_GetMenuInfo ( $hMenu )

Parameters

$hMenu Handle of the menu

Return Value

Success: | a $tagMENUINFO structure.
Failure: | sets the @error flag to non-zero.

Related

$tagMENUINFO, _GUICtrlMenu_SetMenuInfo

See Also

Search GetMenuInfo in MSDN Library.

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile, $tInfo

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set File menu information
    $tInfo = _GUICtrlMenu_GetMenuInfo($hFile)
    Writeln("Menu style ..........: " & DllStructGetData($tInfo, "Style"))
    Writeln("Menu max height .....: " & DllStructGetData($tInfo, "YMax"))
    Writeln("Menu background brush: " & DllStructGetData($tInfo, "hBack"))
    Writeln("Menu context help ID : " & DllStructGetData($tInfo, "ContextHelpID"))
    Writeln("Menu data ...........: " & DllStructGetData($tInfo, "MenuData"))
    Writeln("")
    $tInfo = DllStructCreate($tagMENUINFO)
    DllStructSetData($tInfo, "Size", DllStructGetSize($tInfo))
    DllStructSetData($tInfo, "Mask", BitOR($MIM_HELPID, $MIM_MAXHEIGHT, $MIM_MENUDATA))
    DllStructSetData($tInfo, "YMax", 100)
    DllStructSetData($tInfo, "ContextHelpID", 1234)
    DllStructSetData($tInfo, "MenuData", 4567)
    _GUICtrlMenu_SetMenuInfo($hFile, $tInfo)
    $tInfo = _GUICtrlMenu_GetMenuInfo($hFile)
    Writeln("Menu style ..........: " & DllStructGetData($tInfo, "Style"))
    Writeln("Menu max height .....: " & DllStructGetData($tInfo, "YMax"))
    Writeln("Menu background brush: " & DllStructGetData($tInfo, "hBack"))
    Writeln("Menu context help ID : " & DllStructGetData($tInfo, "ContextHelpID"))
    Writeln("Menu data ...........: " & DllStructGetData($tInfo, "MenuData"))
    Writeln("")
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetMenuStyle

Function Reference

_GUICtrlMenu_GetMenuStyle

Retrieves the style information for a menu

#include <GuiMenu.au3>
_GUICtrlMenu_GetMenuStyle ( $hMenu )

Parameters

$hMenu Handle of the menu

Return Value

Returns the Style of the menu. It can be one or more of the following values:
$MNS_AUTODISMISS - Menu automatically ends when mouse is outside the menu for 10 seconds
$MNS_CHECKORBMP - The same space is reserved for the check mark and the bitmap
$MNS_DRAGDROP - Menu items are OLE drop targets or drag sources
$MNS_MODELESS - Menu is modeless
$MNS_NOCHECK - No space is reserved to the left of an item for a check mark
$MNS_NOTIFYBYPOS - Menu owner receives a WM_MENUCOMMAND message instead of a WM_COMMAND message for selections

Related

_GUICtrlMenu_SetMenuStyle

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set File menu style
    Writeln("File menu style: 0x" & Hex(_GUICtrlMenu_GetMenuStyle($hFile)))
    _GUICtrlMenu_SetMenuStyle($hFile, $MNS_NOCHECK)
    Writeln("File menu style: 0x" & Hex(_GUICtrlMenu_GetMenuStyle($hFile)))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_GetSystemMenu

Function Reference

_GUICtrlMenu_GetSystemMenu

Allows the application to access the window menu for copying and modifying

#include <GuiMenu.au3>
_GUICtrlMenu_GetSystemMenu ( $hWnd [, $bRevert = False] )

Parameters

$hWnd | Handle to the window that will own a copy of the window menu
$bRevert | [optional] Specifies the action to be taken. If this parameter is False, the function returns a handle to the copy of the window menu currently in use. The copy is initially identical to the window menu, but it can be modified. If this parameter is True, the function resets the window menu back to the default state. The previous window menu, if any, is destroyed.

Return Value

Returns If the $bRevert parameter is False, the return value is a handle to a copy of the window menu.
If the $bRevert parameter is True, the return value is 0.

Remarks

Any window that does not use the GetSystemMenu function to make its own copy of the window menu receives the standard window menu.
The window menu initially contains items with various identifier values, such as $SC_CLOSE, $SC_MOVE, and $SC_SIZE. Menu items on the window menu send $WM_SYSCOMMAND messages.
All predefined window menu items have identifier numbers greater than 0xF000.
If an application adds commands to the window menu, it should use identifier numbers less than 0xF000.
The system automatically grays items on the standard window menu, depending on the situation.
The application can perform its own checking or graying by responding to the $WM_INITMENU message that is sent before any menu is displayed.

See Also

Search GetSystemMenu in MSDN Library.

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMenu, $iCount, $iI

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMenu = _GUICtrlMenu_GetSystemMenu($hWnd)

    ; Play with system menu
    _GUICtrlMenu_InsertMenuItem($hMenu, 5, "&AutoIt")

    ; Display system menu
    $iCount = _GUICtrlMenu_GetItemCount($hMenu)
    Writeln("System menu handle: 0x" & Hex($hMenu))
    Writeln("Item count .......: " & $iCount)
    For $iI = 0 To $iCount - 1
        Writeln("Item " & $iI & " text ......: " & _GUICtrlMenu_GetItemText($hMenu, $iI))
    Next
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_InsertMenuItem

Function Reference

_GUICtrlMenu_InsertMenuItem

Inserts a new menu item at the specified position

#include <GuiMenu.au3>
_GUICtrlMenu_InsertMenuItem ( $hMenu, $iIndex, $sText [, $iCmdID = 0 [, $hSubMenu = 0]] )

Parameters

$hMenu | Handle of the menu
$iIndex | 0-based position of the menu item before which to insert the new item
$sText | Menu item text. If blank, a separator will be inserted.
$iCmdID | [optional] Command ID to assign to the item
$hSubMenu | [optional] Handle to the submenu associated with the menu item

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_AddMenuItem, _GUICtrlMenu_AppendMenu, _GUICtrlMenu_InsertMenuItemEx

See Also

Search InsertMenuItem in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>

Example()

Func Example()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $e_idCut)
    _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $e_idCopy)
    _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $e_idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit)
    _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlMenu_InsertMenuItemEx

Function Reference

_GUICtrlMenu_InsertMenuItemEx

Inserts a new menu item at the specified position in a menu

#include <GuiMenu.au3>
_GUICtrlMenu_InsertMenuItemEx ( $hMenu, $iIndex, ByRef $tMenu [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iIndex | Position of the menu item before which to insert the new item
$tMenu | $tagMENUITEMINFO structure
$bByPos | [optional] Menu identifier flag: True - $iIndex is a 0-based item position False - $iIndex is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Related

$tagMENUITEMINFO, _GUICtrlMenu_InsertMenuItem

See Also

Search InsertMenuItem in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>

Example()

Func Example()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste, $e_idAbout

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    InsertItem($hFile, 0, "&New", $e_idNew)
    InsertItem($hFile, 1, "&Open", $e_idOpen)
    InsertItem($hFile, 2, "&Save", $e_idSave)
    InsertItem($hFile, 3, "", 0)
    InsertItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu()
    InsertItem($hEdit, 0, "&Cut", $e_idCut)
    InsertItem($hEdit, 1, "C&opy", $e_idCopy)
    InsertItem($hEdit, 2, "&Paste", $e_idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()
    InsertItem($hHelp, 0, "&About", $e_idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    InsertItem($hMain, 0, "&File", 0, $hFile)
    InsertItem($hMain, 1, "&Edit", 0, $hEdit)
    InsertItem($hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Insert menu item (the hard way)
Func InsertItem($hMenu, $iIndex, $sText, $iCmdID = 0, $hSubMenu = 0)
    Local $tMenu, $tText

    $tMenu = DllStructCreate($tagMENUITEMINFO)
    DllStructSetData($tMenu, "Size", DllStructGetSize($tMenu))
    DllStructSetData($tMenu, "Mask", BitOR($MIIM_ID, $MIIM_STRING, $MIIM_SUBMENU))
    DllStructSetData($tMenu, "ID", $iCmdID)
    DllStructSetData($tMenu, "SubMenu", $hSubMenu)
    If $sText = "" Then
        DllStructSetData($tMenu, "Mask", $MIIM_FTYPE)
        DllStructSetData($tMenu, "Type", $MFT_SEPARATOR)
    Else
        DllStructSetData($tMenu, "Mask", BitOR($MIIM_ID, $MIIM_STRING, $MIIM_SUBMENU))
        $tText = DllStructCreate("wchar Text[" & StringLen($sText) + 1 & "]")
        DllStructSetData($tText, "Text", $sText)
        DllStructSetData($tMenu, "TypeData", DllStructGetPtr($tText))
    EndIf
    _GUICtrlMenu_InsertMenuItemEx($hMenu, $iIndex, $tMenu)
EndFunc   ;==>InsertItem


Function _GUICtrlMenu_IsMenu

Function Reference

_GUICtrlMenu_IsMenu

Determines whether a handle is a menu handle

#include <GuiMenu.au3>
_GUICtrlMenu_IsMenu ( $hMenu )

Parameters

$hMenu Handle to be tested

Return Value

True: | the handle is a menu handle
False: | the handle is not a menu handle

See Also

Search IsMenu in MSDN Library.

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)

    ; Check return value
    Writeln("Is Menu: " & _GUICtrlMenu_IsMenu($hWnd))
    Writeln("Is Menu: " & _GUICtrlMenu_IsMenu($hMain))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_LoadMenu

Function Reference

_GUICtrlMenu_LoadMenu

Loads the specified menu resource from the executable file associated with an application instance

#include <GuiMenu.au3>
_GUICtrlMenu_LoadMenu ( $hInst, $sMenuName )

Parameters

$hInst | Handle to the module containing the menu resource to be loaded
$sMenuName | String that contains the name of the menu resource. Alternatively, this parameter can consist of the resource identifier in the low order word and 0 in the high order word.

Return Value

Success: | the handle to the menu resource.
Failure: | 0.

See Also

Search LoadMenu in MSDN Library.


Function _GUICtrlMenu_MapAccelerator

Function Reference

_GUICtrlMenu_MapAccelerator

Maps a menu accelerator key to it's position in the menu

#include <GuiMenu.au3>
_GUICtrlMenu_MapAccelerator ( $hMenu, $sAccelKey )

Parameters

$hMenu | Handle to menu
$sAccelKey | Accelerator key

Return Value

Success: | the 0-based position of the item in the menu.
Failure: | -1.

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Map Open accelerator ID
    Writeln("Open command ID: " & _GUICtrlMenu_MapAccelerator($hFile, "O"))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_MenuItemFromPoint

Function Reference

_GUICtrlMenu_MenuItemFromPoint

Determines which menu item is at the specified location

#include <GuiMenu.au3>
_GUICtrlMenu_MenuItemFromPoint ( $hWnd, $hMenu [, $iX = -1 [, $iY = -1]] )

Parameters

$hWnd | Handle to the window containing the menu. If this value is 0 and $hMenu represents a popup menu, the function will find the menu window.
$hMenu | Handle to the menu containing the menu items to hit test
$iX | [optional] X position to test. If -1, the current mouse X position will be used.
$iY | [optional] Y position to test. If -1, the current mouse Y position will be used.

Return Value

Success: | the 0-based position of the menu item at the specified location.
Failure: | -1.

Remarks

If $hMenu specifies a menu bar the coordinates are window coordinates. Otherwise, they are client coordinates.

See Also

Search MenuItemFromPoint in MSDN Library.

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile, $tRECT, $tPoint, $iX, $iY, $iIndex

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Open File menu
    Send("!f")
    Sleep(1000)

    ; Move mouse over Open menu item
    $tRECT = _GUICtrlMenu_GetItemRectEx($hWnd, $hFile, 1)
    $tPoint = _Lib_PointFromRect($tRECT, True)
    _Lib_GetXYFromPoint($tPoint, $iX, $iY)
    MouseMove($iX, $iY, 1)
    Sleep(1000)

    ; Get menu item from current mouse position
    $iIndex = _GUICtrlMenu_MenuItemFromPoint($hWnd, $hFile)
    Send("{ESC 2}")
    Writeln("Menu item under cursor was: " & $iIndex)
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln

Func _Lib_PointFromRect(ByRef $tRECT, $bCenter = True)
    Local $iX1, $iY1, $iX2, $iY2, $tPoint

    $iX1 = DllStructGetData($tRECT, "Left")
    $iY1 = DllStructGetData($tRECT, "Top")
    $iX2 = DllStructGetData($tRECT, "Right")
    $iY2 = DllStructGetData($tRECT, "Bottom")
    If $bCenter Then
        $iX1 = $iX1 + (($iX2 - $iX1) / 2)
        $iY1 = $iY1 + (($iY2 - $iY1) / 2)
    EndIf
    $tPoint = DllStructCreate($tagPOINT)
    DllStructSetData($tPoint, "X", $iX1)
    DllStructSetData($tPoint, "Y", $iY1)
    Return $tPoint
EndFunc   ;==>_Lib_PointFromRect

Func _Lib_GetXYFromPoint(ByRef $tPoint, ByRef $iX, ByRef $iY)
    $iX = DllStructGetData($tPoint, "X")
    $iY = DllStructGetData($tPoint, "Y")
EndFunc   ;==>_Lib_GetXYFromPoint


Function _GUICtrlMenu_RemoveMenu

Function Reference

_GUICtrlMenu_RemoveMenu

Deletes a menu item or detaches a submenu from the specified menu

#include <GuiMenu.au3>
_GUICtrlMenu_RemoveMenu ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu | Handle to the menu to be changed
$iItem | Identifier or position of the menu item
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Remarks

If the menu item opens a drop down menu or submenu, _GUICtrlMenu_RemoveMenu() does not destroy the menu or its handle, allowing the menu to be reused.
Before this function is called, the _GUICtrlMenu_GetItemSubMenu() function should be used retrieve a handle to the drop-down menu or submenu.

Related

_GUICtrlMenu_GetItemSubMenu

See Also

Search RemoveMenu in MSDN Library.

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)

    ; Remove Help menu
    _GUICtrlMenu_RemoveMenu($hMain, 4)
EndFunc   ;==>Example


Function _GUICtrlMenu_SetItemBitmaps

Function Reference

_GUICtrlMenu_SetItemBitmaps

Associates the specified bitmap with a menu item

#include <GuiMenu.au3>
_GUICtrlMenu_SetItemBitmaps ( $hMenu, $iItem, $hChecked, $hUnChecked [, $bByPos = True] )

Parameters

$hMenu | Menu handle
$iItem | Identifier or position of the menu item
$hChecked | Handle to the bitmap displayed when the menu item is selected
$hUnChecked | Handle to the bitmap displayed when the menu item is not selected
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Remarks

If either the $hUnchecked or $hChecked parameter is 0, the system displays nothing next to the menu item for the corresponding check state.
If both parameters are 0, the system displays the default check mark bitmap when the item is selected, and removes the bitmap when the item is not selected.

Related

_GUICtrlMenu_SetItemBmpChecked, _GUICtrlMenu_SetItemBmpUnchecked

See Also

Search SetMenuItemBitmaps in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain, $hBmp1, $hBmp2
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste, $e_idAbout

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $e_idCut)
    _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $e_idCopy)
    _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $e_idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hHelp, 0, "&About", $e_idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit)
    _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 276, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set File menu checked/unchecked bitmaps
    $hBmp1 = _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11)
    $hBmp2 = _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 11, 11)
    _GUICtrlMenu_SetItemBitmaps($hFile, 0, $hBmp1, $hBmp2)
    _GUICtrlMenu_SetItemBitmaps($hFile, 1, $hBmp1, $hBmp2)
    _GUICtrlMenu_SetItemBitmaps($hFile, 2, $hBmp1, $hBmp2)

    ; Check Open menu item
    _GUICtrlMenu_CheckMenuItem($hFile, 1)

    ; Show that bitmap handles match
    MemoWrite("Checked handle ......: 0x" & Hex($hBmp1))
    MemoWrite("Unchecked handle ....: 0x" & Hex($hBmp2))
    MemoWrite("Open checked handle .: 0x" & Hex(_GUICtrlMenu_GetItemBmpChecked($hFile, 0)))
    MemoWrite("Open unchecked handle: 0x" & Hex(_GUICtrlMenu_GetItemBmpUnchecked($hFile, 0)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMenu_SetItemBmp

Function Reference

_GUICtrlMenu_SetItemBmp

Sets the bitmap displayed for the item

#include <GuiMenu.au3>
_GUICtrlMenu_SetItemBmp ( $hMenu, $iItem, $hBitmap [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$hBitmap | Handle to the item bitmap
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetItemBmp

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste, $e_idAbout

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $e_idCut)
    _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $e_idCopy)
    _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $e_idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hHelp, 0, "&About", $e_idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit)
    _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 276, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set New menu item to have a bitmap
    _GUICtrlMenu_SetItemBmp($hFile, 0, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11))
    MemoWrite("Item bitmap handle: 0x" & Hex(_GUICtrlMenu_GetItemBmp($hFile, 0)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMenu_SetItemBmpChecked

Function Reference

_GUICtrlMenu_SetItemBmpChecked

Sets the bitmap displayed if the item is selected

#include <GuiMenu.au3>
_GUICtrlMenu_SetItemBmpChecked ( $hMenu, $iItem, $hBitmap [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$hBitmap | Handle to the bitmap to display next to the item if it is selected
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetItemBmpChecked, _GUICtrlMenu_SetItemBitmaps

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain, $hBmp1, $hBmp2
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste, $e_idAbout

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $e_idCut)
    _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $e_idCopy)
    _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $e_idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hHelp, 0, "&About", $e_idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit)
    _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 276, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set File menu checked/unchecked bitmaps
    $hBmp1 = _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11)
    $hBmp2 = _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 11, 11)
    _GUICtrlMenu_SetItemBmpChecked($hFile, 0, $hBmp1)
    _GUICtrlMenu_SetItemBmpChecked($hFile, 1, $hBmp1)
    _GUICtrlMenu_SetItemBmpChecked($hFile, 2, $hBmp1)
    _GUICtrlMenu_SetItemBmpUnchecked($hFile, 0, $hBmp2)
    _GUICtrlMenu_SetItemBmpUnchecked($hFile, 1, $hBmp2)
    _GUICtrlMenu_SetItemBmpUnchecked($hFile, 2, $hBmp2)

    ; Check Open menu item
    _GUICtrlMenu_CheckMenuItem($hFile, 1)

    ; Show that bitmap handles match
    MemoWrite("Checked handle ......: 0x" & Hex($hBmp1))
    MemoWrite("Unchecked handle ....: 0x" & Hex($hBmp2))
    MemoWrite("Open checked handle .: 0x" & Hex(_GUICtrlMenu_GetItemBmpChecked($hFile, 0)))
    MemoWrite("Open unchecked handle: 0x" & Hex(_GUICtrlMenu_GetItemBmpUnchecked($hFile, 0)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMenu_SetItemBmpUnchecked

Function Reference

_GUICtrlMenu_SetItemBmpUnchecked

Sets the bitmap displayed if the item is not selected

#include <GuiMenu.au3>
_GUICtrlMenu_SetItemBmpUnchecked ( $hMenu, $iItem, $hBitmap [, $bByPos = True] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$hBitmap | Handle to the bitmap to display next to the item if it is not selected
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetItemBmpUnchecked, _GUICtrlMenu_SetItemBitmaps

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain, $hBmp1, $hBmp2
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste, $e_idAbout

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $e_idCut)
    _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $e_idCopy)
    _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $e_idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hHelp, 0, "&About", $e_idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit)
    _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 276, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set File menu checked/unchecked bitmaps
    $hBmp1 = _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 11, 11)
    $hBmp2 = _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 11, 11)
    _GUICtrlMenu_SetItemBmpChecked($hFile, 0, $hBmp1)
    _GUICtrlMenu_SetItemBmpChecked($hFile, 1, $hBmp1)
    _GUICtrlMenu_SetItemBmpChecked($hFile, 2, $hBmp1)
    _GUICtrlMenu_SetItemBmpUnchecked($hFile, 0, $hBmp2)
    _GUICtrlMenu_SetItemBmpUnchecked($hFile, 1, $hBmp2)
    _GUICtrlMenu_SetItemBmpUnchecked($hFile, 2, $hBmp2)

    ; Check Open menu item
    _GUICtrlMenu_CheckMenuItem($hFile, 1)

    ; Show that bitmap handles match
    MemoWrite("Checked handle ......: 0x" & Hex($hBmp1))
    MemoWrite("Unchecked handle ....: 0x" & Hex($hBmp2))
    MemoWrite("Open checked handle .: 0x" & Hex(_GUICtrlMenu_GetItemBmpChecked($hFile, 0)))
    MemoWrite("Open unchecked handle: 0x" & Hex(_GUICtrlMenu_GetItemBmpUnchecked($hFile, 0)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMenu_SetItemChecked

Function Reference

_GUICtrlMenu_SetItemChecked

Sets the checked state of a menu item

#include <GuiMenu.au3>
_GUICtrlMenu_SetItemChecked ( $hMenu, $iItem [, $bState = True [, $bByPos = True]] )

Parameters

$hMenu | Menu handle
$iItem | Identifier or position of the menu item
$bState | [optional] True to set state, otherwise False
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetItemChecked

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Check Open menu item
    Writeln("Open is checked: " & _GUICtrlMenu_GetItemChecked($hFile, 1))
    _GUICtrlMenu_SetItemChecked($hFile, 1)
    Writeln("Open is checked: " & _GUICtrlMenu_GetItemChecked($hFile, 1))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_SetItemData

Function Reference

_GUICtrlMenu_SetItemData

Sets the application defined value for a menu item

#include <GuiMenu.au3>
_GUICtrlMenu_SetItemData ( $hMenu, $iItem, $iData [, $bByPos = True] )

Parameters

$hMenu | Menu handle
$iItem | Identifier or position of the menu item
$iData | Application defined value
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetItemData

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)

    ; Get/Set File menu item data
    Writeln("File menu item data: " & _GUICtrlMenu_GetItemData($hMain, 0))
    _GUICtrlMenu_SetItemData($hMain, 0, 1234)
    Writeln("File menu item data: " & _GUICtrlMenu_GetItemData($hMain, 0))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_SetItemDefault

Function Reference

_GUICtrlMenu_SetItemDefault

Sets the status of the menu item default state

#include <GuiMenu.au3>
_GUICtrlMenu_SetItemDefault ( $hMenu, $iItem [, $bState = True [, $bByPos = True]] )

Parameters

$hMenu | Handle of the menu
$iItem | Identifier or position of the menu item
$bState | [optional] Item state to set: True - State is enabled False - State is disabled
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetItemDefault

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set File default item
    Writeln("Open is default: " & _GUICtrlMenu_GetItemDefault($hFile, 1))
    _GUICtrlMenu_SetItemDefault($hFile, 1)
    Writeln("Open is default: " & _GUICtrlMenu_GetItemDefault($hFile, 1))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_SetItemDisabled

Function Reference

_GUICtrlMenu_SetItemDisabled

Sets the disabled state of a menu item

#include <GuiMenu.au3>
_GUICtrlMenu_SetItemDisabled ( $hMenu, $iItem [, $bState = True [, $bByPos = True]] )

Parameters

$hMenu | Menu handle
$iItem | Identifier or position of the menu item
$bState | [optional] True to set state, otherwise False
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetItemDisabled

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set Open enabled
    Writeln("Open is disabled: " & _GUICtrlMenu_GetItemDisabled($hFile, 1))
    _GUICtrlMenu_SetItemDisabled($hFile, 1)
    Writeln("Open is disabled: " & _GUICtrlMenu_GetItemDisabled($hFile, 1))
    _GUICtrlMenu_SetItemEnabled($hFile, 1)
    Writeln("Open is enabled : " & _GUICtrlMenu_GetItemEnabled($hFile, 1))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_SetItemEnabled

Function Reference

_GUICtrlMenu_SetItemEnabled

Sets the enabled state of a menu item

#include <GuiMenu.au3>
_GUICtrlMenu_SetItemEnabled ( $hMenu, $iItem [, $bState = True [, $bByPos = True]] )

Parameters

$hMenu | Menu handle
$iItem | Identifier or position of the menu item
$bState | [optional] Item state to set: True - State is enabled False - State is disabled
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetItemEnabled

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set Open enabled
    Writeln("Open is disabled: " & _GUICtrlMenu_GetItemDisabled($hFile, 1))
    _GUICtrlMenu_SetItemDisabled($hFile, 1)
    Writeln("Open is disabled: " & _GUICtrlMenu_GetItemDisabled($hFile, 1))
    _GUICtrlMenu_SetItemEnabled($hFile, 1)
    Writeln("Open is enabled : " & _GUICtrlMenu_GetItemEnabled($hFile, 1))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_SetItemGrayed

Function Reference

_GUICtrlMenu_SetItemGrayed

Sets the grayed state of a menu item

#include <GuiMenu.au3>
_GUICtrlMenu_SetItemGrayed ( $hMenu, $iItem [, $bState = True [, $bByPos = True]] )

Parameters

$hMenu | Menu handle
$iItem | Identifier or position of the menu item
$bState | [optional] Item state to set: True - State is enabled False - State is disabled
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetItemGrayed

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set Open grayed
    Writeln("Open is grayed: " & _GUICtrlMenu_GetItemGrayed($hFile, 1))
    _GUICtrlMenu_SetItemGrayed($hFile, 1)
    Writeln("Open is grayed: " & _GUICtrlMenu_GetItemGrayed($hFile, 1))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_SetItemHighlighted

Function Reference

_GUICtrlMenu_SetItemHighlighted

Sets the highlighted state of a menu item

#include <GuiMenu.au3>
_GUICtrlMenu_SetItemHighlighted ( $hMenu, $iItem [, $bState = True [, $bByPos = True]] )

Parameters

$hMenu | Menu handle
$iItem | Identifier or position of the menu item
$bState | [optional] Item state to set: True - State is enabled False - State is disabled
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetItemHighlighted

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set Open highlighted
    Writeln("Open is highlighted: " & _GUICtrlMenu_GetItemHighlighted($hFile, 1))
    _GUICtrlMenu_SetItemHighlighted($hFile, 1)
    Writeln("Open is highlighted: " & _GUICtrlMenu_GetItemHighlighted($hFile, 1))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_SetItemID

Function Reference

_GUICtrlMenu_SetItemID

Sets the menu item ID

#include <GuiMenu.au3>
_GUICtrlMenu_SetItemID ( $hMenu, $iItem, $iID [, $bByPos = True] )

Parameters

$hMenu | Menu handle
$iItem | Identifier or position of the menu item
$iID | Menu item ID
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetItemID

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set Open command ID
    Writeln("Open command ID: " & _GUICtrlMenu_GetItemID($hFile, 1))
    _GUICtrlMenu_SetItemID($hFile, 1, 0)
    Writeln("Open command ID: " & _GUICtrlMenu_GetItemID($hFile, 1))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_SetItemInfo

Function Reference

_GUICtrlMenu_SetItemInfo

Changes information about a menu item

#include <GuiMenu.au3>
_GUICtrlMenu_SetItemInfo ( $hMenu, $iItem, ByRef $tInfo [, $bByPos = True] )

Parameters

$hMenu | Menu handle
$iItem | Identifier or position of the menu item
$tInfo | $tagMENUITEMINFO structure
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Related

$tagMENUITEMINFO, _GUICtrlMenu_GetItemInfo

See Also

Search SetMenuItemInfo in MSDN Library.

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile, $tInfo

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set Open command ID
    $tInfo = _GUICtrlMenu_GetItemInfo($hFile, 1)
    Writeln("Open command ID: " & DllStructGetData($tInfo, "ID"))
    DllStructSetData($tInfo, "ID", 0)
    _GUICtrlMenu_SetItemInfo($hFile, 1, $tInfo)
    $tInfo = _GUICtrlMenu_GetItemInfo($hFile, 1)
    Writeln("Open command ID: " & DllStructGetData($tInfo, "ID"))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_SetItemState

Function Reference

_GUICtrlMenu_SetItemState

Sets the state of a menu item

#include <GuiMenu.au3>
_GUICtrlMenu_SetItemState ( $hMenu, $iItem, $iState [, $bState = True [, $bByPos = True]] )

Parameters

$hMenu | Menu handle
$iItem | Identifier or position of the menu item
$iState | Menu item state: $MFS_CHECKED - Item is checked $MFS_DEFAULT - Item is the default item $MFS_DISABLED - Item is disabled $MFS_GRAYED - Item is disabled $MFS_HILITE - Item is highlighted
$bState | [optional] Item state to set: True - State is enabled False - State is disabled
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetItemState, _GUICtrlMenu_GetItemStateEx

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get Open item state
    _GUICtrlMenu_SetItemState($hFile, 1, $MFS_CHECKED)
    Writeln("Open item state: " & _GUICtrlMenu_GetItemStateEx($hFile, 1))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_SetItemSubMenu

Function Reference

_GUICtrlMenu_SetItemSubMenu

Sets the drop down menu or submenu associated with the menu item

#include <GuiMenu.au3>
_GUICtrlMenu_SetItemSubMenu ( $hMenu, $iItem, $hSubMenu [, $bByPos = True] )

Parameters

$hMenu | Menu handle
$iItem | Identifier or position of the menu item
$hSubMenu | Handle to the drop down menu or submenu
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetItemSubMenu

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste, $e_idAbout

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $e_idCut)
    _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $e_idCopy)
    _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $e_idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hHelp, 0, "&About", $e_idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit)
    _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, 0)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 276, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set Help menu
    MemoWrite("Help submenu handle: " & _GUICtrlMenu_GetItemSubMenu($hMain, 2))
    _GUICtrlMenu_SetItemSubMenu($hMain, 2, $hHelp)
    MemoWrite("Help submenu handle: " & _GUICtrlMenu_GetItemSubMenu($hMain, 2))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMenu_SetItemText

Function Reference

_GUICtrlMenu_SetItemText

Sets the text for a menu item

#include <GuiMenu.au3>
_GUICtrlMenu_SetItemText ( $hMenu, $iItem, $sText [, $bByPos = True] )

Parameters

$hMenu | Menu handle
$iItem | Identifier or position of the menu item
$sText | Menu item text
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetItemText

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set Open item text
    Writeln("Open item text: " & _GUICtrlMenu_GetItemText($hFile, 1))
    _GUICtrlMenu_SetItemText($hFile, 1, "&Closed")
    Writeln("Open item text: " & _GUICtrlMenu_GetItemText($hFile, 1))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_SetItemType

Function Reference

_GUICtrlMenu_SetItemType

Sets the menu item type

#include <GuiMenu.au3>
_GUICtrlMenu_SetItemType ( $hMenu, $iItem, $iType [, $bByPos = True] )

Parameters

$hMenu | Menu handle
$iItem | Identifier or position of the menu item
$iType | Menu item type. This can be one or more of the following values: $MFT_BITMAP - Item is displayed using a bitmap $MFT_MENUBARBREAK - Item is placed on a new line. A vertical line separates the new column from the old. $MFT_MENUBREAK - Item is placed on a new line. The columns are not separated by a vertical line. $MFT_OWNERDRAW - Item is owner drawn $MFT_RADIOCHECK - Item is displayed using a radio button mark $MFT_RIGHTJUSTIFY - Item is right justified $MFT_RIGHTORDER - Item cascades from right to left $MFT_SEPARATOR - Item is a separator
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetItemType

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Change Open item type
    Writeln("Open item type: 0x" & Hex(_GUICtrlMenu_GetItemType($hFile, 1)))
    _GUICtrlMenu_SetItemType($hFile, 1, $MFT_RADIOCHECK)
    _GUICtrlMenu_CheckRadioItem($hFile, 0, 8, 1)
    Writeln("Open item type: 0x" & Hex(_GUICtrlMenu_GetItemType($hFile, 1)))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_SetMenu

Function Reference

_GUICtrlMenu_SetMenu

Assigns a new menu to the specified window

#include <GuiMenu.au3>
_GUICtrlMenu_SetMenu ( $hWnd, $hMenu )

Parameters

$hWnd | Handle to the window to which the menu is to be assigned
$hMenu | Handle to the new menu. If 0, the window's current menu is removed.

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetMenu

See Also

Search SetMenu in MSDN Library.

Example

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

Global $g_idMemo
Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste, $e_idAbout

Example()

Func Example()
    Local $hGUI, $hFile, $hEdit, $hHelp, $hMain

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)

    ; Create File menu
    $hFile = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
    _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

    ; Create Edit menu
    $hEdit = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $e_idCut)
    _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $e_idCopy)
    _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $e_idPaste)

    ; Create Help menu
    $hHelp = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hHelp, 0, "&About", $e_idAbout)

    ; Create Main menu
    $hMain = _GUICtrlMenu_CreateMenu()
    _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
    _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit)
    _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp)

    ; Set window menu
    _GUICtrlMenu_SetMenu($hGUI, $hMain)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 276, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Handle menu commands
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam
    Switch _WinAPI_LoWord($wParam)
        Case $e_idNew
            MemoWrite("New")
        Case $e_idOpen
            MemoWrite("Open")
        Case $e_idSave
            MemoWrite("Save")
        Case $e_idExit
            Exit
        Case $e_idCut
            MemoWrite("Cut")
        Case $e_idCopy
            MemoWrite("Copy")
        Case $e_idPaste
            MemoWrite("Paste")
        Case $e_idAbout
            MemoWrite("About")
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMenu_SetMenuBackground

Function Reference

_GUICtrlMenu_SetMenuBackground

Sets the background brush for the menu

#include <GuiMenu.au3>
_GUICtrlMenu_SetMenuBackground ( $hMenu, $hBrush )

Parameters

$hMenu | Handle of the menu
$hBrush | Brush to use for the background

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetMenuBackground

Example

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

Example()

Func Example()
    Local $hWnd, $hMain, $hFile, $hBrush

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; File menu background
    Writeln("File menu background: 0x" & Hex(_GUICtrlMenu_GetMenuBackground($hFile)))
    $hBrush = _WinAPI_GetSysColorBrush($COLOR_INFOBK)
    _GUICtrlMenu_SetMenuBackground($hFile, $hBrush)
    Writeln("File menu background: 0x" & Hex(_GUICtrlMenu_GetMenuBackground($hFile)))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_SetMenuContextHelpID

Function Reference

_GUICtrlMenu_SetMenuContextHelpID

Sets the context help identifier for the menu

#include <GuiMenu.au3>
_GUICtrlMenu_SetMenuContextHelpID ( $hMenu, $iHelpID )

Parameters

$hMenu | Handle of the menu
$iHelpID | Context help ID

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetMenuContextHelpID

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set File menu help context ID
    Writeln("File help context ID: " & _GUICtrlMenu_GetMenuContextHelpID($hFile))
    _GUICtrlMenu_SetMenuContextHelpID($hFile, 1234)
    Writeln("File help context ID: " & _GUICtrlMenu_GetMenuContextHelpID($hFile))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_SetMenuData

Function Reference

_GUICtrlMenu_SetMenuData

Sets the application defined for the menu

#include <GuiMenu.au3>
_GUICtrlMenu_SetMenuData ( $hMenu, $iData )

Parameters

$hMenu | Handle of the menu
$iData | Application defined data

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetMenuData

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set File menu data
    Writeln("File data: " & _GUICtrlMenu_GetMenuData($hFile))
    _GUICtrlMenu_SetMenuData($hFile, 1234)
    Writeln("File data: " & _GUICtrlMenu_GetMenuData($hFile))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_SetMenuDefaultItem

Function Reference

_GUICtrlMenu_SetMenuDefaultItem

Sets the default menu item

#include <GuiMenu.au3>
_GUICtrlMenu_SetMenuDefaultItem ( $hMenu, $iItem [, $bByPos = True] )

Parameters

$hMenu | Menu handle
$iItem | Identifier or position of the default menu item or -1 for no default item
$bByPos | [optional] Menu identifier flag: True - $iItem is a 0-based item position False - $iItem is a menu item identifier

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetMenuDefaultItem

See Also

Search SetMenuDefaultItem in MSDN Library.

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set File menu default item
    Writeln("File menu default item: " & _GUICtrlMenu_GetMenuDefaultItem($hFile))
    _GUICtrlMenu_SetMenuDefaultItem($hFile, 1)
    Writeln("File menu default item: " & _GUICtrlMenu_GetMenuDefaultItem($hFile))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_SetMenuHeight

Function Reference

_GUICtrlMenu_SetMenuHeight

Sets the maximum height of the menu

#include <GuiMenu.au3>
_GUICtrlMenu_SetMenuHeight ( $hMenu, $iHeight )

Parameters

$hMenu | Handle of the menu
$iHeight | Maximum height of the menu

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMenu_GetMenuHeight

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set File menu max height
    Writeln("File menu max height: " & _GUICtrlMenu_GetMenuHeight($hFile))
    _GUICtrlMenu_SetMenuHeight($hFile, 100)
    Writeln("File menu max height: " & _GUICtrlMenu_GetMenuHeight($hFile))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_SetMenuInfo

Function Reference

_GUICtrlMenu_SetMenuInfo

Sets information for a specified menu

#include <GuiMenu.au3>
_GUICtrlMenu_SetMenuInfo ( $hMenu, ByRef $tInfo )

Parameters

$hMenu | Menu handle
$tInfo | $tagMENUINFO structure

Return Value

Success: | True.
Failure: | False.

Related

$tagMENUINFO, _GUICtrlMenu_GetMenuInfo

See Also

Search SetMenuInfo in MSDN Library.

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile, $tInfo

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set File menu information
    $tInfo = _GUICtrlMenu_GetMenuInfo($hFile)
    Writeln("Menu style ..........: " & DllStructGetData($tInfo, "Style"))
    Writeln("Menu max height .....: " & DllStructGetData($tInfo, "YMax"))
    Writeln("Menu background brush: " & DllStructGetData($tInfo, "hBack"))
    Writeln("Menu context help ID : " & DllStructGetData($tInfo, "ContextHelpID"))
    Writeln("Menu data ...........: " & DllStructGetData($tInfo, "MenuData"))
    Writeln("")
    $tInfo = DllStructCreate($tagMENUINFO)
    DllStructSetData($tInfo, "Size", DllStructGetSize($tInfo))
    DllStructSetData($tInfo, "Mask", BitOR($MIM_HELPID, $MIM_MAXHEIGHT, $MIM_MENUDATA))
    DllStructSetData($tInfo, "YMax", 100)
    DllStructSetData($tInfo, "ContextHelpID", 1234)
    DllStructSetData($tInfo, "MenuData", 4567)
    _GUICtrlMenu_SetMenuInfo($hFile, $tInfo)
    $tInfo = _GUICtrlMenu_GetMenuInfo($hFile)
    Writeln("Menu style ..........: " & DllStructGetData($tInfo, "Style"))
    Writeln("Menu max height .....: " & DllStructGetData($tInfo, "YMax"))
    Writeln("Menu background brush: " & DllStructGetData($tInfo, "hBack"))
    Writeln("Menu context help ID : " & DllStructGetData($tInfo, "ContextHelpID"))
    Writeln("Menu data ...........: " & DllStructGetData($tInfo, "MenuData"))
    Writeln("")
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_SetMenuStyle

Function Reference

_GUICtrlMenu_SetMenuStyle

Sets the menu style

#include <GuiMenu.au3>
_GUICtrlMenu_SetMenuStyle ( $hMenu, $iStyle )

Parameters

$hMenu | Handle of the menu
$iStyle | Style of the menu. It can be one or more of the following values: $MNS_AUTODISMISS - Menu automatically ends when mouse is outside the menu for 10 seconds $MNS_CHECKORBMP - The same space is reserved for the check mark and the bitmap $MNS_DRAGDROP - Menu items are OLE drop targets or drag sources $MNS_MODELESS - Menu is modeless $MNS_NOCHECK - No space is reserved to the left of an item for a check mark $MNS_NOTIFYBYPOS - Menu owner receives a WM_MENUCOMMAND message instead of a WM_COMMAND message for selections

Return Value

Success: | True.
Failure: | False.

Remarks

$MNS_NOTIFYBYPOS is a menu header style and has no effect when applied to individual sub menus.

Related

_GUICtrlMenu_GetMenuStyle

Example

#include <GuiMenu.au3>

Example()

Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    Run("notepad.exe")
    WinWaitActive("[CLASS:Notepad]")
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set File menu style
    Writeln("File menu style: 0x" & Hex(_GUICtrlMenu_GetMenuStyle($hFile)))
    _GUICtrlMenu_SetMenuStyle($hFile, $MNS_NOCHECK)
    Writeln("File menu style: 0x" & Hex(_GUICtrlMenu_GetMenuStyle($hFile)))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln


Function _GUICtrlMenu_TrackPopupMenu

Function Reference

_GUICtrlMenu_TrackPopupMenu

Displays a shortcut menu at the specified location

#include <GuiMenu.au3>
_GUICtrlMenu_TrackPopupMenu ( $hMenu, $hWnd [, $iX = -1 [, $iY = -1 [, $iAlignX = 1 [, $iAlignY = 1 [, $iNotify = 0 [, $iButtons = 0]]]]]] )

Parameters

$hMenu | Handle to the shortcut menu to be displayed
$hWnd | Handle to the window that owns the shortcut menu
$iX | [optional] Specifies the horizontal location of the shortcut menu, in screen coordinates. If this is -1, the current mouse position is used.
$iY | [optional] Specifies the vertical location of the shortcut menu, in screen coordinates. If this is -1, the current mouse position is used.
$iAlignX | [optional] Specifies how to position the menu horizontally: 0 - Center the menu horizontally relative to $iX 1 - Position the menu so that its left side is aligned with $iX 2 - Position the menu so that its right side is aligned with $iX
$iAlignY | [optional] Specifies how to position the menu vertically: 0 - Position the menu so that its bottom side is aligned with $iY 1 - Position the menu so that its top side is aligned with $iY 2 - Center the menu vertically relative to $iY
$iNotify | [optional] Use to determine the selection withouta parent window: 1 - Do not send notification messages 2 - Return the menu item identifier of the user's selection
$iButtons | [optional] Mouse button the shortcut menu tracks: 0 - The user can select items with only the left mouse button 1 - The user can select items with both left and right buttons

Return Value

Success: | If $iNotify is set to 2, the return value is the menu item identifier of the item that the user selected. If the user cancels the menu without making a selection or if an error occurs, then the return value is zero. If $iNotify is not set to 2, the return value is 1.
Failure: | 0.

See Also

Search TrackPopupMenu in MSDN Library.

Example

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

Global Enum $e_idOpen = 1000, $e_idSave, $e_idInfo

Example()

Func Example()
    ; Create GUI
    GUICreate("Menu", 400, 300)
    GUISetState(@SW_SHOW)

    ; Register message handlers
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Handle WM_COMMAND messages
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam
    Switch $wParam
        Case $e_idOpen
            _WinAPI_ShowMsg("Open")
        Case $e_idSave
            _WinAPI_ShowMsg("Save")
        Case $e_idInfo
            _WinAPI_ShowMsg("Info")
    EndSwitch
EndFunc   ;==>WM_COMMAND

; Handle WM_CONTEXTMENU messages
Func WM_CONTEXTMENU($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam
    Local $hMenu

    $hMenu = _GUICtrlMenu_CreatePopup()
    _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $e_idOpen)
    _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $e_idSave)
    _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0)
    _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $e_idInfo)
    _GUICtrlMenu_TrackPopupMenu($hMenu, $wParam)
    _GUICtrlMenu_DestroyMenu($hMenu)
    Return True
EndFunc   ;==>WM_CONTEXTMENU


User Defined Functions

GuiMonthCal user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiMonthCal.au3>.

User Defined Function | Description
_GUICtrlMonthCal_Create | Creates a Month Calendar control
_GUICtrlMonthCal_Destroy | Delete the MonthCal control
_GUICtrlMonthCal_GetCalendarBorder | Gets the size of the border, in pixels
_GUICtrlMonthCal_GetCalendarCount | Gets the number of calendars currently displayed in the calendar control
_GUICtrlMonthCal_GetColor | Retrieves a given color for the control
_GUICtrlMonthCal_GetColorArray | Retrieves the color for a given portion of a month calendar control
_GUICtrlMonthCal_GetCurSel | Retrieves the currently selected date
_GUICtrlMonthCal_GetCurSelStr | Retrieves the currently selected date in string format
_GUICtrlMonthCal_GetFirstDOW | Retrieves the first day of the week
_GUICtrlMonthCal_GetFirstDOWStr | Retrieves the first day of the week as a string
_GUICtrlMonthCal_GetMaxSelCount | Retrieves the maximum date range that can be selected in a month calendar control
_GUICtrlMonthCal_GetMaxTodayWidth | Retrieves the maximum width of the "today" string in a month calendar control
_GUICtrlMonthCal_GetMinReqHeight | Retrieves the minimum height required to display a full month
_GUICtrlMonthCal_GetMinReqRect | Retrieves the minimum size required to display a full month
_GUICtrlMonthCal_GetMinReqRectArray | Retrieves the minimum size required to display a full month in a month calendar control
_GUICtrlMonthCal_GetMinReqWidth | Retrieves the minimum width required to display a full month
_GUICtrlMonthCal_GetMonthDelta | Retrieves the scroll rate for a month calendar control
_GUICtrlMonthCal_GetMonthRange | Retrieves date information that represents the high and low display limits
_GUICtrlMonthCal_GetMonthRangeMax | Retrieves date information that represents the high limit of the controls display
_GUICtrlMonthCal_GetMonthRangeMaxStr | Retrieves date information that represents the high limit of the controls display in string format
_GUICtrlMonthCal_GetMonthRangeMin | Retrieves date information that represents the low limit of the controls display
_GUICtrlMonthCal_GetMonthRangeMinStr | Retrieves date information that represents the low limit of the controls display in string format
_GUICtrlMonthCal_GetMonthRangeSpan | Returns a value that represents the range, in months, spanned
_GUICtrlMonthCal_GetRange | Retrieves the minimum and maximum allowable dates
_GUICtrlMonthCal_GetRangeMax | Retrieves the upper limit date range
_GUICtrlMonthCal_GetRangeMaxStr | Retrieves the upper limit date range in string format
_GUICtrlMonthCal_GetRangeMin | Retrieves the lower limit date range
_GUICtrlMonthCal_GetRangeMinStr | Retrieves the lower limit date range in string form
_GUICtrlMonthCal_GetSelRange | Retrieves the upper and lower limits of the date range currently selected
_GUICtrlMonthCal_GetSelRangeMax | Retrieves the upper date range currently selected by the user
_GUICtrlMonthCal_GetSelRangeMaxStr | Retrieves the upper date range currently selected by the user in string form
_GUICtrlMonthCal_GetSelRangeMin | Retrieves the lower date range currently selected by the user
_GUICtrlMonthCal_GetSelRangeMinStr | Retrieves the lower date range currently selected by the user in string form
_GUICtrlMonthCal_GetToday | Retrieves the date information for the date specified as "today"
_GUICtrlMonthCal_GetTodayStr | Retrieves the date information for the date specified as "today" in string format
_GUICtrlMonthCal_GetUnicodeFormat | Retrieves the Unicode character format flag for the control
_GUICtrlMonthCal_HitTest | Determines which portion of a month calendar control is at a given point
_GUICtrlMonthCal_SetCalendarBorder | Sets the size of the border, in pixels
_GUICtrlMonthCal_SetColor | Sets the color for a given portion of the month calendar
_GUICtrlMonthCal_SetCurSel | Sets the currently selected date
_GUICtrlMonthCal_SetDayState | Sets the day states for all months that are currently visible
_GUICtrlMonthCal_SetFirstDOW | Sets the first day of the week for a month calendar control
_GUICtrlMonthCal_SetMaxSelCount | Sets the maximum number of days that can be selected in a month calendar control
_GUICtrlMonthCal_SetMonthDelta | Sets the scroll rate for a month calendar control
_GUICtrlMonthCal_SetRange | Sets date information that represents the high and low limits
_GUICtrlMonthCal_SetSelRange | Sets the selection for a month calendar control to a given date range
_GUICtrlMonthCal_SetToday | Sets the date information for the date specified as "today"
_GUICtrlMonthCal_SetUnicodeFormat | Sets the Unicode character format flag for the control


Function _GUICtrlMonthCal_Create

Function Reference

_GUICtrlMonthCal_Create

Creates a Month Calendar control

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_Create ( $hWnd, $iX, $iY [, $iStyle = 0x00000000 [, $iExStyle = 0x00000000]] )

Parameters

$hWnd | Handle to parent or owner window
$iX | Horizontal position of the control
$iY | Vertical position of the control
$iStyle | [optional] Control styles: $MCS_DAYSTATE - The month calendar will send $MCN_GETDAYSTATE notifications to request information about which days should be displayed in bold. $MCS_MULTISELECT - The month calendar will allow the user to select a range of dates within the control $MCS_WEEKNUMBERS - The month calendar control will display week numbers to the left of each row of days $MCS_NOTODAYCIRCLE - The month calendar control will not circle the "today" date $MCS_NOTODAY - The month calendar control will not display the "today" date at the bottom Forced: $WS_CHILD, $WS_VISIBLE
$iExStyle | [optional] Control extended style. These correspond to the standard $WS_EX_* constants. See Extended Style Table.

Return Value

Success: | the handle to the month calendar window.
Failure: | 0.

Remarks

This function is for Advanced users and for learning how the control works.

Related

_GUICtrlMonthCal_Destroy, _GUICtrlMonthCal_GetColorArray

Example

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

Global $g_hMonthCal

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Month Calendar Create", 400, 300)
    $g_hMonthCal = _GUICtrlMonthCal_Create($hGUI, 4, 4, $WS_BORDER)
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hMonthCal
            Switch $iCode
                Case $MCN_GETDAYSTATE ; Sent by a month calendar control to request information about how individual days should be displayed
                    $tInfo = DllStructCreate($tagNMDAYSTATE, $lParam)
                    _DebugPrint("$MCN_GETDAYSTATE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->Year:" & @TAB & DllStructGetData($tInfo, "Year") & @CRLF & _
                            "-->Month:" & @TAB & DllStructGetData($tInfo, "Month") & @CRLF & _
                            "-->DOW:" & @TAB & DllStructGetData($tInfo, "DOW") & @CRLF & _
                            "-->Day:" & @TAB & DllStructGetData($tInfo, "Day") & @CRLF & _
                            "-->Hour:" & @TAB & DllStructGetData($tInfo, "Hour") & @CRLF & _
                            "-->Minute:" & @TAB & DllStructGetData($tInfo, "Minute") & @CRLF & _
                            "-->Second:" & @TAB & DllStructGetData($tInfo, "Second") & @CRLF & _
                            "-->MSecond:" & @TAB & DllStructGetData($tInfo, "MSecond") & @CRLF & _
                            "-->DayState:" & @TAB & DllStructGetData($tInfo, "DayState") & @CRLF & _
                            "-->pDayState:" & @TAB & DllStructGetData($tInfo, "pDayState"))
                    ; Address of an array of MONTHDAYSTATE (DWORD bit field that holds the state of each day in a month)
                    ; Each bit (1 through 31) represents the state of a day in a month. If a bit is on, the corresponding day will
                    ; be displayed in bold; otherwise it will be displayed with no emphasis.
                    ; No return value
                Case $MCN_SELCHANGE ; Sent by a month calendar control when the currently selected date or range of dates changes
                    $tInfo = DllStructCreate($tagNMSELCHANGE, $lParam)
                    _DebugPrint("$MCN_SELCHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->BegYear:" & @TAB & DllStructGetData($tInfo, "BegYear") & @CRLF & _
                            "-->BegMonth:" & @TAB & DllStructGetData($tInfo, "BegMonth") & @CRLF & _
                            "-->BegDOW:" & @TAB & DllStructGetData($tInfo, "BegDOW") & @CRLF & _
                            "-->BegDay:" & @TAB & DllStructGetData($tInfo, "BegDay") & @CRLF & _
                            "-->BegHour:" & @TAB & DllStructGetData($tInfo, "BegHour") & @CRLF & _
                            "-->BegMinute:" & @TAB & DllStructGetData($tInfo, "BegMinute") & @CRLF & _
                            "-->BegSecond:" & @TAB & DllStructGetData($tInfo, "BegSecond") & @CRLF & _
                            "-->BegMSeconds:" & @TAB & DllStructGetData($tInfo, "BegMSeconds") & @CRLF & _
                            "-->EndYear:" & @TAB & DllStructGetData($tInfo, "EndYear") & @CRLF & _
                            "-->EndMonth:" & @TAB & DllStructGetData($tInfo, "EndMonth") & @CRLF & _
                            "-->EndDOW:" & @TAB & DllStructGetData($tInfo, "EndDOW") & @CRLF & _
                            "-->EndDay:" & @TAB & DllStructGetData($tInfo, "EndDay") & @CRLF & _
                            "-->EndHour:" & @TAB & DllStructGetData($tInfo, "EndHour") & @CRLF & _
                            "-->EndMinute:" & @TAB & DllStructGetData($tInfo, "EndMinute") & @CRLF & _
                            "-->EndSecond:" & @TAB & DllStructGetData($tInfo, "EndSecond") & @CRLF & _
                            "-->EndMSeconds:" & @TAB & DllStructGetData($tInfo, "EndMSeconds"))
                    ; No return value
                Case $MCN_SELECT ; Sent by a month calendar control when the user makes an explicit date selection within a month calendar control
                    $tInfo = DllStructCreate($tagNMSELCHANGE, $lParam)
                    _DebugPrint("$MCN_SELECT" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->BegYear:" & @TAB & DllStructGetData($tInfo, "BegYear") & @CRLF & _
                            "-->BegMonth:" & @TAB & DllStructGetData($tInfo, "BegMonth") & @CRLF & _
                            "-->BegDOW:" & @TAB & DllStructGetData($tInfo, "BegDOW") & @CRLF & _
                            "-->BegDay:" & @TAB & DllStructGetData($tInfo, "BegDay") & @CRLF & _
                            "-->BegHour:" & @TAB & DllStructGetData($tInfo, "BegHour") & @CRLF & _
                            "-->BegMinute:" & @TAB & DllStructGetData($tInfo, "BegMinute") & @CRLF & _
                            "-->BegSecond:" & @TAB & DllStructGetData($tInfo, "BegSecond") & @CRLF & _
                            "-->BegMSeconds:" & @TAB & DllStructGetData($tInfo, "BegMSeconds") & @CRLF & _
                            "-->EndYear:" & @TAB & DllStructGetData($tInfo, "EndYear") & @CRLF & _
                            "-->EndMonth:" & @TAB & DllStructGetData($tInfo, "EndMonth") & @CRLF & _
                            "-->EndDOW:" & @TAB & DllStructGetData($tInfo, "EndDOW") & @CRLF & _
                            "-->EndDay:" & @TAB & DllStructGetData($tInfo, "EndDay") & @CRLF & _
                            "-->EndHour:" & @TAB & DllStructGetData($tInfo, "EndHour") & @CRLF & _
                            "-->EndMinute:" & @TAB & DllStructGetData($tInfo, "EndMinute") & @CRLF & _
                            "-->EndSecond:" & @TAB & DllStructGetData($tInfo, "EndSecond") & @CRLF & _
                            "-->EndMSeconds:" & @TAB & DllStructGetData($tInfo, "EndMSeconds"))
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlMonthCal_Destroy

Function Reference

_GUICtrlMonthCal_Destroy

Delete the MonthCal control

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_Destroy ( ByRef $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True, $hWnd is set to 0.
Failure: | False.

Remarks

Restricted to only be used on Month Calendar controls created with _GUICtrlMonthCal_Create().

Related

_GUICtrlMonthCal_Create

Example

#include <GUIConstantsEx.au3>
#include <GuiMonthCal.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hHandleBefore, $hMonthCal

    ; Create GUI
    $hGUI = GUICreate("Month Calendar Destroy", 400, 300)
    $hMonthCal = _GUICtrlMonthCal_Create($hGUI, 4, 4, $WS_BORDER)
    GUISetState(@SW_SHOW)

    $hHandleBefore = $hMonthCal
    MsgBox($MB_SYSTEMMODAL, "Information", "Destroying the Control for Handle: " & $hMonthCal)
    MsgBox($MB_SYSTEMMODAL, "Information", "Control Destroyed: " & _GUICtrlMonthCal_Destroy($hMonthCal) & @CRLF & _
            "Handel Before Destroy: " & $hHandleBefore & @CRLF & _
            "Handle After Destroy: " & $hMonthCal)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlMonthCal_GetCalendarBorder

Function Reference

_GUICtrlMonthCal_GetCalendarBorder

Gets the size of the border, in pixels

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetCalendarBorder ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the border size, in pixels.

Remarks

Windows Vista or later.

Related

_GUICtrlMonthCal_SetCalendarBorder

Example

#include <GUIConstantsEx.au3>
#include <GuiMonthCal.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, $WS_BORDER, 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set calendar border
    MemoWrite("Border in pixels: " & _GUICtrlMonthCal_GetCalendarBorder($idMonthCal))
    Sleep(3000)
    GUISetState(@SW_LOCK)
    _GUICtrlMonthCal_SetCalendarBorder($idMonthCal, 2)
    MemoWrite("Border in pixels: " & _GUICtrlMonthCal_GetCalendarBorder($idMonthCal))
    GUISetState(@SW_UNLOCK)
    Sleep(3000)
    GUISetState(@SW_LOCK)
    _GUICtrlMonthCal_SetCalendarBorder($idMonthCal, 0, False)
    MemoWrite("Border in pixels: " & _GUICtrlMonthCal_GetCalendarBorder($idMonthCal))
    GUISetState(@SW_UNLOCK)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetCalendarCount

Function Reference

_GUICtrlMonthCal_GetCalendarCount

Gets the number of calendars currently displayed in the calendar control

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetCalendarCount ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the number of calendars currently displayed in the calendar control. The maximum number of allowed calendars is 12.

Remarks

Windows Vista or later.

Example

#include <GUIConstantsEx.au3>
#include <GuiMonthCal.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, $WS_BORDER, 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set calendar border
    MemoWrite("Calendar Count: " & _GUICtrlMonthCal_GetCalendarCount($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetColor

Function Reference

_GUICtrlMonthCal_GetColor

Retrieves a given color for the control

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetColor ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Indicates which month calendar color to retrieve: $MCSC_BACKGROUND - Background color displayed between months $MCSC_TEXT - Color used to display text within a month $MCSC_TITLEBK - Background color displayed in the calendar title $MCSC_TITLETEXT - Color used to display text within the calendar title $MCSC_MONTHBK - Background color displayed within the month $MCSC_TRAILINGTEXT - Color used to display header day and trailing day text

Return Value

Success: | the indicated color.
Failure: | -1.

Related

_GUICtrlMonthCal_SetColor

Example

#include <GUIConstantsEx.au3>
#include <GuiMonthCal.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    ; Create GUI
    GUICreate("Month Calendar Get Color", 400, 300)
    Local $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, $WS_BORDER, 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 188, 392, 108, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set calendar color
    MemoWrite("Background: 0x" & Hex(_GUICtrlMonthCal_GetColor($idMonthCal, $MCSC_MONTHBK), 6))
    ; _GUICtrlMonthCal_SetColor($idMonthCal, $MCSC_MONTHBK, $CLR_MONEYGREEN)
    _GUICtrlMonthCal_SetColor($idMonthCal, $MCSC_TEXT, 0xB02B00)
    _GUICtrlMonthCal_SetColor($idMonthCal, $MCSC_TITLEBK, 0x5EFFFE)
    _GUICtrlMonthCal_SetColor($idMonthCal, $MCSC_TITLETEXT, 0x0000FF)
    _GUICtrlMonthCal_SetColor($idMonthCal, $MCSC_MONTHBK, 0x87C4FF)
    _GUICtrlMonthCal_SetColor($idMonthCal, $MCSC_TRAILINGTEXT, 0x997777)
    MemoWrite("Background: 0x" & Hex(_GUICtrlMonthCal_GetColor($idMonthCal, $MCSC_MONTHBK), 6))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetColorArray

Function Reference

_GUICtrlMonthCal_GetColorArray

Retrieves the color for a given portion of a month calendar control

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetColorArray ( $hWnd, $iColor )

Parameters

$hWnd | Control ID/Handle to the control
$iColor | Value of type int specifying which month calendar color to retrieve This value can be one of the following: $MCSC_BACKGROUND - Retrieve the background color displayed between months. $MCSC_MONTHBK - Retrieve the background color displayed within the month. $MCSC_TEXT - Retrieve the color used to display text within a month. $MCSC_TITLEBK - Retrieve the background color displayed in the calendar's title. $MCSC_TITLETEXT - Retrieve the color used to display text within the calendar's title. $MCSC_TRAILINGTEXT - Retrieve the color used to display header day and trailing day text.

Return Value

Success: | an array in the following format: [0] - contains the number returned [1] - contains COLORREF rgbcolor [2] - contains Hex BGR color [3] - contains Hex RGB color
Failure: | sets the @error flag to non-zero.

Remarks

Header and trailing days are the days from the previous and following months that appear on the current month calendar.

Related

_GUICtrlMonthCal_Create

Example

#include <ColorConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiMonthCal.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Color Array", 425, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, $WS_BORDER, 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 417, 128, BitOR($WS_VSCROLL, $ES_MULTILINE))
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUICtrlSendMsg($g_idMemo, $EM_SETREADONLY, True, 0)
    GUICtrlSetBkColor($g_idMemo, 0xFFFFFF)
    GUISetState(@SW_SHOW)

    _GUICtrlMonthCal_SetColor($idMonthCal, $MCSC_MONTHBK, $CLR_MONEYGREEN)

    ; Get/Set calendar colors
    MemoWrite(_FormatOutPut("Background color displayed between months:", _GUICtrlMonthCal_GetColorArray($idMonthCal, $MCSC_BACKGROUND)))
    MemoWrite(_FormatOutPut(@CRLF & "Background color displayed within the month:", _GUICtrlMonthCal_GetColorArray($idMonthCal, $MCSC_MONTHBK)))
    MemoWrite(_FormatOutPut(@CRLF & "Color used to display text within a month:", _GUICtrlMonthCal_GetColorArray($idMonthCal, $MCSC_TEXT)))
    MemoWrite(_FormatOutPut(@CRLF & "Background color displayed in the calendar's title:", _GUICtrlMonthCal_GetColorArray($idMonthCal, $MCSC_TITLEBK)))
    MemoWrite(_FormatOutPut(@CRLF & "Color used to display text within the calendar's title:", _GUICtrlMonthCal_GetColorArray($idMonthCal, $MCSC_TITLETEXT)))
    MemoWrite(_FormatOutPut(@CRLF & "Color used to display header day and trailing day text:", _GUICtrlMonthCal_GetColorArray($idMonthCal, $MCSC_TRAILINGTEXT)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _FormatOutPut($sText, $aColors)
    Return $sText & _
            @CRLF & @TAB & "COLORREF rgbcolor:" & @TAB & $aColors[1] & _
            @CRLF & @TAB & "Hex BGR color:" & @TAB & @TAB & $aColors[2] & _
            @CRLF & @TAB & "Hex RGB color:" & @TAB & @TAB & $aColors[3]
EndFunc   ;==>_FormatOutPut

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetCurSel

Function Reference

_GUICtrlMonthCal_GetCurSel

Retrieves the currently selected date

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetCurSel ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns a $tagSYSTEMTIME structure.

Related

$tagSYSTEMTIME, _GUICtrlMonthCal_GetCurSelStr, _GUICtrlMonthCal_SetCurSel

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tTime, $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Cur Sel", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, $WS_BORDER, 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set current selection
    _GUICtrlMonthCal_SetCurSel($idMonthCal, @YEAR, 8, 19)
    $tTime = _GUICtrlMonthCal_GetCurSel($idMonthCal)
    MemoWrite("Current selection : " & StringFormat("%02d/%02d/%04d", DllStructGetData($tTime, "Month"), _
            DllStructGetData($tTime, "Day"), _
            DllStructGetData($tTime, "Year")))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetCurSelStr

Function Reference

_GUICtrlMonthCal_GetCurSelStr

Retrieves the currently selected date in string format

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetCurSelStr ( $hWnd [, $sFormat = "%02d/%02d/%04d"] )

Parameters

$hWnd | Control ID/Handle to the control
$sFormat | [optional] StringFormat string used to format the date

Return Value

Returns the date in the specified format.

Related

_GUICtrlMonthCal_GetCurSel

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Cur Sel String", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, $WS_BORDER, 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get current selection
    MemoWrite("Current selection : " & _GUICtrlMonthCal_GetCurSelStr($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetFirstDOW

Function Reference

_GUICtrlMonthCal_GetFirstDOW

Retrieves the first day of the week

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetFirstDOW ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns one of the following values:
0 - Monday
1 - Tuesday
2 - Wednesday
3 - Thursday
4 - Friday
5 - Saturday
6 - Sunday

Related

_GUICtrlMonthCal_GetFirstDOWStr, _GUICtrlMonthCal_SetFirstDOW

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get First DOW", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, $WS_BORDER, 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set first DOW
    _GUICtrlMonthCal_SetFirstDOW($idMonthCal, 0)
    MemoWrite("First DOW : " & _GUICtrlMonthCal_GetFirstDOW($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetFirstDOWStr

Function Reference

_GUICtrlMonthCal_GetFirstDOWStr

Retrieves the first day of the week as a string

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetFirstDOWStr ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns one of the following values:
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday

Related

_GUICtrlMonthCal_GetFirstDOW

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get First DOW String", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, $WS_BORDER, 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set first DOW
    _GUICtrlMonthCal_SetFirstDOW($idMonthCal, 0)
    MemoWrite("First DOW : " & _GUICtrlMonthCal_GetFirstDOWStr($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetMaxSelCount

Function Reference

_GUICtrlMonthCal_GetMaxSelCount

Retrieves the maximum date range that can be selected in a month calendar control

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetMaxSelCount ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an INT value that represents the total number of days that can be selected for the control.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Sel Count", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set maximum selection count
    _GUICtrlMonthCal_SetMaxSelCount($idMonthCal, 7)
    MemoWrite("Maximum selction count: " & _GUICtrlMonthCal_GetMaxSelCount($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetMaxTodayWidth

Function Reference

_GUICtrlMonthCal_GetMaxTodayWidth

Retrieves the maximum width of the "today" string in a month calendar control

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetMaxTodayWidth ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the width of the "today" string, in pixels.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Max Today Width", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get maximum today width
    MemoWrite("Maximum today width: " & _GUICtrlMonthCal_GetMaxTodayWidth($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetMinReqHeight

Function Reference

_GUICtrlMonthCal_GetMinReqHeight

Retrieves the minimum height required to display a full month

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetMinReqHeight ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the minimum height, in pixels.

Related

_GUICtrlMonthCal_GetMinReqRect, _GUICtrlMonthCal_GetMinReqWidth

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Min Req Height", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get minimum required height/width
    MemoWrite("Minimum required height: " & _GUICtrlMonthCal_GetMinReqHeight($idMonthCal))
    MemoWrite("Minimum required width : " & _GUICtrlMonthCal_GetMinReqWidth($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetMinReqRect

Function Reference

_GUICtrlMonthCal_GetMinReqRect

Retrieves the minimum size required to display a full month

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetMinReqRect ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns a $tagRECT structure.

Related

$tagRECT, _GUICtrlMonthCal_GetMinReqHeight, _GUICtrlMonthCal_GetMinReqWidth

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tRECT, $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Min Req Rect", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get minimum required height/width
    $tRECT = _GUICtrlMonthCal_GetMinReqRect($idMonthCal)
    MemoWrite("Minimum required height: " & DllStructGetData($tRECT, "Bottom"))
    MemoWrite("Minimum required width : " & DllStructGetData($tRECT, "Right"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetMinReqRectArray

Function Reference

_GUICtrlMonthCal_GetMinReqRectArray

Retrieves the minimum size required to display a full month in a month calendar control

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetMinReqRectArray ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | an array with the following format: [0] - Count [1] - X coordinate of the upper left corner of the rectangle [2] - Y coordinate of the upper left corner of the rectangle [3] - X coordinate of the lower right corner of the rectangle [4] - Y coordinate of the lower right corner of the rectangle
Failure: | sets the @error flag to non-zero.

Remarks

The minimum required window size for a month calendar control depends on the currently selected font, control styles, system metrics, and regional settings.

Example

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiMonthCal.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Min Req Rect Array", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, BitOR($WS_VSCROLL, $ES_MULTILINE))
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUICtrlSendMsg($g_idMemo, $EM_SETREADONLY, True, 0)
    GUICtrlSetBkColor($g_idMemo, 0xFFFFFF)
    GUISetState(@SW_SHOW)

    ; Get minimum required height/width
    MemoWrite(_FormatOutPut(_GUICtrlMonthCal_GetMinReqRectArray($idMonthCal)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _FormatOutPut($aRect)
    Return "Minimum required Width: " & @TAB & $aRect[3] & @CRLF & "Minimum required Height:" & @TAB & $aRect[4]
EndFunc   ;==>_FormatOutPut

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetMinReqWidth

Function Reference

_GUICtrlMonthCal_GetMinReqWidth

Retrieves the minimum width required to display a full month

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetMinReqWidth ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the minimum width, in pixels.

Related

_GUICtrlMonthCal_GetMinReqHeight, _GUICtrlMonthCal_GetMinReqRect

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Min Req Width", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get minimum required height/width
    MemoWrite("Minimum required height: " & _GUICtrlMonthCal_GetMinReqHeight($idMonthCal))
    MemoWrite("Minimum required width : " & _GUICtrlMonthCal_GetMinReqWidth($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetMonthDelta

Function Reference

_GUICtrlMonthCal_GetMonthDelta

Retrieves the scroll rate for a month calendar control

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetMonthDelta ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an INT value as follow:
the month calendar's current scroll rate, if the month delta was previously set using the _GUICtrlMonthCal_SetMonthDelta().
the current number of months visible, if the month delta was not previously set using the _GUICtrlMonthCal_SetMonthDelta() or the month delta was reset to the default.

Related

_GUICtrlMonthCal_SetMonthDelta

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Month Delta", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set month delta
    _GUICtrlMonthCal_SetMonthDelta($idMonthCal, 2)
    MemoWrite("Month delta: " & _GUICtrlMonthCal_GetMonthDelta($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetMonthRange

Function Reference

_GUICtrlMonthCal_GetMonthRange

Retrieves date information that represents the high and low display limits

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetMonthRange ( $hWnd [, $bPartial = False] )

Parameters

$hWnd | Control ID/Handle to the control
$bPartial | [optional] Specifies the scope of the range limits to be retrieved: True - Preceding and trailing months are included False - Only months that are entirely displayed are included

Return Value

Returns a $tagMCMONTHRANGE structure.

Related

$tagMCMONTHRANGE, _GUICtrlMonthCal_GetMonthRangeMax, _GUICtrlMonthCal_GetMonthRangeMin

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tRange, $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Month Range", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get month range
    $tRange = _GUICtrlMonthCal_GetMonthRange($idMonthCal)
    MemoWrite("Month range minimum: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tRange, "MinMonth"), _
            DllStructGetData($tRange, "MinDay"), _
            DllStructGetData($tRange, "MinYear")))
    MemoWrite("Month range maximum: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tRange, "MaxMonth"), _
            DllStructGetData($tRange, "MaxDay"), _
            DllStructGetData($tRange, "MaxYear")))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetMonthRangeMax

Function Reference

_GUICtrlMonthCal_GetMonthRangeMax

Retrieves date information that represents the high limit of the controls display

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetMonthRangeMax ( $hWnd [, $bPartial = False] )

Parameters

$hWnd | Control ID/Handle to the control
$bPartial | [optional] Specifies the scope of the range limits to be retrieved: True - Preceding and trailing months are included False - Only months that are entirely displayed are included

Return Value

Returns a $tagSYSTEMTIME structure.

Related

$tagSYSTEMTIME, _GUICtrlMonthCal_GetMonthRange, _GUICtrlMonthCal_GetMonthRangeMaxStr, _GUICtrlMonthCal_GetMonthRangeMin

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tMin, $tMax, $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Month Range Max", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get month range
    $tMin = _GUICtrlMonthCal_GetMonthRangeMin($idMonthCal)
    $tMax = _GUICtrlMonthCal_GetMonthRangeMax($idMonthCal)
    MemoWrite("Month range minimum: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tMin, "Month"), _
            DllStructGetData($tMin, "Day"), _
            DllStructGetData($tMin, "Year")))
    MemoWrite("Month range maximum: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tMax, "Month"), _
            DllStructGetData($tMax, "Day"), _
            DllStructGetData($tMax, "Year")))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetMonthRangeMaxStr

Function Reference

_GUICtrlMonthCal_GetMonthRangeMaxStr

Retrieves date information that represents the high limit of the controls display in string format

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetMonthRangeMaxStr ( $hWnd [, $sFormat = "%02d/%02d/%04d"] )

Parameters

$hWnd | Control ID/Handle to the control
$sFormat | [optional] StringFormat string used to format the date

Return Value

Returns a date in the specified format.

Related

_GUICtrlMonthCal_GetMonthRangeMax

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Month Range Max String", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get month range
    MemoWrite("Month range minimum: " & _GUICtrlMonthCal_GetMonthRangeMinStr($idMonthCal))
    MemoWrite("Month range maximum: " & _GUICtrlMonthCal_GetMonthRangeMaxStr($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetMonthRangeMin

Function Reference

_GUICtrlMonthCal_GetMonthRangeMin

Retrieves date information that represents the low limit of the controls display

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetMonthRangeMin ( $hWnd [, $bPartial = False] )

Parameters

$hWnd | Control ID/Handle to the control
$bPartial | [optional] Specifies the scope of the range limits to be retrieved: True - Preceding and trailing months are included False - Only months that are entirely displayed are included

Return Value

Returns a $tagSYSTEMTIME structure.

Related

$tagSYSTEMTIME, _GUICtrlMonthCal_GetMonthRange, _GUICtrlMonthCal_GetMonthRangeMax, _GUICtrlMonthCal_GetMonthRangeMinStr

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tMin, $tMax, $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Month Range Min", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get month range
    $tMin = _GUICtrlMonthCal_GetMonthRangeMin($idMonthCal)
    $tMax = _GUICtrlMonthCal_GetMonthRangeMax($idMonthCal)
    MemoWrite("Month range minimum: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tMin, "Month"), _
            DllStructGetData($tMin, "Day"), _
            DllStructGetData($tMin, "Year")))
    MemoWrite("Month range maximum: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tMax, "Month"), _
            DllStructGetData($tMax, "Day"), _
            DllStructGetData($tMax, "Year")))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetMonthRangeMinStr

Function Reference

_GUICtrlMonthCal_GetMonthRangeMinStr

Retrieves date information that represents the low limit of the controls display in string format

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetMonthRangeMinStr ( $hWnd [, $sFormat = "%02d/%02d/%04d"] )

Parameters

$hWnd | Control ID/Handle to the control
$sFormat | [optional] StringFormat string used to format the date

Return Value

Returns a date in the specified format.

Related

_GUICtrlMonthCal_GetMonthRangeMin

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Month Range Min String", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get month range
    MemoWrite("Month range minimum: " & _GUICtrlMonthCal_GetMonthRangeMinStr($idMonthCal))
    MemoWrite("Month range maximum: " & _GUICtrlMonthCal_GetMonthRangeMaxStr($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetMonthRangeSpan

Function Reference

_GUICtrlMonthCal_GetMonthRangeSpan

Returns a value that represents the range, in months, spanned

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetMonthRangeSpan ( $hWnd [, $bPartial = False] )

Parameters

$hWnd | Control ID/Handle to the control
$bPartial | [optional] Specifies the scope of the range limits to be retrieved: True - Preceding and trailing months are included False - Only months that are entirely displayed are included

Return Value

Returns the spanned months.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Month Range Span", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get month range span
    MemoWrite("Month range span: " & _GUICtrlMonthCal_GetMonthRangeSpan($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetRange

Function Reference

_GUICtrlMonthCal_GetRange

Retrieves the minimum and maximum allowable dates

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetRange ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns a $tagMCRANGE structure.

Related

$tagMCRANGE, _GUICtrlMonthCal_GetRangeMax, _GUICtrlMonthCal_GetRangeMaxStr, _GUICtrlMonthCal_GetRangeMin, _GUICtrlMonthCal_GetRangeMinStr, _GUICtrlMonthCal_SetRange

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tRange, $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Range", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set range
    _GUICtrlMonthCal_SetRange($idMonthCal, @YEAR, 1, 1, @YEAR, 12, 31)
    $tRange = _GUICtrlMonthCal_GetRange($idMonthCal)
    MemoWrite("Minimum selectable date: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tRange, "MinMonth"), _
            DllStructGetData($tRange, "MinDay"), _
            DllStructGetData($tRange, "MinYear")))
    MemoWrite("Maximum selectable date: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tRange, "MaxMonth"), _
            DllStructGetData($tRange, "MaxDay"), _
            DllStructGetData($tRange, "MaxYear")))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetRangeMax

Function Reference

_GUICtrlMonthCal_GetRangeMax

Retrieves the upper limit date range

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetRangeMax ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Return a $tagSYSTEMTIME structure.

Related

$tagSYSTEMTIME, _GUICtrlMonthCal_GetRange, _GUICtrlMonthCal_GetRangeMaxStr, _GUICtrlMonthCal_GetRangeMin

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tMin, $tMax, $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Range Max", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set range
    _GUICtrlMonthCal_SetRange($idMonthCal, @YEAR, 1, 1, @YEAR, 12, 31)
    $tMin = _GUICtrlMonthCal_GetRangeMin($idMonthCal)
    $tMax = _GUICtrlMonthCal_GetRangeMax($idMonthCal)
    MemoWrite("Minimum selectable date: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tMin, "Month"), _
            DllStructGetData($tMin, "Day"), _
            DllStructGetData($tMin, "Year")))
    MemoWrite("Maximum selectable date: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tMax, "Month"), _
            DllStructGetData($tMax, "Day"), _
            DllStructGetData($tMax, "Year")))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetRangeMaxStr

Function Reference

_GUICtrlMonthCal_GetRangeMaxStr

Retrieves the upper limit date range in string format

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetRangeMaxStr ( $hWnd [, $sFormat = "%02d/%02d/%04d"] )

Parameters

$hWnd | Control ID/Handle to the control
$sFormat | [optional] StringFormat string used to format the date

Return Value

Returns a date in the specified format.

Related

_GUICtrlMonthCal_GetRange, _GUICtrlMonthCal_GetRangeMax

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Range Max String", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get range
    _GUICtrlMonthCal_SetRange($idMonthCal, @YEAR, 1, 1, @YEAR, 12, 31)
    MemoWrite("Minimum selectable date: " & _GUICtrlMonthCal_GetRangeMinStr($idMonthCal))
    MemoWrite("Maximum selectable date: " & _GUICtrlMonthCal_GetRangeMaxStr($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetRangeMin

Function Reference

_GUICtrlMonthCal_GetRangeMin

Retrieves the lower limit date range

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetRangeMin ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns a $tagSYSTEMTIME structure.

Related

$tagSYSTEMTIME, _GUICtrlMonthCal_GetRange, _GUICtrlMonthCal_GetRangeMax, _GUICtrlMonthCal_GetRangeMinStr

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tMin, $tMax, $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Range Min", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set range
    _GUICtrlMonthCal_SetRange($idMonthCal, @YEAR, 1, 1, @YEAR, 12, 31)
    $tMin = _GUICtrlMonthCal_GetRangeMin($idMonthCal)
    $tMax = _GUICtrlMonthCal_GetRangeMax($idMonthCal)
    MemoWrite("Minimum selectable date: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tMin, "Month"), _
            DllStructGetData($tMin, "Day"), _
            DllStructGetData($tMin, "Year")))
    MemoWrite("Maximum selectable date: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tMax, "Month"), _
            DllStructGetData($tMax, "Day"), _
            DllStructGetData($tMax, "Year")))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetRangeMinStr

Function Reference

_GUICtrlMonthCal_GetRangeMinStr

Retrieves the lower limit date range in string form

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetRangeMinStr ( $hWnd [, $sFormat = "%02d/%02d/%04d"] )

Parameters

$hWnd | Control ID/Handle to the control
$sFormat | [optional] StringFormat string used to format the date

Return Value

Returns a date in the specified format.

Related

_GUICtrlMonthCal_GetRange, _GUICtrlMonthCal_GetRangeMin

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Range Min String", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get range
    _GUICtrlMonthCal_SetRange($idMonthCal, @YEAR, 1, 1, @YEAR, 12, 31)
    MemoWrite("Minimum selectable date: " & _GUICtrlMonthCal_GetRangeMinStr($idMonthCal))
    MemoWrite("Maximum selectable date: " & _GUICtrlMonthCal_GetRangeMaxStr($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetSelRange

Function Reference

_GUICtrlMonthCal_GetSelRange

Retrieves the upper and lower limits of the date range currently selected

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetSelRange ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns a $tagMCSELRANGE structure.

Related

$tagMCSELRANGE, _GUICtrlMonthCal_SetSelRange

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tRange, $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Sel Range", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set selection
    _GUICtrlMonthCal_SetSelRange($idMonthCal, @YEAR, @MON, 1, @YEAR, @MON, 7)
    $tRange = _GUICtrlMonthCal_GetSelRange($idMonthCal)
    MemoWrite("Start date: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tRange, "MinMonth"), _
            DllStructGetData($tRange, "MinDay"), _
            DllStructGetData($tRange, "MinYear")))
    MemoWrite("End date .: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tRange, "MaxMonth"), _
            DllStructGetData($tRange, "MaxDay"), _
            DllStructGetData($tRange, "MaxYear")))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetSelRangeMax

Function Reference

_GUICtrlMonthCal_GetSelRangeMax

Retrieves the upper date range currently selected by the user

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetSelRangeMax ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns a $tagSYSTEMTIME structure.

Related

$tagSYSTEMTIME, _GUICtrlMonthCal_GetSelRangeMin

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tMin, $tMax, $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Sel Range Max", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set selection
    _GUICtrlMonthCal_SetSelRange($idMonthCal, @YEAR, @MON, 1, @YEAR, @MON, 7)
    $tMin = _GUICtrlMonthCal_GetSelRangeMin($idMonthCal)
    $tMax = _GUICtrlMonthCal_GetSelRangeMax($idMonthCal)
    MemoWrite("Start date: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tMin, "Month"), _
            DllStructGetData($tMin, "Day"), _
            DllStructGetData($tMin, "Year")))
    MemoWrite("End date .: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tMax, "Month"), _
            DllStructGetData($tMax, "Day"), _
            DllStructGetData($tMax, "Year")))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetSelRangeMaxStr

Function Reference

_GUICtrlMonthCal_GetSelRangeMaxStr

Retrieves the upper date range currently selected by the user in string form

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetSelRangeMaxStr ( $hWnd [, $sFormat = "%02d/%02d/%04d"] )

Parameters

$hWnd | Control ID/Handle to the control
$sFormat | [optional] StringFormat string used to format the date

Return Value

Returns a date in the specified format.

Related

_GUICtrlMonthCal_GetSelRangeMinStr

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Sel Range Max String", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set selection
    _GUICtrlMonthCal_SetSelRange($idMonthCal, @YEAR, @MON, 1, @YEAR, @MON, 7)
    MemoWrite("Start date: " & _GUICtrlMonthCal_GetSelRangeMinStr($idMonthCal))
    MemoWrite("End date .: " & _GUICtrlMonthCal_GetSelRangeMaxStr($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetSelRangeMin

Function Reference

_GUICtrlMonthCal_GetSelRangeMin

Retrieves the lower date range currently selected by the user

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetSelRangeMin ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns a $tagSYSTEMTIME structure.

Related

$tagSYSTEMTIME, _GUICtrlMonthCal_GetSelRangeMax

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tMin, $tMax, $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Sel Range Min", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set selection
    _GUICtrlMonthCal_SetSelRange($idMonthCal, @YEAR, @MON, 1, @YEAR, @MON, 7)
    $tMin = _GUICtrlMonthCal_GetSelRangeMin($idMonthCal)
    $tMax = _GUICtrlMonthCal_GetSelRangeMax($idMonthCal)
    MemoWrite("Start date: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tMin, "Month"), _
            DllStructGetData($tMin, "Day"), _
            DllStructGetData($tMin, "Year")))
    MemoWrite("End date .: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tMax, "Month"), _
            DllStructGetData($tMax, "Day"), _
            DllStructGetData($tMax, "Year")))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetSelRangeMinStr

Function Reference

_GUICtrlMonthCal_GetSelRangeMinStr

Retrieves the lower date range currently selected by the user in string form

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetSelRangeMinStr ( $hWnd [, $sFormat = "%02d/%02d/%04d"] )

Parameters

$hWnd | Control ID/Handle to the control
$sFormat | [optional] StringFormat string used to format the date

Return Value

Returns a date in the specified format.

Related

_GUICtrlMonthCal_GetSelRangeMaxStr

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Sel Range Min String", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set selection
    _GUICtrlMonthCal_SetSelRange($idMonthCal, @YEAR, @MON, 1, @YEAR, @MON, 7)
    MemoWrite("Start date: " & _GUICtrlMonthCal_GetSelRangeMinStr($idMonthCal))
    MemoWrite("End date .: " & _GUICtrlMonthCal_GetSelRangeMaxStr($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetToday

Function Reference

_GUICtrlMonthCal_GetToday

Retrieves the date information for the date specified as "today"

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetToday ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns a $tagSYSTEMTIME structure.

Related

$tagSYSTEMTIME, _GUICtrlMonthCal_GetTodayStr, _GUICtrlMonthCal_SetToday

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tToday, $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Today", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, $WS_BORDER, 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set today
    _GUICtrlMonthCal_SetToday($idMonthCal, @YEAR, 8, 19)
    $tToday = _GUICtrlMonthCal_GetToday($idMonthCal)
    MemoWrite("Today: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tToday, "Month"), _
            DllStructGetData($tToday, "Day"), _
            DllStructGetData($tToday, "Year")))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetTodayStr

Function Reference

_GUICtrlMonthCal_GetTodayStr

Retrieves the date information for the date specified as "today" in string format

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetTodayStr ( $hWnd [, $sFormat = "%02d/%02d/%04d"] )

Parameters

$hWnd | Control ID/Handle to the control
$sFormat | [optional] StringFormat string used to format the date

Return Value

Returns a date in the specified format.

Related

_GUICtrlMonthCal_GetToday

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Today String", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, $WS_BORDER, 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get today
    MemoWrite("Today: " & _GUICtrlMonthCal_GetTodayStr($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_GetUnicodeFormat

Function Reference

_GUICtrlMonthCal_GetUnicodeFormat

Retrieves the Unicode character format flag for the control

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_GetUnicodeFormat ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

True: | the control is using Unicode characters.
False: | the control is using ANSI characters.

Related

_GUICtrlMonthCal_SetUnicodeFormat

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Get Unicode Format", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, $WS_BORDER, 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set Unicode setting
    _GUICtrlMonthCal_SetUnicodeFormat($idMonthCal, False)
    MemoWrite("Unicode: " & _GUICtrlMonthCal_GetUnicodeFormat($idMonthCal))
    _GUICtrlMonthCal_SetUnicodeFormat($idMonthCal, True)
    MemoWrite("Unicode: " & _GUICtrlMonthCal_GetUnicodeFormat($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_HitTest

Function Reference

_GUICtrlMonthCal_HitTest

Determines which portion of a month calendar control is at a given point

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_HitTest ( $hWnd, $iX, $iY )

Parameters

$hWnd | Control ID/Handle to the control
$iX | X position to test
$iY | Y position to test

Return Value

Returns a $tagMCHITTESTINFO structure.

Related

$tagMCHITTESTINFO

Example

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

Global $g_idMonthCal, $g_idMemo, $g_hGUI

Example()

Func Example()
    ; Create GUI
    $g_hGUI = GUICreate("Month Calendar Hit Test", 400, 300)
    $g_idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, $WS_BORDER, 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_MOUSEMOVE
                DoHitTest()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete()
EndFunc   ;==>Example

; Perform hit test
Func DoHitTest()
    Local $tHit

    $tHit = _GUICtrlMonthCal_HitTest($g_idMonthCal, _WinAPI_GetMousePosX(True, $g_hGUI), _WinAPI_GetMousePosY(True, $g_hGUI))
    If BitAND(DllStructGetData($tHit, "Hit"), $MCHT_CALENDARDATE) <> 0 Then
        MemoWrite("Date: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tHit, "Month"), _
                DllStructGetData($tHit, "Day"), _
                DllStructGetData($tHit, "Year")))
    EndIf
EndFunc   ;==>DoHitTest

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_SetCalendarBorder

Function Reference

_GUICtrlMonthCal_SetCalendarBorder

Sets the size of the border, in pixels

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_SetCalendarBorder ( $hWnd [, $iBorderSize = 4 [, $bSetBorder = True]] )

Parameters

$hWnd | Control ID/Handle to the control
$iBorderSize | [optional] Number of pixels of the border size
$bSetBorder | [optional] One of the Following: True - The border size is set to the number of pixels that $iBorderSize specifies False - The border size is reset to the default value specified by the theme, or zero if themes are not being used

Return Value

None.

Remarks

Windows Vista or later.

Related

_GUICtrlMonthCal_GetCalendarBorder

Example

#include <GUIConstantsEx.au3>
#include <GuiMonthCal.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, $WS_BORDER, 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set calendar border
    MemoWrite("Border in pixels: " & _GUICtrlMonthCal_GetCalendarBorder($idMonthCal))
    Sleep(3000)
    GUISetState(@SW_LOCK)
    _GUICtrlMonthCal_SetCalendarBorder($idMonthCal, 2)
    MemoWrite("Border in pixels: " & _GUICtrlMonthCal_GetCalendarBorder($idMonthCal))
    GUISetState(@SW_UNLOCK)
    Sleep(3000)
    GUISetState(@SW_LOCK)
    _GUICtrlMonthCal_SetCalendarBorder($idMonthCal, 0, False)
    MemoWrite("Border in pixels: " & _GUICtrlMonthCal_GetCalendarBorder($idMonthCal))
    GUISetState(@SW_UNLOCK)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_SetColor

Function Reference

_GUICtrlMonthCal_SetColor

Sets the color for a given portion of the month calendar

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_SetColor ( $hWnd, $iIndex, $iColor )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Indicates which month calendar color to set: $MCSC_BACKGROUND - Background color displayed between months $MCSC_TEXT - Color used to display text within a month $MCSC_TITLEBK - Background color displayed in the calendar title $MCSC_TITLETEXT - Color used to display text within the calendar title $MCSC_MONTHBK - Background color displayed within the month $MCSC_TRAILINGTEXT - Color used to display header day and trailing day text
$iColor | Color value

Return Value

Success: | the previous color setting for the specified portion of the control.
Failure: | -1.

Related

_GUICtrlMonthCal_GetColor

Example

#include <GUIConstantsEx.au3>
#include <GuiMonthCal.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    ; Create GUI
    GUICreate("Month Calendar Set Color", 400, 300)
    Local $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, $WS_BORDER, 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 188, 392, 108, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set calendar color
    MemoWrite("Background: 0x" & Hex(_GUICtrlMonthCal_GetColor($idMonthCal, $MCSC_MONTHBK), 6))
    ; _GUICtrlMonthCal_SetColor($idMonthCal, $MCSC_MONTHBK, $CLR_MONEYGREEN)
    _GUICtrlMonthCal_SetColor($idMonthCal, $MCSC_TEXT, 0x8BD4DF)
    _GUICtrlMonthCal_SetColor($idMonthCal, $MCSC_TITLEBK, 0xA9D7E4)
    _GUICtrlMonthCal_SetColor($idMonthCal, $MCSC_TITLETEXT, 0x005894)
    _GUICtrlMonthCal_SetColor($idMonthCal, $MCSC_MONTHBK, 0x3F3F3F)
    _GUICtrlMonthCal_SetColor($idMonthCal, $MCSC_TRAILINGTEXT, 0xB2C2A9)
    MemoWrite("Background: 0x" & Hex(_GUICtrlMonthCal_GetColor($idMonthCal, $MCSC_MONTHBK), 6))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_SetCurSel

Function Reference

_GUICtrlMonthCal_SetCurSel

Sets the currently selected date

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_SetCurSel ( $hWnd, $iYear, $iMonth, $iDay )

Parameters

$hWnd | Control ID/Handle to the control
$iYear | Year value
$iMonth | Month value
$iDay | Day value

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMonthCal_GetCurSel

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tTime, $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Set Cur Sel", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, $WS_BORDER, 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set current selection
    _GUICtrlMonthCal_SetCurSel($idMonthCal, @YEAR, 8, 19)
    $tTime = _GUICtrlMonthCal_GetCurSel($idMonthCal)
    MemoWrite("Current selection : " & StringFormat("%02d/%02d/%04d", DllStructGetData($tTime, "Month"), _
            DllStructGetData($tTime, "Day"), _
            DllStructGetData($tTime, "Year")))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_SetDayState

Function Reference

_GUICtrlMonthCal_SetDayState

Sets the day states for all months that are currently visible

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_SetDayState ( $hWnd, $aMasks )

Parameters

$hWnd | Control ID/Handle to the control
$aMasks | An array of integers that corresponds to the months that are visible in the calendar

Return Value

Success: | True.
Failure: | False.

Remarks

You must create the calendar control with the $MCS_DAYSTATE style if you want to use this function.

Example

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

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Set Day State", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_DAYSTATE), 0x00000000)

    ; Get the number of months that we must supply masks for.  Normally, this number will be 3.
    Local $aMasks[_GUICtrlMonthCal_GetMonthRangeSpan($idMonthCal, True)]

    ; Make the 1st, 8th and the 16th of the current month bolded. This results in a binary mask of 1000 0000 1000 0001 or
    ; 0x8081 in hex.
    $aMasks[1] = 0x8081
    _GUICtrlMonthCal_SetDayState($idMonthCal, $aMasks)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlMonthCal_SetFirstDOW

Function Reference

_GUICtrlMonthCal_SetFirstDOW

Sets the first day of the week for a month calendar control

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_SetFirstDOW ( $hWnd, $sDay )

Parameters

$hWnd | Control ID/Handle to the control
$sDay | In the following format: 0 or "Monday" 1 or "Tuesday" 2 or "Wednesday" 3 or "Thursday" 4 or "Friday" 5 or "Saturday" 6 or "Sunday"

Return Value

Success: | the previous first day of the week.
Failure: | -1.

Related

_GUICtrlMonthCal_GetFirstDOW

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Set First DOW", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, $WS_BORDER, 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set first DOW
    _GUICtrlMonthCal_SetFirstDOW($idMonthCal, 0)
    MemoWrite("First DOW : " & _GUICtrlMonthCal_GetFirstDOW($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_SetMaxSelCount

Function Reference

_GUICtrlMonthCal_SetMaxSelCount

Sets the maximum number of days that can be selected in a month calendar control

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_SetMaxSelCount ( $hWnd, $iMaxSel )

Parameters

$hWnd | Control ID/Handle to the control
$iMaxSel | Value of type int that will be set to represent the maximum number of days that can be selected

Return Value

Success: | True.
Failure: | False.

Remarks

This will fail if applied to a month calendar control that does not use the $MCS_MULTISELECT style.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Set Sel Count", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set maximum selection count
    _GUICtrlMonthCal_SetMaxSelCount($idMonthCal, 7)
    MemoWrite("Maximum selction count: " & _GUICtrlMonthCal_GetMaxSelCount($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_SetMonthDelta

Function Reference

_GUICtrlMonthCal_SetMonthDelta

Sets the scroll rate for a month calendar control

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_SetMonthDelta ( $hWnd, $iDelta )

Parameters

$hWnd | Control ID/Handle to the control
$iDelta | Value representing the number of months to be set as the control's scroll rate. If this value is zero, the month delta is reset to the default which is the number of months displayed in the control.

Return Value

Returns an INT value that represents the previous scroll rate.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Set Month Delta", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set month delta
    _GUICtrlMonthCal_SetMonthDelta($idMonthCal, 2)
    MemoWrite("Month delta: " & _GUICtrlMonthCal_GetMonthDelta($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_SetRange

Function Reference

_GUICtrlMonthCal_SetRange

Sets date information that represents the high and low limits

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_SetRange ( $hWnd, $iMinYear, $iMinMonth, $iMinDay, $iMaxYear, $iMaxMonth, $iMaxDay )

Parameters

$hWnd | Control ID/Handle to the control
$iMinYear | Minimum year
$iMinMonth | Minimum month
$iMinDay | Minimum day
$iMaxYear | Maximum year
$iMaxMonth | Maximum month
$iMaxDay | Maximum day

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlMonthCal_GetRange

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tRange, $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Set Range", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set range
    _GUICtrlMonthCal_SetRange($idMonthCal, @YEAR, 1, 1, @YEAR, 12, 31)
    $tRange = _GUICtrlMonthCal_GetRange($idMonthCal)
    MemoWrite("Minimum selectable date: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tRange, "MinMonth"), _
            DllStructGetData($tRange, "MinDay"), _
            DllStructGetData($tRange, "MinYear")))
    MemoWrite("Maximum selectable date: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tRange, "MaxMonth"), _
            DllStructGetData($tRange, "MaxDay"), _
            DllStructGetData($tRange, "MaxYear")))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_SetSelRange

Function Reference

_GUICtrlMonthCal_SetSelRange

Sets the selection for a month calendar control to a given date range

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_SetSelRange ( $hWnd, $iMinYear, $iMinMonth, $iMinDay, $iMaxYear, $iMaxMonth, $iMaxDay )

Parameters

$hWnd | Control ID/Handle to the control
$iMinYear | Minimum year
$iMinMonth | Minimum month
$iMinDay | Minimum day
$iMaxYear | Maximum year
$iMaxMonth | Maximum month
$iMaxDay | Maximum day

Return Value

Success: | True.
Failure: | False.

Remarks

This message will fail if applied to a month calendar control that does not use the $MCS_MULTISELECT style.

Related

_GUICtrlMonthCal_GetSelRange

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tRange, $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Set Sel Range", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set selection
    _GUICtrlMonthCal_SetSelRange($idMonthCal, @YEAR, @MON, 1, @YEAR, @MON, 7)
    $tRange = _GUICtrlMonthCal_GetSelRange($idMonthCal)
    MemoWrite("Start date: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tRange, "MinMonth"), _
            DllStructGetData($tRange, "MinDay"), _
            DllStructGetData($tRange, "MinYear")))
    MemoWrite("End date .: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tRange, "MaxMonth"), _
            DllStructGetData($tRange, "MaxDay"), _
            DllStructGetData($tRange, "MaxYear")))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_SetToday

Function Reference

_GUICtrlMonthCal_SetToday

Sets the date information for the date specified as "today"

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_SetToday ( $hWnd, $iYear, $iMonth, $iDay )

Parameters

$hWnd | Control ID/Handle to the control
$iYear | Year
$iMonth | Month
$iDay | Day

Return Value

None.

Related

_GUICtrlMonthCal_GetToday

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $tToday, $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Set Today", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, $WS_BORDER, 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set today
    _GUICtrlMonthCal_SetToday($idMonthCal, @YEAR, 8, 19)
    $tToday = _GUICtrlMonthCal_GetToday($idMonthCal)
    MemoWrite("Today: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tToday, "Month"), _
            DllStructGetData($tToday, "Day"), _
            DllStructGetData($tToday, "Year")))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlMonthCal_SetUnicodeFormat

Function Reference

_GUICtrlMonthCal_SetUnicodeFormat

Sets the Unicode character format flag for the control

#include <GuiMonthCal.au3>
_GUICtrlMonthCal_SetUnicodeFormat ( $hWnd [, $bUnicode = False] )

Parameters

$hWnd | Control ID/Handle to the control
$bUnicode | [optional] Unicode format flag: True - Control uses Unicode characters False - Control uses ANSI characters

Return Value

Returns the previous Unicode format flag.

Related

_GUICtrlMonthCal_GetUnicodeFormat

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idMonthCal

    ; Create GUI
    GUICreate("Month Calendar Set Unicode Format", 400, 300)
    $idMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, $WS_BORDER, 0x00000000)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set Unicode setting
    _GUICtrlMonthCal_SetUnicodeFormat($idMonthCal, False)
    MemoWrite("Unicode: " & _GUICtrlMonthCal_GetUnicodeFormat($idMonthCal))
    _GUICtrlMonthCal_SetUnicodeFormat($idMonthCal, True)
    MemoWrite("Unicode: " & _GUICtrlMonthCal_GetUnicodeFormat($idMonthCal))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


User Defined Functions

GuiReBar user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiReBar.au3>.

User Defined Function | Description
_GUICtrlRebar_AddBand | Adds a new band in a rebar control
_GUICtrlRebar_AddToolBarBand | Adds a new band in a rebar control
_GUICtrlRebar_BeginDrag | Adds a new band in a rebar control
_GUICtrlRebar_Create | Create a Rebar control
_GUICtrlRebar_DeleteBand | Deletes a band from a rebar control
_GUICtrlRebar_Destroy | Delete the control
_GUICtrlRebar_DragMove | Updates the drag position in the rebar control after a previous _GUICtrlRebar_BeginDrag message
_GUICtrlRebar_EndDrag | Terminates the rebar control's drag-and-drop operation
_GUICtrlRebar_GetBandBackColor | Retrieves the Band background color
_GUICtrlRebar_GetBandBorders | Retrieves the borders of a band
_GUICtrlRebar_GetBandBordersEx | Retrieves the borders of a band
_GUICtrlRebar_GetBandChildHandle | Retrieves the Handle to the child window contained in the band, if any
_GUICtrlRebar_GetBandChildSize | Retrieves the Child size settings
_GUICtrlRebar_GetBandCount | Retrieves the count of bands currently in the rebar control
_GUICtrlRebar_GetBandForeColor | Retrieves the Band foreground color
_GUICtrlRebar_GetBandHeaderSize | Retrieves the size of the band's header, in pixels
_GUICtrlRebar_GetBandID | Get the value that the control uses to identify this band for custom draw notification messages
_GUICtrlRebar_GetBandIdealSize | Get Ideal width of the band, in pixels
_GUICtrlRebar_GetBandLength | Get Length of the band, in pixels
_GUICtrlRebar_GetBandLParam | Get Application-defined value
_GUICtrlRebar_GetBandMargins | Get Length of the band, in pixels
_GUICtrlRebar_GetBandMarginsEx | Get Length of the band, in pixels
_GUICtrlRebar_GetBandRect | Retrieves the bounding rectangle for a given band in a rebar control
_GUICtrlRebar_GetBandRectEx | Retrieves the bounding rectangle for a given band in a rebar control
_GUICtrlRebar_GetBandStyle | Get the band style Flags
_GUICtrlRebar_GetBandStyleBreak | Determine if band break flag is set
_GUICtrlRebar_GetBandStyleChildEdge | Determine if band child edge flag is set
_GUICtrlRebar_GetBandStyleFixedBMP | Determine if band fixed BMP flag is set
_GUICtrlRebar_GetBandStyleFixedSize | Determine if band fixed size flag is set
_GUICtrlRebar_GetBandStyleGripperAlways | Determine if band gripper flag is set
_GUICtrlRebar_GetBandStyleHidden | Determine if band hidden flag is set
_GUICtrlRebar_GetBandStyleHideTitle | Determine if band hide title flag is set
_GUICtrlRebar_GetBandStyleNoGripper | Determine if band noGripper flag is set
_GUICtrlRebar_GetBandStyleTopAlign | Determine if band top align flag is set
_GUICtrlRebar_GetBandStyleUseChevron | Determine if band use chevron flag is set
_GUICtrlRebar_GetBandStyleVariableHeight | Determine if band variable height flag is set
_GUICtrlRebar_GetBandText | Retrieves the display text for the band
_GUICtrlRebar_GetBarHeight | Retrieves the height of the rebar control
_GUICtrlRebar_GetBarInfo | Retrieves information about the rebar control and the image list it uses
_GUICtrlRebar_GetBKColor | Retrieves a rebar control's default background color
_GUICtrlRebar_GetColorScheme | Retrieves the color scheme information from the rebar control
_GUICtrlRebar_GetRowCount | Retrieves the number of rows of bands in a rebar control
_GUICtrlRebar_GetRowHeight | Retrieves the height of a specified row in a rebar control
_GUICtrlRebar_GetTextColor | Retrieves a rebar control's default text color
_GUICtrlRebar_GetToolTips | Retrieves the handle to any ToolTip control associated with the rebar control
_GUICtrlRebar_GetUnicodeFormat | Retrieves the Unicode character format flag for the control
_GUICtrlRebar_HitTest | Determines which band is at a specified position
_GUICtrlRebar_IDToIndex | Converts a band identifier to a band index in a rebar control
_GUICtrlRebar_MaximizeBand | Resizes a band in a rebar control to either its ideal or largest size
_GUICtrlRebar_MinimizeBand | Resizes a band in a rebar control to its smallest size
_GUICtrlRebar_MoveBand | Moves a band from one index to another
_GUICtrlRebar_SetBandBackColor | Set the Band background color
_GUICtrlRebar_SetBandForeColor | Set the Band foreground color
_GUICtrlRebar_SetBandHeaderSize | Set the size of the band's header, in pixels
_GUICtrlRebar_SetBandID | Set the value that the control uses to identify this band for custom draw notification messages
_GUICtrlRebar_SetBandIdealSize | Set Ideal width of the band, in pixels
_GUICtrlRebar_SetBandLength | Set the size length of the band
_GUICtrlRebar_SetBandLParam | Set Application-defined value
_GUICtrlRebar_SetBandStyle | Set the band style Flags
_GUICtrlRebar_SetBandStyleBreak | Set whether the band is on a new line
_GUICtrlRebar_SetBandStyleChildEdge | Set whether the band has an edge at the top and bottom of the child window
_GUICtrlRebar_SetBandStyleFixedBMP | Set whether the band background bitmap does not move when the band is resized
_GUICtrlRebar_SetBandStyleFixedSize | Set whether the band can't be sized. With this style, the sizing grip is not displayed on the band
_GUICtrlRebar_SetBandStyleGripperAlways | Set whether the band will always have a sizing grip, even if it is the only band in the rebar
_GUICtrlRebar_SetBandStyleHidden | Set whether the band will not be visible
_GUICtrlRebar_SetBandStyleHideTitle | Set whether to keep band title hidden
_GUICtrlRebar_SetBandStyleNoGripper | Set whether the band will never have a sizing grip, even if there is more than one band in the rebar
_GUICtrlRebar_SetBandStyleTopAlign | Set whether to keep band in top row
_GUICtrlRebar_SetBandStyleUseChevron | Set whether to display drop-down button
_GUICtrlRebar_SetBandStyleVariableHeight | Set whether the band can be resized by the rebar control
_GUICtrlRebar_SetBandText | Sets the display text for the band of a rebar control
_GUICtrlRebar_SetBarInfo | Sets the characteristics of a rebar control
_GUICtrlRebar_SetBKColor | Sets the default background color of a rebar control
_GUICtrlRebar_SetColorScheme | Sets the color scheme of a rebar control
_GUICtrlRebar_SetTextColor | Sets a rebar control's default text color
_GUICtrlRebar_SetToolTips | Associates a ToolTip control with the rebar control
_GUICtrlRebar_SetUnicodeFormat | Sets the Unicode character format flag for the control
_GUICtrlRebar_ShowBand | Shows or hides a given band in a rebar control


Function _GUICtrlRebar_AddBand

Function Reference

_GUICtrlRebar_AddBand

Adds a new band in a rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_AddBand ( $hWndRebar, $hWndChild [, $iMinWidth = 100 [, $iDefaultWidth = 100 [, $sText = "" [, $iIndex = -1 [, $iStyle = -1]]]]] )

Parameters

$hWndRebar | Handle to the rebar control
$hWndChild | Handle of control to add
$iMinWidth | [optional] Minimum width for the band
$iDefaultWidth | [optional] Length of the band, in pixels
$sText | [optional] Display text for the band
$iIndex [optional] 0-based index of the location where the band will be inserted.
If you set this parameter to -1, the control will add the new band at the last location
$iStyle [optional] Flags that specify the band style. This value can be a combination of the following:
$RBBS_BREAK - The band is on a new line.
$RBBS_CHILDEDGE - The band has an edge at the top and bottom of the child window.
$RBBS_FIXEDBMP - The background bitmap does not move when the band is resized.
$RBBS_FIXEDSIZE - The band can't be sized. With this style, the sizing grip is not displayed on the band.
$RBBS_GRIPPERALWAYS - Version 4.71. The band will always have a sizing grip, even if it is the only band in the rebar.
$RBBS_HIDDEN - The band will not be visible.
$RBBS_NOGRIPPER - Version 4.71. The band will never have a sizing grip, even if there is more than one band in the rebar.
$RBBS_USECHEVRON - Version 5.80. Show a chevron button if the band is smaller than cxIdeal.
$RBBS_VARIABLEHEIGHT - Version 4.71. The band can be resized by the rebar control; cyIntegral and cyMaxChild affect how the rebar will resize the band.
$RBBS_NOVERT - Don't show when vertical.
$RBBS_USECHEVRON - Display drop-down button.
$RBBS_HIDETITLE - Keep band title hidden.
$RBBS_TOPALIGN - Keep band in top row.

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_AddToolBarBand, _GUICtrlRebar_DeleteBand

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>
#include <GuiReBar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGui, $idBtnExit, $hCombo, $hReBar, $hDTP, $idInput

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    ; create a combobox to put in the rebar
    $hCombo = _GUICtrlComboBox_Create($hGui, "", 0, 0, 120)

    _GUICtrlComboBox_BeginUpdate($hCombo)
    _GUICtrlComboBox_AddDir($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($hCombo)

    ; create a date time picker to put in the rebar
    $hDTP = _GUICtrlDTP_Create($hGui, 0, 0, 190)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ; add band with control
    _GUICtrlRebar_AddBand($hReBar, $hCombo, 120, 200, "Dir *.exe")

    ; add and force to second row
    _GUICtrlRebar_AddBand($hReBar, $hDTP, 120)
    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)

    ; add to beginning of rebar
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRebar_AddToolBarBand

Function Reference

_GUICtrlRebar_AddToolBarBand

Adds a new band in a rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_AddToolBarBand ( $hWndRebar, $hWndToolbar [, $sText = "" [, $iIndex = -1 [, $iStyle = -1]]] )

Parameters

$hWndRebar | Handle to the rebar control
$hWndToolbar | Handle of the Toolbar control to add
$sText | [optional] Display text for the band
$iIndex [optional] 0-based index of the location where the band will be inserted.
If you set this parameter to -1, the control will add the new band at the last location
$iStyle [optional] Flags that specify the band style. This value can be a combination of the following:
$RBBS_BREAK - The band is on a new line.
$RBBS_CHILDEDGE - The band has an edge at the top and bottom of the child window.
$RBBS_FIXEDBMP - The background bitmap does not move when the band is resized.
$RBBS_FIXEDSIZE - The band can't be sized. With this style, the sizing grip is not displayed on the band.
$RBBS_GRIPPERALWAYS - Version 4.71. The band will always have a sizing grip, even if it is the only band in the rebar.
$RBBS_HIDDEN - The band will not be visible.
$RBBS_NOGRIPPER - Version 4.71. The band will never have a sizing grip, even if there is more than one band in the rebar.
$RBBS_USECHEVRON - Version 5.80. Show a chevron button if the band is smaller than cxIdeal.
$RBBS_VARIABLEHEIGHT - Version 4.71. The band can be resized by the rebar control; cyIntegral and cyMaxChild affect how the rebar will resize the band.
$RBBS_NOVERT - Don't show when vertical.
$RBBS_USECHEVRON - Display drop-down button.
$RBBS_HIDETITLE - Keep band title hidden.
$RBBS_TOPALIGN - Keep band in top row.

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_AddBand, _GUICtrlRebar_DeleteBand

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGui, $idBtnExit, $hToolbar, $hReBar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRebar_BeginDrag

Function Reference

_GUICtrlRebar_BeginDrag

Adds a new band in a rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_BeginDrag ( $hWnd, $iIndex [, $iPos = -1] )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band that the drag-and-drop operation will affect
$iPos | [optional] DWORD value that contains the starting mouse coordinates. The horizontal coordinate is contained in the LOWORD and the vertical coordinate is contained in the HIWORD. If you pass (DWORD)-1, the rebar control will use the position of the mouse the last time the control's thread called GetMessage or PeekMessage

Return Value

None.

Related

_GUICtrlRebar_DragMove, _GUICtrlRebar_EndDrag

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput, $idBtnBeginDrag
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnBeginDrag = GUICtrlCreateButton("Begin Drag", 150, 330, 100, 25)
    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
            Case $idBtnBeginDrag
                _GUICtrlRebar_BeginDrag($hReBar, 0)
                _GUICtrlRebar_DragMove($hReBar)
                _GUICtrlRebar_EndDrag($hReBar)
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRebar_Create

Function Reference

_GUICtrlRebar_Create

Create a Rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_Create ( $hWnd [, $iStyles = 0x513] )

Parameters

$hWnd Handle to parent or owner window
$iStyles [optional] Rebar controls support a variety of control styles in addition to standard window styles:
$RBS_AUTOSIZE - Version 4.71. The rebar control will automatically change the layout of the bands when the size or position of the control changes.
An $RBN_AUTOSIZE notification will be sent when this occurs
$RBS_BANDBORDERS - Version 4.71. The rebar control displays narrow lines to separate adjacent bands
$RBS_DBLCLKTOGGLE - Version 4.71. The rebar band will toggle its maximized or minimized state when the user double-clicks the band.
Without this style, the maximized or minimized state is toggled when the user single-clicks on the band
$RBS_FIXEDORDER - Version 4.70. The rebar control always displays bands in the same order. You can move bands to different rows, but the band order is static
$RBS_REGISTERDROP - Version 4.71. The rebar control generates $RBN_GETOBJECT notification messages when an object is dragged over a band in the control
$RBS_TOOLTIPS - Version 4.71. Not yet supported
$RBS_VARHEIGHT - Version 4.71. The rebar control displays bands at the minimum required height, when possible.
Without this style, the rebar control displays all bands at the same height, using the height of the tallest visible band to determine the height of other bands
$RBS_VERTICALGRIPPER - Version 4.71. The size grip will be displayed vertically instead of horizontally in a vertical rebar control.
This style is ignored for rebar controls that do not have the $CCS_VERT style
$CCS_LEFT - Version 4.70. Causes the control to be displayed vertically on the left side of the parent window
$CCS_NODIVIDER - Prevents a two-pixel highlight from being drawn at the top of the control
$CCS_RIGHT - Version 4.70. Causes the control to be displayed vertically on the right side of the parent window
$CCS_VERT - Version 4.70. Causes the control to be displayed vertically

Default: $CCS_TOP, $RBS_VARHEIGHT
Forced: $WS_CHILD, $WS_VISIBLE, $WS_CLIPCHILDREN, $WS_CLIPSIBLINGS

Return Value

Success: | the handle to the Rebar control.
Failure: | sets the @error flag to non-zero.

Related

_GUICtrlRebar_Destroy

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <GuiDateTimePicker.au3>
#include <GuiEdit.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_hReBar

Example()

Func Example()
    Local $hGui, $idBtnExit, $hToolbar, $hCombo, $hDTP, $hInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; create the rebar control
    $g_hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a combobox to put in the rebar
    $hCombo = _GUICtrlComboBox_Create($hGui, "", 0, 0, 120)

    _GUICtrlComboBox_BeginUpdate($hCombo)
    _GUICtrlComboBox_AddDir($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($hCombo)

    ; create a date time picker to put in the rebar
    $hDTP = _GUICtrlDTP_Create($hGui, 0, 0, 190)

    ; create a input box to put in the rebar
    ; $hInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)
    $hInput = _GUICtrlEdit_Create($hGui, "Input control", 0, 0, 120, 20)

    ; default for add is append

    ; add band with control
    _GUICtrlRebar_AddBand($g_hReBar, $hCombo, 120, 200, "Dir *.exe")

    ; add band with date time picker
    _GUICtrlRebar_AddBand($g_hReBar, $hDTP, 120)

    ; add band with toolbar to beginning of rebar
    _GUICtrlRebar_AddToolBarBand($g_hReBar, $hToolbar, "", 0)

    ;add another control
    ; _GUICtrlRebar_AddBand($g_hReBar, GUICtrlGetHandle($hInput), 120, 200, "Name:")
    _GUICtrlRebar_AddBand($g_hReBar, $hInput, 120, 200, "Name:")

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR
    Local $tAUTOBREAK, $tAUTOSIZE, $tNMREBAR, $tCHEVRON, $tCHILDSIZE, $tOBJECTNOTIFY

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hReBar
            Switch $iCode
                Case $RBN_AUTOBREAK
                    ; Notifies a rebar's parent that a break will appear in the bar. The parent determines whether to make the break
                    $tAUTOBREAK = DllStructCreate($tagNMREBARAUTOBREAK, $lParam)
                    _DebugPrint("$RBN_AUTOBREAK" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tAUTOBREAK, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tAUTOBREAK, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tAUTOBREAK, "Code") & @CRLF & _
                            "-->uBand:" & @TAB & DllStructGetData($tAUTOBREAK, "uBand") & @CRLF & _
                            "-->wID:" & @TAB & DllStructGetData($tAUTOBREAK, "wID") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tAUTOBREAK, "lParam") & @CRLF & _
                            "-->uMsg:" & @TAB & DllStructGetData($tAUTOBREAK, "uMsg") & @CRLF & _
                            "-->fStyleCurrent:" & @TAB & DllStructGetData($tAUTOBREAK, "fStyleCurrent") & @CRLF & _
                            "-->fAutoBreak:" & @TAB & DllStructGetData($tAUTOBREAK, "fAutoBreak"))
                    ; Return value not used
                Case $RBN_AUTOSIZE
                    ; Sent by a rebar control created with the $RBS_AUTOSIZE style when the rebar automatically resizes itself
                    $tAUTOSIZE = DllStructCreate($tagNMRBAUTOSIZE, $lParam)
                    _DebugPrint("$RBN_AUTOSIZE" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tAUTOSIZE, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tAUTOSIZE, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tAUTOSIZE, "Code") & @CRLF & _
                            "-->fChanged:" & @TAB & DllStructGetData($tAUTOSIZE, "fChanged") & @CRLF & _
                            "-->TargetLeft:" & @TAB & DllStructGetData($tAUTOSIZE, "TargetLeft") & @CRLF & _
                            "-->TargetTop:" & @TAB & DllStructGetData($tAUTOSIZE, "TargetTop") & @CRLF & _
                            "-->TargetRight:" & @TAB & DllStructGetData($tAUTOSIZE, "TargetRight") & @CRLF & _
                            "-->TargetBottom:" & @TAB & DllStructGetData($tAUTOSIZE, "TargetBottom") & @CRLF & _
                            "-->ActualLeft:" & @TAB & DllStructGetData($tAUTOSIZE, "ActualLeft") & @CRLF & _
                            "-->ActualTop:" & @TAB & DllStructGetData($tAUTOSIZE, "ActualTop") & @CRLF & _
                            "-->ActualRight:" & @TAB & DllStructGetData($tAUTOSIZE, "ActualRight") & @CRLF & _
                            "-->ActualBottom:" & @TAB & DllStructGetData($tAUTOSIZE, "ActualBottom"))
                    ; Return value not used
                Case $RBN_BEGINDRAG
                    ; Sent by a rebar control when the user begins dragging a band
                    $tNMREBAR = DllStructCreate($tagNMREBAR, $lParam)
                    _DebugPrint("$RBN_BEGINDRAG" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMREBAR, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMREBAR, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMREBAR, "Code") & @CRLF & _
                            "-->dwMask:" & @TAB & DllStructGetData($tNMREBAR, "dwMask") & @CRLF & _
                            "-->uBand:" & @TAB & DllStructGetData($tNMREBAR, "uBand") & @CRLF & _
                            "-->fStyle:" & @TAB & DllStructGetData($tNMREBAR, "fStyle") & @CRLF & _
                            "-->wID:" & @TAB & DllStructGetData($tNMREBAR, "wID") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tNMREBAR, "lParam"))
                    Return 0 ; to allow the rebar to continue the drag operation
                    ; Return 1 ; nonzero to abort the drag operation
                Case $RBN_CHEVRONPUSHED
                    ; Sent by a rebar control when a chevron is pushed
                    ; When an application receives this notification, it is responsible for displaying a popup menu with items for each hidden tool.
                    ; Use the rc member of the NMREBARCHEVRON structure to find the correct position for the popup menu
                    $tCHEVRON = DllStructCreate($tagNMREBARCHEVRON, $lParam)
                    _DebugPrint("$RBN_CHEVRONPUSHED" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tCHEVRON, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tCHEVRON, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tCHEVRON, "Code") & @CRLF & _
                            "-->uBand:" & @TAB & DllStructGetData($tCHEVRON, "uBand") & @CRLF & _
                            "-->wID:" & @TAB & DllStructGetData($tCHEVRON, "wID") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tCHEVRON, "lParam") & @CRLF & _
                            "-->Left:" & @TAB & DllStructGetData($tCHEVRON, "Left") & @CRLF & _
                            "-->Top:" & @TAB & DllStructGetData($tCHEVRON, "Top") & @CRLF & _
                            "-->Right:" & @TAB & DllStructGetData($tCHEVRON, "Right") & @CRLF & _
                            "-->lParamNM:" & @TAB & DllStructGetData($tCHEVRON, "lParamNM"))
                    ; Return value not used
                Case $RBN_CHILDSIZE
                    ; Sent by a rebar control when a band's child window is resized
                    $tCHILDSIZE = DllStructCreate($tagNMREBARCHILDSIZE, $lParam)
                    _DebugPrint("$RBN_CHILDSIZE" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tCHILDSIZE, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tCHILDSIZE, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tCHILDSIZE, "Code") & @CRLF & _
                            "-->uBand:" & @TAB & DllStructGetData($tCHILDSIZE, "uBand") & @CRLF & _
                            "-->wID:" & @TAB & DllStructGetData($tCHILDSIZE, "wID") & @CRLF & _
                            "-->CLeft:" & @TAB & DllStructGetData($tCHILDSIZE, "CLeft") & @CRLF & _
                            "-->CTop:" & @TAB & DllStructGetData($tCHILDSIZE, "CTop") & @CRLF & _
                            "-->CRight:" & @TAB & DllStructGetData($tCHILDSIZE, "CRight") & @CRLF & _
                            "-->CBottom:" & @TAB & DllStructGetData($tCHILDSIZE, "CBottom") & @CRLF & _
                            "-->BLeft:" & @TAB & DllStructGetData($tCHILDSIZE, "BandLeft") & @CRLF & _
                            "-->BTop:" & @TAB & DllStructGetData($tCHILDSIZE, "BTop") & @CRLF & _
                            "-->BRight:" & @TAB & DllStructGetData($tCHILDSIZE, "BRight") & @CRLF & _
                            "-->BBottom:" & @TAB & DllStructGetData($tCHILDSIZE, "BBottom"))
                    ; Return value not used
                Case $RBN_DELETEDBAND
                    ; Sent by a rebar control after a band has been deleted
                    $tNMREBAR = DllStructCreate($tagNMREBAR, $lParam)
                    _DebugPrint("$RBN_DELETEDBAND" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMREBAR, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMREBAR, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMREBAR, "Code") & @CRLF & _
                            "-->dwMask:" & @TAB & DllStructGetData($tNMREBAR, "dwMask") & @CRLF & _
                            "-->uBand:" & @TAB & DllStructGetData($tNMREBAR, "uBand") & @CRLF & _
                            "-->fStyle:" & @TAB & DllStructGetData($tNMREBAR, "fStyle") & @CRLF & _
                            "-->wID:" & @TAB & DllStructGetData($tNMREBAR, "wID") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tNMREBAR, "lParam"))
                    ; Return value not used
                Case $RBN_DELETINGBAND
                    ; Sent by a rebar control when a band is about to be deleted
                    $tNMREBAR = DllStructCreate($tagNMREBAR, $lParam)
                    _DebugPrint("$RBN_DELETINGBAND" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMREBAR, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMREBAR, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMREBAR, "Code") & @CRLF & _
                            "-->dwMask:" & @TAB & DllStructGetData($tNMREBAR, "dwMask") & @CRLF & _
                            "-->uBand:" & @TAB & DllStructGetData($tNMREBAR, "uBand") & @CRLF & _
                            "-->fStyle:" & @TAB & DllStructGetData($tNMREBAR, "fStyle") & @CRLF & _
                            "-->wID:" & @TAB & DllStructGetData($tNMREBAR, "wID") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tNMREBAR, "lParam"))
                    ; Return value not used
                Case $RBN_ENDDRAG
                    ; Sent by a rebar control when the user stops dragging a band
                    $tNMREBAR = DllStructCreate($tagNMREBAR, $lParam)
                    _DebugPrint("$RBN_ENDDRAG" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tNMREBAR, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tNMREBAR, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tNMREBAR, "Code") & @CRLF & _
                            "-->dwMask:" & @TAB & DllStructGetData($tNMREBAR, "dwMask") & @CRLF & _
                            "-->uBand:" & @TAB & DllStructGetData($tNMREBAR, "uBand") & @CRLF & _
                            "-->fStyle:" & @TAB & DllStructGetData($tNMREBAR, "fStyle") & @CRLF & _
                            "-->wID:" & @TAB & DllStructGetData($tNMREBAR, "wID") & @CRLF & _
                            "-->lParam:" & @TAB & DllStructGetData($tNMREBAR, "lParam"))
                    ; Return value not used
                Case $RBN_GETOBJECT
                    ; Sent by a rebar control created with the $RBS_REGISTERDROP style when an object is dragged over a band in the control
                    $tOBJECTNOTIFY = DllStructCreate($tagNMOBJECTNOTIFY, $lParam)
                    _DebugPrint("$RBN_GETOBJECT" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tOBJECTNOTIFY, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tOBJECTNOTIFY, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tOBJECTNOTIFY, "Code") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tOBJECTNOTIFY, "Item") & @CRLF & _
                            "-->piid:" & @TAB & DllStructGetData($tOBJECTNOTIFY, "piid") & @CRLF & _
                            "-->pObject:" & @TAB & DllStructGetData($tOBJECTNOTIFY, "pObject") & @CRLF & _
                            "-->Result:" & @TAB & DllStructGetData($tOBJECTNOTIFY, "Result"))
                    ; Return value not used
                Case $RBN_HEIGHTCHANGE
                    ; Sent by a rebar control when its height has changed
                    ; Rebar controls that use the $CCS_VERT style send this notification message when their width changes
                    _DebugPrint("$RBN_HEIGHTCHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return value not used
                Case $RBN_LAYOUTCHANGED
                    ; Sent by a rebar control when the user changes the layout of the control's bands
                    _DebugPrint("$RBN_LAYOUTCHANGED" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return value not used
                Case $RBN_MINMAX
                    ; Sent by a rebar control prior to maximizing or minimizing a band
                    _DebugPrint("$RBN_MINMAX" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return 1 ; a non-zero value to prevent the operation from taking place
                    Return 0 ; zero to allow it to continue
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlRebar_DeleteBand

Function Reference

_GUICtrlRebar_DeleteBand

Deletes a band from a rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_DeleteBand ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band to be deleted

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_AddBand, _GUICtrlRebar_AddToolBarBand

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "About to Delete Band Index 1")
    _GUICtrlRebar_DeleteBand($hReBar, 1)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRebar_Destroy

Function Reference

_GUICtrlRebar_Destroy

Delete the control

#include <GuiReBar.au3>
_GUICtrlRebar_Destroy ( ByRef $hWnd )

Parameters

$hWnd Handle to the rebar control

Return Value

Success: | True, $hWnd is set to 0.
Failure: | False.

Remarks

Restricted to only be used on Rebar controls created with _GUICtrlRebar_Create().

Related

_GUICtrlRebar_Create

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "About to Destroy the Rebar")
    _GUICtrlRebar_Destroy($hReBar)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRebar_DragMove

Function Reference

_GUICtrlRebar_DragMove

Updates the drag position in the rebar control after a previous _GUICtrlRebar_BeginDrag message

#include <GuiReBar.au3>
_GUICtrlRebar_DragMove ( $hWnd [, $iPos = -1] )

Parameters

$hWnd | Handle to the rebar control
$iPos | [optional] DWORD value that contains the new mouse coordinates. The horizontal coordinate is contained in the LOWORD and the vertical coordinate is contained in the HIWORD. If you pass (DWORD)-1, the rebar control will use the position of the mouse the last time the control's thread called GetMessage or PeekMessage

Return Value

None.

Related

_GUICtrlRebar_BeginDrag

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput, $idBtnBeginDrag
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnBeginDrag = GUICtrlCreateButton("Begin Drag", 150, 330, 100, 25)
    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
            Case $idBtnBeginDrag
                _GUICtrlRebar_BeginDrag($hReBar, 0)
                _GUICtrlRebar_DragMove($hReBar)
                _GUICtrlRebar_EndDrag($hReBar)
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRebar_EndDrag

Function Reference

_GUICtrlRebar_EndDrag

Terminates the rebar control's drag-and-drop operation

#include <GuiReBar.au3>
_GUICtrlRebar_EndDrag ( $hWnd )

Parameters

$hWnd Handle to the rebar control

Return Value

None.

Remarks

This message does not cause an $RBN_ENDDRAG notification to be sent.

Related

_GUICtrlRebar_BeginDrag

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput, $idBtnBeginDrag
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnBeginDrag = GUICtrlCreateButton("Begin Drag", 150, 330, 100, 25)
    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
            Case $idBtnBeginDrag
                _GUICtrlRebar_BeginDrag($hReBar, 0)
                _GUICtrlRebar_DragMove($hReBar)
                _GUICtrlRebar_EndDrag($hReBar)
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRebar_GetBandBackColor

Function Reference

_GUICtrlRebar_GetBandBackColor

Retrieves the Band background color

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandBackColor ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

Returns the band background color.

Related

_GUICtrlRebar_SetBandBackColor

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("======================")
        MemoWrite("Band Index " & $x)
        MemoWrite("======================")
        MemoWrite("Back Color: " & _GUICtrlRebar_GetBandBackColor($hReBar, $x))
        MemoWrite("Fore Color: " & _GUICtrlRebar_GetBandForeColor($hReBar, $x))
    Next

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandBorders

Function Reference

_GUICtrlRebar_GetBandBorders

Retrieves the borders of a band

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandBorders ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band for which the borders will be retrieved

Return Value

Returns an array with the following format:
[0] - X coordinate of the upper left corner of the rectangle
[1] - Y coordinate of the upper left corner of the rectangle
[2] - X coordinate of the lower right corner of the rectangle
[3] - Y coordinate of the lower right corner of the rectangle

Remarks

The result of this message can be used to calculate the usable area in a band.

Related

_GUICtrlRebar_GetBandBordersEx, _GUICtrlRebar_GetBandRect, _GUICtrlRebar_GetBandRectEx

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput, $aBorders
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        $aBorders = _GUICtrlRebar_GetBandBorders($hReBar, $x)
        MemoWrite("Band Index " & $x)
        MemoWrite("==== Band Borders ====")
        MemoWrite("Left..: " & $aBorders[0])
        MemoWrite("Top...: " & $aBorders[1])
        MemoWrite("Right.: " & $aBorders[2])
        MemoWrite("Bottom: " & $aBorders[3])
        MemoWrite("======================")
        $aBorders = _GUICtrlRebar_GetBandRect($hReBar, $x)
        MemoWrite("====== Band Rect =====")
        MemoWrite("Left..: " & $aBorders[0])
        MemoWrite("Top...: " & $aBorders[1])
        MemoWrite("Right.: " & $aBorders[2])
        MemoWrite("Bottom: " & $aBorders[3])
        MemoWrite("======================")
    Next

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandBordersEx

Function Reference

_GUICtrlRebar_GetBandBordersEx

Retrieves the borders of a band

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandBordersEx ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band for which the borders will be retrieved

Return Value

Returns a $tagRECT structure.

Remarks

The result of this message can be used to calculate the usable area in a band.

Related

$tagRECT, _GUICtrlRebar_GetBandBorders, _GUICtrlRebar_GetBandRect, _GUICtrlRebar_GetBandRectEx

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput, $tBorders
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        $tBorders = _GUICtrlRebar_GetBandBordersEx($hReBar, $x)
        MemoWrite("Band Index " & $x)
        MemoWrite("==== Band Borders ====")
        MemoWrite("Left..: " & DllStructGetData($tBorders, "Left"))
        MemoWrite("Top...: " & DllStructGetData($tBorders, "Top"))
        MemoWrite("Right.: " & DllStructGetData($tBorders, "Right"))
        MemoWrite("Bottom: " & DllStructGetData($tBorders, "Bottom"))
        MemoWrite("======================")
        $tBorders = _GUICtrlRebar_GetBandRectEx($hReBar, $x)
        MemoWrite("====== Band Rect =====")
        MemoWrite("Left..: " & DllStructGetData($tBorders, "Left"))
        MemoWrite("Top...: " & DllStructGetData($tBorders, "Top"))
        MemoWrite("Right.: " & DllStructGetData($tBorders, "Right"))
        MemoWrite("Bottom: " & DllStructGetData($tBorders, "Bottom"))
        MemoWrite("======================")
    Next

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandChildHandle

Function Reference

_GUICtrlRebar_GetBandChildHandle

Retrieves the Handle to the child window contained in the band, if any

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandChildHandle ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band for which the borders will be retrieved

Return Value

Returns the handle to the child window contained in the band.

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x)
        MemoWrite("Child Handle: " & _GUICtrlRebar_GetBandChildHandle($hReBar, $x))
        MemoWrite("======================")
    Next

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandChildSize

Function Reference

_GUICtrlRebar_GetBandChildSize

Retrieves the Child size settings

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandChildSize ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

Returns an array with the following format:
[0] - Minimum width of the child window, in pixels.
[1] - Minimum height of the child window, in pixels.
[2] - Initial height of the band, in pixels.
[3] - Maximum height of the band, in pixels.
[4] - Step value by which the band can grow or shrink, in pixels.

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput, $aChildSize
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        $aChildSize = _GUICtrlRebar_GetBandChildSize($hReBar, $x)
        MemoWrite("Band Index " & $x)
        MemoWrite("==== Child Size ======")
        MemoWrite("cxMinChild: " & $aChildSize[0])
        MemoWrite("cyMinChild: " & $aChildSize[1])
        MemoWrite("cyChild...: " & $aChildSize[2])
        MemoWrite("cyMaxChild: " & $aChildSize[3])
        MemoWrite("cyIntegral: " & $aChildSize[4])
        MemoWrite("======================")
    Next

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandCount

Function Reference

_GUICtrlRebar_GetBandCount

Retrieves the count of bands currently in the rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandCount ( $hWnd )

Parameters

$hWnd Handle to the rebar control

Return Value

Returns the number of bands assigned to the control.

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    MemoWrite("Number of Bands: " & _GUICtrlRebar_GetBandCount($hReBar))

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandForeColor

Function Reference

_GUICtrlRebar_GetBandForeColor

Retrieves the Band foreground color

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandForeColor ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

Returns the band foreground color.

Related

_GUICtrlRebar_SetBandForeColor

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("======================")
        MemoWrite("Band Index " & $x)
        MemoWrite("======================")
        MemoWrite("Back Color: " & _GUICtrlRebar_GetBandBackColor($hReBar, $x))
        MemoWrite("Fore Color: " & _GUICtrlRebar_GetBandForeColor($hReBar, $x))
    Next

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandHeaderSize

Function Reference

_GUICtrlRebar_GetBandHeaderSize

Retrieves the size of the band's header, in pixels

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandHeaderSize ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

Returns the size of the band's header.

Related

_GUICtrlRebar_SetBandHeaderSize

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("============================================")
        MemoWrite("Band Index " & $x & @TAB & "Header Size: " & _GUICtrlRebar_GetBandHeaderSize($hReBar, $x))
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Band Header Size")
    _GUICtrlRebar_SetBandHeaderSize($hReBar, 1, 50)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("============================================")
        MemoWrite("Band Index " & $x & @TAB & "Header Size: " & _GUICtrlRebar_GetBandHeaderSize($hReBar, $x))
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandID

Function Reference

_GUICtrlRebar_GetBandID

Get the value that the control uses to identify this band for custom draw notification messages

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandID ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

Returns the id of the band.

Related

_GUICtrlRebar_SetBandID

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $hCombo, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a combobox to put in the rebar
    $hCombo = _GUICtrlComboBox_Create($hGui, "", 0, 0, 120)
    _GUICtrlComboBox_BeginUpdate($hCombo)
    _GUICtrlComboBox_AddDir($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($hCombo)

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, $hCombo, 120, 200, "Dir " & @WindowsDir & "\*.exe:")

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandID($hReBar, 0, 2246)

    MemoWrite("Moved Band Index 0 -> 2: " & _GUICtrlRebar_MoveBand($hReBar, 0, 2))

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("============================================")
        MemoWrite("Band Index " & $x & @TAB & "ID: " & _GUICtrlRebar_GetBandID($hReBar, $x))
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandIdealSize

Function Reference

_GUICtrlRebar_GetBandIdealSize

Get Ideal width of the band, in pixels

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandIdealSize ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

Returns the ideal width of the band.

Remarks

If the band is maximized to the ideal width (see _GUICtrlRebar_MaximizeBand()), the rebar control will attempt to make the band this width.

Related

_GUICtrlRebar_MaximizeBand, _GUICtrlRebar_SetBandIdealSize

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    _GUICtrlRebar_SetBandIdealSize($hReBar, 1, 150)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "Ideal Size: " & _GUICtrlRebar_GetBandIdealSize($hReBar, $x))
    Next

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandLength

Function Reference

_GUICtrlRebar_GetBandLength

Get Length of the band, in pixels

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandLength ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

Returns the length of the band, in pixels.

Related

_GUICtrlRebar_SetBandLength

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $hCombo, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    ; $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a combobox to put in the rebar
    $hCombo = _GUICtrlComboBox_Create($hGui, "", 0, 0, 90, 120)
    _GUICtrlComboBox_BeginUpdate($hCombo)
    _GUICtrlComboBox_AddDir($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($hCombo)

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 90, 20)

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, $hCombo, 100, 120, "Dir *.exe:")

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 100, 100, "Name:")

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    GUISetState(@SW_SHOW)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "Length: " & _GUICtrlRebar_GetBandLength($hReBar, $x))
    Next

    MemoWrite("============================================")

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Band Width")

    _GUICtrlRebar_SetBandLength($hReBar, 0, 200)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "Length: " & _GUICtrlRebar_GetBandLength($hReBar, $x))
    Next

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    _GUICtrlEdit_AppendText($g_idMemo, $sMessage & @CRLF)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandLParam

Function Reference

_GUICtrlRebar_GetBandLParam

Get Application-defined value

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandLParam ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

Returns the application-defined value.

Related

_GUICtrlRebar_SetBandLParam

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    _GUICtrlRebar_SetBandLParam($hReBar, 0, 150)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "LParam: " & _GUICtrlRebar_GetBandLParam($hReBar, $x))
    Next

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandMargins

Function Reference

_GUICtrlRebar_GetBandMargins

Get Length of the band, in pixels

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandMargins ( $hWnd )

Parameters

$hWnd Handle to the rebar control

Return Value

Returns an array in the following:
[0] - Width of the left border that retains its size
[1] - Width of the right border that retains its size
[2] - Height of the top border that retains its size
[3] - Height of the bottom border that retains its size

Related

_GUICtrlRebar_GetBandMarginsEx

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput, $aMargins
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    $aMargins = _GUICtrlRebar_GetBandMargins($hReBar)
    MemoWrite("==== Band Margins ====")
    MemoWrite("===================================")
    MemoWrite("Minimum OS -> Win XP")
    MemoWrite("Margins are set Depending on Themes")
    MemoWrite("===================================")
    MemoWrite("Left Width.........: " & $aMargins[0])
    MemoWrite("Right Width........: " & $aMargins[1])
    MemoWrite("Top Height.........: " & $aMargins[2])
    MemoWrite("Bottom Height......: " & $aMargins[3])
    MemoWrite("======================")

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandMarginsEx

Function Reference

_GUICtrlRebar_GetBandMarginsEx

Get Length of the band, in pixels

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandMarginsEx ( $hWnd )

Parameters

$hWnd Handle to the rebar control

Return Value

Returns a $tagMargins structure.

Related

$tagMargins, _GUICtrlRebar_GetBandMargins

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput, $tMargins
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    $tMargins = _GUICtrlRebar_GetBandMargins($hReBar)
    MemoWrite("==== Band Margins ====")
    MemoWrite("===================================")
    MemoWrite("Minimum OS -> Win XP")
    MemoWrite("Margins are set Depending on Themes")
    MemoWrite("===================================")
    MemoWrite("Left Width.........: " & DllStructGetData($tMargins, "cxLeftWidth"))
    MemoWrite("Right Width........: " & DllStructGetData($tMargins, "cxRightWidth"))
    MemoWrite("Top Height.........: " & DllStructGetData($tMargins, "cyTopHeight"))
    MemoWrite("Bottom Height......: " & DllStructGetData($tMargins, "cyBottomHeight"))
    MemoWrite("======================")

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandRect

Function Reference

_GUICtrlRebar_GetBandRect

Retrieves the bounding rectangle for a given band in a rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandRect ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of a band in the rebar control

Return Value

Returns an array with the following format:
[0] - X coordinate of the upper left corner of the rectangle
[1] - Y coordinate of the upper left corner of the rectangle
[2] - X coordinate of the lower right corner of the rectangle
[3] - Y coordinate of the lower right corner of the rectangle

Related

_GUICtrlRebar_GetBandBorders, _GUICtrlRebar_GetBandBordersEx, _GUICtrlRebar_GetBandRectEx

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput, $aBorders
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        $aBorders = _GUICtrlRebar_GetBandBorders($hReBar, $x)
        MemoWrite("Band Index " & $x)
        MemoWrite("==== Band Borders ====")
        MemoWrite("Left..: " & $aBorders[0])
        MemoWrite("Top...: " & $aBorders[1])
        MemoWrite("Right.: " & $aBorders[2])
        MemoWrite("Bottom: " & $aBorders[3])
        MemoWrite("======================")
        $aBorders = _GUICtrlRebar_GetBandRect($hReBar, $x)
        MemoWrite("====== Band Rect =====")
        MemoWrite("Left..: " & $aBorders[0])
        MemoWrite("Top...: " & $aBorders[1])
        MemoWrite("Right.: " & $aBorders[2])
        MemoWrite("Bottom: " & $aBorders[3])
        MemoWrite("======================")
    Next

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandRectEx

Function Reference

_GUICtrlRebar_GetBandRectEx

Retrieves the bounding rectangle for a given band in a rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandRectEx ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of a band in the rebar control

Return Value

Returns a $tagRECT structure.

Related

_GUICtrlRebar_GetBandBorders, _GUICtrlRebar_GetBandBordersEx, _GUICtrlRebar_GetBandRect

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput, $tBorders
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        $tBorders = _GUICtrlRebar_GetBandBordersEx($hReBar, $x)
        MemoWrite("Band Index " & $x)
        MemoWrite("==== Band Borders ====")
        MemoWrite("Left..: " & DllStructGetData($tBorders, "Left"))
        MemoWrite("Top...: " & DllStructGetData($tBorders, "Top"))
        MemoWrite("Right.: " & DllStructGetData($tBorders, "Right"))
        MemoWrite("Bottom: " & DllStructGetData($tBorders, "Bottom"))
        MemoWrite("======================")
        $tBorders = _GUICtrlRebar_GetBandRectEx($hReBar, $x)
        MemoWrite("====== Band Rect =====")
        MemoWrite("Left..: " & DllStructGetData($tBorders, "Left"))
        MemoWrite("Top...: " & DllStructGetData($tBorders, "Top"))
        MemoWrite("Right.: " & DllStructGetData($tBorders, "Right"))
        MemoWrite("Bottom: " & DllStructGetData($tBorders, "Bottom"))
        MemoWrite("======================")
    Next

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandStyle

Function Reference

_GUICtrlRebar_GetBandStyle

Get the band style Flags

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandStyle ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

Returns a value of band flags, see fStyle of $tagREBARBANDINFO.

Related

$tagREBARBANDINFO, _GUICtrlRebar_GetBandStyleBreak, _GUICtrlRebar_GetBandStyleChildEdge, _GUICtrlRebar_GetBandStyleFixedBMP, _GUICtrlRebar_GetBandStyleFixedSize, _GUICtrlRebar_GetBandStyleGripperAlways, _GUICtrlRebar_GetBandStyleHidden, _GUICtrlRebar_GetBandStyleHideTitle, _GUICtrlRebar_GetBandStyleNoGripper, _GUICtrlRebar_GetBandStyleTopAlign, _GUICtrlRebar_GetBandStyleUseChevron, _GUICtrlRebar_GetBandStyleVariableHeight, _GUICtrlRebar_SetBandStyle

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    _GUICtrlRebar_SetBandStyle($hReBar, 1, BitOR($RBBS_CHILDEDGE, $RBBS_GRIPPERALWAYS, $RBBS_NOVERT))

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("==== Styles Used =====")
        MemoWrite("Band Index " & $x & @TAB & "fStyle: " & _GUICtrlRebar_GetBandStyle($hReBar, $x))
        MemoWrite("============================================")
        MemoWrite("$RBBS_BREAK.........: " & _GUICtrlRebar_GetBandStyleBreak($hReBar, $x))
        MemoWrite("$RBBS_CHILDEDGE.....: " & _GUICtrlRebar_GetBandStyleChildEdge($hReBar, $x))
        MemoWrite("$RBBS_FIXEDBMP......: " & _GUICtrlRebar_GetBandStyleFixedBMP($hReBar, $x))
        MemoWrite("$RBBS_FIXEDSIZE.....: " & _GUICtrlRebar_GetBandStyleFixedSize($hReBar, $x))
        MemoWrite("$RBBS_GRIPPERALWAYS.: " & _GUICtrlRebar_GetBandStyleGripperAlways($hReBar, $x))
        MemoWrite("$RBBS_HIDDEN........: " & _GUICtrlRebar_GetBandStyleHidden($hReBar, $x))
        MemoWrite("$RBBS_HIDETITLE.....: " & _GUICtrlRebar_GetBandStyleHideTitle($hReBar, $x))
        MemoWrite("$RBBS_NOGRIPPER.....: " & _GUICtrlRebar_GetBandStyleNoGripper($hReBar, $x))
        MemoWrite("$RBBS_NOVERT........: " & _GUICtrlRebar_GetBandStyleNoVert($hReBar, $x))
        MemoWrite("$RBBS_TOPALIGN......: " & _GUICtrlRebar_GetBandStyleTopAlign($hReBar, $x))
        MemoWrite("$RBBS_USECHEVRON....: " & _GUICtrlRebar_GetBandStyleUseChevron($hReBar, $x))
        MemoWrite("$RBBS_VARIABLEHEIGHT: " & _GUICtrlRebar_GetBandStyleVariableHeight($hReBar, $x))
        MemoWrite("============================================")
    Next

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandStyleBreak

Function Reference

_GUICtrlRebar_GetBandStyleBreak

Determine if band break flag is set

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandStyleBreak ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0based index of the band

Return Value

True: | the flag is set (The band is on a new line).
False: | the flag not set.

Related

_GUICtrlRebar_GetBandStyle, _GUICtrlRebar_SetBandStyleBreak

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Break Style")
    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_BREAK.........: " & _GUICtrlRebar_GetBandStyleBreak($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Break Style")
    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_BREAK.........: " & _GUICtrlRebar_GetBandStyleBreak($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandStyleChildEdge

Function Reference

_GUICtrlRebar_GetBandStyleChildEdge

Determine if band child edge flag is set

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandStyleChildEdge ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

True: | the flag is set (The band has an edge at the top and bottom of the child window).
False: | the flag not set.

Related

_GUICtrlRebar_GetBandStyle, _GUICtrlRebar_SetBandStyleChildEdge

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Child Edge Style")

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        _GUICtrlRebar_SetBandStyleChildEdge($hReBar, $x, False)
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_CHILDEDGE.....: " & _GUICtrlRebar_GetBandStyleChildEdge($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Child Edge Style")

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        _GUICtrlRebar_SetBandStyleChildEdge($hReBar, $x)
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_CHILDEDGE.....: " & _GUICtrlRebar_GetBandStyleChildEdge($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandStyleFixedBMP

Function Reference

_GUICtrlRebar_GetBandStyleFixedBMP

Determine if band fixed BMP flag is set

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandStyleFixedBMP ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

True: | the flag is set (The background bitmap does not move when the band is resized).
False: | the flag not set.

Related

_GUICtrlRebar_GetBandStyle, _GUICtrlRebar_SetBandStyleFixedBMP

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Fixed BMP Style")
    _GUICtrlRebar_SetBandStyleFixedBMP($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_FIXEDBMP......: " & _GUICtrlRebar_GetBandStyleFixedBMP($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Fixed BMP Style")
    _GUICtrlRebar_SetBandStyleFixedBMP($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_FIXEDBMP......: " & _GUICtrlRebar_GetBandStyleFixedBMP($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandStyleFixedSize

Function Reference

_GUICtrlRebar_GetBandStyleFixedSize

Determine if band fixed size flag is set

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandStyleFixedSize ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

True: | the flag is set (The band can't be sized. With this style, the sizing grip is not displayed on the band).
False: | the flag not set.

Related

_GUICtrlRebar_GetBandStyle, _GUICtrlRebar_SetBandStyleFixedSize

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Fixed Size Style")
    _GUICtrlRebar_SetBandStyleFixedSize($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_FIXEDSIZE.....: " & _GUICtrlRebar_GetBandStyleFixedSize($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Fixed Size Style")
    _GUICtrlRebar_SetBandStyleFixedSize($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_FIXEDSIZE.....: " & _GUICtrlRebar_GetBandStyleFixedSize($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandStyleGripperAlways

Function Reference

_GUICtrlRebar_GetBandStyleGripperAlways

Determine if band gripper flag is set

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandStyleGripperAlways ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

True: | the flag is set (The band will always have a sizing grip, even if it is the only band in the rebar).
False: | the flag not set.

Related

_GUICtrlRebar_GetBandStyle, _GUICtrlRebar_SetBandStyleGripperAlways

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Gripper Always Style")
    _GUICtrlRebar_SetBandStyleGripperAlways($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_GRIPPERALWAYS.: " & _GUICtrlRebar_GetBandStyleGripperAlways($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Gripper Always Style")
    _GUICtrlRebar_SetBandStyleGripperAlways($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_GRIPPERALWAYS.: " & _GUICtrlRebar_GetBandStyleGripperAlways($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandStyleHidden

Function Reference

_GUICtrlRebar_GetBandStyleHidden

Determine if band hidden flag is set

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandStyleHidden ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

True: | the flag lag is set (The band will not be visible).
False: | the flag not set.

Related

_GUICtrlRebar_GetBandStyle, _GUICtrlRebar_SetBandStyleHidden

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Hidden Style")
    _GUICtrlRebar_SetBandStyleHidden($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_HIDDEN........: " & _GUICtrlRebar_GetBandStyleHidden($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Hidden Style")
    _GUICtrlRebar_SetBandStyleHidden($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_HIDDEN........: " & _GUICtrlRebar_GetBandStyleHidden($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandStyleHideTitle

Function Reference

_GUICtrlRebar_GetBandStyleHideTitle

Determine if band hide title flag is set

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandStyleHideTitle ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

True: | the flag is set (Keep band title hidden).
False: | the flag not set.

Related

_GUICtrlRebar_GetBandStyle, _GUICtrlRebar_SetBandStyleHideTitle

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Hide Title Style")
    _GUICtrlRebar_SetBandStyleHideTitle($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_HIDETITLE.....: " & _GUICtrlRebar_GetBandStyleHideTitle($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Hide Title Style")
    _GUICtrlRebar_SetBandStyleHideTitle($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_HIDETITLE.....: " & _GUICtrlRebar_GetBandStyleHideTitle($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandStyleNoGripper

Function Reference

_GUICtrlRebar_GetBandStyleNoGripper

Determine if band noGripper flag is set

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandStyleNoGripper ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

True: | the flag is set (The band will never have a sizing grip, even if there is more than one band in the rebar).
False: | the flag not set.

Related

_GUICtrlRebar_GetBandStyle, _GUICtrlRebar_SetBandStyleNoGripper

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting No Gripper Style")
    _GUICtrlRebar_SetBandStyleNoGripper($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_NOGRIPPER.....: " & _GUICtrlRebar_GetBandStyleNoGripper($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting No Gripper Style")
    _GUICtrlRebar_SetBandStyleNoGripper($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_NOGRIPPER.....: " & _GUICtrlRebar_GetBandStyleNoGripper($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandStyleTopAlign

Function Reference

_GUICtrlRebar_GetBandStyleTopAlign

Determine if band top align flag is set

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandStyleTopAlign ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

True: | the flag is set (Keep band in top row).
False: | the flag not set.

Related

_GUICtrlRebar_GetBandStyle, _GUICtrlRebar_SetBandStyleTopAlign

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Top Align Style")
    _GUICtrlRebar_SetBandStyleTopAlign($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_TOPALIGN......: " & _GUICtrlRebar_GetBandStyleTopAlign($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Top Align Style")
    _GUICtrlRebar_SetBandStyleTopAlign($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_TOPALIGN......: " & _GUICtrlRebar_GetBandStyleTopAlign($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandStyleUseChevron

Function Reference

_GUICtrlRebar_GetBandStyleUseChevron

Determine if band use chevron flag is set

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandStyleUseChevron ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

True: | the flag is set (Display drop-down button).
False: | the flag not set.

Related

_GUICtrlRebar_GetBandStyle, _GUICtrlRebar_SetBandStyleUseChevron

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Use Chevron Style")
    _GUICtrlRebar_SetBandStyleUseChevron($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_USECHEVRON....: " & _GUICtrlRebar_GetBandStyleUseChevron($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Use Chevron Style")
    _GUICtrlRebar_SetBandStyleUseChevron($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_USECHEVRON....: " & _GUICtrlRebar_GetBandStyleUseChevron($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandStyleVariableHeight

Function Reference

_GUICtrlRebar_GetBandStyleVariableHeight

Determine if band variable height flag is set

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandStyleVariableHeight ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

True: | the flag is set (The band can be resized by the rebar control).
False: | the flag not set.

Related

_GUICtrlRebar_GetBandStyle, _GUICtrlRebar_SetBandStyleVariableHeight

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Variable Height Style")
    _GUICtrlRebar_SetBandStyleVariableHeight($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_VARIABLEHEIGHT: " & _GUICtrlRebar_GetBandStyleVariableHeight($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Variable Height Style")
    _GUICtrlRebar_SetBandStyleVariableHeight($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_VARIABLEHEIGHT: " & _GUICtrlRebar_GetBandStyleVariableHeight($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBandText

Function Reference

_GUICtrlRebar_GetBandText

Retrieves the display text for the band

#include <GuiReBar.au3>
_GUICtrlRebar_GetBandText ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band for which the information will be retrieved

Return Value

Returns the display text for the band.

Related

_GUICtrlRebar_SetBandText

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "Text: " & _GUICtrlRebar_GetBandText($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Band Text")
    _GUICtrlRebar_SetBandText($hReBar, 1, "Your Name:")

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "Text: " & _GUICtrlRebar_GetBandText($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBarHeight

Function Reference

_GUICtrlRebar_GetBarHeight

Retrieves the height of the rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_GetBarHeight ( $hWnd )

Parameters

$hWnd Handle to the rebar control

Return Value

Returns the Value that represents the height, in pixels, of the control.

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MemoWrite("Bar Height: " & _GUICtrlRebar_GetBarHeight($hReBar))

    MsgBox($MB_SYSTEMMODAL, "Information", "Force height to change")
    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)

    MemoWrite("Bar Height: " & _GUICtrlRebar_GetBarHeight($hReBar))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBarInfo

Function Reference

_GUICtrlRebar_GetBarInfo

Retrieves information about the rebar control and the image list it uses

#include <GuiReBar.au3>
_GUICtrlRebar_GetBarInfo ( $hWnd )

Parameters

$hWnd Handle to the rebar control

Return Value

Returns the handle to an image list. The rebar control will use the specified image list to obtain images.

Remarks

Currently, rebar controls support only image list handle

Related

_GUICtrlRebar_SetBarInfo

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput, $hImage
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Load images
    $hImage = _GUIImageList_Create(16, 16, 5, 3, 6)
    For $x = 6 To 11
        _GUIImageList_AddIcon($hImage, "shell32.dll", $x)
    Next
    _GUICtrlRebar_SetBarInfo($hReBar, $hImage)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MemoWrite("Image List Handle: " & _GUICtrlRebar_GetBarInfo($hReBar))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetBKColor

Function Reference

_GUICtrlRebar_GetBKColor

Retrieves a rebar control's default background color

#include <GuiReBar.au3>
_GUICtrlRebar_GetBKColor ( $hWnd )

Parameters

$hWnd Handle to the rebar control

Return Value

Returns a COLORREF value that represents the current default background color.

Related

_GUICtrlRebar_SetBKColor

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hReBar, $hToolbar, $idExit, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGUI = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; Create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGUI, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; Create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGUI, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ; Add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; Add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idExit, $GUI_DEFBUTTON + $GUI_FOCUS)

    GUISetState(@SW_SHOW, $hGUI)

    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)

    MemoWrite("========== Bar Color ==========")
    MemoWrite("Previous BK Color..: " & _GUICtrlRebar_SetBKColor($hReBar, Int(0x00008B)))
    MemoWrite("BK Color...........: " & _GUICtrlRebar_GetBKColor($hReBar))
    MemoWrite("Previous Text Color: " & _GUICtrlRebar_SetTextColor($hReBar, Int(0xFFFFFF)))
    MemoWrite("Text Color.........: " & _GUICtrlRebar_GetTextColor($hReBar))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetColorScheme

Function Reference

_GUICtrlRebar_GetColorScheme

Retrieves the color scheme information from the rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_GetColorScheme ( $hWnd )

Parameters

$hWnd Handle to the rebar control

Return Value

Returns an array of the following:
[0] - The COLORREF value that represents the highlight color of the buttons
[1] - The COLORREF value that represents the shadow color of the buttons

Related

_GUICtrlRebar_SetColorScheme

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput, $aColors
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)

    MemoWrite("========== Color Scheme ==========")
    $aColors = _GUICtrlRebar_GetColorScheme($hReBar)
    MemoWrite("BtnHighlight.......: " & $aColors[0])
    MemoWrite("BtnShadow..........: " & $aColors[1])

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Color Scheme")
    _GUICtrlRebar_SetColorScheme($hReBar, Int(0x00008B), Int(0xFFFFFF))

    MemoWrite(@CRLF & "========== Color Scheme ==========")
    $aColors = _GUICtrlRebar_GetColorScheme($hReBar)
    MemoWrite("BtnHighlight.......: " & $aColors[0])
    MemoWrite("BtnShadow..........: " & $aColors[1])

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetRowCount

Function Reference

_GUICtrlRebar_GetRowCount

Retrieves the number of rows of bands in a rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_GetRowCount ( $hWnd )

Parameters

$hWnd Handle to the rebar control

Return Value

Returns a value that represents the number of band rows in the control.

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)

    MemoWrite("Row Count: " & _GUICtrlRebar_GetRowCount($hReBar))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetRowHeight

Function Reference

_GUICtrlRebar_GetRowHeight

Retrieves the height of a specified row in a rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_GetRowHeight ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of a band. The height of the row that contains the specified band will be retrieved

Return Value

Returns a value that represents the row height, in pixels.

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)
    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "Row Height: " & _GUICtrlRebar_GetRowHeight($hReBar, $x))
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetTextColor

Function Reference

_GUICtrlRebar_GetTextColor

Retrieves a rebar control's default text color

#include <GuiReBar.au3>
_GUICtrlRebar_GetTextColor ( $hWnd )

Parameters

$hWnd Handle to the rebar control

Return Value

Returns a value that represent the current default text color.

Related

_GUICtrlRebar_SetTextColor

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)

    MemoWrite("========== Bar Color ==========")
    MemoWrite("Previous BK Color..: " & _GUICtrlRebar_SetBKColor($hReBar, Int(0x00008B)))
    MemoWrite("BK Color...........: " & _GUICtrlRebar_GetBKColor($hReBar))
    MemoWrite("Previous Text Color: " & _GUICtrlRebar_SetTextColor($hReBar, Int(0xFFFFFF)))
    MemoWrite("Text Color.........: " & _GUICtrlRebar_GetTextColor($hReBar))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetToolTips

Function Reference

_GUICtrlRebar_GetToolTips

Retrieves the handle to any ToolTip control associated with the rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_GetToolTips ( $hWnd )

Parameters

$hWnd Handle to the rebar control

Return Value

Success: | the handle to the ToolTip control associated with the rebar control.
Failure: | 0 if no ToolTip control is associated with the rebar control.

Related

_GUICtrlRebar_SetToolTips

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <GuiToolTip.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput, $hToolTip
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)

    $hToolTip = _GUIToolTip_Create($hReBar)

    MemoWrite("ToolTips Handle: " & _GUICtrlRebar_GetToolTips($hReBar))

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting ToolTips Handle")
    _GUICtrlRebar_SetToolTips($hReBar, $hToolTip)

    MemoWrite("ToolTips Handle: " & _GUICtrlRebar_GetToolTips($hReBar))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_GetUnicodeFormat

Function Reference

_GUICtrlRebar_GetUnicodeFormat

Retrieves the Unicode character format flag for the control

#include <GuiReBar.au3>
_GUICtrlRebar_GetUnicodeFormat ( $hWnd )

Parameters

$hWnd Handle to the rebar control

Return Value

True: | the control is using Unicode characters.
False: | the control is using ANSI characters.

Related

_GUICtrlRebar_SetUnicodeFormat

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)

    MemoWrite("Unicode: " & _GUICtrlRebar_GetUnicodeFormat($hReBar))

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Unicode")
    _GUICtrlRebar_SetUnicodeFormat($hReBar)

    MemoWrite("Unicode: " & _GUICtrlRebar_GetUnicodeFormat($hReBar))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_HitTest

Function Reference

_GUICtrlRebar_HitTest

Determines which band is at a specified position

#include <GuiReBar.au3>
_GUICtrlRebar_HitTest ( $hWnd [, $iX = -1 [, $iY = -1]] )

Parameters

$hWnd | Handle to the rebar control
$iX | [optional] X position, in client coordinates, to be tested or -1 to use the current mouse position
$iY | [optional] Y position, in client coordinates, to be tested or -1 to use the current mouse position

Return Value

Success: | an array with the following format: [0] - 0-based index of the band at the specified position, or -1 [1] - If True, position is in control's client window but not on an band [2] - If True, position is in control's client window [3] - If True, position is over the rebar band's caption [4] - If True, position is over the rebar band's chevron (version 5.80 and greater) [5] - If True, position is over the rebar band's gripper
Failure: | sets the @error flag to non-zero.

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput, $aHitTest
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    $aHitTest = _GUICtrlRebar_HitTest($hReBar, 150, 25)
    MemoWrite("iBand........: " & $aHitTest[0])
    MemoWrite("$RBHT_NOWHERE: " & $aHitTest[5])
    MemoWrite("$RBHT_CLIENT.: " & $aHitTest[3])
    MemoWrite("$RBHT_CAPTION: " & $aHitTest[1])
    MemoWrite("$RBHT_CHEVRON: " & $aHitTest[2])
    MemoWrite("$RBHT_GRABBER: " & $aHitTest[4])

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_IDToIndex

Function Reference

_GUICtrlRebar_IDToIndex

Converts a band identifier to a band index in a rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_IDToIndex ( $hWnd, $iID )

Parameters

$hWnd | Handle to the rebar control
$iID | The application-defined identifier of the band in question

Return Value

Success: | the 0-based band index.
Failure: | -1.

Remarks

If duplicate band identifiers exist, the first one is returned.

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $hCombo, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a combobox to put in the rebar
    $hCombo = _GUICtrlComboBox_Create($hGui, "", 0, 0, 120)
    _GUICtrlComboBox_BeginUpdate($hCombo)
    _GUICtrlComboBox_AddDir($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($hCombo)

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, $hCombo, 120, 200, "Dir " & @WindowsDir & "\*.exe:")

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandID($hReBar, 0, 2246)
    MemoWrite("Set Band Index 0 ID: " & _GUICtrlRebar_GetBandID($hReBar, 0))

    MemoWrite("Moved Band Index 0 -> 2: " & _GUICtrlRebar_MoveBand($hReBar, 0, 2))

    MemoWrite("ID 2246, Index: " & _GUICtrlRebar_IDToIndex($hReBar, 2246))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_MaximizeBand

Function Reference

_GUICtrlRebar_MaximizeBand

Resizes a band in a rebar control to either its ideal or largest size

#include <GuiReBar.au3>
_GUICtrlRebar_MaximizeBand ( $hWnd, $iIndex [, $bIdeal = True] )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$bIdeal | [optional] Indicates if the ideal width of the band should be used when the band is maximized

Return Value

None.

Related

_GUICtrlRebar_GetBandIdealSize

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $hCombo, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a combobox to put in the rebar
    $hCombo = _GUICtrlComboBox_Create($hGui, "", 0, 0, 120)
    _GUICtrlComboBox_BeginUpdate($hCombo)
    _GUICtrlComboBox_AddDir($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($hCombo)

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, $hCombo, 120, 200, "Dir " & @WindowsDir & "\*.exe:")

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Minimize Band")
    _GUICtrlRebar_MinimizeBand($hReBar, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Maximize Band 1 to largest Size")
    _GUICtrlRebar_MaximizeBand($hReBar, 1, False)
    MsgBox($MB_SYSTEMMODAL, "Information", "Maximize Band 0 to Ideal Size")
    _GUICtrlRebar_MaximizeBand($hReBar, 0)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_MinimizeBand

Function Reference

_GUICtrlRebar_MinimizeBand

Resizes a band in a rebar control to its smallest size

#include <GuiReBar.au3>
_GUICtrlRebar_MinimizeBand ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band

Return Value

None.

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $hCombo, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a combobox to put in the rebar
    $hCombo = _GUICtrlComboBox_Create($hGui, "", 0, 0, 120)
    _GUICtrlComboBox_BeginUpdate($hCombo)
    _GUICtrlComboBox_AddDir($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($hCombo)

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, $hCombo, 120, 200, "Dir " & @WindowsDir & "\*.exe:")

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Minimize Band")
    _GUICtrlRebar_MinimizeBand($hReBar, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Maximize Band 1 to largest Size")
    _GUICtrlRebar_MaximizeBand($hReBar, 1, False)
    MsgBox($MB_SYSTEMMODAL, "Information", "Maximize Band 0 to Ideal Size")
    _GUICtrlRebar_MaximizeBand($hReBar, 0)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_MoveBand

Function Reference

_GUICtrlRebar_MoveBand

Moves a band from one index to another

#include <GuiReBar.au3>
_GUICtrlRebar_MoveBand ( $hWnd, $iIndexFrom, $iIndexTo )

Parameters

$hWnd | Handle to the rebar control
$iIndexFrom | 0-based index of the band to be moved
$iIndexTo | 0-based index of the new band position

Return Value

Success: | True.
Failure: | False.

Remarks

This message will most likely change the index of other bands in the rebar control.
If a band is moved from index 6 to index 0, all of the bands in between will have their index incremented by one.

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $hCombo, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a combobox to put in the rebar
    $hCombo = _GUICtrlComboBox_Create($hGui, "", 0, 0, 120)
    _GUICtrlComboBox_BeginUpdate($hCombo)
    _GUICtrlComboBox_AddDir($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($hCombo)

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, $hCombo, 120, 200, "Dir " & @WindowsDir & "\*.exe:")

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandID($hReBar, 0, 2246)

    MemoWrite("Moved Band Index 0 -> 2: " & _GUICtrlRebar_MoveBand($hReBar, 0, 2))

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("============================================")
        MemoWrite("Band Index " & $x & @TAB & "ID: " & _GUICtrlRebar_GetBandID($hReBar, $x))
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandBackColor

Function Reference

_GUICtrlRebar_SetBandBackColor

Set the Band background color

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandBackColor ( $hWnd, $iIndex, $iColor )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$iColor | New color for band background

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_GetBandBackColor

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("======================")
        MemoWrite("Band Index " & $x)
        MemoWrite("======================")
        MemoWrite("Back Color: " & _GUICtrlRebar_GetBandBackColor($hReBar, $x))
        MemoWrite("Fore Color: " & _GUICtrlRebar_GetBandForeColor($hReBar, $x))
    Next

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandForeColor

Function Reference

_GUICtrlRebar_SetBandForeColor

Set the Band foreground color

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandForeColor ( $hWnd, $iIndex, $iColor )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$iColor | New color for band foreground

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_GetBandForeColor

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("======================")
        MemoWrite("Band Index " & $x)
        MemoWrite("======================")
        MemoWrite("Back Color: " & _GUICtrlRebar_GetBandBackColor($hReBar, $x))
        MemoWrite("Fore Color: " & _GUICtrlRebar_GetBandForeColor($hReBar, $x))
    Next

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandHeaderSize

Function Reference

_GUICtrlRebar_SetBandHeaderSize

Set the size of the band's header, in pixels

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandHeaderSize ( $hWnd, $iIndex, $iNewSize )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$iNewSize | New size of the band's header

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_GetBandHeaderSize

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("============================================")
        MemoWrite("Band Index " & $x & @TAB & "Header Size: " & _GUICtrlRebar_GetBandHeaderSize($hReBar, $x))
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Band Header Size")
    _GUICtrlRebar_SetBandHeaderSize($hReBar, 1, 50)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("============================================")
        MemoWrite("Band Index " & $x & @TAB & "Header Size: " & _GUICtrlRebar_GetBandHeaderSize($hReBar, $x))
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandID

Function Reference

_GUICtrlRebar_SetBandID

Set the value that the control uses to identify this band for custom draw notification messages

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandID ( $hWnd, $iIndex, $iID )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$iID | value that the control uses to identify this band for custom draw notification messages

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_GetBandID

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $hCombo, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a combobox to put in the rebar
    $hCombo = _GUICtrlComboBox_Create($hGui, "", 0, 0, 120)
    _GUICtrlComboBox_BeginUpdate($hCombo)
    _GUICtrlComboBox_AddDir($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($hCombo)

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, $hCombo, 120, 200, "Dir " & @WindowsDir & "\*.exe:")

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandID($hReBar, 0, 2246)

    MemoWrite("Moved Band Index 0 -> 2: " & _GUICtrlRebar_MoveBand($hReBar, 0, 2))

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("============================================")
        MemoWrite("Band Index " & $x & @TAB & "ID: " & _GUICtrlRebar_GetBandID($hReBar, $x))
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandIdealSize

Function Reference

_GUICtrlRebar_SetBandIdealSize

Set Ideal width of the band, in pixels

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandIdealSize ( $hWnd, $iIndex, $iNewSize )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$iNewSize | Ideal width of the band, in pixels

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_GetBandIdealSize

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    _GUICtrlRebar_SetBandIdealSize($hReBar, 1, 150)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "Ideal Size: " & _GUICtrlRebar_GetBandIdealSize($hReBar, $x))
    Next

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandLength

Function Reference

_GUICtrlRebar_SetBandLength

Set the size length of the band

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandLength ( $hWnd, $iIndex, $iLength )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$iLength | Length of the band, in pixels

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_GetBandLength

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $hCombo, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    ; $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a combobox to put in the rebar
    $hCombo = _GUICtrlComboBox_Create($hGui, "", 0, 0, 90, 120)
    _GUICtrlComboBox_BeginUpdate($hCombo)
    _GUICtrlComboBox_AddDir($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($hCombo)

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 90, 20)

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, $hCombo, 100, 120, "Dir *.exe:")

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 100, 100, "Name:")

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    GUISetState(@SW_SHOW)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "Length: " & _GUICtrlRebar_GetBandLength($hReBar, $x))
    Next

    MemoWrite("============================================")

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Band Width")

    _GUICtrlRebar_SetBandLength($hReBar, 0, 200)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "Length: " & _GUICtrlRebar_GetBandLength($hReBar, $x))
    Next

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    _GUICtrlEdit_AppendText($g_idMemo, $sMessage & @CRLF)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandLParam

Function Reference

_GUICtrlRebar_SetBandLParam

Set Application-defined value

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandLParam ( $hWnd, $iIndex, $lParam )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$lParam | Application-defined value

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_GetBandLParam

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    _GUICtrlRebar_SetBandLParam($hReBar, 0, 150)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "LParam: " & _GUICtrlRebar_GetBandLParam($hReBar, $x))
    Next

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandStyle

Function Reference

_GUICtrlRebar_SetBandStyle

Set the band style Flags

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandStyle ( $hWnd, $iIndex, $iStyle )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$iStyle | see $tagREBARBANDINFO

Return Value

Success: | True.
Failure: | False.

Related

$tagREBARBANDINFO, _GUICtrlRebar_GetBandStyle, _GUICtrlRebar_SetBandStyleBreak, _GUICtrlRebar_SetBandStyleChildEdge, _GUICtrlRebar_SetBandStyleFixedBMP, _GUICtrlRebar_SetBandStyleFixedSize, _GUICtrlRebar_SetBandStyleGripperAlways, _GUICtrlRebar_SetBandStyleHidden, _GUICtrlRebar_SetBandStyleHideTitle, _GUICtrlRebar_SetBandStyleNoGripper, _GUICtrlRebar_SetBandStyleTopAlign, _GUICtrlRebar_SetBandStyleUseChevron, _GUICtrlRebar_SetBandStyleVariableHeight

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    _GUICtrlRebar_SetBandStyle($hReBar, 1, BitOR($RBBS_CHILDEDGE, $RBBS_GRIPPERALWAYS, $RBBS_NOVERT))

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("==== Styles Used =====")
        MemoWrite("Band Index " & $x & @TAB & "fStyle: " & _GUICtrlRebar_GetBandStyle($hReBar, $x))
        MemoWrite("============================================")
        MemoWrite("$RBBS_BREAK.........: " & _GUICtrlRebar_GetBandStyleBreak($hReBar, $x))
        MemoWrite("$RBBS_CHILDEDGE.....: " & _GUICtrlRebar_GetBandStyleChildEdge($hReBar, $x))
        MemoWrite("$RBBS_FIXEDBMP......: " & _GUICtrlRebar_GetBandStyleFixedBMP($hReBar, $x))
        MemoWrite("$RBBS_FIXEDSIZE.....: " & _GUICtrlRebar_GetBandStyleFixedSize($hReBar, $x))
        MemoWrite("$RBBS_GRIPPERALWAYS.: " & _GUICtrlRebar_GetBandStyleGripperAlways($hReBar, $x))
        MemoWrite("$RBBS_HIDDEN........: " & _GUICtrlRebar_GetBandStyleHidden($hReBar, $x))
        MemoWrite("$RBBS_HIDETITLE.....: " & _GUICtrlRebar_GetBandStyleHideTitle($hReBar, $x))
        MemoWrite("$RBBS_NOGRIPPER.....: " & _GUICtrlRebar_GetBandStyleNoGripper($hReBar, $x))
        MemoWrite("$RBBS_NOVERT........: " & _GUICtrlRebar_GetBandStyleNoVert($hReBar, $x))
        MemoWrite("$RBBS_TOPALIGN......: " & _GUICtrlRebar_GetBandStyleTopAlign($hReBar, $x))
        MemoWrite("$RBBS_USECHEVRON....: " & _GUICtrlRebar_GetBandStyleUseChevron($hReBar, $x))
        MemoWrite("$RBBS_VARIABLEHEIGHT: " & _GUICtrlRebar_GetBandStyleVariableHeight($hReBar, $x))
        MemoWrite("============================================")
    Next

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandStyleBreak

Function Reference

_GUICtrlRebar_SetBandStyleBreak

Set whether the band is on a new line

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandStyleBreak ( $hWnd, $iIndex [, $bEnabled = True] )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$bEnabled | [optional] If True the item state is set, otherwise it is not set

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_GetBandStyleBreak, _GUICtrlRebar_SetBandStyle

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Break Style")
    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_BREAK.........: " & _GUICtrlRebar_GetBandStyleBreak($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Break Style")
    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_BREAK.........: " & _GUICtrlRebar_GetBandStyleBreak($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandStyleChildEdge

Function Reference

_GUICtrlRebar_SetBandStyleChildEdge

Set whether the band has an edge at the top and bottom of the child window

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandStyleChildEdge ( $hWnd, $iIndex [, $bEnabled = True] )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$bEnabled | [optional] If True the item state is set, otherwise it is not set

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_GetBandStyleChildEdge, _GUICtrlRebar_SetBandStyle

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Child Edge Style")

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        _GUICtrlRebar_SetBandStyleChildEdge($hReBar, $x, False)
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_CHILDEDGE.....: " & _GUICtrlRebar_GetBandStyleChildEdge($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Child Edge Style")

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        _GUICtrlRebar_SetBandStyleChildEdge($hReBar, $x)
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_CHILDEDGE.....: " & _GUICtrlRebar_GetBandStyleChildEdge($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandStyleFixedBMP

Function Reference

_GUICtrlRebar_SetBandStyleFixedBMP

Set whether the band background bitmap does not move when the band is resized

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandStyleFixedBMP ( $hWnd, $iIndex [, $bEnabled = True] )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$bEnabled | [optional] If True the item state is set, otherwise it is not set

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_GetBandStyleFixedBMP, _GUICtrlRebar_SetBandStyle

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Fixed BMP Style")
    _GUICtrlRebar_SetBandStyleFixedBMP($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_FIXEDBMP......: " & _GUICtrlRebar_GetBandStyleFixedBMP($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Fixed BMP Style")
    _GUICtrlRebar_SetBandStyleFixedBMP($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_FIXEDBMP......: " & _GUICtrlRebar_GetBandStyleFixedBMP($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandStyleFixedSize

Function Reference

_GUICtrlRebar_SetBandStyleFixedSize

Set whether the band can't be sized. With this style, the sizing grip is not displayed on the band

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandStyleFixedSize ( $hWnd, $iIndex [, $bEnabled = True] )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$bEnabled | [optional] If True the item state is set, otherwise it is not set

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_GetBandStyleFixedSize, _GUICtrlRebar_SetBandStyle

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Fixed Size Style")
    _GUICtrlRebar_SetBandStyleFixedSize($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_FIXEDSIZE.....: " & _GUICtrlRebar_GetBandStyleFixedSize($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Fixed Size Style")
    _GUICtrlRebar_SetBandStyleFixedSize($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_FIXEDSIZE.....: " & _GUICtrlRebar_GetBandStyleFixedSize($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandStyleGripperAlways

Function Reference

_GUICtrlRebar_SetBandStyleGripperAlways

Set whether the band will always have a sizing grip, even if it is the only band in the rebar

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandStyleGripperAlways ( $hWnd, $iIndex [, $bEnabled = True] )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$bEnabled | [optional] If True the item state is set, otherwise it is not set

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_GetBandStyleGripperAlways, _GUICtrlRebar_SetBandStyle

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Gripper Always Style")
    _GUICtrlRebar_SetBandStyleGripperAlways($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_GRIPPERALWAYS.: " & _GUICtrlRebar_GetBandStyleGripperAlways($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Gripper Always Style")
    _GUICtrlRebar_SetBandStyleGripperAlways($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_GRIPPERALWAYS.: " & _GUICtrlRebar_GetBandStyleGripperAlways($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandStyleHidden

Function Reference

_GUICtrlRebar_SetBandStyleHidden

Set whether the band will not be visible

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandStyleHidden ( $hWnd, $iIndex [, $bEnabled = True] )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$bEnabled | [optional] If True the item state is set, otherwise it is not set

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_GetBandStyleHidden, _GUICtrlRebar_SetBandStyle, _GUICtrlRebar_ShowBand

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Hidden Style")
    _GUICtrlRebar_SetBandStyleHidden($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_HIDDEN........: " & _GUICtrlRebar_GetBandStyleHidden($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Hidden Style")
    _GUICtrlRebar_SetBandStyleHidden($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_HIDDEN........: " & _GUICtrlRebar_GetBandStyleHidden($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandStyleHideTitle

Function Reference

_GUICtrlRebar_SetBandStyleHideTitle

Set whether to keep band title hidden

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandStyleHideTitle ( $hWnd, $iIndex [, $bEnabled = True] )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$bEnabled | [optional] If True the item state is set, otherwise it is not set

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_GetBandStyleHideTitle, _GUICtrlRebar_SetBandStyle

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Hide Title Style")
    _GUICtrlRebar_SetBandStyleHideTitle($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_HIDETITLE.....: " & _GUICtrlRebar_GetBandStyleHideTitle($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Hide Title Style")
    _GUICtrlRebar_SetBandStyleHideTitle($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_HIDETITLE.....: " & _GUICtrlRebar_GetBandStyleHideTitle($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandStyleNoGripper

Function Reference

_GUICtrlRebar_SetBandStyleNoGripper

Set whether the band will never have a sizing grip, even if there is more than one band in the rebar

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandStyleNoGripper ( $hWnd, $iIndex [, $bEnabled = True] )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$bEnabled | [optional] If True the item state is set, otherwise it is not set

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_GetBandStyleNoGripper, _GUICtrlRebar_SetBandStyle

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting No Gripper Style")
    _GUICtrlRebar_SetBandStyleNoGripper($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_NOGRIPPER.....: " & _GUICtrlRebar_GetBandStyleNoGripper($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting No Gripper Style")
    _GUICtrlRebar_SetBandStyleNoGripper($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_NOGRIPPER.....: " & _GUICtrlRebar_GetBandStyleNoGripper($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandStyleTopAlign

Function Reference

_GUICtrlRebar_SetBandStyleTopAlign

Set whether to keep band in top row

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandStyleTopAlign ( $hWnd, $iIndex [, $bEnabled = True] )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$bEnabled | [optional] If True the item state is set, otherwise it is not set

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_GetBandStyleTopAlign, _GUICtrlRebar_SetBandStyle

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Top Align Style")
    _GUICtrlRebar_SetBandStyleTopAlign($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_TOPALIGN......: " & _GUICtrlRebar_GetBandStyleTopAlign($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Top Align Style")
    _GUICtrlRebar_SetBandStyleTopAlign($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_TOPALIGN......: " & _GUICtrlRebar_GetBandStyleTopAlign($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandStyleUseChevron

Function Reference

_GUICtrlRebar_SetBandStyleUseChevron

Set whether to display drop-down button

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandStyleUseChevron ( $hWnd, $iIndex [, $bEnabled = True] )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$bEnabled | [optional] If True the item state is set, otherwise it is not set

Return Value

Success: | True.
Failure: | False.

Remarks

Version 5.80. Show a chevron button if the band is smaller than cxIdeal.

Related

_GUICtrlRebar_GetBandStyleUseChevron, _GUICtrlRebar_SetBandStyle

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Use Chevron Style")
    _GUICtrlRebar_SetBandStyleUseChevron($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_USECHEVRON....: " & _GUICtrlRebar_GetBandStyleUseChevron($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Use Chevron Style")
    _GUICtrlRebar_SetBandStyleUseChevron($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_USECHEVRON....: " & _GUICtrlRebar_GetBandStyleUseChevron($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandStyleVariableHeight

Function Reference

_GUICtrlRebar_SetBandStyleVariableHeight

Set whether the band can be resized by the rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandStyleVariableHeight ( $hWnd, $iIndex [, $bEnabled = True] )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$bEnabled | [optional] If True the item state is set, otherwise it is not set

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_GetBandStyleVariableHeight, _GUICtrlRebar_SetBandStyle

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Variable Height Style")
    _GUICtrlRebar_SetBandStyleVariableHeight($hReBar, 1)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_VARIABLEHEIGHT: " & _GUICtrlRebar_GetBandStyleVariableHeight($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Variable Height Style")
    _GUICtrlRebar_SetBandStyleVariableHeight($hReBar, 1, False)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "$RBBS_VARIABLEHEIGHT: " & _GUICtrlRebar_GetBandStyleVariableHeight($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBandText

Function Reference

_GUICtrlRebar_SetBandText

Sets the display text for the band of a rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_SetBandText ( $hWnd, $iIndex, $sText )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band for which the information will be set
$sText | New display text for the band

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlRebar_GetBandText

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "Text: " & _GUICtrlRebar_GetBandText($hReBar, $x))
        MemoWrite("============================================")
    Next

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Band Text")
    _GUICtrlRebar_SetBandText($hReBar, 1, "Your Name:")

    For $x = 0 To _GUICtrlRebar_GetBandCount($hReBar) - 1
        MemoWrite("Band Index " & $x & @TAB & "Text: " & _GUICtrlRebar_GetBandText($hReBar, $x))
        MemoWrite("============================================")
    Next

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBarInfo

Function Reference

_GUICtrlRebar_SetBarInfo

Sets the characteristics of a rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_SetBarInfo ( $hWnd, $hIml )

Parameters

$hWnd | Handle to the rebar control
$hIml | Handle to the Image list

Return Value

Success: | True.
Failure: | False.

Remarks

Currently, rebar controls support only image list handle.

Related

_GUICtrlRebar_GetBarInfo

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput, $hImage
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Load images
    $hImage = _GUIImageList_Create(16, 16, 5, 3, 6)
    For $x = 6 To 11
        _GUIImageList_AddIcon($hImage, "shell32.dll", $x)
    Next
    _GUICtrlRebar_SetBarInfo($hReBar, $hImage)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    _GUICtrlRebar_SetBandBackColor($hReBar, 1, Int(0x00008B))
    _GUICtrlRebar_SetBandForeColor($hReBar, 1, Int(0xFFFFFF))

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MemoWrite("Image List Handle: " & _GUICtrlRebar_GetBarInfo($hReBar))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetBKColor

Function Reference

_GUICtrlRebar_SetBKColor

Sets the default background color of a rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_SetBKColor ( $hWnd, $iColor )

Parameters

$hWnd | Handle to the rebar control
$iColor | COLORREF value that represents the new default background color

Return Value

Returns A COLORREF value that represents the previous default background color.

Related

_GUICtrlRebar_GetBKColor

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)

    MemoWrite("========== Bar Color ==========")
    MemoWrite("Previous BK Color..: " & _GUICtrlRebar_SetBKColor($hReBar, Int(0x00008B)))
    MemoWrite("BK Color...........: " & _GUICtrlRebar_GetBKColor($hReBar))
    MemoWrite("Previous Text Color: " & _GUICtrlRebar_SetTextColor($hReBar, Int(0xFFFFFF)))
    MemoWrite("Text Color.........: " & _GUICtrlRebar_GetTextColor($hReBar))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetColorScheme

Function Reference

_GUICtrlRebar_SetColorScheme

Sets the color scheme of a rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_SetColorScheme ( $hWnd, $iBtnHighlight, $iBtnShadow )

Parameters

$hWnd | Handle to the rebar control
$iBtnHighlight | COLORREF value that represents the highlight color of the buttons
$iBtnShadow | COLORREF value that represents the shadow color of the buttons

Return Value

None.

Related

_GUICtrlRebar_GetColorScheme

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput, $aColors
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)

    MemoWrite("========== Color Scheme ==========")
    $aColors = _GUICtrlRebar_GetColorScheme($hReBar)
    MemoWrite("BtnHighlight.......: " & $aColors[0])
    MemoWrite("BtnShadow..........: " & $aColors[1])

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Color Scheme")
    _GUICtrlRebar_SetColorScheme($hReBar, Int(0x00008B), Int(0xFFFFFF))

    MemoWrite(@CRLF & "========== Color Scheme ==========")
    $aColors = _GUICtrlRebar_GetColorScheme($hReBar)
    MemoWrite("BtnHighlight.......: " & $aColors[0])
    MemoWrite("BtnShadow..........: " & $aColors[1])

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetTextColor

Function Reference

_GUICtrlRebar_SetTextColor

Sets a rebar control's default text color

#include <GuiReBar.au3>
_GUICtrlRebar_SetTextColor ( $hWnd, $iColor )

Parameters

$hWnd | Handle to the rebar control
$iColor | COLORREF value that represents the new default text color

Return Value

Returns a COLORREF value that represents the previous default text color.

Related

_GUICtrlRebar_GetTextColor

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)

    MemoWrite("========== Bar Color ==========")
    MemoWrite("Previous BK Color..: " & _GUICtrlRebar_SetBKColor($hReBar, Int(0x00008B)))
    MemoWrite("BK Color...........: " & _GUICtrlRebar_GetBKColor($hReBar))
    MemoWrite("Previous Text Color: " & _GUICtrlRebar_SetTextColor($hReBar, Int(0xFFFFFF)))
    MemoWrite("Text Color.........: " & _GUICtrlRebar_GetTextColor($hReBar))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetToolTips

Function Reference

_GUICtrlRebar_SetToolTips

Associates a ToolTip control with the rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_SetToolTips ( $hWnd, $hToolTip )

Parameters

$hWnd | Handle to the rebar control
$hToolTip | Handle to the ToolTip control to be set

Return Value

None.

Related

_GUICtrlRebar_GetToolTips

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <GuiToolTip.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput, $hToolTip
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)

    $hToolTip = _GUIToolTip_Create($hReBar)

    MemoWrite("ToolTips Handle: " & _GUICtrlRebar_GetToolTips($hReBar))

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting ToolTips Handle")
    _GUICtrlRebar_SetToolTips($hReBar, $hToolTip)

    MemoWrite("ToolTips Handle: " & _GUICtrlRebar_GetToolTips($hReBar))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_SetUnicodeFormat

Function Reference

_GUICtrlRebar_SetUnicodeFormat

Sets the Unicode character format flag for the control

#include <GuiReBar.au3>
_GUICtrlRebar_SetUnicodeFormat ( $hWnd [, $bUnicode = True] )

Parameters

$hWnd | Handle to the rebar control
$bUnicode | [optional] Determines the character set that is used by the control: True - The control will use Unicode characters False - The control will use ANSI characters

Return Value

None.

Related

_GUICtrlRebar_GetUnicodeFormat

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    _GUICtrlRebar_SetBandStyleBreak($hReBar, 1)

    MemoWrite("Unicode: " & _GUICtrlRebar_GetUnicodeFormat($hReBar))

    MsgBox($MB_SYSTEMMODAL, "Information", "Setting Unicode")
    _GUICtrlRebar_SetUnicodeFormat($hReBar)

    MemoWrite("Unicode: " & _GUICtrlRebar_GetUnicodeFormat($hReBar))

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlRebar_ShowBand

Function Reference

_GUICtrlRebar_ShowBand

Shows or hides a given band in a rebar control

#include <GuiReBar.au3>
_GUICtrlRebar_ShowBand ( $hWnd, $iIndex [, $bShow = True] )

Parameters

$hWnd | Handle to the rebar control
$iIndex | 0-based index of the band
$bShow | [optional] indicates if the band should be shown or hidden: True - Show False - Hide

Return Value

None.

Related

_GUICtrlRebar_SetBandStyleHidden

Example

#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGui, $idBtnExit, $hReBar, $hToolbar, $idInput
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    $hGui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 100, 396, 250, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolbar_Create($hGui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; create a input box to put in the rebar
    $idInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

    ;add band containing the control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "Name:")

    ; add band containing the control to the beginning of rebar
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    $idBtnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUICtrlSetState($idBtnExit, $GUI_DEFBUTTON)
    GUICtrlSetState($idBtnExit, $GUI_FOCUS)

    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Hide Band using _GUICtrlRebar_ShowBand")
    _GUICtrlRebar_ShowBand($hReBar, 0, False)

    MsgBox($MB_SYSTEMMODAL, "Information", "Show Band using _GUICtrlRebar_ShowBand")
    _GUICtrlRebar_ShowBand($hReBar, 0)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idBtnExit
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


User Defined Functions

GuiRichEdit user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiRichEdit.au3>.

User Defined Function | Description
_GUICtrlRichEdit_AppendText | Appends text at the end of the client area
_GUICtrlRichEdit_AutoDetectURL | Enables or disables automatic detection of URLS
_GUICtrlRichEdit_CanPaste | Can the contents of the clipboard be pasted into the control?
_GUICtrlRichEdit_CanPasteSpecial | Can the contents of the clipboard be pasted into the control in both formats?
_GUICtrlRichEdit_CanRedo | Can an undone action be redone?
_GUICtrlRichEdit_CanUndo | Can an action be undone?
_GUICtrlRichEdit_ChangeFontSize | Increment or decrement font size(s) of selected text
_GUICtrlRichEdit_Copy | Copy text to clipboard
_GUICtrlRichEdit_Create | Create an Edit control
_GUICtrlRichEdit_Cut | Cut text to clipboard
_GUICtrlRichEdit_Deselect | Deselects text, leaving none selected
_GUICtrlRichEdit_Destroy | Delete the Rich Edit control
_GUICtrlRichEdit_EmptyUndoBuffer | Resets the undo flag of the control
_GUICtrlRichEdit_FindText | Search for a text starting at insertion point or at anchor point of selection
_GUICtrlRichEdit_FindTextInRange | Search for a text in a range of inter-character positions
_GUICtrlRichEdit_GetBkColor | Gets the background color of the control
_GUICtrlRichEdit_GetCharAttributes | Returns attributes of selected text
_GUICtrlRichEdit_GetCharBkColor | Retrieves the background color of the selected text or, if none selected, of the character to the right of the insertion point
_GUICtrlRichEdit_GetCharColor | Retrieves the color of the selected text or, if none selected, of the character to the right of the insertion point
_GUICtrlRichEdit_GetCharPosFromXY | Gets inter-character position closest to a specified point in the client area
_GUICtrlRichEdit_GetCharPosOfNextWord | Gets inter-character position before the next word
_GUICtrlRichEdit_GetCharPosOfPreviousWord | Gets inter-character position before the Previous word
_GUICtrlRichEdit_GetCharWordBreakInfo | Gets inter-character position before the Previous word/
_GUICtrlRichEdit_GetFirstCharPosOnLine | Retrieves the inter-character position preceding the first character of a line
_GUICtrlRichEdit_GetFont | Gets the font attributes of a selection or, if no selection, at the insertion point
_GUICtrlRichEdit_GetLineCount | Retrieves the number of lines in a multi-line edit control
_GUICtrlRichEdit_GetLineLength | Retrieves the length of a line
_GUICtrlRichEdit_GetLineNumberFromCharPos | Retrieves the line number on which an inter-character position is found
_GUICtrlRichEdit_GetNextRedo | Retrieves the name or type ID of the next possible redo action
_GUICtrlRichEdit_GetNextUndo | Retrieves the name or type ID of the next possible Undo action
_GUICtrlRichEdit_GetNumberOfFirstVisibleLine | Gets number of the first line which is visible in the control
_GUICtrlRichEdit_GetParaAlignment | Gets the alignment of selected paragraph(s), or (if no selection) of the current paragraph
_GUICtrlRichEdit_GetParaAttributes | Gets the attributes of (first) selected paragraph or (if no selection) of the current paragraph
_GUICtrlRichEdit_GetParaBorder | Gets the border settings of (first) selected paragraph or (if no selection) of the current paragraph
_GUICtrlRichEdit_GetParaIndents | Gets the border indent settings of (first) selected paragraph or (if no selection) of the current paragraph
_GUICtrlRichEdit_GetParaNumbering | Gets the numbering style of (first) selected paragraph or (if no selection) of the current paragraph
_GUICtrlRichEdit_GetParaShading | Gets the shading settings of (first) selected paragraph or (if no selection) of the current paragraph
_GUICtrlRichEdit_GetParaSpacing | Gets the spacing settings of (first) selected paragraph or (if no selection) of the current paragraph
_GUICtrlRichEdit_GetParaTabStops | Gets the tabstops of (first) selected paragraph or (if no selection) of the current paragraph
_GUICtrlRichEdit_GetPasswordChar | Gets the password character that a rich edit control displays when the user enters text
_GUICtrlRichEdit_GetRECT | Retrieves the formatting rectangle of a control
_GUICtrlRichEdit_GetScrollPos | Gets the Scrolling position of the control
_GUICtrlRichEdit_GetSel | Gets the low and high inter-character positions of a selection
_GUICtrlRichEdit_GetSelAA | Gets the anchor and active inter-character positions of a selection, in that order
_GUICtrlRichEdit_GetSelText | Retrieves the currently selected text
_GUICtrlRichEdit_GetSpaceUnit | Gets the unit of measure of horizontal and vertical space used in parameters of various _GUICtrlRichEdit functions
_GUICtrlRichEdit_GetText | Get all of the text in the control
_GUICtrlRichEdit_GetTextInLine | Gets a line of text
_GUICtrlRichEdit_GetTextInRange | Gets the text from from one inter-character position to another
_GUICtrlRichEdit_GetTextLength | Get the length of the whole text in the control
_GUICtrlRichEdit_GetVersion | Retrieves the version of Rich Edit
_GUICtrlRichEdit_GetXYFromCharPos | Retrieves the XY coordinates of an inter-character position
_GUICtrlRichEdit_GetZoom | Gets the zoom level of the control
_GUICtrlRichEdit_GotoCharPos | Moves the insertion point to an inter-character position
_GUICtrlRichEdit_HideSelection | Hides (or shows) a selection
_GUICtrlRichEdit_InsertText | Inserts text at insertion point or anchor point of selection
_GUICtrlRichEdit_IsModified | Retrieves the state of a rich edit control's modification flag
_GUICtrlRichEdit_IsTextSelected | Is text selected?
_GUICtrlRichEdit_Paste | Paste RTF or RTF with Objects from clipboard
_GUICtrlRichEdit_PasteSpecial | Paste RTF or RTF and Objects from clipboard
_GUICtrlRichEdit_PauseRedraw | Pauses redrawing of the control
_GUICtrlRichEdit_Redo | Redoes last undone action
_GUICtrlRichEdit_ReplaceText | Replaces selected text
_GUICtrlRichEdit_ResumeRedraw | Resumes redrawing of the control
_GUICtrlRichEdit_ScrollLineOrPage | Scrolls the text down or up a line or a page
_GUICtrlRichEdit_ScrollLines | Scrolls the text down or up a number of lines
_GUICtrlRichEdit_ScrollToCaret | Scrolls to show line on which caret (insertion point) is
_GUICtrlRichEdit_SetBkColor | Sets the background color of the control
_GUICtrlRichEdit_SetCharAttributes | Turns an attribute on or off for selected text or, if none selected, for text inserted at the insertion point
_GUICtrlRichEdit_SetCharBkColor | Sets the background color of selected text or, if none selected, sets the background color of text inserted at the insertion point
_GUICtrlRichEdit_SetCharColor | Sets the color of selected text or, if none selected, sets the background color of text inserted at the insertion point
_GUICtrlRichEdit_SetEventMask | Specifies which notification messages are sent to the parent window
_GUICtrlRichEdit_SetFont | Sets the font attributes of selected text or, if none selected, sets those of text inserted at the insertion point
_GUICtrlRichEdit_SetLimitOnText | Change number of characters that can be typed, pasted or streamed in as Rich Text Format
_GUICtrlRichEdit_SetModified | Sets or clears the modification flag
_GUICtrlRichEdit_SetParaAlignment | Sets alignment of paragraph(s) in the current selection or, if no selection, of paragraphs inserted at the insertion point
_GUICtrlRichEdit_SetParaAttributes | Sets attributes of paragraph(s) in the current selection or, if no selection, of paragraphs inserted at the insertion point
_GUICtrlRichEdit_SetParaBorder | Sets the border of paragraph(s) in the current selection or, if no selection, of paragraphs inserted at the insertion point
_GUICtrlRichEdit_SetParaIndents | Sets indents of paragraph(s) in the current selection or, if no selection, of paragraphs inserted at the insertion point
_GUICtrlRichEdit_SetParaNumbering | Sets numbering of paragraph(s) in the current selection or, if no selection, of paragraph(s) inserted at the insertion point
_GUICtrlRichEdit_SetParaShading | Sets the shading of paragraph(s) in the current selection or, if no selection, of paragraphs inserted at the insertion point
_GUICtrlRichEdit_SetParaSpacing | Sets paragraph spacing of paragraphs having selected text or, if none selected, sets it for text inserted at the insertion point
_GUICtrlRichEdit_SetParaTabStops | Sets tab stops of paragraphs having selected text or, if none selected, sets it for text inserted at the insertion point
_GUICtrlRichEdit_SetPasswordChar | Sets the characters to be displayed instead of those typed, or causes typed characters to show
_GUICtrlRichEdit_SetReadOnly | Sets or removes the read-only state
_GUICtrlRichEdit_SetRECT | Sets the formatting rectangle of a Rich Edit control
_GUICtrlRichEdit_SetScrollPos | Scrolls the display such that ($ix,$iY) is in the upper left corner of the control
_GUICtrlRichEdit_SetSel | Sets the low and high character position of a selection
_GUICtrlRichEdit_SetSpaceUnit | Sets the unit of measure of horizontal and vertical space used in parameters of various _GUICtrlRichEdit functions
_GUICtrlRichEdit_SetTabStops | Sets tab stops for the control
_GUICtrlRichEdit_SetText | Sets the text of a control
_GUICtrlRichEdit_SetUndoLimit | Sets the maximum number of actions that can stored in the undo queue
_GUICtrlRichEdit_SetZoom | Sets zoom level of the control
_GUICtrlRichEdit_StreamFromFile | Sets text in a control from a file
_GUICtrlRichEdit_StreamFromVar | Sets text in a control from a variable
_GUICtrlRichEdit_StreamToFile | Writes contents of a control to a file
_GUICtrlRichEdit_StreamToVar | Writes contents of a control to a variable
_GUICtrlRichEdit_Undo | Undoes the last edit control operation in the control's undo queue


Function _GUICtrlRichEdit_AppendText

Function Reference

_GUICtrlRichEdit_AppendText

Appends text at the end of the client area

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_AppendText ( $hWnd, $sText )

Parameters

$hWnd | Handle to the control
$sText | Text to be appended

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Related

_GUICtrlRichEdit_GetText, _GUICtrlRichEdit_InsertText, _GUICtrlRichEdit_ReplaceText, _GUICtrlRichEdit_SetText

See Also

Search EM_SETTEXTEX in MSDN Library.

Example

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

Example()

Func Example()
    Local $hGui, $hRichEdit, $iMsg
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)
    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is appended text.")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRichEdit_AutoDetectURL

Function Reference

_GUICtrlRichEdit_AutoDetectURL

Enables or disables automatic detection of URLS

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_AutoDetectURL ( $hWnd, $bState )

Parameters

$hWnd | Handle to the control
$bState | True to detect URLs in text, False not to

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $bState is neither True nor False 700 - internal error, e.g. insufficient memory

Remarks

If enabled, any modified text is scanned for text that matches the format of a URL.
It recognizes strings starting with the following as:
URLs: http:, file:, mailto:, ftp:, https:, gopher:, nntp:, prospero:, telnet:, news:, wais:.

When a URL is detected, Windows sets the link attribute for all characters in the URL string, and highlights the string.

When automatic URL detection is on and a URL is detected, Windows removes the link attribute of all characters that are not URLs.

For notification to happen, call _GUICtrlRichEdit_SetEventMask() with $ENM_LINK

Related

_GUICtrlRichEdit_SetEventMask

See Also

Search EM_AUTOURLDETECT in MSDN Library. Search EN_LINK in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_LINK)

    _GUICtrlRichEdit_AutoDetectURL($g_hRichEdit, True)
    _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "http://www.autoitscript.com")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $tEnLink, $iCpMin, $iCpMax, $tMsgFilter
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hRichEdit
            Select
                Case $iCode = $EN_LINK
                    $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_LBUTTONUP Then
                        $tEnLink = DllStructCreate($tagENLINK, $lParam)
                        $iCpMin = DllStructGetData($tEnLink, "cpMin")
                        $iCpMax = DllStructGetData($tEnLink, "cpMax")
                        MsgBox($MB_SYSTEMMODAL, "", "Invoke your web browser here and point it to " & _
                                _GUICtrlRichEdit_GetTextInRange($g_hRichEdit, $iCpMin, $iCpMax))
                    EndIf
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY


Function _GUICtrlRichEdit_CanPaste

Function Reference

_GUICtrlRichEdit_CanPaste

Can the contents of the clipboard be pasted into the control?

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_CanPaste ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True or False.
Failure: | sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Remarks

Data in two clipboard formats can be pasted: RTF and RTF with Objects.
This function determines whether data in either format is on the clipboard.

Related

_GUICtrlRichEdit_Paste

See Also

Search EM_CANPASTE in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_hRichEdit, $g_idMnu, $g_idMnuUndo, $g_idMnuRedo, $g_idMnuCut, $g_idMnuCopy
Global $g_idMnuPaste, $g_idMnuPasteSpl

Example()

Func Example()
    Local $hGui, $idMnuPasteSplRTF, $idMnuPasteSplwObjs
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($g_hRichEdit, ReadBmpToRtf(FindFirstBMP()))

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    $g_idMnu = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
    $g_idMnuUndo = GUICtrlCreateMenuItem("Undo", $g_idMnu)
    $g_idMnuRedo = GUICtrlCreateMenuItem("Redo", $g_idMnu)
    GUICtrlCreateMenuItem("", $g_idMnu)
    $g_idMnuCut = GUICtrlCreateMenuItem("Cut", $g_idMnu)
    $g_idMnuCopy = GUICtrlCreateMenuItem("Copy", $g_idMnu)
    $g_idMnuPaste = GUICtrlCreateMenuItem("Paste", $g_idMnu)
    $g_idMnuPasteSpl = GUICtrlCreateMenu("Paste Special", $g_idMnu)
    $idMnuPasteSplRTF = GUICtrlCreateMenuItem("RTF only", $g_idMnuPasteSpl)
    $idMnuPasteSplwObjs = GUICtrlCreateMenuItem("With objects", $g_idMnuPasteSpl)
    _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_MOUSEEVENTS)

    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $g_idMnuUndo
                _GUICtrlRichEdit_Undo($g_hRichEdit)
            Case $g_idMnuRedo
                _GUICtrlRichEdit_Redo($g_hRichEdit)
            Case $g_idMnuCut
                _GUICtrlRichEdit_Cut($g_hRichEdit)
            Case $g_idMnuCopy
                _GUICtrlRichEdit_Copy($g_hRichEdit)
            Case $g_idMnuPaste
                _GUICtrlRichEdit_Paste($g_hRichEdit)
            Case $idMnuPasteSplRTF
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, False)
            Case $idMnuPasteSplwObjs
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, True)
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hRichEdit
            Select
                Case $iCode = $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_RBUTTONUP Then
                        $hMenu = GUICtrlGetHandle($g_idMnu)
                        SetMenuTexts($hWndFrom, $hMenu)
                        _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    EndIf
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func SetMenuTexts($hWnd, $hMenu)
    Local $bState
    If _GUICtrlRichEdit_CanUndo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo: " & _GUICtrlRichEdit_GetNextUndo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, False, False)
    EndIf
    If _GUICtrlRichEdit_CanRedo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo: " & _GUICtrlRichEdit_GetNextRedo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, False, False)
    EndIf
    $bState = _GUICtrlRichEdit_IsTextSelected($hWnd)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCut, $bState, False)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCopy, $bState, False)

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPaste, _GUICtrlRichEdit_CanPaste($hWnd))

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPasteSpl, _GUICtrlRichEdit_CanPasteSpecial($hWnd), False)
EndFunc   ;==>SetMenuTexts

Func ReadBmpToRtf($sBmpFilspc)
    Local $hFile, $sRtf
    $hFile = FileOpen($sBmpFilspc, $FO_BINARY)
    If FileRead($hFile, 2) <> "0x424D" Then Return SetError(1, 0, "")
    FileRead($hFile, 12)
    $sRtf = '{\rtf1{\pict\dibitmap ' & Hex(FileRead($hFile)) & '}}'
    FileClose($hFile)
    Return $sRtf
EndFunc   ;==>ReadBmpToRtf

Func FindFirstBMP($sPath = Default)
    If $sPath = Default Then
        ; X64 running support
        Local $sWow64 = ""
        If @AutoItX64 Then $sWow64 = "\Wow6432Node"

        $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images"
    EndIf
    Local $hFind, $sBmpFilspc
    $hFind = FileFindFirstFile($sPath & "\*.bmp")
    $sBmpFilspc = FileFindNextFile($hFind)
    FileClose($hFind)
    Return $sPath & "\" & $sBmpFilspc
EndFunc   ;==>FindFirstBMP


Function _GUICtrlRichEdit_CanPasteSpecial

Function Reference

_GUICtrlRichEdit_CanPasteSpecial

Can the contents of the clipboard be pasted into the control in both formats?

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_CanPasteSpecial ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True or False.
Failure: | sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Remarks

Data in two clipboard formats can be pasted: RTF and RTF with Objects.
This function determines whether data in both formats is on the clipboard.

Related

_GUICtrlRichEdit_PasteSpecial

See Also

Search EM_CANPASTE in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_hRichEdit, $g_idMnu, $g_idMnuUndo, $g_idMnuRedo, $g_idMnuCut, $g_idMnuCopy
Global $g_idMnuPaste, $g_idMnuPasteSpl

Example()

Func Example()
    Local $hGui, $idMnuPasteSplRTF, $idMnuPasteSplwObjs
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($g_hRichEdit, ReadBmpToRtf(FindFirstBMP()) & @CRLF)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    $g_idMnu = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
    $g_idMnuUndo = GUICtrlCreateMenuItem("Undo", $g_idMnu)
    $g_idMnuRedo = GUICtrlCreateMenuItem("Redo", $g_idMnu)
    GUICtrlCreateMenuItem("", $g_idMnu)
    $g_idMnuCut = GUICtrlCreateMenuItem("Cut", $g_idMnu)
    $g_idMnuCopy = GUICtrlCreateMenuItem("Copy", $g_idMnu)
    $g_idMnuPaste = GUICtrlCreateMenuItem("Paste", $g_idMnu)
    $g_idMnuPasteSpl = GUICtrlCreateMenu("Paste Special", $g_idMnu)
    $idMnuPasteSplRTF = GUICtrlCreateMenuItem("RTF only", $g_idMnuPasteSpl)
    $idMnuPasteSplwObjs = GUICtrlCreateMenuItem("With objects", $g_idMnuPasteSpl)
    _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_MOUSEEVENTS)

    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $g_idMnuUndo
                _GUICtrlRichEdit_Undo($g_hRichEdit)
            Case $g_idMnuRedo
                _GUICtrlRichEdit_Redo($g_hRichEdit)
            Case $g_idMnuCut
                _GUICtrlRichEdit_Cut($g_hRichEdit)
            Case $g_idMnuCopy
                _GUICtrlRichEdit_Copy($g_hRichEdit)
            Case $g_idMnuPaste
                _GUICtrlRichEdit_Paste($g_hRichEdit)
            Case $idMnuPasteSplRTF
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, False)
            Case $idMnuPasteSplwObjs
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, True)
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hRichEdit
            Select
                Case $iCode = $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_RBUTTONUP Then
                        $hMenu = GUICtrlGetHandle($g_idMnu)
                        SetMenuTexts($hWndFrom, $hMenu)
                        _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    EndIf
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func SetMenuTexts($hWnd, $hMenu)
    Local $fState
    If _GUICtrlRichEdit_CanUndo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo: " & _GUICtrlRichEdit_GetNextUndo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, False, False)
    EndIf
    If _GUICtrlRichEdit_CanRedo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo: " & _GUICtrlRichEdit_GetNextRedo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, False, False)
    EndIf
    $fState = _GUICtrlRichEdit_IsTextSelected($hWnd)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCut, $fState, False)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCopy, $fState, False)

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPaste, _GUICtrlRichEdit_CanPaste($hWnd))

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPasteSpl, _GUICtrlRichEdit_CanPasteSpecial($hWnd), False)
EndFunc   ;==>SetMenuTexts

Func ReadBmpToRtf($sBmpFilspc)
    Local $hFile, $sRtf
    $hFile = FileOpen($sBmpFilspc, 16)
    If FileRead($hFile, 2) <> "0x424D" Then Return SetError(1, 0, "")
    FileRead($hFile, 12)
    $sRtf = '{\rtf1{\pict\dibitmap ' & Hex(FileRead($hFile)) & '}}'
    FileClose($hFile)
    Return $sRtf
EndFunc   ;==>ReadBmpToRtf

Func FindFirstBMP($sPath = @WindowsDir)
    Local $hFind, $sBmpFilspc
    $hFind = FileFindFirstFile($sPath & "\*.bmp")
    $sBmpFilspc = FileFindNextFile($hFind)
    FileClose($hFind)
    Return $sPath & "\" & $sBmpFilspc
EndFunc   ;==>FindFirstBMP


Function _GUICtrlRichEdit_CanRedo

Function Reference

_GUICtrlRichEdit_CanRedo

Can an undone action be redone?

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_CanRedo ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True or False.
Failure: | sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Related

_GUICtrlRichEdit_Redo, _GUICtrlRichEdit_SetUndoLimit

See Also

Search EM_CANREDO in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_hRichEdit, $g_idMnu, $g_idMnuUndo, $g_idMnuRedo, $g_idMnuCut, $g_idMnuCopy
Global $g_idMnuPaste, $g_idMnuPasteSpl

Example()

Func Example()
    Local $hGui, $idMnuPasteSplRTF, $idMnuPasteSplwObjs
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($g_hRichEdit, ReadBmpToRtf(FindFirstBMP()))

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    $g_idMnu = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
    $g_idMnuUndo = GUICtrlCreateMenuItem("Undo", $g_idMnu)
    $g_idMnuRedo = GUICtrlCreateMenuItem("Redo", $g_idMnu)
    GUICtrlCreateMenuItem("", $g_idMnu)
    $g_idMnuCut = GUICtrlCreateMenuItem("Cut", $g_idMnu)
    $g_idMnuCopy = GUICtrlCreateMenuItem("Copy", $g_idMnu)
    $g_idMnuPaste = GUICtrlCreateMenuItem("Paste", $g_idMnu)
    $g_idMnuPasteSpl = GUICtrlCreateMenu("Paste Special", $g_idMnu)
    $idMnuPasteSplRTF = GUICtrlCreateMenuItem("RTF only", $g_idMnuPasteSpl)
    $idMnuPasteSplwObjs = GUICtrlCreateMenuItem("With objects", $g_idMnuPasteSpl)
    _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_MOUSEEVENTS)

    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $g_idMnuUndo
                _GUICtrlRichEdit_Undo($g_hRichEdit)
            Case $g_idMnuRedo
                _GUICtrlRichEdit_Redo($g_hRichEdit)
            Case $g_idMnuCut
                _GUICtrlRichEdit_Cut($g_hRichEdit)
            Case $g_idMnuCopy
                _GUICtrlRichEdit_Copy($g_hRichEdit)
            Case $g_idMnuPaste
                _GUICtrlRichEdit_Paste($g_hRichEdit)
            Case $idMnuPasteSplRTF
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, False)
            Case $idMnuPasteSplwObjs
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, True)
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hRichEdit
            Select
                Case $iCode = $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_RBUTTONUP Then
                        $hMenu = GUICtrlGetHandle($g_idMnu)
                        SetMenuTexts($hWndFrom, $hMenu)
                        _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    EndIf
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func SetMenuTexts($hWnd, $hMenu)
    Local $bState
    If _GUICtrlRichEdit_CanUndo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo: " & _GUICtrlRichEdit_GetNextUndo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, False, False)
    EndIf
    If _GUICtrlRichEdit_CanRedo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo: " & _GUICtrlRichEdit_GetNextRedo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, False, False)
    EndIf
    $bState = _GUICtrlRichEdit_IsTextSelected($hWnd)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCut, $bState, False)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCopy, $bState, False)

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPaste, _GUICtrlRichEdit_CanPaste($hWnd))

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPasteSpl, _GUICtrlRichEdit_CanPasteSpecial($hWnd), False)
EndFunc   ;==>SetMenuTexts

Func ReadBmpToRtf($sBmpFilspc)
    Local $hFile, $sRtf
    $hFile = FileOpen($sBmpFilspc, $FO_BINARY)
    If FileRead($hFile, 2) <> "0x424D" Then Return SetError(1, 0, "")
    FileRead($hFile, 12)
    $sRtf = '{\rtf1{\pict\dibitmap ' & Hex(FileRead($hFile)) & '}}'
    FileClose($hFile)
    Return $sRtf
EndFunc   ;==>ReadBmpToRtf

Func FindFirstBMP($sPath = Default)
    If $sPath = Default Then
        ; X64 running support
        Local $sWow64 = ""
        If @AutoItX64 Then $sWow64 = "\Wow6432Node"

        $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images"
    EndIf
    Local $hFind, $sBmpFilspc
    $hFind = FileFindFirstFile($sPath & "\*.bmp")
    $sBmpFilspc = FileFindNextFile($hFind)
    FileClose($hFind)
    Return $sPath & "\" & $sBmpFilspc
EndFunc   ;==>FindFirstBMP


Function _GUICtrlRichEdit_CanUndo

Function Reference

_GUICtrlRichEdit_CanUndo

Can an action be undone?

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_CanUndo ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True, there are action(s) in the undo queue.
Failure: | False and may sets the @error flag to non-zero.
@error: | 0 - there are no actions in the undo queue 101 - $hWnd is not a handle

Related

_GUICtrlRichEdit_SetUndoLimit, _GUICtrlRichEdit_Undo

See Also

Search EM_CANUNDO in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_hRichEdit, $g_idMnu, $g_idMnuUndo, $g_idMnuRedo, $g_idMnuCut, $g_idMnuCopy
Global $g_idMnuPaste, $g_idMnuPasteSpl

Example()

Func Example()
    Local $hGui, $idMnuPasteSplRTF, $idMnuPasteSplwObjs
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($g_hRichEdit, ReadBmpToRtf(FindFirstBMP()))

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    $g_idMnu = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
    $g_idMnuUndo = GUICtrlCreateMenuItem("Undo", $g_idMnu)
    $g_idMnuRedo = GUICtrlCreateMenuItem("Redo", $g_idMnu)
    GUICtrlCreateMenuItem("", $g_idMnu)
    $g_idMnuCut = GUICtrlCreateMenuItem("Cut", $g_idMnu)
    $g_idMnuCopy = GUICtrlCreateMenuItem("Copy", $g_idMnu)
    $g_idMnuPaste = GUICtrlCreateMenuItem("Paste", $g_idMnu)
    $g_idMnuPasteSpl = GUICtrlCreateMenu("Paste Special", $g_idMnu)
    $idMnuPasteSplRTF = GUICtrlCreateMenuItem("RTF only", $g_idMnuPasteSpl)
    $idMnuPasteSplwObjs = GUICtrlCreateMenuItem("With objects", $g_idMnuPasteSpl)
    _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_MOUSEEVENTS)

    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $g_idMnuUndo
                _GUICtrlRichEdit_Undo($g_hRichEdit)
            Case $g_idMnuRedo
                _GUICtrlRichEdit_Redo($g_hRichEdit)
            Case $g_idMnuCut
                _GUICtrlRichEdit_Cut($g_hRichEdit)
            Case $g_idMnuCopy
                _GUICtrlRichEdit_Copy($g_hRichEdit)
            Case $g_idMnuPaste
                _GUICtrlRichEdit_Paste($g_hRichEdit)
            Case $idMnuPasteSplRTF
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, False)
            Case $idMnuPasteSplwObjs
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, True)
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hRichEdit
            Select
                Case $iCode = $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_RBUTTONUP Then
                        $hMenu = GUICtrlGetHandle($g_idMnu)
                        SetMenuTexts($hWndFrom, $hMenu)
                        _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    EndIf
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func SetMenuTexts($hWnd, $hMenu)
    Local $bState
    If _GUICtrlRichEdit_CanUndo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo: " & _GUICtrlRichEdit_GetNextUndo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, False, False)
    EndIf
    If _GUICtrlRichEdit_CanRedo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo: " & _GUICtrlRichEdit_GetNextRedo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, False, False)
    EndIf
    $bState = _GUICtrlRichEdit_IsTextSelected($hWnd)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCut, $bState, False)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCopy, $bState, False)

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPaste, _GUICtrlRichEdit_CanPaste($hWnd))

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPasteSpl, _GUICtrlRichEdit_CanPasteSpecial($hWnd), False)
EndFunc   ;==>SetMenuTexts

Func ReadBmpToRtf($sBmpFilspc)
    Local $hFile, $sRtf
    $hFile = FileOpen($sBmpFilspc, $FO_BINARY)
    If FileRead($hFile, 2) <> "0x424D" Then Return SetError(1, 0, "")
    FileRead($hFile, 12)
    $sRtf = '{\rtf1{\pict\dibitmap ' & Hex(FileRead($hFile)) & '}}'
    FileClose($hFile)
    Return $sRtf
EndFunc   ;==>ReadBmpToRtf

Func FindFirstBMP($sPath = Default)
    If $sPath = Default Then
        ; X64 running support
        Local $sWow64 = ""
        If @AutoItX64 Then $sWow64 = "\Wow6432Node"

        $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images"
    EndIf
    Local $hFind, $sBmpFilspc
    $hFind = FileFindFirstFile($sPath & "\*.bmp")
    $sBmpFilspc = FileFindNextFile($hFind)
    FileClose($hFind)
    Return $sPath & "\" & $sBmpFilspc
EndFunc   ;==>FindFirstBMP


Function _GUICtrlRichEdit_ChangeFontSize

Function Reference

_GUICtrlRichEdit_ChangeFontSize

Increment or decrement font size(s) of selected text

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_ChangeFontSize ( $hWnd, $iIncrement )

Parameters

$hWnd | Handle to the control
$iIncrement | Positive to increase, negative to decrease

Return Value

Succcess: | True, Font sizes were changed.
Failure: | False and may sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $iIncrement is not a number -1 - no text selected

Remarks

If there are several font sizes in the selected text, all are incremented/decremented.

For $iIncrement positive, font sizes are rounded up; for $iIncrement negative, they are rounded down.

Rich Edit first adds $iIncrement to the existing font size. It then rounds up (or down) as follows:
<= 12 points: 1 e.g. 7 + 1 => 8 points, 14 - 3 => 10 points
12.05 to 28 points: 20 + 2.25 => 24 points
28.05 to 80 points: rounded to next of 28, 36, 48, 72 or 80, e.g. 28 + 1 => 36 points, 80 - 1 => 72 points
> 80 points: 10, e.g. 80 + 1 => 90

Related

_GUICtrlRichEdit_SetFont

See Also

Search EM_SETFONTSIZE in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnDoIt
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnDoIt = GUICtrlCreateButton("Do it", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, -1) ; select all

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnDoIt
                ChangeFontSize()
        EndSelect
    WEnd
EndFunc   ;==>Example

Func ChangeFontSize()
    Local $avArray, $iOld, $iNew
    $avArray = _GUICtrlRichEdit_GetFont($g_hRichEdit)
    $iOld = $avArray[0]
    _GUICtrlRichEdit_ChangeFontSize($g_hRichEdit, 2)
    $avArray = _GUICtrlRichEdit_GetFont($g_hRichEdit)
    $iNew = $avArray[0]
    Report("Was " & $iOld & " points; is now " & $iNew & " points")
EndFunc   ;==>ChangeFontSize

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_Copy

Function Reference

_GUICtrlRichEdit_Copy

Copy text to clipboard

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_Copy ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Related

_GUICtrlRichEdit_Cut, _GUICtrlRichEdit_Paste, _GUICtrlRichEdit_PasteSpecial

See Also

Search WM_COPY in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_hRichEdit, $g_idMnu, $g_idMnuUndo, $g_idMnuRedo, $g_idMnuCut, $g_idMnuCopy
Global $g_idMnuPaste, $g_idMnuPasteSpl

Example()

Func Example()
    Local $hGui, $idMnuPasteSplRTF, $idMnuPasteSplwObjs
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($g_hRichEdit, ReadBmpToRtf(FindFirstBMP()) & @CRLF)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    $g_idMnu = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
    $g_idMnuUndo = GUICtrlCreateMenuItem("Undo", $g_idMnu)
    $g_idMnuRedo = GUICtrlCreateMenuItem("Redo", $g_idMnu)
    GUICtrlCreateMenuItem("", $g_idMnu)
    $g_idMnuCut = GUICtrlCreateMenuItem("Cut", $g_idMnu)
    $g_idMnuCopy = GUICtrlCreateMenuItem("Copy", $g_idMnu)
    $g_idMnuPaste = GUICtrlCreateMenuItem("Paste", $g_idMnu)
    $g_idMnuPasteSpl = GUICtrlCreateMenu("Paste Special", $g_idMnu)
    $idMnuPasteSplRTF = GUICtrlCreateMenuItem("RTF only", $g_idMnuPasteSpl)
    $idMnuPasteSplwObjs = GUICtrlCreateMenuItem("With objects", $g_idMnuPasteSpl)
    _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_MOUSEEVENTS)

    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $g_idMnuUndo
                _GUICtrlRichEdit_Undo($g_hRichEdit)
            Case $g_idMnuRedo
                _GUICtrlRichEdit_Redo($g_hRichEdit)
            Case $g_idMnuCut
                _GUICtrlRichEdit_Cut($g_hRichEdit)
            Case $g_idMnuCopy
                _GUICtrlRichEdit_Copy($g_hRichEdit)
            Case $g_idMnuPaste
                _GUICtrlRichEdit_Paste($g_hRichEdit)
            Case $idMnuPasteSplRTF
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, False)
            Case $idMnuPasteSplwObjs
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, True)
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hRichEdit
            Select
                Case $iCode = $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_RBUTTONUP Then
                        $hMenu = GUICtrlGetHandle($g_idMnu)
                        _SetMenuTexts($hWndFrom, $hMenu)
                        _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    EndIf
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _SetMenuTexts($hWnd, $hMenu)
    Local $bState
    If _GUICtrlRichEdit_CanUndo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo: " & _GUICtrlRichEdit_GetNextUndo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, False, False)
    EndIf
    If _GUICtrlRichEdit_CanRedo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo: " & _GUICtrlRichEdit_GetNextRedo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, False, False)
    EndIf
    $bState = _GUICtrlRichEdit_IsTextSelected($hWnd)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCut, $bState, False)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCopy, $bState, False)

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPaste, _GUICtrlRichEdit_CanPaste($hWnd))

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPasteSpl, _GUICtrlRichEdit_CanPasteSpecial($hWnd), False)
EndFunc   ;==>_SetMenuTexts

Func ReadBmpToRtf($sBmpFilspc)
    Local $hFile, $sRtf
    $hFile = FileOpen($sBmpFilspc, 16)
    If FileRead($hFile, 2) <> "0x424D" Then Return SetError(1, 0, "")
    FileRead($hFile, 12)
    $sRtf = '{\rtf1{\pict\dibitmap ' & Hex(FileRead($hFile)) & '}}'
    FileClose($hFile)
    Return $sRtf
EndFunc   ;==>ReadBmpToRtf

Func FindFirstBMP($sPath = @WindowsDir)
    Local $hFind, $sBmpFilspc
    $hFind = FileFindFirstFile($sPath & "\*.bmp")
    $sBmpFilspc = FileFindNextFile($hFind)
    FileClose($hFind)
    Return $sPath & "\" & $sBmpFilspc
EndFunc   ;==>FindFirstBMP


Function _GUICtrlRichEdit_Create

Function Reference

_GUICtrlRichEdit_Create

Create an Edit control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_Create ( $hWnd, $sText, $iLeft, $iTop [, $iWidth = 150 [, $iHeight = 150 [, $iStyle = -1 [, $iExStyle = -1]]]] )

Parameters

$hWnd | Handle to parent or owner window
$sText | Text to be displayed in the control
$iLeft | Horizontal position of the control
$iTop | Vertical position of the control
$iWidth | [optional] Control width
$iHeight | [optional] Control height
$iStyle [optional] Control styles:
$ES_AUTOHSCROLL - Automatically scrolls text to the right by 10 characters when the user types a character at the end of the line.
$ES_AUTOVSCROLL - Automatically scrolls text up one page when the user presses the ENTER key on the last line.
$WS_HSCROLL - Control has horizontal scroll bar
$WS_VSCROLL - Control has vertical scroll bar
$ES_CENTER - Centers text in an edit control.
$ES_LEFT - Aligns text with the left margin.
$ES_MULTILINE - Generates a multi-line control (Default)
$ES_NOHIDESEL - The selected text is inverted, even if the control does not have the focus.
$ES_NUMBER - Allows only digits to be entered into the edit control.
$ES_READONLY - Prevents the user from typing or editing text in the edit control.
$ES_RIGHT - Right-aligns text edit control.
$ES_WANTRETURN - Specifies that a carriage return be inserted when the user presses the ENTER key. (Default)
$ES_PASSWORD - Displays an asterisk (*) for each character that is typed into the edit control

Default: 0
Forced : WS_CHILD, $WS_VISIBLE, $WS_TABSTOP unless $ES_READONLY
$iExStyle | [optional] Control extended style. These correspond to the standard $WS_EX_* constants. See Extended Style Table.

Return Value

Success: | the handle to the Rich Edit control.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 105 - $iWidth is neither a positive number nor -1 106 - $iHeight is neither a positive number nor -1 107 - $iStyle is is neither a positive number nor zero nor -1 108 - $iExStyle is is neither a positive number nor zero nor -1

Related

_GUICtrlRichEdit_Destroy

Example

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

Example()

Func Example()
    Local $hGui, $hRichEdit, $iMsg
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is more text")
    GUISetState(@SW_SHOW)

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRichEdit_Cut

Function Reference

_GUICtrlRichEdit_Cut

Cut text to clipboard

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_Cut ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Related

_GUICtrlRichEdit_Copy, _GUICtrlRichEdit_Paste, _GUICtrlRichEdit_PasteSpecial

See Also

Search WM_CUT in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_hRichEdit, $g_idMnu, $g_idMnuUndo, $g_idMnuRedo, $g_idMnuCut, $g_idMnuCopy
Global $g_idMnuPaste, $g_idMnuPasteSpl

Example()

Func Example()
    Local $hGui, $idMnuPasteSplRTF, $idMnuPasteSplwObjs
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($g_hRichEdit, ReadBmpToRtf(FindFirstBMP()) & @CRLF)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    $g_idMnu = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
    $g_idMnuUndo = GUICtrlCreateMenuItem("Undo", $g_idMnu)
    $g_idMnuRedo = GUICtrlCreateMenuItem("Redo", $g_idMnu)
    GUICtrlCreateMenuItem("", $g_idMnu)
    $g_idMnuCut = GUICtrlCreateMenuItem("Cut", $g_idMnu)
    $g_idMnuCopy = GUICtrlCreateMenuItem("Copy", $g_idMnu)
    $g_idMnuPaste = GUICtrlCreateMenuItem("Paste", $g_idMnu)
    $g_idMnuPasteSpl = GUICtrlCreateMenu("Paste Special", $g_idMnu)
    $idMnuPasteSplRTF = GUICtrlCreateMenuItem("RTF only", $g_idMnuPasteSpl)
    $idMnuPasteSplwObjs = GUICtrlCreateMenuItem("With objects", $g_idMnuPasteSpl)
    _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_MOUSEEVENTS)

    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $g_idMnuUndo
                _GUICtrlRichEdit_Undo($g_hRichEdit)
            Case $g_idMnuRedo
                _GUICtrlRichEdit_Redo($g_hRichEdit)
            Case $g_idMnuCut
                _GUICtrlRichEdit_Cut($g_hRichEdit)
            Case $g_idMnuCopy
                _GUICtrlRichEdit_Copy($g_hRichEdit)
            Case $g_idMnuPaste
                _GUICtrlRichEdit_Paste($g_hRichEdit)
            Case $idMnuPasteSplRTF
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, False)
            Case $idMnuPasteSplwObjs
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, True)
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hRichEdit
            Select
                Case $iCode = $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_RBUTTONUP Then
                        $hMenu = GUICtrlGetHandle($g_idMnu)
                        _SetMenuTexts($hWndFrom, $hMenu)
                        _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    EndIf
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _SetMenuTexts($hWnd, $hMenu)
    Local $bState
    If _GUICtrlRichEdit_CanUndo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo: " & _GUICtrlRichEdit_GetNextUndo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, False, False)
    EndIf
    If _GUICtrlRichEdit_CanRedo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo: " & _GUICtrlRichEdit_GetNextRedo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, False, False)
    EndIf
    $bState = _GUICtrlRichEdit_IsTextSelected($hWnd)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCut, $bState, False)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCopy, $bState, False)

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPaste, _GUICtrlRichEdit_CanPaste($hWnd))

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPasteSpl, _GUICtrlRichEdit_CanPasteSpecial($hWnd), False)
EndFunc   ;==>_SetMenuTexts

Func ReadBmpToRtf($sBmpFilspc)
    Local $hFile, $sRtf
    $hFile = FileOpen($sBmpFilspc, 16)
    If FileRead($hFile, 2) <> "0x424D" Then Return SetError(1, 0, "")
    FileRead($hFile, 12)
    $sRtf = '{\rtf1{\pict\dibitmap ' & Hex(FileRead($hFile)) & '}}'
    FileClose($hFile)
    Return $sRtf
EndFunc   ;==>ReadBmpToRtf

Func FindFirstBMP($sPath = @WindowsDir)
    Local $hFind, $sBmpFilspc
    $hFind = FileFindFirstFile($sPath & "\*.bmp")
    $sBmpFilspc = FileFindNextFile($hFind)
    FileClose($hFind)
    Return $sPath & "\" & $sBmpFilspc
EndFunc   ;==>FindFirstBMP


Function _GUICtrlRichEdit_Deselect

Function Reference

_GUICtrlRichEdit_Deselect

Deselects text, leaving none selected

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_Deselect ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Remarks

Leaves the insertion point at the anchor point of the selection.

Related

_GUICtrlRichEdit_GetSel, _GUICtrlRichEdit_IsTextSelected, _GUICtrlRichEdit_SetSel

See Also

Search EM_SETSEL in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $aiSel, $idBtnNext, $hRichEdit, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetSel($hRichEdit, 5, 12)
                        $aiSel = _GUICtrlRichEdit_GetSel($hRichEdit)
                        Report("1.Text is selected from inter-character position " & $aiSel[0] & " to " & $aiSel[1])
                    Case 2
                        _GUICtrlRichEdit_Deselect($hRichEdit)
                        $aiSel = _GUICtrlRichEdit_GetSel($hRichEdit)
                        If $aiSel[0] = $aiSel[1] Then Report("2.No text is selected now")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_Destroy

Function Reference

_GUICtrlRichEdit_Destroy

Delete the Rich Edit control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_Destroy ( ByRef $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | 1, $hWnd is set to 0.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - attempt to destroy a control belonging to another application

Remarks

Restricted to only be used on Rich Edit controls created with _GUICtrlRichEdit_Create().

Related

_GUICtrlRichEdit_Create

Example

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

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnDoIt, $hRichEdit
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $idBtnDoIt = GUICtrlCreateButton("Do it", 10, 260, 90, 25)

    GUISetState(@SW_SHOW)

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                GUIDelete() ; needed unless script crashes if DoIt as not been pushed
                Exit
            Case $iMsg = $idBtnDoIt
                _GUICtrlRichEdit_Destroy($hRichEdit)
        EndSelect
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRichEdit_EmptyUndoBuffer

Function Reference

_GUICtrlRichEdit_EmptyUndoBuffer

Resets the undo flag of the control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_EmptyUndoBuffer ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Related

_GUICtrlRichEdit_Redo, _GUICtrlRichEdit_SetText, _GUICtrlRichEdit_Undo

See Also

Search EM_SETEMPTYUNDOBUFFER in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_hRichEdit, $g_idMnu, $g_idMnuUndo, $g_idMnuRedo, $g_idMnuEmpty

Example()

Func Example()
    Local $hGui
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    $g_idMnu = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
    $g_idMnuUndo = GUICtrlCreateMenuItem("Undo", $g_idMnu)
    $g_idMnuRedo = GUICtrlCreateMenuItem("Redo", $g_idMnu)
    GUICtrlCreateMenuItem("", $g_idMnu)
    $g_idMnuEmpty = GUICtrlCreateMenuItem("Empty Undo buffer", $g_idMnu)

    _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_MOUSEEVENTS)

    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $g_idMnuUndo
                _GUICtrlRichEdit_Undo($g_hRichEdit)
            Case $g_idMnuRedo
                _GUICtrlRichEdit_Redo($g_hRichEdit)
            Case $g_idMnuEmpty
                _GUICtrlRichEdit_EmptyUndoBuffer($g_hRichEdit)
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hRichEdit
            Select
                Case $iCode = $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_RBUTTONUP Then
                        $hMenu = GUICtrlGetHandle($g_idMnu)
                        SetMenuTexts($hWndFrom, $hMenu)
                        _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    EndIf
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func SetMenuTexts($hWnd, $hMenu)
    If _GUICtrlRichEdit_CanUndo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo: " & _GUICtrlRichEdit_GetNextUndo($hWnd), False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuEmpty, True, False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, False, False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuEmpty, False, False)
    EndIf
    If _GUICtrlRichEdit_CanRedo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo: " & _GUICtrlRichEdit_GetNextRedo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, False, False)
    EndIf
EndFunc   ;==>SetMenuTexts


Function _GUICtrlRichEdit_FindText

Function Reference

_GUICtrlRichEdit_FindText

Search for a text starting at insertion point or at anchor point of selection

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_FindText ( $hWnd, $sText [, $bForward = True [, $bMatchCase = False [, $bWholeWord = False [, $iBehavior = 0]]]] )

Parameters

$hWnd | Handle to the control
$sText | Text to find
$bForward | [optional] Search direction (Win 95: search is always forward)
$bMatchCase | [optional] Search is case-sensitive Default: case-insensitive
$bWholeWord | [optional] Search only for text as a whole word Default: partial or full word
$iBehavior | [optional] Any BitOR combination of $FR_MATCHALEFHAMZA, $FR_MATCHDIAC and $FR_MATCHKASHIDA Default: 0

Return Value

Success: | the inter-character position before start of matching text if found, else -1.
Failure: | sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $sText = "" 103 - $bForward is neither True nor False 104 - $bMatchCase is neither True nor False 105 - $bWholeWord is neither True nor False 1061 - $iBehavior is not a number 1062 - $iBehavior is invalid

Related

_GUICtrlRichEdit_FindTextInRange

See Also

Search EM_FINDTEXT in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $hRichEdit, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is appended text.")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetSel($hRichEdit, 8, 8)
                        Report("1.set starting position ")
                    Case 2
                        Report('2."appended" found just after inter-character position ' & _
                                _GUICtrlRichEdit_FindText($hRichEdit, "appended"))
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_FindTextInRange

Function Reference

_GUICtrlRichEdit_FindTextInRange

Search for a text in a range of inter-character positions

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_FindTextInRange ( $hWnd, $sText [, $iStart = 0 [, $iEnd = -1 [, $bMatchCase = False [, $bWholeWord = False [, $iBehavior = 0]]]]] )

Parameters

$hWnd | Handle to the control
$sText | Text to find
$iStart | [optional] Starting inter-character position of search Default: beginning of control
$iEnd | [optional] Ending inter-character position of search Default: end of control
$bMatchCase | [optional] Search is case-sensitive Default: case-insensitive
$bWholeWord | [optional] Search only for text as a whole word Default: partial or full word
$iBehavior | [optional] Any BitOR combination of $FR_MATCHALEFHAMZA, $FR_MATCHDIAC and $FR_MATCHKASHIDA Default: 0

Return Value

Success: | an $Array[2] containing values: If target string found, range of inter-character positions containing the matching text, e.g. [45, 52] If not found, [-1, -1]
Failure: | sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $sText = "" 103 - $iStart is neither a positive number nor zero nor -1 104 - $iEnd is neither a positive number nor zero nor -1 105 - $bMatchCase must be True or False 106 - $bWholeWord must be True or False 1071 - $iBehavior is not a number 1072 - $iBehavior is invalid

Remarks

The inter-character position at the beginning of the control is 0.
The default character range, 0 to -1, searches the whole text downwwards.
Setting $iEnd to -1 searches down to the end of the control
Setting $iStart to -1 searches up to the start of the control

Related

_GUICtrlRichEdit_FindText

See Also

Search EM_FINDTEXTEX in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $aiPos, $hRichEdit
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is appended text.")

    $aiPos = _GUICtrlRichEdit_FindTextInRange($hRichEdit, "test", 20, 6)
    Report('"test" found between inter-character positions ' & $aiPos[0] & " and " & $aiPos[1])

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetBkColor

Function Reference

_GUICtrlRichEdit_GetBkColor

Gets the background color of the control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetBkColor ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | a COLORREF value.
Failure: | sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Remarks

If you need to create an color array use _ColorGetCOLORREF() not _ColorGetRGB().

Related

_GUICtrlRichEdit_SetBkColor

See Also

Search EM_SETBKGNDCOLOR in MSDN Library.

Example

#include <Color.au3>
#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "Paragraph 1")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetBkColor($g_hRichEdit, 0xE8CCCC)
                        Report("1. Colored background")
                    Case 2
                        _GUICtrlRichEdit_SetBkColor($g_hRichEdit)
                        Report("2. Back to white")
                    Case 3
                        _GUICtrlRichEdit_SetBkColor($g_hRichEdit, 0xB3B3C7)
                        Report("3. Colored background again")
                        ; Stream all text to the Desktop so you can look at settings in Word
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    Local $iBngColor = _GUICtrlRichEdit_GetBkColor($g_hRichEdit)
    Local $aRet = _ColorGetRGB($iBngColor)
    $sMsg = $sMsg & @CRLF & @CRLF & $aRet[0] & ";" & $aRet[1] & ";" & $aRet[2] & " BngColor=0x" & Hex($iBngColor)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetCharAttributes

Function Reference

_GUICtrlRichEdit_GetCharAttributes

Returns attributes of selected text

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetCharAttributes ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | a string consisting of three-character groups. Each group consists of: first and second character: any of: bo - bolded di - disabled - characters displayed with a shadow [nd] em - embossed [nd] hi - hidden, i.e. not displayed im - imprinted [nd] it - italcized li - EN_LINK messages are sent when mouse is over text with this attribute ou - outlined [nd] pr - EN_PROTECT sent when user attempts to modify re - marked as revised [nd] sh - shadowed [nd] sm - small capital letters [nd] st - struck out sb - subscript [nd] sp - superscript [nd] un - underlined third character: + for on, ~ for mixed
Failure: | "" and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle -1 - no text is selected

Remarks

Some attributes do not display in a Rich Edit control; they are marked with [nd] above.

Returns "" if no attributes are on

Related

_GUICtrlRichEdit_SetCharAttributes

See Also

Search EM_GETCHARFORMAT in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $iCp1, $hRichEdit
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AutoDetectURL($hRichEdit, True)
    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "http://www.autoitscript.com")
    $iCp1 = _GUICtrlRichEdit_GetFirstCharPosOnLine($hRichEdit, 2)
    _GUICtrlRichEdit_SetSel($hRichEdit, $iCp1, $iCp1 + 3)
    Report("Character attributes at start of line 2 are " & _
            _GUICtrlRichEdit_GetCharAttributes($hRichEdit))
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetCharBkColor

Function Reference

_GUICtrlRichEdit_GetCharBkColor

Retrieves the background color of the selected text or, if none selected, of the character to the right of the insertion point

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetCharBkColor ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | a COLORREF value an @extended set to 1 if the color is the same throught the selection.
Failure: | sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Remarks

If you need to create an color array use _ColorGetCOLORREF() not _ColorGetRGB().

Related

_GUICtrlRichEdit_SetCharBkColor

See Also

Search EM_GETCHARFORMAT in MSDN Library.

Example

#include <Color.au3>
#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $idBtnNext, $iStep = 0
    $hGui = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 420, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, 'This is a test.', 10, 10, 400, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 60, 30)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                GUIDelete()
                Exit
            Case $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        Report("1. Initial setting")
                    Case 2
                        _GUICtrlRichEdit_SetCharBkColor($g_hRichEdit, Dec('00FF00'))
                        Report("2. Setting is now")
                    Case 3
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 1, 5)
                        _GUICtrlRichEdit_SetCharBkColor($g_hRichEdit, Dec('8888FF'))
                        Report("3. Background of a few characters changed")
                    Case 4
                        ; Stream all text to the Desktop so you can look at settings in Word
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                        GUICtrlSetData($g_idLblMsg, "4. Saved to a file on the desktop gcre.rtf")
                EndSwitch
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    Local $iColor = _GUICtrlRichEdit_GetCharBkColor($g_hRichEdit)
    Local $aRet = _ColorGetRGB($iColor)
    $sMsg &= @CRLF & @CRLF & $aRet[0] & ";" & $aRet[1] & ";" & $aRet[2] & " BkColor=0x" & Hex($iColor)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetCharColor

Function Reference

_GUICtrlRichEdit_GetCharColor

Retrieves the color of the selected text or, if none selected, of the character to the right of the insertion point

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetCharColor ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | a COLORREF value an @extended set to 1 if the color is the same throught the selection.
Failure: | sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Remarks

If you need to create an color array use _ColorGetCOLORREF() not _ColorGetRGB().

Related

_GUICtrlRichEdit_SetCharColor

See Also

Search EM_GETCHARFORMAT in MSDN Library.

Example

#include <Color.au3>
#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "Paragraph 1")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        Report("1. Initial setting")
                    Case 2
                        _GUICtrlRichEdit_SetCharColor($g_hRichEdit, "304050")
                        Report("2. Setting is now")
                    Case 3
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 1, 5)
                        _GUICtrlRichEdit_SetCharColor($g_hRichEdit, "sys")
                        Report("3. Background of a few characters changed")
                    Case 4
                        _GUICtrlRichEdit_Deselect($g_hRichEdit)
                        ; Stream all text to the Desktop so you can look at settings in Word
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        Report("4. Written to file")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    Local $iColor = _GUICtrlRichEdit_GetCharColor($g_hRichEdit)
    Local $aRet = _ColorGetRGB($iColor)
    $sMsg = $sMsg & @CRLF & @CRLF & $aRet[0] & ";" & $aRet[1] & ";" & $aRet[2] & " Color=0x" & Hex($iColor)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetCharPosFromXY

Function Reference

_GUICtrlRichEdit_GetCharPosFromXY

Gets inter-character position closest to a specified point in the client area

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetCharPosFromXY ( $hWnd, $iX, $iY )

Parameters

$hWnd | Handle to the control
$iX | horizontal coordinate relative to left side of control
$iY | vertical coordinate relative to top of control

Return Value

Success: | the 0-based character index of the character nearest the specified point (index of the character at the edge of the control if the specified point is beyond text).
Failure: | 0 and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $iX is not a number 103 - $iY is not a number -1 - ($iX,$iY) outside client area

Related

_GUICtrlRichEdit_GetXYFromCharPos

See Also

Search EM_CHARFROMPOS in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $aiPos, $idBtnNext, $hRichEdit, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is appended text.")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        $aiPos = _GUICtrlRichEdit_GetXYFromCharPos($hRichEdit, 20)
                        Report("1.The coordinates of inter-character position 20 are (" & $aiPos[0] & "," & $aiPos[1] & ")")
                    Case 2
                        Report("2.The inter-character position at or nearest coordinates (" & $aiPos[0] & "," & $aiPos[1] & ")" & @CRLF & _
                                "is " & _GUICtrlRichEdit_GetCharPosFromXY($hRichEdit, $aiPos[0], $aiPos[1]))
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetCharPosOfNextWord

Function Reference

_GUICtrlRichEdit_GetCharPosOfNextWord

Gets inter-character position before the next word

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetCharPosOfNextWord ( $hWnd, $iCpStart )

Parameters

$hWnd | Handle to the control
$iCPStart | inter-character position to start from

Return Value

Success: | the inter-character position before next word.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $iCpStart is not a number

Remarks

"Word" is defined broadly; it includes punctuation, parentheses and hyphens.

Related

_GUICtrlRichEdit_GetCharPosOfPreviousWord, _GUICtrlRichEdit_GetCharWordBreakInfo

See Also

Search EM_FINDWORDBREAK in MSDN Library.

Example

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

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $idLblMsg, $hRichEdit, $iCp = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($hRichEdit, "AutoIt v3 is a freeware BASIC-like scripting language designed for " _
             & "automating the Windows GUI and general scripting.")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iCp = _GUICtrlRichEdit_GetCharPosOfNextWord($hRichEdit, $iCp)
                GUICtrlSetData($idLblMsg, $iCp)
                _GUICtrlRichEdit_GotoCharPos($hRichEdit, $iCp)
        EndSelect
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRichEdit_GetCharPosOfPreviousWord

Function Reference

_GUICtrlRichEdit_GetCharPosOfPreviousWord

Gets inter-character position before the Previous word

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetCharPosOfPreviousWord ( $hWnd, $iCpStart )

Parameters

$hWnd | Handle to the control
$iCPStart | inter-character position to start from

Return Value

Success: | the inter-character position before previous word.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $iCpStart is not a number

Remarks

"Word" is defined broadly; it includes punctuation, parentheses and hyphens.

Related

_GUICtrlRichEdit_GetCharPosOfNextWord, _GUICtrlRichEdit_GetCharWordBreakInfo

See Also

Search EM_FINDWORDBREAK in MSDN Library.

Example

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

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $idLblMsg, $hRichEdit, $iCp = 200
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($hRichEdit, "AutoIt v3 is a freeware BASIC-like scripting language designed for " _
             & "automating the Windows GUI and general scripting.")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iCp = _GUICtrlRichEdit_GetCharPosOfPreviousWord($hRichEdit, $iCp)
                GUICtrlSetData($idLblMsg, $iCp)
                _GUICtrlRichEdit_GotoCharPos($hRichEdit, $iCp)
        EndSelect
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRichEdit_GetCharWordBreakInfo

Function Reference

_GUICtrlRichEdit_GetCharWordBreakInfo

Gets inter-character position before the Previous word/

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetCharWordBreakInfo ( $hWnd, $iCp )

Parameters

$hWnd | Handle to the control
$iCP | Inter-character position to left of character of interest

Return Value

Success: | a string consisting of comma-separated values: value 1 - word-break flag(s): c - line may be broken after this character d - character is an end-of-word delimiter. Lines may be broken after delimiters w - character is white-space. (Trailing white-spaces are not included in line length.) value 2 - character class: a number
Failure: | "" and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $iCp is not a number

Remarks

Lines may be broken at delimiters or between characters od different classes.

Character classes are defined in word-break procedures.
The classes in the default procedure are:
0 = alphanumeric character,
1 = other printing character (except hyphen),
2 = space,
3 = tab,
4 = hyphen or end-of-paragraph.

Related

_GUICtrlRichEdit_GetCharPosOfNextWord, _GUICtrlRichEdit_GetCharPosOfPreviousWord

See Also

Search EM_FINDWORDBREAK in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $hRichEdit, $iCp = -1, $s
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    $s = Chr(9)
    For $i = 32 To 126
        $s &= Chr($i)
    Next
    _GUICtrlRichEdit_AppendText($hRichEdit, $s & @CRLF)
    _GUICtrlRichEdit_AppendText($hRichEdit, "AutoIt v3 is a (freeware) BASIC-like scripting language designed for " _
             & "automating the Windows GUI and general scripting.")
    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "Another paragraph")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iCp += 1
                _GUICtrlRichEdit_GotoCharPos($hRichEdit, $iCp)
                GUICtrlSetData($g_idLblMsg, _GUICtrlRichEdit_GetCharWordBreakInfo($hRichEdit, $iCp))
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report

Func GetWord($hWnd, $iCp, $bForward, $bStartOfWord, $bClass = False)
    Local $iRet, $wParam
    If $bClass Then
        If $bForward Then
            $wParam = $WB_MOVEWORDRIGHT
        Else
            $wParam = $WB_MOVEWORDLEFT
        EndIf
    Else
        If $bForward Then
            If $bStartOfWord Then
                $wParam = $WB_RIGHT
            Else
                $wParam = $WB_LEFT
            EndIf
        Else
            If $bStartOfWord Then
                $wParam = $WB_RIGHTBREAK
            Else
                $wParam = $wb_LEFTBREAK
            EndIf
        EndIf
    EndIf
    $iRet = _SendMessage($hWnd, $EM_FINDWORDBREAK, $wParam, $iCp)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $wParam = ' & $wParam & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    Return $iRet
EndFunc   ;==>GetWord


Function _GUICtrlRichEdit_GetFirstCharPosOnLine

Function Reference

_GUICtrlRichEdit_GetFirstCharPosOnLine

Retrieves the inter-character position preceding the first character of a line

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetFirstCharPosOnLine ( $hWnd [, $iLine = -1] )

Parameters

$hWnd | Handle to the control
$iLine | [optional] Line number Default: current line

Return Value

Success: | the character position of the first character of the line.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 1021 - $iLine is neither positive nor -1 1022 - $iLine greater than number of lines of text

Remarks

A control that contains no text has one line.

The first line is line 1. The first character position in the client area is 0.

See Also

Search EM_GETLINEINDEX in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $iCp1, $hRichEdit
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AutoDetectURL($hRichEdit, True)
    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "http://www.autoitscript.com")
    $iCp1 = _GUICtrlRichEdit_GetFirstCharPosOnLine($hRichEdit, 2)
    _GUICtrlRichEdit_SetSel($hRichEdit, $iCp1, $iCp1 + 3)
    Report("Character attributes at start of line 2 are " & _
            _GUICtrlRichEdit_GetCharAttributes($hRichEdit))

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetFont

Function Reference

_GUICtrlRichEdit_GetFont

Gets the font attributes of a selection or, if no selection, at the insertion point

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetFont ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | an array containing values: [0] - point size 0 if sizes are mixed in selection [1] - the name of the font "" if fonts are mixed in selection [2] - the character set $ANSI_CHARSET - 0 $BALTIC_CHARSET - 186 $CHINESEBIG5_CHARSET - 136 $EASTEUROPE_CHARSET - 238 $GB2312_CHARSET - 134 $GREEK_CHARSET - 161 $HANGEUL_CHARSET - 129 $MAC_CHARSET - 77 $OEM_CHARSET - 255 $RUSSIAN_CHARSET - 204 $SHIFTJIS_CHARSET - 128 $SYMBOL_CHARSET - 2 $TURKISH_CHARSET - 162 $VIETNAMESE_CHARSET - 163
Failure: | sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Related

_GUICtrlRichEdit_SetFont

See Also

Search EM_GETCHARFORMAT in MSDN Library. Search LOGFONT in MSDN Library. See http://www.hep.wisc.edu/~pinghc/books/apirefeng/l/logfont.html.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        Report("1. Initial")
                    Case 2
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, 5)
                        _GUICtrlRichEdit_SetFont($g_hRichEdit, 15, "Times New Roman")
                        Report("2. Set Font")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    Local $aRet = _GUICtrlRichEdit_GetFont($g_hRichEdit)
    $sMsg = $sMsg & @CRLF & @CRLF & $aRet[1] & " " & $aRet[0] & " points"
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetLineCount

Function Reference

_GUICtrlRichEdit_GetLineCount

Retrieves the number of lines in a multi-line edit control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetLineCount ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the total number of text lines.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Remarks

A control that contains no text has one line.

Lines that are not currently visible are included in the count.

If Wordwrap is enabled, the number of lines can change when the dimensions of the editing window change.

See Also

Search EM_GETLINECOUNT in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $hRichEdit
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    GUISetState(@SW_SHOW)

    For $i = 2 To 10
        _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "Line " & $i)
    Next

    Report("The control contains " & _GUICtrlRichEdit_GetLineCount($hRichEdit) & " lines")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetLineLength

Function Reference

_GUICtrlRichEdit_GetLineLength

Retrieves the length of a line

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetLineLength ( $hWnd, $iLine )

Parameters

$hWnd | Handle to the control
$iLine | line number Special value: -1 - return number of unselected characters on lines containing selected characters

Return Value

Success: | Multi-line control - Length of the line (in characters). Single-line control - number of characters in the control.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $iLine is neither positive nor -1 1022 - $iLine is greater than number of characters in the control

Remarks

A control that contains no text has one line.
The first inter-character position in a control is 0.

The result does not include carriage-return characters at the end of the line.

See Also

Search EM_GETLINELENGTH in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $hRichEdit, $iMsg
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    GUISetState(@SW_SHOW)

    Report("The current line contains " & _GUICtrlRichEdit_GetLineLength($hRichEdit, -1) & " characters")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetLineNumberFromCharPos

Function Reference

_GUICtrlRichEdit_GetLineNumberFromCharPos

Retrieves the line number on which an inter-character position is found

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetLineNumberFromCharPos ( $hWnd, $iCharPos )

Parameters

$hWnd | Handle to the control
$iCharPos | Inter-character position

Return Value

Success: | the line number (1-based).
Failure: | 0 and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $iCharPos is not a positive number

Remarks

A control that contains no text has one line.
The first inter-character position in a control is 0.

The first line is line 1.

If $iCharPos is negative or more than the number of characters in the control, returns the number of lines in the control.

See Also

Search EM_EXLINEFROMCHAR in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $hRichEdit
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is appended text")
    Report("Inter-character position 30 is on line " & _GUICtrlRichEdit_GetLineNumberFromCharPos($hRichEdit, 30))

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetNextRedo

Function Reference

_GUICtrlRichEdit_GetNextRedo

Retrieves the name or type ID of the next possible redo action

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetNextRedo ( $hWnd [, $bName = True] )

Parameters

$hWnd | Handle to the control
$bName | [optional] True (return name, default) or False (return ID number)

Return Value

Success: | depends on value of $bName: If $bName is True: "Unknown", "Typing", "Delete", "Drag and drop", "Cut" or "Paste" If $Name is False: the corresponding number (0 to 5)
Failure: | "" and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $bName is neither True nor False

Remarks

Note that EM_GETREDONAME does not distinguish between Unknown and redo queue empty.

Related

_GUICtrlRichEdit_Redo, _GUICtrlRichEdit_SetUndoLimit, _GUICtrlRichEdit_Undo

See Also

Search EM_GETREDONAME in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_hRichEdit, $g_idMnu, $g_idMnuUndo, $g_idMnuRedo, $g_idMnuCut, $g_idMnuCopy
Global $g_idMnuPaste, $g_idMnuPasteSpl

Example()

Func Example()
    Local $hGui, $idMnuPasteSplRTF, $idMnuPasteSplwObjs
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($g_hRichEdit, ReadBmpToRtf(FindFirstBMP()) & @CRLF)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    $g_idMnu = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
    $g_idMnuUndo = GUICtrlCreateMenuItem("Undo", $g_idMnu)
    $g_idMnuRedo = GUICtrlCreateMenuItem("Redo", $g_idMnu)
    GUICtrlCreateMenuItem("", $g_idMnu)
    $g_idMnuCut = GUICtrlCreateMenuItem("Cut", $g_idMnu)
    $g_idMnuCopy = GUICtrlCreateMenuItem("Copy", $g_idMnu)
    $g_idMnuPaste = GUICtrlCreateMenuItem("Paste", $g_idMnu)
    $g_idMnuPasteSpl = GUICtrlCreateMenu("Paste Special", $g_idMnu)
    $idMnuPasteSplRTF = GUICtrlCreateMenuItem("RTF only", $g_idMnuPasteSpl)
    $idMnuPasteSplwObjs = GUICtrlCreateMenuItem("With objects", $g_idMnuPasteSpl)
    _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_MOUSEEVENTS)

    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $g_idMnuUndo
                _GUICtrlRichEdit_Undo($g_hRichEdit)
            Case $g_idMnuRedo
                _GUICtrlRichEdit_Redo($g_hRichEdit)
            Case $g_idMnuCut
                _GUICtrlRichEdit_Cut($g_hRichEdit)
            Case $g_idMnuCopy
                _GUICtrlRichEdit_Copy($g_hRichEdit)
            Case $g_idMnuPaste
                _GUICtrlRichEdit_Paste($g_hRichEdit)
            Case $idMnuPasteSplRTF
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, False)
            Case $idMnuPasteSplwObjs
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, True)
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hRichEdit
            Select
                Case $iCode = $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_RBUTTONUP Then
                        $hMenu = GUICtrlGetHandle($g_idMnu)
                        _SetMenuTexts($hWndFrom, $hMenu)
                        _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    EndIf
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _SetMenuTexts($hWnd, $hMenu)
    Local $bState
    If _GUICtrlRichEdit_CanUndo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo: " & _GUICtrlRichEdit_GetNextUndo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, False, False)
    EndIf
    If _GUICtrlRichEdit_CanRedo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo: " & _GUICtrlRichEdit_GetNextRedo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, False, False)
    EndIf
    $bState = _GUICtrlRichEdit_IsTextSelected($hWnd)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCut, $bState, False)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCopy, $bState, False)

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPaste, _GUICtrlRichEdit_CanPaste($hWnd))

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPasteSpl, _GUICtrlRichEdit_CanPasteSpecial($hWnd), False)
EndFunc   ;==>_SetMenuTexts

Func ReadBmpToRtf($sBmpFilspc)
    Local $hFile, $sRtf
    $hFile = FileOpen($sBmpFilspc, 16)
    If FileRead($hFile, 2) <> "0x424D" Then Return SetError(1, 0, "")
    FileRead($hFile, 12)
    $sRtf = '{\rtf1{\pict\dibitmap ' & Hex(FileRead($hFile)) & '}}'
    FileClose($hFile)
    Return $sRtf
EndFunc   ;==>ReadBmpToRtf

Func FindFirstBMP($sPath = @WindowsDir)
    Local $hFind, $sBmpFilspc
    $hFind = FileFindFirstFile($sPath & "\*.bmp")
    $sBmpFilspc = FileFindNextFile($hFind)
    FileClose($hFind)
    Return $sPath & "\" & $sBmpFilspc
EndFunc   ;==>FindFirstBMP


Function _GUICtrlRichEdit_GetNextUndo

Function Reference

_GUICtrlRichEdit_GetNextUndo

Retrieves the name or type ID of the next possible Undo action

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetNextUndo ( $hWnd [, $bName = True] )

Parameters

$hWnd | Handle to the control
$bName | [optional] True (return name, default) or False (return ID number)

Return Value

Success: | depends on value of $bName: If $bName is True: "Unknown", "Typing", "Delete", "Drag and drop", "Cut" or "Paste" If $Name is False: the corresponding number (0 to 5)
Failure: | "" and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $bName is neither True nor False

Remarks

Note that EM_GETUNDONAME does not distinguish between Unknown and Undo queue empty.

Related

_GUICtrlRichEdit_Undo

See Also

Search EM_GETUNDONAME in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_hRichEdit, $g_idMnu, $g_idMnuUndo, $g_idMnuRedo, $g_idMnuCut, $g_idMnuCopy
Global $g_idMnuPaste, $g_idMnuPasteSpl

Example()

Func Example()
    Local $hGui, $idMnuPasteSplRTF, $idMnuPasteSplwObjs
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($g_hRichEdit, ReadBmpToRtf(FindFirstBMP()) & @CRLF)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    $g_idMnu = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
    $g_idMnuUndo = GUICtrlCreateMenuItem("Undo", $g_idMnu)
    $g_idMnuRedo = GUICtrlCreateMenuItem("Redo", $g_idMnu)
    GUICtrlCreateMenuItem("", $g_idMnu)
    $g_idMnuCut = GUICtrlCreateMenuItem("Cut", $g_idMnu)
    $g_idMnuCopy = GUICtrlCreateMenuItem("Copy", $g_idMnu)
    $g_idMnuPaste = GUICtrlCreateMenuItem("Paste", $g_idMnu)
    $g_idMnuPasteSpl = GUICtrlCreateMenu("Paste Special", $g_idMnu)
    $idMnuPasteSplRTF = GUICtrlCreateMenuItem("RTF only", $g_idMnuPasteSpl)
    $idMnuPasteSplwObjs = GUICtrlCreateMenuItem("With objects", $g_idMnuPasteSpl)
    _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_MOUSEEVENTS)

    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $g_idMnuUndo
                _GUICtrlRichEdit_Undo($g_hRichEdit)
            Case $g_idMnuRedo
                _GUICtrlRichEdit_Redo($g_hRichEdit)
            Case $g_idMnuCut
                _GUICtrlRichEdit_Cut($g_hRichEdit)
            Case $g_idMnuCopy
                _GUICtrlRichEdit_Copy($g_hRichEdit)
            Case $g_idMnuPaste
                _GUICtrlRichEdit_Paste($g_hRichEdit)
            Case $idMnuPasteSplRTF
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, False)
            Case $idMnuPasteSplwObjs
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, True)
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hRichEdit
            Select
                Case $iCode = $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_RBUTTONUP Then
                        $hMenu = GUICtrlGetHandle($g_idMnu)
                        _SetMenuTexts($hWndFrom, $hMenu)
                        _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    EndIf
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _SetMenuTexts($hWnd, $hMenu)
    Local $bState
    If _GUICtrlRichEdit_CanUndo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo: " & _GUICtrlRichEdit_GetNextUndo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, False, False)
    EndIf
    If _GUICtrlRichEdit_CanRedo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo: " & _GUICtrlRichEdit_GetNextRedo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, False, False)
    EndIf
    $bState = _GUICtrlRichEdit_IsTextSelected($hWnd)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCut, $bState, False)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCopy, $bState, False)

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPaste, _GUICtrlRichEdit_CanPaste($hWnd))

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPasteSpl, _GUICtrlRichEdit_CanPasteSpecial($hWnd), False)
EndFunc   ;==>_SetMenuTexts

Func ReadBmpToRtf($sBmpFilspc)
    Local $hFile, $sRtf
    $hFile = FileOpen($sBmpFilspc, 16)
    If FileRead($hFile, 2) <> "0x424D" Then Return SetError(1, 0, "")
    FileRead($hFile, 12)
    $sRtf = '{\rtf1{\pict\dibitmap ' & Hex(FileRead($hFile)) & '}}'
    FileClose($hFile)
    Return $sRtf
EndFunc   ;==>ReadBmpToRtf

Func FindFirstBMP($sPath = @WindowsDir)
    Local $hFind, $sBmpFilspc
    $hFind = FileFindFirstFile($sPath & "\*.bmp")
    $sBmpFilspc = FileFindNextFile($hFind)
    FileClose($hFind)
    Return $sPath & "\" & $sBmpFilspc
EndFunc   ;==>FindFirstBMP


Function _GUICtrlRichEdit_GetNumberOfFirstVisibleLine

Function Reference

_GUICtrlRichEdit_GetNumberOfFirstVisibleLine

Gets number of the first line which is visible in the control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetNumberOfFirstVisibleLine ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the line number (1-based).
Failure: | 0 and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Remarks

The first line is numbered 1.

See Also

Search EM_GETFIRSTVISIBLELINE in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $hRichEdit
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    GUISetState(@SW_SHOW)

    For $i = 2 To 50
        _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "Line " & $i)
    Next

    Report("First visible line is number " & _GUICtrlRichEdit_GetNumberOfFirstVisibleLine($hRichEdit))

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetParaAlignment

Function Reference

_GUICtrlRichEdit_GetParaAlignment

Gets the alignment of selected paragraph(s), or (if no selection) of the current paragraph

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetParaAlignment ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | a string consisting of a value, a semicolon (;), and a scope character: alignment: l - aligned with the left margin. r - aligned with the right margin. c - centered between margins j - justified between margins f - justified between margins w - justified between margins by only expanding spaces scope: a - all (or only) selected paragraphs have this alignment f - the first selected paragraph has this alignment, but other(s) don't c - the current paragraph has this alignment
Failure: | "" and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Remarks

In Richedit 2.0, justify does not display.

Related

_GUICtrlRichEdit_SetParaAlignment

See Also

Search EM_SETPARAFORMAT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $iCp, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "First paragraph")
    Report("First paragraph")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetParaAlignment($g_hRichEdit, "r")
                        Report("First paragraph")
                    Case 2
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Second paragraph")
                        _GUICtrlRichEdit_SetParaAlignment($g_hRichEdit, "c")
                        Report("Second paragraph")
                    Case 3
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Third paragraph")
                        _GUICtrlRichEdit_SetParaAlignment($g_hRichEdit, "l")
                        Report("Third paragraph")
                    Case 4
                        $iCp = _GUICtrlRichEdit_GetFirstCharPosOnLine($g_hRichEdit, 2)
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, $iCp, -1)
                        Report("Alignment of paragraphs in selection")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & @CRLF & _GUICtrlRichEdit_GetParaAlignment($g_hRichEdit)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetParaAttributes

Function Reference

_GUICtrlRichEdit_GetParaAttributes

Gets the attributes of (first) selected paragraph or (if no selection) of the current paragraph

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetParaAttributes ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | a string consisting of values separated by semicolons ";". Values 1 to 10: a group consisting of: Characters 1 to 3 - attribute fpg - force this/these paragraphs on to new page(s) (Initially off) hyp - automatic hypthenation (Initially on) kpt - keep this/these paragraph(s) together on a page (Initially off} kpn - keep this/these paragraph(s) and the next together on a page (Initially off) pwo - prevent widows and orphans, i.e. avoid a single line of this/these paragraph(s) on a page (Initially off) r2l - display text using right-to-left reading order (Initially off) sbs - display paragraphs side by side (Initially off) sln - suppress line numbers in documents or sections with line numbers (Initially off) tbl - paragraph(s) is/are table row(s) (Initially off) Character 4 - state: + - attribute is on - - attribute is off Value 11 - scope: f - the first selected paragraph has these attributes c - the current paragraph has these attributes
Failure: | "" and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Related

_GUICtrlRichEdit_SetParaAttributes

See Also

Search EM_SETPARAFORMAT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($g_hRichEdit, "First paragraph")
    Report("First paragraph: default attributes")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Second paragraph")
                        _GUICtrlRichEdit_SetParaAttributes($g_hRichEdit, "-hyp")
                        Report("Second paragraph: hyphenation off")
                    Case 2
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 10, -1)
                        _GUICtrlRichEdit_SetParaAttributes($g_hRichEdit, "-hyp;+fpg;+kpn")
                        Report("Attributes of first paragraph in selection")
                    Case 3
                        ; Stream all text to the Desktop so you can look at attributes in Word
                        _GUICtrlRichEdit_Deselect($g_hRichEdit)
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & @CRLF & _GUICtrlRichEdit_GetParaAttributes($g_hRichEdit)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetParaBorder

Function Reference

_GUICtrlRichEdit_GetParaBorder

Gets the border settings of (first) selected paragraph or (if no selection) of the current paragraph

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetParaBorder ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: settings of first selected paragraph - a string consisting of values separated by semicolons (:):
Value 1 - one or more of:
l - left border
r - right border
t - top border
b - bottom border
i - inside border
o - outside border
or
empty - no border
Value 2 - line style - one of:
none - no line
.75 - 3/4 point
1.5 - 1 1/2 points
2.25 - 2 1/4 points
3 - 3 points
4.5 - 4 1/2 points
6 - 6 points
.75d - 1/2 points, double
1.5d - 1 1/2 points, double
2.25d - 2 1/4 points, double
.75g - 3/4 point grey
.75gd - 3/4 point grey dashed
Value 3 - one of:
aut - autocolor
blk - black
blu - blue
cyn - cyan
grn - green
mag - magenta
red - red
yel - yellow
whi - white
dbl - dark blue
dgn - dark green
dmg - dark magenta
drd - dark red
dyl - dark yellow
dgy - dark grey
lgy - light grey
Value 4 - space between the border and the text (in space units)
Value 5 - scope:
a - all (or only) selected paragraphs have these settings
f - the first selected paragraph has these settings, but other(s) don't
c - the current paragraph has these settings
Failure: "" and sets the @error flag to non-zero.
@error: 101 - $hWnd is not a handle

Remarks

Borders do not show in Rich Edit, but borders created here will show in Word.

Related

_GUICtrlRichEdit_SetParaBorder

See Also

Search EM_GETPARAFORMAT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $iStep = 0, $idBtnNext
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($g_hRichEdit, "First paragraph")
    Report("0. First paragraph: default settings")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Second paragraph")
                        _GUICtrlRichEdit_SetParaBorder($g_hRichEdit, "o", 3, "mag", 0.25)
                        Report("1. Second paragraph: with border (should show in Word)")
                    Case 2
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 10, -1)
                        Report("2. Settings of first paragraph in selection")
                    Case 3
                        _GUICtrlRichEdit_SetParaBorder($g_hRichEdit, "l", 6, "blu")
                        Report("3. Settings of both paragraphs changed")
                    Case 4
                        _GUICtrlRichEdit_SetParaBorder($g_hRichEdit, Default, ".75gd")
                        Report("4. Line style changed")
                    Case 5
                        ; Stream all text to the Desktop so you can look at border settings in Word
                        _GUICtrlRichEdit_Deselect($g_hRichEdit)
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & @CRLF & _GUICtrlRichEdit_GetParaBorder($g_hRichEdit)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetParaIndents

Function Reference

_GUICtrlRichEdit_GetParaIndents

Gets the border indent settings of (first) selected paragraph or (if no selection) of the current paragraph

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetParaIndents ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | settings - a string consisting of values separated by semicolons (:): Value 1 - Left - indentation of left side of the body of the paragraph (of lines after the first) (in space units) Value 2 - Right - indentation of right side of the paragraph (in space units) Value 3 - FirstLine - indentation of the first line relative to other lines (in space units) Value 4 - scope: a - all (or only) selected paragraphs have these settings f - the first selected paragraph has these settings, but other(s) don't c - the current paragraph has these settings
Failure: | "" and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Remarks

Postive values of $iLeft, $iRight and $iFirstLine indent towards the center of the paragraph.

Related

_GUICtrlRichEdit_SetParaIndents

See Also

Search EM_GETPARAFORMAT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "First paragraph")
    Report("Para with default indent settings")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Second paragraph")
                        Report("Added second paragraph")
                    Case 2
                        _GUICtrlRichEdit_SetParaIndents($g_hRichEdit, 0.25, .1)
                        Report("Changed indent settings of second paragraph")
                    Case 3
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 10, 26)
                        _GUICtrlRichEdit_SetParaIndents($g_hRichEdit, Default, 0, .2)
                        Report("Change settings of both paragraphs")
                    Case 4
                        ; Stream all text to the Desktop so you can look at Indents settings in Word
                        _GUICtrlRichEdit_Deselect($g_hRichEdit)
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & @CRLF & _GUICtrlRichEdit_GetParaIndents($g_hRichEdit)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetParaNumbering

Function Reference

_GUICtrlRichEdit_GetParaNumbering

Gets the numbering style of (first) selected paragraph or (if no selection) of the current paragraph

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetParaNumbering ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | values separated by semicolons (;): value 1 - a string showing the style and starting "number" e.g. "." (bullet), "1)","(b)", "C.", "iv", "V)" Trailing spaces indicate the minimum spaces between the number and the paragraph Special cases: "=" - This paragraph is an unnumbered paragraph within the preceding list element "" - removed the numbering from the selected paragraph(s) value 2 - If Roman numbers, "Roman" else "" value 3 - space between number/bullet and paragraph (in space units) value 4 - scope: a - all (or only) selected paragraphs have these settings f - the first selected paragraph has these settings, but other(s) don't c - the current paragraph has these settings
Failure: | "" and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Related

_GUICtrlRichEdit_SetParaNumbering

See Also

Search EM_GETPARAFORMAT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "First paragraph")
    _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, 1)
    Report("Para with default indent settings")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Second paragraph")
                        _GUICtrlRichEdit_SetParaNumbering($g_hRichEdit, ".")
                        Report("Added second paragraph")
                    Case 2
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, 2)
                        Report("Style of first paragraph in the selection")
                    Case 3
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 10, 26)
                        _GUICtrlRichEdit_SetParaNumbering($g_hRichEdit, "v)  ", Default, True)
                        Report("Change settings of both paragraphs")
                    Case 4
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 10, 26)
                        _GUICtrlRichEdit_SetParaNumbering($g_hRichEdit, "2.  ", Default, True)
                        Report("Changed settings for both paragraphs")
                    Case 5
                        ; Stream all text to the Desktop so you can look at settings in Word
                        _GUICtrlRichEdit_Deselect($g_hRichEdit)
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & @CRLF & _GUICtrlRichEdit_GetParaNumbering($g_hRichEdit)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetParaShading

Function Reference

_GUICtrlRichEdit_GetParaShading

Gets the shading settings of (first) selected paragraph or (if no selection) of the current paragraph

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetParaShading ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: settings of first selected paragraph - a string consisting of values separated by semicolons (:):
value 1 - Weight - percent of foreground color, the rest being background color
value 2 - style - a string containing one of the following:
non - none
dhz - dark horizontal
dvt - dark vertical
ddd - dark down diagonal
dud - dark up diagonal
dgr - dark grid
dtr - dark trellis
lhz - light horizontal
lvt - light vertical
ldd - light down diagonal
lud - light up diagonal
lgr - light grid
ltr - light trellis
value 3 - Foreground color - one of the following:
"blk" - black
"blu" - blue
"cyn" - cyan
"grn" - green
"mag" - magenta
"red" - red
"yel" - yellow
"whi" - white
"dbl" - dark blue
"dgn" - dark green
"dmg" - dark magenta
"drd" - dark red
"dyl" - dark yellow
"dgy" - dark grey
"lgy" - light grey
value 4 - Background color - same values as for Foreground color
value 5 - scope:
a - all (or only) selected paragraphs have these settings
f - the first selected paragraph has these settings, but other(s) don't
c - the current paragraph has these settings
Failure: "" and sets the @error flag to non-zero.
@error: 101 - $hWnd is not a handle

Remarks

Shading does not show in Rich Edit, but shading created here will show in Word.

Related

_GUICtrlRichEdit_SetParaShading

See Also

Search EM_SETPARAFORMAT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "First paragraph")
    Report("0. Para with default settings")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Second paragraph")
                        _GUICtrlRichEdit_SetParaShading($g_hRichEdit, 60, "ddd", "blu", "dmg")
                        Report("1. Shading of second paragraph is ")
                    Case 2
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, 2)
                        Report("2. Style of first paragraph in the selection is ")
                    Case 3
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 10, 26)
                        _GUICtrlRichEdit_SetParaShading($g_hRichEdit, Default, "dgr")
                        Report("3. Change shading of both paragraphs")
                    Case 4
                        ; Stream all text to the Desktop so you can look at settings in Word
                        _GUICtrlRichEdit_Deselect($g_hRichEdit)
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & @CRLF & _GUICtrlRichEdit_GetParaShading($g_hRichEdit)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetParaSpacing

Function Reference

_GUICtrlRichEdit_GetParaSpacing

Gets the spacing settings of (first) selected paragraph or (if no selection) of the current paragraph

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetParaSpacing ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | a string consisting of the settings separated by semicolons (;): value 1 - inter-line spacing: either a number - in space units or " lines" - in lines value 2 - scope of value 1: a - all (or only) selected paragraph(s) have the above setting f - the first selected paragraph has this setting, but other(s) don't c - the current paragraph has this setting value 3 - spacing before paragraphs (in space units) value 4 - scope of value 3 - see above value 5 - spacing after paragraphs (in space units) value 6 - scope of value 5 - see above
Failure: | "" and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Related

_GUICtrlRichEdit_SetParaSpacing

See Also

Search EM_SETPARAFORMAT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "First paragraph")
    Report("0. Para with default settings")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Second paragraph")
                        _GUICtrlRichEdit_SetParaSpacing($g_hRichEdit, "2 lines", .2, .25)
                        Report("1. Spacing of second paragraph is ")
                    Case 2
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, 2)
                        Report("2. Settings of first paragraph in the selection are ")
                    Case 3
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 10, 26)
                        _GUICtrlRichEdit_SetParaSpacing($g_hRichEdit, Default, .1)
                        Report("3. Change spacing of both paragraphs")
                    Case 4
                        ; Stream all text to the Desktop so you can look at Indents settings in Word
                        _GUICtrlRichEdit_Deselect($g_hRichEdit)
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & @CRLF & _GUICtrlRichEdit_GetParaSpacing($g_hRichEdit)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetParaTabStops

Function Reference

_GUICtrlRichEdit_GetParaTabStops

Gets the tabstops of (first) selected paragraph or (if no selection) of the current paragraph

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetParaTabStops ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | A string consisting of values separated by ; (semicolons). value 1 - number of tabstops values 2 to + 1 - description of a tabstop: absolute position of a tab stop (in space units) kind of tab l - left tab c - center tab r - decimal tab b - bar tab (a vertical bar, as in Word) kind of dot leader . - dotted leader - - dashed leader _ - underline leader = - double line leader t - thick-line leader a space - no leader Value + 2 - scope: a - all (or only) selected paragraphs have these settings f - the first selected paragraph has these settings, but other(s) don't c - the current paragraph has these settings
Failure: | "" and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Remarks

To enter a tab into a control, press Ctrl_Tab.

Related

_GUICtrlRichEdit_SetParaTabStops

See Also

Search EM_GETPARAFORMAT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "First paragraph")
    Report("0. Para with default settings")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Second paragraph")
                        _GUICtrlRichEdit_SetParaTabStops($g_hRichEdit, ".3l ;1c ;2.5r.")
                        Report("1. TabStops of second paragraph")
                    Case 2
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, 2)
                        Report("2. Tabstops of first paragraph")
                    Case 3
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 10, 26)
                        Report("Tabstops of first paragraph in selection")
                    Case 4
                        _GUICtrlRichEdit_SetParaTabStops($g_hRichEdit, "2.3r=")
                        Report("3. Change tabstops of both paragraphs")
                    Case 5
                        ; Stream all text to the Desktop so you can look at settings in Word
                        _GUICtrlRichEdit_Deselect($g_hRichEdit)
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & @CRLF & _GUICtrlRichEdit_GetParaTabStops($g_hRichEdit)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetPasswordChar

Function Reference

_GUICtrlRichEdit_GetPasswordChar

Gets the password character that a rich edit control displays when the user enters text

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetPasswordChar ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the character to be displayed in place of any characters typed by the user.
Special: | 0 - there is no password character, so the control displays the characters typed by the user.
Failure: | an empty string and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Related

_GUICtrlRichEdit_SetPasswordChar

See Also

Search EM_GETPASSWORDCHAR in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    Report("Initial state after creation:")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetPasswordChar($g_hRichEdit, "*")
                        Report("Changed password character. Type some text")
                    Case 2
                        _GUICtrlRichEdit_SetPasswordChar($g_hRichEdit, "")
                        Report("Changed it back")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    Local $sPasswordChar
    $sPasswordChar = _GUICtrlRichEdit_GetPasswordChar($g_hRichEdit)
    If $sPasswordChar = "" Then
        $sMsg &= @CRLF & "Characters appear as typed"
    Else
        $sMsg = $sMsg & @CRLF & "Typed characters appear as " & $sPasswordChar & "s"
    EndIf
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetRECT

Function Reference

_GUICtrlRichEdit_GetRECT

Retrieves the formatting rectangle of a control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetRECT ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | an array consisting of x and y coordinates. $aArray[0] = Left $aArray[1] = Top $aArray[2] = Right $aArray[3] = Bottom
Failure: | sets the flag to non-zero.
@error: | 101 - $hWnd is not a handle

Remarks

The formatting rectangle is the area in which text is drawn, part of which may not be visible.

All returned values are in dialog units referenced to the control.

Per MSDN, the values returned by this function may not be exactly what may be set by _GUICtrlRichEdit_SetRECT().

Related

_GUICtrlRichEdit_SetRECT

See Also

Search EM_GETRECT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "First paragraph")
    _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Second paragraph")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        Report("1. Default settings ")
                    Case 2
                        _GUICtrlRichEdit_SetRECT($g_hRichEdit, 10, 10, 100, 100)
                        Report("2. Settings ")
                    Case 3
                        _GUICtrlRichEdit_SetRECT($g_hRichEdit)
                        Report("3. ReSettings to default")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    Local $aRect = _GUICtrlRichEdit_GetRECT($g_hRichEdit)
    $sMsg = $sMsg & @CRLF & @CRLF & "Left=" & $aRect[0] & " Top=" & $aRect[1] & " Right=" & $aRect[2] & " Bottom=" & $aRect[3]
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetScrollPos

Function Reference

_GUICtrlRichEdit_GetScrollPos

Gets the Scrolling position of the control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetScrollPos ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | an array containing [x, y]
Failure: | sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Remarks

The scrolling position is the upper left corner of the control.

Related

_GUICtrlRichEdit_GetSelAA, _GUICtrlRichEdit_SetScrollPos

See Also

Search EM_GETSCROLLPOS in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "Paragraph 1")
    For $i = 2 To 20
        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Paragraph " & $i)
    Next
    Report("0. Initially scrolled to show insertion point")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetScrollPos($g_hRichEdit, 0, 0)
                        Report("1. Scrolled to top")
                    Case 2
                        _GUICtrlRichEdit_SetScrollPos($g_hRichEdit, 7, 22)
                        Report("2. Scrolled down a bit, and to the right")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    Local $aPos = _GUICtrlRichEdit_GetScrollPos($g_hRichEdit)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & $aPos[0] & ";" & $aPos[1]
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetSel

Function Reference

_GUICtrlRichEdit_GetSel

Gets the low and high inter-character positions of a selection

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetSel ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | an array in the format [<low>, <high>].
Failure: | sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Remarks

The first character of the text is after inter-character position 0.
If high = low, no text is selected.

Related

_GUICtrlRichEdit_Deselect, _GUICtrlRichEdit_GetSelAA, _GUICtrlRichEdit_GetSelText, _GUICtrlRichEdit_GetTextInLine, _GUICtrlRichEdit_IsTextSelected, _GUICtrlRichEdit_SetSel

See Also

Search EM_EXGETSEL in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetSel($g_hRichEdit, 2, 10)

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        Report("1. Text is selected from inter-character position")
                    Case 2
                        _GUICtrlRichEdit_Deselect($g_hRichEdit)
                        Report("2. No text is selected now")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    Local $aPos = _GUICtrlRichEdit_GetSel($g_hRichEdit)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & $aPos[0] & "," & $aPos[1]
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetSelAA

Function Reference

_GUICtrlRichEdit_GetSelAA

Gets the anchor and active inter-character positions of a selection, in that order

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetSelAA ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | an array in the format: $aArray[0] = Anchor $aArray[1] = Active
Failure: | sets the @error flag to non-zero.
@error: | -1 - no text is selected 101 - $hWnd is not a handle

Remarks

The first character of the text is after inter-character position 0.

Related

_GUICtrlRichEdit_GetScrollPos, _GUICtrlRichEdit_GetSel, _GUICtrlRichEdit_SetSel

See Also

Search EM_EXGETSEL in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "Paragraph 1")
    _GUICtrlRichEdit_SetSel($g_hRichEdit, 7, 2)
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        Report("1. Selection is high to low")
                    Case 2
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 2, 7)
                        Report("2. Selection is low to high")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    Local $aRet = _GUICtrlRichEdit_GetSelAA($g_hRichEdit)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & $aRet[0] & "," & $aRet[1]
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetSelText

Function Reference

_GUICtrlRichEdit_GetSelText

Retrieves the currently selected text

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetSelText ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the selected text.
Failure: | sets the @error flag to non-zero.
@error: | -1 - no text is selected 101 - $hWnd is not a handle

Related

_GUICtrlRichEdit_GetSel

See Also

Search EM_EXGETSELTEXT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "Paragraph 1")
    _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, 4)

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        Report("Selected text is" & @CRLF & _GUICtrlRichEdit_GetSelText($g_hRichEdit))
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    Local $aRet = _GUICtrlRichEdit_GetSelAA($g_hRichEdit)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & $aRet[0] & "," & $aRet[1]
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetSpaceUnit

Function Reference

_GUICtrlRichEdit_GetSpaceUnit

Gets the unit of measure of horizontal and vertical space used in parameters of various _GUICtrlRichEdit functions

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetSpaceUnit ( )

Return Value

Returns "in", "cm", "mm", "pt" (points), or "tw" (twips, 1/1440 inches, 1/567 centimetres).

Remarks

Initially, space is measured in inches.

Related

_GUICtrlRichEdit_SetSpaceUnit

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $hRichEdit, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($hRichEdit, "Paragraph 1")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        Report("1. Initial setting")
                    Case 2
                        _GUICtrlRichEdit_SetSpaceUnit("cm")
                        Report("2. Setting is now")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & _GUICtrlRichEdit_GetSpaceUnit()
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetText

Function Reference

_GUICtrlRichEdit_GetText

Get all of the text in the control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetText ( $hWnd [, $bCrToCrLf = False [, $iCodePage = 0 [, $sReplChar = ""]]] )

Parameters

$hWnd | Handle to the control
$bCrToCrLf | [optional] Convert each CR to a CrLf True - do it False - don't (Default)
$iCodePage | [optional] code page used in translation Default: use system default CP_ACP for ANSI, 1200 for Unicode
$sReplChar | [optional] Character used if $iCodePage is not 1200 and a wide character cannot be represented in specified code page

Return Value

Success: | the text.
Failure: | "" and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $bCrToCrLf must be True or False 103 - $iCodePage is not a number 700 - internal error

Remarks

On success, if $sReplChar set, @extended contains whether this character was used.

Call _GUICtrlRichEdit_IsModified() to determine whether the text has changed.

Related

_GUICtrlRichEdit_AppendText, _GUICtrlRichEdit_InsertText, _GUICtrlRichEdit_IsModified, _GUICtrlRichEdit_SetText

See Also

Search EM_GETTEXTEX in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $hRichEdit, $iMsg
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is appended text.")

    Report("Text Appended: " & @CRLF & @CRLF & _GUICtrlRichEdit_GetText($hRichEdit))

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetTextInLine

Function Reference

_GUICtrlRichEdit_GetTextInLine

Gets a line of text

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetTextInLine ( $hWnd, $iLine )

Parameters

$hWnd | Handle to the control
$iLine | Line number

Return Value

Success: | the text.
Failure: | sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 1021 - $iLine is not a positive number 1022 - $iLine exceeds number of lines in control 700 - internal error

Remarks

The first line in a control is 1.

Related

_GUICtrlRichEdit_GetSel, _GUICtrlRichEdit_GetTextInRange

See Also

Search EM_GETLINE in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $hRichEdit
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($hRichEdit, "This is a test." & @CRLF & "More text in another line")
    Report(_GUICtrlRichEdit_GetTextInLine($hRichEdit, 1))

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetTextInRange

Function Reference

_GUICtrlRichEdit_GetTextInRange

Gets the text from from one inter-character position to another

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetTextInRange ( $hWnd, $iStart, $iEnd )

Parameters

$hWnd | Handle to the control
$iStart | Inter-character position before the text
$iEnd | Inter-character position after the text Special value: -1 - end of text

Return Value

Success: | the text.
Failure: | sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $iStart is neither positive nor zero 1031 - $iEnd is neither positive nor zero nor -1 1032 - $iStart < $iEnd and $iEnd &l;> -1

Remarks

The first character position in the control is 0.

Related

_GUICtrlRichEdit_GetTextInLine

See Also

Search EM_GETTEXTRANGE in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_LINK)

    _GUICtrlRichEdit_AutoDetectURL($g_hRichEdit, True)
    _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "http://www.autoitscript.com")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $tEnLink, $iCpMin, $iCpMax, $tMsgFilter
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hRichEdit
            Select
                Case $iCode = $EN_LINK
                    $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_LBUTTONUP Then
                        $tEnLink = DllStructCreate($tagENLINK, $lParam)
                        $iCpMin = DllStructGetData($tEnLink, "cpMin")
                        $iCpMax = DllStructGetData($tEnLink, "cpMax")
                        MsgBox($MB_SYSTEMMODAL, "", "Invoke your web browser here and point it to " & _
                                _GUICtrlRichEdit_GetTextInRange($g_hRichEdit, $iCpMin, $iCpMax))
                    EndIf
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY


Function _GUICtrlRichEdit_GetTextLength

Function Reference

_GUICtrlRichEdit_GetTextLength

Get the length of the whole text in the control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetTextLength ( $hWnd [, $bExact = True [, $bChars = False]] )

Parameters

$hWnd | Handle to the control
$bExact | [optional] True - Return the exact length False - return at least the number of characters in the control (faster) Default: exact length
$bChars | [optional] True - return length in characters False - return length in bytes Default: bytes

Return Value

Success: | the length, in bytes or characters.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $bExact must be True or False 103 - $bChars must be True or False

See Also

Search EM_GETTEXTLENGTHEX in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $hRichEdit
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is appended text.")

    Report("There are " & _GUICtrlRichEdit_GetTextLength($hRichEdit, True, True) & _
            " characters in the control")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetVersion

Function Reference

_GUICtrlRichEdit_GetVersion

Retrieves the version of Rich Edit

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetVersion ( )

Return Value

None.

Remarks

The versions of Rich Edit included in versions of Windows are:
3.0 - Windows XP
3.1 - Windows Vista
4.0 - Windows XP SP1
4.1 - Windows Vista or later

Example

#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGui, $iMsg, $hRichEdit
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($hRichEdit, "This is a test.")
    MsgBox($MB_SYSTEMMODAL, "", _GUICtrlRichEdit_GetVersion())

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRichEdit_GetXYFromCharPos

Function Reference

_GUICtrlRichEdit_GetXYFromCharPos

Retrieves the XY coordinates of an inter-character position

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetXYFromCharPos ( $hWnd, $iCharPos )

Parameters

$hWnd | Handle to the control
$iCharPos | Inter-character position

Return Value

Success: | an array [, ] - coordinates of the inter-character position, relative to the top-left corner of the client area.
Failure: | sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 1021 - $iCharPos is neither a positive number nor zero 1022 - $iCharPos exceeds the number of characters in the control

Remarks

The first inter-character position is numbered 0.

With a multi-line control, coordinates are returned even for inter-character positions that are not visible.

Related

_GUICtrlRichEdit_GetCharPosFromXY

See Also

Search EM_POSFROMCHAR in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $hRichEdit, $iMsg, $aiPos, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is appended text.")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        $aiPos = _GUICtrlRichEdit_GetXYFromCharPos($hRichEdit, 20)
                        Report("1.The coordinates of inter-character position 20 are (" & $aiPos[0] & "," & $aiPos[1] & ")")
                    Case 2
                        Report("2.The inter-character position at or nearest coordinates (" & $aiPos[0] & "," & $aiPos[1] & ") is " & _
                                _GUICtrlRichEdit_GetCharPosFromXY($hRichEdit, $aiPos[0], $aiPos[1]))
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GetZoom

Function Reference

_GUICtrlRichEdit_GetZoom

Gets the zoom level of the control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetZoom ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the zoom level, in percent.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 700 - internal error

Related

_GUICtrlRichEdit_SetZoom

See Also

Search EM_GETZOOM in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $hRichEdit, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is appended text.")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        Report("1.Now zoomed to " & _GUICtrlRichEdit_GetZoom($hRichEdit) & "%")
                    Case 2
                        _GUICtrlRichEdit_SetZoom($hRichEdit, 250)
                        Report("2.Now zoomed to " & _GUICtrlRichEdit_GetZoom($hRichEdit) & "%")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_GotoCharPos

Function Reference

_GUICtrlRichEdit_GotoCharPos

Moves the insertion point to an inter-character position

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GotoCharPos ( $hWnd, $iCharPos )

Parameters

$hWnd | Handle to the control
$iCharPos | the inter character position Special value: -1 - end of text

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $iCharPos is neither a positive number nor zero nor -1

Remarks

The first character of the text in a control is at character position 0.

Cancels text selection (if any).

Related

_GUICtrlRichEdit_SetSel

See Also

Search EM_EXSETSEL in MSDN Library.

Example

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

Example()

Func Example()
    Local $hGui, $iMsg, $hRichEdit
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($hRichEdit, "This is a test.")
    _GUICtrlRichEdit_GotoCharPos($hRichEdit, 8)

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRichEdit_HideSelection

Function Reference

_GUICtrlRichEdit_HideSelection

Hides (or shows) a selection

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_HideSelection ( $hWnd [, $bHide = True] )

Parameters

$hWnd | Handle to the control
$bHide | [optional] True - hide False - show Default: hide

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $bHide must be True or False

See Also

Search EM_HIDESELECTION in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "First paragraph")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 2, 5)
                        Report("Text is selected")
                    Case 2
                        _GUICtrlRichEdit_HideSelection($g_hRichEdit, True)
                        Report("Selection is hidden")
                    Case 3
                        _GUICtrlRichEdit_HideSelection($g_hRichEdit, False)
                        Report("Selection is not hidden")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    Local $sRet = _GUICtrlRichEdit_GetCharAttributes($g_hRichEdit)
    $sMsg = $sMsg & @CRLF & @CRLF & "Char Attributes=" & $sRet
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_InsertText

Function Reference

_GUICtrlRichEdit_InsertText

Inserts text at insertion point or anchor point of selection

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_InsertText ( $hWnd, $sText )

Parameters

$hWnd | Handle to the control
$sText | Text to be inserted

Return Value

Succcess: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $sText = "" 103 - Cannot be set

Related

_GUICtrlRichEdit_AppendText, _GUICtrlRichEdit_GetText, _GUICtrlRichEdit_ReplaceText, _GUICtrlRichEdit_SetText

See Also

Search EM_SETTEXTEX in MSDN Library.

Example

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

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0, $idLblMsg, $hRichEdit
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($hRichEdit, "First paragraph")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetSel($hRichEdit, 5, 2)
                    Case 2
                        _GUICtrlRichEdit_InsertText($hRichEdit, "INSERTED_1")
                        GUICtrlSetData($idLblMsg, "Text is inserted at active point of selection")
                    Case 3
                        _GUICtrlRichEdit_GotoCharPos($hRichEdit, 20)
                        _GUICtrlRichEdit_InsertText($hRichEdit, "INSERTED_2")
                        GUICtrlSetData($idLblMsg, "Text is inserted at insertion point")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRichEdit_IsModified

Function Reference

_GUICtrlRichEdit_IsModified

Retrieves the state of a rich edit control's modification flag

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_IsModified ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True or False.
Failure: | sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Remarks

The system automatically sets the modification flag to False when the control is created.
If the control's text is changed, either by the user or programmatically, the system sets the flag to True Call _GUICtrlRichEdit_SetModified() to set or clear the flag.

Related

_GUICtrlRichEdit_GetText, _GUICtrlRichEdit_SetModified

See Also

Search EM_GETMODIFY in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    Report("Initial state after creation")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "A paragraph")
                        Report("Added some text")
                    Case 2
                        _GUICtrlRichEdit_SetModified($g_hRichEdit, False)
                        Report("After clearing the modification flag")
                    Case 3
                        GUICtrlSetData($g_idLblMsg, "Type some text. Then click on Next")
                    Case 4
                        Report("After typing")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & @CRLF & "State is " & _GUICtrlRichEdit_IsModified($g_hRichEdit)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_IsTextSelected

Function Reference

_GUICtrlRichEdit_IsTextSelected

Is text selected?

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_IsTextSelected ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True or False.
Failure: | sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Related

_GUICtrlRichEdit_Deselect, _GUICtrlRichEdit_GetSel, _GUICtrlRichEdit_SetSel

See Also

Search EM_EXGETSEL in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_hRichEdit, $g_idMnu, $g_idMnuUndo, $g_idMnuRedo, $g_idMnuCut, $g_idMnuCopy
Global $g_idMnuPaste, $g_idMnuPasteSpl

Example()

Func Example()
    Local $hGui, $idMnuPasteSplRTF, $idMnuPasteSplwObjs
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($g_hRichEdit, ReadBmpToRtf(FindFirstBMP()))

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    $g_idMnu = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
    $g_idMnuUndo = GUICtrlCreateMenuItem("Undo", $g_idMnu)
    $g_idMnuRedo = GUICtrlCreateMenuItem("Redo", $g_idMnu)
    GUICtrlCreateMenuItem("", $g_idMnu)
    $g_idMnuCut = GUICtrlCreateMenuItem("Cut", $g_idMnu)
    $g_idMnuCopy = GUICtrlCreateMenuItem("Copy", $g_idMnu)
    $g_idMnuPaste = GUICtrlCreateMenuItem("Paste", $g_idMnu)
    $g_idMnuPasteSpl = GUICtrlCreateMenu("Paste Special", $g_idMnu)
    $idMnuPasteSplRTF = GUICtrlCreateMenuItem("RTF only", $g_idMnuPasteSpl)
    $idMnuPasteSplwObjs = GUICtrlCreateMenuItem("With objects", $g_idMnuPasteSpl)
    _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_MOUSEEVENTS)

    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $g_idMnuUndo
                _GUICtrlRichEdit_Undo($g_hRichEdit)
            Case $g_idMnuRedo
                _GUICtrlRichEdit_Redo($g_hRichEdit)
            Case $g_idMnuCut
                _GUICtrlRichEdit_Cut($g_hRichEdit)
            Case $g_idMnuCopy
                _GUICtrlRichEdit_Copy($g_hRichEdit)
            Case $g_idMnuPaste
                _GUICtrlRichEdit_Paste($g_hRichEdit)
            Case $idMnuPasteSplRTF
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, False)
            Case $idMnuPasteSplwObjs
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, True)
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hRichEdit
            Select
                Case $iCode = $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_RBUTTONUP Then
                        $hMenu = GUICtrlGetHandle($g_idMnu)
                        SetMenuTexts($hWndFrom, $hMenu)
                        _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    EndIf
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func SetMenuTexts($hWnd, $hMenu)
    Local $bState
    If _GUICtrlRichEdit_CanUndo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo: " & _GUICtrlRichEdit_GetNextUndo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, False, False)
    EndIf
    If _GUICtrlRichEdit_CanRedo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo: " & _GUICtrlRichEdit_GetNextRedo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, False, False)
    EndIf
    $bState = _GUICtrlRichEdit_IsTextSelected($hWnd)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCut, $bState, False)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCopy, $bState, False)

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPaste, _GUICtrlRichEdit_CanPaste($hWnd))

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPasteSpl, _GUICtrlRichEdit_CanPasteSpecial($hWnd), False)
EndFunc   ;==>SetMenuTexts

Func ReadBmpToRtf($sBmpFilspc)
    Local $hFile, $sRtf
    $hFile = FileOpen($sBmpFilspc, $FO_BINARY)
    If FileRead($hFile, 2) <> "0x424D" Then Return SetError(1, 0, "")
    FileRead($hFile, 12)
    $sRtf = '{\rtf1{\pict\dibitmap ' & Hex(FileRead($hFile)) & '}}'
    FileClose($hFile)
    Return $sRtf
EndFunc   ;==>ReadBmpToRtf

Func FindFirstBMP($sPath = Default)
    If $sPath = Default Then
        ; X64 running support
        Local $sWow64 = ""
        If @AutoItX64 Then $sWow64 = "\Wow6432Node"

        $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images"
    EndIf
    Local $hFind, $sBmpFilspc
    $hFind = FileFindFirstFile($sPath & "\*.bmp")
    $sBmpFilspc = FileFindNextFile($hFind)
    FileClose($hFind)
    Return $sPath & "\" & $sBmpFilspc
EndFunc   ;==>FindFirstBMP


Function _GUICtrlRichEdit_Paste

Function Reference

_GUICtrlRichEdit_Paste

Paste RTF or RTF with Objects from clipboard

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_Paste ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Remarks

Pastes with objects if available, else without.

Related

_GUICtrlRichEdit_CanPaste, _GUICtrlRichEdit_Copy, _GUICtrlRichEdit_Cut, _GUICtrlRichEdit_PasteSpecial

See Also

Search WM_PASTE in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_hRichEdit, $g_idMnu, $g_idMnuUndo, $g_idMnuRedo, $g_idMnuCut, $g_idMnuCopy
Global $g_idMnuPaste, $g_idMnuPasteSpl

Example()

Func Example()
    Local $hGui, $idMnuPasteSplRTF, $idMnuPasteSplwObjs
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($g_hRichEdit, ReadBmpToRtf(FindFirstBMP()))

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    $g_idMnu = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
    $g_idMnuUndo = GUICtrlCreateMenuItem("Undo", $g_idMnu)
    $g_idMnuRedo = GUICtrlCreateMenuItem("Redo", $g_idMnu)
    GUICtrlCreateMenuItem("", $g_idMnu)
    $g_idMnuCut = GUICtrlCreateMenuItem("Cut", $g_idMnu)
    $g_idMnuCopy = GUICtrlCreateMenuItem("Copy", $g_idMnu)
    $g_idMnuPaste = GUICtrlCreateMenuItem("Paste", $g_idMnu)
    $g_idMnuPasteSpl = GUICtrlCreateMenu("Paste Special", $g_idMnu)
    $idMnuPasteSplRTF = GUICtrlCreateMenuItem("RTF only", $g_idMnuPasteSpl)
    $idMnuPasteSplwObjs = GUICtrlCreateMenuItem("With objects", $g_idMnuPasteSpl)
    _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_MOUSEEVENTS)

    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $g_idMnuUndo
                _GUICtrlRichEdit_Undo($g_hRichEdit)
            Case $g_idMnuRedo
                _GUICtrlRichEdit_Redo($g_hRichEdit)
            Case $g_idMnuCut
                _GUICtrlRichEdit_Cut($g_hRichEdit)
            Case $g_idMnuCopy
                _GUICtrlRichEdit_Copy($g_hRichEdit)
            Case $g_idMnuPaste
                _GUICtrlRichEdit_Paste($g_hRichEdit)
            Case $idMnuPasteSplRTF
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, False)
            Case $idMnuPasteSplwObjs
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, True)
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hRichEdit
            Select
                Case $iCode = $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_RBUTTONUP Then
                        $hMenu = GUICtrlGetHandle($g_idMnu)
                        SetMenuTexts($hWndFrom, $hMenu)
                        _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    EndIf
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func SetMenuTexts($hWnd, $hMenu)
    Local $bState
    If _GUICtrlRichEdit_CanUndo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo: " & _GUICtrlRichEdit_GetNextUndo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, False, False)
    EndIf
    If _GUICtrlRichEdit_CanRedo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo: " & _GUICtrlRichEdit_GetNextRedo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, False, False)
    EndIf
    $bState = _GUICtrlRichEdit_IsTextSelected($hWnd)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCut, $bState, False)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCopy, $bState, False)

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPaste, _GUICtrlRichEdit_CanPaste($hWnd))

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPasteSpl, _GUICtrlRichEdit_CanPasteSpecial($hWnd), False)
EndFunc   ;==>SetMenuTexts

Func ReadBmpToRtf($sBmpFilspc)
    Local $hFile, $sRtf
    $hFile = FileOpen($sBmpFilspc, $FO_BINARY)
    If FileRead($hFile, 2) <> "0x424D" Then Return SetError(1, 0, "")
    FileRead($hFile, 12)
    $sRtf = '{\rtf1{\pict\dibitmap ' & Hex(FileRead($hFile)) & '}}'
    FileClose($hFile)
    Return $sRtf
EndFunc   ;==>ReadBmpToRtf

Func FindFirstBMP($sPath = Default)
    If $sPath = Default Then
        ; X64 running support
        Local $sWow64 = ""
        If @AutoItX64 Then $sWow64 = "\Wow6432Node"

        $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images"
    EndIf
    Local $hFind, $sBmpFilspc
    $hFind = FileFindFirstFile($sPath & "\*.bmp")
    $sBmpFilspc = FileFindNextFile($hFind)
    FileClose($hFind)
    Return $sPath & "\" & $sBmpFilspc
EndFunc   ;==>FindFirstBMP


Function _GUICtrlRichEdit_PasteSpecial

Function Reference

_GUICtrlRichEdit_PasteSpecial

Paste RTF or RTF and Objects from clipboard

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_PasteSpecial ( $hWnd [, $bAndObjects = True] )

Parameters

$hWnd | Handle to the control
$bAndObjects | [optional] Paste objects as well as RTF - True (default) or False

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Related

_GUICtrlRichEdit_CanPasteSpecial, _GUICtrlRichEdit_Copy, _GUICtrlRichEdit_Cut, _GUICtrlRichEdit_Paste

See Also

Search WM_PASTESPECIAL in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_hRichEdit, $g_idMnu, $g_idMnuUndo, $g_idMnuRedo, $g_idMnuCut, $g_idMnuCopy
Global $g_idMnuPaste, $g_idMnuPasteSpl

Example()

Func Example()
    Local $hGui, $idMnuPasteSplRTF, $idMnuPasteSplwObjs
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($g_hRichEdit, ReadBmpToRtf(FindFirstBMP()))

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    $g_idMnu = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
    $g_idMnuUndo = GUICtrlCreateMenuItem("Undo", $g_idMnu)
    $g_idMnuRedo = GUICtrlCreateMenuItem("Redo", $g_idMnu)
    GUICtrlCreateMenuItem("", $g_idMnu)
    $g_idMnuCut = GUICtrlCreateMenuItem("Cut", $g_idMnu)
    $g_idMnuCopy = GUICtrlCreateMenuItem("Copy", $g_idMnu)
    $g_idMnuPaste = GUICtrlCreateMenuItem("Paste", $g_idMnu)
    $g_idMnuPasteSpl = GUICtrlCreateMenu("Paste Special", $g_idMnu)
    $idMnuPasteSplRTF = GUICtrlCreateMenuItem("RTF only", $g_idMnuPasteSpl)
    $idMnuPasteSplwObjs = GUICtrlCreateMenuItem("With objects", $g_idMnuPasteSpl)
    _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_MOUSEEVENTS)

    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $g_idMnuUndo
                _GUICtrlRichEdit_Undo($g_hRichEdit)
            Case $g_idMnuRedo
                _GUICtrlRichEdit_Redo($g_hRichEdit)
            Case $g_idMnuCut
                _GUICtrlRichEdit_Cut($g_hRichEdit)
            Case $g_idMnuCopy
                _GUICtrlRichEdit_Copy($g_hRichEdit)
            Case $g_idMnuPaste
                _GUICtrlRichEdit_Paste($g_hRichEdit)
            Case $idMnuPasteSplRTF
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, False)
            Case $idMnuPasteSplwObjs
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, True)
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hRichEdit
            Select
                Case $iCode = $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_RBUTTONUP Then
                        $hMenu = GUICtrlGetHandle($g_idMnu)
                        SetMenuTexts($hWndFrom, $hMenu)
                        _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    EndIf
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func SetMenuTexts($hWnd, $hMenu)
    Local $bState
    If _GUICtrlRichEdit_CanUndo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo: " & _GUICtrlRichEdit_GetNextUndo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, False, False)
    EndIf
    If _GUICtrlRichEdit_CanRedo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo: " & _GUICtrlRichEdit_GetNextRedo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, False, False)
    EndIf
    $bState = _GUICtrlRichEdit_IsTextSelected($hWnd)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCut, $bState, False)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCopy, $bState, False)

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPaste, _GUICtrlRichEdit_CanPaste($hWnd))

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPasteSpl, _GUICtrlRichEdit_CanPasteSpecial($hWnd), False)
EndFunc   ;==>SetMenuTexts

Func ReadBmpToRtf($sBmpFilspc)
    Local $hFile, $sRtf
    $hFile = FileOpen($sBmpFilspc, $FO_BINARY)
    If FileRead($hFile, 2) <> "0x424D" Then Return SetError(1, 0, "")
    FileRead($hFile, 12)
    $sRtf = '{\rtf1{\pict\dibitmap ' & Hex(FileRead($hFile)) & '}}'
    FileClose($hFile)
    Return $sRtf
EndFunc   ;==>ReadBmpToRtf

Func FindFirstBMP($sPath = Default)
    If $sPath = Default Then
        ; X64 running support
        Local $sWow64 = ""
        If @AutoItX64 Then $sWow64 = "\Wow6432Node"

        $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images"
    EndIf
    Local $hFind, $sBmpFilspc
    $hFind = FileFindFirstFile($sPath & "\*.bmp")
    $sBmpFilspc = FileFindNextFile($hFind)
    FileClose($hFind)
    Return $sPath & "\" & $sBmpFilspc
EndFunc   ;==>FindFirstBMP


Function _GUICtrlRichEdit_PauseRedraw

Function Reference

_GUICtrlRichEdit_PauseRedraw

Pauses redrawing of the control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_PauseRedraw ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Related

_GUICtrlRichEdit_ResumeRedraw

See Also

Search WM_SETREDRAW in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $hRichEdit, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($hRichEdit, "First paragraph")
    _GUICtrlRichEdit_PauseRedraw($hRichEdit)
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetSel($hRichEdit, 5, 2)
                        Report("1.Redraw is paused")
                    Case 2
                        _GUICtrlRichEdit_InsertText($hRichEdit, "INSERTED_2")
                        Report("2.Text is inserted at active point of selection")
                    Case 3
                        _GUICtrlRichEdit_GotoCharPos($hRichEdit, 20)
                        _GUICtrlRichEdit_InsertText($hRichEdit, "INSERTED_3")
                        Report("3.Text is inserted at insertion point and Redraw is resume")
                        _GUICtrlRichEdit_ResumeRedraw($hRichEdit)
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_Redo

Function Reference

_GUICtrlRichEdit_Redo

Redoes last undone action

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_Redo ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Related

_GUICtrlRichEdit_CanRedo, _GUICtrlRichEdit_EmptyUndoBuffer, _GUICtrlRichEdit_GetNextRedo, _GUICtrlRichEdit_SetUndoLimit, _GUICtrlRichEdit_Undo

See Also

Search EM_REDO in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_hRichEdit, $g_idMnu, $g_idMnuUndo, $g_idMnuRedo, $g_idMnuCut, $g_idMnuCopy
Global $g_idMnuPaste, $g_idMnuPasteSpl

Example()

Func Example()
    Local $hGui, $idMnuPasteSplRTF, $idMnuPasteSplwObjs
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($g_hRichEdit, ReadBmpToRtf(FindFirstBMP()) & @CRLF)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    $g_idMnu = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
    $g_idMnuUndo = GUICtrlCreateMenuItem("Undo", $g_idMnu)
    $g_idMnuRedo = GUICtrlCreateMenuItem("Redo", $g_idMnu)
    GUICtrlCreateMenuItem("", $g_idMnu)
    $g_idMnuCut = GUICtrlCreateMenuItem("Cut", $g_idMnu)
    $g_idMnuCopy = GUICtrlCreateMenuItem("Copy", $g_idMnu)
    $g_idMnuPaste = GUICtrlCreateMenuItem("Paste", $g_idMnu)
    $g_idMnuPasteSpl = GUICtrlCreateMenu("Paste Special", $g_idMnu)
    $idMnuPasteSplRTF = GUICtrlCreateMenuItem("RTF only", $g_idMnuPasteSpl)
    $idMnuPasteSplwObjs = GUICtrlCreateMenuItem("With objects", $g_idMnuPasteSpl)
    _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_MOUSEEVENTS)

    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $g_idMnuUndo
                _GUICtrlRichEdit_Undo($g_hRichEdit)
            Case $g_idMnuRedo
                _GUICtrlRichEdit_Redo($g_hRichEdit)
            Case $g_idMnuCut
                _GUICtrlRichEdit_Cut($g_hRichEdit)
            Case $g_idMnuCopy
                _GUICtrlRichEdit_Copy($g_hRichEdit)
            Case $g_idMnuPaste
                _GUICtrlRichEdit_Paste($g_hRichEdit)
            Case $idMnuPasteSplRTF
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, False)
            Case $idMnuPasteSplwObjs
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, True)
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hRichEdit
            Select
                Case $iCode = $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_RBUTTONUP Then
                        $hMenu = GUICtrlGetHandle($g_idMnu)
                        _SetMenuTexts($hWndFrom, $hMenu)
                        _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    EndIf
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _SetMenuTexts($hWnd, $hMenu)
    Local $bState
    If _GUICtrlRichEdit_CanUndo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo: " & _GUICtrlRichEdit_GetNextUndo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, False, False)
    EndIf
    If _GUICtrlRichEdit_CanRedo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo: " & _GUICtrlRichEdit_GetNextRedo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, False, False)
    EndIf
    $bState = _GUICtrlRichEdit_IsTextSelected($hWnd)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCut, $bState, False)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCopy, $bState, False)

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPaste, _GUICtrlRichEdit_CanPaste($hWnd))

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPasteSpl, _GUICtrlRichEdit_CanPasteSpecial($hWnd), False)
EndFunc   ;==>_SetMenuTexts

Func ReadBmpToRtf($sBmpFilspc)
    Local $hFile, $sRtf
    $hFile = FileOpen($sBmpFilspc, 16)
    If FileRead($hFile, 2) <> "0x424D" Then Return SetError(1, 0, "")
    FileRead($hFile, 12)
    $sRtf = '{\rtf1{\pict\dibitmap ' & Hex(FileRead($hFile)) & '}}'
    FileClose($hFile)
    Return $sRtf
EndFunc   ;==>ReadBmpToRtf

Func FindFirstBMP($sPath = @WindowsDir)
    Local $hFind, $sBmpFilspc
    $hFind = FileFindFirstFile($sPath & "\*.bmp")
    $sBmpFilspc = FileFindNextFile($hFind)
    FileClose($hFind)
    Return $sPath & "\" & $sBmpFilspc
EndFunc   ;==>FindFirstBMP


Function _GUICtrlRichEdit_ReplaceText

Function Reference

_GUICtrlRichEdit_ReplaceText

Replaces selected text

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_ReplaceText ( $hWnd, $sText [, $bCanUndo = True] )

Parameters

$hWnd | Handle to the control
$sText | Replacement text
$bCanUndo | [optional] Can operation can be undone? True (Default) or False

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 103 - $bCanUndo must be True or False -1 - no text is selected

Related

_GUICtrlRichEdit_AppendText, _GUICtrlRichEdit_InsertText, _GUICtrlRichEdit_SetText

See Also

Search EM_REPLACESEL in MSDN Library.

Example

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

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0, $idLblMsg, $hRichEdit
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($hRichEdit, "First paragraph")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetSel($hRichEdit, 0, 5)
                    Case 2
                        _GUICtrlRichEdit_ReplaceText($hRichEdit, "1st")
                        GUICtrlSetData($idLblMsg, "Text has been replaced")
                    Case 3
                        _GUICtrlRichEdit_SetSel($hRichEdit, 0, 3)
                        _GUICtrlRichEdit_ReplaceText($hRichEdit, "")
                        GUICtrlSetData($idLblMsg, "1st has been deleted")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRichEdit_ResumeRedraw

Function Reference

_GUICtrlRichEdit_ResumeRedraw

Resumes redrawing of the control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_ResumeRedraw ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Related

_GUICtrlRichEdit_PauseRedraw

See Also

Search WM_SETREDRAW in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $hRichEdit, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($hRichEdit, "First paragraph")
    _GUICtrlRichEdit_PauseRedraw($hRichEdit)
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetSel($hRichEdit, 5, 2)
                        Report("1.Redraw is paused")
                    Case 2
                        _GUICtrlRichEdit_InsertText($hRichEdit, "INSERTED_2")
                        Report("2.Text is inserted at active point of selection")
                    Case 3
                        _GUICtrlRichEdit_GotoCharPos($hRichEdit, 20)
                        _GUICtrlRichEdit_InsertText($hRichEdit, "INSERTED_3")
                        Report("3.Text is inserted at insertion point and Redraw is resume")
                        _GUICtrlRichEdit_ResumeRedraw($hRichEdit)
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_ScrollLineOrPage

Function Reference

_GUICtrlRichEdit_ScrollLineOrPage

Scrolls the text down or up a line or a page

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_ScrollLineOrPage ( $hWnd, $sAction )

Parameters

$hWnd | Handle to the control
$sAction | one of the following: "ld" - line down "lu" - line up "pd" - page down "pu" - page up

Return Value

Success: | the number of lines actually scrolled (positive if down).
Failure: | 0 and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 1021 - $sAction is not two characters 1022 - first character must be l or p 1023 - second character must be d or u

Remarks

This function is well behaved: it never scrolls such that lines beyond the last one are shown.

Related

_GUICtrlRichEdit_ScrollLines, _GUICtrlRichEdit_ScrollToCaret

See Also

Search EM_SCROLL in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    For $i = 1 To 20
        _GUICtrlRichEdit_AppendText($g_hRichEdit, "Line " & $i & @CRLF)
    Next
    _GUICtrlRichEdit_AppendText($g_hRichEdit, "Line 21")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        DoIt("lu", "Scrolled up a line")
                    Case 2
                        DoIt("pu", "Scrolled up a page")
                    Case 3
                        DoIt("pd", "Scrolled down a page")
                    Case 4
                        DoIt("pd", "Tried to scroll down another page")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func DoIt($sAction, $sMsg)
    Local $iQlines
    $iQlines = _GUICtrlRichEdit_ScrollLineOrPage($g_hRichEdit, $sAction)
    GUICtrlSetData($g_idLblMsg, $sMsg & @CRLF & @CRLF & "Actually scrolled " & @CRLF & $iQlines & " lines")
EndFunc   ;==>DoIt


Function _GUICtrlRichEdit_ScrollLines

Function Reference

_GUICtrlRichEdit_ScrollLines

Scrolls the text down or up a number of lines

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_ScrollLines ( $hWnd, $iQlines )

Parameters

$hWnd | Handle to the control
$iQlines | number of lines to scroll

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $iQlines is not numeric 700 - attempt to scroll a single-line control

Remarks

To scroll down, set $iQlines to a positive value; to scroll up, a negative value.

_GUICtrlRichEdit_ScrollLines() is well behaved:
if $iQlines is more than the number of lines below the current line, it scrolls to show only the last line;
if $iQlines is negative and specifies a line before the first one, it scrolls to show the first line at the top of the control window.

Related

_GUICtrlRichEdit_ScrollLineOrPage, _GUICtrlRichEdit_ScrollToCaret

See Also

Search EM_LINESCROLL in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $hRichEdit, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    For $i = 1 To 20
        _GUICtrlRichEdit_AppendText($hRichEdit, "Line " & $i & @CRLF)
    Next
    _GUICtrlRichEdit_AppendText($hRichEdit, "Line 21")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_ScrollLines($hRichEdit, -10.2)
                        Report("Scrolled up")
                    Case 2
                        _GUICtrlRichEdit_ScrollLines($hRichEdit, +100)
                        Report("Scrolled down so only last line shows")
                    Case 3
                        _GUICtrlRichEdit_ScrollLines($hRichEdit, -200)
                        Report("Scrolled up all the way")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_ScrollToCaret

Function Reference

_GUICtrlRichEdit_ScrollToCaret

Scrolls to show line on which caret (insertion point) is

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_ScrollToCaret ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Related

_GUICtrlRichEdit_ScrollLineOrPage, _GUICtrlRichEdit_ScrollLines

See Also

Search EM_SCROLLCARET in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $hRichEdit, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    For $i = 1 To 20
        _GUICtrlRichEdit_AppendText($hRichEdit, "Line " & $i & @CRLF)
    Next
    _GUICtrlRichEdit_AppendText($hRichEdit, "Line 21")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_ScrollLineOrPage($hRichEdit, "pu")
                        Report("Scrolled up a page")
                    Case 2
                        _GUICtrlRichEdit_ScrollToCaret($hRichEdit)
                        Report("Scrolled caret into view")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetBkColor

Function Reference

_GUICtrlRichEdit_SetBkColor

Sets the background color of the control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetBkColor ( $hWnd [, $iBngColor = Default] )

Parameters

$hWnd | Handle to the control
$iBngColor | [optional] one of the following: a number - a COLORREF value Default keyword - the system color (default)

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 1022 - $iBngColor is invalid

Remarks

If you need to create a COLORREF value from an color array use _ColorSetCOLORREF() not _ColorSetRGB().

Related

_GUICtrlRichEdit_GetBkColor

See Also

Search EM_SETBKGNDCOLOR in MSDN Library.

Example

#include <Color.au3>
#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "Paragraph 1")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetBkColor($g_hRichEdit, 0xE8CCCC)
                        Report("1. Colored background")
                    Case 2
                        _GUICtrlRichEdit_SetBkColor($g_hRichEdit)
                        Report("2. Back to white")
                    Case 3
                        _GUICtrlRichEdit_SetBkColor($g_hRichEdit, 0xB3B3C7)
                        Report("3. Colored background again")
                        ; Stream all text to the Desktop so you can look at settings in Word
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    Local $iBngColor = _GUICtrlRichEdit_GetBkColor($g_hRichEdit)
    Local $aRet = _ColorGetRGB($iBngColor)
    $sMsg = $sMsg & @CRLF & @CRLF & $aRet[0] & ";" & $aRet[1] & ";" & $aRet[2] & " BngColor=0x" & Hex($iBngColor)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetCharAttributes

Function Reference

_GUICtrlRichEdit_SetCharAttributes

Turns an attribute on or off for selected text or, if none selected, for text inserted at the insertion point

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetCharAttributes ( $hWnd, $sStatesAndEffects [, $bWord = False] )

Parameters

$hWnd | Handle to the control
$sStatesAndEffects | a string consisting of three character groups: + (or -) for the state, and a two-letter abbreviation for the attribute first character: + for on, - for off second and third character: any of: bo - bold di - disable - displays characters with a shadow [nd] em - emboss [nd] hi - hide, i.e. don't display im - imprint [nd] it - italcize li - send EN_LINK messages when mouse is over text with this attribute ou - outline [nd] pr - send EN_PROTECT when user attempts to modify re - mark as revised [nd] sh - shadow [nd] sm - small capital letters [nd] st - strike out sb - subscript [nd] sp - superscript [nd] un - underline
$bWord | [optional] True If text is selected, apply the attribute to whole words in the selected text If not: If the insertion point is in a word, or at the end of it, apply the attribute to the word If not, apply the attribute to text inserted at the insertion point False (Default) If text is selected, apply the attribute to the selected text If not, apply the attribute to text inserted at the insertion point

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 103 - $bWord must be True or False 1021 - length of $sStatesAndAtts is not multiple of 3 1022 - first character of group not + or -. The character is in @extended 1023 - An abbreviation for an attribute is invalid. It is in @extended

Remarks

Some attributes do not display; they are marked with [nd] above.

Related

_GUICtrlRichEdit_GetCharAttributes

See Also

Search EM_SETCHARFORMAT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "Paragraph 1 ")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, 2)
                        _GUICtrlRichEdit_SetCharAttributes($g_hRichEdit, "+un")
                        Report("1. Two characters underlined")
                    Case 2
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 1, 5)
                        _GUICtrlRichEdit_SetCharAttributes($g_hRichEdit, "+bo")
                        Report("2. Some characters bolded")
                    Case 3
                        ; Stream all text to the Desktop so you can look at settings in Word
                        _GUICtrlRichEdit_Deselect($g_hRichEdit)
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & @CRLF & _GUICtrlRichEdit_GetCharAttributes($g_hRichEdit)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetCharBkColor

Function Reference

_GUICtrlRichEdit_SetCharBkColor

Sets the background color of selected text or, if none selected, sets the background color of text inserted at the insertion point

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetCharBkColor ( $hWnd [, $iBkColor = Default] )

Parameters

$hWnd | Handle to the control
$iBkColor | [optional] one of the following: a number - a COLORREF value Default keyword - the system color (default)

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 1021 - $iBkColor: not 2 semicolons 1022 - $iBkColor: value not 0 to 100 1023 - $iBkColor: invalid character

Remarks

If you need to create a COLORREF value from an color array use _ColorSetCOLORREF() not _ColorSetRGB().

Related

_GUICtrlRichEdit_GetCharBkColor

See Also

Search EM_SETCHARFORMAT in MSDN Library.

Example

#include <Color.au3>
#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $idBtnNext, $iStep = 0
    $hGui = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 420, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, 'This is a test.', 10, 10, 400, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 60, 30)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                GUIDelete()
                Exit
            Case $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        Report("1. Initial setting")
                    Case 2
                        _GUICtrlRichEdit_SetCharBkColor($g_hRichEdit, Dec('00FF00'))
                        Report("2. Setting is now")
                    Case 3
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 1, 5)
                        _GUICtrlRichEdit_SetCharBkColor($g_hRichEdit, Dec('8888FF'))
                        Report("3. Background of a few characters changed")
                    Case 4
                        ; Stream all text to the Desktop so you can look at settings in Word
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                        GUICtrlSetData($g_idLblMsg, "4. Saved to a file on the desktop gcre.rtf")
                EndSwitch
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    Local $iColor = _GUICtrlRichEdit_GetCharBkColor($g_hRichEdit)
    Local $aRet = _ColorGetRGB($iColor)
    $sMsg &= @CRLF & @CRLF & $aRet[0] & ";" & $aRet[1] & ";" & $aRet[2] & " BkColor=0x" & Hex($iColor)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetCharColor

Function Reference

_GUICtrlRichEdit_SetCharColor

Sets the color of selected text or, if none selected, sets the background color of text inserted at the insertion point

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetCharColor ( $hWnd [, $iColor = Default] )

Parameters

$hWnd | Handle to the control
$iColor | [optional] one of the following: a number - a COLORREF value Default keyword - the system color (default)

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 1022 - $iColor is invalid

Remarks

If you need to create a COLORREF value from an color array use _ColorSetCOLORREF() not _ColorSetRGB().

Related

_GUICtrlRichEdit_GetCharColor

See Also

Search EM_SETCHARFORMAT in MSDN Library.

Example

#include <Color.au3>
#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "Paragraph 1")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        Report("1. Initial setting")
                    Case 2
                        _GUICtrlRichEdit_SetCharColor($g_hRichEdit, "304050")
                        Report("2. Setting is now")
                    Case 3
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 1, 5)
                        _GUICtrlRichEdit_SetCharColor($g_hRichEdit)
                        Report("3. Background of a few characters changed")
                    Case 4
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 6, -1)
                        ; Stream all text to the Desktop so you can look at settings in Word
                        _GUICtrlRichEdit_Deselect($g_hRichEdit)
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        Report("4. Saved to File")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    Local $iColor = _GUICtrlRichEdit_GetCharColor($g_hRichEdit)
    Local $sMixed = @extended ? "+" : "~"
    Local $aRet = _ColorGetRGB($iColor)
    $sMsg = $sMsg & @CRLF & @CRLF & $aRet[0] & ";" & $aRet[1] & ";" & $aRet[2] & " Color=0x" & Hex($iColor) & ":" & $sMixed
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetEventMask

Function Reference

_GUICtrlRichEdit_SetEventMask

Specifies which notification messages are sent to the parent window

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetEventMask ( $hWnd, $iEventMask )

Parameters

$hWnd Handle to the control
$iEventMask BitOR combination of :
$ENM_CHANGE - Sends $EN_CHANGE notifications (user may have altered text)
$ENM_CORRECTTEXT - Sends $EN_CORRECTTEXT notifications (parent window can cancel correction of text)
$ENM_DRAGDROPDONE - Sends $EN_DRAGDROPDONE notifications (drag and drop operation completed)
$ENM_DROPFILES - Sends $EN_DROPFILES notifications (user is attempting to drop files into the control)
$ENM_KEYEVENTS - Sends $EN_MSGFILTER notifications for keyboard events
$ENM_LINK - Sends $EN_LINK notifications when the mouse pointer is over text having the link character attribute set and when user clicks the mouse [2.0+]
$ENM_MOUSEEVENTS - Sends $EN_MSGFILTER notifications for mouse events to parent window
$ENM_OBJECTPOSITIONS - Sends $EN_OBJECTPOSITIONS notifications when the control reads in objects
$ENM_PROTECTED - Sends $EN_PROTECTED notifications when the user attempts to change characters having the protected attribute set
$ENM_REQUESTRESIZE - Sends $EN_REQUESTRESIZE notifications that the control's contents are either smaller or larger than the control's window size
$ENM_SCROLL - Sends $EN_HSCROLL and $EN_VSCROLL notifications when the user clicks the horizontal/vertical scroll bar
$ENM_SCROLLEVENTS - Sends EN_MSGFILTER notifications for mouse wheel events
$ENM_SELCHANGE - Sends EN_SELCHANGE notifications when the current selection changes
$ENM_UPDATE - Sends EN_UPDATE notifications when a control is about to redraw itself
or
$ENM_NONE - Disables sending of notification messages to the parent window

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $iEventMask is not a number

Remarks

The number in parentheses indicate which versions mask settings apply to.

$ENM_IMECHANGE only applies to Asian-language versions of Windows.

$EN_UPDATE notifications are always sent except for when 4.0 is emulating 1.0

Related

_GUICtrlRichEdit_AutoDetectURL

See Also

Search EM_SETEVENTMASK in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_hRichEdit, $g_idMnu, $g_idMnuUndo, $g_idMnuRedo, $g_idMnuCut, $g_idMnuCopy
Global $g_idMnuPaste, $g_idMnuPasteSpl

Example()

Func Example()
    Local $hGui, $idMnuPasteSplRTF, $idMnuPasteSplwObjs
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($g_hRichEdit, ReadBmpToRtf(FindFirstBMP()))

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    $g_idMnu = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
    $g_idMnuUndo = GUICtrlCreateMenuItem("Undo", $g_idMnu)
    $g_idMnuRedo = GUICtrlCreateMenuItem("Redo", $g_idMnu)
    GUICtrlCreateMenuItem("", $g_idMnu)
    $g_idMnuCut = GUICtrlCreateMenuItem("Cut", $g_idMnu)
    $g_idMnuCopy = GUICtrlCreateMenuItem("Copy", $g_idMnu)
    $g_idMnuPaste = GUICtrlCreateMenuItem("Paste", $g_idMnu)
    $g_idMnuPasteSpl = GUICtrlCreateMenu("Paste Special", $g_idMnu)
    $idMnuPasteSplRTF = GUICtrlCreateMenuItem("RTF only", $g_idMnuPasteSpl)
    $idMnuPasteSplwObjs = GUICtrlCreateMenuItem("With objects", $g_idMnuPasteSpl)
    _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_MOUSEEVENTS)

    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $g_idMnuUndo
                _GUICtrlRichEdit_Undo($g_hRichEdit)
            Case $g_idMnuRedo
                _GUICtrlRichEdit_Redo($g_hRichEdit)
            Case $g_idMnuCut
                _GUICtrlRichEdit_Cut($g_hRichEdit)
            Case $g_idMnuCopy
                _GUICtrlRichEdit_Copy($g_hRichEdit)
            Case $g_idMnuPaste
                _GUICtrlRichEdit_Paste($g_hRichEdit)
            Case $idMnuPasteSplRTF
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, False)
            Case $idMnuPasteSplwObjs
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, True)
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hRichEdit
            Select
                Case $iCode = $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_RBUTTONUP Then
                        $hMenu = GUICtrlGetHandle($g_idMnu)
                        SetMenuTexts($hWndFrom, $hMenu)
                        _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    EndIf
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func SetMenuTexts($hWnd, $hMenu)
    Local $bState
    If _GUICtrlRichEdit_CanUndo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo: " & _GUICtrlRichEdit_GetNextUndo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, False, False)
    EndIf
    If _GUICtrlRichEdit_CanRedo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo: " & _GUICtrlRichEdit_GetNextRedo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, False, False)
    EndIf
    $bState = _GUICtrlRichEdit_IsTextSelected($hWnd)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCut, $bState, False)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCopy, $bState, False)

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPaste, _GUICtrlRichEdit_CanPaste($hWnd))

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPasteSpl, _GUICtrlRichEdit_CanPasteSpecial($hWnd), False)
EndFunc   ;==>SetMenuTexts

Func ReadBmpToRtf($sBmpFilspc)
    Local $hFile, $sRtf
    $hFile = FileOpen($sBmpFilspc, $FO_BINARY)
    If FileRead($hFile, 2) <> "0x424D" Then Return SetError(1, 0, "")
    FileRead($hFile, 12)
    $sRtf = '{\rtf1{\pict\dibitmap ' & Hex(FileRead($hFile)) & '}}'
    FileClose($hFile)
    Return $sRtf
EndFunc   ;==>ReadBmpToRtf

Func FindFirstBMP($sPath = Default)
    If $sPath = Default Then
        ; X64 running support
        Local $sWow64 = ""
        If @AutoItX64 Then $sWow64 = "\Wow6432Node"

        $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images"
    EndIf
    Local $hFind, $sBmpFilspc
    $hFind = FileFindFirstFile($sPath & "\*.bmp")
    $sBmpFilspc = FileFindNextFile($hFind)
    FileClose($hFind)
    Return $sPath & "\" & $sBmpFilspc
EndFunc   ;==>FindFirstBMP


Function _GUICtrlRichEdit_SetFont

Function Reference

_GUICtrlRichEdit_SetFont

Sets the font attributes of selected text or, if none selected, sets those of text inserted at the insertion point

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetFont ( $hWnd [, $iPoints = Default [, $sName = Default [, $iCharset = Default [, $iLcid = Default]]]] )

Parameters

$hWnd | Handle to the control
$iPoints | [optional] point size
$sName | [optional] the name of the font face, e.g. "Courier" not "Courier Bold"
$iCharSet | [optional] the character set - one of: $ANSI_CHARSET - 0 $BALTIC_CHARSET - 186 $CHINESEBIG5_CHARSET - 136 $DEFAULT_CHARSET - 1 $EASTEUROPE_CHARSET - 238 $GB2312_CHARSET - 134 $GREEK_CHARSET - 161 $HANGEUL_CHARSET - 129 $MAC_CHARSET - 77 $OEM_CHARSET - 255 $RUSSIAN_CHARSET - 204 $SHIFTJIS_CHARSET - 128 $SYMBOL_CHARSET - 2 $TURKISH_CHARSET - 162 $VIETNAMESE_CHARSET - 163
$iLcid | [optional] see http://www.microsoft.com/globaldev/reference/lcid-all.mspx

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $iPoints is not a positive number 103 - $sName is not alphabetic 104 - $iCharSet is not a number 105 - $iLcid is not a number

Remarks

If a parameter is omitted (or is Default), the value is unchanged.

Related

_GUICtrlRichEdit_ChangeFontSize, _GUICtrlRichEdit_GetFont

See Also

Search EM_SETCHARFORMAT in MSDN Library. Search LOGFONT in MSDN Library. See http://www.hep.wisc.edu/~pinghc/books/apirefeng/l/logfont.html.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        Report("1. Initial")
                    Case 2
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, 5)
                        _GUICtrlRichEdit_SetFont($g_hRichEdit, 15, "Times New Roman")
                        Report("2. Set Font")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    Local $aRet = _GUICtrlRichEdit_GetFont($g_hRichEdit)
    $sMsg = $sMsg & @CRLF & @CRLF & $aRet[1] & " " & $aRet[0] & " points"
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetLimitOnText

Function Reference

_GUICtrlRichEdit_SetLimitOnText

Change number of characters that can be typed, pasted or streamed in as Rich Text Format

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetLimitOnText ( $hWnd, $iNewLimit )

Parameters

$hWnd | Handle to the control
$iNewLimit | new limit

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $iNewLimit is neither a positive number nor zero

Remarks

This function sets the limit on the number of characters a user can type in or paste into a control.

It also limits the number of characters of RTF text that can be streamed in using
_GUICtrlRichEdit_StreamFromFile() and _GUICtrlRichEdit_StreamFromVar().

It does not limit the amount of plain text that can be streamed in.

The initial limit is 32,767 characters.

Related

_GUICtrlRichEdit_StreamFromFile, _GUICtrlRichEdit_StreamFromVar, _GUICtrlRichEdit_StreamToFile, _GUICtrlRichEdit_StreamToVar

See Also

Search EM_EXLIMITTEXT in MSDN Library.

Example

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

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    Local $idLblMsg, $hRichEdit
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($hRichEdit, "Paragraph 1")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetLimitOnText($hRichEdit, 0)
                        GUICtrlSetData($idLblMsg, "1. Limit set to 65,536 characters")
                    Case 2
                        _GUICtrlRichEdit_SetLimitOnText($hRichEdit, 100000)
                        GUICtrlSetData($idLblMsg, "2. Limit set to 100,000 characters")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRichEdit_SetModified

Function Reference

_GUICtrlRichEdit_SetModified

Sets or clears the modification flag

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetModified ( $hWnd [, $bState = True] )

Parameters

$hWnd | Handle to the control
$bState | [optional] Specifies the new value for the modification flag: True - Indicates that the text has been modified (default) False - Indicates it has not been modified.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $bState must be True or False

Remarks

The system automatically sets the modification flag to False when the control is created.
If the control's text is changed, either by the user or programmatically, the system sets the flag to True
Call _GUICtrlRichEdit_IsModified() to retrieve the current state of the flag.

Related

_GUICtrlRichEdit_IsModified

See Also

Search EM_SETMODIFY in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    Report("Initial state after creation")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "A paragraph")
                        Report("Added some text")
                    Case 2
                        _GUICtrlRichEdit_SetModified($g_hRichEdit, False)
                        Report("After clearing the modification flag")
                    Case 3
                        GUICtrlSetData($g_idLblMsg, "Type some text. Then click on Next")
                    Case 4
                        Report("After typing")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & "State is " & _GUICtrlRichEdit_IsModified($g_hRichEdit)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetParaAlignment

Function Reference

_GUICtrlRichEdit_SetParaAlignment

Sets alignment of paragraph(s) in the current selection or, if no selection, of paragraphs inserted at the insertion point

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetParaAlignment ( $hWnd, $sAlignment )

Parameters

$hWnd | Handle to the control
$sAlignment | values: "l" - align with the left margin. "r" - align with the right margin. "c" - center between margins "j" - justify between margins "f" - justify between margins by only expanding spaces

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - invalid $sAlignment

Remarks

In Richedit 2.0, justify does not display.

Related

_GUICtrlRichEdit_GetParaAlignment

See Also

Search EM_SETPARAFORMAT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $iCp, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "First paragraph")
    Report("First paragraph")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetParaAlignment($g_hRichEdit, "r")
                        Report("First paragraph")
                    Case 2
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Second paragraph")
                        _GUICtrlRichEdit_SetParaAlignment($g_hRichEdit, "c")
                        Report("Second paragraph")
                    Case 3
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Third paragraph")
                        _GUICtrlRichEdit_SetParaAlignment($g_hRichEdit, "l")
                        Report("Third paragraph")
                    Case 4
                        $iCp = _GUICtrlRichEdit_GetFirstCharPosOnLine($g_hRichEdit, 2)
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, $iCp, -1)
                        Report("Alignment of paragraphs in selection")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & @CRLF & _GUICtrlRichEdit_GetParaAlignment($g_hRichEdit)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetParaAttributes

Function Reference

_GUICtrlRichEdit_SetParaAttributes

Sets attributes of paragraph(s) in the current selection or, if no selection, of paragraphs inserted at the insertion point

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetParaAttributes ( $hWnd, $sStatesAndAtts )

Parameters

$hWnd | Handle to the control
$sStatesAndAtts | a string consisting of groups separated by semicolons ";". Each group consists of: First character - state: + - turn attribute on - - turn attribute off "fpg" - force this/these paragraphs on to new page(s) (Initially off) "hyp" - automatic hypthenation (Initially on) "kpt" - keep this/these paragraph(s) together on a page (Initially off} "kpn" - keep this/these paragraph(s) and the next together on a page (Initially off) "pwo" - prevent widows and orphans, i.e. avoid a single line of this/these paragraphs on a page (Initially off) "r2l" - display text using right-to-left reading order (Initially off) "row" - paragraph(s) is/are table row(s) (Initially off) "sbs" - display paragraphs side by side (Initially off) "sln" - suppress line numbers in documents or sections with line numbers (Initially off)

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 1021 - a state character in $sStatesAndAtts is invalid. It is in @extended 1022 - an attribute abbreviation in $sStatesAndAtts is invalid. It is in @extended 1023 - length of $sStatesAndAtts is invalid

Remarks

Displays results in Word but not in Rich Edit.

Related

_GUICtrlRichEdit_GetParaAttributes

See Also

Search EM_SETPARAFORMAT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($g_hRichEdit, "First paragraph")
    Report("First paragraph: default attributes")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Second paragraph")
                        _GUICtrlRichEdit_SetParaAttributes($g_hRichEdit, "-hyp")
                        Report("Second paragraph: hyphenation off")
                    Case 2
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 10, -1)
                        _GUICtrlRichEdit_SetParaAttributes($g_hRichEdit, "-hyp;+fpg;+kpn")
                        Report("Attributes of first paragraph in selection")
                    Case 3
                        ; Stream all text to the Desktop so you can look at attributes in Word
                        _GUICtrlRichEdit_Deselect($g_hRichEdit)
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & @CRLF & _GUICtrlRichEdit_GetParaAttributes($g_hRichEdit)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetParaBorder

Function Reference

_GUICtrlRichEdit_SetParaBorder

Sets the border of paragraph(s) in the current selection or, if no selection, of paragraphs inserted at the insertion point

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetParaBorder ( $hWnd [, $sLocation = Default [, $vLineStyle = Default [, $sColor = Default [, $iSpace = Default]]]] )

Parameters

$hWnd | Handle to the control
$sLocation | [optional] a string consisting of any logical combination of: l - left border r - right border t - top border b - bottom border i - inside border o - outside border or "" - no border (initial value)
$vLineStyle | [optional] line style - one of: "none" - no line (initial value) .75 - 3/4 point 1.5 - 1 1/2 points 2.25 - 2 1/4 points 3 - 3 points 4.5 - 4 1/2 points 6 - 6 points ".75d" - 1/2 points, double "1.5d" - 1 1/2 points, double "2.25d" - 2 1/4 points, double ".75g" - 3/4 point grey ".75gd" - 3/4 point grey dashed
$sColor | [optional] one of: "aut" - autocolor "blk" - black (initial value) "blu" - blue "cyn" - cyan "grn" - green "mag" - magenta "red" - red "yel" - yellow "whi" - white "dbl" - dark blue "dgn" - dark green "dmg" - dark magenta "drd" - dark red "dyl" - dark yellow "dgy" - dark grey "lgy" - light grey
$iSpace | [optional] space between the border and the text (in space units) ( (initial value): 0)

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - value of $sLocation is invalid 103 - value of $vLineStyle is invalid 104 - value of $sColor is invalid 105 - $iSpace is neither a positive number nor zero

Remarks

To set "space units", call _GUICtrlRichEdit_SetSpaceUnit(). Initially inches.

If text is selected, the defaults are the values of the first paragraph with text selected.
If none is selected, the defaults are the values of the current paragraph.

To remove a border, call with two parameters: ($hWnd, "").

Borders do not show in Rich Edit, but ones created here should show in Word.

Related

_GUICtrlRichEdit_GetParaBorder, _GUICtrlRichEdit_SetSpaceUnit

See Also

Search EM_SETPARAFORMAT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $iStep = 0, $idBtnNext
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($g_hRichEdit, "First paragraph")
    Report("0. First paragraph: default settings")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Second paragraph")
                        _GUICtrlRichEdit_SetParaBorder($g_hRichEdit, "o", 3, "mag", 0.25)
                        Report("1. Second paragraph: with border (should show in Word)")
                    Case 2
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 10, -1)
                        Report("2. Settings of first paragraph in selection")
                    Case 3
                        _GUICtrlRichEdit_SetParaBorder($g_hRichEdit, "l", 6, "blu")
                        Report("3. Settings of both paragraphs changed")
                    Case 4
                        _GUICtrlRichEdit_SetParaBorder($g_hRichEdit, Default, ".75gd")
                        Report("4. Line style changed")
                    Case 5
                        ; Stream all text to the Desktop so you can look at border settings in Word
                        _GUICtrlRichEdit_Deselect($g_hRichEdit)
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & @CRLF & _GUICtrlRichEdit_GetParaBorder($g_hRichEdit)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetParaIndents

Function Reference

_GUICtrlRichEdit_SetParaIndents

Sets indents of paragraph(s) in the current selection or, if no selection, of paragraphs inserted at the insertion point

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetParaIndents ( $hWnd [, $vLeft = Default [, $iRight = Default [, $iFirstLine = Default]]] )

Parameters

$hWnd | Handle to the control
$vLeft | [optional] indentation of left side of the body of the paragraph (in space units) absolute - a number relative to previous - a string - "+" or "-"
$iRight | [optional] indentation of right side of the paragraph (in space units)
$iFirstLine | [optional] indentation of the first line relative to other lines (in space units)

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 103 - $iRight is not a number 104 - $iFirstLine is not a number 1021 - $vLeft is neither a number nor a string consisting of a number 1022 - $vLeft would start body of paragrpah to left of client area 200 - First line would be outdented beyond the client area 700 - Operation failed

Remarks

Postive values of $vLeft, $iRight and $iFirstLine indent towards the center of the paragraph.

All three values are initially zero.

To set "space units", call _GUICtrlRichEdit_SetSpaceUnit(). Initially inches.

If text is selected, the defaults are the values of the first paragraph with text selected.
If none is selected, the defaults are the values of the current paragraph.

Related

_GUICtrlRichEdit_GetParaIndents, _GUICtrlRichEdit_SetSpaceUnit

See Also

Search EM_SETPARAFORMAT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "First paragraph")
    Report("Para with default indent settings")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Second paragraph")
                        Report("Added second paragraph")
                    Case 2
                        _GUICtrlRichEdit_SetParaIndents($g_hRichEdit, 0.25, .1)
                        Report("Changed indent settings of second paragraph")
                    Case 3
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 10, 26)
                        _GUICtrlRichEdit_SetParaIndents($g_hRichEdit, Default, 0, .2)
                        Report("Change settings of both paragraphs")
                    Case 4
                        ; Stream all text to the Desktop so you can look at Indents settings in Word
                        _GUICtrlRichEdit_Deselect($g_hRichEdit)
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & @CRLF & _GUICtrlRichEdit_GetParaIndents($g_hRichEdit)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetParaNumbering

Function Reference

_GUICtrlRichEdit_SetParaNumbering

Sets numbering of paragraph(s) in the current selection or, if no selection, of paragraph(s) inserted at the insertion point

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetParaNumbering ( $hWnd, $sStyle [, $iTextToNbrSpace = Default [, $bForceRoman = False]] )

Parameters

$hWnd | Handle to the control
$sStyle | a string specifying style and starting "number": e.g. "." (bullet), "1)","(b)", "C.", "iv", "V)" This is the "numbering" that will display for the first paragraph. Trailing spaces indicate the minimum spaces between the number and the paragraph unless $iTextToNbrSpace is entered Special cases: "=" - This paragraph is an unnumbered paragraph within the preceding list element "" - removed the numbering from the selected paragraph(s)
$iTextToNbrSpace | [optional] space between number/bullet and paragraph (in space units) Default: number of trailing spaces times point size
$bForceRoman | [optional] False - i, v, x ... in $sStyle is letter i, v, x ... {Default)

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 103 - $iTextToNbrSpace is not a postive number 104 - $bForceRoman must be True or False

Remarks

To set "space units", call _GUICtrlRichEdit_SetSpaceUnit(). Initially inches.

Related

_GUICtrlRichEdit_GetParaNumbering, _GUICtrlRichEdit_SetSpaceUnit

See Also

Search EM_SETPARAFORMAT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "First paragraph")
    _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, 1)
    Report("Para with default indent settings")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Second paragraph")
                        _GUICtrlRichEdit_SetParaNumbering($g_hRichEdit, ".")
                        Report("Added second paragraph")
                    Case 2
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, 2)
                        Report("Style of first paragraph in the selection")
                    Case 3
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 10, 26)
                        _GUICtrlRichEdit_SetParaNumbering($g_hRichEdit, "v)  ", Default, True)
                        Report("Change settings of both paragraphs")
                    Case 4
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 10, 26)
                        _GUICtrlRichEdit_SetParaNumbering($g_hRichEdit, "2.  ", Default, True)
                        Report("Changed settings for both paragraphs")
                    Case 5
                        ; Stream all text to the Desktop so you can look at settings in Word
                        _GUICtrlRichEdit_Deselect($g_hRichEdit)
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & @CRLF & _GUICtrlRichEdit_GetParaNumbering($g_hRichEdit)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetParaShading

Function Reference

_GUICtrlRichEdit_SetParaShading

Sets the shading of paragraph(s) in the current selection or, if no selection, of paragraphs inserted at the insertion point

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetParaShading ( $hWnd [, $iWeight = Default [, $sStyle = Default [, $sForeColor = Default [, $sBackColor = Default]]]] )

Parameters

$hWnd | Handle to the control
$iWeight | [optional] percent of foreground color, the rest being background color
$sStyle | [optional] shading style - a string containing one of the following: non - none dhz - dark horizontal dvt - dark vertical ddd - dark down diagonal dud - dark up diagonal dgr - dark grid dtr - dark trellis lhz - light horizontal lvt - light vertical ldd - light down diagonal lud - light up diagonal lgr - light grid ltr - light trellis
$sForeColor | [optional] one of the following: "blk" - black (initial value) "blu" - blue "cyn" - cyan "grn" - green "mag" - magenta "red" - red "yel" - yellow "whi" - white "dbl" - dark blue "dgn" - dark green "dmg" - dark magenta "drd" - dark red "dyl" - dark yellow "dgy" - dark grey "lgy" - light grey
$sBackColor | [optional] same values as for $sForeColor

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 103 - value of $sStyle is invalid 104 - value of $sForeColor is invalid 105 - value of $sBackColor is invalid 1021 - $iWeight is not a positive number 1022 - value of $iWeight is invalid 700 - operation failed

Remarks

If text is selected, the defaults are the values of the first paragraph with text selected.
If none is selected, the defaults are the values of the current paragraph.

Shading does not show in Rich Edit, but shading created here will show in Word.

Related

_GUICtrlRichEdit_GetParaShading

See Also

Search EM_SETPARAFORMAT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "First paragraph")
    Report("0. Para with default settings")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Second paragraph")
                        _GUICtrlRichEdit_SetParaShading($g_hRichEdit, 60, "ddd", "blu", "dmg")
                        Report("1. Shading of second paragraph is ")
                    Case 2
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, 2)
                        Report("2. Style of first paragraph in the selection is ")
                    Case 3
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 10, 26)
                        _GUICtrlRichEdit_SetParaShading($g_hRichEdit, Default, "dgr")
                        Report("3. Change shading of both paragraphs")
                    Case 4
                        ; Stream all text to the Desktop so you can look at settings in Word
                        _GUICtrlRichEdit_Deselect($g_hRichEdit)
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & @CRLF & _GUICtrlRichEdit_GetParaShading($g_hRichEdit)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetParaSpacing

Function Reference

_GUICtrlRichEdit_SetParaSpacing

Sets paragraph spacing of paragraphs having selected text or, if none selected, sets it for text inserted at the insertion point

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetParaSpacing ( $hWnd [, $vInter = Default [, $iBefore = Default [, $iAfter = Default]]] )

Parameters

$hWnd | Handle to the control
$vInter | [optional] spacing between lines: either: a number - in space units or: " lines" - in lines
$iBefore | [optional] spacing before paragraph(s) (in space units)
$iAfter | [optional] spacing after paragraph(s) (in space units)

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 103 - $iBefore is neither a positive number nor zero 104 - $iAfter is neither a positive number nor zero 1021 - $vInter is invalid 1022 - Only 1, 1.5 and 2 line spacing can be set via " lines"

Remarks

Only settings which are not defaulted are set.

To set "space units", call _GUICtrlRichEdit_SetSpaceUnit(). Initially inches.

Related

_GUICtrlRichEdit_GetParaSpacing, _GUICtrlRichEdit_SetSpaceUnit

See Also

Search EM_SETPARAFORMAT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "First paragraph")
    Report("0. Para with default settings")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Second paragraph")
                        _GUICtrlRichEdit_SetParaSpacing($g_hRichEdit, "2 lines", .2, .25)
                        Report("1. Spacing of second paragraph is ")
                    Case 2
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, 2)
                        Report("2. Settings of first paragraph in the selection are ")
                    Case 3
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 10, 26)
                        _GUICtrlRichEdit_SetParaSpacing($g_hRichEdit, Default, .1)
                        Report("3. Change spacing of both paragraphs")
                    Case 4
                        ; Stream all text to the Desktop so you can look at Indents settings in Word
                        _GUICtrlRichEdit_Deselect($g_hRichEdit)
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & @CRLF & _GUICtrlRichEdit_GetParaSpacing($g_hRichEdit)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetParaTabStops

Function Reference

_GUICtrlRichEdit_SetParaTabStops

Sets tab stops of paragraphs having selected text or, if none selected, sets it for text inserted at the insertion point

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetParaTabStops ( $hWnd, $sTabStops )

Parameters

$hWnd | Handle to the control
$sTabStops | A string consisting of groups separated by ; (semicolon). Format of a group: absolute position of a tab stop (in space units) kind of tab l - left tab c - center tab r - decimal tab b - bar tab kind of dot leader . - dotted leader - - dashed leader _ - underline leader = - double line leader t - thick-line leader a space - no leader

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 1021 - absolute position of a tab stop missing or invalid 1022 - kind of tab missing or invalid 1023 - kind of tab leader missing or invalid 1024 - attempt to set too many tab stops @extended contains the tab number (ref 1) in $sTabStops where the error occurred.

Remarks

To reset the tab stops, do _GUICtrlRichEdit_SetParaTabStops($hWnd, "").

To set "space units", call _GUICtrlRichEdit_SetSpaceUnit(), initially inches.

To enter a tab into a control, press Ctrl_Tab.

Related

_GUICtrlRichEdit_GetParaTabStops, _GUICtrlRichEdit_SetSpaceUnit, _GUICtrlRichEdit_SetTabStops

See Also

Search EM_SETCHARFORMAT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "First paragraph")
    Report("0. Para with default settings")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Second paragraph")
                        _GUICtrlRichEdit_SetParaTabStops($g_hRichEdit, ".3l ;1c ;2.5r.")
                        Report("1. TabStops of second paragraph")
                    Case 2
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, 2)
                        Report("2. Tabstops of first paragraph")
                    Case 3
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 10, 26)
                        Report("Tabstops of first paragraph in selection")
                    Case 4
                        _GUICtrlRichEdit_SetParaTabStops($g_hRichEdit, "2.3r=")
                        Report("3. Change tabstops of both paragraphs")
                    Case 5
                        ; Stream all text to the Desktop so you can look at settings in Word
                        _GUICtrlRichEdit_Deselect($g_hRichEdit)
                        _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & @CRLF & "Get function returns " & @CRLF & _GUICtrlRichEdit_GetParaTabStops($g_hRichEdit)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetPasswordChar

Function Reference

_GUICtrlRichEdit_SetPasswordChar

Sets the characters to be displayed instead of those typed, or causes typed characters to show

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetPasswordChar ( $hWnd [, $sDisplayChar = "*"] )

Parameters

$hWnd | Handle to the control
$sDisplayChar | [optional] The character to be displayed in place of the characters typed by the user. Special value: "" - characters typed are displayed

Return Value

Succcess: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $sDisplayChar is not a character

Related

_GUICtrlRichEdit_GetPasswordChar

See Also

Search EM_SETPASSWORDCHAR in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    Report("Initial state after creation:")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetPasswordChar($g_hRichEdit, "*")
                        Report("Changed password character. Type some text")
                    Case 2
                        _GUICtrlRichEdit_SetPasswordChar($g_hRichEdit, "")
                        Report("Changed it back")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    Local $sPasswordChar
    $sPasswordChar = _GUICtrlRichEdit_GetPasswordChar($g_hRichEdit)
    If $sPasswordChar = "" Then
        $sMsg &= @CRLF & "Characters appear as typed"
    Else
        $sMsg = $sMsg & @CRLF & "Typed characters appear as " & $sPasswordChar & "s"
    EndIf
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetReadOnly

Function Reference

_GUICtrlRichEdit_SetReadOnly

Sets or removes the read-only state

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetReadOnly ( $hWnd [, $bState = True] )

Parameters

$hWnd | Handle to the control
$bState | [optional] one of the following values: True - Sets control to read-only (default) False - Sets control to read-write

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $bState is neither true nor false 700 - operation failed

See Also

Search EM_SETREADONLY in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $hRichEdit, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    For $i = 1 To 5
        _GUICtrlRichEdit_AppendText($hRichEdit, "Line " & $i & @CRLF)
    Next
    _GUICtrlRichEdit_AppendText($hRichEdit, "Line 6")
    Report("Initial state")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetReadOnly($hRichEdit)
                        Report("Set to read-only")
                    Case 2
                        _GUICtrlRichEdit_SetReadOnly($hRichEdit, False)
                        Report("Now read-write")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg & @CRLF & "Try typing some text")
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetRECT

Function Reference

_GUICtrlRichEdit_SetRECT

Sets the formatting rectangle of a Rich Edit control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetRECT ( $hWnd [, $iLeft = Default [, $iTop = Default [, $iRight = Default [, $iBottom = Default [, $bRedraw = True]]]]] )

Parameters

$hWnd | Handle to the control
$iLeft | [optional] Left position in dialog units
$iTop | [optional] Top position in dialog units
$iRight | [optional] Right position in dialog units
$iBottom | [optional] Bottom position in dialog unit
$bRedraw | [optional] True to force redraw

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 1021 - $iLeft is not a positive number 1022 - $iTop is not a positive number 1023 - $iRight is not a positive number 1024 - $iBottom is not a positive number 1025 - $iLeft >= $iRight 1026 - $iTop >= $iBottom

Remarks

The formatting rectangle is the area in which text is drawn, part of which may not be visible.
Parameters default = no change to previous values.
If only $hWnd defined, formatting is reset as at creation time.

Related

_GUICtrlRichEdit_GetRECT

See Also

Search EM_SETMODIFY in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "First paragraph")
    _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Second paragraph")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        Report("1. Default settings ")
                    Case 2
                        _GUICtrlRichEdit_SetRECT($g_hRichEdit, 10, 10, 100, 100)
                        Report("2. Settings ")
                    Case 3
                        _GUICtrlRichEdit_SetRECT($g_hRichEdit)
                        Report("3. ReSettings to default")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    Local $aRect = _GUICtrlRichEdit_GetRECT($g_hRichEdit)
    $sMsg = $sMsg & @CRLF & @CRLF & "Left=" & $aRect[0] & " Top=" & $aRect[1] & " Right=" & $aRect[2] & " Bottom=" & $aRect[3]
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetScrollPos

Function Reference

_GUICtrlRichEdit_SetScrollPos

Scrolls the display such that ($ix,$iY) is in the upper left corner of the control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetScrollPos ( $hWnd, $iX, $iY )

Parameters

$hWnd | Handle to the control
$iX | x coordinate (in pixels)
$iY | y coordinate (in pixels)

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $iX is neither a positive number nor zero 103 - $iY is neither a positive number nor zero

Remarks

Never scrolls the text completely off the view rectangle.

Related

_GUICtrlRichEdit_GetScrollPos

See Also

Search EM_SETSCROLLPOS in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($g_hRichEdit, "Paragraph 1")
    For $i = 2 To 20
        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "Paragraph " & $i)
    Next
    Report("0. Initially scrolled to show insertion point")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetScrollPos($g_hRichEdit, 0, 0)
                        Report("1. Scrolled to top")
                    Case 2
                        _GUICtrlRichEdit_SetScrollPos($g_hRichEdit, 7, 22)
                        Report("2. Scrolled down a bit, and to the right")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    Local $aPos = _GUICtrlRichEdit_GetScrollPos($g_hRichEdit)
    $sMsg = $sMsg & @CRLF & "Get function returns " & $aPos[0] & ";" & $aPos[1]
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetSel

Function Reference

_GUICtrlRichEdit_SetSel

Sets the low and high character position of a selection

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetSel ( $hWnd, $iAnchor, $iActive [, $bHideSel = False] )

Parameters

$hWnd | Handle to the control
$iAnchor | the character position of the first character to select Special value: -1 - end of text
$iActive | the character position of the last character to select Special value: -1 - end of text
$bHideSel | [optional] True to hide the selection

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $iAnchor is neither a positive number nor zero nor -1 103 - $iActive is neither a positive number nor zero nor -1 104 - $bHideSel must be True or False

Remarks

The first character of the text in a control is at character position 0.

$iActive can be less than $iAnchor.

Related

_GUICtrlRichEdit_Deselect, _GUICtrlRichEdit_GetSel, _GUICtrlRichEdit_GetSelAA, _GUICtrlRichEdit_GotoCharPos, _GUICtrlRichEdit_IsTextSelected

See Also

Search EM_EXSETSEL in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0, $iCp1
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_NOHIDESEL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, 3)
                        Report("1. Initial Character attributes at start of line 1 are")
                    Case 2
                        _GUICtrlRichEdit_AutoDetectURL($g_hRichEdit, True)
                        _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "http://www.autoitscript.com")
                        $iCp1 = _GUICtrlRichEdit_GetFirstCharPosOnLine($g_hRichEdit, 2)
                        _GUICtrlRichEdit_SetSel($g_hRichEdit, $iCp1, $iCp1 + 3)
                        Report("2. Character attributes at start of line 2 are")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    Local $sRet = _GUICtrlRichEdit_GetCharAttributes($g_hRichEdit)
    $sMsg = $sMsg & @CRLF & @CRLF & "Char Attributes=" & $sRet
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetSpaceUnit

Function Reference

_GUICtrlRichEdit_SetSpaceUnit

Sets the unit of measure of horizontal and vertical space used in parameters of various _GUICtrlRichEdit functions

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetSpaceUnit ( $sUnit )

Parameters

$sUnit "in", "cm", "mm", "pt" (points), or "tw" (twips, 1/1440 inches, 1/567 centimeters)

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.

Remarks

Initially, space is measured in inches.

Related

_GUICtrlRichEdit_GetSpaceUnit, _GUICtrlRichEdit_SetParaBorder, _GUICtrlRichEdit_SetParaIndents, _GUICtrlRichEdit_SetParaNumbering, _GUICtrlRichEdit_SetParaSpacing, _GUICtrlRichEdit_SetParaTabStops, _GUICtrlRichEdit_SetTabStops

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $hRichEdit, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($hRichEdit, "Paragraph 1")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        Report("1. Initial setting")
                    Case 2
                        _GUICtrlRichEdit_SetSpaceUnit("cm")
                        Report("2. Setting is now")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    $sMsg = $sMsg & @CRLF & @CRLF & _GUICtrlRichEdit_GetSpaceUnit()
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_SetTabStops

Function Reference

_GUICtrlRichEdit_SetTabStops

Sets tab stops for the control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetTabStops ( $hWnd, $vTabStops [, $bRedraw = True] )

Parameters

$hWnd | handle of control
$VTabStops | tab stop(s) to set in space units: If a string, semicolon-separated tab stop positions If numeric: set a tab stop every space units
$bRedraw | [optional] whether to redraw the control - True (default) or False

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 103 - $bRedraw must be True or False 1021 - $vTabStops is neither a string nor a number 1022 - $vTabStops is a string but a tab stop in it is not a positive number 1023 - $vTabStops is an empty string 1024 - $vTabStops is a number but it is zero or negative

Remarks

Space units are initially inches.
To enter a tab into a control, press Ctrl_Tab.

Related

_GUICtrlRichEdit_SetParaTabStops, _GUICtrlRichEdit_SetSpaceUnit

See Also

Search EM_SETTABSTOPS in MSDN Library.

Example

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

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0
    Local $idLblMsg, $hRichEdit
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($hRichEdit, "Paragraph 1" & @TAB & "Paragraph 2" & @TAB & "Paragraph 3")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetTabStops($hRichEdit, 1)
                        GUICtrlSetData($idLblMsg, "1. Set tab stops every inch")
                    Case 2
                        _GUICtrlRichEdit_SetTabStops($hRichEdit, "0.5;1.5")
                        GUICtrlSetData($idLblMsg, "2. Set tab stops at 0.5 and 1.5 inches")

                        ; Stream all text to the Desktop so you can look at settings in Word
                        _GUICtrlRichEdit_Deselect($hRichEdit)
                        _GUICtrlRichEdit_StreamToFile($hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRichEdit_SetText

Function Reference

_GUICtrlRichEdit_SetText

Sets the text of a control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetText ( $hWnd, $sText )

Parameters

$hWnd | Handle to the control
$sText | Plain or RTF text to put into the control

Return Value

Succcess: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Remarks

Sets all of the text. Text can be plain or RTF text.
Keeps the undo stack.

Related

_GUICtrlRichEdit_AppendText, _GUICtrlRichEdit_EmptyUndoBuffer, _GUICtrlRichEdit_GetText, _GUICtrlRichEdit_InsertText, _GUICtrlRichEdit_ReplaceText

Example

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

Example()

Func Example()
    Local $hGui, $iMsg, $hRichEdit
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($hRichEdit, "First paragraph")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRichEdit_SetUndoLimit

Function Reference

_GUICtrlRichEdit_SetUndoLimit

Sets the maximum number of actions that can stored in the undo queue

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetUndoLimit ( $hWnd, $iLimit )

Parameters

$hWnd | Handle to the control
$iLimit | the maximum number of actions that can be stored in the undo queue

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - $iLimit is neither a positive number nor zero

Remarks

To disable the Undo feature, set $iLimit to zero.

The initial value of $iLimit is 100.

Related

_GUICtrlRichEdit_CanRedo, _GUICtrlRichEdit_CanUndo, _GUICtrlRichEdit_GetNextRedo, _GUICtrlRichEdit_Redo, _GUICtrlRichEdit_Undo

See Also

Search EM_SETUNDOLIMIT in MSDN Library.

Example

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

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0, $idLblMsg, $hRichEdit
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($hRichEdit, "First paragraph")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_SetUndoLimit($hRichEdit, 200)
                        GUICtrlSetData($idLblMsg, "Increased the number of actions that can stored in the undo queue from 100 to 200")
                    Case 2
                        _GUICtrlRichEdit_SetUndoLimit($hRichEdit, 0)
                        GUICtrlSetData($idLblMsg, "Undo is disabled")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRichEdit_SetZoom

Function Reference

_GUICtrlRichEdit_SetZoom

Sets zoom level of the control

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetZoom ( $hWnd, $iPercent )

Parameters

$hWnd | Handle to the control
$iPercent | percentage zoom values: 100 and 200 to 6400

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 1021 - $iPercent is not a positive number 1022 - $iPercent neither 100 nor in the range 200 to 6400

Remarks

MSDN claims that EM_SETZOOM works from 1.56% (1/64) to 6400% (64/1) but testing shows that it only works reliably for the values shown above.

Related

_GUICtrlRichEdit_GetZoom

See Also

Search EM_SETZOOM in MSDN Library.

Example

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $hRichEdit, $iStep = 0
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        Report("1.Now zoomed to " & _GUICtrlRichEdit_GetZoom($hRichEdit) & "%")
                    Case 2
                        _GUICtrlRichEdit_SetZoom($hRichEdit, 250)
                        Report("2.Now zoomed to " & _GUICtrlRichEdit_GetZoom($hRichEdit) & "%")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report


Function _GUICtrlRichEdit_StreamFromFile

Function Reference

_GUICtrlRichEdit_StreamFromFile

Sets text in a control from a file

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_StreamFromFile ( $hWnd, $sFileSpec )

Parameters

$hWnd | Handle to the control
$sFileSpec | file specification

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 1021 - unable to open $sFileSpec 1022 - file is empty 700 - attempt to stream in too many characters

Remarks

If text is selected, replaces selection, else replaces all text in the control.

Call _GUICtrlRichEdit_SetLimitOnText() to increase the number of characters the control can contain.

Related

_GUICtrlRichEdit_SetLimitOnText, _GUICtrlRichEdit_StreamFromVar, _GUICtrlRichEdit_StreamToFile

See Also

Search EM_STREAMIN in MSDN Library.

Example

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

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0, $idLblMsg, $hRichEdit
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($hRichEdit, "First paragraph")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        _GUICtrlRichEdit_StreamToFile($hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetData($idLblMsg, "Streamed to gcre.rtf")
                    Case 2
                        _GUICtrlRichEdit_SetText($hRichEdit, "")
                        _GUICtrlRichEdit_StreamFromFile($hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetData($idLblMsg, "Streamed from gcre.rtf")
                    Case 3
                        _GUICtrlRichEdit_SetSel($hRichEdit, 2, 6)
                        _GUICtrlRichEdit_StreamFromFile($hRichEdit, @DesktopDir & "\gcre.rtf")
                        GUICtrlSetData($idLblMsg, "Replaced selection: an intentional mess!")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRichEdit_StreamFromVar

Function Reference

_GUICtrlRichEdit_StreamFromVar

Sets text in a control from a variable

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_StreamFromVar ( $hWnd, $sVar )

Parameters

$hWnd | Handle to the control
$sVar | a string

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 700 - attempt to stream in too many characters

Remarks

If text is selected, replaces selection, else replaces all text in the control.

Call _GUICtrlRichEdit_SetLimitOnText() to increase the number of characters the control can contain.

Related

_GUICtrlRichEdit_SetLimitOnText, _GUICtrlRichEdit_StreamFromFile, _GUICtrlRichEdit_StreamToFile, _GUICtrlRichEdit_StreamToVar

See Also

Search EM_STREAMIN in MSDN Library.

Example

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

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0, $idLblMsg, $hRichEdit, $s
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($hRichEdit, "First paragraph")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        $s = _GUICtrlRichEdit_StreamToVar($hRichEdit)
                        GUICtrlSetData($idLblMsg, "Streamed to variable")
                    Case 2
                        _GUICtrlRichEdit_SetText($hRichEdit, "")
                        _GUICtrlRichEdit_StreamFromVar($hRichEdit, $s)
                        GUICtrlSetData($idLblMsg, "Streamed from variable")
                    Case 3
                        _GUICtrlRichEdit_SetSel($hRichEdit, 2, 6)
                        _GUICtrlRichEdit_StreamFromVar($hRichEdit, $s)
                        GUICtrlSetData($idLblMsg, "Replaced selection: an intentional mess!")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRichEdit_StreamToFile

Function Reference

_GUICtrlRichEdit_StreamToFile

Writes contents of a control to a file

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_StreamToFile ( $hWnd, $sFileSpec [, $bIncludeCOM = True [, $iOpts = 0 [, $iCodePage = 0]]] )

Parameters

$hWnd | Handle to the control
$sFileSpec | file specification
$bIncludeCOM | [optional] True (default): If writing to a .rtf file, includes any COM objects (space consuming) If writing to any other file, writes a text represntation of COM objects False: Writes spaces instead of COM objects
$iOpts | [optional] additional options: (default: 0) $SFF_PLAINRTF - write only rich text keywords common to all languages $SF_UNICODE - write Unicode
$iCodePage | [optional] Generate UTF-8 and text using this code page Default: do not

Return Value

Success: | True
Failure: | False and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 102 - Can't create $sFileSpec 1041 - $SFF_PLAINRTF is invalid for a text file 1042 - $opts: invalid option 1043 - $SF_UNICODE is only valid for a text file 700 - internal error

Remarks

If text is selected, writes only the selection, else writes all text in the control.

If the extension in $sFileSpec is .rtf, RTF is written, else text.

Related

_GUICtrlRichEdit_SetLimitOnText, _GUICtrlRichEdit_StreamFromFile, _GUICtrlRichEdit_StreamFromVar, _GUICtrlRichEdit_StreamToVar

See Also

Search EM_STREAMIN in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGui, $hRichEdit, $iMsg
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($hRichEdit, "Para with default border settings")
    MsgBox($MB_SYSTEMMODAL, "", "The default paragraph border settings are " & _GUICtrlRichEdit_GetParaBorder($hRichEdit))

    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "Second paragraph")
    _GUICtrlRichEdit_SetParaBorder($hRichEdit, "o", 3, "mag", 0.25)
    MsgBox($MB_SYSTEMMODAL, "", "Border settings of second paragraph are " & _GUICtrlRichEdit_GetParaBorder($hRichEdit))

    _GUICtrlRichEdit_SetSel($hRichEdit, 10, -1)
    Sleep(1000)
    MsgBox($MB_SYSTEMMODAL, "", "Border settings of first paragraph in the selection are " & _GUICtrlRichEdit_GetParaBorder($hRichEdit))

    ; Change from outside border to left border
    _GUICtrlRichEdit_SetParaBorder($hRichEdit, "l")

    ; Stream all text to the Desktop so you can look at border settings in Word
    _GUICtrlRichEdit_Deselect($hRichEdit)
    _GUICtrlRichEdit_StreamToFile($hRichEdit, @DesktopDir & "\gcre.rtf")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRichEdit_StreamToVar

Function Reference

_GUICtrlRichEdit_StreamToVar

Writes contents of a control to a variable

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_StreamToVar ( $hWnd [, $bRtf = True [, $bIncludeCOM = True [, $iOpts = 0 [, $iCodePage = 0]]]] )

Parameters

$hWnd | Handle to the control
$bRtf | [optional] True - write Rich Text Format (RTF) (Default) False - write only text
$bIncludeCOM | [optional] True (default): If writing RTF, include any COM objects (space consuming) If writing only text, write a text represntation of COM objects False: Write spaces instead of COM objects
$iOpts | [optional] additional options: $SFF_PLAINRTF - write only rich text keywords common to all languages $SF_UNICODE - write Unicode
$iCodePage | [optional] Generate UTF-8 and text using this code page Default: do not

Return Value

Success: | the RTF or text.
Failure: | "" and sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle 1041 - $SFF_PLAINRTF is invalid for a text file 1042 - $opts: invalid option 1043 - $SF_UNICODE is only valid for a text file 700 - internal error

Remarks

$SF_* , $SFF_* constants are defined in RichEditConstants.au3
If text is selected, writes only the selection, else writes all text in the control.

Call _GUICtrlRichEdit_IsModified() to determine whether the text has changed.

Related

_GUICtrlRichEdit_SetLimitOnText, _GUICtrlRichEdit_StreamFromVar, _GUICtrlRichEdit_StreamToFile

See Also

Search EM_STREAMIN in MSDN Library.

Example

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

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnNext, $iStep = 0, $idLblMsg, $hRichEdit, $s
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
    $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetText($hRichEdit, "First paragraph")
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $idBtnNext
                $iStep += 1
                Switch $iStep
                    Case 1
                        $s = _GUICtrlRichEdit_StreamToVar($hRichEdit)
                        GUICtrlSetData($idLblMsg, "Streamed to variable")
                    Case 2
                        _GUICtrlRichEdit_SetText($hRichEdit, "")
                        _GUICtrlRichEdit_StreamFromVar($hRichEdit, $s)
                        GUICtrlSetData($idLblMsg, "Streamed from variable")
                    Case 3
                        _GUICtrlRichEdit_SetSel($hRichEdit, 2, 6)
                        _GUICtrlRichEdit_StreamFromVar($hRichEdit, $s)
                        GUICtrlSetData($idLblMsg, "Replaced selection: an intentional mess!")
                        GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                EndSwitch
        EndSelect
    WEnd
EndFunc   ;==>Example


Function _GUICtrlRichEdit_Undo

Function Reference

_GUICtrlRichEdit_Undo

Undoes the last edit control operation in the control's undo queue

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_Undo ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True - undo operation succeeded.
Failure: | False - undo operation failed. May sets the @error flag to non-zero.
@error: | 101 - $hWnd is not a handle

Remarks

For a single-line edit control, the return value is always True.

Related

_GUICtrlRichEdit_CanUndo, _GUICtrlRichEdit_EmptyUndoBuffer, _GUICtrlRichEdit_GetNextRedo, _GUICtrlRichEdit_GetNextUndo, _GUICtrlRichEdit_Redo, _GUICtrlRichEdit_SetUndoLimit

See Also

Search EM_UNDO in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Global $g_hRichEdit, $g_idMnu, $g_idMnuUndo, $g_idMnuRedo, $g_idMnuCut, $g_idMnuCopy
Global $g_idMnuPaste, $g_idMnuPasteSpl

Example()

Func Example()
    Local $hGui, $idMnuPasteSplRTF, $idMnuPasteSplwObjs
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($g_hRichEdit, ReadBmpToRtf(FindFirstBMP()))

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    $g_idMnu = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
    $g_idMnuUndo = GUICtrlCreateMenuItem("Undo", $g_idMnu)
    $g_idMnuRedo = GUICtrlCreateMenuItem("Redo", $g_idMnu)
    GUICtrlCreateMenuItem("", $g_idMnu)
    $g_idMnuCut = GUICtrlCreateMenuItem("Cut", $g_idMnu)
    $g_idMnuCopy = GUICtrlCreateMenuItem("Copy", $g_idMnu)
    $g_idMnuPaste = GUICtrlCreateMenuItem("Paste", $g_idMnu)
    $g_idMnuPasteSpl = GUICtrlCreateMenu("Paste Special", $g_idMnu)
    $idMnuPasteSplRTF = GUICtrlCreateMenuItem("RTF only", $g_idMnuPasteSpl)
    $idMnuPasteSplwObjs = GUICtrlCreateMenuItem("With objects", $g_idMnuPasteSpl)
    _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_MOUSEEVENTS)

    While True
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $g_idMnuUndo
                _GUICtrlRichEdit_Undo($g_hRichEdit)
            Case $g_idMnuRedo
                _GUICtrlRichEdit_Redo($g_hRichEdit)
            Case $g_idMnuCut
                _GUICtrlRichEdit_Cut($g_hRichEdit)
            Case $g_idMnuCopy
                _GUICtrlRichEdit_Copy($g_hRichEdit)
            Case $g_idMnuPaste
                _GUICtrlRichEdit_Paste($g_hRichEdit)
            Case $idMnuPasteSplRTF
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, False)
            Case $idMnuPasteSplwObjs
                _GUICtrlRichEdit_PasteSpecial($g_hRichEdit, True)
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hRichEdit
            Select
                Case $iCode = $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_RBUTTONUP Then
                        $hMenu = GUICtrlGetHandle($g_idMnu)
                        SetMenuTexts($hWndFrom, $hMenu)
                        _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    EndIf
            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func SetMenuTexts($hWnd, $hMenu)
    Local $bState
    If _GUICtrlRichEdit_CanUndo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo: " & _GUICtrlRichEdit_GetNextUndo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuUndo, "Undo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuUndo, False, False)
    EndIf
    If _GUICtrlRichEdit_CanRedo($hWnd) Then
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, True, False)
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo: " & _GUICtrlRichEdit_GetNextRedo($hWnd), False)
    Else
        _GUICtrlMenu_SetItemText($hMenu, $g_idMnuRedo, "Redo", False)
        _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuRedo, False, False)
    EndIf
    $bState = _GUICtrlRichEdit_IsTextSelected($hWnd)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCut, $bState, False)
    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuCopy, $bState, False)

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPaste, _GUICtrlRichEdit_CanPaste($hWnd))

    _GUICtrlMenu_SetItemEnabled($hMenu, $g_idMnuPasteSpl, _GUICtrlRichEdit_CanPasteSpecial($hWnd), False)
EndFunc   ;==>SetMenuTexts

Func ReadBmpToRtf($sBmpFilspc)
    Local $hFile, $sRtf
    $hFile = FileOpen($sBmpFilspc, $FO_BINARY)
    If FileRead($hFile, 2) <> "0x424D" Then Return SetError(1, 0, "")
    FileRead($hFile, 12)
    $sRtf = '{\rtf1{\pict\dibitmap ' & Hex(FileRead($hFile)) & '}}'
    FileClose($hFile)
    Return $sRtf
EndFunc   ;==>ReadBmpToRtf

Func FindFirstBMP($sPath = Default)
    If $sPath = Default Then
        ; X64 running support
        Local $sWow64 = ""
        If @AutoItX64 Then $sWow64 = "\Wow6432Node"

        $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images"
    EndIf
    Local $hFind, $sBmpFilspc
    $hFind = FileFindFirstFile($sPath & "\*.bmp")
    $sBmpFilspc = FileFindNextFile($hFind)
    FileClose($hFind)
    Return $sPath & "\" & $sBmpFilspc
EndFunc   ;==>FindFirstBMP


User Defined Functions

GuiScrollBars user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiScrollBars.au3>.

User Defined Function | Description
_GUIScrollBars_EnableScrollBar | Enable/Disable scrollbar
_GUIScrollBars_GetScrollBarInfoEx | Retrieves information about the specified scroll bar
_GUIScrollBars_GetScrollBarRect | Retrieves coordinates of the scroll bar
_GUIScrollBars_GetScrollBarRGState | Retrieves the state of a scroll bar component
_GUIScrollBars_GetScrollBarXYLineButton | Retrieves the Height or width of the thumb
_GUIScrollBars_GetScrollBarXYThumbBottom | Retrieves the Position of the bottom or right of the thumb
_GUIScrollBars_GetScrollBarXYThumbTop | Retrieves the Position of the top or left of the thumb
_GUIScrollBars_GetScrollInfo | Retrieves the parameters of a scroll bar
_GUIScrollBars_GetScrollInfoEx | Retrieves the parameters of a scroll bar
_GUIScrollBars_GetScrollInfoMax | Retrieves the maximum scrolling position
_GUIScrollBars_GetScrollInfoMin | Retrieves the minimum scrolling position
_GUIScrollBars_GetScrollInfoPage | Retrieves the page size
_GUIScrollBars_GetScrollInfoPos | Retrieves the position of the scroll box
_GUIScrollBars_GetScrollInfoTrackPos | Retrieves the immediate position of a scroll box that the user is dragging
_GUIScrollBars_GetScrollPos | Retrieves the current position of the scroll box (thumb) in the specified scroll bar
_GUIScrollBars_GetScrollRange | Retrieves the current minimum and maximum scroll box (thumb) positions for the specified scroll bar
_GUIScrollBars_Init | Initialize the scrollbars for the window
_GUIScrollBars_ScrollWindow | Scrolls the contents of the specified window's client area
_GUIScrollBars_SetScrollInfo | Sets the parameters of a scroll bar
_GUIScrollBars_SetScrollInfoMax | Sets the maximum scrolling position
_GUIScrollBars_SetScrollInfoMin | Sets the minimum scrolling position
_GUIScrollBars_SetScrollInfoPage | Sets the page size
_GUIScrollBars_SetScrollInfoPos | Sets the position of the scroll box (thumb) in the specified scroll bar
_GUIScrollBars_SetScrollRange | Sets the minimum and maximum scroll box positions for the specified scroll bar
_GUIScrollBars_ShowScrollBar | Shows or hides the specified scroll bar


Function _GUIScrollBars_EnableScrollBar

Function Reference

_GUIScrollBars_EnableScrollBar

Enable/Disable scrollbar

#include <GuiScrollBars.au3>
_GUIScrollBars_EnableScrollBar ( $hWnd [, $iSBflags = $SB_BOTH [, $iArrows = $ESB_ENABLE_BOTH]] )

Parameters

$hWnd | Handle to the window
$iSBflags | [optional] Specifies the scroll bar type. This parameter can be one of the following values: $SB_BOTH - Enables or disables the arrows on the horizontal and vertical scroll bars associated with the specified window. $SB_CTL - Indicates that the scroll bar is a scroll bar control. The $hWnd must be the handle to the scroll bar control. $SB_HORZ - Enables or disables the arrows on the horizontal scroll bar associated with the specified window. $SB_VERT - Enables or disables the arrows on the vertical scroll bar associated with the specified window.
$iArrows | [optional] Specifies whether the scroll bar arrows are enabled or disabled and indicates which arrows are enabled or disabled. This parameter can be one of the following values $ESB_DISABLE_BOTH - Disables both arrows on a scroll bar. $ESB_DISABLE_DOWN - Disables the down arrow on a vertical scroll bar. $ESB_DISABLE_LEFT - Disables the left arrow on a horizontal scroll bar. $ESB_DISABLE_LTUP - Disables the left arrow on a horizontal scroll bar or the up arrow of a vertical scroll bar. $ESB_DISABLE_RIGHT - Disables the right arrow on a horizontal scroll bar. $ESB_DISABLE_RTDN - Disables the right arrow on a horizontal scroll bar or the down arrow of a vertical scroll bar. $ESB_DISABLE_UP - Disables the up arrow on a vertical scroll bar. $ESB_ENABLE_BOTH - Enables both arrows on a scroll bar.

Return Value

Success: | True.
Failure: | False.

Related

_GUIScrollBars_ShowScrollBar

See Also

Search EnableScrollBar in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 380, 226, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    MemoWrite("Disable down arrow: " & _GUIScrollBars_EnableScrollBar($hGUI, $SB_VERT, $ESB_DISABLE_DOWN))
    Sleep(3000)
    MemoWrite("Disable up arrow: " & _GUIScrollBars_EnableScrollBar($hGUI, $SB_VERT, $ESB_DISABLE_UP))
    Sleep(3000)
    MemoWrite("Enable both arrows: " & _GUIScrollBars_EnableScrollBar($hGUI, $SB_VERT, $ESB_ENABLE_BOTH))
    Sleep(3000)
    MemoWrite("Disable left arrow: " & _GUIScrollBars_EnableScrollBar($hGUI, $SB_HORZ, $ESB_DISABLE_LEFT))
    Sleep(3000)
    MemoWrite("Disable right arrow: " & _GUIScrollBars_EnableScrollBar($hGUI, $SB_HORZ, $ESB_DISABLE_RIGHT))
    Sleep(3000)
    MemoWrite("Enable both arrows: " & _GUIScrollBars_EnableScrollBar($hGUI, $SB_HORZ, $ESB_ENABLE_BOTH))

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE;, $nExititem
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_GetScrollBarInfoEx

Function Reference

_GUIScrollBars_GetScrollBarInfoEx

Retrieves information about the specified scroll bar

#include <GuiScrollBars.au3>
_GUIScrollBars_GetScrollBarInfoEx ( $hWnd, $iObject )

Parameters

$hWnd | Handle to the window
$iObject | Specifies the scroll bar object. This parameter can be one of the following values: $OBJID_CLIENT - The $hWnd parameter is a handle to a scroll bar control. $OBJID_HSCROLL - The horizontal scroll bar of the $hWnd window. $OBJID_VSCROLL - The vertical scroll bar of the $hWnd window.

Return Value

Success: | a $tagSCROLLBARINFO structure.
Failure: | sets the @error flag to non-zero.

Related

$tagSCROLLBARINFO, _GUIScrollBars_GetScrollBarRect, _GUIScrollBars_GetScrollBarRGState, _GUIScrollBars_GetScrollBarXYLineButton, _GUIScrollBars_GetScrollBarXYThumbBottom, _GUIScrollBars_GetScrollBarXYThumbTop

See Also

Search GetScrollBarInfo in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI, $tSCROLLBARINFO

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 380, 360, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    $tSCROLLBARINFO = _GUIScrollBars_GetScrollBarInfoEx($hGUI, $OBJID_HSCROLL)
    MemoWrite("Horizontal" & @CRLF & "--------------------------------------")
    MemoWrite("Left.........: " & DllStructGetData($tSCROLLBARINFO, "Left"))
    MemoWrite("Top..........: " & DllStructGetData($tSCROLLBARINFO, "Top"))
    MemoWrite("Right........: " & DllStructGetData($tSCROLLBARINFO, "Right"))
    MemoWrite("Bottom.......: " & DllStructGetData($tSCROLLBARINFO, "Bottom"))
    MemoWrite("dxyLineButton: " & DllStructGetData($tSCROLLBARINFO, "dxyLineButton"))
    MemoWrite("xyThumbTop...: " & DllStructGetData($tSCROLLBARINFO, "xyThumbTop"))
    MemoWrite("xyThumbBottom: " & DllStructGetData($tSCROLLBARINFO, "xyThumbBottom"))
    For $x = 0 To 5
        MemoWrite("rgstate[" & $x & "]...: " & DllStructGetData($tSCROLLBARINFO, "rgstate", $x + 1))
    Next

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_GetScrollBarRect

Function Reference

_GUIScrollBars_GetScrollBarRect

Retrieves coordinates of the scroll bar

#include <GuiScrollBars.au3>
_GUIScrollBars_GetScrollBarRect ( $hWnd, $iObject )

Parameters

$hWnd | Handle to the window
$iObject | Specifies the scroll bar object. This parameter can be one of the following values: $OBJID_CLIENT - The $hWnd parameter is a handle to a scroll bar control. $OBJID_HSCROLL - The horizontal scroll bar of the $hWnd window. $OBJID_VSCROLL - The vertical scroll bar of the $hWnd window.

Return Value

Success: | an array in the following format: [0] - Left [1] - Top [2] - Right [3] - Bottom
Failure: | sets the @error flag to non-zero.

Related

_GUIScrollBars_GetScrollBarInfoEx

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI, $aRect

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 380, 360, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    $aRect = _GUIScrollBars_GetScrollBarRect($hGUI, $OBJID_HSCROLL)
    MemoWrite("Horizontal" & @CRLF & "--------------------------------------")
    MemoWrite("Left.........: " & $aRect[0])
    MemoWrite("Top..........: " & $aRect[1])
    MemoWrite("Right........: " & $aRect[2])
    MemoWrite("Bottom.......: " & $aRect[3])

    $aRect = _GUIScrollBars_GetScrollBarRect($hGUI, $OBJID_VSCROLL)
    MemoWrite(@CRLF & "--------------------------------------" & @CRLF & "Vertical" & @CRLF & "--------------------------------------")
    MemoWrite("Left.........: " & $aRect[0])
    MemoWrite("Top..........: " & $aRect[1])
    MemoWrite("Right........: " & $aRect[2])
    MemoWrite("Bottom.......: " & $aRect[3])

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_GetScrollBarRGState

Function Reference

_GUIScrollBars_GetScrollBarRGState

Retrieves the state of a scroll bar component

#include <GuiScrollBars.au3>
_GUIScrollBars_GetScrollBarRGState ( $hWnd, $iObject )

Parameters

$hWnd | Handle to the window
$iObject | Specifies the scroll bar object. This parameter can be one of the following values: $OBJID_CLIENT - The $hWnd parameter is a handle to a scroll bar control. $OBJID_HSCROLL - The horizontal scroll bar of the $hWnd window. $OBJID_VSCROLL - The vertical scroll bar of the $hWnd window.

Return Value

Success: | an array in the following format: [0] - The scroll bar itself. [1] - The top or right arrow button. [2] - The page up or page right region. [3] - The scroll box (thumb). [4] - The page down or page left region. [5] - The bottom or left arrow button.
Failure: | sets the @error flag to non-zero.

Related

_GUIScrollBars_GetScrollBarInfoEx

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI, $aRGState

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 380, 360, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    $aRGState = _GUIScrollBars_GetScrollBarRGState($hGUI, $OBJID_HSCROLL)
    MemoWrite("Horizontal (Before)" & @CRLF & "--------------------------------------")
    For $x = 0 To 5
        MemoWrite("rgstate[" & $x & "]...: " & $aRGState[$x])
    Next

    MemoWrite(@CRLF & "Disable both arrows: " & _GUIScrollBars_EnableScrollBar($hGUI, $SB_HORZ, $ESB_DISABLE_BOTH) & @CRLF)

    $aRGState = _GUIScrollBars_GetScrollBarRGState($hGUI, $OBJID_HSCROLL)
    MemoWrite("Horizontal (After)" & @CRLF & "--------------------------------------")
    For $x = 0 To 5
        MemoWrite("rgstate[" & $x & "]...: " & $aRGState[$x])
    Next

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_GetScrollBarXYLineButton

Function Reference

_GUIScrollBars_GetScrollBarXYLineButton

Retrieves the Height or width of the thumb

#include <GuiScrollBars.au3>
_GUIScrollBars_GetScrollBarXYLineButton ( $hWnd, $iObject )

Parameters

$hWnd | Handle to the window
$iObject | Specifies the scroll bar object. This parameter can be one of the following values: $OBJID_CLIENT - The $hWnd parameter is a handle to a scroll bar control. $OBJID_HSCROLL - The horizontal scroll bar of the $hWnd window. $OBJID_VSCROLL - The vertical scroll bar of the $hWnd window.

Return Value

Success: | the height or width of the thumb.
Failure: | -1 and sets the @error flag to non-zero.

Related

_GUIScrollBars_GetScrollBarInfoEx

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 380, 360, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    MemoWrite("Horizontal" & @CRLF & "--------------------------------------")
    MemoWrite("Height of thumb: " & _GUIScrollBars_GetScrollBarXYLineButton($hGUI, $OBJID_HSCROLL) & @CRLF)

    MemoWrite("Vertical" & @CRLF & "--------------------------------------")
    MemoWrite("Width of thumb: " & _GUIScrollBars_GetScrollBarXYLineButton($hGUI, $OBJID_VSCROLL))

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_GetScrollBarXYThumbBottom

Function Reference

_GUIScrollBars_GetScrollBarXYThumbBottom

Retrieves the Position of the bottom or right of the thumb

#include <GuiScrollBars.au3>
_GUIScrollBars_GetScrollBarXYThumbBottom ( $hWnd, $iObject )

Parameters

$hWnd | Handle to the window
$iObject | Specifies the scroll bar object. This parameter can be one of the following values: $OBJID_CLIENT - The $hWnd parameter is a handle to a scroll bar control. $OBJID_HSCROLL - The horizontal scroll bar of the $hWnd window. $OBJID_VSCROLL - The vertical scroll bar of the $hWnd window.

Return Value

Success: | the position of the bottom or right of the thumb.
Failure: | -1 and sets the @error flag to non-zero.

Related

_GUIScrollBars_GetScrollBarInfoEx

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 380, 380, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    MemoWrite("Horizontal" & @CRLF & "--------------------------------------")
    MemoWrite("Left of thumb: " & _GUIScrollBars_GetScrollBarXYThumbTop($hGUI, $OBJID_HSCROLL))
    MemoWrite("Right of thumb: " & _GUIScrollBars_GetScrollBarXYThumbBottom($hGUI, $OBJID_HSCROLL) & @CRLF)

    MemoWrite("Vertical" & @CRLF & "--------------------------------------")
    MemoWrite("Top of thumb: " & _GUIScrollBars_GetScrollBarXYLineButton($hGUI, $OBJID_VSCROLL))
    MemoWrite("Bottom of thumb: " & _GUIScrollBars_GetScrollBarXYThumbBottom($hGUI, $OBJID_VSCROLL))

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_GetScrollBarXYThumbTop

Function Reference

_GUIScrollBars_GetScrollBarXYThumbTop

Retrieves the Position of the top or left of the thumb

#include <GuiScrollBars.au3>
_GUIScrollBars_GetScrollBarXYThumbTop ( $hWnd, $iObject )

Parameters

$hWnd | Handle to the window
$iObject | Specifies the scroll bar object. This parameter can be one of the following values: $OBJID_CLIENT - The $hWnd parameter is a handle to a scroll bar control. $OBJID_HSCROLL - The horizontal scroll bar of the $hWnd window. $OBJID_VSCROLL - The vertical scroll bar of the $hWnd window.

Return Value

Success: | the position of the top or left of the thumb.
Failure: | sets the @error flag to non-zero.

Related

_GUIScrollBars_GetScrollBarInfoEx

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 380, 380, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    MemoWrite("Horizontal" & @CRLF & "--------------------------------------")
    MemoWrite("Left of thumb: " & _GUIScrollBars_GetScrollBarXYThumbTop($hGUI, $OBJID_HSCROLL))
    MemoWrite("Right of thumb: " & _GUIScrollBars_GetScrollBarXYThumbBottom($hGUI, $OBJID_HSCROLL) & @CRLF)

    MemoWrite("Vertical" & @CRLF & "--------------------------------------")
    MemoWrite("Top of thumb: " & _GUIScrollBars_GetScrollBarXYLineButton($hGUI, $OBJID_VSCROLL))
    MemoWrite("Bottom of thumb: " & _GUIScrollBars_GetScrollBarXYThumbBottom($hGUI, $OBJID_VSCROLL))

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_GetScrollInfo

Function Reference

_GUIScrollBars_GetScrollInfo

Retrieves the parameters of a scroll bar

#include <GuiScrollBars.au3>
_GUIScrollBars_GetScrollInfo ( $hWnd, $iBar, ByRef $tSCROLLINFO )

Parameters

$hWnd | Handle to the window
$iBar | Specifies the type of scroll bar. This parameter can be one of the following values: $SB_CTL - Retrieves the parameters for a scroll bar control. The $hWnd parameter must be the handle to the scroll bar control. $SB_HORZ - Retrieves the parameters for the window's standard horizontal scroll bar. $SB_VERT - Retrieves the parameters for the window's standard vertical scroll bar.
$tSCROLLINFO | Structure of type $tagSCROLLINFO

Return Value

Success: | True.
Failure: | False.

Related

$tagSCROLLINFO, _GUIScrollBars_GetScrollInfoEx, _GUIScrollBars_SetScrollInfo

See Also

Search GetScrollInfo in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI, $tSCROLLINFO = DllStructCreate($tagSCROLLINFO)

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 380, 360, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    DllStructSetData($tSCROLLINFO, "cbSize", DllStructGetSize($tSCROLLINFO))
    DllStructSetData($tSCROLLINFO, "fMask", $SIF_ALL)
    _GUIScrollBars_GetScrollInfo($hGUI, $SB_HORZ, $tSCROLLINFO)
    MemoWrite("Horizontal" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & DllStructGetData($tSCROLLINFO, "nPage"))
    MemoWrite("nPos.....: " & DllStructGetData($tSCROLLINFO, "nPos"))
    MemoWrite("nMin.....: " & DllStructGetData($tSCROLLINFO, "nMin"))
    MemoWrite("nMax.....: " & DllStructGetData($tSCROLLINFO, "nMax"))
    MemoWrite("nTrackPos: " & DllStructGetData($tSCROLLINFO, "nTrackPos"))

    DllStructSetData($tSCROLLINFO, "cbSize", DllStructGetSize($tSCROLLINFO))
    DllStructSetData($tSCROLLINFO, "fMask", $SIF_ALL)
    _GUIScrollBars_GetScrollInfo($hGUI, $SB_VERT, $tSCROLLINFO)
    $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hGUI, $SB_VERT)
    MemoWrite(@CRLF & "Vertical" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & DllStructGetData($tSCROLLINFO, "nPage"))
    MemoWrite("nPos.....: " & DllStructGetData($tSCROLLINFO, "nPos"))
    MemoWrite("nMin.....: " & DllStructGetData($tSCROLLINFO, "nMin"))
    MemoWrite("nMax.....: " & DllStructGetData($tSCROLLINFO, "nMax"))
    MemoWrite("nTrackPos: " & DllStructGetData($tSCROLLINFO, "nTrackPos"))

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_GetScrollInfoEx

Function Reference

_GUIScrollBars_GetScrollInfoEx

Retrieves the parameters of a scroll bar

#include <GuiScrollBars.au3>
_GUIScrollBars_GetScrollInfoEx ( $hWnd, $iBar )

Parameters

$hWnd | Handle to the window
$iBar | Specifies the type of scroll bar. This parameter can be one of the following values: $SB_CTL - Retrieves the parameters for a scroll bar control. The $hWnd parameter must be the handle to the scroll bar control. $SB_HORZ - Retrieves the parameters for the window's standard horizontal scroll bar. $SB_VERT - Retrieves the parameters for the window's standard vertical scroll bar.

Return Value

Success: | a $tagSCROLLINFO structure.
Failure: | sets the @error flag to non-zero.

Related

$tagSCROLLINFO, _GUIScrollBars_GetScrollInfo, _GUIScrollBars_GetScrollInfoMax, _GUIScrollBars_GetScrollInfoMin, _GUIScrollBars_GetScrollInfoPage, _GUIScrollBars_GetScrollInfoPos, _GUIScrollBars_GetScrollInfoTrackPos

See Also

Search GetScrollInfo in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI, $tSCROLLBARINFO

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 380, 226, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    $tSCROLLBARINFO = _GUIScrollBars_GetScrollBarInfoEx($hGUI, $OBJID_HSCROLL)
    MemoWrite("Horizontal" & @CRLF & "--------------------------------------")
    MemoWrite("Left.........: " & DllStructGetData($tSCROLLBARINFO, "Left"))
    MemoWrite("Top..........: " & DllStructGetData($tSCROLLBARINFO, "Top"))
    MemoWrite("Right........: " & DllStructGetData($tSCROLLBARINFO, "Right"))
    MemoWrite("Bottom.......: " & DllStructGetData($tSCROLLBARINFO, "Bottom"))
    MemoWrite("dxyLineButton: " & DllStructGetData($tSCROLLBARINFO, "dxyLineButton"))
    MemoWrite("xyThumbTop...: " & DllStructGetData($tSCROLLBARINFO, "xyThumbTop"))
    MemoWrite("xyThumbBottom: " & DllStructGetData($tSCROLLBARINFO, "xyThumbBottom"))
    For $x = 0 To 5
        MemoWrite("rgstate[" & $x & "]...: " & DllStructGetData($tSCROLLBARINFO, "rgstate", $x + 1))
    Next

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_GetScrollInfoMax

Function Reference

_GUIScrollBars_GetScrollInfoMax

Retrieves the maximum scrolling position

#include <GuiScrollBars.au3>
_GUIScrollBars_GetScrollInfoMax ( $hWnd, $iBar )

Parameters

$hWnd | Handle to the window
$iBar | Specifies the type of scroll bar. This parameter can be one of the following values: $SB_CTL - Retrieves the parameters for a scroll bar control. The $hWnd parameter must be the handle to the scroll bar control. $SB_HORZ - Retrieves the parameters for the window's standard horizontal scroll bar. $SB_VERT - Retrieves the parameters for the window's standard vertical scroll bar.

Return Value

Success: | the maximum scrolling position.
Failure: | sets the @error flag to non-zero.

Related

_GUIScrollBars_GetScrollInfoEx

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 380, 380, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    MemoWrite("Horizontal" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_HORZ))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_HORZ))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_HORZ))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_HORZ))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_HORZ))

    MemoWrite(@CRLF & "Vertical" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_VERT))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_VERT))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_VERT))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_VERT))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_VERT))

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_GetScrollInfoMin

Function Reference

_GUIScrollBars_GetScrollInfoMin

Retrieves the minimum scrolling position

#include <GuiScrollBars.au3>
_GUIScrollBars_GetScrollInfoMin ( $hWnd, $iBar )

Parameters

$hWnd | Handle to the window
$iBar | Specifies the type of scroll bar. This parameter can be one of the following values: $SB_CTL - Retrieves the parameters for a scroll bar control. The $hWnd parameter must be the handle to the scroll bar control. $SB_HORZ - Retrieves the parameters for the window's standard horizontal scroll bar. $SB_VERT - Retrieves the parameters for the window's standard vertical scroll bar.

Return Value

Success: | the minimum scrolling position.
Failure: | sets the @error flag to non-zero.

Related

_GUIScrollBars_GetScrollInfoEx

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 380, 380, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    MemoWrite("Horizontal" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_HORZ))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_HORZ))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_HORZ))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_HORZ))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_HORZ))

    MemoWrite(@CRLF & "Vertical" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_VERT))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_VERT))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_VERT))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_VERT))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_VERT))

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_GetScrollInfoPage

Function Reference

_GUIScrollBars_GetScrollInfoPage

Retrieves the page size

#include <GuiScrollBars.au3>
_GUIScrollBars_GetScrollInfoPage ( $hWnd, $iBar )

Parameters

$hWnd | Handle to the window
$iBar | Specifies the type of scroll bar. This parameter can be one of the following values: $SB_CTL - Retrieves the parameters for a scroll bar control. The $hWnd parameter must be the handle to the scroll bar control. $SB_HORZ - Retrieves the parameters for the window's standard horizontal scroll bar. $SB_VERT - Retrieves the parameters for the window's standard vertical scroll bar.

Return Value

Success: | the page size.
Failure: | sets the @error flag to non-zero.

Related

_GUIScrollBars_GetScrollInfoEx

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 380, 380, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    MemoWrite("Horizontal" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_HORZ))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_HORZ))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_HORZ))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_HORZ))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_HORZ))

    MemoWrite(@CRLF & "Vertical" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_VERT))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_VERT))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_VERT))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_VERT))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_VERT))

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_GetScrollInfoPos

Function Reference

_GUIScrollBars_GetScrollInfoPos

Retrieves the position of the scroll box

#include <GuiScrollBars.au3>
_GUIScrollBars_GetScrollInfoPos ( $hWnd, $iBar )

Parameters

$hWnd | Handle to the window
$iBar | Specifies the type of scroll bar. This parameter can be one of the following values: $SB_CTL - Retrieves the parameters for a scroll bar control. The $hWnd parameter must be the handle to the scroll bar control. $SB_HORZ - Retrieves the parameters for the window's standard horizontal scroll bar. $SB_VERT - Retrieves the parameters for the window's standard vertical scroll bar.

Return Value

Success: | the position of the scroll box.
Failure: | sets the @error flag to non-zero.

Related

_GUIScrollBars_GetScrollInfoEx

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 380, 380, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    MemoWrite("Horizontal" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_HORZ))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_HORZ))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_HORZ))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_HORZ))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_HORZ))

    MemoWrite(@CRLF & "Vertical" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_VERT))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_VERT))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_VERT))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_VERT))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_VERT))

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_GetScrollInfoTrackPos

Function Reference

_GUIScrollBars_GetScrollInfoTrackPos

Retrieves the immediate position of a scroll box that the user is dragging

#include <GuiScrollBars.au3>
_GUIScrollBars_GetScrollInfoTrackPos ( $hWnd, $iBar )

Parameters

$hWnd | Handle to the window
$iBar | Specifies the type of scroll bar. This parameter can be one of the following values: $SB_CTL - Retrieves the parameters for a scroll bar control. The $hWnd parameter must be the handle to the scroll bar control. $SB_HORZ - Retrieves the parameters for the window's standard horizontal scroll bar. $SB_VERT - Retrieves the parameters for the window's standard vertical scroll bar.

Return Value

Success: | the immediate position of a scroll box.
Failure: | sets the @error flag to non-zero.

Related

_GUIScrollBars_GetScrollInfoEx

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 380, 380, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    MemoWrite("Horizontal" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_HORZ))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_HORZ))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_HORZ))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_HORZ))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_HORZ))

    MemoWrite(@CRLF & "Vertical" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_VERT))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_VERT))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_VERT))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_VERT))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_VERT))

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_GetScrollPos

Function Reference

_GUIScrollBars_GetScrollPos

Retrieves the current position of the scroll box (thumb) in the specified scroll bar

#include <GuiScrollBars.au3>
_GUIScrollBars_GetScrollPos ( $hWnd, $iBar )

Parameters

$hWnd | Handle to the window
$iBar | Specifies the type of scroll bar. This parameter can be one of the following values: $SB_CTL - Retrieves the position of the scroll box in a scroll bar control. The $hWnd parameter must be the handle to the scroll bar control. $SB_HORZ - Retrieves the position of the scroll box in a window's standard horizontal scroll bar $SB_VERT - Retrieves the position of the scroll box in a window's standard vertical scroll bar.

Return Value

Success: | the current position of the scroll box.
Failure: | -1.

Related

_GUIScrollBars_SetScrollInfoPos

See Also

Search GetScrollPos in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 380, 380, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, 10)
    MemoWrite("Scroll Pos Horizontal: " & _GUIScrollBars_GetScrollPos($hGUI, $SB_HORZ))
    Sleep(1000)
    _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, 0)
    MemoWrite("Scroll Pos Horizontal: " & _GUIScrollBars_GetScrollPos($hGUI, $SB_HORZ))
    Sleep(1000)
    _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, 20)
    MemoWrite("Scroll Pos Vertical: " & _GUIScrollBars_GetScrollPos($hGUI, $SB_VERT))
    Sleep(1000)
    _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, 0)
    MemoWrite("Scroll Pos Vertical: " & _GUIScrollBars_GetScrollPos($hGUI, $SB_VERT))

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_GetScrollRange

Function Reference

_GUIScrollBars_GetScrollRange

Retrieves the current minimum and maximum scroll box (thumb) positions for the specified scroll bar

#include <GuiScrollBars.au3>
_GUIScrollBars_GetScrollRange ( $hWnd, $iBar )

Parameters

$hWnd | Handle to the window
$iBar | Specifies the type of scroll bar. This parameter can be one of the following values: $SB_CTL - Retrieves the positions of a scroll bar control. The $hWnd parameter must be the handle to the scroll bar control. $SB_HORZ - Retrieves the positions of the window's standard horizontal scroll bar. $SB_VERT - Retrieves the positions of the window's standard vertical scroll bar.

Return Value

Success: | the current minimum and maximum scroll box (thumb) positions for the specified scroll bar, in the following format: [0] - minimum position [1] - maximum position
Failure: | sets the @error flag to non-zero.

Related

_GUIScrollBars_SetScrollRange

See Also

Search GetScrollRange in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI, $aRangeMinMax

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 380, 380, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    $aRangeMinMax = _GUIScrollBars_GetScrollRange($hGUI, $SB_VERT)
    MemoWrite("Vertical Min/Max: " & $aRangeMinMax[0] & "/" & $aRangeMinMax[1])
    $aRangeMinMax = _GUIScrollBars_GetScrollRange($hGUI, $SB_HORZ)
    MemoWrite("Horizontal Min/Max: " & $aRangeMinMax[0] & "/" & $aRangeMinMax[1])
    Sleep(1000)
    _GUIScrollBars_SetScrollRange($hGUI, $SB_VERT, 3, 30)
    $aRangeMinMax = _GUIScrollBars_GetScrollRange($hGUI, $SB_VERT)
    MemoWrite("New Vertical Min/Max: " & $aRangeMinMax[0] & "/" & $aRangeMinMax[1])
    Sleep(1000)
    _GUIScrollBars_SetScrollRange($hGUI, $SB_HORZ, 10, 98)
    $aRangeMinMax = _GUIScrollBars_GetScrollRange($hGUI, $SB_HORZ)
    MemoWrite("New Horizontal Min/Max: " & $aRangeMinMax[0] & "/" & $aRangeMinMax[1])

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_Init

Function Reference

_GUIScrollBars_Init

Initialize the scrollbars for the window

#include <GuiScrollBars.au3>
_GUIScrollBars_Init ( $hWnd [, $iMaxH = -1 [, $iMaxV = -1]] )

Parameters

$hWnd | Handle to the window
$iMaxH | [optional] Max size of Horizontal scrollbar
$iMaxV | [optional] Max size of Vertical scrollbar

Return Value

None.

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idFileMenu, $idExititem, $hGUIMsg, $hGUI, $h_GUIC, $h_GUIC2
    Local $idListview, $idButton

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    GUISetBkColor(0x88AABB)

    $idFileMenu = GUICtrlCreateMenu("File")
    $idExititem = GUICtrlCreateMenuItem("Exit", $idFileMenu)
    $idListview = GUICtrlCreateListView("col1  |col2|col3  ", 10, 10, 200, 150) ; ,$LVS_SORTDESCENDING)
    $idButton = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
    GUICtrlSetResizing($idButton, $GUI_DOCKALL)
    For $x = 1 To 30
        GUICtrlCreateListViewItem("item" & $x & "|col2|col3", $idListview)
    Next
    GUICtrlSetResizing($idListview, $GUI_DOCKALL)

    $h_GUIC = GUICreate("Child GUI", 200, 200, 10, 200, $WS_CHILD, $WS_EX_CLIENTEDGE, $hGUI)
    GUICtrlCreateButton("a button", 10, 10, 90, 20)
    GUISetBkColor(0X006400)
    GUISetState(@SW_SHOW)
    GUICtrlSetResizing($h_GUIC, $GUI_DOCKALL)

    GUISwitch($hGUI)

    $h_GUIC2 = GUICreate("Child GUI", 200, 200, 215, 10, $WS_CHILD, $WS_EX_CLIENTEDGE, $hGUI)
    GUICtrlCreateButton("a button", 10, 10, 90, 20)
    GUISetBkColor(0X006400)
    GUISetState(@SW_SHOW)
    GUICtrlSetResizing($h_GUIC2, $GUI_DOCKALL)

    GUISwitch($hGUI)

    GUIRegisterMsg($WM_SIZE, "WM_SIZE")
    GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
    GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)
    _GUIScrollBars_Init($h_GUIC)

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE, $idExititem
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $iIndex = -1, $iCharY, $iCharX, $iClientMaxX, $iClientX, $iClientY, $iMax
    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $iClientMaxX = $__g_aSB_WindowInfo[$iIndex][1]
            $iCharX = $__g_aSB_WindowInfo[$iIndex][2]
            $iCharY = $__g_aSB_WindowInfo[$iIndex][3]
            $iMax = $__g_aSB_WindowInfo[$iIndex][7]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO)

    ; Retrieve the dimensions of the client area.
    $iClientX = BitAND($lParam, 0x0000FFFF)
    $iClientY = BitShift($lParam, 16)
    $__g_aSB_WindowInfo[$iIndex][4] = $iClientX
    $__g_aSB_WindowInfo[$iIndex][5] = $iClientY

    ; Set the vertical scrolling range and page size
    DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
    DllStructSetData($tSCROLLINFO, "nMin", 0)
    DllStructSetData($tSCROLLINFO, "nMax", $iMax)
    DllStructSetData($tSCROLLINFO, "nPage", $iClientY / $iCharY)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)

    ; Set the horizontal scrolling range and page size
    DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
    DllStructSetData($tSCROLLINFO, "nMin", 0)
    DllStructSetData($tSCROLLINFO, "nMax", 2 + $iClientMaxX / $iCharX)
    DllStructSetData($tSCROLLINFO, "nPage", $iClientX / $iCharX)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE

Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $lParam
    Local $iScrollCode = BitAND($wParam, 0x0000FFFF)

    Local $iIndex = -1, $iCharX, $iPosX
    Local $iMin, $iMax, $iPage, $iPos, $iTrackPos

    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $iCharX = $__g_aSB_WindowInfo[$iIndex][2]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    ; ; Get all the horizontal scroll bar information
    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ)
    $iMin = DllStructGetData($tSCROLLINFO, "nMin")
    $iMax = DllStructGetData($tSCROLLINFO, "nMax")
    $iPage = DllStructGetData($tSCROLLINFO, "nPage")
    ; Save the position for comparison later on
    $iPosX = DllStructGetData($tSCROLLINFO, "nPos")
    $iPos = $iPosX
    $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
    #forceref $iMin, $iMax
    Switch $iScrollCode

        Case $SB_LINELEFT ; user clicked left arrow
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1)

        Case $SB_LINERIGHT ; user clicked right arrow
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1)

        Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage)

        Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage)

        Case $SB_THUMBTRACK ; user dragged the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos)
    EndSwitch

    ; // Set the position and then retrieve it.  Due to adjustments
    ; //   by Windows it may not be the same as the value set.

    DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    ;// If the position has changed, scroll the window and update it
    $iPos = DllStructGetData($tSCROLLINFO, "nPos")
    If ($iPos <> $iPosX) Then _GUIScrollBars_ScrollWindow($hWnd, $iCharX * ($iPosX - $iPos), 0)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_HSCROLL

Func WM_VSCROLL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam
    Local $iScrollCode = BitAND($wParam, 0x0000FFFF)
    Local $iIndex = -1, $iCharY, $iPosY
    Local $iMin, $iMax, $iPage, $iPos, $iTrackPos

    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $iCharY = $__g_aSB_WindowInfo[$iIndex][3]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    ; Get all the vertial scroll bar information
    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
    $iMin = DllStructGetData($tSCROLLINFO, "nMin")
    $iMax = DllStructGetData($tSCROLLINFO, "nMax")
    $iPage = DllStructGetData($tSCROLLINFO, "nPage")
    ; Save the position for comparison later on
    $iPosY = DllStructGetData($tSCROLLINFO, "nPos")
    $iPos = $iPosY
    $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")

    Switch $iScrollCode
        Case $SB_TOP ; user clicked the HOME keyboard key
            DllStructSetData($tSCROLLINFO, "nPos", $iMin)

        Case $SB_BOTTOM ; user clicked the END keyboard key
            DllStructSetData($tSCROLLINFO, "nPos", $iMax)

        Case $SB_LINEUP ; user clicked the top arrow
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1)

        Case $SB_LINEDOWN ; user clicked the bottom arrow
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1)

        Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage)

        Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage)

        Case $SB_THUMBTRACK ; user dragged the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos)
    EndSwitch

    ; // Set the position and then retrieve it.  Due to adjustments
    ; //   by Windows it may not be the same as the value set.

    DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
    _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
    ;// If the position has changed, scroll the window and update it
    $iPos = DllStructGetData($tSCROLLINFO, "nPos")

    If ($iPos <> $iPosY) Then
        _GUIScrollBars_ScrollWindow($hWnd, 0, $iCharY * ($iPosY - $iPos))
        $iPosY = $iPos
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_VSCROLL


Function _GUIScrollBars_ScrollWindow

Function Reference

_GUIScrollBars_ScrollWindow

Scrolls the contents of the specified window's client area

#include <GuiScrollBars.au3>
_GUIScrollBars_ScrollWindow ( $hWnd, $iXAmount, $iYAmount )

Parameters

$hWnd | Handle to the window
$iXAmount | Specifies the amount, in device units, of horizontal scrolling
$iYAmount | Specifies the amount, in device units, of vertical scrolling

Return Value

Success: | True.
Failure: | False.

See Also

Search ScrollWindow in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idFileMenu, $idExititem, $hGUIMsg, $hGUI, $h_GUIC, $h_GUIC2
    Local $idListview, $idButton

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    GUISetBkColor(0x88AABB)

    $idFileMenu = GUICtrlCreateMenu("File")
    $idExititem = GUICtrlCreateMenuItem("Exit", $idFileMenu)
    $idListview = GUICtrlCreateListView("col1  |col2|col3  ", 10, 10, 200, 150) ; ,$LVS_SORTDESCENDING)
    $idButton = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
    GUICtrlSetResizing($idButton, $GUI_DOCKALL)
    For $x = 1 To 30
        GUICtrlCreateListViewItem("item" & $x & "|col2|col3", $idListview)
    Next
    GUICtrlSetResizing($idListview, $GUI_DOCKALL)

    $h_GUIC = GUICreate("Child GUI", 200, 200, 10, 200, $WS_CHILD, $WS_EX_CLIENTEDGE, $hGUI)
    GUICtrlCreateButton("a button", 10, 10, 90, 20)
    GUISetBkColor(0X006400)
    GUISetState(@SW_SHOW)
    GUICtrlSetResizing($h_GUIC, $GUI_DOCKALL)

    GUISwitch($hGUI)

    $h_GUIC2 = GUICreate("Child GUI", 200, 200, 215, 10, $WS_CHILD, $WS_EX_CLIENTEDGE, $hGUI)
    GUICtrlCreateButton("a button", 10, 10, 90, 20)
    GUISetBkColor(0X006400)
    GUISetState(@SW_SHOW)
    GUICtrlSetResizing($h_GUIC2, $GUI_DOCKALL)

    GUISwitch($hGUI)

    GUIRegisterMsg($WM_SIZE, "WM_SIZE")
    GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
    GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)
    _GUIScrollBars_Init($h_GUIC)

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE, $idExititem
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $iIndex = -1, $iCharY, $iCharX, $iClientMaxX, $iClientX, $iClientY, $iMax
    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $iClientMaxX = $__g_aSB_WindowInfo[$iIndex][1]
            $iCharX = $__g_aSB_WindowInfo[$iIndex][2]
            $iCharY = $__g_aSB_WindowInfo[$iIndex][3]
            $iMax = $__g_aSB_WindowInfo[$iIndex][7]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO)

    ; Retrieve the dimensions of the client area.
    $iClientX = BitAND($lParam, 0x0000FFFF)
    $iClientY = BitShift($lParam, 16)
    $__g_aSB_WindowInfo[$iIndex][4] = $iClientX
    $__g_aSB_WindowInfo[$iIndex][5] = $iClientY

    ; Set the vertical scrolling range and page size
    DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
    DllStructSetData($tSCROLLINFO, "nMin", 0)
    DllStructSetData($tSCROLLINFO, "nMax", $iMax)
    DllStructSetData($tSCROLLINFO, "nPage", $iClientY / $iCharY)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)

    ; Set the horizontal scrolling range and page size
    DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
    DllStructSetData($tSCROLLINFO, "nMin", 0)
    DllStructSetData($tSCROLLINFO, "nMax", 2 + $iClientMaxX / $iCharX)
    DllStructSetData($tSCROLLINFO, "nPage", $iClientX / $iCharX)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE

Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $lParam
    Local $iScrollCode = BitAND($wParam, 0x0000FFFF)

    Local $iIndex = -1, $iCharX, $iPosX
    Local $iMin, $iMax, $iPage, $iPos, $iTrackPos

    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $iCharX = $__g_aSB_WindowInfo[$iIndex][2]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    ; ; Get all the horizontal scroll bar information
    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ)
    $iMin = DllStructGetData($tSCROLLINFO, "nMin")
    $iMax = DllStructGetData($tSCROLLINFO, "nMax")
    $iPage = DllStructGetData($tSCROLLINFO, "nPage")
    ; Save the position for comparison later on
    $iPosX = DllStructGetData($tSCROLLINFO, "nPos")
    $iPos = $iPosX
    $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
    #forceref $iMin, $iMax
    Switch $iScrollCode

        Case $SB_LINELEFT ; user clicked left arrow
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1)

        Case $SB_LINERIGHT ; user clicked right arrow
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1)

        Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage)

        Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage)

        Case $SB_THUMBTRACK ; user dragged the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos)
    EndSwitch

    ; // Set the position and then retrieve it.  Due to adjustments
    ; //   by Windows it may not be the same as the value set.

    DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    ;// If the position has changed, scroll the window and update it
    $iPos = DllStructGetData($tSCROLLINFO, "nPos")
    If ($iPos <> $iPosX) Then _GUIScrollBars_ScrollWindow($hWnd, $iCharX * ($iPosX - $iPos), 0)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_HSCROLL

Func WM_VSCROLL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam
    Local $iScrollCode = BitAND($wParam, 0x0000FFFF)
    Local $iIndex = -1, $iCharY, $iPosY
    Local $iMin, $iMax, $iPage, $iPos, $iTrackPos

    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $iCharY = $__g_aSB_WindowInfo[$iIndex][3]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    ; Get all the vertial scroll bar information
    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
    $iMin = DllStructGetData($tSCROLLINFO, "nMin")
    $iMax = DllStructGetData($tSCROLLINFO, "nMax")
    $iPage = DllStructGetData($tSCROLLINFO, "nPage")
    ; Save the position for comparison later on
    $iPosY = DllStructGetData($tSCROLLINFO, "nPos")
    $iPos = $iPosY
    $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")

    Switch $iScrollCode
        Case $SB_TOP ; user clicked the HOME keyboard key
            DllStructSetData($tSCROLLINFO, "nPos", $iMin)

        Case $SB_BOTTOM ; user clicked the END keyboard key
            DllStructSetData($tSCROLLINFO, "nPos", $iMax)

        Case $SB_LINEUP ; user clicked the top arrow
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1)

        Case $SB_LINEDOWN ; user clicked the bottom arrow
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1)

        Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage)

        Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage)

        Case $SB_THUMBTRACK ; user dragged the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos)
    EndSwitch

    ; // Set the position and then retrieve it.  Due to adjustments
    ; //   by Windows it may not be the same as the value set.

    DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
    _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
    ;// If the position has changed, scroll the window and update it
    $iPos = DllStructGetData($tSCROLLINFO, "nPos")

    If ($iPos <> $iPosY) Then
        _GUIScrollBars_ScrollWindow($hWnd, 0, $iCharY * ($iPosY - $iPos))
        $iPosY = $iPos
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_VSCROLL


Function _GUIScrollBars_SetScrollInfo

Function Reference

_GUIScrollBars_SetScrollInfo

Sets the parameters of a scroll bar

#include <GuiScrollBars.au3>
_GUIScrollBars_SetScrollInfo ( $hWnd, $iBar, $tSCROLLINFO [, $bRedraw = True] )

Parameters

$hWnd | Handle to the window
$iBar | Specifies the type of scroll bar. This parameter can be one of the following values: $SB_CTL - Sets the parameters of a scroll bar control. The $hWnd parameter must be the handle to the scroll bar control. $SB_HORZ - Sets the parameters of the window's standard horizontal scroll bar. $SB_VERT - Sets the parameters of the window's standard vertical scroll bar.
$tSCROLLINFO | Structure of type $tagSCROLLINFO
$bRedraw | [optional] Specifies whether the scroll bar is redrawn to reflect the changes to the scroll bar

Return Value

Success: | the current position of the scroll box.
Failure: | -1.

Related

_GUIScrollBars_GetScrollInfo, _GUIScrollBars_SetScrollInfoMax, _GUIScrollBars_SetScrollInfoMin, _GUIScrollBars_SetScrollInfoPage, _GUIScrollBars_SetScrollInfoPos

See Also

Search SetScrollInfo in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idFileMenu, $idExititem, $hGUIMsg, $hGUI, $h_GUIC, $h_GUIC2
    Local $idListview, $idButton

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    GUISetBkColor(0x88AABB)

    $idFileMenu = GUICtrlCreateMenu("File")
    $idExititem = GUICtrlCreateMenuItem("Exit", $idFileMenu)
    $idListview = GUICtrlCreateListView("col1  |col2|col3  ", 10, 10, 200, 150) ; ,$LVS_SORTDESCENDING)
    $idButton = GUICtrlCreateButton("Value?", 75, 170, 70, 20)
    GUICtrlSetResizing($idButton, $GUI_DOCKALL)
    For $x = 1 To 30
        GUICtrlCreateListViewItem("item" & $x & "|col2|col3", $idListview)
    Next
    GUICtrlSetResizing($idListview, $GUI_DOCKALL)

    $h_GUIC = GUICreate("Child GUI", 200, 200, 10, 200, $WS_CHILD, $WS_EX_CLIENTEDGE, $hGUI)
    GUICtrlCreateButton("a button", 10, 10, 90, 20)
    GUISetBkColor(0X006400)
    GUISetState(@SW_SHOW)
    GUICtrlSetResizing($h_GUIC, $GUI_DOCKALL)

    GUISwitch($hGUI)

    $h_GUIC2 = GUICreate("Child GUI", 200, 200, 215, 10, $WS_CHILD, $WS_EX_CLIENTEDGE, $hGUI)
    GUICtrlCreateButton("a button", 10, 10, 90, 20)
    GUISetBkColor(0X006400)
    GUISetState(@SW_SHOW)
    GUICtrlSetResizing($h_GUIC2, $GUI_DOCKALL)

    GUISwitch($hGUI)

    GUIRegisterMsg($WM_SIZE, "WM_SIZE")
    GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
    GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)
    _GUIScrollBars_Init($h_GUIC)

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE, $idExititem
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam
    Local $iIndex = -1, $iCharY, $iCharX, $iClientMaxX, $iClientX, $iClientY, $iMax
    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $iClientMaxX = $__g_aSB_WindowInfo[$iIndex][1]
            $iCharX = $__g_aSB_WindowInfo[$iIndex][2]
            $iCharY = $__g_aSB_WindowInfo[$iIndex][3]
            $iMax = $__g_aSB_WindowInfo[$iIndex][7]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO)

    ; Retrieve the dimensions of the client area.
    $iClientX = BitAND($lParam, 0x0000FFFF)
    $iClientY = BitShift($lParam, 16)
    $__g_aSB_WindowInfo[$iIndex][4] = $iClientX
    $__g_aSB_WindowInfo[$iIndex][5] = $iClientY

    ; Set the vertical scrolling range and page size
    DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
    DllStructSetData($tSCROLLINFO, "nMin", 0)
    DllStructSetData($tSCROLLINFO, "nMax", $iMax)
    DllStructSetData($tSCROLLINFO, "nPage", $iClientY / $iCharY)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)

    ; Set the horizontal scrolling range and page size
    DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
    DllStructSetData($tSCROLLINFO, "nMin", 0)
    DllStructSetData($tSCROLLINFO, "nMax", 2 + $iClientMaxX / $iCharX)
    DllStructSetData($tSCROLLINFO, "nPage", $iClientX / $iCharX)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE

Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $lParam
    Local $iScrollCode = BitAND($wParam, 0x0000FFFF)

    Local $iIndex = -1, $iCharX, $iPosX
    Local $iMin, $iMax, $iPage, $iPos, $iTrackPos

    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $iCharX = $__g_aSB_WindowInfo[$iIndex][2]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    ; ; Get all the horizontal scroll bar information
    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ)
    $iMin = DllStructGetData($tSCROLLINFO, "nMin")
    $iMax = DllStructGetData($tSCROLLINFO, "nMax")
    $iPage = DllStructGetData($tSCROLLINFO, "nPage")
    ; Save the position for comparison later on
    $iPosX = DllStructGetData($tSCROLLINFO, "nPos")
    $iPos = $iPosX
    $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
    #forceref $iMin, $iMax
    Switch $iScrollCode

        Case $SB_LINELEFT ; user clicked left arrow
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1)

        Case $SB_LINERIGHT ; user clicked right arrow
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1)

        Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage)

        Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage)

        Case $SB_THUMBTRACK ; user dragged the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos)
    EndSwitch

    ; // Set the position and then retrieve it.  Due to adjustments
    ; //   by Windows it may not be the same as the value set.

    DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    ;// If the position has changed, scroll the window and update it
    $iPos = DllStructGetData($tSCROLLINFO, "nPos")
    If ($iPos <> $iPosX) Then _GUIScrollBars_ScrollWindow($hWnd, $iCharX * ($iPosX - $iPos), 0)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_HSCROLL

Func WM_VSCROLL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam
    Local $iScrollCode = BitAND($wParam, 0x0000FFFF)
    Local $iIndex = -1, $iCharY, $iPosY
    Local $iMin, $iMax, $iPage, $iPos, $iTrackPos

    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $iCharY = $__g_aSB_WindowInfo[$iIndex][3]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    ; Get all the vertial scroll bar information
    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
    $iMin = DllStructGetData($tSCROLLINFO, "nMin")
    $iMax = DllStructGetData($tSCROLLINFO, "nMax")
    $iPage = DllStructGetData($tSCROLLINFO, "nPage")
    ; Save the position for comparison later on
    $iPosY = DllStructGetData($tSCROLLINFO, "nPos")
    $iPos = $iPosY
    $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")

    Switch $iScrollCode
        Case $SB_TOP ; user clicked the HOME keyboard key
            DllStructSetData($tSCROLLINFO, "nPos", $iMin)

        Case $SB_BOTTOM ; user clicked the END keyboard key
            DllStructSetData($tSCROLLINFO, "nPos", $iMax)

        Case $SB_LINEUP ; user clicked the top arrow
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1)

        Case $SB_LINEDOWN ; user clicked the bottom arrow
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1)

        Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage)

        Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage)

        Case $SB_THUMBTRACK ; user dragged the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos)
    EndSwitch

    ; // Set the position and then retrieve it.  Due to adjustments
    ; //   by Windows it may not be the same as the value set.

    DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
    _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
    ;// If the position has changed, scroll the window and update it
    $iPos = DllStructGetData($tSCROLLINFO, "nPos")

    If ($iPos <> $iPosY) Then
        _GUIScrollBars_ScrollWindow($hWnd, 0, $iCharY * ($iPosY - $iPos))
        $iPosY = $iPos
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_VSCROLL


Function _GUIScrollBars_SetScrollInfoMax

Function Reference

_GUIScrollBars_SetScrollInfoMax

Sets the maximum scrolling position

#include <GuiScrollBars.au3>
_GUIScrollBars_SetScrollInfoMax ( $hWnd, $iBar, $iMax )

Parameters

$hWnd | Handle to the window
$iBar | Specifies the type of scroll bar. This parameter can be one of the following values: $SB_CTL - Sets the parameters of a scroll bar control. The $hWnd parameter must be the handle to the scroll bar control. $SB_HORZ - Sets the parameters of the window's standard horizontal scroll bar. $SB_VERT - Sets the parameters of the window's standard vertical scroll bar.
$iMax | Maximum scrolling position

Return Value

Success: | True.
Failure: | False.

Related

_GUIScrollBars_SetScrollInfo, _GUIScrollBars_SetScrollRange

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 380, 380, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    _GUIScrollBars_SetScrollInfoMin($hGUI, $SB_HORZ, 10)
    _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_HORZ, 80)

    MemoWrite("Horizontal" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_HORZ))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_HORZ))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_HORZ))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_HORZ))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_HORZ))

    MemoWrite(@CRLF & "Vertical" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_VERT))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_VERT))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_VERT))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_VERT))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_VERT))

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_SetScrollInfoMin

Function Reference

_GUIScrollBars_SetScrollInfoMin

Sets the minimum scrolling position

#include <GuiScrollBars.au3>
_GUIScrollBars_SetScrollInfoMin ( $hWnd, $iBar, $iMin )

Parameters

$hWnd | Handle to the window
$iBar | Specifies the type of scroll bar. This parameter can be one of the following values: $SB_CTL - Sets the parameters of a scroll bar control. The $hWnd parameter must be the handle to the scroll bar control. $SB_HORZ - Sets the parameters of the window's standard horizontal scroll bar. $SB_VERT - Sets the parameters of the window's standard vertical scroll bar.
$iMin | Minimum scrolling position

Return Value

Success: | True.
Failure: | False.

Related

_GUIScrollBars_SetScrollInfo, _GUIScrollBars_SetScrollRange

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 380, 380, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    _GUIScrollBars_SetScrollInfoMin($hGUI, $SB_HORZ, 10)
    _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_HORZ, 80)

    MemoWrite("Horizontal" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_HORZ))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_HORZ))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_HORZ))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_HORZ))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_HORZ))

    MemoWrite(@CRLF & "Vertical" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_VERT))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_VERT))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_VERT))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_VERT))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_VERT))

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_SetScrollInfoPage

Function Reference

_GUIScrollBars_SetScrollInfoPage

Sets the page size

#include <GuiScrollBars.au3>
_GUIScrollBars_SetScrollInfoPage ( $hWnd, $iBar, $iPage )

Parameters

$hWnd | Handle to the window
$iBar | Specifies the type of scroll bar. This parameter can be one of the following values: $SB_CTL - Sets the parameters of a scroll bar control. The $hWnd parameter must be the handle to the scroll bar control. $SB_HORZ - Sets the parameters of the window's standard horizontal scroll bar. $SB_VERT - Sets the parameters of the window's standard vertical scroll bar.
$iPage | Page size

Return Value

Success: | the current position of the scroll box.
Failure: | sets the @error flag to non-zero.

Related

_GUIScrollBars_SetScrollInfo

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 380, 380, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    _GUIScrollBars_SetScrollInfoMin($hGUI, $SB_HORZ, 10)
    _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_HORZ, 80)
    _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_HORZ, 60)

    MemoWrite("Horizontal" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_HORZ))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_HORZ))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_HORZ))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_HORZ))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_HORZ))

    MemoWrite(@CRLF & "Vertical" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_VERT))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_VERT))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_VERT))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_VERT))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_VERT))

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_SetScrollInfoPos

Function Reference

_GUIScrollBars_SetScrollInfoPos

Sets the position of the scroll box (thumb) in the specified scroll bar

#include <GuiScrollBars.au3>
_GUIScrollBars_SetScrollInfoPos ( $hWnd, $iBar, $iPos )

Parameters

$hWnd | Handle to the window
$iBar | Specifies the type of scroll bar. This parameter can be one of the following values: $SB_CTL - Sets the parameters of a scroll bar control. The $hWnd parameter must be the handle to the scroll bar control. $SB_HORZ - Sets the parameters of the window's standard horizontal scroll bar. $SB_VERT - Sets the parameters of the window's standard vertical scroll bar.
$iPos | Position of the scroll box

Return Value

None.

Related

_GUIScrollBars_GetScrollPos, _GUIScrollBars_SetScrollInfo

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 380, 380, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, 30)

    MemoWrite("Horizontal" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_HORZ))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_HORZ))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_HORZ))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_HORZ))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_HORZ))

    Sleep(3000)

    MemoWrite(@CRLF & "Vertical" & @CRLF & "--------------------------------------")
    MemoWrite("nPage....: " & _GUIScrollBars_GetScrollInfoPage($hGUI, $SB_VERT))
    MemoWrite("nPos.....: " & _GUIScrollBars_GetScrollInfoPos($hGUI, $SB_VERT))
    MemoWrite("nMin.....: " & _GUIScrollBars_GetScrollInfoMin($hGUI, $SB_VERT))
    MemoWrite("nMax.....: " & _GUIScrollBars_GetScrollInfoMax($hGUI, $SB_VERT))
    MemoWrite("nTrackPos: " & _GUIScrollBars_GetScrollInfoTrackPos($hGUI, $SB_VERT))

    _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_HORZ, 0)

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_SetScrollRange

Function Reference

_GUIScrollBars_SetScrollRange

Sets the minimum and maximum scroll box positions for the specified scroll bar

#include <GuiScrollBars.au3>
_GUIScrollBars_SetScrollRange ( $hWnd, $iBar, $iMinPos, $iMaxPos )

Parameters

$hWnd | Handle to the window
$iBar | Specifies the type of scroll bar. This parameter can be one of the following values: $SB_CTL - Sets the range of a scroll bar control. The $hWnd parameter must be the handle to the scroll bar control. $SB_HORZ - Sets the range of a window's standard horizontal scroll bar. $SB_VERT - Sets the range of a window's standard vertical scroll bar.
$iMinPos | Specifies the minimum scrolling position
$iMaxPos | Specifies the maximum scrolling position

Return Value

Success: | True.
Failure: | False.

Related

_GUIScrollBars_GetScrollRange, _GUIScrollBars_SetScrollInfoMax, _GUIScrollBars_SetScrollInfoMin

See Also

Search SetScrollRange in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiScrollBars.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $hGUIMsg, $hGUI, $aRangeMinMax

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 380, 380, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetResizing($g_idMemo, $GUI_DOCKALL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    $aRangeMinMax = _GUIScrollBars_GetScrollRange($hGUI, $SB_VERT)
    MemoWrite("Vertical Min/Max: " & $aRangeMinMax[0] & "/" & $aRangeMinMax[1])
    $aRangeMinMax = _GUIScrollBars_GetScrollRange($hGUI, $SB_HORZ)
    MemoWrite("Horizontal Min/Max: " & $aRangeMinMax[0] & "/" & $aRangeMinMax[1])
    Sleep(1000)
    _GUIScrollBars_SetScrollRange($hGUI, $SB_VERT, 3, 30)
    $aRangeMinMax = _GUIScrollBars_GetScrollRange($hGUI, $SB_VERT)
    MemoWrite("New Vertical Min/Max: " & $aRangeMinMax[0] & "/" & $aRangeMinMax[1])
    Sleep(1000)
    _GUIScrollBars_SetScrollRange($hGUI, $SB_HORZ, 10, 98)
    $aRangeMinMax = _GUIScrollBars_GetScrollRange($hGUI, $SB_HORZ)
    MemoWrite("New Horizontal Min/Max: " & $aRangeMinMax[0] & "/" & $aRangeMinMax[1])

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUIScrollBars_ShowScrollBar

Function Reference

_GUIScrollBars_ShowScrollBar

Shows or hides the specified scroll bar

#include <GuiScrollBars.au3>
_GUIScrollBars_ShowScrollBar ( $hWnd, $iBar [, $bShow = True] )

Parameters

$hWnd | Handle to the window
$iBar | Specifies the type of scroll bar. This parameter can be one of the following values: $SB_BOTH - Shows or hides a window's standard horizontal and vertical scroll bars. $SB_CTL - Shows or hides a scroll bar control. The $hWnd parameter must be the handle to the scroll bar control. $SB_HORZ - Shows or hides a window's standard horizontal scroll bars. $SB_VERT - Shows or hides a window's standard vertical scroll bar.
$bShow | [optional] Specifies whether the scroll bar is shown or hidden

Return Value

Success: | True.
Failure: | False.

Related

_GUIScrollBars_EnableScrollBar

See Also

Search ShowScrollBar in MSDN Library.

Example

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

Example()

Func Example()
    Local $hGUIMsg, $hGUI

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    GUISetBkColor(0x88AABB)

    GUISetState(@SW_SHOW)

    _GUIScrollBars_Init($hGUI)

    _GUIScrollBars_ShowScrollBar($hGUI, $SB_HORZ, False)
    Sleep(1000)
    _GUIScrollBars_ShowScrollBar($hGUI, $SB_HORZ)

    Sleep(1000)
    _GUIScrollBars_ShowScrollBar($hGUI, $SB_VERT, False)
    Sleep(1000)
    _GUIScrollBars_ShowScrollBar($hGUI, $SB_VERT)

    While 1
        $hGUIMsg = GUIGetMsg()

        Switch $hGUIMsg
            Case $GUI_EVENT_CLOSE;, $nExititem
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>Example


User Defined Functions

GuiSlider user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiSlider.au3>.

User Defined Function | Description
_GUICtrlSlider_ClearSel | Clears the current selection range
_GUICtrlSlider_ClearTics | Removes the current tick marks from a slider
_GUICtrlSlider_Create | Create a Slider control
_GUICtrlSlider_Destroy | Delete the control
_GUICtrlSlider_GetBuddy | Retrieves the handle to a slider control buddy window at a given location
_GUICtrlSlider_GetChannelRect | Retrieves the size and position of the bounding rectangle for a sliders's channel
_GUICtrlSlider_GetChannelRectEx | Retrieves the size and position of the bounding rectangle for a sliders's channel
_GUICtrlSlider_GetLineSize | Retrieves the number of logical positions the slider moves
_GUICtrlSlider_GetLogicalTics | Retrieves an array that contains the logical positions of the tick marks for a slider
_GUICtrlSlider_GetNumTics | Retrieves the number of tick marks from a slider
_GUICtrlSlider_GetPageSize | Retrieves the number of logical positions the slider moves
_GUICtrlSlider_GetPos | Retrieves the logical position the slider
_GUICtrlSlider_GetRange | Retrieves the maximum and minimum position for the slider
_GUICtrlSlider_GetRangeMax | Retrieves the maximum position for the slider
_GUICtrlSlider_GetRangeMin | Retrieves the minimum position for the slider
_GUICtrlSlider_GetSel | Retrieves the ending and starting position of the current selection range
_GUICtrlSlider_GetSelEnd | Retrieves the ending position of the current selection range
_GUICtrlSlider_GetSelStart | Retrieves the starting position of the current selection range
_GUICtrlSlider_GetThumbLength | Retrieves the length of the slider
_GUICtrlSlider_GetThumbRect | Retrieves the size and position of the bounding rectangle for the slider
_GUICtrlSlider_GetThumbRectEx | Retrieves the size and position of the bounding rectangle for the slider
_GUICtrlSlider_GetTic | Retrieves the logical position of a tick mark
_GUICtrlSlider_GetTicPos | Retrieves the current physical position of a tick mark
_GUICtrlSlider_GetToolTips | Retrieves the handle to the ToolTip control assigned to the slider, if any
_GUICtrlSlider_GetUnicodeFormat | Retrieves the Unicode character format flag for the control
_GUICtrlSlider_SetBuddy | Assigns a window as the buddy window for a slider control
_GUICtrlSlider_SetLineSize | Sets the number of logical positions the slider moves
_GUICtrlSlider_SetPageSize | Sets the number of logical positions the slider moves
_GUICtrlSlider_SetPos | Sets the current logical position of the slider
_GUICtrlSlider_SetRange | Sets the range of minimum and maximum logical positions for the slider
_GUICtrlSlider_SetRangeMax | Sets the maximum logical position for the slider
_GUICtrlSlider_SetRangeMin | Sets the minimum logical position for the slider
_GUICtrlSlider_SetSel | Sets the starting and ending positions for the available selection range
_GUICtrlSlider_SetSelEnd | Sets the ending logical position of the current selection range
_GUICtrlSlider_SetSelStart | Sets the starting logical position of the current selection range
_GUICtrlSlider_SetThumbLength | Sets the length of the slider
_GUICtrlSlider_SetTic | Sets a tick mark in a slider at the specified logical position
_GUICtrlSlider_SetTicFreq | Sets the interval frequency for tick marks in a slider
_GUICtrlSlider_SetTipSide | Positions a ToolTip control
_GUICtrlSlider_SetToolTips | Assigns a ToolTip control to a slider control
_GUICtrlSlider_SetUnicodeFormat | Sets the Unicode character format flag for the control


Function _GUICtrlSlider_ClearSel

Function Reference

_GUICtrlSlider_ClearSel

Clears the current selection range

#include <GuiSlider.au3>
_GUICtrlSlider_ClearSel ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

None.

Related

_GUICtrlSlider_SetSel, _GUICtrlSlider_SetSelEnd, _GUICtrlSlider_SetSelStart

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("(Internal) Slider Clear Sel", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Set Sel
    _GUICtrlSlider_SetSel($idSlider, 10, 50)

    MsgBox($MB_SYSTEMMODAL, "Information", "Clear Sel")
    ; Clear Sel
    _GUICtrlSlider_ClearSel($idSlider)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_ClearTics

Function Reference

_GUICtrlSlider_ClearTics

Removes the current tick marks from a slider

#include <GuiSlider.au3>
_GUICtrlSlider_ClearTics ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

None.

Remarks

This does not remove the first and last tick marks, which are created automatically.

Related

_GUICtrlSlider_SetTic, _GUICtrlSlider_SetTicFreq

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("(Internal) Slider Clear Tics", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Clear Tics")
    ; Clear Tics
    _GUICtrlSlider_ClearTics($idSlider)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_Create

Function Reference

_GUICtrlSlider_Create

Create a Slider control

#include <GuiSlider.au3>
_GUICtrlSlider_Create ( $hWnd, $iX, $iY [, $iWidth = 100 [, $iHeight = 20 [, $iStyle = $TBS_AUTOTICKS [, $iExStyle = 0x00000000]]]] )

Parameters

$hWnd | Handle to parent or owner window
$iX | Horizontal position of the control
$iY | Vertical position of the control
$iWidth | [optional] Control width
$iHeight | [optional] Control height
$iStyle [optional] Control style:
$TBS_AUTOTICKS - Adds tick marks when you set the range on the slider by using the TBM_SETRANGE message
$TBS_BOTH - Places ticks on both sides of the slider
$TBS_BOTTOM - Places ticks on the bottom of a horizontal slider
$TBS_DOWNISLEFT - Down equal left and up equal right
$TBS_ENABLESELRANGE - The tick marks at the starting and ending positions of a selection range are displayed as triangles
(instead of vertical dashes), and the selection range is highlighted.
$TBS_FIXEDLENGTH - allows the size of the slider to be changed with the $TBM_SETTHUMBLENGTH message
$TBS_HORZ - Specifies a horizontal slider. This is the default
$TBS_LEFT - Places ticks on the left side of a vertical slider
$TBS_NOTHUMB - Specifies that the slider has no slider
$TBS_NOTICKS - Specifies that no ticks are placed on the slider
$TBS_REVERSED - Smaller number indicates "higher" and a larger number indicates "lower"
$TBS_RIGHT - Places ticks on the right side of a vertical slider
$TBS_TOP - Places ticks on the top of a horizontal slider
$TBS_TOOLTIPS - Creates a default ToolTip control that displays the slider's current position
$TBS_VERT - Creates a vertical slider

Default: $TBS_AUTOTICKS
Forced : $WS_CHILD, $WS_VISIBLE
$iExStyle [optional] Control extended style. These correspond to the standard $WS_EX_* constants. See Extended Style Table.
Default: $WS_EX_STATICEDGE

Return Value

Success: | the handle to the slider control.
Failure: | 0

Remarks

This function is for Advanced users and for learning how the control works.

Related

_GUICtrlSlider_Destroy

Example

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

Global $g_hSlider

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("(UDF Created) Slider Create", 400, 296)
    $g_hSlider = _GUICtrlSlider_Create($hGUI, 2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS))
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndSlider
    $hWndSlider = $g_hSlider
    If Not IsHWnd($g_hSlider) Then $hWndSlider = GUICtrlGetHandle($g_hSlider)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndSlider
            Switch $iCode
                Case $NM_RELEASEDCAPTURE ; The control is releasing mouse capture
                    _DebugPrint("$NM_RELEASEDCAPTURE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlSlider_Destroy

Function Reference

_GUICtrlSlider_Destroy

Delete the control

#include <GuiSlider.au3>
_GUICtrlSlider_Destroy ( ByRef $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True, $hWnd is set to 0.
Failure: | False.

Remarks

Restricted to only be used on Slider controls created with _GUICtrlSlider_Create().

Related

_GUICtrlSlider_Create

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hSlider

    ; Create GUI
    $hGUI = GUICreate("(UDF Created) Slider Destroy", 400, 296)
    $hSlider = _GUICtrlSlider_Create($hGUI, 2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS))
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Destroy Slider")
    _GUICtrlSlider_Destroy($hSlider)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetBuddy

Function Reference

_GUICtrlSlider_GetBuddy

Retrieves the handle to a slider control buddy window at a given location

#include <GuiSlider.au3>
_GUICtrlSlider_GetBuddy ( $hWnd, $bLocation )

Parameters

$hWnd | Control ID/Handle to the control
$bLocation | Which buddy window handle will be retrieved. This value can be one of the following: True - Retrieves the handle to the buddy to the left of the slider. If the slider control uses the $TBS_VERT style, the message will retrieve the buddy above the slider. False - Retrieves the handle to the buddy to the right of the slider. If the slider control uses the $TBS_VERT style, the message will retrieve the buddy below the slider.

Return Value

Success: | the handle to the buddy window at the location specified by $bLocation.
Failure: | 0.

Related

_GUICtrlSlider_SetBuddy

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idInput, $idInput2, $idSlider

    ; Create GUI
    GUICreate("Slider Get Buddy", 400, 296)
    $idSlider = GUICtrlCreateSlider(95, 2, 205, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    $idInput = GUICtrlCreateInput("0", 2, 25, 90, 20)
    $idInput2 = GUICtrlCreateInput("0", 2, 25, 90, 20)
    GUISetState(@SW_SHOW)

    ; Set buddy to left
    _GUICtrlSlider_SetBuddy($idSlider, True, $idInput)
    ; Set buddy to right
    _GUICtrlSlider_SetBuddy($idSlider, False, $idInput2)

    ; Get Buddy from the left
    MsgBox($MB_SYSTEMMODAL, "Information", "Buddy Handle: " & _GUICtrlSlider_GetBuddy($idSlider, True))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetChannelRect

Function Reference

_GUICtrlSlider_GetChannelRect

Retrieves the size and position of the bounding rectangle for a sliders's channel

#include <GuiSlider.au3>
_GUICtrlSlider_GetChannelRect ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an array in the following format:
[0] - X coordinate of the upper left corner of the rectangle
[1] - Y coordinate of the upper left corner of the rectangle
[2] - X coordinate of the lower right corner of the rectangle
[3] - Y coordinate of the lower right corner of the rectangle

Related

_GUICtrlSlider_GetChannelRectEx

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aRect, $idSlider

    ; Create GUI
    GUICreate("Slider Get Channel Rect", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Channel Rect
    $aRect = _GUICtrlSlider_GetChannelRect($idSlider)

    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("[%d][%d][%d][%d]", $aRect[0], $aRect[1], $aRect[2], $aRect[3]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetChannelRectEx

Function Reference

_GUICtrlSlider_GetChannelRectEx

Retrieves the size and position of the bounding rectangle for a sliders's channel

#include <GuiSlider.au3>
_GUICtrlSlider_GetChannelRectEx ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Return a $tagRECT structure that receives the channel coordinates.

Related

$tagRECT, _GUICtrlSlider_GetChannelRect

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $tRECT, $idSlider

    ; Create GUI
    GUICreate("Slider Get Channel RectEx", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Channel Rect
    $tRECT = _GUICtrlSlider_GetChannelRectEx($idSlider)

    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("[%d][%d][%d][%d]", _
            DllStructGetData($tRECT, "Left"), DllStructGetData($tRECT, "Top"), _
            DllStructGetData($tRECT, "Right"), DllStructGetData($tRECT, "Bottom")))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetLineSize

Function Reference

_GUICtrlSlider_GetLineSize

Retrieves the number of logical positions the slider moves

#include <GuiSlider.au3>
_GUICtrlSlider_GetLineSize ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the line size for the slider.

Remarks

The default setting for the line size is 1

Related

_GUICtrlSlider_SetLineSize

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Get Line Size", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Line Size
    MsgBox($MB_SYSTEMMODAL, "Information", "Line Size: " & _GUICtrlSlider_GetLineSize($idSlider))

    ; Set Line Size
    _GUICtrlSlider_SetLineSize($idSlider, 4)

    ; Get Line Size
    MsgBox($MB_SYSTEMMODAL, "Information", "Line Size: " & _GUICtrlSlider_GetLineSize($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetLogicalTics

Function Reference

_GUICtrlSlider_GetLogicalTics

Retrieves an array that contains the logical positions of the tick marks for a slider

#include <GuiSlider.au3>
_GUICtrlSlider_GetLogicalTics ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | an array of logical positions.
Failure: | sets the @error flag to non-zero.

Remarks

The number of elements in the array is two less than the tick count returned by the _GUICtrlSlider_GetNumTics() function.
Note that the values in the array may include duplicate positions and may not be in sequential order.
The data in the returned array is valid until you change the slider's tick marks.

The elements of the array specify the logical positions of the sliders's tick marks, not including the first and last tick marks created by the slider.
The logical positions can be any of the integer values in the sliders's range of minimum to maximum slider positions.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $idSlider, $aTics

    ; Create GUI
    GUICreate("Slider Get Logical Tic Positions", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 300, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS))
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    $aTics = _GUICtrlSlider_GetLogicalTics($idSlider)
    MemoWrite("Number Tics Excluding 1st and last .....: " & UBound($aTics))
    For $x = 0 To UBound($aTics) - 1
        MemoWrite(StringFormat("(%02d) Logical Tick Position .............: %d", $x, $aTics[$x]))
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlSlider_GetNumTics

Function Reference

_GUICtrlSlider_GetNumTics

Retrieves the number of tick marks from a slider

#include <GuiSlider.au3>
_GUICtrlSlider_GetNumTics ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an INT value as follow:
2 if no tick flag is set, for the beginning and ending ticks.
0 if $TBS_NOTICKS is set.
Otherwise, it takes the difference between the range minimum and maximum, divides by the tick frequency and adds 2.

Related

_GUICtrlSlider_SetTicFreq

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Get Num Tics", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Num Tics
    MsgBox($MB_SYSTEMMODAL, "Information", "Num Tics: " & _GUICtrlSlider_GetNumTics($idSlider))

    ; Set Tic Freq
    _GUICtrlSlider_SetTicFreq($idSlider, 1)

    ; Get Num Tics
    MsgBox($MB_SYSTEMMODAL, "Information", "Num Tics: " & _GUICtrlSlider_GetNumTics($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetPageSize

Function Reference

_GUICtrlSlider_GetPageSize

Retrieves the number of logical positions the slider moves

#include <GuiSlider.au3>
_GUICtrlSlider_GetPageSize ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the page size for the slider.

Related

_GUICtrlSlider_SetPageSize

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Get Page Size", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Page Size
    MsgBox($MB_SYSTEMMODAL, "Information", "Page Size: " & _GUICtrlSlider_GetPageSize($idSlider))

    ; Set Page Size
    _GUICtrlSlider_SetPageSize($idSlider, 4)

    ; Get Page Size
    MsgBox($MB_SYSTEMMODAL, "Information", "Page Size: " & _GUICtrlSlider_GetPageSize($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetPos

Function Reference

_GUICtrlSlider_GetPos

Retrieves the logical position the slider

#include <GuiSlider.au3>
_GUICtrlSlider_GetPos ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the current logical position of the slider.

Related

_GUICtrlSlider_SetPos

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Get Pos", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Set Pos
    _GUICtrlSlider_SetPos($idSlider, Random(0, 100, 1))

    ; Get Pos
    MsgBox($MB_SYSTEMMODAL, "Information", "Pos: " & _GUICtrlSlider_GetPos($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetRange

Function Reference

_GUICtrlSlider_GetRange

Retrieves the maximum and minimum position for the slider

#include <GuiSlider.au3>
_GUICtrlSlider_GetRange ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an array in the following format:
[0] - Minimum position in the slider's range of minimum to maximum slider positions
[1] - Maximum position in the slider's range of minimum to maximum slider positions

Related

_GUICtrlSlider_GetRangeMax, _GUICtrlSlider_GetRangeMin, _GUICtrlSlider_SetRange

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aRange, $idSlider

    ; Create GUI
    GUICreate("Slider Get Range", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Range
    $aRange = _GUICtrlSlider_GetRange($idSlider)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Range: %d - %d", $aRange[0], $aRange[1]))

    ; Set Range
    _GUICtrlSlider_SetRange($idSlider, 20, 50)

    ; Get Range
    $aRange = _GUICtrlSlider_GetRange($idSlider)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Range: %d - %d", $aRange[0], $aRange[1]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetRangeMax

Function Reference

_GUICtrlSlider_GetRangeMax

Retrieves the maximum position for the slider

#include <GuiSlider.au3>
_GUICtrlSlider_GetRangeMax ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the maximum position in the slider's range of minimum to maximum slider positions.

Related

_GUICtrlSlider_GetRange, _GUICtrlSlider_SetRangeMax

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Get Range Max", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Range Max
    MsgBox($MB_SYSTEMMODAL, "Information", "Range Max: " & _GUICtrlSlider_GetRangeMax($idSlider))

    ; Set Range Max
    _GUICtrlSlider_SetRangeMax($idSlider, 50)

    ; Get Range Max
    MsgBox($MB_SYSTEMMODAL, "Information", "Range Max: " & _GUICtrlSlider_GetRangeMax($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetRangeMin

Function Reference

_GUICtrlSlider_GetRangeMin

Retrieves the minimum position for the slider

#include <GuiSlider.au3>
_GUICtrlSlider_GetRangeMin ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the minimum position in the slider's range of minimum to maximum slider positions.

Related

_GUICtrlSlider_GetRange, _GUICtrlSlider_SetRangeMin

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Get Range Min", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Range Min
    MsgBox($MB_SYSTEMMODAL, "Information", "Range Min: " & _GUICtrlSlider_GetRangeMin($idSlider))

    ; Set Range Min
    _GUICtrlSlider_SetRangeMin($idSlider, 20)

    ; Get Range Min
    MsgBox($MB_SYSTEMMODAL, "Information", "Range Min: " & _GUICtrlSlider_GetRangeMin($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetSel

Function Reference

_GUICtrlSlider_GetSel

Retrieves the ending and starting position of the current selection range

#include <GuiSlider.au3>
_GUICtrlSlider_GetSel ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an array in the following format:
[0] - The starting position of the current selection range
[1] - The ending position of the current selection range

Related

_GUICtrlSlider_SetSel, _GUICtrlSlider_SetSelEnd, _GUICtrlSlider_SetSelStart

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aSel, $idSlider

    ; Create GUI
    GUICreate("Slider Get Sel", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Set Sel
    _GUICtrlSlider_SetSel($idSlider, 10, 50)

    ; Get Sel
    $aSel = _GUICtrlSlider_GetSel($idSlider)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Sel: %d - %d", $aSel[0], $aSel[1]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetSelEnd

Function Reference

_GUICtrlSlider_GetSelEnd

Retrieves the ending position of the current selection range

#include <GuiSlider.au3>
_GUICtrlSlider_GetSelEnd ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the ending position of the current selection range.

Related

_GUICtrlSlider_SetSelEnd

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Get Sel End", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Set Sel End
    _GUICtrlSlider_SetSelEnd($idSlider, 50)

    ; Get Sel End
    MsgBox($MB_SYSTEMMODAL, "Information", "Sel End: " & _GUICtrlSlider_GetSelEnd($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetSelStart

Function Reference

_GUICtrlSlider_GetSelStart

Retrieves the starting position of the current selection range

#include <GuiSlider.au3>
_GUICtrlSlider_GetSelStart ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the starting position of the current selection range.

Related

_GUICtrlSlider_SetSelStart

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Get Sel Start", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Set Sel Start
    _GUICtrlSlider_SetSelStart($idSlider, 10)

    ; Get Sel Start
    MsgBox($MB_SYSTEMMODAL, "Information", "Sel Start: " & _GUICtrlSlider_GetSelStart($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetThumbLength

Function Reference

_GUICtrlSlider_GetThumbLength

Retrieves the length of the slider

#include <GuiSlider.au3>
_GUICtrlSlider_GetThumbLength ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the length, in pixels, of the slider.

Related

_GUICtrlSlider_SetThumbLength

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Get Thumb Length", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 25, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_FIXEDLENGTH))
    GUISetState(@SW_SHOW)

    ; Get Thumb Length
    MsgBox($MB_SYSTEMMODAL, "Information", "Thumb Length: " & _GUICtrlSlider_GetThumbLength($idSlider))

    ; Set Thumb Length
    _GUICtrlSlider_SetThumbLength($idSlider, 10)

    ; Get Thumb Length
    MsgBox($MB_SYSTEMMODAL, "Information", "Thumb Length: " & _GUICtrlSlider_GetThumbLength($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetThumbRect

Function Reference

_GUICtrlSlider_GetThumbRect

Retrieves the size and position of the bounding rectangle for the slider

#include <GuiSlider.au3>
_GUICtrlSlider_GetThumbRect ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns an array in the following format:
[0] - X coordinate of the upper left corner of the rectangle
[1] - Y coordinate of the upper left corner of the rectangle
[2] - X coordinate of the lower right corner of the rectangle
[3] - Y coordinate of the lower right corner of the rectangle

Related

_GUICtrlSlider_GetThumbRectEx

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aRect, $idSlider

    ; Create GUI
    GUICreate("Slider Get Thumb Rect", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Thumb Rect
    $aRect = _GUICtrlSlider_GetThumbRect($idSlider)

    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("[%d][%d][%d][%d]", $aRect[0], $aRect[1], $aRect[2], $aRect[3]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetThumbRectEx

Function Reference

_GUICtrlSlider_GetThumbRectEx

Retrieves the size and position of the bounding rectangle for the slider

#include <GuiSlider.au3>
_GUICtrlSlider_GetThumbRectEx ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns a $tagRECT structure that receives the bounding rectangle of the slider in client coordinates.

Related

$tagRECT, _GUICtrlSlider_GetThumbRect

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $tRECT, $idSlider

    ; Create GUI
    GUICreate("Slider Get Thumb RectEx", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Thumb Rect
    $tRECT = _GUICtrlSlider_GetThumbRectEx($idSlider)

    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("[%d][%d][%d][%d]", _
            DllStructGetData($tRECT, "Left"), DllStructGetData($tRECT, "Top"), _
            DllStructGetData($tRECT, "Right"), DllStructGetData($tRECT, "Bottom")))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetTic

Function Reference

_GUICtrlSlider_GetTic

Retrieves the logical position of a tick mark

#include <GuiSlider.au3>
_GUICtrlSlider_GetTic ( $hWnd, $iTic )

Parameters

$hWnd | Control ID/Handle to the control
$iTic | 0-based index identifying a tick mark. Valid indexes are in the range from zero to two less than the tick count returned by the _GUICtrlSlider_GetNumTics() depends on the _GUICtrlSlider_SetTicFreq().

Return Value

Success: | the logical position of the specified tick mark.
Failure: | -1.

Related

_GUICtrlSlider_SetTic

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iTic = Random(0, 100, 1), $idSlider

    ; Create GUI
    GUICreate("Slider Get Tic", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Set Tic
    _GUICtrlSlider_SetTic($idSlider, $iTic)

    ; Get Tic
    MsgBox($MB_SYSTEMMODAL, "Information", "Tic: " & _GUICtrlSlider_GetTic($idSlider, $iTic))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetTicPos

Function Reference

_GUICtrlSlider_GetTicPos

Retrieves the current physical position of a tick mark

#include <GuiSlider.au3>
_GUICtrlSlider_GetTicPos ( $hWnd, $iTic )

Parameters

$hWnd | Control ID/Handle to the control
$iTic | 0-based index identifying a tick mark. The positions of the first and last tick marks are not directly available via this message.

Return Value

Success: | The following values for type of slider: horizontal - The x-coordinate of the tick mark vertical - The y-coordinate of the tick mark
Failure: | -1.

Remarks

Because the first and last tick marks are not available through this function, valid indexes are offset from their tick position on the slider.
If the difference between _GUICtrlSlider_GetRangeMin() and _GUICtrlSlider_GetRangeMax() is less than two, then there is no valid index and this message will fail.

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iTic = Random(1, 99, 1), $idSlider

    ; Create GUI
    GUICreate("Slider Get Tic Pos", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Tic Pos
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Tic %d: X Pos: %d", $iTic, _GUICtrlSlider_GetTicPos($idSlider, $iTic)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetToolTips

Function Reference

_GUICtrlSlider_GetToolTips

Retrieves the handle to the ToolTip control assigned to the slider, if any

#include <GuiSlider.au3>
_GUICtrlSlider_GetToolTips ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the handle to the ToolTip control assigned to the slider.
Failure: | 0.

Remarks

If the slider control does not use the $TBS_TOOLTIPS style, the return value is 0.

Related

_GUICtrlSlider_SetToolTips

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hWndTT, $idSlider

    ; Create GUI
    GUICreate("Slider Get Tool Tips", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Tool Tips
    $hWndTT = _GUICtrlSlider_GetToolTips($idSlider)
    MsgBox($MB_SYSTEMMODAL, "Information", "Tool Tip Handle: " & $hWndTT)

    ; Set Tool Tips
    _GUICtrlSlider_SetToolTips($idSlider, $hWndTT)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_GetUnicodeFormat

Function Reference

_GUICtrlSlider_GetUnicodeFormat

Retrieves the Unicode character format flag for the control

#include <GuiSlider.au3>
_GUICtrlSlider_GetUnicodeFormat ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

True: | the control is using Unicode characters.
False: | the control is using ANSI characters.

Related

_GUICtrlSlider_SetUnicodeFormat

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Get Unicode Format", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Unicode Format
    MsgBox($MB_SYSTEMMODAL, "Information", "Unicode Format: " & _GUICtrlSlider_GetUnicodeFormat($idSlider))

    ; Set Unicode Format
    MsgBox($MB_SYSTEMMODAL, "Information", "Previous Unicode Format: " & _GUICtrlSlider_SetUnicodeFormat($idSlider, False))

    ; Get Unicode Format
    MsgBox($MB_SYSTEMMODAL, "Information", "Unicode Format: " & _GUICtrlSlider_GetUnicodeFormat($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_SetBuddy

Function Reference

_GUICtrlSlider_SetBuddy

Assigns a window as the buddy window for a slider control

#include <GuiSlider.au3>
_GUICtrlSlider_SetBuddy ( $hWnd, $bLocation, $hBuddy )

Parameters

$hWnd | Control ID/Handle to the control
$bLocation | Following values: True - The buddy will appear to the left of the slider if the control uses the $TBS_HORZ style The buddy will appear above the slider if the control uses the $TBS_VERT style False - The buddy will appear to the right of the slider if the control uses the $TBS_HORZ style The buddy will appear below the slider if the control uses the $TBS_VERT style
$hBuddy | Handle to buddy control

Return Value

Returns the handle to the window that was previously assigned to the control at that location.

Related

_GUICtrlSlider_GetBuddy

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idInput, $idInput2, $idSlider

    ; Create GUI
    GUICreate("Slider Set Buddy", 400, 296)
    $idSlider = GUICtrlCreateSlider(95, 2, 205, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    $idInput = GUICtrlCreateInput("0", 2, 25, 90, 20)
    $idInput2 = GUICtrlCreateInput("0", 2, 25, 90, 20)
    GUISetState(@SW_SHOW)

    ; Set buddy to left
    _GUICtrlSlider_SetBuddy($idSlider, True, $idInput)
    ; Set buddy to right
    _GUICtrlSlider_SetBuddy($idSlider, False, $idInput2)

    ; Get Buddy from the left
    MsgBox($MB_SYSTEMMODAL, "Information", "Buddy Handle: " & _GUICtrlSlider_GetBuddy($idSlider, True))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_SetLineSize

Function Reference

_GUICtrlSlider_SetLineSize

Sets the number of logical positions the slider moves

#include <GuiSlider.au3>
_GUICtrlSlider_SetLineSize ( $hWnd, $iLineSize )

Parameters

$hWnd | Control ID/Handle to the control
$iLineSize | New line size

Return Value

Returns the previous line size.

Remarks

The default setting for the line size is 1

Related

_GUICtrlSlider_GetLineSize

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Set Line Size", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Line Size
    MsgBox($MB_SYSTEMMODAL, "Information", "Line Size: " & _GUICtrlSlider_GetLineSize($idSlider))

    ; Set Line Size
    _GUICtrlSlider_SetLineSize($idSlider, 4)

    ; Get Line Size
    MsgBox($MB_SYSTEMMODAL, "Information", "Line Size: " & _GUICtrlSlider_GetLineSize($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_SetPageSize

Function Reference

_GUICtrlSlider_SetPageSize

Sets the number of logical positions the slider moves

#include <GuiSlider.au3>
_GUICtrlSlider_SetPageSize ( $hWnd, $iPageSize )

Parameters

$hWnd | Control ID/Handle to the control
$iPageSize | New page size

Return Value

Returns the previous page size.

Related

_GUICtrlSlider_GetPageSize

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Set Page Size", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Page Size
    MsgBox($MB_SYSTEMMODAL, "Information", "Page Size: " & _GUICtrlSlider_GetPageSize($idSlider))

    ; Set Page Size
    _GUICtrlSlider_SetPageSize($idSlider, 4)

    ; Get Page Size
    MsgBox($MB_SYSTEMMODAL, "Information", "Page Size: " & _GUICtrlSlider_GetPageSize($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_SetPos

Function Reference

_GUICtrlSlider_SetPos

Sets the current logical position of the slider

#include <GuiSlider.au3>
_GUICtrlSlider_SetPos ( $hWnd, $iPosition )

Parameters

$hWnd | Control ID/Handle to the control
$iPosition | New logical position of the slider

Return Value

None.

Related

_GUICtrlSlider_GetPos

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Set Pos", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Set Pos
    _GUICtrlSlider_SetPos($idSlider, Random(0, 100, 1))

    ; Get Pos
    MsgBox($MB_SYSTEMMODAL, "Information", "Pos: " & _GUICtrlSlider_GetPos($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_SetRange

Function Reference

_GUICtrlSlider_SetRange

Sets the range of minimum and maximum logical positions for the slider

#include <GuiSlider.au3>
_GUICtrlSlider_SetRange ( $hWnd, $iMinimum, $iMaximum )

Parameters

$hWnd | Control ID/Handle to the control
$iMinimum | Minimum position for the slider
$iMaximum | Maximum position for the slider

Return Value

None.

Remarks

If the current slider position is outside the new range, the _GUICtrlSlider_SetRange() function sets the slider position to the new maximum or minimum value.

Related

_GUICtrlSlider_GetRange, _GUICtrlSlider_SetRangeMax, _GUICtrlSlider_SetRangeMin

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aRange, $idSlider

    ; Create GUI
    GUICreate("Slider Set Range", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Range
    $aRange = _GUICtrlSlider_GetRange($idSlider)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Range: %d - %d", $aRange[0], $aRange[1]))

    ; Set Range
    _GUICtrlSlider_SetRange($idSlider, 20, 50)

    ; Get Range
    $aRange = _GUICtrlSlider_GetRange($idSlider)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Range: %d - %d", $aRange[0], $aRange[1]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_SetRangeMax

Function Reference

_GUICtrlSlider_SetRangeMax

Sets the maximum logical position for the slider

#include <GuiSlider.au3>
_GUICtrlSlider_SetRangeMax ( $hWnd, $iMaximum )

Parameters

$hWnd | Control ID/Handle to the control
$iMaximum | Maximum position for the slider

Return Value

None.

Remarks

If the current slider position is greater than the new maximum, the _GUICtrlSlider_SetRangeMax() function sets the slider position to the new maximum value.

Related

_GUICtrlSlider_GetRangeMax, _GUICtrlSlider_SetRange, _GUICtrlSlider_SetRangeMin

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Set Range Max", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Range Max
    MsgBox($MB_SYSTEMMODAL, "Information", "Range Max: " & _GUICtrlSlider_GetRangeMax($idSlider))

    ; Set Range Max
    _GUICtrlSlider_SetRangeMax($idSlider, 50)

    ; Get Range Max
    MsgBox($MB_SYSTEMMODAL, "Information", "Range Max: " & _GUICtrlSlider_GetRangeMax($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_SetRangeMin

Function Reference

_GUICtrlSlider_SetRangeMin

Sets the minimum logical position for the slider

#include <GuiSlider.au3>
_GUICtrlSlider_SetRangeMin ( $hWnd, $iMinimum )

Parameters

$hWnd | Control ID/Handle to the control
$iMinimum | Minimum position for the slider

Return Value

None.

Remarks

If the current slider position is less than the new minimum, the _GUICtrlSlider_SetRangeMin() function sets the slider position to the new minimum value.

Related

_GUICtrlSlider_GetRangeMin, _GUICtrlSlider_SetRange, _GUICtrlSlider_SetRangeMax

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Set Range Min", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Range Min
    MsgBox($MB_SYSTEMMODAL, "Information", "Range Min: " & _GUICtrlSlider_GetRangeMin($idSlider))

    ; Set Range Min
    _GUICtrlSlider_SetRangeMin($idSlider, 20)

    ; Get Range Min
    MsgBox($MB_SYSTEMMODAL, "Information", "Range Min: " & _GUICtrlSlider_GetRangeMin($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_SetSel

Function Reference

_GUICtrlSlider_SetSel

Sets the starting and ending positions for the available selection range

#include <GuiSlider.au3>
_GUICtrlSlider_SetSel ( $hWnd, $iMinimum, $iMaximum )

Parameters

$hWnd | Control ID/Handle to the control
$iMinimum | Starting logical position for the selection range
$iMaximum | Ending logical position for the selection range

Return Value

None.

Remarks

This function is ignored if the slider does not have the $TBS_ENABLESELRANGE style.
_GUICtrlSlider_SetSel() allows you to restrict the pointer to only a portion of the range available to the slider.

Related

_GUICtrlSlider_ClearSel, _GUICtrlSlider_GetSel, _GUICtrlSlider_SetSelEnd, _GUICtrlSlider_SetSelStart

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aSel, $idSlider

    ; Create GUI
    GUICreate("Slider Set Sel", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Set Sel
    _GUICtrlSlider_SetSel($idSlider, 10, 50)

    ; Get Sel
    $aSel = _GUICtrlSlider_GetSel($idSlider)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Sel: %d - %d", $aSel[0], $aSel[1]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_SetSelEnd

Function Reference

_GUICtrlSlider_SetSelEnd

Sets the ending logical position of the current selection range

#include <GuiSlider.au3>
_GUICtrlSlider_SetSelEnd ( $hWnd, $iMaximum )

Parameters

$hWnd | Control ID/Handle to the control
$iMaximum | Ending logical position for the selection range

Return Value

None.

Related

_GUICtrlSlider_ClearSel, _GUICtrlSlider_GetSel, _GUICtrlSlider_GetSelEnd, _GUICtrlSlider_SetSel, _GUICtrlSlider_SetSelStart

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Set Sel End", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Set Sel End
    _GUICtrlSlider_SetSelEnd($idSlider, 50)

    ; Get Sel End
    MsgBox($MB_SYSTEMMODAL, "Information", "Sel End: " & _GUICtrlSlider_GetSelEnd($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_SetSelStart

Function Reference

_GUICtrlSlider_SetSelStart

Sets the starting logical position of the current selection range

#include <GuiSlider.au3>
_GUICtrlSlider_SetSelStart ( $hWnd, $iMinimum )

Parameters

$hWnd | Control ID/Handle to the control
$iMinimum | Starting logical position for the selection range

Return Value

None.

Related

_GUICtrlSlider_ClearSel, _GUICtrlSlider_GetSel, _GUICtrlSlider_GetSelStart, _GUICtrlSlider_SetSel, _GUICtrlSlider_SetSelEnd

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Set Sel Start", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Set Sel Start
    _GUICtrlSlider_SetSelStart($idSlider, 10)

    ; Get Sel Start
    MsgBox($MB_SYSTEMMODAL, "Information", "Sel Start: " & _GUICtrlSlider_GetSelStart($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_SetThumbLength

Function Reference

_GUICtrlSlider_SetThumbLength

Sets the length of the slider

#include <GuiSlider.au3>
_GUICtrlSlider_SetThumbLength ( $hWnd, $iLength )

Parameters

$hWnd | Control ID/Handle to the control
$iLength | Length, in pixels, of the slider

Return Value

None.

Remarks

This function is ignored if the trackbar does not have the $TBS_FIXEDLENGTH style.

Related

_GUICtrlSlider_GetThumbLength

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Set Thumb Length", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 25, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_FIXEDLENGTH))
    GUISetState(@SW_SHOW)

    ; Get Thumb Length
    MsgBox($MB_SYSTEMMODAL, "Information", "Thumb Length: " & _GUICtrlSlider_GetThumbLength($idSlider))

    ; Set Thumb Length
    _GUICtrlSlider_SetThumbLength($idSlider, 10)

    ; Get Thumb Length
    MsgBox($MB_SYSTEMMODAL, "Information", "Thumb Length: " & _GUICtrlSlider_GetThumbLength($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_SetTic

Function Reference

_GUICtrlSlider_SetTic

Sets a tick mark in a slider at the specified logical position

#include <GuiSlider.au3>
_GUICtrlSlider_SetTic ( $hWnd, $iPosition )

Parameters

$hWnd | Control ID/Handle to the control
$iPosition | Position of the tick mark This parameter can be any of the integer values in the slider's range of minimum to maximum positions

Return Value

Success: | True.
Failure: | False.

Remarks

A slider creates its own first and last tick marks.
Do not use this message to set the first and last tick marks.

Related

_GUICtrlSlider_ClearTics, _GUICtrlSlider_GetTic

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iTic = Random(0, 100, 1), $idSlider

    ; Create GUI
    GUICreate("Slider Set Tic", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Set Tic
    _GUICtrlSlider_SetTic($idSlider, $iTic)

    ; Get Tic
    MsgBox($MB_SYSTEMMODAL, "Information", "Tic: " & _GUICtrlSlider_GetTic($idSlider, $iTic))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_SetTicFreq

Function Reference

_GUICtrlSlider_SetTicFreq

Sets the interval frequency for tick marks in a slider

#include <GuiSlider.au3>
_GUICtrlSlider_SetTicFreq ( $hWnd, $iFreg )

Parameters

$hWnd | Control ID/Handle to the control
$iFreg | Frequency of the tick marks.

Return Value

None.

Remarks

The slider must have the $TBS_AUTOTICKS style to use this function.

Related

_GUICtrlSlider_ClearTics, _GUICtrlSlider_GetNumTics

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Set Tic Freq", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Num Tics
    MsgBox($MB_SYSTEMMODAL, "Information", "Num Tics: " & _GUICtrlSlider_GetNumTics($idSlider))

    ; Set Tic Freq
    _GUICtrlSlider_SetTicFreq($idSlider, 1)

    ; Get Num Tics
    MsgBox($MB_SYSTEMMODAL, "Information", "Num Tics: " & _GUICtrlSlider_GetNumTics($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_SetTipSide

Function Reference

_GUICtrlSlider_SetTipSide

Positions a ToolTip control

#include <GuiSlider.au3>
_GUICtrlSlider_SetTipSide ( $hWnd, $iLocation )

Parameters

$hWnd | Control ID/Handle to the control
$iLocation | The location at which to display the ToolTip control. This value can be one of the following: $TBTS_TOP - Will be positioned above the slider. This flag is for use with horizontal sliders. $TBTS_LEFT - Will be positioned to the left of the slider. This flag is for use with vertical sliders. $TBTS_BOTTOM - Will be positioned below the slider This flag is for use with horizontal sliders. $TBTS_RIGHT - Will be positioned to the right of the slider. This flag is for use with vertical sliders.

Return Value

Returns the ToolTip control's previous location.
The return value equals one of the possible values for $iLocation.

Remarks

Use the $TBS_TOOLTIPS style display ToolTips.

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>

Example()

Func Example()
    Local $idRdoBottom, $idRdoLeft, $idRdoRight, $idRdoTop, $idSlider, $idSlider2

    ; Create GUI
    GUICreate("Slider Set Tip Side", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 375, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS))
    $idSlider2 = GUICtrlCreateSlider(380, 2, 20, 292, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_VERT))
    GUISetState(@SW_SHOW)

    GUICtrlCreateGroup("Tip Side Horiz", 2, 25, 120, 120)
    $idRdoBottom = GUICtrlCreateRadio("Bottom", 5, 40, 108, 20)
    $idRdoTop = GUICtrlCreateRadio("Top", 5, 115, 108, 20)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlSetState($idRdoTop, $GUI_CHECKED)

    GUICtrlCreateGroup("Tip Side Vert", 130, 25, 120, 120)
    $idRdoLeft = GUICtrlCreateRadio("Left", 132, 65, 108, 20)
    $idRdoRight = GUICtrlCreateRadio("Right", 132, 90, 108, 20)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlSetState($idRdoLeft, $GUI_CHECKED)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idRdoBottom
                _GUICtrlSlider_SetTipSide($idSlider, $TBTS_BOTTOM)
            Case $idRdoLeft
                _GUICtrlSlider_SetTipSide($idSlider2, $TBTS_LEFT)
            Case $idRdoRight
                _GUICtrlSlider_SetTipSide($idSlider2, $TBTS_RIGHT)
            Case $idRdoTop
                _GUICtrlSlider_SetTipSide($idSlider, $TBTS_TOP)
        EndSwitch
    WEnd
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_SetToolTips

Function Reference

_GUICtrlSlider_SetToolTips

Assigns a ToolTip control to a slider control

#include <GuiSlider.au3>
_GUICtrlSlider_SetToolTips ( $hWnd, $hWndTT )

Parameters

$hWnd | Control ID/Handle to the control
$hWndTT | Handle to an existing ToolTip control

Return Value

None.

Remarks

When a slider control is created with the $TBS_TOOLTIPS style, it creates a default ToolTip control that appears next to the slider, displaying the slider's current position.

Related

_GUICtrlSlider_GetToolTips

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hWndTT, $idSlider

    ; Create GUI
    GUICreate("Slider Set Tool Tips", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Tool Tips
    $hWndTT = _GUICtrlSlider_GetToolTips($idSlider)
    MsgBox($MB_SYSTEMMODAL, "Information", "Tool Tip Handle: " & $hWndTT)

    ; Set Tool Tips
    _GUICtrlSlider_SetToolTips($idSlider, $hWndTT)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlSlider_SetUnicodeFormat

Function Reference

_GUICtrlSlider_SetUnicodeFormat

Sets the Unicode character format flag for the control

#include <GuiSlider.au3>
_GUICtrlSlider_SetUnicodeFormat ( $hWnd, $bUnicode )

Parameters

$hWnd | Control ID/Handle to the control
$bUnicode | Determines the character set that is used by the control: True - The control will use Unicode characters False - The control will use ANSI characters

Return Value

Returns the previous Unicode format flag for the control.

Related

_GUICtrlSlider_GetUnicodeFormat

Example

#include <GUIConstantsEx.au3>
#include <GuiSlider.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idSlider

    ; Create GUI
    GUICreate("Slider Set Unicode Format", 400, 296)
    $idSlider = GUICtrlCreateSlider(2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUISetState(@SW_SHOW)

    ; Get Unicode Format
    MsgBox($MB_SYSTEMMODAL, "Information", "Unicode Format: " & _GUICtrlSlider_GetUnicodeFormat($idSlider))

    ; Set Unicode Format
    MsgBox($MB_SYSTEMMODAL, "Information", "Previous Unicode Format: " & _GUICtrlSlider_SetUnicodeFormat($idSlider, False))

    ; Get Unicode Format
    MsgBox($MB_SYSTEMMODAL, "Information", "Unicode Format: " & _GUICtrlSlider_GetUnicodeFormat($idSlider))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


User Defined Functions

GuiStatusBar user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiStatusBar.au3>.

User Defined Function | Description
_GUICtrlStatusBar_Create | Create a statusbar
_GUICtrlStatusBar_Destroy | Delete the control
_GUICtrlStatusBar_EmbedControl | Embeds a child control in the control
_GUICtrlStatusBar_GetBorders | Retrieves the current widths of the horizontal and vertical borders
_GUICtrlStatusBar_GetBordersHorz | Retrieves the current width of the horizontal border
_GUICtrlStatusBar_GetBordersRect | Retrieves the current width of the rectangle border
_GUICtrlStatusBar_GetBordersVert | Retrieves the current width of the vertical border
_GUICtrlStatusBar_GetCount | Retrieves the number of parts
_GUICtrlStatusBar_GetHeight | Retrieves the height of the statusbar
_GUICtrlStatusBar_GetIcon | Retrieves the icon for a part
_GUICtrlStatusBar_GetParts | Retrieves the number of parts and the part edges
_GUICtrlStatusBar_GetRect | Retrieves the bounding rectangle of a part
_GUICtrlStatusBar_GetRectEx | Retrieves the bounding rectangle of a part
_GUICtrlStatusBar_GetText | Retrieves the text from the specified part
_GUICtrlStatusBar_GetTextFlags | Retrieves the text length flags for a part
_GUICtrlStatusBar_GetTextLength | Retrieves the length of a part text
_GUICtrlStatusBar_GetTextLengthEx | Retrieves the uFlag of a part
_GUICtrlStatusBar_GetTipText | Retrieves the ToolTip text for a part
_GUICtrlStatusBar_GetUnicodeFormat | Retrieves the Unicode character format flag
_GUICtrlStatusBar_GetWidth | Retrieves the width of a part
_GUICtrlStatusBar_IsSimple | Checks a status bar control to determine if it is in simple mode
_GUICtrlStatusBar_Resize | Causes the status bar to resize itself
_GUICtrlStatusBar_SetBkColor | Sets the background color
_GUICtrlStatusBar_SetIcon | Sets the icon for a part
_GUICtrlStatusBar_SetMinHeight | Sets the minimum height of a status window's drawing area
_GUICtrlStatusBar_SetParts | Sets the number of parts and the part edges
_GUICtrlStatusBar_SetSimple | Specifies whether a status window displays simple text or displays all window parts
_GUICtrlStatusBar_SetText | Sets the text in the specified part of a status window
_GUICtrlStatusBar_SetTipText | Sets the ToolTip text for a part
_GUICtrlStatusBar_SetUnicodeFormat | Sets the Unicode character format flag
_GUICtrlStatusBar_ShowHide | Show/Hide the StatusBar control


Function _GUICtrlStatusBar_Create

Function Reference

_GUICtrlStatusBar_Create

Create a statusbar

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_Create ( $hWnd [, $vPartEdge = -1 [, $vPartText = "" [, $iStyles = -1 [, $iExStyles = 0x00000000]]]] )

Parameters

$hWnd | Handle to parent window
$vPartEdge | [optional] Width of part or parts, for more than 1 part pass in 0-based array in the following format: $vPartEdge[0] - Right edge of part #1 $vPartEdge[1] - Right edge of part #2 $vPartEdge[n] - Right edge of part n
$vPartText | [optional] Text of part or parts, for more than 1 part pass in 0-based array in the following format: $vPartText[0] - First part $vPartText[1] - Second part $vPartText[n] - Last part
$iStyles | [optional] Control styles: $SBARS_SIZEGRIP - The status bar control will include a sizing grip at the right end of the status bar $SBARS_TOOLTIPS - The status bar will have tooltips Forced: $WS_CHILD, $WS_VISIBLE
$iExStyles | [optional] Control extended style. These correspond to the standard $WS_EX_* constants. See Extended Style Table.

Return Value

Success: | the handle to the control.
Failure: | 0.

Remarks

If using GUICtrlCreateMenu() then use _GUICtrlStatusBar_Create() after GUICtrlCreateMenu().

Related

_GUICtrlStatusBar_Destroy

Example

Example 1

#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_hMainGUI, $g_hStatus

Example()

Func Example()
    Local $hGUI
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("(Example 1) StatusBar Create", 400, 300)

    ; defaults to 1 part, no text
    $g_hStatus = _GUICtrlStatusBar_Create($hGUI)
    _GUICtrlStatusBar_SetParts($g_hStatus, $aParts)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUICtrlSendMsg($g_idMemo, $EM_SETREADONLY, True, 0)
    GUICtrlSetBkColor($g_idMemo, 0xFFFFFF)
    GUISetState(@SW_SHOW)

    MemoWrite("StatusBar Created with:" & @CRLF & _
            @TAB & "Handle to GUI window" & @CRLF)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Get border sizes
    MemoWrite("Horizontal border width .: " & _GUICtrlStatusBar_GetBordersHorz($g_hStatus))
    MemoWrite("Vertical border width ...: " & _GUICtrlStatusBar_GetBordersVert($g_hStatus))
    MemoWrite("Width between rectangles : " & _GUICtrlStatusBar_GetBordersRect($g_hStatus))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUISetState(@SW_ENABLE, $g_hMainGUI)
    GUIDelete($hGUI)
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Local $tInfo
    Switch $hWndFrom
        Case $g_hStatus
            Switch $iCode
                Case $NM_CLICK ; The user has clicked the left mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_RCLICK ; The user has clicked the right mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_RDBLCLK ; The user has double-clicked the right mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $SBN_SIMPLEMODECHANGE ; Simple mode changes
                    _DebugPrint("$SBN_SIMPLEMODECHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint

Example 2

#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_hMainGUI, $g_hStatus

Example()

Func Example()
    Local $hGUI
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("(Example 2) StatusBar Create", 400, 300)

    ; sets parts with no text
    $g_hStatus = _GUICtrlStatusBar_Create($hGUI, $aParts)
    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUICtrlSendMsg($g_idMemo, $EM_SETREADONLY, True, 0)
    GUICtrlSetBkColor($g_idMemo, 0xFFFFFF)
    GUISetState(@SW_SHOW)

    MemoWrite("StatusBar Created with:" & @CRLF & _
            @TAB & "Handle to GUI window" & @CRLF & _
            @TAB & "part width array of 3 elements" & @CRLF)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Get border sizes
    MemoWrite("Horizontal border width .: " & _GUICtrlStatusBar_GetBordersHorz($g_hStatus))
    MemoWrite("Vertical border width ...: " & _GUICtrlStatusBar_GetBordersVert($g_hStatus))
    MemoWrite("Width between rectangles : " & _GUICtrlStatusBar_GetBordersRect($g_hStatus))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUISetState(@SW_ENABLE, $g_hMainGUI)
    GUIDelete($hGUI)
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Local $tInfo
    Switch $hWndFrom
        Case $g_hStatus
            Switch $iCode
                Case $NM_CLICK ; The user has clicked the left mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_RCLICK ; The user has clicked the right mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_RDBLCLK ; The user has double-clicked the right mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $SBN_SIMPLEMODECHANGE ; Simple mode changes
                    _DebugPrint("$SBN_SIMPLEMODECHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint

Example 3

#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_hMainGUI, $g_hStatus

Example()

Func Example()
    Local $hGUI
    Local $aText[3] = ["Left Justified", @TAB & "Centered", @TAB & @TAB & "Right Justified"]
    Local $aParts[3] = [100, 175, -1]

    ; Create GUI
    $hGUI = GUICreate("(Example 3) StatusBar Create", 400, 300)

    ;sets parts and text
    $g_hStatus = _GUICtrlStatusBar_Create($hGUI, $aParts, $aText)
    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUICtrlSendMsg($g_idMemo, $EM_SETREADONLY, True, 0)
    GUICtrlSetBkColor($g_idMemo, 0xFFFFFF)
    GUISetState(@SW_SHOW)

    MemoWrite("StatusBar Created with:" & @CRLF & _
            @TAB & "only Handle," & @CRLF & _
            @TAB & "part width array of 3 elements" & @CRLF & _
            @TAB & "part text array of 3 elements" & @CRLF)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Get border sizes
    MemoWrite("Horizontal border width .: " & _GUICtrlStatusBar_GetBordersHorz($g_hStatus))
    MemoWrite("Vertical border width ...: " & _GUICtrlStatusBar_GetBordersVert($g_hStatus))
    MemoWrite("Width between rectangles : " & _GUICtrlStatusBar_GetBordersRect($g_hStatus))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUISetState(@SW_ENABLE, $g_hMainGUI)
    GUIDelete($hGUI)
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Local $tInfo
    Switch $hWndFrom
        Case $g_hStatus
            Switch $iCode
                Case $NM_CLICK ; The user has clicked the left mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_RCLICK ; The user has clicked the right mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_RDBLCLK ; The user has double-clicked the right mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $SBN_SIMPLEMODECHANGE ; Simple mode changes
                    _DebugPrint("$SBN_SIMPLEMODECHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint

Example 4

#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_hMainGUI, $g_hStatus

Example()

Func Example()
    Local $hGUI
    Local $aText[3] = ["Left Justified", @TAB & "Centered", @TAB & @TAB & "Right Justified"]

    ; Create GUI
    $hGUI = GUICreate("(Example 4) StatusBar Create", 400, 300)

    ; will create part widths based on part size passed in
    $g_hStatus = _GUICtrlStatusBar_Create($hGUI, 100, $aText)
    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUICtrlSendMsg($g_idMemo, $EM_SETREADONLY, True, 0)
    GUICtrlSetBkColor($g_idMemo, 0xFFFFFF)
    GUISetState(@SW_SHOW)

    MemoWrite("StatusBar Created with:" & @CRLF & _
            @TAB & "only Handle," & @CRLF & _
            @TAB & "part width number" & @CRLF & _
            @TAB & "part text array of 3 elements" & @CRLF)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Get border sizes
    MemoWrite("Horizontal border width .: " & _GUICtrlStatusBar_GetBordersHorz($g_hStatus))
    MemoWrite("Vertical border width ...: " & _GUICtrlStatusBar_GetBordersVert($g_hStatus))
    MemoWrite("Width between rectangles : " & _GUICtrlStatusBar_GetBordersRect($g_hStatus))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUISetState(@SW_ENABLE, $g_hMainGUI)
    GUIDelete($hGUI)
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Local $tInfo
    Switch $hWndFrom
        Case $g_hStatus
            Switch $iCode
                Case $NM_CLICK ; The user has clicked the left mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_RCLICK ; The user has clicked the right mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_RDBLCLK ; The user has double-clicked the right mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $SBN_SIMPLEMODECHANGE ; Simple mode changes
                    _DebugPrint("$SBN_SIMPLEMODECHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint

Example 5

#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_hMainGUI, $g_hStatus

Example()

Func Example()
    Local $hGUI
    Local $aText[3] = ["Left Justified", @TAB & "Centered", @TAB & @TAB & "Right Justified"]
    Local $aParts[2] = [100, 175]

    ; Create GUI
    $hGUI = GUICreate("(Example 5) StatusBar Create", 400, 300)

    ; adjusts array to largest array passed in (this time the text array is the largest)
    $g_hStatus = _GUICtrlStatusBar_Create($hGUI, $aParts, $aText)
    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUICtrlSendMsg($g_idMemo, $EM_SETREADONLY, True, 0)
    GUICtrlSetBkColor($g_idMemo, 0xFFFFFF)
    GUISetState(@SW_SHOW)

    MemoWrite("StatusBar Created with:" & @CRLF & _
            @TAB & "only Handle," & @CRLF & _
            @TAB & "part width array of 2 elements" & @CRLF & _
            @TAB & "part text array of 3 elements" & @CRLF)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Get border sizes
    MemoWrite("Horizontal border width .: " & _GUICtrlStatusBar_GetBordersHorz($g_hStatus))
    MemoWrite("Vertical border width ...: " & _GUICtrlStatusBar_GetBordersVert($g_hStatus))
    MemoWrite("Width between rectangles : " & _GUICtrlStatusBar_GetBordersRect($g_hStatus))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUISetState(@SW_ENABLE, $g_hMainGUI)
    GUIDelete($hGUI)
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Local $tInfo
    Switch $hWndFrom
        Case $g_hStatus
            Switch $iCode
                Case $NM_CLICK ; The user has clicked the left mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_RCLICK ; The user has clicked the right mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_RDBLCLK ; The user has double-clicked the right mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $SBN_SIMPLEMODECHANGE ; Simple mode changes
                    _DebugPrint("$SBN_SIMPLEMODECHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint

Example 6

#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_hMainGUI, $g_hStatus

Example()

Func Example()
    Local $hGUI
    Local $aText[2] = ["Left Justified", @TAB & "Centered"]
    Local $aParts[3] = [100, 175, -1]

    ; Create GUI
    $hGUI = GUICreate("(Example 6) StatusBar Create", 400, 300)

    ; adjusts array to largest array passed in (this time the part width array)
    $g_hStatus = _GUICtrlStatusBar_Create($hGUI, $aParts, $aText)
    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUICtrlSendMsg($g_idMemo, $EM_SETREADONLY, True, 0)
    GUICtrlSetBkColor($g_idMemo, 0xFFFFFF)
    GUISetState(@SW_SHOW)

    MemoWrite("StatusBar Created with:" & @CRLF & _
            @TAB & "only Handle," & @CRLF & _
            @TAB & "part width array of 3 elements" & @CRLF & _
            @TAB & "part text array of 2 elements" & @CRLF)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Get border sizes
    MemoWrite("Horizontal border width .: " & _GUICtrlStatusBar_GetBordersHorz($g_hStatus))
    MemoWrite("Vertical border width ...: " & _GUICtrlStatusBar_GetBordersVert($g_hStatus))
    MemoWrite("Width between rectangles : " & _GUICtrlStatusBar_GetBordersRect($g_hStatus))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUISetState(@SW_ENABLE, $g_hMainGUI)
    GUIDelete($hGUI)
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Local $tInfo
    Switch $hWndFrom
        Case $g_hStatus
            Switch $iCode
                Case $NM_CLICK ; The user has clicked the left mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_RCLICK ; The user has clicked the right mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $NM_RDBLCLK ; The user has double-clicked the right mouse button within the control
                    $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    $iCode = DllStructGetData($tInfo, "Code")
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode & @CRLF & _
                            "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                            "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                            "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                            "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                            "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    Return True ; indicate that the mouse click was handled and suppress default processing by the system
                    ; Return FALSE ;to allow default processing of the click.
                Case $SBN_SIMPLEMODECHANGE ; Simple mode changes
                    _DebugPrint("$SBN_SIMPLEMODECHANGE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlStatusBar_Destroy

Function Reference

_GUICtrlStatusBar_Destroy

Delete the control

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_Destroy ( ByRef $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True, $hWnd is set to 0.
Failure: | False.

Remarks

Restricted to only be used on StatusBar controls created with _GUICtrlStatusBar_Create().

Related

_GUICtrlStatusBar_Create

Example

#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hHandleBefore, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Destroy", 400, 300)

    ; defaults to 1 part, no text
    $hStatus = _GUICtrlStatusBar_Create($hGUI)
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)

    GUISetState(@SW_SHOW)

    $hHandleBefore = $hStatus
    MsgBox($MB_SYSTEMMODAL, "Information", "Destroying the Control for Handle: " & $hStatus)
    MsgBox($MB_SYSTEMMODAL, "Information", "Control Destroyed: " & _GUICtrlStatusBar_Destroy($hStatus) & @CRLF & _
            "Handle Before Destroy: " & $hHandleBefore & @CRLF & _
            "Handle After Destroy: " & $hStatus)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlStatusBar_EmbedControl

Function Reference

_GUICtrlStatusBar_EmbedControl

Embeds a child control in the control

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_EmbedControl ( $hWnd, $iPart, $hControl [, $iFit = 4] )

Parameters

$hWnd | Handle to the control
$iPart | 0-based part index
$hControl | Handle of control to embed in panel
$iFit | [optional] Determines how to fit the control. Can be a combination of: 1 - Center the control horizontally 2 - Center the control vertically 4 - Fit the control to the status bar part

Return Value

None.

Remarks

You can embed ANY control in the status bar, not just the usual Progress Bar.

Example

#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>
#include <SendMessage.au3>

Example()

Func Example()
    Local $hGUI, $hProgress, $hInput, $idInput, $idProgress, $hStatus
    Local $aParts[4] = [80, 160, 300, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Embed Control", 400, 300)

    ; defaults to 1 part, no text
    $hStatus = _GUICtrlStatusBar_Create($hGUI)
    _GUICtrlStatusBar_SetMinHeight($hStatus, 20)

    GUISetState(@SW_SHOW)

    ; Initialize parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Part 1")
    _GUICtrlStatusBar_SetText($hStatus, "Part 2", 1)

    ; Embed a progress bar
    If @OSType = "WIN32_WINDOWS" Then
        $idProgress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_SMOOTH)
        $hProgress = GUICtrlGetHandle($idProgress)
        _GUICtrlStatusBar_EmbedControl($hStatus, 2, $hProgress)
    Else
        $idProgress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_MARQUEE) ; marquee works on Win XP and above
        $hProgress = GUICtrlGetHandle($idProgress)
        _GUICtrlStatusBar_EmbedControl($hStatus, 2, $hProgress)
        _SendMessage($hProgress, $PBM_SETMARQUEE, True, 200) ; marquee works on Win XP and above
    EndIf

    $idInput = GUICtrlCreateInput("This is Embeded", 0, 0)
    $hInput = GUICtrlGetHandle($idInput)
    _GUICtrlStatusBar_EmbedControl($hStatus, 3, $hInput, 3)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlStatusBar_GetBorders

Function Reference

_GUICtrlStatusBar_GetBorders

Retrieves the current widths of the horizontal and vertical borders

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_GetBorders ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | an array with the following format: $aBorders[0] - Width of the horizontal border $aBorders[1] - Width of the vertical border $aBorders[2] - Width of the border between rectangles
Failure: | sets the @error flag to non-zero.

Related

_GUICtrlStatusBar_GetBordersHorz, _GUICtrlStatusBar_GetBordersRect, _GUICtrlStatusBar_GetBordersVert

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $aInfo, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Get Borders", 400, 300)

    $hStatus = _GUICtrlStatusBar_Create($hGUI)
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get border sizes
    $aInfo = _GUICtrlStatusBar_GetBorders($hStatus)
    MemoWrite("Horizontal border width .: " & $aInfo[0])
    MemoWrite("Vertical border width ...: " & $aInfo[1])
    MemoWrite("Width between rectangles : " & $aInfo[2])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_GetBordersHorz

Function Reference

_GUICtrlStatusBar_GetBordersHorz

Retrieves the current width of the horizontal border

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_GetBordersHorz ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the width of the horizontal border.
Failure: | sets the @error flag to non-zero.

Related

_GUICtrlStatusBar_GetBorders, _GUICtrlStatusBar_GetBordersRect, _GUICtrlStatusBar_GetBordersVert

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Get Borders Horizontal", 400, 300)

    $hStatus = _GUICtrlStatusBar_Create($hGUI)
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get border sizes
    MemoWrite("Horizontal border width .: " & _GUICtrlStatusBar_GetBordersHorz($hStatus))
    MemoWrite("Vertical border width ...: " & _GUICtrlStatusBar_GetBordersVert($hStatus))
    MemoWrite("Width between rectangles : " & _GUICtrlStatusBar_GetBordersRect($hStatus))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_GetBordersRect

Function Reference

_GUICtrlStatusBar_GetBordersRect

Retrieves the current width of the rectangle border

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_GetBordersRect ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the width of the rectangle border.
Failure: | sets the @error flag to non-zero.

Related

_GUICtrlStatusBar_GetBorders, _GUICtrlStatusBar_GetBordersHorz, _GUICtrlStatusBar_GetBordersVert

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Get Borders Rect", 400, 300)

    $hStatus = _GUICtrlStatusBar_Create($hGUI)
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get border sizes
    MemoWrite("Horizontal border width .: " & _GUICtrlStatusBar_GetBordersHorz($hStatus))
    MemoWrite("Vertical border width ...: " & _GUICtrlStatusBar_GetBordersVert($hStatus))
    MemoWrite("Width between rectangles : " & _GUICtrlStatusBar_GetBordersRect($hStatus))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_GetBordersVert

Function Reference

_GUICtrlStatusBar_GetBordersVert

Retrieves the current width of the vertical border

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_GetBordersVert ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the width of the vertical border.
Failure: | sets the @error flag to non-zero.

Related

_GUICtrlStatusBar_GetBorders, _GUICtrlStatusBar_GetBordersHorz, _GUICtrlStatusBar_GetBordersRect

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Get Borders Vertical", 400, 300)

    $hStatus = _GUICtrlStatusBar_Create($hGUI)
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get border sizes
    MemoWrite("Horizontal border width .: " & _GUICtrlStatusBar_GetBordersHorz($hStatus))
    MemoWrite("Vertical border width ...: " & _GUICtrlStatusBar_GetBordersVert($hStatus))
    MemoWrite("Width between rectangles : " & _GUICtrlStatusBar_GetBordersRect($hStatus))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_GetCount

Function Reference

_GUICtrlStatusBar_GetCount

Retrieves the number of parts

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_GetCount ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns the number of status bar parts.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Get Count", 400, 300)

    $hStatus = _GUICtrlStatusBar_Create($hGUI)
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get number of parts
    MemoWrite("Number of parts .: " & _GUICtrlStatusBar_GetCount($hStatus))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_GetHeight

Function Reference

_GUICtrlStatusBar_GetHeight

Retrieves the height of the statusbar

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_GetHeight ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns the height.

Related

_GUICtrlStatusBar_GetWidth, _GUICtrlStatusBar_SetMinHeight

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Get Height", 400, 300)

    $hStatus = _GUICtrlStatusBar_Create($hGUI)
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get parts height/width
    MemoWrite("Height of parts .: " & _GUICtrlStatusBar_GetHeight($hStatus))
    MemoWrite("Width of part 1 .: " & _GUICtrlStatusBar_GetWidth($hStatus, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_GetIcon

Function Reference

_GUICtrlStatusBar_GetIcon

Retrieves the icon for a part

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_GetIcon ( $hWnd [, $iIndex = 0] )

Parameters

$hWnd | Handle to the control
$iIndex | [optional] 0-based index of the part that contains the icon to be retrieved. If this parameter is -1, the status bar is assumed to be a Simple Mode status bar.

Return Value

Success: | the handle to the icon.
Failure: | 0

Related

_GUICtrlStatusBar_SetIcon

Example

Example 1

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $ahIcons[2], $hStatus
    Local $aParts[4] = [75, 150, 300, 400]

    ; Create GUI
    $hGUI = GUICreate("(Example 1) StatusBar Get Icon", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Part 1")
    _GUICtrlStatusBar_SetText($hStatus, "Part 2", 1)

    ; Set icons
    $ahIcons[0] = _WinAPI_LoadShell32Icon(23)
    $ahIcons[1] = _WinAPI_LoadShell32Icon(40)
    _GUICtrlStatusBar_SetIcon($hStatus, 0, $ahIcons[0])
    _GUICtrlStatusBar_SetIcon($hStatus, 1, $ahIcons[1])

    ; Show icon handles
    MemoWrite("Part 1 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 0)))
    MemoWrite("IsPtr = " & IsPtr(_GUICtrlStatusBar_GetIcon($hStatus, 0)) & " IsHWnd = " & IsHWnd(_GUICtrlStatusBar_GetIcon($hStatus, 0)))
    MemoWrite("Part 2 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 1)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    ; Free icons
    _WinAPI_DestroyIcon($ahIcons[0])
    _WinAPI_DestroyIcon($ahIcons[1])
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Example 2

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[4] = [75, 150, 300, 400]

    ; Create GUI
    $hGUI = GUICreate("(Example 2) StatusBar Get Icon", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Part 1")
    _GUICtrlStatusBar_SetText($hStatus, "Part 2", 1)

    ; Set icons
    _GUICtrlStatusBar_SetIcon($hStatus, 0, 23, "shell32.dll")
    _GUICtrlStatusBar_SetIcon($hStatus, 1, 40, "shell32.dll")

    ; Show icon handles
    MemoWrite("Part 1 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 0)))
    MemoWrite("Part 2 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 1)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_GetParts

Function Reference

_GUICtrlStatusBar_GetParts

Retrieves the number of parts and the part edges

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_GetParts ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns an array with the following format:
$aParts[0] - Number of parts
$aParts[1] - Right edge of part #1
$aParts[2] - Right edge of part #2
$aParts[n] - Right edge of part n

Related

_GUICtrlStatusBar_SetParts

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Get Parts", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set/Get parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    $aParts = _GUICtrlStatusBar_GetParts($hStatus)
    For $iI = 1 To $aParts[0]
        MemoWrite("Part " & $iI & " width .: " & $aParts[$iI])
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_GetRect

Function Reference

_GUICtrlStatusBar_GetRect

Retrieves the bounding rectangle of a part

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_GetRect ( $hWnd, $iPart )

Parameters

$hWnd | Handle to the control
$iPart | 0-based part index

Return Value

Success: | an array with the following format: $aRect[0] = X coordinate of the upper left corner of the rectangle $aRect[1] = Y coordinate of the upper left corner of the rectangle $aRect[2] = X coordinate of the lower right corner of the rectangle $aRect[3] = Y coordinate of the lower right corner of the rectangle
Failure: | sets the @error flag to non-zero.

Related

_GUICtrlStatusBar_GetRectEx

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $aRect, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Get Rect", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set/Get parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)

    ; Get part 1 rectangles
    $aRect = _GUICtrlStatusBar_GetRect($hStatus, 0)
    MemoWrite("Part 1 left ...: " & $aRect[0])
    MemoWrite("Part 1 top ....: " & $aRect[1])
    MemoWrite("Part 1 right ..: " & $aRect[2])
    MemoWrite("Part 1 bottom .: " & $aRect[3])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_GetRectEx

Function Reference

_GUICtrlStatusBar_GetRectEx

Retrieves the bounding rectangle of a part

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_GetRectEx ( $hWnd, $iPart )

Parameters

$hWnd | Handle to the control
$iPart | 0-based part index. If the control is in simple mode this field is ignored and the rectangle of the status bar is returned.

Return Value

Success: | a $tagRECT structure that receives the bounding rectangle.
Failure: | sets the @error flag to non-zero.

Related

$tagRECT, _GUICtrlStatusBar_GetRect

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $tRECT, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Get RectEx", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set/Get parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)

    ; Get part 1 rectangles
    $tRECT = _GUICtrlStatusBar_GetRectEx($hStatus, 0)
    MemoWrite("Part 1 left ...: " & DllStructGetData($tRECT, "Left"))
    MemoWrite("Part 1 top ....: " & DllStructGetData($tRECT, "Top"))
    MemoWrite("Part 1 right ..: " & DllStructGetData($tRECT, "Right"))
    MemoWrite("Part 1 bottom .: " & DllStructGetData($tRECT, "Bottom"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_GetText

Function Reference

_GUICtrlStatusBar_GetText

Retrieves the text from the specified part

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_GetText ( $hWnd, $iPart )

Parameters

$hWnd | Handle to the control
$iPart | 0-based part index

Return Value

Success: | the part text.
Failure: | sets the @error flag to non-zero.

Related

_GUICtrlStatusBar_SetText

Example

Example 1

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $ahIcons[2], $hStatus
    Local $aParts[4] = [75, 150, 300, 400]

    ; Create GUI
    $hGUI = GUICreate("(Example 1) StatusBar Get Text", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Part 1")
    _GUICtrlStatusBar_SetText($hStatus, "Part 2", 1)

    ; Set icons
    $ahIcons[0] = _WinAPI_LoadShell32Icon(23)
    $ahIcons[1] = _WinAPI_LoadShell32Icon(40)
    _GUICtrlStatusBar_SetIcon($hStatus, 0, $ahIcons[0])
    _GUICtrlStatusBar_SetIcon($hStatus, 1, $ahIcons[1])

    ; Show part text
    MemoWrite("Part 1 text ........: " & _GUICtrlStatusBar_GetText($hStatus, 0))
    MemoWrite("Part 2 text ........: " & _GUICtrlStatusBar_GetText($hStatus, 1))

    ; Show icon handles
    MemoWrite("Part 1 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 0)))
    MemoWrite("Part 2 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 1)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    ; Free icons
    _WinAPI_DestroyIcon($ahIcons[0])
    _WinAPI_DestroyIcon($ahIcons[1])
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Example 2

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[4] = [75, 150, 300, 400]

    ; Create GUI
    $hGUI = GUICreate("(Example 2) StatusBar Get Text", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Part 1")
    _GUICtrlStatusBar_SetText($hStatus, "Part 2", 1)

    ; Set icons
    _GUICtrlStatusBar_SetIcon($hStatus, 0, 23, "shell32.dll")
    _GUICtrlStatusBar_SetIcon($hStatus, 1, 40, "shell32.dll")

    ; Show part text
    MemoWrite("Part 1 text ........: " & _GUICtrlStatusBar_GetText($hStatus, 0))
    MemoWrite("Part 2 text ........: " & _GUICtrlStatusBar_GetText($hStatus, 1))

    ; Show icon handles
    MemoWrite("Part 1 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 0)))
    MemoWrite("Part 2 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 1)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_GetTextFlags

Function Reference

_GUICtrlStatusBar_GetTextFlags

Retrieves the text length flags for a part

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_GetTextFlags ( $hWnd, $iPart )

Parameters

$hWnd | Handle to the control
$iPart | 0-based part index

Return Value

Returns the low word specifies the length, in characters, of the text. The high word specifies the type of operation used to draw the text. The type can be one of the following values:
0 - The text is drawn with a border to appear lower than the plane of the window
$SBT_NOBORDERS - The text is drawn without borders
$SBT_OWNERDRAW - The text is drawn by the parent window
$SBT_POPOUT - The text is drawn with a border to appear higher than the plane of the window
$SBT_RTLREADING - The text will be displayed in the opposite direction to the text in the parent window

Related

_GUICtrlStatusBar_GetTextLength, _GUICtrlStatusBar_GetTextLengthEx

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("(Example 1) StatusBar Get Text Flags", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Part 1", 0, $SBT_POPOUT)
    _GUICtrlStatusBar_SetText($hStatus, "Part 2", 1, $SBT_NOBORDERS)
    _GUICtrlStatusBar_SetText($hStatus, "Part 3", 2, $SBT_NOTABPARSING)

    ; Get text information
    For $iI = 0 To _GUICtrlStatusBar_GetCount($hStatus) - 1
        MemoWrite("Part " & $iI & " text flags .: " & _GUICtrlStatusBar_GetTextFlags($hStatus, $iI))
        MemoWrite("Part " & $iI & " text length : " & _GUICtrlStatusBar_GetTextLength($hStatus, $iI))
        MemoWrite("Part " & $iI & " text length : 0x" & Hex(_GUICtrlStatusBar_GetTextLengthEx($hStatus, $iI)))
        MemoWrite()
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_GetTextLength

Function Reference

_GUICtrlStatusBar_GetTextLength

Retrieves the length of a part text

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_GetTextLength ( $hWnd, $iPart )

Parameters

$hWnd | Handle to the control
$iPart | 0-based part index

Return Value

Returns the length of part text.

Related

_GUICtrlStatusBar_GetTextFlags, _GUICtrlStatusBar_GetTextLengthEx

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Get Text Length", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Part 1")
    _GUICtrlStatusBar_SetText($hStatus, "Part 2", 1)

    ; Get text information
    For $iI = 0 To _GUICtrlStatusBar_GetCount($hStatus) - 1
        MemoWrite("Part " & $iI & " text flags .: 0x" & Hex(_GUICtrlStatusBar_GetTextFlags($hStatus, $iI)))
        MemoWrite("Part " & $iI & " text length : " & _GUICtrlStatusBar_GetTextLength($hStatus, $iI))
        MemoWrite()
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_GetTextLengthEx

Function Reference

_GUICtrlStatusBar_GetTextLengthEx

Retrieves the uFlag of a part

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_GetTextLengthEx ( $hWnd, $iPart )

Parameters

$hWnd | Handle to the control
$iPart | 0-based part index

Return Value

Returns the Type of drawing operation. The type can be one of the following values:
0 - The text is drawn with a border to appear lower than the plane of the window
$SBT_NOBORDERS - The text is drawn without borders
$SBT_OWNERDRAW - The text is drawn by the parent window
$SBT_POPOUT - The text is drawn with a border to appear higher than the plane of the window
$SBT_RTLREADING - The text will be displayed in the opposite direction to the text in the parent window

Related

_GUICtrlStatusBar_GetTextFlags, _GUICtrlStatusBar_GetTextLength

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $iI, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Get Text LengthEx", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI, $SBT_NOBORDERS)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Part 1", 0, $SBT_POPOUT)
    _GUICtrlStatusBar_SetText($hStatus, "Part 2", 1, $SBT_NOBORDERS)
    _GUICtrlStatusBar_SetText($hStatus, "Part 3", 2, $SBT_NOTABPARSING)

    ; Get text information
    For $iI = 0 To _GUICtrlStatusBar_GetCount($hStatus) - 1
        MemoWrite("Part " & $iI & " text flags .: " & _GUICtrlStatusBar_GetTextFlags($hStatus, $iI))
        MemoWrite("Part " & $iI & " text length : " & _GUICtrlStatusBar_GetTextLength($hStatus, $iI))
        MemoWrite("Part " & $iI & " text length : 0x" & Hex(_GUICtrlStatusBar_GetTextLengthEx($hStatus, $iI)))
        MemoWrite()
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_GetTipText

Function Reference

_GUICtrlStatusBar_GetTipText

Retrieves the ToolTip text for a part

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_GetTipText ( $hWnd, $iPart )

Parameters

$hWnd | Handle to the control
$iPart | 0-based part index

Return Value

Returns the part text.

Remarks

The status bar must be created with the $SBARS_TOOLTIPS style to enable ToolTips.

Related

_GUICtrlStatusBar_SetTipText

Example

Example 1

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hIcon, $hStatus
    Local $aParts[4] = [75, 150, 300, 400]

    ; Create GUI
    $hGUI = GUICreate("(Example 1) StatusBar Get Tip Text", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI, -1, "", $SBARS_TOOLTIPS)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Force tip to be shown when text is more than fits in the box", 1)

    ; Set icon
    $hIcon = _WinAPI_LoadShell32Icon(23)
    _GUICtrlStatusBar_SetIcon($hStatus, 0, $hIcon)

    ; Set text tips
    _GUICtrlStatusBar_SetTipText($hStatus, 0, "Tip works when only icon in part or text exceeds part")
    _GUICtrlStatusBar_SetTipText($hStatus, 1, "Force tip to be shown when text is more than fits in the box")

    MemoWrite("Hold Mouse Cursor over part to see tip." & @CRLF)

    ; Show text tips
    MemoWrite("Text tip 1 .: " & _GUICtrlStatusBar_GetTipText($hStatus, 0) & @CRLF)
    MemoWrite("Text tip 2 .: " & _GUICtrlStatusBar_GetTipText($hStatus, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    ; Free icons
    _WinAPI_DestroyIcon($hIcon)
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Example 2

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[4] = [75, 150, 300, 400]

    ; Create GUI
    $hGUI = GUICreate("(Example 2) StatusBar Get Tip Text", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI, -1, "", $SBARS_TOOLTIPS)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Force tip to be shown when text is more than fits in the box", 1)

    ; Set icon
    _GUICtrlStatusBar_SetIcon($hStatus, 0, 23, "shell32.dll")

    ; Set text tips
    _GUICtrlStatusBar_SetTipText($hStatus, 0, "Tip works when only icon in part or text exceeds part")
    _GUICtrlStatusBar_SetTipText($hStatus, 1, "Force tip to be shown when text is more than fits in the box")

    MemoWrite("Hold Mouse Cursor over part to see tip." & @CRLF)

    ; Show text tips
    MemoWrite("Text tip 1 .: " & _GUICtrlStatusBar_GetTipText($hStatus, 0) & @CRLF)
    MemoWrite("Text tip 2 .: " & _GUICtrlStatusBar_GetTipText($hStatus, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_GetUnicodeFormat

Function Reference

_GUICtrlStatusBar_GetUnicodeFormat

Retrieves the Unicode character format flag

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_GetUnicodeFormat ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

True: | the control is using Unicode characters.
False: | the control is using ANSI characters.

Related

_GUICtrlStatusBar_SetUnicodeFormat

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus

    ; Create GUI
    $hGUI = GUICreate("StatusBar Get Unicode Format", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set Unicode format
    MemoWrite("Unicode format .: " & _GUICtrlStatusBar_GetUnicodeFormat($hStatus))
    _GUICtrlStatusBar_SetUnicodeFormat($hStatus, False)
    MemoWrite("Unicode format .: " & _GUICtrlStatusBar_GetUnicodeFormat($hStatus))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_GetWidth

Function Reference

_GUICtrlStatusBar_GetWidth

Retrieves the width of a part

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_GetWidth ( $hWnd, $iPart )

Parameters

$hWnd | Handle to the control
$iPart | 0-based part index

Return Value

Returns the width of the parts.

Related

_GUICtrlStatusBar_GetHeight

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Get Width", 400, 300)

    $hStatus = _GUICtrlStatusBar_Create($hGUI)
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get parts height/width
    MemoWrite("Height of parts .: " & _GUICtrlStatusBar_GetHeight($hStatus))
    MemoWrite("Width of part 1 .: " & _GUICtrlStatusBar_GetWidth($hStatus, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_IsSimple

Function Reference

_GUICtrlStatusBar_IsSimple

Checks a status bar control to determine if it is in simple mode

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_IsSimple ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

True: | the status bar is in simple mode.
False: | the status bar is not in simple mode.

Related

_GUICtrlStatusBar_SetSimple

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar IsSimple", 400, 300)

    $hStatus = _GUICtrlStatusBar_Create($hGUI)
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set simple format
    MemoWrite("Simple mode on .: " & _GUICtrlStatusBar_IsSimple($hStatus))
    Sleep(1000)
    _GUICtrlStatusBar_SetSimple($hStatus, True)
    MemoWrite("Simple mode on .: " & _GUICtrlStatusBar_IsSimple($hStatus))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_Resize

Function Reference

_GUICtrlStatusBar_Resize

Causes the status bar to resize itself

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_Resize ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

None.

Example

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

Global $g_hStatus

Example()

Func Example()
    Local $hGUI
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Resize", 400, 300, -1, -1, $WS_OVERLAPPEDWINDOW)

    $g_hStatus = _GUICtrlStatusBar_Create($hGUI)
    _GUICtrlStatusBar_SetParts($g_hStatus, $aParts)
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_SIZE, "WM_SIZE")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Resize the status bar when GUI size changes
Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam
    _GUICtrlStatusBar_Resize($g_hStatus)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE


Function _GUICtrlStatusBar_SetBkColor

Function Reference

_GUICtrlStatusBar_SetBkColor

Sets the background color

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_SetBkColor ( $hWnd, $iColor )

Parameters

$hWnd | Handle to the control
$iColor | New background color. Specify the CLR_DEFAULT value to cause the status bar to use its default background color.

Return Value

Returns the previous background color, or CLR_DEFAULT if the background color is the default color.

Remarks

Returns RGB COLORREF color, color passed in must be BGR Hex color or RGB COLORREF

StatusBar controls cannot be painted if the "Windows XP style" is used. Some themes also prevent the statusbar from colouring - if the function appears not to work try removing the theme using _WinAPI_SetWindowTheme() with empty strings for the parameters.

Example

#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Set BkColor", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Part 1")
    _GUICtrlStatusBar_SetText($hStatus, "Part 2", 1)

    ; Set background color
    _GUICtrlStatusBar_SetBkColor($hStatus, $CLR_MONEYGREEN)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlStatusBar_SetIcon

Function Reference

_GUICtrlStatusBar_SetIcon

Sets the icon for a part

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_SetIcon ( $hWnd, $iPart [, $hIcon = -1 [, $sIconFile = ""]] )

Parameters

$hWnd | Handle to the control
$iPart | 0-based part index. If the control is in simple mode, this field is ignored.
$hIcon | [optional] Handle to the icon. If this value is -1, the icon is removed.
$sIconFile | [optional] Icon filename to be used.

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlStatusBar_GetIcon

Example

Example 1

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $ahIcons[2], $hStatus
    Local $aParts[4] = [75, 150, 300, 400]

    ; Create GUI
    $hGUI = GUICreate("(Example 1) StatusBar Set Icon", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Part 1")
    _GUICtrlStatusBar_SetText($hStatus, "Part 2", 1)

    ; Set icons
    $ahIcons[0] = _WinAPI_LoadShell32Icon(23)
    $ahIcons[1] = _WinAPI_LoadShell32Icon(40)
    _GUICtrlStatusBar_SetIcon($hStatus, 0, $ahIcons[0])
    _GUICtrlStatusBar_SetIcon($hStatus, 1, $ahIcons[1])

    ; Show icon handles
    MemoWrite("Part 1 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 0)))
    MemoWrite("Part 2 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 1)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    ; Free icons
    _WinAPI_DestroyIcon($ahIcons[0])
    _WinAPI_DestroyIcon($ahIcons[1])
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Example 2

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[4] = [75, 150, 300, 400]

    ; Create GUI
    $hGUI = GUICreate("(Example 2) StatusBar Set Icon", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Part 1")
    _GUICtrlStatusBar_SetText($hStatus, "Part 2", 1)

    ; Set icons
    _GUICtrlStatusBar_SetIcon($hStatus, 0, 23, "shell32.dll")
    _GUICtrlStatusBar_SetIcon($hStatus, 1, 40, "shell32.dll")

    ; Show icon handles
    MemoWrite("Part 1 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 0)))
    MemoWrite("Part 2 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 1)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_SetMinHeight

Function Reference

_GUICtrlStatusBar_SetMinHeight

Sets the minimum height of a status window's drawing area

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_SetMinHeight ( $hWnd, $iMinHeight )

Parameters

$hWnd | Handle to the control
$iMinHeight | Minimum height, in pixels, of the window

Return Value

None.

Related

_GUICtrlStatusBar_GetHeight

Example

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

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Set Min Height", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Part 1")
    _GUICtrlStatusBar_SetText($hStatus, "Part 2", 1)

    ; Set minimum height
    _GUICtrlStatusBar_SetMinHeight($hStatus, 30)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlStatusBar_SetParts

Function Reference

_GUICtrlStatusBar_SetParts

Sets the number of parts and the part edges

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_SetParts ( $hWnd [, $aParts = -1 [, $aPartWidth = 25]] )

Parameters

$hWnd | Handle to the control
$aParts | [optional] Number of parts, can be an 0-based array of ints in the following format: $aParts[0] - Right edge of part #1 $aParts[1] - Right edge of part #2 $aParts[n] - Right edge of part n
$aPartWidth | [optional] Size of parts, can be an 0-based array of ints in the following format: $aPartWidth[0] - width part #1 $aPartWidth[1] - width of part #2 $aPartWidth[n] - width of part n

Return Value

Success: | True.
Failure: | False.

Remarks

If an element is -1, the right edge of the corresponding part extends to the border of the window.

Related

_GUICtrlStatusBar_GetParts

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Set Parts", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set/Get parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    $aParts = _GUICtrlStatusBar_GetParts($hStatus)
    For $iI = 1 To $aParts[0]
        MemoWrite("Part " & $iI & " width .: " & $aParts[$iI])
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_SetSimple

Function Reference

_GUICtrlStatusBar_SetSimple

Specifies whether a status window displays simple text or displays all window parts

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_SetSimple ( $hWnd [, $bSimple = True] )

Parameters

$hWnd | Handle to the control
$bSimple | [optional] Sets the display of the windows True - The window displays simple text False - The window displays multiple parts

Return Value

None.

Related

_GUICtrlStatusBar_IsSimple

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Set Simple", 400, 300)

    $hStatus = _GUICtrlStatusBar_Create($hGUI)
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set simple format
    MemoWrite("Simple mode on .: " & _GUICtrlStatusBar_IsSimple($hStatus))
    Sleep(1000)
    _GUICtrlStatusBar_SetSimple($hStatus, True)
    MemoWrite("Simple mode on .: " & _GUICtrlStatusBar_IsSimple($hStatus))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_SetText

Function Reference

_GUICtrlStatusBar_SetText

Sets the text in the specified part of a status window

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_SetText ( $hWnd [, $sText = "" [, $iPart = 0 [, $iUFlag = 0]]] )

Parameters

$hWnd | Handle to the control
$sText | [optional] The text to display in the part
$iPart | [optional] The part to hold the text
$iUFlag | [optional] Type of drawing operation. The type can be one of the following values: 0 - The text is drawn with a border to appear lower than the plane of the window $SBT_NOBORDERS - The text is drawn without borders $SBT_OWNERDRAW - The text is drawn by the parent window $SBT_POPOUT - The text is drawn with a border to appear higher than the plane of the window $SBT_RTLREADING - The text will be displayed in the opposite direction to the text in the parent window

Return Value

Success: | True.
Failure: | False.

Remarks

Set $iPart to $SB_SIMPLEID for simple statusbar.

Related

_GUICtrlStatusBar_GetText

Example

Example 1

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $ahIcons[2], $hStatus
    Local $aParts[4] = [75, 150, 300, 400]

    ; Create GUI
    $hGUI = GUICreate("(Example 1) StatusBar Set Text", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Part 1")
    _GUICtrlStatusBar_SetText($hStatus, "Part 2", 1)

    ; Set icons
    $ahIcons[0] = _WinAPI_LoadShell32Icon(23)
    $ahIcons[1] = _WinAPI_LoadShell32Icon(40)
    _GUICtrlStatusBar_SetIcon($hStatus, 0, $ahIcons[0])
    _GUICtrlStatusBar_SetIcon($hStatus, 1, $ahIcons[1])

    ; Show part text
    MemoWrite("Part 1 text ........: " & _GUICtrlStatusBar_GetText($hStatus, 0))
    MemoWrite("Part 2 text ........: " & _GUICtrlStatusBar_GetText($hStatus, 1))

    ; Show icon handles
    MemoWrite("Part 1 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 0)))
    MemoWrite("Part 2 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 1)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    ; Free icons
    _WinAPI_DestroyIcon($ahIcons[0])
    _WinAPI_DestroyIcon($ahIcons[1])
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Example 2

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[4] = [75, 150, 300, 400]

    ; Create GUI
    $hGUI = GUICreate("(Example 2) StatusBar Set Text", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Part 1")
    _GUICtrlStatusBar_SetText($hStatus, "Part 2", 1)

    ; Set icons
    _GUICtrlStatusBar_SetIcon($hStatus, 0, 23, "shell32.dll")
    _GUICtrlStatusBar_SetIcon($hStatus, 1, 40, "shell32.dll")

    ; Show part text
    MemoWrite("Part 1 text ........: " & _GUICtrlStatusBar_GetText($hStatus, 0))
    MemoWrite("Part 2 text ........: " & _GUICtrlStatusBar_GetText($hStatus, 1))

    ; Show icon handles
    MemoWrite("Part 1 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 0)))
    MemoWrite("Part 2 icon handle .: 0x" & Hex(_GUICtrlStatusBar_GetIcon($hStatus, 1)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_SetTipText

Function Reference

_GUICtrlStatusBar_SetTipText

Sets the ToolTip text for a part

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_SetTipText ( $hWnd, $iPart, $sText )

Parameters

$hWnd | Handle to the control
$iPart | 0-based part index
$sText | Text of Tip

Return Value

None.

Remarks

The status bar must have been created with the $SBARS_TOOLTIPS style to enable ToolTips.

Related

_GUICtrlStatusBar_GetTipText

Example

Example 1

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hIcon, $hStatus
    Local $aParts[4] = [75, 150, 300, 400]

    ; Create GUI
    $hGUI = GUICreate("(Example 1) StatusBar Set Tip Text", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI, -1, "", $SBARS_TOOLTIPS)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Force tip to be shown when text is more than fits in the box", 1)

    ; Set icon
    $hIcon = _WinAPI_LoadShell32Icon(23)
    _GUICtrlStatusBar_SetIcon($hStatus, 0, $hIcon)

    ; Set text tips
    _GUICtrlStatusBar_SetTipText($hStatus, 0, "Tip works when only icon in part or text exceeds part")
    _GUICtrlStatusBar_SetTipText($hStatus, 1, "Force tip to be shown when text is more than fits in the box")

    MemoWrite("Hold Mouse Cursor over part to see tip." & @CRLF)

    ; Show text tips
    MemoWrite("Text tip 1 .: " & _GUICtrlStatusBar_GetTipText($hStatus, 0) & @CRLF)
    MemoWrite("Text tip 2 .: " & _GUICtrlStatusBar_GetTipText($hStatus, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    ; Free icons
    _WinAPI_DestroyIcon($hIcon)
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Example 2

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[4] = [75, 150, 300, 400]

    ; Create GUI
    $hGUI = GUICreate("(Example 2) StatusBar Set Tip Text", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI, -1, "", $SBARS_TOOLTIPS)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set parts
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)
    _GUICtrlStatusBar_SetText($hStatus, "Force tip to be shown when text is more than fits in the box", 1)

    ; Set icon
    _GUICtrlStatusBar_SetIcon($hStatus, 0, 23, "shell32.dll")

    ; Set text tips
    _GUICtrlStatusBar_SetTipText($hStatus, 0, "Tip works when only icon in part or text exceeds part")
    _GUICtrlStatusBar_SetTipText($hStatus, 1, "Force tip to be shown when text is more than fits in the box")

    MemoWrite("Hold Mouse Cursor over part to see tip." & @CRLF)

    ; Show text tips
    MemoWrite("Text tip 1 .: " & _GUICtrlStatusBar_GetTipText($hStatus, 0) & @CRLF)
    MemoWrite("Text tip 2 .: " & _GUICtrlStatusBar_GetTipText($hStatus, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_SetUnicodeFormat

Function Reference

_GUICtrlStatusBar_SetUnicodeFormat

Sets the Unicode character format flag

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_SetUnicodeFormat ( $hWnd [, $bUnicode = True] )

Parameters

$hWnd | Handle to the control
$bUnicode | [optional] Unicode character format flag: True - Control uses Unicode characters False - Control uses ANSI characters

Return Value

Returns the previous character format flag setting.

Related

_GUICtrlStatusBar_GetUnicodeFormat

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hStatus

    ; Create GUI
    $hGUI = GUICreate("StatusBar Set Unicode Format", 400, 300)
    $hStatus = _GUICtrlStatusBar_Create($hGUI)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 274, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get/Set Unicode format
    MemoWrite("Unicode format .: " & _GUICtrlStatusBar_GetUnicodeFormat($hStatus))
    _GUICtrlStatusBar_SetUnicodeFormat($hStatus, False)
    MemoWrite("Unicode format .: " & _GUICtrlStatusBar_GetUnicodeFormat($hStatus))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlStatusBar_ShowHide

Function Reference

_GUICtrlStatusBar_ShowHide

Show/Hide the StatusBar control

#include <GuiStatusBar.au3>
_GUICtrlStatusBar_ShowHide ( $hWnd, $iState )

Parameters

$hWnd | Handle to the control
$iState | State of the StatusBar, can be the following values: @SW_SHOW @SW_HIDE

Return Value

True: | the control was previously visible.
False: | the control was previously hidden.

Example

#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hStatus
    Local $aParts[3] = [75, 150, -1]

    ; Create GUI
    $hGUI = GUICreate("StatusBar Show/Hide", 400, 300)

    ; defaults to 1 part, no text
    $hStatus = _GUICtrlStatusBar_Create($hGUI)
    _GUICtrlStatusBar_SetParts($hStatus, $aParts)

    GUISetState(@SW_SHOW)

    _GUICtrlStatusBar_ShowHide($hStatus, @SW_HIDE)
    MsgBox($MB_SYSTEMMODAL, "Information", "Hide StatusBar")
    Sleep(1000)

    _GUICtrlStatusBar_ShowHide($hStatus, @SW_SHOW)
    MsgBox($MB_SYSTEMMODAL, "Information", "Show StatusBar")
    Sleep(1000)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


User Defined Functions

GuiTab user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiTab.au3>.

User Defined Function | Description
_GUICtrlTab_ActivateTab | Activates a tab by its index
_GUICtrlTab_ClickTab | Clicks a tab
_GUICtrlTab_Create | Create a TabControl control
_GUICtrlTab_DeleteAllItems | Deletes all tabs
_GUICtrlTab_DeleteItem | Deletes a tab
_GUICtrlTab_DeselectAll | Resets tabs, clearing any that were set to the pressed state
_GUICtrlTab_Destroy | Delete the control
_GUICtrlTab_FindTab | Searches for a tab with the specific text
_GUICtrlTab_GetCurFocus | Returns the index of the item that has the focus in a tab control
_GUICtrlTab_GetCurSel | Determines the currently selected tab
_GUICtrlTab_GetDisplayRect | Retrieves the display rectangle of the client area
_GUICtrlTab_GetDisplayRectEx | Retrieves the display rectangle of the client area
_GUICtrlTab_GetExtendedStyle | Retrieves the extended styles that are currently in use
_GUICtrlTab_GetImageList | Retrieves the tab control image list
_GUICtrlTab_GetItem | Retrieves information about a tab
_GUICtrlTab_GetItemCount | Retrieves the number of tabs
_GUICtrlTab_GetItemImage | Retrieves the image index for a tab
_GUICtrlTab_GetItemParam | Retrieves the param data for a tab
_GUICtrlTab_GetItemRect | Retrieves the bounding rectangle for a tab
_GUICtrlTab_GetItemRectEx | Retrieves the bounding rectangle for a tab
_GUICtrlTab_GetItemState | Retrieves the state of a tab
_GUICtrlTab_GetItemText | Retrieves the text of a tab
_GUICtrlTab_GetRowCount | Retrieves the current number of rows of tabs
_GUICtrlTab_GetToolTips | Retrieves the handle to the ToolTip control associated with the control
_GUICtrlTab_GetUnicodeFormat | Retrieves the Unicode character format flag for the control
_GUICtrlTab_HighlightItem | Sets the highlight state of a tab item
_GUICtrlTab_HitTest | Determines where a point lies control
_GUICtrlTab_InsertItem | Inserts a new tab
_GUICtrlTab_RemoveImage | Removes an image from the control's image list
_GUICtrlTab_SetCurFocus | Sets the focus to a specified tab
_GUICtrlTab_SetCurSel | Selects a tab
_GUICtrlTab_SetExtendedStyle | Sets the extended styles that are currently in use
_GUICtrlTab_SetImageList | Sets the image list associated with a tab control
_GUICtrlTab_SetItem | Sets information about a tab
_GUICtrlTab_SetItemImage | Sets the image of a tab
_GUICtrlTab_SetItemParam | Sets the param data of a tab
_GUICtrlTab_SetItemSize | Sets the width and height of tabs in a fixed width or owner drawn control
_GUICtrlTab_SetItemState | Sets the state of a tab
_GUICtrlTab_SetItemText | Sets the text of a tab
_GUICtrlTab_SetMinTabWidth | Sets the minimum width of items in a tab control
_GUICtrlTab_SetPadding | Sets the amount of space around each tab's icon and label
_GUICtrlTab_SetToolTips | Sets the handle to the ToolTip control associated with the control
_GUICtrlTab_SetUnicodeFormat | Sets the Unicode character format flag for the control


Function _GUICtrlTab_ActivateTab

Function Reference

_GUICtrlTab_ActivateTab

Activates a tab by its index

#include <GuiTab.au3>
_GUICtrlTab_ActivateTab ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Specifies the 0-based index of the item

Return Value

Success: | the index of the previously selected tab.
Failure: | -1.


Function _GUICtrlTab_ClickTab

Function Reference

_GUICtrlTab_ClickTab

Clicks a tab

#include <GuiTab.au3>
_GUICtrlTab_ClickTab ( $hWnd, $iIndex [, $sButton = "left" [, $bMove = False [, $iClicks = 1 [, $iSpeed = 1]]]] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Specifies the 0-based index of the item
$sButton | [optional] Button to click with
$bMove | [optional] If True, the mouse will be moved. If False, the mouse does not move.
$iClicks | [optional] Number of clicks
$iSpeed | [optional] Mouse movement speed

Return Value

None.

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Click Tab", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Click Tab
    _GUICtrlTab_ClickTab($idTab, 1, "left", True, 100)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_Create

Function Reference

_GUICtrlTab_Create

Create a TabControl control

#include <GuiTab.au3>
_GUICtrlTab_Create ( $hWnd, $iX, $iY [, $iWidth = 150 [, $iHeight = 150 [, $iStyle = 0x00000040 [, $iExStyle = 0x00000000]]]] )

Parameters

$hWnd | Handle to parent or owner window
$iX | Horizontal position of the control
$iY | Vertical position of the control
$iWidth | [optional] Control width
$iHeight | [optional] Control height
$iStyle [optional] Control styles:
$TCS_BOTTOM - Tabs appear at the bottom of the control
$TCS_BUTTONS - Tabs appear as buttons, and no border is drawn around the display area
$TCS_FIXEDWIDTH - All tabs are the same width
$TCS_FLATBUTTONS - Selected tabs appear as being indented into the background while other tabs appear as being on the same plane as the background.
This only affects tab controls with the $TCS_BUTTONS style.
$TCS_FOCUSNEVER - The control does not receive the input focus when clicked
$TCS_FOCUSONBUTTONDOWN - The control receives the input focus when clicked
$TCS_FORCEICONLEFT - Icons are aligned with the left edge of each fixed width tab.
This style can only be used with the $TCS_FIXEDWIDTH style.
$TCS_FORCELABELLEFT - Labels are aligned on the left edge of each fixed width tab.
The label is displayed immediately to the right of the icon instead of being centered.
This style can only be used with the
$TCS_FIXEDWIDTH style and it implies the $TCS_FORCEICONLEFT style.
$TCS_HOTTRACK - Items under the pointer are automatically highlighted.
You can check whether or not hot tracking is enabled by calling SystemParametersInfo.
$TCS_MULTILINE - Multiple rows of tabs are displayed, if necessary, so all tabs are visible at once
$TCS_MULTISELECT - Multiple tabs can be selected by holding down the CTRL key when clicking.
This style must be used with the $TCS_BUTTONS style.
$TCS_OWNERDRAWFIXED - The parent window is responsible for drawing tabs
$TCS_RAGGEDRIGHT - Rows of tabs will not be stretched to fill the entire width of the control.
This style is the default.
$TCS_RIGHT - Tabs appear vertically on the right side of controls that use the $TCS_VERTICAL style.
This value equals $TCS_BOTTOM. This style is not supported if you use visual styles.
$TCS_RIGHTJUSTIFY - The width of each tab is increased, if necessary, so that each row of tabs fills the entire width of the tab control.
This style is ignored unless the $TCS_MULTILINE style is also specified.
$TCS_SCROLLOPPOSITE - Unneeded tabs scroll to the opposite side of the control when a tab is selected
$TCS_SINGLELINE - Only one row of tabs is displayed. The user can scroll to see more tabs, if necessary.
This style is the default.
$TCS_TABS - Tabs appear as tabs, and a border is drawn around the display area.
This style is the default.
$TCS_TOOLTIPS - The tab control has a ToolTip control associated with it
$TCS_VERTICAL - Tabs appear at the left side of the control with tab text displayed vertically.
This style is valid only when used with the $TCS_MULTILINE style.
To make tabs appear on the right side of the control, also use the $TCS_RIGHT style.

Default: $TCS_HOTTRACK
Forced: $WS_CHILD, $WS_CLIPSIBLINGS, $WS_VISIBLE
$iExStyle [optional] Control extended styles:
$TCS_EX_FLATSEPARATORS - The control will draw separators between the tab items
$TCS_EX_REGISTERDROP - The control generates $TCN_GETOBJECT notification messages to request a drop target object when an object is dragged over the tab items.

Return Value

Success: | Handle to the control
Failure: | 0

Remarks

This function is for Advanced users and for learning how the control works.

Related

_GUICtrlTab_Destroy

Example

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

Global $g_hTab

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("(UDF Created) Tab Control Create", 400, 300)
    $g_hTab = _GUICtrlTab_Create($hGUI, 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Add tabs
    _GUICtrlTab_InsertItem($g_hTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($g_hTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($g_hTab, 2, "Tab 3")
    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTab
    $hWndTab = $g_hTab
    If Not IsHWnd($g_hTab) Then $hWndTab = GUICtrlGetHandle($g_hTab)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndTab
            Switch $iCode
                Case $NM_CLICK ; The user has clicked the left mouse button within the control
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; The return value is ignored by the tab control
                Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return 1 ; nonzero to not allow the default processing
                    Return 0 ; zero to allow the default processing
                Case $NM_RCLICK ; The user has clicked the right mouse button within the control
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return 1 ; nonzero to not allow the default processing
                    Return 0 ; zero to allow the default processing
                Case $NM_RDBLCLK ; The user has double-clicked the right mouse button within the control
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return 1 ; nonzero to not allow the default processing
                    Return 0 ; zero to allow the default processing
                Case $NM_RELEASEDCAPTURE ; control is releasing mouse capture
                    _DebugPrint("$NM_RELEASEDCAPTURE" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlTab_DeleteAllItems

Function Reference

_GUICtrlTab_DeleteAllItems

Deletes all tabs

#include <GuiTab.au3>
_GUICtrlTab_DeleteAllItems ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Remarks

This does not delete the controls on the tabitems.

Related

_GUICtrlTab_DeleteItem

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Delete All Items", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Delete all tabs
    MsgBox($MB_SYSTEMMODAL, "Information", "Deleting all tabs")
    _GUICtrlTab_DeleteAllItems($idTab)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_DeleteItem

Function Reference

_GUICtrlTab_DeleteItem

Deletes a tab

#include <GuiTab.au3>
_GUICtrlTab_DeleteItem ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the item

Return Value

Success: | True.
Failure: | False.

Remarks

This does not delete the controls on the tabitems.

Related

_GUICtrlTab_DeleteAllItems

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Delete Item", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Delete last tabs
    MsgBox($MB_SYSTEMMODAL, "Information", "Deleting last tab")
    _GUICtrlTab_DeleteItem($idTab, 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_DeselectAll

Function Reference

_GUICtrlTab_DeselectAll

Resets tabs, clearing any that were set to the pressed state

#include <GuiTab.au3>
_GUICtrlTab_DeselectAll ( $hWnd [, $bExclude = True] )

Parameters

$hWnd | Control ID/Handle to the control
$bExclude | [optional] Exclusion flag: True - All tabs except for the one currently selected will be reset False - All tab items will be reset

Return Value

None.

Remarks

This only works if $TCS_BUTTONS style flag has been set.

Related

_GUICtrlTab_SetCurSel

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Deselect All", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296, $TCS_BUTTONS)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Select 2nd Tab Item
    _GUICtrlTab_SetCurSel($idTab, 1)

    ; Reset tab selection
    MsgBox($MB_SYSTEMMODAL, "Information", "Resetting tab selection")
    _GUICtrlTab_DeselectAll($idTab, False)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_Destroy

Function Reference

_GUICtrlTab_Destroy

Delete the control

#include <GuiTab.au3>
_GUICtrlTab_Destroy ( ByRef $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True, $hWnd is set to 0.
Failure: | False.

Remarks

Restricted to only be used on Tab controls created with _GUICtrlTab_Create().

Related

_GUICtrlTab_Create

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hTab

    ; Create GUI
    $hGUI = GUICreate("(UDF Created) Tab Control Destroy", 400, 300)
    $hTab = _GUICtrlTab_Create($hGUI, 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($hTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($hTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($hTab, 2, "Tab 3")

    MsgBox($MB_SYSTEMMODAL, "Information", "Destroy Tab Control")
    _GUICtrlTab_Destroy($hTab)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_FindTab

Function Reference

_GUICtrlTab_FindTab

Searches for a tab with the specific text

#include <GuiTab.au3>
_GUICtrlTab_FindTab ( $hWnd, $sText [, $bInStr = False [, $iStart = 0]] )

Parameters

$hWnd | Control ID/Handle to the control
$sText | Text to search for
$bInStr | [optional] If True, the text can be anywhere in the tab's text.
$iStart | [optional] 0-based index of the tab to start searching from

Return Value

Success: | the 0-based tab index that matches the search.
Failure: | -1.

Remarks

The search is case insensitive.

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Find Tab", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Search for "Tab 2"
    MsgBox($MB_SYSTEMMODAL, "Information", '"Tab 2" at index ' & _GUICtrlTab_FindTab($idTab, "Tab 2"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_GetCurFocus

Function Reference

_GUICtrlTab_GetCurFocus

Returns the index of the item that has the focus in a tab control

#include <GuiTab.au3>
_GUICtrlTab_GetCurFocus ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the 0-based index of the tab item that has the focus.
Failure: | -1.

Remarks

The item that has the focus may be different than the selected item.

Related

_GUICtrlTab_SetCurFocus

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Get Current Focus", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get/Set current focus
    _GUICtrlTab_SetCurFocus($idTab, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Current Focus: " & _GUICtrlTab_GetCurFocus($idTab))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_GetCurSel

Function Reference

_GUICtrlTab_GetCurSel

Determines the currently selected tab

#include <GuiTab.au3>
_GUICtrlTab_GetCurSel ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the 0-based index of the selected tab.
Failure: | -1.

Related

_GUICtrlTab_SetCurSel

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Get Current Selected", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get/Set current selection
    _GUICtrlTab_SetCurSel($idTab, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Current Selection: " & _GUICtrlTab_GetCurSel($idTab))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_GetDisplayRect

Function Reference

_GUICtrlTab_GetDisplayRect

Retrieves the display rectangle of the client area

#include <GuiTab.au3>
_GUICtrlTab_GetDisplayRect ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns an array with the following format:
[0] = X coordinate of the upper left corner of the rectangle
[1] = Y coordinate of the upper left corner of the rectangle
[2] = X coordinate of the lower right corner of the rectangle
[3] = Y coordinate of the lower right corner of the rectangle

Remarks

Use this function to obtain the coordinates, in pixels, of the portion of the tab control that represents the contents of the tab pages.
The appearance of this portion of the tab control does not change when different tabs are selected.

Related

_GUICtrlTab_GetDisplayRectEx

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aRect, $sRect, $idTab

    ; Create GUI
    GUICreate("Tab Control Get Display Rect", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get display rectangle
    $aRect = _GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($idTab))
    $sRect = StringFormat("[%d, %d, %d, %d]", $aRect[0], $aRect[1], $aRect[2], $aRect[3])
    MsgBox($MB_SYSTEMMODAL, "Information", "Display rectangle: " & $sRect)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_GetDisplayRectEx

Function Reference

_GUICtrlTab_GetDisplayRectEx

Retrieves the display rectangle of the client area

#include <GuiTab.au3>
_GUICtrlTab_GetDisplayRectEx ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns a $tagRECT structure that receives the rectangle of the tab, in viewport coordinates.

Remarks

Use this function to obtain the coordinates, in pixels, of the portion of the tab control that represents the contents of the tab pages.
The appearance of this portion of the tab control does not change when different tabs are selected.

Related

$tagRECT, _GUICtrlTab_GetDisplayRect

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $tRECT, $sRect, $idTab

    ; Create GUI
    GUICreate("Tab Control Get Display RectEx", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get display rectangle
    $tRECT = _GUICtrlTab_GetDisplayRectEx(GUICtrlGetHandle($idTab))
    $sRect = StringFormat("[%d, %d, %d, %d]", DllStructGetData($tRECT, "Left"), _
            DllStructGetData($tRECT, "Top"), _
            DllStructGetData($tRECT, "Right"), _
            DllStructGetData($tRECT, "Bottom"))
    MsgBox($MB_SYSTEMMODAL, "Information", "Display rectangle: " & $sRect)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_GetExtendedStyle

Function Reference

_GUICtrlTab_GetExtendedStyle

Retrieves the extended styles that are currently in use

#include <GuiTab.au3>
_GUICtrlTab_GetExtendedStyle ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the extended styles currently in use:
$TCS_EX_FLATSEPARATORS - The control will draw separators between the tab items
$TCS_EX_REGISTERDROP - The control generates $TCN_GETOBJECT notification messages to request a drop target object when an object is dragged over the tab items.

Related

_GUICtrlTab_SetExtendedStyle

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Get Extended Style", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296, BitOR($TCS_BUTTONS, $TCS_FLATBUTTONS))
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get/Set extended styles
    _GUICtrlTab_SetExtendedStyle($idTab, $TCS_EX_FLATSEPARATORS)
    MsgBox($MB_SYSTEMMODAL, "Information", "Extended styles: 0x" & Hex(_GUICtrlTab_GetExtendedStyle($idTab)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_GetImageList

Function Reference

_GUICtrlTab_GetImageList

Retrieves the tab control image list

#include <GuiTab.au3>
_GUICtrlTab_GetImageList ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the handle to the image list.
Failure: | 0.

Related

_GUICtrlTab_SetImageList

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hTab

    ; Create GUI
    $hGUI = GUICreate("Tab Control Get Image List", 400, 300)
    $hTab = _GUICtrlTab_Create($hGUI, 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Create images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 16, 16))
    _GUICtrlTab_SetImageList($hTab, $hImage)

    ; Add tabs
    _GUICtrlTab_InsertItem($hTab, 0, "Tab 1", 0)
    _GUICtrlTab_InsertItem($hTab, 1, "Tab 2", 1)
    _GUICtrlTab_InsertItem($hTab, 2, "Tab 3", 2)

    ; Show image list handle
    MsgBox($MB_SYSTEMMODAL, "Information", "Image list handle: 0x" & Hex(_GUICtrlTab_GetImageList($hTab)) & @CRLF & _
            "IsPtr = " & IsPtr(_GUICtrlTab_GetImageList($hTab)) & " IsHWnd = " & IsHWnd(_GUICtrlTab_GetImageList($hTab)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_GetItem

Function Reference

_GUICtrlTab_GetItem

Retrieves information about a tab

#include <GuiTab.au3>
_GUICtrlTab_GetItem ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index

Return Value

Returns an array with the following format:
[0] - Item state flags:
$TCIS_BUTTONPRESSED - The tab control item is selected
$TCIS_HIGHLIGHTED - The tab control item is highlighted
[1] - Item text
[2] - 0-based item image index or -1 if item has no image
[3] - Application-defined data

Related

_GUICtrlTab_SetItem

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $aItem, $idTab, $hImage, $idTab0

    ; Create GUI
    GUICreate("Tab Control Get Item", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Create images
    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
    _GUICtrlTab_SetImageList($idTab, $hImage)

    ; Add tabs
    $idTab0 = GUICtrlCreateTabItem("Tab 0")
    $g_idMemo = GUICtrlCreateEdit("", 4, 28, 390, 265)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUICtrlCreateTabItem("")
    GUICtrlCreateTabItem("Tab 1")
    GUICtrlCreateTabItem("")
    GUICtrlCreateTabItem("Tab 2")
    GUICtrlCreateTabItem("")
    GUICtrlSetState($idTab0, $GUI_SHOW)

    ; Get/Set tab 0
    _GUICtrlTab_SetItem($idTab, 0, "New Text", BitOR($TCIS_BUTTONPRESSED, $TCIS_BUTTONPRESSED), 2)
    _GUICtrlTab_SetItem($idTab, 1, -1, -1, 4)
    _GUICtrlTab_SetItem($idTab, 2, -1, -1, 5)
    GUISetState(@SW_LOCK)
    For $x = 0 To 2
        $aItem = _GUICtrlTab_GetItem($idTab, $x)
        MemoWrite("Tab Item " & $x & @CRLF & "---------------------")
        For $y = 0 To 3
            MemoWrite("$aItem[" & $y & "]: " & $aItem[$y])
        Next
        MemoWrite(@CRLF & "---------------------")
    Next
    GUISetState(@SW_UNLOCK)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlTab_GetItemCount

Function Reference

_GUICtrlTab_GetItemCount

Retrieves the number of tabs

#include <GuiTab.au3>
_GUICtrlTab_GetItemCount ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the number of tabs.

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Get Item Count", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Show number of tabs
    MsgBox($MB_SYSTEMMODAL, "Information", "Number of tabs: " & _GUICtrlTab_GetItemCount($idTab))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_GetItemImage

Function Reference

_GUICtrlTab_GetItemImage

Retrieves the image index for a tab

#include <GuiTab.au3>
_GUICtrlTab_GetItemImage ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index

Return Value

Returns the 0-based image index of the tab.

Related

_GUICtrlTab_SetItemImage

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $idTab

    ; Create GUI
    $hGUI = GUICreate("Tab Control Get Item Image", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Create images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 16, 16))
    _GUICtrlTab_SetImageList($idTab, $hImage)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get/Set tab 2 image
    _GUICtrlTab_SetItemImage($idTab, 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Tab 2 image index: " & _GUICtrlTab_GetItemImage($idTab, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_GetItemParam

Function Reference

_GUICtrlTab_GetItemParam

Retrieves the param data for a tab

#include <GuiTab.au3>
_GUICtrlTab_GetItemParam ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index

Return Value

Returns the tab param data.

Related

_GUICtrlTab_SetItemParam

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

; Warning do not use SetItemParam on items created with GUICtrlCreateTabItem
; Param is the controlID for items created with built-in functions

Example()

Func Example()
    Local $hGUI, $hTab

    ; Create GUI
    $hGUI = GUICreate("(UDF Created) Tab Control Get Item Param", 400, 300)
    $hTab = _GUICtrlTab_Create($hGUI, 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($hTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($hTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($hTab, 2, "Tab 3")

    ; Get/Set tab 1 parameter
    _GUICtrlTab_SetItemParam($hTab, 0, 1234)
    MsgBox($MB_SYSTEMMODAL, "Information", "Tab 1 parameter: " & _GUICtrlTab_GetItemParam($hTab, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_GetItemRect

Function Reference

_GUICtrlTab_GetItemRect

Retrieves the bounding rectangle for a tab

#include <GuiTab.au3>
_GUICtrlTab_GetItemRect ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index

Return Value

Returns an array with the following format:
[0] = X coordinate of the upper left corner of the rectangle
[1] = Y coordinate of the upper left corner of the rectangle
[2] = X coordinate of the lower right corner of the rectangle
[3] = Y coordinate of the lower right corner of the rectangle

Related

_GUICtrlTab_GetItemRectEx

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aRect, $sRect, $idTab

    ; Create GUI
    GUICreate("Tab Control Get Item Rect", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get tab 0 rectangle
    $aRect = _GUICtrlTab_GetItemRect($idTab, 0)
    $sRect = StringFormat("[%d, %d, %d, %d]", $aRect[0], $aRect[1], $aRect[2], $aRect[3])
    MsgBox($MB_SYSTEMMODAL, "Information", "Tab 0 rectangle: " & $sRect)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_GetItemRectEx

Function Reference

_GUICtrlTab_GetItemRectEx

Retrieves the bounding rectangle for a tab

#include <GuiTab.au3>
_GUICtrlTab_GetItemRectEx ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index

Return Value

Returns a $tagRECT structure that receives the rectangle of the tab, in viewport coordinates.

Related

$tagRECT, _GUICtrlTab_GetItemRect

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $tRECT, $sRect, $idTab

    ; Create GUI
    GUICreate("Tab Control Get Item RectEx", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get item 0 rectangle
    $tRECT = _GUICtrlTab_GetItemRectEx($idTab, 0)
    $sRect = StringFormat("[%d, %d, %d, %d]", DllStructGetData($tRECT, "Left"), _
            DllStructGetData($tRECT, "Top"), _
            DllStructGetData($tRECT, "Right"), _
            DllStructGetData($tRECT, "Bottom"))
    MsgBox($MB_SYSTEMMODAL, "Information", "Display rectangle: " & $sRect)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_GetItemState

Function Reference

_GUICtrlTab_GetItemState

Retrieves the state of a tab

#include <GuiTab.au3>
_GUICtrlTab_GetItemState ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index

Return Value

Returns an Integer with the following tab states:
$TCIS_BUTTONPRESSED - The tab control item is selected
$TCIS_HIGHLIGHTED - The tab control item is highlighted

Related

_GUICtrlTab_SetItemState

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Get Item State", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296, $TCS_BUTTONS)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get/Set tab 2 state
    _GUICtrlTab_SetItemState($idTab, 1, $TCIS_BUTTONPRESSED)
    MsgBox($MB_SYSTEMMODAL, "Information", "Tab 2 state: " & _ExplainItemState(_GUICtrlTab_GetItemState($idTab, 1)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _ExplainItemState($iState)
    Local $sText = ""
    If $iState = 0 Then $sText &= "No state set on this item" & @CRLF
    If BitAND($iState, $TCIS_BUTTONPRESSED) Then $sText &= "Button Pressed" & @CRLF
    If BitAND($iState, $TCIS_HIGHLIGHTED) Then $sText &= "Button Highlighted"
    Return $sText
EndFunc   ;==>_ExplainItemState


Function _GUICtrlTab_GetItemText

Function Reference

_GUICtrlTab_GetItemText

Retrieves the text of a tab

#include <GuiTab.au3>
_GUICtrlTab_GetItemText ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index

Return Value

Returns the tab text.

Related

_GUICtrlTab_SetItemText

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Get Item Text", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get/Set tab 1 text
    _GUICtrlTab_SetItemText($idTab, 0, "New Text")
    MsgBox($MB_SYSTEMMODAL, "Information", "Tab 1 text: " & _GUICtrlTab_GetItemText($idTab, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_GetRowCount

Function Reference

_GUICtrlTab_GetRowCount

Retrieves the current number of rows of tabs

#include <GuiTab.au3>
_GUICtrlTab_GetRowCount ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the number of rows of tabs.

Remarks

Only tab controls that have the $TCS_MULTILINE style can have multiple rows of tabs.

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Get Row Count", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296, $TCS_MULTILINE)
    GUISetState(@SW_SHOW)

    ; Add tabs
    For $x = 0 To 10
        _GUICtrlTab_InsertItem($idTab, $x, "Tab " & $x + 1)
    Next

    ; Get row count
    MsgBox($MB_SYSTEMMODAL, "Information", "Row count: " & _GUICtrlTab_GetRowCount($idTab))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_GetToolTips

Function Reference

_GUICtrlTab_GetToolTips

Retrieves the handle to the ToolTip control associated with the control

#include <GuiTab.au3>
_GUICtrlTab_GetToolTips ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the handle to the ToolTip control.
Failure: | 0.

Related

_GUICtrlTab_SetToolTips

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <GuiToolTip.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI, $hTool, $hTab

    ; Create GUI
    $hGUI = GUICreate("Tab Control Get Tool Tips", 400, 300)
    $hTab = _GUICtrlTab_Create($hGUI, 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($hTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($hTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($hTab, 2, "Tab 3")

    ; Get/Set tooltip
    $hTool = _GUIToolTip_Create($hTab)
    _GUICtrlTab_SetToolTips($hTab, $hTool)

    MsgBox($MB_SYSTEMMODAL, "Information", "ToolTip handle: 0x" & _GUICtrlTab_GetToolTips($hTab) & @CRLF & _
            "IsPtr = " & IsPtr(_GUICtrlTab_GetToolTips($hTab)) & " IsHWnd = " & IsHWnd(_GUICtrlTab_GetToolTips($hTab)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_GetUnicodeFormat

Function Reference

_GUICtrlTab_GetUnicodeFormat

Retrieves the Unicode character format flag for the control

#include <GuiTab.au3>
_GUICtrlTab_GetUnicodeFormat ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

True: | using Unicode characters.
False: | using ANSI characters.

Related

_GUICtrlTab_SetUnicodeFormat

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $bFormat, $idTab

    ; Create GUI
    GUICreate("Tab Control Get Unicode Format", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get/Set Unicode format
    $bFormat = _GUICtrlTab_GetUnicodeFormat($idTab)
    MsgBox($MB_SYSTEMMODAL, "Information", "Unicode format: " & $bFormat)
    _GUICtrlTab_SetUnicodeFormat($idTab, Not $bFormat)
    MsgBox($MB_SYSTEMMODAL, "Information", "Unicode format: " & _GUICtrlTab_GetUnicodeFormat($idTab))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_HighlightItem

Function Reference

_GUICtrlTab_HighlightItem

Sets the highlight state of a tab item

#include <GuiTab.au3>
_GUICtrlTab_HighlightItem ( $hWnd, $iIndex [, $bHighlight = True] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index
$bHighlight | [optional] If True, the tab is highlighted, otherwise the tab is reset

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTab_SetCurSel

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Get Highlight Item", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296, $TCS_BUTTONS)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Highlight tab 2
    _GUICtrlTab_HighlightItem($idTab, 1)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_HitTest

Function Reference

_GUICtrlTab_HitTest

Determines where a point lies control

#include <GuiTab.au3>
_GUICtrlTab_HitTest ( $hWnd, $iX, $iY )

Parameters

$hWnd | Control ID/Handle to the control
$iX | X position to test
$iY | Y position to test

Return Value

Returns an array with the following format:
[0] - 0-based index of the tab, or -1 if no tab is at the position
[1] - Results of the hit test:
1 - The position is not over a tab
2 - The position is over a tab's icon
4 - The position is over a tab's text

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aHit, $idTab

    ; Create GUI
    GUICreate("Tab Control HitTest", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Do a hit test
    $aHit = _GUICtrlTab_HitTest($idTab, 80, 10)
    MsgBox($MB_SYSTEMMODAL, "Information", "Point [80,10] is over tab " & $aHit[0])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_InsertItem

Function Reference

_GUICtrlTab_InsertItem

Inserts a new tab

#include <GuiTab.au3>
_GUICtrlTab_InsertItem ( $hWnd, $iIndex, $sText [, $iImage = -1 [, $iParam = 0]] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | Index of the new tab
$sText | Tab text
$iImage | [optional] 0-based tab image index
$iParam | [optional] Application defined data

Return Value

Success: | the 0-based index of the new tab.
Failure: | -1.

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Insert Item", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_RemoveImage

Function Reference

_GUICtrlTab_RemoveImage

Removes an image from the control's image list

#include <GuiTab.au3>
_GUICtrlTab_RemoveImage ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based index of the image to remove

Return Value

None.

Remarks

The tab control updates each tab's image index, so each tab remains associated with the same image as before.
If a tab is using the image being removed, the tab will be set to have no image.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $idTab

    ; Create GUI
    $hGUI = GUICreate("Tab Control Remove Image", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Create images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 16, 16))
    _GUICtrlTab_SetImageList($idTab, $hImage)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1", 0)
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2", 1)
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3", 2)

    ; Remove second image
    MsgBox($MB_SYSTEMMODAL, "Information", "Removing second image in list")
    _GUICtrlTab_RemoveImage($idTab, 1)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_SetCurFocus

Function Reference

_GUICtrlTab_SetCurFocus

Sets the focus to a specified tab

#include <GuiTab.au3>
_GUICtrlTab_SetCurFocus ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index

Return Value

None.

Remarks

If the tab control has the $TCS_BUTTONS style (button mode), the tab with the focus may be different from the selected tab.
For example, when a tab is selected, the user can press the arrow keys to set the focus to a different tab without changing the selected tab.
In button mode, $TCM_SETCURFOCUS sets the input focus to the button associated with the specified tab, but it does not change the selected tab.

If the tab control does not have the $TCS_BUTTONS style, changing the focus also changes the selected tab.

Related

_GUICtrlTab_GetCurFocus

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Set Current Focus", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get/Set current focus
    _GUICtrlTab_SetCurFocus($idTab, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Current Focus: " & _GUICtrlTab_GetCurFocus($idTab))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_SetCurSel

Function Reference

_GUICtrlTab_SetCurSel

Selects a tab

#include <GuiTab.au3>
_GUICtrlTab_SetCurSel ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index

Return Value

Success: | the index of the previously selected tab.
Failure: | -1.

Remarks

A tab control does not send a $TCN_SELCHANGING or $TCN_SELCHANGE notification message when a tab is selected using this function.

Related

_GUICtrlTab_DeselectAll, _GUICtrlTab_GetCurSel, _GUICtrlTab_HighlightItem

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Set Current Selected", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get/Set current selection
    _GUICtrlTab_SetCurSel($idTab, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Current Selection: " & _GUICtrlTab_GetCurSel($idTab))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_SetExtendedStyle

Function Reference

_GUICtrlTab_SetExtendedStyle

Sets the extended styles that are currently in use

#include <GuiTab.au3>
_GUICtrlTab_SetExtendedStyle ( $hWnd, $iStyle )

Parameters

$hWnd | Control ID/Handle to the control
$iStyle | Extended styles currently in use: $TCS_EX_FLATSEPARATORS - The control will draw separators between the tab items $TCS_EX_REGISTERDROP - The control generates TCN_GETOBJECT notification messages to request a drop target object when an object is dragged over the tab items.

Return Value

Returns the previous extended styles.

Related

_GUICtrlTab_GetExtendedStyle

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Set Extended Style", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296, BitOR($TCS_BUTTONS, $TCS_FLATBUTTONS))
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get/Set extended styles
    _GUICtrlTab_SetExtendedStyle($idTab, $TCS_EX_FLATSEPARATORS)
    MsgBox($MB_SYSTEMMODAL, "Information", "Extended styles: 0x" & Hex(_GUICtrlTab_GetExtendedStyle($idTab)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_SetImageList

Function Reference

_GUICtrlTab_SetImageList

Sets the image list associated with a tab control

#include <GuiTab.au3>
_GUICtrlTab_SetImageList ( $hWnd, $hImage )

Parameters

$hWnd | Control ID/Handle to the control
$hImage | Handle to the image list to assign to the tab control

Return Value

Returns the handle to the previous image list.

Related

_GUICtrlTab_GetImageList

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $hTab

    ; Create GUI
    $hGUI = GUICreate("Tab Control Set Image List", 400, 300)
    $hTab = _GUICtrlTab_Create($hGUI, 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Create images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 16, 16))
    $hImage = _GUICtrlTab_SetImageList($hTab, $hImage)

    ; Add tabs
    _GUICtrlTab_InsertItem($hTab, 0, "Tab 1", 0)
    _GUICtrlTab_InsertItem($hTab, 1, "Tab 2", 1)
    _GUICtrlTab_InsertItem($hTab, 2, "Tab 3", 2)

    ; Show image list handle
    MsgBox($MB_SYSTEMMODAL, "Information", "Previous Image list handle: 0x" & Hex($hImage) & @CRLF & _
            "IsPtr = " & IsPtr($hImage) & " IsHWnd = " & IsHWnd($hImage))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_SetItem

Function Reference

_GUICtrlTab_SetItem

Sets information about a tab

#include <GuiTab.au3>
_GUICtrlTab_SetItem ( $hWnd, $iIndex [, $sText = -1 [, $iState = -1 [, $iImage = -1 [, $iParam = -1]]]] )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index
$sText | [optional] Item text
$iState | [optional] Item state
$iImage | [optional] 0-based item image
$iParam | [optional] Application defined data

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTab_GetItem

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $aItem, $idTab

    ; Create GUI
    GUICreate("Tab Control Set Item", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get/Set tab 1 parameter
    _GUICtrlTab_SetItem($idTab, 0, -1, -1, -1, 1234)
    $aItem = _GUICtrlTab_GetItem($idTab, 0)
    MsgBox($MB_SYSTEMMODAL, "Information", "Tab 1 parameter: " & $aItem[3])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_SetItemImage

Function Reference

_GUICtrlTab_SetItemImage

Sets the image of a tab

#include <GuiTab.au3>
_GUICtrlTab_SetItemImage ( $hWnd, $iIndex, $iImage )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index
$iImage | 0-based item image

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTab_GetItemImage

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $idTab

    ; Create GUI
    $hGUI = GUICreate("Tab Control Set Item Image", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Create images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 16, 16))
    _GUICtrlTab_SetImageList($idTab, $hImage)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get/Set tab 2 image
    _GUICtrlTab_SetItemImage($idTab, 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", "Tab 2 image index: " & _GUICtrlTab_GetItemImage($idTab, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_SetItemParam

Function Reference

_GUICtrlTab_SetItemParam

Sets the param data of a tab

#include <GuiTab.au3>
_GUICtrlTab_SetItemParam ( $hWnd, $iIndex, $iParam )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index
$iParam | Application defined data

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTab_GetItemParam

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

; Warning do not use SetItemParam on items created with GUICtrlCreateTabItem
; Param is the controlID for items created with built-in functions

Example()

Func Example()
    Local $hGUI, $hTab

    ; Create GUI
    $hGUI = GUICreate("(UDF Created) Tab Control Set Item Param", 400, 300)
    $hTab = _GUICtrlTab_Create($hGUI, 2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($hTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($hTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($hTab, 2, "Tab 3")

    ; Get/Set tab 1 parameter
    _GUICtrlTab_SetItemParam($hTab, 0, 1234)
    MsgBox($MB_SYSTEMMODAL, "Information", "Tab 1 parameter: " & _GUICtrlTab_GetItemParam($hTab, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_SetItemSize

Function Reference

_GUICtrlTab_SetItemSize

Sets the width and height of tabs in a fixed width or owner drawn control

#include <GuiTab.au3>
_GUICtrlTab_SetItemSize ( $hWnd, $iWidth, $iHeight )

Parameters

$hWnd | Control ID/Handle to the control
$iWidth | New width, in pixels
$iHeight | New height, in pixels

Return Value

Returns the old width and height.
The width is in the low order word of the return value, and the height is in the high-order word.

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Set Item Size", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296, BitOR($TCS_BUTTONS, $TCS_FIXEDWIDTH))
    _GUICtrlTab_SetItemSize($idTab, 70, 40)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_SetItemState

Function Reference

_GUICtrlTab_SetItemState

Sets the state of a tab

#include <GuiTab.au3>
_GUICtrlTab_SetItemState ( $hWnd, $iIndex, $iState )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index
$iState | Item state. Can be a combination of: $TCIS_BUTTONPRESSED - The tab control item is selected $TCIS_HIGHLIGHTED - The tab control item is highlighted

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTab_GetItemState

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Set Item State", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296, $TCS_BUTTONS)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get/Set tab 2 state
    _GUICtrlTab_SetItemState($idTab, 1, $TCIS_BUTTONPRESSED)
    MsgBox($MB_SYSTEMMODAL, "Information", "Tab 2 state: " & _ExplainItemState(_GUICtrlTab_GetItemState($idTab, 1)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _ExplainItemState($iState)
    Local $sText = ""
    If $iState = 0 Then $sText &= "No state set on this item" & @CRLF
    If BitAND($iState, 1) Then $sText &= "Button Pressed" & @CRLF
    If BitAND($iState, 2) Then $sText &= "Button Highlighted"
    Return $sText
EndFunc   ;==>_ExplainItemState


Function _GUICtrlTab_SetItemText

Function Reference

_GUICtrlTab_SetItemText

Sets the text of a tab

#include <GuiTab.au3>
_GUICtrlTab_SetItemText ( $hWnd, $iIndex, $sText )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | 0-based item index
$sText | Item text

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTab_GetItemText

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Set Item Text", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get/Set tab 1 text
    _GUICtrlTab_SetItemText($idTab, 0, "New Text")
    MsgBox($MB_SYSTEMMODAL, "Information", "Tab 1 text: " & _GUICtrlTab_GetItemText($idTab, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_SetMinTabWidth

Function Reference

_GUICtrlTab_SetMinTabWidth

Sets the minimum width of items in a tab control

#include <GuiTab.au3>
_GUICtrlTab_SetMinTabWidth ( $hWnd, $iMinWidth )

Parameters

$hWnd | Control ID/Handle to the control
$iMinWidth | Minimum width to be set for a tab control item. If -1, the control will use the default width.

Return Value

Returns the previous minimum tab width.

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>

Example()

Func Example()
    Local $idTab

    ; Create GUI
    GUICreate("Tab Control Set Min Tab Width", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_SetMinTabWidth($idTab, 80)
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_SetPadding

Function Reference

_GUICtrlTab_SetPadding

Sets the amount of space around each tab's icon and label

#include <GuiTab.au3>
_GUICtrlTab_SetPadding ( $hWnd, $iHorz, $iVert )

Parameters

$hWnd | Control ID/Handle to the control
$iHorz | Amount of horizontal padding, in pixels
$iVert | Amount of vertical padding, in pixels

Return Value

None.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTab.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hGUI, $hImage, $idTab

    ; Create GUI
    $hGUI = GUICreate("Tab Control Set Padding", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Create images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 16, 16))
    _GUICtrlTab_SetImageList($idTab, $hImage)

    ; Add tabs
    _GUICtrlTab_SetPadding($idTab, 20, 4)
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1", 0)
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2", 1)
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3", 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_SetToolTips

Function Reference

_GUICtrlTab_SetToolTips

Sets the handle to the ToolTip control associated with the control

#include <GuiTab.au3>
_GUICtrlTab_SetToolTips ( $hWnd, $hToolTip )

Parameters

$hWnd | Control ID/Handle to the control
$hToolTip | Handle to the ToolTip control

Return Value

None.

Related

_GUICtrlTab_GetToolTips

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <GuiToolTip.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hTool, $idTab

    ; Create GUI
    GUICreate("Tab Control Set Tool Tips", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get/Set tooltip
    $hTool = _GUIToolTip_Create(GUICtrlGetHandle($idTab))
    _GUICtrlTab_SetToolTips($idTab, $hTool)
    MsgBox($MB_SYSTEMMODAL, "Information", "ToolTip handle: 0x" & _GUICtrlTab_GetToolTips($idTab))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTab_SetUnicodeFormat

Function Reference

_GUICtrlTab_SetUnicodeFormat

Sets the Unicode character format flag for the control

#include <GuiTab.au3>
_GUICtrlTab_SetUnicodeFormat ( $hWnd, $bUnicode )

Parameters

$hWnd | Control ID/Handle to the control
$bUnicode | Unicode character flag: True - Control uses Unicode characters False - Control uses ANSI characters

Return Value

Returns the previous character format flag setting.

Related

_GUICtrlTab_GetUnicodeFormat

Example

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $bFormat, $idTab

    ; Create GUI
    GUICreate("Tab Control Set Unicode Format", 400, 300)
    $idTab = GUICtrlCreateTab(2, 2, 396, 296)
    GUISetState(@SW_SHOW)

    ; Add tabs
    _GUICtrlTab_InsertItem($idTab, 0, "Tab 1")
    _GUICtrlTab_InsertItem($idTab, 1, "Tab 2")
    _GUICtrlTab_InsertItem($idTab, 2, "Tab 3")

    ; Get/Set Unicode format
    $bFormat = _GUICtrlTab_GetUnicodeFormat($idTab)
    MsgBox($MB_SYSTEMMODAL, "Information", "Unicode format: " & $bFormat)
    _GUICtrlTab_SetUnicodeFormat($idTab, Not $bFormat)
    MsgBox($MB_SYSTEMMODAL, "Information", "Unicode format: " & _GUICtrlTab_GetUnicodeFormat($idTab))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


User Defined Functions

GuiToolbar user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiToolbar.au3>.

User Defined Function | Description
_GUICtrlToolbar_AddBitmap | Adds images to the image list
_GUICtrlToolbar_AddButton | Adds a button
_GUICtrlToolbar_AddButtonSep | Adds a separator
_GUICtrlToolbar_AddString | Adds a new string to the toolbar's string pool
_GUICtrlToolbar_ButtonCount | Retrieves a count of the buttons
_GUICtrlToolbar_CheckButton | Checks or unchecks a given button
_GUICtrlToolbar_ClickAccel | Clicks a specific button using it's accelerator
_GUICtrlToolbar_ClickButton | Clicks a specific button
_GUICtrlToolbar_ClickIndex | Clicks a specific button using it's index
_GUICtrlToolbar_CommandToIndex | Retrieves the index for the button associated with the specified command identifier
_GUICtrlToolbar_Create | Create a Toolbar control
_GUICtrlToolbar_Customize | Displays the Customize Toolbar dialog box
_GUICtrlToolbar_DeleteButton | Deletes a button from the toolbar
_GUICtrlToolbar_Destroy | Delete the control
_GUICtrlToolbar_EnableButton | Enables or disables the specified button
_GUICtrlToolbar_FindToolbar | Finds a specific toolbar
_GUICtrlToolbar_GetAnchorHighlight | Retrieves the anchor highlight setting
_GUICtrlToolbar_GetBitmapFlags | Retrieves the flags that describe the type of bitmap to be used
_GUICtrlToolbar_GetButtonBitmap | Retrieves the index of the bitmap associated with a button
_GUICtrlToolbar_GetButtonInfo | Retrieves information for a button
_GUICtrlToolbar_GetButtonInfoEx | Retrieves extended information for a button
_GUICtrlToolbar_GetButtonParam | Retrieves the button param value
_GUICtrlToolbar_GetButtonRect | Retrieves the bounding rectangle for a button
_GUICtrlToolbar_GetButtonRectEx | Retrieves the bounding rectangle for a specified toolbar button
_GUICtrlToolbar_GetButtonSize | Retrieves the current button width and height, in pixels
_GUICtrlToolbar_GetButtonState | Retrieves information about the state of the specified button
_GUICtrlToolbar_GetButtonStyle | Retrieves the style flags of a button
_GUICtrlToolbar_GetButtonText | Retrieves the display text of a button
_GUICtrlToolbar_GetColorScheme | Retrieves the color scheme information
_GUICtrlToolbar_GetDisabledImageList | Retrieves the disabled button image list
_GUICtrlToolbar_GetExtendedStyle | Retrieves the extended styles
_GUICtrlToolbar_GetHotImageList | Retrieves the hot button image list
_GUICtrlToolbar_GetHotItem | Retrieves the index of the hot item
_GUICtrlToolbar_GetImageList | Retrieves the default state image list
_GUICtrlToolbar_GetInsertMark | Retrieves the current insertion mark
_GUICtrlToolbar_GetInsertMarkColor | Retrieves the color used to draw the insertion mark
_GUICtrlToolbar_GetMaxSize | Retrieves the total size of all of the visible buttons and separators
_GUICtrlToolbar_GetMetrics | Retrieves the metrics of a toolbar control
_GUICtrlToolbar_GetPadding | Retrieves the horizontal and vertical padding
_GUICtrlToolbar_GetRows | Retrieves the number of rows of buttons
_GUICtrlToolbar_GetString | Retrieves a string from the string pool
_GUICtrlToolbar_GetStyle | Retrieves the styles currently in use for a toolbar control
_GUICtrlToolbar_GetStyleAltDrag | Indicates that the control allows buttons to be dragged
_GUICtrlToolbar_GetStyleCustomErase | Indicates that the control generates NM_CUSTOMDRAW notification messages
_GUICtrlToolbar_GetStyleFlat | Indicates that the control is flat
_GUICtrlToolbar_GetStyleList | Indicates that the control has button text to the right of the bitmap
_GUICtrlToolbar_GetStyleRegisterDrop | Indicates that the control generates TBN_GETOBJECT notification messages
_GUICtrlToolbar_GetStyleToolTips | Indicates that the control has tooltips
_GUICtrlToolbar_GetStyleTransparent | Indicates that the control is transparent
_GUICtrlToolbar_GetStyleWrapable | Indicates that the control is wrapable
_GUICtrlToolbar_GetTextRows | Retrieves the maximum number of text rows that can be displayed on a button
_GUICtrlToolbar_GetToolTips | Retrieves the handle to the ToolTip control
_GUICtrlToolbar_GetUnicodeFormat | Retrieves the Unicode character format flag
_GUICtrlToolbar_HideButton | Hides or shows the specified button
_GUICtrlToolbar_HighlightButton | Sets the highlight state of a given button control
_GUICtrlToolbar_HitTest | Determines where a point lies within the control
_GUICtrlToolbar_IndexToCommand | Retrieves the command identifier associated with the button
_GUICtrlToolbar_InsertButton | Inserts a button
_GUICtrlToolbar_InsertMarkHitTest | Retrieves the insertion mark information for a point
_GUICtrlToolbar_IsButtonChecked | Indicates whether the specified button is checked
_GUICtrlToolbar_IsButtonEnabled | Indicates whether the specified button is enabled
_GUICtrlToolbar_IsButtonHidden | Indicates whether the specified button is hidden
_GUICtrlToolbar_IsButtonHighlighted | Indicates whether the specified button is hilighted
_GUICtrlToolbar_IsButtonIndeterminate | Indicates whether the specified button is indeterminate
_GUICtrlToolbar_IsButtonPressed | Indicates that the button is being clicked
_GUICtrlToolbar_LoadBitmap | Adds a bitmap to the image list from a file
_GUICtrlToolbar_LoadImages | Loads system defined button images into a toolbar control's image list
_GUICtrlToolbar_MapAccelerator | Determines the ID of the button that corresponds to the specified accelerator
_GUICtrlToolbar_MoveButton | Moves a button from one index to another
_GUICtrlToolbar_PressButton | Presses or releases the specified button
_GUICtrlToolbar_SetAnchorHighlight | Sets the anchor highlight setting
_GUICtrlToolbar_SetBitmapSize | Sets the size of the bitmapped images to be added to a toolbar
_GUICtrlToolbar_SetButtonBitMap | Sets the index of the bitmap associated with a button
_GUICtrlToolbar_SetButtonInfo | Sets information for a button
_GUICtrlToolbar_SetButtonInfoEx | Sets extended information for a button
_GUICtrlToolbar_SetButtonParam | Sets the button param value
_GUICtrlToolbar_SetButtonSize | Sets the size of the buttons to be added to a toolbar
_GUICtrlToolbar_SetButtonState | Sets information about the state of the specified button
_GUICtrlToolbar_SetButtonStyle | Sets the style flags of a button
_GUICtrlToolbar_SetButtonText | Sets the display text of a button
_GUICtrlToolbar_SetButtonWidth | Sets the minimum and maximum button widths in the toolbar control
_GUICtrlToolbar_SetCmdID | Sets the command identifier of a toolbar button
_GUICtrlToolbar_SetColorScheme | Sets the color scheme information
_GUICtrlToolbar_SetDisabledImageList | Sets the disabled image list
_GUICtrlToolbar_SetDrawTextFlags | Sets the text drawing flags for the toolbar
_GUICtrlToolbar_SetExtendedStyle | Sets the extended styles control
_GUICtrlToolbar_SetHotImageList | Sets the hot button image list
_GUICtrlToolbar_SetHotItem | Sets the hot item
_GUICtrlToolbar_SetImageList | Sets the default button image list
_GUICtrlToolbar_SetIndent | Sets the indentation for the first button control
_GUICtrlToolbar_SetIndeterminate | Sets or clears the indeterminate state of the specified button
_GUICtrlToolbar_SetInsertMark | Sets the current insertion mark for the toolbar
_GUICtrlToolbar_SetInsertMarkColor | Sets the color used to draw the insertion mark
_GUICtrlToolbar_SetMaxTextRows | Sets the maximum number of text rows displayed button
_GUICtrlToolbar_SetMetrics | Sets the metrics of a toolbar control
_GUICtrlToolbar_SetPadding | Sets the padding control
_GUICtrlToolbar_SetParent | Sets the window to which the control sends notification messages
_GUICtrlToolbar_SetRows | Sets the number of rows of buttons
_GUICtrlToolbar_SetStyle | Sets the style control
_GUICtrlToolbar_SetStyleAltDrag | Sets whether that the control allows buttons to be dragged
_GUICtrlToolbar_SetStyleCustomErase | Sets whether the control generates NM_CUSTOMDRAW notification messages
_GUICtrlToolbar_SetStyleFlat | Sets whether the control is flat
_GUICtrlToolbar_SetStyleList | Sets whether the control has button text to the right of the bitmap
_GUICtrlToolbar_SetStyleRegisterDrop | Sets whether the control generates TBN_GETOBJECT notification messages
_GUICtrlToolbar_SetStyleToolTips | Sets whether the control has tooltips
_GUICtrlToolbar_SetStyleTransparent | Sets whether the control is transparent
_GUICtrlToolbar_SetStyleWrapable | Sets whether the control is wrapable
_GUICtrlToolbar_SetToolTips | Associates a ToolTip control with a toolbar
_GUICtrlToolbar_SetUnicodeFormat | Sets the Unicode character format flag
_GUICtrlToolbar_SetWindowTheme | Sets the visual style


Function _GUICtrlToolbar_AddBitmap

Function Reference

_GUICtrlToolbar_AddBitmap

Adds images to the image list

#include <GuiToolbar.au3>
_GUICtrlToolbar_AddBitmap ( $hWnd, $iButtons, $hInst, $iID )

Parameters

$hWnd | Handle to the control
$iButtons | Number of button images in the bitmap
$hInst | Handle to the module instance with the executable file that contains a bitmap resource. To use bitmap handles instead of resource IDs, set this to 0. You can add system defined button bitmaps to the list by specifying -1 as the $hInst member and one of the following values as the $iID member: $IDB_STD_LARGE_COLOR - Adds large, color standard bitmaps $IDB_STD_SMALL_COLOR - Adds small, color standard bitmaps $IDB_VIEW_LARGE_COLOR - Adds large, color view bitmaps $IDB_VIEW_SMALL_COLOR - Adds small, color view bitmaps
$iID | If $hInst is 0, set this member to the bitmap handle of the bitmap with the button images. Otherwise, set it to the resource identifier of the bitmap with the button images. The following are resource IDs to the standard and view bitmaps: $STD_COPY - Copy image $STD_CUT - Cut image $STD_DELETE - Delete image $STD_FILENEW - New file image $STD_FILEOPEN - Open file image $STD_FILESAVE - Save file image $STD_FIND - Find image $STD_HELP - Help image $STD_PASTE - Paste image $STD_PRINT - Print image $STD_PRINTPRE - Print preview image $STD_PROPERTIES - Properties image $STD_REDOW - Redo image $STD_REPLACE - Replace image $STD_UNDO - Undo image $VIEW_DETAILS - View details image $VIEW_LARGEICONS - View large icons image $VIEW_LIST - View list image $VIEW_SMALLICONS - View small icons image. $VIEW_SORTDATE - Sort by date image. $VIEW_SORTNAME - Sort by name image. $VIEW_SORTSIZE - Sort by size image. $VIEW_SORTTYPE - Sort by type image.

Return Value

Success: | the 0-based index of the first new image.
Failure: | -1.

Related

_GUICtrlToolbar_LoadBitmap

Example

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

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_AddButton

Function Reference

_GUICtrlToolbar_AddButton

Adds a button

#include <GuiToolbar.au3>
_GUICtrlToolbar_AddButton ( $hWnd, $iID, $iImage [, $iString = 0 [, $iStyle = 0 [, $iState = 4 [, $iParam = 0]]]] )

Parameters

$hWnd | Handle to the control
$iID | Command ID
$iImage | 0-based index of the button image. Set this parameter to -1 and the control will send the $TBN_GETDISPINFO notification to retrieve the image index when it is needed. Set this to -2 to indicate that the button does not have an image. The button layout will only include space for the text. If the button is a separator, this is the width of the separator, in pixels.
$iString | [optional] 0-based index of the button string that was set with AddString
$iStyle | [optional] Button style. Can be a combination of the following: $BTNS_AUTOSIZE - The toolbar control should not assign the standard width to the button $BTNS_BUTTON - Standard button (Default) $BTNS_CHECK - Toggles between the pressed and nonpressed $BTNS_CHECKGROUP - Button that stays pressed until another button in the group is pressed $BTNS_DROPDOWN - Creates a drop-down style button that can display a list $BTNS_GROUP - Button that stays pressed until another button in the group is pressed $BTNS_NOPREFIX - The button text will not have an accelerator prefix $BTNS_SEP - Creates a separator $BTNS_SHOWTEXT - Specifies that button text should be displayed $BTNS_WHOLEDROPDOWN - Specifies that the button will have a drop-down arrow
$iState | [optional] Button state. Can be a combination of the following: $TBSTATE_CHECKED - The button has the $TBSTYLE_CHECK style and is being clicked $TBSTATE_PRESSED - The button is being clicked $TBSTATE_ENABLED - The button accepts user input $TBSTATE_HIDDEN - The button is not visible and cannot receive user input $TBSTATE_INDETERMINATE - The button is grayed $TBSTATE_WRAP - The button is followed by a line break $TBSTATE_ELLIPSES - The button's text is cut off and an ellipsis is displayed $TBSTATE_MARKED - The button is marked
$iParam | [optional] Application-defined value

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlToolbar_DeleteButton, _GUICtrlToolbar_InsertButton

Example

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

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_AddButtonSep

Function Reference

_GUICtrlToolbar_AddButtonSep

Adds a separator

#include <GuiToolbar.au3>
_GUICtrlToolbar_AddButtonSep ( $hWnd [, $iWidth = 6] )

Parameters

$hWnd | Handle to toolbar
$iWidth | [optional] Separator width

Return Value

None.

Example

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

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_AddString

Function Reference

_GUICtrlToolbar_AddString

Adds a new string to the toolbar's string pool

#include <GuiToolbar.au3>
_GUICtrlToolbar_AddString ( $hWnd, $sString )

Parameters

$hWnd | Handle to the control
$sString | String to add

Return Value

Success: | 0-based index of the new string.
Failure: | -1.

Related

_GUICtrlToolbar_GetString

Example

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

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_ButtonCount

Function Reference

_GUICtrlToolbar_ButtonCount

Retrieves a count of the buttons

#include <GuiToolbar.au3>
_GUICtrlToolbar_ButtonCount ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns the number of buttons on toolbar.

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Show button count
    MsgBox($MB_SYSTEMMODAL, "Information", "There are " & _GUICtrlToolbar_ButtonCount($hToolbar) & " buttons")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_CheckButton

Function Reference

_GUICtrlToolbar_CheckButton

Checks or unchecks a given button

#include <GuiToolbar.au3>
_GUICtrlToolbar_CheckButton ( $hWnd, $iCommandID [, $bCheck = True] )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID
$bCheck | [optional] Check state: True - Button will be checked False - Button will be unchecked

Return Value

Success: | True.
Failure: | False.

Remarks

When a button is checked, it is displayed in the pressed state

Example

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

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Check Save button
    _GUICtrlToolbar_CheckButton($hToolbar, $e_idSave)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_ClickAccel

Function Reference

_GUICtrlToolbar_ClickAccel

Clicks a specific button using it's accelerator

#include <GuiToolbar.au3>
_GUICtrlToolbar_ClickAccel ( $hWnd, $sAccelKey [, $sButton = "left" [, $bMove = False [, $iClicks = 1 [, $iSpeed = 1]]]] )

Parameters

$hWnd | Handle to the control
$sAccelKey | Button accelerator
$sButton | [optional] Button to click
$bMove | [optional] Mouse movement flag: True - Mouse will be moved False - Mouse will not be moved
$iClicks | [optional] Number of clicks
$iSpeed | [optional] Mouse movement speed

Return Value

None.

Related

_GUICtrlToolbar_ClickButton, _GUICtrlToolbar_ClickIndex

Example

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

Global $g_hToolbar, $g_idMemo
Global $g_iItem ; Command identifier of the button associated with the notification.
Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp

Example()

Func Example()
    Local $hGUI, $aSize, $aStrings[4]

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 600, 400)
    $g_hToolbar = _GUICtrlToolbar_Create($hGUI)
    $aSize = _GUICtrlToolbar_GetMaxSize($g_hToolbar)

    $g_idMemo = GUICtrlCreateEdit("", 2, $aSize[1] + 30, 596, 396 - ($aSize[1] + 30), $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)
    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap($g_hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($g_hToolbar, "&New")
    $aStrings[1] = _GUICtrlToolbar_AddString($g_hToolbar, "&Open")
    $aStrings[2] = _GUICtrlToolbar_AddString($g_hToolbar, "&Save")
    $aStrings[3] = _GUICtrlToolbar_AddString($g_hToolbar, "&Help")

    ; Add buttons
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($g_hToolbar)
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idHelp, $STD_HELP, $aStrings[3])

    ; Click Save button using accelerator
    _GUICtrlToolbar_ClickAccel($g_hToolbar, "s", "left", True)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; WM_NOTIFY event handler
Func _WM_NOTIFY($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $hWndGUI, $iMsgID, $wParam
    Local $tNMHDR, $hWndFrom, $iCode, $iNew, $iFlags, $iOld
    Local $tNMTBHOTITEM
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hToolbar
            Switch $iCode
                Case $NM_LDOWN
                    ;----------------------------------------------------------------------------------------------
                    MemoWrite("$NM_LDOWN: Clicked Item: " & $g_iItem & " at index: " & _GUICtrlToolbar_CommandToIndex($g_hToolbar, $g_iItem))
                    ;----------------------------------------------------------------------------------------------
                Case $TBN_HOTITEMCHANGE
                    $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam)
                    $iOld = DllStructGetData($tNMTBHOTITEM, "idOld")
                    $iNew = DllStructGetData($tNMTBHOTITEM, "idNew")
                    $g_iItem = $iNew
                    $iFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags")
                    If BitAND($iFlags, $HICF_LEAVING) = $HICF_LEAVING Then
                        MemoWrite("$HICF_LEAVING: " & $iOld)
                    Else
                        Switch $iNew
                            Case $e_idNew
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $e_idNew")
                                ;----------------------------------------------------------------------------------------------
                            Case $e_idOpen
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $e_idOpen")
                                ;----------------------------------------------------------------------------------------------
                            Case $e_idSave
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $e_idSave")
                                ;----------------------------------------------------------------------------------------------
                            Case $e_idHelp
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $idHelp")
                                ;----------------------------------------------------------------------------------------------
                        EndSwitch
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY


Function _GUICtrlToolbar_ClickButton

Function Reference

_GUICtrlToolbar_ClickButton

Clicks a specific button

#include <GuiToolbar.au3>
_GUICtrlToolbar_ClickButton ( $hWnd, $iCommandID [, $sButton = "left" [, $bMove = False [, $iClicks = 1 [, $iSpeed = 1]]]] )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID
$sButton | [optional] Button to click
$bMove | [optional] Mouse movement flag: True - Mouse will be moved False - Mouse will not be moved
$iClicks | [optional] Number of clicks
$iSpeed | [optional] Mouse movement speed

Return Value

None.

Related

_GUICtrlToolbar_ClickAccel, _GUICtrlToolbar_ClickIndex

Example

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

Global $g_hToolbar, $g_idMemo
Global $g_iItem ; Command identifier of the button associated with the notification.
Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp

Example()

Func Example()
    Local $hGUI, $aSize, $aStrings[4]

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 600, 400)
    $g_hToolbar = _GUICtrlToolbar_Create($hGUI)
    $aSize = _GUICtrlToolbar_GetMaxSize($g_hToolbar)

    $g_idMemo = GUICtrlCreateEdit("", 2, $aSize[1] + 30, 596, 396 - ($aSize[1] + 30), $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)
    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap($g_hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($g_hToolbar, "&New")
    $aStrings[1] = _GUICtrlToolbar_AddString($g_hToolbar, "&Open")
    $aStrings[2] = _GUICtrlToolbar_AddString($g_hToolbar, "&Save")
    $aStrings[3] = _GUICtrlToolbar_AddString($g_hToolbar, "&Help")

    ; Add buttons
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($g_hToolbar)
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idHelp, $STD_HELP, $aStrings[3])

    ; Click Save button using accelerator
    _GUICtrlToolbar_ClickButton($g_hToolbar, $e_idSave, "left", True)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; WM_NOTIFY event handler
Func _WM_NOTIFY($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $hWndGUI, $iMsgID, $wParam
    Local $tNMHDR, $hWndFrom, $iCode, $iNew, $iFlags, $iOld
    Local $tNMTBHOTITEM
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hToolbar
            Switch $iCode
                Case $NM_LDOWN
                    ;----------------------------------------------------------------------------------------------
                    MemoWrite("$NM_LDOWN: Clicked Item: " & $g_iItem & " at index: " & _GUICtrlToolbar_CommandToIndex($g_hToolbar, $g_iItem))
                    ;----------------------------------------------------------------------------------------------
                Case $TBN_HOTITEMCHANGE
                    $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam)
                    $iOld = DllStructGetData($tNMTBHOTITEM, "idOld")
                    $iNew = DllStructGetData($tNMTBHOTITEM, "idNew")
                    $g_iItem = $iNew
                    $iFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags")
                    If BitAND($iFlags, $HICF_LEAVING) = $HICF_LEAVING Then
                        MemoWrite("$HICF_LEAVING: " & $iOld)
                    Else
                        Switch $iNew
                            Case $e_idNew
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $e_idNew")
                                ;----------------------------------------------------------------------------------------------
                            Case $e_idOpen
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $e_idOpen")
                                ;----------------------------------------------------------------------------------------------
                            Case $e_idSave
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $e_idSave")
                                ;----------------------------------------------------------------------------------------------
                            Case $e_idHelp
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $idHelp")
                                ;----------------------------------------------------------------------------------------------
                        EndSwitch
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY


Function _GUICtrlToolbar_ClickIndex

Function Reference

_GUICtrlToolbar_ClickIndex

Clicks a specific button using it's index

#include <GuiToolbar.au3>
_GUICtrlToolbar_ClickIndex ( $hWnd, $iIndex [, $sButton = "left" [, $bMove = False [, $iClicks = 1 [, $iSpeed = 1]]]] )

Parameters

$hWnd | Handle to the control
$iIndex | Button index
$sButton | [optional] Button to click
$bMove | [optional] Mouse movement flag: True - Mouse will be moved False - Mouse will not be moved
$iClicks | [optional] Number of clicks
$iSpeed | [optional] Mouse movement speed

Return Value

None.

Related

_GUICtrlToolbar_ClickAccel, _GUICtrlToolbar_ClickButton

Example

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

Global $g_hToolbar, $g_idMemo
Global $g_iItem ; Command identifier of the button associated with the notification.
Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp

Example()

Func Example()
    Local $hGUI, $aSize, $aStrings[4]

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 600, 400)
    $g_hToolbar = _GUICtrlToolbar_Create($hGUI)
    $aSize = _GUICtrlToolbar_GetMaxSize($g_hToolbar)

    $g_idMemo = GUICtrlCreateEdit("", 2, $aSize[1] + 30, 596, 396 - ($aSize[1] + 30), $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)
    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap($g_hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($g_hToolbar, "&New")
    $aStrings[1] = _GUICtrlToolbar_AddString($g_hToolbar, "&Open")
    $aStrings[2] = _GUICtrlToolbar_AddString($g_hToolbar, "&Save")
    $aStrings[3] = _GUICtrlToolbar_AddString($g_hToolbar, "&Help")

    ; Add buttons
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($g_hToolbar)
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idHelp, $STD_HELP, $aStrings[3])

    ; Click Save button using accelerator
    _GUICtrlToolbar_ClickIndex($g_hToolbar, 2, "left", True)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; WM_NOTIFY event handler
Func _WM_NOTIFY($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $hWndGUI, $iMsgID, $wParam
    Local $tNMHDR, $hWndFrom, $iCode, $iNew, $iFlags, $iOld
    Local $tNMTBHOTITEM
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hToolbar
            Switch $iCode
                Case $NM_LDOWN
                    ;----------------------------------------------------------------------------------------------
                    MemoWrite("$NM_LDOWN: Clicked Item: " & $g_iItem & " at index: " & _GUICtrlToolbar_CommandToIndex($g_hToolbar, $g_iItem))
                    ;----------------------------------------------------------------------------------------------
                Case $TBN_HOTITEMCHANGE
                    $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam)
                    $iOld = DllStructGetData($tNMTBHOTITEM, "idOld")
                    $iNew = DllStructGetData($tNMTBHOTITEM, "idNew")
                    $g_iItem = $iNew
                    $iFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags")
                    If BitAND($iFlags, $HICF_LEAVING) = $HICF_LEAVING Then
                        MemoWrite("$HICF_LEAVING: " & $iOld)
                    Else
                        Switch $iNew
                            Case $e_idNew
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $e_idNew")
                                ;----------------------------------------------------------------------------------------------
                            Case $e_idOpen
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $e_idOpen")
                                ;----------------------------------------------------------------------------------------------
                            Case $e_idSave
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $e_idSave")
                                ;----------------------------------------------------------------------------------------------
                            Case $e_idHelp
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $idHelp")
                                ;----------------------------------------------------------------------------------------------
                        EndSwitch
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY


Function _GUICtrlToolbar_CommandToIndex

Function Reference

_GUICtrlToolbar_CommandToIndex

Retrieves the index for the button associated with the specified command identifier

#include <GuiToolbar.au3>
_GUICtrlToolbar_CommandToIndex ( $hWnd, $iCommandID )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID

Return Value

Success: | 0-based button index.
Failure: | -1.

Related

_GUICtrlToolbar_IndexToCommand

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $iIndex
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Show Save button index
    $iIndex = _GUICtrlToolbar_CommandToIndex($hToolbar, $e_idSave)
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button index .: " & $iIndex)
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button command .: " & _GUICtrlToolbar_IndexToCommand($hToolbar, $iIndex))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_Create

Function Reference

_GUICtrlToolbar_Create

Create a Toolbar control

#include <GuiToolbar.au3>
_GUICtrlToolbar_Create ( $hWnd [, $iStyle = 0x00000800 [, $iExStyle = 0x00000000]] )

Parameters

$hWnd Handle to parent or owner window
$iStyle [optional] Control styles:
$TBSTYLE_ALTDRAG - Allows users to change a toolbar button's position by dragging it while holding down the ALT key.
If this style is not specified, the user must hold down the SHIFT key while dragging a button.
Note that the $CCS_ADJUSTABLE style must be specified to enable toolbar buttons to be dragged.
$TBSTYLE_CUSTOMERASE - Generates $NM_CUSTOMDRAW messages when the toolbar processes $WM_ERASEBKGND messages
$TBSTYLE_FLAT - Creates a flat toolbar
$TBSTYLE_LIST - Creates a flat toolbar with button text to the right of the bitmap
$TBSTYLE_REGISTERDROP - Generates $TBN_GETOBJECT notification messages to request drop target objects when the cursor passes over toolbar buttons.
$TBSTYLE_TOOLTIPS - Creates a ToolTip control that an application can use to display descriptive text for the buttons in the toolbar.
$TBSTYLE_TRANSPARENT - Creates a transparent toolbar. In a transparent toolbar, the toolbar is transparent but the buttons are not.
Button text appears under button bitmaps. To prevent repainting problems, this style should be set before the toolbar control becomes visible.
$TBSTYLE_WRAPABLE - Creates a toolbar that can have multiple lines of buttons.
Toolbar buttons can "wrap" to the next line when the toolbar becomes too narrow to include all buttons on the same line.
When the toolbar is wrapped, the break will occur on either the rightmost separator or the rightmost button if there are no separators on the bar.
This style must be set to display a vertical toolbar control when the toolbar is part of a vertical rebar control.

Default: $TBSTYLE_FLAT
Forced: $WS_CHILD, $WS_CLIPSIBLINGS, $WS_VISIBLE
$iExStyle [optional] Control extended styles:
$TBSTYLE_EX_DRAWDDARROWS - Allows buttons to have a separate dropdown arrow. Buttons that have the
$BTNS_DROPDOWN style will be drawn with a drop down arrow in a separate section, to the right of the button.
If the arrow is clicked, only the arrow portion of the button will depress, and the toolbar control will send a $TBN_DROPDOWN notification to prompt the application to display the dropdown menu.
If the main part of the button is clicked, the toolbar control sends a $WM_COMMAND message with the button's ID.
$TBSTYLE_EX_HIDECLIPPEDBUTTONS - Hides partially clipped buttons
$TBSTYLE_EX_DOUBLEBUFFER - Requires the toolbar to be double buffered
$TBSTYLE_EX_MIXEDBUTTONS - Allows you to set text for all buttons, but only display it for the buttons with the $BTNS_SHOWTEXT button style.
The $TBSTYLE_LIST style must also be set.
Normally, when a button does not display text, you must handle $TBN_GETINFOTIP to display a ToolTip.
With the $TBSTYLE_EX_MIXEDBUTTONS extended style, text that is set but not displayed on a button will automatically be used as the button's ToolTip text.
You only need to handle $TBN_GETINFOTIP if it needs more flexibility in specifying the ToolTip text.

Return Value

Success: | the handle to the Toolbar control.
Failure: | 0.

Related

_GUICtrlToolbar_Destroy

Example

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

Global $g_hToolbar, $g_idMemo
Global $g_iItem ; Command identifier of the button associated with the notification.
Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp

Example()

Func Example()
    Local $hGUI, $aSize

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 600, 400)
    $g_hToolbar = _GUICtrlToolbar_Create($hGUI)
    $aSize = _GUICtrlToolbar_GetMaxSize($g_hToolbar)

    $g_idMemo = GUICtrlCreateEdit("", 2, $aSize[1] + 20, 596, 396 - ($aSize[1] + 20), $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)
    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap($g_hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add buttons
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($g_hToolbar)
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idHelp, $STD_HELP)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; WM_NOTIFY event handler
Func _WM_NOTIFY($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $hWndGUI, $iMsgID, $wParam
    Local $tNMHDR, $hWndFrom, $iCode, $iNew, $iFlags, $iOld
    Local $tNMTBHOTITEM
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hToolbar
            Switch $iCode
                Case $NM_LDOWN
                    ;----------------------------------------------------------------------------------------------
                    MemoWrite("$NM_LDOWN: Clicked Item: " & $g_iItem & " at index: " & _GUICtrlToolbar_CommandToIndex($g_hToolbar, $g_iItem))
                    ;----------------------------------------------------------------------------------------------
                Case $TBN_HOTITEMCHANGE
                    $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam)
                    $iOld = DllStructGetData($tNMTBHOTITEM, "idOld")
                    $iNew = DllStructGetData($tNMTBHOTITEM, "idNew")
                    $g_iItem = $iNew
                    $iFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags")
                    If BitAND($iFlags, $HICF_LEAVING) = $HICF_LEAVING Then
                        MemoWrite("$HICF_LEAVING: " & $iOld)
                    Else
                        Switch $iNew
                            Case $e_idNew
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $e_idNew")
                                ;----------------------------------------------------------------------------------------------
                            Case $e_idOpen
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $e_idOpen")
                                ;----------------------------------------------------------------------------------------------
                            Case $e_idSave
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $e_idSave")
                                ;----------------------------------------------------------------------------------------------
                            Case $e_idHelp
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $idHelp")
                                ;----------------------------------------------------------------------------------------------
                        EndSwitch
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY


Function _GUICtrlToolbar_Customize

Function Reference

_GUICtrlToolbar_Customize

Displays the Customize Toolbar dialog box

#include <GuiToolbar.au3>
_GUICtrlToolbar_Customize ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

None.

Remarks

The toolbar must handle the $TBN_QUERYINSERT and $TBN_QUERYDELETE notifications for the Customize Toolbar dialog box to appear.
If the toolbar does not handle those notifications, $TB_CUSTOMIZE has no effect.


Function _GUICtrlToolbar_DeleteButton

Function Reference

_GUICtrlToolbar_DeleteButton

Deletes a button from the toolbar

#include <GuiToolbar.au3>
_GUICtrlToolbar_DeleteButton ( $hWnd, $iCommandID )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlToolbar_AddButton

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Delete Help button
    MsgBox($MB_SYSTEMMODAL, "Information", "Deleting Help button")
    _GUICtrlToolbar_DeleteButton($hToolbar, $idHelp)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_Destroy

Function Reference

_GUICtrlToolbar_Destroy

Delete the control

#include <GuiToolbar.au3>
_GUICtrlToolbar_Destroy ( ByRef $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | True, $hWnd is set to 0.
Failure: | False.

Remarks

Restricted to only be used on Toolbar controls created with _GUICtrlToolbar_Create()

Related

_GUICtrlToolbar_Create

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Delete ToolBar
    MsgBox($MB_SYSTEMMODAL, "Information", "Destroying ToolBar")
    _GUICtrlToolbar_Destroy($hToolbar)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_EnableButton

Function Reference

_GUICtrlToolbar_EnableButton

Enables or disables the specified button

#include <GuiToolbar.au3>
_GUICtrlToolbar_EnableButton ( $hWnd, $iCommandID [, $bEnable = True] )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID
$bEnable | [optional] Enable flag: True - Button will be enabled False - Button will be disabled

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlToolbar_HideButton

Example

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

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Disable Help button
    _GUICtrlToolbar_EnableButton($hToolbar, $idHelp, False)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_FindToolbar

Function Reference

_GUICtrlToolbar_FindToolbar

Finds a specific toolbar

#include <GuiToolbar.au3>
_GUICtrlToolbar_FindToolbar ( $hWnd, $sText )

Parameters

$hWnd | Window handle or text of window
$sText | Button text to search for

Return Value

Success: | the handle of the toolbar.
Failure: | 0.

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hToolbar

    Run("explorer.exe /root, ,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")
    WinWaitActive("[CLASS:CabinetWClass]")
    Sleep(1000)
    $hToolbar = _GUICtrlToolbar_FindToolbar("[CLASS:CabinetWClass]", "&File")
    MsgBox($MB_SYSTEMMODAL, "Information", "File Toolbar handle: 0x" & Hex($hToolbar))
EndFunc   ;==>Example


Function _GUICtrlToolbar_GetAnchorHighlight

Function Reference

_GUICtrlToolbar_GetAnchorHighlight

Retrieves the anchor highlight setting

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetAnchorHighlight ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

True: | anchor highlighting is enabled.
False: | anchor highlighting is not enabled?

Remarks

Anchor highlighting means that the last highlighted item will remain highlighted until another item is highlighted.
This occurs even if the cursor leaves the toolbar control.

Related

_GUICtrlToolbar_SetAnchorHighlight

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hToolbar, $bEnabled

    Run("explorer.exe /root, ,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")
    WinWaitActive("My Computer")
    Sleep(1000)
    $hToolbar = _GUICtrlToolbar_FindToolbar("[CLASS:CabinetWClass]", "&File")
    $bEnabled = _GUICtrlToolbar_GetAnchorHighlight($hToolbar)
    MsgBox($MB_SYSTEMMODAL, "Information", "Anchor highlight enabled: " & $bEnabled)
    _GUICtrlToolbar_SetAnchorHighlight($hToolbar, Not $bEnabled)
    MsgBox($MB_SYSTEMMODAL, "Information", "Anchor highlight enabled: " & _GUICtrlToolbar_GetAnchorHighlight($hToolbar))
EndFunc   ;==>Example


Function _GUICtrlToolbar_GetBitmapFlags

Function Reference

_GUICtrlToolbar_GetBitmapFlags

Retrieves the flags that describe the type of bitmap to be used

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetBitmapFlags ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns a value that describes the type of bitmap that should be used:
0 - Use small (16 x 16) bitmaps
1 - Use large (24 x 24) bitmaps

Remarks

The value returned is only advisory. The control recommends large or small bitmaps based upon whether the user has chosen large or small fonts.

Example

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

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_GetButtonBitmap

Function Reference

_GUICtrlToolbar_GetButtonBitmap

Retrieves the index of the bitmap associated with a button

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetButtonBitmap ( $hWnd, $iCommandID )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID

Return Value

Returns the 0-based button bitmap index.

Related

_GUICtrlToolbar_SetButtonBitMap

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Show Save button bitmap index
    MsgBox($MB_SYSTEMMODAL, "Information", "Changing Save bitmap to Print bitmap")
    _GUICtrlToolbar_SetButtonBitMap($hToolbar, $e_idSave, $STD_PRINT)
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button bitmap index: " & _GUICtrlToolbar_GetButtonBitmap($hToolbar, $e_idSave))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_GetButtonInfo

Function Reference

_GUICtrlToolbar_GetButtonInfo

Retrieves information for a button

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetButtonInfo ( $hWnd, $iCommandID )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID

Return Value

Returns an array with the following format:
[0] - 0-based button image index
[1] - Button state. Can be a combination of the following:
$TBSTATE_CHECKED - The button has is being clicked
$TBSTATE_PRESSED - The button is being clicked
$TBSTATE_ENABLED - The button accepts user input
$TBSTATE_HIDDEN - The button is not visible
$TBSTATE_INDETERMINATE - The button is grayed
$TBSTATE_WRAP - The button is followed by a line break
$TBSTATE_ELLIPSES - The button's text is cut off
$TBSTATE_MARKED - The button is marked
[2] - Button style. Can be a combination of the following:
$BTNS_AUTOSIZE - The control should not assign the standard width
$BTNS_BUTTON - Standard button
$BTNS_CHECK - Toggles between the pressed and nonpressed
$BTNS_CHECKGROUP - Button that stays pressed until another button is pressed
$BTNS_DROPDOWN - Creates a drop-down style button that can display a list
$BTNS_GROUP - Button that stays pressed until another button is pressed
$BTNS_NOPREFIX - The button text will not have an accelerator prefix
$BTNS_SEP - Creates a separator
$BTNS_SHOWTEXT - Specifies that button text should be displayed
$BTNS_WHOLEDROPDOWN - Specifies that the button will have a drop-down arrow
[3] - Button width
[4] - Button parameter

Related

_GUICtrlToolbar_SetButtonInfo

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aButton
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Set Save button information
    _GUICtrlToolbar_SetButtonInfo($hToolbar, $e_idSave, $STD_PRINT, BitOR($TBSTATE_PRESSED, $TBSTATE_ENABLED), -1, 100, 1234)

    ; Show Save button information
    $aButton = _GUICtrlToolbar_GetButtonInfo($hToolbar, $e_idSave)
    MemoWrite("Image index ....: " & $aButton[0])
    MemoWrite("State flags ....: " & $aButton[1])
    MemoWrite("Style flags ....: " & $aButton[2])
    MemoWrite("Button width ...: " & $aButton[3])
    MemoWrite("Param ..........: " & $aButton[4])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetButtonInfoEx

Function Reference

_GUICtrlToolbar_GetButtonInfoEx

Retrieves extended information for a button

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetButtonInfoEx ( $hWnd, $iCommandID )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID

Return Value

Returns a $tagTBBUTTONINFO structure.

Related

$tagTBBUTTONINFO, _GUICtrlToolbar_SetButtonInfoEx

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $tButton
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Set Save button information
    $tButton = DllStructCreate($tagTBBUTTONINFO)
    DllStructSetData($tButton, "Mask", BitOR($TBIF_IMAGE, $TBIF_STATE, $TBIF_SIZE, $TBIF_LPARAM))
    DllStructSetData($tButton, "State", BitOR($TBSTATE_PRESSED, $TBSTATE_ENABLED))
    DllStructSetData($tButton, "Image", $STD_PRINT)
    DllStructSetData($tButton, "CX", 100)
    DllStructSetData($tButton, "Param", 1234)
    _GUICtrlToolbar_SetButtonInfoEx($hToolbar, $e_idSave, $tButton)

    ; Show Save button information
    $tButton = _GUICtrlToolbar_GetButtonInfoEx($hToolbar, $e_idSave)
    MemoWrite("Image index ....: " & DllStructGetData($tButton, "Image"))
    MemoWrite("State flags ....: " & DllStructGetData($tButton, "State"))
    MemoWrite("Button width ...: " & DllStructGetData($tButton, "CX"))
    MemoWrite("Param ..........: " & DllStructGetData($tButton, "Param"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetButtonParam

Function Reference

_GUICtrlToolbar_GetButtonParam

Retrieves the button param value

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetButtonParam ( $hWnd, $iCommandID )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID

Return Value

Returns the application-defined value.

Related

_GUICtrlToolbar_SetButtonParam

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Set Save button parameter
    _GUICtrlToolbar_SetButtonParam($hToolbar, $e_idSave, 1234)

    ; Show Save button parameter
    MemoWrite("Save button parameter: " & _GUICtrlToolbar_GetButtonParam($hToolbar, $e_idSave))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetButtonRect

Function Reference

_GUICtrlToolbar_GetButtonRect

Retrieves the bounding rectangle for a button

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetButtonRect ( $hWnd, $iCommandID )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID

Return Value

Returns an array with the following format:
[0] - X coordinate of the upper left corner of the rectangle
[1] - Y coordinate of the upper left corner of the rectangle
[2] - X coordinate of the lower right corner of the rectangle
[3] - Y coordinate of the lower right corner of the rectangle

Related

_GUICtrlToolbar_GetButtonRectEx

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aRect
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Show Save button rectangle
    $aRect = _GUICtrlToolbar_GetButtonRect($hToolbar, $e_idSave)
    MemoWrite("Save Button Rect")
    MemoWrite("----------------")
    MemoWrite("Left ...: " & $aRect[0])
    MemoWrite("Top ....: " & $aRect[1])
    MemoWrite("Right ..: " & $aRect[2])
    MemoWrite("Bottom .: " & $aRect[3])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetButtonRectEx

Function Reference

_GUICtrlToolbar_GetButtonRectEx

Retrieves the bounding rectangle for a specified toolbar button

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetButtonRectEx ( $hWnd, $iCommandID )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID

Return Value

Returns a $tagRECT structure.

Related

$tagRECT, _GUICtrlToolbar_GetButtonRect

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $tRECT
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Show Save button rectangle
    $tRECT = _GUICtrlToolbar_GetButtonRectEx($hToolbar, $e_idSave)
    MemoWrite("Save Button Rect")
    MemoWrite("----------------")
    MemoWrite("Left ...: " & DllStructGetData($tRECT, "Left"))
    MemoWrite("Top ....: " & DllStructGetData($tRECT, "Top"))
    MemoWrite("Right ..: " & DllStructGetData($tRECT, "Right"))
    MemoWrite("Bottom .: " & DllStructGetData($tRECT, "Bottom"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetButtonSize

Function Reference

_GUICtrlToolbar_GetButtonSize

Retrieves the current button width and height, in pixels

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetButtonSize ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns an array with the following format:
[0] - Button height
[1] - Button width

Related

_GUICtrlToolbar_SetButtonSize

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aSize
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Show button size
    $aSize = _GUICtrlToolbar_GetButtonSize($hToolbar)
    MemoWrite("Button height : " & $aSize[0])
    MemoWrite("Button width .: " & $aSize[1])
    _GUICtrlToolbar_SetButtonSize($hToolbar, $aSize[0], $aSize[1] + 10)
    $aSize = _GUICtrlToolbar_GetButtonSize($hToolbar)
    MemoWrite("New Button Size")
    MemoWrite("Button height : " & $aSize[0])
    MemoWrite("Button width .: " & $aSize[1])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetButtonState

Function Reference

_GUICtrlToolbar_GetButtonState

Retrieves information about the state of the specified button

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetButtonState ( $hWnd, $iCommandID )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID

Return Value

Success: | Button state. Can be one or more of the following $TBSTATE_CHECKED - The button has the $TBSTYLE_CHECK style and is being clicked $TBSTATE_PRESSED - The button is being clicked $TBSTATE_ENABLED - The button accepts user input $TBSTATE_HIDDEN - The button is not visible and cannot receive user input $TBSTATE_INDETERMINATE - The button is grayed $TBSTATE_WRAP - The button is followed by a line break $TBSTATE_ELLIPSES - The button's text is cut off and an ellipsis is displayed $TBSTATE_MARKED - The button is marked
Failure: | -1.

Related

_GUICtrlToolbar_SetButtonState

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Show Save button state
    MemoWrite("Save button state: " & _GUICtrlToolbar_GetButtonState($hToolbar, $e_idSave))

    Sleep(1000)

    ; Set Save button state
    _GUICtrlToolbar_SetButtonState($hToolbar, $e_idSave, BitOR($TBSTATE_ENABLED, $TBSTATE_PRESSED))

    ; Show Save button state
    MemoWrite("Save button state: " & _GUICtrlToolbar_GetButtonState($hToolbar, $e_idSave))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetButtonStyle

Function Reference

_GUICtrlToolbar_GetButtonStyle

Retrieves the style flags of a button

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetButtonStyle ( $hWnd, $iCommandID )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID

Return Value

Returns the button style. Can be a combination of the following:
$BTNS_AUTOSIZE - The toolbar control should not assign the standard width to the button
$BTNS_CHECK - Toggles between the pressed and nonpressed
$BTNS_CHECKGROUP - Button that stays pressed until another button in the group is pressed
$BTNS_DROPDOWN - Drop-down style button that can display a list
$BTNS_GROUP - Button that stays pressed until another button in the group is pressed
$BTNS_NOPREFIX - The button text will not have an accelerator prefix
$BTNS_SEP - Separator
$BTNS_SHOWTEXT - Button text should be displayed
$BTNS_WHOLEDROPDOWN - The button has a drop-down arrow

Related

_GUICtrlToolbar_SetButtonStyle

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Set Save button style
    _GUICtrlToolbar_SetButtonStyle($hToolbar, $e_idSave, $BTNS_CHECK)

    ; Show Save button style
    MemoWrite("Save button style: " & _GUICtrlToolbar_GetButtonStyle($hToolbar, $e_idSave))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetButtonText

Function Reference

_GUICtrlToolbar_GetButtonText

Retrieves the display text of a button

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetButtonText ( $hWnd, $iCommandID )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID

Return Value

Returns the button text.

Related

_GUICtrlToolbar_GetString, _GUICtrlToolbar_SetButtonText

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Change Save button text
    _GUICtrlToolbar_SetButtonText($hToolbar, $e_idSave, "&Close")

    ; Show Save button text
    MemoWrite("Save button text: " & _GUICtrlToolbar_GetButtonText($hToolbar, $e_idSave))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetColorScheme

Function Reference

_GUICtrlToolbar_GetColorScheme

Retrieves the color scheme information

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetColorScheme ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns an array with the following format:
[0] - The highlight color of the buttons
[1] - The shadow color of the buttons

Remarks

The control uses the color scheme information when drawing the 3-D elements in the control.

Related

_GUICtrlToolbar_SetColorScheme

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aScheme
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Change Color Scheme
    _GUICtrlToolbar_SetColorScheme($hToolbar, 0x00ffff, 0x800000)

    ; Show Color Scheme
    $aScheme = _GUICtrlToolbar_GetColorScheme($hToolbar)
    MemoWrite("Highlight: " & '0x' & Hex($aScheme[0], 6))
    MemoWrite("Shadow: " & '0x' & Hex($aScheme[1], 6))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetDisabledImageList

Function Reference

_GUICtrlToolbar_GetDisabledImageList

Retrieves the disabled button image list

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetDisabledImageList ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the handle to the disabled image list.
Failure: | 0.

Related

_GUICtrlToolbar_SetDisabledImageList

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $hNormal, $hDisabled, $hHot
    Local Enum $idRed = 1000, $idGreen, $idBlue

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    GUISetBkColor(0xffff00)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create normal image list
    $hNormal = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 32, 24))
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 32, 24))
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 32, 24))
    _GUICtrlToolbar_SetImageList($hToolbar, $hNormal)

    ; Create disabled image list
    $hDisabled = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    _GUICtrlToolbar_SetDisabledImageList($hToolbar, $hDisabled)

    ; Create hot image list
    $hHot = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0x111111, 32, 24))
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0x888888, 32, 24))
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0xAAAAAA, 32, 24))
    _GUICtrlToolbar_SetHotImageList($hToolbar, $hHot)

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $idRed, 0)
    _GUICtrlToolbar_AddButton($hToolbar, $idGreen, 1)
    _GUICtrlToolbar_AddButton($hToolbar, $idBlue, 2)

    ; Disable Blue button
    _GUICtrlToolbar_EnableButton($hToolbar, $idBlue, False)

    ; Show image list handles
    MemoWrite("Disabled list handle .: 0x" & Hex(_GUICtrlToolbar_GetDisabledImageList($hToolbar)))
    MemoWrite("IsPtr = " & IsPtr(_GUICtrlToolbar_GetDisabledImageList($hToolbar)) & " IsHWnd = " & IsHWnd(_GUICtrlToolbar_GetDisabledImageList($hToolbar)))
    MemoWrite("Hot list handle ......: 0x" & Hex(_GUICtrlToolbar_GetHotImageList($hToolbar)))
    MemoWrite("Normal list handle ...: 0x" & Hex(_GUICtrlToolbar_GetImageList($hToolbar)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetExtendedStyle

Function Reference

_GUICtrlToolbar_GetExtendedStyle

Retrieves the extended styles

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetExtendedStyle ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns the control extended styles. Can be one or more of the following:
$TBSTYLE_EX_DRAWDDARROWS - Allows buttons to have a separate dropdown arrow
$TBSTYLE_EX_MIXEDBUTTONS - Allows mixing buttons with text and images
$TBSTYLE_EX_HIDECLIPPEDBUTTONS - Hides partially clipped buttons
$TBSTYLE_EX_DOUBLEBUFFER - Requires the toolbar to be double buffered

Related

_GUICtrlToolbar_SetExtendedStyle

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_hGUI, $g_idMemo

Example()

Func Example()
    Local $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $g_hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($g_hGUI)
    _GUICtrlToolbar_SetExtendedStyle($hToolbar, $TBSTYLE_EX_DRAWDDARROWS)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, 0, $BTNS_DROPDOWN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Show extended styles in use
    MemoWrite("Extended sytles: " & _GUICtrlToolbar_GetExtendedStyle($hToolbar))

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Handle TBN_DROPDOWN message
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $tNMHDR, $iCode, $hMenu

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $iCode = DllStructGetData($tNMHDR, "Code")

    If $iCode = $TBN_DROPDOWN Then
        $hMenu = _GUICtrlMenu_CreatePopup()
        _GUICtrlMenu_AddMenuItem($hMenu, "Template 1", 2000)
        _GUICtrlMenu_AddMenuItem($hMenu, "Template 2", 2001)
        _GUICtrlMenu_AddMenuItem($hMenu, "Template 3", 2002)
        _GUICtrlMenu_TrackPopupMenu($hMenu, $g_hGUI)
        _GUICtrlMenu_DestroyMenu($hMenu)
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY


Function _GUICtrlToolbar_GetHotImageList

Function Reference

_GUICtrlToolbar_GetHotImageList

Retrieves the hot button image list

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetHotImageList ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the handle to the hot image list.
Failure: | 0.

Remarks

A button is considered hot when the cursor is over it.

Related

_GUICtrlToolbar_SetHotImageList

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $hNormal, $hDisabled, $hHot
    Local Enum $idRed = 1000, $idGreen, $idBlue

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    GUISetBkColor(0xffff00)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create normal image list
    $hNormal = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 32, 24))
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 32, 24))
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 32, 24))
    _GUICtrlToolbar_SetImageList($hToolbar, $hNormal)

    ; Create disabled image list
    $hDisabled = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    _GUICtrlToolbar_SetDisabledImageList($hToolbar, $hDisabled)

    ; Create hot image list
    $hHot = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0x111111, 32, 24))
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0x888888, 32, 24))
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0xAAAAAA, 32, 24))
    _GUICtrlToolbar_SetHotImageList($hToolbar, $hHot)

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $idRed, 0)
    _GUICtrlToolbar_AddButton($hToolbar, $idGreen, 1)
    _GUICtrlToolbar_AddButton($hToolbar, $idBlue, 2)

    ; Disable Blue button
    _GUICtrlToolbar_EnableButton($hToolbar, $idBlue, False)

    ; Show image list handles
    MemoWrite("Disabled list handle .: 0x" & Hex(_GUICtrlToolbar_GetDisabledImageList($hToolbar)))
    MemoWrite("Hot list handle ......: 0x" & Hex(_GUICtrlToolbar_GetHotImageList($hToolbar)))
    MemoWrite("IsPtr = " & IsPtr(_GUICtrlToolbar_GetHotImageList($hToolbar)) & " IsHWnd = " & IsHWnd(_GUICtrlToolbar_GetHotImageList($hToolbar)))
    MemoWrite("Normal list handle ...: 0x" & Hex(_GUICtrlToolbar_GetImageList($hToolbar)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetHotItem

Function Reference

_GUICtrlToolbar_GetHotItem

Retrieves the index of the hot item

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetHotItem ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the 0-based index of the hot item.
Failure: | -1.

Remarks

A button is considered hot when the cursor is over it.

Related

_GUICtrlToolbar_SetHotItem

Example

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

Global $g_hToolbar, $g_idMemo
Global $g_iItem ; Command identifier of the button associated with the notification.
Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp

Example()

Func Example()
    Local $hGUI, $aSize

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 600, 400)
    $g_hToolbar = _GUICtrlToolbar_Create($hGUI)
    $aSize = _GUICtrlToolbar_GetMaxSize($g_hToolbar)

    $g_idMemo = GUICtrlCreateEdit("", 2, $aSize[1] + 20, 596, 396 - ($aSize[1] + 20), $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)
    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap($g_hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add buttons
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($g_hToolbar)
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idHelp, $STD_HELP)

    ; Gets the hot item
    Local $iHotItem = _GUICtrlToolbar_GetHotItem($g_hToolbar)
    MemoWrite("before $iHotItem= " & $iHotItem)

    ; Sets the hot item
    _GUICtrlToolbar_SetHotItem($g_hToolbar, 2)
    ; Gets the hot item
    $iHotItem = _GUICtrlToolbar_GetHotItem($g_hToolbar)
    MemoWrite("after $iHotItem= " & $iHotItem)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; WM_NOTIFY event handler
Func _WM_NOTIFY($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $hWndGUI, $iMsgID, $wParam
    Local $tNMHDR, $hWndFrom, $iCode, $iNew, $iFlags, $iOld
    Local $tNMTBHOTITEM
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hToolbar
            Switch $iCode
                Case $NM_LDOWN
                    ;----------------------------------------------------------------------------------------------
                    MemoWrite("$NM_LDOWN: Clicked Item: " & $g_iItem & " at index: " & _GUICtrlToolbar_CommandToIndex($g_hToolbar, $g_iItem))
                    ;----------------------------------------------------------------------------------------------
                Case $TBN_HOTITEMCHANGE
                    $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam)
                    $iOld = DllStructGetData($tNMTBHOTITEM, "idOld")
                    $iNew = DllStructGetData($tNMTBHOTITEM, "idNew")
                    $g_iItem = $iNew
                    $iFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags")
                    If BitAND($iFlags, $HICF_LEAVING) = $HICF_LEAVING Then
                        MemoWrite("$HICF_LEAVING: " & $iOld)
                    Else
                        Switch $iNew
                            Case $e_idNew
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $e_idNew")
                                ;----------------------------------------------------------------------------------------------
                            Case $e_idOpen
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $e_idOpen")
                                ;----------------------------------------------------------------------------------------------
                            Case $e_idSave
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $e_idSave")
                                ;----------------------------------------------------------------------------------------------
                            Case $e_idHelp
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $idHelp")
                                ;----------------------------------------------------------------------------------------------
                        EndSwitch
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY


Function _GUICtrlToolbar_GetImageList

Function Reference

_GUICtrlToolbar_GetImageList

Retrieves the default state image list

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetImageList ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the handle to the image list.
Failure: | 0.

Remarks

A toolbar control uses this image list to display buttons when they are not hot or disabled.

Related

_GUICtrlToolbar_SetImageList

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $hNormal, $hDisabled, $hHot
    Local Enum $idRed = 1000, $idGreen, $idBlue

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    GUISetBkColor(0xffff00)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create normal image list
    $hNormal = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 32, 24))
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 32, 24))
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 32, 24))
    _GUICtrlToolbar_SetImageList($hToolbar, $hNormal)

    ; Create disabled image list
    $hDisabled = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    _GUICtrlToolbar_SetDisabledImageList($hToolbar, $hDisabled)

    ; Create hot image list
    $hHot = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0x111111, 32, 24))
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0x888888, 32, 24))
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0xAAAAAA, 32, 24))
    _GUICtrlToolbar_SetHotImageList($hToolbar, $hHot)

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $idRed, 0)
    _GUICtrlToolbar_AddButton($hToolbar, $idGreen, 1)
    _GUICtrlToolbar_AddButton($hToolbar, $idBlue, 2)

    ; Disable Blue button
    _GUICtrlToolbar_EnableButton($hToolbar, $idBlue, False)

    ; Show image list handles
    MemoWrite("Disabled list handle .: 0x" & Hex(_GUICtrlToolbar_GetDisabledImageList($hToolbar)))
    MemoWrite("Hot list handle ......: 0x" & Hex(_GUICtrlToolbar_GetHotImageList($hToolbar)))
    MemoWrite("Normal list handle ...: 0x" & Hex(_GUICtrlToolbar_GetImageList($hToolbar)))
    MemoWrite("IsPtr = " & IsPtr(_GUICtrlToolbar_GetImageList($hToolbar)) & " IsHWnd = " & IsHWnd(_GUICtrlToolbar_GetImageList($hToolbar)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetInsertMark

Function Reference

_GUICtrlToolbar_GetInsertMark

Retrieves the current insertion mark

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetInsertMark ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns an array with the following format:
[0] - 0-based index of the insertion mark or -1 for no insertion mark
[1] - defines where the insertion mark is in relation to the button:
0 - To the left
1 - To the right
2 - On the background of the toolbar

Related

_GUICtrlToolbar_SetInsertMark

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aMark
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Set insert mark
    _GUICtrlToolbar_SetInsertMarkColor($hToolbar, 0xFF0000)
    _GUICtrlToolbar_SetInsertMark($hToolbar, 1, 1)

    ; Show insert mark
    $aMark = _GUICtrlToolbar_GetInsertMark($hToolbar)
    MemoWrite("Index ........: " & $aMark[0])
    MemoWrite("Relationship .: " & $aMark[1])
    MemoWrite("Mark color ...: 0x" & Hex(_GUICtrlToolbar_GetInsertMarkColor($hToolbar), 6))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetInsertMarkColor

Function Reference

_GUICtrlToolbar_GetInsertMarkColor

Retrieves the color used to draw the insertion mark

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetInsertMarkColor ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns the insertion mark color.

Related

_GUICtrlToolbar_SetInsertMarkColor

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aMark
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Set insert mark
    _GUICtrlToolbar_SetInsertMarkColor($hToolbar, 0xFF0000)
    _GUICtrlToolbar_SetInsertMark($hToolbar, 1, 1)

    ; Show insert mark
    $aMark = _GUICtrlToolbar_GetInsertMark($hToolbar)
    MemoWrite("Index ........: " & $aMark[0])
    MemoWrite("Relationship .: " & $aMark[1])
    MemoWrite("Mark color ...: 0x" & Hex(_GUICtrlToolbar_GetInsertMarkColor($hToolbar), 6))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetMaxSize

Function Reference

_GUICtrlToolbar_GetMaxSize

Retrieves the total size of all of the visible buttons and separators

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetMaxSize ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns an array with the following format:
[0] - Maximum width
[1] - Maximum height

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aSize
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Show maximum size
    $aSize = _GUICtrlToolbar_GetMaxSize($hToolbar)
    MemoWrite("Max width .: " & $aSize[0])
    MemoWrite("Max height : " & $aSize[1])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetMetrics

Function Reference

_GUICtrlToolbar_GetMetrics

Retrieves the metrics of a toolbar control

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetMetrics ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns an array with the following format:
[0] - Width of the padding inside the toolbar buttons
[1] - Height of the padding inside the toolbar buttons
[2] - Width of the space between toolbar buttons
[3] - Height of the space between toolbar buttons

Related

_GUICtrlToolbar_SetMetrics

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aMetrics
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    MemoWrite("Before _GUICtrlToolbar_SetMetrics")

    Sleep(1000)
    GUISetState(@SW_LOCK)
    ; Set control metrics
    MemoWrite("Step 1:")
    MemoWrite("$iXPad = 10")
    _GUICtrlToolbar_SetMetrics($hToolbar, 10, 0, 0, 0)
    GUISetState(@SW_UNLOCK)

    Sleep(1000)
    GUISetState(@SW_LOCK)
    ; Set control metrics
    MemoWrite("Step 2:")
    MemoWrite("$iYPad = 10")
    _GUICtrlToolbar_SetMetrics($hToolbar, 0, 10, 0, 0)
    GUISetState(@SW_UNLOCK)

    Sleep(1000)
    GUISetState(@SW_LOCK)
    ; Set control metrics
    MemoWrite("Step 3:")
    MemoWrite("$iXSpacing = 10")
    _GUICtrlToolbar_SetMetrics($hToolbar, 0, 0, 10, 0)
    GUISetState(@SW_UNLOCK)

    Sleep(1000)
    GUISetState(@SW_LOCK)
    ; Set control metrics
    MemoWrite("Step 4:")
    MemoWrite("$iYSpacing = 10")
    _GUICtrlToolbar_SetMetrics($hToolbar, 0, 0, 0, 10)
    GUISetState(@SW_UNLOCK)

    Sleep(1000)
    GUISetState(@SW_LOCK)
    ; Set control metrics
    MemoWrite("")
    MemoWrite("Step 5:")
    MemoWrite("$iXPad = 10")
    MemoWrite("$iYPad = 10")
    MemoWrite("$iXSpacing = 10")
    MemoWrite("$iYSpacing = 10")
    _GUICtrlToolbar_SetMetrics($hToolbar, 10, 10, 10, 10)
    GUISetState(@SW_UNLOCK)

    ; Show control metrics
    $aMetrics = _GUICtrlToolbar_GetMetrics($hToolbar)
    MemoWrite("Button padding width ...: " & $aMetrics[0])
    MemoWrite("Button padding height ..: " & $aMetrics[1])
    MemoWrite("Button spacing width ...: " & $aMetrics[2])
    MemoWrite("Button spacing height ..: " & $aMetrics[3])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetPadding

Function Reference

_GUICtrlToolbar_GetPadding

Retrieves the horizontal and vertical padding

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetPadding ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns an array with the following format:
[0] - Horizontal padding
[1] - Vertical padding

Related

_GUICtrlToolbar_SetPadding

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aPad
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Set control padding
    _GUICtrlToolbar_SetPadding($hToolbar, 2, 3)

    ; Show control padding
    $aPad = _GUICtrlToolbar_GetPadding($hToolbar)
    MemoWrite("Horizontal padding : " & $aPad[0])
    MemoWrite("Vertical padding ..: " & $aPad[1])
    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetRows

Function Reference

_GUICtrlToolbar_GetRows

Retrieves the number of rows of buttons

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetRows ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns the number of rows.

Related

_GUICtrlToolbar_SetRows

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 36, 2, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Create a vertical toolbar
    _GUICtrlToolbar_SetStyle($hToolbar, BitOR($CCS_LEFT, $TBSTYLE_FLAT))
    _GUICtrlToolbar_SetRows($hToolbar, 4)

    ; Show number of rows
    MemoWrite("Number of rows:" & _GUICtrlToolbar_GetRows($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetString

Function Reference

_GUICtrlToolbar_GetString

Retrieves a string from the string pool

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetString ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | Index of the string

Return Value

Returns the specified string.

Remarks

This message returns the specified string from the control's string pool. It does not necessarily correspond to the text string currently being displayed by a button.
To retrieve a button's current text string, send use _GUICtrlToolbar_GetButtonText().

Related

_GUICtrlToolbar_AddString, _GUICtrlToolbar_GetButtonText

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 45, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Get string 2 text
    MemoWrite("String 2 text .: " & _GUICtrlToolbar_GetString($hToolbar, 2))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetStyle

Function Reference

_GUICtrlToolbar_GetStyle

Retrieves the styles currently in use for a toolbar control

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetStyle ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Returns the control styles. Can be a combination of the following:
$TBSTYLE_TOOLTIPS - Creates a ToolTip control
$TBSTYLE_WRAPABLE - Creates a toolbar that can have multiple lines of buttons
$TBSTYLE_ALTDRAG - Allows users to change a toolbar button's position by dragging it
$TBSTYLE_FLAT - Creates a flat toolbar
$TBSTYLE_LIST - Creates a flat toolbar with button text to the right of the bitmap
$TBSTYLE_CUSTOMERASE - Sends $NM_CUSTOMDRAW messages when processing $WM_ERASEBKGND messages
$TBSTYLE_REGISTERDROP - Sends $TBN_GETOBJECT messages to request drop target objects
$TBSTYLE_TRANSPARENT - Creates a transparent toolbar

Related

_GUICtrlToolbar_SetStyle

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set control style
    _GUICtrlToolbar_SetStyle($hToolbar, BitOR($TBSTYLE_LIST, $CCS_TOP))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Show control style
    MemoWrite("Toolbar style .: 0x" & Hex(_GUICtrlToolbar_GetStyle($hToolbar)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetStyleAltDrag

Function Reference

_GUICtrlToolbar_GetStyleAltDrag

Indicates that the control allows buttons to be dragged

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetStyleAltDrag ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

True: | style is present.
False: | style is not present.

Related

_GUICtrlToolbar_SetStyleAltDrag

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $bStyle
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Change control style
    $bStyle = _GUICtrlToolbar_GetStyleAltDrag($hToolbar)
    MemoWrite("Toolbar has drag style .: " & $bStyle)
    _GUICtrlToolbar_SetStyleAltDrag($hToolbar, Not $bStyle)
    MemoWrite("Toolbar has drag style .: " & _GUICtrlToolbar_GetStyleAltDrag($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetStyleCustomErase

Function Reference

_GUICtrlToolbar_GetStyleCustomErase

Indicates that the control generates NM_CUSTOMDRAW notification messages

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetStyleCustomErase ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

True: | style is present.
False: | style is not present.

Related

_GUICtrlToolbar_SetStyleCustomErase

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $bStyle
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Change control style
    $bStyle = _GUICtrlToolbar_GetStyleCustomErase($hToolbar)
    MemoWrite("Toolbar sends custom erase .: " & $bStyle)
    _GUICtrlToolbar_SetStyleCustomErase($hToolbar, Not $bStyle)
    MemoWrite("Toolbar sends custom erase .: " & _GUICtrlToolbar_GetStyleCustomErase($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_GetStyleFlat

Function Reference

_GUICtrlToolbar_GetStyleFlat

Indicates that the control is flat

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetStyleFlat ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

True: | style is present.
False: | style is not present.

Related

_GUICtrlToolbar_SetStyleFlat

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $bStyle
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Change control style
    $bStyle = _GUICtrlToolbar_GetStyleFlat($hToolbar)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has flat style .: " & $bStyle)
    GUISetState(@SW_LOCK)
    _GUICtrlToolbar_SetStyleFlat($hToolbar, Not $bStyle)
    GUISetState(@SW_UNLOCK)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has flat style .: " & _GUICtrlToolbar_GetStyleFlat($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_GetStyleList

Function Reference

_GUICtrlToolbar_GetStyleList

Indicates that the control has button text to the right of the bitmap

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetStyleList ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

True: | style is present.
False: | style is not present.

Related

_GUICtrlToolbar_SetStyleList

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $bStyle
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Change control style
    $bStyle = _GUICtrlToolbar_GetStyleList($hToolbar)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has list style .: " & $bStyle)
    _GUICtrlToolbar_SetStyleList($hToolbar, Not $bStyle)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has list style .: " & _GUICtrlToolbar_GetStyleList($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_GetStyleRegisterDrop

Function Reference

_GUICtrlToolbar_GetStyleRegisterDrop

Indicates that the control generates TBN_GETOBJECT notification messages

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetStyleRegisterDrop ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

True: | style is present.
False: | style is not present.

Related

_GUICtrlToolbar_SetStyleRegisterDrop

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $bStyle
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Change control style
    $bStyle = _GUICtrlToolbar_GetStyleRegisterDrop($hToolbar)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has register drop style .: " & $bStyle)
    _GUICtrlToolbar_SetStyleRegisterDrop($hToolbar, Not $bStyle)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has register drop style .: " & _GUICtrlToolbar_GetStyleRegisterDrop($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_GetStyleToolTips

Function Reference

_GUICtrlToolbar_GetStyleToolTips

Indicates that the control has tooltips

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetStyleToolTips ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

True: | style is present.
False: | style is not present.

Related

_GUICtrlToolbar_SetStyleToolTips

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $bStyle
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Change control style
    $bStyle = _GUICtrlToolbar_GetStyleToolTips($hToolbar)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has tooltips style .: " & $bStyle)
    _GUICtrlToolbar_SetStyleToolTips($hToolbar, Not $bStyle)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has tooltips style .: " & _GUICtrlToolbar_GetStyleToolTips($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_GetStyleTransparent

Function Reference

_GUICtrlToolbar_GetStyleTransparent

Indicates that the control is transparent

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetStyleTransparent ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

True: | style is present.
False: | style is not present.

Related

_GUICtrlToolbar_SetStyleTransparent

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $bStyle
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetBkColor(0xffffff)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Change control style
    $bStyle = _GUICtrlToolbar_GetStyleTransparent($hToolbar)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has transparent style .: " & $bStyle)
    GUISetState(@SW_LOCK)
    _GUICtrlToolbar_SetStyleTransparent($hToolbar, Not $bStyle)
    GUISetState(@SW_UNLOCK)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has transparent style .: " & _GUICtrlToolbar_GetStyleTransparent($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_GetStyleWrapable

Function Reference

_GUICtrlToolbar_GetStyleWrapable

Indicates that the control is wrapable

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetStyleWrapable ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

True: | style is present.
False: | style is not present.

Related

_GUICtrlToolbar_SetStyleWrapable

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $bStyle
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Change control style
    $bStyle = _GUICtrlToolbar_GetStyleWrapable($hToolbar)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has wrapable style .: " & $bStyle)
    _GUICtrlToolbar_SetStyleWrapable($hToolbar, Not $bStyle)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has wrapable style .: " & _GUICtrlToolbar_GetStyleWrapable($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_GetTextRows

Function Reference

_GUICtrlToolbar_GetTextRows

Retrieves the maximum number of text rows that can be displayed on a button

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetTextRows ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Return the maximum number of text rows that can be displayed on a button.

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Show number of text rows
    MsgBox($MB_SYSTEMMODAL, "Information", "Number of text rows:" & _GUICtrlToolbar_GetTextRows($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_GetToolTips

Function Reference

_GUICtrlToolbar_GetToolTips

Retrieves the handle to the ToolTip control

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetToolTips ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | the ToolTip handle.
Failure: | 0.

Related

_GUICtrlToolbar_SetToolTips

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <GuiToolTip.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp

Example()

Func Example()
    Local $hGUI, $hToolbar, $hToolTip

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Create ToolTip
    $hToolTip = _GUIToolTip_Create($hToolbar)
    _GUICtrlToolbar_SetToolTips($hToolbar, $hToolTip)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idHelp, $STD_HELP)

    ; Show ToolTip handle
    MsgBox($MB_SYSTEMMODAL, "Information", "ToolTip handle .: 0x" & Hex(_GUICtrlToolbar_GetToolTips($hToolbar)) & @CRLF & _
            "IsPtr = " & IsPtr(_GUICtrlToolbar_GetToolTips($hToolbar)) & " IsHWnd = " & IsHWnd(_GUICtrlToolbar_GetToolTips($hToolbar)))

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Handle WM_NOTIFY messages
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam
    Local $tInfo, $iID, $iCode

    $tInfo = DllStructCreate($tagNMTTDISPINFO, $lParam)
    $iCode = DllStructGetData($tInfo, "Code")
    If $iCode = $TTN_GETDISPINFOW Then
        $iID = DllStructGetData($tInfo, "IDFrom")
        Switch $iID
            Case $e_idNew
                DllStructSetData($tInfo, "aText", "New")
            Case $e_idOpen
                DllStructSetData($tInfo, "aText", "Open")
            Case $e_idSave
                DllStructSetData($tInfo, "aText", "Save")
            Case $e_idHelp
                DllStructSetData($tInfo, "aText", "Help")
        EndSwitch
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY


Function _GUICtrlToolbar_GetUnicodeFormat

Function Reference

_GUICtrlToolbar_GetUnicodeFormat

Retrieves the Unicode character format flag

#include <GuiToolbar.au3>
_GUICtrlToolbar_GetUnicodeFormat ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

True: | the control is using Unicode characters.
False: | the control is using ANSI characters.

Related

_GUICtrlToolbar_SetUnicodeFormat

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $bUnicode
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Show Unicode format
    $bUnicode = _GUICtrlToolbar_GetUnicodeFormat($hToolbar)
    MemoWrite("Unicode format .:" & $bUnicode)

    ; Change Unicode format
    _GUICtrlToolbar_SetUnicodeFormat($hToolbar, Not $bUnicode)
    MemoWrite("Unicode format .:" & _GUICtrlToolbar_GetUnicodeFormat($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_HideButton

Function Reference

_GUICtrlToolbar_HideButton

Hides or shows the specified button

#include <GuiToolbar.au3>
_GUICtrlToolbar_HideButton ( $hWnd, $iCommandID [, $bHide = True] )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID
$bHide | [optional] State indicator: True - Button will be hidden False - Button will be made visible

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlToolbar_EnableButton

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Hide Save button
    MsgBox($MB_SYSTEMMODAL, "Information", "Hiding Save button")
    _GUICtrlToolbar_HideButton($hToolbar, $e_idSave, True)
    MsgBox($MB_SYSTEMMODAL, "Information", "Restoring Save button")
    _GUICtrlToolbar_HideButton($hToolbar, $e_idSave, False)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_HighlightButton

Function Reference

_GUICtrlToolbar_HighlightButton

Sets the highlight state of a given button control

#include <GuiToolbar.au3>
_GUICtrlToolbar_HighlightButton ( $hWnd, $iCommandID [, $bHighlight = True] )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID
$bHighlight | [optional] Highlight state: True - Button will be highlighted False - Button will be unhighlighted

Return Value

Success: | True.
Failure: | False.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Mark Save button
    MemoWrite("Save button Highlight State: " & _GUICtrlToolbar_IsButtonHighlighted($hToolbar, $e_idSave))
    _GUICtrlToolbar_HighlightButton($hToolbar, $e_idSave)
    MemoWrite("Save button Highlight State: " & _GUICtrlToolbar_IsButtonHighlighted($hToolbar, $e_idSave))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_HitTest

Function Reference

_GUICtrlToolbar_HitTest

Determines where a point lies within the control

#include <GuiToolbar.au3>
_GUICtrlToolbar_HitTest ( $hWnd, $iX, $iY )

Parameters

$hWnd | Handle to the control
$iX | X position to test
$iY | Y position to test

Return Value

Success: | If the value is zero or a positive value, it is the 0-based index of the nonseparator item in which the point lies.
Failure: | If the value is negative, the point does not lie within a button.

Remarks

The absolute value of the return value is the index of a separator item or the nearest nonseparator item.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aRect, $iHit, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Do a hit test on the Save button
    $aRect = _GUICtrlToolbar_GetButtonRect($hToolbar, $e_idSave)
    $iHit = _GUICtrlToolbar_HitTest($hToolbar, $aRect[0], $aRect[1])
    MemoWrite(StringFormat("Hit test at %d, %d = %d", $aRect[0], $aRect[1], $iHit))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_IndexToCommand

Function Reference

_GUICtrlToolbar_IndexToCommand

Retrieves the command identifier associated with the button

#include <GuiToolbar.au3>
_GUICtrlToolbar_IndexToCommand ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | Button index

Return Value

Returns the button command identifier.

Related

_GUICtrlToolbar_CommandToIndex

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $iIndex
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Show Save button index
    $iIndex = _GUICtrlToolbar_CommandToIndex($hToolbar, $e_idSave)
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button index .: " & $iIndex)
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button command .: " & _GUICtrlToolbar_IndexToCommand($hToolbar, $iIndex))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_InsertButton

Function Reference

_GUICtrlToolbar_InsertButton

Inserts a button

#include <GuiToolbar.au3>
_GUICtrlToolbar_InsertButton ( $hWnd, $iIndex, $iID, $iImage [, $sText = "" [, $iStyle = 0 [, $iState = 4 [, $iParam = 0]]]] )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based index of a button
$iID | Command ID
$iImage | 0-based image index
$sText | [optional] Button text
$iStyle | [optional] Button style. Can be a combination of the following: $BTNS_AUTOSIZE - The toolbar control should not assign the standard width to the button $BTNS_BUTTON - Standard button $BTNS_CHECK - Toggles between the pressed and nonpressed $BTNS_CHECKGROUP - Button that stays pressed until another button in the group is pressed $BTNS_DROPDOWN - Creates a drop-down style button that can display a list $BTNS_GROUP - Button that stays pressed until another button in the group is pressed $BTNS_NOPREFIX - The button text will not have an accelerator prefix $BTNS_SEP - Creates a separator $BTNS_SHOWTEXT - Specifies that button text should be displayed $BTNS_WHOLEDROPDOWN - Specifies that the button will have a drop-down arrow
$iState | [optional] Button state. Can be a combination of the following: $TBSTATE_CHECKED - The button has the $TBSTYLE_CHECK style and is being clicked $TBSTATE_PRESSED - The button is being clicked $TBSTATE_ENABLED - The button accepts user input $TBSTATE_HIDDEN - The button is not visible and cannot receive user input $TBSTATE_INDETERMINATE - The button is grayed $TBSTATE_WRAP - The button is followed by a line break $TBSTATE_ELLIPSES - The button's text is cut off and an ellipsis is displayed $TBSTATE_MARKED - The button is marked
$iParam | [optional] Application-defined value

Return Value

Success: | True.
Failure: | False.

Remarks

Inserts the new button to the left of the button at $iIndex

Related

_GUICtrlToolbar_AddButton

Example

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

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add buttons
    _GUICtrlToolbar_InsertButton($hToolbar, 0, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_InsertButton($hToolbar, 1, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_InsertButton($hToolbar, 2, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_InsertButton($hToolbar, 4, $idHelp, $STD_HELP)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_InsertMarkHitTest

Function Reference

_GUICtrlToolbar_InsertMarkHitTest

Retrieves the insertion mark information for a point

#include <GuiToolbar.au3>
_GUICtrlToolbar_InsertMarkHitTest ( $hWnd, $iX, $iY )

Parameters

$hWnd | Handle to the control
$iX | X position relative to the client area
$iY | Y position relative to the client area

Return Value

Returns an array with the following format:
[0] - 0-based index of the insertion mark or -1 for no insertion mark
[1] - Defines the insertion position. This can be one of the following values:
0 - To the left
1 - To the right
2 - On the background of the toolbar

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4], $aRect, $aMark
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Set insert mark
    _GUICtrlToolbar_SetInsertMark($hToolbar, 1, 1)

    ; Do insert mark hit test 1
    $aMark = _GUICtrlToolbar_InsertMarkHitTest($hToolbar, 0, 0)
    MemoWrite("Index ........: " & $aMark[0])
    MemoWrite("Relationship .: " & $aMark[1])

    ; Do insert mark hit test 2
    $aRect = _GUICtrlToolbar_GetButtonRect($hToolbar, $e_idSave)
    $aMark = _GUICtrlToolbar_InsertMarkHitTest($hToolbar, $aRect[0], $aRect[1])
    MemoWrite("Index ........: " & $aMark[0])
    MemoWrite("Relationship .: " & $aMark[1])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_IsButtonChecked

Function Reference

_GUICtrlToolbar_IsButtonChecked

Indicates whether the specified button is checked

#include <GuiToolbar.au3>
_GUICtrlToolbar_IsButtonChecked ( $hWnd, $iCommandID )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID

Return Value

True: | the button is checked.
False: | the button is not checked.

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Check Save button
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button is checked: " & _GUICtrlToolbar_IsButtonChecked($hToolbar, $e_idSave))
    _GUICtrlToolbar_CheckButton($hToolbar, $e_idSave)
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button is checked: " & _GUICtrlToolbar_IsButtonChecked($hToolbar, $e_idSave))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_IsButtonEnabled

Function Reference

_GUICtrlToolbar_IsButtonEnabled

Indicates whether the specified button is enabled

#include <GuiToolbar.au3>
_GUICtrlToolbar_IsButtonEnabled ( $hWnd, $iCommandID )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID

Return Value

True: | the button is enabled.
False: | the button is not enabled.

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Disable Help button
    MsgBox($MB_SYSTEMMODAL, "Information", "Help button enabled: " & _GUICtrlToolbar_IsButtonEnabled($hToolbar, $idHelp))
    _GUICtrlToolbar_EnableButton($hToolbar, $idHelp, False)
    MsgBox($MB_SYSTEMMODAL, "Information", "Help button enabled: " & _GUICtrlToolbar_IsButtonEnabled($hToolbar, $idHelp))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_IsButtonHidden

Function Reference

_GUICtrlToolbar_IsButtonHidden

Indicates whether the specified button is hidden

#include <GuiToolbar.au3>
_GUICtrlToolbar_IsButtonHidden ( $hWnd, $iCommandID )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID

Return Value

True: | the button is hidden.
False: | the button is not hidden.

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Hide Save button
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button hidden: " & _GUICtrlToolbar_IsButtonHidden($hToolbar, $e_idSave))
    _GUICtrlToolbar_HideButton($hToolbar, $e_idSave, True)
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button hidden: " & _GUICtrlToolbar_IsButtonHidden($hToolbar, $e_idSave))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_IsButtonHighlighted

Function Reference

_GUICtrlToolbar_IsButtonHighlighted

Indicates whether the specified button is hilighted

#include <GuiToolbar.au3>
_GUICtrlToolbar_IsButtonHighlighted ( $hWnd, $iCommandID )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID

Return Value

True: | the button is highlighted.
False: | the button is not highlighted.

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Mark Save button
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button Marked: " & _GUICtrlToolbar_IsButtonHighlighted($hToolbar, $e_idSave))
    _GUICtrlToolbar_HighlightButton($hToolbar, $e_idSave)
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button Marked: " & _GUICtrlToolbar_IsButtonHighlighted($hToolbar, $e_idSave))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_IsButtonIndeterminate

Function Reference

_GUICtrlToolbar_IsButtonIndeterminate

Indicates whether the specified button is indeterminate

#include <GuiToolbar.au3>
_GUICtrlToolbar_IsButtonIndeterminate ( $hWnd, $iCommandID )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID

Return Value

True: | the button is indeterminate.
False: | the button is not indeterminate.

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Set Save button state
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button indeterminate: " & _GUICtrlToolbar_IsButtonIndeterminate($hToolbar, $e_idSave))
    _GUICtrlToolbar_SetIndeterminate($hToolbar, $e_idSave)
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button indeterminate: " & _GUICtrlToolbar_IsButtonIndeterminate($hToolbar, $e_idSave))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_IsButtonPressed

Function Reference

_GUICtrlToolbar_IsButtonPressed

Indicates that the button is being clicked

#include <GuiToolbar.au3>
_GUICtrlToolbar_IsButtonPressed ( $hWnd, $iCommandID )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID

Return Value

True: | the button is pressed.
False: | the button is not pressed.

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Set Save button state
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button pressed: " & _GUICtrlToolbar_IsButtonPressed($hToolbar, $e_idSave))
    _GUICtrlToolbar_PressButton($hToolbar, $e_idSave)
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button pressed: " & _GUICtrlToolbar_IsButtonPressed($hToolbar, $e_idSave))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_LoadBitmap

Function Reference

_GUICtrlToolbar_LoadBitmap

Adds a bitmap to the image list from a file

#include <GuiToolbar.au3>
_GUICtrlToolbar_LoadBitmap ( $hWnd, $sFileName )

Parameters

$hWnd | Handle to toolbar
$sFileName | Fully qualified path to bitmap file

Return Value

Success: | the 0-based index of the new image.
Failure: | -1.

Related

_GUICtrlToolbar_AddBitmap

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idRed = 1000, $e_idGreen, $e_idBlue
    Local $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images"

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add bitmaps
    _GUICtrlToolbar_LoadBitmap($hToolbar, $sPath & "\red.bmp")
    _GUICtrlToolbar_LoadBitmap($hToolbar, $sPath & "\green.bmp")
    _GUICtrlToolbar_LoadBitmap($hToolbar, $sPath & "\blue.bmp")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idRed, 0)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idGreen, 1)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idBlue, 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_LoadImages

Function Reference

_GUICtrlToolbar_LoadImages

Loads system defined button images into a toolbar control's image list

#include <GuiToolbar.au3>
_GUICtrlToolbar_LoadImages ( $hWnd, $iBitMapID )

Parameters

$hWnd | Handle to the control
$iBitMapID | Identifier of a system-defined button image list. Can be set to one of the following values: $IDB_HIST_LARGE_COLOR $IDB_HIST_SMALL_COLOR $IDB_STD_LARGE_COLOR $IDB_STD_SMALL_COLOR $IDB_VIEW_LARGE_COLOR $IDB_VIEW_SMALL_COLOR $IDB_HIST_NORMAL $IDB_HIST_HOT $IDB_HIST_DISABLED $IDB_HIST_PRESSED

Return Value

Success: | the count of images in the image list, not including the ones just added.
Failure: | 0.

Example

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

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    _GUICtrlToolbar_SetBitmapSize($hToolbar, 24, 24)
    _GUICtrlToolbar_LoadImages($hToolbar, $IDB_STD_LARGE_COLOR)

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_MapAccelerator

Function Reference

_GUICtrlToolbar_MapAccelerator

Determines the ID of the button that corresponds to the specified accelerator

#include <GuiToolbar.au3>
_GUICtrlToolbar_MapAccelerator ( $hWnd, $sAccelKey )

Parameters

$hWnd | Handle to the control
$sAccelKey | Accelerator character

Return Value

Returns the command ID of the button that has $sAccelKey as its accelerator character.

Example

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

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4], $iCmdID
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Press Save button by accelerator
    $iCmdID = _GUICtrlToolbar_MapAccelerator($hToolbar, "s")
    _GUICtrlToolbar_PressButton($hToolbar, $iCmdID)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_MoveButton

Function Reference

_GUICtrlToolbar_MoveButton

Moves a button from one index to another

#include <GuiToolbar.au3>
_GUICtrlToolbar_MoveButton ( $hWnd, $iOldPos, $iNewPos )

Parameters

$hWnd | Handle to the control
$iOldPos | 0-based index of the button to be moved
$iNewPos | 0-based index where the button will be moved

Return Value

Success: | True.
Failure: | False.

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Move Save button state
    MsgBox($MB_SYSTEMMODAL, "Information", "Moving Save button")
    _GUICtrlToolbar_MoveButton($hToolbar, 2, 1)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_PressButton

Function Reference

_GUICtrlToolbar_PressButton

Presses or releases the specified button

#include <GuiToolbar.au3>
_GUICtrlToolbar_PressButton ( $hWnd, $iCommandID [, $bPress = True] )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID
$bPress | [optional] Pressed state: True - Button will be set to a pressed state False - Button will be set to an unpressed state

Return Value

Success: | True.
Failure: | False.

Remarks

This function does not fire the click event on dropdown style buttons. You should use the _GUICtrlToolbar_ClickButton()
function if you want to ensure that the button click event is fired, regardless of the button style.

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Set Save button state
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button pressed: " & _GUICtrlToolbar_IsButtonPressed($hToolbar, $e_idSave))
    _GUICtrlToolbar_PressButton($hToolbar, $e_idSave)
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button pressed: " & _GUICtrlToolbar_IsButtonPressed($hToolbar, $e_idSave))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_SetAnchorHighlight

Function Reference

_GUICtrlToolbar_SetAnchorHighlight

Sets the anchor highlight setting

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetAnchorHighlight ( $hWnd, $bAnchor )

Parameters

$hWnd | Handle to the control
$bAnchor | Anchor highlighting setting: True - Anchor highlighting will be enabled False - Anchor highlighting will be disabled

Return Value

Returns the previous anchor highlight setting.

Remarks

Anchor highlighting means that the last highlighted item will remain highlighted until another item is highlighted.
This occurs even if the cursor leaves the toolbar control.

Related

_GUICtrlToolbar_GetAnchorHighlight

Example

#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hToolbar, $bEnabled

    Run("explorer.exe /root, ,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")
    WinWaitActive("My Computer")
    $hToolbar = _GUICtrlToolbar_FindToolbar("[CLASS:CabinetWClass]", "&File")
    $bEnabled = _GUICtrlToolbar_GetAnchorHighlight($hToolbar)
    MsgBox($MB_SYSTEMMODAL, "Information", "Anchor highlight enabled: " & $bEnabled)
    _GUICtrlToolbar_SetAnchorHighlight($hToolbar, Not $bEnabled)
    MsgBox($MB_SYSTEMMODAL, "Information", "Anchor highlight enabled: " & _GUICtrlToolbar_GetAnchorHighlight($hToolbar))
EndFunc   ;==>Example


Function _GUICtrlToolbar_SetBitmapSize

Function Reference

_GUICtrlToolbar_SetBitmapSize

Sets the size of the bitmapped images to be added to a toolbar

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetBitmapSize ( $hWnd, $iWidth, $iHeight )

Parameters

$hWnd | Handle to the control
$iWidth | Width, in pixels, of the bitmapped images
$iHeight | Height, in pixels, of the bitmapped images

Return Value

Success: | True.
Failure: | False.

Remarks

The size can be set only before adding any bitmaps to the toolbar. If an application does not explicitly set the bitmap size, the size defaults to 16 by 15 pixels.

Example

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

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    _GUICtrlToolbar_SetBitmapSize($hToolbar, 24, 24)
    _GUICtrlToolbar_LoadImages($hToolbar, $IDB_STD_LARGE_COLOR)

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_SetButtonBitMap

Function Reference

_GUICtrlToolbar_SetButtonBitMap

Sets the index of the bitmap associated with a button

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetButtonBitMap ( $hWnd, $iCommandID, $iIndex )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID
$iIndex | 0-based index of an images image list

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlToolbar_GetButtonBitmap

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Show Save button bitmap index
    MsgBox($MB_SYSTEMMODAL, "Information", "Changing Save bitmap to Print bitmap")
    _GUICtrlToolbar_SetButtonBitMap($hToolbar, $e_idSave, $STD_PRINT)
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button bitmap index: " & _GUICtrlToolbar_GetButtonBitmap($hToolbar, $e_idSave))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_SetButtonInfo

Function Reference

_GUICtrlToolbar_SetButtonInfo

Sets information for a button

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetButtonInfo ( $hWnd, $iCommandID [, $iImage = -3 [, $iState = -1 [, $iStyle = -1 [, $iWidth = -1 [, $iParam = -1]]]]] )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID
$iImage | [optional] 0-based index of the button image. Set this parameter to -1 and the control will send the $TBN_GETDISPINFO notification to retrieve the image index when it is needed. Set this to -2 to indicate that the button does not have an image. The button layout will only include space for the text. If the button is a separator, this is the width of the separator, in pixels.
$iState | [optional] Button state. Can be a combination of the following: $TBSTATE_CHECKED - The button being clicked $TBSTATE_PRESSED - The button is being clicked $TBSTATE_ENABLED - The button accepts user input $TBSTATE_HIDDEN - The button is not visible $TBSTATE_INDETERMINATE - The button is grayed $TBSTATE_WRAP - The button is followed by a line break $TBSTATE_ELLIPSES - The button's text is cut off $TBSTATE_MARKED - The button is marked
$iStyle | [optional] Button style. Can be a combination of the following: $BTNS_AUTOSIZE - The control should not assign the standard width $BTNS_BUTTON - Standard button $BTNS_CHECK - Toggles between the pressed and nonpressed $BTNS_CHECKGROUP - Button that stays pressed until another button is pressed $BTNS_DROPDOWN - Creates a drop-down style button that can display a list $BTNS_GROUP - Button that stays pressed until another button is pressed $BTNS_NOPREFIX - The button text will not have an accelerator prefix $BTNS_SEP - Creates a separator $BTNS_SHOWTEXT - Specifies that button text should be displayed $BTNS_WHOLEDROPDOWN - Specifies that the button will have a drop-down arrow
$iWidth | [optional] Button width
$iParam | [optional] Application-defined value

Return Value

Success: | True.
Failure: | False.

Related

$tagTBBUTTONINFO, _GUICtrlToolbar_GetButtonInfo

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aButton
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Set Save button information
    _GUICtrlToolbar_SetButtonInfo($hToolbar, $e_idSave, $STD_PRINT, BitOR($TBSTATE_PRESSED, $TBSTATE_ENABLED), -1, 100, 1234)

    ; Show Save button information
    $aButton = _GUICtrlToolbar_GetButtonInfo($hToolbar, $e_idSave)
    MemoWrite("Image index ....: " & $aButton[0])
    MemoWrite("State flags ....: " & $aButton[1])
    MemoWrite("Style flags ....: " & $aButton[2])
    MemoWrite("Button width ...: " & $aButton[3])
    MemoWrite("Param ..........: " & $aButton[4])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetButtonInfoEx

Function Reference

_GUICtrlToolbar_SetButtonInfoEx

Sets extended information for a button

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetButtonInfoEx ( $hWnd, $iCommandID, $tButton )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID
$tButton | $tagTBBUTTONINFO structure

Return Value

Success: | True.
Failure: | False.

Related

$tagTBBUTTONINFO, _GUICtrlToolbar_GetButtonInfoEx

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $tButton
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Set Save button information
    $tButton = DllStructCreate($tagTBBUTTONINFO)
    DllStructSetData($tButton, "Mask", BitOR($TBIF_IMAGE, $TBIF_STATE, $TBIF_SIZE, $TBIF_LPARAM))
    DllStructSetData($tButton, "State", BitOR($TBSTATE_PRESSED, $TBSTATE_ENABLED))
    DllStructSetData($tButton, "Image", $STD_PRINT)
    DllStructSetData($tButton, "CX", 100)
    DllStructSetData($tButton, "Param", 1234)
    _GUICtrlToolbar_SetButtonInfoEx($hToolbar, $e_idSave, $tButton)

    ; Show Save button information
    $tButton = _GUICtrlToolbar_GetButtonInfoEx($hToolbar, $e_idSave)
    MemoWrite("Image index ....: " & DllStructGetData($tButton, "Image"))
    MemoWrite("State flags ....: " & DllStructGetData($tButton, "State"))
    MemoWrite("Button width ...: " & DllStructGetData($tButton, "CX"))
    MemoWrite("Param ..........: " & DllStructGetData($tButton, "Param"))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetButtonParam

Function Reference

_GUICtrlToolbar_SetButtonParam

Sets the button param value

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetButtonParam ( $hWnd, $iCommandID, $iParam )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID
$iParam | Application-defined value

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlToolbar_GetButtonParam

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Set Save button parameter
    _GUICtrlToolbar_SetButtonParam($hToolbar, $e_idSave, 1234)

    ; Show Save button parameter
    MemoWrite("Save button parameter: " & _GUICtrlToolbar_GetButtonParam($hToolbar, $e_idSave))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetButtonSize

Function Reference

_GUICtrlToolbar_SetButtonSize

Sets the size of the buttons to be added to a toolbar

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetButtonSize ( $hWnd, $iHeight, $iWidth )

Parameters

$hWnd | Handle to the control
$iHeight | Height, in pixels, of the buttons
$iWidth | Width, in pixels, of the buttons

Return Value

Success: | True.
Failure: | False.

Remarks

The size can be set only before adding any buttons to the toolbar. If an application does not explicitly set the button size, the size defaults to 24 by 22 pixels.

Related

_GUICtrlToolbar_GetButtonSize

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aSize
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Show button size
    $aSize = _GUICtrlToolbar_GetButtonSize($hToolbar)
    MemoWrite("Button height : " & $aSize[0])
    MemoWrite("Button width .: " & $aSize[1])
    _GUICtrlToolbar_SetButtonSize($hToolbar, $aSize[0], $aSize[1] + 10)
    $aSize = _GUICtrlToolbar_GetButtonSize($hToolbar)
    MemoWrite("New Button Size")
    MemoWrite("Button height : " & $aSize[0])
    MemoWrite("Button width .: " & $aSize[1])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetButtonState

Function Reference

_GUICtrlToolbar_SetButtonState

Sets information about the state of the specified button

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetButtonState ( $hWnd, $iCommandID, $iState )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID
$iState | Button state. Can be one or more of the following: $TBSTATE_CHECKED - The button has the $TBSTYLE_CHECK style and is being clicked $TBSTATE_PRESSED - The button is being clicked $TBSTATE_ENABLED - The button accepts user input $TBSTATE_HIDDEN - The button is not visible and cannot receive user input $TBSTATE_INDETERMINATE - The button is grayed $TBSTATE_WRAP - The button is followed by a line break $TBSTATE_ELLIPSES - The button's text is cut off and an ellipsis is displayed $TBSTATE_MARKED - The button is marked

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlToolbar_GetButtonState

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Show Save button state
    MemoWrite("Save button state: " & _GUICtrlToolbar_GetButtonState($hToolbar, $e_idSave))

    Sleep(1000)

    ; Set Save button state
    Local $idBalloon = _GUICtrlToolbar_SetButtonState($hToolbar, $e_idSave, BitOR($TBSTATE_ENABLED, $TBSTATE_PRESSED))
    MemoWrite("Set button state: " & $idBalloon)

    ; Show Save button state
    MemoWrite("Save button state: " & _GUICtrlToolbar_GetButtonState($hToolbar, $e_idSave))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetButtonStyle

Function Reference

_GUICtrlToolbar_SetButtonStyle

Sets the style flags of a button

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetButtonStyle ( $hWnd, $iCommandID, $iStyle )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID
$iStyle | Button style. Can be one or more of the following: $BTNS_AUTOSIZE - The toolbar control should not assign the standard width to the button $BTNS_CHECK - Toggles between the pressed and nonpressed $BTNS_CHECKGROUP - Button that stays pressed until another button in the group is pressed $BTNS_DROPDOWN - Drop-down style button that can display a list $BTNS_GROUP - Button that stays pressed until another button in the group is pressed $BTNS_NOPREFIX - The button text will not have an accelerator prefix $BTNS_SEP - Separator $BTNS_SHOWTEXT - Button text should be displayed $BTNS_WHOLEDROPDOWN - The button has a drop-down arrow

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlToolbar_GetButtonStyle

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Set Save button style
    _GUICtrlToolbar_SetButtonStyle($hToolbar, $e_idSave, $BTNS_CHECK)

    ; Show Save button style
    MemoWrite("Save button style: " & _GUICtrlToolbar_GetButtonStyle($hToolbar, $e_idSave))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetButtonText

Function Reference

_GUICtrlToolbar_SetButtonText

Sets the display text of a button

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetButtonText ( $hWnd, $iCommandID, $sText )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID
$sText | Button text

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlToolbar_GetButtonText

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 60, 396, 238, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Change Save button text
    _GUICtrlToolbar_SetButtonText($hToolbar, $e_idSave, "&Close")

    ; Show Save button text
    MemoWrite("Save button text: " & _GUICtrlToolbar_GetButtonText($hToolbar, $e_idSave))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetButtonWidth

Function Reference

_GUICtrlToolbar_SetButtonWidth

Sets the minimum and maximum button widths in the toolbar control

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetButtonWidth ( $hWnd, $iMin, $iMax )

Parameters

$hWnd | Handle to the control
$iMin | Minimum button width, in pixels
$iMax | Maximum button width, in pixels

Return Value

Success: | True.
Failure: | False.

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Enable multi line button labels
    _GUICtrlToolbar_SetButtonWidth($hToolbar, 32, 40)
    _GUICtrlToolbar_SetMaxTextRows($hToolbar, 2)

    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Show number of text rows
    MsgBox($MB_SYSTEMMODAL, "Information", "Number of text rows:" & _GUICtrlToolbar_GetTextRows($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_SetCmdID

Function Reference

_GUICtrlToolbar_SetCmdID

Sets the command identifier of a toolbar button

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetCmdID ( $hWnd, $iIndex, $iCommandID )

Parameters

$hWnd | Handle to the control
$iIndex | 0-based index of the button whose command identifier is to be set
$iCommandID | Command identifier

Return Value

Success: | True.
Failure: | False.

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp, $idPrint

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Change Save button to Print button
    MsgBox($MB_SYSTEMMODAL, "Information", "Changing Save button to Print button")
    _GUICtrlToolbar_SetCmdID($hToolbar, 2, $idPrint)
    _GUICtrlToolbar_SetButtonBitMap($hToolbar, $idPrint, $STD_PRINT)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_SetColorScheme

Function Reference

_GUICtrlToolbar_SetColorScheme

Sets the color scheme information

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetColorScheme ( $hWnd, $iHighlight, $iShadow )

Parameters

$hWnd | Handle to the control
$iHighlight | Highlight color
$iShadow | Shadow color

Return Value

None.

Remarks

The control uses the color scheme information when drawing the 3-D elements in the control.

Related

_GUICtrlToolbar_GetColorScheme

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aScheme
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Change Color Scheme
    _GUICtrlToolbar_SetColorScheme($hToolbar, 0x00ffff, 0x800000)

    ; Show Color Scheme
    $aScheme = _GUICtrlToolbar_GetColorScheme($hToolbar)
    MemoWrite("Highlight: " & '0x' & Hex($aScheme[0], 6))
    MemoWrite("Shadow: " & '0x' & Hex($aScheme[1], 6))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetDisabledImageList

Function Reference

_GUICtrlToolbar_SetDisabledImageList

Sets the disabled image list

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetDisabledImageList ( $hWnd, $hImageList )

Parameters

$hWnd | Handle to the control
$hImageList | Handle to the image list that will be set

Return Value

Success: | the handle to the image list previously used to display disabled buttons.
Failure: | 0.

Related

_GUICtrlToolbar_GetDisabledImageList

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $hNormal, $hDisabled, $hHot
    Local Enum $idRed = 1000, $idGreen, $idBlue

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    GUISetBkColor(0xffff00)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create normal image list
    $hNormal = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 32, 24))
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 32, 24))
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 32, 24))
    _GUICtrlToolbar_SetImageList($hToolbar, $hNormal)

    ; Create disabled image list
    $hDisabled = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    Local $hPrevImageList = _GUICtrlToolbar_SetDisabledImageList($hToolbar, $hDisabled)
    MemoWrite("Previous Disabled list handle .: 0x" & Hex($hPrevImageList))
    MemoWrite("IsPtr = " & IsPtr($hPrevImageList) & " IsHWnd = " & IsHWnd($hPrevImageList))

    ; Create hot image list
    $hHot = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0x111111, 32, 24))
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0x888888, 32, 24))
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0xAAAAAA, 32, 24))
    _GUICtrlToolbar_SetHotImageList($hToolbar, $hHot)

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $idRed, 0)
    _GUICtrlToolbar_AddButton($hToolbar, $idGreen, 1)
    _GUICtrlToolbar_AddButton($hToolbar, $idBlue, 2)

    ; Disable Blue button
    _GUICtrlToolbar_EnableButton($hToolbar, $idBlue, False)

    ; Show image list handles
    MemoWrite("Disabled list handle .: 0x" & Hex(_GUICtrlToolbar_GetDisabledImageList($hToolbar)))
    MemoWrite("Hot list handle ......: 0x" & Hex(_GUICtrlToolbar_GetHotImageList($hToolbar)))
    MemoWrite("Normal list handle ...: 0x" & Hex(_GUICtrlToolbar_GetImageList($hToolbar)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetDrawTextFlags

Function Reference

_GUICtrlToolbar_SetDrawTextFlags

Sets the text drawing flags for the toolbar

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetDrawTextFlags ( $hWnd, $iMask, $iDTFlags )

Parameters

$hWnd | Handle to the control
$iMask | One or more of the DT_ flags, specified in DrawText, that indicate which bits in $iDTFlags will be used when drawing the text.
$iDTFlags | One or more of the DT_ flags, specified in DrawText, that indicate how the button text will be drawn. This value will be passed to the DrawText API when the button text is drawn.

Return Value

Returns the previous text drawing flags.

Remarks

The $iMask parameter allows you to specify which flags will be used when drawing the text, even if these flags are turned off.
For example, if you don't want the $DT_CENTER flag used when drawing text you would add the $DT_CENTER flag to $iMask and not specify the $DT_CENTER flag in $iDTFlags.
This prevents the control from passing the $DT_CENTER flag to the DrawText API.


Function _GUICtrlToolbar_SetExtendedStyle

Function Reference

_GUICtrlToolbar_SetExtendedStyle

Sets the extended styles control

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetExtendedStyle ( $hWnd, $iStyle )

Parameters

$hWnd | Handle to the control
$iStyle | Control extended styles. Can be one or more of the following: $TBSTYLE_EX_DRAWDDARROWS - Allows buttons to have a separate dropdown arrow $TBSTYLE_EX_MIXEDBUTTONS - Allows mixing buttons with text and images $TBSTYLE_EX_HIDECLIPPEDBUTTONS - Hides partially clipped buttons $TBSTYLE_EX_DOUBLEBUFFER - Requires the toolbar to be double buffered

Return Value

Returns the previous extended styles.

Related

_GUICtrlToolbar_GetExtendedStyle

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <GuiToolbar.au3>
#include <WindowsConstants.au3>

Global $g_hGUI, $g_idMemo

Example()

Func Example()
    Local $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $g_hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($g_hGUI)
    _GUICtrlToolbar_SetExtendedStyle($hToolbar, $TBSTYLE_EX_DRAWDDARROWS)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, 0, $BTNS_DROPDOWN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Show extended styles in use
    MemoWrite("Extended sytles: " & _GUICtrlToolbar_GetExtendedStyle($hToolbar))

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Handle TBN_DROPDOWN message
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $tNMHDR, $iCode, $hMenu

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $iCode = DllStructGetData($tNMHDR, "Code")

    If $iCode = $TBN_DROPDOWN Then
        $hMenu = _GUICtrlMenu_CreatePopup()
        _GUICtrlMenu_AddMenuItem($hMenu, "Template 1", 2000)
        _GUICtrlMenu_AddMenuItem($hMenu, "Template 2", 2001)
        _GUICtrlMenu_AddMenuItem($hMenu, "Template 3", 2002)
        _GUICtrlMenu_TrackPopupMenu($hMenu, $g_hGUI)
        _GUICtrlMenu_DestroyMenu($hMenu)
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY


Function _GUICtrlToolbar_SetHotImageList

Function Reference

_GUICtrlToolbar_SetHotImageList

Sets the hot button image list

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetHotImageList ( $hWnd, $hImageList )

Parameters

$hWnd | Handle to the control
$hImageList | Handle to the image list that will be set

Return Value

Success: | the handle to the image list previously used to display hot buttons.
Failure: | 0.

Related

_GUICtrlToolbar_GetHotImageList

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $hNormal, $hDisabled, $hHot
    Local Enum $idRed = 1000, $idGreen, $idBlue

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    GUISetBkColor(0xffff00)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create normal image list
    $hNormal = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 32, 24))
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 32, 24))
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 32, 24))
    _GUICtrlToolbar_SetImageList($hToolbar, $hNormal)

    ; Create disabled image list
    $hDisabled = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    _GUICtrlToolbar_SetDisabledImageList($hToolbar, $hDisabled)

    ; Create hot image list
    $hHot = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0x111111, 32, 24))
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0x888888, 32, 24))
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0xAAAAAA, 32, 24))
    Local $hPrevImageList = _GUICtrlToolbar_SetHotImageList($hToolbar, $hHot)
    MemoWrite("Previous Hot image list handle .: 0x" & Hex($hPrevImageList))
    MemoWrite("IsPtr = " & IsPtr($hPrevImageList) & " IsHWnd = " & IsHWnd($hPrevImageList))

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $idRed, 0)
    _GUICtrlToolbar_AddButton($hToolbar, $idGreen, 1)
    _GUICtrlToolbar_AddButton($hToolbar, $idBlue, 2)

    ; Disable Blue button
    _GUICtrlToolbar_EnableButton($hToolbar, $idBlue, False)

    ; Show image list handles
    MemoWrite("Disabled list handle .: 0x" & Hex(_GUICtrlToolbar_GetDisabledImageList($hToolbar)))
    MemoWrite("Hot list handle ......: 0x" & Hex(_GUICtrlToolbar_GetHotImageList($hToolbar)))
    MemoWrite("Normal list handle ...: 0x" & Hex(_GUICtrlToolbar_GetImageList($hToolbar)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetHotItem

Function Reference

_GUICtrlToolbar_SetHotItem

Sets the hot item

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetHotItem ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the control
$iIndex | Index of the item that will be made hot. If this value is -1, none of the items will be hot.

Return Value

Returns the index of the previous hot item, or -1 if there was no hot item.

Remarks

A button is considered hot when the cursor is over it

Related

_GUICtrlToolbar_GetHotItem

Example

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

Global $g_hToolbar, $g_idMemo
Global $g_iItem ; Command identifier of the button associated with the notification.
Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp

Example()

Func Example()
    Local $hGUI, $aSize

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 600, 400)
    $g_hToolbar = _GUICtrlToolbar_Create($hGUI)
    $aSize = _GUICtrlToolbar_GetMaxSize($g_hToolbar)

    $g_idMemo = GUICtrlCreateEdit("", 2, $aSize[1] + 20, 596, 396 - ($aSize[1] + 20), $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)
    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap($g_hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add buttons
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($g_hToolbar)
    _GUICtrlToolbar_AddButton($g_hToolbar, $e_idHelp, $STD_HELP)

    ; Gets the hot item
    Local $iHotItem = _GUICtrlToolbar_GetHotItem($g_hToolbar)
    MemoWrite("before $iHotItem= " & $iHotItem)

    ; Sets the hot item
    _GUICtrlToolbar_SetHotItem($g_hToolbar, 2)
    ; Gets the hot item
    $iHotItem = _GUICtrlToolbar_GetHotItem($g_hToolbar)
    MemoWrite("after $iHotItem= " & $iHotItem)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; WM_NOTIFY event handler
Func _WM_NOTIFY($hWndGUI, $iMsgID, $wParam, $lParam)
    #forceref $hWndGUI, $iMsgID, $wParam
    Local $tNMHDR, $hWndFrom, $iCode, $iNew, $iFlags, $iOld
    Local $tNMTBHOTITEM
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hToolbar
            Switch $iCode
                Case $NM_LDOWN
                    ;----------------------------------------------------------------------------------------------
                    MemoWrite("$NM_LDOWN: Clicked Item: " & $g_iItem & " at index: " & _GUICtrlToolbar_CommandToIndex($g_hToolbar, $g_iItem))
                    ;----------------------------------------------------------------------------------------------
                Case $TBN_HOTITEMCHANGE
                    $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam)
                    $iOld = DllStructGetData($tNMTBHOTITEM, "idOld")
                    $iNew = DllStructGetData($tNMTBHOTITEM, "idNew")
                    $g_iItem = $iNew
                    $iFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags")
                    If BitAND($iFlags, $HICF_LEAVING) = $HICF_LEAVING Then
                        MemoWrite("$HICF_LEAVING: " & $iOld)
                    Else
                        Switch $iNew
                            Case $e_idNew
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $e_idNew")
                                ;----------------------------------------------------------------------------------------------
                            Case $e_idOpen
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $e_idOpen")
                                ;----------------------------------------------------------------------------------------------
                            Case $e_idSave
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $e_idSave")
                                ;----------------------------------------------------------------------------------------------
                            Case $e_idHelp
                                ;----------------------------------------------------------------------------------------------
                                MemoWrite("$TBN_HOTITEMCHANGE: $idHelp")
                                ;----------------------------------------------------------------------------------------------
                        EndSwitch
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY


Function _GUICtrlToolbar_SetImageList

Function Reference

_GUICtrlToolbar_SetImageList

Sets the default button image list

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetImageList ( $hWnd, $hImageList )

Parameters

$hWnd | Handle to the control
$hImageList | Handle to the image list to set. If this parameter is 0, no images are displayed in the buttons.

Return Value

Success: | the handle to the image list previously used to display buttons in their default state.
Failure: | 0.

Related

_GUICtrlToolbar_GetImageList

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $hNormal, $hDisabled, $hHot
    Local Enum $idRed = 1000, $idGreen, $idBlue

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    GUISetBkColor(0xffff00)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Create normal image list
    $hNormal = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0xFF0000, 32, 24))
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0x00FF00, 32, 24))
    _GUIImageList_Add($hNormal, _WinAPI_CreateSolidBitmap($hGUI, 0x0000FF, 32, 24))
    Local $hPrevImageList = _GUICtrlToolbar_SetImageList($hToolbar, $hNormal)
    MemoWrite("Previous Image list handle .: 0x" & Hex($hPrevImageList))
    MemoWrite("IsPtr = " & IsPtr($hPrevImageList) & " IsHWnd = " & IsHWnd($hPrevImageList))

    ; Create disabled image list
    $hDisabled = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    _GUIImageList_Add($hDisabled, _WinAPI_CreateSolidBitmap($hGUI, 0xCCCCCC, 32, 24))
    _GUICtrlToolbar_SetDisabledImageList($hToolbar, $hDisabled)

    ; Create hot image list
    $hHot = _GUIImageList_Create(32, 24)
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0x111111, 32, 24))
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0x888888, 32, 24))
    _GUIImageList_Add($hHot, _WinAPI_CreateSolidBitmap($hGUI, 0xAAAAAA, 32, 24))
    _GUICtrlToolbar_SetHotImageList($hToolbar, $hHot)

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $idRed, 0)
    _GUICtrlToolbar_AddButton($hToolbar, $idGreen, 1)
    _GUICtrlToolbar_AddButton($hToolbar, $idBlue, 2)

    ; Disable Blue button
    _GUICtrlToolbar_EnableButton($hToolbar, $idBlue, False)

    ; Show image list handles
    MemoWrite("Disabled list handle .: 0x" & Hex(_GUICtrlToolbar_GetDisabledImageList($hToolbar)))
    MemoWrite("Hot list handle ......: 0x" & Hex(_GUICtrlToolbar_GetHotImageList($hToolbar)))
    MemoWrite("Normal list handle ...: 0x" & Hex(_GUICtrlToolbar_GetImageList($hToolbar)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetIndent

Function Reference

_GUICtrlToolbar_SetIndent

Sets the indentation for the first button control

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetIndent ( $hWnd, $iIndent )

Parameters

$hWnd | Handle to the control
$iIndent | Indentation in pixels

Return Value

Success: | True.
Failure: | False.

Example

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

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Set the first button indent
    _GUICtrlToolbar_SetIndent($hToolbar, 24)

    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_SetIndeterminate

Function Reference

_GUICtrlToolbar_SetIndeterminate

Sets or clears the indeterminate state of the specified button

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetIndeterminate ( $hWnd, $iCommandID [, $bState = True] )

Parameters

$hWnd | Handle to the control
$iCommandID | Button command ID
$bState | [optional] True if indeterminate, otherwise False

Return Value

Success: | True.
Failure: | False.

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Set Save button state
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button indeterminate: " & _GUICtrlToolbar_IsButtonIndeterminate($hToolbar, $e_idSave))
    _GUICtrlToolbar_SetIndeterminate($hToolbar, $e_idSave)
    MsgBox($MB_SYSTEMMODAL, "Information", "Save button indeterminate: " & _GUICtrlToolbar_IsButtonIndeterminate($hToolbar, $e_idSave))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_SetInsertMark

Function Reference

_GUICtrlToolbar_SetInsertMark

Sets the current insertion mark for the toolbar

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetInsertMark ( $hWnd, $iButton [, $iFlags = 0] )

Parameters

$hWnd | Handle to the control
$iButton | 0-based index of the insertion mark. If -1, there is no mark.
$iFlags | [optional] Defines where the insertion mark is in relation to $iButton: 0 - Left of the specified button 1 - Right of the specified button 2 - Background of the toolbar

Return Value

None.

Related

_GUICtrlToolbar_GetInsertMark

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aMark
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Set insert mark
    _GUICtrlToolbar_SetInsertMarkColor($hToolbar, 0xFF0000)
    _GUICtrlToolbar_SetInsertMark($hToolbar, 1, 1)

    ; Show insert mark
    $aMark = _GUICtrlToolbar_GetInsertMark($hToolbar)
    MemoWrite("Index ........: " & $aMark[0])
    MemoWrite("Relationship .: " & $aMark[1])
    MemoWrite("Mark color ...: 0x" & Hex(_GUICtrlToolbar_GetInsertMarkColor($hToolbar), 6))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetInsertMarkColor

Function Reference

_GUICtrlToolbar_SetInsertMarkColor

Sets the color used to draw the insertion mark

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetInsertMarkColor ( $hWnd, $iColor )

Parameters

$hWnd | Handle to the control
$iColor | Insertion mark color

Return Value

Returns the previous insertion mark color.

Related

_GUICtrlToolbar_GetInsertMarkColor

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aMark
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Set insert mark
    _GUICtrlToolbar_SetInsertMarkColor($hToolbar, 0xFF0000)
    _GUICtrlToolbar_SetInsertMark($hToolbar, 1, 1)

    ; Show insert mark
    $aMark = _GUICtrlToolbar_GetInsertMark($hToolbar)
    MemoWrite("Index ........: " & $aMark[0])
    MemoWrite("Relationship .: " & $aMark[1])
    MemoWrite("Mark color ...: 0x" & Hex(_GUICtrlToolbar_GetInsertMarkColor($hToolbar), 6))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetMaxTextRows

Function Reference

_GUICtrlToolbar_SetMaxTextRows

Sets the maximum number of text rows displayed button

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetMaxTextRows ( $hWnd, $iMaxRows )

Parameters

$hWnd | Handle to the control
$iMaxRows | Maximum number of rows of text that can be displayed

Return Value

Success: | True.
Failure: | False.

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $aStrings[4]
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Enable multi line button labels
    _GUICtrlToolbar_SetButtonWidth($hToolbar, 32, 40)
    _GUICtrlToolbar_SetMaxTextRows($hToolbar, 2)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString($hToolbar, "&New Button")
    $aStrings[1] = _GUICtrlToolbar_AddString($hToolbar, "&Open Button")
    $aStrings[2] = _GUICtrlToolbar_AddString($hToolbar, "&Save Button")
    $aStrings[3] = _GUICtrlToolbar_AddString($hToolbar, "&Help Button")

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Show number of text rows
    MsgBox($MB_SYSTEMMODAL, "Information", "Number of text rows:" & _GUICtrlToolbar_GetTextRows($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_SetMetrics

Function Reference

_GUICtrlToolbar_SetMetrics

Sets the metrics of a toolbar control

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetMetrics ( $hWnd, $iXPad, $iYPad, $iXSpacing, $iYSpacing )

Parameters

$hWnd | Handle to the control
$iXPad | Width of the padding inside the toolbar buttons
$iYPad | Height of the padding inside the toolbar buttons
$iXSpacing | Width of the space between toolbar buttons
$iYSpacing | Height of the space between toolbar buttons

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlToolbar_GetMetrics

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aMetrics
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    MemoWrite("Before _GUICtrlToolbar_SetMetrics")

    Sleep(3000)
    GUISetState(@SW_LOCK)
    ; Set control metrics
    MemoWrite("Step 1:")
    MemoWrite("$iXPad = 10")
    _GUICtrlToolbar_SetMetrics($hToolbar, 10, 0, 0, 0)
    GUISetState(@SW_UNLOCK)
    MemoWrite("==> No effect")

    Sleep(3000)
    GUISetState(@SW_LOCK)
    ; Set control metrics
    MemoWrite("Step 2:")
    MemoWrite("$iYPad = 10")
    _GUICtrlToolbar_SetMetrics($hToolbar, 0, 10, 0, 0)
    GUISetState(@SW_UNLOCK)
    MemoWrite("==> No effect")

    Sleep(3000)
    GUISetState(@SW_LOCK)
    ; Set control metrics
    MemoWrite("Step 3:")
    MemoWrite("$iXSpacing = 10")
    _GUICtrlToolbar_SetMetrics($hToolbar, 0, 0, 10, 0)
    GUISetState(@SW_UNLOCK)
    MemoWrite("==> buttons are spaced")

    Sleep(3000)
    GUISetState(@SW_LOCK)
    ; Set control metrics
    MemoWrite("Step 4:")
    MemoWrite("$iYSpacing = 10")
    _GUICtrlToolbar_SetMetrics($hToolbar, 0, 0, 0, 10)
    GUISetState(@SW_UNLOCK)
    MemoWrite("==> No effect has only one line of buttons")

    Sleep(3000)
    GUISetState(@SW_LOCK)
    ; Set control metrics
    MemoWrite("")
    MemoWrite("Step 5:")
    MemoWrite("$iXPad = 10")
    MemoWrite("$iYPad = 10")
    MemoWrite("$iXSpacing = 10")
    MemoWrite("$iYSpacing = 10")
    _GUICtrlToolbar_SetMetrics($hToolbar, 10, 10, 10, 10)
    GUISetState(@SW_UNLOCK)
    MemoWrite("==> Spaced just because $iXpacing is not 0")

    ; Show control metrics
    $aMetrics = _GUICtrlToolbar_GetMetrics($hToolbar)
    MemoWrite("Button padding width ...: " & $aMetrics[0])
    MemoWrite("Button padding height ..: " & $aMetrics[1])
    MemoWrite("Button spacing width ...: " & $aMetrics[2])
    MemoWrite("Button spacing height ..: " & $aMetrics[3])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetPadding

Function Reference

_GUICtrlToolbar_SetPadding

Sets the padding control

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetPadding ( $hWnd, $iCX, $iCY )

Parameters

$hWnd | Handle to the control
$iCX | The horizontal padding, in pixels
$iCY | The vertical padding, in pixels

Return Value

Returns the previous horizontal padding in the low word and the previous vertical padding in the high word.

Remarks

The padding values are used to create a blank area between the edge of the button and the button's image and/or text.
The horizontal padding value is applied to both the right and left of the button and the vertical padding value is applied to both the top and bottom of the button.
Padding is only applied to buttons that have the $BTNS_AUTOSIZE style.

Related

_GUICtrlToolbar_GetPadding

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $aPad
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Set control padding
    _GUICtrlToolbar_SetPadding($hToolbar, 2, 3)

    ; Show control padding
    $aPad = _GUICtrlToolbar_GetPadding($hToolbar)
    MemoWrite("Horizontal padding : " & $aPad[0])
    MemoWrite("Vertical padding ..: " & $aPad[1])
    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetParent

Function Reference

_GUICtrlToolbar_SetParent

Sets the window to which the control sends notification messages

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetParent ( $hWnd, $hParent )

Parameters

$hWnd | Handle to the control
$hParent | Handle to the window to receive notification messages

Return Value

Success: | the handle to the previous notification window.
Failure: | 0.

Remarks

The $TB_SETPARENT message does not change the parent window that was specified when the control was created.
Calling the _WinAPI_GetParent() function control will return the actual parent window, not the window specified in
$TB_SETPARENT. To change the control's parent window, call the _WinAPI_SetParent() function.


Function _GUICtrlToolbar_SetRows

Function Reference

_GUICtrlToolbar_SetRows

Sets the number of rows of buttons

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetRows ( $hWnd, $iRows [, $bLarger = True] )

Parameters

$hWnd | Handle to the control
$iRows | Number of rows requested. The minimum number of rows is one, and the maximum number of rows is equal to the total number of buttons.
$bLarger | [optional] Flag that indicates whether to create more rows than requested when the system can not create the number of rows specified by $iRows. If this parameter is True, the system creates more rows. If it is False, the system creates fewer rows.

Return Value

Returns an array with the following format:
[0] - X coordinate of the upper left corner of the rectangle
[1] - Y coordinate of the upper left corner of the rectangle
[2] - X coordinate of the lower right corner of the rectangle
[3] - Y coordinate of the lower right corner of the rectangle

Remarks

Because the system does not break up button groups when setting the number of rows, the resulting number of rows might differ from the number requested.

Related

_GUICtrlToolbar_GetRows

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 36, 2, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Create a vertical toolbar
    _GUICtrlToolbar_SetStyle($hToolbar, BitOR($CCS_LEFT, $TBSTYLE_FLAT))
    _GUICtrlToolbar_SetRows($hToolbar, 4)

    ; Show number of rows
    MemoWrite("Number of rows:" & _GUICtrlToolbar_GetRows($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetStyle

Function Reference

_GUICtrlToolbar_SetStyle

Sets the style control

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetStyle ( $hWnd, $iStyle )

Parameters

$hWnd | Handle to the control
$iStyle | Control styles. Can be a combination of the following: $TBSTYLE_TOOLTIPS - Creates a ToolTip control $TBSTYLE_WRAPABLE - Creates a toolbar that can have multiple lines of buttons $TBSTYLE_ALTDRAG - Allows users to change a toolbar button's position by dragging it $TBSTYLE_FLAT - Creates a flat toolbar $TBSTYLE_LIST - Creates a flat toolbar with button text to the right of the bitmap $TBSTYLE_CUSTOMERASE - Sends $NM_CUSTOMDRAW messages when processing $WM_ERASEBKGND messages $TBSTYLE_REGISTERDROP - Sends $TBN_GETOBJECT messages to request drop target objects $TBSTYLE_TRANSPARENT - Creates a transparent toolbar

Return Value

None.

Related

_GUICtrlToolbar_GetStyle

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Set control style
    _GUICtrlToolbar_SetStyle($hToolbar, BitOR($TBSTYLE_LIST, $CCS_TOP))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Show control style
    MemoWrite("Toolbar style .: 0x" & Hex(_GUICtrlToolbar_GetStyle($hToolbar)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetStyleAltDrag

Function Reference

_GUICtrlToolbar_SetStyleAltDrag

Sets whether that the control allows buttons to be dragged

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetStyleAltDrag ( $hWnd [, $bState = True] )

Parameters

$hWnd | Handle to the control
$bState | [optional] True to set, False to unset

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlToolbar_GetStyleAltDrag

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $bStyle
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Change control style
    $bStyle = _GUICtrlToolbar_GetStyleAltDrag($hToolbar)
    MemoWrite("Toolbar has drag style .: " & $bStyle)
    _GUICtrlToolbar_SetStyleAltDrag($hToolbar, Not $bStyle)
    MemoWrite("Toolbar has drag style .: " & _GUICtrlToolbar_GetStyleAltDrag($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetStyleCustomErase

Function Reference

_GUICtrlToolbar_SetStyleCustomErase

Sets whether the control generates NM_CUSTOMDRAW notification messages

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetStyleCustomErase ( $hWnd [, $bState = True] )

Parameters

$hWnd | Handle to the control
$bState | [optional] True to set, False to unset

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlToolbar_GetStyleCustomErase

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $bStyle
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Change control style
    $bStyle = _GUICtrlToolbar_GetStyleCustomErase($hToolbar)
    MemoWrite("Toolbar sends custom erase .: " & $bStyle)
    _GUICtrlToolbar_SetStyleCustomErase($hToolbar, Not $bStyle)
    MemoWrite("Toolbar sends custom erase .: " & _GUICtrlToolbar_GetStyleCustomErase($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetStyleFlat

Function Reference

_GUICtrlToolbar_SetStyleFlat

Sets whether the control is flat

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetStyleFlat ( $hWnd, $bState )

Parameters

$hWnd | Handle to the control
$bState | True to set, false to unset

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlToolbar_GetStyleFlat

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $bStyle
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Change control style
    $bStyle = _GUICtrlToolbar_GetStyleFlat($hToolbar)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has flat style .: " & $bStyle)
    GUISetState(@SW_LOCK)
    _GUICtrlToolbar_SetStyleFlat($hToolbar, Not $bStyle)
    GUISetState(@SW_UNLOCK)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has flat style .: " & _GUICtrlToolbar_GetStyleFlat($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_SetStyleList

Function Reference

_GUICtrlToolbar_SetStyleList

Sets whether the control has button text to the right of the bitmap

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetStyleList ( $hWnd, $bState )

Parameters

$hWnd | Handle to the control
$bState | True to set, false to unset

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlToolbar_GetStyleList

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $bStyle
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Change control style
    $bStyle = _GUICtrlToolbar_GetStyleList($hToolbar)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has list style .: " & $bStyle)
    _GUICtrlToolbar_SetStyleList($hToolbar, Not $bStyle)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has list style .: " & _GUICtrlToolbar_GetStyleList($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_SetStyleRegisterDrop

Function Reference

_GUICtrlToolbar_SetStyleRegisterDrop

Sets whether the control generates TBN_GETOBJECT notification messages

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetStyleRegisterDrop ( $hWnd, $bState )

Parameters

$hWnd | Handle to the control
$bState | True to set, false to unset

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlToolbar_GetStyleRegisterDrop

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $bStyle
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Change control style
    $bStyle = _GUICtrlToolbar_GetStyleRegisterDrop($hToolbar)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has register drop style .: " & $bStyle)
    _GUICtrlToolbar_SetStyleRegisterDrop($hToolbar, Not $bStyle)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has register drop style .: " & _GUICtrlToolbar_GetStyleRegisterDrop($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_SetStyleToolTips

Function Reference

_GUICtrlToolbar_SetStyleToolTips

Sets whether the control has tooltips

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetStyleToolTips ( $hWnd, $bState )

Parameters

$hWnd | Handle to the control
$bState | True to set, false to unset

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlToolbar_GetStyleToolTips

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $bStyle
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Change control style
    $bStyle = _GUICtrlToolbar_GetStyleToolTips($hToolbar)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has tooltips style .: " & $bStyle)
    _GUICtrlToolbar_SetStyleToolTips($hToolbar, Not $bStyle)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has tooltips style .: " & _GUICtrlToolbar_GetStyleToolTips($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_SetStyleTransparent

Function Reference

_GUICtrlToolbar_SetStyleTransparent

Sets whether the control is transparent

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetStyleTransparent ( $hWnd, $bState )

Parameters

$hWnd | Handle to the control
$bState | True to set, false to unset

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlToolbar_GetStyleTransparent

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $bStyle
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetBkColor(0xffffff)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Change control style
    $bStyle = _GUICtrlToolbar_GetStyleTransparent($hToolbar)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has transparent style .: " & $bStyle)
    GUISetState(@SW_LOCK)
    _GUICtrlToolbar_SetStyleTransparent($hToolbar, Not $bStyle)
    GUISetState(@SW_UNLOCK)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has transparent style .: " & _GUICtrlToolbar_GetStyleTransparent($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_SetStyleWrapable

Function Reference

_GUICtrlToolbar_SetStyleWrapable

Sets whether the control is wrapable

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetStyleWrapable ( $hWnd, $bState )

Parameters

$hWnd | Handle to the control
$bState | True to set, false to unset

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlToolbar_GetStyleWrapable

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hToolbar, $bStyle
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Change control style
    $bStyle = _GUICtrlToolbar_GetStyleWrapable($hToolbar)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has wrapable style .: " & $bStyle)
    _GUICtrlToolbar_SetStyleWrapable($hToolbar, Not $bStyle)
    MsgBox($MB_SYSTEMMODAL, "Information", "Toolbar has wrapable style .: " & _GUICtrlToolbar_GetStyleWrapable($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example


Function _GUICtrlToolbar_SetToolTips

Function Reference

_GUICtrlToolbar_SetToolTips

Associates a ToolTip control with a toolbar

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetToolTips ( $hWnd, $hToolTip )

Parameters

$hWnd | Handle to the control
$hToolTip | Handle to the ToolTip control

Return Value

None.

Remarks

Any buttons that are added to the control before sending the calling this function will not be registered with the ToolTip control.

Related

_GUICtrlToolbar_GetToolTips

Example

#include <GUIConstantsEx.au3>
#include <GuiToolbar.au3>
#include <GuiToolTip.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp

Example()

Func Example()
    Local $hGUI, $hToolbar, $hToolTip

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    GUISetState(@SW_SHOW)

    ; Create ToolTip
    $hToolTip = _GUIToolTip_Create($hToolbar)
    _GUICtrlToolbar_SetToolTips($hToolbar, $hToolTip)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idHelp, $STD_HELP)

    ; Show ToolTip handle
    MsgBox($MB_SYSTEMMODAL, "Information", "ToolTip handle .: 0x" & Hex(_GUICtrlToolbar_GetToolTips($hToolbar)))

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Handle WM_NOTIFY messages
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $tInfo, $iID, $iCode

    $tInfo = DllStructCreate($tagNMTTDISPINFO, $lParam)
    $iCode = DllStructGetData($tInfo, "Code")
    If $iCode = $TTN_GETDISPINFOW Then
        $iID = DllStructGetData($tInfo, "IDFrom")
        Switch $iID
            Case $e_idNew
                DllStructSetData($tInfo, "aText", "New")
            Case $e_idOpen
                DllStructSetData($tInfo, "aText", "Open")
            Case $e_idSave
                DllStructSetData($tInfo, "aText", "Save")
            Case $e_idHelp
                DllStructSetData($tInfo, "aText", "Help")
        EndSwitch
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY


Function _GUICtrlToolbar_SetUnicodeFormat

Function Reference

_GUICtrlToolbar_SetUnicodeFormat

Sets the Unicode character format flag

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetUnicodeFormat ( $hWnd [, $bUnicode = False] )

Parameters

$hWnd | Handle to the control
$bUnicode | [optional] Unicode character setting: True - Control uses Unicode characters False - Control uses ANSI characters

Return Value

Returns the previous character format flag setting.

Related

_GUICtrlToolbar_GetUnicodeFormat

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $hToolbar, $bUnicode
    Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 400, 300)
    $hToolbar = _GUICtrlToolbar_Create($hGUI)
    $g_idMemo = GUICtrlCreateEdit("", 2, 36, 396, 262, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
        Case 0
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
        Case 2
            _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $e_idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $e_idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

    ; Show Unicode format
    $bUnicode = _GUICtrlToolbar_GetUnicodeFormat($hToolbar)
    MemoWrite("Unicode format .:" & $bUnicode)

    ; Change Unicode format
    _GUICtrlToolbar_SetUnicodeFormat($hToolbar, Not $bUnicode)
    MemoWrite("Unicode format .:" & _GUICtrlToolbar_GetUnicodeFormat($hToolbar))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _GUICtrlToolbar_SetWindowTheme

Function Reference

_GUICtrlToolbar_SetWindowTheme

Sets the visual style

#include <GuiToolbar.au3>
_GUICtrlToolbar_SetWindowTheme ( $hWnd, $sTheme )

Parameters

$hWnd | Handle to the control
$sTheme | String that contains the toolbar visual style

Return Value

None.


User Defined Functions

GuiToolTip user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiToolTip.au3>.

User Defined Function | Description
_GUIToolTip_Activate | Activates a ToolTip control
_GUIToolTip_AddTool | Registers a tool with the ToolTip control
_GUIToolTip_AdjustRect | Calculates the text display rectangle from the window rectangle
_GUIToolTip_BitsToTTF | Decode bit flags to TTF_* strings
_GUIToolTip_Create | Creates a ToolTip control
_GUIToolTip_Deactivate | Deactivates a ToolTip control
_GUIToolTip_DelTool | Deletes a tool from a tooltip control
_GUIToolTip_Destroy | Delete a ToolTip control
_GUIToolTip_EnumTools | Retrieves information about the current tool
_GUIToolTip_GetBubbleHeight | Returns the height of the control
_GUIToolTip_GetBubbleSize | Returns the width and height of a ToolTip control
_GUIToolTip_GetBubbleWidth | Returns the width of a ToolTip control
_GUIToolTip_GetCurrentTool | Retrieves information for the current tool
_GUIToolTip_GetDelayTime | Retrieves the initial, pop-up or reshow durations of a ToolTip control
_GUIToolTip_GetMargin | Retrieves the top, left, bottom, and right margins of a ToolTip control
_GUIToolTip_GetMarginEx | Retrieves the top, left, bottom, and right margins of a ToolTip control
_GUIToolTip_GetMaxTipWidth | Retrieves the maximum width of a ToolTip window
_GUIToolTip_GetText | Retrieves the text of a tool
_GUIToolTip_GetTipBkColor | Retrieves the background color
_GUIToolTip_GetTipTextColor | Retrieves the text color of a ToolTip control
_GUIToolTip_GetTitleBitMap | Retrieves the title bitmap icon
_GUIToolTip_GetTitleText | Retrieve the title
_GUIToolTip_GetToolCount | Returns the count of tools maintained by the ToolTip control
_GUIToolTip_GetToolInfo | Retrieves the information about a specific tool
_GUIToolTip_HitTest | Retrieves the information that a ToolTip control maintains about a tool
_GUIToolTip_NewToolRect | Sets a new bounding rectangle for a tool
_GUIToolTip_Pop | Removes a displayed ToolTip from view
_GUIToolTip_PopUp | Causes the ToolTip to display at the coordinates of the last mouse message
_GUIToolTip_SetDelayTime | Sets the initial, pop-up, and reshow durations of a ToolTip
_GUIToolTip_SetMargin | Sets the top, left, bottom, and right margins of a ToolTip
_GUIToolTip_SetMaxTipWidth | Sets the maximum width for a ToolTip window
_GUIToolTip_SetTipBkColor | Sets the background color of a ToolTip
_GUIToolTip_SetTipTextColor | Sets the text color
_GUIToolTip_SetTitle | Adds a standard icon and title string
_GUIToolTip_SetToolInfo | Sets the information for a tool
_GUIToolTip_SetWindowTheme | Sets the visual style
_GUIToolTip_ToolExists | Determines whether a tool currently exists (is displayed)
_GUIToolTip_ToolToArray | Transfers a ToolInfo structure to an array
_GUIToolTip_TrackActivate | Activates or deactivates a tracking ToolTip
_GUIToolTip_TrackPosition | Sets the position of a tracking ToolTip
_GUIToolTip_Update | Forces the current tool to be redrawn
_GUIToolTip_UpdateTipText | Sets the ToolTip text for a tool


Function _GUIToolTip_Activate

Function Reference

_GUIToolTip_Activate

Activates a ToolTip control

#include <GuiToolTip.au3>
_GUIToolTip_Activate ( $hWnd )

Parameters

$hWnd Handle to the ToolTip control (returned by _GUIToolTip_Create.)

Return Value

None.

Related

_GUIToolTip_Deactivate

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idToggleTips = GUICtrlCreateButton("Tips: On", 30, 32, 180, 28)
    Local $hToggleTips = GUICtrlGetHandle($idToggleTips)
    ; create a tooltip control using the balloon style
    Local $hToolTip = _GUIToolTip_Create(0, $TTS_BALLOON)

    ; add a tool to the tooltip control using the default settings.
    _GUIToolTip_AddTool($hToolTip, 0, "Tooltip for the GUI", $hGUI)
    ; add a tool to the tooltip control centering the tip below the button instead of above the mouse pointer
    _GUIToolTip_AddTool($hToolTip, 0, "This button toggles the tooltips on and off", $hToggleTips, 0, 0, 0, 0, BitOR($TTF_CENTERTIP, $TTF_SUBCLASS, $TTF_IDISHWND))
    GUISetState(@SW_SHOW)

    Local $bActivate = True
    While 1
        Switch GUIGetMsg()
            Case $idToggleTips
                $bActivate = Not $bActivate
                If $bActivate Then
                    _GUIToolTip_Activate($hToolTip)
                    GUICtrlSetData($idToggleTips, 'Tips: On')
                Else
                    _GUIToolTip_Deactivate($hToolTip)
                    GUICtrlSetData($idToggleTips, 'Tips: Off')
                EndIf

            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_AddTool

Function Reference

_GUIToolTip_AddTool

Registers a tool with the ToolTip control

#include <GuiToolTip.au3>
_GUIToolTip_AddTool ( $hTool, $hWnd, $sText [, $iID = 0 [, $iLeft = 0 [, $iTop = 0 [, $iRight = 0 [, $iBottom = 0 [, $iFlags = Default [, $iParam = 0]]]]]]] )

Parameters

$hTool | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$hWnd | Handle of the window that contains the tool, or 0
$sText | Text for the ToolTip control. See remark.
$iID | [optional] Identifier of the tool, or Window handle of the control the tool is to be assigned to
$iLeft | [optional] X coordinate of the upper left corner of the rectangle
$iTop | [optional] Y coordinate of the upper left corner of the rectangle
$iRight | [optional] X coordinate of the lower right corner of the rectangle
$iBottom | [optional] Y coordinate of the lower right corner of the rectangle
$iFlags | [optional] Flags that control the ToolTip display: $TTF_IDISHWND - Indicates that $iID is a window or control handle, instead of the ID of the tool $TTF_CENTERTIP - Centers the tooltip below the control specified by $iID $TTF_RTLREADING - Indicates that text will be displayed in the opposite direction of the parent window (see remarks) $TTF_SUBCLASS - Indicates that the control should subclass the tool's window $TTF_TRACK - Positions the tooltip window next to the tool to which it corresponds $TTF_ABSOLUTE - Positions the window at the same coordinates provided by TTM_TRACKPOSITION. (see remarks) $TTF_TRANSPARENT- Causes the control to forward mouse messages to the parent window $TTF_PARSELINKS - Indicates that links in the control text should be displayed as links Default = BitOr($TTF_SUBCLASS, $TTF_IDISHWND)
$iParam | [optional] Application-defined value that is associated with the tool

Return Value

Success: | True.
Failure: | False.

Remarks

If a notification callback is needed, you have to set $sText = -1 (LPSTR_TEXTCALLBACK).

If you use the flag $TTF_IDISHWND then the coordinates in $iLeft, $iTop, $iRight and $iBottom are ignored.

If you use the flag $TTF_ABSOLUTE it must be used with the $TTF_TRACK flag.
Normal windows display text left-to-right (LTR). Windows can be mirrored to display languages such as Hebrew or Arabic that read right-to-left (RTL). Normally, tooltip text is displayed in the same direction as the text in its parent window. If $TTF_RTLREADING is set, tooltip text will read in the opposite direction from the text in the parent window.

Related

_GUIToolTip_DelTool

Example

Example 1

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("This is a button", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)
    ; create a tooltip control using default settings
    Local $hToolTip = _GUIToolTip_Create(0)

    ; add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "This is a ToolTip", $hButton)
    GUISetState(@SW_SHOW)

    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example

Example 2

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

; This example demonstrates how to add a tool, it does not assign the tool to any control, just an area of the GUI
Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)
    ; create frames to indicate where the tooltip will display when the mouse is in the
    ; correct location on the GUI, these frames do not have a tooltip assigned to it
    ; these frames are ONLY for visual representation as to where the tooltip will display,
    ; they are not needed to make the tooltip display.
    GUICtrlCreateLabel("", 10, 10, 160, 75, $SS_ETCHEDFRAME)
    ; this label control must be disabled or the tooltip will not display when the mouse
    ; is over it.
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateLabel("", 10, 84, 160, 75, $SS_ETCHEDFRAME)
    ; this label control must be disabled or the tooltip will not display when the mouse
    ; is over it.
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateLabel("", 169, 10, 160, 75, $SS_ETCHEDFRAME)
    ; this label control must be disabled or the tooltip will not display when the mouse
    ; is over it.
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateLabel("", 169, 84, 160, 75, $SS_ETCHEDFRAME)
    ; this label control must be disabled or the tooltip will not display when the mouse
    ; is over it.
    GUICtrlSetState(-1, $GUI_DISABLE)
    Local $idButton = GUICtrlCreateButton("This is a button", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)
    ; create a tooltip control using default settings
    Local $hToolTip = _GUIToolTip_Create(0)

    ; add 4 tools to the tooltip control, these tools are created using the location on the GUI
    ; rather than assigning them to a specific control.
    _GUIToolTip_AddTool($hToolTip, $hGUI, "Upper Left corner", 0, 10, 10, 168, 85, $TTF_SUBCLASS)
    _GUIToolTip_AddTool($hToolTip, $hGUI, "Upper Right corner", 0, 168, 10, 328, 85, $TTF_SUBCLASS)
    _GUIToolTip_AddTool($hToolTip, $hGUI, "Lower Left corner", 0, 10, 85, 168, 160, $TTF_SUBCLASS)
    _GUIToolTip_AddTool($hToolTip, $hGUI, "Lower Right corner", 0, 168, 85, 328, 160, $TTF_SUBCLASS)
    ; add a tool to the tooltip control that is assigned to the button control
    _GUIToolTip_AddTool($hToolTip, 0, "This tooltip belongs to the button", $hButton)
    GUISetState(@SW_SHOW)

    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_AdjustRect

Function Reference

_GUIToolTip_AdjustRect

Calculates the text display rectangle from the window rectangle

#include <GuiToolTip.au3>
_GUIToolTip_AdjustRect ( $hWnd, ByRef $tRECT [, $bLarger = True] )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$tRECT | $tagRECT structure that holds a window or text display rectangle
$bLarger | [optional] Value that specifies which operation to perform. If True, $tRECT is used to specify a text display rectangle and it receives the corresponding window rectangle. If False, $tRECT is used to specify a window rectangle and it receives the corresponding text display rectangle.

Return Value

Returns a $tagRECT structure.

Remarks

The ToolTip's window rectangle is somewhat larger than the text display rectangle that bounds the ToolTip string.
The window origin is also offset up and to the left from the origin of the text display rectangle.
To position the text display rectangle, you must calculate the corresponding window rectangle and use that rectangle to position the ToolTip.
_GUIToolTip_AdjustRect() handles this calculation for you.
If you set $bLarger to True, _GUIToolTip_AdjustRect() takes the size and position of the desired ToolTip text display rectangle, and passes back the size and position of the ToolTip window needed to display the text in the specified position.
If you set $bLarger to False you can specify a ToolTip window rectangle and _GUIToolTip_AdjustRect() will return the size and position of its text rectangle.


Function _GUIToolTip_BitsToTTF

Function Reference

_GUIToolTip_BitsToTTF

Decode bit flags to TTF_* strings

#include <GuiToolTip.au3>
_GUIToolTip_BitsToTTF ( $iFlags )

Parameters

$iFlags A value representing the ToolTip constants needing decoding

Return Value

Returns a comma separated string showing what ToolTip constants make up the $iFlags value.

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("This is a button", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)
    ; create a tooltip control using default settings
    Local $hToolTip = _GUIToolTip_Create(0)

    ; add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "This is a ToolTip", $hButton)
    GUISetState(@SW_SHOW)
    ; Retrieve the information for the tool assigned to the button
    Local $aTool = _GUIToolTip_GetToolInfo($hToolTip, 0, $hButton)
    ; Convert the array to text using the _GUIToolTip_BitsToTTF function to convert the flag
    ; information to a text string.
    MsgBox($MB_SYSTEMMODAL, "Tooltip info", "Flags: " & @TAB & _GUIToolTip_BitsToTTF($aTool[0]) & @CRLF & _
            "HWnd: " & @TAB & $aTool[1] & @CRLF & _
            "ID: " & @TAB & $aTool[2] & @CRLF & _
            "Left X:" & @TAB & $aTool[3] & @CRLF & _
            "Left Y:" & @TAB & $aTool[4] & @CRLF & _
            "Right X:" & @TAB & $aTool[5] & @CRLF & _
            "Right Y:" & @TAB & $aTool[6] & @CRLF & _
            "Instance:" & @TAB & $aTool[7] & @CRLF & _
            "Text:" & @TAB & $aTool[8] & @CRLF & _
            "lParam:" & @TAB & $aTool[9])

    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_Create

Function Reference

_GUIToolTip_Create

Creates a ToolTip control

#include <GuiToolTip.au3>
_GUIToolTip_Create ( $hWnd [, $iStyle = $_TT_ghTTDefaultStyle] )

Parameters

$hWnd | Handle to the window that will own the tool tip control. See remarks.
$iStyle | [optional] ToolTip style: $TTS_ALWAYSTIP (0x01)- Indicates that the ToolTip control appears when the cursor is on a tool even if the ToolTip control's owner window is inactive. Without this style, the ToolTip appears only when the tool's owner window is active. $TTS_NOPREFIX (0x02) - Prevents the system from stripping the ampersand character from a string. Without this style the system automatically strips ampersand characters. This allows an application to use the same string as both a menu item and as text in a ToolTip control. $TTS_NOANIMATE (0x10) - Disables sliding ToolTip animation. $TTS_NOFADE (0x20) - Disables fading ToolTip animation. $TTS_BALLOON (0x40) - Indicates that the ToolTip control has the appearance of a cartoon "balloon" $TTS_CLOSE (0x80) - Displays a close icon so that the tooltip can be cancelled Default: $_TT_ghTTDefaultStyle = BitOr($TTS_ALWAYSTIP, $TTS_NOPREFIX)

Return Value

Success: | The handle to the Tooltip control.
Failure: | 0.

Remarks

$hWnd is usually set to zero (0), or a handle to the parent or owner window of the window being created. To create a child window or an owned window, supply a valid window handle.

Related

_GUIToolTip_Destroy

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 270, 200)

    Local $idButton = GUICtrlCreateButton("Add", 30, 32, 75, 25)
    Local $hButton = GUICtrlGetHandle($idButton)
    Local $idClear = GUICtrlCreateButton("Clear", 30, 72, 75, 25)
    Local $hClear = GUICtrlGetHandle($idClear)
    Local $idMylist = GUICtrlCreateList("Item 1", 120, 32, 121, 97)
    Local $hMylist = GUICtrlGetHandle($idMylist)
    Local $idClose = GUICtrlCreateButton("Exit button", 80, 150, 110, 28)
    Local $hClose = GUICtrlGetHandle($idClose)

    ; Create 2 tooltip controls
    Local $hToolTip1 = _GUIToolTip_Create(0, BitOR($_TT_ghTTDefaultStyle, $TTS_BALLOON)); balloon style tooltip
    Local $hToolTip2 = _GUIToolTip_Create(0) ; default style tooltip
    _GUIToolTip_SetMaxTipWidth($hToolTip2, 100) ; this allows multiline tooltips to be used with $hToolTip2
    ; add tools to the tooltip controls
    _GUIToolTip_AddTool($hToolTip1, 0, "Adds an item to the list", $hButton)
    _GUIToolTip_AddTool($hToolTip1, 0, "Exit the script", $hClose)
    _GUIToolTip_AddTool($hToolTip1, 0, "The listbox", $hMylist)
    _GUIToolTip_AddTool($hToolTip2, 0, "Clears the list", $hClear)
    _GUIToolTip_AddTool($hToolTip2, 0, "Multiline tooltip" & @CRLF & "for the GUI", $hGUI) ; Multiline ToolTip
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $idButton
                GUICtrlSetData($idMylist, 'The Add button was pressed"|')
            Case $idClear
                GUICtrlSetData($idMylist, '')
            Case $idClose, $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    ; Destroy the tooltip controls
    _GUIToolTip_Destroy($hToolTip1)
    _GUIToolTip_Destroy($hToolTip2)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_Deactivate

Function Reference

_GUIToolTip_Deactivate

Deactivates a ToolTip control

#include <GuiToolTip.au3>
_GUIToolTip_Deactivate ( $hWnd )

Parameters

$hWnd Handle to the ToolTip control (returned by _GUIToolTip_Create.)

Return Value

None.

Related

_GUIToolTip_Activate

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>

Example()

Func Example()
    Local $bActivate = True

    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idToggleTips = GUICtrlCreateButton("Tips: On", 30, 32, 180, 28)
    Local $hToggleTips = GUICtrlGetHandle($idToggleTips)
    ; create a tooltip control using the balloon style
    Local $hToolTip = _GUIToolTip_Create(0, $TTS_BALLOON)

    ; add a tool to the tooltip control using the default settings.
    _GUIToolTip_AddTool($hToolTip, 0, "Tooltip for the GUI", $hGUI)
    ; add a tool to the tooltip control centering the tip below the button instead of above the mouse pointer
    _GUIToolTip_AddTool($hToolTip, 0, "This button toggles the tooltips on and off", $hToggleTips, 0, 0, 0, 0, BitOR($TTF_CENTERTIP, $TTF_SUBCLASS, $TTF_IDISHWND))
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $idToggleTips
                $bActivate = Not $bActivate
                If $bActivate Then
                    _GUIToolTip_Activate($hToolTip)
                    GUICtrlSetData($idToggleTips, 'Tips: On')
                Else
                    _GUIToolTip_Deactivate($hToolTip)
                    GUICtrlSetData($idToggleTips, 'Tips: Off')
                EndIf
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_DelTool

Function Reference

_GUIToolTip_DelTool

Deletes a tool from a tooltip control

#include <GuiToolTip.au3>
_GUIToolTip_DelTool ( $hWnd, $hTool [, $iID = 0] )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$hTool | Handle to the window that contains the tool (see Remarks)
$iID | [optional] Handle of the tool to delete (see Remarks)

Return Value

None.

Remarks

Use the same parameters for $hTool and $iID that were used to create the tool using _GUIToolTip_AddTool()

Related

_GUIToolTip_AddTool

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>

Example()

Func Example()
    Local $iMsg
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("This is a button", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)
    ; create a tooltip control using default settings
    Local $hToolTip = _GUIToolTip_Create(0)
    _GUIToolTip_SetMaxTipWidth($hToolTip, 400)
    ; add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "Click this to delete the tooltip" & @CRLF & "for this button", $hButton)
    _GUIToolTip_AddTool($hToolTip, 0, "ToolTip text for the GUI", $hGUI)
    GUISetState(@SW_SHOW)

    While 1
        $iMsg = GUIGetMsg()
        Switch $iMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idButton
                ; Deletes the tooltip assigned to the button, but not the tooltip control
                ; or the tool for the GUI
                _GUIToolTip_DelTool($hToolTip, 0, $hButton)
        EndSwitch
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_Destroy

Function Reference

_GUIToolTip_Destroy

Delete a ToolTip control

#include <GuiToolTip.au3>
_GUIToolTip_Destroy ( ByRef $hWnd )

Parameters

$hWnd Handle to the ToolTip control (returned by _GUIToolTip_Create.)

Return Value

Success: | True, $hWnd is set to 0.
Failure: | False, and @error set to 1 - Not Allowed to Destroy Other Applications' Control(s) 2 - $hWnd Not a Tooltip Control Handle

Remarks

Restricted to only be used on ToolTip controls created with _GUIToolTip_Create.

Related

_GUIToolTip_Create

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
; Click the button to destroy the tooltip control
Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("This is a button", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)
    ; create a tooltip control using default settings
    Local $hToolTip = _GUIToolTip_Create(0)

    ; add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "This is a ToolTip", $hButton)
    _GUIToolTip_AddTool($hToolTip, 0, "ToolTip text for the GUI", $hGUI)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idButton
                ; Destroys the tooltip control
                _GUIToolTip_Destroy($hToolTip)
        EndSwitch
    WEnd
    ; Destroy the tooltip control (in case the button hasn't been actioned yet)
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_EnumTools

Function Reference

_GUIToolTip_EnumTools

Retrieves information about the current tool

#include <GuiToolTip.au3>
_GUIToolTip_EnumTools ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$iIndex | 0-based index of the tool for which to retrieve information

Return Value

Returns an array with the following format:
[0] - Comma separated string displaying TTF_ flags used
TTF_IDISHWND = Indicates that $iID is the window handle to the tool instead of the ID
TTF_CENTERTIP = Centers the window below the tool specified by $iID
TTF_RTLREADING = Indicates that text will be displayed in the opposite direction
TTF_SUBCLASS = Indicates that the control should subclass the tool's window to intercept messages
TTF_TRACK = Positions the control next to the tool to which it corresponds
TTF_ABSOLUTE = Positions the window at the same coordinates provided by TTM_TRACKPOSITION
TTF_TRANSPARENT = Causes the control to forward mouse messages to the parent window
TTF_PARSELINKS = Indicates that links in the control text should be parsed
[1] - Handle to the window that contains the tool ($hWnd)
[2] - Identifier of the tool ($iID)
[3] - X coordinate of the upper left corner of the rectangle
[4] - Y coordinate of the upper left corner of the rectangle
[5] - X coordinate of the lower right corner of the rectangle
[6] - Y coordinate of the lower right corner of the rectangle
[7] - Handle to the instance that contains the string resource for the tool
[8] - Text for the tool
[9] - Application-defined value associated with the tool

Related

_GUIToolTip_GetCurrentTool, _GUIToolTip_GetToolInfo

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("This is a button", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)
    ; create a tooltip control using default settings
    Local $hToolTip = _GUIToolTip_Create(0)

    ; add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "This is a ToolTip", $hButton)
    _GUIToolTip_AddTool($hToolTip, 0, "This is the GUI ToolTip", $hGUI)
    GUISetState(@SW_SHOW)
    ; GetToolCount returns 2, but tools are numbered starting from zero (0), so we have to subtract 1
    For $I = 0 To _GUIToolTip_GetToolCount($hToolTip) - 1
        Local $aTool = _GUIToolTip_EnumTools($hToolTip, $I)
        MsgBox($MB_SYSTEMMODAL, "Tooltip info for tooltip - " & $I, "Flags: " & @TAB & _GUIToolTip_BitsToTTF($aTool[0]) & @CRLF & _
                "HWnd: " & @TAB & $aTool[1] & @CRLF & _
                "ID: " & @TAB & $aTool[2] & @CRLF & _
                "Left X:" & @TAB & $aTool[3] & @CRLF & _
                "Left Y:" & @TAB & $aTool[4] & @CRLF & _
                "Right X:" & @TAB & $aTool[5] & @CRLF & _
                "Right Y:" & @TAB & $aTool[6] & @CRLF & _
                "Instance:" & @TAB & $aTool[7] & @CRLF & _
                "Text:" & @TAB & $aTool[8] & @CRLF & _
                "lParam:" & @TAB & $aTool[9])
    Next

    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_GetBubbleHeight

Function Reference

_GUIToolTip_GetBubbleHeight

Returns the height of the control

#include <GuiToolTip.au3>
_GUIToolTip_GetBubbleHeight ( $hWnd, $hTool, $iID [, $iFlags = 0x00000001 + 0x00000010] )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$hTool | Handle to the window that contains the tool
$iID | Handle of the control that the tool is associated with, or the ID of the tool
$iFlags | [optional] Flags that control the ToolTip display: $TTF_IDISHWND = Indicates that $iID is the window handle to the tool instead of the ID $TTF_CENTERTIP = Centers the window below the tool specified by $iID $TTF_RTLREADING = Indicates that text will be displayed in the opposite direction $TTF_SUBCLASS = Indicates that the control should subclass the tool's window to intercept messages $TTF_TRACK = Positions the control next to the tool to which it corresponds $TTF_ABSOLUTE = Positions the window at the same coordinates provided by TTM_TRACKPOSITION $TTF_TRANSPARENT = Causes the control to forward mouse messages to the parent window $TTF_PARSELINKS = Indicates that links in the control text should be parsed

Return Value

Returns the height the ToolTip.

Remarks

This function works correctly only on a tracking tooltip, if the tracking hasn't been activated for the tooltip you will get incorrect values returned.

Related

_GUIToolTip_GetBubbleSize, _GUIToolTip_GetBubbleWidth

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("This is a button", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)
    ; create a tooltip control using default settings
    Local $hToolTip = _GUIToolTip_Create(0)

    ; add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "This is a ToolTip", $hButton)
    _GUIToolTip_TrackActivate($hToolTip, True, 0, $hButton)
    GUISetState(@SW_SHOW)
    ; Display the height of the tooltip bubble in pixels
    MsgBox($MB_SYSTEMMODAL, "Info", "Bubble Height = " & _GUIToolTip_GetBubbleHeight($hToolTip, 0, $hButton) & " Pixels")

    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_GetBubbleSize

Function Reference

_GUIToolTip_GetBubbleSize

Returns the width and height of a ToolTip control

#include <GuiToolTip.au3>
_GUIToolTip_GetBubbleSize ( $hWnd, $hTool, $iID [, $iFlags = 0x00000001 + 0x00000010] )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$hTool | Handle to the window that contains the tool
$iID | Handle of the control that the tool is associated with, or the ID of the tool
$iFlags | [optional] Flags that control the ToolTip display $TTF_IDISHWND = Indicates that $iID is the window handle to the tool instead of the ID $TTF_CENTERTIP = Centers the window below the tool specified by $iID $TTF_RTLREADING = Indicates that text will be displayed in the opposite direction $TTF_SUBCLASS = Indicates that the control should subclass the tool's window to intercept messages $TTF_TRACK = Positions the control next to the tool to which it corresponds $TTF_ABSOLUTE = Positions the window at the same coordinates provided by TTM_TRACKPOSITION $TTF_TRANSPARENT = Causes the control to forward mouse messages to the parent window $TTF_PARSELINKS = Indicates that links in the control text should be parsed

Return Value

Returns the width of the ToolTip in the low word and the height in the high word.

Remarks

This function works correctly only on a tracking tooltip, if the tracking hasn't been activated for the tooltip you will get incorrect values returned.

Related

_GUIToolTip_GetBubbleHeight, _GUIToolTip_GetBubbleWidth

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("This is a button", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)
    ; create a tooltip control using default settings
    Local $hToolTip = _GUIToolTip_Create(0)
    ; add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "This is a ToolTip", $hButton)
    GUISetState(@SW_SHOW)
    _GUIToolTip_TrackActivate($hToolTip, True, 0, $hButton)

    Local $iBubbleHeight = _WinAPI_HiWord(_GUIToolTip_GetBubbleSize($hToolTip, 0, $hButton))
    Local $iBubbleWidth = _WinAPI_LoWord(_GUIToolTip_GetBubbleSize($hToolTip, 0, $hButton))
    ; Display the height of the tooltip bubble in pixels
    MsgBox($MB_SYSTEMMODAL, "Info", "Bubble Height = " & @TAB & $iBubbleHeight & " Pixels" & @CRLF & _
            "Bubble Width = " & @TAB & $iBubbleWidth & " Pixels")
    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_GetBubbleWidth

Function Reference

_GUIToolTip_GetBubbleWidth

Returns the width of a ToolTip control

#include <GuiToolTip.au3>
_GUIToolTip_GetBubbleWidth ( $hWnd, $hTool, $iID [, $iFlags = 0x00000001 + 0x00000010] )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$hTool | Handle to the window that contains the tool
$iID | Handle of the control that the tool is associated with, or the ID of the tool
$iFlags | [optional] Flags that control the ToolTip display $TTF_IDISHWND = Indicates that $iID is the window handle to the tool instead of the ID $TTF_CENTERTIP = Centers the window below the tool specified by $iID $TTF_RTLREADING = Indicates that text will be displayed in the opposite direction $TTF_SUBCLASS = Indicates that the control should subclass the tool's window to intercept messages $TTF_TRACK = Positions the control next to the tool to which it corresponds $TTF_ABSOLUTE = Positions the window at the same coordinates provided by TTM_TRACKPOSITION $TTF_TRANSPARENT = Causes the control to forward mouse messages to the parent window $TTF_PARSELINKS = Indicates that links in the control text should be parsed

Return Value

Returns the width of a ToolTip.

Remarks

This function works correctly only on a tracking tooltip, if the tracking hasn't been activated for the tooltip you will get incorrect values returned.

Related

_GUIToolTip_GetBubbleHeight, _GUIToolTip_GetBubbleSize

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("This is a button", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)
    ; create a tooltip control using default settings
    Local $hToolTip = _GUIToolTip_Create(0)

    ; add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "This is a ToolTip", $hButton)
    _GUIToolTip_TrackActivate($hToolTip, True, 0, $hButton)
    GUISetState(@SW_SHOW)
    ; Display the height of the tooltip bubble in pixels
    MsgBox($MB_SYSTEMMODAL, "Info", "Bubble Width = " & _GUIToolTip_GetBubbleWidth($hToolTip, 0, $hButton) & " Pixels")

    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_GetCurrentTool

Function Reference

_GUIToolTip_GetCurrentTool

Retrieves information for the current tool

#include <GuiToolTip.au3>
_GUIToolTip_GetCurrentTool ( $hWnd )

Parameters

$hWnd Handle to the ToolTip control (returned by _GUIToolTip_Create.)

Return Value

Returns an array with the following format:
[0] - Comma separated string displaying TTF_ flags used
TTF_IDISHWND = Indicates that $iID is the window handle to the tool instead of the ID
TTF_CENTERTIP = Centers the window below the tool specified by $iID
TTF_RTLREADING = Indicates that text will be displayed in the opposite direction
TTF_SUBCLASS = Indicates that the control should subclass the tool's window to intercept messages
TTF_TRACK = Positions the control next to the tool to which it corresponds
TTF_ABSOLUTE = Positions the window at the same coordinates provided by TTM_TRACKPOSITION
TTF_TRANSPARENT = Causes the control to forward mouse messages to the parent window
TTF_PARSELINKS = Indicates that links in the control text should be parsed
[1] - Handle to the window that contains the tool ($hWnd)
[2] - Identifier of the tool ($iID)
[3] - X coordinate of the upper left corner of the rectangle
[4] - Y coordinate of the upper left corner of the rectangle
[5] - X coordinate of the lower right corner of the rectangle
[6] - Y coordinate of the lower right corner of the rectangle
[7] - Handle to the instance that contains the string resource for the tool
[8] - Text for the tool
[9] - Application-defined value associated with the tool

Remarks

The tooltip has to be displaying when this function is called or the returned results will be all zeroes.

Related

_GUIToolTip_EnumTools, _GUIToolTip_GetToolInfo

Example

Example 1

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>

Global $g_hToolTip

; Hover over the button on the GUI and press the "g" key to disply the information
HotKeySet("g", "Get_Tool")

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("Button ToolTip", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)
    ; create a tooltip control using default settings
    $g_hToolTip = _GUIToolTip_Create(0)

    ; add a tool to the tooltip control
    _GUIToolTip_AddTool($g_hToolTip, 0, "This is a ToolTip", $hButton)
    GUISetState(@SW_SHOW)
    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($g_hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example

Func Get_Tool()
    Local $aTool = _GUIToolTip_GetCurrentTool($g_hToolTip)
    MsgBox($MB_SYSTEMMODAL, "Tooltip info", "Flags: " & @TAB & _GUIToolTip_BitsToTTF($aTool[0]) & @CRLF & _
            "HWnd: " & @TAB & $aTool[1] & @CRLF & _
            "ID: " & @TAB & $aTool[2] & @CRLF & _
            "Left X:" & @TAB & $aTool[3] & @CRLF & _
            "Left Y:" & @TAB & $aTool[4] & @CRLF & _
            "Right X:" & @TAB & $aTool[5] & @CRLF & _
            "Right Y:" & @TAB & $aTool[6] & @CRLF & _
            "Instance:" & @TAB & $aTool[7] & @CRLF & _
            "Text:" & @TAB & $aTool[8] & @CRLF & _
            "lParam:" & @TAB & $aTool[9])
EndFunc   ;==>Get_Tool

Example 2

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>

Global $g_iPID

; Hover over one of the characters in the Charmap app to get a tooltip to display, then press 'g' to
; retrieve its information.
HotKeySet('g', "_Read_Tip")

Example()

Func Example()
    ; Run character map program
    $g_iPID = Run("charmap.exe")
    ; Wait for it to become the active window
    WinWaitActive("Character Map", "", 10)
    While ProcessExists($g_iPID)
        Sleep(100)
    WEnd
EndFunc   ;==>Example

Func _Read_Tip()
    ; Get list of tooltips
    Local $aTipList = WinList("[CLASS:tooltips_class32]")
    ; See which belong to your app
    For $i = 1 To $aTipList[0][0]
        If WinGetProcess($aTipList[$i][1]) = $g_iPID Then
            ; See which one is active
            _GUIToolTip_GetCurrentTool($aTipList[$i][1])
            ; If one is active then display it
            Local $aTool = _GUIToolTip_GetCurrentTool($aTipList[$i][1])
            MsgBox($MB_SYSTEMMODAL, "Tooltip info", "Flags: " & @TAB & _GUIToolTip_BitsToTTF($aTool[0]) & @CRLF & _
                    "HWnd: " & @TAB & $aTool[1] & @CRLF & _
                    "ID: " & @TAB & $aTool[2] & @CRLF & _
                    "Left X:" & @TAB & $aTool[3] & @CRLF & _
                    "Left Y:" & @TAB & $aTool[4] & @CRLF & _
                    "Right X:" & @TAB & $aTool[5] & @CRLF & _
                    "Right Y:" & @TAB & $aTool[6] & @CRLF & _
                    "Instance:" & @TAB & $aTool[7] & @CRLF & _
                    "Text:" & @TAB & $aTool[8] & @CRLF & _
                    "lParam:" & @TAB & $aTool[9])
        EndIf
    Next
EndFunc   ;==>_Read_Tip


Function _GUIToolTip_GetDelayTime

Function Reference

_GUIToolTip_GetDelayTime

Retrieves the initial, pop-up or reshow durations of a ToolTip control

#include <GuiToolTip.au3>
_GUIToolTip_GetDelayTime ( $hWnd, $iDuration )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$iDuration | Flag that specifies which duration value will be retrieved: $TTDT_RESHOW (1) = Time it takes for subsequent ToolTip windows to appear as the pointer moves from one tool to another $TTDT_AUTOPOP (2) = Time the ToolTip window remains visible if the pointer is stationary within a tool's bounding rectangle $TTDT_INITIAL (3) = Time the pointer must remain stationary within a tool's bounding rectangle before the window appears

Return Value

Returns the specified duration, in milliseconds.

Related

_GUIToolTip_SetDelayTime

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("This is a button", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)
    ; Create a tooltip control
    Local $hToolTip = _GUIToolTip_Create($hGUI)

    ; Add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "This is the ToolTip text", $hButton)

    ; set the time for how long the tooltip displays, to 1500 ms ($TTDT_AUTOPOP)
    _GUIToolTip_SetDelayTime($hToolTip, $TTDT_AUTOPOP, 1500)
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, 'Message', 'Display time : ' & _GUIToolTip_GetDelayTime($hToolTip, $TTDT_AUTOPOP) & ' ms')

    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)

EndFunc   ;==>Example


Function _GUIToolTip_GetMargin

Function Reference

_GUIToolTip_GetMargin

Retrieves the top, left, bottom, and right margins of a ToolTip control

#include <GuiToolTip.au3>
_GUIToolTip_GetMargin ( $hWnd )

Parameters

$hWnd Handle to the ToolTip control (returned by _GUIToolTip_Create.)

Return Value

Returns an array with the following format:
[0] - Distance between top left border and top left of text, in pixels
[1] - Distance between left top border and left top end of text, in pixels
[2] - Distance between bottom right border and bottom right of text, in pixels
[3] - Distance between right bottom border and right bottom end of text, in pixels

Related

_GUIToolTip_GetMarginEx, _GUIToolTip_SetMargin, _GUIToolTip_ToolToArray

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>
#include <WinAPITheme.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idAdd = GUICtrlCreateButton("Button ToolTip", 30, 32, 130, 28)
    Local $hAdd = GUICtrlGetHandle($idAdd)
    ; Create a tooltip control
    Local $hToolTip1 = _GUIToolTip_Create(0)
    ; If using a Windows theme setting, this will disable that for the tooltip displayed, so you can change
    ; the margins and have the change seen
    _WinAPI_SetWindowTheme($hToolTip1, "", "")

    Local $hToolTip2 = _GUIToolTip_Create(0)
    _WinAPI_SetWindowTheme($hToolTip2, "", "")
    ; This is only used because the tooltip is a multiline tool, you don't need this to change
    ; the margins
    _GUIToolTip_SetMaxTipWidth($hToolTip1, 400)
    _GUIToolTip_SetMaxTipWidth($hToolTip2, 400)

    ; Manually set the margins of the tooltip instead of using default settings.
    _GUIToolTip_SetMargin($hToolTip1, 30, 10, 20, 12)

    Local $aMargins = _GUIToolTip_GetMargin($hToolTip1)
    Local $aMargins1 = _GUIToolTip_GetMargin($hToolTip2)

    ; Add a tool to the first tooltip control
    _GUIToolTip_AddTool($hToolTip1, 0, 'Left : ' & $aMargins[0] & @LF & _
            'Top : ' & $aMargins[1] & @LF & _
            'Right : ' & $aMargins[2] & @LF & _
            'Bottom : ' & $aMargins[3], $hAdd)
    _GUIToolTip_SetTitle($hToolTip1, "This is the ToolTip with manually set margins")
    ; Add a tool to the second tooltip control
    _GUIToolTip_AddTool($hToolTip2, 0, 'Left : ' & $aMargins1[0] & @LF & _
            'Top : ' & $aMargins1[1] & @LF & _
            'Right : ' & $aMargins1[2] & @LF & _
            'Bottom : ' & $aMargins1[3], $hGUI)
    _GUIToolTip_SetTitle($hToolTip2, "This is the ToolTip with default margins")
    GUISetState(@SW_SHOW)
    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip1)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_GetMarginEx

Function Reference

_GUIToolTip_GetMarginEx

Retrieves the top, left, bottom, and right margins of a ToolTip control

#include <GuiToolTip.au3>
_GUIToolTip_GetMarginEx ( $hWnd )

Parameters

$hWnd Handle to the ToolTip control (returned by _GUIToolTip_Create.)

Return Value

Returns a $tagRECT structure that will receive the margin information:
Top - Distance between top border and top of ToolTip text, in pixels
Left - Distance between left border and left end of ToolTip text, in pixels
Bottom - Distance between bottom border and bottom of ToolTip text, in pixels
Right - Distance between right border and right end of ToolTip text, in pixels

Related

_GUIToolTip_GetMargin, _GUIToolTip_ToolToArray

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>
#include <WinAPITheme.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("Button", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)
    ; Create a tooltip control
    Local $hToolTip = _GUIToolTip_Create($hGUI, BitOR($_TT_ghTTDefaultStyle, $TTS_BALLOON))

    ; If using a Windows theme setting, this will disable that for the tooltip displayed, so you can change
    ; the margin settings. If you don't do this, the margins won't appear any different
    _WinAPI_SetWindowTheme($hToolTip, "", "")

    ; Add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "This is the ToolTip text", $hButton)
    ; Manually set the margins of the tooltip instead of using default settings.
    _GUIToolTip_SetMargin($hToolTip, 30, 10, 20, 12)

    ; Retrieve the margin settings of the tooltip
    Local $tRECT = _GUIToolTip_GetMarginEx($hToolTip)
    GUISetState(@SW_SHOW)
    MsgBox($MB_SYSTEMMODAL, 'Message', _
            'Left :' & @TAB & DllStructGetData($tRECT, "Left") & @LF & _
            'Top :' & @TAB & DllStructGetData($tRECT, "Top") & @LF & _
            'Right :' & @TAB & DllStructGetData($tRECT, "Right") & @LF & _
            'Bottom :' & @TAB & DllStructGetData($tRECT, "Bottom"))
    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_GetMaxTipWidth

Function Reference

_GUIToolTip_GetMaxTipWidth

Retrieves the maximum width of a ToolTip window

#include <GuiToolTip.au3>
_GUIToolTip_GetMaxTipWidth ( $hWnd )

Parameters

$hWnd Handle to the ToolTip control (returned by _GUIToolTip_Create.)

Return Value

Success: | the maximum ToolTip width, in pixels.
Failure: | -1.

Remarks

The maximum ToolTip width value does not indicate a ToolTip window's actual width.
Rather, if a ToolTip string exceeds the maximum width, the control breaks the text into multiple lines, using spaces to determine line breaks.
If the text cannot be segmented into multiple lines, it will be displayed on a single line.
The length of this line may exceed the maximum ToolTip width.

Related

_GUIToolTip_SetMaxTipWidth

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("This is a button", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)

    ; Create a tooltip control
    Local $hToolTip = _GUIToolTip_Create($hGUI)
    ; Set the maximum width to 400 pixels
    _GUIToolTip_SetMaxTipWidth($hToolTip, 400)

    _GUIToolTip_AddTool($hToolTip, 0, 'If the text exceeds the width, then it carries over to the next line.' & @CRLF & 'Also allows you to use @CRLF', $hButton)
    GUISetState(@SW_SHOW)
    ; Display the max width of the tooltip
    MsgBox($MB_SYSTEMMODAL, "Info", "Max Width: " & _GUIToolTip_GetMaxTipWidth($hToolTip) & " Pixels")
    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_GetText

Function Reference

_GUIToolTip_GetText

Retrieves the text of a tool

#include <GuiToolTip.au3>
_GUIToolTip_GetText ( $hWnd, $hTool, $iID )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$hTool | Handle to the window that contains the tool
$iID | Identifier of the tool, or Window handle of the control the tool is assigned to

Return Value

Returns the text of the specified tool. On non-AutoIt created ToolTips it only retrieves the first 42 characters of the text of the specified tool.

Related

_GUIToolTip_UpdateTipText

Example

Example 1

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("Button", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)

    Local $hToolTip = _GUIToolTip_Create($hGUI)

    _GUIToolTip_AddTool($hToolTip, 0, "This is the ToolTip text", $hButton)

    GUISetState(@SW_SHOW)
    ; Retrieve the text of the tool
    MsgBox($MB_SYSTEMMODAL, 'Message', _GUIToolTip_GetText($hToolTip, 0, $hButton))

    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example

Example 2

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>

Global $g_iPID

; Hover over one of the characters in the Charmap app to get a tooltip to display, then press 'g' to
; retrieve its text information.
HotKeySet('g', "_Read_Tip")

Example()

Func Example()
    ; Run character map program
    $g_iPID = Run("charmap.exe")
    ; Wait for it to become the active window
    WinWaitActive("Character Map", "", 10)
    While ProcessExists($g_iPID)
        Sleep(100)
    WEnd
EndFunc   ;==>Example

Func _Read_Tip()
    ; Get list of tooltips
    Local $aTipList = WinList("[CLASS:tooltips_class32]")
    Local $aRet
    ; See which belong to your app
    For $i = 1 To $aTipList[0][0]
        If WinGetProcess($aTipList[$i][1]) = $g_iPID Then
            ; See which one is active
            $aRet = _GUIToolTip_GetCurrentTool($aTipList[$i][1])
            ; If one is active then display it
            If $aRet[8] <> "" Then MsgBox(0, "Visible Tip", $aRet[8])
        EndIf
    Next
EndFunc   ;==>_Read_Tip


Function _GUIToolTip_GetTipBkColor

Function Reference

_GUIToolTip_GetTipBkColor

Retrieves the background color

#include <GuiToolTip.au3>
_GUIToolTip_GetTipBkColor ( $hWnd )

Parameters

$hWnd Handle to the ToolTip control (returned by _GUIToolTip_Create.)

Return Value

Returns the COLORREF (BGR) value of the background color of the ToolTip control.

Related

_GUIToolTip_GetTipTextColor, _GUIToolTip_SetTipBkColor, _GUIToolTip_SetTipTextColor

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>
#include <WinAPITheme.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("Button", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)

    ; Create a tooltip control
    Local $hToolTip = _GUIToolTip_Create($hGUI, $TTS_BALLOON)
    _WinAPI_SetWindowTheme($hToolTip, "", "")
    ; Change the color settings for the tooltip, color setting is a COLORREF (BGR) value.
    _GUIToolTip_SetTipBkColor($hToolTip, 0x395A00)
    _GUIToolTip_SetTipTextColor($hToolTip, 0x1EBFFF)

    ; Add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "This is the ToolTip text", $hButton)
    GUISetState(@SW_SHOW)

    ; Retrieve the background color of the tooltip.
    MsgBox($MB_SYSTEMMODAL, 'Message', 'Background color : 0x' & Hex(_GUIToolTip_GetTipBkColor($hToolTip), 6))

    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_GetTipTextColor

Function Reference

_GUIToolTip_GetTipTextColor

Retrieves the text color of a ToolTip control

#include <GuiToolTip.au3>
_GUIToolTip_GetTipTextColor ( $hWnd )

Parameters

$hWnd Handle to the ToolTip control (returned by _GUIToolTip_Create.)

Return Value

Returns the COLORREF (BGR) value of text color of the ToolTip control.

Related

_GUIToolTip_GetTipBkColor, _GUIToolTip_SetTipBkColor, _GUIToolTip_SetTipTextColor

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>
#include <WinAPITheme.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idAdd = GUICtrlCreateButton("Button", 30, 32, 130, 28)
    Local $hAdd = GUICtrlGetHandle($idAdd)

    ; Create a tooltip control
    Local $hToolTip = _GUIToolTip_Create($hGUI, $TTS_BALLOON)
    _WinAPI_SetWindowTheme($hToolTip, "", "")

    ; Change the color settings for the tooltip
    ; The color value used in the _GUIToolTip_SetTipBkColor function is a COLORREF (BGR) value
    _GUIToolTip_SetTipBkColor($hToolTip, 0x395A00)
    ; The color value used in the _GUIToolTip_SetTipTextColor function is a COLORREF (BGR) value
    _GUIToolTip_SetTipTextColor($hToolTip, 0x1EBFFF)

    ; Add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "This is the ToolTip text", $hAdd)
    GUISetState(@SW_SHOW)

    ; Retrieve the text color of the tooltip.
    MsgBox($MB_SYSTEMMODAL, 'Message', 'Text color : 0x' & Hex(_GUIToolTip_GetTipTextColor($hToolTip), 6))

    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_GetTitleBitMap

Function Reference

_GUIToolTip_GetTitleBitMap

Retrieves the title bitmap icon

#include <GuiToolTip.au3>
_GUIToolTip_GetTitleBitMap ( $hWnd )

Parameters

$hWnd Handle to the ToolTip control (returned by _GUIToolTip_Create.)

Return Value

Returns the reference number of the ToolTip title icon. See remarks

Remarks

The icon reference number returned by this function is related to the icons used to set the title icon, see _GUIToolTip_SetTitle().
If using the standard icons, the return values will be
$TTI_NONE = 0
$TTI_INFO or $TTI_INFO_LARGE = 1
$TTI_WARNING or $TTI_WARNING_LARGE = 2
$TTI_ERROR or $TTI_ERROR_LARGE = 3
Any icon used that isn't one of these will return 4 signifying an HICON was used.

Related

_GUIToolTip_SetTitle

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>
Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("Button", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)

    ; Create a tooltip control
    Local $hToolTip = _GUIToolTip_Create($hGUI)

    ; Add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "This is the ToolTip text", $hButton)

    Local $hIcon = _WinAPI_LoadShell32Icon(15)

    ; Set the title of the tooltip
    _GUIToolTip_SetTitle($hToolTip, 'This is the Title Text', $hIcon)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idButton
                MsgBox($MB_SYSTEMMODAL, "Title Bitmap", _GUIToolTip_GetTitleBitMap($hToolTip))
        EndSwitch
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_GetTitleText

Function Reference

_GUIToolTip_GetTitleText

Retrieve the title

#include <GuiToolTip.au3>
_GUIToolTip_GetTitleText ( $hWnd )

Parameters

$hWnd Handle to the ToolTip control (returned by _GUIToolTip_Create.)

Return Value

Returns the ToolTip title.

Related

_GUIToolTip_GetTitleBitMap, _GUIToolTip_SetTitle

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>
Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("Button", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)

    ; Create a tooltip control
    Local $hToolTip = _GUIToolTip_Create($hGUI)

    ; Add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "This is the ToolTip text", $hButton)

    Local $hIcon = _WinAPI_LoadShell32Icon(15)

    ; Set the title of the tooltip
    _GUIToolTip_SetTitle($hToolTip, 'This is the Title Text', $hIcon)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idButton
                MsgBox($MB_SYSTEMMODAL, "Title Text", _GUIToolTip_GetTitleText($hToolTip))
        EndSwitch
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_GetToolCount

Function Reference

_GUIToolTip_GetToolCount

Returns the count of tools maintained by the ToolTip control

#include <GuiToolTip.au3>
_GUIToolTip_GetToolCount ( $hWnd )

Parameters

$hWnd Handle to the ToolTip control (returned by _GUIToolTip_Create.)

Return Value

Returns the count of tools maintained by the ToolTip control.

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 270, 200)

    Local $idAdd = GUICtrlCreateButton("Get Count 1", 30, 32, 75, 25)
    Local $hAdd = GUICtrlGetHandle($idAdd)
    Local $idClear = GUICtrlCreateButton("Get Count 2", 30, 72, 75, 25)
    Local $hClear = GUICtrlGetHandle($idClear)
    Local $idMylist = GUICtrlCreateList("Item 1", 120, 32, 121, 97)
    Local $hMylist = GUICtrlGetHandle($idMylist)
    Local $idClose = GUICtrlCreateButton("Exit button", 80, 150, 110, 28)
    Local $hClose = GUICtrlGetHandle($idClose)

    ; Create 2 tooltip controls
    Local $hToolTip1 = _GUIToolTip_Create(0, BitOR($_TT_ghTTDefaultStyle, $TTS_BALLOON)); balloon style tooltip
    Local $hToolTip2 = _GUIToolTip_Create(0) ; default style tooltip
    _GUIToolTip_SetMaxTipWidth($hToolTip2, 100) ; this allows multiline tooltips to be used with $hToolTip2
    ; add tools to the tooltip controls
    ; 3 tools for $hToolTip1
    _GUIToolTip_AddTool($hToolTip1, 0, "Click to display the # of tools assigned to $hToolTip1", $hAdd)
    _GUIToolTip_AddTool($hToolTip1, 0, "Exit the script", $hClose)
    _GUIToolTip_AddTool($hToolTip1, 0, "The listbox", $hMylist)
    ; 2 tools for $hToolTip2
    _GUIToolTip_AddTool($hToolTip2, 0, "Click to display the # of tools assigned to $hToolTip2", $hClear)
    _GUIToolTip_AddTool($hToolTip2, 0, "Multiline tooltip" & @CRLF & "for the GUI", $hGUI) ; Multiline ToolTip
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $idAdd
                MsgBox($MB_SYSTEMMODAL, "Tool count", "Number of tools:" & @TAB & _GUIToolTip_GetToolCount($hToolTip1))
            Case $idClear
                MsgBox($MB_SYSTEMMODAL, "Tool count", "Number of tools:" & @TAB & _GUIToolTip_GetToolCount($hToolTip2))
            Case $idClose, $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    ; Destroy the tooltip controls
    _GUIToolTip_Destroy($hToolTip1)
    _GUIToolTip_Destroy($hToolTip2)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_GetToolInfo

Function Reference

_GUIToolTip_GetToolInfo

Retrieves the information about a specific tool

#include <GuiToolTip.au3>
_GUIToolTip_GetToolInfo ( $hWnd, $hTool, $iID )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$hTool | Handle to the window that contains the tool
$iID | Identifier of the tool, or Window handle of the control the tool is assigned to

Return Value

Returns an array with the following format:
[0] - Comma separated string displaying TTF_ flags used
TTF_IDISHWND = Indicates that $iID is the window handle to the tool instead of the ID
TTF_CENTERTIP = Centers the window below the tool specified by $iID
TTF_RTLREADING = Indicates that text will be displayed in the opposite direction
TTF_SUBCLASS = Indicates that the control should subclass the tool's window to intercept messages
TTF_TRACK = Positions the control next to the tool to which it corresponds
TTF_ABSOLUTE = Positions the window at the same coordinates provided by TTM_TRACKPOSITION
TTF_TRANSPARENT = Causes the control to forward mouse messages to the parent window
TTF_PARSELINKS = Indicates that links in the control text should be parsed
[1] - Handle to the window that contains the tool
[2] - Identifier of the tool
[3] - X coordinate of the upper left corner of the rectangle
[4] - Y coordinate of the upper left corner of the rectangle
[5] - X coordinate of the lower right corner of the rectangle
[6] - Y coordinate of the lower right corner of the rectangle
[7] - Handle to the instance that contains the string resource for the tool
[8] - Text for the tool
[9] - Application-defined value associated with the tool

Related

_GUIToolTip_EnumTools, _GUIToolTip_GetCurrentTool, _GUIToolTip_SetToolInfo, _GUIToolTip_ToolToArray

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("This is a button", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)
    ; create a tooltip control using default settings
    Local $hToolTip = _GUIToolTip_Create(0)

    ; add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "This is a ToolTip", $hButton)
    GUISetState(@SW_SHOW)
    ; Display the information for the tool assigned to the button
    Local $aTool = _GUIToolTip_GetToolInfo($hToolTip, 0, $hButton)
    MsgBox($MB_SYSTEMMODAL, "Tooltip info", "Flags: " & @TAB & _GUIToolTip_BitsToTTF($aTool[0]) & @CRLF & _
            "HWnd: " & @TAB & $aTool[1] & @CRLF & _
            "ID: " & @TAB & $aTool[2] & @CRLF & _
            "Left X:" & @TAB & $aTool[3] & @CRLF & _
            "Left Y:" & @TAB & $aTool[4] & @CRLF & _
            "Right X:" & @TAB & $aTool[5] & @CRLF & _
            "Right Y:" & @TAB & $aTool[6] & @CRLF & _
            "Instance:" & @TAB & $aTool[7] & @CRLF & _
            "Text:" & @TAB & $aTool[8] & @CRLF & _
            "lParam:" & @TAB & $aTool[9])
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_HitTest

Function Reference

_GUIToolTip_HitTest

Retrieves the information that a ToolTip control maintains about a tool

#include <GuiToolTip.au3>
_GUIToolTip_HitTest ( $hWnd, $hTool, $iX, $iY )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$hTool | Handle to the window that contains the tool
$iX | X position to test
$iY | Y position to test

Return Value

Returns an array with the following format:
[0] - Comma separated string displaying TTF_ flags used
TTF_IDISHWND = Indicates that $iID is the window handle to the tool instead of the ID
TTF_CENTERTIP = Centers the window below the tool specified by $iID
TTF_RTLREADING = Indicates that text will be displayed in the opposite direction
TTF_SUBCLASS = Indicates that the control should subclass the tool's window to intercept messages
TTF_TRACK = Positions the control next to the tool to which it corresponds
TTF_ABSOLUTE = Positions the window at the same coordinates provided by TTM_TRACKPOSITION
TTF_TRANSPARENT = Causes the control to forward mouse messages to the parent window
TTF_PARSELINKS = Indicates that links in the control text should be parsed
[1] - Handle to the window that contains the tool
[2] - Identifier of the tool
[3] - X coordinate of the upper left corner of the rectangle
[4] - Y coordinate of the upper left corner of the rectangle
[5] - X coordinate of the lower right corner of the rectangle
[6] - Y coordinate of the lower right corner of the rectangle
[7] - Handle to the instance that contains the string resource for the tool
[8] - Text for the tool
[9] - Application-defined value associated with the tool

Remarks

This message can only be used when the tool has the $TTF_TRACK flag set. _GUIToolTip_HitTest() will fail if $TTF_TRACK is not set, regardless if the hit point is in the tools rectangle or not.

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>

Global $g_hToolTip, $g_aPos, $g_hAdd

; Press g to display the current tooltip information.
HotKeySet("g", "GetInfo")

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idAdd = GUICtrlCreateButton("Button ToolTip", 30, 32, 130, 28)
    $g_hAdd = GUICtrlGetHandle($idAdd)

    $g_hToolTip = _GUIToolTip_Create($hGUI, $TTS_CLOSE + $TTS_BALLOON)

    _GUIToolTip_AddTool($g_hToolTip, 0, "X: " & @TAB & " Y: " & @TAB, $g_hAdd)

    Local $hIcon = _WinAPI_LoadShell32Icon(15)

    _GUIToolTip_SetTitle($g_hToolTip, 'Title', $hIcon)
    GUISetState(@SW_SHOW)
    $g_aPos = MouseGetPos()
    _GUIToolTip_TrackPosition($g_hToolTip, $g_aPos[0] + 10, $g_aPos[1] + 20)
    _GUIToolTip_TrackActivate($g_hToolTip, True, 0, $g_hAdd)
    _GUIToolTip_UpdateTipText($g_hToolTip, 0, $g_hAdd, "X: " & $g_aPos[0] & " Y: " & $g_aPos[1])
    While 1
        Sleep(10)
        $g_aPos = MouseGetPos()
        _GUIToolTip_TrackPosition($g_hToolTip, $g_aPos[0] + 10, $g_aPos[1] + 20)
        _GUIToolTip_UpdateTipText($g_hToolTip, 0, $g_hAdd, "X: " & $g_aPos[0] & " Y: " & $g_aPos[1])
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    _GUIToolTip_Destroy($g_hToolTip)
EndFunc   ;==>Example

Func GetInfo()
    Local $aTool = _GUIToolTip_HitTest($g_hToolTip, $g_hAdd, $g_aPos[0], $g_aPos[1])
    MsgBox($MB_SYSTEMMODAL, "Tooltip info", "Flags: " & @TAB & _GUIToolTip_BitsToTTF($aTool[0]) & @CRLF & _
            "HWnd: " & @TAB & $aTool[1] & @CRLF & _
            "ID: " & @TAB & $aTool[2] & @CRLF & _
            "Left X:" & @TAB & $aTool[3] & @CRLF & _
            "Left Y:" & @TAB & $aTool[4] & @CRLF & _
            "Right X:" & @TAB & $aTool[5] & @CRLF & _
            "Right Y:" & @TAB & $aTool[6] & @CRLF & _
            "Instance:" & @TAB & $aTool[7] & @CRLF & _
            "Text:" & @TAB & $aTool[8] & @CRLF & _
            "lParam:" & @TAB & $aTool[9])
EndFunc   ;==>GetInfo


Function _GUIToolTip_NewToolRect

Function Reference

_GUIToolTip_NewToolRect

Sets a new bounding rectangle for a tool

#include <GuiToolTip.au3>
_GUIToolTip_NewToolRect ( $hWnd, $hTool, $iID, $iLeft, $iTop, $iRight, $iBottom )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$hTool | Handle of the window that contains the tool, or 0
$iID | Identifier of the tool, or Window handle of the control the tool is to be assigned to
$iLeft | X coordinate of the upper left corner of the rectangle
$iTop | Y coordinate of the upper left corner of the rectangle
$iRight | X coordinate of the lower right corner of the rectangle
$iBottom | Y coordinate of the lower right corner of the rectangle

Return Value

None.

Related

_GUIToolTip_AdjustRect


Function _GUIToolTip_Pop

Function Reference

_GUIToolTip_Pop

Removes a displayed ToolTip from view

#include <GuiToolTip.au3>
_GUIToolTip_Pop ( $hWnd )

Parameters

$hWnd Handle to the ToolTip control (returned by _GUIToolTip_Create.)

Return Value

None.

Related

_GUIToolTip_PopUp

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton(" Button ", 30, 32, 130, 28)
    ; Local $hButton = GUICtrlGetHandle($idButton)

    Local $hToolTip = _GUIToolTip_Create($hGUI, $TTS_BALLOON)
    Local $aPos = MouseGetPos()

    _GUIToolTip_AddTool($hToolTip, 0, " ", 0, 0, 0, 0, 0, 0)

    _GUIToolTip_SetTitle($hToolTip, 'Mouse Coordinates', $TTI_INFO)
    GUISetState(@SW_SHOW)
    ; Find the mouse's position to use as the starting point for tracking
    _GUIToolTip_TrackPosition($hToolTip, $aPos[0], $aPos[1])
    _GUIToolTip_TrackActivate($hToolTip, True, 0, 0)
    Local $hTimer = TimerInit()
    While 1
        ; Read the mouse position
        $aPos = MouseGetPos()
        ; Use the position of the mouse to set the location of the tooltip
        _GUIToolTip_TrackPosition($hToolTip, $aPos[0], $aPos[1])
        _GUIToolTip_UpdateTipText($hToolTip, 0, 0, "X: " & $aPos[0] & " Y: " & $aPos[1])

        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idButton
                ; ...
        EndSwitch
        ; 3 seconds after starting, this will remove the tool from displaying
        If TimerDiff($hTimer) >= 3000 Then
            _GUIToolTip_Pop($hToolTip)
        EndIf
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_PopUp

Function Reference

_GUIToolTip_PopUp

Causes the ToolTip to display at the coordinates of the last mouse message

#include <GuiToolTip.au3>
_GUIToolTip_PopUp ( $hWnd )

Parameters

$hWnd Handle to the ToolTip control (returned by _GUIToolTip_Create.)

Return Value

None.

Related

_GUIToolTip_Pop

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("ToolTip showing", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)

    Local $hToolTip = _GUIToolTip_Create($hGUI, BitOR($_TT_ghTTDefaultStyle, $TTS_BALLOON))
    _GUIToolTip_AddTool($hToolTip, 0, " ", $hButton)
    GUISetState(@SW_SHOW)

    _GUIToolTip_TrackActivate($hToolTip, True, 0, $hButton)
    Local $bDisplay = True
    Local $hTimer = TimerInit()
    While 1
        Sleep(10)
        Local $aMousePos = MouseGetPos()
        _GUIToolTip_TrackPosition($hToolTip, $aMousePos[0] + 10, $aMousePos[1] + 20)
        _GUIToolTip_UpdateTipText($hToolTip, 0, $hButton, "X: " & $aMousePos[0] & " Y: " & $aMousePos[1])
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
        ; Every 8 seconds the tooltip will be "popped" in or out of view
        ; to get it to display after the 8 seconds has passed, you have to hover
        ; over the button.
        If TimerDiff($hTimer) > 8000 Then
            $bDisplay = Not $bDisplay
            $hTimer = TimerInit()
            If $bDisplay Then
                GUICtrlSetData($idButton, "ToolTip showing")
                _GUIToolTip_PopUp($hToolTip)
            Else
                GUICtrlSetData($idButton, "Hover here now")
                _GUIToolTip_Pop($hToolTip)
            EndIf
        EndIf
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_SetDelayTime

Function Reference

_GUIToolTip_SetDelayTime

Sets the initial, pop-up, and reshow durations of a ToolTip

#include <GuiToolTip.au3>
_GUIToolTip_SetDelayTime ( $hWnd, $iDuration, $iTime )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$iDuration | Flag that specifies which duration value will be set: $TTDT_AUTOMATIC (0) - Set all three delay times to default proportions. (see remarks) $TTDT_RESHOW (1) - Time it takes for subsequent ToolTip windows to appear as the pointer moves from one tool to another $TTDT_AUTOPOP (2) - Time the ToolTip window remains visible if the pointer is stationary within a tool's bounding rectangle $TTDT_INITIAL (3) - Time the pointer must remain stationary within a tool's bounding rectangle before the window appears
$iTime | Delay time in milliseconds

Return Value

None.

Remarks

The default delay times are based on the double-click time. The autopop time will be ten times the initial time and the reshow time will be one fifth the initial time.
For the default double-click time of 500 ms, the initial, autopop, and reshow delay times are 500ms, 5000ms, and 100ms respectively.

If the $iDuration flag is set to $TTDT_AUTOMATIC, use a positive value of $iTime to specify the initial time, in milliseconds. Set $iTime to a negative value to return all three delay times to their default values.

Related

_GUIToolTip_GetDelayTime

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("Button ToolTip", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)
    ; Create a tooltip control
    Local $hToolTip = _GUIToolTip_Create($hGUI)

    ; Add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "This is the ToolTip text", $hButton)

    ; set the time for how long the tooltip displays, to 1500 ms
    _GUIToolTip_SetDelayTime($hToolTip, $TTDT_AUTOPOP, 1500)
    GUISetState(@SW_SHOW)
    ; Retrieve and display the time that the tooltip displays
    MsgBox($MB_SYSTEMMODAL, 'Message', 'Display time : ' & _GUIToolTip_GetDelayTime($hToolTip, $TTDT_AUTOPOP) & ' ms')

    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_SetMargin

Function Reference

_GUIToolTip_SetMargin

Sets the top, left, bottom, and right margins of a ToolTip

#include <GuiToolTip.au3>
_GUIToolTip_SetMargin ( $hWnd, $iLeft, $iTop, $iRight, $iBottom )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$iLeft | Distance between left border and left end of text, in pixels
$iTop | Distance between top border and top of text, in pixels
$iRight | Distance between right border and right end of text, in pixels
$iBottom | Distance between bottom border and bottom of text, in pixels

Return Value

None.

Related

_GUIToolTip_GetMargin

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>
#include <WinAPITheme.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("Button ToolTip", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)
    ; Create a tooltip control
    Local $hToolTip1 = _GUIToolTip_Create(0)
    ; If using a Windows theme setting, this will disable that for the tooltip displayed, so you can change
    ; the margins and have the change seen
    _WinAPI_SetWindowTheme($hToolTip1, "", "")

    Local $hToolTip2 = _GUIToolTip_Create(0)
    _WinAPI_SetWindowTheme($hToolTip2, "", "")
    ; This is only used because the tooltip is a multiline tool, you don't need this to change
    ; the margins
    _GUIToolTip_SetMaxTipWidth($hToolTip1, 400)
    _GUIToolTip_SetMaxTipWidth($hToolTip2, 400)

    ; Manually set the margins of the tooltip instead of using default settings.
    _GUIToolTip_SetMargin($hToolTip1, 30, 10, 20, 12)

    Local $aMargins = _GUIToolTip_GetMargin($hToolTip1)
    Local $aMargins1 = _GUIToolTip_GetMargin($hToolTip2)

    ; Add a tool to the first tooltip control
    _GUIToolTip_AddTool($hToolTip1, 0, 'Left : ' & $aMargins[0] & @LF & _
            'Top : ' & $aMargins[1] & @LF & _
            'Right : ' & $aMargins[2] & @LF & _
            'Bottom : ' & $aMargins[3], $hButton)
    _GUIToolTip_SetTitle($hToolTip1, "This is the ToolTip with manually set margins")
    ; Add a tool to the second tooltip control
    _GUIToolTip_AddTool($hToolTip2, 0, 'Left : ' & $aMargins1[0] & @LF & _
            'Top : ' & $aMargins1[1] & @LF & _
            'Right : ' & $aMargins1[2] & @LF & _
            'Bottom : ' & $aMargins1[3], $hGUI)
    _GUIToolTip_SetTitle($hToolTip2, "This is the ToolTip with default margins")
    GUISetState(@SW_SHOW)
    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip1)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_SetMaxTipWidth

Function Reference

_GUIToolTip_SetMaxTipWidth

Sets the maximum width for a ToolTip window

#include <GuiToolTip.au3>
_GUIToolTip_SetMaxTipWidth ( $hWnd, $iWidth )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$iWidth | Maximum ToolTip window width to be set (in pixels)

Return Value

Returns the previous maximum ToolTip width in pixels.

Remarks

The maximum ToolTip width value does not indicate a ToolTip window's actual width.
Rather, if a ToolTip string exceeds the maximum width, the control breaks the text into multiple lines, using spaces to determine line breaks.
If the text cannot be segmented into multiple lines, it will be displayed on a single line.
The length of this line may exceed the maximum ToolTip width.

A ToolTip control needs this setting if you want to have a multi-line ToolTip. Without this setting, if you put a line break (@CR, @LF, @CRLF) in the text of a tool, the text will be truncated at that line break.

Related

_GUIToolTip_GetMaxTipWidth

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("Button ToolTip", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)

    ; Create a ToolTip control
    Local $hToolTip = _GUIToolTip_Create($hGUI)
    ; Set the maximum width to 400 pixels
    _GUIToolTip_SetMaxTipWidth($hToolTip, 400)
    ; Add a multi-line tool to the ToolTip control using @CRLF to break the text into 2 lines
    _GUIToolTip_AddTool($hToolTip, 0, 'If the text exceeds the width, then it carries over to the next line.' & @CRLF & 'Also allows you to use @CRLF', $hButton)
    ; Add a multi-line tool to the ToolTip control using the MaxTipWidth setting to break the text into 2 lines.
    _GUIToolTip_AddTool($hToolTip, 0, 'If the text exceeds the width, then it carries over to the next line. Also allows you to use @CRLF', $hGUI)
    GUISetState(@SW_SHOW)

    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the ToolTip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_SetTipBkColor

Function Reference

_GUIToolTip_SetTipBkColor

Sets the background color of a ToolTip

#include <GuiToolTip.au3>
_GUIToolTip_SetTipBkColor ( $hWnd, $iColor )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$iColor | New text color (see remarks)

Return Value

None.

Remarks

The color value used in the _GUIToolTip_SetTipBkColor() function is a COLORREF (BGR) value in the format 0x00bbggrr. The low-order byte contains a value for the relative intensity of red, the second byte contains a value for green, and the third byte contains a value for blue.
The high-order byte must be zero.

Related

_GUIToolTip_GetTipBkColor, _GUIToolTip_SetTipTextColor

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <WinAPITheme.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("Button ToolTip", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)
    ; Create a tooltip control
    Local $hToolTip = _GUIToolTip_Create($hGUI, BitOR($TTS_BALLOON, $_TT_ghTTDefaultStyle))
    ; If using a Windows theme setting, this will disable that for the tooltip displayed, so you can color it
    ; it has to be placed before you try to actually set the colors, doing it after will reset the colors.
    _WinAPI_SetWindowTheme($hToolTip, "", "")

    ; The color value used in the _GUIToolTip_SetTipBkColor function is a COLORREF (BGR) value.
    _GUIToolTip_SetTipBkColor($hToolTip, 0x395A00)
    ; The color value used in the _GUIToolTip_SetTipTextColor function is a COLORREF (BGR) value.
    _GUIToolTip_SetTipTextColor($hToolTip, 0x1EBFFF)

    ; add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "This is the ToolTip text", $hButton)
    GUISetState(@SW_SHOW)
    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_SetTipTextColor

Function Reference

_GUIToolTip_SetTipTextColor

Sets the text color

#include <GuiToolTip.au3>
_GUIToolTip_SetTipTextColor ( $hWnd, $iColor )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$iColor | New text color (see remarks)

Return Value

None.

Remarks

The color value used in the _GUIToolTip_SetTipTextColor() function is a COLORREF (BGR) value in the format 0x00bbggrr. The low-order byte contains a value for the relative intensity of red, the second byte contains a value for green, and the third byte contains a value for blue.
The high-order byte must be zero.

Related

_GUIToolTip_GetTipTextColor

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <WinAPITheme.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("Button ToolTip", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)

    ; Create a tooltip control
    Local $hToolTip = _GUIToolTip_Create($hGUI, $TTS_BALLOON)
    ; If using a Windows theme setting, this will disable that for the tooltip displayed, so you can color it
    ; it has to be placed before you try to actually set the colors, doing it after will reset the colors.
    _WinAPI_SetWindowTheme($hToolTip, "", "")

    ; The color value used in the _GUIToolTip_SetTipBkColor function is a COLORREF (BGR) value.
    _GUIToolTip_SetTipBkColor($hToolTip, 0x395A00)
    ; The color value used in the _GUIToolTip_SetTipTextColor function is a COLORREF (BGR) value.
    _GUIToolTip_SetTipTextColor($hToolTip, 0x1EBFFF)

    ; add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "This is the ToolTip text", $hButton)
    GUISetState(@SW_SHOW)

    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_SetTitle

Function Reference

_GUIToolTip_SetTitle

Adds a standard icon and title string

#include <GuiToolTip.au3>
_GUIToolTip_SetTitle ( $hWnd, $sTitle [, $iIcon = 0] )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$sTitle | Title string
$iIcon | [optional] Set to one of the values below:. $TTI_NONE (0) - No icon [default] $TTI_INFO (1) - Information icon $TTI_WARNING (2) - Warning icon $TTI_ERROR (3) - Error Icon $TTI_INFO_LARGE (4) - Large Information Icon $TTI_WARNING_LARGE (5) - Large Warning Icon $TTI_ERROR_LARGE (6) - Large Error Icon

Return Value

Success: | True.
Failure: | False.

Remarks

As of Windows XP SP2 and later, $iIcon can contain an HICON value. Any value greater than 3 is assumed to be an HICON.
The title of a tooltip appears above the text, in a different font. It is not sufficient to have a title; the tooltip must have text as well, or it is not displayed.
A title with an Icon but no text in the title won't display a title or the icon. You have to set the text of the title, even if it's only one character, if you plan on using an icon.
The string entered in $sTitle must not exceed 99 characters in length.

Related

_GUIToolTip_GetTitleText, _GUIToolTip_UpdateTipText

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idAdd = GUICtrlCreateButton("Button", 30, 32, 130, 28)
    Local $hAdd = GUICtrlGetHandle($idAdd)

    ; Create a tooltip control
    Local $hToolTip = _GUIToolTip_Create($hGUI)

    ; Add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "This is the ToolTip text", $hAdd)

    ; Set the title of the tooltip
    _GUIToolTip_SetTitle($hToolTip, 'This is the ToolTip title', $TTI_INFO)

    GUISetState(@SW_SHOW)

    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_SetToolInfo

Function Reference

_GUIToolTip_SetToolInfo

Sets the information for a tool

#include <GuiToolTip.au3>
_GUIToolTip_SetToolInfo ( $hWnd, $sText [, $iID = 0 [, $iLeft = 0 [, $iTop = 0 [, $iRight = 0 [, $iBottom = 0 [, $iFlags = Default [, $iParam = 0]]]]]]] )

Parameters

$hWnd | Handle of the window that contains the tool, or 0
$sText | Text for the ToolTip control
$iID | [optional] Identifier of the tool, or Window handle of the control the tool is assigned to
$iLeft | [optional] X coordinate of the upper left corner of the rectangle
$iTop | [optional] Y coordinate of the upper left corner of the rectangle
$iRight | [optional] X coordinate of the lower right corner of the rectangle
$iBottom | [optional] Y coordinate of the lower right corner of the rectangle
$iFlags | [optional] Flags that control the ToolTip display: $TTF_IDISHWND - Indicates that $iID is a window or control handle, instead of the ID of the tool [default] $TTF_CENTERTIP - Centers the tooltip below the control specified by $iID $TTF_RTLREADING - Indicates that text will be displayed in the opposite direction (right to left) $TTF_SUBCLASS - Indicates that the control should subclass the tool's window [default] $TTF_TRACK - Positions the tooltip window next to the tool to which it corresponds $TTF_ABSOLUTE - Positions the window at the same coordinates provided by TTM_TRACKPOSITION. (see Remarks) $TTF_TRANSPARENT- Causes the control to forward mouse messages to the parent window $TTF_PARSELINKS - Indicates that links in the control text should be displayed as links
$iParam | [optional] Application-defined value that is associated with the tool

Return Value

None.

Remarks

Some internal properties of a tool are established when the tool is created, and are not recomputed when a $TTM_SETTOOLINFO message is sent.
If you simply assign values to a TOOLINFO structure and pass it to the ToolTip control with a $TTM_SETTOOLINFO message, these properties may be lost.
Instead your application should first request the tool's current TOOLINFO structure by sending a $TTM_GETTOOLINFO message.
Then, modify the members of this structure as needed and pass it back to the ToolTip control with $TTM_SETTOOLINFO.
When calling $TTM_SETTOOLINFO, the string pointed to by the Text member of the TOOLINFO structure must not exceed 80 characters in length.

Related

_GUIToolTip_GetToolInfo


Function _GUIToolTip_SetWindowTheme

Function Reference

_GUIToolTip_SetWindowTheme

Sets the visual style

#include <GuiToolTip.au3>
_GUIToolTip_SetWindowTheme ( $hWnd, $sStyle )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$sStyle | String that contains the ToolTip visual style to set

Return Value

None.


Function _GUIToolTip_ToolExists

Function Reference

_GUIToolTip_ToolExists

Determines whether a tool currently exists (is displayed)

#include <GuiToolTip.au3>
_GUIToolTip_ToolExists ( $hWnd )

Parameters

$hWnd Handle to the ToolTip control (returned by _GUIToolTip_Create.)

Return Value

True: | the tool exists.
False: | the tool does not exist.

Remarks

This function will only return true if the ToolTip control is currently displaying one of the Tools added to it.

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>
#include <MsgBoxConstants.au3>

Global $g_hToolTip

; Press the "g" key to display the information
HotKeySet("g", "Get_Tool")

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("Button ToolTip", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)
    ; create a tooltip control using default settings
    $g_hToolTip = _GUIToolTip_Create(0)

    ; add a tool to the tooltip control
    _GUIToolTip_AddTool($g_hToolTip, 0, "This is a ToolTip", $hButton)
    GUISetState(@SW_SHOW)
    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($g_hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example

Func Get_Tool()
    ; This will display "True" if the tool is displaying
    MsgBox($MB_SYSTEMMODAL, "", "Tooltip Exists = " & _GUIToolTip_ToolExists($g_hToolTip))
EndFunc   ;==>Get_Tool


Function _GUIToolTip_ToolToArray

Function Reference

_GUIToolTip_ToolToArray

Transfers a ToolInfo structure to an array

#include <GuiToolTip.au3>
_GUIToolTip_ToolToArray ( $hWnd, ByRef $tToolInfo, $iError )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$tToolInfo | $tagTOOLINFO structure
$iError | Error code to be returned

Return Value

Returns an array with the following format:
[0] - Comma separated string displaying TTF_ flags used
TTF_IDISHWND = Indicates that $iID is the window handle to the tool instead of the ID
TTF_CENTERTIP = Centers the window below the tool specified by $iID
TTF_RTLREADING = Indicates that text will be displayed in the opposite direction
TTF_SUBCLASS = Indicates that the control should subclass the tool's window to intercept messages
TTF_TRACK = Positions the control next to the tool to which it corresponds
TTF_ABSOLUTE = Positions the window at the same coordinates provided by TTM_TRACKPOSITION
TTF_TRANSPARENT = Causes the control to forward mouse messages to the parent window
TTF_PARSELINKS = Indicates that links in the control text should be parsed
[1] - Handle to the window that contains the tool
[2] - Identifier of the tool
[3] - X coordinate of the upper left corner of the rectangle
[4] - Y coordinate of the upper left corner of the rectangle
[5] - X coordinate of the lower right corner of the rectangle
[6] - Y coordinate of the lower right corner of the rectangle
[7] - Handle to the instance that contains the string resource for the tool
[8] - Text for the tool
[9] - Application-defined value associated with the tool

Remarks

$iError is the return code you want the function to return to the calling process.
This function is usually used with other UDF functions to disassemble the $tagTOOLINFO structure to an array for display purposes.

Related

_GUIToolTip_GetToolInfo


Function _GUIToolTip_TrackActivate

Function Reference

_GUIToolTip_TrackActivate

Activates or deactivates a tracking ToolTip

#include <GuiToolTip.au3>
_GUIToolTip_TrackActivate ( $hWnd [, $bActivate = True [, $hTool = 0 [, $iID = 0]]] )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$bActivate | [optional] True to activate, False to deactivate
$hTool | [optional] Handle to the window that contains the tool
$iID | [optional] Control handle that the tool is assigned to, or application-defined identifier of the tool

Return Value

None.

Remarks

You must use this function to activate a tracking tooltip prior to attempting to update its position using _GUIToolTip_TrackPosition()
If you use _GUIToolTip_TrackPosition() without using _GUIToolTip_TrackActivate() then the tool will only display when the mouse if over the assigned window or control, if applicable.

Related

_GUIToolTip_TrackPosition

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $hToolTip = _GUIToolTip_Create(0, $TTS_BALLOON)
    ; Add tool to the ToolTip control, not using a control or the GUI to link it to
    _GUIToolTip_AddTool($hToolTip, 0, " ", 0, 0, 0, 0, 0, $TTF_SUBCLASS)

    _GUIToolTip_SetTitle($hToolTip, 'Mouse position', $TTI_INFO)
    GUISetState(@SW_SHOW)

    _GUIToolTip_TrackActivate($hToolTip, True, 0, 0)
    Local $aPos, $iOldaPos0, $iOldaPos1
    While 1
        Sleep(10)
        $aPos = MouseGetPos()
        If $aPos[0] <> $iOldaPos0 Or $aPos[1] <> $iOldaPos1 Then
            _GUIToolTip_TrackPosition($hToolTip, $aPos[0] + 10, $aPos[1] + 20)
            _GUIToolTip_UpdateTipText($hToolTip, 0, 0, "X: " & $aPos[0] & " Y: " & $aPos[1])
            $iOldaPos0 = $aPos[0]
            $iOldaPos1 = $aPos[1]
        EndIf
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_TrackPosition

Function Reference

_GUIToolTip_TrackPosition

Sets the position of a tracking ToolTip

#include <GuiToolTip.au3>
_GUIToolTip_TrackPosition ( $hWnd, $iX, $iY )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$iX | X position in screen coordinates
$iY | Y position in screen coordinates

Return Value

None.

Remarks

The ToolTip will display the window based on the coordinates you provide with this message.
You must use _GUIToolTip_TrackActivate() in combination with _GUIToolTip_TrackPosition() otherwise this function has no effect on the ToolTip.

Related

_GUIToolTip_TrackActivate

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton(" Button ", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)

    Local $hToolTip = _GUIToolTip_Create($hGUI, BitOR($_TT_ghTTDefaultStyle, $TTS_BALLOON))

    _GUIToolTip_AddTool($hToolTip, 0, " ", $hButton)

    _GUIToolTip_SetTitle($hToolTip, 'Mouse position', $TTI_INFO)
    GUISetState(@SW_SHOW)
    ; Find the mouse's position to use as the starting point for tracking
    Local $aPos = MouseGetPos()
    _GUIToolTip_TrackPosition($hToolTip, $aPos[0], $aPos[1])
    _GUIToolTip_TrackActivate($hToolTip, True, 0, $hButton)

    While 1
        ; Read the mouse position
        $aPos = MouseGetPos()
        ; Use the position of the mouse to set the location of the tooltip
        _GUIToolTip_TrackPosition($hToolTip, $aPos[0], $aPos[1])
        _GUIToolTip_UpdateTipText($hToolTip, 0, $hButton, "X: " & $aPos[0] & " Y: " & $aPos[1])
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _GUIToolTip_Update

Function Reference

_GUIToolTip_Update

Forces the current tool to be redrawn

#include <GuiToolTip.au3>
_GUIToolTip_Update ( $hWnd )

Parameters

$hWnd Handle to the ToolTip control (returned by _GUIToolTip_Create.)

Return Value

None.

Remarks

This will redraw the currently displaying tooltip, it will have no effect on a tool if it is not showing when you call this function.


Function _GUIToolTip_UpdateTipText

Function Reference

_GUIToolTip_UpdateTipText

Sets the ToolTip text for a tool

#include <GuiToolTip.au3>
_GUIToolTip_UpdateTipText ( $hWnd, $hTool, $iID, $sText )

Parameters

$hWnd | Handle to the ToolTip control (returned by _GUIToolTip_Create.)
$hTool | Handle of the window that contains the tool, or 0
$iID | Identifier of the tool, or Window handle of the control the tool is to be assigned to
$sText | Text for the ToolTip control.

Return Value

None.

Related

_GUIToolTip_GetText

Example

#include <GUIConstantsEx.au3>
#include <GUIToolTip.au3>

Example()

Func Example()
    Local $hGUI = GUICreate(StringTrimRight(@ScriptName, StringLen(".exe")), 350, 200)

    Local $idButton = GUICtrlCreateButton("Button", 30, 32, 130, 28)
    Local $hButton = GUICtrlGetHandle($idButton)

    ; Create a tooltip control
    Local $hToolTip = _GUIToolTip_Create($hGUI)

    ; Add a tool to the tooltip control
    _GUIToolTip_AddTool($hToolTip, 0, "Click this to change tooltip text", $hButton)
    GUISetState(@SW_SHOW)
    Local $bNew = False
    While 1
        Switch GUIGetMsg()
            Case $idButton ; Press the button to change the text of the tooltip
                $bNew = Not $bNew
                If $bNew Then
                    _GUIToolTip_UpdateTipText($hToolTip, 0, $hButton, 'New text')
                Else
                    _GUIToolTip_UpdateTipText($hToolTip, 0, $hButton, "Click this to change tooltip text")
                EndIf
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    ; Destroy the tooltip control
    _GUIToolTip_Destroy($hToolTip)
    GUIDelete($hGUI)
EndFunc   ;==>Example


User Defined Functions

GuiTreeView user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GuiTreeView.au3>.

User Defined Function | Description
_GUICtrlTreeView_Add | Adds a new item
_GUICtrlTreeView_AddChild | Adds a new item
_GUICtrlTreeView_AddChildFirst | Adds a new item
_GUICtrlTreeView_AddFirst | Adds a new item
_GUICtrlTreeView_BeginUpdate | Prevents updating of the control until the EndUpdate function is called
_GUICtrlTreeView_ClickItem | Click on a item
_GUICtrlTreeView_Create | Create a TreeView control
_GUICtrlTreeView_CreateDragImage | Creates a dragging bitmap for the specified item
_GUICtrlTreeView_CreateSolidBitMap | Creates a solid color bitmap
_GUICtrlTreeView_Delete | Removes an item and all its children
_GUICtrlTreeView_DeleteAll | Removes all items from a tree-view control
_GUICtrlTreeView_DeleteChildren | Deletes all children of a item
_GUICtrlTreeView_Destroy | Delete the control
_GUICtrlTreeView_DisplayRect | Returns the bounding rectangle for a tree item
_GUICtrlTreeView_DisplayRectEx | Returns the bounding rectangle for a tree item
_GUICtrlTreeView_EditText | Begins in-place editing of the specified item's text
_GUICtrlTreeView_EndEdit | Ends the editing of the item's text
_GUICtrlTreeView_EndUpdate | Enables screen repainting that was turned off with the BeginUpdate function
_GUICtrlTreeView_EnsureVisible | Ensures that a item is visible, expanding the parent item or scrolling the control if necessary
_GUICtrlTreeView_Expand | Expands or collapses the list of child items associated with the specified parent item, if any
_GUICtrlTreeView_ExpandedOnce | Indicates if the item's list of child items has been expanded at least once
_GUICtrlTreeView_FindItem | Retrieves a item based on it's text
_GUICtrlTreeView_FindItemEx | Retrieves a item based on a tree path
_GUICtrlTreeView_GetBkColor | Retrieve the text back color
_GUICtrlTreeView_GetBold | Indicates if the item is drawn in a bold style
_GUICtrlTreeView_GetChecked | Indicates if a item has its checkbox checked
_GUICtrlTreeView_GetChildCount | Retrieves the number of children of an parent item
_GUICtrlTreeView_GetChildren | Indicates whether the item children flag is set
_GUICtrlTreeView_GetCount | Retrieves a count of the items
_GUICtrlTreeView_GetCut | Indicates if the item is drawn as if selected as part of a cut and paste operation
_GUICtrlTreeView_GetDropTarget | Indicates whether the item is drawn as a drag and drop target
_GUICtrlTreeView_GetEditControl | Retrieves the handle to the edit control being used to edit a item's text
_GUICtrlTreeView_GetExpanded | Indicates whether the item is expanded
_GUICtrlTreeView_GetFirstChild | Retrieves the first child item of the specified item
_GUICtrlTreeView_GetFirstItem | Retrieves the topmost or very first item
_GUICtrlTreeView_GetFirstVisible | Retrieves the first visible item in the control
_GUICtrlTreeView_GetFocused | Indicates whether the item has focus
_GUICtrlTreeView_GetHeight | Retrieves the current height of the each item
_GUICtrlTreeView_GetImageIndex | Retrieves the normal state image index
_GUICtrlTreeView_GetImageListIconHandle | Retrieve ImageList handle
_GUICtrlTreeView_GetIndent | Retrieves the amount, in pixels, that child items are indented relative to their parent items
_GUICtrlTreeView_GetInsertMarkColor | Retrieves the color used to draw the insertion mark
_GUICtrlTreeView_GetISearchString | Retrieves the incremental search string
_GUICtrlTreeView_GetItemByIndex | Retrieve a item by its position in the list of child items
_GUICtrlTreeView_GetItemHandle | Retrieve the item handle
_GUICtrlTreeView_GetItemParam | Retrieves the application specific value of the item
_GUICtrlTreeView_GetLastChild | Retrieves the last child item of the specified item
_GUICtrlTreeView_GetLineColor | Retrieve the line color
_GUICtrlTreeView_GetNext | Retrieves the next item after the calling item
_GUICtrlTreeView_GetNextChild | Returns the next item at the same level as the specified item
_GUICtrlTreeView_GetNextSibling | Returns the next item at the same level as the specified item
_GUICtrlTreeView_GetNextVisible | Retrieves the next visible item that follows the specified item
_GUICtrlTreeView_GetNormalImageList | Retrieves the normal image list
_GUICtrlTreeView_GetParentHandle | Retrieve the parent handle of item
_GUICtrlTreeView_GetParentParam | Retrieve the parent control ID/Param of item
_GUICtrlTreeView_GetPrev | Retrieves the previous item before the calling item
_GUICtrlTreeView_GetPrevChild | Retrieves the previous child item of a specified item
_GUICtrlTreeView_GetPrevSibling | Returns the previous item before the calling item at the same level
_GUICtrlTreeView_GetPrevVisible | Retrieves the first visible item that precedes the specified item
_GUICtrlTreeView_GetScrollTime | Retrieves the maximum scroll time
_GUICtrlTreeView_GetSelected | Indicates whether the item appears in the selected state
_GUICtrlTreeView_GetSelectedImageIndex | Retrieves the index in the image list of the image displayed for the item when it is selected
_GUICtrlTreeView_GetSelection | Retrieves the currently selected item
_GUICtrlTreeView_GetSiblingCount | Retrieves the number of siblings at the level of an item
_GUICtrlTreeView_GetState | Retrieve the state of the item
_GUICtrlTreeView_GetStateImageIndex | Retrieves the index of the state image to display for the item
_GUICtrlTreeView_GetStateImageList | Retrieves the handle to the state image list
_GUICtrlTreeView_GetText | Retrieve the item text
_GUICtrlTreeView_GetTextColor | Retrieve the text color
_GUICtrlTreeView_GetToolTips | Retrieves the handle to the child ToolTip control
_GUICtrlTreeView_GetTree | Retrieve all items text
_GUICtrlTreeView_GetUnicodeFormat | Retrieves the Unicode character format flag
_GUICtrlTreeView_GetVisible | Indicates whether the item is currently visible in the control image
_GUICtrlTreeView_GetVisibleCount | Returns the number of items that can be fully visible in the control
_GUICtrlTreeView_HitTest | Returns information about the location of a point relative to the control
_GUICtrlTreeView_HitTestEx | Returns information about the location of a point relative to the control
_GUICtrlTreeView_HitTestItem | Returns the item at the specified coordinates
_GUICtrlTreeView_Index | Retrieves the position of the item in the list
_GUICtrlTreeView_InsertItem | Insert an item
_GUICtrlTreeView_IsFirstItem | Indicates whether the tree item is very first
_GUICtrlTreeView_IsParent | Indicates whether one item is the parent of another item
_GUICtrlTreeView_Level | Indicates the level of indentation of a item
_GUICtrlTreeView_SelectItem | Selects the specified item, scrolls the item into view, or redraws the item
_GUICtrlTreeView_SelectItemByIndex | Selects the item based on it's index in the parent list
_GUICtrlTreeView_SetBkColor | Sets the back color
_GUICtrlTreeView_SetBold | Sets whether the item is drawn using a bold sytle
_GUICtrlTreeView_SetChecked | Sets whether a item has it's checkbox checked or not
_GUICtrlTreeView_SetCheckedByIndex | Sets whether an item has it's checkbox checked or not by it's index
_GUICtrlTreeView_SetChildren | Sets whether the item children flag
_GUICtrlTreeView_SetCut | Sets whether the item is drawn as if selected as part of a cut and paste operation
_GUICtrlTreeView_SetDropTarget | Sets whether the item is drawn as a drag and drop target
_GUICtrlTreeView_SetFocused | Sets whether the item appears to have focus
_GUICtrlTreeView_SetHeight | Sets the height of the each item
_GUICtrlTreeView_SetIcon | Set an item icon
_GUICtrlTreeView_SetImageIndex | Sets the index into image list for which image is displayed when a item is in its normal state
_GUICtrlTreeView_SetIndent | Sets the width of indentation for a tree-view control and redraws the control to reflect the new width
_GUICtrlTreeView_SetInsertMark | Sets the insertion mark
_GUICtrlTreeView_SetInsertMarkColor | Sets the color used to draw the insertion mark
_GUICtrlTreeView_SetItemHeight | Sets the height of an individual item
_GUICtrlTreeView_SetItemParam | Sets the value specific to the item
_GUICtrlTreeView_SetLineColor | Sets the line color
_GUICtrlTreeView_SetNormalImageList | Sets the normal image list for the control
_GUICtrlTreeView_SetScrollTime | Sets the maximum scroll time
_GUICtrlTreeView_SetSelected | Sets whether the item appears in the selected state
_GUICtrlTreeView_SetSelectedImageIndex | Sets the selected image index
_GUICtrlTreeView_SetState | Set the state of the specified item
_GUICtrlTreeView_SetStateImageIndex | Sets the index into image list for the state image
_GUICtrlTreeView_SetStateImageList | Sets the state image list for the control
_GUICtrlTreeView_SetText | Set the text of an item
_GUICtrlTreeView_SetTextColor | Sets the text color
_GUICtrlTreeView_SetToolTips | Sets the handle to the child ToolTip control
_GUICtrlTreeView_SetUnicodeFormat | Sets the Unicode character format flag
_GUICtrlTreeView_Sort | Sorts the items


Function _GUICtrlTreeView_Add

Function Reference

_GUICtrlTreeView_Add

Adds a new item

#include <GuiTreeView.au3>
_GUICtrlTreeView_Add ( $hWnd, $hSibling, $sText [, $iImage = -1 [, $iSelImage = -1]] )

Parameters

$hWnd | Control ID/Handle to the control
$hSibling | Sibling item
$sText | Text of the item
$iImage | [optional] 0-based index of the item's icon in the control's image list
$iSelImage | [optional] 0-based index of the item's icon in the control's image list

Return Value

Success: | the handle to the new item.
Failure: | 0.

Remarks

The item is added as the last sibling of $hSibling.
If the control is sorted, the function inserts the item in the correct sort order position rather than as the last child of $hSibling.

Related

_GUICtrlTreeView_AddFirst

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hItem, $hImage, $iImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Add", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 1 To Random(2, 10, 1)
        $iImage = Random(0, 5, 1)
        $hItem = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), $iImage, $iImage)
        For $y = 1 To Random(2, 10, 1)
            $iImage = Random(0, 5, 1)
            _GUICtrlTreeView_AddChild($idTreeView, $hItem, StringFormat("[%02d] New Child", $y), $iImage, $iImage)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_AddChild

Function Reference

_GUICtrlTreeView_AddChild

Adds a new item

#include <GuiTreeView.au3>
_GUICtrlTreeView_AddChild ( $hWnd, $hParent, $sText [, $iImage = -1 [, $iSelImage = -1]] )

Parameters

$hWnd | Control ID/Handle to the control
$hParent | Parent item
$sText | Text of the item
$iImage | [optional] 0-based index of the item's icon in the control's image list
$iSelImage | [optional] 0-based index of the item's icon in the control's image list

Return Value

Success: | the handle to the new item.
Failure: | 0.

Remarks

The item is added as a child of $hParent. It is added to the end of $hParent's list of child items.
If the control is sorted, this function inserts the item in the correct sort order position, rather than as the last child of $hParent.

Related

_GUICtrlTreeView_AddChildFirst

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hItem, $hImage, $iImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Add Child", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 1 To Random(2, 10, 1)
        $iImage = Random(0, 5, 1)
        $hItem = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), $iImage, $iImage)
        For $y = 1 To Random(2, 10, 1)
            $iImage = Random(0, 5, 1)
            _GUICtrlTreeView_AddChild($idTreeView, $hItem, StringFormat("[%02d] New Child", $y), $iImage, $iImage)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_AddChildFirst

Function Reference

_GUICtrlTreeView_AddChildFirst

Adds a new item

#include <GuiTreeView.au3>
_GUICtrlTreeView_AddChildFirst ( $hWnd, $hParent, $sText [, $iImage = -1 [, $iSelImage = -1]] )

Parameters

$hWnd | Control ID/Handle to the control
$hParent | Parent item
$sText | Text of the item
$iImage | [optional] 0-based index of the item's icon in the control's image list
$iSelImage | [optional] 0-based index of the item's icon in the control's image list

Return Value

Success: | the handle to the new item.
Failure: | 0.

Remarks

The item is added as the first child of $hParent. Items that appear after the added item are moved down.

Related

_GUICtrlTreeView_AddChild

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hItem, $hImage, $iImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Add Child First", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 1 To Random(2, 10, 1)
        $iImage = Random(0, 5, 1)
        $hItem = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), $iImage, $iImage)
        For $y = 1 To Random(2, 10, 1)
            $iImage = Random(0, 4, 1)
            _GUICtrlTreeView_AddChild($idTreeView, $hItem, StringFormat("[%02d] New Child", $y), $iImage, $iImage)
        Next
        _GUICtrlTreeView_AddChildFirst($idTreeView, $hItem, "[00] First Child", 5, 5)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_AddFirst

Function Reference

_GUICtrlTreeView_AddFirst

Adds a new item

#include <GuiTreeView.au3>
_GUICtrlTreeView_AddFirst ( $hWnd, $hSibling, $sText [, $iImage = -1 [, $iSelImage = -1]] )

Parameters

$hWnd | Control ID/Handle to the control
$hSibling | Sibling item
$sText | Text of the item
$iImage | [optional] 0-based index of the item's icon in the control's image list
$iSelImage | [optional] 0-based index of the item's icon in the control's image list

Return Value

Success: | the handle to the new item.
Failure: | 0.

Remarks

The item is added as the first sibling of $hSibling. Items that appear after the added item are moved down.

Related

_GUICtrlTreeView_Add

Example

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

Example()

Func Example()
    Local $hItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Add First", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 1 To Random(2, 10, 1)
        $hItem = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x))
        For $y = 1 To Random(2, 10, 1)
            _GUICtrlTreeView_AddChild($idTreeView, $hItem, StringFormat("[%02d] New Child", $y))
        Next
    Next
    _GUICtrlTreeView_AddFirst($idTreeView, $hItem, "[00] New First Item")
    _GUICtrlTreeView_EndUpdate($idTreeView)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_BeginUpdate

Function Reference

_GUICtrlTreeView_BeginUpdate

Prevents updating of the control until the EndUpdate function is called

#include <GuiTreeView.au3>
_GUICtrlTreeView_BeginUpdate ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTreeView_EndUpdate

Example

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

Example()

Func Example()
    Local $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Begin Update", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 1 To 100
        _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x))
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_ClickItem

Function Reference

_GUICtrlTreeView_ClickItem

Click on a item

#include <GuiTreeView.au3>
_GUICtrlTreeView_ClickItem ( $hWnd, $hItem [, $sButton = "left" [, $bMove = False [, $iClicks = 1 [, $iSpeed = 0]]]] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item
$sButton | [optional] Button to click
$bMove | [optional] If True, the mouse will be moved. If False, the mouse does not move.
$iClicks | [optional] Number of clicks
$iSpeed | [optional] Mouse movement speed

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>

Global $g_idTreeView

Example()

Func Example()
    Local $hItem, $hImage, $iImage
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Click Item", 400, 300)

    $g_idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($g_idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($g_idTreeView)
    For $x = 1 To Random(2, 10, 1)
        $iImage = Random(0, 5, 1)
        $hItem = _GUICtrlTreeView_Add($g_idTreeView, 0, StringFormat("[%02d] New Item", $x), $iImage, $iImage)
        For $y = 1 To Random(2, 10, 1)
            $iImage = Random(0, 5, 1)
            _GUICtrlTreeView_AddChild($g_idTreeView, $hItem, StringFormat("[%02d] New Child", $y), $iImage, $iImage)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($g_idTreeView)

    _GUICtrlTreeView_ClickItem($g_idTreeView, $hItem, "left", False, 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview
    $hWndTreeview = $g_idTreeView
    If Not IsHWnd($g_idTreeView) Then $hWndTreeview = GUICtrlGetHandle($g_idTreeView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndTreeview
            Switch $iCode
                Case $NM_CLICK ; The user has clicked the left mouse button within the control
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return 1 ; nonzero to not allow the default processing
                    Return 0 ; zero to allow the default processing
                Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return 1 ; nonzero to not allow the default processing
                    Return 0 ; zero to allow the default processing
                Case $NM_RCLICK ; The user has clicked the right mouse button within the control
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return 1 ; nonzero to not allow the default processing
                    Return 0 ; zero to allow the default processing
                Case $NM_RDBLCLK ; The user has double-clicked the right mouse button within the control
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return 1 ; nonzero to not allow the default processing
                    Return 0 ; zero to allow the default processing
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlTreeView_Create

Function Reference

_GUICtrlTreeView_Create

Create a TreeView control

#include <GuiTreeView.au3>
_GUICtrlTreeView_Create ( $hWnd, $iX, $iY [, $iWidth = 150 [, $iHeight = 150 [, $iStyle = 0x00000037 [, $iExStyle = 0x00000000]]]] )

Parameters

$hWnd | Handle to parent or owner window
$iX | Horizontal position of the control
$iY | Vertical position of the control
$iWidth | [optional] Control width
$iHeight | [optional] Control height
$iStyle [optional] Control style:
$TVS_CHECKBOXES - Enables check boxes for items. A check box will be displayed only if an image is associated with the item.
When set to this style, the control effectively uses DrawFrameControl to create and set a state image list containing two images.
State image 1 is the unchecked box and state image 2 is the checked box.
Setting the state image to zero removes the check box.
Version 5.80 displays a check box even if no image is associated with the item.
$TVS_DISABLEDRAGDROP - Prevents the control from sending $TVN_BEGINDRAG notification messages
$TVS_EDITLABELS - Allows the user to edit the item labels
$TVS_FULLROWSELECT - Enables full row selection.
The entire row of the selected item is highlighted, and clicking anywhere on an item's row causes it to be selected.
This style cannot be used in conjunction with the $TVS_HASLINES style.
$TVS_HASBUTTONS - Displays plus and minus buttons next to parent items.
The user clicks the buttons to expand or collapse a parent item's list of child items.
To include buttons with items at the root, you must also specify $TVS_LINESATROOT.
$TVS_HASLINES - Uses lines to show the hierarchy of items
$TVS_INFOTIP - Obtains ToolTip information by sending the $TVN_GETINFOTIP notification
$TVS_LINESATROOT - Uses lines to link items at the root of the control. This value is ignored if
$TVS_HASLINES is not also specified.
$TVS_NOHSCROLL - Disables horizontal scrolling in the control. The control will not display any horizontal scroll bars.
$TVS_NONEVENHEIGHT - Sets the height of the items to an odd height with the $TVM_SETITEMHEIGHT message.
By default the height of items must be an even value.
$TVS_NOSCROLL - Disables both horizontal and vertical scrolling in the control. The control will not display any scroll bars.
$TVS_NOTOOLTIPS - Disables ToolTips
$TVS_RTLREADING - Causes text to be displayed from right to left
$TVS_SHOWSELALWAYS - Causes a selected item to remain selected when the control loses focus
$TVS_SINGLEEXPAND - Causes the item being selected to expand and the item being unselected to collapse upon selection.
If the mouse is used to single-click the selected item and that item is closed, it will be expanded.
If the user holds down the CTRL key while selecting an item, the item being unselected will not be collapsed.
Version 5.80 causes the item being selected to expand and the item being unselected to collapse upon selection.
If the user holds down the CTRL key while selecting an item, the item being unselected will not be collapsed.
$TVS_TRACKSELECT - Enables hot tracking

Default: $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS
Forced: $WS_CHILD, $WS_VISIBLE
$iExStyle | [optional] Control extended style

Return Value

Success: | the handle to the control.
Failure: | 0.

Remarks

This function is for Advanced users and for learning how the control works.

Related

_GUICtrlTreeView_Destroy

Example

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

Global $g_hTreeView

Example()

Func Example()
    Local $hGUI, $hItem
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
    $hGUI = GUICreate("(UDF Created) TreeView Create", 400, 300)

    $g_hTreeView = _GUICtrlTreeView_Create($hGUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    _GUICtrlTreeView_BeginUpdate($g_hTreeView)
    For $x = 1 To Random(2, 10, 1)
        $hItem = _GUICtrlTreeView_Add($g_hTreeView, 0, StringFormat("[%02d] New Item", $x))
        For $y = 1 To Random(2, 10, 1)
            _GUICtrlTreeView_AddChild($g_hTreeView, $hItem, StringFormat("[%02d] New Child", $y))
        Next
    Next
    _GUICtrlTreeView_EndUpdate($g_hTreeView)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview
    $hWndTreeview = $g_hTreeView
    If Not IsHWnd($g_hTreeView) Then $hWndTreeview = GUICtrlGetHandle($g_hTreeView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndTreeview
            Switch $iCode
                Case $NM_CLICK ; The user has clicked the left mouse button within the control
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return 1 ; nonzero to not allow the default processing
                    Return 0 ; zero to allow the default processing
                Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return 1 ; nonzero to not allow the default processing
                    Return 0 ; zero to allow the default processing
                Case $NM_RCLICK ; The user has clicked the right mouse button within the control
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return 1 ; nonzero to not allow the default processing
                    Return 0 ; zero to allow the default processing
                Case $NM_RDBLCLK ; The user has double-clicked the right mouse button within the control
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return 1 ; nonzero to not allow the default processing
                    Return 0 ; zero to allow the default processing
                Case $NM_KILLFOCUS ; control has lost the input focus
                    _DebugPrint("$NM_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_RETURN ; control has the input focus and that the user has pressed the key
                    _DebugPrint("$NM_RETURN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return 1 ; nonzero to not allow the default processing
                    Return 0 ; zero to allow the default processing
                    ; Case $NM_SETCURSOR ; control is setting the cursor in response to a WM_SETCURSOR message
                    ; Local $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    ; $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    ; $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    ; $iCode = DllStructGetData($tInfo, "Code")
                    ; _DebugPrint("$NM_SETCURSOR" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                    ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                    ; "-->Code:" & @TAB & $iCode & @CRLF & _
                    ; "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                    ; "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                    ; "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                    ; "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                    ; "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    ; Return 0 ; to enable the control to set the cursor
                    ; Return 1 ; nonzero to prevent the control from setting the cursor
                Case $NM_SETFOCUS ; control has received the input focus
                    _DebugPrint("$NM_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $TVN_BEGINDRAGA, $TVN_BEGINDRAGW
                    _DebugPrint("$TVN_BEGINDRAG")
                Case $TVN_BEGINLABELEDITA, $TVN_BEGINLABELEDITW
                    _DebugPrint("$TVN_BEGINLABELEDIT")
                Case $TVN_BEGINRDRAGA, $TVN_BEGINRDRAGW
                    _DebugPrint("$TVN_BEGINRDRAG")
                Case $TVN_DELETEITEMA, $TVN_DELETEITEMW
                    _DebugPrint("$TVN_DELETEITEM")
                Case $TVN_ENDLABELEDITA, $TVN_ENDLABELEDITW
                    _DebugPrint("$TVN_ENDLABELEDIT")
                Case $TVN_GETDISPINFOA, $TVN_GETDISPINFOW
                    _DebugPrint("$TVN_GETDISPINFO")
                Case $TVN_GETINFOTIPA, $TVN_GETINFOTIPW
                    _DebugPrint("$TVN_GETINFOTIP")
                Case $TVN_ITEMEXPANDEDA, $TVN_ITEMEXPANDEDW
                    _DebugPrint("$TVN_ITEMEXPANDED")
                Case $TVN_ITEMEXPANDINGA, $TVN_ITEMEXPANDINGW
                    _DebugPrint("$TVN_ITEMEXPANDING")
                Case $TVN_KEYDOWN
                    _DebugPrint("$TVN_KEYDOWN")
                Case $TVN_SELCHANGEDA, $TVN_SELCHANGEDW
                    _DebugPrint("$TVN_SELCHANGED")
                Case $TVN_SELCHANGINGA, $TVN_SELCHANGINGW
                    _DebugPrint("$TVN_SELCHANGING")
                Case $TVN_SETDISPINFOA, $TVN_SETDISPINFOW
                    _DebugPrint("$TVN_SETDISPINFO")
                Case $TVN_SINGLEEXPAND
                    _DebugPrint("$TVN_SINGLEEXPAND")
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlTreeView_CreateDragImage

Function Reference

_GUICtrlTreeView_CreateDragImage

Creates a dragging bitmap for the specified item

#include <GuiTreeView.au3>
_GUICtrlTreeView_CreateDragImage ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

Success: | the image list handle to which the dragging bitmap was added.
Failure: | 0.

Remarks

If you create the control without an associated image list, you cannot use this function to create the image to display during a drag operation.
You must implement your own method of creating a drag cursor.
You are responsible for destroying the image list when it is no longer needed.

Example

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

Example()

Func Example()
    Local $hGUI, $hImage, $iImage, $hItem, $bDragging = False, $aDrag, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    $hGUI = GUICreate("TreeView Create Drage Image", 400, 300)
    $idTreeView = GUICtrlGetHandle(GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE))

    GUISetState(@SW_SHOW)

    ; Load images
    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUIImageList_Add($hImage, _GUICtrlTreeView_CreateSolidBitMap($idTreeView, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlTreeView_CreateSolidBitMap($idTreeView, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlTreeView_CreateSolidBitMap($idTreeView, 0x0000FF, 16, 16))
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 1 To Random(2, 10, 1)
        $iImage = Random(0, 8, 1)
        $hItem = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), $iImage, $iImage)
        For $y = 1 To Random(2, 10, 1)
            $iImage = Random(0, 8, 1)
            _GUICtrlTreeView_AddChild($idTreeView, $hItem, StringFormat("[%02d] New Child", $y), $iImage, $iImage)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)
    _GUICtrlTreeView_SelectItem($idTreeView, 0)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_MOUSEMOVE
                If $bDragging Then DrawDragImage($idTreeView, $aDrag)

            Case $GUI_EVENT_PRIMARYDOWN
                Local $hSelected = _GUICtrlTreeView_GetSelection($idTreeView)
                If $hSelected Then
                    $bDragging = True
                    ; Create drag image
                    $aDrag = _GUICtrlTreeView_CreateDragImage($idTreeView, $hSelected)
                    DrawDragImage($idTreeView, $aDrag)
                EndIf

            Case $GUI_EVENT_PRIMARYUP
                If $bDragging Then
                    $bDragging = False
                    ; delete image list
                    _GUIImageList_Destroy($aDrag)
                    _WinAPI_InvalidateRect($idTreeView)
                    _WinAPI_InvalidateRect(HWnd($hGUI))
                EndIf
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete()
EndFunc   ;==>Example

; Draw drag image
Func DrawDragImage(ByRef $hControl, ByRef $aDrag)
    Local $tPoint, $hDC
    $hDC = _WinAPI_GetWindowDC($hControl)
    $tPoint = _WinAPI_GetMousePos(True, $hControl)
    _WinAPI_InvalidateRect($hControl)
    _GUIImageList_Draw($aDrag, 0, $hDC, DllStructGetData($tPoint, "X"), DllStructGetData($tPoint, "Y"))
    _WinAPI_ReleaseDC($hControl, $hDC)
EndFunc   ;==>DrawDragImage


Function _GUICtrlTreeView_CreateSolidBitMap

Function Reference

_GUICtrlTreeView_CreateSolidBitMap

Creates a solid color bitmap

#include <GuiTreeView.au3>
_GUICtrlTreeView_CreateSolidBitMap ( $hWnd, $iColor, $iWidth, $iHeight )

Parameters

$hWnd | Control ID/Handle to the control
$iColor | The color of the bitmap, stated in RGB
$iWidth | The width of the bitmap
$iHeight | The height of the bitmap

Return Value

Returns the handle to the bitmap.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Create Solid BitMap", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlTreeView_CreateSolidBitMap($idTreeView, 0xFF0000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlTreeView_CreateSolidBitMap($idTreeView, 0x00FF00, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlTreeView_CreateSolidBitMap($idTreeView, 0x0000FF, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlTreeView_CreateSolidBitMap($idTreeView, 0xFF00FF, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlTreeView_CreateSolidBitMap($idTreeView, 0x000000, 16, 16))
    _GUIImageList_Add($hImage, _GUICtrlTreeView_CreateSolidBitMap($idTreeView, 0x00FFFF, 16, 16))
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
        _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x + 3)
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_Delete

Function Reference

_GUICtrlTreeView_Delete

Removes an item and all its children

#include <GuiTreeView.au3>
_GUICtrlTreeView_Delete ( $hWnd [, $hItem = 0] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | [optional] Handle/Control ID of item

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTreeView_DeleteAll, _GUICtrlTreeView_DeleteChildren

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hItem, $hImage, $iImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Delete", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 1 To Random(2, 10, 1)
        $iImage = Random(0, 5, 1)
        $hItem = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), $iImage, $iImage)
        For $y = 1 To Random(2, 10, 1)
            $iImage = Random(0, 5, 1)
            _GUICtrlTreeView_AddChild($idTreeView, $hItem, StringFormat("[%02d] New Child", $y), $iImage, $iImage)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Delete Item")
    _GUICtrlTreeView_Delete($idTreeView, $hItem)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_DeleteAll

Function Reference

_GUICtrlTreeView_DeleteAll

Removes all items from a tree-view control

#include <GuiTreeView.au3>
_GUICtrlTreeView_DeleteAll ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTreeView_Delete, _GUICtrlTreeView_DeleteChildren

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hItem, $hImage, $iImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Delete All", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 1 To Random(2, 10, 1)
        $iImage = Random(0, 5, 1)
        $hItem = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), $iImage, $iImage)
        For $y = 1 To Random(2, 10, 1)
            $iImage = Random(0, 5, 1)
            _GUICtrlTreeView_AddChild($idTreeView, $hItem, StringFormat("[%02d] New Child", $y), $iImage, $iImage)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Delete All")
    _GUICtrlTreeView_DeleteAll($idTreeView)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_DeleteChildren

Function Reference

_GUICtrlTreeView_DeleteChildren

Deletes all children of a item

#include <GuiTreeView.au3>
_GUICtrlTreeView_DeleteChildren ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item whose children will be deleted

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTreeView_Delete, _GUICtrlTreeView_DeleteAll

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hItem, $hImage, $iImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Delete All", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 1 To 2
        $iImage = Random(0, 5, 1)
        $hItem = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), $iImage, $iImage)
        For $y = 1 To 3
            $iImage = Random(0, 5, 1)
            _GUICtrlTreeView_AddChild($idTreeView, $hItem, StringFormat("[%02d] New Child", $y), $iImage, $iImage)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_Expand($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Delete Children")
    _GUICtrlTreeView_DeleteChildren($idTreeView, $hItem)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_Destroy

Function Reference

_GUICtrlTreeView_Destroy

Delete the control

#include <GuiTreeView.au3>
_GUICtrlTreeView_Destroy ( ByRef $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True, Handle is set to 0.
Failure: | False.

Remarks

Restricted to only be used on TreeView controls created with _GUICtrlTreeView_Create()

Related

_GUICtrlTreeView_Create

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGUI, $hItem, $hTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    $hGUI = GUICreate("(UDF Created) TreeView Destroy", 400, 300)

    $hTreeView = _GUICtrlTreeView_Create($hGUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($hTreeView)
    For $x = 1 To Random(2, 10, 1)
        $hItem = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x))
        For $y = 1 To Random(2, 10, 1)
            _GUICtrlTreeView_AddChild($hTreeView, $hItem, StringFormat("[%02d] New Child", $y))
        Next
    Next
    _GUICtrlTreeView_EndUpdate($hTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Destroy TreeView Control")
    _GUICtrlTreeView_Destroy($hTreeView)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_DisplayRect

Function Reference

_GUICtrlTreeView_DisplayRect

Returns the bounding rectangle for a tree item

#include <GuiTreeView.au3>
_GUICtrlTreeView_DisplayRect ( $hWnd, $hItem [, $bTextOnly = False] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item whose rectangle will be returned
$bTextOnly | [optional] If the True, the bounding rectangle includes only the text of the item. Otherwise, it includes the entire line that the item occupies.

Return Value

Success: | an array with the following format: $aRect[0] - X coordinate of the upper left corner of the rectangle $aRect[1] - Y coordinate of the upper left corner of the rectangle $aRect[2] - X coordinate of the lower right corner of the rectangle $aRect[3] - Y coordinate of the lower right corner of the rectangle
Failure: | sets the @error flag to non-zero.

Related

_GUICtrlTreeView_DisplayRectEx

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $ahItem[6], $hImage, $aRect, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Display Rect", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
    Next
    $aRect = _GUICtrlTreeView_DisplayRect($idTreeView, $ahItem[2])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item 2 Rectangle : [%d, %d, %d, %d]", $aRect[0], $aRect[1], $aRect[2], $aRect[3]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_DisplayRectEx

Function Reference

_GUICtrlTreeView_DisplayRectEx

Returns the bounding rectangle for a tree item

#include <GuiTreeView.au3>
_GUICtrlTreeView_DisplayRectEx ( $hWnd, $hItem [, $bTextOnly = False] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item whose rectangle will be returned
$bTextOnly | [optional] If the True, the bounding rectangle includes only the text of the item. Otherwise, it includes the entire line that the item occupies.

Return Value

Success: | a $tagRECT structure that holds the bounding rectangle. The coordinates are relative to the upper left corner of the control.
Failure: | sets the @error flag to non-zero.

Related

$tagRECT, _GUICtrlTreeView_DisplayRect

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $ahItem[6], $hImage, $tRECT, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Display RectEx", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
    Next
    $tRECT = _GUICtrlTreeView_DisplayRectEx($idTreeView, $ahItem[2])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item 2 Rectangle : [%d, %d, %d, %d]", DllStructGetData($tRECT, "Left"), _
            DllStructGetData($tRECT, "Top"), DllStructGetData($tRECT, "Right"), DllStructGetData($tRECT, "Bottom")))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_EditText

Function Reference

_GUICtrlTreeView_EditText

Begins in-place editing of the specified item's text

#include <GuiTreeView.au3>
_GUICtrlTreeView_EditText ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item to edit

Return Value

Success: | the handle to the edit control.
Failure: | 0.

Related

_GUICtrlTreeView_EndEdit, _GUICtrlTreeView_GetEditControl

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $ahItem[6], $hImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Edit Text", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
    Next

    ; Edit item 0 label
    _GUICtrlTreeView_EditText($idTreeView, $ahItem[0])
    Sleep(500)
    Send("This is a test")
    Sleep(500)
    _GUICtrlTreeView_EndEdit($idTreeView)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_EndEdit

Function Reference

_GUICtrlTreeView_EndEdit

Ends the editing of the item's text

#include <GuiTreeView.au3>
_GUICtrlTreeView_EndEdit ( $hWnd [, $bCancel = False] )

Parameters

$hWnd | Control ID/Handle to the control
$bCancel | [optional] Indicates whether the editing is cancelled without being saved to the item. If True, the system cancels editing without saving the changes.

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTreeView_EditText

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $ahItem[6], $hImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView End Edit", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
    Next

    ; Edit item 0 label
    _GUICtrlTreeView_EditText($idTreeView, $ahItem[0])
    Sleep(500)
    Send("This is a test")
    Sleep(500)
    _GUICtrlTreeView_EndEdit($idTreeView)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_EndUpdate

Function Reference

_GUICtrlTreeView_EndUpdate

Enables screen repainting that was turned off with the BeginUpdate function

#include <GuiTreeView.au3>
_GUICtrlTreeView_EndUpdate ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTreeView_BeginUpdate

Example

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

Example()

Func Example()
    Local $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView End Update", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 1 To 100
        _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x))
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_EnsureVisible

Function Reference

_GUICtrlTreeView_EnsureVisible

Ensures that a item is visible, expanding the parent item or scrolling the control if necessary

#include <GuiTreeView.au3>
_GUICtrlTreeView_EnsureVisible ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

True: | if the system scrolled the items in the tree-view control and no items were expanded.
False: | otherwise.

Related

_GUICtrlTreeView_GetVisible

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $ahItem[100], $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Ensure Visible", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 99
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x))
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(40, 99, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Index %d Visible: %s", $iRand, _GUICtrlTreeView_GetVisible($idTreeView, $ahItem[$iRand])))
    _GUICtrlTreeView_EnsureVisible($idTreeView, $ahItem[$iRand])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Index %d Visible: %s", $iRand, _GUICtrlTreeView_GetVisible($idTreeView, $ahItem[$iRand])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_Expand

Function Reference

_GUICtrlTreeView_Expand

Expands or collapses the list of child items associated with the specified parent item, if any

#include <GuiTreeView.au3>
_GUICtrlTreeView_Expand ( $hWnd [, $hItem = 0 [, $bExpand = True]] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | [optional] Handle to the item
$bExpand | [optional] Expand or Collapse, use the following values: True - Expand items False - Collapse items

Return Value

None.

Related

_GUICtrlTreeView_ExpandedOnce, _GUICtrlTreeView_GetExpanded

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[5], $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Expand", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 4
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 0 To 2
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Expand All")
    _GUICtrlTreeView_Expand($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Collapse All")
    _GUICtrlTreeView_Expand($idTreeView, 0, False)

    MsgBox($MB_SYSTEMMODAL, "Information", "Expand item 0")
    _GUICtrlTreeView_Expand($idTreeView, $aidItem[0])

    MsgBox($MB_SYSTEMMODAL, "Information", "Collapse item 0")
    _GUICtrlTreeView_Expand($idTreeView, $aidItem[0], False)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_ExpandedOnce

Function Reference

_GUICtrlTreeView_ExpandedOnce

Indicates if the item's list of child items has been expanded at least once

#include <GuiTreeView.au3>
_GUICtrlTreeView_ExpandedOnce ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

True: | item has been expanded at least once.
False: | item has not been expanded at least once.

Related

_GUICtrlTreeView_Expand

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[5], $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Expanded Once", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 4
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 0 To 2
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Expand item 0")
    _GUICtrlTreeView_Expand($idTreeView, $aidItem[0])

    MsgBox($MB_SYSTEMMODAL, "Information", "Collapse item 0")
    _GUICtrlTreeView_Expand($idTreeView, $aidItem[0], False)

    MsgBox($MB_SYSTEMMODAL, "Information", "Item 0 expanded at least once? " & _GUICtrlTreeView_ExpandedOnce($idTreeView, $aidItem[0]))
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 1 expanded at least once? " & _GUICtrlTreeView_ExpandedOnce($idTreeView, $aidItem[1]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_FindItem

Function Reference

_GUICtrlTreeView_FindItem

Retrieves a item based on it's text

#include <GuiTreeView.au3>
_GUICtrlTreeView_FindItem ( $hWnd, $sText [, $bInStr = False [, $hStart = 0]] )

Parameters

$hWnd | Control ID/Handle to the control
$sText | Text to search for
$bInStr | [optional] If True, the text can be anywhere in the item's text.
$hStart | [optional] Item to start searching from. If 0, the root item is used.

Return Value

Success: | the handle of the first item that contains the item text.
Failure: | 0.

Remarks

The search is case insensitive

Related

_GUICtrlTreeView_FindItemEx

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[10], $hItemFound, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Find Item", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 3
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 0 To 2
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $aidItem[$x])
        Next
    Next
    $aidItem[4] = GUICtrlCreateTreeViewItem(StringFormat("Looking for me?", $x), $idTreeView)
    For $x = 5 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 0 To 2
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hItemFound = _GUICtrlTreeView_FindItem($idTreeView, "Looking for me?")
    If $hItemFound Then
        MsgBox($MB_SYSTEMMODAL, "Information", "Item Found:" & @CRLF & "Handle: " & $hItemFound & @CRLF & "Text: " & _GUICtrlTreeView_GetText($idTreeView, $hItemFound))
    Else
        MsgBox($MB_SYSTEMMODAL, "Information", "Not Found")
    EndIf

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_FindItemEx

Function Reference

_GUICtrlTreeView_FindItemEx

Retrieves a item based on a tree path

#include <GuiTreeView.au3>
_GUICtrlTreeView_FindItemEx ( $hWnd, $sTreePath [, $hStart = 0] )

Parameters

$hWnd | Handle to the control
$sTreePath | The path to take, delimiter of your choice, see Opt("GUIDataSeparatorChar")
$hStart | [optional] Item to start searching from. If 0, the root item is used.

Return Value

Success: | the handle of the first item that matches the tree path.
Failure: | 0.

Remarks

The search is case insensitive

Related

_GUICtrlTreeView_FindItem

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[10], $hItemFound, $idTmp_item, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Find ItemEx", 400, 300)
    Opt("GUIDataSeparatorChar", "\")

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 3
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 0 To 2
            $idTmp_item = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $aidItem[$x])
        Next
    Next
    $aidItem[4] = GUICtrlCreateTreeViewItem(StringFormat("Looking for me?", $x), $idTmp_item)
    For $x = 5 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 0 To 2
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hItemFound = _GUICtrlTreeView_FindItemEx($idTreeView, "[03] New Item\[02] New Item\Looking for me?")
    If $hItemFound Then
        _GUICtrlTreeView_SelectItem($idTreeView, $hItemFound)
        MsgBox($MB_SYSTEMMODAL, "Information", "Item Found:" & @CRLF & "Handle: " & $hItemFound & @CRLF & "Text: " & _GUICtrlTreeView_GetText($idTreeView, $hItemFound))
    Else
        MsgBox($MB_SYSTEMMODAL, "Information", "Not Found")
    EndIf

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetBkColor

Function Reference

_GUICtrlTreeView_GetBkColor

Retrieve the text back color

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetBkColor ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the hex RGB back color.

Related

_GUICtrlTreeView_SetBkColor

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global Const $COLOR_Turquoise = 0x40e0d0
Global Const $COLOR_Crimson = 0xDC143C

Example()

Func Example()
    Local $hImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get BkColor", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_SetBkColor($idTreeView, $COLOR_Turquoise)
    _GUICtrlTreeView_SetTextColor($idTreeView, $COLOR_Crimson)
    _GUICtrlTreeView_SetLineColor($idTreeView, $COLOR_WHITE)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
        _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Back Color: " & _GUICtrlTreeView_GetBkColor($idTreeView) & @CRLF & _
            "Text Color: " & _GUICtrlTreeView_GetTextColor($idTreeView) & @CRLF & _
            "Line Color: " & _GUICtrlTreeView_GetLineColor($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetBold

Function Reference

_GUICtrlTreeView_GetBold

Indicates if the item is drawn in a bold style

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetBold ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

True: | item is drawn in bold.
False: | item is not drawn in bold.

Related

_GUICtrlTreeView_SetBold

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[6], $hRandomItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Bold", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To UBound($aidItem) - 1
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x + 1), $idTreeView)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandomItem = Random(0, UBound($aidItem) - 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Bold? %s", $hRandomItem, _GUICtrlTreeView_GetBold($idTreeView, $aidItem[$hRandomItem])))
    _GUICtrlTreeView_SetBold($idTreeView, $aidItem[$hRandomItem])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Bold? %s", $hRandomItem, _GUICtrlTreeView_GetBold($idTreeView, $aidItem[$hRandomItem])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetChecked

Function Reference

_GUICtrlTreeView_GetChecked

Indicates if a item has its checkbox checked

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetChecked ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

True: | item's checkbox is checked.
False: | item's checkbox is not checked.

Related

_GUICtrlTreeView_SetChecked

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[6], $hRandomItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Checked", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To UBound($aidItem) - 1
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x + 1), $idTreeView)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandomItem = Random(0, UBound($aidItem) - 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Checked? %s", $hRandomItem, _GUICtrlTreeView_GetChecked($idTreeView, $aidItem[$hRandomItem])))
    _GUICtrlTreeView_SetChecked($idTreeView, $aidItem[$hRandomItem])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Checked? %s", $hRandomItem, _GUICtrlTreeView_GetChecked($idTreeView, $aidItem[$hRandomItem])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetChildCount

Function Reference

_GUICtrlTreeView_GetChildCount

Retrieves the number of children of an parent item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetChildCount ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to item

Return Value

Success: | the number of childrens.
Failure: | -1 if 0 children were found.

Related

_GUICtrlTreeView_GetCount, _GUICtrlTreeView_GetSiblingCount

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[10], $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Child Count", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 0 To Random(1, 20, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(0, 9)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Child Count for item index %d: %d", $iRand, _GUICtrlTreeView_GetChildCount($idTreeView, $aidItem[$iRand])))
    _GUICtrlTreeView_Expand($idTreeView, $aidItem[$iRand])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetChildren

Function Reference

_GUICtrlTreeView_GetChildren

Indicates whether the item children flag is set

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetChildren ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

True: | item children flag is set.
False: | item children flag is not set.

Related

_GUICtrlTreeView_SetChildren

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[11], $idTmp_item, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Children", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 3
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 0 To 2
            $idTmp_item = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $aidItem[$x])
        Next
    Next
    $aidItem[4] = GUICtrlCreateTreeViewItem(StringFormat("Looking for me?", $x), $idTmp_item)
    For $x = 5 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 0 To 2
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $aidItem[$x])
        Next
    Next
    $aidItem[10] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", 10), $idTreeView)
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Item 0 has Children? " & _GUICtrlTreeView_GetChildren($idTreeView, $aidItem[0]))
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 10 has Children? " & _GUICtrlTreeView_GetChildren($idTreeView, $aidItem[10]))
    _GUICtrlTreeView_SetChildren($idTreeView, $aidItem[10])
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 10 has Children? " & _GUICtrlTreeView_GetChildren($idTreeView, $aidItem[10]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetCount

Function Reference

_GUICtrlTreeView_GetCount

Retrieves a count of the items

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetCount ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the count of items.

Related

_GUICtrlTreeView_GetChildCount, _GUICtrlTreeView_GetSiblingCount

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Count", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To Random(10, 20, 1)
        $idItem = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 0 To 2
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $idItem)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Count: " & _GUICtrlTreeView_GetCount($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetCut

Function Reference

_GUICtrlTreeView_GetCut

Indicates if the item is drawn as if selected as part of a cut and paste operation

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetCut ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

True: | item is cut.
False: | item is not cut.

Related

_GUICtrlTreeView_SetCut

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[6], $hRandomItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Cut", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To UBound($aidItem) - 1
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x + 1), $idTreeView)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandomItem = Random(0, UBound($aidItem) - 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Cut? %s", $hRandomItem, _GUICtrlTreeView_GetCut($idTreeView, $aidItem[$hRandomItem])))
    _GUICtrlTreeView_SetCut($idTreeView, $aidItem[$hRandomItem])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Cut? %s", $hRandomItem, _GUICtrlTreeView_GetCut($idTreeView, $aidItem[$hRandomItem])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetDropTarget

Function Reference

_GUICtrlTreeView_GetDropTarget

Indicates whether the item is drawn as a drag and drop target

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetDropTarget ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

True: | item is drawn as a drop target.
False: | item is not drawn as a drop target.

Related

_GUICtrlTreeView_SetDropTarget

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[6], $hRandomItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Drop Target", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To UBound($aidItem) - 1
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x + 1), $idTreeView)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandomItem = Random(0, UBound($aidItem) - 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Drop Target? %s", $hRandomItem, _GUICtrlTreeView_GetDropTarget($idTreeView, $aidItem[$hRandomItem])))
    _GUICtrlTreeView_SetDropTarget($idTreeView, $aidItem[$hRandomItem])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Drop Target? %s", $hRandomItem, _GUICtrlTreeView_GetDropTarget($idTreeView, $aidItem[$hRandomItem])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetEditControl

Function Reference

_GUICtrlTreeView_GetEditControl

Retrieves the handle to the edit control being used to edit a item's text

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetEditControl ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the handle to the edit control.
Failure: | 0.

Related

_GUICtrlTreeView_EditText

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>

Global $g_hTreeView

Example()

Func Example()
    Local $hGui, $ahItem[6], $hImage
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    $hGui = GUICreate("TreeView Get Edit Control", 400, 300)

    $g_hTreeView = _GUICtrlTreeView_Create($hGui, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($g_hTreeView, $hImage)

    For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
        $ahItem[$x] = _GUICtrlTreeView_Add($g_hTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
    Next

    ; Edit item 0 label
    _GUICtrlTreeView_EditText($g_hTreeView, $ahItem[0])
    Sleep(1000)
    _GUICtrlTreeView_EndEdit($g_hTreeView)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview
    $hWndTreeview = $g_hTreeView
    If Not IsHWnd($g_hTreeView) Then $hWndTreeview = GUICtrlGetHandle($g_hTreeView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndTreeview
            Switch $iCode
                Case $NM_CLICK ; The user has clicked the left mouse button within the control
                    _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return 1 ; nonzero to not allow the default processing
                    Return 0 ; zero to allow the default processing
                Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control
                    _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return 1 ; nonzero to not allow the default processing
                    Return 0 ; zero to allow the default processing
                Case $NM_RCLICK ; The user has clicked the right mouse button within the control
                    _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return 1 ; nonzero to not allow the default processing
                    Return 0 ; zero to allow the default processing
                Case $NM_RDBLCLK ; The user has double-clicked the right mouse button within the control
                    _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return 1 ; nonzero to not allow the default processing
                    Return 0 ; zero to allow the default processing
                Case $NM_KILLFOCUS ; control has lost the input focus
                    _DebugPrint("$NM_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $NM_RETURN ; control has the input focus and that the user has pressed the key
                    _DebugPrint("$NM_RETURN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; Return 1 ; nonzero to not allow the default processing
                    Return 0 ; zero to allow the default processing
                    ; Case $NM_SETCURSOR ; control is setting the cursor in response to a WM_SETCURSOR message
                    ; Local $tInfo = DllStructCreate($tagNMMOUSE, $lParam)
                    ; $hWndFrom = HWnd(DllStructGetData($tInfo, "hWndFrom"))
                    ; $iIDFrom = DllStructGetData($tInfo, "IDFrom")
                    ; $iCode = DllStructGetData($tInfo, "Code")
                    ; _DebugPrint("$NM_SETCURSOR" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                    ; "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                    ; "-->Code:" & @TAB & $iCode & @CRLF & _
                    ; "-->ItemSpec:" & @TAB & DllStructGetData($tInfo, "ItemSpec") & @CRLF & _
                    ; "-->ItemData:" & @TAB & DllStructGetData($tInfo, "ItemData") & @CRLF & _
                    ; "-->X:" & @TAB & DllStructGetData($tInfo, "X") & @CRLF & _
                    ; "-->Y:" & @TAB & DllStructGetData($tInfo, "Y") & @CRLF & _
                    ; "-->HitInfo:" & @TAB & DllStructGetData($tInfo, "HitInfo"))
                    ; Return 0 ; to enable the control to set the cursor
                    ; Return 1 ; nonzero to prevent the control from setting the cursor
                Case $NM_SETFOCUS ; control has received the input focus
                    _DebugPrint("$NM_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    ; No return value
                Case $TVN_BEGINDRAGA, $TVN_BEGINDRAGW
                    _DebugPrint("$TVN_BEGINDRAG")
                Case $TVN_BEGINLABELEDITA, $TVN_BEGINLABELEDITW
                    _DebugPrint("$TVN_BEGINLABELEDIT")
                    ConsoleWrite("Edit Control Handle: 0x" & Hex(_GUICtrlTreeView_GetEditControl($g_hTreeView)) & @CRLF & _
                            "IsPtr = " & IsPtr(_GUICtrlTreeView_GetEditControl($g_hTreeView)) & " IsHWnd = " & IsHWnd(_GUICtrlTreeView_GetEditControl($g_hTreeView)))
                Case $TVN_BEGINRDRAGA, $TVN_BEGINRDRAGW
                    _DebugPrint("$TVN_BEGINRDRAG")
                Case $TVN_DELETEITEMA, $TVN_DELETEITEMW
                    _DebugPrint("$TVN_DELETEITEM")
                Case $TVN_ENDLABELEDITA, $TVN_ENDLABELEDITW
                    _DebugPrint("$TVN_ENDLABELEDIT")
                    Local $tInfo = DllStructCreate($tagNMHDR & ";" & $tagTVITEMEX, $lParam)
                    If DllStructGetData($tInfo, "Text") <> 0 Then
                        Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", DllStructGetData($tInfo, "Text"))
                        _GUICtrlTreeView_SetText($g_hTreeView, _GUICtrlTreeView_GetSelection($g_hTreeView), DllStructGetData($tBuffer, "Text"))
                    EndIf
                Case $TVN_GETDISPINFOA, $TVN_GETDISPINFOW
                    _DebugPrint("$TVN_GETDISPINFO")
                Case $TVN_GETINFOTIPA, $TVN_GETINFOTIPW
                    _DebugPrint("$TVN_GETINFOTIP")
                Case $TVN_ITEMEXPANDEDA, $TVN_ITEMEXPANDEDW
                    _DebugPrint("$TVN_ITEMEXPANDED")
                Case $TVN_ITEMEXPANDINGA, $TVN_ITEMEXPANDINGW
                    _DebugPrint("$TVN_ITEMEXPANDING")
                Case $TVN_KEYDOWN
                    _DebugPrint("$TVN_KEYDOWN")
                Case $TVN_SELCHANGEDA, $TVN_SELCHANGEDW
                    _DebugPrint("$TVN_SELCHANGED")
                Case $TVN_SELCHANGINGA, $TVN_SELCHANGINGW
                    _DebugPrint("$TVN_SELCHANGING")
                Case $TVN_SETDISPINFOA, $TVN_SETDISPINFOW
                    _DebugPrint("$TVN_SETDISPINFO")
                Case $TVN_SINGLEEXPAND
                    _DebugPrint("$TVN_SINGLEEXPAND")
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint


Function _GUICtrlTreeView_GetExpanded

Function Reference

_GUICtrlTreeView_GetExpanded

Indicates whether the item is expanded

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetExpanded ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

True: | item is expanded.
False: | item is not expanded.

Related

_GUICtrlTreeView_Expand

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[6], $hRandomItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Expanded", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To UBound($aidItem) - 1
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 0 To 2
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandomItem = Random(0, UBound($aidItem) - 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Expanded? %s", $hRandomItem, _GUICtrlTreeView_GetExpanded($idTreeView, $aidItem[$hRandomItem])))
    _GUICtrlTreeView_Expand($idTreeView, $aidItem[$hRandomItem])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Expanded? %s", $hRandomItem, _GUICtrlTreeView_GetExpanded($idTreeView, $aidItem[$hRandomItem])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetFirstChild

Function Reference

_GUICtrlTreeView_GetFirstChild

Retrieves the first child item of the specified item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetFirstChild ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

Success: | the handle of the first child item.
Failure: | 0.

Related

_GUICtrlTreeView_GetLastChild, _GUICtrlTreeView_GetNextChild, _GUICtrlTreeView_GetPrevChild

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[6], $hRandomItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get First Child", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To UBound($aidItem) - 1
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 0 To 2
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandomItem = Random(0, UBound($aidItem) - 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d handle of the first child? %s", $hRandomItem, _GUICtrlTreeView_GetFirstChild($idTreeView, $aidItem[$hRandomItem])))
    _GUICtrlTreeView_SelectItem($idTreeView, _GUICtrlTreeView_GetFirstChild($idTreeView, $aidItem[$hRandomItem]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetFirstItem

Function Reference

_GUICtrlTreeView_GetFirstItem

Retrieves the topmost or very first item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetFirstItem ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the handle of the first item.
Failure: | 0.

Related

_GUICtrlTreeView_GetFirstVisible

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get First Item", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 6
        $idItem = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 0 To 2
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $idItem)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    Local $hFirst = _GUICtrlTreeView_GetFirstVisible($idTreeView)
    MsgBox($MB_SYSTEMMODAL, "Information", "The handle of the first visible item: " & $hFirst)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetFirstVisible

Function Reference

_GUICtrlTreeView_GetFirstVisible

Retrieves the first visible item in the control

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetFirstVisible ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the handle of the first visible item.
Failure: | 0.

Related

_GUICtrlTreeView_GetFirstItem

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get First Visible", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 20
        $idItem = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 0 To 2
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $idItem)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_EnsureVisible($idTreeView, $idItem)
    Local $hFirst = _GUICtrlTreeView_GetFirstVisible($idTreeView)
    MsgBox($MB_SYSTEMMODAL, "Information", "The handle of the first visible item: " & $hFirst)
    _GUICtrlTreeView_SelectItem($idTreeView, $hFirst)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetFocused

Function Reference

_GUICtrlTreeView_GetFocused

Indicates whether the item has focus

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetFocused ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

True: | item has focus.
False: | item does not have focus.

Related

_GUICtrlTreeView_SetFocused

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[6], $hRandomItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Focused", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To UBound($aidItem) - 1
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x + 1), $idTreeView)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandomItem = Random(0, UBound($aidItem) - 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Focused? %s", $hRandomItem, _GUICtrlTreeView_GetFocused($idTreeView, $aidItem[$hRandomItem])))
    _GUICtrlTreeView_SetFocused($idTreeView, $aidItem[$hRandomItem])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Focused? %s", $hRandomItem, _GUICtrlTreeView_GetFocused($idTreeView, $aidItem[$hRandomItem])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetHeight

Function Reference

_GUICtrlTreeView_GetHeight

Retrieves the current height of the each item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetHeight ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the item height in pixels.

Related

_GUICtrlTreeView_SetHeight

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[6], $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Height", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To UBound($aidItem) - 1
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x + 1), $idTreeView)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item Height? %s", _GUICtrlTreeView_GetHeight($idTreeView)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetImageIndex

Function Reference

_GUICtrlTreeView_GetImageIndex

Retrieves the normal state image index

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetImageIndex ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

Success: | the image list index.
Failure: | 0.

Related

_GUICtrlTreeView_SetImageIndex

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $ahItem[6], $hImage, $hRandomImage, $hRandomItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Image Index", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
        $hRandomImage = Random(0, 5, 1)
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $hRandomImage, $hRandomImage)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandomItem = Random(0, UBound($ahItem) - 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Image Index? %s", $hRandomItem, _GUICtrlTreeView_GetImageIndex($idTreeView, $ahItem[$hRandomItem])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetImageListIconHandle

Function Reference

_GUICtrlTreeView_GetImageListIconHandle

Retrieve ImageList handle

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetImageListIconHandle ( $hWnd, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$iIndex | ImageList index to retrieve

Return Value

Returns the imageList handle.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hImage, $hRandomImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get ImageList Icon Handle", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
        _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandomImage = Random(0, _GUIImageList_GetImageCount($hImage) - 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("ImageList Icon Handle for Image %d: %s", $hRandomImage, _GUICtrlTreeView_GetImageListIconHandle($idTreeView, $hRandomImage)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetIndent

Function Reference

_GUICtrlTreeView_GetIndent

Retrieves the amount, in pixels, that child items are indented relative to their parent items

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetIndent ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the amount of indentation.

Related

_GUICtrlTreeView_SetIndent

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Indent", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
        _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Indent: " & _GUICtrlTreeView_GetIndent($idTreeView))

    _GUICtrlTreeView_SetIndent($idTreeView, 25)

    MsgBox($MB_SYSTEMMODAL, "Information", "Indent: " & _GUICtrlTreeView_GetIndent($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetInsertMarkColor

Function Reference

_GUICtrlTreeView_GetInsertMarkColor

Retrieves the color used to draw the insertion mark

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetInsertMarkColor ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the current insertion mark color.

Related

_GUICtrlTreeView_SetInsertMarkColor

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $ahItem[6], $hImage, $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Insert Mark Color", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Insert Mark Color: " & _GUICtrlTreeView_GetInsertMarkColor($idTreeView))

    _GUICtrlTreeView_SetInsertMarkColor($idTreeView, $COLOR_MONEYGREEN)

    $iRand = Random(0, 5, 1)
    _GUICtrlTreeView_SetInsertMark($idTreeView, $ahItem[$iRand])

    MsgBox($MB_SYSTEMMODAL, "Information", "Insert Mark Color: " & _GUICtrlTreeView_GetInsertMarkColor($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetISearchString

Function Reference

_GUICtrlTreeView_GetISearchString

Retrieves the incremental search string

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetISearchString ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the incremental search string if the control is in incremental search mode.
Failure: | otherwise "".

Remarks

The incremental search string is used to select an item based on characters typed by the user

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hImage, $idTreeView
    Local $aText[6] = ["AutoIt", "freeware", "BASIC-like", "scripting", "language", "automating"]
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get ISearch String", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
        _GUICtrlTreeView_Add($idTreeView, 0, $aText[$x], $x, $x)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    Send($aText[Random(0, 5, 1)])
    MsgBox($MB_SYSTEMMODAL, "Information", "ISearch String: " & _GUICtrlTreeView_GetISearchString($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetItemByIndex

Function Reference

_GUICtrlTreeView_GetItemByIndex

Retrieve a item by its position in the list of child items

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetItemByIndex ( $hWnd, $hItem, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item
$iIndex | 0-based index of item in the list of child items

Return Value

Success: | the handle of the item.
Failure: | 0.

Related

_GUICtrlTreeView_Index

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $ahItem[6], $hImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Item By Index", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 5
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
        For $y = 1 To 3
            _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $y), $x, $x)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Item 3, Child Index 1 Handle: " & _GUICtrlTreeView_GetItemByIndex($idTreeView, $ahItem[3], 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetItemHandle

Function Reference

_GUICtrlTreeView_GetItemHandle

Retrieve the item handle

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetItemHandle ( $hWnd [, $hItem = 0] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | [optional] Item ID

Return Value

Success: | the item handle.
Failure: | 0.

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGui, $ahItem[10], $ahItemChild[30], $iYIndex = 0, $iRand, $hTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    $hGui = GUICreate("TreeView Get Item Handle", 400, 300)

    $hTreeView = _GUICtrlTreeView_Create($hGui, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($hTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x))
        For $y = $iYIndex To $iYIndex + 2
            $ahItemChild[$y] = _GUICtrlTreeView_AddChild($hTreeView, $ahItem[$x], StringFormat("[%02d] New Child Item", $y))
        Next
        $iYIndex += 3
    Next
    _GUICtrlTreeView_EndUpdate($hTreeView)

    $iRand = Random(0, 9, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item handle for index %d: %s\r\nIsPtr = %d IsHWnd = %d", $iRand, _GUICtrlTreeView_GetItemHandle($hTreeView, $ahItem[$iRand]), _
            IsPtr(_GUICtrlTreeView_GetItemHandle($hTreeView, $ahItem[$iRand])), IsHWnd(_GUICtrlTreeView_GetItemHandle($hTreeView, $ahItem[$iRand]))))
    $iRand = Random(0, 29, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item handle for child index %d: %s", $iRand, _GUICtrlTreeView_GetItemHandle($hTreeView, $ahItemChild[$iRand])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetItemParam

Function Reference

_GUICtrlTreeView_GetItemParam

Retrieves the application specific value of the item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetItemParam ( $hWnd [, $hItem = 0] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | [optional] Item ID

Return Value

Success: | the item param.
Failure: | 0

Related

_GUICtrlTreeView_SetItemParam

Example

Example 1

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

; Warning do not use SetItemParam on items created with GUICtrlCreateTreeViewItem
; Param is the controlID for items created with the built-in function

Example_Internal()

Func Example_Internal()
    Local $aidItem[10], $aidItemChild[30], $iYIndex = 0, $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Item Param", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = $iYIndex To $iYIndex + 2
            $aidItemChild[$y] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child Item", $y), $aidItem[$x])
        Next
        $iYIndex += 3
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(0, 9, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item Param/ID for index %d: %s\r\nIsPtr = %d IsHWnd = %d", $iRand, _GUICtrlTreeView_GetItemParam($idTreeView, $aidItem[$iRand]), _
            IsPtr(_GUICtrlTreeView_GetItemHandle($idTreeView, $aidItem[$iRand])), IsHWnd(_GUICtrlTreeView_GetItemHandle($idTreeView, $aidItem[$iRand]))))
    $iRand = Random(0, 29, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item Param/ID for child index %d: %s", $iRand, _GUICtrlTreeView_GetItemParam($idTreeView, $aidItemChild[$iRand])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example_Internal

Example 2

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

; Warning do not use SetItemParam on items created with GUICtrlCreateTreeViewItem
; Param is the controlID for items created with the built-in function

Example_External()

Func Example_External()
    Local $hGUI, $ahItem[10], $ahItemChild[30], $iYIndex = 0, $iRand, $iParam = 1, $hTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    $hGUI = GUICreate("(UDF Created) TreeView Get Item Param", 400, 300)

    $hTreeView = _GUICtrlTreeView_Create($hGUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($hTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x))
        _GUICtrlTreeView_SetItemParam($hTreeView, $ahItem[$x], $iParam)
        $iParam += 1
        For $y = $iYIndex To $iYIndex + 2
            $ahItemChild[$y] = _GUICtrlTreeView_AddChild($hTreeView, $ahItem[$x], StringFormat("[%02d] New Item", $y))
            _GUICtrlTreeView_SetItemParam($hTreeView, $ahItemChild[$y], $iParam)
            $iParam += 1
        Next
        $iYIndex += 3
    Next
    _GUICtrlTreeView_EndUpdate($hTreeView)

    $iRand = Random(0, 9, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item Param/ID for index %d: %s\r\nIsPtr = %d IsHWnd = %d", $iRand, _GUICtrlTreeView_GetItemParam($hTreeView, $ahItem[$iRand]), _
            IsPtr(_GUICtrlTreeView_GetItemHandle($hTreeView, $ahItem[$iRand])), IsHWnd(_GUICtrlTreeView_GetItemHandle($hTreeView, $ahItem[$iRand]))))
    $iRand = Random(0, 29, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item Param for child index %d: %s", $iRand, _GUICtrlTreeView_GetItemParam($hTreeView, $ahItemChild[$iRand])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example_External


Function _GUICtrlTreeView_GetLastChild

Function Reference

_GUICtrlTreeView_GetLastChild

Retrieves the last child item of the specified item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetLastChild ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

Success: | the handle of the last child item.
Failure: | 0.

Related

_GUICtrlTreeView_GetFirstChild, _GUICtrlTreeView_GetNextChild, _GUICtrlTreeView_GetPrevChild

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[10], $iYIndex = 0, $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Last Child", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = $iYIndex To $iYIndex + 2
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child Item", $y), $aidItem[$x])
        Next
        $iYIndex += 3
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(0, 9, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Last Child for Item %d: %s", $iRand, _GUICtrlTreeView_GetLastChild($idTreeView, $aidItem[$iRand])))
    _GUICtrlTreeView_SelectItem($idTreeView, _GUICtrlTreeView_GetLastChild($idTreeView, $aidItem[$iRand]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetLineColor

Function Reference

_GUICtrlTreeView_GetLineColor

Retrieve the line color

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetLineColor ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the Hex RGB Line Color.

Related

_GUICtrlTreeView_SetLineColor

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global Const $COLOR_Turquoise = 0x40e0d0
Global Const $COLOR_Crimson = 0xDC143C

Example()

Func Example()
    Local $hImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Line Color", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_SetBkColor($idTreeView, $COLOR_Turquoise)
    _GUICtrlTreeView_SetTextColor($idTreeView, $COLOR_Crimson)
    _GUICtrlTreeView_SetLineColor($idTreeView, $COLOR_WHITE)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
        _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Back Color: " & _GUICtrlTreeView_GetBkColor($idTreeView) & @CRLF & _
            "Text Color: " & _GUICtrlTreeView_GetTextColor($idTreeView) & @CRLF & _
            "Line Color: " & _GUICtrlTreeView_GetLineColor($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetNext

Function Reference

_GUICtrlTreeView_GetNext

Retrieves the next item after the calling item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetNext ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

Success: | the handle of the next item.
Failure: | 0.

Remarks

If the calling item is the last item, _GUICtrlTreeView_GetNext() returns 0, otherwise it will return the next item including items that aren't visible and child items.
To get the next item at the same level as the calling item use _GUICtrlTreeView_GetNextSibling().
To get the next visible item, use _GUICtrlTreeView_GetNextVisible().

Related

_GUICtrlTreeView_GetNextSibling, _GUICtrlTreeView_GetNextVisible, _GUICtrlTreeView_GetPrev

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[10], $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Next", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 3
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x + 1), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    $aidItem[4] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", 5), $idTreeView)
    For $x = 5 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x + 1), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Index 2, Next: " & _GUICtrlTreeView_GetNext($idTreeView, $aidItem[2]))
    _GUICtrlTreeView_SelectItem($idTreeView, _GUICtrlTreeView_GetNext($idTreeView, $aidItem[2]))

    MsgBox($MB_SYSTEMMODAL, "Information", "Index 4, Next: " & _GUICtrlTreeView_GetNext($idTreeView, $aidItem[4]))
    _GUICtrlTreeView_SelectItem($idTreeView, _GUICtrlTreeView_GetNext($idTreeView, $aidItem[4]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetNextChild

Function Reference

_GUICtrlTreeView_GetNextChild

Returns the next item at the same level as the specified item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetNextChild ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the child item

Return Value

Success: | the handle to the next child item.
Failure: | 0.

Related

_GUICtrlTreeView_GetFirstChild, _GUICtrlTreeView_GetLastChild, _GUICtrlTreeView_GetPrevChild

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[10], $hFirstChild, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Next Child", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 3
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    $aidItem[4] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", 4), $idTreeView)
    For $x = 5 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hFirstChild = _GUICtrlTreeView_GetFirstChild($idTreeView, $aidItem[2])
    _GUICtrlTreeView_SelectItem($idTreeView, $hFirstChild)
    MsgBox($MB_SYSTEMMODAL, "Information", "Index 2, Next Child: " & _GUICtrlTreeView_GetNextChild($idTreeView, $hFirstChild))
    _GUICtrlTreeView_SelectItem($idTreeView, _GUICtrlTreeView_GetNextChild($idTreeView, $hFirstChild))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetNextSibling

Function Reference

_GUICtrlTreeView_GetNextSibling

Returns the next item at the same level as the specified item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetNextSibling ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

Success: | the handle to the next sibling item.
Failure: | 0.

Related

_GUICtrlTreeView_GetNext, _GUICtrlTreeView_GetPrevSibling

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[10], $hRandItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Next Sibling", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 3
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    $aidItem[4] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", 4), $idTreeView)
    For $x = 5 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandItem = Random(0, 8, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Index %d, Next: %s", $hRandItem, _GUICtrlTreeView_GetNextSibling($idTreeView, $aidItem[$hRandItem])))
    _GUICtrlTreeView_SelectItem($idTreeView, _GUICtrlTreeView_GetNextSibling($idTreeView, $aidItem[$hRandItem]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetNextVisible

Function Reference

_GUICtrlTreeView_GetNextVisible

Retrieves the next visible item that follows the specified item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetNextVisible ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

Success: | the handle to the next visible item.
Failure: | 0.

Remarks

The specified item must be visible

Related

_GUICtrlTreeView_GetNext, _GUICtrlTreeView_GetPrevVisible

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[10], $hRandItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Next Visible", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 3
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    $aidItem[4] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", 4), $idTreeView)
    For $x = 5 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandItem = Random(0, 8, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Index %d, Next Visible: %s", $hRandItem, _GUICtrlTreeView_GetNextVisible($idTreeView, $aidItem[$hRandItem])))
    _GUICtrlTreeView_SelectItem($idTreeView, _GUICtrlTreeView_GetNextVisible($idTreeView, $aidItem[$hRandItem]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetNormalImageList

Function Reference

_GUICtrlTreeView_GetNormalImageList

Retrieves the normal image list

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetNormalImageList ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the handle to image list.
Failure: | 0.

Related

_GUICtrlTreeView_SetNormalImageList

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global Const $COLOR_Turquoise = 0x40e0d0
Global Const $COLOR_Crimson = 0xDC143C

Example()

Func Example()
    Local $hImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Normal ImageList", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_SetTextColor($idTreeView, $COLOR_Crimson)
    _GUICtrlTreeView_SetLineColor($idTreeView, $COLOR_WHITE)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 5
        _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Normal ImageList Handle: " & _GUICtrlTreeView_GetNormalImageList($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetParentHandle

Function Reference

_GUICtrlTreeView_GetParentHandle

Retrieve the parent handle of item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetParentHandle ( $hWnd [, $hItem = 0] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | [optional] item ID/handle

Return Value

Success: | the handle to parent item.
Failure: | 0.

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idItem, $idChild, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Parent Handle", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 20
        $idItem = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 0 To 2
            $idChild = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $idItem)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_SelectItem($idTreeView, $idChild)
    MsgBox($MB_SYSTEMMODAL, "Information", "Parent Handle: " & _GUICtrlTreeView_GetParentHandle($idTreeView, $idChild))
    _GUICtrlTreeView_SelectItem($idTreeView, _GUICtrlTreeView_GetParentHandle($idTreeView, $idChild))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetParentParam

Function Reference

_GUICtrlTreeView_GetParentParam

Retrieve the parent control ID/Param of item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetParentParam ( $hWnd [, $hItem = 0] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | [optional] item ID/Param

Return Value

Success: | the parent control param.
Failure: | False.

Example

Example 1

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example_Internal()

Func Example_Internal()
    Local $idItem, $idChild, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Parent Param", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 20
        $idItem = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 0 To 2
            $idChild = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $idItem)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_SelectItem($idTreeView, $idChild)
    MsgBox($MB_SYSTEMMODAL, "Information", "Parent Param/ID: " & _GUICtrlTreeView_GetParentParam($idTreeView, $idChild)) ; same as controlID

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example_Internal

Example 2

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example_External()

Func Example_External()
    Local $hGUI, $hItem, $hChild, $iParam = 1, $hTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    $hGUI = GUICreate("(UDF Created) TreeView Get Parent Param", 400, 300)

    $hTreeView = _GUICtrlTreeView_Create($hGUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($hTreeView)
    For $x = 0 To 20
        $hItem = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x))
        _GUICtrlTreeView_SetItemParam($hTreeView, $hItem, $iParam)
        $iParam += 1
        For $y = 0 To 2
            $hChild = _GUICtrlTreeView_AddChild($hTreeView, $hItem, StringFormat("[%02d] New Item", $y))
            _GUICtrlTreeView_SetItemParam($hTreeView, $hChild, $iParam)
            $iParam += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($hTreeView)

    _GUICtrlTreeView_SelectItem($hTreeView, $hChild)
    MsgBox($MB_SYSTEMMODAL, "Information", "Parent Param: " & _GUICtrlTreeView_GetParentParam($hTreeView, $hChild))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example_External


Function _GUICtrlTreeView_GetPrev

Function Reference

_GUICtrlTreeView_GetPrev

Retrieves the previous item before the calling item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetPrev ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

Success: | the handle of the previous item.
Failure: | 0.

Remarks

If the calling item is the first item _GUICtrlTreeView_GetPrev() returns 0, otherwise it will return the previous item including items that aren't visible and child items.
To get the previous item at the same level as the calling item use _GUICtrlTreeView_GetPrevChild().
To get the previous visible item, use _GUICtrlTreeView_GetPrevVisible().

Related

_GUICtrlTreeView_GetNext, _GUICtrlTreeView_GetPrevChild, _GUICtrlTreeView_GetPrevVisible

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[10], $iYItem = 0, $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Prev", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 3
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $iYItem), $aidItem[$x])
            $iYItem += 1
        Next
    Next
    $aidItem[4] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", 4), $idTreeView)
    For $x = 5 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $iYItem), $aidItem[$x])
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(0, 9, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Prev from Index %d: %s", $iRand, _GUICtrlTreeView_GetPrev($idTreeView, $aidItem[$iRand])))
    _GUICtrlTreeView_SelectItem($idTreeView, _GUICtrlTreeView_GetPrev($idTreeView, $aidItem[$iRand]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetPrevChild

Function Reference

_GUICtrlTreeView_GetPrevChild

Retrieves the previous child item of a specified item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetPrevChild ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

Success: | the handle to the previous child item.
Failure: | 0.

Related

_GUICtrlTreeView_GetFirstChild, _GUICtrlTreeView_GetLastChild, _GUICtrlTreeView_GetNextChild, _GUICtrlTreeView_GetPrev

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[10], $hLastChild, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Prev Child", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 3
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x + 1), $idTreeView)
        For $y = 1 To 4
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    $aidItem[4] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", 5), $idTreeView)
    For $x = 5 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x + 1), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hLastChild = _GUICtrlTreeView_GetLastChild($idTreeView, $aidItem[2])
    _GUICtrlTreeView_SelectItem($idTreeView, $hLastChild)
    MsgBox($MB_SYSTEMMODAL, "Information", "Index 2, Prev Child: " & _GUICtrlTreeView_GetPrevChild($idTreeView, $hLastChild))
    _GUICtrlTreeView_SelectItem($idTreeView, _GUICtrlTreeView_GetPrevChild($idTreeView, $hLastChild))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetPrevSibling

Function Reference

_GUICtrlTreeView_GetPrevSibling

Returns the previous item before the calling item at the same level

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetPrevSibling ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

Success: | the handle to the previous sibling item.
Failure: | 0.

Related

_GUICtrlTreeView_GetNextSibling

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[10], $hRandItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Prev Sibling", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 3
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    $aidItem[4] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", 4), $idTreeView)
    For $x = 5 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandItem = Random(0, 8, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Index %d, Prev: %s", $hRandItem, _GUICtrlTreeView_GetPrevSibling($idTreeView, $aidItem[$hRandItem])))
    _GUICtrlTreeView_SelectItem($idTreeView, _GUICtrlTreeView_GetPrevSibling($idTreeView, $aidItem[$hRandItem]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetPrevVisible

Function Reference

_GUICtrlTreeView_GetPrevVisible

Retrieves the first visible item that precedes the specified item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetPrevVisible ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

Success: | the handle to the previous visible item.
Failure: | 0.

Related

_GUICtrlTreeView_GetNextVisible, _GUICtrlTreeView_GetPrev

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[20], $hRandItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Prev Visible", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 3
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    $aidItem[4] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", 4), $idTreeView)
    For $x = 5 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    For $x = 10 To 19
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandItem = Random(1, 19, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Index %d, Prev Visible: %s", $hRandItem, _GUICtrlTreeView_GetPrevVisible($idTreeView, $aidItem[$hRandItem])))
    _GUICtrlTreeView_SelectItem($idTreeView, _GUICtrlTreeView_GetPrevVisible($idTreeView, $aidItem[$hRandItem]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetScrollTime

Function Reference

_GUICtrlTreeView_GetScrollTime

Retrieves the maximum scroll time

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetScrollTime ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the maximum scroll time, in milliseconds.

Remarks

The maximum scroll time is the longest amount of time that a scroll operation can take. Scrolling will be adjusted so that the scroll will take place within the maximum scroll time.
A scroll operation may take less time than the maximum.

Related

_GUICtrlTreeView_SetScrollTime

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[10], $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Scroll Time", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_SetScrollTime($idTreeView, 2)
    MsgBox($MB_SYSTEMMODAL, "Information", "Scroll Time: " & _GUICtrlTreeView_GetScrollTime($idTreeView) & " milliseconds")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetSelected

Function Reference

_GUICtrlTreeView_GetSelected

Indicates whether the item appears in the selected state

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetSelected ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

True: | item is in the selected state.
False: | item is not in the selected state.

Related

_GUICtrlTreeView_SetSelected

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[10], $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Selected", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(0, 9, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Index %d Selected? %s", $iRand, _GUICtrlTreeView_GetSelected($idTreeView, $aidItem[$iRand])))
    _GUICtrlTreeView_SetSelected($idTreeView, $aidItem[$iRand])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Index %d Selected? %s", $iRand, _GUICtrlTreeView_GetSelected($idTreeView, $aidItem[$iRand])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetSelectedImageIndex

Function Reference

_GUICtrlTreeView_GetSelectedImageIndex

Retrieves the index in the image list of the image displayed for the item when it is selected

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetSelectedImageIndex ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

Returns the selected list index.

Related

_GUICtrlTreeView_SetSelectedImageIndex

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $ahItem[10], $hImage, $iImage, $iSImage, $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Selected Image Index", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $iImage = Random(0, 5, 1)
        $iSImage = Random(0, 5, 1)
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), $iImage, $iSImage)
        For $y = 1 To Random(2, 10, 1)
            $iImage = Random(0, 5, 1)
            $iSImage = Random(0, 5, 1)
            _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $y), $iImage, $iSImage)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(0, 9, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Selected Image Index for Item Index %d? %d", $iRand, _GUICtrlTreeView_GetSelectedImageIndex($idTreeView, $ahItem[$iRand])))
    _GUICtrlTreeView_SelectItem($idTreeView, $ahItem[$iRand])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetSelection

Function Reference

_GUICtrlTreeView_GetSelection

Retrieves the currently selected item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetSelection ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the handle to the currently selected item.
Failure: | 0 if no item is selected.

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[10], $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Selection", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(0, 9, 1)
    _GUICtrlTreeView_SelectItem($idTreeView, $aidItem[$iRand])
    MsgBox($MB_SYSTEMMODAL, "Information", "Selection? " & _GUICtrlTreeView_GetSelection($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetSiblingCount

Function Reference

_GUICtrlTreeView_GetSiblingCount

Retrieves the number of siblings at the level of an item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetSiblingCount ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to item

Return Value

Returns the number of siblings.

Related

_GUICtrlTreeView_GetChildCount, _GUICtrlTreeView_GetCount

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[100], $aidChildItem[100], $iRand, $iChildRand, $iYItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Sibling Count", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    $iRand = Random(2, 9, 1)
    For $x = 0 To $iRand
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        $iChildRand = Random(0, 9, 1)
        For $y = 0 To $iChildRand
            $aidChildItem[$iYItem] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $aidItem[$x])
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(0, 9)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Sibling Count for item index %d: %d", $iRand, _GUICtrlTreeView_GetSiblingCount($idTreeView, $aidItem[$iRand])))

    $iRand = Random(0, 99)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Sibling Count for Child item index %d: %d", $iRand, _GUICtrlTreeView_GetSiblingCount($idTreeView, $aidChildItem[$iRand])))
    _GUICtrlTreeView_Expand($idTreeView, _GUICtrlTreeView_GetParentHandle($idTreeView, $aidChildItem[$iRand]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetState

Function Reference

_GUICtrlTreeView_GetState

Retrieve the state of the item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetState ( $hWnd [, $hItem = 0] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | [optional] item ID/handle

Return Value

Success: | the state of the item.
Failure: | sets the @error flag to non-zero.

Related

_GUICtrlTreeView_SetState

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[10], $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get State", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(0, 9, 1)
    _GUICtrlTreeView_SetSelected($idTreeView, $aidItem[$iRand])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("State for Index %d: %s", $iRand, _GUICtrlTreeView_GetState($idTreeView, $aidItem[$iRand])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetStateImageIndex

Function Reference

_GUICtrlTreeView_GetStateImageIndex

Retrieves the index of the state image to display for the item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetStateImageIndex ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

Returns the state image index.

Related

_GUICtrlTreeView_SetStateImageIndex

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hImage

Example()

Func Example()
    Local $ahItem[10], $aidChildItem[30], $iYItem = 0, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Get State Image Index", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _CreateStateImageList()
    _GUICtrlTreeView_SetStateImageList($idTreeView, $g_hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x))
        _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[$x], 1)
        For $y = 1 To 3
            $aidChildItem[$iYItem] = _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $y))
            _GUICtrlTreeView_SetStateImageIndex($idTreeView, $aidChildItem[$iYItem], 1)
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_SelectItem($idTreeView, $ahItem[0])
    _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[0], 2)

    MsgBox($MB_SYSTEMMODAL, "Information", "State Image Index for Item 0: " & _GUICtrlTreeView_GetStateImageIndex($idTreeView, $ahItem[0]))
    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _CreateStateImageList()
    $g_hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 3)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList


Function _GUICtrlTreeView_GetStateImageList

Function Reference

_GUICtrlTreeView_GetStateImageList

Retrieves the handle to the state image list

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetStateImageList ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the handle to image list.
Failure: | 0.

Related

_GUICtrlTreeView_SetStateImageList

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hImage, $g_hStateImage

Example()

Func Example()
    Local $ahItem[10], $aidChildItem[30], $iYItem = 0, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Get State Image List", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _CreateNormalImageList()
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $g_hImage)

    _CreateStateImageList()
    _GUICtrlTreeView_SetStateImageList($idTreeView, $g_hStateImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), 4, 5)
        _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[$x], 1)
        For $y = 1 To 3
            $aidChildItem[$iYItem] = _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $y), 0, 3)
            _GUICtrlTreeView_SetStateImageIndex($idTreeView, $aidChildItem[$iYItem], 1)
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_SelectItem($idTreeView, $ahItem[0])
    _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[0], 2)

    MsgBox($MB_SYSTEMMODAL, "Information", "State Image List: " & _GUICtrlTreeView_GetStateImageList($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _CreateNormalImageList()
    $g_hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 146)
EndFunc   ;==>_CreateNormalImageList

Func _CreateStateImageList()
    $g_hStateImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList


Function _GUICtrlTreeView_GetText

Function Reference

_GUICtrlTreeView_GetText

Retrieve the item text

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetText ( $hWnd [, $hItem = 0] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | [optional] item ID/handle

Return Value

Success: | the text from item.
Failure: | an empty string.

Related

_GUICtrlTreeView_SetText

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hImage, $g_hStateImage

Example()

Func Example()
    Local $ahItem[10], $aidChildItem[30], $iYItem = 0, $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Text", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _CreateNormalImageList()
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $g_hImage)

    _CreateStateImageList()
    _GUICtrlTreeView_SetStateImageList($idTreeView, $g_hStateImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), 4, 5)
        _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[$x], 1)
        For $y = 1 To 3
            $aidChildItem[$iYItem] = _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $y), 0, 3)
            _GUICtrlTreeView_SetStateImageIndex($idTreeView, $aidChildItem[$iYItem], 1)
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_SelectItem($idTreeView, $ahItem[0])
    _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[0], 2)

    $iRand = Random(0, 9, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Text for Item %d: %s", $iRand, _GUICtrlTreeView_GetText($idTreeView, $ahItem[$iRand])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _CreateNormalImageList()
    $g_hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 146)
EndFunc   ;==>_CreateNormalImageList

Func _CreateStateImageList()
    $g_hStateImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList


Function _GUICtrlTreeView_GetTextColor

Function Reference

_GUICtrlTreeView_GetTextColor

Retrieve the text color

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetTextColor ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the Hex RGB Text Color.

Related

_GUICtrlTreeView_SetTextColor

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global Const $COLOR_Turquoise = 0x40e0d0
Global Const $COLOR_Crimson = 0xDC143C

Example()

Func Example()
    Local $hImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Text Color", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_SetBkColor($idTreeView, $COLOR_Turquoise)
    _GUICtrlTreeView_SetTextColor($idTreeView, $COLOR_Crimson)
    _GUICtrlTreeView_SetLineColor($idTreeView, $COLOR_WHITE)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
        _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Back Color: " & _GUICtrlTreeView_GetBkColor($idTreeView) & @CRLF & _
            "Text Color: " & _GUICtrlTreeView_GetTextColor($idTreeView) & @CRLF & _
            "Line Color: " & _GUICtrlTreeView_GetLineColor($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetToolTips

Function Reference

_GUICtrlTreeView_GetToolTips

Retrieves the handle to the child ToolTip control

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetToolTips ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: | the handle to the child ToolTip control.
Failure: | 0 if the control is not using ToolTips.

Remarks

When created, controls automatically create a ToolTip control.
To cause a control not to use ToolTips, create the control with the $TVS_NOTOOLTIPS style.

Related

_GUICtrlTreeView_SetToolTips

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hImage, $g_hStateImage

Example()

Func Example()
    Local $ahItem[10], $aidChildItem[30], $iYItem = 0, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Get ToolTips", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _CreateNormalImageList()
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $g_hImage)

    _CreateStateImageList()
    _GUICtrlTreeView_SetStateImageList($idTreeView, $g_hStateImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), 4, 5)
        _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[$x], 1)
        For $y = 1 To 3
            $aidChildItem[$iYItem] = _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $y), 0, 3)
            _GUICtrlTreeView_SetStateImageIndex($idTreeView, $aidChildItem[$iYItem], 1)
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_SelectItem($idTreeView, $ahItem[0])
    _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[0], 2)

    MsgBox($MB_SYSTEMMODAL, "Information", "ToolTips Handle: " & _GUICtrlTreeView_GetToolTips($idTreeView))

    _GUICtrlTreeView_SetToolTips($idTreeView, _GUICtrlTreeView_GetToolTips($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _CreateNormalImageList()
    $g_hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 146)
EndFunc   ;==>_CreateNormalImageList

Func _CreateStateImageList()
    $g_hStateImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList


Function _GUICtrlTreeView_GetTree

Function Reference

_GUICtrlTreeView_GetTree

Retrieve all items text

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetTree ( $hWnd [, $hItem = 0] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | [optional] item ID/handle

Return Value

Success: | the tree path of Item.
Failure: | an empty string.

Remarks

Use Opt("GUIDataSeparatorChar", param) to change the separator char used.
If $hItem is 0 then an attempt to use current selected is used.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hImage, $g_hStateImage

Example()

Func Example()
    Local $ahItem[10], $aidChildItem[30], $iYItem = 0, $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    Opt("GUIDataSeparatorChar", "\")

    GUICreate("TreeView Get Tree", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _CreateNormalImageList()
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $g_hImage)

    _CreateStateImageList()
    _GUICtrlTreeView_SetStateImageList($idTreeView, $g_hStateImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), 4, 5)
        _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[$x], 1)
        For $y = 1 To 3
            $aidChildItem[$iYItem] = _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $y), 0, 3)
            _GUICtrlTreeView_SetStateImageIndex($idTreeView, $aidChildItem[$iYItem], 1)
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_SelectItem($idTreeView, $ahItem[0])
    _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[0], 2)

    MsgBox($MB_SYSTEMMODAL, "Information", "Tree for Child Index 2: " & _GUICtrlTreeView_GetTree($idTreeView, $aidChildItem[2]))
    _GUICtrlTreeView_SelectItem($idTreeView, $aidChildItem[2])

    $iRand = Random(0, 29, 1)
    _GUICtrlTreeView_SelectItem($idTreeView, $aidChildItem[$iRand])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Tree for Child Selected Index %d: %s", $iRand, _GUICtrlTreeView_GetTree($idTreeView)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _CreateNormalImageList()
    $g_hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 146)
EndFunc   ;==>_CreateNormalImageList

Func _CreateStateImageList()
    $g_hStateImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList


Function _GUICtrlTreeView_GetUnicodeFormat

Function Reference

_GUICtrlTreeView_GetUnicodeFormat

Retrieves the Unicode character format flag

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetUnicodeFormat ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

True: | Control is using Unicode characters.
False: | Control is using ANSI characters.

Related

_GUICtrlTreeView_SetUnicodeFormat

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hImage, $g_hStateImage

Example()

Func Example()
    Local $ahItem[10], $aidChildItem[30], $iYItem = 0, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Get Unicode Format", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _CreateNormalImageList()
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $g_hImage)

    _CreateStateImageList()
    _GUICtrlTreeView_SetStateImageList($idTreeView, $g_hStateImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), 4, 5)
        _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[$x], 1)
        For $y = 1 To 3
            $aidChildItem[$iYItem] = _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $y), 0, 3)
            _GUICtrlTreeView_SetStateImageIndex($idTreeView, $aidChildItem[$iYItem], 1)
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Unicode Format: " & _GUICtrlTreeView_GetUnicodeFormat($idTreeView))
    _GUICtrlTreeView_SetUnicodeFormat($idTreeView)
    MsgBox($MB_SYSTEMMODAL, "Information", "Unicode Format: " & _GUICtrlTreeView_GetUnicodeFormat($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _CreateNormalImageList()
    $g_hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 146)
EndFunc   ;==>_CreateNormalImageList

Func _CreateStateImageList()
    $g_hStateImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList


Function _GUICtrlTreeView_GetVisible

Function Reference

_GUICtrlTreeView_GetVisible

Indicates whether the item is currently visible in the control image

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetVisible ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

True: | Item is visible in the control image.
False: | Item is not visible in the control image.

Related

_GUICtrlTreeView_EnsureVisible

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $ahItem[100], $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Get Visible", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 99
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x))
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(40, 99, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Index %d Visible: %s", $iRand, _GUICtrlTreeView_GetVisible($idTreeView, $ahItem[$iRand])))
    _GUICtrlTreeView_EnsureVisible($idTreeView, $ahItem[$iRand])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Index %d Visible: %s", $iRand, _GUICtrlTreeView_GetVisible($idTreeView, $ahItem[$iRand])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_GetVisibleCount

Function Reference

_GUICtrlTreeView_GetVisibleCount

Returns the number of items that can be fully visible in the control

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetVisibleCount ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Returns the Maximum number of items possibly visible in the control.

Remarks

The number of items that can be fully visible may be greater than the number of items in the control.
The control calculates this value by dividing the height of the client window by the height of an item.
Note that the return value is the number of items that can be fully visible.
If you can see all of 20 items and part of one more item, the return value is 20 not 21.

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Get Visible Count", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 99
        _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x))
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Visible: " & _GUICtrlTreeView_GetVisibleCount($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_HitTest

Function Reference

_GUICtrlTreeView_HitTest

Returns information about the location of a point relative to the control

#include <GuiTreeView.au3>
_GUICtrlTreeView_HitTest ( $hWnd, $iX, $iY )

Parameters

$hWnd | Control ID/Handle to the control
$iX | X position, relative to the control, to test
$iY | Y position, relative to the control, to test

Return Value

Success: | Value indicating the results of the hit test: 1 - In the client area, but below the last item. 2 - On the bitmap associated with an item 4 - On the text associated with an item 8 - In the indentation associated with an item 16 - On the button associated with an item 32 - In the area to the right of an item 64 - On the state icon for a item that is in a user-defined state 128 - Above the client area 256 - Below the client area 512 - To the right of the client area 1024 - To the left of the client area
Failure: | 0.

Related

_GUICtrlTreeView_HitTestEx, _GUICtrlTreeView_HitTestItem

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hImage, $g_hStateImage

Example()

Func Example()
    Local $ahItem[10], $aidChildItem[30], $iYItem = 0, $iYRand, $iXRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Hit Test", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _CreateNormalImageList()
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $g_hImage)

    _CreateStateImageList()
    _GUICtrlTreeView_SetStateImageList($idTreeView, $g_hStateImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), 4, 5)
        _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[$x], 1)
        For $y = 1 To 3
            $aidChildItem[$iYItem] = _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $y), 0, 3)
            _GUICtrlTreeView_SetStateImageIndex($idTreeView, $aidChildItem[$iYItem], 1)
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_SelectItem($idTreeView, $ahItem[0])
    _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[0], 2)

    $iYRand = Random(0, 268, 1)
    $iXRand = Random(0, 396, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Hit Test (%d, %d): %s", $iXRand, $iYRand, _GetHitString(_GUICtrlTreeView_HitTest($idTreeView, $iXRand, $iYRand))))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _GetHitString($iResult)
    Switch $iResult
        Case 1
            Return "In the client area, but below the last item"
        Case 2
            Return "On the bitmap associated with an item"
        Case 4
            Return "On the text associated with an item"
        Case 8
            Return "In the indentation associated with an item"
        Case 16
            Return "On the button associated with an item"
        Case 32
            Return "In the area to the right of an item"
        Case 64
            Return "On the state icon for a item that is in a user-defined state"
        Case 128
            Return "Above the client area"
        Case 256
            Return "Below the client area"
        Case 512
            Return "To the left of the client area"
        Case 1024
            Return "To the right of the client area"
    EndSwitch
EndFunc   ;==>_GetHitString

Func _CreateNormalImageList()
    $g_hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 146)
EndFunc   ;==>_CreateNormalImageList

Func _CreateStateImageList()
    $g_hStateImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList


Function _GUICtrlTreeView_HitTestEx

Function Reference

_GUICtrlTreeView_HitTestEx

Returns information about the location of a point relative to the control

#include <GuiTreeView.au3>
_GUICtrlTreeView_HitTestEx ( $hWnd, $iX, $iY )

Parameters

$hWnd | Control ID/Handle to the control
$iX | X position to test
$iY | Y position to test

Return Value

Returns a $tagTVHITTESTINFO structure.

Related

$tagTVHITTESTINFO, _GUICtrlTreeView_HitTest, _GUICtrlTreeView_HitTestItem

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hImage, $g_hStateImage

Example()

Func Example()
    Local $ahItem[10], $aidChildItem[30], $iYItem = 0, $iYRand, $iXRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Hit TestEx", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _CreateNormalImageList()
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $g_hImage)

    _CreateStateImageList()
    _GUICtrlTreeView_SetStateImageList($idTreeView, $g_hStateImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), 4, 5)
        _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[$x], 1)
        For $y = 1 To 3
            $aidChildItem[$iYItem] = _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $y), 0, 3)
            _GUICtrlTreeView_SetStateImageIndex($idTreeView, $aidChildItem[$iYItem], 1)
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_SelectItem($idTreeView, $ahItem[0])
    _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[0], 2)

    $iYRand = Random(0, 268, 1)
    $iXRand = Random(0, 396, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Hit TestEx (%d, %d): %s", $iXRand, $iYRand, _GetHitString(_GUICtrlTreeView_HitTestEx($idTreeView, $iXRand, $iYRand))))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _GetHitString($tHitTest)
    Local $iFlags = DllStructGetData($tHitTest, "Flags")
    Select
        Case BitAND($iFlags, $TVHT_NOWHERE) <> 0
            Return "In the client area, but below the last item"
        Case BitAND($iFlags, $TVHT_ONITEMICON) <> 0
            Return "On the bitmap associated with an item"
        Case BitAND($iFlags, $TVHT_ONITEMLABEL) <> 0
            Return "On the text associated with an item"
        Case BitAND($iFlags, $TVHT_ONITEMINDENT) <> 0
            Return "In the indentation associated with an item"
        Case BitAND($iFlags, $TVHT_ONITEMBUTTON) <> 0
            Return "On the button associated with an item"
        Case BitAND($iFlags, $TVHT_ONITEMRIGHT) <> 0
            Return "In the area to the right of an item"
        Case BitAND($iFlags, $TVHT_ONITEMSTATEICON) <> 0
            Return "On the state icon for a item that is in a user-defined state"
        Case BitAND($iFlags, $TVHT_ABOVE) <> 0
            Return "Above the client area"
        Case BitAND($iFlags, $TVHT_BELOW) <> 0
            Return "Below the client area"
        Case BitAND($iFlags, $TVHT_TORIGHT) <> 0
            Return "To the left of the client area"
        Case BitAND($iFlags, $TVHT_TOLEFT) <> 0
            Return "To the right of the client area"
    EndSelect
EndFunc   ;==>_GetHitString

Func _CreateNormalImageList()
    $g_hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 146)
EndFunc   ;==>_CreateNormalImageList

Func _CreateStateImageList()
    $g_hStateImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList


Function _GUICtrlTreeView_HitTestItem

Function Reference

_GUICtrlTreeView_HitTestItem

Returns the item at the specified coordinates

#include <GuiTreeView.au3>
_GUICtrlTreeView_HitTestItem ( $hWnd, $iX, $iY )

Parameters

$hWnd | Control ID/Handle to the control
$iX | X position to test
$iY | Y position to test

Return Value

Success: | the Handle to the item at the specified point.
Failure: | 0 if no item occupies the point.

Related

_GUICtrlTreeView_HitTest, _GUICtrlTreeView_HitTestEx

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hImage, $g_hStateImage

Example()

Func Example()
    Local $ahItem[10], $aidChildItem[30], $iYItem = 0, $iYRand, $iXRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Hit Test Item", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _CreateNormalImageList()
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $g_hImage)

    _CreateStateImageList()
    _GUICtrlTreeView_SetStateImageList($idTreeView, $g_hStateImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), 4, 5)
        _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[$x], 1)
        For $y = 1 To 3
            $aidChildItem[$iYItem] = _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $y), 0, 3)
            _GUICtrlTreeView_SetStateImageIndex($idTreeView, $aidChildItem[$iYItem], 1)
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_SelectItem($idTreeView, $ahItem[0])
    _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[0], 2)

    $iYRand = Random(0, 130, 1)
    $iXRand = Random(0, 100, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Hit Test Item (%d, %d): %s", $iXRand, $iYRand, _GetHitString(_GUICtrlTreeView_HitTestItem($idTreeView, $iXRand, $iYRand))))
    _GUICtrlTreeView_SelectItem($idTreeView, _GUICtrlTreeView_HitTestItem($idTreeView, $iXRand, $iYRand))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _GetHitString($iResult)
    If $iResult = 0 Then
        Return "No Item in Hit area"
    Else
        Return "Item Handle: " & $iResult
    EndIf
EndFunc   ;==>_GetHitString

Func _CreateNormalImageList()
    $g_hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 146)
EndFunc   ;==>_CreateNormalImageList

Func _CreateStateImageList()
    $g_hStateImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList


Function _GUICtrlTreeView_Index

Function Reference

_GUICtrlTreeView_Index

Retrieves the position of the item in the list

#include <GuiTreeView.au3>
_GUICtrlTreeView_Index ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to item

Return Value

Success: | the index position.
Failure: | -1.

Remarks

If $hItem is a child item the index is the position under the parent.
If $hItem has no parent this function will get the index of that item.

Related

_GUICtrlTreeView_GetItemByIndex

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hImage, $g_hStateImage

Example()

Func Example()
    Local $ahItem[10], $aidChildItem[30], $iYItem = 0, $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Index", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _CreateNormalImageList()
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $g_hImage)

    _CreateStateImageList()
    _GUICtrlTreeView_SetStateImageList($idTreeView, $g_hStateImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 9 To 0 Step -1
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), 4, 5)
        _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[$x], 1)
        For $y = 2 To 0 Step -1
            $aidChildItem[$iYItem] = _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $y), 0, 3)
            _GUICtrlTreeView_SetStateImageIndex($idTreeView, $aidChildItem[$iYItem], 1)
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(0, 29, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Index for Child Item %d: %d", $iRand, _GUICtrlTreeView_Index($idTreeView, $aidChildItem[$iRand])))
    _GUICtrlTreeView_SelectItem($idTreeView, $aidChildItem[$iRand])

    $iRand = Random(0, 9, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Index for Item %d: %d", $iRand, _GUICtrlTreeView_Index($idTreeView, $ahItem[$iRand])))
    _GUICtrlTreeView_SelectItem($idTreeView, $ahItem[$iRand])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _CreateNormalImageList()
    $g_hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 146)
EndFunc   ;==>_CreateNormalImageList

Func _CreateStateImageList()
    $g_hStateImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList


Function _GUICtrlTreeView_InsertItem

Function Reference

_GUICtrlTreeView_InsertItem

Insert an item

#include <GuiTreeView.au3>
_GUICtrlTreeView_InsertItem ( $hWnd, $sItem_Text [, $hItem_Parent = 0 [, $hItem_After = 0 [, $iImage = -1 [, $iSelImage = -1]]]] )

Parameters

$hWnd | Control ID/Handle to the control
$sItem_Text | Text of new item. See remark.
$hItem_Parent | [optional] parent item ID/handle/item
$hItem_After | [optional] item ID/handle/flag to insert new item after
$iImage | [optional] 0-based index of the item's icon in the control's image list
$iSelImage | [optional] 0-based index of the item's icon in the control's image list

Return Value

Success: | the new item handle.
Failure: | 0.

Remarks

If a notification callback is needed, you have to specify $sItem_Text = -1 (LPSTR_TEXTCALLBACK).

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[10], $aidChildItem[30], $iYItem = 0, $iRand, $hInsert, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Insert Item", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To 3
            $aidChildItem[$iYItem] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $iYItem), $aidItem[$x])
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(0, 9, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Inserted after index %d: %s", $iRand, _GUICtrlTreeView_InsertItem($idTreeView, "Inserted Item", 0, $aidItem[$iRand])))

    $iRand = Random(0, 29, 1)
    $hInsert = _GUICtrlTreeView_InsertItem($idTreeView, "Inserted Item", _GUICtrlTreeView_GetParentHandle($idTreeView, $aidChildItem[$iRand]), $aidChildItem[$iRand])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Inserted after child index %d: %s", $iRand, $hInsert))

    $hInsert = _GUICtrlTreeView_InsertItem($idTreeView, "Inserted first child Item", _GUICtrlTreeView_GetParentHandle($idTreeView, $aidChildItem[$iRand]), $TVI_FIRST)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Inserted child index %d firsts: %s", $iRand, $hInsert))
    _GUICtrlTreeView_SelectItem($idTreeView, $hInsert)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_IsFirstItem

Function Reference

_GUICtrlTreeView_IsFirstItem

Indicates whether the tree item is very first

#include <GuiTreeView.au3>
_GUICtrlTreeView_IsFirstItem ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

True: | Item is the first item.
False: | Item is not the first item.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hImage, $g_hStateImage

Example()

Func Example()
    Local $ahItem[10], $aidChildItem[30], $iYItem = 0, $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Is First Item", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _CreateNormalImageList()
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $g_hImage)

    _CreateStateImageList()
    _GUICtrlTreeView_SetStateImageList($idTreeView, $g_hStateImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), 4, 5)
        _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[$x], 1)
        For $y = 1 To 3
            $aidChildItem[$iYItem] = _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $iYItem), 0, 3)
            _GUICtrlTreeView_SetStateImageIndex($idTreeView, $aidChildItem[$iYItem], 1)
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(0, 9, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Is Index %d First Item? %s", $iRand, _GUICtrlTreeView_IsFirstItem($idTreeView, $ahItem[$iRand])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _CreateNormalImageList()
    $g_hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 146)
EndFunc   ;==>_CreateNormalImageList

Func _CreateStateImageList()
    $g_hStateImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList


Function _GUICtrlTreeView_IsParent

Function Reference

_GUICtrlTreeView_IsParent

Indicates whether one item is the parent of another item

#include <GuiTreeView.au3>
_GUICtrlTreeView_IsParent ( $hWnd, $hParent, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hParent | Handle to parent item
$hItem | Handle to the item to test

Return Value

True: | $hParent is a parent of $hItem.
False: | $hParent is not a parent of $hItem.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hImage, $g_hStateImage

Example()

Func Example()
    Local $ahItem[10], $aidChildItem[30], $iYItem = 0, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Is Parent", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _CreateNormalImageList()
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $g_hImage)

    _CreateStateImageList()
    _GUICtrlTreeView_SetStateImageList($idTreeView, $g_hStateImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), 4, 5)
        _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[$x], 1)
        For $y = 1 To 3
            $aidChildItem[$iYItem] = _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $iYItem), 0, 3)
            _GUICtrlTreeView_SetStateImageIndex($idTreeView, $aidChildItem[$iYItem], 1)
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_Expand($idTreeView, $ahItem[0])

    MsgBox($MB_SYSTEMMODAL, "Information", "Is Index 2 Parent of Child Index 2: " & _GUICtrlTreeView_IsParent($idTreeView, $ahItem[2], $aidChildItem[2]))

    MsgBox($MB_SYSTEMMODAL, "Information", "Is Index 0 Parent of Child Index 2: " & _GUICtrlTreeView_IsParent($idTreeView, $ahItem[0], $aidChildItem[2]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _CreateNormalImageList()
    $g_hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 146)
EndFunc   ;==>_CreateNormalImageList

Func _CreateStateImageList()
    $g_hStateImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList


Function _GUICtrlTreeView_Level

Function Reference

_GUICtrlTreeView_Level

Indicates the level of indentation of a item

#include <GuiTreeView.au3>
_GUICtrlTreeView_Level ( $hWnd, $hItem )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item

Return Value

Returns the 0-based item indentation level.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hImage, $g_hStateImage

Example()

Func Example()
    Local $ahItem[4], $aidChildItem[120], $iYItem = 0, $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Level", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _CreateNormalImageList()
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $g_hImage)

    _CreateStateImageList()
    _GUICtrlTreeView_SetStateImageList($idTreeView, $g_hStateImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 3
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), 4, 5)
        _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[$x], 1)
        For $y = 0 To 4
            $aidChildItem[$iYItem] = _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $iYItem), 0, 3)
            _GUICtrlTreeView_SetStateImageIndex($idTreeView, $aidChildItem[$iYItem], 1)
            For $z = 1 To 5
                $aidChildItem[$iYItem + $z] = _GUICtrlTreeView_AddChild($idTreeView, $aidChildItem[$iYItem], StringFormat("[%02d] New Child", $iYItem + $z), 0, 3)
            Next
            $iYItem += 6
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(0, 99, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Index %d Levl: %d", $iRand, _GUICtrlTreeView_Level($idTreeView, $aidChildItem[$iRand])))
    _GUICtrlTreeView_SelectItem($idTreeView, $aidChildItem[$iRand])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _CreateNormalImageList()
    $g_hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 146)
EndFunc   ;==>_CreateNormalImageList

Func _CreateStateImageList()
    $g_hStateImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList


Function _GUICtrlTreeView_SelectItem

Function Reference

_GUICtrlTreeView_SelectItem

Selects the specified item, scrolls the item into view, or redraws the item

#include <GuiTreeView.au3>
_GUICtrlTreeView_SelectItem ( $hWnd, $hItem [, $iFlag = 0] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item
$iFlag | [optional] Action flag: $TVGN_CARET - Sets the selection to the given item $TVGN_DROPHILITE - Redraws the given item in the style used to indicate the target of a drag/drop operation $TVGN_FIRSTVISIBLE - Scrolls the tree view vertically so that the given item is the first visible item

Return Value

Success: | True.
Failure: | False.

Example

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

Example()

Func Example()
    Local $aidItem[10], $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Select Item", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To 3
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(0, 9, 1)
    _GUICtrlTreeView_SelectItem($idTreeView, $aidItem[$iRand])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SelectItemByIndex

Function Reference

_GUICtrlTreeView_SelectItemByIndex

Selects the item based on it's index in the parent list

#include <GuiTreeView.au3>
_GUICtrlTreeView_SelectItemByIndex ( $hWnd, $hItem, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item
$iIndex | 0-based index of item in the parent list

Return Value

Success: | True.
Failure: | False.

Example

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

Example()

Func Example()
    Local $aidItem[10], $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Select Item By Index", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To 3
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(0, 9, 1)
    _GUICtrlTreeView_SelectItemByIndex($idTreeView, $aidItem[$iRand], 1)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetBkColor

Function Reference

_GUICtrlTreeView_SetBkColor

Sets the back color

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetBkColor ( $hWnd, $vRGBColor )

Parameters

$hWnd | Control ID/Handle to the control
$vRGBColor | New hex RGB Color

Return Value

Returns the Previous Hex RGB color.

Related

_GUICtrlTreeView_GetBkColor

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global Const $COLOR_Turquoise = 0x40e0d0
Global Const $COLOR_Crimson = 0xDC143C

Example()

Func Example()
    Local $hImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set BkColor", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_SetBkColor($idTreeView, $COLOR_Turquoise)
    _GUICtrlTreeView_SetTextColor($idTreeView, $COLOR_Crimson)
    _GUICtrlTreeView_SetLineColor($idTreeView, $COLOR_WHITE)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
        _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Back Color: " & _GUICtrlTreeView_GetBkColor($idTreeView) & @CRLF & _
            "Text Color: " & _GUICtrlTreeView_GetTextColor($idTreeView) & @CRLF & _
            "Line Color: " & _GUICtrlTreeView_GetLineColor($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetBold

Function Reference

_GUICtrlTreeView_SetBold

Sets whether the item is drawn using a bold sytle

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetBold ( $hWnd, $hItem [, $bFlag = True] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item
$bFlag | [optional] True if item is drawn bold, otherwise False

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTreeView_GetBold

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[6], $hRandomItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set Bold", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To UBound($aidItem) - 1
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x + 1), $idTreeView)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandomItem = Random(0, UBound($aidItem) - 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Bold? %s", $hRandomItem, _GUICtrlTreeView_GetBold($idTreeView, $aidItem[$hRandomItem])))
    _GUICtrlTreeView_SetBold($idTreeView, $aidItem[$hRandomItem])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Bold? %s", $hRandomItem, _GUICtrlTreeView_GetBold($idTreeView, $aidItem[$hRandomItem])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetChecked

Function Reference

_GUICtrlTreeView_SetChecked

Sets whether a item has it's checkbox checked or not

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetChecked ( $hWnd, $hItem [, $bCheck = True] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item
$bCheck | [optional] Value to set checked state to: True - Checked False - Not checked

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTreeView_GetChecked

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[6], $hRandomItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set Checked", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To UBound($aidItem) - 1
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x + 1), $idTreeView)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandomItem = Random(0, UBound($aidItem) - 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Checked? %s", $hRandomItem, _GUICtrlTreeView_GetChecked($idTreeView, $aidItem[$hRandomItem])))
    _GUICtrlTreeView_SetChecked($idTreeView, $aidItem[$hRandomItem])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Checked? %s", $hRandomItem, _GUICtrlTreeView_GetChecked($idTreeView, $aidItem[$hRandomItem])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetCheckedByIndex

Function Reference

_GUICtrlTreeView_SetCheckedByIndex

Sets whether an item has it's checkbox checked or not by it's index

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetCheckedByIndex ( $hWnd, $hItem, $iIndex [, $bCheck = True] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item
$iIndex | 0-based index into $hItem list of items
$bCheck | [optional] Value to set checked state to: True - Checked False - Not checked

Return Value

Success: | True.
Failure: | False.

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[6], $hRandomItem, $iRandIndex, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set Checked By Index", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To UBound($aidItem) - 1
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x + 1), $idTreeView)
        For $y = 0 To 5
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child Item", $y + 1), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandomItem = Random(0, UBound($aidItem) - 1, 1)
    $iRandIndex = Random(0, 5, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", _
            StringFormat("Set Child Item index[%d] of Item Index[%d]: %s", $iRandIndex, $hRandomItem, _
            _GUICtrlTreeView_SetCheckedByIndex($idTreeView, $aidItem[$hRandomItem], $iRandIndex)))
    _GUICtrlTreeView_Expand($idTreeView)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetChildren

Function Reference

_GUICtrlTreeView_SetChildren

Sets whether the item children flag

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetChildren ( $hWnd, $hItem [, $bFlag = True] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item
$bFlag | [optional] Flag setting: True - Item children flag is set False - Item children flag is cleared

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTreeView_GetChildren

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[11], $idTmp_item, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set Children", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 3
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 0 To 2
            $idTmp_item = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $aidItem[$x])
        Next
    Next
    $aidItem[4] = GUICtrlCreateTreeViewItem(StringFormat("Looking for me?", $x), $idTmp_item)
    For $x = 5 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 0 To 2
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $aidItem[$x])
        Next
    Next
    $aidItem[10] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", 10), $idTreeView)
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Item 0 has Children? " & _GUICtrlTreeView_GetChildren($idTreeView, $aidItem[0]))
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 10 has Children? " & _GUICtrlTreeView_GetChildren($idTreeView, $aidItem[10]))
    _GUICtrlTreeView_SetChildren($idTreeView, $aidItem[10])
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 10 has Children? " & _GUICtrlTreeView_GetChildren($idTreeView, $aidItem[10]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetCut

Function Reference

_GUICtrlTreeView_SetCut

Sets whether the item is drawn as if selected as part of a cut and paste operation

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetCut ( $hWnd, $hItem [, $bFlag = True] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item
$bFlag | [optional] Flag setting: True - Item is cut False - Item is not

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTreeView_GetCut

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[6], $hRandomItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set Cut", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To UBound($aidItem) - 1
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x + 1), $idTreeView)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandomItem = Random(0, UBound($aidItem) - 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Cut? %s", $hRandomItem, _GUICtrlTreeView_GetCut($idTreeView, $aidItem[$hRandomItem])))
    _GUICtrlTreeView_SetCut($idTreeView, $aidItem[$hRandomItem])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Cut? %s", $hRandomItem, _GUICtrlTreeView_GetCut($idTreeView, $aidItem[$hRandomItem])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetDropTarget

Function Reference

_GUICtrlTreeView_SetDropTarget

Sets whether the item is drawn as a drag and drop target

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetDropTarget ( $hWnd, $hItem [, $bFlag = True] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item
$bFlag | [optional] Flag setting: True - Item is drawn as a drag and drop target False - Item is not

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTreeView_GetDropTarget

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[6], $hRandomItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set Drop Target", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To UBound($aidItem) - 1
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x + 1), $idTreeView)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandomItem = Random(0, UBound($aidItem) - 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Drop Target? %s", $hRandomItem, _GUICtrlTreeView_GetDropTarget($idTreeView, $aidItem[$hRandomItem])))
    _GUICtrlTreeView_SetDropTarget($idTreeView, $aidItem[$hRandomItem])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Drop Target? %s", $hRandomItem, _GUICtrlTreeView_GetDropTarget($idTreeView, $aidItem[$hRandomItem])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetFocused

Function Reference

_GUICtrlTreeView_SetFocused

Sets whether the item appears to have focus

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetFocused ( $hWnd, $hItem [, $bFlag = True] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item
$bFlag | [optional] Flag setting: True - Item appears to have focus False - Item does not

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTreeView_GetFocused

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[6], $hRandomItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set Focused", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To UBound($aidItem) - 1
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x + 1), $idTreeView)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandomItem = Random(0, UBound($aidItem) - 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Focused? %s", $hRandomItem, _GUICtrlTreeView_GetFocused($idTreeView, $aidItem[$hRandomItem])))
    _GUICtrlTreeView_SetFocused($idTreeView, $aidItem[$hRandomItem])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Focused? %s", $hRandomItem, _GUICtrlTreeView_GetFocused($idTreeView, $aidItem[$hRandomItem])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetHeight

Function Reference

_GUICtrlTreeView_SetHeight

Sets the height of the each item

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetHeight ( $hWnd, $iHeight )

Parameters

$hWnd | Control ID/Handle to the control
$iHeight | New height of every item in pixels. Heights less than 1 will be set to 1. If not even and the control does not have the $TVS_NONEVENHEIGHT style this value will be rounded down to the nearest even value. If -1, the control will revert to using its default item height.

Return Value

Returns the Previous height of the items, in pixels.

Related

_GUICtrlTreeView_GetHeight

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[6], $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set Height", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To UBound($aidItem) - 1
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x + 1), $idTreeView)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item Height? %s", _GUICtrlTreeView_GetHeight($idTreeView)))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetIcon

Function Reference

_GUICtrlTreeView_SetIcon

Set an item icon

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetIcon ( $hWnd [, $hItem = 0 [, $sIconFile = "" [, $iIconID = 0 [, $iImageMode = 6]]]] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | [optional] item ID/handle
$sIconFile | [optional] The file to extract the icon of
$iIconID | [optional] The iconID to extract of the file
$iImageMode | [optional] 2=normal image / 4=selected image to set

Return Value

Success: | True.
Failure: | False.

Example

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

Example()

Func Example()
    Local $aidItem[10], $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Set Icon", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        _GUICtrlTreeView_SetIcon($idTreeView, $aidItem[$x], "shell32.dll", 3)
        For $y = 1 To 3
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_SetIcon($idTreeView, $aidItem[0], "shell32.dll", 4)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetImageIndex

Function Reference

_GUICtrlTreeView_SetImageIndex

Sets the index into image list for which image is displayed when a item is in its normal state

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetImageIndex ( $hWnd, $hItem, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item
$iIndex | Image list index

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTreeView_GetImageIndex

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $ahItem[6], $hImage, $hRandomImage, $hRandomItem, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set Image Index", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 3)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To UBound($ahItem) - 1
        $hRandomImage = Random(0, 5, 1)
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $hRandomImage, $hRandomImage)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $hRandomItem = Random(0, UBound($ahItem) - 1, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Image Index? %s", $hRandomItem, _GUICtrlTreeView_GetImageIndex($idTreeView, $ahItem[$hRandomItem])))
    _GUICtrlTreeView_SetImageIndex($idTreeView, $ahItem[$hRandomItem], 6)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item %d Image Index? %s", $hRandomItem, _GUICtrlTreeView_GetImageIndex($idTreeView, $ahItem[$hRandomItem])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetIndent

Function Reference

_GUICtrlTreeView_SetIndent

Sets the width of indentation for a tree-view control and redraws the control to reflect the new width

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetIndent ( $hWnd, $iIndent )

Parameters

$hWnd | Control ID/Handle to the control
$iIndent | Width, in pixels, of the indentation.

Return Value

None.

Remarks

If the $iIndent parameter is less than the system-defined minimum width, the new width is set to the system-defined minimum.

Related

_GUICtrlTreeView_GetIndent

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set Indent", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
        _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Indent: " & _GUICtrlTreeView_GetIndent($idTreeView))

    _GUICtrlTreeView_SetIndent($idTreeView, 25)

    MsgBox($MB_SYSTEMMODAL, "Information", "Indent: " & _GUICtrlTreeView_GetIndent($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetInsertMark

Function Reference

_GUICtrlTreeView_SetInsertMark

Sets the insertion mark

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetInsertMark ( $hWnd, $hItem [, $bAfter = True] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Specifies at which item the insertion mark will be placed. If this is 0, the insertion mark is removed.
$bAfter | [optional] Specifies if the insertion mark is placed before or after the item. If this is True, the insertion mark will be placed after the item. If this is False, the insertion mark will be placed before the item.

Return Value

Success: | True.
Failure: | False.

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hImage, $g_hStateImage

Example()

Func Example()
    Local $ahItem[10], $aidChildItem[30], $iYItem = 0, $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Set Insert Mark", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _CreateNormalImageList()
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $g_hImage)

    _CreateStateImageList()
    _GUICtrlTreeView_SetStateImageList($idTreeView, $g_hStateImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), 4, 5)
        _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[$x], 1)
        For $y = 1 To 3
            $aidChildItem[$iYItem] = _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $y), 0, 3)
            _GUICtrlTreeView_SetStateImageIndex($idTreeView, $aidChildItem[$iYItem], 1)
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(0, 9, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Set Insert Mark at Item Index[%d]: %s", $iRand, _GUICtrlTreeView_SetInsertMark($idTreeView, $ahItem[$iRand])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _CreateNormalImageList()
    $g_hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 146)
EndFunc   ;==>_CreateNormalImageList

Func _CreateStateImageList()
    $g_hStateImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList


Function _GUICtrlTreeView_SetInsertMarkColor

Function Reference

_GUICtrlTreeView_SetInsertMarkColor

Sets the color used to draw the insertion mark

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetInsertMarkColor ( $hWnd, $iColor )

Parameters

$hWnd | Control ID/Handle to the control
$iColor | Insertion mark color

Return Value

Returns the Previous insertion mark color.

Related

_GUICtrlTreeView_GetInsertMarkColor

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $ahItem[6], $hImage, $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set Insert Mark Color", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Insert Mark Color: " & _GUICtrlTreeView_GetInsertMarkColor($idTreeView))

    _GUICtrlTreeView_SetInsertMarkColor($idTreeView, $COLOR_MONEYGREEN)

    $iRand = Random(0, 5, 1)
    _GUICtrlTreeView_SetInsertMark($idTreeView, $ahItem[$iRand])

    MsgBox($MB_SYSTEMMODAL, "Information", "Insert Mark Color: " & _GUICtrlTreeView_GetInsertMarkColor($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetItemHeight

Function Reference

_GUICtrlTreeView_SetItemHeight

Sets the height of an individual item

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetItemHeight ( $hWnd, $hItem, $iIntegral )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item
$iIntegral | Height of the item. This height is in increments of the standard item height. By default, each item gets one increment of item height. Setting this field to 2 will give the item twice the standard height; setting this field to 3 will give the item three times the standard height; and so on. The control does not draw in this extra area.

Return Value

Success: | True.
Failure: | False.

Example

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

Example()

Func Example()
    Local $aidItem[6], $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set Item Height", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To UBound($aidItem) - 1
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x + 1), $idTreeView)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_SetItemHeight($idTreeView, $aidItem[2], 2)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetItemParam

Function Reference

_GUICtrlTreeView_SetItemParam

Sets the value specific to the item

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetItemParam ( $hWnd, $hItem, $iParam )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item
$iParam | A value to associate with the item

Return Value

Success: | True.
Failure: | False.

Remarks

Warning: Do not use this function on items created with GUICtrlCreateTreeViewItem().

Related

_GUICtrlTreeView_GetItemParam

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

; Warning do not use SetItemParam on items created with GUICtrlCreateTreeViewItem
; Param is the controlID for items created with the built-in function

Example()

Func Example()
    Local $hGUI, $ahItem[10], $ahItemChild[30], $iYIndex = 0, $iRand, $iParam = 1, $hTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    $hGUI = GUICreate("(UDF Created) TreeView Set Item Param", 400, 300)

    $hTreeView = _GUICtrlTreeView_Create($hGUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($hTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x))
        _GUICtrlTreeView_SetItemParam($hTreeView, $ahItem[$x], $iParam)
        $iParam += 1
        For $y = $iYIndex To $iYIndex + 2
            $ahItemChild[$y] = _GUICtrlTreeView_AddChild($hTreeView, $ahItem[$x], StringFormat("[%02d] New Item", $y))
            _GUICtrlTreeView_SetItemParam($hTreeView, $ahItemChild[$y], $iParam)
            $iParam += 1
        Next
        $iYIndex += 3
    Next
    _GUICtrlTreeView_EndUpdate($hTreeView)

    $iRand = Random(0, 9, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item Param for index %d: %s", $iRand, _GUICtrlTreeView_GetItemParam($hTreeView, $ahItem[$iRand])))
    $iRand = Random(0, 29, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Item Param for child index %d: %s", $iRand, _GUICtrlTreeView_GetItemParam($hTreeView, $ahItemChild[$iRand])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetLineColor

Function Reference

_GUICtrlTreeView_SetLineColor

Sets the line color

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetLineColor ( $hWnd, $vRGBColor )

Parameters

$hWnd | Control ID/Handle to the control
$vRGBColor | New Hex RGB line color

Return Value

Returns the Previous Hex RGB line color.

Related

_GUICtrlTreeView_GetLineColor

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global Const $COLOR_Turquoise = 0x40e0d0
Global Const $COLOR_Crimson = 0xDC143C

Example()

Func Example()
    Local $hImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set Line Color", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_SetBkColor($idTreeView, $COLOR_Turquoise)
    _GUICtrlTreeView_SetTextColor($idTreeView, $COLOR_Crimson)
    _GUICtrlTreeView_SetLineColor($idTreeView, $COLOR_WHITE)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
        _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Back Color: " & _GUICtrlTreeView_GetBkColor($idTreeView) & @CRLF & _
            "Text Color: " & _GUICtrlTreeView_GetTextColor($idTreeView) & @CRLF & _
            "Line Color: " & _GUICtrlTreeView_GetLineColor($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetNormalImageList

Function Reference

_GUICtrlTreeView_SetNormalImageList

Sets the normal image list for the control

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetNormalImageList ( $hWnd, $hImageList )

Parameters

$hWnd | Control ID/Handle to the control
$hImageList | Handle to the image list. If 0, all images are removed

Return Value

Returns the handle to the previous image list?

Related

_GUICtrlTreeView_GetNormalImageList

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global Const $COLOR_Turquoise = 0x40e0d0
Global Const $COLOR_Crimson = 0xDC143C

Example()

Func Example()
    Local $hImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set Normal ImageList", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_SetBkColor($idTreeView, $COLOR_Turquoise)
    _GUICtrlTreeView_SetTextColor($idTreeView, $COLOR_Crimson)
    _GUICtrlTreeView_SetLineColor($idTreeView, $COLOR_WHITE)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 5
        _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Normal ImageList Handle: " & _GUICtrlTreeView_GetNormalImageList($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetScrollTime

Function Reference

_GUICtrlTreeView_SetScrollTime

Sets the maximum scroll time

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetScrollTime ( $hWnd, $iTime )

Parameters

$hWnd | Control ID/Handle to the control
$iTime | New maximum scroll time, in milliseconds

Return Value

Returns the Previous scroll time, in milliseconds.

Remarks

The maximum scroll time is the longest amount of time that a scroll operation can take.
Scrolling will be adjusted so that the scroll will take place within the maximum scroll time.
A scroll operation may take less time than the maximum.

Related

_GUICtrlTreeView_GetScrollTime

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[10], $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("(Internal) TreeView Set Scroll Time", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Scroll Time: " & _GUICtrlTreeView_GetScrollTime($idTreeView) & " milliseconds")
    _GUICtrlTreeView_SetScrollTime($idTreeView, 2)
    MsgBox($MB_SYSTEMMODAL, "Information", "Scroll Time: " & _GUICtrlTreeView_GetScrollTime($idTreeView) & " milliseconds")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetSelected

Function Reference

_GUICtrlTreeView_SetSelected

Sets whether the item appears in the selected state

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetSelected ( $hWnd, $hItem [, $bFlag = True] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item
$bFlag | [optional] True if item is to be selected, otherwise False

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTreeView_GetSelected

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[10], $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set Selected", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 1 To Random(2, 10, 1)
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $y), $aidItem[$x])
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(0, 9, 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Index %d Selected? %s", $iRand, _GUICtrlTreeView_GetSelected($idTreeView, $aidItem[$iRand])))
    _GUICtrlTreeView_SetSelected($idTreeView, $aidItem[$iRand])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Index %d Selected? %s", $iRand, _GUICtrlTreeView_GetSelected($idTreeView, $aidItem[$iRand])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetSelectedImageIndex

Function Reference

_GUICtrlTreeView_SetSelectedImageIndex

Sets the selected image index

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetSelectedImageIndex ( $hWnd, $hItem, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item
$iIndex | Image list index

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTreeView_GetSelectedImageIndex

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $ahItem[10], $hImage, $iImage, $iSImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set Selected Image Index", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 5
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), $x, $x)
        For $y = 1 To Random(2, 10, 1)
            $iImage = Random(0, 5, 1)
            $iSImage = Random(0, 5, 1)
            _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $y), $iImage, $iSImage)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_SelectItem($idTreeView, $ahItem[2])
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Selected Image Index for Item Index 2? %d", _GUICtrlTreeView_GetSelectedImageIndex($idTreeView, $ahItem[2])))
    _GUICtrlTreeView_SetSelectedImageIndex($idTreeView, $ahItem[2], 1)
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Selected Image Index for Item Index 2? %d", _GUICtrlTreeView_GetSelectedImageIndex($idTreeView, $ahItem[2])))
    _GUICtrlTreeView_SelectItem($idTreeView, $ahItem[2])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetState

Function Reference

_GUICtrlTreeView_SetState

Set the state of the specified item

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetState ( $hWnd, $hItem [, $iState = 0 [, $bSetState = True]] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item
$iState | [optional] The new item state, can be one or more of the following: $TVIS_SELECTED - Set item selected $TVIS_CUT - Set item as part of a cut-and-paste operation $TVIS_DROPHILITED - Set item as a drag-and-drop target $TVIS_BOLD - Set item as bold $TVIS_EXPANDED - Expand item $TVIS_EXPANDEDONCE - Set item's list of child items has been expanded at least once $TVIS_EXPANDPARTIAL - Set item as partially expanded
$bSetState | [optional] True if item state is to be set, False remove item state

Return Value

Success: | True.
Failure: | False.

Remarks

State values can BitOR'ed together as for example BitOR($TVIS_SELECTED, $TVIS_BOLD).

Related

_GUICtrlTreeView_GetState

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $a_hItem[10], $hImage, $iImage, $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set State", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $iImage = Random(0, 5, 1)
        $a_hItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), $iImage, $iImage)
        For $y = 1 To Random(2, 10, 1)
            $iImage = Random(0, 5, 1)
            _GUICtrlTreeView_AddChild($idTreeView, $a_hItem[$x], StringFormat("[%02d] New Child", $y), $iImage, $iImage)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    $iRand = Random(0, 9, 1)
    _GUICtrlTreeView_SetState($idTreeView, $a_hItem[$iRand], BitOR($TVIS_BOLD, $TVIS_EXPANDED)) ; set bold and just the expanded "-" not really expanded
    _GUICtrlTreeView_SetState($idTreeView, $a_hItem[$iRand], $TVIS_BOLD, False) ; reset just Bold state
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("State for Index %d: %s", $iRand, _GUICtrlTreeView_GetState($idTreeView, $a_hItem[$iRand])))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetStateImageIndex

Function Reference

_GUICtrlTreeView_SetStateImageIndex

Sets the index into image list for the state image

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetStateImageIndex ( $hWnd, $hItem, $iIndex )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | Handle to the item
$iIndex | Image list index

Return Value

Success: | True.
Failure: | False.

Remarks

This is a 1-based index list.
Index equal 0 can be used to suppress the checkbox image of a specific TreeViewItem if the TreeView has been created with $TVS_CHECKBOXES style.

Related

_GUICtrlTreeView_GetStateImageIndex

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hStateImage

Example()

Func Example()
    Local $ahItem[10], $aidChildItem[30], $iYItem = 0, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Set State Image Index", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _CreateStateImageList()
    _GUICtrlTreeView_SetStateImageList($idTreeView, $g_hStateImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x))
        _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[$x], 1)
        For $y = 1 To 3
            $aidChildItem[$iYItem] = _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $y))
            _GUICtrlTreeView_SetStateImageIndex($idTreeView, $aidChildItem[$iYItem], 1)
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_SelectItem($idTreeView, $ahItem[0])
    _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[0], 2)

    MsgBox($MB_SYSTEMMODAL, "Information", "State Image Index for Item 0: " & _GUICtrlTreeView_GetStateImageIndex($idTreeView, $ahItem[0]))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _CreateStateImageList()
    $g_hStateImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList


Function _GUICtrlTreeView_SetStateImageList

Function Reference

_GUICtrlTreeView_SetStateImageList

Sets the state image list for the control

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetStateImageList ( $hWnd, $hImageList )

Parameters

$hWnd | Control ID/Handle to the control
$hImageList | Handle to the image list. If 0, all images are removed

Return Value

Success: | the handle to the previous image list.
Failure: | 0.

Remarks

This is a 1-based index list.

Related

_GUICtrlTreeView_GetStateImageList

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hImage, $g_hStateImage

Example()

Func Example()
    Local $ahItem[10], $aidChildItem[30], $iYItem = 0, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Set State Image List", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _CreateNormalImageList()
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $g_hImage)

    _CreateStateImageList()
    _GUICtrlTreeView_SetStateImageList($idTreeView, $g_hStateImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), 4, 5)
        _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[$x], 1)
        For $y = 1 To 3
            $aidChildItem[$iYItem] = _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $y), 0, 3)
            _GUICtrlTreeView_SetStateImageIndex($idTreeView, $aidChildItem[$iYItem], 1)
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_SelectItem($idTreeView, $ahItem[0])
    _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[0], 2)

    MsgBox($MB_SYSTEMMODAL, "Information", "State Image List: " & _GUICtrlTreeView_GetStateImageList($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _CreateNormalImageList()
    $g_hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 146)
EndFunc   ;==>_CreateNormalImageList

Func _CreateStateImageList()
    $g_hStateImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList


Function _GUICtrlTreeView_SetText

Function Reference

_GUICtrlTreeView_SetText

Set the text of an item

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetText ( $hWnd [, $hItem = 0 [, $sText = ""]] )

Parameters

$hWnd | Control ID/Handle to the control
$hItem | [optional] Handle to the item
$sText | [optional] The new item text

Return Value

Success: | True.
Failure: | False.

Related

_GUICtrlTreeView_GetText

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hImage, $g_hStateImage

Example()

Func Example()
    Local $ahItem[10], $aidChildItem[30], $iYItem = 0, $iRand, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set Text", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _CreateNormalImageList()
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $g_hImage)

    _CreateStateImageList()
    _GUICtrlTreeView_SetStateImageList($idTreeView, $g_hStateImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), 4, 5)
        _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[$x], 1)
        For $y = 1 To 3
            $aidChildItem[$iYItem] = _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $y), 0, 3)
            _GUICtrlTreeView_SetStateImageIndex($idTreeView, $aidChildItem[$iYItem], 1)
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_SelectItem($idTreeView, $ahItem[0])
    _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[0], 2)

    $iRand = Random(0, 9, 1)
    _GUICtrlTreeView_SetText($idTreeView, $ahItem[$iRand], "This text has been Set")
    MsgBox($MB_SYSTEMMODAL, "Information", StringFormat("Text for Item %d: %s", $iRand, _GUICtrlTreeView_GetText($idTreeView, $ahItem[$iRand])))
    _GUICtrlTreeView_SelectItem($idTreeView, $ahItem[$iRand])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _CreateNormalImageList()
    $g_hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 146)
EndFunc   ;==>_CreateNormalImageList

Func _CreateStateImageList()
    $g_hStateImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList


Function _GUICtrlTreeView_SetTextColor

Function Reference

_GUICtrlTreeView_SetTextColor

Sets the text color

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetTextColor ( $hWnd, $vRGBColor )

Parameters

$hWnd | Control ID/Handle to the control
$vRGBColor | New Hex text color

Return Value

Returns the Previous Hex RGB text color.

Related

_GUICtrlTreeView_GetTextColor

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global Const $COLOR_Turquoise = 0x40e0d0
Global Const $COLOR_Crimson = 0xDC143C

Example()

Func Example()
    Local $hImage, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Set Text Color", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_SetBkColor($idTreeView, $COLOR_Turquoise)
    _GUICtrlTreeView_SetTextColor($idTreeView, $COLOR_Crimson)
    _GUICtrlTreeView_SetLineColor($idTreeView, $COLOR_WHITE)

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
        _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Back Color: " & _GUICtrlTreeView_GetBkColor($idTreeView) & @CRLF & _
            "Text Color: " & _GUICtrlTreeView_GetTextColor($idTreeView) & @CRLF & _
            "Line Color: " & _GUICtrlTreeView_GetLineColor($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


Function _GUICtrlTreeView_SetToolTips

Function Reference

_GUICtrlTreeView_SetToolTips

Sets the handle to the child ToolTip control

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetToolTips ( $hWnd, $hToolTip )

Parameters

$hWnd | Control ID/Handle to the control
$hToolTip | Handle to a ToolTip control

Return Value

Success: | a handle to the previous ToolTip control.
Failure: | 0 if the control is not using ToolTips.

Remarks

When created, controls automatically create a ToolTip control.
To cause a control not to use ToolTips, create the control with the $TVS_NOTOOLTIPS style.

Related

_GUICtrlTreeView_GetToolTips

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hImage, $g_hStateImage

Example()

Func Example()
    Local $ahItem[10], $aidChildItem[30], $iYItem = 0, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Set ToolTips", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _CreateNormalImageList()
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $g_hImage)

    _CreateStateImageList()
    _GUICtrlTreeView_SetStateImageList($idTreeView, $g_hStateImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), 4, 5)
        _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[$x], 1)
        For $y = 1 To 3
            $aidChildItem[$iYItem] = _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $y), 0, 3)
            _GUICtrlTreeView_SetStateImageIndex($idTreeView, $aidChildItem[$iYItem], 1)
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_SelectItem($idTreeView, $ahItem[0])
    _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[0], 2)

    MsgBox($MB_SYSTEMMODAL, "Information", "ToolTips Handle: " & _GUICtrlTreeView_GetToolTips($idTreeView))

    _GUICtrlTreeView_SetToolTips($idTreeView, _GUICtrlTreeView_GetToolTips($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _CreateNormalImageList()
    $g_hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 146)
EndFunc   ;==>_CreateNormalImageList

Func _CreateStateImageList()
    $g_hStateImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList


Function _GUICtrlTreeView_SetUnicodeFormat

Function Reference

_GUICtrlTreeView_SetUnicodeFormat

Sets the Unicode character format flag

#include <GuiTreeView.au3>
_GUICtrlTreeView_SetUnicodeFormat ( $hWnd [, $bFormat = True] )

Parameters

$hWnd | Control ID/Handle to the control
$bFormat | [optional] Determines the character set that is used by the control. True - The control will use Unicode characters False - The control will use ANSI characters.

Return Value

Returns the Previous character format flag setting.

Related

_GUICtrlTreeView_GetUnicodeFormat

Example

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hImage, $g_hStateImage

Example()

Func Example()
    Local $ahItem[10], $aidChildItem[30], $iYItem = 0, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Set Unicode Format", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    _GUICtrlTreeView_SetUnicodeFormat($idTreeView, False)
    GUISetState(@SW_SHOW)

    _CreateNormalImageList()
    _GUICtrlTreeView_SetNormalImageList($idTreeView, $g_hImage)

    _CreateStateImageList()
    _GUICtrlTreeView_SetStateImageList($idTreeView, $g_hStateImage)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $ahItem[$x] = _GUICtrlTreeView_Add($idTreeView, 0, StringFormat("[%02d] New Item", $x), 4, 5)
        _GUICtrlTreeView_SetStateImageIndex($idTreeView, $ahItem[$x], 1)
        For $y = 1 To 3
            $aidChildItem[$iYItem] = _GUICtrlTreeView_AddChild($idTreeView, $ahItem[$x], StringFormat("[%02d] New Child", $y), 0, 3)
            _GUICtrlTreeView_SetStateImageIndex($idTreeView, $aidChildItem[$iYItem], 1)
            $iYItem += 1
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Unicode Format: " & _GUICtrlTreeView_GetUnicodeFormat($idTreeView))
    _GUICtrlTreeView_SetUnicodeFormat($idTreeView)
    MsgBox($MB_SYSTEMMODAL, "Information", "Unicode Format: " & _GUICtrlTreeView_GetUnicodeFormat($idTreeView))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _CreateNormalImageList()
    $g_hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($g_hImage, "shell32.dll", 146)
EndFunc   ;==>_CreateNormalImageList

Func _CreateStateImageList()
    $g_hStateImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 3)
    _GUIImageList_AddIcon($g_hStateImage, "shell32.dll", 4)
EndFunc   ;==>_CreateStateImageList


Function _GUICtrlTreeView_Sort

Function Reference

_GUICtrlTreeView_Sort

Sorts the items

#include <GuiTreeView.au3>
_GUICtrlTreeView_Sort ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

None.

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $aidItem[10], $iX = 9, $iY = 29, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)

    GUICreate("TreeView Sort", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 9
        $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $iX), $idTreeView)
        $iX -= 1
        For $y = 1 To 3
            GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Child", $iY), $aidItem[$x])
            $iY -= 1
        Next
    Next
    _GUICtrlTreeView_Expand($idTreeView)
    _GUICtrlTreeView_EndUpdate($idTreeView)

    MsgBox($MB_SYSTEMMODAL, "Information", "Sort")
    _GUICtrlTreeView_Sort($idTreeView)
    _GUICtrlTreeView_SelectItem($idTreeView, $aidItem[9])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example


User Defined Functions

IE user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <IE.au3>.

User Defined Function | Description
_IE_Example | Display a new browser window pre-loaded with documents to be used in IE.au3 examples or your own testing
_IE_Introduction | Display introductory information about IE.au3 in a new browser window
_IE_VersionInfo | Returns an array of information about the IE.au3 version
_IEAction | Perform any of a set of simple actions on the Browser
_IEAttach | Attach to the specified instance of Internet Explorer where the search string sub-string matches (based on the selected mode)
_IEBodyReadHTML | Returns the HTML inside the <body> tag of the document
_IEBodyReadText | Returns the Text inside the <body> tag of the document
_IEBodyWriteHTML | Replaces the HTML inside the <body> tag of the document
_IECreate | Create an Internet Explorer Browser Window
_IECreateEmbedded | Create a Webbrowser object suitable for embedding in an AutoIt GUI with GUICtrlCreateObj()
_IEDocGetObj | Given any DOM object, returns a reference to the associated document object
_IEDocInsertHTML | Inserts HTML Text in or around an element
_IEDocInsertText | Inserts Text in or around an element
_IEDocReadHTML | Returns the full HTML source of a document
_IEDocWriteHTML | Replaces the HTML for the entire document
_IEErrorNotify | Specifies whether IE.au3 automatically notifies of Warnings and Errors (to the console)
_IEFormElementCheckBoxSelect | Set the value of a specified form element
_IEFormElementGetCollection | Returns a collection object variable representing all Form Elements within a given Form
_IEFormElementGetObjByName | Returns an object reference to a Form Element by name
_IEFormElementGetValue | Returns the value of a given Form Element
_IEFormElementOptionSelect | Set the value of a specified form element
_IEFormElementRadioSelect | Set the value of a specified form element
_IEFormElementSetValue | Set the value of a specified Form Element
_IEFormGetCollection | Returns a collection object variable representing the Forms in the document or a single form by index
_IEFormGetObjByName | Returns an object reference to a Form by name
_IEFormImageClick | Simulate a mouse click on an <input type=image>. Match by sub-string match of alt text, name or src
_IEFormReset | Reset a specified Form setting the values back to their loaded defaults
_IEFormSubmit | Submit a specified Form
_IEFrameGetCollection | Returns a collection object containing the frames in a FrameSet or the iFrames on a normal page or a single Frame or iFrame by index
_IEFrameGetObjByName | Returns an object reference to a Frame or iFrame by name
_IEGetObjById | Returns an object variable by id
_IEGetObjByName | Returns an object variable by name
_IEHeadInsertEventScript | Inserts a Javascript into the Head of the document
_IEImgClick | Simulate a mouse click on an image. Match by sub-string match of alt text, name, or src
_IEImgGetCollection | Returns a collection object variable representing the IMG tags in the document or a single image by index
_IEIsFrameSet | Checks to see if the specified Window contains a FrameSet
_IELinkClickByIndex | Simulate a mouse click on a link by 0-based index (in source order)
_IELinkClickByText | Simulate a mouse click on a link with text sub-string matching the string provided
_IELinkGetCollection | Returns a collection object containing all links in the document or a single link by index
_IELoadWait | Wait for a browser page load to complete before returning
_IELoadWaitTimeout | Retrieve or set the current value in milliseconds _IELoadWait() will try before timing out
_IENavigate | Directs an existing browser window to navigate to the specified URL
_IEPropertyGet | Returns a select property of the Browser or DOM element
_IEPropertySet | Set a select property of the Browser or DOM element
_IEQuit | Close the browser and remove the object reference to it
_IETableGetCollection | Returns a collection object variable representing all the tables in a document or a single table by index
_IETableWriteToArray | Reads the contents of a Table into an array
_IETagNameAllGetCollection | Returns a collection object all elements in the document or document hierarchy in source order or a single element by index
_IETagNameGetCollection | Returns a collection object of all elements in the object with the specified TagName or a single element by index


Function _IE_Example

Function Reference

_IE_Example

Display a new browser window pre-loaded with documents to be used in IE.au3 examples or your own testing

#include <IE.au3>
_IE_Example ( [$sModule = "basic"] )

Parameters

$sModule [optional] specifies which module to run
"basic" = (Default) simple HTML page with text, links and images
"form" = simple HTML page with multiple form elements
"frameset" = simple HTML page with frames
"iframe" = simple HTML page with iframes
"table" = simple HTML page with tables

Return Value

Success: | an object variable pointing to an InternetExplorer.Application object.
Failure: | sets the @error flag to non-zero.
@error: | 5 ($_IEStatus_InvalidValue) - Invalid Value
@extended: | Contains invalid parameter number

Remarks

This function displays browser windows pre-populated with HTML and HTML elements that are used throughout the helpfile and IE.au3 examples.
You are also encouraged to use them to experiment with the IE.au3 function set.

Related

_IE_Introduction

Example

; Create browser windows with each of the example pages displayed.
; The object variable returned can be used just as the object
; variables returned by _IECreate or _IEAttach

#include <IE.au3>

Local $oIE_basic = _IE_Example("basic")
Local $oIE_form = _IE_Example("form")
Local $oIE_table = _IE_Example("table")
Local $oIE_frameset = _IE_Example("frameset")
Local $oIE_iframe = _IE_Example("iframe")


Function _IE_Introduction

Function Reference

_IE_Introduction

Display introductory information about IE.au3 in a new browser window

#include <IE.au3>
_IE_Introduction ( [$sModule = "basic"] )

Parameters

$sModule [optional] specifies which module to run
"basic" = (Default) basic introduction

Return Value

Success: | an object variable pointing to an InternetExplorer.Application object.
Failure: | sets the @error flag to non-zero.
@error: | 5 ($_IEStatus_InvalidValue) - Invalid Value
@extended: | Contains invalid parameter number

Remarks

The AutoIt Helpfile does not currently allow UDFs to have general documentation that covers a series of functions, but rather UDF documentation is focused on individual functions.
This function is intended to provide that general documentation. It will grow over time.

Related

_IE_Example

Example

; Open a browser with the basic IE.au3 introductory text displayed

#include <IE.au3>

Local $oIE = _IE_Introduction("basic")


Function _IE_VersionInfo

Function Reference

_IE_VersionInfo

Returns an array of information about the IE.au3 version

#include <IE.au3>
_IE_VersionInfo ( )

Return Value

Returns an array $IEAU3VersionInfo:
$IEAU3VersionInfo[0] = Release Type (T=Test or V=Production)
$IEAU3VersionInfo[1] = Major Version
$IEAU3VersionInfo[2] = Minor Version
$IEAU3VersionInfo[3] = Sub Version
$IEAU3VersionInfo[4] = Release Date (YYYYMMDD)
$IEAU3VersionInfo[5] = Display Version (e.g. V2.1-0)

Remarks

The array contents make it easy to determine of the UDF version is higher or lower than a required version.

Example

; Retrieve and display IE.au3 version information

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $aVersion = _IE_VersionInfo()
MsgBox($MB_SYSTEMMODAL, "IE.au3 Version", $aVersion[5] & " released " & $aVersion[4])


Function _IEAction

Function Reference

_IEAction

Perform any of a set of simple actions on the Browser

#include <IE.au3>
_IEAction ( ByRef $oObject, $sAction )

Parameters

$oObject | Object variable of an InternetExplorer.Application
$sAction | Action selection (see remarks)

Return Value

Success: | 1.
Failure: | 0 and ssets the @error flag to non-zero.
@error: | 2 ($_IEStatus_COMError) - COM Error in Object reference 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 5 ($_IEStatus_InvalidValue) - Invalid Value
@extended: | Contains invalid parameter number

Remarks

Action | Description
"back" | Navigates backward one item in the history list.
"blur" | Causes the element to lose focus, but does not set focus on the next element in the tab order.
"click" | Simulates a click on the specified element.
"copy" | Copies the current selection to the clipboard.
"cut" | Copies the current selection to the clipboard and then deletes it.
"delete" | Deletes the current selection.
"disable" | Disables the specified element.
"enable" | Enables the specified element.
"focus" | Causes the element to receive focus.
"forward" | Navigates forward one item in the history list.
"home" | Navigates to the current home or start page.
"invisible" | Sets an object state to hidden.
"paste" | Overwrites the contents of the clipboard on the current selection.
"print" | Opens the print dialog box so the user can print the current page.
"printdefault" | Print directly to default printer (no dialog)
"quit" | Closes the object.
"refresh" | Refreshes the current document.
"saveas" | Opens a dialog box to save the current Web page to a file.
"scrollintoview" | scrolls the document such that the specified element is visible.
"search" | Navigates to the current search page.
"selectall" | Selects the entire document.
"stop" | Cancels any pending navigation or download operation and stops any dynamic page elements, such as background sounds and animations.
"unselect" | Clears the current selection.
"visible" | Sets an object state to visible.

Related

_IELoadWait, _IEPropertySet

Example

Example 1

; Open a browser with the "form" example, get a reference
; to the submit button by name and "click" it. This technique
; of submitting forms is useful because many forms rely on JavaScript
; code and "onClick" events on their submit button making _IEFormSubmit()
; not perform as expected

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oSubmit = _IEGetObjByName($oIE, "submitExample")
_IEAction($oSubmit, "click")
_IELoadWait($oIE)

Example 2

; Same as Example 1, except instead of using click, give the element focus
; and then use ControlSend to send Enter.  Use this technique when the
; browser-side scripting associated with a click action prevents control
; from being automatically returned to your code.

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oSubmit = _IEGetObjByName($oIE, "submitExample")
Local $hWnd = _IEPropertyGet($oIE, "hwnd")
_IEAction($oSubmit, "focus")
ControlSend($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

; Wait for Alert window, then click on OK
WinWait("", "ExampleFormSubmitted")
Sleep(2000)

ControlClick("", "ExampleFormSubmitted", "[CLASS:Button; TEXT:OK; Instance:1;]")
Sleep(2000)

_IEQuit($oIE)


Function _IEAttach

Function Reference

_IEAttach

Attach to the specified instance of Internet Explorer where the search string sub-string matches (based on the selected mode)

#include <IE.au3>
_IEAttach ( $sString [, $sMode = "title" [, $iInstance = 1]] )

Parameters

$sString | String to search for (for "embedded" or "dialogbox", use Title sub-string or HWND of window)
$sMode [optional] specifies search mode
"title" = (Default) sub-string of main document title
"windowtitle" = sub-string of full window title (instead of document title)
"url" = sub-string or url of the current page
"text" = sub-string in text from the body of the current page
"html" = sub-string in html from the body of the current page
"hwnd" = hwnd of the browser window
"embedded" = title sub-string or hwnd of the window embedding the control
"dialogbox" = title sub-string or hwnd of modal/modeless dialogbox
"instance" = $sString is ignored, one browser reference returned (by matching instance number) from all available browser instances
$iInstance | [optional] 1-based index into group of browsers or embedded browsers matching $sString and $sMode. See Remarks.

Return Value

Success: | an object variable pointing to the InternetExplorer Object for all but Embedded and DislogBox modes which return a Window Object.
Failure: | sets the @error flag to non-zero.
@error: | 5 ($_IEStatus_InvalidValue) - Invalid Value 7 ($_IEStatus_NoMatch) - No Match
@extended: | Contains invalid parameter number

Remarks

_IEAttach() provides the "dialogbox" parameter to attach to modal and modeless dialogs created by the browser.
It is important to note that not all dialogs created through browser interaction can be attached to and controlled in this way.
Many of these dialogs are actually standard windows and can be controlled through the traditional AutoIt window functions. A reliable way to tell the difference between these types of windows is to use the "AutoIt Window Info" tool to examine it -- if the window contains a control called "Internet Explorer_Server" then you can attach to it with this function, if it does not it is a standard window and traditional AutoIt windows functions must be used to control it.

HyperTextApplication (.hta) windows may be attached to using the "embedded" option.

The advanced Window Title selection syntax available to the standard Win* functions may be used in place of a title sub-string for the modes "dialogbox" and "embedded".

Use of $iInstance with the "embedded" mode: used to return a reference to a specific instance of a WebBrowser and is particularly useful when more than one exists in a particular window.
If you pass a window title in $sString using embedded mode, only the first window matching that title will be used.
If the WebBrowser control you desire is in another window you must pass the HWnd of that window rather than the title, or use the advanced Window Title selection syntax available to the standard Win* functions.

Use of $iInstance with all modes other than "embedded": used to return a browser reference from a groups of all windows that match the criteria from $sString and $sMode.
Instance order for "dialogbox" mode determined by the order returned by WinList() matching the title.
For all other modes the Instance order is determined by the Shell.Windows collection.

$iInstance values > 1 are set to 1 and a warning message is displayed when used with "hwnd" mode or with "dialogbox" mode when an HWnd is passed in $sString.

"dialogbox" and "embedded" modes can be used to attach to standard browser windows, but the object returned is that if the top level Window in the browser and not the InternetExplorer object.
Window objects do not offer access to all of the attributes of the InternetExplorer object (e.g. status text, address bar etc.).
As well, if you attempt to use a function like _IENavigate() on such an object you may receive COM errors due to the way that IE7 has implemented Tabs.
It may be useful to find browser instances in this way, but it is recommended that you immediately use _IEAttach() using one of the other modes and using information that you may have obtained from the Window object in order to get a reference to the associated InternetExplorer object.

Related

_IECreate, _IECreateEmbedded, _IEQuit

Example

Example 1

; Attach to a browser with "AutoIt" in its title, display the URL

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IECreate("www.autoitscript.com")
Local $oIE1 = _IECreate("www.google.com")

$oIE = _IEAttach("AutoIt")
MsgBox($MB_SYSTEMMODAL, "The URL", _IEPropertyGet($oIE, "locationurl"))

_IEQuit($oIE)
_IEQuit($oIE1)

Example 2

; Attach to a browser with "simple HTML page"
; in the text of it's top-level document

#include <IE.au3>

Local $oIE_basic = _IE_Example("basic")

Local $oIE = _IEAttach("simple HTML page", "text")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $oIE = ' & $oIE & @CRLF & '>Error code: ' & @error & '    Extended code: 0x' & Hex(@extended) & @CRLF) ;### Debug Console

Example 3

; Attach to a browser control embedded in another window

#include <IE.au3>

Local $oIE = _IEAttach("A Window Title", "embedded")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $oIE = ' & $oIE & @CRLF & '>Error code: ' & @error & '    Extended code: 0x' & Hex(@extended) & @CRLF) ;### Debug Console

Example 4

; Attach to the 3rd browser control embedded in another window
; Use the advanced window title syntax to use the 2nd window
; with the string 'ICQ' in the title

#include <IE.au3>

Local $oIE = _IEAttach("[REGEXPTITLE:ICQ; INSTANCE:2]", "embedded", 3)

Example 5

; Create an array of object references to all current browser instances
; The first array element will contain the number of instances found

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $aIE[1]
$aIE[0] = 0

Local $i = 1, $oIE
While 1
    $oIE = _IEAttach("", "instance", $i)
    If @error = $_IEStatus_NoMatch Then ExitLoop
    ReDim $aIE[$i + 1]
    $aIE[$i] = $oIE
    $aIE[0] = $i
    $i += 1
WEnd

MsgBox($MB_SYSTEMMODAL, "Browsers Found", "Number of browser instances in the array: " & $aIE[0])


Function _IEBodyReadHTML

Function Reference

_IEBodyReadHTML

Returns the HTML inside the <body> tag of the document

#include <IE.au3>
_IEBodyReadHTML ( ByRef $oObject )

Parameters

$oObject Object variable of an InternetExplorer.Application, Window or Frame object

Return Value

Success: | an HTML included in the <body> of the document.
Failure: | sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type
@extended: | Contains invalid parameter number

Remarks

This function uses the .innerHTML property of the document Body.
.innerHTML is available for nearly all DOM elements using _IEPropertyGet().

Related

_IEBodyReadText, _IEBodyWriteHTML, _IEDocInsertHTML, _IEDocInsertText, _IEDocReadHTML, _IEPropertyGet

Example

; Open a browser with the basic example, ready the body HTML,
; append new HTML to the original and write it back to the browser

#include <IE.au3>

Local $oIE = _IE_Example("basic")
Local $sHTML = _IEBodyReadHTML($oIE)
$sHTML = $sHTML & "<p><font color=red size=+5>Big RED text!</font>"
_IEBodyWriteHTML($oIE, $sHTML)


Function _IEBodyReadText

Function Reference

_IEBodyReadText

Returns the Text inside the <body> tag of the document

#include <IE.au3>
_IEBodyReadText ( ByRef $oObject )

Parameters

$oObject Object variable of an InternetExplorer.Application, Window or Frame object

Return Value

Success: | the text included in the <body> of the document.
Failure: | sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type
@extended: | Contains invalid parameter number

Remarks

This function uses the .innerText property of the document Body.
.innerText is available for nearly all DOM elements and is a fast convenient method of parsing out just the text in a document using _IEPropertyGet().

Related

_IEBodyReadHTML, _IEBodyWriteHTML, _IEPropertyGet

Example

; Open a browser with the basic example, read the body Text
; (the content with all HTML tags removed) and display it in a MsgBox

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IE_Example("basic")
Local $sText = _IEBodyReadText($oIE)
MsgBox($MB_SYSTEMMODAL, "Body Text", $sText)

_IEQuit($oIE)


Function _IEBodyWriteHTML

Function Reference

_IEBodyWriteHTML

Replaces the HTML inside the <body> tag of the document

#include <IE.au3>
_IEBodyWriteHTML ( ByRef $oObject, $sHTML )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Window or Frame object
$sHTML | The HTML string to write to the document

Return Value

Success: | None
Failure: | 0 or -1 and sets the @error flag to non-zero.
@error: | 1 ($_IEStatus_GeneralError) - General Error 2 ($_IEStatus_COMError) - COM Error in Object reference 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 6 ($_IEStatus_LoadWaitTimeout) - Load Wait Timeout 8 ($_IEStatus_AccessIsDenied) - Access Is Denied 9 ($_IEStatus_ClientDisconnected) = Client Disconnected
@extended: | Contains invalid parameter number

Remarks

You may use _IEBodyReadHTML() to read the current HTML contents of the document body, manipulat that string and then write it back with _IEBodyWriteHTML().
You may also use _IEDocInsertHTML(), _IEDocInsertText() and the innerHTML, innerText, outerHTML and outerText features of _IEPropertyGet() and _IEPropertySet() to control specific elements without rewriting large blocks of text.

Related

_IEBodyReadHTML, _IEBodyReadText, _IEDocInsertHTML, _IEDocInsertText, _IELoadWait, _IEPropertyGet, _IEPropertySet

Example

; Open a browser with the iFrame example, get a reference
; to the iFrame with a name of "iFrameTwo" and replace its body HTML

#include <IE.au3>

Local $oIE = _IE_Example("iframe")
Local $oFrame = _IEFrameGetObjByName($oIE, "iFrameTwo")
_IEBodyWriteHTML($oFrame, "Hello <b><font color=red>iFrame!</font></b>")


Function _IECreate

Function Reference

_IECreate

Create an Internet Explorer Browser Window

#include <IE.au3>
_IECreate ( [$sUrl = "about:blank" [, $iTryAttach = 0 [, $iVisible = 1 [, $iWait = 1 [, $iTakeFocus = 1]]]]] )

Parameters

$sUrl | [optional] specifies the Url to navigate to upon creation
$iTryAttach | [optional] specifies whether to try to attach to an existing window 0 = (Default) do not try to attach 1 = Try to attach to an existing window
$iVisible | [optional] specifies whether the browser window will be visible 0 = Browser Window is hidden 1 = (Default) Browser Window is visible
$iWait | [optional] specifies whether to wait for page to load before returning 0 = Return immediately, not waiting for page to load 1 = (Default) Wait for page load to complete before returning
$iTakeFocus | [optional] specifies whether to bring the attached window to focus 0 = Do not bring window into focus 1 = (Default) bring window into focus

Return Value

Success: | an object variable pointing to an InternetExplorer.Application object.
Failure: | sets the @error flag to non-zero.
@error: | 1 ($_IEStatus_GeneralError) - General Error 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 6 ($_IEStatus_LoadWaitTimeout) - Load Wait Timeout 8 ($_IEStatus_AccessIsDenied) - Access Is Denied 9 ($_IEStatus_ClientDisconnected) - Client Disconnected
@extended: | Set to true (1) or false (0) depending on the success of $iTryAttach

Remarks

When using tryAttach, a No Match error will be displayed to the console from _IEAttach().
This can be controlled with _IEErrorNotify().

When opening a local HyperTextApplication (.hta) file, Internet Explorer will open a new browser process for it that will not be accessible through the object variable returned by _IECreate().
To control this new browser you must use _IEAttach() with the "embedded" option.

New security in Windows Vista causes a new browser window to be created when a browser is instructed to navigate to a URL in a different security zone.
This occurs as well with the initial creation and navigation initiated with _IECreate().
The new window is a new browser instance and the previous browser object variable no longer points to it.
There are several workarounds:
1) add #RequireAdmin to your code (this is required even if the account is part of the Administrator's Group and will prompt for credentials if necessary),
2) use _IEAttach() to connect to the new browser window
3) add the target website to the Trusted Sites security zone in IE,
4) turn off "Protected Mode" in IE,
or 5) disable UAC. Care must be taken to understand the implications of disabling IE security features when accessing untrusted sites.

Related

_IEAttach, _IECreateEmbedded, _IELoadWait, _IENavigate, _IEQuit

Example

Example 1

; Create a browser window and navigate to a website

#include <IE.au3>

Local $oIE = _IECreate("www.autoitscript.com")

Example 2

; Create new browser windows pointing to each of 3 different URLs
; if one does not already exist ($f_tryAttach = 1)
; do not wait for the page loads to complete ($f_wait = 0)

#include <IE.au3>

_IECreate("www.autoitscript.com", 1, 1, 0)
_IECreate("my.yahoo.com", 1, 1, 0)
_IECreate("www.google.com", 1, 1, 0)

Example 3

; Attempt to attach to an existing browser displaying a particular website URL
; Create a new browser and navigate to that site if one does not already exist

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IECreate("www.autoitscript.com", 1)
; Check @extended return value to see if attach was successful
If @extended Then
    MsgBox($MB_SYSTEMMODAL, "", "Attached to Existing Browser")
Else
    MsgBox($MB_SYSTEMMODAL, "", "Created New Browser")
EndIf

Example 4

; Create an empty browser window and populate it with custom HTML

#include <IE.au3>

Local $oIE = _IECreate()
Local $sHTML = "<h1>Hello World!</h1>"
_IEBodyWriteHTML($oIE, $sHTML)

Example 5

; Create a browser window attached to a new instance of iexplore.exe
; This is often necessary in order to get a new session cookie context
; (session cookies are shared among all browser instances sharing the same iexplore.exe)

#include <IE.au3>

Opt("WinTitleMatchMode", 2)

ShellExecute("iexplore.exe", "about:blank")
WinWait("Windows Internet Explorer")

Local $oIE = _IEAttach("about:blank", "url")
_IELoadWait($oIE)
_IENavigate($oIE, "www.autoitscript.com")


Function _IECreateEmbedded

Function Reference

_IECreateEmbedded

Create a Webbrowser object suitable for embedding in an AutoIt GUI with GUICtrlCreateObj()

#include <IE.au3>
_IECreateEmbedded ( )

Return Value

Success: | a Webbrowser object reference.
Failure: | sets the @error flag to non-zero.
@error: | 1 ($_IEStatus_GeneralError) - General Error

Remarks

No actions can be performed on this object until it has been embedded into a parent application (e.g. you cannot perform an _IENavigate().
Because of this restriction, the browser is not automatically navigated to 'about:blank' as is a browser created with _IECreate().
You must therefore use _IENavigate() to navigate this browser to 'about:blank' after it has been embedded into the parent application and before you attempt any operations that rely on having a document loaded (e.g. _IEBodyWriteHTML()
).

There are several properties related to an InternetExplorer object (e.g. returned by _IECreate() ) that do not apply to this object.
These include status text, addressbar and others that may exist for a browser, but do not exist for an embedded control.

You may have object visibility issues unless you use the Windows style $WS_CLIPCHILDREN in GUICreate().

_IEQuit() cannot be used with this object. The object will be destroyed when its parent GUI is destroyed.

Related

_IEAttach, _IECreate, _IENavigate

Example

; Trap COM errors so that 'Back' and 'Forward'
; outside of history bounds does not abort script
; (expect COM errors to be sent to the console)

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

Local $oIE = _IECreateEmbedded()
GUICreate("Embedded Web control Test", 640, 580, _
        (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
        $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
GUICtrlCreateObj($oIE, 10, 40, 600, 360)
Local $idButton_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30)
Local $idButton_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30)
Local $idButton_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30)
Local $idButton_Stop = GUICtrlCreateButton("Stop", 340, 420, 100, 30)

Global $g_idError_Message = GUICtrlCreateLabel("", 100, 500, 500, 30)
GUICtrlSetColor(-1, 0xff0000)

GUISetState(@SW_SHOW) ;Show GUI

_IENavigate($oIE, "http://www.autoitscript.com")
_IEAction($oIE, "stop")

; Waiting for user to close the window
While 1
    Local $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $iMsg = $idButton_Home
            _IENavigate($oIE, "http://www.autoitscript.com")
            _IEAction($oIE, "stop")
            _IEAction($oIE, "back")
            CheckError("Home", @error, @extended)
        Case $iMsg = $idButton_Back
            _IEAction($oIE, "back")
            CheckError("Back", @error, @extended)
        Case $iMsg = $idButton_Forward
            _IEAction($oIE, "forward")
            CheckError("Forward", @error, @extended)
        Case $iMsg = $idButton_Stop
            _IEAction($oIE, "stop")
            CheckError("Stop", @error, @extended)
    EndSelect
WEnd

GUIDelete()

Exit

Func CheckError($sMsg, $iError, $iExtended)
    If $iError Then
        $sMsg = "Error using " & $sMsg & " button (" & $iExtended & ")"
    Else
        $sMsg = ""
    EndIf
    GUICtrlSetData($g_idError_Message, $sMsg)
EndFunc   ;==>CheckError


Function _IEDocGetObj

Function Reference

_IEDocGetObj

Given any DOM object, returns a reference to the associated document object

#include <IE.au3>
_IEDocGetObj ( ByRef $oObject )

Parameters

$oObject Object variable of an InternetExplorer.Application, Window, Frame or any DOM object

Return Value

Success: | an object variable pointing to the Document object.
Failure: | sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type
@extended: | Contains invalid parameter number

Remarks

Given any DOM object (e.g. Browser, Window, Frame, iFrame, Document or Document Element) this will return a reference to the associated document object.
It is particularly useful when writing generalized functions when you cannot control the type of object that will be passed in.

Example

; Open a browser to the AutoIt Homepage, get a reference
; to the document object and display a document attribute

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IECreate("http://www.google.com")
Local $oDoc = _IEDocGetObj($oIE)
MsgBox($MB_SYSTEMMODAL, "Document Created Date", $oDoc.fileCreatedDate)


Function _IEDocInsertHTML

Function Reference

_IEDocInsertHTML

Inserts HTML Text in or around an element

#include <IE.au3>
_IEDocInsertHTML ( ByRef $oObject, $sString [, $sWhere = "beforeend"] )

Parameters

$oObject | Object variable pointing to a document element.
$sString | The string containing the HTML text to insert.
$sWhere [optional] specifies the string insertion point
"beforebegin" = Inserts string immediately before the object.
"afterbegin" = Inserts string after the start of the object but before all other content in the object.
"beforeend" = (Default) Inserts string immediately before the end of the object but after all other content in the object.
"afterend" = Inserts string immediately after the end of the object.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 2 ($_IEStatus_COMError) - COM Error in Object reference 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 5 ($_IEStatus_InvalidValue) - Invalid Value
@extended: | Contains invalid parameter number

Remarks

The innerHTML, outerHTML, innerText and outerText features of _IEPropertySet() can be used to dynamically manipulate inserted content.

Related

_IEBodyReadHTML, _IEBodyWriteHTML, _IEDocInsertText, _IEDocReadHTML, _IEHeadInsertEventScript, _IEPropertyGet, _IEPropertySet

Example

Example 1

; Insert HTML at the top and bottom of a document

#include <IE.au3>

Local $oIE = _IECreate("http://www.autoitscript.com")
Local $oBody = _IETagNameGetCollection($oIE, "body", 0)
_IEDocInsertHTML($oBody, "<h2><font color=red>This HTML is inserted After Begin</font></h2>", "afterbegin")
_IEDocInsertHTML($oBody, "<h2><font color=red>This HTML is inserted Before End</font></h2>", "beforeend")

Example 2

; Open a browser with the basic example page, insert HTML
; in and around the DIV tag named "IEAu3Data" and display Body HTML

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IE_Example("basic")
Local $oDiv = _IEGetObjById($oIE, "IEAu3Data")

_IEDocInsertHTML($oDiv, "<b>(HTML beforebegin)</b>", "beforebegin")
_IEDocInsertHTML($oDiv, "<i>(HTML afterbegin)</i>", "afterbegin")
_IEDocInsertHTML($oDiv, "<b>(HTML beforeend)</b>", "beforeend")
_IEDocInsertHTML($oDiv, "<i>(HTML afterend)</i>", "afterend")

MsgBox($MB_SYSTEMMODAL, "Body", _IEBodyReadHTML($oIE) & @CRLF)

Example 3

; Advanced example
; Insert a clock and a referrer string at the top of every page, even when you
; browse to a new location.  Uses _IEDocInsertText, _IEDocInsertHTML and
; _IEPropertySet features "innerhtml" and "referrer"

#include <IE.au3>

Global $g_oIE = _IECreate("http://www.autoitscript.com")

AdlibRegister("UpdateClock", 1000) ; Update clock once per second

While 1
    Sleep(10000)
WEnd

Exit

Func UpdateClock()
    ; update as long as the browser window exists
    If Not WinExists(_IEPropertyGet($g_oIE, "hwnd")) Then Exit

    Local $sCurTime = "<font color=red><b>Current Time is: </b>" & @HOUR & ":" & @MIN & ":" & @SEC & "</font>"
    ; _IEGetObjById is expected to return a NoMatch error after navigation
    ;   (before DIV is inserted), so temporarily turn off notification
    _IEErrorNotify(False)
    Local $oAutoItClock = _IEGetObjById($g_oIE, "AutoItClock")
    If Not IsObj($oAutoItClock) Then ; Insert DIV element if it wasn't found
        ;
        ; Get reference to BODY, insert DIV, get reference to DIV, update time
        Local $oBody = _IETagNameGetCollection($g_oIE, "body", 0)
        _IEDocInsertHTML($oBody, "<div id='AutoItClock'></div>", "afterbegin")
        $oAutoItClock = _IEGetObjById($g_oIE, "AutoItClock")
        _IEPropertySet($oAutoItClock, "innerhtml", $sCurTime)
        ;
        ; Check referrer string, if not blank insert after clock
        _IELoadWait($g_oIE)
        Local $sReferrer = _IEPropertyGet($g_oIE, "referrer")
        If $sReferrer Then _IEDocInsertText($oAutoItClock, _
                "  Referred by: <font color=red>" & $sReferrer & "</font>", "afterend")
    Else
        _IEPropertySet($oAutoItClock, "innerhtml", $sCurTime) ; update time
    EndIf
    _IEErrorNotify(True)
EndFunc   ;==>UpdateClock


Function _IEDocInsertText

Function Reference

_IEDocInsertText

Inserts Text in or around an element

#include <IE.au3>
_IEDocInsertText ( ByRef $oObject, $sString [, $sWhere = "beforeend"] )

Parameters

$oObject | Object variable pointing to a document element.
$sString | The string containing the text to insert.
$sWhere [optional] specifies the string insertion point
"beforebegin" = Inserts string immediately before the object.
"afterbegin" = Inserts string after the start of the object but before all other content in the object.
"beforeend" = (Default) Inserts string immediately before the end of the object but after all other content in the object.
"afterend" = Inserts string immediately after the end of the object.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 2 ($_IEStatus_COMError) - COM Error in Object reference 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 5 ($_IEStatus_InvalidValue) - Invalid Value
@extended: | Contains invalid parameter number

Remarks

In the text to be inserted includes HTML tags, they are first converted so that they display as text.
The innerHTML, outerHTML, innerText and outerText features of _IEPropertySet() can be used to dynamically manipulate inserted content.

Related

_IEBodyReadHTML, _IEBodyWriteHTML, _IEDocInsertHTML, _IEDocReadHTML, _IEHeadInsertEventScript, _IEPropertyGet, _IEPropertySet

Example

Example 1

; Open a browser with the basic example page, insert text
; in and around the first Paragraph tag and display Body HTML

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IE_Example("basic")
Local $oP = _IETagNameGetCollection($oIE, "p", 0)

_IEDocInsertText($oP, "(Text beforebegin)", "beforebegin")
_IEDocInsertText($oP, "(Text afterbegin)", "afterbegin")
_IEDocInsertText($oP, "(Text beforeend)", "beforeend")
_IEDocInsertText($oP, "(Text afterend)", "afterend")

MsgBox($MB_SYSTEMMODAL, "Body", _IEBodyReadHTML($oIE) & @CRLF)

Example 2

; Insert HTML at the top and bottom of a document

#include <IE.au3>

Local $oIE = _IE_Example("basic")
Local $oBody = _IETagNameGetCollection($oIE, "body", 0)
_IEDocInsertText($oBody, "This Text is inserted After Begin", "afterbegin")
_IEDocInsertText($oBody, "Notice that <b>Tags</b> are <encoded> before display", "beforeend")

Example 3

; Advanced example
; Insert a clock and a referrer string at the top of every page, even when you
; browse to a new location.  Uses _IEDocInsertText, _IEDocInsertHTML and
; _IEPropertySet features "innerhtml" and "referrer"

#include <IE.au3>

Global $g_oIE = _IECreate("http://www.autoitscript.com")

AdlibRegister("UpdateClock", 1000) ; Update clock once per second

While 1
    Sleep(10000)
WEnd

Exit

Func UpdateClock()
    ; update as long as the browser window exists
    If Not WinExists(_IEPropertyGet($g_oIE, "hwnd")) Then Exit

    Local $sCurTime = "<font color=red><b>Current Time is: </b>" & @HOUR & ":" & @MIN & ":" & @SEC & "</font>"
    ; _IEGetObjById is expected to return a NoMatch error after navigation
    ;   (before DIV is inserted), so temporarily turn off notification
    _IEErrorNotify(False)
    Local $oAutoItClock = _IEGetObjById($g_oIE, "AutoItClock")
    If Not IsObj($oAutoItClock) Then ; Insert DIV element if it wasn't found
        ;
        ; Get reference to BODY, insert DIV, get reference to DIV, update time
        Local $oBody = _IETagNameGetCollection($g_oIE, "body", 0)
        _IEDocInsertHTML($oBody, "<div id='AutoItClock'></div>", "afterbegin")
        $oAutoItClock = _IEGetObjById($g_oIE, "AutoItClock")
        _IEPropertySet($oAutoItClock, "innerhtml", $sCurTime)
        ;
        ; Check referrer string, if not blank insert after clock
        _IELoadWait($g_oIE)
        Local $sReferrer = _IEPropertyGet($g_oIE, "referrer")
        If $sReferrer Then _IEDocInsertText($oAutoItClock, _
                "  Referred by: <font color=red>" & $sReferrer & "</font>", "afterend")
    Else
        _IEPropertySet($oAutoItClock, "innerhtml", $sCurTime) ; update time
    EndIf
    _IEErrorNotify(True)
EndFunc   ;==>UpdateClock


Function _IEDocReadHTML

Function Reference

_IEDocReadHTML

Returns the full HTML source of a document

#include <IE.au3>
_IEDocReadHTML ( ByRef $oObject )

Parameters

$oObject Object variable of an InternetExplorer.Application, Window or Frame object

Return Value

Success: | the HTML included in the <HTML> of the document, including the <html> and </html> tags.
Failure: | sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type
@extended: | Contains invalid parameter number

Remarks

This function returns the document source after any client-side modifications (e.g. by AutoIt or by client-side JavaScript).
It may therefore be different than what is shown by the browser View Source or by _INetGetSource().

Related

_IEBodyReadHTML, _IEDocInsertHTML, _IEDocInsertText, _IEDocWriteHTML, _INetGetSource

Example

; Open a browser with the basic example, read the document HTML
; (all HTML including the <HEAD> and script) and display it in a MsgBox

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IE_Example("basic")
Local $sHTML = _IEDocReadHTML($oIE)
MsgBox($MB_SYSTEMMODAL, "Document Source", $sHTML)

_IEQuit($oIE)


Function _IEDocWriteHTML

Function Reference

_IEDocWriteHTML

Replaces the HTML for the entire document

#include <IE.au3>
_IEDocWriteHTML ( ByRef $oObject, $sHTML )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Window or Frame object
$sHTML | The HTML string to write to the document

Return Value

Success: | none.
Failure: | 0 or -1 and sets the @error flag to non-zero.
@error: | 1 ($_IEStatus_GeneralError) = General Error 2 ($_IEStatus_COMError) = COM Error in Object reference 3 ($_IEStatus_InvalidDataType) = Invalid Data Type 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type 6 ($_IEStatus_LoadWaitTimeout) = Load Wait Timeout 8 ($_IEStatus_AccessIsDenied) = Access Is Denied 9 ($_IEStatus_ClientDisconnected) = Client Disconnected
@extended: | Contains invalid parameter number

Remarks

This function completely replaces the content of the document in a browser or a frame.
It can be used to create a new page with custom HTML and JavaScript.

It is sometimes necessary to refresh the page after writing with _IEAction($oIE, "refresh") (e,g, after creating a FRAMESET).

Related

_IEDocReadHTML, _IELoadWait

Example

; Create an empty browser, write customer HTML to it - in this case a
; FRAMESET - and then update the contents of each of the frames

#include <IE.au3>

Local $oIE = _IECreate()
Local $sHTML = ""
$sHTML &= "<HTML>" & @CRLF
$sHTML &= "<HEAD>" & @CRLF
$sHTML &= "<TITLE>_IE_Example('frameset')</TITLE>" & @CRLF
$sHTML &= "</HEAD>" & @CRLF
$sHTML &= "<FRAMESET rows='25,200'>" & @CRLF
$sHTML &= " <FRAME NAME=Top SRC=about:blank>" & @CRLF
$sHTML &= " <FRAMESET cols='100,500'>" & @CRLF
$sHTML &= "   <FRAME NAME=Menu SRC=about:blank>" & @CRLF
$sHTML &= "   <FRAME NAME=Main SRC=about:blank>" & @CRLF
$sHTML &= " </FRAMESET>" & @CRLF
$sHTML &= "</FRAMESET>" & @CRLF
$sHTML &= "</HTML>"
_IEDocWriteHTML($oIE, $sHTML)
_IEAction($oIE, "refresh")
Local $oFrameTop = _IEFrameGetObjByName($oIE, "Top")
Local $oFrameMenu = _IEFrameGetObjByName($oIE, "Menu")
Local $oFrameMain = _IEFrameGetObjByName($oIE, "Main")
_IEBodyWriteHTML($oFrameTop, '$oFrameTop = _IEFrameGetObjByName($oIE, "Top")')
_IEBodyWriteHTML($oFrameMenu, '$oFrameMenu = _IEFrameGetObjByName($oIE, "Menu")')
_IEBodyWriteHTML($oFrameMain, '$oFrameMain = _IEFrameGetObjByName($oIE, "Main")')


Function _IEErrorNotify

Function Reference

_IEErrorNotify

Specifies whether IE.au3 automatically notifies of Warnings and Errors (to the console)

#include <IE.au3>
_IEErrorNotify ( [$vNotify = Default] )

Parameters

$vNotify [optional] specifies whether notification should be on or off
-1 = (Default) return current setting
True = Turn On
False = Turn Off

Return Value

Returns the current notification setting, if $vNotify = -1 (Default), else returns 1.

Remarks

IE.au3 writes diagnostic information, warnings and errors to the console by default.
This information can readily be seen when using the SciTE editor to run your scripts.

This function allows you to turn this functionality on or off.

Example

Example 1

; Check the current status of _IEErrorNotify, turn it off if on, on if off

#include <IE.au3>
#include <MsgBoxConstants.au3>

If _IEErrorNotify() Then
    MsgBox($MB_SYSTEMMODAL, "_IEErrorNotify Status", "Notification is ON, turning it OFF")
    _IEErrorNotify(False)
Else
    MsgBox($MB_SYSTEMMODAL, "_IEErrorNotify Status", "Notification is OFF, turning it ON")
    _IEErrorNotify(True)
EndIf

Example 2

#include <IE.au3>
#include <MsgBoxConstants.au3>

MsgBox($MB_SYSTEMMODAL, "_IEErrorNotify Status", "Notification now is " & _IEErrorNotify())

ConsoleWrite(@CRLF)
ConsoleWrite('! Look what happens when _IEErrorNotify is ON' & @CRLF)
Local $oIE = _IECreate('www.google') ; URL is broken
Local $oForm = _IEFormGetObjByName($oIE, "gbqf")
Local $oQuery = _IEFormElementGetObjByName($oForm, "q")
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
_IEFormSubmit($oForm)
_IEQuit($oIE)
ConsoleWrite('! This is what you can see in console when _IEErrorNotify is Turned ON' & @CRLF)

ConsoleWrite(@CRLF)
_IEErrorNotify_ON_OFF()
MsgBox($MB_SYSTEMMODAL, "_IEErrorNotify Status", "Notification now is " & _IEErrorNotify())

ConsoleWrite(@CRLF)
ConsoleWrite('! Now look what happens when _IEErrorNotify is OFF' & @CRLF)
$oIE = _IECreate('www.google') ; URL is broken
$oForm = _IEFormGetObjByName($oIE, "gbqf")
; $oForm = _IEFormGetObjByName($oIE, "gbqf")
$oQuery = _IEFormElementGetObjByName($oForm, "q")
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
_IEFormSubmit($oForm)
_IEQuit($oIE)
ConsoleWrite('! This is what you can see in console when _IEErrorNotify is Turned OFF' & @CRLF)
ConsoleWrite(@CRLF)

_IEErrorNotify_ON_OFF()
MsgBox($MB_SYSTEMMODAL, "_IEErrorNotify Status", "Notification now is " & _IEErrorNotify())
ConsoleWrite(@CRLF)

ConsoleWrite(@CRLF)
ConsoleWrite('! Look what happens when _IEErrorNotify is ON with some ERRORs' & @CRLF)
$oIE = _IECreate('www.google.com') ; URL is OK
$oForm = _IEFormGetObjByName($oIE, "gbqf", 1) ; try to retrieve the index = 1 -> ERROR
$oQuery = _IEFormElementGetObjByName($oForm, "q", 1) ; try to retrieve the index = 1 -> ERROR
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
_IEFormSubmit($oForm)
_IEQuit($oIE)
ConsoleWrite('! This is what you can see in console when _IEErrorNotify is Turned ON' & @CRLF)

Func _IEErrorNotify_ON_OFF()
    If _IEErrorNotify() Then
        MsgBox($MB_SYSTEMMODAL, "_IEErrorNotify Status", "Notification is ON, turning it OFF")
        ConsoleWrite('> Turning _IEErrorNotify OFF' & @CRLF)
        _IEErrorNotify(False)
    Else
        MsgBox($MB_SYSTEMMODAL, "_IEErrorNotify Status", "Notification is OFF, turning it ON")
        ConsoleWrite('> Turning _IEErrorNotify ON' & @CRLF)
        _IEErrorNotify(True)
    EndIf
EndFunc   ;==>_IEErrorNotify_ON_OFF


Function _IEFormElementCheckBoxSelect

Function Reference

_IEFormElementCheckBoxSelect

Set the value of a specified form element

#include <IE.au3>
_IEFormElementCheckBoxSelect ( ByRef $oObject, $sString [, $sName = "" [, $iSelect = 1 [, $sMode = "byValue" [, $iFireEvent = 1]]]] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Form object
$sString | Value used to match element - treatment based on $sMode
$sName | [optional] Name or Id of checkbox(es)
$iSelect [optional] specifies whether element should be checked or unchecked
-1 = Return checked state
0 = Uncheck the element
1 = (Default) Check the element
$sMode [optional] specify search mode
"byValue" = (Default) value of the checkbox you wish to select
"byIndex" = 0-based index of checkbox you wish to select
$iFireEvent [optional] specifies whether to fire OnChange and OnClick events after changing value
0 = do not fire OnChange or OnClick event after setting value
1 = (Default) fire OnChange and OnClick events after setting value

Return Value

Success: | the current checked state if $iSelect = -1, else returns 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type 5 ($_IEStatus_InvalidValue) = Invalid Value 7 ($_IEStatus_NoMatch) = No Match
@extended: | Contains invalid parameter number

Remarks

The $iFireEvent parameter is significant only if the form element has an onChange event associated with it.

$sName is optional for this function.
If it is omitted, the function will operate on a collection of all <input type=checkbox> elements in the form.
If specified, the function will operate on a collection of <input type=checkbox> elements with that name.

Related

_IEFormElementGetValue, _IEFormElementOptionSelect, _IEFormElementRadioSelect, _IEFormElementSetValue

Example

Example 1

; Open a browser with the form example, get reference to form, select and
; deselect the checkboxes byValue.  Since $s_Name is not specified, operate
; on the collection of all <input type=checkbox> elements in the form
; Note: You will likely need to scroll down on the page to see the changes

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
For $i = 1 To 3
    _IEFormElementCheckBoxSelect($oForm, "gameBasketball", "", 1, "byValue")
    Sleep(1000)
    _IEFormElementCheckBoxSelect($oForm, "gameFootball", "", 1, "byValue")
    Sleep(1000)
    _IEFormElementCheckBoxSelect($oForm, "gameTennis", "", 1, "byValue")
    Sleep(1000)
    _IEFormElementCheckBoxSelect($oForm, "gameBaseball", "", 1, "byValue")
    Sleep(1000)
    _IEFormElementCheckBoxSelect($oForm, "gameBasketball", "", 0, "byValue")
    Sleep(1000)
    _IEFormElementCheckBoxSelect($oForm, "gameFootball", "", 0, "byValue")
    Sleep(1000)
    _IEFormElementCheckBoxSelect($oForm, "gameTennis", "", 0, "byValue")
    Sleep(1000)
    _IEFormElementCheckBoxSelect($oForm, "gameBaseball", "", 0, "byValue")
    Sleep(1000)
Next

_IEQuit($oIE)

Example 2

; Open a browser with the form example, get reference to form, select and
; deselect the checkboxes byIndex.  Since $s_Name is not specified, operate
; on the collection of all <input type=checkbox> elements in the form
; Note: You will likely need to scroll down on the page to see the changes

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
For $i = 1 To 3
    _IEFormElementCheckBoxSelect($oForm, 3, "", 1, "byIndex")
    Sleep(1000)
    _IEFormElementCheckBoxSelect($oForm, 2, "", 1, "byIndex")
    Sleep(1000)
    _IEFormElementCheckBoxSelect($oForm, 1, "", 1, "byIndex")
    Sleep(1000)
    _IEFormElementCheckBoxSelect($oForm, 0, "", 1, "byIndex")
    Sleep(1000)
    _IEFormElementCheckBoxSelect($oForm, 3, "", 0, "byIndex")
    Sleep(1000)
    _IEFormElementCheckBoxSelect($oForm, 2, "", 0, "byIndex")
    Sleep(1000)
    _IEFormElementCheckBoxSelect($oForm, 1, "", 0, "byIndex")
    Sleep(1000)
    _IEFormElementCheckBoxSelect($oForm, 0, "", 0, "byIndex")
    Sleep(1000)
Next

_IEQuit($oIE)

Example 3

; Open a browser with the form example, get reference to form, select and
; deselect the checkboxes byIndex in the group that shares the name checkboxG2Example
; Note: You will likely need to scroll down on the page to see the changes

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
For $i = 1 To 3
    _IEFormElementCheckBoxSelect($oForm, 0, "checkboxG2Example", 1, "byIndex")
    Sleep(1000)
    _IEFormElementCheckBoxSelect($oForm, 1, "checkboxG2Example", 1, "byIndex")
    Sleep(1000)
    _IEFormElementCheckBoxSelect($oForm, 0, "checkboxG2Example", 0, "byIndex")
    Sleep(1000)
    _IEFormElementCheckBoxSelect($oForm, 1, "checkboxG2Example", 0, "byIndex")
    Sleep(1000)
Next

_IEQuit($oIE)


Function _IEFormElementGetCollection

Function Reference

_IEFormElementGetCollection

Returns a collection object variable representing all Form Elements within a given Form

#include <IE.au3>
_IEFormElementGetCollection ( ByRef $oObject [, $iIndex = -1] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Form object
$iIndex | [optional] specifies whether to return a collection or indexed instance 0 or positive integer returns an indexed instance -1 = (Default) returns a collection

Return Value

Success: | an object variable containing the Form Elements collection, @extended = form element count.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 5 ($_IEStatus_InvalidValue) - Invalid Value 7 ($_IEStatus_NoMatch) - No Match
@extended: | Contains invalid parameter number

Related

_IEFormElementGetObjByName, _IEFormElementGetValue, _IEFormElementSetValue, _IEFormSubmit

Example

; Get a reference to a specific form element by 0-based index.
; In this case, submit a query to the Google search engine

#include <IE.au3>

Local $oIE = _IECreate("http://www.google.com")
Local $oForm = _IEFormGetCollection($oIE, 0)
Local $oQuery = _IEFormElementGetCollection($oForm, 4)
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
_IEFormSubmit($oForm)


Function _IEFormElementGetObjByName

Function Reference

_IEFormElementGetObjByName

Returns an object reference to a Form Element by name

#include <IE.au3>
_IEFormElementGetObjByName ( ByRef $oObject, $sName [, $iIndex = 0] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Form object
$sName | Specifies the name of the Form Element you wish to match
$iIndex | [optional] If the Form Element name occurs more than once, specifies instance by 0-based index 0 (Default) or positive integer returns an indexed instance -1 returns a collection of the specified Form Elements

Return Value

Success: | an object variable pointing to the Form Element object, @extended = form count.
Failure: | sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 7 ($_IEStatus_NoMatch) - No Match
@extended: | Contains invalid parameter number

Remarks

If the desired form element does not have a name or ID, _IEFormElementGetCollection() to get a reference by index.

Related

_IEFormElementGetCollection, _IEFormElementGetValue, _IEFormElementSetValue, _IEFormSubmit

Example

; Get a reference to a specific form element by name.
; In this case, submit a query to the Google search engine

#include <IE.au3>

Local $oIE = _IECreate("http://www.google.com")
Local $oForm = _IEFormGetObjByName($oIE, "gbqf")
Local $oQuery = _IEFormElementGetObjByName($oForm, "q")
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
_IEFormSubmit($oForm)


Function _IEFormElementGetValue

Function Reference

_IEFormElementGetValue

Returns the value of a given Form Element

#include <IE.au3>
_IEFormElementGetValue ( ByRef $oObject )

Parameters

$oObject Object variable of an InternetExplorer.Application, Form Element object

Return Value

Success: | the string value of the given Form Element.
Failure: | sets the @error flag to non-zero.
@error: | 2 ($_IEStatus_COMError) - COM Error in Object reference 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type
@extended: | Contains invalid parameter number

Remarks

See remarks for _IEFormElementSetValue().

Related

_IEFormElementCheckBoxSelect, _IEFormElementGetCollection, _IEFormElementGetObjByName, _IEFormElementOptionSelect, _IEFormElementRadioSelect, _IEFormElementSetValue

Example

; Open a browser with the form example, set the value of a text
; form element, retrieve and display the value from the element

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IE_Example("form")
Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
Local $oText = _IEFormElementGetObjByName($oForm, "textExample")
Local $aIEAu3Version = _IE_VersionInfo()
_IEFormElementSetValue($oText, $aIEAu3Version[5])
MsgBox($MB_SYSTEMMODAL, "Form Element Value", _IEFormElementGetValue($oText))

_IEQuit($oIE)


Function _IEFormElementOptionSelect

Function Reference

_IEFormElementOptionSelect

Set the value of a specified form element

#include <IE.au3>
_IEFormElementOptionSelect ( ByRef $oObject, $sString [, $iSelect = 1 [, $sMode = "byValue" [, $iFireEvent = 1]]] )

Parameters

$oObject | Form Element Object of type "Select Option"
$sString | Value used to match element - treatment based on $sMode
$iSelect [optional] specifies whether element should be selected or deselected
-1 = Return selected state
0 = Deselect the element
1 = (Default) Select the element
$sMode [optional] specifies search mode
"byValue" = (Default) value of the option you wish to select
"byText" = text of the option you wish to select
"byIndex" = 0-based index of option you wish to select
$iFireEvent [optional] specifies whether to fire OnChange and OnClick events after changing value
0 = do not fire OnChange or OnClick event after setting value
1 = (Default) fire OnChange and OnClick events after setting value

Return Value

Success: | the current selected state if $iSelect = -1, else returns 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 5 ($_IEStatus_InvalidValue) - Invalid Value 7 ($_IEStatus_NoMatch) - No Match
@extended: | Contains invalid parameter number

Remarks

The $iFireEvent parameter is significant only if the form element has an onChange event associated with it.

Related

_IEFormElementCheckBoxSelect, _IEFormElementGetValue, _IEFormElementRadioSelect, _IEFormElementSetValue

Example

Example 1

; Open a browser with the form example, get reference to form, get reference
; to select element, cycle 10 times selecting options byValue, byText and byIndex

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
Local $oSelect = _IEFormElementGetObjByName($oForm, "selectExample")
_IEAction($oSelect, "focus")
For $i = 1 To 10
    _IEFormElementOptionSelect($oSelect, "Freepage", 1, "byText")
    Sleep(1000)
    _IEFormElementOptionSelect($oSelect, "midipage.html", 1, "byValue")
    Sleep(1000)
    _IEFormElementOptionSelect($oSelect, 0, 1, "byIndex")
    Sleep(1000)
Next

_IEQuit($oIE)

Example 2

; Open a browser with the form example, get reference to form, get reference
; to select multiple element, cycle 5 times selecting and then deselecting
; options byValue, byText and byIndex.

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
Local $oSelect = _IEFormElementGetObjByName($oForm, "multipleSelectExample")
_IEAction($oSelect, "focus")
For $i = 1 To 3
    _IEFormElementOptionSelect($oSelect, "Carlos", 1, "byText")
    Sleep(1000)
    _IEFormElementOptionSelect($oSelect, "Name2", 1, "byValue")
    Sleep(1000)
    _IEFormElementOptionSelect($oSelect, 5, 1, "byIndex")
    Sleep(1000)
    _IEFormElementOptionSelect($oSelect, "Carlos", 0, "byText")
    Sleep(1000)
    _IEFormElementOptionSelect($oSelect, "Name2", 0, "byValue")
    Sleep(1000)
    _IEFormElementOptionSelect($oSelect, 5, 0, "byIndex")
    Sleep(1000)
Next

_IEQuit($oIE)

Example 3

; Open a browser with the form example, get reference to form, get reference
; to select element, check to see if the option "Freepage" is selected and
; report result.  Repeat for the option with index 0 and for the option
; with value of 'midipage.html'

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IE_Example("form")
Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
Local $oSelect = _IEFormElementGetObjByName($oForm, "selectExample")
If _IEFormElementOptionSelect($oSelect, "Freepage", -1, "byText") Then
    MsgBox($MB_SYSTEMMODAL, "Option Selected", "Option Freepage is selected")
Else
    MsgBox($MB_SYSTEMMODAL, "Option Selected", "Option Freepage is Not selected")
EndIf
If _IEFormElementOptionSelect($oSelect, 0, -1, "byIndex") Then
    MsgBox($MB_SYSTEMMODAL, "Option Selected", "The First (index 0) option is selected")
Else
    MsgBox($MB_SYSTEMMODAL, "Option Selected", "The First (index 0) option is Not selected")
EndIf
If _IEFormElementOptionSelect($oSelect, "midipage.html", -1, "byValue") Then
    MsgBox($MB_SYSTEMMODAL, "Option Selected", "The option with value 'midipage.html' is selected")
Else
    MsgBox($MB_SYSTEMMODAL, "Option Selected", "The option with value 'midipage.html' is NOT selected")
EndIf

_IEQuit($oIE)


Function _IEFormElementRadioSelect

Function Reference

_IEFormElementRadioSelect

Set the value of a specified form element

#include <IE.au3>
_IEFormElementRadioSelect ( ByRef $oObject, $sString, $sName [, $iSelect = 1 [, $sMode = "byValue" [, $iFireEvent = 1]]] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Form object
$sString | Value used to match element - treatment based on $sMode
$sName | Name or Id of Radio Group
$iSelect [optional] specifies whether element should be selected or deselected
-1 = Return selected state
0 = Unselect the element
1 = (Default) Select the element
$sMode [optional] specifies search mode
"byValue" = (Default) value of the radio you wish to select
"byIndex" = 0-based index of radio you wish to select
$iFireEvent [optional] specifies whether to fire OnChange and OnClick events after changing value
0 = do not fire OnChange or OnClick event after setting value
1 = (Default) fire OnChange and OnClick events after setting value

Return Value

Success: | the current selected state if $iSelect = -1, else returns 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 5 ($_IEStatus_InvalidValue) - Invalid Value 7 ($_IEStatus_NoMatch) - No Match
@extended: | Contains invalid parameter number

Remarks

The $iFireEvent parameter is significant only if the form element has an onChange event associated with it.

$sName is a mandatory parameter for this function.
Radio buttons are operated upon in groups sharing the same name.
No more than one element within a group may be selected at a given time - when one item is selected, all others are deselected.

Related

_IEFormElementCheckBoxSelect, _IEFormElementGetValue, _IEFormElementOptionSelect, _IEFormElementSetValue

Example

Example 1

; Open a browser with the form example, get reference to form, select
; each radio button byValue, then deselect the last item leaving none selected.

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
_IEAction($oForm, "focus")
For $i = 1 To 3
    _IEFormElementRadioSelect($oForm, "vehicleAirplane", "radioExample", 1, "byValue")
    Sleep(1000)
    _IEFormElementRadioSelect($oForm, "vehicleTrain", "radioExample", 1, "byValue")
    Sleep(1000)
    _IEFormElementRadioSelect($oForm, "vehicleBoat", "radioExample", 1, "byValue")
    Sleep(1000)
    _IEFormElementRadioSelect($oForm, "vehicleCar", "radioExample", 1, "byValue")
    Sleep(1000)
    _IEFormElementRadioSelect($oForm, "vehicleCar", "radioExample", 0, "byValue")
    Sleep(1000)
Next

_IEQuit($oIE)

Example 2

; Open a browser with the form example, get reference to form, select
; each radio button byIndex, then deselect the last item leaving none selected.
; Note: You will likely need to scroll down on the page to see the changes

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
For $i = 1 To 3
    _IEFormElementRadioSelect($oForm, 3, "radioExample", 1, "byIndex")
    Sleep(1000)
    _IEFormElementRadioSelect($oForm, 2, "radioExample", 1, "byIndex")
    Sleep(1000)
    _IEFormElementRadioSelect($oForm, 1, "radioExample", 1, "byIndex")
    Sleep(1000)
    _IEFormElementRadioSelect($oForm, 0, "radioExample", 1, "byIndex")
    Sleep(1000)
    _IEFormElementRadioSelect($oForm, 0, "radioExample", 0, "byIndex")
    Sleep(1000)
Next

_IEQuit($oIE)


Function _IEFormElementSetValue

Function Reference

_IEFormElementSetValue

Set the value of a specified Form Element

#include <IE.au3>
_IEFormElementSetValue ( ByRef $oObject, $sNewValue [, $iFireEvent = 1] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Form Element object
$sNewValue | The new value to be set into the Form Element
$iFireEvent | [optional] specifies whether to fire an OnChange event after changing value 0 = Do not fire OnChange or OnClick event after setting value 1 = (Default) fire OnChange and OnClick event after setting value

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 2 ($_IEStatus_COMError) - COM Error in Object reference 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type
@extended: | Contains invalid parameter number

Remarks

While all Form Elements have a value, only text oriented elements use their value attribute in an obvious fashion (type text, textarea, hidden, password and file).
The value of other form elements does not affect what is displayed in the user interface, but rather the value that is returned by the element when it is selected or activated.

See _IEFormElementOptionSelect(), _IEFormElementCheckBoxSelect(), _IEFormElementRadioSelect() and _IEFormImageClick() for more information.

Note: You cannot use _IEFormElementSetValue() to set the value of an INPUT TYPE=FILE element. Browser security restrictions prevent this element from being scripted. See the example below for a workaround.

Related

_IEFormElementCheckBoxSelect, _IEFormElementGetCollection, _IEFormElementGetObjByName, _IEFormElementGetValue, _IEFormElementOptionSelect, _IEFormElementRadioSelect

Example

Example 1

; Open a browser with the form example, set the value of a text form element

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
Local $oText = _IEFormElementGetObjByName($oForm, "textExample")
_IEFormElementSetValue($oText, "Hey! This works!")

Example 2

; Get a reference to a specific form element and set its value.
; In this case, submit a query to the Google search engine

#include <IE.au3>

Local $oIE = _IECreate("http://www.google.com")
Local $oForm = _IEFormGetCollection($oIE, 0)
Local $oQuery = _IEFormElementGetCollection($oForm, 4)
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
_IEFormSubmit($oForm)

Example 3

; Set the value of an INPUT TYPE=TEXT element using Send()

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
Local $oInputFile = _IEFormElementGetObjByName($oForm, "textExample")

; Assign input focus to the field and then send the text string
_IEAction($oInputFile, "focus")

; Select existing content so it will be overwritten.
_IEAction($oInputFile, "selectall")

Send("This works")

Example 4

; Set the value of an INPUT TYPE=TEXT element on an invisible
; window using ControlSend()

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IE_Example("form")

; Hide the browser window to demonstrate sending text to invisible window
_IEAction($oIE, "invisible")

Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
Local $oInputFile = _IEFormElementGetObjByName($oForm, "textExample")

; Assign input focus to the field and then send the text string
_IEAction($oInputFile, "focus")

; Select existing content so it will be overwritten.
_IEAction($oInputFile, "selectall")

; Get a handle to the IE window.
Local $hIE = _IEPropertyGet($oIE, "hwnd")
ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "This works")

_IEAction($oIE, "visible")
MsgBox($MB_SYSTEMMODAL, "Success", "Value set to 'This works'")


Function _IEFormGetCollection

Function Reference

_IEFormGetCollection

Returns a collection object variable representing the Forms in the document or a single form by index

#include <IE.au3>
_IEFormGetCollection ( ByRef $oObject [, $iIndex = -1] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Window, Frame or iFrame object
$iIndex | [optional] specifies whether to return a collection or indexed instance 0 or positive integer returns an indexed instance -1 = (Default) returns a collection

Return Value

Success: | an object variable with a collection of all forms in the document, @extended = form count.
Failure: | sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 5 ($_IEStatus_InvalidValue) - Invalid Value 7 ($_IEStatus_NoMatch) - No Match
@extended: | Contains invalid parameter number

Related

_IEFormGetObjByName, _IEFormReset, _IEFormSubmit

Example

Example 1

; Get a reference to a specific form by 0-based index,
; in this case the first form on the page

#include <IE.au3>

Local $oIE = _IECreate("http://www.google.com")
Local $oForm = _IEFormGetCollection($oIE, 0)
Local $oQuery = _IEFormElementGetCollection($oForm, 4)
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
_IEFormSubmit($oForm)

Example 2

; Get a reference to the collection of forms on a page,
; and then loop through them displaying information for each

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IECreate("http://www.autoitscript.com")
Local $oForms = _IEFormGetCollection($oIE)
MsgBox($MB_SYSTEMMODAL, "Forms Info", "There are " & @extended & " form(s) on this page")
For $oForm In $oForms
    MsgBox($MB_SYSTEMMODAL, "Form Info", $oForm.name)
Next

Example 3

; Get a reference to the collection of forms on a page,
; and then loop through them displaying information for each
; demonstrating use of form index

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IECreate("http://www.autoitscript.com")
Local $oForms = _IEFormGetCollection($oIE)
Local $iNumForms = @extended
MsgBox($MB_SYSTEMMODAL, "Forms Info", "There are " & $iNumForms & " forms on this page")
Local $oForm
For $i = 0 To $iNumForms - 1
    $oForm = _IEFormGetCollection($oIE, $i)
    MsgBox($MB_SYSTEMMODAL, "Form Info", $oForm.name)
Next


Function _IEFormGetObjByName

Function Reference

_IEFormGetObjByName

Returns an object reference to a Form by name

#include <IE.au3>
_IEFormGetObjByName ( ByRef $oObject, $sName [, $iIndex = 0] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Window or Frame object
$sName | Specifies the name of the Form you wish to match
$iIndex | [optional] If Form name occurs more than once, specifies instance by 0-based index 0 (Default) or positive integer returns an indexed instance -1 returns a collection of the specified Forms

Return Value

Success: | an object variable pointing to the Form object, @extended = form count.
Failure: | sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 7 ($_IEStatus_NoMatch) - No Match
@extended: | Contains invalid parameter number

Remarks

If the desired form does not have a name or ID, _IEFormGetCollection() to get a reference by index.

Related

_IEFormGetCollection, _IEFormReset, _IEFormSubmit

Example

; Get a reference to a specific form by name.  In this case, submit a query
; to the Google search engine.  Note that the names of the form and form
; elements can be found by viewing the page HTML source

#include <IE.au3>

Local $oIE = _IECreate("http://www.google.com")
Local $oForm = _IEFormGetObjByName($oIE, "gbqf")
Local $oQuery = _IEFormElementGetObjByName($oForm, "q")
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
_IEFormSubmit($oForm)


Function _IEFormImageClick

Function Reference

_IEFormImageClick

Simulate a mouse click on an <input type=image>. Match by sub-string match of alt text, name or src

#include <IE.au3>
_IEFormImageClick ( ByRef $oObject, $sLinkText [, $sMode = "src" [, $iIndex = 0 [, $iWait = 1]]] )

Parameters

$oObject | Object variable of any DOM element (will be converted to the associated document object)
$sLinkText | Value used to match element - treatment based on $sMode
$sMode [optional] specifies search mode
"src" = (Default) match the url of the image
"id" = match the id of the image (see remarks)
"alt" = match the alternate text of the image
$iIndex | [optional] If the img text occurs more than once, specifies which instance you want by 0-based index
$iWait [optional] specifies whether to wait for page to load before returning
0 = Return immediately, not waiting for page to load
1 = (Default) Wait for page load to complete before returning

Return Value

Success: | none.
Failure: | 0 or -1 and sets the @error flag to non-zero.
@error: | 1 ($_IEStatus_GeneralError) - General Error 2 ($_IEStatus_COMError) - COM Error in Object reference 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 5 ($_IEStatus_InvalidValue) - Invalid Value 6 ($_IEStatus_LoadWaitTimeout) - Load Wait Timeout 7 ($_IEStatus_NoMatch) - No Match 8 ($_IEStatus_AccessIsDenied) - Access Is Denied 9 ($_IEStatus_ClientDisconnected) - Client Disconnected
@extended: | Contains invalid parameter number

Remarks

The <input type=image> form element is handled differently from all others.
It is not recognized by Internet Explorer as a member of the form element collection and this function therefore gives you other means of getting a reference to it within the document using src, name or alt strings.
Regardless of the object passed to this function, it looks for the form element within the full document context.

"name" is no more supported when using HTLM5 but still accepted and equivalent to "id" for HTML5 pages.

Related

_IEImgClick, _IEImgGetCollection, _IELoadWait

Example

Example 1

; Open a browser with the form example, click on the
; <input type=image> form element with matching alt text

#include <IE.au3>

Local $oIE = _IE_Example("form")
_IEFormImageClick($oIE, "AutoIt Homepage", "alt")

Example 2

; Open a browser with the form example, click on the <input type=image>
; form element with matching img source URL (sub-string)

#include <IE.au3>

Local $oIE = _IE_Example("form")
_IEFormImageClick($oIE, "autoit_6_240x100.jpg", "src")

Example 3

; Open a browser with the form example, click on the
; <input type=image> form element with matching name

#include <IE.au3>

Local $oIE = _IE_Example("form")
_IEFormImageClick($oIE, "imageExample", "name")


Function _IEFormReset

Function Reference

_IEFormReset

Reset a specified Form setting the values back to their loaded defaults

#include <IE.au3>
_IEFormReset ( ByRef $oObject )

Parameters

$oObject Object variable of an InternetExplorer.Application, Form object

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 2 ($_IEStatus_COMError) - COM Error in Object reference 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type
@extended: | Contains invalid parameter number

Related

_IEFormGetCollection, _IEFormGetObjByName, _IEFormSubmit

Example

; Open a browser with the form example, fill in a form field and
; reset the form back to default values

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
Local $oText = _IEFormElementGetObjByName($oForm, "textExample")
_IEFormElementSetValue($oText, "Hey! It works!")
Sleep(2000)
_IEFormReset($oForm)


Function _IEFormSubmit

Function Reference

_IEFormSubmit

Submit a specified Form

#include <IE.au3>
_IEFormSubmit ( ByRef $oObject [, $iWait = 1] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Form object
$iWait | [optional] specifies whether to wait for page to load before returning 0 = Return immediately, not waiting for page to load 1 = (Default) Wait for page load to complete before returning

Return Value

Success: | None.
Failure: | 0 or -1 and sets the @error flag to non-zero.
@error: | 1 ($_IEStatus_GeneralError) - General Error 2 ($_IEStatus_COMError) - COM Error in Object reference 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 6 ($_IEStatus_LoadWaitTimeout) - Load Wait Timeout 8 ($_IEStatus_AccessIsDenied) - Access Is Denied 9 ($_IEStatus_ClientDisconnected) - Client Disconnected
@extended: | Contains invalid parameter number

Remarks

For many HTML forms it is not sufficient to use _IEFormSubmit() because there is often custom JavaScript tied to an onClick event for its Submit button.
In these cases you'll need to simulate a click of the submit button instead of using _IEFormSubmit(). See the example for the "click" action of _IEAction().
As well, some form processing relies on the "value" of the submit button being passed along with the rest of the form data (often when there is more than one submit button in the form and they are designed to trigger different results).
This function will not result in a submit button value being passed. The solution is to use the "click" action of _IEAction() as above.
If you experience trouble with the automatic _IELoadWait() called by default, please set $iWait parameter to 0 and call _IELoadWait() from your script, passing it the InternetExplorer object.

Related

_IEFormElementGetCollection, _IEFormElementGetObjByName, _IEFormGetCollection, _IEFormGetObjByName, _IEFormReset, _IELoadWait

Example

Example 1

; Open a browser with the form example, fill in a form field and submit the form

#include <IE.au3>

Local $oIE = _IE_Example("form")
Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
Local $oText = _IEFormElementGetObjByName($oForm, "textExample")
_IEFormElementSetValue($oText, "Hey! It works!")
Sleep(2000)
_IEFormSubmit($oForm)

Example 2

; Get a reference to a specific form element and set its value.
; In this case, submit a query to the Google search engine

#include <IE.au3>

Local $oIE = _IECreate("http://www.google.com")
Local $oForm = _IEFormGetCollection($oIE, 0)
Local $oQuery = _IEFormElementGetCollection($oForm, 4)
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
Sleep(2000)
_IEFormSubmit($oForm)

Example 3

; Get a reference to a specific form element and set its value.
; Call _IELoadWait manually if the default _IELoadWait experiences trouble.

#include <IE.au3>

Local $oIE = _IECreate("http://www.google.com")
Local $oForm = _IEFormGetCollection($oIE, 0)
Local $oQuery = _IEFormElementGetCollection($oForm, 4)
_IEFormElementSetValue($oQuery, "AutoIt IE.au3")
_IEFormSubmit($oForm, 0)
_IELoadWait($oIE)


Function _IEFrameGetCollection

Function Reference

_IEFrameGetCollection

Returns a collection object containing the frames in a FrameSet or the iFrames on a normal page or a single Frame or iFrame by index

#include <IE.au3>
_IEFrameGetCollection ( ByRef $oObject [, $iIndex = -1] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Window or Frame object
$iIndex | [optional] specifies whether to return a collection or indexed instance 0 or positive integer returns an indexed instance -1 = (Default) returns a collection

Return Value

Success: | an object variable containing the Frames collection, @extended = Frame count.
Failure: | sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 5 ($_IEStatus_InvalidValue) - Invalid Value 7 ($_IEStatus_NoMatch) - No Match
@extended: | Contains invalid parameter number

Remarks

Although MSDN documents the return value for this function as a collection object, it cannot be looped through with a For...In...Next loop like a standard collection object.
You must instead step through the collection by index - see example.

Related

_IEFrameGetObjByName, _IEIsFrameSet

Example

; Open frameset example, get collection of frames
; and loop through them displaying their source URL's

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IE_Example("frameset")
Local $oFrames = _IEFrameGetCollection($oIE)
Local $iNumFrames = @extended
Local $sTxt = $iNumFrames & " frames found" & @CRLF & @CRLF
Local $oFrame = 0
For $i = 0 To ($iNumFrames - 1)
    $oFrame = _IEFrameGetCollection($oIE, $i)
    $sTxt &= _IEPropertyGet($oFrame, "innertext") & @CRLF
Next
MsgBox($MB_SYSTEMMODAL, "Frames Info", $sTxt)

_IEQuit($oIE)


Function _IEFrameGetObjByName

Function Reference

_IEFrameGetObjByName

Returns an object reference to a Frame or iFrame by name

#include <IE.au3>
_IEFrameGetObjByName ( ByRef $oObject, $sName )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Window or Frame object
$sName | Name of the Frame you wish to match

Return Value

Success: | an object variable pointing to the Window object in a Frame, @extended = Frame count.
Failure: | sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 7 ($_IEStatus_NoMatch) - No Match
@extended: | Contains invalid parameter number

Remarks

The object returned by this function is a window object which allows access to the document contained within.
You may also want to access the frame or iframe tag and its properties - to do this, use _IETagNameGetCollection().

Related

_IEFrameGetCollection

Example

; Open iFrame example, get a reference to the iFrame
; with a name of "iFrameTwo" and replace its body HTML

#include <IE.au3>

Local $oIE = _IE_Example("iframe")
Local $oFrame = _IEFrameGetObjByName($oIE, "iFrameTwo")
_IEBodyWriteHTML($oFrame, "Hello <b><font color=red>iFrame!</font></b>")
_IELoadWait($oFrame)


Function _IEGetObjById

Function Reference

_IEGetObjById

Returns an object variable by id

#include <IE.au3>
_IEGetObjById ( ByRef $oObject, $sID )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Window or Frame object
$sID | Specifies id of the object you wish to match

Return Value

Success: | an object variable pointing to the specified Object.
Failure: | sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 7 ($_IEStatus_NoMatch) - No Match

Remarks

This function will return an object reference to any object in the document with a specified id or name.
DOM elements can have Name or ID attributes or both.
A specific ID can be assigned to only a single element while a specific Name can be assigned to multiple elements.
In Internet Explorer, the Name and ID namespaces are shared.

Related

_IEGetObjByName

Example

; Open a browser to the basic example, get an object reference
; to the DIV element with the ID "line1". Display the innerText
; of this element to the console.

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IE_Example("basic")
Local $oDiv = _IEGetObjById($oIE, "line1")

MsgBox($MB_SYSTEMMODAL, "Line1", $oDiv.innertext)


Function _IEGetObjByName

Function Reference

_IEGetObjByName

Returns an object variable by name

#include <IE.au3>
_IEGetObjByName ( ByRef $oObject, $sName [, $iIndex = 0] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Window or Frame object
$sName | Specifies name of the object you wish to match
$iIndex | [optional] If name occurs more than once, specifies instance by 0-based index 0 (Default) or positive integer returns an indexed instance -1 returns a collection of the specified objects

Return Value

Success: | an object variable pointing to the specified Object, @extended = specified object count.
Failure: | sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 7 ($_IEStatus_NoMatch) - No Match
@extended: | Contains invalid parameter number

Remarks

This function will return an object reference to any object in the document with a specified name or id.
DOM elements can have Name or ID attributes or both.
A specific ID can be assigned to only a single element while a specific Name can be assigned to multiple elements.
In Internet Explorer, the Name and ID namespaces are shared.

Related

_IEGetObjById

Example

; Open a browser to the form example, get an object reference
; to the element with the name "ExampleForm".  In this case the
; result is identical to using $oForm = _IEFormGetObjByName($oIE, "ExampleForm")

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IE_Example("form")
Local $oForm = _IEGetObjByName($oIE, "ExampleForm")
MsgBox($MB_SYSTEMMODAL, "ExampleForm", _IEPropertyGet($oForm, "innertext") & @CRLF)


Function _IEHeadInsertEventScript

Function Reference

_IEHeadInsertEventScript

Inserts a Javascript into the Head of the document

#include <IE.au3>
_IEHeadInsertEventScript ( ByRef $oObject, $sHTMLFor, $sEvent, $sScript )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Window or Frame object
$sHTMLFor | The HTML element for event monitoring (e.g. "document", "window" or an element ID)
$sEvent | The event to monitor (e.g. "onclick" or "oncontextmenu")
$sScript | Javascript string to be executed

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 2 ($_IEStatus_COMError) - COM Error in Object reference 3 ($_IEStatus_InvalidDataType) - Invalid Data Type
@extended: | Contains invalid parameter number

Remarks

Using ObjEvent(), AutoIt is able to be notified of events via COM, but it manages them asynchronously (rather than synchronously as they are handled in the browser context).
This routine allows you to inject code that is managed inside the browser context.

Note that elements that do not have an ID assigned can still be used by obtaining their "uniqueID" property with _IEPropertyGet()

Related

_IEDocInsertHTML, _IEDocInsertText, _IEPropertyGet

Example

Example 1

; Open a browser with the basic example page, insert an
; event script into the head of the document that creates
; a JavaScript alert when someone clicks on the document

#include <IE.au3>

Local $oIE = _IE_Example("basic")
_IEHeadInsertEventScript($oIE, "document", "onclick", "alert('Someone clicked the document!');")

Example 2

; Open a browser with the basic example page, insert an
; event script into the head of the document that creates
; a JavaScript alert when someone tries to right-click on the
; document and then the event script returns "false" to prevent
; the right-click context menu from appearing

#include <IE.au3>

Local $oIE = _IE_Example("basic")
_IEHeadInsertEventScript($oIE, "document", "oncontextmenu", "alert('No Context Menu');return false")

Example 3

; Open a browser with the basic example page, insert an
; event script into the head of the document that creates a
; JavaScript alert when we are about to navigate away from the
; page and presents the option to cancel the operation.

#include <IE.au3>

Local $oIE = _IE_Example("basic")
_IEHeadInsertEventScript($oIE, "window", "onbeforeunload", _
        "alert('Example warning follows...');return 'Pending changes may be lost';")
_IENavigate($oIE, "www.autoitscript.com")

Example 4

; Open a browser with the basic example page, insert an
; event script into the head of the document that prevents
; selection of text in the document

#include <IE.au3>

Local $oIE = _IE_Example()
_IEHeadInsertEventScript($oIE, "document", "ondrag", "return false;")
_IEHeadInsertEventScript($oIE, "document", "onselectstart", "return false;")

Example 5

; Open a browser with the AutoIt homepage, insert an
; event script into the head of the document that prevents
; navigation when any link is clicked and log the URL of the
; clicked link to the console

#include <IE.au3>

Local $oIE = _IECreate("http://www.autoitscript.com")

Local $oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
    Local $sLinkId = _IEPropertyGet($oLink, "uniqueid")
    If @error Then Exit
    _IEHeadInsertEventScript($oIE, $sLinkId, "onclick", "return false;")
    If @error Then Exit
    ObjEvent($oLink, "_Evt_")
Next

; idle as long as the browser window exists
While WinExists(_IEPropertyGet($oIE, "hwnd"))
    Sleep(100)
WEnd

Func _Evt_onClick()
    Local $o_Link = @COM_EventObj
    ConsoleWrite($o_Link.href & @CRLF)
EndFunc   ;==>_Evt_onClick


Function _IEImgClick

Function Reference

_IEImgClick

Simulate a mouse click on an image. Match by sub-string match of alt text, name, or src

#include <IE.au3>
_IEImgClick ( ByRef $oObject, $sLinkText [, $sMode = "src" [, $iIndex = 0 [, $iWait = 1]]] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Window or Frame object
$sLinkText | Text to match the content of the attribute specified in $sMode
$sMode [optional] specifies search mode
"src" = (Default) match the url of the image
"id" = match the id of the image (see remarks)
"alt" = match the alternate text of the image
$iIndex | [optional] If the img text occurs more than once, specify which instance you want by 0-based index
$iWait [optional] specifies whether to wait for page to load before returning
0 = Return immediately, not waiting for page to load
1 = (Default) Wait for page load to complete before returning

Return Value

Success: | None.
Failure: | 0 or -1 and sets the @error flag to non-zero.
@error: | 1 ($_IEStatus_GeneralError) - General Error 2 ($_IEStatus_COMError) - COM Error in Object reference 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 5 ($_IEStatus_InvalidValue) - Invalid Value 6 ($_IEStatus_LoadWaitTimeout) - Load Wait Timeout 7 ($_IEStatus_NoMatch) - No Match 8 ($_IEStatus_AccessIsDenied) - Access Is Denied 9 ($_IEStatus_ClientDisconnected) - Client Disconnected
@extended: | Contains invalid parameter number

Remarks

"name" is no more supported when using HTLM5 but still accepted and equivalent to "id" for HTML5 pages.

Related

_IEFormImageClick, _IEImgGetCollection, _IELoadWait

Example

Example 1

; Click on IMG by Alt text

#include <IE.au3>

Local $oIE = _IE_Example("basic")
_IEImgClick($oIE, "AutoIt Homepage Image", "alt")

Example 2

; Click on IMG by id

#include <IE.au3>

Local $oIE = _IE_Example("basic")
_IEImgClick($oIE, "AutoItImage", "id") ; "name" is still equivalent for HTML5 pages

Example 3

; Click on IMG by src sub-string

#include <IE.au3>

Local $oIE = _IE_Example("basic")
_IEImgClick($oIE, "autoit_6_240x100.jpg", "src")

Example 4

; Click on IMG by full src string

#include <IE.au3>

Local $oIE = _IE_Example("basic")
_IEImgClick($oIE, "http://www.autoitscript.com/images/autoit_6_240x100.jpg")


Function _IEImgGetCollection

Function Reference

_IEImgGetCollection

Returns a collection object variable representing the IMG tags in the document or a single image by index

#include <IE.au3>
_IEImgGetCollection ( ByRef $oObject [, $iIndex = -1] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Window, Frame or iFrame object
$iIndex | [optional] specifies whether to return a collection or indexed instance 0 or positive integer returns an indexed instance -1 = (Default) returns a collection

Return Value

Success: | an object variable with a collection of all IMG tags in the document, @extended = img count.
Failure: | sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 5 ($_IEStatus_InvalidValue) - Invalid Value 7 ($_IEStatus_NoMatch) - No Match
@extended: | Contains invalid parameter number

Related

_IEFormImageClick, _IEImgClick

Example

Example 1

; Create browser at AutoIt homepage, get a reference to the 5th Image
; on the page (note: the first image is index 0)
; and display information about it

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IECreate("http://www.autoitscript.com/")
Local $oImg = _IEImgGetCollection($oIE, 5)
Local $sInfo = "Src: " & $oImg.src & @CRLF
$sInfo &= "FileName: " & $oImg.nameProp & @CRLF
$sInfo &= "Height: " & $oImg.height & @CRLF
$sInfo &= "Width: " & $oImg.width & @CRLF
$sInfo &= "Border: " & $oImg.border
MsgBox($MB_SYSTEMMODAL, "5th Image Info", $sInfo)

_IEQuit($oIE)

Example 2

; Create browser at AutoIt homepage, get Img collection
; and display src URL for each

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IECreate("http://www.autoitscript.com/")
Local $oImgs = _IEImgGetCollection($oIE)
Local $iNumImg = @extended

Local $sTxt = "There are " & $iNumImg & " images on the page" & @CRLF & @CRLF
For $oImg In $oImgs
    $sTxt &= $oImg.src & @CRLF
Next
MsgBox($MB_SYSTEMMODAL, "Img Info", $sTxt)

_IEQuit($oIE)


Function _IEIsFrameSet

Function Reference

_IEIsFrameSet

Checks to see if the specified Window contains a FrameSet

#include <IE.au3>
_IEIsFrameSet ( ByRef $oObject )

Parameters

$oObject Object variable of an InternetExplorer.Application, Window or Frame object

Return Value

Success: | 1 if the object references a FrameSet page.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 2 ($_IEStatus_COMError) - COM Error in Object reference 3 ($_IEStatus_InvalidDataType) - Invalid Data Type
@extended: | Contains invalid parameter number

Remarks

_IEFrameGetCollection() does not specify whether the referenced frames are part of a FrameSet or whether they are iFrames.
If frames exist on a page and this function return False, then the frames are iFrames.

Related

_IEFrameGetCollection

Example

; Display the frameset example, get frame collection,
; check number of frames, display number of frames or iFrames present

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IE_Example("frameset")
Local $oFrames = _IEFrameGetCollection($oIE)
Local $iNumFrames = @extended
If $iNumFrames > 0 Then
    If _IEIsFrameSet($oIE) Then
        MsgBox($MB_SYSTEMMODAL, "Frame Info", "Page contains " & $iNumFrames & " frames in a FrameSet")
    Else
        MsgBox($MB_SYSTEMMODAL, "Frame Info", "Page contains " & $iNumFrames & " iFrames")
    EndIf
Else
    MsgBox($MB_SYSTEMMODAL, "Frame Info", "Page contains no frames")
EndIf

_IEQuit($oIE)


Function _IELinkClickByIndex

Function Reference

_IELinkClickByIndex

Simulate a mouse click on a link by 0-based index (in source order)

#include <IE.au3>
_IELinkClickByIndex ( ByRef $oObject, $iIndex [, $iWait = 1] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Window or Frame object
$iIndex | 0-based index of the link you wish to match
$iWait | [optional] specifies whether to wait for page to load before returning 0 = Return immediately, not waiting for page to load 1 = (Default) Wait for page load to complete before returning

Return Value

Success: | none.
Failure: | 0 or -1 and sets the @error flag to non-zero.
@error: | 1 ($_IEStatus_GeneralError) - General Error 2 ($_IEStatus_COMError) - COM Error in Object reference 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 6 ($_IEStatus_LoadWaitTimeout) - Load Wait Timeout 7 ($_IEStatus_NoMatch) - No Match 8 ($_IEStatus_AccessIsDenied) - Access Is Denied 9 ($_IEStatus_ClientDisconnected) - Client Disconnected
@extended: | Contains invalid parameter number

Remarks

Not all elements that appear to be links actually are.
It is common practice to attach onClick JavaScript events to other DOM elements to simulate the behavior of links.
To activate such elements, use "click" with _IEAction().

Related

_IELinkClickByText, _IELoadWait

Example

; Open browser with basic example, click on the 3rd link
; on the page (note: the first link is index 0)

#include <IE.au3>

Local $oIE = _IE_Example("basic")
_IELinkClickByIndex($oIE, 2)


Function _IELinkClickByText

Function Reference

_IELinkClickByText

Simulate a mouse click on a link with text sub-string matching the string provided

#include <IE.au3>
_IELinkClickByText ( ByRef $oObject, $sLinkText [, $iIndex = 0 [, $iWait = 1]] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Window or Frame object
$sLinkText | Text displayed on the web page for the desired link to click
$iIndex | [optional] If the link text occurs more than once, specify which instance you want by 0-based index
$iWait | [optional] specifies whether to wait for page to load before returning 0 = Return immediately, not waiting for page to load 1 = (Default) Wait for page load to complete before returning

Return Value

Success: | none.
Failure: | 0 or -1 and sets the @error flag to non-zero.
@error: | 1 ($_IEStatus_GeneralError) - General Error 2 ($_IEStatus_COMError) - COM Error in Object reference 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 6 ($_IEStatus_LoadWaitTimeout) - Load Wait Timeout 7 ($_IEStatus_NoMatch) - No Match 8 ($_IEStatus_AccessIsDenied) - Access Is Denied 9 ($_IEStatus_ClientDisconnected) - Client Disconnected
@extended: | Contains invalid parameter number

Remarks

Not all elements that appear to be links actually are.
It is common practice to attach onClick JavaScript events to other DOM elements to simulate the behavior of links.
To activate such elements, use "click" with _IEAction().

Related

_IELinkClickByIndex, _IELoadWait

Example

Example 1

; Open browser with basic example, click on the link with text "user forum"

#include <IE.au3>

Local $oIE = _IE_Example("basic")
_IELinkClickByText($oIE, "user forum")

Example 2

; Open browser to the AutoIt homepage, loop through the links
; on the page and click on the link with text "overview"
; using a sub-string match.

#include <IE.au3>

Local $oIE = _IECreate("http://www.autoitscript.com")

Local $sMyString = "overview"
Local $oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
    Local $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, $sMyString) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next


Function _IELinkGetCollection

Function Reference

_IELinkGetCollection

Returns a collection object containing all links in the document or a single link by index

#include <IE.au3>
_IELinkGetCollection ( ByRef $oObject [, $iIndex = -1] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Window or Frame object
$iIndex | [optional] specifies whether to return a collection or indexed instance 0 or positive integer returns an indexed instance -1 = (Default) returns a collection

Return Value

Success: | an object collection of all links in the document, @extended = link count?
Failure: | sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 5 ($_IEStatus_InvalidValue) - Invalid Value 7 ($_IEStatus_NoMatch) - No Match
@extended: | Contains invalid parameter number

Remarks

Not all elements that appear to be links actually are.
It is common practice to attach onClick JavaScript events to other DOM elements to simulate the behavior of links.
To activate such elements, use "click" with _IEAction().

Example

; Open browser with basic example, get link collection,
; loop through items and display the associated link URL references

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IE_Example("basic")
Local $oLinks = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended

Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF
For $oLink In $oLinks
    $sTxt &= $oLink.href & @CRLF
Next
MsgBox($MB_SYSTEMMODAL, "Link Info", $sTxt)


Function _IELoadWait

Function Reference

_IELoadWait

Wait for a browser page load to complete before returning

#include <IE.au3>
_IELoadWait ( ByRef $oObject [, $iDelay = 0 [, $iTimeout = -1]] )

Parameters

$oObject | Object variable of an InternetExplorer.Application or DOM element
$iDelay | [optional] Milliseconds to wait before checking status
$iTimeout | [optional] Period of time to wait before exiting function (default = 300000 ms aka 5 min)

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 ($_IEStatus_GeneralError) - General Error 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 6 ($_IEStatus_LoadWaitTimeout) - Load Wait Timeout 8 ($_IEStatus_AccessIsDenied) - Access Is Denied 9 ($_IEStatus_ClientDisconnected) - Client Disconnected
@extended: | Contains invalid parameter number

Remarks

Several IE.au3 functions call _IELoadWait() automatically (e.g. _IECreate(), _IENavigate() etc.).
Most functions that do this also allow you to turn this off with a $fWait parameter if you do not want the wait or if you want to call it yourself.

When document objects or DOM elements are passed to _IELoadWait(), it will check the readyState of the container elements up to and including the parentWindow.

Browser scripting security restrictions may sometimes prevent _IELoadWait() from guaranteeing that a page is fully loaded and can occasionally result in untrapped errors.
In these cases you may need to avoid calling _IELoadWait() and attempt to employ other methods of insuring that the page load has completed.
These methods might include using a Sleep command, examining browser status bar text and other methods. When using functions that call _IELoadWait() for objects other than the InternetExplorer (browser) object, you may also be successful by calling _IELoadWait() for the browser yourself (e.g. _IELoadWait($oIE)).

The most common causes of trouble are page redirects and cross-site scripting security restrictions associated with frames. Page re-writing techniques employed by some applications (e.g. Gmail) can also cause trouble here.

Related

_IEAction, _IEBodyWriteHTML, _IECreate, _IEDocWriteHTML, _IEFormImageClick, _IEFormSubmit, _IEImgClick, _IELinkClickByIndex, _IELinkClickByText, _IELoadWaitTimeout, _IENavigate

Example

; Open the AutoIt forum page, tab to the "View new posts"
; link and activate the link with the enter key.
; Then wait for the page load to complete   before moving on.

#include <IE.au3>

Local $oIE = _IECreate("http://www.autoitscript.com/forum/index.php")
Send("{TAB 12}")
Send("{ENTER}")
_IELoadWait($oIE)


Function _IELoadWaitTimeout

Function Reference

_IELoadWaitTimeout

Retrieve or set the current value in milliseconds _IELoadWait() will try before timing out

#include <IE.au3>
_IELoadWaitTimeout ( [$iTimeout = -1] )

Parameters

$iTimeout [optional] retrieve or specify the number of milliseconds
0 or positive integer sets timeout to this value
-1 = (Default) returns the current timeout value (stored in global variable $__IELoadWaitTimeout)

Return Value

Returns the current timeout value if $iTimeout = -1, else returns 1.

Remarks

There is no way to completely disable the Timeout value.
You can functionally do this however by setting it to a very large positive integer.
The initial timeout value is 30000 ms (5 minutes).

Related

_IELoadWait

Example

Example 1

; Obtain current timeout value

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $iCurrentTimeout = _IELoadWaitTimeout()
MsgBox($MB_SYSTEMMODAL, "_IELoadWaitTimeout", $iCurrentTimeout / 1000 & " sec")

Example 2

; Set timeout to 1 minute (60000 milliseconds)

#include <IE.au3>
#include <MsgBoxConstants.au3>

_IELoadWaitTimeout(60000)

Local $iCurrentTimeout = _IELoadWaitTimeout()
MsgBox($MB_SYSTEMMODAL, "_IELoadWaitTimeout", $iCurrentTimeout / 1000 & " sec")


Function _IENavigate

Function Reference

_IENavigate

Directs an existing browser window to navigate to the specified URL

#include <IE.au3>
_IENavigate ( ByRef $oObject, $sUrl [, $iWait = 1] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Window or Frame object
$sUrl | URL to navigate to (e.g. "http://www.autoitscript.com")
$iWait | [optional] specifies whether to wait for page to load before returning 0 = Return immediately, not waiting for page to load 1 = (Default) Wait for page load to complete before returning

Return Value

Success: | None.
Failure: | 0 or -1 and sets the @error flag to non-zero.
@error: | 1 ($_IEStatus_GeneralError) - General Error 2 ($_IEStatus_COMError) - COM Error in Object reference 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 6 ($_IEStatus_LoadWaitTimeout) - Load Wait Timeout 8 ($_IEStatus_AccessIsDenied) - Access Is Denied 9 ($_IEStatus_ClientDisconnected) - Client Disconnected
@extended: | Contains invalid parameter number

Remarks

This function always returns a value of -1.
This is because the navigate method has no useful return value and therefore nothing can be implied from it.
You will need to employ other methods to determine success or failure of the navigation.

New security in Windows Vista causes a new browser window to be created when a browser is instructed to navigate to a URL in a different security zone.
This occurs as well with the initial creation and navigation initiated with _IECreate(). The new window is a new browser instance and the previous browser object variable no longer points to it.
There are several workarounds:
1) add #RequireAdmin to your code (this is required even if the account is part of the Administrator's Group and will prompt for credentials if necessary),
2) use _IEAttach() to connect to the new browser window
3) add the target website to the Trusted Sites security zone in IE,
4) turn off "Protected Mode" in IE,
or 5) disable UAC. Care must be taken to understand the implications of disabling IE security features when accessing untrusted sites.

Related

_IECreate, _IECreateEmbedded, _IELoadWait

Example

Example 1

; Create a browser window and navigate to a website,
; wait 5 seconds and navigate to another
; wait 5 seconds and navigate to another

#include <IE.au3>

Local $oIE = _IECreate("www.autoitscript.com")
Sleep(5000)
_IENavigate($oIE, "http://www.autoitscript.com/forum/index.php?")
Sleep(5000)
_IENavigate($oIE, "http://www.autoitscript.com/forum/index.php?showforum=9")

Example 2

; Create a browser window and navigate to a website,
; do not wait for page load to complete before moving to next line

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IECreate("www.autoitscript.com", 0)
MsgBox($MB_SYSTEMMODAL, "_IENavigate()", "This code executes immediately")


Function _IEPropertyGet

Function Reference

_IEPropertyGet

Returns a select property of the Browser or DOM element

#include <IE.au3>
_IEPropertyGet ( ByRef $oObject, $sProperty )

Parameters

$oObject | Object variable of an InternetExplorer.Application or DOM element
$sProperty | Property selection (see remarks)

Return Value

Success: | the selected property.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 5 ($_IEStatus_InvalidValue) - Invalid Value
@extended: | Contains invalid parameter number

Remarks

The following tables provide a description of each property available for use.
Some properties to DOM elements, others to the browser.

Browser Properties

Property | Description
"addressbar" | Retrieves a Boolean value indicating whether the browser address bar is visible or hidden.
"browserx" | Retrieves the x-coordinate of the top left corner of a document element, relative to the browser.
"browsery" | Retrieves the y-coordinate of the top left corner of a document element, relative to the browser.
"busy" | Retrieves a Boolean value indicating whether the object is engaged in a navigation or downloading operation.
"contenteditable" | Retrieves a Boolean value that indicates whether the object can be edited with mouse and keyboard.
"fullscreen" | Retrieves a Boolean value that indicates whether the browser is in full-screen or normal window mode.
"height" | Retrieves the height of the browser main window or a document element.
"hwnd" | Retrieves the handle of the Internet Explorer main window. Can be used in most AutoIt Win* functions.
"innerhtml" | Retrieves the rendered HTML of an element excluding the beginning and ending element tags.
"innertext" | Retrieves the rendered Text (but not any tags) of an element. Typically identical to outertext.
"isdisabled" | Retrieves the value indicating whether the user can interact with the object.
"left" | Retrieves the screen coordinate of the left edge of the main window of the object.
"locationname" | Retrieves the name of the resource that Internet Explorer is currently displaying.
"locationurl" | Retrieves the URL of the resource that Internet Explorer is currently displaying.
"menubar" | Retrieves a Boolean value that indicates whether the browser menu bar is visible.
"offline" | Retrieves a Boolean value that indicates whether the browser is currently operating in offline mode.
"outertext" | Retrieves the rendered Text (but not any tags) of an element. Typically identical to innertext.
"outerhtml" | Retrieves the rendered HTML of an element including the beginning and ending element tags.
"readystate" | Retrieves the ready state of the object.
"referrer" | Retrieves a string of the URL of the page from which the current page was accessed (but only if accessed via a link on that page, else the string is null).
"resizable" | Retrieves a value that indicates whether the object can be resized.
"screenx" | Retrieves the x-coordinate of the top left corner of a document object or the browser, relative to the screen.
"screeny" | Retrieves the y-coordinate of the top left corner of a document object or the browser, relative to the screen.
"silent" | Retrieves a value that indicates whether the browser can show dialog boxes.
"statusbar" | Retrieves a value that indicates whether the status bar for the object is visible.
"statustext" | Retrieves the text in the status bar for the object.
"theatermode" | Retrieves a Boolean value indicating whether the browser is in Theater Mode. In theater mode, the browser main window fills the entire screen and displays a toolbar with a minimal set of navigational buttons.
"title" | Retrieves the document title. Note that this is different than the window title which typically starts with the document title, but has additional text specified in the windows registry appended to it.
"toolbar" | Retrieves a Boolean value indicating whether the tool bar of the browser is visible or hidden.
"top" | Retrieves the screen coordinate of the top edge of the main window of the object.
"visible" | Retrieves a value that indicates whether the object is visible or hidden.
"width" | Retrieves the width of the browser main window or a document element.
"uniqueid" | Retrieves an ID assigned by the DOM that is unique among all elements. This can be used in any context that requires an element ID.

Further information for ClientInfo Object can be found at MSDN.

ClientInfo Properties
Property | Description
"appcodename" | Retrieves the code name of the browser (the property has a default value of Mozilla).
"appminorversion" | Retrieves the application's minor version value.
"appname" | Retrieves the name of the browser (the property has a default value of Microsoft Internet Explorer).
"appversion" | Retrieves the platform and version of the browser.
"browserlanguage" | Retrieves the current browser language (the value will be one of these Language Codes).
"cookieenabled" | Retrieves whether client-side persistent cookies are enabled in the browser. Persistent cookies are those that are stored on the client-side computer.
"cpuclass" | Retrieves a string denoting the CPU class (the return values can be found here).
"javaenabled" | Returns whether Java is enabled.
"online" | Retrieves a value indicating whether the system is in global offline mode.
"platform" | Retrieves the name of the user's operating system (the return values can be found here).
"systemlanguage" | Retrieves the default language used by the operating system (the value will be one of these Language Codes).
"useragent" | Retrieves a string equivalent to the HTTP user-agent request header.
"userlanguage" | Retrieves the operating system's natural language setting (the value will be one of these Language Codes).

Related

_IEBodyReadHTML, _IEBodyReadText, _IEBodyWriteHTML, _IEDocInsertHTML, _IEDocInsertText, _IEHeadInsertEventScript, _IEPropertySet

Example

Example 1

; Open a browser with the basic example, check to see if the
; addressbar is visible, if it is turn it off, if it is not turn it on

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IE_Example("basic")
If _IEPropertyGet($oIE, "addressbar") Then
    MsgBox($MB_SYSTEMMODAL, "AddressBar Status", "AddressBar Visible, turning it off")
    _IEPropertySet($oIE, "addressbar", False)
Else
    MsgBox($MB_SYSTEMMODAL, "AddressBar Status", "AddressBar Invisible, turning it on")
    _IEPropertySet($oIE, "addressbar", True)
EndIf

Example 2

; Open a browser with the form example and get a reference to the form
; textarea element.  Get the coordinates and dimensions of the text area,
; outline its shape with the mouse and come to rest in the center

#include <IE.au3>

Local $oIE = _IE_Example("form")

Local $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
Local $oTextArea = _IEFormElementGetObjByName($oForm, "textareaExample")

; Get coordinates and dimensions of the textarea
Local $iScreenX = _IEPropertyGet($oTextArea, "screenx")
Local $iScreenY = _IEPropertyGet($oTextArea, "screeny")
Local $iBrowserX = _IEPropertyGet($oTextArea, "browserx")
Local $iBrowserY = _IEPropertyGet($oTextArea, "browserY")
Local $iWidth = _IEPropertyGet($oTextArea, "width")
Local $iHeight = _IEPropertyGet($oTextArea, "height")

; Outline the textarea with the mouse, come to rest in the center
Local $iMousespeed = 50
MouseMove($iScreenX, $iScreenY, $iMousespeed)
MouseMove($iScreenX + $iWidth, $iScreenY, $iMousespeed)
MouseMove($iScreenX + $iWidth, $iScreenY + $iHeight, $iMousespeed)
MouseMove($iScreenX, $iScreenY + $iHeight, $iMousespeed)
MouseMove($iScreenX, $iScreenY, $iMousespeed)
MouseMove($iScreenX + $iWidth / 2, $iScreenY + $iHeight / 2, $iMousespeed)


Function _IEPropertySet

Function Reference

_IEPropertySet

Set a select property of the Browser or DOM element

#include <IE.au3>
_IEPropertySet ( ByRef $oObject, $sProperty, $vValue )

Parameters

$oObject | Object variable of an InternetExplorer.Application
$sProperty | Property selection (see remarks)
$vValue | The new value to be set into the Browser Property

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 5 ($_IEStatus_InvalidValue) - Invalid Value
@extended: | Contains invalid parameter number

Remarks

The following table provide a description of each property available for use.
Some properties to DOM elements, others to the browser.

Browser Properties

Property | Description
"addressbar" | Specifies whether the address bar of the object is visible or hidden.
"contenteditable" | Specifies a Boolean value that indicates whether the object can be edited with mouse and keyboard.
"height" | Specifies the height of the browser main window.
"innerhtml" | Sets the rendered HTML of an element excluding the beginning and ending element tags.
"innertext" | Sets the rendered Text (but not any tags) of an element. Typically identical to outertext.
"left" | Specifies the screen coordinate of the left edge of the browser main window.
"menubar" | Specifies a Boolean value that indicates whether the browser menu bar is visible.
"offline" | Specifies a Boolean value that indicates whether the browser is currently operating in offline mode.
"outertext" | Sets the rendered Text (but not any tags) of an element. Typically identical to innertext.
"outerhtml" | Sets the rendered HTML of an element including the beginning and ending element tags.
"resizable" | Specifies a Boolean value that indicates whether the object can be resized.
"silent" | Specifies a Boolean value that indicates whether the browser can show dialog boxes.
"statusbar" | Specifies a value that indicates whether the browser status bar is visible.
"statustext" | Specifies the text in the browser status bar.
"theatermode" | Specifies a Boolean value indicating whether the browser is in Theater Mode. In theater mode, the browser main window fills the entire screen and displays a toolbar with a minimal set of navigational buttons.
"title" | Sets the document title. Note that this is different than the window title which typically starts with the document title, but has additional text specified in the windows registry appended to it.
"toolbar" | Specifies a Boolean value indicating whether the tool bar of the browser is visible or hidden.
"top" | Specifies the screen coordinate of the top edge of the browser main window.
"width" | Specifies the width of the browser main window.

Related

_IEAction, _IEBodyWriteHTML, _IEDocInsertHTML, _IEDocInsertText, _IEPropertyGet

Example

; Open a browser with the basic example, check to see if the
; addressbar is visible, if it is not turn it on. Then change
; the text displayed in the statusbar

#include <IE.au3>

Local $oIE = _IE_Example("basic")
If Not _IEPropertyGet($oIE, "statusbar") Then _IEPropertySet($oIE, "statusbar", True)
_IEPropertySet($oIE, "statustext", "Look What I can Do")
Sleep(2000)
_IEPropertySet($oIE, "statustext", "I can change the status text")


Function _IEQuit

Function Reference

_IEQuit

Close the browser and remove the object reference to it

#include <IE.au3>
_IEQuit ( ByRef $oObject )

Parameters

$oObject Object variable of an InternetExplorer.Application

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 2 ($_IEStatus_COMError) - COM Error in Object reference 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type
@extended: | Contains invalid parameter number

Remarks

_IEQuit() is particularly important when creating or working with invisible instances of Internet Explorer.
When AutoIt exits when working with visible instances of a browser, the browser continues to run and the visible window is left for the user to manage.
When the browser instance is invisible however, when AutoIt exits the browser process is left running and there is no user interface to interact with and an orphan Iexplore.exe process is left running on the system.
It is therefore good practice to call _IEQuit() whenever the browser process is not needed after or just before the script exists.

_IEQuit() is not allowed with embedded browser objects created with _IECreateEmbedded().
The browser processes associated with those objects will close when their parent GUI window is destroyed.

Related

_IEAttach, _IECreate

Example

; Create an invisible browser window, navigate to a
; website, retrieve some information and Quit

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IECreate("http://sourceforge.net")
; Display the innerText on an element on the page with a name of "sfmarquee"
Local $oMarquee = _IEGetObjByName($oIE, "sfmarquee")
If IsObj($oMarquee) Then
    MsgBox($MB_SYSTEMMODAL, "SourceForge Information", $oMarquee.innerText)
Else
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), "SourceForge Information", "NO sfmarquee FOUND !!!")
EndIf
_IEQuit($oIE)


Function _IETableGetCollection

Function Reference

_IETableGetCollection

Returns a collection object variable representing all the tables in a document or a single table by index

#include <IE.au3>
_IETableGetCollection ( ByRef $oObject [, $iIndex = -1] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Window or Frame object
$iIndex | [optional] specifies whether to return a collection or indexed instance 0 or positive integer returns an indexed instance -1 = (Default) returns a collection

Return Value

Success: | an object collection of all tables in the document, @extended = table count.
Failure: | sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 5 ($_IEStatus_InvalidValue) - Invalid Value 7 ($_IEStatus_NoMatch) - No Match
@extended: | Contains invalid parameter number

Related

_IETableWriteToArray

Example

Example 1

; Open a browser with the table example, get a reference to the first table
; on the page (index 0) and read its contents into a 2-D array

#include <Array.au3>
#include <IE.au3>

Local $oIE = _IE_Example("table")
Local $oTable = _IETableGetCollection($oIE, 0)
Local $aTableData = _IETableWriteToArray($oTable)

_ArrayDisplay($aTableData)

_IEQuit($oIE)

Example 2

; Open a browser with the table example, get a reference to the
; table collection and display the number of tables on the page

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IE_Example("table")
Local $oTable = _IETableGetCollection($oIE)
Local $iNumTables = @extended
MsgBox($MB_SYSTEMMODAL, "Table Info", "There are " & $iNumTables & " tables on the page")

_IEQuit($oIE)


Function _IETableWriteToArray

Function Reference

_IETableWriteToArray

Reads the contents of a Table into an array

#include <IE.au3>
_IETableWriteToArray ( ByRef $oObject [, $bTranspose = False] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Table object
$bTranspose | [optional] Boolean value specifying whether to swap the rows and columns in the output array

Return Value

Success: | a 2-dimensional array containing the contents of the Table.
Failure: | sets the @error flag to non-zero.
@error: | 2 ($_IEStatus_COMError) - COM Error in Object reference 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type
@extended: | Contains invalid parameter number

Remarks

When table cells span multiple columns or rows, blank array elements are added to properly align the results.
Data in spanning cells will be in the left or uppermost array elements.

Tables are often nested in HTML documents.
If all of your data is unexpectedly returned in a single array element, you may need to reference a more deeply nested table to this function.

Related

_IETableGetCollection

Example

Example 1

; Open a browser with the table example, get a reference to the second table
; on the page (index 1) and read its contents into a 2-D array

#include <Array.au3>
#include <IE.au3>

Local $oIE = _IE_Example("table")
Local $oTable = _IETableGetCollection($oIE, 1)
Local $aTableData = _IETableWriteToArray($oTable)

_ArrayDisplay($aTableData)

_IEQuit($oIE)

Example 2

; Same as Example 1, except transpose the output array and display
; the results with _ArrayDisplay()

#include <Array.au3>
#include <IE.au3>

Local $oIE = _IE_Example("table")
Local $oTable = _IETableGetCollection($oIE, 1)
Local $aTableData = _IETableWriteToArray($oTable, True)
_ArrayDisplay($aTableData)

_IEQuit($oIE)


Function _IETagNameAllGetCollection

Function Reference

_IETagNameAllGetCollection

Returns a collection object all elements in the document or document hierarchy in source order or a single element by index

#include <IE.au3>
_IETagNameAllGetCollection ( ByRef $oObject [, $iIndex = -1] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Window, Frame, iFrame or any object in the DOM
$iIndex | [optional] specifies whether to return a collection or indexed instance 0 or positive integer returns an indexed instance -1 = (Default) returns a collection

Return Value

Success: | an object variable containing the Tag collection, @extended = Tag count.
Failure: | sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 5 ($_IEStatus_InvalidValue) - Invalid Value 7 ($_IEStatus_NoMatch) - No Match
@extended: | Contains invalid parameter number

Remarks

The DOM is hierarchical, so if the object passed is the document object, all elements in the document are returned.
If the object passed in is an object inside the document (e.g. a TABLE object), then only the elements inside that object are returned.

Related

_IETagNameGetCollection

Example

; Open a browser with the basic example, get the collection
; of all elements and display the tagname and innerText of each

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IE_Example("basic")
Local $oElements = _IETagNameAllGetCollection($oIE)
For $oElement In $oElements
    If $oElement.id Then MsgBox($MB_SYSTEMMODAL, "Element Info", "Tagname: " & $oElement.tagname & @CRLF & "id: " & $oElement.id & @CRLF & "innerText: " & $oElement.innerText)
Next

_IEQuit($oIE)


Function _IETagNameGetCollection

Function Reference

_IETagNameGetCollection

Returns a collection object of all elements in the object with the specified TagName or a single element by index

#include <IE.au3>
_IETagNameGetCollection ( ByRef $oObject, $sTagName [, $iIndex = -1] )

Parameters

$oObject | Object variable of an InternetExplorer.Application, Window, Frame, iFrame or any object in the DOM
$sTagName | TagName of collection to return (e.g. IMG, TR etc.)
$iIndex | [optional] specifies whether to return a collection or indexed instance 0 or positive integer returns an indexed instance -1 = (Default) returns a collection

Return Value

Success: | an object variable containing the specified Tag collection, @extended = specified Tag count.
Failure: | sets the @error flag to non-zero.
@error: | 3 ($_IEStatus_InvalidDataType) - Invalid Data Type 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type 5 ($_IEStatus_InvalidValue) - Invalid Value 7 ($_IEStatus_NoMatch) - No Match
@extended: | Contains invalid parameter number

Remarks

The DOM is hierarchical, so if the object passed is the document object, the specified elements in the document are returned.
If the object passed is an object inside the document (e.g. a TABLE object), then only the specified elements inside that object are returned.

Related

_IETagNameAllGetCollection

Example

; Open a browser with the form example, get the collection
; of all INPUT tags and display the formname and type of each

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IE_Example("form")
Local $oInputs = _IETagNameGetCollection($oIE, "input")
Local $sTxt = ""
For $oInput In $oInputs
    $sTxt &= $oInput.type & @CRLF
Next
MsgBox($MB_SYSTEMMODAL, "Form Input Type", "Form: " & $oInput.form.name & @CRLF & @CRLF & "         Types :" & @CRLF & $sTxt)

_IEQuit($oIE)


User Defined Functions

Inet user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <Inet.au3>.

User Defined Function | Description
_GetIP | Get public IP address of a network/computer
_INetExplorerCapable | Converts a string to IE(Internet Explorer) capable line
_INetGetSource | Gets the source from an URL without writing a temp file
_INetMail | Opens default user's mail client with given address, subject, and body
_INetSmtpMail | Sends an email without using an external email program
_TCPIpToName | Resolves IP address to Hostname(s)


Function _GetIP

Function Reference

_GetIP

Get public IP address of a network/computer

#include <Inet.au3>
_GetIP ( )

Return Value

Success: | the public IP address. (See remarks.)
Failure: | -1 and sets the @error to non-zero.

Remarks

This only returns the public IP address of a computer or network (i.e. the public IP on the WAN link of your NAT router). The address is determined by accessing an external IP discovery web site. The sites used are http://checkip.dyndns.org, http://www.myexternalip.com/raw and http://www.bot.whatismyipaddress.com.

To reduce overloading the IP discovery sites a 5 minute timer is used between each function call. If _GetIP() is used during this 5 minute period, the previous IP is returned and @extended set to 1.

Example

#include <Inet.au3>
#include <MsgBoxConstants.au3>

Local $sPublicIP = _GetIP()
MsgBox($MB_SYSTEMMODAL, "", "Your external IP address is: " & $sPublicIP)


Function _INetExplorerCapable

Function Reference

_INetExplorerCapable

Converts a string to IE(Internet Explorer) capable line

#include <Inet.au3>
_INetExplorerCapable ( $sIEString )

Parameters

$sIEString String to be converted

Return Value

Success: | the converted string.
Failure: | an empty string and sets the @error flag to non-zero.

Remarks

This converts IE uncapable characters to '%' and their hex value.

Example

#include <Inet.au3>
#include <MsgBoxConstants.au3>

MsgBox($MB_SYSTEMMODAL, "", _INetExplorerCapable(InputBox("", "Enter a string to convert into browser readable text")))


Function _INetGetSource

Function Reference

_INetGetSource

Gets the source from an URL without writing a temp file

#include <Inet.au3>
_INetGetSource ( $sURL [, $bString = True] )

Parameters

$sURL | (The URL of the site.) eg 'http://www.autoitscript.com'
$bString | [optional] If True the data is returned in string format, otherwise binary format.

Return Value

Success: | the read string and sets @extended to the number of bytes returned.
Failure: | an empty string and and sets the @error flag to non-zero.

Related

_IEDocReadHTML

Example

#include <Inet.au3>
ConsoleWrite(_INetGetSource('http://www.autoitscript.com'))


Function _INetMail

Function Reference

_INetMail

Opens default user's mail client with given address, subject, and body

#include <Inet.au3>
_INetMail ( $sMailTo, $sMailSubject, $sMailBody )

Parameters

$sMailTo | Address for the E-Mail
$sMailSubject | Subject for the E-Mail
$sMailBody | Body for the E-Mail

Return Value

Success: | the process identifier for the E-Mail client.
Failure: | 0 and sets the @error flag to non-zero.

Related

_INetSmtpMail

Example

#include <Inet.au3>
#include <MsgBoxConstants.au3>

Local $sAddress = InputBox('Address', 'Enter the E-Mail address to send message to')
Local $sSubject = InputBox('Subject', 'Enter a subject for the E-Mail')
Local $sBody = InputBox('Body', 'Enter the body (message) of the E-Mail')
MsgBox($MB_SYSTEMMODAL, 'E-Mail has been opened', 'The E-Mail has been opened and process identifier for the E-Mail client is ' & _INetMail($sAddress, $sSubject, $sBody))


Function _INetSmtpMail

Function Reference

_INetSmtpMail

Sends an email without using an external email program

#include <Inet.au3>
_INetSmtpMail ( $sSMTPServer, $sFromName, $sFromAddress, $sToAddress [, $sSubject = "" [, $aBody = "" [, $sEHLO = "" [, $sFirst = "" [, $bTrace = 0]]]]] )

Parameters

$sSMTPServer | Smtp server the eMail is to be sent though May be either alpha or a numeric IP address. In order to fight spam, many ISPs require this to be their server. eg "smtp.ispdomain.com", "mail.ispdomain.com" or "192.168.1.1"
$sFromName | The name you wish the message to appear to be sent from. eg "Bob Smith"
$sFromAddress | The email address you wish the message to appear to be sent from. eg "bob.smith@mydomain.com".
$sToAddress | The email address the message is to go to. eg "jane.brown@yourdomain.com"
$sSubject | [optional] The subject of the email.
$aBody | [optional] The body of the email as a single dimensional array of strings. Each value in the array will be terminated with a @CRLF in the email.
$sEHLO | [optional] identifier for the smtp server connection (by default @ComputerName). If Smtp server require a "EHLO" string just set the string to "EHLO " & @ComputerName.
$sFirst | [optional] string sent before helo for the smtp server connection (by default {SPACE}). To not send any character this parameter must equal -1, some SMTP server required it.
$bTrace | [optional] trace the dialog in a splash window

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 2 - Unable to start TCP 3 - Unable to resolve IP 4 - Unable to create socket 5x - Cannot open SMTP session. x indicates the index number of last command issued to the SMTP server. 50x - Cannot send body. x indicates the line number of $aBody (first line is 0). 5000 - Cannot close SMTP session

Remarks

This function sends an email directly through an SMTP server without the use of a third party email client.

Related

_INetMail

Example

#include <Inet.au3>
#include <MsgBoxConstants.au3>

Local $s_SmtpServer = "mysmtpserver.com.au"
Local $s_FromName = "My Name"
Local $s_FromAddress = "From eMail Address"
Local $s_ToAddress = "To eMail Address"
Local $s_Subject = "My Test UDF"
Local $as_Body[2]
$as_Body[0] = "Testing the new email udf"
$as_Body[1] = "Second Line"
Local $iResponse = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body)
Local $iErr = @error
If $iResponse = 1 Then
    MsgBox($MB_SYSTEMMODAL, "Success!", "Mail sent")
Else
    MsgBox($MB_SYSTEMMODAL, "Error!", "Mail failed with error code " & $iErr)
EndIf


Function _TCPIpToName

Function Reference

_TCPIpToName

Resolves IP address to Hostname(s)

#include <Inet.au3>
_TCPIpToName ( $sIp [, $iOption = 0 [, $hDll = "Ws2_32.dll"]] )

Parameters

$sIp | Ip Adress in dotted (v4) Format
$iOption | [optional] Default = 0 0 = Return String Hostname 1 = Return Array (see Remarks)
$hDll | [optional] Handle to Ws2_32.dll

Return Value

Success: | Hostname or Array (see Remarks)
Failure: | ""
@error: | 1 - inet_addr DllCall Failed 2 - inet_addr Failed 3 - gethostbyaddr DllCall Failed 4 - gethostbyaddr Failed, WSAGetLastError = @extended 5 - gethostbyaddr Failed, WSAGetLastError Failed 6 - strlen/sZStringRead Failed 7 - Error reading Aliases Array

Remarks

A successfull WSAStartup (Done by TCPStartup()) is required.
if $iOption = 1 then the returned Array looks Like this:
$aResult[0] = Number of elements
$aResult[1] = "Hostname"
$aResult[2] = "Alias 1"
$aResult[3] = "Alias 2"
...

Example

Example 1

#include <Array.au3>
#include <Inet.au3>
#include <MsgBoxConstants.au3>

Local $aResult, $sResult, $sIp

TCPStartup()
$sIp = TCPNameToIP("autoitscript.com")
$sResult = _TCPIpToName($sIp)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "_TCPIpToName()", "@error = " & @error & @CRLF & "@extended = " & @extended)
Else
    MsgBox($MB_SYSTEMMODAL, "autoitscript.com really is:", $sResult)
EndIf

Example 2

#include <Array.au3>
#include <Inet.au3>
#include <MsgBoxConstants.au3>

Local $aResult, $sResult, $sIp

TCPStartup()
$sIp = _GetIP()
$aResult = _TCPIpToName($sIp, 1)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "_TCPIpToName()", "@error = " & @error & @CRLF & "@extended = " & @extended)
Else
    _ArrayDisplay($aResult, "Local Hostname(s)")
EndIf


User Defined Functions

Math user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <Math.au3>.

User Defined Function | Description
_Degree | Converts radians to degrees
_MathCheckDiv | Checks if first number is divisible by the second number
_Max | Evaluates which of the two numbers is higher
_Min | Evaluates which of the two numbers is lower
_Radian | Converts degrees to radians


Function _Degree

Function Reference

_Degree

Converts radians to degrees

#include <Math.au3>
_Degree ( $iRadians )

Parameters

$iRadians Radians to be converted into degrees.

Return Value

Success: | Degrees converted from radians.
Failure: | Empty string and @error set to 1.

Remarks

Can be used in conjunction with the Sin(), Cos(), and Tan() functions.

Related

_Radian

Example

#include <Math.au3>
#include <MsgBoxConstants.au3>

Local $fRadians = 3.14159265358979
Local $fDegrees = _Degree($fRadians)

MsgBox($MB_SYSTEMMODAL, "Radians to Degrees", $fRadians & " radians = " & $fDegrees & " degrees")


Function _MathCheckDiv

Function Reference

_MathCheckDiv

Checks if first number is divisible by the second number

#include <Math.au3>
_MathCheckDiv ( $iNum1 [, $iNum2 = 2] )

Parameters

$iNum1 | Integer value to check
$iNum2 | [optional] Integer value to divide by (default = 2)

Return Value

Success: | $MATH_ISNOTDIVISIBLE (1) for not divisible. $MATH_ISDIVISIBLE (2) for divisible.
Failure: | -1 and sets the @error flag to non-zero if non-integers are entered.

Remarks

This function by default checks if the first number is either odd or even, as the second value is default to 2.

Example

#include <Math.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $iVar = Int(InputBox("Odd or Even", "Enter a number:")) ; Parse as an integer.
    Local $iResult = _MathCheckDiv($iVar, 2) ; Divide the number by 2.
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "You did not enter a valid number")
    Else
        Switch $iResult
            Case -1
                MsgBox($MB_SYSTEMMODAL, "", "You did not enter a valid number")
            Case $MATH_ISNOTDIVISIBLE
                MsgBox($MB_SYSTEMMODAL, "", "Number is odd")
            Case $MATH_ISDIVISIBLE
                MsgBox($MB_SYSTEMMODAL, "", "Number is even")
            Case Else
                MsgBox($MB_SYSTEMMODAL, "", "Could not parse")
        EndSwitch
    EndIf
EndFunc   ;==>Example


Function _Max

Function Reference

_Max

Evaluates which of the two numbers is higher

#include <Math.au3>
_Max ( $iNum1, $iNum2 )

Parameters

$iNum1 | First number.
$iNum2 | Second number.

Return Value

Success: | the higher of the two numbers.
Failure: | 0 and sets the @error flag to non-zero
@error: | 1 - $iNum1 isn't a number. 2 - $iNum2 isn't a number.

Remarks

This function works with floats as well as integers.

Related

_Min

Example

#include <Math.au3>
#include <MsgBoxConstants.au3>

Local $iMax = _Max(1, 10) ; Returns 10.
MsgBox($MB_SYSTEMMODAL, '', 'Maximum value: ' & $iMax)


Function _Min

Function Reference

_Min

Evaluates which of the two numbers is lower

#include <Math.au3>
_Min ( $iNum1, $iNum2 )

Parameters

$iNum1 | First number.
$iNum2 | Second number.

Return Value

Success: | the lower of the two numbers.
Failure: | 0 and sets the @error flag to non-zero
@error: | 1 - $iNum1 isn't a number. 2 - $iNum2 isn't a number.

Remarks

This function works with floats as well as integers.

Related

_Max

Example

#include <Math.au3>
#include <MsgBoxConstants.au3>

Local $iMin = _Min(1, 10) ; Returns 1.
MsgBox($MB_SYSTEMMODAL, '', 'Minimum value: ' & $iMin)


Function _Radian

Function Reference

_Radian

Converts degrees to radians

#include <Math.au3>
_Radian ( $iDegrees )

Parameters

$iDegrees Degrees to be converted into radians.

Return Value

Success: | the radians converted from degrees.
Failure: | an empty string and sets the @error flag to non-zero.

Remarks

Can be used in conjunction with the Sin(), Cos(), and Tan() functions.

Related

_Degree

Example

#include <Math.au3>
#include <MsgBoxConstants.au3>

Local $fDegrees = 35
Local $fRadians = _Radian($fDegrees)

MsgBox($MB_SYSTEMMODAL, "Degrees to Radians", $fDegrees & " degrees = " & $fRadians & " radians")


User Defined Functions

Memory user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPISys.au3>.

User Defined Function | Description
_MemGlobalAlloc | Allocates the specified number of bytes from the heap
_MemGlobalFree | Frees the specified global memory object and invalidates its handle
_MemGlobalLock | Locks a global memory object and returns a pointer to the first byte of the object's memory block
_MemGlobalSize | Retrieves the current size of the specified global memory object
_MemGlobalUnlock | Decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE
_MemMoveMemory | Moves memory either forward or backward, aligned or unaligned
_MemVirtualAlloc | Reserves or commits a region of pages in the virtual address space of the calling process
_MemVirtualAllocEx | Reserves a region of memory within the virtual address space of a specified process
_MemVirtualFree | Releases a region of pages within the virtual address space of a process
_MemVirtualFreeEx | Releases a region of pages within the virtual address space of a process


Function _MemGlobalAlloc

Function Reference

_MemGlobalAlloc

Allocates the specified number of bytes from the heap

#include <Memory.au3>
_MemGlobalAlloc ( $iBytes [, $iFlags = 0] )

Parameters

$iBytes | The number of bytes to allocate. If this parameter is zero and the $iFlags parameter specifies $GMEM_MOVEABLE, the function returns a handle to a memory object that is marked as discarded.
$iFlags | [optional] The memory allocation attributes: $GMEM_FIXED - Allocates fixed memory. The return value is a pointer. $GMEM_MOVEABLE - Allocates movable memory. Memory blocks are never moved in physical memory, but they can be moved within the default heap. The return value is a handle to the memory object. To translate the handle into a pointer, use the _MemGlobalLock() function. This value cannot be combined with $GMEM_FIXED. $GMEM_ZEROINIT - Initializes memory contents to zero $GHND - Combines $GMEM_MOVEABLE and $GMEM_ZEROINIT $GPTR - Combines $GMEM_FIXED and $GMEM_ZEROINIT

Return Value

Success: | a handle to the newly allocated memory object.
Failure: | 0.

Remarks

Windows memory management does not provide a separate local heap and global heap.
If this function succeeds, it allocates at least the amount of memory requested.
If the actual amount allocated is greater than the amount requested, the process can use the entire amount.
To determine the actual number of bytes allocated, use the _MemGlobalSize() function.
If the heap does not contain sufficient free space to satisfy the request, this function returns NULL.
Memory allocated with this function is guaranteed to be aligned on an 8 byte boundary.
To execute dynamically generated code, use the _MemVirtualAlloc() function to allocate memory and the _Mem_VirtualProtect() function to grant $PAGE_EXECUTE access.
To free the memory, use the _MemGlobalFree() function.

Related

_MemGlobalFree, _MemGlobalLock, _MemGlobalSize, _MemVirtualAlloc

See Also

Search GlobalAlloc in MSDN Library.


Function _MemGlobalFree

Function Reference

_MemGlobalFree

Frees the specified global memory object and invalidates its handle

#include <Memory.au3>
_MemGlobalFree ( $hMemory )

Parameters

$hMemory Handle to the global memory object

Return Value

Success: | 0.
Failure: | $hMemory.

Related

_MemGlobalAlloc

See Also

Search GlobalFree in MSDN Library.


Function _MemGlobalLock

Function Reference

_MemGlobalLock

Locks a global memory object and returns a pointer to the first byte of the object's memory block

#include <Memory.au3>
_MemGlobalLock ( $hMemory )

Parameters

$hMemory Handle to the global memory object

Return Value

Success: | a pointer to the first byte of the memory block.
Failure: | 0.

Related

_MemGlobalAlloc, _MemGlobalUnlock

See Also

Search GlobalLock in MSDN Library.


Function _MemGlobalSize

Function Reference

_MemGlobalSize

Retrieves the current size of the specified global memory object

#include <Memory.au3>
_MemGlobalSize ( $hMemory )

Parameters

$hMemory Handle to the global memory object

Return Value

Success: | the size of the specified global memory object, in bytes.
Failure: | 0.

Related

_MemGlobalAlloc

See Also

Search GlobalSize in MSDN Library.


Function _MemGlobalUnlock

Function Reference

_MemGlobalUnlock

Decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE

#include <Memory.au3>
_MemGlobalUnlock ( $hMemory )

Parameters

$hMemory Handle to the global memory object

Return Value

None.

Related

_MemGlobalLock

See Also

Search GlobalUnlock in MSDN Library.


Function _MemMoveMemory

Function Reference

_MemMoveMemory

Moves memory either forward or backward, aligned or unaligned

#include <Memory.au3>
_MemMoveMemory ( $pSource, $pDest, $iLength )

Parameters

$pSource | Pointer to the source of the move
$pDest | Pointer to the destination of the move
$iLength | Specifies the number of bytes to be copied

Return Value

None, @error flag may be set in case of bad DllCall() return (AutoIt or Windows errors).

Remarks

Invalid pointers will crash the script.

See Also

Search RtlMoveMemory in MSDN Library.


Function _MemVirtualAlloc

Function Reference

_MemVirtualAlloc

Reserves or commits a region of pages in the virtual address space of the calling process

#include <Memory.au3>
_MemVirtualAlloc ( $pAddress, $iSize, $iAllocation, $iProtect )

Parameters

$pAddress | Specifies the desired starting address of the region to allocate
$iSize | Specifies the size, in bytes, of th region
$iAllocation | Specifies the type of allocation: $MEM_COMMIT - Allocates physical storage in memory or in the paging file on disk for the specified region of pages. $MEM_RESERVE - Reserves a range of the process's virtual address space without allocating any physical storage. $MEM_TOP_DOWN - Allocates memory at the highest possible address
$iProtect | Type of access protection: $PAGE_READONLY - Enables read access to the committed region of pages $PAGE_READWRITE - Enables read and write access to the committed region $PAGE_EXECUTE - Enables execute access to the committed region $PAGE_EXECUTE_READ - Enables execute and read access to the committed region $PAGE_EXECUTE_READWRITE - Enables execute, read, and write access to the committed region of pages $PAGE_GUARD - Pages in the region become guard pages $PAGE_NOACCESS - Disables all access to the committed region of pages $PAGE_NOCACHE - Allows no caching of the committed regions of pages

Return Value

Success: | a memory address pointer.
Failure: | 0.

Related

_MemGlobalAlloc, _MemVirtualFree

See Also

Search VirtualAlloc in MSDN Library.


Function _MemVirtualAllocEx

Function Reference

_MemVirtualAllocEx

Reserves a region of memory within the virtual address space of a specified process

#include <Memory.au3>
_MemVirtualAllocEx ( $hProcess, $pAddress, $iSize, $iAllocation, $iProtect )

Parameters

$hProcess | Handle to process
$pAddress | Specifies the desired starting address of the region to allocate
$iSize | Specifies the size, in bytes, of th region
$iAllocation | Specifies the type of allocation: $MEM_COMMIT - Allocates physical storage in memory or in the paging file on disk for the specified region of pages. $MEM_RESERVE - Reserves a range of the process's virtual address space without allocating any physical storage. $MEM_TOP_DOWN - Allocates memory at the highest possible address
$iProtect | Type of access protection: $PAGE_READONLY - Enables read access to the committed region of pages $PAGE_READWRITE - Enables read and write access to the committed region $PAGE_EXECUTE - Enables execute access to the committed region $PAGE_EXECUTE_READ - Enables execute and read access to the committed region $PAGE_EXECUTE_READWRITE - Enables execute, read, and write access to the committed region of pages $PAGE_GUARD - Pages in the region become guard pages $PAGE_NOACCESS - Disables all access to the committed region of pages $PAGE_NOCACHE - Allows no caching of the committed regions of pages

Return Value

Returns a memory address pointer.

Related

_MemVirtualFreeEx

See Also

Search VirtualAllocEx in MSDN Library.


Function _MemVirtualFree

Function Reference

_MemVirtualFree

Releases a region of pages within the virtual address space of a process

#include <Memory.au3>
_MemVirtualFree ( $pAddress, $iSize, $iFreeType )

Parameters

$pAddress | Points to the base address of the region of pages to be freed
$iSize | Specifies the size, in bytes, of the region to be freed
$iFreeType | Specifies the type of free operation: $MEM_DECOMMIT - Decommits the specified region of committed pages $MEM_RELEASE - Releases the specified region of reserved pages

Return Value

Success: | True.
Failure: | False.

Related

_MemVirtualAlloc

See Also

Search VirtualFree in MSDN Library.


Function _MemVirtualFreeEx

Function Reference

_MemVirtualFreeEx

Releases a region of pages within the virtual address space of a process

#include <Memory.au3>
_MemVirtualFreeEx ( $hProcess, $pAddress, $iSize, $iFreeType )

Parameters

$hProcess | Handle to a process
$pAddress | A pointer to the starting address of the region of memory to be freed
$iSize | The size of the region of memory to free, in bytes
$iFreeType | Specifies the type of free operation: $MEM_DECOMMIT - Decommits the specified region of committed pages $MEM_RELEASE - Releases the specified region of reserved pages

Return Value

Success: | True.
Failure: | False.

Related

_MemVirtualAllocEx

See Also

Search VirtualFreeEx in MSDN Library.


User Defined Functions

Misc user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <Misc.au3>.

User Defined Function | Description
_ChooseColor | Creates a Color dialog box that enables the user to select a color
_ChooseFont | Creates a Font dialog box that enables the user to choose attributes for a logical font
_ClipPutFile | Copy Files to Clipboard Like Explorer does
_IsPressed | Check if key has been pressed
_MouseTrap | Confine the Mouse Cursor to specified coords
_Singleton | Enforce a design paradigm where only one instance of the script may be running
_VersionCompare | Compares two file versions for equality


Function _ChooseColor

Function Reference

_ChooseColor

Creates a Color dialog box that enables the user to select a color

#include <Misc.au3>
_ChooseColor ( [$iReturnType = 0 [, $iColorRef = 0 [, $iRefType = 0 [, $hWndOwnder = 0]]]] )

Parameters

$iReturnType | [optional] Determines return type, valid values: 0 - COLORREF rgbcolor 1 - BGR hex 2 - RGB hex
$iColorRef | [optional] Default selected Color
$iRefType | [optional] Type of $iColorRef passed in, valid values: 0 - COLORREF rgbcolor 1 - BGR hex 2 - RGB hex
$hWndOwnder | [optional] Handle to the window that owns the dialog box

Return Value

Success: | Color returned
Failure: | -1

Example

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

Example()

Func Example()
    Local $hGUI, $idCOLORREF, $idBGR, $idRGB, $idMemo

    $hGUI = GUICreate("_ChooseColor() Example", 400, 300)
    $idMemo = GUICtrlCreateEdit("", 2, 55, 396, 200, BitOR($WS_VSCROLL, $WS_HSCROLL))
    GUICtrlSetFont($idMemo, 10, 400, 0, "Courier New")
    $idCOLORREF = GUICtrlCreateButton("COLORREF", 70, 10, 80, 40)
    $idBGR = GUICtrlCreateButton("BGR", 160, 10, 80, 40)
    $idRGB = GUICtrlCreateButton("RGB", 250, 10, 80, 40)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idCOLORREF
                _ShowChoice($hGUI, $idMemo, 0, _ChooseColor(0, 255, 0, $hGUI), "COLORREF color of your choice: ")
            Case $idBGR
                _ShowChoice($hGUI, $idMemo, 1, _ChooseColor(2, 0x808000, 1, $hGUI), "BGR Hex color of your choice: ")
            Case $idRGB
                _ShowChoice($hGUI, $idMemo, 2, _ChooseColor(2, 0x0080C0, 2, $hGUI), "RGB Hex color of your choice: ")
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func _ShowChoice($hGUI, $idMemo, $iType, $iChoose, $sMessage)
    Local $sCr
    If $iChoose <> -1 Then

        If $iType = 0 Then ; convert COLORREF to RGB for this example
            $sCr = Hex($iChoose, 6)
            GUISetBkColor('0x' & StringMid($sCr, 5, 2) & StringMid($sCr, 3, 2) & StringMid($sCr, 1, 2), $hGUI)
        Else
            GUISetBkColor($iChoose, $hGUI)
        EndIf

        GUICtrlSetData($idMemo, $sMessage & $iChoose & @CRLF, 1)

    Else
        GUICtrlSetData($idMemo, "User Canceled Selction" & @CRLF, 1)
    EndIf
EndFunc   ;==>_ShowChoice


Function _ChooseFont

Function Reference

_ChooseFont

Creates a Font dialog box that enables the user to choose attributes for a logical font

#include <Misc.au3>
_ChooseFont ( [$sFontName = "Courier New" [, $iPointSize = 10 [, $iFontColorRef = 0 [, $iFontWeight = 0 [, $bItalic = False [, $bUnderline = False [, $bStrikethru = False [, $hWndOwner = 0]]]]]]]] )

Parameters

$sFontName | [optional] Default font name
$iPointSize | [optional] Pointsize of font
$iFontColorRef | [optional] COLORREF rgbColors
$iFontWeight | [optional] Font Weight
$bItalic | [optional] Italic
$bUnderline | [optional] Underline
$bStrikethru | [optional] Strikethru
$hWndOwner | [optional] Handle to the window that owns the dialog box

Return Value

Success: | an array in the following format: [0] - contains the number of elements [1] - attributes = BitOR of italic:2, undeline:4, strikeout:8 [2] - fontname [3] - font size = point size [4] - font weight = = 0-1000 [5] - COLORREF rgbColors [6] - Hex BGR Color [7] - Hex RGB Color
Failure: | sets the @error flag to non-zero.

Example

Example 1

#include <Misc.au3>
#include <MsgBoxConstants.au3>

Local $a_vFont = _ChooseFont("Arial", 8)
If (@error) Then
    MsgBox($MB_SYSTEMMODAL, "", "Error _ChooseFont: " & @error)
Else
    MsgBox($MB_SYSTEMMODAL, "", "Font Name: " & $a_vFont[2] & @CRLF & "Size: " & $a_vFont[3] & @CRLF & "Weight: " & $a_vFont[4] & @CRLF & "COLORREF rgbColors: " & $a_vFont[5] & @CRLF & "Hex BGR Color: " & $a_vFont[6] & @CRLF & "Hex RGB Color: " & $a_vFont[7])
EndIf

Example 2

#include <Misc.au3>
#include <MsgBoxConstants.au3>

Local $a_vFont = _ChooseFont()
If (@error) Then
    MsgBox($MB_SYSTEMMODAL, "ERROR", "Error _ChooseFont: " & @error)
    Exit
Else
    MsgBox($MB_SYSTEMMODAL, "", "Font Name: " & $a_vFont[2] & @CRLF & "Size: " & $a_vFont[3] & @CRLF & "Weight: " & $a_vFont[4] & @CRLF & "COLORREF rgbColors: " & $a_vFont[5] & @CRLF & "Hex BGR Color: " & $a_vFont[6] & @CRLF & "Hex RGB Color: " & $a_vFont[7])
EndIf

Example 3

#include <Misc.au3>
#include <MsgBoxConstants.au3>

Local $a_vFont = _ChooseFont()

Local $sFontName = $a_vFont[2]
Local $iFontSize = $a_vFont[3]
Local $iColorRef = $a_vFont[5]
Local $iFontWeight = $a_vFont[4]
Local $bItalic = BitAND($a_vFont[1], 2)
Local $bUnderline = BitAND($a_vFont[1], 4)
Local $bStrikethru = BitAND($a_vFont[1], 8)
$a_vFont = _ChooseFont($sFontName, $iFontSize, $iColorRef, $iFontWeight, $bItalic, $bUnderline, $bStrikethru)
If (@error) Then
    MsgBox($MB_SYSTEMMODAL, "", "Error _ChooseFont: " & @error)
Else
    MsgBox($MB_SYSTEMMODAL, "", "Font Name: " & $a_vFont[2] & @CRLF & "Size: " & $a_vFont[3] & @CRLF & "Weight: " & $a_vFont[4] & @CRLF & "COLORREF rgbColors: " & $a_vFont[5] & @CRLF & "Hex BGR Color: " & $a_vFont[6] & @CRLF & "Hex RGB Color: " & $a_vFont[7])
EndIf


Function _ClipPutFile

Function Reference

_ClipPutFile

Copy Files to Clipboard Like Explorer does

#include <Misc.au3>
_ClipPutFile ( $sFilePath [, $sDelimiter = "|"] )

Parameters

$sFilePath | Full Path to File(s)
$sDelimiter | [optional] Separator for multiple Files, Default = '|'

Return Value

Success: | True
Failure: | False and sets the @error flag to non-zero.
@error: | 1 - Unable to Open Clipboard 2 - Unable to Empty Cipboard 3 - GlobalAlloc Failed 4 - GlobalLock Failed 5 - Unable to Create H_DROP 6 - Unable to Update Clipboard 7 - Unable to Close Clipboard 8 - GlobalUnlock Failed 9 - GlobalFree Failed

Example

#include <Misc.au3>
#include <MsgBoxConstants.au3>

; Add the following contents to the clipboard.
Local $bReturn = _ClipPutFile(@ScriptFullPath & "|" & @ScriptDir & "|" & @SystemDir)
If Not $bReturn Then
    MsgBox($MB_SYSTEMMODAL, "_ClipPutFile() call Failed", "@error = " & @error)
Else
    MsgBox($MB_SYSTEMMODAL, "_ClipPutFile()", "Content of Clipboard:" & @CRLF & ClipGet())
EndIf


Function _IsPressed

Function Reference

_IsPressed

Check if key has been pressed

#include <Misc.au3>
_IsPressed ( $sHexKey [, $vDLL = 'user32.dll'] )

Parameters

$sHexKey | Key to check for
$vDLL | [optional] Handle to DLL or default to user32.dll

Return Value

True: | if the key is pressed.
False: | if the key is not pressed.

Remarks

If calling this function repeatedly, you should open 'user32.dll' and pass the handle.
Make sure to close the handle at end of script using DllClose.

_IsPressed() will return 1 until the key is released.
Even brief key presses can result in multiple returns within a loop.
If the code called does not include a blocking function (such as MsgBox) and the user does not require multiple returns, the script should wait until _IsPressed() returns 0 before continuing.

01 Left mouse button
02 Right mouse button
03 Control-break processing
04 Middle mouse button (three-button mouse)
05 X1 mouse button
06 X2 mouse button
08 BACKSPACE key
09 TAB key
0C CLEAR key
0D ENTER key
10 SHIFT key
11 CTRL key
12 ALT key
13 PAUSE key
14 CAPS LOCK key
1B ESC key
20 SPACEBAR
21 PAGE UP key
22 PAGE DOWN key
23 END key
24 HOME key
25 LEFT ARROW key
26 UP ARROW key
27 RIGHT ARROW key
28 DOWN ARROW key
29 SELECT key
2A PRINT key
2B EXECUTE key
2C PRINT SCREEN key
2D INS key
2E DEL key
30 0 key
31 1 key
32 2 key
33 3 key
34 4 key
35 5 key
36 6 key
37 7 key
38 8 key
39 9 key
41 A key
42 B key
43 C key
44 D key
45 E key
46 F key
47 G key
48 H key
49 I key
4A J key
4B K key
4C L key
4D M key
4E N key
4F O key
50 P key
51 Q key
52 R key
53 S key
54 T key
55 U key
56 V key
57 W key
58 X key
59 Y key
5A Z key
5B Left Windows key
5C Right Windows key
60 Numeric keypad 0 key
61 Numeric keypad 1 key
62 Numeric keypad 2 key
63 Numeric keypad 3 key
64 Numeric keypad 4 key
65 Numeric keypad 5 key
66 Numeric keypad 6 key
67 Numeric keypad 7 key
68 Numeric keypad 8 key
69 Numeric keypad 9 key
6A Multiply key
6B Add key
6C Separator key
6D Subtract key
6E Decimal key
6F Divide key
70 F1 key
71 F2 key
72 F3 key
73 F4 key
74 F5 key
75 F6 key
76 F7 key
77 F8 key
78 F9 key
79 F10 key
7A F11 key
7B F12 key
7C-7F F13 key - F16 key
80H-87H F17 key - F24 key
90 NUM LOCK key
91 SCROLL LOCK key
A0 Left SHIFT key
A1 Right SHIFT key
A2 Left CONTROL key
A3 Right CONTROL key
A4 Left MENU key
A5 Right MENU key
BA ;
BB =
BC ,
BD -
BE .
BF /
C0 `
DB [
DC \
DD ]

Example

#include <Misc.au3>
#include <MsgBoxConstants.au3>

Local $hDLL = DllOpen("user32.dll")

While 1
    If _IsPressed("10", $hDLL) Then
        ConsoleWrite("_IsPressed - Shift Key was pressed." & @CRLF)
        ; Wait until key is released.
        While _IsPressed("10", $hDLL)
            Sleep(250)
        WEnd
        ConsoleWrite("_IsPressed - Shift Key was released." & @CRLF)
    ElseIf _IsPressed("1B", $hDLL) Then
        MsgBox($MB_SYSTEMMODAL, "_IsPressed", "The Esc Key was pressed, therefore we will close the application.")
        ExitLoop
    EndIf
    Sleep(250)
WEnd

DllClose($hDLL)


Function _MouseTrap

Function Reference

_MouseTrap

Confine the Mouse Cursor to specified coords

#include <Misc.au3>
_MouseTrap ( [$iLeft = 0 [, $iTop = 0 [, $iRight = 0 [, $iBottom = 0]]]] )

Parameters

$iLeft | [optional] Left coord
$iTop | [optional] Top coord
$iRight | [optional] Right coord
$iBottom | [optional] Bottom coord

Return Value

Success: | True.
Failure: | False.

Remarks

Use _MouseTrap() with no params to release the Mouse Cursor.

Example

#include <GUIConstantsEx.au3>
#include <Misc.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Mouse Trap Example")

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Hold the window's position.
    Local $aCoords = 0

    ; Loop until the user exits.
    While 1
        $aCoords = WinGetPos($hGUI)
        If Not @error Then
            ; If no error occurs, then trap the mouse cursor between the window client.
            _MouseTrap($aCoords[0], $aCoords[1], $aCoords[0] + $aCoords[2], $aCoords[1] + $aCoords[3])
        EndIf
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    ; Release the mouse cursor
    _MouseTrap()
EndFunc   ;==>Example


Function _Singleton

Function Reference

_Singleton

Enforce a design paradigm where only one instance of the script may be running

#include <Misc.au3>
_Singleton ( $sOccurrenceName [, $iFlag = 0] )

Parameters

$sOccurrenceName | String to identify the occurrence of the script. This string may not contain the \ character unless you are placing the object in a namespace (See Remarks).
$iFlag | [optional] Behavior options. 0 - Exit the script with the exit code -1 if another instance already exists. 1 - Return from the function without exiting the script. 2 - Allow the object to be accessed by anybody in the system. This is useful if specifying a "Global\" object in a multi-user environment.

Return Value

Success: | The handle to the object used for synchronization (a mutex).
Failure: | 0

Remarks

You can place the object in a namespace by prefixing your object name with either "Global\" or "Local\". "Global\" objects combined with the flag 2 are useful in multi-user environments.

Example

#include <Misc.au3>
#include <MsgBoxConstants.au3>

If _Singleton("test", 1) = 0 Then
    MsgBox($MB_SYSTEMMODAL, "Warning", "An occurrence of test is already running")
    Exit
EndIf
MsgBox($MB_SYSTEMMODAL, "OK", "the first occurrence of test is running")


Function _VersionCompare

Function Reference

_VersionCompare

Compares two file versions for equality

#include <Misc.au3>
_VersionCompare ( $sVersion1, $sVersion2 )

Parameters

$sVersion1 | The first version value
$sVersion2 | The second version value

Return Value

Success: | Following Values: 0 - Both versions equal 1 - Version 1 greater -1 - Version 2 greater
Failure: | @error will be set in the event of a catasrophic error

Remarks

This will try to use a numerical comparison but fall back on a lexicographical comparison.
See @extended for details about which type was performed.
Numerical version can be ended with a letter as "3.3.1c".

Example

#include <Misc.au3>
#include <MsgBoxConstants.au3>

Global $g_sResult = ""

Check_VersionCompare("25.2.1", "5.2.1", 1)
Check_VersionCompare("5.12.0", "5.2.1", 1)
Check_VersionCompare("10.0.0.0", "12,0,0,0", -1)

Check_VersionCompare("1.2.1", "1.10", -1)
Check_VersionCompare("1.11.1b", "1.2", 1)
Check_VersionCompare("1.1b", "1.11c", -1)
Check_VersionCompare("1.11b", "1.1c", 1)
Check_VersionCompare("5.2.1", "5.2.1a", -1)
Check_VersionCompare("5.2.1", "5.2.1", 0)
Check_VersionCompare("5.2.1", "5.2.1.0", 0)
Check_VersionCompare("5.2.1a", "5.2.1.0", 1)
Check_VersionCompare("5.2.1a", "5.2.1.1", -1)
Check_VersionCompare("5.2.1b", "5.2.1.1a", -1)
Check_VersionCompare("5.2.1b", "5.2.1a", 1)
Check_VersionCompare("5.2.1a", "5.2.1a", 0)
Check_VersionCompare("5.2.1a", "5.2.1b", -1)

MsgBox($MB_SYSTEMMODAL, '_VersionCompare Results', $g_sResult)

Func Check_VersionCompare($sVersion1, $sVersion2, $iReturn)
    Local $iRet = _VersionCompare($sVersion1, $sVersion2)
    Local $iExtended = @extended
    $g_sResult &= '"' & $sVersion1 & '" to "' & $sVersion2 & @TAB & " return " & $iRet
    If $iRet <> $iReturn Then $g_sResult &= " INSTEAD of " & $iReturn
    $g_sResult &= @TAB & "@extended = " & $iExtended & @CRLF
EndFunc   ;==>Check_VersionCompare


User Defined Functions

NamedPipes user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <NamedPipes.au3>.

User Defined Function | Description
_NamedPipes_CallNamedPipe | Performs a read/write operation on a named pipe
_NamedPipes_ConnectNamedPipe | Enables a named pipe server process to wait for a client process to connect
_NamedPipes_CreateNamedPipe | Creates an instance of a named pipe
_NamedPipes_CreatePipe | Creates an anonymous pipe
_NamedPipes_DisconnectNamedPipe | Disconnects the server end of a named pipe instance from a client process
_NamedPipes_GetNamedPipeHandleState | Retrieves information about a specified named pipe
_NamedPipes_GetNamedPipeInfo | Retrieves information about the specified named pipe
_NamedPipes_PeekNamedPipe | Copies data from a pipe into a buffer without removing it from the pipe
_NamedPipes_SetNamedPipeHandleState | Sets the read mode and the blocking mode of the specified named pipe
_NamedPipes_TransactNamedPipe | Reads and writes to a named pipe in one network operation
_NamedPipes_WaitNamedPipe | Waits for an instance of a named pipe to become available


Function _NamedPipes_CallNamedPipe

Function Reference

_NamedPipes_CallNamedPipe

Performs a read/write operation on a named pipe

#include <NamedPipes.au3>
_NamedPipes_CallNamedPipe ( $sPipeName, $pInpBuf, $iInpSize, $pOutBuf, $iOutSize, ByRef $iRead [, $iTimeOut = 0] )

Parameters

$sPipeName | Pipe name
$pInpBuf | Pointer to the buffer containing the data written to the pipe
$iInpSize | Size of the write buffer, in bytes
$pOutBuf | Pointer to the buffer that receives the data read from the pipe
$iOutSize | Size of the read buffer, in bytes
$iRead | On return, contains the number of bytes read from the pipe
$iTimeOut | [optional] Number of milliseconds to wait for the named pipe to be available. In addition to numeric values, the following special values can be specified: -1 - Wait indefinitely 0 - Uses the default time-out specified in the call to the CreateNamedPipe 1 - Do not wait. If the pipe is not available, return an error

Return Value

Success: | True.
Failure: | False.

Remarks

Calling CallNamedPipe is equivalent to calling the CreateFile (or WaitNamedPipe, if CreateFile cannot open the pipe immediately), TransactNamedPipe, and CloseHandle functions.
CreateFile is called with an access flag of GENERIC_READ | GENERIC_WRITE, and an inherit handle flag of False.
CallNamedPipe fails if the pipe is a byte-type pipe.

Related

_NamedPipes_TransactNamedPipe, _NamedPipes_WaitNamedPipe

See Also

Search CallNamedPipe in MSDN Library.


Function _NamedPipes_ConnectNamedPipe

Function Reference

_NamedPipes_ConnectNamedPipe

Enables a named pipe server process to wait for a client process to connect

#include <NamedPipes.au3>
_NamedPipes_ConnectNamedPipe ( $hNamedPipe [, $tOverlapped = 0] )

Parameters

$hNamedPipe | Handle to the server end of a named pipe instance
$tOverlapped | [optional] a $tagOVERLAPPED structure. If $hNamedPipe was opened with $PIPE_FLAG_OVERLAPPED, $pOverlapped must not be 0. If $hNamedPipe was created with $PIPE_FLAG_OVERLAPPED and $pOverlapped is not 0, the $tagOVERLAPPED structure should contain a handle to a manual reset event object. If $hNamedPipe was not opened with $PIPE_FLAG_OVERLAPPED, the function does not return until a client is connected or an error occurs. Successful synchronous operations result in the function returning a nonzero value if a client connects after the function is called.

Return Value

Success: | True.
Failure: | False.

Remarks

If a client connects before the function is called, the function returns zero and GetLastError will return $ERROR_PIPE_CONNECTED (defined in APIErrorsConstants.au3).
This can happen if a client connects in the interval between the call to CreateNamedPipe and the call to ConnectNamedPipe.
In this situation, there is a good connection between client and server even though the function returns zero.

Related

$tagOVERLAPPED, _NamedPipes_CreateNamedPipe

See Also

Search ConnectNamedPipe in MSDN Library.


Function _NamedPipes_CreateNamedPipe

Function Reference

_NamedPipes_CreateNamedPipe

Creates an instance of a named pipe

#include <NamedPipes.au3>
_NamedPipes_CreateNamedPipe ( $sName [, $iAccess = 2 [, $iFlags = 2 [, $iACL = 0 [, $iType = 1 [, $iRead = 1 [, $iWait = 0 [, $iMaxInst = 25 [, $iOutBufSize = 4096 [, $iInpBufSize = 4096 [, $iDefaultTimeout = 5000 [, $tSecurity = 0]]]]]]]]]]] )

Parameters

$sName | Pipe name with the following format: \\.\pipe\pipename. The pipename part of the name can include any character other than a backslash, including numbers and special characters. The pipe name string can be up to 256 characters long. Pipe names are not case sensitive.
$iAccess | [optional] The pipe access mode. Must be one of the following: 0 - The flow of data in the pipe goes from client to server only (inbound) 1 - The flow of data in the pipe goes from server to client only (outbound) 2 - The pipe is bi-directional (duplex)
$iFlags | [optional] The pipe flags. Can be any combination of the following: 1 - If you attempt to create multiple instances of a pipe with this flag, creation of the first instance succeeds, but creation of the next instance fails. 2 - Overlapped mode is enabled. If this mode is enabled functions performing read, write, and connect operations that may take a significant time to be completed can return immediately. 4 - Write-through mode is enabled. This mode affects only write operations on byte type pipes and only when the client and server are on different computers.
$iACL | [optional] Security ACL flags. Can be any combination of the following: 1 - The caller will have write access to the named pipe's discretionary ACL 2 - The caller will have write access to the named pipe's owner 4 - The caller will have write access to the named pipe's security ACL
$iType | [optional] Pipe type mode. Must be one of the following: 0 - Data is written to the pipe as a stream of bytes 1 - Data is written to the pipe as a stream of messages
$iRead | [optional] Pipe read mode. Must be one of the following: 0 - Data is read from the pipe as a stream of bytes 1 - Data is read from the pipe as a stream of messages
$iWait | [optional] Pipe wait mode. Must be one of the following: 0 - Blocking mode is enabled. When the pipe handle is specified in ReadFile, WriteFile, or ConnectNamedPipe, the operation is not completed until there is data to read, all data is written, or a client is connected. 1 - Nonblocking mode is enabled. ReadFile, WriteFile, and ConnectNamedPipe always return immediately.
$iMaxInst | [optional] The maximum number of instances that can be created for this pipe
$iOutBufSize | [optional] The number of bytes to reserve for the output buffer
$iInpBufSize | [optional] The number of bytes to reserve for the input buffer
$iDefaultTimeOut | [optional] The default time out value, in milliseconds
$tSecurity | [optional] a $tagSECURITY_ATTRIBUTES structure that specifies a security descriptor for the new named pipe and determines whether child processes can inherit the returned handle. If $tSecurity is 0, the named pipe gets a default security descriptor and the handle cannot be inherited. The ACLs in the default security descriptor for a named pipe grant full control to the LocalSystem account administrators, and the creator owner. They also grant read access to members of the Everyone group and the anonymous account.

Return Value

Success: | a handle to the server end of a named pipe instance.
Failure: | -1.

Related

$tagSECURITY_ATTRIBUTES, _NamedPipes_ConnectNamedPipe, _NamedPipes_CreatePipe

See Also

Search CreateNamedPipe in MSDN Library.


Function _NamedPipes_CreatePipe

Function Reference

_NamedPipes_CreatePipe

Creates an anonymous pipe

#include <NamedPipes.au3>
_NamedPipes_CreatePipe ( ByRef $hReadPipe, ByRef $hWritePipe [, $tSecurity = 0 [, $iSize = 0]] )

Parameters

$hReadPipe | Variable that receives the read handle for the pipe
$hWritePipe | Variable that receives the write handle for the pipe
$tSecurity | [optional] $tagSECURITY_ATTRIBUTES structure that determines if the returned handle can be inherited by child processes. If 0, the handles cannot be inherited.
$iSize | [optional] The size of the buffer for the pipe, in bytes. If 0, the system uses the default buffer size.

Return Value

Success: | True.
Failure: | False.

Related

$tagSECURITY_ATTRIBUTES, _NamedPipes_CreateNamedPipe

See Also

Search CreatePipe in MSDN Library.


Function _NamedPipes_DisconnectNamedPipe

Function Reference

_NamedPipes_DisconnectNamedPipe

Disconnects the server end of a named pipe instance from a client process

#include <NamedPipes.au3>
_NamedPipes_DisconnectNamedPipe ( $hNamedPipe )

Parameters

$hNamedPipe Handle to the server end of a named pipe instance.

Return Value

Success: | True.
Failure: | False.

Remarks

If the client end of the named pipe is open, the DisconnectNamedPipe function forces that end of the named pipe closed.
The client receives an error the next time it attempts to access the pipe.
A client that is forced off a pipe must still use the CloseHandle function to close its end of the pipe.

See Also

Search DisconnectNamedPipe in MSDN Library.


Function _NamedPipes_GetNamedPipeHandleState

Function Reference

_NamedPipes_GetNamedPipeHandleState

Retrieves information about a specified named pipe

#include <NamedPipes.au3>
_NamedPipes_GetNamedPipeHandleState ( $hNamedPipe )

Parameters

$hNamedPipe Handle to the server end of a named pipe instance

Return Value

Success: | an array with the following format: $aState[0] - True if pipe handle is in nonblocking mode, otherwise blocking mode $aState[1] - True if pipe handle is in message-read mode, otherwise byte read mode $aState[2] - Number of current pipe instances $aState[3] - Maximum number of bytes to be collected on the client's computer before transmission $aState[4] - Maximum time, in milliseconds, that can pass before a remote named pipe transfers information over the network $aState[5] - User name string associated with the client application. The server can only retrieve this information if the client opened the pipe with the SECURITY_IMPERSONATION access privilege
Failure: | sets the @error flag to non-zero.

Related

_NamedPipes_SetNamedPipeHandleState

See Also

Search GetNamedPipeHandleState in MSDN Library.


Function _NamedPipes_GetNamedPipeInfo

Function Reference

_NamedPipes_GetNamedPipeInfo

Retrieves information about the specified named pipe

#include <NamedPipes.au3>
_NamedPipes_GetNamedPipeInfo ( $hNamedPipe )

Parameters

$hNamedPipe Handle to the named pipe instance. The handle must have GENERIC_READ access to the named pipe

Return Value

Success: | an array with the following format: $aInfo[0] - True if handle refers to server end, otherwise client end $aInfo[1] - True for a message pipe, otherwise byte pipe $aInfo[2] - Size of the buffer for outgoing data, in bytes $aInfo[3] - Size of the buffer for incoming data, in bytes $aInfo[4] - Maximum number of pipe instances that can be created
Failure: | sets the @error flag to non-zero.

See Also

Search GetNamedPipeInfo in MSDN Library.


Function _NamedPipes_PeekNamedPipe

Function Reference

_NamedPipes_PeekNamedPipe

Copies data from a pipe into a buffer without removing it from the pipe

#include <NamedPipes.au3>
_NamedPipes_PeekNamedPipe ( $hNamedPipe )

Parameters

$hNamedPipe Handle to the pipe

Return Value

Success: | an array with the following format: $aInfo[0] - Data read from the pipe $aInfo[1] - Bytes read from the pipe $aInfo[2] - Total bytes available to be read $aInfo[3] - Bytes remaining to be read for this message
Failure: | sets the @error flag to non-zero.

See Also

Search PeekNamedPipe in MSDN Library.


Function _NamedPipes_SetNamedPipeHandleState

Function Reference

_NamedPipes_SetNamedPipeHandleState

Sets the read mode and the blocking mode of the specified named pipe

#include <NamedPipes.au3>
_NamedPipes_SetNamedPipeHandleState ( $hNamedPipe, $iRead, $iWait [, $iBytes = 0 [, $iTimeOut = 0]] )

Parameters

$hNamedPipe | Handle to the named pipe instance
$iRead | Pipe read mode. Must be one of the following: 0 - Data is read from the pipe as a stream of bytes 1 - Data is read from the pipe as a stream of messages
$iWait | Pipe wait mode. Must be one of the following: 0 - Blocking mode is enabled 1 - Nonblocking mode is enabled
$iBytes | [optional] Maximum number of bytes collected on the client computer before transmission to the server
$iTimeout | [optional] Maximum time, in milliseconds, that can pass before a remote named pipe transfers information

Return Value

Success: | True.
Failure: | False.

Related

_NamedPipes_GetNamedPipeHandleState

See Also

Search SetNamedPipeHandleState in MSDN Library.


Function _NamedPipes_TransactNamedPipe

Function Reference

_NamedPipes_TransactNamedPipe

Reads and writes to a named pipe in one network operation

#include <NamedPipes.au3>
_NamedPipes_TransactNamedPipe ( $hNamedPipe, $pInpBuf, $iInpSize, $pOutBuf, $iOutSize [, $tOverlapped = 0] )

Parameters

$hNamedPipe | The handle to the named pipe
$pInpBuf | Pointer to the buffer containing the data to be written to the pipe
$iInpSize | Size of the write buffer, in bytes
$pOutBuf | Pointer to the buffer that receives the data read from the pipe
$iOutSize | Size of the read buffer, in bytes
$tOverlapped | [optional] a $tagOVERLAPPED structure. This structure is required if $hNamedPipe was opened with $PIPE_FLAG_OVERLAPPED. If $hNamedPipe was opened with $PIPE_FLAG_OVERLAPPED, $tOverlapped must not be 0. If $hNamedPipe was opened with $PIPE_FLAG_OVERLAPPED and $tOverlapped is not 0, TransactNamedPipe is executed as an overlapped operation. The $tagOVERLAPPED structure should contain a manual reset event object. If the operation cannot be completed immediately, TransactNamedPipe returns False and GetLastError will return ERROR_IO_PENDING.

Return Value

Success: | the number of bytes read from the pipe.
Failure: | sets the @error flag to non-zero.

Remarks

TransactNamedPipe fails if the server did not create the pipe as a message-type pipe or if the pipe handle is not in message-read mode.

Related

$tagOVERLAPPED, _NamedPipes_CallNamedPipe

See Also

Search TransactNamedPipe in MSDN Library.


Function _NamedPipes_WaitNamedPipe

Function Reference

_NamedPipes_WaitNamedPipe

Waits for an instance of a named pipe to become available

#include <NamedPipes.au3>
_NamedPipes_WaitNamedPipe ( $sPipeName [, $iTimeOut = 0] )

Parameters

$sPipeName | The name of the named pipe. The string must include the name of the computer on which the server process is executing. A period may be used for the servername if the pipe is local.
$iTimeout | [optional] The number of milliseconds that the function will wait for the named pipe to be available. You can also use one of the following values: -1 - The function does not return until an instance of the named pipe is available 0 - The time-out interval is the default value specified by the server process

Return Value

Success: | True.
Failure: | False.

Remarks

If no instances of the specified named pipe exist the WaitNamedPipe function returns immediately.

Related

_NamedPipes_CallNamedPipe

See Also

Search WaitNamedPipe in MSDN Library.


User Defined Functions

NetShare user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <NetShare.au3>.

User Defined Function | Description
_Net_Share_ConnectionEnum | Lists all connections made to a shared resource
_Net_Share_FileClose | Forces a resource to close
_Net_Share_FileEnum | Returns information about open files on a server
_Net_Share_FileGetInfo | Retrieves information about a particular opening of a server resource
_Net_Share_PermStr | Returns the string representation of a resource's permissions
_Net_Share_ResourceStr | Returns the string representation of a resource
_Net_Share_SessionDel | Ends a network session between a server and a workstation
_Net_Share_SessionEnum | Provides information about sessions established on a server
_Net_Share_SessionGetInfo | Retrieves information about a session established between a server and workstation
_Net_Share_ShareAdd | Shares a server resource
_Net_Share_ShareCheck | Checks whether or not a server is sharing a device
_Net_Share_ShareDel | Deletes a share name from a server's list of shared resources
_Net_Share_ShareEnum | Retrieves information about each shared resource on a server
_Net_Share_ShareGetInfo | Retrieves information about a particular shared resource on a server
_Net_Share_ShareSetInfo | Shares a server resource
_Net_Share_StatisticsGetSvr | Retrieves operating statistics for a server
_Net_Share_StatisticsGetWrk | Retrieves operating statistics for a workstation


Function _Net_Share_ConnectionEnum

Function Reference

_Net_Share_ConnectionEnum

Lists all connections made to a shared resource

#include <NetShare.au3>
_Net_Share_ConnectionEnum ( $sServer, $sQualifier )

Parameters

$sServer | String that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is blank the local computer is used.
$sQualifier | Specifies a share name or computer name of interest. If it is a share name, then all of the connections made to that share name are listed. If it is a computer name, the function lists all connections made from that computer to the server specified.

Return Value

Success: | an array with the following format: [0][0] - Number of entries in array [1][0] - Connection identification number [1][1] - Type of connection. Can be combination of: $STYPE_DISKTREE - Disk drive $STYPE_PRINTQ - Print queue $STYPE_DEVICE - Communication device $STYPE_IPC - IPC $STYPE_SPECIAL - Special share reserved for IPC$ or remote administration of the server $STYPE_TEMPORARY - A temporary share [1][2] - Number of files currently open as a result of the connection [1][3] - Number of users on the connection [1][4] - Number of seconds that the connection has been established [1][5] - If the server sharing the resource is running with user level security, this member describes which user made the connection. If the server is running with share level security, this member describes which computer made the connection. [1][6] - Specifies either the share name of the server's shared resource or the computername of the client
Failure: | sets the @error flag to non-zero.

Remarks

Administrator, Server or Print Operator or Power User group membership is required to execute this function

Related

_Net_Share_FileEnum, _Net_Share_SessionEnum, _Net_Share_ShareEnum

See Also

Search NetConnectionEnum in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $sServer, $sShare, $aInfo

    ; Create GUI
    GUICreate("NetShare", 400, 300)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get server and share information
    $sServer = InputBox("NetWork Demo", "Enter Server Name:", "\\MyServer", "", 200, 130)
    If @error Then Exit
    $sShare = InputBox("NetWork Demo", "Enter Share Name:", "MyShare", "", 200, 130)
    If @error Then Exit

    ; Enumerate network connections
    $aInfo = _Net_Share_ConnectionEnum($sServer, $sShare)
    MemoWrite("Error ...................: " & @error)
    MemoWrite("Entries read ............: " & $aInfo[0][0])
    For $iI = 1 To $aInfo[0][0]
        MemoWrite("Connection ID ...........: " & $aInfo[$iI][0])
        MemoWrite("Connection type..........: " & _Net_Share_ResourceStr($aInfo[$iI][1]))
        MemoWrite("Number of files open ....: " & $aInfo[$iI][2])
        MemoWrite("Number of users .........: " & $aInfo[$iI][3])
        MemoWrite("Connection time .........: " & $aInfo[$iI][4])
        MemoWrite("Username ................: " & $aInfo[$iI][5])
        MemoWrite("Network name ............: " & $aInfo[$iI][6])
        MemoWrite()
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Net_Share_FileClose

Function Reference

_Net_Share_FileClose

Forces a resource to close

#include <NetShare.au3>
_Net_Share_FileClose ( $sServer, $iFileID )

Parameters

$sServer | Specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is blank, the local computer is used.
$iFileID | Specifies the file identifier of the opened resource instance to close

Return Value

Success: | True.
Failure: | False.

Remarks

Only members of the Administrators or Server Operators local group can execute this function.

See Also

Search NetFileClose in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $sServer, $aInfo

    ; Create GUI
    GUICreate("NetShare", 400, 300)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get server and share information
    $sServer = InputBox("NetWork Demo", "Enter Server Name:", "\\MyServer", "", 200, 130)
    If @error Then Exit

    ; Enumerate open files on the server
    $aInfo = _Net_Share_FileEnum($sServer)
    MemoWrite("Error ...................: " & @error)
    MemoWrite("Entries read ............: " & $aInfo[0][0])

    ; Force close any file open named "Test.txt"
    For $iI = 1 To $aInfo[0][0]
        If StringInStr($aInfo[$iI][3], "Test.txt") > 0 Then
            _Net_Share_FileClose($sServer, $aInfo[$iI][0])
            MemoWrite("Closed file")
        EndIf
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Net_Share_FileEnum

Function Reference

_Net_Share_FileEnum

Returns information about open files on a server

#include <NetShare.au3>
_Net_Share_FileEnum ( [$sServer = "" [, $sBaseName = "" [, $sUserName = ""]]] )

Parameters

$sServer | [optional] String that contains the name of the server on which the function is to execute. A blank specifies the local computer.
$sBaseName | [optional] String containing a qualifier for the returned information. If blank all open resources are enumerated. If not blank, the function enumerates only resources that have $sBaseName as a prefix.
$sUserName | [optional] String that specifies the name of the user. If not blank $sUserName serves as a qualifier to the enumeration.

Return Value

Success: | an array with the following format: [0][0] - Number of entries in the array (n) [1][0] - ID number assigned to the resource when it is opened [1][1] - Access permissions associated with the opening application: 1 - Permission to read a resource and execute the resource 2 - Permission to write to a resource. 4 - Permission to create a resource 8 - Execute permission 16 - Delete permission 32 - Change attribute permission 64 - Change ACL permission [1][2] - Contains the number of file locks on the resource [1][3] - Specifies the path of the opened resource [1][4] - Specifies which user or which computer opened the resource
Failure: | sets the @error flag to non-zero.

Remarks

Only members of the Administrators or Server Operators local group can execute this function.

Related

_Net_Share_ConnectionEnum, _Net_Share_SessionEnum, _Net_Share_ShareEnum

See Also

Search NetFileEnum in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $sServer, $aInfo

    ; Create GUI
    GUICreate("NetShare", 400, 300)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get server and share information
    $sServer = InputBox("NetWork Demo", "Enter Server Name:", "\\MyServer", "", 200, 130)
    If @error Then Exit

    ; Enumerate open files on the server
    $aInfo = _Net_Share_FileEnum($sServer)
    MemoWrite("Error ...................: " & @error)
    MemoWrite("Entries read ............: " & $aInfo[0][0])
    For $iI = 1 To $aInfo[0][0]
        MemoWrite("Resource ID .............: " & $aInfo[$iI][0])
        MemoWrite("Resource permissions ....: " & _Net_Share_PermStr($aInfo[$iI][1]))
        MemoWrite("Resource locks ..........: " & $aInfo[$iI][2])
        MemoWrite("Resource path ...........: " & $aInfo[$iI][3])
        MemoWrite("Resource user ...........: " & $aInfo[$iI][4])
        MemoWrite()
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Net_Share_FileGetInfo

Function Reference

_Net_Share_FileGetInfo

Retrieves information about a particular opening of a server resource

#include <NetShare.au3>
_Net_Share_FileGetInfo ( $sServer, $iFileID )

Parameters

$sServer | Specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is blank, the local computer is used.
$iFileID | File identifier of the resource for which to return information. The value of this parameter must have been returned in a previous enumeration call.

Return Value

Success: | an array with the following format: [0] - ID number assigned to the resource when it is opened [1] - Access permissions associated with the opening application: 1 - Permission to read a resource and execute the resource 2 - Permission to write to a resource. 4 - Permission to create a resource 8 - Execute permission 16 - Delete permission 32 - Change attribute permission 64 - Change ACL permission [2] - Contains the number of file locks on the resource [3] - Specifies the path of the opened resource [4] - Specifies which user or which computer opened the resource
Failure: | sets the @error flag to non-zero.

Remarks

Administrator, Server or Print Operator or Power User group membership is required to execute this function.

Related

_Net_Share_SessionGetInfo, _Net_Share_ShareGetInfo

See Also

Search NetFileGetInfo in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $sServer, $aFile, $aInfo

    ; Create GUI
    GUICreate("NetShare", 400, 300)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get server and share information
    $sServer = InputBox("NetWork Demo", "Enter Server Name:", "\\MyServer", "", 200, 130)
    If @error Then Exit

    ; Enumerate open files on the server
    $aFile = _Net_Share_FileEnum($sServer)
    MemoWrite("Error ...................: " & @error)
    MemoWrite("Entries read ............: " & $aFile[0][0])
    MemoWrite()

    ; Get information for each open file (same as $aFile info)
    For $iI = 1 To $aFile[0][0]
        $aInfo = _Net_Share_FileGetInfo($sServer, $aFile[$iI][0])
        MemoWrite("Error ...................: " & @error)
        MemoWrite("File permissions ........: " & _Net_Share_PermStr($aInfo[1]))
        MemoWrite("File locks ..............: " & $aInfo[2])
        MemoWrite("File path ...............: " & $aInfo[3])
        MemoWrite("File user ...............: " & $aInfo[4])
        MemoWrite()
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Net_Share_PermStr

Function Reference

_Net_Share_PermStr

Returns the string representation of a resource's permissions

#include <NetShare.au3>
_Net_Share_PermStr ( $iPerm )

Parameters

$iPerm The resource's permissions:
1 - Permission to read data from a resource and to execute
2 - Permission to write data to the resource
4 - Permission to create an instance of the resource
8 - Permission to execute the resource
16 - Permission to delete the resource
32 - Permission to modify the resource's attributes
64 - Permission to modify the permissions assigned to a resource

Return Value

Returns a permissions string.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $sServer, $aInfo

    ; Create GUI
    GUICreate("NetShare", 400, 300)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get server and share information
    $sServer = InputBox("NetWork Demo", "Enter Server Name:", "\\MyServer", "", 200, 130)
    If @error Then Exit

    ; Enumerate open files on the server
    $aInfo = _Net_Share_FileEnum($sServer)
    MemoWrite("Error ...................: " & @error)
    MemoWrite("Entries read ............: " & $aInfo[0][0])
    For $iI = 1 To $aInfo[0][0]
        MemoWrite("Resource ID .............: " & $aInfo[$iI][0])
        MemoWrite("Resource permissions ....: " & _Net_Share_PermStr($aInfo[$iI][1]))
        MemoWrite("Resource locks ..........: " & $aInfo[$iI][2])
        MemoWrite("Resource path ...........: " & $aInfo[$iI][3])
        MemoWrite("Resource user ...........: " & $aInfo[$iI][4])
        MemoWrite()
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Net_Share_ResourceStr

Function Reference

_Net_Share_ResourceStr

Returns the string representation of a resource

#include <NetShare.au3>
_Net_Share_ResourceStr ( $iResource )

Parameters

$iResource Resource type. Can be a combination of:
$STYPE_DISKTREE - Print queue
$STYPE_PRINTQ - Disk drive
$STYPE_DEVICE - Communication device
$STYPE_IPC - IPC
$STYPE_SPECIAL - Special share reserved for IPC$ or remote administration of the server
$STYPE_TEMPORARY - A temporary share

Return Value

Returns a resource type string.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $sServer, $sShare, $aInfo

    ; Create GUI
    GUICreate("NetShare", 400, 300)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get server and share information
    $sServer = InputBox("NetWork Demo", "Enter Server Name:", "\\MyServer", "", 200, 130)
    If @error Then Exit

    $sShare = InputBox("NetWork Demo", "Enter Share Name:", "MyShare", "", 200, 130)
    If @error Then Exit

    ; Enumerate network connections
    $aInfo = _Net_Share_ConnectionEnum($sServer, $sShare)
    MemoWrite("Error ...................: " & @error)
    MemoWrite("Entries read ............: " & $aInfo[0][0])
    For $iI = 1 To $aInfo[0][0]
        MemoWrite("Connection ID ...........: " & $aInfo[$iI][0])
        MemoWrite("Connection type..........: " & _Net_Share_ResourceStr($aInfo[$iI][1]))
        MemoWrite("Number of files open ....: " & $aInfo[$iI][2])
        MemoWrite("Number of users .........: " & $aInfo[$iI][3])
        MemoWrite("Connection time .........: " & $aInfo[$iI][4])
        MemoWrite("Username ................: " & $aInfo[$iI][5])
        MemoWrite("Network name ............: " & $aInfo[$iI][6])
        MemoWrite()
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Net_Share_SessionDel

Function Reference

_Net_Share_SessionDel

Ends a network session between a server and a workstation

#include <NetShare.au3>
_Net_Share_SessionDel ( [$sServer = "" [, $sClientName = "" [, $sUserName = ""]]] )

Parameters

$sServer | [optional] Specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is blank, the local computer is used.
$sClientName | [optional] Specifies the computer name of the client to disconnect. If blank, then all the sessions of the user identified by the username parameter will be deleted on the server specified by $sServer.
$sUserName | [optional] Specifies the name of the user whose session is to be terminated. If this parameter is blank, all user sessions from the client specified by the $sClientName parameter are to be terminated.

Return Value

Success: | True.
Failure: | False.

Remarks

Only members of the Administrators or Server Operators local group can execute this function.
You must pass either $sClientName or $sUserName (or both) for this function to work.

Related

_Net_Share_ShareDel

See Also

Search NetSessionDel in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $sServer

    ; Create GUI
    GUICreate("NetShare", 400, 300)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get server and share information
    $sServer = InputBox("NetWork Demo", "Enter Server Name:", "\\MyServer", "", 200, 130)
    If @error Then Exit

    ; Delete all our sessions on the server
    _Net_Share_SessionDel($sServer, @ComputerName)
    MemoWrite("Error ...................: " & @error)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Net_Share_SessionEnum

Function Reference

_Net_Share_SessionEnum

Provides information about sessions established on a server

#include <NetShare.au3>
_Net_Share_SessionEnum ( [$sServer = "" [, $sClientName = "" [, $sUserName = ""]]] )

Parameters

$sServer | [optional] String that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is blank the local computer is used.
$sClientName | [optional] Specifies the name of the computer session for which information is to be returned. If this parameter is blank, the function returns information for all computer sessions on the server.
$sUserName | [optional] Specifies the name of the user for which information is to be returned. If this parameter is blank, the function returns information for all users.

Return Value

Success: | an array with the following format: [0][0] - Number of entries in array [1][0] - Name of the computer that established the session [1][1] - Name of the user who established the session [1][2] - Number of files, devices, and pipes opened during the session [1][3] - Number of seconds the session has been active [1][4] - Number of seconds the session has been idle [1][5] - Specifies how the user established the session: 1 - User established session using a guest account 2 - User established session without using password encryption [1][6] - Specifies the type of client that established the session [1][7] - Name of the transport that the client is using
Failure: | sets the @error flag to non-zero.

Remarks

Only members of the Administrators or Server Operators local group can execute this function.

Related

_Net_Share_ConnectionEnum, _Net_Share_FileEnum, _Net_Share_ShareEnum

See Also

Search NetSessionEnum in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $sServer, $aInfo

    ; Create GUI
    GUICreate("NetShare", 400, 300)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get server and share information
    $sServer = InputBox("NetWork Demo", "Enter Server Name:", "\\MyServer", "", 200, 130)
    If @error Then Exit

    ; Enumerate network sessions
    $aInfo = _Net_Share_SessionEnum($sServer, @ComputerName)
    MemoWrite("Error ..........: " & @error)
    MemoWrite("Entries read ...: " & $aInfo[0][0])
    For $iI = 1 To $aInfo[0][0]
        MemoWrite("Computer name ..: " & $aInfo[$iI][0])
        MemoWrite("User name.......: " & $aInfo[$iI][1])
        MemoWrite("Resources open .: " & $aInfo[$iI][2])
        MemoWrite("Seconds active .: " & $aInfo[$iI][3])
        MemoWrite("Seconds idle ...: " & $aInfo[$iI][4])
        MemoWrite("Connection type : " & $aInfo[$iI][5])
        MemoWrite("Client type ....: " & $aInfo[$iI][6])
        MemoWrite("Transport ......: " & $aInfo[$iI][7])
        MemoWrite()
    Next

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Net_Share_SessionGetInfo

Function Reference

_Net_Share_SessionGetInfo

Retrieves information about a session established between a server and workstation

#include <NetShare.au3>
_Net_Share_SessionGetInfo ( $sServer, $sClientName, $sUserName )

Parameters

$sServer | String that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is blank the local computer is used.
$sClientName | Specifies the name of the computer session for which information is to be returned. This parameter cannot be blank.
$sUserName | String that specifies the name of the user whose session information is to be returned. This parameter cannot be blank.

Return Value

Success: | an array with the following format: [0] - Name of the computer that established the session [1] - Name of the user who established the session [2] - Number of files, devices, and pipes opened during the session [3] - Number of seconds the session has been active [4] - Number of seconds the session has been idle [5] - Specifies how the user established the session: 1 - User established session using a guest account 2 - User established session without using password encryption [6] - Specifies the type of client that established the session
Failure: | sets the @error flag to non-zero.

Remarks

Only members of the Administrators or Server Operators local group can execute this function.

Related

_Net_Share_FileGetInfo, _Net_Share_ShareGetInfo

See Also

Search NetSessionGetInfo in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $sServer, $aInfo

    ; Create GUI
    GUICreate("NetShare", 400, 300)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get server and share information
    $sServer = InputBox("NetWork Demo", "Enter Server Name:", "\\MyServer", "", 200, 130)
    If @error Then Exit

    ; Get session information
    $aInfo = _Net_Share_SessionGetInfo($sServer, @ComputerName, "Administrator")
    MemoWrite("Error ..........: " & @error)
    MemoWrite("Computer name ..: " & $aInfo[0])
    MemoWrite("User name ......: " & $aInfo[1])
    MemoWrite("Resources open .: " & $aInfo[2])
    MemoWrite("Seconds active .: " & $aInfo[3])
    MemoWrite("Seconds idle ...: " & $aInfo[4])
    MemoWrite("Connection type : " & $aInfo[5])
    MemoWrite("Client type ....: " & $aInfo[6])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Net_Share_ShareAdd

Function Reference

_Net_Share_ShareAdd

Shares a server resource

#include <NetShare.au3>
_Net_Share_ShareAdd ( $sServer, $sShare, $iType, $sResourcePath [, $sComment = "" [, $iMaxUses = -1]] )

Parameters

$sServer | Specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is blank, the local computer is used.
$sShare | Share name of a resource
$iType | Contains the type of the shared resource. Can be a combination of: $STYPE_DISKTREE - Disk drive $STYPE_PRINTQ - Print queue $STYPE_DEVICE - Communication device $STYPE_IPC - IPC $STYPE_SPECIAL - Special share reserved for IPC$ or remote administration of the server $STYPE_TEMPORARY - A temporary share
$sResourcePath | Local path for the shared resource. For disks, this is the path being shared. For print queues, this is the name of the print queue being shared.
$sComment | [optional] String that contains an comment about the shared resource
$iMaxUses | [optional] The maximum number of concurrent connections that the shared resource can accommodate. The number of connections is unlimited if the value specified is –1.

Return Value

Success: | True.
Failure: | False.

Remarks

Only members of the Administrators, System Operators, or Power Users local group can add file shares with a call to this function.
The Print Operator can add printer shares.

Related

_Net_Share_ShareCheck, _Net_Share_ShareDel

See Also

Search NetApiBufferFree in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <NetShare.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $iI, $aInfo
    Local Const $sShareName = "AutoIt Share"

    ; Create GUI
    GUICreate("NetShare", 400, 300)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; See if the share exists
    If _Net_Share_ShareCheck(@ComputerName, $sShareName) = -1 Then
        ; Create a share on the local computer
        _Net_Share_ShareAdd(@ComputerName, $sShareName, 0, "C:\", "AutoIt Share Comment")
        If @error Then MsgBox($MB_SYSTEMMODAL, "Information", "Share add error : " & @error)
        MemoWrite("Share added")
    Else
        MemoWrite("Share exists")
    EndIf

    ; Show information about all local shares
    $aInfo = _Net_Share_ShareEnum(@ComputerName)
    MemoWrite("Entries read ............: " & $aInfo[0][0])
    For $iI = 1 To $aInfo[0][0]
        MemoWrite("Share name ..............: " & $aInfo[$iI][0])
        MemoWrite("Share type...............: " & _Net_Share_ResourceStr($aInfo[$iI][1]))
        MemoWrite("Comment .................: " & $aInfo[$iI][2])
        MemoWrite("Permissions .............: " & _Net_Share_PermStr($aInfo[$iI][3]))
        MemoWrite("Maximum connections .....: " & $aInfo[$iI][4])
        MemoWrite("Current connections .....: " & $aInfo[$iI][5])
        MemoWrite("Local path ..............: " & $aInfo[$iI][6])
        MemoWrite("Password ................: " & $aInfo[$iI][7])
        MemoWrite()
    Next

    ; Delete the share
    _Net_Share_ShareDel(@ComputerName, $sShareName)
    If @error Then MsgBox($MB_SYSTEMMODAL, "Information", "Share delete error : " & @error)
    MemoWrite("Share deleted")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Net_Share_ShareCheck

Function Reference

_Net_Share_ShareCheck

Checks whether or not a server is sharing a device

#include <NetShare.au3>
_Net_Share_ShareCheck ( $sServer, $sShare )

Parameters

$sServer | Specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is blank, the local computer is used.
$sShare | Specifies the name of the device to check for shared access

Return Value

Success: | the Type of the shared device. Can be a combination of: $STYPE_DISKTREE - Disk drive $STYPE_PRINTQ - Print queue $STYPE_DEVICE - Communication device $STYPE_IPC - IPC $STYPE_SPECIAL - Special share reserved for IPC$ or remote administration of the server $STYPE_TEMPORARY - A temporary share
Failure: | -1 - Share does not exist

Remarks

No special group membership is required to successfully execute this function.

Related

_Net_Share_ShareAdd, _Net_Share_ShareDel

See Also

Search NetShareCheck in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <NetShare.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $iI, $aInfo
    Local Const $sShareName = "AutoIt Share"

    ; Create GUI
    GUICreate("NetShare", 400, 300)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; See if the share exists
    If _Net_Share_ShareCheck(@ComputerName, $sShareName) = -1 Then
        ; Create a share on the local computer
        _Net_Share_ShareAdd(@ComputerName, $sShareName, 0, "C:\", "AutoIt Share Comment")
        If @error Then MsgBox($MB_SYSTEMMODAL, "Information", "Share add error : " & @error)
        MemoWrite("Share added")
    Else
        MemoWrite("Share exists")
    EndIf

    ; Show information about all local shares
    $aInfo = _Net_Share_ShareEnum(@ComputerName)
    MemoWrite("Entries read ............: " & $aInfo[0][0])
    For $iI = 1 To $aInfo[0][0]
        MemoWrite("Share name ..............: " & $aInfo[$iI][0])
        MemoWrite("Share type...............: " & _Net_Share_ResourceStr($aInfo[$iI][1]))
        MemoWrite("Comment .................: " & $aInfo[$iI][2])
        MemoWrite("Permissions .............: " & _Net_Share_PermStr($aInfo[$iI][3]))
        MemoWrite("Maximum connections .....: " & $aInfo[$iI][4])
        MemoWrite("Current connections .....: " & $aInfo[$iI][5])
        MemoWrite("Local path ..............: " & $aInfo[$iI][6])
        MemoWrite("Password ................: " & $aInfo[$iI][7])
        MemoWrite()
    Next

    ; Delete the share
    _Net_Share_ShareDel(@ComputerName, $sShareName)
    If @error Then MsgBox($MB_SYSTEMMODAL, "Information", "Share delete error : " & @error)
    MemoWrite("Share deleted")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Net_Share_ShareDel

Function Reference

_Net_Share_ShareDel

Deletes a share name from a server's list of shared resources

#include <NetShare.au3>
_Net_Share_ShareDel ( $sServer, $sShare )

Parameters

$sServer | Specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is blank, the local computer is used.
$sShare | Specifies the name of the share to delete

Return Value

Success: | True.
Failure: | False.

Remarks

Only members of the Administrators, Server Operators, or Power Users local group, or those with Server
Operator group membership, can successfully delete file shares with this function.
The Print Operator can delete printer shares.

Related

_Net_Share_SessionDel, _Net_Share_ShareAdd, _Net_Share_ShareCheck

See Also

Search NetShareDel in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <NetShare.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $iI, $aInfo
    Local Const $sShareName = "AutoIt Share"

    ; Create GUI
    GUICreate("NetShare", 400, 300)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; See if the share exists
    If _Net_Share_ShareCheck(@ComputerName, $sShareName) = -1 Then
        ; Create a share on the local computer
        _Net_Share_ShareAdd(@ComputerName, $sShareName, 0, "C:\", "AutoIt Share Comment")
        If @error Then MsgBox($MB_SYSTEMMODAL, "Information", "Share add error : " & @error)
        MemoWrite("Share added")
    Else
        MemoWrite("Share exists")
    EndIf

    ; Show information about all local shares
    $aInfo = _Net_Share_ShareEnum(@ComputerName)
    MemoWrite("Entries read ............: " & $aInfo[0][0])
    For $iI = 1 To $aInfo[0][0]
        MemoWrite("Share name ..............: " & $aInfo[$iI][0])
        MemoWrite("Share type...............: " & _Net_Share_ResourceStr($aInfo[$iI][1]))
        MemoWrite("Comment .................: " & $aInfo[$iI][2])
        MemoWrite("Permissions .............: " & _Net_Share_PermStr($aInfo[$iI][3]))
        MemoWrite("Maximum connections .....: " & $aInfo[$iI][4])
        MemoWrite("Current connections .....: " & $aInfo[$iI][5])
        MemoWrite("Local path ..............: " & $aInfo[$iI][6])
        MemoWrite("Password ................: " & $aInfo[$iI][7])
        MemoWrite()
    Next

    ; Delete the share
    _Net_Share_ShareDel(@ComputerName, $sShareName)
    If @error Then MsgBox($MB_SYSTEMMODAL, "Information", "Share delete error : " & @error)
    MemoWrite("Share deleted")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Net_Share_ShareEnum

Function Reference

_Net_Share_ShareEnum

Retrieves information about each shared resource on a server

#include <NetShare.au3>
_Net_Share_ShareEnum ( [$sServer = ""] )

Parameters

$sServer [optional] String that specifies the DNS or NetBIOS name of the remote server on which the function is to execute.
If this parameter is blank the local computer is used.

Return Value

Success: an array with the following format:
[0][0] - Number of entries in array
[1][0] - Share name of a resource
[1][1] - Type of the shared resource. Can be a combination of:
$STYPE_DISKTREE - Print queue
$STYPE_PRINTQ - Disk drive
$STYPE_DEVICE - Communication device
$STYPE_IPC - IPC
$STYPE_SPECIAL - Special share reserved for IPC$ or remote administration of the server
$STYPE_TEMPORARY - A temporary share
[1][2] - Contains an optional comment about the shared resource
[1][3] - Indicates the shared resource's permissions:
1 - Permission to read data from a resource and to execute
2 - Permission to write data to the resource
4 - Permission to create an instance of the resource
8 - Permission to execute the resource
16 - Permission to delete the resource
32 - Permission to modify the resource's attributes
64 - Permission to modify the permissions assigned to a resource
[1][4] - Maximum number of concurrent connections for the resource
[1][5] - Indicates the number of current connections to the resource
[1][6] - Specifies the local path for the shared resource
[1][7] - Specifies the share's password
Failure: sets the @error flag to non-zero.

Remarks

Administrator, Power User, Print Operator, or Server Operator group membership is required to execute this function.

Related

_Net_Share_ConnectionEnum, _Net_Share_FileEnum, _Net_Share_SessionEnum

See Also

Search NetShareEnum in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <NetShare.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $iI, $aInfo
    Local Const $sShareName = "AutoIt Share"

    ; Create GUI
    GUICreate("NetShare", 400, 300)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; See if the share exists
    If _Net_Share_ShareCheck(@ComputerName, $sShareName) = -1 Then
        ; Create a share on the local computer
        _Net_Share_ShareAdd(@ComputerName, $sShareName, 0, "C:\", "AutoIt Share Comment")
        If @error Then MsgBox($MB_SYSTEMMODAL, "Information", "Share add error : " & @error)
        MemoWrite("Share added")
    Else
        MemoWrite("Share exists")
    EndIf

    ; Show information about all local shares
    $aInfo = _Net_Share_ShareEnum(@ComputerName)
    MemoWrite("Entries read ............: " & $aInfo[0][0])
    For $iI = 1 To $aInfo[0][0]
        MemoWrite("Share name ..............: " & $aInfo[$iI][0])
        MemoWrite("Share type...............: " & _Net_Share_ResourceStr($aInfo[$iI][1]))
        MemoWrite("Comment .................: " & $aInfo[$iI][2])
        MemoWrite("Permissions .............: " & _Net_Share_PermStr($aInfo[$iI][3]))
        MemoWrite("Maximum connections .....: " & $aInfo[$iI][4])
        MemoWrite("Current connections .....: " & $aInfo[$iI][5])
        MemoWrite("Local path ..............: " & $aInfo[$iI][6])
        MemoWrite("Password ................: " & $aInfo[$iI][7])
        MemoWrite()
    Next

    ; Delete the share
    _Net_Share_ShareDel(@ComputerName, $sShareName)
    If @error Then MsgBox($MB_SYSTEMMODAL, "Information", "Share delete error : " & @error)
    MemoWrite("Share deleted")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Net_Share_ShareGetInfo

Function Reference

_Net_Share_ShareGetInfo

Retrieves information about a particular shared resource on a server

#include <NetShare.au3>
_Net_Share_ShareGetInfo ( $sServer, $sShare )

Parameters

$sServer | String that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is blank the local computer is used.
$sShare | Name of the share for which to return information

Return Value

Success: an array with the following format:
[0] - Share name of a resource
[1] - Type of the shared resource. Can be a combination of:
$STYPE_DISKTREE - Print queue
$STYPE_PRINTQ - Disk drive
$STYPE_DEVICE - Communication device
$STYPE_IPC - IPC
$STYPE_SPECIAL - Special share reserved for IPC$ or remote administration of the server
$STYPE_TEMPORARY - A temporary share
[2] - Contains an optional comment about the shared resource
[3] - Indicates the shared resource's permissions:
1 - Permission to read data from a resource and to execute
2 - Permission to write data to the resource
4 - Permission to create an instance of the resource
8 - Permission to execute the resource
16 - Permission to delete the resource
32 - Permission to modify the resource's attributes
64 - Permission to modify the permissions assigned to a resource
[4] - Indicates the maximum number of connections that the resource can have
[5] - Indicates the number of current connections to the resource
[6] - Specifies the local path for the shared resource
[7] - Specifies the share's password
Failure: sets the @error flag to non-zero.

Remarks

Only members of the Administrators, Server Operators, or Power Users local group, or those with Print or
Server Operator group membership, can successfully execute this function.

Related

_Net_Share_FileGetInfo, _Net_Share_SessionGetInfo, _Net_Share_ShareSetInfo

See Also

Search NetShareGetInfo in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <NetShare.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $aInfo
    Local Const $sShareName = "AutoIt Share"

    ; Create GUI
    GUICreate("NetShare", 400, 300)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; See if the share exists
    If _Net_Share_ShareCheck(@ComputerName, $sShareName) = -1 Then
        ; Create a share on the local computer
        _Net_Share_ShareAdd(@ComputerName, $sShareName, 0, "C:\", "AutoIt Share Comment")
        If @error Then MsgBox($MB_SYSTEMMODAL, "Information", "Share add error : " & @error)
        MemoWrite("Share added")
    Else
        MemoWrite("Share exists")
    EndIf

    ; Show information about the share we added
    $aInfo = _Net_Share_ShareGetInfo(@ComputerName, $sShareName)
    MemoWrite("Share name ..............: " & $aInfo[0])
    MemoWrite("Share type...............: " & _Net_Share_ResourceStr($aInfo[1]))
    MemoWrite("Comment .................: " & $aInfo[2])
    MemoWrite("Permissions .............: " & _Net_Share_PermStr($aInfo[3]))
    MemoWrite("Maximum connections .....: " & $aInfo[4])
    MemoWrite("Current connections .....: " & $aInfo[5])
    MemoWrite("Local path ..............: " & $aInfo[6])
    MemoWrite("Password ................: " & $aInfo[7])

    ; Delete the share
    _Net_Share_ShareDel(@ComputerName, $sShareName)
    If @error Then MsgBox($MB_SYSTEMMODAL, "Information", "Share delete error : " & @error)
    MemoWrite("Share deleted")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Net_Share_ShareSetInfo

Function Reference

_Net_Share_ShareSetInfo

Shares a server resource

#include <NetShare.au3>
_Net_Share_ShareSetInfo ( $sServer, $sShare, $sComment, $iMaxUses )

Parameters

$sServer | Specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is blank, the local computer is used.
$sShare | Specifies the name of the share to set information on
$sComment | String that contains an optional comment about the shared resource
$iMaxUses | Indicates the maximum number of connections that the resource can accommodate. The number of connections is unlimited if this value is –1.

Return Value

Success: | True.
Failure: | False.

Remarks

Only members of the Administrators or Power Users local group or those with Print or Server Operator group membership, can successfully execute this function.
The Print Operator can set information only about Printer shares.

Related

_Net_Share_ShareGetInfo

See Also

Search NetShareSetInfo in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <NetShare.au3>
#include <WindowsConstants.au3>

Global $g_idMemo

Example()

Func Example()
    Local $aInfo
    Local Const $sShareName = "AutoIt Share"

    ; Create GUI
    GUICreate("NetShare", 400, 300)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; See if the share exists
    If _Net_Share_ShareCheck(@ComputerName, $sShareName) = -1 Then
        ; Create a share on the local computer
        _Net_Share_ShareAdd(@ComputerName, $sShareName, 0, "C:\", "AutoIt Share Comment")
        If @error Then MsgBox($MB_SYSTEMMODAL, "Information", "Share add error : " & @error)
        MemoWrite("Share added")
    Else
        MemoWrite("Share exists")
    EndIf

    ; Change share information
    _Net_Share_ShareSetInfo(@ComputerName, $sShareName, "New Comment", 4)

    ; Show information about the share we added
    $aInfo = _Net_Share_ShareGetInfo(@ComputerName, $sShareName)
    MemoWrite("Share name ..............: " & $aInfo[0])
    MemoWrite("Share type...............: " & _Net_Share_ResourceStr($aInfo[1]))
    MemoWrite("Comment .................: " & $aInfo[2])
    MemoWrite("Permissions .............: " & _Net_Share_PermStr($aInfo[3]))
    MemoWrite("Maximum connections .....: " & $aInfo[4])
    MemoWrite("Current connections .....: " & $aInfo[5])
    MemoWrite("Local path ..............: " & $aInfo[6])
    MemoWrite("Password ................: " & $aInfo[7])

    ; Delete the share
    _Net_Share_ShareDel(@ComputerName, $sShareName)
    If @error Then MsgBox($MB_SYSTEMMODAL, "Information", "Share delete error : " & @error)
    MemoWrite("Share deleted")

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Net_Share_StatisticsGetSvr

Function Reference

_Net_Share_StatisticsGetSvr

Retrieves operating statistics for a server

#include <NetShare.au3>
_Net_Share_StatisticsGetSvr ( [$sServer = ""] )

Parameters

$sServer [optional] Specifies the DNS or NetBIOS name of the remote server on which the function is to execute.
If this parameter is blank, the local computer is used.

Return Value

Success: an array with the following format:
[ 0] - Indicates the time when statistics collection started.
The value is stored as the number of seconds that have elapsed since 00:00:00, January 1, 1970, GMT.
[ 1] - Indicates the number of times a file is opened on a server
[ 2] - Indicates the number of times a server device is opened
[ 3] - Indicates the number of server print jobs spooled
[ 4] - Indicates the number of times the server session started
[ 5] - Indicates the number of times the server session disconnected
[ 6] - Indicates the number of times the server sessions failed with error
[ 7] - Indicates the number of server password violations
[ 8] - Indicates the number of server access permission errors
[ 9] - Indicates the number of server system errors
[10] - Number of server bytes sent to the network
[11] - Number of server bytes received from the network
[12] - Indicates the average server response time (in milliseconds)
[13] - Indicates the number of times the server required a request buffer but failed to allocate one
[14] - Indicates the number of times the server required a big buffer but failed to allocate one
Failure: sets the @error flag to non-zero.

Remarks

No special group membership is required to obtain workstation statistics.
Only members of the Administrators or Server Operators local group can successfully execute this function on a remote server.

Related

_Net_Share_StatisticsGetWrk

See Also

Search NetStatisticsGet in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $aInfo

    ; Create GUI
    GUICreate("NetShare", 400, 300)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get server statistics
    $aInfo = _Net_Share_StatisticsGetSvr(@ComputerName)
    MemoWrite("Statistics started ......: " & $aInfo[0])
    MemoWrite("Times file opened .......: " & $aInfo[1])
    MemoWrite("Times device opened .....: " & $aInfo[2])
    MemoWrite("Print jobs spooled ......: " & $aInfo[3])
    MemoWrite("Sessions started ........: " & $aInfo[4])
    MemoWrite("Sessions disconnected ...: " & $aInfo[5])
    MemoWrite("Session errors ..........: " & $aInfo[6])
    MemoWrite("Password violations .....: " & $aInfo[7])
    MemoWrite("Permission errors .......: " & $aInfo[8])
    MemoWrite("Server system errors ....: " & $aInfo[9])
    MemoWrite("Network bytes sent ......: " & $aInfo[10])
    MemoWrite("Network bytes recv ......: " & $aInfo[11])
    MemoWrite("Average response time ...: " & $aInfo[12])
    MemoWrite("Req buffer failures .....: " & $aInfo[13])
    MemoWrite("Big buffer failures .....: " & $aInfo[14])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Net_Share_StatisticsGetWrk

Function Reference

_Net_Share_StatisticsGetWrk

Retrieves operating statistics for a workstation

#include <NetShare.au3>
_Net_Share_StatisticsGetWrk ( [$sWorkStation = ""] )

Parameters

$sWorkStation [optional] Specifies the DNS or NetBIOS name of the remote server on which the function is to execute.
If this parameter is blank, the local computer is used.

Return Value

Success: an array with the following format:
[ 0] - Statistics collection start time. The value is stored as the number of seconds elapsed since 00:00:00, January 1, 1970.
[ 1] - Bytes received by the workstation
[ 2] - Server message blocks (SMBs) received by the workstation
[ 3] - Bytes that have been read by paging I/O requests
[ 4] - Bytes that have been read by non-paging I/O requests
[ 5] - Bytes that have been read by cache I/O requests
[ 6] - Bytes that have been read by disk I/O requests
[ 7] - Bytes transmitted by the workstation
[ 8] - SMBs transmitted by the workstation
[ 9] - Bytes that have been written by paging I/O requests
[10] - Bytes that have been written by non-paging I/O requests
[11] - Bytes that have been written by cache I/O requests
[12] - Bytes that have been written by disk I/O requests
[13] - Network operations that failed to begin
[14] - Network operations that failed to complete
[15] - Read operations initiated by the workstation
[16] - Random access reads initiated by the workstation
[17] - Read requests the workstation has sent to servers
[18] - Read requests the workstation has sent to servers that are greater than twice the size of the server's negotiated buffer size.
[19] - Read requests the workstation has sent to servers that are less than 1/4 of the size of the server's negotiated buffer size.
[20] - Write operations initiated by the workstation
[21] - Random access writes initiated by the workstation
[22] - Write requests the workstation has sent to servers
[23] - Write requests the workstation has sent to servers that are greater than twice the size of the server's negotiated buffer size.
[24] - Write requests the workstation has sent to servers that are less than 1/4 of the size of the server's negotiated buffer size.
[25] - Raw read requests made by the workstation that have been denied
[26] - Raw write requests made by the workstation that have been denied
[27] - Network errors received by the workstation
[28] - Workstation sessions that were established
[29] - Imes the workstation attempted to create a session but failed
[30] - Connections that have failed
[31] - PCNET connections that have succeeded
[32] - LanManager 20 connections that have succeeded
[33] - LanManager 21 connections that have succeeded
[34] - Windows NT connections that have succeeded
[35] - Times the workstation was disconnected by a network server
[36] - Sessions that have expired on the workstation
[37] - Network connections established by the workstation
[38] - Failed network connections for the workstation
[39] - Current requests that have not been completed
Failure: sets the @error flag to non-zero.

Remarks

No special group membership is required to obtain workstation statistics.
Only members of the Administrators or Server Operators local group can successfully execute this function on a remote server.

Related

_Net_Share_StatisticsGetSvr

See Also

Search NetStatisticsGet in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $aInfo

    ; Create GUI
    GUICreate("NetShare", 400, 300)

    ; Create memo control
    $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    GUISetState(@SW_SHOW)

    ; Get workstation statistics
    $aInfo = _Net_Share_StatisticsGetWrk(@ComputerName)
    MemoWrite("NetStatisticsGetWrk")
    MemoWrite("Statistics started ......: " & $aInfo[0])
    MemoWrite("Bytes received ..........: " & $aInfo[1])
    MemoWrite("SMBs received ...........: " & $aInfo[2])
    MemoWrite("Paging I/O bytes ........: " & $aInfo[3])
    MemoWrite("Non-paging I/O bytes ....: " & $aInfo[4])
    MemoWrite("Cache I/O bytes ..... ...: " & $aInfo[5])
    MemoWrite("Disk I/O bytes ..........: " & $aInfo[6])
    MemoWrite("Bytes transmitted .......: " & $aInfo[7])
    MemoWrite("SMBs transmitted ........: " & $aInfo[8])
    MemoWrite("Paging I/O bytes ........: " & $aInfo[9])
    MemoWrite("Non-paging I/O bytes ....: " & $aInfo[10])
    MemoWrite("Cache I/O bytes .........: " & $aInfo[11])
    MemoWrite("Disk I/O bytes ..........: " & $aInfo[12])
    MemoWrite("Failed ops begin ........: " & $aInfo[13])
    MemoWrite("Failed ops completed ....: " & $aInfo[14])
    MemoWrite("Read operations .........: " & $aInfo[15])
    MemoWrite("Random access reads .....: " & $aInfo[16])
    MemoWrite("Read requests sent ......: " & $aInfo[17])
    MemoWrite("Read requests big .......: " & $aInfo[18])
    MemoWrite("Read requests small .....: " & $aInfo[19])
    MemoWrite("Write operations ........: " & $aInfo[20])
    MemoWrite("Random access writes ....: " & $aInfo[21])
    MemoWrite("Write requests sent .....: " & $aInfo[22])
    MemoWrite("Write requests big ......: " & $aInfo[23])
    MemoWrite("Write requests small ....: " & $aInfo[24])
    MemoWrite("Denied raw reads ........: " & $aInfo[25])
    MemoWrite("Denied raw writes .......: " & $aInfo[26])
    MemoWrite("Network errors ..........: " & $aInfo[27])
    MemoWrite("Sessions established ....: " & $aInfo[28])
    MemoWrite("Failed sessions .........: " & $aInfo[29])
    MemoWrite("Failed connections ......: " & $aInfo[30])
    MemoWrite("PCNET connections .......: " & $aInfo[31])
    MemoWrite("NetShare 20 connections .: " & $aInfo[32])
    MemoWrite("NetShare 21 connections .: " & $aInfo[33])
    MemoWrite("WinNT connections .......: " & $aInfo[34])
    MemoWrite("Disconnects .............: " & $aInfo[35])
    MemoWrite("Sessions expired ........: " & $aInfo[36])
    MemoWrite("Connections made ........: " & $aInfo[37])
    MemoWrite("Connections failed ......: " & $aInfo[38])
    MemoWrite("Incomplete requests .....: " & $aInfo[39])

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


User Defined Functions

Process user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIProc.au3>.

User Defined Function | Description
_ProcessGetName | Returns a string containing the process name that belongs to a given PID
_ProcessGetPriority | Get the priority of an open process
_RunDos | Executes a DOS command in a hidden command window


Function _ProcessGetName

Function Reference

_ProcessGetName

Returns a string containing the process name that belongs to a given PID

#include <Process.au3>
_ProcessGetName ( $iPID )

Parameters

$iPID The PID of a currently running process.

Return Value

Success: | the name of the process.
Failure: | an empty string and sets the @error flag to non-zero.
@error: | 1 - Process doesn't exist 2 - Error getting process list 3 - No processes found

Remarks

Supplementary to ProcessExists().

Example

#include <MsgBoxConstants.au3>
#include <Process.au3>

Run("notepad.exe")
WinWaitActive("[CLASS:Notepad]", "")
Local $iPid = WinGetProcess("[CLASS:Notepad]", "")
Local $sName = _ProcessGetName($iPid)

MsgBox($MB_SYSTEMMODAL, "Notepad - " & $iPid, $sName)


Function _ProcessGetPriority

Function Reference

_ProcessGetPriority

Get the priority of an open process

#include <Process.au3>
_ProcessGetPriority ( $vProcess )

Parameters

$vProcess The name or PID of the process to be examined.

Return Value

Success: | an integer corressponding to the processes's priority: 0 - Idle/Low 1 - Below Normal 2 - Normal 3 - Above Normal 4 - High 5 - Realtime
Failure: | -1 and sets the @error flag to non-zero.

Example

#include <MsgBoxConstants.au3>
#include <Process.au3>

Local $i_Priority_Level, $i_Notepad_PID, $i_ArrayItem
Local $a_RunLevels[3] = [0, 2, 4] ;low, normal, high priorities
; Get Priority Level of this instance of AutoIt Scripting Engine
$i_Priority_Level = _ProcessGetPriority(@AutoItPID)
MsgBox($MB_SYSTEMMODAL, "AutoIt Script", "Should be 2: " & $i_Priority_Level)
$i_Notepad_PID = Run(@ComSpec & ' /k notepad.exe', '', @SW_HIDE)
For $i_ArrayItem = 0 To 2
    ProcessSetPriority($i_Notepad_PID, $a_RunLevels[$i_ArrayItem])
    $i_Priority_Level = _ProcessGetPriority($i_Notepad_PID)
    MsgBox($MB_SYSTEMMODAL, "Notepad Priority", "Should be " & $a_RunLevels[$i_ArrayItem] & ": " & $i_Priority_Level)
Next
ProcessClose('notepad.exe')


Function _RunDos

Function Reference

_RunDos

Executes a DOS command in a hidden command window

#include <Process.au3>
_RunDos ( $sCommand )

Parameters

$sCommand Command to execute

Return Value

Success: | the exit code of the command.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

The script waits until the command has been executed.

Example

#include <Process.au3>

Local $iRc = _RunDos("start Http://www.autoitscript.com")


User Defined Functions

ScreenCapture user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <ScreenCapture.au3>.

User Defined Function | Description
_ScreenCapture_Capture | Captures a region of the screen
_ScreenCapture_CaptureWnd | Captures a screen shot of a specified window or controlID
_ScreenCapture_SaveImage | Saves an image to file
_ScreenCapture_SetBMPFormat | Sets the bit format that will be used for BMP screen captures
_ScreenCapture_SetJPGQuality | Sets the quality level that will be used for JPEG screen captures
_ScreenCapture_SetTIFColorDepth | Sets the color depth used for TIFF screen captures
_ScreenCapture_SetTIFCompression | Sets the compression used for TIFF screen captures


Function _ScreenCapture_Capture

Function Reference

_ScreenCapture_Capture

Captures a region of the screen

#include <ScreenCapture.au3>
_ScreenCapture_Capture ( [$sFileName = "" [, $iLeft = 0 [, $iTop = 0 [, $iRight = -1 [, $iBottom = -1 [, $bCursor = True]]]]]] )

Parameters

$sFileName | [optional] Full path and extension of the image file
$iLeft | [optional] X coordinate of the upper left corner of the rectangle
$iTop | [optional] Y coordinate of the upper left corner of the rectangle
$iRight | [optional] X coordinate of the lower right corner of the rectangle. If this is -1, the current screen width will be used.
$iBottom | [optional] Y coordinate of the lower right corner of the rectangle. If this is -1, the current screen height will be used.
$bCursor | [optional] If True the cursor will be captured with the image

Return Value

Success: | a handle to an HBITMAP if $sFileName is empty, or True If called with $sFileName and the image is successfully saved.
Failure: | Set @error to non-zero.

Remarks

If a handle is returned, it must be released using _WinAPI_DeleteObject().

Related

_ScreenCapture_SaveImage, _WinAPI_DeleteObject

Example

#include <ScreenCapture.au3>

Example()

Func Example()
    ; Capture full screen
    _ScreenCapture_Capture(@MyDocumentsDir & "\GDIPlus_Image1.jpg")

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image1.jpg")

    ; Capture region
    _ScreenCapture_Capture(@MyDocumentsDir & "\GDIPlus_Image2.jpg", 0, 0, 796, 596)

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image2.jpg")
EndFunc   ;==>Example


Function _ScreenCapture_CaptureWnd

Function Reference

_ScreenCapture_CaptureWnd

Captures a screen shot of a specified window or controlID

#include <ScreenCapture.au3>
_ScreenCapture_CaptureWnd ( $sFileName, $hWnd [, $iLeft = 0 [, $iTop = 0 [, $iRight = -1 [, $iBottom = -1 [, $bCursor = True]]]]] )

Parameters

$sFileName | Full path and extension of the image file
$hWnd | Handle to the window to be captured
$iLeft | [optional] X coordinate of the upper left corner of the client rectangle
$iTop | [optional] Y coordinate of the upper left corner of the client rectangle
$iRight | [optional] X coordinate of the lower right corner of the rectangle
$iBottom | [optional] Y coordinate of the lower right corner of the rectangle
$bCursor | [optional] If True the cursor will be captured with the image

Return Value

Success: | a handle to an HBITMAP if $sFileName is empty, or True If called with $sFileName and the image is successfully saved.
Failure: | Set @error to non-zero.

Remarks

All coordinates are in client coordinate mode.

If a handle is returned, it must be released using _WinAPI_DeleteObject().

Related

_WinAPI_DeleteObject

Example

#include <ScreenCapture.au3>

Example()

Func Example()
    Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Screen Capture", 400, 300)
    GUISetState(@SW_SHOW)
    Sleep(250)

    ; Capture window
    _ScreenCapture_CaptureWnd(@MyDocumentsDir & "\GDIPlus_Image.jpg", $hGUI)

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
EndFunc   ;==>Example


Function _ScreenCapture_SaveImage

Function Reference

_ScreenCapture_SaveImage

Saves an image to file

#include <ScreenCapture.au3>
_ScreenCapture_SaveImage ( $sFileName, $hBitmap [, $bFreeBmp = True] )

Parameters

$sFileName | Full path and extension of the bitmap file to be saved
$hBitmap | HBITMAP handle
$bFreeBmp | [optional] If True, $hBitmap will be freed on a successful save (default)

Return Value

Success: | True.
Failure: | False.

Remarks

This function saves a bitmap to file, converting it to the image format specified by the file name extension.
For Windows XP, the valid extensions are BMP, GIF, JPEG, PNG and TIF.

Related

_ScreenCapture_Capture

Example

#include <ScreenCapture.au3>

Example()

Func Example()
    Local $hBmp

    ; Capture full screen
    $hBmp = _ScreenCapture_Capture("")

    ; Save bitmap to file
    _ScreenCapture_SaveImage(@MyDocumentsDir & "\GDIPlus_Image.jpg", $hBmp)

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
EndFunc   ;==>Example


Function _ScreenCapture_SetBMPFormat

Function Reference

_ScreenCapture_SetBMPFormat

Sets the bit format that will be used for BMP screen captures

#include <ScreenCapture.au3>
_ScreenCapture_SetBMPFormat ( $iFormat )

Parameters

$iFormat Image bits per pixel (bpp) setting:
0 = 16 bpp; 5 bits for each RGB component
1 = 16 bpp; 5 bits for red, 6 bits for green and 5 bits blue
2 = 24 bpp; 8 bits for each RGB component
3 = 32 bpp; 8 bits for each RGB component. No alpha component.
4 = 32 bpp; 8 bits for each RGB and alpha component

Return Value

None.

Remarks

If not explicitly set, BMP screen captures default to 24 bpp

Example

#include <ScreenCapture.au3>

Example()

Func Example()
    ; Capture full screen
    _ScreenCapture_SetBMPFormat(0)
    _ScreenCapture_Capture(@MyDocumentsDir & "\GDIPlus_Image.bmp")

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.bmp")
EndFunc   ;==>Example


Function _ScreenCapture_SetJPGQuality

Function Reference

_ScreenCapture_SetJPGQuality

Sets the quality level that will be used for JPEG screen captures

#include <ScreenCapture.au3>
_ScreenCapture_SetJPGQuality ( $iQuality )

Parameters

$iQuality The quality level of the image. Must be in the range of 0 to 100.

Return Value

None.

Remarks

If not explicitly set, JPEG screen captures default to a quality level of 100


Function _ScreenCapture_SetTIFColorDepth

Function Reference

_ScreenCapture_SetTIFColorDepth

Sets the color depth used for TIFF screen captures

#include <ScreenCapture.au3>
_ScreenCapture_SetTIFColorDepth ( $iDepth )

Parameters

$iDepth Image color depth:
0 - Default encoder color depth
24 - 24 bit
32 - 32 bit

Return Value

None.

Remarks

If not explicitly set, TIFF screen captures default to 24 bits.

Related

_ScreenCapture_SetTIFCompression


Function _ScreenCapture_SetTIFCompression

Function Reference

_ScreenCapture_SetTIFCompression

Sets the compression used for TIFF screen captures

#include <ScreenCapture.au3>
_ScreenCapture_SetTIFCompression ( $iCompress )

Parameters

$iCompress Image compression type:
0 - Default encoder compression
1 - No compression
2 - LZW compression

Return Value

None.

Remarks

If not explicitly set, TIF screen captures default to LZW compression.

Related

_ScreenCapture_SetTIFColorDepth


User Defined Functions

Security user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <Security.au3>.

User Defined Function | Description
_Security__AdjustTokenPrivileges | Enables or disables privileges in the specified access token
_Security__CreateProcessWithToken | Creates a new process and its primary thread running in the security context of the specified token
_Security__DuplicateTokenEx | Creates a new access token that duplicates an existing token
_Security__GetAccountSid | Retrieves the security identifier (SID) for an account
_Security__GetLengthSid | Returns the length, in bytes, of a valid SID
_Security__GetTokenInformation | Retrieves a specified type of information about an access token
_Security__ImpersonateSelf | Obtains an access token that impersonates the calling process security context
_Security__IsValidSid | Validates a SID
_Security__LookupAccountName | Retrieves a security identifier (SID) for the account and the name of the domain
_Security__LookupAccountSid | Retrieves the name of the account for a SID
_Security__LookupPrivilegeValue | Retrieves the locally unique identifier (LUID) for a privilege value in form of 64bit integer
_Security__OpenProcessToken | Returns the access token associated with a process
_Security__OpenThreadToken | Opens the access token associated with a thread
_Security__OpenThreadTokenEx | Opens the access token associated with a thread, impersonating the client's security context if required
_Security__SetPrivilege | Enables or disables a local token privilege
_Security__SetTokenInformation | Sets various types of information for a specified access token
_Security__SidToStringSid | Converts a binary SID to a string
_Security__SidTypeStr | Converts a SID type to string form
_Security__StringSidToSid | Converts a String SID to a binary SID


Function _Security__AdjustTokenPrivileges

Function Reference

_Security__AdjustTokenPrivileges

Enables or disables privileges in the specified access token

#include <Security.au3>
_Security__AdjustTokenPrivileges ( $hToken, $bDisableAll, $tNewState, $iBufferLen [, $tPrevState = 0 [, $pRequired = 0]] )

Parameters

$hToken | Handle to the access token that contains privileges to be modified
$bDisableAll | If True, the function disables all privileges and ignores the NewState parameter. If False, the function modifies privileges based on the information pointed to by the $pNewState parameter.
$tNewState | A $tagTOKEN_PRIVILEGES structure or a pointer to it that contains the privilege and it's attributes
$iBufferLen | Size, in bytes, of the buffer pointed to by $pNewState
$tPrevState | [optional] A $tagTOKEN_PRIVILEGES structure or a pointer to it that specifies the previous state of the privilege that the function modified. This can be 0.
$pRequired | [optional] Pointer to a variable that receives the required size, in bytes, of the buffer pointed to by $tPrevState. This parameter can be 0 if $tPrevState is 0.

Return Value

Success: | True.
Failure: | False.

Remarks

This function cannot add new privileges to an access token. It can only enable or disable the token's existing privileges.

Related

$tagTOKEN_PRIVILEGES

See Also

Search AdjustTokenPrivileges in MSDN Library.

Example

#RequireAdmin ; for this example to have sense

#include <MsgBoxConstants.au3>
#include <Security.au3>
#include <SecurityConstants.au3>
#include <WinAPI.au3>

Local $hToken = _Security__OpenProcessToken(_WinAPI_GetCurrentProcess(), $TOKEN_ALL_ACCESS)
If $hToken Then
    ; $hToken is this process' token with $TOKEN_ALL_ACCESS access

    ; Disable all privileges for this token
    If _Security__AdjustTokenPrivileges($hToken, True, 0, 0) Then
        ;... Do whatever with this token now and here...
        MsgBox($MB_SYSTEMMODAL, "TokenPrivileges", "All TokenPrivileges disabled!")
    EndIf

    ; Close handle when done
    _WinAPI_CloseHandle($hToken)
EndIf


Function _Security__CreateProcessWithToken

Function Reference

_Security__CreateProcessWithToken

Creates a new process and its primary thread running in the security context of the specified token

#include <Security.au3>
_Security__CreateProcessWithToken ( $hToken, $iLogonFlags, $sCommandLine, $iCreationFlags, $sCurDir, $tSTARTUPINFO, $tPROCESS_INFORMATION )

Parameters

$hToken | A handle to the primary token that represents a user
$iLogonFlags | The logon option
$sCommandLine | The command line to be executed
$iCreationFlags | The flags that control how the process is created
$sCurDir | The full path to the current directory for the process
$tSTARTUPINFO | A (pointer to a) STARTUPINFO structure
$tPROCESS_INFORMATION | A (pointer to a) PROCESS_INFORMATION structure that receives identification information for the new process

Return Value

Success: | True.
Failure: | False.

Remarks

The module name must be the first white space–delimited token in the $sCommandLine parameter.

Related

_Security__DuplicateTokenEx

See Also

Search CreateProcessWithTokenW in MSDN Library.

Example

#RequireAdmin ; for this example to have sense

#include <MsgBoxConstants.au3>
#include <ProcessConstants.au3>
#include <Security.au3>
#include <SecurityConstants.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>

Example_ProcessWithTok()

Func Example_ProcessWithTok()
    ; Run AutoIt non-elevated regardless of having full administrator rights obtained using #RequireAdmin or by any other means
    _RunNonElevated('"' & @AutoItExe & '" /AutoIt3ExecuteLine  "MsgBox(4096, ''RunNonElevated'', ''IsAdmin() = '' & "IsAdmin()" & '', PID = '' & "@AutoItPID")"')
EndFunc   ;==>Example_ProcessWithTok

Func _RunNonElevated($sCommandLine = "")
    If Not IsAdmin() Then Return Run($sCommandLine) ; if current process is run non-elevated then just Run new one.

    ; Structures needed for creating process
    Local $tSTARTUPINFO = DllStructCreate($tagSTARTUPINFO)
    Local $tPROCESS_INFORMATION = DllStructCreate($tagPROCESS_INFORMATION)

    ; Process handle of some process that's run non-elevated. For example "Explorer"
    Local $hProcess = _WinAPI_OpenProcess($PROCESS_ALL_ACCESS, 0, ProcessExists("explorer.exe"))

    ; If successful
    If $hProcess Then
        ; Token...
        Local $hTokOriginal = _Security__OpenProcessToken($hProcess, $TOKEN_ALL_ACCESS)
        ; Process handle is no longer needed. Close it
        _WinAPI_CloseHandle($hProcess)
        ; If successful
        If $hTokOriginal Then
            ; Duplicate the original token
            Local $hTokDuplicate = _Security__DuplicateTokenEx($hTokOriginal, $TOKEN_ALL_ACCESS, $SECURITYIMPERSONATION, $TOKENPRIMARY)
            ; Close the original token
            _WinAPI_CloseHandle($hTokOriginal)
            ; If successful
            If $hTokDuplicate Then
                ; Create process with this new token
                _Security__CreateProcessWithToken($hTokDuplicate, 0, $sCommandLine, 0, @ScriptDir, $tSTARTUPINFO, $tPROCESS_INFORMATION)

                ; Close that token
                _WinAPI_CloseHandle($hTokDuplicate)
                ; Close get handles
                _WinAPI_CloseHandle(DllStructGetData($tPROCESS_INFORMATION, "hProcess"))
                _WinAPI_CloseHandle(DllStructGetData($tPROCESS_INFORMATION, "hThread"))
                ; Return PID of newly created process
                Return DllStructGetData($tPROCESS_INFORMATION, "ProcessID")
            EndIf
        EndIf
    EndIf
EndFunc   ;==>_RunNonElevated


Function _Security__DuplicateTokenEx

Function Reference

_Security__DuplicateTokenEx

Creates a new access token that duplicates an existing token

#include <Security.au3>
_Security__DuplicateTokenEx ( $hExistingToken, $iDesiredAccess, $iImpersonationLevel, $iTokenType )

Parameters

$hExistingToken | A handle to an access token opened with TOKEN_DUPLICATE access
$iDesiredAccess | The requested access rights for the new token
$iImpersonationLevel | The impersonation level of the new token
$iTokenType | The type of new token

Return Value

Success: | a handle that receives the new token.
Failure: | 0.

Related

_Security__OpenProcessToken, _Security__OpenThreadToken, _Security__OpenThreadTokenEx

See Also

Search DuplicateTokenEx in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <ProcessConstants.au3>
#include <Security.au3>
#include <SecurityConstants.au3>
#include <WinAPI.au3>

Local $hProcess = _WinAPI_OpenProcess($PROCESS_ALL_ACCESS, 0, ProcessExists("explorer.exe"))
; If successful
If $hProcess Then
    ; Token...
    Local $hTokOriginal = _Security__OpenProcessToken($hProcess, $TOKEN_ALL_ACCESS)
    ; Process handle is no longer needed. Close it
    _WinAPI_CloseHandle($hProcess)
    ; If successful
    If $hTokOriginal Then
        ; Duplicate the original token
        Local $hTokDuplicate = _Security__DuplicateTokenEx($hTokOriginal, $TOKEN_ALL_ACCESS, $SECURITYIMPERSONATION, $TOKENPRIMARY)
        ; Close the original token
        _WinAPI_CloseHandle($hTokOriginal)
        ; What's created is a primary token (!)
        ; ... Do whatever with that token here ...

        MsgBox($MB_SYSTEMMODAL, "DuplicateTokenEx", "$hTokDuplicate = " & $hTokDuplicate)

        ; Close that token when done
        _WinAPI_CloseHandle($hTokDuplicate)
    EndIf
EndIf


Function _Security__GetAccountSid

Function Reference

_Security__GetAccountSid

Retrieves the security identifier (SID) for an account

#include <Security.au3>
_Security__GetAccountSid ( $sAccount [, $sSystem = ""] )

Parameters

$sAccount | Specifies the account name. Use a fully qualified string in the domain_name\user_name format to ensure that the function finds the account in the desired domain.
$sSystem | [optional] Name of the system. This string can be the name of a remote computer. If this string is blank, the account name translation begins on the local system. If the name cannot be resolved on the local system, this function will try to resolve the name using domain controllers trusted by the local system.

Return Value

Success: | a binary SID in a byte structure.
Failure: | 0.

Related

_Security__LookupAccountSid

Example

#include <Security.au3>

Local $tSID = _Security__GetAccountSid(@UserName)
If Not @error Then
    ; $tSID is structure filled with SID data for spesified account
    ; ... The rest of the script here...
EndIf


Function _Security__GetLengthSid

Function Reference

_Security__GetLengthSid

Returns the length, in bytes, of a valid SID

#include <Security.au3>
_Security__GetLengthSid ( $pSID )

Parameters

$pSID Pointer to a SID

Return Value

Success: | the length of SID.
Failure: | 0.

Related

_Security__IsValidSid

See Also

Search GetLengthSid in MSDN Library.

Example

#include <Security.au3>

Local $tSID = _Security__GetAccountSid(@UserName)
If Not @error Then
    ; $tSID is structure filled with SID data for spesified account
    ; Check its length:
    Local $iLength = _Security__GetLengthSid($tSID)
    ConsoleWrite("The length of SID is: " & $iLength & " bytes" & @CRLF)

    ; ... The rest of the script here...
EndIf


Function _Security__GetTokenInformation

Function Reference

_Security__GetTokenInformation

Retrieves a specified type of information about an access token

#include <Security.au3>
_Security__GetTokenInformation ( $hToken, $iClass )

Parameters

$hToken | A handle to an access token from which information is retrieved. If $iClass specifies $sTokenSource, the handle must have $TOKEN_QUERY_SOURCE access. For all other $iClass values, the handle must have $TOKEN_QUERY access.
$iClass | Specifies a value to identify the type of information the function retrieves

Return Value

Success: | a byte structure filled with the requested information.
Failure: | 0.

Related

_Security__OpenProcessToken, _Security__OpenThreadToken, _Security__OpenThreadTokenEx

See Also

Search GetTokenInformation in MSDN Library.

Example

#include <Security.au3>
#include <SecurityConstants.au3>
#include <WinAPI.au3>

Example_TokInfo()

Func Example_TokInfo()
    Local $hProcess = _WinAPI_GetCurrentProcess()
    If @error Then Return ; check for possible errors

    Local $hToken = _Security__OpenProcessToken($hProcess, $TOKEN_ALL_ACCESS)
    ; If token is get...
    If $hToken Then
        ; Get information about the type of this token:
        Local $tInfo = _Security__GetTokenInformation($hToken, $TOKENTYPE)
        ; The result will be raw binary data. For $TOKENTYPE it's TOKEN_TYPE value (enum value). Reinterpreting as "int" type therefore:
        Local $iTokenType = DllStructGetData(DllStructCreate("int", DllStructGetPtr($tInfo)), 1)

        ConsoleWrite("Token type is " & $iTokenType & @CRLF) ; Can be value of either $TOKENPRIMARY or $TOKENIMPERSONATION

        ; Close the token handle
        _WinAPI_CloseHandle($hToken)
    EndIf
EndFunc   ;==>Example_TokInfo


Function _Security__ImpersonateSelf

Function Reference

_Security__ImpersonateSelf

Obtains an access token that impersonates the calling process security context

#include <Security.au3>
_Security__ImpersonateSelf ( [$iLevel = $SECURITYIMPERSONATION] )

Parameters

$iLevel [optional] Impersonation level of the new token:
$SECURITYANONYMOUS. The server process cannot obtain identification information about the client, and it cannot impersonate the client.
$SECURITYIDENTIFICATION. The server process can obtain information about the client, such as security identifiers and privileges, but it cannot impersonate the client.
$SECURITYIMPERSONATION. The server process can impersonate the clients security context on its local system. The server cannot impersonate the client on remote systems.
$SECURITYDELEGATION. The server process can impersonate the client's security context on remote systems.

Return Value

Success: | True.
Failure: | False.

Related

_Security__OpenThreadTokenEx

See Also

Search ImpersonateSelf in MSDN Library.

Example

#include <Security.au3>
#include <SecurityConstants.au3>
#include <WinAPI.au3>

Local $hToken = _Security__OpenThreadToken($TOKEN_ADJUST_PRIVILEGES)
If $hToken Then
    _WinAPI_CloseHandle($hToken)
Else
    ConsoleWrite("_Security__OpenThreadToken failed with error description: " & _WinAPI_GetLastErrorMessage() & @CRLF)
    ConsoleWrite("New attempt..." & @CRLF)

    ; Read remarks for  _Security__OpenThreadToken function
    _Security__ImpersonateSelf()
    $hToken = _Security__OpenThreadToken($TOKEN_ADJUST_PRIVILEGES)
    If $hToken Then
        ConsoleWrite(">>> SUCCESS, $hToken = " & $hToken & @CRLF)
        _WinAPI_CloseHandle($hToken)
    Else
        ConsoleWrite("!FAILED" & @CRLF)
    EndIf
EndIf


Function _Security__IsValidSid

Function Reference

_Security__IsValidSid

Validates a SID

#include <Security.au3>
_Security__IsValidSid ( $pSID )

Parameters

$pSID Pointer to a SID

Return Value

True: | the SID is valid.
False: | the SID is not valid.

Related

_Security__GetLengthSid

See Also

Search IsValidSid in MSDN Library.

Example

#include <Security.au3>

Local $tSID = _Security__GetAccountSid(@ComputerName)
If Not @error Then
    ; $tSID is structure filled with SID data for spesified account
    ; Check this SID for validity:
    Local $bValid = _Security__IsValidSid($tSID)
    If $bValid Then
        ConsoleWrite("The SID is valid." & @CRLF)
        ; ... The rest of the script here...
    Else
        ConsoleWrite("The SID is NOT valid." & @CRLF)
        Exit
    EndIf
EndIf


Function _Security__LookupAccountName

Function Reference

_Security__LookupAccountName

Retrieves a security identifier (SID) for the account and the name of the domain

#include <Security.au3>
_Security__LookupAccountName ( $sAccount [, $sSystem = ""] )

Parameters

$sAccount | Specifies the account name. Use a fully qualified string in the domain_name\user_name format to ensure that the function finds the account in the desired domain.
$sSystem | [optional] Name of the system. This string can be the name of a remote computer. If this string is blank, the account name translation begins on the local system. If the name cannot be resolved on the local system, this function will try to resolve the name using domain controllers trusted by the local system.

Return Value

Success: | an array with the following format: $aAcct[0] - SID String $aAcct[1] - Domain name $aAcct[2] - SID type
Failure: | sets the @error flag to non-zero.

Related

_Security__LookupAccountSid

See Also

Search LookupAccountName in MSDN Library.

Example

#include <Security.au3>

Local $aArrayOfData = _Security__LookupAccountName(@UserName)

; Print returned data if no error occured
If IsArray($aArrayOfData) Then
    ConsoleWrite("SID String = " & $aArrayOfData[0] & @CRLF)
    ConsoleWrite("Domain name = " & $aArrayOfData[1] & @CRLF)
    ConsoleWrite("SID type = " & _Security__SidTypeStr($aArrayOfData[2]) & @CRLF)
EndIf


Function _Security__LookupAccountSid

Function Reference

_Security__LookupAccountSid

Retrieves the name of the account for a SID

#include <Security.au3>
_Security__LookupAccountSid ( $vSID [, $sSystem = ""] )

Parameters

$vSID | Either a binary SID or a string SID
$sSystem | [optional] The name of a remote computer. By default the local system.

Return Value

Success: | an array with the following format: $aAcct[0] - Account name $aAcct[1] - Domain name $aAcct[2] - SID type
Failure: | sets the @error flag to non-zero.

Related

_Security__GetAccountSid, _Security__LookupAccountName

See Also

Search LookupAccountSid in MSDN Library.

Example

#include <Security.au3>
#include <SecurityConstants.au3>

Local $aArrayOfData = _Security__LookupAccountSid($SID_ALL_SERVICES)

; Print returned data if no error occured
If IsArray($aArrayOfData) Then
    ConsoleWrite("Account name = " & $aArrayOfData[0] & @CRLF)
    ConsoleWrite("Domain name = " & $aArrayOfData[1] & @CRLF)
    ConsoleWrite("SID type = " & _Security__SidTypeStr($aArrayOfData[2]) & @CRLF)
EndIf


Function _Security__LookupPrivilegeValue

Function Reference

_Security__LookupPrivilegeValue

Retrieves the locally unique identifier (LUID) for a privilege value in form of 64bit integer

#include <Security.au3>
_Security__LookupPrivilegeValue ( $sSystem, $sName )

Parameters

$sSystem | Specifies the name of the system on which the privilege name is retrieved. If blank, the function attempts to find the privilege name on the local system.
$sName | Specifies the name of the privilege.

Return Value

Success: | the LUID by which the privilege is known.
Failure: | 0.

Related

_Security__SetPrivilege

See Also

Search LookupPrivilegeValue in MSDN Library.

Example

#include <Security.au3>
#include <SecurityConstants.au3>

Local $vLUID = _Security__LookupPrivilegeValue("", $SE_DEBUG_NAME)
; $vLUID represents LUID for a privilege value in form of 64bit integer. Print it out of curiosity:
ConsoleWrite("$vLUID = " & $vLUID & @CRLF)
; ... The rest of the script here...


Function _Security__OpenProcessToken

Function Reference

_Security__OpenProcessToken

Returns the access token associated with a process

#include <Security.au3>
_Security__OpenProcessToken ( $hProcess, $iAccess )

Parameters

$hProcess | A handle to the process whose access token is opened. The process must have been given the $PROCESS_QUERY_INFORMATION access permission.
$iAccess | Specifies an access mask that specifies the requested types of access to the access token.

Return Value

Success: | an handle that identifies the newly opened access token when the function returns.
Failure: | 0.

Remarks

Close the access token handle returned by calling _WinAPI_CloseHandle().

Related

_Security__OpenThreadToken

See Also

Search OpenProcessToken in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <Security.au3>
#include <SecurityConstants.au3>
#include <WinAPI.au3>

Local $hToken = _Security__OpenProcessToken(_WinAPI_GetCurrentProcess(), $TOKEN_QUERY)
If $hToken Then
    ; $hToken is this process' token with $TOKEN_QUERY access

    ;... Do whatever with this token now and here...
    MsgBox($MB_SYSTEMMODAL, "OpenProcessToken", "$hToken = " & $hToken)

    ; Close handle when done
    _WinAPI_CloseHandle($hToken)
EndIf


Function _Security__OpenThreadToken

Function Reference

_Security__OpenThreadToken

Opens the access token associated with a thread

#include <Security.au3>
_Security__OpenThreadToken ( $iAccess [, $hThread = 0 [, $bOpenAsSelf = False]] )

Parameters

$iAccess | Access mask that specifies the requested types of access to the access token. These requested access types are reconciled against the token's discretionary access control list (DACL) to determine which accesses are granted or denied.
$hThread | [optional] Handle to the thread whose access token is opened
$bOpenAsSelf | [optional] Indicates whether the access check is to be made against the security context of the thread calling the OpenThreadToken function or against the security context of the process for the calling thread. If this parameter is False, the access check is performed using the security context for the calling thread. If the thread is impersonating a client, this security context can be that of a client process. If this parameter is True, the access check is made using the security context of the process for the calling thread.

Return Value

Success: | a handle to the newly opened access token.
Failure: | 0.

Remarks

OpenThreadToken will fail if not impersonating.

Related

_Security__OpenProcessToken, _Security__OpenThreadTokenEx

See Also

Search OpenThreadToken in MSDN Library.

Example

#include <Security.au3>
#include <SecurityConstants.au3>
#include <WinAPI.au3>

Local $hToken = _Security__OpenThreadToken($TOKEN_ADJUST_PRIVILEGES)
If $hToken Then
    ConsoleWrite("$hToken is " & $hToken & @CRLF)
    ; $hToken it this thread's token with $TOKEN_ADJUST_PRIVILEGES access

    ; ... The rest of the token work here...

    _WinAPI_CloseHandle($hToken)
Else
    ConsoleWrite(_WinAPI_GetLastErrorMessage())
    ; Read remarks for _Security__OpenThreadToken
EndIf


Function _Security__OpenThreadTokenEx

Function Reference

_Security__OpenThreadTokenEx

Opens the access token associated with a thread, impersonating the client's security context if required

#include <Security.au3>
_Security__OpenThreadTokenEx ( $iAccess [, $hThread = 0 [, $bOpenAsSelf = False]] )

Parameters

$iAccess | Access mask that specifies the requested types of access to the access token. These requested access types are reconciled against the token's discretionary access control list (DACL) to determine which accesses are granted or denied.
$hThread | [optional] Handle to the thread whose access token is opened
$bOpenAsSelf | [optional] Indicates whether the access check is to be made against the security context of the thread calling the OpenThreadToken function or against the security context of the process for the calling thread. If this parameter is False, the access check is performed using the security context for the calling thread. If the thread is impersonating a client, this security context can be that of a client process. If this parameter is True, the access check is made using the security context of the process for the calling thread.

Return Value

Success: | a handle to the newly opened access token.
Failure: | 0.

Related

_Security__ImpersonateSelf, _Security__OpenThreadToken

Example

#include <MsgBoxConstants.au3>
#include <Security.au3>
#include <SecurityConstants.au3>
#include <WinAPI.au3>

Local $hToken = _Security__OpenThreadTokenEx($TOKEN_ADJUST_PRIVILEGES)
If $hToken Then
    ; $hToken is this thread's token with $TOKEN_ADJUST_PRIVILEGES access
    MsgBox($MB_SYSTEMMODAL, "OpenThreadTokenEx", "$hToken is " & $hToken)

    _WinAPI_CloseHandle($hToken)
Else
    ConsoleWrite("! _Security__OpenThreadTokenEx failed with error description: " & _WinAPI_GetLastErrorMessage())
EndIf


Function _Security__SetPrivilege

Function Reference

_Security__SetPrivilege

Enables or disables a local token privilege

#include <Security.au3>
_Security__SetPrivilege ( $hToken, $sPrivilege, $bEnable )

Parameters

$hToken | Handle to a token
$sPrivilege | Privilege name
$bEnable | Privilege setting: True - Enable privilege False - Disable privilege

Return Value

Success: | True.
Failure: | False.

Related

_Security__AdjustTokenPrivileges

Example

#RequireAdmin ; for this example to have sense

#include <Date.au3>
#include <MsgBoxConstants.au3>
#include <Security.au3>
#include <SecurityConstants.au3>
#include <WinAPI.au3>

Local $hToken = _Security__OpenProcessToken(_WinAPI_GetCurrentProcess(), $TOKEN_ALL_ACCESS)
If $hToken Then
    ; $hToken it this process' token with $TOKEN_ALL_ACCESS access

    ; Enable SeDebugPrivilege for this token
    If _Security__SetPrivilege($hToken, $SE_DEBUG_NAME, True) Then
        ;... Do whatever with this token now and here...
        MsgBox($MB_SYSTEMMODAL, "TokenPrivileges", $SE_DEBUG_NAME & " enabled!")
        ; Disable
        _Security__SetPrivilege($hToken, $SE_DEBUG_NAME, False)
        MsgBox($MB_SYSTEMMODAL, "TokenPrivileges", $SE_DEBUG_NAME & " disabled!")
    EndIf

    ; Close handle when done
    _WinAPI_CloseHandle($hToken)
EndIf


Function _Security__SetTokenInformation

Function Reference

_Security__SetTokenInformation

Sets various types of information for a specified access token

#include <Security.au3>
_Security__SetTokenInformation ( $hToken, $iTokenInformation, $vTokenInformation, $iTokenInformationLength )

Parameters

$hToken | A handle to the access token for which information is to be set
$iTokenInformation | The type of information the function sets
$vTokenInformation | A (pointer to a) structure that contains the information set in the access token
$iTokenInformationLength | The length, in bytes, of the buffer pointed to by $vTokenInformation

Return Value

Success: | True.
Failure: | False.

Related

_Security__GetTokenInformation

See Also

Search SetTokenInformation in MSDN Library.

Example

#RequireAdmin ; for this example to have sense

#include <MsgBoxConstants.au3>
#include <Security.au3>
#include <SecurityConstants.au3>
#include <WinAPI.au3>

Example_SeTokInfo()

Func Example_SeTokInfo()
    Local $hProcess = _WinAPI_GetCurrentProcess()
    If @error Then Return ; check for possible errors

    Local $hToken = _Security__OpenProcessToken($hProcess, $TOKEN_ALL_ACCESS)

    ; If token is get...
    If $hToken Then
        ; Set Medium Integrity Level for this token.
        Local $tSID = _Security__StringSidToSid($SID_MEDIUM_MANDATORY_LEVEL)
        ; Define TOKEN_MANDATORY_LABEL structure
        Local Const $tTOKEN_MANDATORY_LABEL = DllStructCreate("ptr Sid; dword Attributes")
        ; Fill it with wanted data
        DllStructSetData($tTOKEN_MANDATORY_LABEL, "Sid", DllStructGetPtr($tSID, 1))
        DllStructSetData($tTOKEN_MANDATORY_LABEL, "Attributes", $SE_GROUP_INTEGRITY)

        If _Security__SetTokenInformation($hToken, $TOKENINTEGRITYLEVEL, $tTOKEN_MANDATORY_LABEL, DllStructGetSize($tTOKEN_MANDATORY_LABEL)) Then

            ; Default IL is $SID_HIGH_MANDATORY_LEVEL, however...
            MsgBox($MB_SYSTEMMODAL, "SetTokenInformation", "$hToken = " & $hToken & @CRLF & "This token have non-default Medium Integrity Level")

            ; ... Do something with token here ...

        EndIf
        ; Close the token handle when no longer needed
        _WinAPI_CloseHandle($hToken)
    EndIf
EndFunc   ;==>Example_SeTokInfo


Function _Security__SidToStringSid

Function Reference

_Security__SidToStringSid

Converts a binary SID to a string

#include <Security.au3>
_Security__SidToStringSid ( $pSID )

Parameters

$pSID Pointer to a binary SID to be converted

Return Value

Success: | the SID in string form.
Failure: | an empty string.

Related

_Security__StringSidToSid

See Also

Search ConvertSidToStringSid in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <Security.au3>

Local $sAccount = @UserName
Local $tSID = _Security__GetAccountSid($sAccount)
Local $sStringSID = _Security__SidToStringSid($tSID)
MsgBox($MB_SYSTEMMODAL, "SID", "User = " & $sAccount & @CRLF & "SID = " & $sStringSID)


Function _Security__SidTypeStr

Function Reference

_Security__SidTypeStr

Converts a SID type to string form

#include <Security.au3>
_Security__SidTypeStr ( $iType )

Parameters

$iType SID type

Return Value

Returns the SID type in string form.

Example

#include <Security.au3>
#include <SecurityConstants.au3>

ConsoleWrite("SID type for $SIDTYPEDOMAIN is: " & _Security__SidTypeStr($SIDTYPEDOMAIN) & @CRLF)


Function _Security__StringSidToSid

Function Reference

_Security__StringSidToSid

Converts a String SID to a binary SID

#include <Security.au3>
_Security__StringSidToSid ( $sSID )

Parameters

$sSID String SID to be converted

Return Value

Success: | the SID in a byte structure.
Failure: | 0.

Related

_Security__SidToStringSid

See Also

Search ConvertStringSidToSid in MSDN Library.

Example

#include <Security.au3>
#include <SecurityConstants.au3>

Local $tSID = _Security__StringSidToSid($SID_ADMINISTRATORS)
If Not @error Then
    ; $tSID is structure filled with SID data for spesified string form SID
    ; ... The rest of the script here...
EndIf


User Defined Functions

SendMessage user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <SendMessage.au3>.

User Defined Function | Description
_SendMessage | Wrapper for commonly used DLL Call
_SendMessageA | Send a Message to a Window/Control (Force Ansi Call)


Function _SendMessage

Function Reference

_SendMessage

Wrapper for commonly used DLL Call

#include <SendMessage.au3>
_SendMessage ( $hWnd, $iMsg [, $wParam = 0 [, $lParam = 0 [, $iReturn = 0 [, $wParamType = "wparam" [, $lParamType = "lparam" [, $sReturnType = "lresult"]]]]]] )

Parameters

$hWnd | Window/control handle
$iMsg | Message to send to control (number)
$wParam | [optional] Specifies additional message-specific information
$lParam | [optional] Specifies additional message-specific information
$iReturn | [optional] What to return: 0 - Return value from DLL call 1 - $ihWnd 2 - $iMsg 3 - $wParam 4 - $lParam <0 or > 4 - array same as DllCall()
$wParamType | [optional] See DllCall in Related
$lParamType | [optional] See DllCall in Related
$sReturnType | [optional] See DllCall in Related

Return Value

Success: | the user selected value from the DllCall() result.
Failure: | sets the @error flag to non-zero.

Remarks

When a message is blocked by UIPI the last error, retrieved with _WinAPI_GetLastError(), is set to 5 (access denied).

Related

DllCall(), _SendMessageA, _WinAPI_GetLastError

Example

#include <MsgBoxConstants.au3>
#include <SendMessage.au3>

Example()

Func Example()
    Local Const $iOff = 2, $iOn = -1

    Opt("WinTitleMatchMode", 4)
    Local $hWnd = WinGetHandle('classname=Progman')
    _ToggleMonitor($hWnd, $iOff)
    Sleep(3000)
    _ToggleMonitor($hWnd, $iOn)
EndFunc   ;==>Example

Func _ToggleMonitor($hWnd, $iOnOff)
    Local Const $WM_SYSCOMMAND = 274
    Local Const $SC_MONITORPOWER = 61808
    _SendMessage($hWnd, $WM_SYSCOMMAND, $SC_MONITORPOWER, $iOnOff)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "_ToggleMonitor", "_SendMessage Error: " & @error)
        Exit
    EndIf
EndFunc   ;==>_ToggleMonitor


Function _SendMessageA

Function Reference

_SendMessageA

Send a Message to a Window/Control (Force Ansi Call)

#include <SendMessage.au3>
_SendMessageA ( $hWnd, $iMsg [, $wParam = 0 [, $lParam = 0 [, $iReturn = 0 [, $wParamType = "wparam" [, $lParamType = "lparam" [, $sReturnType = "lresult"]]]]]] )

Parameters

$hWnd | Window/control handle
$iMsg | Message to send to control (number)
$wParam | [optional] Specifies additional message-specific information
$lParam | [optional] Specifies additional message-specific information
$iReturn | [optional] What to return: 0 - Return value from DLL call 1 - $ihWnd 2 - $iMsg 3 - $wParam 4 - $lParam <0 or > 4 - array same as DllCall
$wParamType | [optional] See DllCall in Related
$lParamType | [optional] See DllCall in Related
$sReturnType | [optional] See DllCall in Related

Return Value

Success: | the user selected value from the DllCall() result.
Failure: | sets the @error flag to non-zero.

Remarks

When a message is blocked by UIPI the last error, retrieved with _WinAPI_GetLastError(), is set to 5 (access denied).

Related

DllCall(), _SendMessage, _WinAPI_GetLastError


User Defined Functions

Sound user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <Sound.au3>.

User Defined Function | Description
_SoundClose | Closes a sound previously opened with _SoundOpen
_SoundLength | Returns the length of the soundfile
_SoundOpen | Opens a sound file for use with other _Sound functions
_SoundPause | Pause a playing sound
_SoundPlay | Play a sound file
_SoundPos | Returns the current position of the sound
_SoundResume | Resume a paused sound
_SoundSeek | Seeks the sound to the specified position
_SoundStatus | Returns the status of the sound
_SoundStop | Stop a playing sound


Function _SoundClose

Function Reference

_SoundClose

Closes a sound previously opened with _SoundOpen

#include <Sound.au3>
_SoundClose ( $aSndID )

Parameters

$aSndID Sound ID array as returned by _SoundOpen()

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 = Failure 3 = Invalid Sound ID. Use return array from _SoundOpen().

Related

_SoundOpen

Example

#include <MsgBoxConstants.au3>
#include <Sound.au3>

Local $aSound = _SoundOpen(@WindowsDir & "\media\tada.wav")
If @error = 2 Then
    MsgBox($MB_SYSTEMMODAL, "Error", "The file does not exist")
    Exit
ElseIf @extended <> 0 Then
    Local $iExtended = @extended ; Assign because @extended will be set after DllStructCreate().
    Local $tText = DllStructCreate("char[128]")
    DllCall("winmm.dll", "short", "mciGetErrorStringA", "str", $iExtended, "struct*", $tText, "int", 128)
    MsgBox($MB_SYSTEMMODAL, "Error", "The open failed." & @CRLF & "Error Number: " & $iExtended & @CRLF & "Error Description: " & DllStructGetData($tText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
    MsgBox($MB_SYSTEMMODAL, "Success", "The file opened successfully")
EndIf

If _SoundClose($aSound) Then
    MsgBox($MB_SYSTEMMODAL, "Success", "The sound was closed successfully")
Else
    MsgBox($MB_SYSTEMMODAL, "Error", "The file was not closed successfully")
EndIf


Function _SoundLength

Function Reference

_SoundLength

Returns the length of the soundfile

#include <Sound.au3>
_SoundLength ( $aSndID [, $iMode = 1] )

Parameters

$aSndID | Sound ID array as returned by _SoundOpen() or a file name
$iMode | [optional] This flag determines the format of the returned sound length 1 = (by default) hh:mm:ss where h = hours, m = minutes and s = seconds (default) 2 = milliseconds

Return Value

Success: | the sound length.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 = $iMode is invalid 3 = Invalid Sound ID. Use return array from _SoundOpen() or valid file name.

Remarks

This function will return the best available value for the length of the file regardless of encoding method or parameter type.

Related

_SoundOpen, _SoundPos

Example

#include <MsgBoxConstants.au3>
#include <Sound.au3>

Local $aSound = _SoundOpen(@WindowsDir & "\media\tada.wav")
If @error = 2 Then
    MsgBox($MB_SYSTEMMODAL, "Error", "The file does not exist")
    Exit
ElseIf @extended <> 0 Then
    Local $iExtended = @extended ; Assign because @extended will be set after DllStructCreate().
    Local $tText = DllStructCreate("char[128]")
    DllCall("winmm.dll", "short", "mciGetErrorStringA", "str", $iExtended, "struct*", $tText, "int", 128)
    MsgBox($MB_SYSTEMMODAL, "Error", "The open failed." & @CRLF & "Error Number: " & $iExtended & @CRLF & "Error Description: " & DllStructGetData($tText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
    MsgBox($MB_SYSTEMMODAL, "Success", "The file opened successfully")
EndIf

MsgBox($MB_SYSTEMMODAL, "Sound Length", "The Sound has a length of:" & @CRLF & "hh:mm:ss - " & _
        _SoundLength($aSound, 1) & @CRLF & "Milliseconds - " & _SoundLength($aSound, 2))


Function _SoundOpen

Function Reference

_SoundOpen

Opens a sound file for use with other _Sound functions

#include <Sound.au3>
_SoundOpen ( $sFilePath )

Parameters

$sFilePath Path to sound file

Return Value

Success: | a 4-element array containing the following information: $aArray[0] = Sound file ID string $aArray[1] = VBR length correction factor $aArray[2] = VBR timing correction factor $aArray[3] = Sound ID marker
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - MCI open error 2 - File does not exist
@extended: | Integer other than 0 = MCI Error

Remarks

Although many of the _Sound...() functions will accept the filename as a parameter, if there is a possibility of the file being VBR (variable bit rate) encoded it is highly recommended to use _SoundOpen() initially and then use the returned array as the identity parameter in other _Sound...() functions. This is because the MCI DLL assumes all files are CBR (constant bit rate) encoded and produces incorrect results from those _Sound...() functions dealing with length and position when the sound file has been VBR (variable bit rate) encoded. If using the array as the ID parameter with the _Sound...() functions which alter the VBR correction factors (_SoundStop()) the ID array will be updated when needed.
The individual elements of the returned array have no utility outside the _Sound functions and their internal use is transparent to the user.

Related

_SoundClose, _SoundLength, _SoundPause, _SoundPlay, _SoundPos, _SoundResume, _SoundStatus, _SoundStop

Example

#include <MsgBoxConstants.au3>
#include <Sound.au3>

Local $aSound = _SoundOpen(@WindowsDir & "\media\tada.wav")
If @error = 2 Then
    MsgBox($MB_SYSTEMMODAL, "Error", "The file does not exist")
    Exit
ElseIf @extended <> 0 Then
    Local $iExtended = @extended ; Assign because @extended will be set after DllStructCreate().
    Local $tText = DllStructCreate("char[128]")
    DllCall("winmm.dll", "short", "mciGetErrorStringA", "str", $iExtended, "struct*", $tText, "int", 128)
    MsgBox($MB_SYSTEMMODAL, "Error", "The open failed." & @CRLF & "Error Number: " & $iExtended & @CRLF & "Error Description: " & DllStructGetData($tText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
    MsgBox($MB_SYSTEMMODAL, "Success", "The file opened successfully")
EndIf

_SoundClose($aSound)


Function _SoundPause

Function Reference

_SoundPause

Pause a playing sound

#include <Sound.au3>
_SoundPause ( $aSndID )

Parameters

$aSndID Sound ID array as returned by _SoundOpen() or a file name

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 = Pause Failed 3 = Invalid Sound ID. Use return array from _SoundOpen() or a valid file name.

Related

_SoundOpen, _SoundPlay, _SoundResume

Example

#include <MsgBoxConstants.au3>
#include <Sound.au3>

Local $aSound = _SoundOpen(@WindowsDir & "\media\tada.wav")
If @error = 2 Then
    MsgBox($MB_SYSTEMMODAL, "Error", "The file does not exist")
    Exit
ElseIf @extended <> 0 Then
    Local $iExtended = @extended ; Assign because @extended will be set after DllStructCreate().
    Local $tText = DllStructCreate("char[128]")
    DllCall("winmm.dll", "short", "mciGetErrorStringA", "str", $iExtended, "struct*", $tText, "int", 128)
    MsgBox($MB_SYSTEMMODAL, "Error", "The open failed." & @CRLF & "Error Number: " & $iExtended & @CRLF & "Error Description: " & DllStructGetData($tText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
    MsgBox($MB_SYSTEMMODAL, "Success", "The file opened successfully")
EndIf
_SoundPlay($aSound)
Sleep(1000)

_SoundPause($aSound)
Sleep(1000)

_SoundResume($aSound)

While 1
    Sleep(100)
    If _SoundPos($aSound, 2) >= _SoundLength($aSound, 2) Then ExitLoop
WEnd

_SoundClose($aSound)


Function _SoundPlay

Function Reference

_SoundPlay

Play a sound file

#include <Sound.au3>
_SoundPlay ( $aSndID [, $iWait = 0] )

Parameters

$aSndID | Sound ID array as returned by _SoundOpen() or a file name
$iWait | [optional] This flag determines if the script should wait for the sound to finish before continuing: 0 = continue script while sound is playing (default) 1 = wait until sound has finished

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 = Play Failed 2 = $iWait parameter is invalid 3 = Invalid Sound ID. Use return array from _SoundOpen() or a valid file name.

Remarks

In Windows Vista or later, "\Windows\Media\..." files containing spaces must be opened with _SoundOpen() before using this command with the returned Sound ID array.

Related

_SoundOpen, _SoundPause, _SoundResume, _SoundSeek, _SoundStop

Example

#include <MsgBoxConstants.au3>
#include <Sound.au3>

Local $aSound = _SoundOpen(@WindowsDir & "\media\tada.wav")
If @error = 2 Then
    MsgBox($MB_SYSTEMMODAL, "Error", "The file does not exist")
    Exit
ElseIf @extended <> 0 Then
    Local $iExtended = @extended ; Assign because @extended will be set after DllStructCreate().
    Local $tText = DllStructCreate("char[128]")
    DllCall("winmm.dll", "short", "mciGetErrorStringA", "str", $iExtended, "struct*", $tText, "int", 128)
    MsgBox($MB_SYSTEMMODAL, "Error", "The open failed." & @CRLF & "Error Number: " & $iExtended & @CRLF & "Error Description: " & DllStructGetData($tText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
    MsgBox($MB_SYSTEMMODAL, "Success", "The file opened successfully")
EndIf

_SoundPlay($aSound, 1)

_SoundClose($aSound)


Function _SoundPos

Function Reference

_SoundPos

Returns the current position of the sound

#include <Sound.au3>
_SoundPos ( $aSndID [, $iMode = 1] )

Parameters

$aSndID | Sound ID array as returned by _SoundOpen() or a file name
$iMode | [optional] This flag determines which format the position of the sound is returned in 1 = (by default) hh:mm:ss where h = hours, m = minutes and s = seconds (default) 2 = milliseconds

Return Value

Success: | the sound position.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 = $iMode is invalid 3 = Invalid Sound ID. Use return array from _SoundOpen() or a valid file name.

Remarks

It is recommended to open a sound file with _SoundOpen() and pass the ID array rather than use the file name in this function. A VBR encoded file is very unlikely to return the correct position if the file name is passed directly to this function.

Related

_SoundLength, _SoundOpen

Example

#include <MsgBoxConstants.au3>
#include <Sound.au3>

Local $aSound = _SoundOpen(@WindowsDir & "\media\tada.wav")
If @error = 2 Then
    MsgBox($MB_SYSTEMMODAL, "Error", "The file does not exist")
    Exit
ElseIf @extended <> 0 Then
    Local $iExtended = @extended ; Assign because @extended will be set after DllStructCreate().
    Local $tText = DllStructCreate("char[128]")
    DllCall("winmm.dll", "short", "mciGetErrorStringA", "str", $iExtended, "struct*", $tText, "int", 128)
    MsgBox($MB_SYSTEMMODAL, "Error", "The open failed." & @CRLF & "Error Number: " & $iExtended & @CRLF & "Error Description: " & DllStructGetData($tText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
    MsgBox($MB_SYSTEMMODAL, "Success", "The file opened successfully")
EndIf

_SoundPlay($aSound, 0)
SplashTextOn("Current Position", _SoundPos($aSound, 1), 300, 90, Default, Default, 18, Default, 55)

While 1
    Sleep(100)
    ControlSetText("Current Position", "", "Static1", _SoundPos($aSound, 1))
    If _SoundPos($aSound, 2) >= _SoundLength($aSound, 2) Then ExitLoop
WEnd

_SoundClose($aSound)


Function _SoundResume

Function Reference

_SoundResume

Resume a paused sound

#include <Sound.au3>
_SoundResume ( $aSndID )

Parameters

$aSndID Sound ID array as returned by _SoundOpen() or a file name

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 = Pause Failed 3 = Invalid Sound ID. Use return array from _SoundOpen() or a valid file name.

Remarks

_SoundPlay() will also resume playing after a sound has been paused in some cases.

Related

_SoundOpen, _SoundPause, _SoundPlay

Example

#include <MsgBoxConstants.au3>
#include <Sound.au3>

Local $aSound = _SoundOpen(@WindowsDir & "\media\tada.wav")
If @error = 2 Then
    MsgBox($MB_SYSTEMMODAL, "Error", "The file does not exist")
    Exit
ElseIf @extended <> 0 Then
    Local $iExtended = @extended ; Assign because @extended will be set after DllStructCreate().
    Local $tText = DllStructCreate("char[128]")
    DllCall("winmm.dll", "short", "mciGetErrorStringA", "str", $iExtended, "struct*", $tText, "int", 128)
    MsgBox($MB_SYSTEMMODAL, "Error", "The open failed." & @CRLF & "Error Number: " & $iExtended & @CRLF & "Error Description: " & DllStructGetData($tText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
    MsgBox($MB_SYSTEMMODAL, "Success", "The file opened successfully")
EndIf

_SoundPlay($aSound)
Sleep(1000)

_SoundPause($aSound)
Sleep(1000)

_SoundResume($aSound)

While 1
    Sleep(100)
    If _SoundPos($aSound, 2) >= _SoundLength($aSound, 2) Then ExitLoop
WEnd

_SoundClose($aSound)


Function _SoundSeek

Function Reference

_SoundSeek

Seeks the sound to the specified position

#include <Sound.au3>
_SoundSeek ( ByRef $aSndID, $iHour, $iMin, $iSec )

Parameters

$aSndID | Sound ID array as returned by _SoundOpen()
$iHour | Hour to seek to
$iMin | Minute to seek to
$iSec | Second to seek to

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 = Failure 3 = Invalid Sound ID. Use return array from _SoundOpen().

Remarks

After using _SoundSeek() on a sound, _SoundPlay() must be used to resume playing.
The use of the ID array returned from _SoundOpen() is mandatory with this function to ensure that the file plays from the correct position regardless of encoding type.
The ID array should be updated by the function as the VBR timing correction factor may have been altered.

Related

_SoundPlay

Example

#include <MsgBoxConstants.au3>
#include <Sound.au3>

Local $aSound = _SoundOpen(@WindowsDir & "\media\tada.wav")
If @error = 2 Then
    MsgBox($MB_SYSTEMMODAL, "Error", "The file does not exist")
    Exit
ElseIf @extended <> 0 Then
    Local $iExtended = @extended ; Assign because @extended will be set after DllStructCreate().
    Local $tText = DllStructCreate("char[128]")
    DllCall("winmm.dll", "short", "mciGetErrorStringA", "str", $iExtended, "struct*", $tText, "int", 128)
    MsgBox($MB_SYSTEMMODAL, "Error", "The open failed." & @CRLF & "Error Number: " & $iExtended & @CRLF & "Error Description: " & DllStructGetData($tText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
    MsgBox($MB_SYSTEMMODAL, "Success", "The file opened successfully")
EndIf
_SoundPlay($aSound, 0)

; Play one second of sound.
Sleep(1000)

; Seek to 2 seconds into the sound.
_SoundSeek($aSound, 0, 0, 2)
ConsoleWrite("After _SoundSeek: " & _SoundPos($aSound, 2) & " _SoundStatus: " & _SoundStatus($aSound) & @CRLF)

_SoundSeek($aSound, 0, 0, 1)
ConsoleWrite("After _SoundSeek1: " & _SoundPos($aSound, 2) & " _SoundStatus: " & _SoundStatus($aSound) & @CRLF)

_SoundPlay($aSound, 0)

While 1
    Sleep(100)
    If _SoundPos($aSound, 2) >= _SoundLength($aSound, 2) Then ExitLoop
WEnd

_SoundClose($aSound)


Function _SoundStatus

Function Reference

_SoundStatus

Returns the status of the sound

#include <Sound.au3>
_SoundStatus ( $aSndID )

Parameters

$aSndID Sound ID array as returned by _SoundOpen() or a file name

Return Value

Success: | the sound status.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 3 = Invalid Sound ID. Use return array from _SoundOpen() or a valid file name.

Remarks

From MSDN:
All devices can return the "not ready", "paused", "playing", and "stopped" values.
Some devices can return the additional "open", "parked", "recording", and "seeking" values.

Related

_SoundOpen

Example

#include <MsgBoxConstants.au3>
#include <Sound.au3>

Local $aSound = _SoundOpen(@WindowsDir & "\media\tada.wav")
If @error = 2 Then
    MsgBox($MB_SYSTEMMODAL, "Error", "The file does not exist")
    Exit
ElseIf @extended <> 0 Then
    Local $iExtended = @extended ; Assign because @extended will be set after DllStructCreate().
    Local $tText = DllStructCreate("char[128]")
    DllCall("winmm.dll", "short", "mciGetErrorStringA", "str", $iExtended, "struct*", $tText, "int", 128)
    MsgBox($MB_SYSTEMMODAL, "Error", "The open failed." & @CRLF & "Error Number: " & $iExtended & @CRLF & "Error Description: " & DllStructGetData($tText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
    MsgBox($MB_SYSTEMMODAL, "Success", "The file opened successfully")
EndIf

ConsoleWrite("After _SoundOpen: " & _SoundStatus($aSound) & @CRLF)

_SoundPlay($aSound)
ConsoleWrite("After _SoundPlay: " & _SoundStatus($aSound) & @CRLF)

Sleep(1000)

_SoundPause($aSound)
ConsoleWrite("After _SoundPause: " & _SoundStatus($aSound) & @CRLF)

Sleep(1000)
_SoundResume($aSound)

While 1
    Sleep(100)
    If _SoundPos($aSound, 2) = _SoundLength($aSound, 2) Then ExitLoop
WEnd

_SoundClose($aSound)


Function _SoundStop

Function Reference

_SoundStop

Stop a playing sound

#include <Sound.au3>
_SoundStop ( ByRef $aSndID )

Parameters

$aSndID Sound ID array as returned by _SoundOpen() or a file name (must be a variable)

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 = Stop Failed 3 = Invalid Sound ID. Use return array from _SoundOpen() or a valid file name.

Remarks

_SoundPlay() will replay the sound from the beginning.

Related

_SoundOpen, _SoundPlay

Example

#include <MsgBoxConstants.au3>
#include <Sound.au3>

Local $aSound = _SoundOpen(@WindowsDir & "\media\tada.wav")
If @error = 2 Then
    MsgBox($MB_SYSTEMMODAL, "Error", "The file does not exist")
    Exit
ElseIf @extended <> 0 Then
    Local $iExtended = @extended ; Assign because @extended will be set after DllStructCreate().
    Local $tText = DllStructCreate("char[128]")
    DllCall("winmm.dll", "short", "mciGetErrorStringA", "str", $iExtended, "struct*", $tText, "int", 128)
    MsgBox($MB_SYSTEMMODAL, "Error", "The open failed." & @CRLF & "Error Number: " & $iExtended & @CRLF & "Error Description: " & DllStructGetData($tText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
    MsgBox($MB_SYSTEMMODAL, "Success", "The file opened successfully")
EndIf

_SoundPlay($aSound)

While 1
    Sleep(100)
    If _SoundPos($aSound, 2) >= 1000 Then
        _SoundStop($aSound)
        ExitLoop
    EndIf
WEnd

; Show that the sound starts from the beginning after its stopped.
_SoundPlay($aSound, 1)

_SoundClose($aSound)


User Defined Functions

SQLite user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <SQLite.au3>.

User Defined Function | Description
_SQLite_Changes | Returns the number of database rows that were changed by the most recently completed statement with this connection
_SQLite_Close | Close an open database
_SQLite_Display2DResult | Returns or prints to Console a formated display of a 2Dimensional array
_SQLite_Encode | Binary encodes a string, number or binary data for use as BLOB in SQLite statements
_SQLite_ErrCode | Returns last error code (numeric)
_SQLite_ErrMsg | Returns a string describing in english the error condition for the most recent sqlite3_* API call
_SQLite_Escape | Escapes a string or number for use as TEXT in SQLite statements
_SQLite_Exec | Executes a SQLite query, does not handle results
_SQLite_FastEncode | Fast encodes binary data (exclusively) for use in SQLite statements
_SQLite_FastEscape | Fast escapes a string or number for use as TEXT in SQLite statements
_SQLite_FetchData | Fetches 1 row of data from a _SQLite_Query() based query
_SQLite_FetchNames | Read out the Column names of a _SQLite_Query() based query
_SQLite_GetTable | Passes Out a 1Dimensional Array Containing Tablenames and Data of Executed Query
_SQLite_GetTable2d | Passes out a 2Dimensional array containing column names and data of executed query
_SQLite_LastInsertRowID | Returns the ROWID of the most recent insert in the database by this connection
_SQLite_LibVersion | Returns the version number of the library
_SQLite_Open | Opens/creates a SQLite database
_SQLite_Query | Prepares a SQLite Query
_SQLite_QueryFinalize | Finalizes an _SQLite_Query() based query. The query is interrupted
_SQLite_QueryReset | Reset a _SQLite_Query() based query
_SQLite_QuerySingleRow | Read out the first row of the result from the specified query
_SQLite_SafeMode | Disable or Enable Safe mode
_SQLite_SetTimeout | Sets timeout for busy handler
_SQLite_Shutdown | Unloads SQLite.dll
_SQLite_SQLiteExe | Executes commands in sqlite3.exe
_SQLite_Startup | Loads SQLite3.dll
_SQLite_TotalChanges | Returns number of all changes (including via triggers and foreign keys) from start of connection


Function _SQLite_Changes

Function Reference

_SQLite_Changes

Returns the number of database rows that were changed by the most recently completed statement with this connection

#include <SQLite.au3>
_SQLite_Changes ( [$hDB = -1] )

Parameters

$hDB [optional] An open database, default is the last opened database

Return Value

Success: | the number of changes.
Failure: | 0.
@error: | 1 - Error calling SQLite API 'sqlite3_changes' 2 - Call prevented by SafeMode

Remarks

Changes due to action of triggers or foreign keys are not part of this count. See _SQLite_TotalChanges().

Related

_SQLite_TotalChanges

Example

#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open()
_SQLite_Exec(-1, "CREATE TABLE test (a, b);") ; Create Table
_SQLite_Exec(-1, "INSERT INTO test VALUES ('1', '2');") ; Insert Row 1
_SQLite_Exec(-1, "INSERT INTO test VALUES ('3', '4');") ; Insert Row 2
MsgBox($MB_SYSTEMMODAL, "SQLite", "The last SQL statement changed " & _SQLite_Changes() & " rows" & @CRLF & _
        "All statements during this session changed " & _SQLite_TotalChanges() & " rows")
_SQLite_Close()
_SQLite_Shutdown()


Function _SQLite_Close

Function Reference

_SQLite_Close

Close an open database

#include <SQLite.au3>
_SQLite_Close ( [$hDB = -1] )

Parameters

$hDB [optional] Database handle.

Return Value

Success: | $SQLITE_OK.
Failure: | a value can be compared against $SQLITE_* constants.
@error: | -1 - SQLite reported an error (Check Return value) 1 - Error calling SQLite API 'sqlite3_close' 2 - Call prevented by SafeMode

Remarks

It waits for SQLite <> $SQLITE_BUSY until 'global Timeout' has elapsed.
If no database handle is given, the last opened database will be closed.
Prior to calling _SQLite_Close(), the application must invoke _SQLite_QueryFinalize() for each query explicitely left unfinalized.

Related

_SQLite_Open

Example

#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup()
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite.dll Can't be Loaded!")
    Exit -1
EndIf
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open() ; Open a :memory: database
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't Load Database!")
    Exit -1
EndIf
_SQLite_Close()
_SQLite_Shutdown()


Function _SQLite_Display2DResult

Function Reference

_SQLite_Display2DResult

Returns or prints to Console a formated display of a 2Dimensional array

#include <SQLite.au3>
_SQLite_Display2DResult ( $aResult [, $iCellWidth = 0 [, $bReturn = False]] )

Parameters

$aResult | The array to be displayed
$iCellWidth | [optional] specifies the size of a data field
$bReturn | [optional] if True the formated string is returned, not displayed If False the formatted string is send to StdOut

Return Value

Success: | none or formated string.
Failure: | sets the @error flag to non-zero.
@error: | 1 - $aResult is no array or has wrong dimension

Related

_SQLite_GetTable2d

Example

#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $aResult, $iRows, $iColumns, $iRval

_SQLite_Startup()
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite.dll Can't be Loaded!")
    Exit -1
EndIf
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open() ; Open a :memory: database
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't Load Database!")
    Exit -1
EndIf

; Example Table
; Name        | Age
; -----------------------
; Alice       | 43
; Bob         | 28
; Cindy       | 21

If Not _SQLite_Exec(-1, "CREATE TEMP TABLE persons (Name, Age);") = $SQLITE_OK Then _
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Alice','43');") = $SQLITE_OK Then _
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Bob','28');") = $SQLITE_OK Then _
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Cindy','21');") = $SQLITE_OK Then _
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())

; Query
$iRval = _SQLite_GetTable2d(-1, "SELECT * FROM persons;", $aResult, $iRows, $iColumns)
If $iRval = $SQLITE_OK Then
    _SQLite_Display2DResult($aResult)

    ; $aResult looks like this:
    ; Name   Age
    ; Alice  43
    ; Bob    28
    ; Cindy  21
    ; If the dimensions would be switched in _SQLite_GetTable2d the result would look like this:
    ; Name  Alice  Bob  Cindy
    ; Age   43     28   21

Else
    MsgBox($MB_SYSTEMMODAL, "SQLite Error: " & $iRval, _SQLite_ErrMsg())
EndIf

_SQLite_Close()
_SQLite_Shutdown()


Function _SQLite_Encode

Function Reference

_SQLite_Encode

Binary encodes a string, number or binary data for use as BLOB in SQLite statements

#include <SQLite.au3>
_SQLite_Encode ( $vData )

Parameters

$vData Data To be encoded (String, Number or Binary)

Return Value

Success: | an encoded string.
Failure: | an empty string and sets the @error flag to non-zero.

Remarks

The encoded string is already wrapped with single quotes.
For example Chr(0) & Chr(1) would look like X'0001'.
The encoded string can be decoded by Sqlite and stored in binary state as a BLOB.
For strings to be stored as TEXT use _SQLite_Escape().
For numeric value to be stored as such, use simple concatenation.

Related

_SQLite_Escape

Example

#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $hFile, $vData, $sFileName, $sData, $hQuery, $aRow, $sMsg
_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open()
_SQLite_Exec(-1, "CREATE TABLE IF NOT EXISTS Test (data blob);")
$vData = Binary("Hello" & Chr(0) & "World"); = 48656C6C6F00576F726C64
$sData = _SQLite_Encode($vData)
_SQLite_Exec(-1, "INSERT INTO Test VALUES (" & $sData & ");")
$vData = Binary(Chr(0) & @CRLF); = 000D0A
$sData = _SQLite_Encode($vData)
_SQLite_Exec(-1, "INSERT INTO Test VALUES (" & $sData & ");")
$vData = Binary(Chr(0)); = 00 but this is interpreted as Number and returns 0000000000000000
$sData = _SQLite_Encode($vData)
_SQLite_Exec(-1, "INSERT INTO Test VALUES ( " & $sData & " );")
_SQLite_Query(-1, "SELECT * FROM Test;", $hQuery)
While _SQLite_FetchData($hQuery, $aRow, 1) = $SQLITE_OK
    $sMsg &= Hex($aRow[0]) & @CRLF
WEnd
MsgBox($MB_SYSTEMMODAL, "Result", $sMsg)
_SQLite_Close()
_SQLite_Shutdown()


Function _SQLite_ErrCode

Function Reference

_SQLite_ErrCode

Returns last error code (numeric)

#include <SQLite.au3>
_SQLite_ErrCode ( [$hDB = -1] )

Parameters

$hDB [optional] An open database, default is the last opened database

Return Value

Success: | a value can be compared against $SQLITE_* constants.
Failure: | 0.
@error: | 1 - error calling SQLite API 'sqlite3_errcode' 2 - Call Prevented by SafeMode

Related

_SQLite_ErrMsg

Example

#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open()
If $SQLITE_OK <> _SQLite_Exec(-1, "CREATE TABLE test (a', 'b');") Then _ ; a Quote is missing
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Error Code: " & _SQLite_ErrCode() & @CRLF & "Error Message: " & _SQLite_ErrMsg())
_SQLite_Close()
_SQLite_Shutdown()


Function _SQLite_ErrMsg

Function Reference

_SQLite_ErrMsg

Returns a string describing in english the error condition for the most recent sqlite3_* API call

#include <SQLite.au3>
_SQLite_ErrMsg ( [$hDB = -1] )

Parameters

$hDB [optional] An open database, default is the last opened database

Return Value

Success: | an error message string.
Failure: | sets the @error flag to non-zero.
@error: | 1 - error calling SQLite API 'sqlite3_errmsg16' 2 - Call Prevented by SafeMode

Related

_SQLite_ErrCode

Example

#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open()
If $SQLITE_OK <> _SQLite_Exec(-1, "CREATE TABLE test (a', 'b');") Then _ ; a Quote is missing
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Error Code: " & _SQLite_ErrCode() & @CRLF & "Error Message: " & _SQLite_ErrMsg())
_SQLite_Close()
_SQLite_Shutdown()


Function _SQLite_Escape

Function Reference

_SQLite_Escape

Escapes a string or number for use as TEXT in SQLite statements

#include <SQLite.au3>
_SQLite_Escape ( $sString [, $iBuffSize = Default] )

Parameters

$sString | string to escape
$iBuffSize | [optional] Size of the escaped string to be returned (Default = complete escaped string)

Return Value

Success: | an escaped string
Failure: | an empty string and sets the @error flag to non-zero.
@error: | 1 - Error Calling SQLite API 'sqlite3_mprintf' 2 - Error converting string to UTF-8 3 - Error reading escaped string

Remarks

The escaped string is already wrapped with single quotes.
For example "It's a fine day" is turned into "'It''s a fine day'".
For binary data use _SQLite_Encode().
For numeric value to be stored as such, use simple concatenation.

Related

_SQLite_Encode

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
Local $sTestString, $i, $aRow
For $i = 1 To 255
    $sTestString &= Chr($i)
Next
_SQLite_Open()
_SQLite_Exec(-1, "CREATE TABLE test (a)")
_SQLite_Exec(-1, "INSERT INTO test VALUES (" & _SQLite_Escape($sTestString) & ")")
_SQLite_QuerySingleRow(-1, "SELECT a FROM test LIMIT 1", $aRow)
If $aRow[0] = $sTestString Then ConsoleWrite("! identical !" & @CRLF)
_SQLite_Shutdown()


Function _SQLite_Exec

Function Reference

_SQLite_Exec

Executes a SQLite query, does not handle results

#include <SQLite.au3>
_SQLite_Exec ( $hDB, $sSQL [, $sCallBack = ""] )

Parameters

$hDB | An open database, use -1 to use last opened database
$sSQL | SQL statement to be executed
$sCallback | [optional] if specified the function will be called for each row

Return Value

Success: | $SQLITE_OK.
Failure: | a value that can be compared against $SQLITE_* constants.
@error: | -1 - SQLite reported an error (Check return value) 1 - Error calling SQLite API 'sqlite3_exec' 2 - Call prevented by SafeMode 3 - Error Processing Callback from within _SQLite_GetTable2d() 4 - Error while converting SQL statement to UTF-8

Remarks

The Callback function must accept 1 parameter and can return $SQLITE_ABORT to stop processing (See example).
The first row in the Callback sequence will be the column names.

Related

_SQLite_GetTable, _SQLite_GetTable2d, _SQLite_Query

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $hQuery, $aRow
_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open()
; Without $sCallback it's a resultless statement
_SQLite_Exec(-1, "Create table tblTest (a,b int,c single not null);" & _
        "Insert into tblTest values ('1',2,3);" & _
        "Insert into tblTest values (Null,5,6);")

Local $d = _SQLite_Exec(-1, "Select rowid,* From tblTest", "_cb") ; _cb will be called for each row

Func _cb($aRow)
    For $s In $aRow
        ConsoleWrite($s & @TAB)
    Next
    ConsoleWrite(@CRLF)
    ; Return $SQLITE_ABORT ; Would Abort the process and trigger an @error in _SQLite_Exec()
EndFunc   ;==>_cb
_SQLite_Close()
_SQLite_Shutdown()

; Output:
; 1     1   2   3
; 2         5   6


Function _SQLite_FastEncode

Function Reference

_SQLite_FastEncode

Fast encodes binary data (exclusively) for use in SQLite statements

#include <SQLite.au3>
_SQLite_FastEncode ( $vData )

Parameters

$vData Data To be encoded (Binary only)

Return Value

Success: | an encoded binary string.
Failure: | an empty string and sets the @error flag to non-zero.
@error: | 1 - Data is not a binary type

Remarks

The encoded string is already wrapped with single quotes.
For example Chr(0) & Chr(1) would look like X'0001'.
The encoded string can be decoded by Sqlite and stored in binary state as a BLOB.
For strings to be stored as TEXT, use _SQLite_Escape().
For numeric value to be stored as such, use simple concatenation.

Related

_SQLite_Escape

Example

#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $hFile, $vData, $sFileName, $sData, $hQuery, $aRow, $sMsg
_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open()
_SQLite_Exec(-1, "CREATE TABLE IF NOT EXISTS Test (data blob);")
$vData = Binary("Hello" & Chr(0) & "World"); = 48656C6C6F00576F726C64
$sData = _SQLite_FastEncode($vData)
_SQLite_Exec(-1, "INSERT INTO Test VALUES (" & $sData & ");")
$vData = Binary(Chr(0) & @CRLF); = 000D0A
$sData = _SQLite_FastEncode($vData)
_SQLite_Exec(-1, "INSERT INTO Test VALUES (" & $sData & ");")
$vData = Binary(Chr(0)); = 00
$sData = _SQLite_FastEncode($vData)
_SQLite_Exec(-1, "INSERT INTO Test VALUES ( " & $sData & " );")
_SQLite_Query(-1, "SELECT * FROM Test;", $hQuery)
While _SQLite_FetchData($hQuery, $aRow, 1) = $SQLITE_OK
    $sMsg &= Hex($aRow[0]) & @CRLF
WEnd
MsgBox($MB_SYSTEMMODAL, "Result", $sMsg)
_SQLite_Close()
_SQLite_Shutdown()


Function _SQLite_FastEscape

Function Reference

_SQLite_FastEscape

Fast escapes a string or number for use as TEXT in SQLite statements

#include <SQLite.au3>
_SQLite_FastEscape ( $sString )

Parameters

$sString string to escape

Return Value

Success: | an escaped string.
Failure: | an empty string and sets the @error flag to non-zero.
@error: | 1 - Data is not a string or a numeric

Remarks

The escaped string is wrapped with single quotes.
For example "It's a fine day" is turned into "'It''s a fine day'".
For binary data use _SQLite_Encode().
For numeric values to be stored as such, use simple concatenation.

Related

_SQLite_Encode, _SQLite_Escape

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
Local $sTestString, $i, $aRow
For $i = 1 To 32 * 1024 ; a large number of characters in Unicode plane 0
    $sTestString &= ChrW($i)
Next
_SQLite_Open()
_SQLite_Exec(-1, "CREATE TABLE test (a text);")
_SQLite_Exec(-1, "INSERT INTO test VALUES (" & _SQLite_FastEscape($sTestString) & ")")
_SQLite_QuerySingleRow(-1, "SELECT a FROM test;", $aRow)
If $aRow[0] == $sTestString Then ConsoleWrite("! identical !" & @CRLF)
_SQLite_Shutdown()


Function _SQLite_FetchData

Function Reference

_SQLite_FetchData

Fetches 1 row of data from a _SQLite_Query() based query

#include <SQLite.au3>
_SQLite_FetchData ( $hQuery, ByRef $aRow [, $bBinary = False [, $bDoNotFinalize = False [, $iColumns = 0]]] )

Parameters

$hQuery | Queryhandle passed out by _SQLite_Query()
$aRow | A 1 dimensional array containing a row of data
$bBinary | [optional] Switch for binary mode ($aRow will be an array of binary strings)
$bDoNotFinalize | [optional] Switch can be set to True if you need to keep the query unfinalized for further use. (It is then the caller's responsability to invoke _SQLite_QueryFinalize() before closing database.)
$iColumns | [optional] Number of columns to be returned ((Default = all)

Return Value

Success: | $SQLITE_OK.
Failure: | a value that can be compared against $SQLITE_* constants.
@error: | -1 - SQLite reported an error (Check return value) 1 - Error calling SQLite API 'sqlite3_step' 2 - Error calling SQLite API 'sqlite3_data_count' 3 - Error calling SQLite API 'sqlite3_column_text16' 4 - Error calling SQLite API 'sqlite3_column_type' 5 - Error calling SQLite API 'sqlite3_column_bytes' 6 - Error calling SQLite API 'sqlite3_column_blob' 7 - Call prevented by SafeMode

Related

_SQLite_Query, _SQLite_QueryFinalize

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $hQuery, $aRow, $aNames
_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open() ; open :memory: Database
_SQLite_Exec(-1, "CREATE TABLE aTest (A,B,C);")
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('c','2','World');")
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('b','3',' ');")
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('a','1','Hello');")
_SQLite_Query(-1, "SELECT ROWID,* FROM aTest ORDER BY a;", $hQuery)
_SQLite_FetchNames($hQuery, $aNames)
ConsoleWrite(StringFormat(" %-10s  %-10s  %-10s  %-10s ", $aNames[0], $aNames[1], $aNames[2], $aNames[3]) & @CRLF)
While _SQLite_FetchData($hQuery, $aRow, False, False) = $SQLITE_OK ; Read Out the next Row
    ConsoleWrite(StringFormat(" %-10s  %-10s  %-10s  %-10s ", $aRow[0], $aRow[1], $aRow[2], $aRow[3]) & @CRLF)
WEnd
_SQLite_QueryFinalize($hQuery)
_SQLite_Exec(-1, "DROP TABLE aTest;")
_SQLite_Close()
_SQLite_Shutdown()

; Output:
; rowid       A           B           C
; 3           a           1           Hello
; 2           b           3
; 1           c           2           World


Function _SQLite_FetchNames

Function Reference

_SQLite_FetchNames

Read out the Column names of a _SQLite_Query() based query

#include <SQLite.au3>
_SQLite_FetchNames ( $hQuery, ByRef $aNames )

Parameters

$hQuery | Query handle generated by SQLite_Query()
$aNames | 1 dimensional array containing the Column names

Return Value

Success: | $SQLITE_OK.
Failure: | a value that can be compared against $SQLITE_* constants.
@error: | -1 - SQLite reported an error (Check return value) 1 - Error calling SQLite API 'sqlite3_data_count' 2 - Error calling SQLite API 'sqlite3_column_name16' 3 - Call prevented by SafeMode

Related

_SQLite_Query

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $hQuery, $aRow, $aNames
_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open() ; open :memory: Database
_SQLite_Exec(-1, "CREATE TABLE aTest (A,B,C);")
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('c','2','World');")
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('b','3',' ');")
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('a','1','Hello');")
_SQLite_Query(-1, "SELECT ROWID,* FROM aTest ORDER BY a;", $hQuery)
_SQLite_FetchNames($hQuery, $aNames) ; Read out Column Names
ConsoleWrite(StringFormat(" %-10s  %-10s  %-10s  %-10s ", $aNames[0], $aNames[1], $aNames[2], $aNames[3]) & @CRLF)
While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK
    ConsoleWrite(StringFormat(" %-10s  %-10s  %-10s  %-10s ", $aRow[0], $aRow[1], $aRow[2], $aRow[3]) & @CRLF)
WEnd
_SQLite_Exec(-1, "DROP TABLE aTest;")
_SQLite_Close()
_SQLite_Shutdown()

; Output:
; rowid       A           B           C
; 3           a           1           Hello
; 2           b           3
; 1           c           2           World


Function _SQLite_GetTable

Function Reference

_SQLite_GetTable

Passes Out a 1Dimensional Array Containing Tablenames and Data of Executed Query

#include <SQLite.au3>
_SQLite_GetTable ( $hDB, $sSQL, ByRef $aResult, ByRef $iRows, ByRef $iColumns [, $iCharSize = -1] )

Parameters

$hDB | An open database, use -1 to use last opened database
$sSQL | SQL Statement to be executed
$aResult | Passes out the result
$iRows | Passes out the amount of 'data' Rows
$iColumns | Passes out the amount of columns
$iCharSize | [optional] Specifies the maximal size of a data field

Return Value

Success: $SQLITE_OK.
Failure: a value that can be compared against $SQLITE_* constants.
@error: -1 - SQLite reported an error (Check Return value)
1 - Call Prevented by SafeMode
2 - Error returned by _SQLite_Query() in @extended
3 - Error returned by _SQLite_FetchNames() in @extended
4 - Error returned by _SQLite_FetchData() in @extended

Remarks

The number of values inserted into $aResult will be (($iRows) + 1) * ($iColumns) this number is inserted into $aResult[0].
A NULL will be returned as numeric 0.
If you do not need a result (or if there will be none) consider using _SQLite_Exec().

Related

_SQLite_Exec, _SQLite_GetTable2d, _SQLite_Query

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $aResult, $iRows, $iColumns, $iRval

_SQLite_Startup()
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite.dll Can't be Loaded!")
    Exit -1
EndIf
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open() ; Open a :memory: database
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't Load Database!")
    Exit -1
EndIf

; Example Table
;   Name        | Age
;   -----------------------
;   Alice       | 43
;   Bob         | 28
;   Cindy       | 21

If Not _SQLite_Exec(-1, "CREATE TEMP TABLE persons (Name, Age);") = $SQLITE_OK Then _
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Alice','43');") = $SQLITE_OK Then _
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Bob','28');") = $SQLITE_OK Then _
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Cindy','21');") = $SQLITE_OK Then _
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())

; Query
$iRval = _SQLite_GetTable(-1, "SELECT * FROM persons;", $aResult, $iRows, $iColumns)
If $iRval = $SQLITE_OK Then
    ; $aResult Looks Like this:
    ; [0]    = 8
    ; [1]    = Name
    ; [2]    = Age
    ; [3]    = Alice
    ; [4]    = 43
    ; [5]    = Bob
    ; [6]    = 28
    ; [7]    = Cindy
    ; [8]    = 21
    _ArrayDisplay($aResult, "Query Result")
Else
    MsgBox($MB_SYSTEMMODAL, "SQLite Error: " & $iRval, _SQLite_ErrMsg())
EndIf

_SQLite_Close()
_SQLite_Shutdown()


Function _SQLite_GetTable2d

Function Reference

_SQLite_GetTable2d

Passes out a 2Dimensional array containing column names and data of executed query

#include <SQLite.au3>
_SQLite_GetTable2d ( $hDB, $sSQL, ByRef $aResult, ByRef $iRows, ByRef $iColumns [, $iCharSize = -1 [, $bSwichDimensions = False]] )

Parameters

$hDB | An Open Database, Use -1 To use Last Opened Database
$sSQL | SQL Statement to be executed
$aResult | Passes out the result
$iRows | Passes out the amount of 'data' Rows
$iColumns | Passes out the amount of columns
$iCharSize | [optional] Specifies the maximal size of a data field
$bSwichDimensions | [optional] Switches dimensions of $aResult

Return Value

Success: | $SQLITE_OK.
Failure: | a value that can be compared against $SQLITE_* constants.
@error: | -1 - SQLite reported an error (Check Return value) 1 - Error Calling _SQLite_Query() 2 - Error calling SQLite API 'sqlite3_free_table' 3 - Call prevented by SafeMode 4 - Abort, Interrupt or @error set by Callback (@extended set to SQLite error)

Remarks

The number of values inserted into $aResult will be (($iRows) + 1) * ($iColumns).
A NULL will be returned as Numeric 0.
This function uses more memory than _SQLite_Query() / _SQLite_Fetch*()... but it's faster.
If you do not need a result (or if there will be none) consider using SQLite_Exec().

Related

_SQLite_Display2DResult, _SQLite_Exec, _SQLite_GetTable, _SQLite_Query

Example

#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $aResult, $iRows, $iColumns, $iRval

_SQLite_Startup()
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite.dll Can't be Loaded!")
    Exit -1
EndIf
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open() ; Open a :memory: database
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't Load Database!")
    Exit -1
EndIf

; Example Table
; Name        | Age
; -----------------------
; Alice       | 43
; Bob         | 28
; Cindy       | 21

If Not _SQLite_Exec(-1, "CREATE TEMP TABLE persons (Name, Age);") = $SQLITE_OK Then _
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Alice','43');") = $SQLITE_OK Then _
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Bob','28');") = $SQLITE_OK Then _
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Cindy','21');") = $SQLITE_OK Then _
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())

; Query
$iRval = _SQLite_GetTable2d(-1, "SELECT * FROM persons;", $aResult, $iRows, $iColumns)
If $iRval = $SQLITE_OK Then
    _SQLite_Display2DResult($aResult)

    ; $aResult looks like this:
    ; Name   Age
    ; Alice  43
    ; Bob    28
    ; Cindy  21
    ; If the dimensions would be switched in _SQLite_GetTable2d the result would look like this:
    ; Name  Alice  Bob  Cindy
    ; Age   43     28   21

Else
    MsgBox($MB_SYSTEMMODAL, "SQLite Error: " & $iRval, _SQLite_ErrMsg())
EndIf

_SQLite_Close()
_SQLite_Shutdown()


Function _SQLite_LastInsertRowID

Function Reference

_SQLite_LastInsertRowID

Returns the ROWID of the most recent insert in the database by this connection

#include <SQLite.au3>
_SQLite_LastInsertRowID ( [$hDB = -1] )

Parameters

$hDB [optional] An open database, use -1 to use last opened database

Return Value

Success: | ROWID.
Failure: | 0.
@error: | 1 - Error calling SQLite API 'sqlite3_last_insert_rowid' 2 - Call prevented by SafeMode

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $aResult, $iRows, $iColumns, $iRval

_SQLite_Startup()
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite.dll Can't be Loaded!")
    Exit -1
EndIf
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open() ; Open a :memory: database
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't Load Database!")
    Exit -1
EndIf

; Example Table
;   Name        | Age
;   -----------------------
;   Alice       | 43
;   Bob         | 28
;   Cindy       | 21

; _SQLite_Exec() and _SQLite_Execute() are quite similar
If Not _SQLite_Exec(-1, "CREATE TEMP TABLE persons (Name, Age);") = $SQLITE_OK Then _
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Alice','43');") = $SQLITE_OK Then _
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Bob','28');") = $SQLITE_OK Then _
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Cindy','21');") = $SQLITE_OK Then _
        MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())

; _SQLite_LastInsertRowID() tells us Cindy's row
MsgBox($MB_SYSTEMMODAL, "_SQLite_LastInsertRowID()", _SQLite_LastInsertRowID())

; Query
$iRval = _SQLite_GetTable(-1, "SELECT * FROM persons;", $aResult, $iRows, $iColumns)
If $iRval = $SQLITE_OK Then
    ; $aResult Looks Like this:
    ; [0]    = 8
    ; [1]    = Name
    ; [2]    = Age
    ; [3]    = Alice
    ; [4]    = 43
    ; [5]    = Bob
    ; [6]    = 28
    ; [7]    = Cindy
    ; [8]    = 21
    _ArrayDisplay($aResult, "Query Result")
Else
    MsgBox($MB_SYSTEMMODAL, "SQLite Error: " & $iRval, _SQLite_ErrMsg())
EndIf

_SQLite_Close()
_SQLite_Shutdown()


Function _SQLite_LibVersion

Function Reference

_SQLite_LibVersion

Returns the version number of the library

#include <SQLite.au3>
_SQLite_LibVersion ( )

Return Value

Success: | the SQLite version string.
Failure: | sets the @error flag to non-zero.

Remarks

Requires SQLite3.dll in Current or System directory.

Example

#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $sSQliteDll
$sSQliteDll = _SQLite_Startup()
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite3.dll Can't be Loaded!")
    Exit -1
EndIf
MsgBox($MB_SYSTEMMODAL, "SQLite3.dll Loaded", $sSQliteDll)
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Shutdown()


Function _SQLite_Open

Function Reference

_SQLite_Open

Opens/creates a SQLite database

#include <SQLite.au3>
_SQLite_Open ( [$sDatabase_Filename = ":memory:" [, $iAccessMode = Default [, $iEncoding = $SQLITE_ENCODING_UTF8]]] )

Parameters

$sDatabase_Filename | [optional] Database filename, by default will open a memory database.
$iAccessMode | [optional] access mode flags. Defaults to $SQLITE_OPEN_READWRITE + $SQLITE_OPEN_CREATE
$iEncoding | [optional] encoding mode flag, only used at creation time. Defaults to $SQLITE_ENCODING_UTF8

Return Value

Success: | a database handle.
Failure: | 0.
@error: | -1 - SQLite Reported an Error (Check @extended Value) 1 - Error Calling SQLite API 'sqlite3_open_v2' 2 - Error while converting filename to UTF-8 3 - _SQLite_Startup() not yet called
@extended: | value can be compared against $SQLITE_* constants

Remarks

There is no need to store the database handle, except if you use more than one database in the same session.
Functions that use the handle are using the last opened by default.

To create a database encoded in UFT16 just create it with $iEncoding = $SQLITE_ENCODING_UTF16.

Memory, temporary and permanent databases can be opened:
$hDb = _SQLite_Open() ; opens a temporary private memory DB
$hDb = _SQLite_Open(Default, ...) ; ditto
$hDb = _SQLite_Open(':memory:', ...) ; ditto

$hDb = _SQLite_Open('', ...) ; opens a temporary private on-disk DB

$hDb = _SQLite_Open('abc.db', ...) ; opens or creates a permanent shareable on-disk DB named 'abc.db'

In case you insist confusing yourself:
$hDb = _SQLite_Open('./:memory:', ...) ; opens or creates a permanent shareable on-disk DB named ':memory:'

Contrary to permanent disk-based DBs, memory and temporary DBs can't be shared nor be used for IPC (Inter Process Communication) and are destroyed at the end of the connection.

Related

_SQLite_Close

Example

#include <File.au3>
#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup()
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite3.dll Can't be Loaded!")
    Exit -1
EndIf
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)

_SQLite_Open() ; Creates a :memory: database and don't use its handle to refer to it
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't create a memory Database!")
    Exit -1
EndIf
_SQLite_Close()

Local $hMemDb = _SQLite_Open() ; Creates a :memory: database
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't create a memory Database!")
    Exit -1
EndIf

Local $hTmpDb = _SQLite_Open('') ; Creates a temporary disk database
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't create a temporary Database!")
    Exit -1
EndIf

Local $sDbName = _TempFile()
Local $hDskDb = _SQLite_Open($sDbName) ; Open a permanent disk database
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't open or create a permanent Database!")
    Exit -1
EndIf

; we can use the 3 database as needed by refering to their handle

; close the Dbs we created, in any order
_SQLite_Close($hTmpDb) ; temporary database are deleted automatically at Close
_SQLite_Close($hDskDb) ; DB is a regular file that could be reopened later
_SQLite_Close($hMemDb)

; we don't really need that DB
FileDelete($sDbName)

_SQLite_Shutdown()


Function _SQLite_Query

Function Reference

_SQLite_Query

Prepares a SQLite Query

#include <SQLite.au3>
_SQLite_Query ( $hDB, $sSQL, ByRef $hQuery )

Parameters

$hDB | An open database, use -1 to use last opened database
$sSQL | SQL statement to be executed
$hQuery | Passes out a query handle

Return Value

Success: | $SQLITE_OK.
Failure: | a value that can be compared against $SQLITE_* constants.
@error: | -1 - SQLite reported an error (Check return value) 1 - Error calling SQLite API 'sqlite3_prepare16_v2' 2 - Call prevented by SafeMode

Related

_SQLite_Exec, _SQLite_FetchData, _SQLite_FetchNames, _SQLite_GetTable, _SQLite_GetTable2d, _SQLite_QueryFinalize, _SQLite_QueryReset, _SQLite_QuerySingleRow, _SQLite_SetTimeout

Example

#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $hQuery, $aRow, $sMsg
_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open() ; open :memory: Database
_SQLite_Exec(-1, "CREATE TABLE aTest (a,b,c);") ; CREATE a Table
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('c','2','World');") ; INSERT Data
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('b','3',' ');") ; INSERT Data
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('a','1','Hello');") ; INSERT Data
_SQLite_Query(-1, "SELECT c FROM aTest ORDER BY a;", $hQuery) ; the query
While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK
    $sMsg &= $aRow[0]
WEnd
_SQLite_Exec(-1, "DROP TABLE aTest;") ; Remove the table
MsgBox($MB_SYSTEMMODAL, "SQLite", "Get Data using a Query : " & $sMsg)
_SQLite_Close()
_SQLite_Shutdown()

; Output:
; Hello World


Function _SQLite_QueryFinalize

Function Reference

_SQLite_QueryFinalize

Finalizes an _SQLite_Query() based query. The query is interrupted

#include <SQLite.au3>
_SQLite_QueryFinalize ( $hQuery )

Parameters

$hQuery Query handle generated by _SQLite_Query()

Return Value

Success: | $SQLITE_OK.
Failure: | a value that can be compared against $SQLITE_* constants.
@error: | -1 - SQLite reported an Error (Check Return value) 1 - Error calling SQLite API 'sqlite3_finalize' 2 - Call prevented by SafeMode

Remarks

The _SQLite_QueryFinalize() function is called to delete a prepared SQL statement obtained by a previous call to _SQLite_Query(). If the statement was executed successfully, or not executed at all, then $SQLITE_OK is returned. If execution of the statement failed then an error code is returned.

All prepared statements must be finalized before _SQLite_Close() is called or else the call will fail with a return code of $SQLITE_BUSY.

Related

_SQLite_Query, _SQLite_QueryReset

Example

#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $hQuery, $aRow, $aNames
_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open() ; open :memory: Database
_SQLite_Exec(-1, "CREATE TABLE aTest (A,B,C);")
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('c','2','World');")
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('b','3',' ');")
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('a','1','Hello');")
_SQLite_Query(-1, "SELECT ROWID,* FROM aTest ORDER BY a;", $hQuery)
_SQLite_FetchNames($hQuery, $aNames) ; Read out the Tablenames
MsgBox($MB_SYSTEMMODAL, "SQLite", "Row ID is : " & StringFormat(" %-10s  %-10s  %-10s  %-10s ", $aNames[0], $aNames[1], $aNames[2], $aNames[3]) & @CRLF)
While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK ; This get 1 row at a time
    MsgBox($MB_SYSTEMMODAL, "SQLite", "Get Data using FetchData : " & StringFormat(" %-10s  %-10s  %-10s  %-10s ", $aRow[0], $aRow[1], $aRow[2], $aRow[3]) & @CRLF)
    _SQLite_QueryFinalize($hQuery) ; This will stop the query, getting more rows
WEnd
_SQLite_Exec(-1, "DROP TABLE aTest;")
_SQLite_Close()
_SQLite_Shutdown()

; Output:
; rowid       A           B           C
; 3           a           1           Hello


Function _SQLite_QueryReset

Function Reference

_SQLite_QueryReset

Reset a _SQLite_Query() based query

#include <SQLite.au3>
_SQLite_QueryReset ( $hQuery )

Parameters

$hQuery Query handle generated by _SQLite_Query()

Return Value

Success: | $SQLITE_OK.
Failure: | a value that can be compared against $SQLITE_* constants.
@error: | -1 - SQLite reported an error (Check Return value) 1 - Error calling SQLite API 'sqlite3_reset' 2 - Call prevented by SafeMode

Remarks

This will reset an unlinalized query so that the resulting rowset can be forward scanned again.

Related

_SQLite_Query, _SQLite_QueryFinalize

Example

#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $hQuery, $aRow, $iSwitch
_SQLite_Startup()
_SQLite_Open()
_SQLite_Exec(-1, "CREATE TABLE tblTest (a,b,c);")
_SQLite_Exec(-1, "INSERT INTO tblTest VALUES ('1','1','1');" & _ ; Row 1
        "INSERT INTO tblTest VALUES ('2','2','2');" & _ ; Row 2
        "INSERT INTO tblTest VALUES ('3','3','3');") ; Row 3
_SQLite_Query(-1, "SELECT RowID,* FROM tblTest;", $hQuery)
While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK
    $iSwitch = MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL), "Row: " & $aRow[0], $aRow[1] & "," & $aRow[2] & "," & $aRow[3] & @CRLF & _
            "Continue Looping?")
    If $iSwitch = 6 Then ; Yes
        If $aRow[0] = 3 Then _SQLite_QueryReset($hQuery)
    Else ; No
        _SQLite_QueryFinalize($hQuery)
        ExitLoop
    EndIf
WEnd
_SQLite_Close()
_SQLite_Shutdown()


Function _SQLite_QuerySingleRow

Function Reference

_SQLite_QuerySingleRow

Read out the first row of the result from the specified query

#include <SQLite.au3>
_SQLite_QuerySingleRow ( $hDB, $sSQL, ByRef $aRow )

Parameters

$hDB | An open database, use -1 to use last opened database
$sSQL | SQL statement to be executed
$aRow | Passes out the amount of 'data' rows

Return Value

Success: $SQLITE_OK.
Failure: a value that can be compared against $SQLITE_* constants.
@error: -1 - SQLite Reported an Error (Check Return value)
1 - Error Calling _SQLite_Query()
2 - Call prevented by SafeMode
3 - Error Calling _SQLite_FetchData()
4 - Error Calling _SQLite_QueryFinalize()

Related

_SQLite_Query

Example

#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $aRow
_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open() ; open :memory: Database
_SQLite_Exec(-1, "CREATE TEMP TABLE settings (key,value);")
_SQLite_Exec(-1, "INSERT INTO settings (key,value) VALUES ('1','setting one');")
_SQLite_Exec(-1, "INSERT INTO settings (key,value) VALUES ('2','setting two');")
_SQLite_Exec(-1, "INSERT INTO settings (key,value) VALUES ('3','setting Three');")
_SQLite_Exec(-1, "INSERT INTO settings (key,value) VALUES ('4','setting Four');")
_SQLite_QuerySingleRow(-1, "SELECT value FROM settings WHERE key > '2';", $aRow) ; Select single row and single field !
MsgBox($MB_SYSTEMMODAL, "One of the values for key > 2:", $aRow[0])
_SQLite_Close()
_SQLite_Shutdown()


Function _SQLite_SafeMode

Function Reference

_SQLite_SafeMode

Disable or Enable Safe mode

#include <SQLite.au3>
_SQLite_SafeMode ( $bSafeModeState )

Parameters

$bSafeModeState True or False to enable or disable SafeMode

Return Value

Returns $SQLITE_OK.

Remarks

Safe mode prevents SQLite from crashing which can be caused by passing invalid query or database handles.
It's enabled by default.

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_SafeMode(False)
_SQLite_Exec(-1, "CREATE tblTest (a,b,c);"); No database open, this will crash due to SafeMode = false
_SQLite_Shutdown()


Function _SQLite_SetTimeout

Function Reference

_SQLite_SetTimeout

Sets timeout for busy handler

#include <SQLite.au3>
_SQLite_SetTimeout ( [$hDB = -1 [, $iTimeout = 1000]] )

Parameters

$hDB | [optional] An open database, use -1 to use last opened database
$iTimeout | [optional] Timeout [msec]

Return Value

Success: | $SQLITE_OK.
Failure: | a value that can be compared against $SQLITE_* constants.
@error: | -1 - SQLite reported an error (Check Return value) 1 - Error calling SQLite API 'sqlite3_busy_timeout' 2 - Call prevented by SafeMode

Remarks

This routine sets a busy handler that sleeps for a while when a table is locked. The handler will sleep multiple times until at least "ms" milliseconds of sleeping have been done. After "ms" milliseconds of sleeping, the handler returns 0 which causes sqlite3_exec() to return $SQLITE_BUSY.

Related

_SQLite_Query

Example

#include <File.au3>
#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)

Local $sDatabase, $hDB_a, $hDB_b, $iTimer, $iRval
$sDatabase = _TempFile()
$hDB_a = _SQLite_Open($sDatabase)
$hDB_b = _SQLite_Open($sDatabase)

_SQLite_Exec($hDB_a, "BEGIN EXCLUSIVE;")
_SQLite_Exec($hDB_a, "CREATE TABLE test (a,b,c);")
_SQLite_Exec($hDB_a, "INSERT INTO test VALUES (1,2,3);")
; Table 'test' is Busy now...

_SQLite_SetTimeout($hDB_b, 0)
$iTimer = TimerInit()
$iRval = _SQLite_Exec($hDB_b, "SELECT * FROM test") ; This will fail
MsgBox($MB_SYSTEMMODAL, "_SQLite_SetTimeout Example No Timeout", "Time: " & TimerDiff($iTimer) & @CRLF _
         & "Error: " & _SQLite_ErrMsg($hDB_b) & @CRLF)
_SQLite_SetTimeout($hDB_b, 5000)
$iTimer = TimerInit()
$iRval = _SQLite_Exec($hDB_b, "SELECT * FROM test") ; This will fail
MsgBox($MB_SYSTEMMODAL, "_SQLite_SetTimeout Example 5 Sec Timeout", "Time: " & TimerDiff($iTimer) & @CRLF _
         & "Error: " & _SQLite_ErrMsg($hDB_b) & @CRLF)
_SQLite_Exec($hDB_a, "END;")
_SQLite_Close($hDB_a)
_SQLite_Close($hDB_b)
_SQLite_Shutdown()
FileDelete($sDatabase)


Function _SQLite_Shutdown

Function Reference

_SQLite_Shutdown

Unloads SQLite.dll

#include <SQLite.au3>
_SQLite_Shutdown ( )

Return Value

None.

Remarks

If _SQLite_Startup() failed or was not executed, an AutoIt runtime error will be thrown, and the script will terminate!
AutoIt automatically closes any dlls it opened, but calling _SQLite_Shutdown() is still a good idea.

Related

_SQLite_Startup

Example

#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup()
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite3.dll Can't be Loaded!")
    Exit -1
EndIf
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Shutdown()


Function _SQLite_SQLiteExe

Function Reference

_SQLite_SQLiteExe

Executes commands in sqlite3.exe

#include <SQLite.au3>
_SQLite_SQLiteExe ( $sDatabaseFile, $sInput, ByRef $sOutput [, $sSQLiteExeFilename = "sqlite3.exe" [, $bDebug = False]] )

Parameters

$sDatabaseFile | Database filename
$sInput | Commands for sqlite3.exe
$sOutput | Raw output from sqlite3.exe
$sSQLiteExeFilename | [optional] Path to sqlite3.exe
$bDebug | [optional] Write sqlite3.exe exitcode through the callback function specified in _SQLite_Startup() (default is don't print)

Return Value

Success: | $SQLITE_OK.
Failure: | a value that can be compared against $SQLITE_* constants.
@error: | 1 - Can't create new Database 2 - sqlite3.exe not Found 3 - SQL error / incomplete SQL 4 - Can't open input file

Remarks

Run sqlite3.exe, press enter and type .Help for more info about the SQLite3.exe Commands.

If it not can be found, sqlite3.exe is downloaded in the @TempDir.
Other versions can be found at the SQLite Web site.

Example

#include <File.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <StringConstants.au3>

; Filenames
Local $sTsvFile = FileGetShortName(_TempFile(@ScriptDir, "~", ".tsv"))
Local $sDbFile = FileGetShortName(_TempFile(@ScriptDir, "~", ".db"))

; Create Tsv File
FileWriteLine($sTsvFile, "a" & @TAB & "b" & @TAB & "c")
FileWriteLine($sTsvFile, "a1" & @TAB & "b1" & @TAB & "c1")
FileWriteLine($sTsvFile, "a2" & @TAB & "b2" & @TAB & "c2")

; import (using SQLite3.exe)
Local $sIn, $sOut, $i, $sCreate = "CREATE TABLE TblImport (";
For $i = 1 To _StringCountOccurance(FileReadLine($sTsvFile, 1), @TAB) + 1
    $sCreate &= "Column_" & $i & ","
Next
$sCreate = StringTrimRight($sCreate, 1) & ");"
$sIn = $sCreate & @CRLF ; Create Table
$sIn &= ".separator \t" & @CRLF ; Select @TAB as Separator
$sIn &= ".import '" & $sTsvFile & "' TblImport" & @CRLF
_SQLite_SQLiteExe($sDbFile, $sIn, $sOut, -1, True)

If @error = 0 Then
    ;Show Table (using SQLite3.dll)
    Local $iRows, $iColumns, $aRes
    _SQLite_Startup()
    ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
    _SQLite_Open($sDbFile)
    _SQLite_GetTable2d(-1, "SELECT ROWID,* FROM TblImport;", $aRes, $iRows, $iColumns)
    _SQLite_Display2DResult($aRes) ; Output to Console
    _SQLite_Close()
    _SQLite_Shutdown()
Else
    If @error = 2 Then
        ConsoleWrite("ERROR: Sqlite3.exe file not found" & @CRLF)
    Else
        ConsoleWrite("ERROR: @error=" & @error & " when calling _SQLite_SQLiteExe" & @CRLF)
    EndIf
EndIf

; Remove Temp Files
FileDelete($sTsvFile)
FileDelete($sDbFile)

; Output:
; rowid  Column_1  Column_2  Column_3
; 1      a         b         c
; 2      a1        b1        c1
; 3      a2        b2        c2

Func _StringCountOccurance($sSearchString, $sSubString, $iCaseSense = $STR_NOCASESENSE) ; Returns Number of $sSubString in $sSearchString
    Local $iOccCnt = 1
    Do
        If StringInStr($sSearchString, $sSubString, $iCaseSense, $iOccCnt) > 0 Then
            $iOccCnt += 1
        Else
            ExitLoop
        EndIf
    Until 0
    Return $iOccCnt - 1
EndFunc   ;==>_StringCountOccurance


Function _SQLite_Startup

Function Reference

_SQLite_Startup

Loads SQLite3.dll

#include <SQLite.au3>
_SQLite_Startup ( [$sDll_Filename = "" [, $bUTF8ErrorMsg = False [, $iForceLocal = 0 [, $hPrintCallback = $__g_hPrintCallback_SQLite]]]] )

Parameters

$sDll_Filename | [optional] DLL filename. Default is "sqlite3.dll" or "sqlite3_x64.dll" in X64 mode.
$bUTF8ErrorMsg | [optional] to force ConsoleWrite() to display UTF8 chars
$iForceLocal | [optional] 1 = use the defined DLL file. No version checking. Automatic "_x64.dll" in X64 mode. 0 = the DLL will be downloaded if not found in @ScriptDir, @SystemDir, @WindowsDir or @WorkingDir. -1 = force download
$hPrintCallback | [optional] A variable assigned to the user defined function to display a SQLite diagnostic message. Default = __SQLite_ConsoleWrite(). See remarks.

Return Value

Success: | the path to the opened DLL file.
Failure: | sets the @error flag to non-zero.

Remarks

If #include <SQLite.dll.au3> is included the SQLite version is checked. If older, download will occur.

The downloaded file will be created in @SystemDir (may need #RequireAdmin).
If the creation is not successfull a temporary file will be created which will be destroyed when _SQLite_Shutdown() is called.

If $bUTF8ErrorMsg is not zero prints UTF8 formated string prints to console.
This allows applications as SciTE to display those characters if configured with output.code.page=65001.
This is the case when running SciTE under a non-english version as Vista(fr).

The $hPrintCallback parameter specifies the name of user-defined callback function. This function will be passed a single parameter which is the message to display. The default callback is $__g_hPrintCallback_SQLite. See that function for an example of how to implement your own callback function.

Related

_SQLite_Shutdown

Example

Example 1

; SQLite.dll version must match

#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $sSQliteDll = _SQLite_Startup()
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite3.dll Can't be Loaded!" & @CRLF & @CRLF & _
            "Not FOUND in @SystemDir, @WindowsDir, @ScriptDir, @WorkingDir or from www.autoitscript.com")
    Exit -1
EndIf

MsgBox($MB_SYSTEMMODAL, "SQLite3.dll Loaded", $sSQliteDll & " (" & _SQLite_LibVersion() & ")")
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Shutdown()

Example 2

; no version reference so file must exist in @SystemDir, @WindowsDir, @ScriptDir or @WorkingDir

#include <MsgBoxConstants.au3>
#include <SQLite.au3>

Local $sSQliteDll
$sSQliteDll = _SQLite_Startup()
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite3.dll Can't be Loaded!" & @CRLF & @CRLF & _
            "Not FOUND in @SystemDir, @WindowsDir, @ScriptDir or @WorkingDir")
    Exit -1
EndIf

MsgBox($MB_SYSTEMMODAL, "SQLite3.dll Loaded", $sSQliteDll & " (" & _SQLite_LibVersion() & ")")
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Shutdown()

Example 3

; open SQLite with a specific local file

#include <MsgBoxConstants.au3>
#include <SQLite.au3>

Local $sLocalSQLiteDll = "local SQLite.dll" ; to be change to an existing .dll to have no error

Local $sSQliteDll = _SQLite_Startup($sLocalSQLiteDll, False, 1)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "'SQLite3.dll' Can't be Loaded!")
    Exit -1
EndIf

MsgBox($MB_SYSTEMMODAL, "SQLite3.dll Loaded", $sSQliteDll & " (" & _SQLite_LibVersion() & ")")
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Shutdown()

Example 4

; Force download from www.autoitscript.com

; #RequireAdmin ; needed if storing in @systemdir is wanted

#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $sSQliteDll = _SQLite_Startup("", False, -1)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "'SQLite3.dll' Can't be Loaded!")
    Exit -1
EndIf

MsgBox($MB_SYSTEMMODAL, "SQLite3.dll Loaded", $sSQliteDll & " (" & _SQLite_LibVersion() & ")")
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Shutdown()


Function _SQLite_TotalChanges

Function Reference

_SQLite_TotalChanges

Returns number of all changes (including via triggers and foreign keys) from start of connection

#include <SQLite.au3>
_SQLite_TotalChanges ( [$hDB = -1] )

Parameters

$hDB [optional] An open database, default is the last opened database

Return Value

Success: | the number of changes.
Failure: | 0.
@error: | 1 - Error calling SQLite API 'sqlite3_total_changes' 2 - Call prevented by SafeMode

Related

_SQLite_Changes

Example

#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open()
_SQLite_Exec(-1, "CREATE TABLE test (a, b);") ; Create Table
_SQLite_Exec(-1, "INSERT INTO test VALUES ('1', '2');") ; Insert Row 1
_SQLite_Exec(-1, "INSERT INTO test VALUES ('3', '4');") ; Insert Row 2
MsgBox($MB_SYSTEMMODAL, "SQLite", "The last SQL statement changed " & _SQLite_Changes() & " rows" & @CRLF & _
        "All statements during this session changed " & _SQLite_TotalChanges() & " rows")
_SQLite_Close()
_SQLite_Shutdown()


User Defined Functions

String user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <String.au3>.

User Defined Function | Description
_HexToString | Convert a hex string to a string
_StringBetween | Find strings between two string delimiters
_StringExplode | Splits up a string into substrings depending on the given delimiters as PHP Explode v5
_StringInsert | Inserts a string within another string
_StringProper | Changes a string to proper case, same as the =Proper function in Excel
_StringRepeat | Repeats a string a specified number of times
_StringTitleCase | Changes a string to a title case string
_StringToHex | Convert a string to a hex string


Function _HexToString

Function Reference

_HexToString

Convert a hex string to a string

#include <String.au3>
_HexToString ( $sHex )

Parameters

$sHex A hexadecimal string

Return Value

Success: | a string.
Failure: | an empty string and sets the @error flag to non-zero.

Related

_StringToHex

Example

#include <MsgBoxConstants.au3>
#include <String.au3>

Local $sString = "This is a sample string"
Local $sHex = _StringToHex($sString) ; Convert the string to a hex string.
MsgBox($MB_SYSTEMMODAL, "", "Original String: " & $sString & @CRLF & " Hex: " & $sHex)

$sString = _HexToString($sHex) ; Convert the hex string back to the original string.
MsgBox($MB_SYSTEMMODAL, "", "Original Hex: " & $sHex & @CRLF & "String: " & $sString)


Function _StringBetween

Function Reference

_StringBetween

Find strings between two string delimiters

#include <String.au3>
_StringBetween ( $sString, $sStart, $sEnd [, $iMode = $STR_ENDISSTART [, $bCase = False]] )

Parameters

$sString | The string to search.
$sStart | The beginning of the string to find. Passing an empty string starts at the beginning
$sEnd | The end of the string to find. Passing an empty string searches from $sStart to end of string
$iMode | [optional] Search mode when $sStart = $sEnd $STR_ENDISSTART (0) the $sEnd string at the end of a match starts the next possible match (default) $STR_ENDNOTSTART (1) a further instance of the $sStart starts the next match
$bCase | [optional] False (default setting) = case-insensitive. True = case-sensitive.

Return Value

Success: | a 0-based array - element [0] contains the first found string.
Failure: | sets the @error flag to non-zero.
@error: | 1 - No strings found.

Example

#include <Array.au3>
#include <String.au3>

Example()

Func Example()
    ; Create an array of all the values between "[" and "]".
    Local $aArray = _StringBetween("[18][20][3][5][500][60]", "[", "]")

    ; Display the results in _ArrayDisplay.
    _ArrayDisplay($aArray, "Default Search")

    ; Create an array of all the values between "|" and "|" - note $sStart and $sEnd are identical
    Local $sString = "-----|Both Modes|$STR_ENDISSTART only|Both Modes|-----"

    ; Mode $STR_ENDISSTART - default - $sEnd is next $sStart
    $aArray = _StringBetween($sString, "|", "|")
    ; Display the results in _ArrayDisplay.
    _ArrayDisplay($aArray, "$STR_ENDISSTART")

    ; Mode $STR_ENDNOTSTART - $sEnd is not next $sStart
    $aArray = _StringBetween($sString, "|", "|", $STR_ENDNOTSTART)
    ; Display the results in _ArrayDisplay.
    _ArrayDisplay($aArray, "$STR_ENDNOTSTART")
EndFunc   ;==>Example


Function _StringExplode

Function Reference

_StringExplode

Splits up a string into substrings depending on the given delimiters as PHP Explode v5

#include <String.au3>
_StringExplode ( $sString, $sDelimiter [, $iLimit = 0] )

Parameters

$sString | String to be split
$sDelimiter | Delimiter to split on (split is performed on entire string, not individual characters)
$iLimit | [optional] Maximum elements to be returned =0 : (default) Split on every instance of the delimiter >0 : Split until limit, last element will contain remaining portion of the string <0 : Split on every instance, removing limit count from end of the array

Return Value

Returns an array containing the exploded strings.

Remarks

Use negative limit values to remove the first possible elements.

Example

#include <Array.au3>
#include <String.au3>

Local $sText = "one##two##three##four##five##six##seven##eight"
Local $aArray1 = _StringExplode($sText, "##", 0)
_ArrayDisplay($aArray1, "StringExplode 0")

; DISPLAYED
; [0] = one
; [1] = two
; [2] = three
; [3] = four
; [4] = five
; [5] = six
; [6] = seven
; [7] = eight

Local $aArray2 = _StringExplode($sText, "##", 4)
_ArrayDisplay($aArray2, "StringExplode 4")

; DISPLAYED
; [0] = one
; [1] = two
; [2] = three
; [3] = four
; [4] = five##six##seven##eight

Local $aArray3 = _StringExplode($sText, "##", -3)
_ArrayDisplay($aArray3, "StringExplode -3")

; DISPLAYED
; [0] = one
; [1] = two
; [2] = three
; [3] = four
; [4] = five


Function _StringInsert

Function Reference

_StringInsert

Inserts a string within another string

#include <String.au3>
_StringInsert ( $sString, $sInsertString, $iPosition )

Parameters

$sString | Original string
$sInsertString | String to be inserted
$iPosition | Position to insert string (negatives values count from right hand side)

Return Value

Success: | a new modified string.
Failure: | the original string and sets the @error flag to non-zero.
@error: | 1 - Invalid position

Remarks

Use negative position values to insert string from the right hand side.

Example

#include <String.au3>

; Inserts three "moving" underscores and prints them to the console.
For $i = -20 To 20
    ConsoleWrite($i & @TAB & _StringInsert("Supercalifragilistic", "___", $i) & @CRLF)
Next


Function _StringProper

Function Reference

_StringProper

Changes a string to proper case, same as the =Proper function in Excel

#include <String.au3>
_StringProper ( $sString )

Parameters

$sString Input string

Return Value

Success: | a proper string.
Failure: | an empty string.

Remarks

This function will capitalize every character following a non-alpha character.

Related

StringLower(), StringUpper()

Example

#include <MsgBoxConstants.au3>
#include <String.au3>

; Will return : Somebody Lastnames
MsgBox($MB_SYSTEMMODAL, '', _StringProper("somebody lastnames"))
; Will return : Some.Body Last(Name)
MsgBox($MB_SYSTEMMODAL, '', _StringProper("SOME.BODY LAST(NAME)"))
Exit


Function _StringRepeat

Function Reference

_StringRepeat

Repeats a string a specified number of times

#include <String.au3>
_StringRepeat ( $sString, $iRepeatCount )

Parameters

$sString | String to repeat
$iRepeatCount | Number of times to repeat the string

Return Value

Success: | a string with specified number of repeats.
Failure: | an empty string and sets the @error flag to non-zero.
@error: | 1 - One of the parameters is invalid

Example

#include <MsgBoxConstants.au3>
#include <String.au3>

; Repeat the string "+-" forty times.
MsgBox($MB_SYSTEMMODAL, '', _StringRepeat("+-", 40))


Function _StringTitleCase

Function Reference

_StringTitleCase

Changes a string to a title case string

#include <String.au3>
_StringTitleCase ( $sString )

Parameters

$sString Input string

Return Value

Success: | a titlecased string.
Failure: | an empty string.

Remarks

This function will capitalize the first character of every word. Does not support unicode strings.

Related

_StringProper

Example

#include <MsgBoxConstants.au3>
#include <String.au3>

Local $sString = "'she's all 'that' I, wAnt (" & '1st "disk" of 2)'
MsgBox($MB_SYSTEMMODAL, '', 'Original string: ' & $sString & @CRLF & _ ; Display the orginal and titlecased string.
        'Titlecased string: ' & _StringTitleCase($sString) & @CRLF)


Function _StringToHex

Function Reference

_StringToHex

Convert a string to a hex string

#include <String.au3>
_StringToHex ( $sString )

Parameters

$sString String to be converted.

Return Value

Success: | a hex string.
Failure: | an empty string.

Related

_HexToString

Example

#include <MsgBoxConstants.au3>
#include <String.au3>

Local $sString = "This is a sample string"
Local $sHex = _StringToHex($sString) ; Convert the string to a hex string.
MsgBox($MB_SYSTEMMODAL, "", "Original String: " & $sString & @CRLF & " Hex: " & $sHex)

$sString = _HexToString($sHex) ; Convert the hex string back to the original string.
MsgBox($MB_SYSTEMMODAL, "", "Original Hex: " & $sHex & @CRLF & "String: " & $sString)


User Defined Functions

StructureConstants user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <StructureConstants.au3>.

User Defined Function | Description
$tagBITMAPINFO | This structure defines the dimensions and color information of a Windows-based device-independent bitmap (DIB)
$tagBITMAPINFOHEADER | This structure defines the dimensions information of a Windows-based device-independent bitmap (DIB)
$tagBLENDFUNCTION | $tagBLENDFUNCTION structure controls blending by specifying the blending functions for source and destination bitmaps
$tagCOLORSCHEME | Contains information for the drawing of buttons in a toolbar or rebar
$tagCOMBOBOXEXITEM | Contains information about an item in a ComboBoxEx control
$tagDTPRANGE | Specifies a range of date and time, in coordinated universal time (UTC)
$tagEVENTLOGRECORD | Contains information about an event record
$tagFILETIME | Contains the number of 100-nanosecond intervals since January 1, 1601
$tagGDIP_EFFECTPARAMS_Blur | Blur effect parameter structure
$tagGDIP_EFFECTPARAMS_BrightnessContrast | BrightnessContrast effect parameter structure
$tagGDIP_EFFECTPARAMS_ColorBalance | ColorBalance effect parameter structure
$tagGDIP_EFFECTPARAMS_ColorCurve | ColorCurve effect parameter structure
$tagGDIP_EFFECTPARAMS_ColorLUT | ColorLUT effect parameter structure
$tagGDIP_EFFECTPARAMS_HueSaturationLightness | HueSaturationLightnes effect parameter structure
$tagGDIP_EFFECTPARAMS_Levels | Levels effect parameter structure
$tagGDIP_EFFECTPARAMS_RedEyeCorrection | RedEyeCorrection effect parameter structure
$tagGDIP_EFFECTPARAMS_Sharpen | Sharpen effect parameter structure
$tagGDIP_EFFECTPARAMS_Tint | Tint effect parameter structure
$tagGDIPBITMAPDATA | Bitmap Data
$tagGDIPCOLORMATRIX | The ColorMatrix structure contains a 5×5 matrix of real numbers. Several methods of the ImageAttributes class adjust image colors by using a color matrix
$tagGDIPENCODERPARAM | $tagGDIPENCODERPARAM structure
$tagGDIPENCODERPARAMS | $tagGDIPENCODERPARAMS structure
$tagGDIPIMAGECODECINFO | $tagGDIPIMAGECODECINFO structure
$tagGDIPRECTF | $tagGDIPRECTF structure
$tagGDIPSTARTUPINPUT | $tagGDIPSTARTUPINPUT structure
$tagGDIPSTARTUPOUTPUT | $tagGDIPSTARTUPOUTPUT structure
$tagGETIPAddress | Contains information for all 4 fields of the IP Address control
$tagGUID | Represents a globally unique identifier (GUID)
$tagHDITEM | Contains information about an item in a header control
$tagIMAGEINFO | Contains information about an image in an image list
$tagKBDLLHOOKSTRUCT | Contains information about a low-level keyboard input event
$tagLOGFONT | Defines the attributes of a font
$tagLVFINDINFO | Contains information used when searching for a list-view item
$tagLVHITTESTINFO | Contains information about a hit test
$tagLVITEM | Specifies or receives the attributes of a list-view item
$tagMARGINS | Defines the margins of windows that have visual styles applied
$tagMCHITTESTINFO | Carries information specific to hit-testing points for a month calendar control
$tagMCMONTHRANGE | Retrieves date information that represents the high and low limits of a month calendar control's display
$tagMCRANGE | Contains information for setting the minimum and maximum allowable dates for a month calendar control
$tagMCSELRANGE | Specifies a date and time, in coordinated universal time (UTC)
$tagMENUINFO | Contains information about a menu
$tagMENUITEMINFO | Contains information about a menu item
$tagNETRESOURCE | $tagNETRESOURCE structure
$tagNMCBEDRAGBEGIN | Contains information used with the $CBEN_DRAGBEGIN notification message
$tagNMCBEENDEDIT | Contains information about the conclusion of an edit operation within a ComboBoxEx control
$tagNMCOMBOBOXEX | Contains information specific to ComboBoxEx items for use with notification messages
$tagNMDATETIMECHANGE | Contains information about a change that has taken place in a date and time picker (DTP) control
$tagNMDATETIMEFORMAT | Contains information about a portion of the format string that defines a callback field within a date and time picker (DTP) control
$tagNMDATETIMEFORMATQUERY | Contains information about the control callback field
$tagNMDATETIMEKEYDOWN | Carries information used to describe and handle a $DTN_WMKEYDOWN notification message
$tagNMDATETIMESTRING | Contains information specific to an edit operation that has taken place in the control
$tagNMDAYSTATE | Carries information required to process the $MCN_GETDAYSTATE notification me
$tagNMHDDISPINFO | Contains information used in handling $HDN_GETDISPINFO notification messages
$tagNMHDFILTERBTNCLICK | Specifies or receives the attributes of a filter button click
$tagNMHDR | Contains information about a notification message
$tagNMHEADER | Contains information about control notification messages
$tagNMIPADDRESS | Contains information for the $IPN_FIELDCHANGED notification message
$tagNMITEMACTIVATE | Sent by a list-view control when the user activates an item
$tagNMLISTVIEW | Contains information about a list-view notification message
$tagNMLVCUSTOMDRAW | Contains information specific to an NM_CUSTOMDRAW (list view) notification message sent by a list-view control
$tagNMLVDISPINFO | Contains information about an $LVN_GETDISPINFO or $LVN_SETDISPINFO notification message
$tagNMLVFINDITEM | Contains information the owner needs to find items requested by a virtual list view control
$tagNMLVGETINFOTIP | Contains and receives list-view item information needed to display a ToolTip for an item
$tagNMLVKEYDOWN | Contains information used in processing the $LVN_KEYDOWN notification message
$tagNMLVSCROLL | Provides information about a scrolling operation
$tagNMMOUSE | Contains information used with mouse notification messages
$tagNMOBJECTNOTIFY | Contains information used with the $TBN_GETOBJECT, $TCN_GETOBJECT, $RBN_GETOBJECT, and $PSN_GETOBJECT notification messages
$tagNMRBAUTOSIZE | Contains information used in handling the $RBN_AUTOSIZE notification messages
$tagNMREBAR | Contains information used in handling various rebar notification messages
$tagNMREBARAUTOBREAK | Contains information used with the $RBN_AUTOBREAK notification
$tagNMREBARCHEVRON | Contains information used in handling the RBN_CHEVRONPUSHED notification message
$tagNMREBARCHILDSIZE | Contains information used in handling the RBN_CHILDSIZE notification message
$tagNMSELCHANGE | Carries information required to process the $MCN_SELCHANGE notification message
$tagNMTBHOTITEM | Contains information used with the $TBN_HOTITEMCHANGE notification
$tagNMTCKEYDOWN | Contains information used in processing the $LVN_KEYDOWN notification message
$tagNMTOOLBAR | Contains information used to process toolbar notification messages
$tagNMTREEVIEW | Contains information about a tree-view notification message
$tagNMTVCUSTOMDRAW | Contains information specific to an NM_CUSTOMDRAW (tree view) notification message sent by a tree-view control
$tagNMTVDISPINFO | Contains and receives display information for a tree-view item
$tagNMTVGETINFOTIP | Contains and receives tree-view item information needed to display a ToolTip for an item
$tagNMTVITEMCHANGE | Contains information on a treeview item change, sent with $TVN_ITEMCHANGED and $TVN_ITEMCHANGING notifications
$tagNMTVKEYDOWN | Contains information about a keyboard event in a tree-view control
$tagOPENFILENAME | Contains information information that the GetOpenFileName and GetSaveFileName functions use to initialize an Open or Save As dialog box
$tagOVERLAPPED | Contains information used in asynchronous (or overlapped) input and output (I/O)
$tagPOINT | Defines the x- and y- coordinates of a point
$tagPROCESS_INFORMATION | Contains information about a newly created process and its primary thread
$tagREBARBANDINFO | Contains information that defines a band in a rebar control
$tagRECT | Defines the coordinates of the upper-left and lower-right corners of a rectangle
$tagSCROLLBARINFO | Contains scroll bar information
$tagSCROLLINFO | Contains scroll bar parameters to be set by the $SBM_SETSCROLLINFO message, or retrieved by the $SBM_GETSCROLLINFO message
$tagSECURITY_ATTRIBUTES | Contains the security descriptor for an object and specifies whether the handle retrieved by specifying this structure is inheritable
$tagSIZE | Stores an ordered pair of integers, typically the width and height of a rectangle
$tagSTARTUPINFO | Specifies the window station, desktop, standard handles, and appearance of the main window for a process at creation time
$tagSYSTEMTIME | Specifies a date and time, in coordinated universal time (UTC)
$tagTBBUTTON | Contains information about a button in a toolbar
$tagTBBUTTONINFO | Contains or receives information for a specific button in a toolbar
$tagTEXTMETRIC | Contains basic information about a physical font
$tagTIME_ZONE_INFORMATION | Specifies information specific to the time zone
$tagTOKEN_PRIVILEGES | Contains information about a set of privileges for an access token
$tagTVHITTESTINFO | Contains information used to determine the location of a point relative to a tree-view control
$tagTVITEMEX | Specifies or receives attributes of a tree-view item
$tagWIN32_FIND_DATA | Contains the data found when finding a file
$tagWINDOWPLACEMENT | The WINDOWPLACEMENT structure contains information about the placement of a window on the screen
$tagWINDOWPOS | The WINDOWPOS structure contains information about the size and position of a window


Keyword $tagBITMAPINFO

Keyword Reference

$tagBITMAPINFO

This structure defines the dimensions and color information of a Windows-based device-independent bitmap (DIB)

Global Const $tagBITMAPINFO = $tagBITMAPINFOHEADER & ";dword biRGBQuad[1]"

Parameters

$tagBITMAPINFOHEADER | Contains information about dimensions of a bitmap.
biRGBQuad | An array of tagRGBQUAD structures. The elements of the array that make up the color table.

Remarks

This structure should not be used for declaration as the biRGBQuad field does not have the right dimension.
It is provided just for documentation.

Concatenation of a suitable sized array to $tagBITMAPINFOHEADER must be used.
Take care of the right initialization of 'biSize' field.


Keyword $tagBITMAPINFOHEADER

Keyword Reference

$tagBITMAPINFOHEADER

This structure defines the dimensions information of a Windows-based device-independent bitmap (DIB)

Global Const $tagBITMAPINFOHEADER = "struct; dword biSize;long biWidth;long biHeight;word biPlanes;word biBitCount;" & _
"dword biCompression;dword biSizeImage;long biXPelsPerMeter;long biYPelsPerMeter;" & _
"dword biClrUsed;dword biClrImportant; endstruct"

Parameters

biSize | The number of bytes required by the structure, minus the size of the RGBQuad data
biWidth | Specifies the width of the bitmap, in pixels
biHeight | Specifies the height of the bitmap, in pixels
biPlanes | Specifies the number of planes for the target device. This must be set to 1
biBitCount | Specifies the number of bits-per-pixel
biCompression | Specifies the type of compression for a compressed bottom-up bitmap
biSizeImage | Specifies the size, in bytes, of the image
biXPelsPerMeter | Specifies the horizontal resolution, in pixels-per-meter, of the target device for the bitmap
biYPelsPerMeter | Specifies the vertical resolution, in pixels-per-meter, of the target device for the bitmap
biClrUsed | Specifies the number of color indexes in the color table that are actually used by the bitmap
biClrImportant | Specifies the number of color indexes that are required for displaying the bitmap


Keyword $tagBLENDFUNCTION

Keyword Reference

$tagBLENDFUNCTION

$tagBLENDFUNCTION structure controls blending by specifying the blending functions for source and destination bitmaps

Global Const $tagBLENDFUNCTION = "byte Op;byte Flags;byte Alpha;byte Format"

Parameters

Op | Specifies the source blend operation:
Flags | Must be zero
Alpha | Specifies an alpha transparency value to be used on the entire source bitmap. This value is combined with any per-pixel alpha values in the source bitmap. If set to 0, it is assumed that your image is transparent. Set to 255 (opaque) when you only want to use per-pixel alpha values.
Format | This member controls the way the source and destination bitmaps are interpreted: $AC_SRC_ALPHA - This flag is set when the bitmap has an Alpha channel (that is, per-pixel alpha). Note that the APIs use premultiplied alpha, which means that the red, green and blue channel values in the bitmap must be premultiplied with the alpha channel value.

Remarks

The source bitmap used with $tagBLENDFUNCTION must be 32 bpp


Keyword $tagCOLORSCHEME

Keyword Reference

$tagCOLORSCHEME

Contains information for the drawing of buttons in a toolbar or rebar

Global Const $tagCOLORSCHEME = "dword Size;dword BtnHighlight;dword BtnShadow"

Parameters

Size | Size of this structure, in bytes
BtnHighlight | The COLORREF value that represents the highlight color of the buttons. Use $CLR_DEFAULT for the default highlight color.
BtnShadow | The COLORREF value that represents the shadow color of the buttons. Use $CLR_DEFAULT for the default shadow color.


Keyword $tagCOMBOBOXEXITEM

Keyword Reference

$tagCOMBOBOXEXITEM

Contains information about an item in a ComboBoxEx control

Global Const $tagCOMBOBOXEXITEM = "int Mask;int Item;ptr Text;int TextMax;int Image;int SelectedImage;int OverlayImage;" & _
"int Indent;int Param"

Parameters

Mask | A set of bit flags that specify attributes. Can be a combination of the following values. CBEIF_DI_SETITEM - Set this flag when processing CBEN_GETDISPINFO CBEIF_IMAGE - The iImage member is valid or must be filled in. CBEIF_INDENT - The iIndent member is valid or must be filled in. CBEIF_LPARAM - The lParam member is valid or must be filled in. CBEIF_OVERLAY - The iOverlay member is valid or must be filled in. CBEIF_SELECTEDIMAGE - The iSelectedImage member is valid or must be filled in. CBEIF_TEXT - The pszText member is valid or must be filled in.
Item | The 0-based index of the item.
Text | A pointer to a character buffer that contains or receives the item's text.
TextMax | The length of pszText, in TCHARs. If text information is being set, this member is ignored.
Image | The 0-based index of an image within the image list.
SelectedImage | The 0-based index of an image within the image list.
OverlayImage | The 1-based index of an overlay image within the image list.
Indent | The number of indent spaces to display for the item. Each indentation equals 10 pixels.
Param | A value specific to the item.


Keyword $tagDTPRANGE

Keyword Reference

$tagDTPRANGE

Specifies a range of date and time, in coordinated universal time (UTC)

Global Const $tagDTPRANGE = "word MinYear;word MinMonth;word MinDOW;word MinDay;word MinHour;word MinMinute;" & _
"word MinSecond;word MinMSecond;word MaxYear;word MaxMonth;word MaxDOW;word MaxDay;word MaxHour;" & _
"word MaxMinute;word MaxSecond;word MaxMSecond;bool MinValid;bool MaxValid"

Parameters

MinYear | Minimum year
MinMonth | Minimum month
MinDOW | Minimum day of week
MinDay | Minimum day
MinHour | Minimum hour
MinMinute | Minimum minute
MinSecond | Minimum second
MinMSecond | Minimum milliseconds
MaxYear | Maximum year
MaxMonth | Maximum month
MaxDOW | Maximum day of week
MaxDay | Maximum day
MaxHour | Maximum hour
MaxMinute | Maximum Minute
MaxSecond | Maximum second
MaxMSecond | Maximum milliseconds
MinValid | If True, minimum data is valid
MaxValid | If True, maximum data is valid


Keyword $tagEVENTLOGRECORD

Keyword Reference

$tagEVENTLOGRECORD

Contains information about an event record

Global Const $tagEVENTLOGRECORD = "int Length;int Reserved;int RecordNumber;int TimeGenerated;int TimeWritten;int EventID;" & _
"short EventType;short NumStrings;short EventCategory;short ReservedFlags;int ClosingRecordNumber;int StringOffset;" & _
"int UserSidLength;int UserSidOffset;int DataLength;int DataOffset"

Parameters

Length | The size of this event record, in bytes
Reserved | Reserved
RecordNumber | The number of the record
TimeGenerated | The time at which this entry was submitted
TimeWritten | The time at which this entry was received by the service to be written to the log
EventID | The event identifier
EventType | The type of event
NumStrings | The number of strings present in the log
EventCategory | The category for this event
ReservedFlags | Reserved
ClosingRecordNumber | Reserved
StringOffset | The offset of the description strings within this event log record
UserSidLength | The size of the UserSid member, in bytes
UserSidOffset | The offset of the security identifier (SID) within this event log record
DataLength | The size of the event-specific data (at the position indicated by DataOffset), in bytes
DataOffset | The offset of the event-specific information within this event log record, in bytes


Keyword $tagFILETIME

Keyword Reference

$tagFILETIME

Contains the number of 100-nanosecond intervals since January 1, 1601

Global Const $tagFILETIME = "struct; dword Lo;dword Hi; endstruct"

Parameters

Lo | The low order part of the file time
Hi | The high order part of the file time


Keyword $tagGDIP_EFFECTPARAMS_Blur

Keyword Reference

$tagGDIP_EFFECTPARAMS_Blur

Blur effect parameter structure

Global Const $tagGDIP_EFFECTPARAMS_Blur = "float Radius; bool ExpandEdge"

Parameters

Radius | Real number that specifies the sharpening radius (the radius of the convolution kernel) in pixels. The radius must be in the range 0.0 through 255.0
ExpandEdge | Boolean value that specifies whether the bitmap expands by an amount equal to the blur radius. If TRUE, the bitmap expands by an amount equal to the radius so that it can have soft edges. If FALSE, the bitmap remains the same size and the soft edges are clipped


Keyword $tagGDIP_EFFECTPARAMS_BrightnessContrast

Keyword Reference

$tagGDIP_EFFECTPARAMS_BrightnessContrast

BrightnessContrast effect parameter structure

Global Const $tagGDIP_EFFECTPARAMS_BrightnessContrast = "int BrightnessLevel; int ContrastLevel"

Parameters

BrightnessLevel | Integer in the range -255 through 255 that specifies the brightness level.
ContrastLevel | Integer in the range -100 through 100 that specifies the contrast level.


Keyword $tagGDIP_EFFECTPARAMS_ColorBalance

Keyword Reference

$tagGDIP_EFFECTPARAMS_ColorBalance

ColorBalance effect parameter structure

Global Const $tagGDIP_EFFECTPARAMS_ColorBalance = "int CyanRed; int MagentaGreen; int YellowBlue"

Parameters

CyanRed | Integer in the range -100 through 100 that specifies a change in the amount of red in the image.
MagentaGreen | Integer in the range -100 through 100 that specifies a change in the amount of green in the image.
YellowBlue | Integer in the range -100 through 100 that specifies a change in the amount of blue in the image.


Keyword $tagGDIP_EFFECTPARAMS_ColorCurve

Keyword Reference

$tagGDIP_EFFECTPARAMS_ColorCurve

ColorCurve effect parameter structure

Global Const $tagGDIP_EFFECTPARAMS_ColorCurve = "int Adjustment; int Channel; int AdjustValue"

Parameters

Adjustment | CurveAdjustments constant that specifies the adjustment to be applied ($GDIP_Adjust*).
Channel | CurveChannel constant that specifies the color channel to which the adjustment applies ($GDIP_CurveChannel*).
AdjustValue | Integer that specifies the intensity of the adjustment. The range of acceptable values depends on which adjustment is being applied (see $GDIP_Adjust* constants).


Keyword $tagGDIP_EFFECTPARAMS_ColorLUT

Keyword Reference

$tagGDIP_EFFECTPARAMS_ColorLUT

ColorLUT effect parameter structure

Global Const $tagGDIP_EFFECTPARAMS_ColorLUT = "byte LutB[256]; byte LutG[256]; byte LutR[256]; byte LutA[256]"

Parameters

LutB | an array of 256 items for Blue
LutG | an array of 256 items for Green
LutR | an array of 256 items for Red
LutA | an array of 256 items for Alpha

Remarks

look up tables for each color channel.


Keyword $tagGDIP_EFFECTPARAMS_HueSaturationLightness

Keyword Reference

$tagGDIP_EFFECTPARAMS_HueSaturationLightness

HueSaturationLightnes effect parameter structure

Global Const $tagGDIP_EFFECTPARAMS_HueSaturationLightness = "int HueLevel; int SaturationLevel; int LightnessLevel"

Parameters

HueLevel | Integer in the range -180 through 180 that specifies the change in hue.
SaturationLevel | Integer in the range -180 through 180 that specifies the change in saturation.
LightnessLevel | Integer in the range -180 through 180 that specifies the change in lightness.


Keyword $tagGDIP_EFFECTPARAMS_Levels

Keyword Reference

$tagGDIP_EFFECTPARAMS_Levels

Levels effect parameter structure

Global Const $tagGDIP_EFFECTPARAMS_Levels = "int Highlight; int Midtone; int Shadow"

Parameters

Highlight | Integer in the range 0 through 100 that specifies which pixels should be lightened.
Midtone | Integer in the range -100 through 100 that specifies how much to lighten or darken an image.
Shadow | Integer in the range 0 through 100 that specifies which pixels should be darkened.


Keyword $tagGDIP_EFFECTPARAMS_RedEyeCorrection

Keyword Reference

$tagGDIP_EFFECTPARAMS_RedEyeCorrection

RedEyeCorrection effect parameter structure

Global Const $tagGDIP_EFFECTPARAMS_RedEyeCorrection = "uint NumberOfAreas; ptr Areas"

Parameters

NumberOfAreas | Integer number of areas.
Areas | ptr to an array of X, Y, W, H


Keyword $tagGDIP_EFFECTPARAMS_Sharpen

Keyword Reference

$tagGDIP_EFFECTPARAMS_Sharpen

Sharpen effect parameter structure

Global Const $tagGDIP_EFFECTPARAMS_Sharpen = "float Radius; float Amount"

Parameters

Radius | Real number that specifies the sharpening radius (the radius of the convolution kernel) in pixels. The radius must be in the range 0.0 through 255.0?
Amount | Real number in the range 0.0 through 100.0 that specifies the amount of sharpening to be applied.


Keyword $tagGDIP_EFFECTPARAMS_Tint

Keyword Reference

$tagGDIP_EFFECTPARAMS_Tint

Tint effect parameter structure

Global Const $tagGDIP_EFFECTPARAMS_Tint = "int Hue; int Amount"

Parameters

Hue | Integer in the range -180 through 180 that specifies the hue to be strengthened or weakened.
Amount | Integer in the range -100 through 100 that specifies how much the hue (given by the hue parameter) is strengthened or weakened.


Keyword $tagGDIPBITMAPDATA

Keyword Reference

$tagGDIPBITMAPDATA

Bitmap Data

Global Const $tagGDIPBITMAPDATA = "uint Width;uint Height;int Stride;uint Format;ptr Scan0;ptr Reserved"

Parameters

Width | Number of pixels in one scan line of the bitmap
Height | Number of scan lines in the bitmap
Stride | Offset, in bytes, between consecutive scan lines of the bitmap. If the stride is positive, the bitmap is top-down. If the stride is negative, the bitmap is bottom-up.
Format | Specifies the pixel format of the bitmap
Scan0 | Pointer to the first (index 0) scan line of the bitmap
Reserved | Reserved for future use


Keyword $tagGDIPCOLORMATRIX

Keyword Reference

$tagGDIPCOLORMATRIX

The ColorMatrix structure contains a 5×5 matrix of real numbers. Several methods of the ImageAttributes class adjust image colors by using a color matrix

Global Const $tagGDIPCOLORMATRIX = "float m[25]"

Parameters

m Contains information about color matrix.

Remarks

A 5×5 color matrix is a homogeneous matrix for a 4-space transformation.
The element in the fifth row and fifth column of a 5×5 homogeneous matrix must be 1, and all of the other elements in the fifth column must be 0.
Color matrices are used to transform color vectors.
The first four components of a color vector hold the red, green, blue, and alpha components (in that order) of a color.
The fifth component of a color vector is always 1.


Keyword $tagGDIPENCODERPARAM

Keyword Reference

$tagGDIPENCODERPARAM

$tagGDIPENCODERPARAM structure

Global Const $tagGDIPENCODERPARAM = "struct;byte GUID[16];ulong NumberOfValues;ulong Type;ptr Values;endstruct"

Parameters

GUID | Identifies the parameter category (GDI_EPG constants)
NumberOfValues | Number of values in the array pointed to by the Value member
Type | Identifies the data type of the parameters (GDI_EPT constants)
Values | Pointer to an array of values. Each value has the type specified by the Type member.


Keyword $tagGDIPENCODERPARAMS

Keyword Reference

$tagGDIPENCODERPARAMS

$tagGDIPENCODERPARAMS structure

Global Const $tagGDIPENCODERPARAMS = "uint Count;" & $tagGDIPENCODERPARAM

Parameters

Count | Number of $tagGDIPENCODERPARAM structures in the array
$tagGDIPENCODERPARAM | First $tagGDIPENCODERPARAM structure of the array

Remarks

Use such kind of code to $i entry being less than the $ibEntries in the $tagGDIPENCODERPARAMS (Count)

; Just to calculate entry size to be OK under x86 or x64
Local $tParam = DllStructCreate($tagGDIPENCODERPARAM)
Local $iParamSize = DllStructGetSize($tParam)

; allocate a $tagGDIPENCODERPARAMS structure with $ibEntries
Local $ibEntries = 3;
Local $tParams = DllStructCreate($tagGDIPENCODERPARAMS & "byte[$iEntrySize * ($ibEntries - 1))
DLLStructSetData($tParams, "Count", $ibEntries)

; Reallocate entry structure to point to the desired $i entry (0-based)
Local $i = 1;
Local $tParamI = DllStructCreate($tagGDIPENCODERPARAM, DllStructGetPtr($tParams, "GUID") + ($i * $iParamSize))

; we can access the $tagGDIPENCODERPARAM selected entry just using $tParam structure which has been reallocated

; if we only use one entry the code is greatly simplified
Local $tParams = DllStructCreate($tagGDIPENCODERPARAMS)
DLLStructSetData($tParams, "Count", 1)

; the entry can be access directly thru $tParams structure

Related

$tagGDIPENCODERPARAM


Keyword $tagGDIPIMAGECODECINFO

Keyword Reference

$tagGDIPIMAGECODECINFO

$tagGDIPIMAGECODECINFO structure

Global Const $tagGDIPIMAGECODECINFO = "byte CLSID[16];byte FormatID[16];ptr CodecName;ptr DllName;ptr FormatDesc;ptr FileExt;" & _
"ptr MimeType;dword Flags;dword Version;dword SigCount;dword SigSize;ptr SigPattern;ptr SigMask"

Parameters

CLSID | Codec identifier (GUID structure)
FormatID | File format identifier (GUID structure)
CodecName | Pointer to a Unicode null terminated string that contains the codec name
DllName | Pointer to a Unicode null terminated string that contains the path name of the DLL in which the codec resides. If the codec is not in a DLL, this pointer is 0.
FormatDesc | Pointer to a Unicode null terminated string that contains the name of the file format used by the codec.
FileExt | Pointer to a Unicode null terminated string that contains all filename extensions associated with the codec. The extensions are separated by semicolons.
MimeType | Pointer to a null-terminated string that contains the mime type of the codec
Flags | Combination of $GDIP_ICF flags
Version | Indicates the version of the codec
SigCount | Indicates the number of signatures used by the file format associated with the codec
SigSize | Indicates the number of bytes in each signature
SigPattern | Pointer to an array of bytes that contains the pattern for each signature
SigMask | Pointer to an array of bytes that contains the mask for each signature


Keyword $tagGDIPRECTF

Keyword Reference

$tagGDIPRECTF

$tagGDIPRECTF structure

Global Const $tagGDIPRECTF = "float X;float Y;float Width;float Height"

Parameters

X | X coordinate of upper left hand corner of rectangle
Y | Y coordinate of upper left hand corner of rectangle
Width | Rectangle width
Height | Rectangle height


Keyword $tagGDIPSTARTUPINPUT

Keyword Reference

$tagGDIPSTARTUPINPUT

$tagGDIPSTARTUPINPUT structure

Global Const $tagGDIPSTARTUPINPUT = "int Version;ptr Callback;int NoThread;int NoCodecs"

Parameters

Version | Specifies the version of Microsoft Windows GDI+
Callback | Pointer to a callback function that GDI+ can call, on debug builds, for assertions and warnings
NoThread | Boolean value that specifies whether to suppress the GDI+ background thread. If you set this member to True, GdiplusStartup returns a pointer to a hook function and a pointer to an unhook function. You must call those functions appropriately to replace the background thread. If you do not want to be responsible for calling the hook and unhook functions, set this member to False.
NoCodecs | Boolean value that specifies whether you want GDI+ to suppress external image codecs. GDI+ version 1.0 does not support external image codecs, so this parameter is ignored.


Keyword $tagGDIPSTARTUPOUTPUT

Keyword Reference

$tagGDIPSTARTUPOUTPUT

$tagGDIPSTARTUPOUTPUT structure

Global Const $tagGDIPSTARTUPOUTPUT = "ptr HookProc;ptr UnhookProc"

Parameters

HookProc | Receives a pointer to a hook function
UnhookProc | Receives a pointer to an unhook function


Keyword $tagGETIPAddress

Keyword Reference

$tagGETIPAddress

Contains information for all 4 fields of the IP Address control

Global Const $tagGETIPAddress = "byte Field4;byte Field3;byte Field2;byte Field1"

Parameters

Field4 | contains bits 0 through 7
Field3 | contains bits 8 through 15
Field2 | contains bits 16 through 23
Field1 | contains bits 24 through 31


Keyword $tagGUID

Keyword Reference

$tagGUID

Represents a globally unique identifier (GUID)

Global Const $tagGUID = "struct; ulong Data1;ushort Data2;ushort Data3;byte Data4[8]; endstruct"

Parameters

Data1 | Data 1 element
Data2 | Data 2 element
Data3 | Data 3 element
Data4 | Data 4 element


Keyword $tagHDITEM

Keyword Reference

$tagHDITEM

Contains information about an item in a header control

Global Const $tagHDITEM = "int Mask;int XY;ptr Text;hwnd hBMP;int TextMax;int Fmt;int Param;int Image;int Order;int Type;ptr pFilter;int State"

Parameters

Mask | Flags indicating which other structure members contain valid data or must be filled in
XY | Width or height of the item
Text | Address of Item string
hBMP | Handle to the item bitmap
TextMax | Length of the item string
Fmt | Flags that specify the item's format
Param | Application-defined item data
Image | 0-based index of an image within the image list
Order | Order in which the item appears within the header control, from left to right
Type | Type of filter specified by pFilter
pFilter | Address of an application-defined data item
State | Item state


Keyword $tagIMAGEINFO

Keyword Reference

$tagIMAGEINFO

Contains information about an image in an image list

Global Const $tagIMAGEINFO = "hwnd hBitmap;hwnd hMask;int Unused1;int Unused2;int Left;int Top;int Right;int Bottom"

Parameters

hBitmap | Handle to the bitmap that contains the image
hMask | Handle to a monochrome bitmap that contains the mask for the image
Unused1 | Not used
Unused2 | Not used
Left | Left side of the rectangle of the image
Top | Top of the rectangle of the image
Right | Right side of the rectangle of the image
Bottom | Bottom of the rectangle of the image


Keyword $tagKBDLLHOOKSTRUCT

Keyword Reference

$tagKBDLLHOOKSTRUCT

Contains information about a low-level keyboard input event

Global Const $tagKBDLLHOOKSTRUCT = "dword vkCode;dword scanCode;dword flags;dword time;ulong_ptr dwExtraInfo"

Parameters

vkCode | Specifies a virtual-key code. The code must be a value in the range 1 to 254
scanCode | Specifies a hardware scan code for the key
flags | Specifies the extended-key flag, event-injected flag, context code, and transition-state flag. This member is specified as follows. An application can use the following values to test the keystroke flags: $LLKHF_EXTENDED - Test the extended-key flag $LLKHF_INJECTED - Test the event-injected flag $LLKHF_ALTDOWN - Test the context code $LLKHF_UP - Test the transition-state flag 0 - Specifies whether the key is an extended key, such as a function key or a key on the numeric keypad The value is 1 if the key is an extended key; otherwise, it is 0 1 to 3 - Reserved 4 - Specifies whether the event was injected. The value is 1 if the event was injected; otherwise, it is 0 5 - Specifies the context code. The value is 1 if the ALT key is pressed; otherwise, it is 0 6 - Reserved 7 - Specifies the transition state. The value is 0 if the key is pressed and 1 if it is being released
time | Specifies the time stamp for this message, equivalent to what GetMessageTime would return for this message
dwExtraInfo | Specifies extra information associated with the message


Keyword $tagLOGFONT

Keyword Reference

$tagLOGFONT

Defines the attributes of a font

Global Const $tagLOGFONT = "struct; int Height;int Width;int Escapement;int Orientation;int Weight;byte Italic;byte Underline;" & _
"byte Strikeout;byte CharSet;byte OutPrecision;byte ClipPrecision;byte Quality;byte PitchAndFamily;char FaceName[32]; endstruct"

Parameters

Height | Height, in logical units, of the font's character cell or character
Width | Specifies the average width, in logical units, of characters in the font
Escapement | Specifies the angle, in tenths of degrees, between the escapement vector and the X axis
Orientation | Specifies the angle, in tenths of degrees, between each character's base line and the X axis
Weight | Specifies the weight of the font in the range 0 through 1000
Italic | Specifies an italic font if set to True
Underline | Specifies an underlined font if set to True
StrikeOut | Specifies a strikeout font if set to True
CharSet | Specifies the character set
OutPrecision | Specifies the output precision
ClipPrecision | Specifies the clipping precision
Quality | Specifies the output quality
PitchAndFamily | Specifies the pitch and family of the font
FaceName | Specifies the typeface name of the font


Keyword $tagLVFINDINFO

Keyword Reference

$tagLVFINDINFO

Contains information used when searching for a list-view item

Global Const $tagLVFINDINFO = "struct; uint Flags;ptr Text;lparam Param;" & $tagPOINT & ";uint Direction; endstruct"

Parameters

Flags | Type of search to perform. This member can be set to one or more of the following values: $LVFI_PARAM - Searches for a match between this structure's Param member and the Param member of an item. If $LVFI_PARAM is specified, all other flags are ignored. $LVFI_PARTIAL - Checks to see if the item text begins with the string pointed to by the Text member. This value implies use of $LVFI_STRING. $LVFI_STRING - Searches based on the item text. Unless additional values are specified, the item text of the matching item must exactly match the string pointed to by the Text member. $LVFI_SUBSTRING - Equivalent to $LVFI_PARTIAL Windows Vista or later. $LVFI_WRAP - Continues the search at the beginning if no match is found $LVFI_NEARESTXY - Finds the item nearest to the position specified in the X and Y members, in the direction specified by the Direction member. This flag is supported only by large icon and small icon modes.
Text | Address of a string to compare with the item text. It is valid if $LVFI_STRING or $LVFI_PARTIAL is set in the Flags member.
Param | Value to compare with the Param member of an item's $LVITEM structure. It is valid only if $LVFI_PARAM is set in the flags member.
$tagPOINT | Initial X,Y search position. It is valid only if $LVFI_NEARESTXY is set in the Flags member.
Direction | Virtual key code that specifies the direction to search. The following codes are supported: VK_LEFT VK_RIGHT VK_UP VK_DOWN VK_HOME VK_END VK_PRIOR VK_NEXT This member is valid only if $LVFI_NEARESTXY is set in the flags member.


Keyword $tagLVHITTESTINFO

Keyword Reference

$tagLVHITTESTINFO

Contains information about a hit test

Global Const $tagLVHITTESTINFO = $tagPOINT & ";uint Flags;int Item;int SubItem;int iGroup"

Parameters

$tagPOINT | X,Y position to hit test
Flags Results of a hit test. Can be one or more of the following values:
$LVHT_ABOVE - The position is above the control's client area
$LVHT_BELOW - The position is below the control's client area
$LVHT_NOWHERE - The position is inside the client window, but it is not over a list item
$LVHT_ONITEMICON - The position is over an item's icon
$LVHT_ONITEMLABEL - The position is over an item's text
$LVHT_ONITEMSTATEICON - The position is over the state image of an item
$LVHT_TOLEFT - The position is to the left of the client area
$LVHT_TORIGHT - The position is to the right of the client area
For Windows Vista or later:
$LVHT_EX_GROUP_HEADER - The point is within the group header.
$LVHT_EX_GROUP_FOOTER - The point is within the group footer.
$LVHT_EX_GROUP_COLLAPSE - The point is within the collapse/expand button of the group.
$LVHT_EX_GROUP_BACKGROUND - The point is within the area of the group where items are displayed.
$LVHT_EX_GROUP_STATEICON - The point is within the state icon of the group.
$LVHT_EX_GROUP_SUBSETLINK - The point is within the subset link of the group.
$LVHT_EX_GROUP - $LVHT_EX_GROUP_BACKGROUND | $LVHT_EX_GROUP_COLLAPSE | $LVHT_EX_GROUP_FOOTER | $LVHT_EX_GROUP_HEADER | $LVHT_EX_GROUP_STATEICON | $LVHT_EX_GROUP_SUBSETLINK.
$LVHT_EX_ONCONTENTS - The point is within the icon or text content of the item and not on the background.
$LVHT_EX_FOOTER - The point is within the footer of the list-view control.
Item | Receives the index of the matching item. Or if hit-testing a subitem, this value represents the subitem's parent item.
SubItem | Receives the index of the matching subitem. When hit-testing an item, this member will be zero.
iGroup | Group index of the item hit (read only). Valid only for owner data. If the point is within an item that is displayed in multiple groups then iGroup will specify the group index of the item Windows Vista or later.


Keyword $tagLVITEM

Keyword Reference

$tagLVITEM

Specifies or receives the attributes of a list-view item

Global Const $tagLVITEM = "struct; uint Mask;int Item;int SubItem;uint State;uint StateMask;ptr Text;int TextMax;int Image;lparam Param;" & _
"int Indent;int GroupID;uint Columns;ptr pColumns;ptr piColFmt;int iGroup; endstruct"

Parameters

Mask | Set of flags that specify which members of this structure contain data to be set or which members are being requested. This member can have one or more of the following flags set: $LVIF_COLFMT - The piColFmt member is valid or must be set. If this flag is used, the cColumns member is valid or must be set Windows Vista or later. $LVIF_COLUMNS - The Columns member is valid $LVIF_DI_SETITEM - The operating system should store the requested list item information $LVIF_GROUPID - The GroupID member is valid $LVIF_IMAGE - The Image member is valid $LVIF_INDENT - The Indent member is valid $LVIF_NORECOMPUTE - The control will not generate LVN_GETDISPINFO to retrieve text information $LVIF_PARAM - The Param member is valid $LVIF_STATE - The State member is valid $LVIF_TEXT - The Text member is valid
Item | 0-based index of the item to which this structure refers
SubItem | 1-based index of the subitem to which this structure refers
State | Indicates the item's state, state image, and overlay image
StateMask | Value specifying which bits of the state member will be retrieved or modified
Text | Pointer to a string containing the item text
TextMax | Number of bytes in the buffer pointed to by Text, including the string terminator
Image | Index of the item's icon in the control's image list
Param | Value specific to the item
Indent | Number of image widths to indent the item
GroupID | Identifier of the tile view group that receives the item
Columns | Number of tile view columns to display for this item
pColumns | Pointer to the array of column indices
piColFmt | A pointer to an array of the following flags (alone or in combination, specifying the format of each subitem in extended tile view (Windows 7 and later). Value Meaning: $LVCFMT_LINE_BREAK - Forces the column to wrap to the top of the next list of columns. $LVCFMT_FILL Fills - the remainder of the tile area. Might have a title. $LVCFMT_WRAP - Allows the column to wrap within the remaining space in its list of columns. $LVCFMT_NO_TITLE - Removes the title from the subitem. $LVCFMT_TILE_PLACEMENTMASK - Equivalent to a combination of $LVCFMT_LINE_BREAK and $LVCFMT_FILL.
iGroup | Group index of the item. Valid only for owner data/callback (single item in multiple groups) (Windows Vista or later).


Keyword $tagMARGINS

Keyword Reference

$tagMARGINS

Defines the margins of windows that have visual styles applied

Global Const $tagMARGINS = "int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight"

Parameters

cxLeftWidth | Width of the left border that retains its size
cxRightWidth | Width of the right border that retains its size
cyTopHeight | Height of the top border that retains its size
cyBottomHeight | Height of the bottom border that retains its size


Keyword $tagMCHITTESTINFO

Keyword Reference

$tagMCHITTESTINFO

Carries information specific to hit-testing points for a month calendar control

Global Const $tagMCHITTESTINFO = "uint Size;" & $tagPOINT & ";uint Hit;" & $tagSYSTEMTIME & _
";" & $tagRECT & ";int iOffset;int iRow;int iCol"

Parameters

Size | Size of this structure, in bytes
$tagPOINT | X,Y position of the point to be hit tested
Hit | Results of the hit test operation. This value will be one of the following: $MCHT_CALENDARBK - The given point was in the calendar's background $MCHT_CALENDARDATE - The given point was on a particular date within the calendar $MCHT_CALENDARDATENEXT - The given point was over a date from the next month $MCHT_CALENDARDATEPREV - The given point was over a date from the previous month $MCHT_CALENDARDAY - The given point was over a day abbreviation $MCHT_CALENDARWEEKNUM - The given point was over a week number $MCHT_NOWHERE - The given point was not on the month calendar control $MCHT_TITLEBK - The given point was over the background of a month's title $MCHT_TITLEBTNNEXT - The given point was over the button at the top right corner $MCHT_TITLEBTNPREV - The given point was over the button at the top left corner $MCHT_TITLEMONTH - The given point was in a month's title bar, over a month name $MCHT_TITLEYEAR - The given point was in a month's title bar, over the year value
$tagSYSTEMTIME | Year Month DOW Day Hour Minute Seconds MSeconds
$tagRECT | The RECT of the hit-tested location.
iOffset | When displaying more than one calendar, this is the offset of the calendar at the hit-tested point (0-based).
iRow | The row number for the calendar grid that the given hit point was over. Example: If you hit-tested the 8th of a month, which is in the second week of the month, iRow will be one since the index of the row is 0-based row index.
iCol | The column number for the calendar grid that the given point was over. For example, if your week starts on Sunday and the 1st of the month is Friday, hit testing the 1st will return five (5) for iCol, since Friday is in the fifth column from the beginning of the row, using a 0-based column index.


Keyword $tagMCMONTHRANGE

Keyword Reference

$tagMCMONTHRANGE

Retrieves date information that represents the high and low limits of a month calendar control's display

Global Const $tagMCMONTHRANGE = "short MinYear;short MinMonth;short MinDOW;short MinDay;short MinHour;short MinMinute;short MinSecond;" & _
"short MinMSeconds;short MaxYear;short MaxMonth;short MaxDOW;short MaxDay;short MaxHour;short MaxMinute;short MaxSecond;" & _
"short MaxMSeconds;short Span"

Parameters

MinYear | Year
MinMonth | Month
MinDOW | DOW
MinDay | Day
MinHour | Hour
MinMinute | Minute
MinSecond | Seconds
MinMSeconds | Milliseconds
MaxYear | Year
MaxMonth | Month
MaxDOW | DOW
MaxDay | Day
MaxHour | Hour
MaxMinute | Minute
MaxSecond | Seconds
MaxMSeconds | Milliseconds
Span | Range, in months, spanned by the two limits


Keyword $tagMCRANGE

Keyword Reference

$tagMCRANGE

Contains information for setting the minimum and maximum allowable dates for a month calendar control

Global Const $tagMCRANGE = "short MinYear;short MinMonth;short MinDOW;short MinDay;short MinHour;short MinMinute;short MinSecond;" & _
"short MinMSeconds;short MaxYear;short MaxMonth;short MaxDOW;short MaxDay;short MaxHour;short MaxMinute;short MaxSecond;" & _
"short MaxMSeconds;short MinSet;short MaxSet"

Parameters

MinYear | Year
MinMonth | Month
MinDOW | DOW
MinDay | Day
MinHour | Hour
MinMinute | Minute
MinSecond | Seconds
MinMSeconds | Milliseconds
MaxYear | Year
MaxMonth | Month
MaxDOW | DOW
MaxDay | Day
MaxHour | Hour
MaxMinute | Minute
MaxSecond | Seconds
MaxMSeconds | Milliseconds
MinSet | A minimum limit is set for the control
MaxSet | A maximum limit is set for the control


Keyword $tagMCSELRANGE

Keyword Reference

$tagMCSELRANGE

Specifies a date and time, in coordinated universal time (UTC)

Global Const $tagMCSELRANGE = "short MinYear;short MinMonth;short MinDOW;short MinDay;short MinHour;short MinMinute;short MinSecond;" & _
"short MinMSeconds;short MaxYear;short MaxMonth;short MaxDOW;short MaxDay;short MaxHour;short MaxMinute;short MaxSecond;" & _
"short MaxMSeconds"

Parameters

MinYear | Year
MinMonth | Month
MinDOW | DOW
MinDay | Day
MinHour | Hour
MinMinute | Minute
MinSecond | Seconds
MinMSeconds | Milliseconds
MaxYear | Year
MaxMonth | Month
MaxDOW | DOW
MaxDay | Day
MaxHour | Hour
MaxMinute | Minute
MaxSecond | Seconds
MaxMSeconds | Milliseconds


Keyword $tagMENUINFO

Keyword Reference

$tagMENUINFO

Contains information about a menu

Global Const $tagMENUINFO = "int Size;int Mask;int Style;int YMax;int hBack;int ContextHelpID;ptr MenuData"

Parameters

Size | Specifies the size, in bytes, of the structure
Mask | Members to retrieve or set. This member can be one or more of the following values: $MIM_APPLYTOSUBMENUS - Settings apply to the menu and all of its submenus $MIM_BACKGROUND - Retrieves or sets the hBack member $MIM_HELPID - Retrieves or sets the ContextHelpID member $MIM_MAXHEIGHT - Retrieves or sets the YMax member $MIM_MENUDATA - Retrieves or sets the MenuData member $MIM_STYLE - Retrieves or sets the Style member
Style | Style of the menu. It can be one or more of the following values: $MNS_AUTODISMISS - Menu automatically ends when mouse is outside the menu for approximately 10 seconds $MNS_CHECKORBMP - The same space is reserved for the check mark and the bitmap $MNS_DRAGDROP - Menu items are OLE drop targets or drag sources $MNS_MODELESS - Menu is modeless; that is, there is no menu modal message loop while the menu is active. $MNS_NOCHECK - No space is reserved to the left of an item for a check mark $MNS_NOTIFYBYPOS - A WM_MENUCOMMAND message is sent instead of a WM_COMMAND message when a selection is made
YMax | Maximum height of the menu in pixels
hBack | Brush to use for the menu's background
ContextHelpID | The context help identifier
MenuData | An application defined value


Keyword $tagMENUITEMINFO

Keyword Reference

$tagMENUITEMINFO

Contains information about a menu item

Global Const $tagMENUITEMINFO = "int Size;int Mask;int Type;int State;int ID;int SubMenu;int BmpChecked;int BmpUnchecked;" & _
"int ItemData;ptr TypeData;int CCH;int BmpItem"

Parameters

Size | Specifies the size, in bytes, of the structure
Mask | Members to retrieve or set. This member can be one or more of these values: $MIIM_BITMAP - Retrieves or sets the BmpItem member $MIIM_CHECKMARKS - Retrieves or sets the BmpChecked and BmpUnchecked members $MIIM_DATA - Retrieves or sets the ItemData member $MIIM_FTYPE - Retrieves or sets the Type member $MIIM_ID - Retrieves or sets the ID member $MIIM_STATE - Retrieves or sets the State member $MIIM_STRING - Retrieves or sets the TypeData member $MIIM_SUBMENU - Retrieves or sets the SubMenu member $MIIM_TYPE - Retrieves or sets the Type and TypeData members
Type | Menu item type. This member can be one or more of the following values: $MFT_BITMAP - Displays the menu item using a bitmap $MFT_MENUBARBREAK - Places the menu item on a new line or in a new column $MFT_MENUBREAK - Places the menu item on a new line or in a new column $MFT_OWNERDRAW - Assigns responsibility for drawing the menu item to the menu owner $MFT_RADIOCHECK - Displays selected menu items using a radio button mark $MFT_RIGHTJUSTIFY - Right justifies the menu item and any subsequent items $MFT_RIGHTORDER - Specifies that menus cascade right to left $MFT_SEPARATOR - Specifies that the menu item is a separator
State | Menu item state. This member can be one or more of these values: $MFS_CHECKED - Checks the menu item $MFS_DEFAULT - Specifies that the menu item is the default $MFS_DISABLED - Disables the menu item and grays it so that it cannot be selected $MFS_ENABLED - Enables the menu item so that it can be selected $MFS_GRAYED - Disables the menu item and grays it so that it cannot be selected $MFS_HILITE - Highlights the menu item
ID | Application-defined 16-bit value that identifies the menu item
SubMenu | Handle to the drop down menu or submenu associated with the menu item
BmpChecked | Handle to the bitmap to display next to the item if it is selected
BmpUnchecked | Handle to the bitmap to display next to the item if it is not selected
ItemData | Application-defined value associated with the menu item
TypeData | Content of the menu item
CCH | Length of the menu item text
BmpItem | Handle to the bitmap to be displayed


Keyword $tagNETRESOURCE

Keyword Reference

$tagNETRESOURCE

$tagNETRESOURCE structure

Global Const $tagNETRESOURCE = "int Scope;int Type;int DisplayType;int Usage;ptr LocalName;ptr RemoteName;ptr Comment;ptr Provider"

Parameters

Scope Scope of the enumeration:
$RESOURCE_CONNECTED - Enumerate currently connected resources
$RESOURCE_GLOBALNET - Enumerate all resources on the network
$RESOURCE_REMEMBERED - Enumerate remembered connections
Type Set of bit flags identifying the type of resource:
$RESOURCETYPE_ANY - All resources
$RESOURCETYPE_DISK - Disk resources
$RESOURCETYPE_PRINT - Print resources
DisplayType Display options for the network object in a network browsing user interface:
$RESOURCEDISPLAYTYPE_DOMAIN - The object should be displayed as a domain
$RESOURCEDISPLAYTYPE_SERVER - The object should be displayed as a server
$RESOURCEDISPLAYTYPE_SHARE - The object should be displayed as a share
$RESOURCEDISPLAYTYPE_GENERIC - The method used to display the object does not matter
Usage Set of bit flags describing how the resource can be used. Note that this member can be specified only if the Scope member is equal to $RESOURCE_GLOBALNET. This member can be one of the following values:
$RESOURCEUSAGE_CONNECTABLE - The resource is a connectable resource; the name pointed to by RemoteName can be passed to the _WinNet_AddConnection() function to make a network connection.
$RESOURCEUSAGE_CONTAINER - The resource is a container resource; the name pointed to by RemoteName can be passed to the _WinNet_OpenEnum() function to enumerate the resources in the container.
LocalName If the Scope member is equal to $RESOURCE_CONNECTED or $RESOURCE_REMEMBERED, this member is a pointer to a null terminated character string that specifies the name of a local device.
This member is 0 if the connection does not use a device.
RemoteName | If the entry is a network resource, this member is a pointer to a null terminated string that specifies the remote network name. If the entry is a current or persistent connection, RemoteName points to the network name associated with the name pointed to by the LocalName member.
Comment | Pointer to a null-terminated string that contains a comment supplied by the network provider
Provider | Pointer to a null-terminated string that contains the name of the provider that owns the resource. This member can be NULL if the provider name is unknown. To retrieve the provider name, you can call the _WinNet_GetProviderName() function.


Keyword $tagNMCBEDRAGBEGIN

Keyword Reference

$tagNMCBEDRAGBEGIN

Contains information used with the $CBEN_DRAGBEGIN notification message

Global Const $tagNMCBEDRAGBEGIN = $tagNMHDR & ";int ItemID;wchar szText[260]"

Parameters

$tagNMHDR | Contains information about a notification message
ItemID | The ze0-ro-based index of the item being dragged. This value will always be -1, indicating that the item being dragged is the item displayed in the edit portion of the control.
szText | The character buffer that contains the text of the item being dragged


Keyword $tagNMCBEENDEDIT

Keyword Reference

$tagNMCBEENDEDIT

Contains information about the conclusion of an edit operation within a ComboBoxEx control

Global Const $tagNMCBEENDEDIT = $tagNMHDR & ";bool fChanged;int NewSelection;wchar szText[260];int Why"

Parameters

$tagNMHDR | Contains information about a notification message
fChanged | Indicating whether the contents of the control's edit box have changed
NewSelection | The 0-based index of the item that will be selected after completing the edit operation This value can be $CB_ERR if no item will be selected
szText | A zero-terminated string that contains the text from within the control's edit box
Why | The action that generated the $CBEN_ENDEDIT notification message This value can be one of the following: $CBENF_DROPDOWN - The user activated the drop-down list $CBENF_ESCAPE - The user pressed ESC $CBENF_KILLFOCUS - The edit box lost the keyboard focus $CBENF_RETURN - The user completed the edit operation by pressing ENTER


Keyword $tagNMCOMBOBOXEX

Keyword Reference

$tagNMCOMBOBOXEX

Contains information specific to ComboBoxEx items for use with notification messages

Global Const $tagNMCOMBOBOXEX = $tagNMHDR & ";int Mask;int Item;ptr Text;int TextMax;int Image;" & _
"int SelectedImage;int OverlayImage;int Indent;int Param"

Parameters

$tagNMHDR | Contains information about a notification message
Mask | A set of bit flags that specify attributes. Can be a combination of the following values. CBEIF_DI_SETITEM - Set this flag when processing CBEN_GETDISPINFO CBEIF_IMAGE - The iImage member is valid or must be filled in. CBEIF_INDENT - The iIndent member is valid or must be filled in. CBEIF_LPARAM - The lParam member is valid or must be filled in. CBEIF_OVERLAY - The iOverlay member is valid or must be filled in. CBEIF_SELECTEDIMAGE - The iSelectedImage member is valid or must be filled in. CBEIF_TEXT - The pszText member is valid or must be filled in.
Item | The 0-based index of the item.
Text | A pointer to a character buffer that contains or receives the item's text.
TextMax | The length of pszText, in TCHARs. If text information is being set, this member is ignored.
Image | The 0-based index of an image within the image list.
SelectedImage | The 0-based index of an image within the image list.
OverlayImage | The 1-based index of an overlay image within the image list.
Indent | The number of indent spaces to display for the item. Each indentation equals 10 pixels.
Param | A value specific to the item.


Keyword $tagNMDATETIMECHANGE

Keyword Reference

$tagNMDATETIMECHANGE

Contains information about a change that has taken place in a date and time picker (DTP) control

Global Const $tagNMDATETIMECHANGE = $tagNMHDR & ";int Flag;" & $tagSYSTEMTIME

Parameters

$tagNMHDR | Contains information about a notification message.
Flag | Indicates if the control is set to "no date" status. This flag also specifies whether the contents of the date are valid and contain current time information. This value can be one of the following: $GDT_NONE - The control is set to "no date" status $GDT_VALID - The control is not set to the "no date" status
$tagSYSTEMTIME | Contains information about the current system date and time.

Remarks

This structure is used with the $DTN_DATETIMECHANGE notification message.

Related

$tagNMHDR, $tagSYSTEMTIME


Keyword $tagNMDATETIMEFORMAT

Keyword Reference

$tagNMDATETIMEFORMAT

Contains information about a portion of the format string that defines a callback field within a date and time picker (DTP) control

Global Const $tagNMDATETIMEFORMAT = $tagNMHDR & ";ptr Format;" & $tagSYSTEMTIME & ";ptr pDisplay;wchar Display[64]"

Parameters

$tagNMHDR | Contains information about a notification message.
Format | Pointer to a null terminated string that defines the control callback field. The string comprises one or more "X" characters.
$tagSYSTEMTIME | The date and time to be formatted.
pDisplay | Pointer to a null terminated string that contains the display text of the control. By default, this is the address of the Display member of this structure. It is acceptable to have pDisplay point to an existing string. In this case, you don't need to assign a value to Display. However, the string that pDisplay points to must remain valid until another $DTN_FORMAT notification is sent or until the control is destroyed.
Display | 64 character buffer that is to receive the null terminated string that the control will display. It is not necessary to fill the entire buffer.

Remarks

It carries the string that defines the callback field and contains a buffer to receive the string that will be displayed in the callback field.
This structure is used with the $DTN_FORMAT notification message.

Related

$tagNMHDR, $tagSYSTEMTIME


Keyword $tagNMDATETIMEFORMATQUERY

Keyword Reference

$tagNMDATETIMEFORMATQUERY

Contains information about the control callback field

Global Const $tagNMDATETIMEFORMATQUERY = $tagNMHDR & ";ptr Format;struct ;long SizeX;long SizeY; endstruct"

Parameters

$tagNMHDR | Contains information about a notification message
Format | Pointer to a null terminated string that defines the control callback field. The string comprises one or more "X" characters.
SizeX | Must be filled with the maximum width of the text that will be displayed in the callback field
SizeY | Must be filled with the maximum height of the text that will be displayed in the callback field

Remarks

It contains a string (taken from the control's format string) that defines a callback field.
The structure receives the maximum allowable size of the text that will be displayed in the callback field.
This structure is used with the $DTN_FORMATQUERY notification message.


Keyword $tagNMDATETIMEKEYDOWN

Keyword Reference

$tagNMDATETIMEKEYDOWN

Carries information used to describe and handle a $DTN_WMKEYDOWN notification message

Global Const $tagNMDATETIMEKEYDOWN = $tagNMHDR & ";int VirtKey;ptr Format;" & $tagSYSTEMTIME

Parameters

$tagNMHDR | Contains information about a notification message
VirtKey | Virtual key code that represents the key that the user pressed
Format | Pointer to a null terminated string that defines the control callback field. The string comprises one or more "X" characters.
$tagSYSTEMTIME | Contains information about the current system date and time from the DTP control. The owner of the control must modify the time information based on the user's keystroke.

Related

$tagNMHDR, $tagSYSTEMTIME


Keyword $tagNMDATETIMESTRING

Keyword Reference

$tagNMDATETIMESTRING

Contains information specific to an edit operation that has taken place in the control

Global Const $tagNMDATETIMESTRING = $tagNMHDR & ";ptr UserString;" & $tagSYSTEMTIME & ";dword Flags"

Parameters

$tagNMHDR | Contains information about a notification message.
UserString | Address of the null terminated string that the user entered?
$tagSYSTEMTIME | date and time that must be filled in by the owner when handling the $DTN_USERSTRING notification code.
Flags | Return field. Set this member to $GDT_VALID to indicate that the date is valid or to $GDT_NONE to set the control to "no date" status ($DTS_SHOWNONE style only).

Remarks

This message is used with the $DTN_USERSTRING notification message.

Related

$tagNMHDR, $tagSYSTEMTIME


Keyword $tagNMDAYSTATE

Keyword Reference

$tagNMDAYSTATE

Carries information required to process the $MCN_GETDAYSTATE notification me

Global Const $tagNMDAYSTATE = $tagNMHDR & ";" & $tagSYSTEMTIME & ";int DayState;ptr pDayState"

Parameters

$tagNMHDR | Contains information about a notification message.
$tagSYSTEMTIME | Contains the starting date.
DayState | The total number of elements that must be in the array at pDayState
pDayState | Address of an array of MONTHDAYSTATE (DWORD bit field that holds the state of each day in a month) Each bit (1 through 31) represents the state of a day in a month. If a bit is on, the corresponding day will be displayed in bold; otherwise it will be displayed with no emphasis. The buffer at this address must be large enough to contain at least DayState elements.

Related

$tagSYSTEMTIME


Keyword $tagNMHDDISPINFO

Keyword Reference

$tagNMHDDISPINFO

Contains information used in handling $HDN_GETDISPINFO notification messages

Global Const $tagNMHDDISPINFO = "hwnd WndFrom;int IDFrom;int Code;int Item;int Mask;ptr Text;int TextMax;int Image;int lParam"

Parameters

WndFrom | Window handle to the control sending a message
IDFrom | Identifier of the control sending a message
Code | Notification code
Item | 0-based index of the item in the header control
Mask | Set of bit flags specifying which members of the structure must be filled in by the owner of the control. This value can be a combination of the following values: $HDI_TEXT - The Text field must be filled in $HDI_IMAGE - The Image field must be filled in $HDI_LPARAM - The lParam field must be filled in $HDI_DI_SETITEM - A return value. Indicates that the control should store the item information and not ask for it again.
Text | Pointer to a null terminated string containing the text that will be displayed for the header item
TextMax | Size of the buffer that Text points to
Image | 0-based index of an image within the image list. The specified image will be displayed with the header item, but it does not take the place of the item's bitmap. If iImage is set to $I_IMAGECALLBACK, the control requests image information for this item by using an $HDN_GETDISPINFO notification message.
lParam | An application-defined value to associate with the item


Keyword $tagNMHDFILTERBTNCLICK

Keyword Reference

$tagNMHDFILTERBTNCLICK

Specifies or receives the attributes of a filter button click

Global Const $tagNMHDFILTERBTNCLICK = $tagNMHDR & ";int Item;int Left;int Top;int Right;int Bottom"

Parameters

$tagNMHDR | Contains information about a notification message
Item | 0-based index of the control to which this structure refers
Left | X coordinate of the upper left corner of the rectangle
Top | Y coordinate of the upper left corner of the rectangle
Right | X coordinate of the lower right corner of the rectangle
Bottom | Y coordinate of the lower right corner of the rectangle


Keyword $tagNMHDR

Keyword Reference

$tagNMHDR

Contains information about a notification message

Global Const $tagNMHDR = "struct; hwnd hWndFrom;uint_ptr IDFrom;INT Code; endstruct"

Parameters

hWndFrom | Window handle to the control sending a message
IDFrom | Identifier of the control sending a message
Code | Notification code


Keyword $tagNMHEADER

Keyword Reference

$tagNMHEADER

Contains information about control notification messages

Global Const $tagNMHEADER = $tagNMHDR & ";int Item;int Button;ptr pItem"

Parameters

$tagNMHDR | Contains information about a notification message
Item | 0-based index of the control to which this structure refers
Button | Index of the mouse button used to generate the notification message. This member can be one of the following values: 0 - Left button 1 - Right button 2 - Middle button
pItem | Optional pointer to a tagHDITEM structure containing information about the item specified by Item. The mask member of the tagHDITEM structure indicates which of its members are valid.


Keyword $tagNMIPADDRESS

Keyword Reference

$tagNMIPADDRESS

Contains information for the $IPN_FIELDCHANGED notification message

Global Const $tagNMIPADDRESS = $tagNMHDR & ";int Field;int Value"

Parameters

$tagNMHDR | Contains information about a notification message
Field | The 0-based number of the field that was changed.
Value | The new value of the field specified in the Field member. While processing the $IPN_FIELDCHANGED notification, this member can be set to any value that is within the range of the field and the control will place this new value in the field.


Keyword $tagNMITEMACTIVATE

Keyword Reference

$tagNMITEMACTIVATE

Sent by a list-view control when the user activates an item

Global Const $tagNMITEMACTIVATE = $tagNMHDR & ";int Index;int SubItem;int NewState;int OldState;" & _
"int Changed;int X;int Y;int lParam;int KeyFlags"

Parameters

$tagNMHDR | Contains information about a notification message
Index | Index of the list-view item. If the item index is not used for the notification, this member will contain -1
SubItem | 1-based index of the subitem. If the subitem index is not used for the notification or the notification does not apply to a subitem, this member will contain zero.
NewState | New item state. This member is zero for notification messages that do not use it
OldState | Old item state. This member is zero for notification messages that do not use it
Changed | Set of flags that indicate the item attributes that have changed. This member is zero for notifications that do not use it. This member can have one or more of the following flags set: $LVIF_COLUMNS - The Columns member is valid $LVIF_DI_SETITEM - The operating system should store the requested list item information $LVIF_GROUPID - The GroupID member is valid $LVIF_IMAGE - The Image member is valid $LVIF_INDENT - The Indent member is valid $LVIF_NORECOMPUTE - The control will not generate LVN_GETDISPINFO to retrieve text information $LVIF_PARAM - The Param member is valid $LVIF_STATE - The State member is valid $LVIF_TEXT - The Text member is valid
X | Specifies the x-coordinate of the point
Y | Specifies the y-coordinate of the point
lParam | Application-defined value of the item. This member is undefined for notification messages that do not use it
KeyFlags | Modifier keys that were pressed at the time of the activation. This member contains zero or a combination of the following flags: $LVKF_ALT - The key is pressed. $LVKF_CONTROL - The key is pressed. $LVKF_SHIFT - The key is pressed.


Keyword $tagNMLISTVIEW

Keyword Reference

$tagNMLISTVIEW

Contains information about a list-view notification message

Global Const $tagNMLISTVIEW = $tagNMHDR & ";int Item;int SubItem;uint NewState;uint OldState;uint Changed;" & _
"struct; long ActionX;long ActionY; endstruct;lparam Param"

Parameters

$tagNMHDR | Contains information about a notification message
Item | Identifies the item, or -1 if not used
SubItem | Identifies the subitem, or zero if none
NewState | New item state
OldState | Old item state
Changed | Set of flags that indicate the item attributes that have changed
ActionX | X position at which the event occurred
ActionY | Y position at which the event occurred
Param | Application-defined value of the item


Keyword $tagNMLVCUSTOMDRAW

Keyword Reference

$tagNMLVCUSTOMDRAW

Contains information specific to an NM_CUSTOMDRAW (list view) notification message sent by a list-view control

Global Const $tagNMLVCUSTOMDRAW = "struct;" & $tagNMHDR & ";dword dwDrawStage;handle hdc;" & $tagRECT & _
";dword_ptr dwItemSpec;uint uItemState;lparam lItemlParam;endstruct" & _
";dword clrText;dword clrTextBk;int iSubItem;dword dwItemType;dword clrFace;int iIconEffect;" & _
"int iIconPhase;int iPartId;int iStateId;struct;long TextLeft;long TextTop;long TextRight;long TextBottom;endstruct;uint uAlign"

Parameters

$tagNMHDR | Contains information about a notification message
dwDrawStage The current drawing stage. This is one of the following values:
Global Values:
$CDDS_POSTERASE - After the erasing cycle is complete.
$CDDS_POSTPAINT - After the painting cycle is complete.
$CDDS_PREERASE - Before the erasing cycle begins.
$CDDS_PREPAINT - Before the painting cycle begins.
Item-specific Values:
$CDDS_ITEM - Indicates that the dwItemSpec, uItemState, and lItemlParam members are valid.
$CDDS_ITEMPOSTERASE - After an item has been erased.
$CDDS_ITEMPOSTPAINT - After an item has been drawn.
$CDDS_ITEMPREERASE - Before an item is erased.
$CDDS_ITEMPREPAINT - Before an item is drawn.
$CDDS_SUBITEM - Flag combined with $CDDS_ITEMPREPAINT or $CDDS_ITEMPOSTPAINT if a subitem is being drawn.
This will only be set if $CDRF_NOTIFYITEMDRAW is returned from $CDDS_PREPAINT.
hdc A handle to the control's device context.
Use this handle to a device context (HDC) to perform any Microsoft Windows Graphics Device Interface (GDI) functions.
$tagRECT Left,Top coordinate of the upper left corner of the rectangle of the area being drawn.
This member is initialized only by the $CDDS_ITEMPREPAINT notification Right,Bottom coordinate of the lower right corner of the rectangle of the area being drawn.
This member is initialized only by the $CDDS_ITEMPREPAINT notification.
dwItemSpec | The item number
uItemState The current item state. This value is a combination of the following flags:
$CDIS_CHECKED - The item is checked.
$CDIS_DEFAULT - The item is in its default state.
$CDIS_DISABLED - The item is disabled.
$CDIS_FOCUS - The item is in focus.
$CDIS_GRAYED - The item is grayed.
$CDIS_HOT - The item is currently under the pointer ("hot").
$CDIS_INDETERMINATE - The item is in an indeterminate state.
$CDIS_MARKED - The item is marked. The meaning of this is determined by the implementation.
$CDIS_SELECTED - The item is selected.
$CDIS_SHOWKEYBOARDCUES - Version 6.0 Comctl32. The item is a keyboard cue.
$CDIS_NEARHOT - The item is part of a control that is currently under the mouse pointer ("hot"), but the item is not "hot" itself.
The meaning of this is determined by the implementation.
$CDIS_OTHERSIDEHOT - The item is part of a splitbutton that is currently under the mouse pointer ("hot"), but the item is not "hot" itself.
The meaning of this is determined by the implementation.
$CDIS_DROPHILITED - The item is currently the drop target of a drag-and-drop operation.
lItemlParam | Application-defined item data.
clrText | COLORREF value representing the color that will be used to display text foreground in the list-view control.
clrTextBk | COLORREF value representing the color that will be used to display text background in the list-view control.
iSubItem | Index of the subitem that is being drawn. If the main item is being drawn, this member will be zero.
dwItemType Version 6.0. DWORD that contains the type of the item to draw. This member can be one of the following values:
$LVCDI_ITEM - An item is to be drawn.
$LVCDI_GROUP - A group is to be drawn.
clrFace | Version 6.0. COLORREF value representing the color that will be used to display the face of an item.
iIconEffect | Version 6.0. Value of type int that specifies the effect that is applied to an icon, such as Glow, Shadow, or Pulse.
iIconPhase | Version 6.0. Value of type int that specifies the phase of an icon.
iPartId | Version 6.0. Value of type int that specifies the ID of the part of an item to draw.
iStateId | Version 6.0. Value of type int that specifies the ID of the state of an item to draw.
TextLeft | X coordinate of the upper left corner of the rectangle in which the text is to be drawn
TextTop | Y coordinate of the upper left corner of the rectangle in which the text is to be drawn
TextRight | X coordinate of the lower right corner of the rectangle in which the text is to be drawn
TextBottom | Y coordinate of the lower right corner of the rectangle in which the text is to be drawn
uAlign Version 6.0. UINT that specifies how a group should be aligned. This member can be one of the following values:
$LVGA_HEADER_CENTER - Center the group.
$LVGA_HEADER_LEFT - Align the group on the left.
$LVGA_HEADER_RIGHT - Align the group on the right.

Remarks

$LVxxx_ constants require #include <ListViewConstants.au3>, $CDxx_ constants require #include


Keyword $tagNMLVDISPINFO

Keyword Reference

$tagNMLVDISPINFO

Contains information about an $LVN_GETDISPINFO or $LVN_SETDISPINFO notification message

Global Const $tagNMLVDISPINFO = $tagNMHDR & ";int Mask;int Item;int SubItem;int State;int StateMask;" & _
"ptr Text;int TextMax;int Image;int Param;int Indent;int GroupID;int Columns;ptr pColumns"

Parameters

$tagNMHDR | Contains information about a notification message
Mask | Set of flags that specify which members of this structure contain data to be set or which members are being requested. This member can have one or more of the following flags set: $LVIF_COLUMNS - The Columns member is valid $LVIF_DI_SETITEM - The operating system should store the requested list item information $LVIF_GROUPID - The GroupID member is valid $LVIF_IMAGE - The Image member is valid $LVIF_INDENT - The Indent member is valid $LVIF_NORECOMPUTE - The control will not generate LVN_GETDISPINFO to retrieve text information $LVIF_PARAM - The Param member is valid $LVIF_STATE - The State member is valid $LVIF_TEXT - The Text member is valid
Item | 0-based index of the item to which this structure refers
SubItem | 1-based index of the subitem to which this structure refers
State | Indicates the item's state, state image, and overlay image
StateMask | Value specifying which bits of the state member will be retrieved or modified
Text | Pointer to a string containing the item text
TextMax | Number of bytes in the buffer pointed to by Text, including the string terminator
Image | Index of the item's icon in the control's image list
Param | Value specific to the item
Indent | Number of image widths to indent the item
GroupID | Identifier of the tile view group that receives the item
Columns | Number of tile view columns to display for this item
pColumns | Pointer to the array of column indices


Keyword $tagNMLVFINDITEM

Keyword Reference

$tagNMLVFINDITEM

Contains information the owner needs to find items requested by a virtual list view control

Global Const $tagNMLVFINDITEM = $tagNMHDR & ";int Start;" & $tagLVFINDINFO

Parameters

$tagNMHDR | Contains information about a notification message
Start | Index of the item at which the search will start
$tagLVFINDINFO Flags - Type of search to perform. This member can be set to one or more of the following values:
$LVFI_PARAM - Searches for a match between this structure's Param member and the Param member of an item.
If $LVFI_PARAM is specified, all other flags are ignored.
$LVFI_PARTIAL - Checks to see if the item text begins with the string pointed to by the Text member.
This value implies use of $LVFI_STRING.
$LVFI_STRING - Searches based on the item text.
Unless additional values are specified, the item text of the matching item must exactly match the string pointed to by the Text member.
$LVFI_WRAP - Continues the search at the beginning if no match is found
LVFI_NEARESTXY - Finds the item nearest to the position specified in the X and Y members, in the direction specified by the Direction member.
This flag is supported only by large icon and small icon modes.
Text - Address of a string to compare with the item text. It is valid if $LVFI_STRING or $LVFI_PARTIAL is set in the Flags member.
Param - Value to compare with the Param member of an item's $LVITEM structure. It is valid only if $LVFI_PARAM is set in the flags member.
X - Initial X search position. It is valid only if $LVFI_NEARESTXY is set in the Flags member.
Y - Initial Y search position. It is valid only if $LVFI_NEARESTXY is set in the Flags member.
Direction - Virtual key code that specifies the direction to search. The following codes are supported:
VK_LEFT
VK_RIGHT
VK_UP
VK_DOWN
VK_HOME
VK_END
VK_PRIOR
VK_NEXT
This member is valid only if $LVFI_NEARESTXY is set in the flags member.

Remarks

This notification gives an application (or the notification receiver) the opportunity to customize an incremental search.
For example, if the search items are numeric, the application can perform a numerical search instead of a string search.
The application sets the Param member to the result of the search, or to another application defined value to fail the search and indicate to the control how to proceed


Keyword $tagNMLVGETINFOTIP

Keyword Reference

$tagNMLVGETINFOTIP

Contains and receives list-view item information needed to display a ToolTip for an item

Global Const $tagNMLVGETINFOTIP = $tagNMHDR & ";int Flags;ptr Text;int TextMax;int Item;int SubItem;int lParam"

Parameters

$tagNMHDR | Contains information about a notification message
Flags | Either zero or $LVGIT_UNFOLDED
Text | Address of a string buffer that receives any additional text information. If Flags is zero, this member will contain the existing item text. In this case, you should append any additional text onto the end of this string.
TextMax | Size, in characters, of the buffer pointed to by Text. Although you should never assume that this buffer will be of any particular size, the $INFOTIPSIZE value can be used for design purposes
Item | 0-based index of the item to which this structure refers.
SubItem | 1-based index of the subitem to which this structure refers. If this member is zero, the structure is referring to the item and not a subitem. This member is not currently used and will always be zero.
lParam | Application-defined value associated with the item This member is not currently used and will always be zero.


Keyword $tagNMLVKEYDOWN

Keyword Reference

$tagNMLVKEYDOWN

Contains information used in processing the $LVN_KEYDOWN notification message

Global Const $tagNMLVKEYDOWN = "align 1;" & $tagNMHDR & ";word VKey;uint Flags"

Parameters

$tagNMHDR | Contains information about a notification message
VKey | Virtual key code
Flags | This member must always be zero


Keyword $tagNMLVSCROLL

Keyword Reference

$tagNMLVSCROLL

Provides information about a scrolling operation

Global Const $tagNMLVSCROLL = $tagNMHDR & ";int DX;int DY"

Parameters

$tagNMHDR | Contains information about a notification message
DX | Specifies in pixels the horizontal position where a scrolling operation should begin or end
DY | Specifies in pixels the vertical position where a scrolling operation should begin or end


Keyword $tagNMMOUSE

Keyword Reference

$tagNMMOUSE

Contains information used with mouse notification messages

Global Const $tagNMMOUSE = $tagNMHDR & ";dword ItemSpec;dword ItemData;int X;int Y;dword HitInfo"

Parameters

$tagNMHDR | Contains information about a notification message
ItemSpec | A control-specific item identifier
ItemData | A control-specific item data
X | Specifies the x-coordinate of the point
Y | Specifies the y-coordinate of the point
HitInfo | Carries information about where on the item or control the cursor is pointing


Keyword $tagNMOBJECTNOTIFY

Keyword Reference

$tagNMOBJECTNOTIFY

Contains information used with the $TBN_GETOBJECT, $TCN_GETOBJECT, $RBN_GETOBJECT, and $PSN_GETOBJECT notification messages

Global Const $tagNMOBJECTNOTIFY = $tagNMHDR & ";int Item;ptr piid;ptr pObject;long Result;dword dwFlags"

Parameters

$tagNMHDR | Contains information about a notification message
Item | A control-specific item identifier
piid | A pointer to an interface identifier of the requested object
pObject | A pointer to an object provided by the window processing the notification message. The application processing the notification message sets this member
Result | COM success or failure flags. The application processing the notification message sets this member
dwFlags | control specific flags (hints as to where in iItem it hit)


Keyword $tagNMRBAUTOSIZE

Keyword Reference

$tagNMRBAUTOSIZE

Contains information used in handling the $RBN_AUTOSIZE notification messages

Global Const $tagNMRBAUTOSIZE = $tagNMHDR & ";bool fChanged;" & _
"struct; long TargetLeft;long TargetTop;long TargetRight;long TargetBottom; endstruct;" & _
"struct; long ActualLeft;long ActualTop;long ActualRight;long ActualBottom; endstruct"

Parameters

$tagNMHDR | Contains information about a notification message
fChanged | Member that indicates if the size or layout of the rebar control has changed (nonzero if a change occurred or zero otherwise)
TargetLeft | Specifies the x-coordinate of the upper-left corner of the rectangle to which the rebar control tried to size itself
TargetTop | Specifies the y-coordinate of the upper-left corner of the rectangle to which the rebar control tried to size itself
TargetRight | Specifies the x-coordinate of the lower-right corner of the rectangle to which the rebar control tried to size itself
TargetBottom | Specifies the y-coordinate of the lower-right corner of the rectangle to which the rebar control tried to size itself
ActualLeft | Specifies the x-coordinate of the upper-left corner of the rectangle to which the rebar control actually sized itself
ActualTop | Specifies the y-coordinate of the upper-left corner of the rectangle to which the rebar control actually sized itself
ActualRight | Specifies the x-coordinate of the lower-right corner of the rectangle to which the rebar control actually sized itself
ActualBottom | Specifies the y-coordinate of the lower-right corner of the rectangle to which the rebar control actually sized itself


Keyword $tagNMREBAR

Keyword Reference

$tagNMREBAR

Contains information used in handling various rebar notification messages

Global Const $tagNMREBAR = $tagNMHDR & ";dword dwMask;uint uBand;uint fStyle;uint wID;lparam lParam"

Parameters

$tagNMHDR | Contains information about a notification message
dwMask | Set of flags that define which members of this structure contain valid information. This can be one or more of the following values: $RBNM_ID - The wID member contains valid information. $RBNM_LPARAM - The lParam member contains valid information. $RBNM_STYLE - The fStyle member contains valid information.
uBand | 0-based index of the band affected by the notification. This will be -1 if no band is affected.
fStyle | The style of the band. This is one or more of the $RBBS_ styles detailed in the fStyle member of the $tagREBARBANDINFO structure. This member is only valid if dwMask contains $RBNM_STYLE.
wID | Application-defined identifier of the band. This member is only valid if dwMask contains $RBNM_ID.
lParam | Application-defined value associated with the band. This member is only valid if dwMask contains $RBNM_LPARAM


Keyword $tagNMREBARAUTOBREAK

Keyword Reference

$tagNMREBARAUTOBREAK

Contains information used with the $RBN_AUTOBREAK notification

Global Const $tagNMREBARAUTOBREAK = $tagNMHDR & ";uint uBand;uint wID;int lParam;uint uMsg;uint fStyleCurrent;int fAutoBreak"

Parameters

$tagNMHDR | Contains information about a notification message
uBand | 0-based index of the band affected by the notification. This is -1 if no band is affected.
wID | Application-defined ID of the band.
lParam | Application-defined value from the lParam member of the $tagREBARBANDINFO structure that defines the rebar band.
uMsg | ID of the message.
fStyleCurrent | Style of the specified band.
fAutoBreak | indicates whether a break should occur.


Keyword $tagNMREBARCHEVRON

Keyword Reference

$tagNMREBARCHEVRON

Contains information used in handling the RBN_CHEVRONPUSHED notification message

Global Const $tagNMREBARCHEVRON = $tagNMHDR & ";uint uBand;uint wID;int lParam;int Left;int Top;int Right;int Bottom;int lParamNM"

Parameters

$tagNMHDR | Contains information about a notification message
uBand | 0-based index of the band sending the notification
wID | Application-defined identifier for the band
lParam | Application-defined value associated with the band
Left | Specifies the x-coordinate of the upper-left corner of the rectangle
Top | Specifies the y-coordinate of the upper-left corner of the rectangle
Right | Specifies the x-coordinate of the lower-right corner of the rectangle
Bottom | Specifies the y-coordinate of the lower-right corner of the rectangle
lParamNM | An application-defined value If the $RBN_CHEVRONPUSHED notification was sent as a result of an $RB_PUSHCHEVRON message, this member contains the message's lAppValue value. Otherwise, it is set to zero.


Keyword $tagNMREBARCHILDSIZE

Keyword Reference

$tagNMREBARCHILDSIZE

Contains information used in handling the RBN_CHILDSIZE notification message

Global Const $tagNMREBARCHILDSIZE = $tagNMHDR & ";uint uBand;uint wID;" & _
"struct; long CLeft;long CTop;long CRight;long CBottom; endstruct;" & _
"struct; long BLeft;long BTop;long BRight;long BBottom; endstruct"

Parameters

$tagNMHDR | Contains information about a notification message
uBand | 0-based index of the band sending the notification
wID | Application-defined identifier for the band
CLeft | Specifies the x-coordinate of the upper-left corner of the rectangle of the new size of the child window This member can be changed during the notification to modify the child window's position and size
CTop | Specifies the y-coordinate of the upper-left corner of the rectangle of the new size of the child window This member can be changed during the notification to modify the child window's position and size
CRight | Specifies the x-coordinate of the lower-right corner of the rectangle of the new size of the child window This member can be changed during the notification to modify the child window's position and size
CBottom | Specifies the y-coordinate of the lower-right corner of the rectangle of the new size of the child window This member can be changed during the notification to modify the child window's position and size
BLeft | Specifies the x-coordinate of the upper-left corner of the rectangle of the new size of the band
BTop | Specifies the y-coordinate of the upper-left corner of the rectangle of the new size of the band
BRight | Specifies the x-coordinate of the lower-right corner of the rectangle of the new size of the band
BBottom | Specifies the y-coordinate of the lower-right corner of the rectangle of the new size of the band


Keyword $tagNMSELCHANGE

Keyword Reference

$tagNMSELCHANGE

Carries information required to process the $MCN_SELCHANGE notification message

Global Const $tagNMSELCHANGE = $tagNMHDR & _
";struct ;word BegYear;word BegMonth;word BegDOW;word BegDay;word BegHour;word BegMinute;word BegSecond;word BegMSeconds; endstruct;" & _
"struct; word EndYear;word EndMonth;word EndDOW;word EndDay;word EndHour;word EndMinute;word EndSecond;word EndMSeconds; endstruct"

Parameters

$tagNMHDR | Contains information about a notification message
BegYear | Year
BegMonth | Month
BegDOW | DOW
BegDay | Day
BegHour | Hour
BegMinute | Minute
BegSecond | Seconds
BegMSeconds | Milliseconds
EndYear | Year
EndMonth | Month
EndDOW | DOW
EndDay | Day
EndHour | Hour
EndMinute | Minute
EndSecond | Seconds
EndMSeconds | Milliseconds


Keyword $tagNMTBHOTITEM

Keyword Reference

$tagNMTBHOTITEM

Contains information used with the $TBN_HOTITEMCHANGE notification

Global Const $tagNMTBHOTITEM = $tagNMHDR & ";int idOld;int idNew;dword dwFlags"

Parameters

$tagNMHDR | Contains information about a notification message
idOld | Command identifier of the previously highlighted item
idNew | Command identifier of the item about to be highlighted
dwFlags Flags that indicate why the hot item has changed. This can be one or more of the following values:
$HICF_ACCELERATOR - The change in the hot item was caused by a shortcut key
$HICF_ARROWKEYS - The change in the hot item was caused by an arrow key
$HICF_DUPACCEL - Modifies $HICF_ACCELERATOR. If this flag is set, more than one item has the same shortcut key character
$HICF_ENTERING - Modifies the other reason flags. If this flag is set, there is no previous hot item and idOld does not contain valid information
$HICF_LEAVING - Modifies the other reason flags. If this flag is set, there is no new hot item and idNew does not contain valid information
$HICF_LMOUSE - The change in the hot item resulted from a left-click mouse event
$HICF_MOUSE - The change in the hot item resulted from a mouse event
$HICF_OTHER - The change in the hot item resulted from an event that could not be determined. This will most often be due to a change in focus or the $TB_SETHOTITEM message
$HICF_RESELECT - The change in the hot item resulted from the user entering the shortcut key for an item that was already hot
$HICF_TOGGLEDROPDOWN - Version 5.80. Causes the button to switch states

Remarks

Needs alignment for x64


Keyword $tagNMTCKEYDOWN

Keyword Reference

$tagNMTCKEYDOWN

Contains information used in processing the $LVN_KEYDOWN notification message

Global Const $tagNMTCKEYDOWN = "align 1;" & $tagNMHDR & ";word VKey;uint Flags"

Parameters

$tagNMHDR | Contains information about a notification message
VKey | Virtual key code
Flags | Bits as shown in the following table: 0-15 - Specifies the repeat count for the current message. 16-23 - Specifies the scan code. The value depends on the OEM. 24 - Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0. 25-28 - Reserved; do not use. 29 - Specifies the context code. The value is always 0 for a $WM_KEYDOWN message. 30 - Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is zero if the key is up. 31 - Specifies the transition state. The value is always zero for a $WM_KEYDOWN message


Keyword $tagNMTOOLBAR

Keyword Reference

$tagNMTOOLBAR

Contains information used to process toolbar notification messages

Global Const $tagNMTOOLBAR = $tagNMHDR & ";int iItem;" & _
"struct; int iBitmap;int idCommand;byte fsState;byte fsStyle;dword_ptr dwData;int_ptr iString; endstruct" & _
";int cchText;ptr pszText;" & $tagRECT

Parameters

$tagNMHDR | Contains information about a notification message
iItem | Command identifier of the button associated with the notification
iBitmap | 0-based index of the button image. If the button is a separator, that is, if fsStyle is set to $BTNS_SEP, iBitmap determines the width of the separator, in pixels
idCommand | Command identifier associated with the button. This identifier is used in a WM_COMMAND message when the button is chosen
fsState | Button state flags. This member can be a combination of the values listed in Toolbar Button States
fsStyle | Button style. This member can be a combination of the button style values listed in Toolbar Control and Button Styles
dwData | Application-defined value
iString | 0-based index of the button string, or a pointer to a string buffer that contains text for the button
cchText | Count of characters in the button text
pszText | Address of a character buffer that contains the button text
$tagRECT | Left - Specifies the x-coordinate of the upper-left corner of the rectangle Top - Specifies the y-coordinate of the upper-left corner of the rectangle Right - Specifies the x-coordinate of the lower-right corner of the rectangle Bottom - Specifies the y-coordinate of the lower-right corner of the rectangle


Keyword $tagNMTREEVIEW

Keyword Reference

$tagNMTREEVIEW

Contains information about a tree-view notification message

Global Const $tagNMTREEVIEW = $tagNMHDR & ";uint Action;" & _
"struct; uint OldMask;handle OldhItem;uint OldState;uint OldStateMask;" & _
"ptr OldText;int OldTextMax;int OldImage;int OldSelectedImage;int OldChildren;lparam OldParam; endstruct;" & _
"struct; uint NewMask;handle NewhItem;uint NewState;uint NewStateMask;" & _
"ptr NewText;int NewTextMax;int NewImage;int NewSelectedImage;int NewChildren;lparam NewParam; endstruct;" & _
"struct; long PointX;long PointY; endstruct"

Parameters

$tagNMHDR | Contains information about a notification message
Action | Notification-specific action flag
OldMask | Flags that indicate which of the other structure members contain valid data.
OldhItem | Item to which this structure refers
OldState | Set of bit flags and image list indexes that indicate the item's state
OldStateMask | Bits of the state member that are valid
OldText | Pointer to a null-terminated string that contains the item text.
OldTextMax | Size of the buffer pointed to by the Text member, in characters
OldImage | Index in the image list of the icon image to use when the item is in the nonselected state
OldSelectedImage | Index in the image list of the icon image to use when the item is in the selected state
OldChildren | Flag that indicates whether the item has associated child items
OldParam | A value to associate with the item
NewMask | Flags that indicate which of the other structure members contain valid data.
NewhItem | Item to which this structure refers
NewState | Set of bit flags and image list indexes that indicate the item's state
NewStateMask | Bits of the state member that are valid
NewText | Pointer to a null-terminated string that contains the item text.
NewTextMax | Size of the buffer pointed to by the Text member, in characters
NewImage | Index in the image list of the icon image to use when the item is in the nonselected state
NewSelectedImage | Index in the image list of the icon image to use when the item is in the selected state
NewChildren | Flag that indicates whether the item has associated child items
NewParam | A value to associate with the item
PointX | X position that of the mouse at the time the event occurred
PointY | Y position that of the mouse at the time the event occurred


Keyword $tagNMTVCUSTOMDRAW

Keyword Reference

$tagNMTVCUSTOMDRAW

Contains information specific to an NM_CUSTOMDRAW (tree view) notification message sent by a tree-view control

Global Const $tagNMTVCUSTOMDRAW = "struct;" & $tagNMHDR & ";dword DrawStage;handle HDC;" & $tagRECT & _
";dword_ptr ItemSpec;uint ItemState;lparam ItemParam; endstruct" & _
";dword ClrText;dword ClrTextBk;int Level"

Parameters

$tagNMHDR | Contains information about a notification message
DrawStage | Current drawing stage. This value is one of the following: Global Values: $CDDS_POSTERASE - After the erasing cycle is complete $CDDS_POSTPAINT - After the painting cycle is complete $CDDS_PREERASE - Before the erasing cycle begins $CDDS_PREPAINT - Before the painting cycle begins Item-specific Values: $CDDS_ITEM - Indicates that the ItemSpec, ItemState, and ItemParam members are valid $CDDS_ITEMPOSTERASE - After an item has been erased $CDDS_ITEMPOSTPAINT - After an item has been drawn $CDDS_ITEMPREERASE - Before an item is erased $CDDS_ITEMPREPAINT - Before an item is drawn $CDDS_SUBITEM - Flag combined with $CDDS_ITEMPREPAINT or $CDDS_ITEMPOSTPAINT if a subitem is being drawn
HDC | Handle to the control's device context
$tagRECT | Left - X coordinate of upper left corner of bounding rectangle being drawn Top - Y coordinate of upper left corner of bounding rectangle being drawn Right - X coordinate of lower right corner of bounding rectangle being drawn Bottom - Y coordinate of lower right corner of bounding rectangle being drawn
ItemSpec | Item number
ItemState | Current item state. This value is a combination of the following: $CDIS_CHECKED - The item is checked $CDIS_DEFAULT - The item is in its default state $CDIS_DISABLED - The item is disabled $CDIS_FOCUS - The item is in focus $CDIS_GRAYED - The item is grayed $CDIS_HOT - The item is currently under the pointer $CDIS_INDETERMINATE - The item is in an indeterminate state $CDIS_MARKED - The item is marked $CDIS_SELECTED - The item is selected $CDIS_SHOWKEYBOARDCUES - The item is a keyboard cue
ItemParam | Application defined item data
ClrText | The color that will be used to display text foreground in the control
ClrTextBk | The color that will be used to display text background in the control
Level | 0-based level of the item being drawn

Remarks

$CDxx_ constants require #include <WindowsConstants.au3>


Keyword $tagNMTVDISPINFO

Keyword Reference

$tagNMTVDISPINFO

Contains and receives display information for a tree-view item

Global Const $tagNMTVDISPINFO = $tagNMHDR & ";int Mask;int hItem;int State;int StateMask;" & _
"ptr Text;int TextMax;int Image;int SelectedImage;int Children;int Param"

Parameters

$tagNMHDR | Contains information about a notification message
Mask | Specifies which information is being set or retrieved. It can be one or more of the following values: $TVIF_CHILDREN - The Children member is valid $TVIF_IMAGE - The Image member is valid $TVIF_SELECTEDIMAGE - The SelectedImage member is valid $TVIF_TEXT - The Text and TextMax members are valid
hItem | Item to which this structure refers
State | Set of bit flags and image list indexes that indicate the item's state. When setting the state of an item, the StateMask member indicates the bits of this member that are valid. When retrieving the state of an item, this member returns the current state for the bits indicated in the StateMask member. Bits 0 through 7 of this member contain the item state flags. Bits 8 through 11 of this member specify the 1-based overlay image index.
StateMask | Bits of the state member that are valid. If you are retrieving an item's state, set the bits of the stateMask member to indicate the bits to be returned in the state member. If you are setting an item's state, set the bits of the stateMask member to indicate the bits of the state member that you want to set.
Text | Pointer to a null-terminated string that contains the item text.
TextMax | Size of the buffer pointed to by the Text member, in characters
Image | Index in the image list of the icon image to use when the item is in the nonselected state
SelectedImage | Index in the image list of the icon image to use when the item is in the selected state
Children | Flag that indicates whether the item has associated child items. This member can be one of the following values: 0 - The item has no child items 1 - The item has one or more child items
Param | A value to associate with the item


Keyword $tagNMTVGETINFOTIP

Keyword Reference

$tagNMTVGETINFOTIP

Contains and receives tree-view item information needed to display a ToolTip for an item

Global Const $tagNMTVGETINFOTIP = $tagNMHDR & ";ptr Text;int TextMax;hwnd hItem;int lParam"

Parameters

$tagNMHDR | Contains information about a notification message
Text | Address of a character buffer that contains the text to be displayed
TextMax | Size of the buffer at Text, in characters. Although you should never assume that this buffer will be of any particular size, the $INFOTIPSIZE value can be used for design purposes
hItem | Tree handle to the item for which the ToolTip is being displayed
lParam | Application-defined data associated with the item for which the ToolTip is being displayed


Keyword $tagNMTVITEMCHANGE

Keyword Reference

$tagNMTVITEMCHANGE

Contains information on a treeview item change, sent with $TVN_ITEMCHANGED and $TVN_ITEMCHANGING notifications

Global Const $tagNMTVITEMCHANGE = $tagNMHDR & ";uint Changed;handle hItem;uint StateNew;uint StateOld;lparam lParam;"

Parameters

$tagNMHDR | Contains information about a notification message
Changed | Specifies the attribute. Changed must always have the following value: TVIF_STATE - The change is the state attribute.
hItem | Handle to the changed tree-view item.
StateNew | Flag that specifies the new item state.
StateOld | Flag that specifies the item's previous state.
lParam | Reserved for application specific data. For example, a value to associate with the item.

Remarks

This notification is only present on Windows Vista and later.


Keyword $tagNMTVKEYDOWN

Keyword Reference

$tagNMTVKEYDOWN

Contains information about a keyboard event in a tree-view control

Global Const $tagNMTVKEYDOWN = "align 1;" & $tagNMHDR & ";word VKey;uint Flags"

Parameters

$tagNMHDR | Contains information about a notification message
VKey | Virtual key code
Flags | Always zero


Keyword $tagOPENFILENAME

Keyword Reference

$tagOPENFILENAME

Contains information information that the GetOpenFileName and GetSaveFileName functions use to initialize an Open or Save As dialog box

Global Const $tagOPENFILENAME = "dword StructSize;hwnd hwndOwner;hwnd hInstance;ptr lpstrFilter;ptr lpstrCustomFilter;" & _
"dword nMaxCustFilter;dword nFilterIndex;ptr lpstrFile;dword nMaxFile;ptr lpstrFileTitle;int nMaxFileTitle;" & _
"ptr lpstrInitialDir;ptr lpstrTitle;dword Flags;short nFileOffset;short nFileExtension;ptr lpstrDefExt;ptr lCustData;" & _
"ptr lpfnHook;ptr lpTemplateName;ptr pvReserved;dword dwReserved;dword FlagsEx"

Parameters

StructSize | Specifies the length, in bytes, of the structure.
hwndOwner | Handle to the window that owns the dialog box. This member can be any valid window handle, or it can be NULL if the dialog box has no owner.
hInstance If the $OFN_ENABLETEMPLATEHANDLE flag is set in the Flags member, hInstance is a handle to a memory object containing a dialog box template.
If the $OFN_ENABLETEMPLATE flag is set, hInstance is a handle to a module that contains a dialog box template named by the lpTemplateName member.
If neither flag is set, this member is ignored.
If the $OFN_EXPLORER flag is set, the system uses the specified template to create a dialog box that is a child of the default Explorer-style dialog box.
If the $OFN_EXPLORER flag is not set, the system uses the template to create an old-style dialog box that replaces the default dialog box.
lpstrFilter | Pointer to a buffer containing pairs of null-terminated filter strings. The last string in the buffer must be terminated by two NULL characters.
lpstrCustomFilter Pointer to a static buffer that contains a pair of null-terminated filter strings for preserving the filter pattern chosen by the user.
The first string is your display string that describes the custom filter, and the second string is the filter pattern selected by the user.
The first time your application creates the dialog box, you specify the first string, which can be any nonempty string.
When the user selects a file, the dialog box copies the current filter pattern to the second string.
The preserved filter pattern can be one of the patterns specified in the lpstrFilter buffer, or it can be a filter pattern typed by the user.
The system uses the strings to initialize the user-defined file filter the next time the dialog box is created.
If the nFilterIndex member is zero, the dialog box uses the custom filter.
If this member is NULL, the dialog box does not preserve user-defined filter patterns.
If this member is not NULL, the value of the nMaxCustFilter member must specify the size, in TCHARs, of the lpstrCustomFilter buffer.
For the ANSI version, this is the number of bytes; for the Unicode version, this is the number of characters.
nMaxCustFilter Specifies the size, in TCHARs, of the buffer identified by lpstrCustomFilter.
For the ANSI version, this is the number of bytes; for the Unicode version, this is the number of characters.
This buffer should be at least 40 characters long. This member is ignored if lpstrCustomFilter is NULL or points to a NULL string.
nFilterIndex Specifies the index of the currently selected filter in the File Types control.
The buffer pointed to by lpstrFilter contains pairs of strings that define the filters.
The first pair of strings has an index value of 1, the second pair 2, and so on.
An index of zero indicates the custom filter specified by lpstrCustomFilter.
You can specify an index on input to indicate the initial filter description and filter pattern for the dialog box.
When the user selects a file, nFilterIndex returns the index of the currently displayed filter.
If nFilterIndex is zero and lpstrCustomFilter is NULL, the system uses the first filter in the lpstrFilter buffer.
If all three members are zero or NULL, the system does not use any filters and does not show any files in the file list control of the dialog box.
lpstrFile Pointer to a buffer that contains a file name used to initialize the File Name edit control.
The first character of this buffer must be NULL if initialization is not necessary.
When the _WinAPI_GetOpenFileName or _WinAPI_GetSaveFileName function returns successfully, this buffer contains the drive designator, path, file name, and extension of the selected file.
If the $OFN_ALLOWMULTISELECT flag is set and the user selects multiple files, the buffer contains the current directory followed by the file names of the selected files.
For Explorer-style dialog boxes, the directory and file name strings are NULL separated, with an extra NULL character after the last file name.
For old-style dialog boxes, the strings are space separated and the function uses short file names for file names with spaces.
You can use the FindFirstFile function to convert between long and short file names.
If the user selects only one file, the lpstrFile string does not have a separator between the path and file name.
If the buffer is too small, the function returns False and the _WinAPI_CommDlgExtendedError function returns $FNERR_BUFFERTOOSMALL.
In this case, the first two bytes of the lpstrFile buffer contain the required size, in bytes or characters.
nMaxFile Specifies the size, in TCHARs, of the buffer pointed to by lpstrFile.
For the ANSI version, this is the number of bytes; for the Unicode version, this is the number of characters.
The buffer must be large enough to store the path and file name string or strings, including the terminating NULL character.
The _WinAPI_GetOpenFileName and _WinAPI_GetSaveFileName functions return False if the buffer is too small to contain the file information.
The buffer should be at least 256 characters long.
lpstrFileTitle | Pointer to a buffer that receives the file name and extension (without path information) of the selected file. This member can be NULL.
nMaxFileTitle Specifies the size, in TCHARs, of the buffer pointed to by lpstrFileTitle.
For the ANSI version, this is the number of bytes; for the Unicode version, this is the number of characters. This member is ignored if lpstrFileTitle is NULL.
lpstrInitialDir | Pointer to a NULL terminated string that can specify the initial directory.
lpstrTitle | Pointer to a string to be placed in the title bar of the dialog box. If this member is NULL, the system uses the default title (that is, Save As or Open).
Flags A set of bit flags you can use to initialize the dialog box. When the dialog box returns, it sets these flags to indicate the user's input. This member can be a combination of the following flags.
$OFN_ALLOWMULTISELECT - Specifies that the File Name list box allows multiple selections.
If you also set the $OFN_EXPLORER flag, the dialog box uses the Explorer-style user interface; otherwise, it uses the old-style user interface.
$OFN_CREATEPROMPT - If the user specifies a file that does not exist, this flag causes the dialog box to prompt the user for permission to create the file.
If the user chooses to create the file, the dialog box closes and the function returns the specified name; otherwise, the dialog box remains open.
If you use this flag with the $OFN_ALLOWMULTISELECT flag, the dialog box allows the user to specify only one nonexistent file.
$OFN_DONTADDTORECENT - Prevents the system from adding a link to the selected file in the file system directory that contains the user's most recently used documents.
$OFN_ENABLEHOOK - Enables the hook function specified in the lpfnHook member.
$OFN_ENABLEINCLUDENOTIFY - Causes the dialog box to send CDN_INCLUDEITEM notification messages to your OFNHookProc hook procedure when the user opens a folder.
The dialog box sends a notification for each item in the newly opened folder.
These messages enable you to control which items the dialog box displays in the folder's item list.
$OFN_ENABLESIZING - Enables the Explorer-style dialog box to be resized using either the mouse or the keyboard.
By default, the Explorer-style Open and Save As dialog boxes allow the dialog box to be resized regardless of whether this flag is set.
This flag is necessary only if you provide a hook procedure or custom template. The old-style dialog box does not permit resizing.
$OFN_ENABLETEMPLATE - Indicates that the lpTemplateName member is a pointer to the name of a dialog template resource in the module identified by the hInstance member.
If the $OFN_EXPLORER flag is set, the system uses the specified template to create a dialog box that is a child of the default Explorer-style dialog box.
If the $OFN_EXPLORER flag is not set, the system uses the template to create an old-style dialog box that replaces the default dialog box.
$OFN_ENABLETEMPLATEHANDLE - Indicates that the hInstance member identifies a data block that contains a preloaded dialog box template.
The system ignores lpTemplateName if this flag is specified.
If the $OFN_EXPLORER flag is set, the system uses the specified template to create a dialog box that is a child of the default Explorer-style dialog box.
If the $OFN_EXPLORER flag is not set, the system uses the template to create an old-style dialog box that replaces the default dialog box.
$OFN_EXPLORER - Indicates that any customizations made to the Open or Save As dialog box use the new Explorer-style customization methods.
By default, the Open and Save As dialog boxes use the Explorer-style user interface regardless of whether this flag is set.
This flag is necessary only if you provide a hook procedure or custom template, or set the $OFN_ALLOWMULTISELECT flag.
If you want the old-style user interface, omit the $OFN_EXPLORER flag and provide a replacement old-style template or hook procedure.
If you want the old style but do not need a custom template or hook procedure, simply provide a hook procedure that always returns False.
$OFN_EXTENSIONDIFFERENT - Specifies that the user typed a file name extension that differs from the extension specified by lpstrDefExt.
The function does not use this flag if lpstrDefExt is NULL.
$OFN_FILEMUSTEXIST - Specifies that the user can type only names of existing files in the File Name entry field.
If this flag is specified and the user enters an invalid name, the dialog box procedure displays a warning in a message box.
If this flag is specified, the $OFN_PATHMUSTEXIST flag is also used. This flag can be used in an Open dialog box. It cannot be used with a Save As dialog box.
$OFN_FORCESHOWHIDDEN - Forces the showing of system and hidden files, thus overriding the user setting to show or not show hidden files.
However, a file that is marked both system and hidden is not shown.
$OFN_HIDEREADONLY - Hides the Read Only check box.
$OFN_LONGNAMES - For old-style dialog boxes, this flag causes the dialog box to use long file names.
If this flag is not specified, or if the $OFN_ALLOWMULTISELECT flag is also set, old-style dialog boxes use short file names (8.3 format) for file names with spaces.
Explorer-style dialog boxes ignore this flag and always display long file names.
$OFN_NOCHANGEDIR - Restores the current directory to its original value if the user changed the directory while searching for files.
This flag is ineffective for GetOpenFileName.
$OFN_NODEREFERENCELINKS - Directs the dialog box to return the path and file name of the selected shortcut (.LNK) file.
If this value is not specified, the dialog box returns the path and file name of the file referenced by the shortcut.
$OFN_NOLONGNAMES - For old-style dialog boxes, this flag causes the dialog box to use short file names (8.3 format).
Explorer-style dialog boxes ignore this flag and always display long file names.
$OFN_NONETWORKBUTTON - Hides and disables the Network button.
$OFN_NOREADONLYRETURN - Specifies that the returned file does not have the Read Only check box selected and is not in a write-protected directory.
$OFN_NOTESTFILECREATE - Specifies that the file is not created before the dialog box is closed.
This flag should be specified if the application saves the file on a create-nonmodify network share.
When an application specifies this flag, the library does not check for write protection, a full disk, an open drive door, or network protection.
Applications using this flag must perform file operations carefully, because a file cannot be reopened once it is closed.
$OFN_NOVALIDATE - Specifies that the common dialog boxes allow invalid characters in the returned file name.
Typically, the calling application uses a hook procedure that checks the file name by using the FILEOKSTRING message.
If the text box in the edit control is empty or contains nothing but spaces, the lists of files and directories are updated.
If the text box in the edit control contains anything else, nFileOffset and nFileExtension are set to values generated by parsing the text.
No default extension is added to the text, nor is text copied to the buffer specified by lpstrFileTitle.
If the value specified by nFileOffset is less than zero, the file name is invalid.
Otherwise, the file name is valid, and nFileExtension and nFileOffset can be used as if the $OFN_NOVALIDATE flag had not been specified.
$OFN_OVERWRITEPROMPT - Causes the Save As dialog box to generate a message box if the selected file already exists.
The user must confirm whether to overwrite the file.
$OFN_PATHMUSTEXIST - Specifies that the user can type only valid paths and file names.
If this flag is used and the user types an invalid path and file name in the File Name entry field, the dialog box function displays a warning in a message box.
$OFN_READONLY - Causes the Read Only check box to be selected initially when the dialog box is created.
This flag indicates the state of the Read Only check box when the dialog box is closed.
$OFN_SHAREAWARE - Specifies that if a call to the OpenFile function fails because of a network sharing violation, the error is ignored and the dialog box returns the selected file name.
If this flag is not set, the dialog box notifies your hook procedure when a network sharing violation occurs for the file name specified by the user.
If you set the $OFN_EXPLORER flag, the dialog box sends the CDN_SHAREVIOLATION message to the hook procedure.
If you do not set $OFN_EXPLORER, the dialog box sends the SHAREVISTRING registered message to the hook procedure.
$OFN_SHOWHELP - Causes the dialog box to display the Help button.
The hwndOwner member must specify the window to receive the HELPMSGSTRING registered messages that the dialog box sends when the user clicks the Help button.
An Explorer-style dialog box sends a CDN_HELP notification message to your hook procedure when the user clicks the Help button.
$OFN_USESHELLITEM - Do not use.
nFileOffset Specifies the 0-based offset, in TCHARs, from the beginning of the path to the file name in the string pointed to by lpstrFile.
For the ANSI version, this is the number of bytes; for the Unicode version, this is the number of characters.
nFileExtension Specifies the 0-based offset, in TCHARs, from the beginning of the path to the file name extension in the string pointed to by lpstrFile.
For the ANSI version, this is the number of bytes; for the Unicode version, this is the number of characters.
lpstrDefExt | Pointer to a buffer that contains the default extension.
lCustData | Specifies application-defined data that the system passes to the hook procedure identified by the lpfnHook member.
lpfnHook | Pointer to a hook procedure. This member is ignored unless the Flags member includes the $OFN_ENABLEHOOK flag.
lpTemplateName | Pointer to a null-terminated string that names a dialog template resource in the module identified by the hInstance member.
pvReserved | Reserved. Must be set to NULL.
dwReserved | Reserved. Must be set to 0.
FlagsEx A set of bit flags you can use to initialize the dialog box. Currently, this member can be zero or the following flag.
$OFN_EX_NOPLACESBAR - If this flag is set, the places bar is not displayed.
If this flag is not set, Explorer-style dialog boxes include a places bar containing icons for commonly-used folders, such as Favorites and Desktop.


Keyword $tagOVERLAPPED

Keyword Reference

$tagOVERLAPPED

Contains information used in asynchronous (or overlapped) input and output (I/O)

Global Const $tagOVERLAPPED = "ulong_ptr Internal;ulong_ptr InternalHigh;struct; dword Offset;dword OffsetHigh; endstruct;handle hEvent"

Parameters

Internal | Reserved for operating system use. This member, which specifies a system-dependent status, is valid when the GetOverlappedResult function returns without setting the extended error information to ERROR_IO_PENDING.
InternalHigh | Reserved for operating system use. This member, which specifies the length of the data transferred, is valid when the GetOverlappedResult function returns True.
Offset | File position at which to start the transfer. The file position is a byte offset from the start of the file. The calling process must set this member before calling the ReadFile or WriteFile function. This member is used only when the device is a file. Otherwise, this member must be zero.
OffsetHigh | High-order word of the file position at which to start the transfer. This member is used only when the device is a file. Otherwise, this member must be zero.
hEvent | Handle to an event that will be set to the signaled state when the operation has completed. The calling process must set this member either to zero or a valid event handle before calling any overlapped functions.


Keyword $tagPOINT

Keyword Reference

$tagPOINT

Defines the x- and y- coordinates of a point

Global Const $tagPOINT = "struct; long X;long Y; endstruct"

Parameters

X | Specifies the x-coordinate of the point
Y | Specifies the y-coordinate of the point


Keyword $tagPROCESS_INFORMATION

Keyword Reference

$tagPROCESS_INFORMATION

Contains information about a newly created process and its primary thread

Global Const $tagPROCESS_INFORMATION = "hwnd hProcess;hwnd hThread;int ProcessID;int ThreadID"

Parameters

hProcess | A handle to the newly created process
hThread | A handle to the primary thread of the newly created process
ProcessID | A value that can be used to identify a process
ThreadID | A value that can be used to identify a thread


Keyword $tagREBARBANDINFO

Keyword Reference

$tagREBARBANDINFO

Contains information that defines a band in a rebar control

Global Const $tagREBARBANDINFO = "uint cbSize;uint fMask;uint fStyle;dword clrFore;dword clrBack;ptr lpText;uint cch;" & _
"int iImage;hwnd hwndChild;uint cxMinChild;uint cyMinChild;uint cx;handle hbmBack;uint wID;uint cyChild;uint cyMaxChild;" & _
"uint cyIntegral;uint cxIdeal;lparam lParam;uint cxHeader;" & $tagRECT & ";uint uChevronState"

Parameters

cbSize | Size of this structure, in bytes. Your application must fill this member before sending any messages that use the address of this structure as a parameter.
fMask Flags that indicate which members of this structure are valid or must be filled. This value can be a combination of the following:
$RBBIM_BACKGROUND - The hbmBack member is valid or must be set.
$RBBIM_CHILD - The hwndChild member is valid or must be set.
$RBBIM_CHILDSIZE - The cxMinChild, cyMinChild, cyChild, cyMaxChild, and cyIntegral members are valid or must be set.
$RBBIM_COLORS - The clrFore and clrBack members are valid or must be set.
$RBBIM_HEADERSIZE - Version 4.71. The cxHeader member is valid or must be set.
$RBBIM_IDEALSIZE - Version 4.71. The cxIdeal member is valid or must be set.
$RBBIM_ID - The wID member is valid or must be set.
$RBBIM_IMAGE - The iImage member is valid or must be set.
$RBBIM_LPARAM - Version 4.71. The lParam member is valid or must be set.
$RBBIM_SIZE - The cx member is valid or must be set.
$RBBIM_STYLE - The fStyle member is valid or must be set.
$RBBIM_TEXT - The lpText member is valid or must be set.
$RBBIM_CHEVRONLOCATION - The rcChevronLocation member is valid or must be set.
$RBBIM_CHEVRONSTATE - The uChevronState member is valid or must be set.
fStyle Flags that specify the band style. This value can be a combination of the following:
$RBBS_BREAK - The band is on a new line.
$RBBS_CHILDEDGE - The band has an edge at the top and bottom of the child window.
$RBBS_FIXEDBMP - The background bitmap does not move when the band is resized.
$RBBS_FIXEDSIZE - The band can't be sized. With this style, the sizing grip is not displayed on the band.
$RBBS_GRIPPERALWAYS - Version 4.71. The band will always have a sizing grip, even if it is the only band in the rebar.
$RBBS_HIDDEN - The band will not be visible.
$RBBS_NOGRIPPER - Version 4.71. The band will never have a sizing grip, even if there is more than one band in the rebar.
$RBBS_USECHEVRON - Version 5.80. Show a chevron button if the band is smaller than cxIdeal.
$RBBS_VARIABLEHEIGHT - Version 4.71. The band can be resized by the rebar control; cyIntegral and cyMaxChild affect how the rebar will resize the band.
$RBBS_NOVERT - Don't show when vertical.
$RBBS_USECHEVRON - Display drop-down button.
$RBBS_HIDETITLE - Keep band title hidden.
$RBBS_TOPALIGN - Keep band in top row.
clrFore | Band foreground colors.
clrBack Band background colors.
If hbmBack specifies a background bitmap, these members are ignored.
By default, the band will use the background color of the rebar control set with the $RB_SETBKCOLOR message.
If a background color is specified here, then this background color will be used instead.
lpText Pointer to a buffer that contains the display text for the band.
If band information is being requested from the control and $RBBIM_TEXT is specified in fMask, this member must be initialized to the address of the buffer that will receive the text.
cch | Size of the buffer at lpText, in bytes. If information is not being requested from the control, this member is ignored.
iImage | 0-based index of any image that should be displayed in the band. The image list is set using the $RB_SETBARINFO message.
hwndChild | Handle to the child window contained in the band, if any.
cxMinChild | Minimum width of the child window, in pixels. The band can't be sized smaller than this value.
cyMinChild | Minimum height of the child window, in pixels. The band can't be sized smaller than this value.
cx | Length of the band, in pixels.
hbmBack | Handle to a bitmap that is used as the background for this band.
wID | UINT value that the control uses to identify this band for custom draw notification messages.
cyChild | Version 4.71. Initial height of the band, in pixels. This member is ignored unless the $RBBS_VARIABLEHEIGHT style is specified.
cyMaxChild | Version 4.71. Maximum height of the band, in pixels. This member is ignored unless the $RBBS_VARIABLEHEIGHT style is specified.
cyIntegral Version 4.71. Step value by which the band can grow or shrink, in pixels.
If the band is resized, it will be resized in steps specified by this value.
This member is ignored unless the $RBBS_VARIABLEHEIGHT style is specified.
cxIdeal Version 4.71. Ideal width of the band, in pixels.
If the band is maximized to the ideal width (see $RB_MAXIMIZEBAND), the rebar control will attempt to make the band this width.
lParam | Version 4.71. Application-defined value.
cxHeader Version 4.71. Size of the band's header, in pixels.
The band header is the area between the edge of the band and the edge of the child window.
This is the area where band text and images are displayed, if they are specified.
If this value is specified, it will override the normal header dimensions that the control calculates for the band.
$tagRECT | Version 6. Location of the chevron.
uChevronState | Version 6. A combination of the Object State Constants.


Keyword $tagRECT

Keyword Reference

$tagRECT

Defines the coordinates of the upper-left and lower-right corners of a rectangle

Global Const $tagRECT = "struct; long Left;long Top;long Right;long Bottom; endstruct"

Parameters

Left | Specifies the x-coordinate of the upper-left corner of the rectangle
Top | Specifies the y-coordinate of the upper-left corner of the rectangle
Right | Specifies the x-coordinate of the lower-right corner of the rectangle
Bottom | Specifies the y-coordinate of the lower-right corner of the rectangle


Keyword $tagSCROLLBARINFO

Keyword Reference

$tagSCROLLBARINFO

Contains scroll bar information

Global Const $tagSCROLLBARINFO = "dword cbSize;int Left;int Top;int Right;int Bottom;int dxyLineButton;int xyThumbTop;" & _
"int xyThumbBottom;int reserved;dword rgstate[6]"

Parameters

cbSize | Specifies the size, in bytes, of this structure. The caller must set this to DllStructGetSize($tagSCROLLBARINFO).
Left | Specifies the x-coordinate of the upper-left corner of the rectangle coordinates of the scroll bar
Top | Specifies the y-coordinate of the upper-left corner of the rectangle coordinates of the scroll bar
Right | Specifies the x-coordinate of the lower-right corner of the rectangle coordinates of the scroll bar
Bottom | Specifies the y-coordinate of the lower-right corner of the rectangle coordinates of the scroll bar
dxyLineButton | Height or width of the thumb.
xyThumbTop | Position of the top or left of the thumb.
xyThumbBottom | Position of the bottom or right of the thumb.
reserved | Reserved.
rgstate | An array of DWORD elements. Each element indicates the state of a scroll bar component. The following values show the scroll bar component that corresponds to each array index: 0 The scroll bar itself. 1 The top or right arrow button. 2 The page up or page right region. 3 The scroll box (thumb). 4 The page down or page left region. 5 The bottom or left arrow button. The DWORD element for each scroll bar component can include a combination of the following bit flags. STATE_SYSTEM_INVISIBLE - For the scroll bar itself, indicates the specified vertical or horizontal scroll bar does not exist. For the page up or page down regions, indicates the thumb is positioned such that the region does not exist. STATE_SYSTEM_OFFSCREEN - For the scroll bar itself, indicates the window is sized such that the specified vertical or horizontal scroll bar is not currently displayed. STATE_SYSTEM_PRESSED - The arrow button or page region is pressed. STATE_SYSTEM_UNAVAILABLE - The component is disabled.

Remarks

$SIF_xxxxx and $SB_xxxxx for scrollbar require #include <WindowsConstants.au3>


Keyword $tagSCROLLINFO

Keyword Reference

$tagSCROLLINFO

Contains scroll bar parameters to be set by the $SBM_SETSCROLLINFO message, or retrieved by the $SBM_GETSCROLLINFO message

Global Const $tagSCROLLINFO = "uint cbSize;uint fMask;int nMin;int nMax;uint nPage;int nPos;int nTrackPos"

Parameters

cbSize | Specifies the size, in bytes, of this structure. The caller must set this to DllStructGetSize($tagSCROLLINFO).
fMask | Specifies the scroll bar parameters to set or retrieve. This member can be a combination of the following values: $SIF_ALL - Combination of $SIF_PAGE, $SIF_POS, $SIF_RANGE, and $SIF_TRACKPOS. $SIF_DISABLENOSCROLL - This value is used only when setting a scroll bar's parameters. If the scroll bar's new parameters make the scroll bar unnecessary, disable the scroll bar instead of removing it. $SIF_PAGE - The nPage member contains the page size for a proportional scroll bar. $SIF_POS - The nPos member contains the scroll box position, which is not updated while the user drags the scroll box. $SIF_RANGE - The nMin and nMax members contain the minimum and maximum values for the scrolling range. $SIF_TRACKPOS - The nTrackPos member contains the current position of the scroll box while the user is dragging it.
nMin | Specifies the minimum scrolling position.
nMax | Specifies the maximum scrolling position.
nPage | Specifies the page size. A scroll bar uses this value to determine the appropriate size of the proportional scroll box.
nPos | Specifies the position of the scroll box.
nTrackPos | Specifies the immediate position of a scroll box that the user is dragging. An application can retrieve this value while processing the $SB_THUMBTRACK request code. An application cannot set the immediate scroll position, the SetScrollInfo function ignores this member.

Remarks

$SIF_xxxxx and $SB_XXX for scrollbar require #include <ScrollbarsConstants.au3>


Keyword $tagSECURITY_ATTRIBUTES

Keyword Reference

$tagSECURITY_ATTRIBUTES

Contains the security descriptor for an object and specifies whether the handle retrieved by specifying this structure is inheritable

Global Const $tagSECURITY_ATTRIBUTES = "int Length;ptr Descriptor;int InheritHandle"

Parameters

Length | The size, in bytes, of this structure
Descriptor | A pointer to a security descriptor for the object that controls the sharing of it
InheritHandle | If True, the new process inherits the handle.


Keyword $tagSIZE

Keyword Reference

$tagSIZE

Stores an ordered pair of integers, typically the width and height of a rectangle

Global Const $tagSIZE = "struct; long X;long Y; endstruct"

Parameters

X | Width
Y | Height


Keyword $tagSTARTUPINFO

Keyword Reference

$tagSTARTUPINFO

Specifies the window station, desktop, standard handles, and appearance of the main window for a process at creation time

Global Const $tagSTARTUPINFO = "int Size;ptr Reserved1;ptr Desktop;ptr Title;int X;int Y;int XSize;int YSize;int XCountChars;" & _
"int YCountChars;int FillAttribute;int Flags;short ShowWindow;short Reserved2;ptr Reserved3;int StdInput;" & _
"int StdOutput;int StdError"

Parameters

Size | The size of the structure, in bytes
Reserved1 | Reserved, must be zero
Desktop | The name of the desktop, or the name of both the desktop and window station for this process
Title | For console processes, the title displayed in the title bar if a new console is created
X | If Flags specifies $STARTF_USEPOSITION, this member is the x offset of the upper left corner of a window if a new window is created, in pixels.
Y | If Flags specifies $STARTF_USEPOSITION, this member is the y offset of the upper left corner of a window if a new window is created, in pixels.
XSize | If Flags specifies $STARTF_USESIZE, this member is the height of the window, in pixels
YSize | If Flags specifies $STARTF_USESIZE, this member is the width of the window, in pixels
XCountChars | If Flags specifies $STARTF_USECOUNTCHARS, if a new console window is created in a console process, this member specifies the screen buffer width, in character columns.
YCountChars | If Flags specifies $STARTF_USECOUNTCHARS, if a new console window is created in a console process, this member specifies the screen buffer height, in character rows.
FillAttribute | If Flags specifies $STARTF_USEFILLATTRIBUTE, this member is the initial text and background colors if a new console window is created in a console application.
Flags Determines which members are used when the process creates a window:
$STARTF_FORCEONFEEDBACK - The cursor is in feedback mode for two seconds after CreateProcess is called.
The Working in Background cursor is displayed.
If during those two seconds the process makes the first GUI call, the system gives five more seconds to the process.
If during those five seconds the process shows a window, the system gives five more seconds to the process to finish drawing the window.
The system turns the feedback cursor off after the first call to GetMessage, regardless of whether the process is drawing.
$STARTF_FORCEOFFFEEDBACK - Indicates that the feedback cursor is forced off while the process is starting.
The Normal Select cursor is displayed.
$STARTF_RUNFULLSCREEN - Indicates that the process should be run in full screen mode, rather than in windowed mode.
This flag is only valid for console applications running on an x86 computer.
$STARTF_USECOUNTCHARS - The XCountChars and YCountChars members are valid
$STARTF_USEFILLATTRIBUTE - The FillAttribute member is valid
$STARTF_USEPOSITION - The X and Y members are valid
$STARTF_USESHOWWINDOW - The ShowWindow member is valid
$STARTF_USESIZE - The XSize and YSize members are valid
$STARTF_USESTDHANDLES - The hStdInput, hStdOutput, and hStdError members are valid
ShowWindow | If Flags specifies $STARTF_USESHOWWINDOW, this member can be any of the SW_ constants
Reserved2 | Reserved, must be zero
Reserved3 | Reserved, must be zero
StdInput | If Flags specifies $STARTF_USESTDHANDLES, this member is the standard input handle
StdOutput | If Flags specifies $STARTF_USESTDHANDLES, this member is the standard output handle
StdError | If Flags specifies $STARTF_USESTDHANDLES, this member is the standard error handle


Keyword $tagSYSTEMTIME

Keyword Reference

$tagSYSTEMTIME

Specifies a date and time, in coordinated universal time (UTC)

Global Const $tagSYSTEMTIME = "struct; word Year;word Month;word Dow;word Day;word Hour;word Minute;word Second;word MSeconds; endstruct"

Parameters

Year | Year
Month | Month
Dow | Day of week
Day | Day
Hour | Hour
Minute | Minute
Second | Second
MSeconds | Milliseconds


Keyword $tagTBBUTTON

Keyword Reference

$tagTBBUTTON

Contains information about a button in a toolbar

Global Const $tagTBBUTTON = "int Bitmap;int Command;byte State;byte Style;short Reserved;int Param;int String"

Parameters

Bitmap | 0-based index of the button image. Set this member to $I_IMAGECALLBACK, and the toolbar will send the $TBN_GETDISPINFO notification to retrieve the image index when it is needed. Set this member to $I_IMAGENONE to indicate that the button does not have an image. The button layout will not include any space for a bitmap, only text. If the button is a separator, Bitmap determines the width of the separator, in pixels.
Command | Command identifier associated with the button. This identifier is used in a $WM_COMMAND message when the button is chosen.
State | Button state flags
Style | Button style flags
Reserved | Reserved
Param | Application defined value
String | 0-based index of the button string, or a pointer to a string that contains text for the button


Keyword $tagTBBUTTONINFO

Keyword Reference

$tagTBBUTTONINFO

Contains or receives information for a specific button in a toolbar

Global Const $tagTBBUTTONINFO = "int Size;int Mask;int Command;int Image;byte State;byte Style;short CX;int Param;ptr Text;int TextMax"

Parameters

Size | Size of this structure, in bytes
Mask | Set of flags that indicate which members contain valid information: $TBIF_BYINDEX - The Param sent with a $TB_GETBUTTONINFO or $TB_SETBUTTONINFO message is an index $TBIF_COMMAND - The Command member contains valid information or is being requested $TBIF_IMAGE - The Image member contains valid information or is being requested $TBIF_IMAGELABEL - Indicates that ImageLabel should be used $TBIF_LPARAM - The Param member contains valid information or is being requested $TBIF_SIZE - The CX member contains valid information or is being requested $TBIF_STATE - The State member contains valid information or is being requested $TBIF_STYLE - The Style member contains valid information or is being requested $TBIF_TEXT - The Text member contains valid information or is being requested
Command | Command identifier of the button
Image | Image index of the button. Set this member to $I_IMAGECALLBACK, and the toolbar will send the $TBN_GETDISPINFO notification to retrieve the image index when it is needed. Set this member to $I_IMAGENONE to indicate that the button does not have an image.
State | State flags of the button
Style | Style flags of the button
CX | Width of the button, in pixels
Param | Application defined value associated with the button
Text | Address of a character buffer that contains or receives the button text
TextMax | Size of the buffer at Text. If the button information is being set, this member is ignored


Keyword $tagTEXTMETRIC

Keyword Reference

$tagTEXTMETRIC

Contains basic information about a physical font

Global Const $tagTEXTMETRIC = "long tmHeight;long tmAscent;long tmDescent;long tmInternalLeading;long tmExternalLeading;" & _
"long tmAveCharWidth;long tmMaxCharWidth;long tmWeight;long tmOverhang;long tmDigitizedAspectX;long tmDigitizedAspectY;" & _
"wchar tmFirstChar;wchar tmLastChar;wchar tmDefaultChar;wchar tmBreakChar;byte tmItalic;byte tmUnderlined;byte tmStruckOut;" & _
"byte tmPitchAndFamily;byte tmCharSet"

Parameters

tmHeight | Specifies the height (ascent + descent) of characters.
tmAscent | Specifies the ascent (units above the base line) of characters.
tmDescent | Specifies the descent (units below the base line) of characters.
tmInternalLeading | Specifies the amount of leading (space) inside the bounds set by the tmHeight member. Accent marks and other diacritical characters may occur in this area. The designer may set this member to zero.
tmExternalLeading | Specifies the amount of extra leading (space) that the application adds between rows. Since this area is outside the font, it contains no marks and is not altered by text output calls in either OPAQUE or TRANSPARENT mode. The designer may set this member to zero.
tmAveCharWidth | Specifies the average width of characters in the font (generally defined as the width of the letter x). This value does not include the overhang required for bold or italic characters.
tmMaxCharWidth | Specifies the width of the widest character in the font.
tmWeight | Specifies the weight of the font. Application defined value associated with the button
tmOverhang | Specifies the extra width per string that may be added to some synthesized fonts. When synthesizing some attributes, such as bold or italic, graphics device interface (GDI) or a device may have to add width to a string on both a per-character and per-string basis. For example, GDI makes a string bold by expanding the spacing of each character and overstriking by an offset value it italicizes a font by shearing the string. In either case, there is an overhang past the basic string. For bold strings, the overhang is the distance by which the overstrike is offset. For italic strings, the overhang is the amount the top of the font is sheared past the bottom of the font. The tmOverhang member enables the application to determine how much of the character width returned by a GetTextExtentPoint32 function call on a single character is the actual character width and how much is the per-string extra width. The actual width is the extent minus the overhang.
tmDigitizedAspectX | Specifies the horizontal aspect of the device for which the font was designed.
tmDigitizedAspectY | Specifies the vertical aspect of the device for which the font was designed. The ratio of the tmDigitizedAspectX and tmDigitizedAspectY members is the aspect ratio of the device for which the font was designed.
tmFirstChar | Specifies the value of the first character defined in the font.
tmLastChar | Specifies the value of the last character defined in the font.
tmDefaultChar | Specifies the value of the character to be substituted for characters not in the font.
tmBreakChar | Specifies the value of the character that will be used to define word breaks for text justification.
tmItalic | Specifies an italic font if it is nonzero.
tmUnderlined | Specifies an underlined font if it is nonzero.
tmStruckOut | Specifies a strikeout font if it is nonzero.
tmPitchAndFamily | Specifies information about the pitch, the technology, and the family of a physical font. The four low-order bits of this member specify information about the pitch and the technology of the font. A constant is defined for each of the four bits. $TMPF_FIXED_PITCH If this bit is set the font is a variable pitch font. If this bit is clear the font is a fixed pitch font. Note very carefully that those meanings are the opposite of what the constant name implies. $TMPF_VECTOR If this bit is set the font is a vector font. $TMPF_TRUETYPE If this bit is set the font is a TrueType font. $TMPF_DEVICE If this bit is set the font is a device font.
tmCharSet | Specifies the character set of the font. The character set can be one of the following values. ANSI_CHARSET BALTIC_CHARSET CHINESEBIG5_CHARSET DEFAULT_CHARSET EASTEUROPE_CHARSET GB2312_CHARSET GREEK_CHARSET HANGUL_CHARSET MAC_CHARSET OEM_CHARSET RUSSIAN_CHARSET SHIFTJIS_CHARSET SYMBOL_CHARSET TURKISH_CHARSET VIETNAMESE_CHARSET

Remarks

All sizes are specified in logical units, that is, they depend on the current mapping mode of the display context.


Keyword $tagTIME_ZONE_INFORMATION

Keyword Reference

$tagTIME_ZONE_INFORMATION

Specifies information specific to the time zone

Global Const $tagTIME_ZONE_INFORMATION = "struct; long Bias;wchar StdName[32];word StdDate[8];long StdBias;wchar DayName[32];word DayDate[8];long DayBias; endstruct"

Parameters

Bias | The current bias for local time translation on this computer, in minutes
StdName | A description for standard time
StdDate | A SYSTEMTIME structure that contains a date and local time when the transition from daylight saving time to standard time occurs on this operating system.
StdBias | The bias value to be used during local time translations that occur during standard time
DayName | A description for daylight saving time
DayDate | A SYSTEMTIME structure that contains a date and local time when the transition from standard time to daylight saving time occurs on this operating system.
DayBias | The bias value to be used during local time translations that occur during daylight saving time


Keyword $tagTOKEN_PRIVILEGES

Keyword Reference

$tagTOKEN_PRIVILEGES

Contains information about a set of privileges for an access token

Global Const $tagTOKEN_PRIVILEGES = "dword Count;align 4;int64 LUID;dword Attributes"

Parameters

Count | Specifies the number of entries
LUID | Specifies a LUID value
Attributes | Specifies attributes of the LUID


Keyword $tagTVHITTESTINFO

Keyword Reference

$tagTVHITTESTINFO

Contains information used to determine the location of a point relative to a tree-view control

Global Const $tagTVHITTESTINFO = "int X;int Y;int Flags;int Item"

Parameters

X | X position, in client coordinates, to be tested
Y | Y position, in client coordinates, to be tested
Flags | Results of a hit test. This member can be one or more of the following values: $TVHT_ABOVE - Above the client area $TVHT_BELOW - Below the client area $TVHT_NOWHERE - In the client area, but below the last item $TVHT_ONITEM - On the bitmap or label associated with an item $TVHT_ONITEMBUTTON - On the button associated with an item $TVHT_ONITEMICON - On the bitmap associated with an item $TVHT_ONITEMINDENT - In the indentation associated with an item $TVHT_ONITEMLABEL - On the label (string) associated with an item $TVHT_ONITEMRIGHT - In the area to the right of an item $TVHT_ONITEMSTATEICON - On the state icon for an item that is in a user-defined state $TVHT_TOLEFT - To the left of the client area $TVHT_TORIGHT - To the right of the client area
Item | Handle to the item that occupies the position


Keyword $tagTVITEMEX

Keyword Reference

$tagTVITEMEX

Specifies or receives attributes of a tree-view item

Global Const $tagTVITEMEX = "struct; uint Mask;struct; handle hItem;uint State;uint StateMask;ptr Text;int TextMax;int Image;int SelectedImage;int Children;lparam Param; endstruct;" & _
"int Integral;uint uStateEx;hwnd hwnd;int iExpandedImage;int iReserved; endstruct"

Parameters

Mask | Flags that indicate which of the other structure members contain valid data: $TVIF_CHILDREN - The Children member is valid $TVIF_DI_SETITEM - The will retain the supplied information and will not request it again $TVIF_EXPANDEDIMAGE - The iExpandedImage member is valid (IE Version 6.00 and Windows Vista) $TVIF_HANDLE - The hItem member is valid $TVIF_IMAGE - The Image member is valid $TVIF_INTEGRAL - The Integral member is valid $TVIF_PARAM - The Param member is valid $TVIF_SELECTEDIMAGE - The SelectedImage member is valid $TVIF_STATE - The State and StateMask members are valid $TVIF_STATEEX - The uStateEx member is valid (IE Version 6.00 and Windows Vista) $TVIF_TEXT - The Text and TextMax members are valid
hItem | Item to which this structure refers
State | Set of bit flags and image list indexes that indicate the item's state. When setting the state of an item. The StateMask member indicates the bits of this member that are valid. When retrieving the state of an item, this member returns the current state for the bits indicated in the StateMask member. Bits 0 through 7 of this member contain the item state flags. Bits 8 through 11 of this member specify the 1-based overlay image index.
StateMask | Bits of the state member that are valid. If you are retrieving an item's state, set the bits of the stateMask member to indicate the bits to be returned in the state member. If you are setting an item's state, set the bits of the stateMask member to indicate the bits of the state member that you want to set.
Text | Pointer to a null-terminated string that contains the item text.
TextMax | Size of the buffer pointed to by the Text member, in characters
Image | Index in the image list of the icon image to use when the item is in the nonselected state
SelectedImage | Index in the image list of the icon image to use when the item is in the selected state
Children | Flag that indicates whether the item has associated child items. This member can be one of the following values: 0 - The item has no child items 1 - The item has one or more child items
Param | A value to associate with the item
Integral | Height of the item
uStateEx | One or more (as a bitwise combination) of the following extended states. Value Meaning: TVIS_EX_DISABLED Windows Vista or later. Creates a control that is drawn in grey, that the user cannot interact with. TVIS_EX_FLAT Creates a flat item—the item is virtual and is not visible in the tree; instead, its children take its place in the tree hierarchy. TVIS_EX_HWND Creates a separate HWND for the item.
hwnd | Not used; must be NULL.
iExpandedImage | Index of the image in the control's image list to display when the item is in the expanded state.
iReserved | Reserved member. Do not use.


Keyword $tagWIN32_FIND_DATA

Keyword Reference

$tagWIN32_FIND_DATA

Contains the data found when finding a file

Global Const $tagWIN32_FIND_DATA = "dword dwFileAttributes;dword ftCreationTime[2];dword ftLastAccessTime[2];dword ftLastWriteTime[2];dword nFileSizeHigh;dword nFileSizeLow;dword dwReserved0;dword dwReserved1;wchar cFileName[260];wchar cAlternateFileName[14]"

Parameters

dwFileAttributes | The file attributes of a file.
ftCreationTime | A FILETIME structure that specifies when a file or directory was created.
ftLastAccessTime | A FILETIME structure that specifies when the file was last read from, written to, or for executable files, run.
ftLastWriteTime | A FILETIME structure that specifies when when the file was last written to, truncated, or overwritten.
nFileSizeHigh | The high-order DWORD value of the file size, in bytes.
nFileSizeLow | The low-order DWORD value of the file size, in bytes.
dwReserved0 | If the dwFileAttributes member includes the $FILE_ATTRIBUTE_REPARSE_POINT attribute. This member specifies the reparse tag.
dwReserved1 | Reserved.
cFileName | The name of the file.
cAlternateFileName | An alternative name for the file, the classic 8.3 (filename.ext) file name format.

Remarks

Unicode version must be used.

See Also

Search WIN32_FIND_DATA in MSDN Library.


Keyword $tagWINDOWPLACEMENT

Keyword Reference

$tagWINDOWPLACEMENT

The WINDOWPLACEMENT structure contains information about the placement of a window on the screen

Global Const $tagWINDOWPLACEMENT = "UINT length; UINT flags; UINT showCmd; int ptMinPosition[2]; int ptMaxPosition[2]; int rcNormalPosition[4]"

Parameters

length | Specifies the length, in bytes, of the structure
flags Specifies flags that control the position of the minimized window and the method by which the window is restored. This member can be one or more of the following values
$WPF_ASYNCWINDOWPLACEMENT - If the calling thread and the thread that owns the window are attached to different input queues, the system posts the request to the thread that owns the window.
$WPF_RESTORETOMAXIMIZED - Specifies that the restored window will be maximized, regardless of whether it was maximized before it was minimized.
This setting is only valid the next time the window is restored. It does not change the default restoration behavior.
This flag is only valid when the @SW_SHOWMINIMIZED value is specified for the showCmd member.
$WPF_SETMINPOSITION - Specifies that the coordinates of the minimized window may be specified.
This flag must be specified if the coordinates are set in the ptMinPosition member.
showCmd Specifies the current show state of the window. This member can be one of the following values:
@SW_HIDE - Hides the window and activates another window.
@SW_MAXIMIZE - Maximizes the specified window.
@SW_MINIMIZE - Minimizes the specified window and activates the next top-level window in the z-order.
@SW_RESTORE - Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position.
An application should specify this flag when restoring a minimized window.
@SW_SHOW - Activates the window and displays it in its current size and position.
@SW_SHOWMAXIMIZED - Activates the window and displays it as a maximized window.
@SW_SHOWMINIMIZED - Activates the window and displays it as a minimized window.
@SW_SHOWMINNOACTIVE - Displays the window as a minimized window.
This value is similar to @SW_SHOWMINIMIZED, except the window is not activated.
@SW_SHOWNA - Displays the window in its current size and position.
This value is similar to @SW_SHOW, except the window is not activated.
@SW_SHOWNOACTIVATE - Displays a window in its most recent size and position.
This value is similar to @SW_SHOWNORMAL, except the window is not activated.
@SW_SHOWNORMAL - Activates and displays a window.
If the window is minimized or maximized, the system restores it to its original size and position.
An application should specify this flag when displaying the window for the first time.
ptMinPosition | Specifies the coordinates of the window's upper-left corner when the window is minimized.
ptMaxPosition | Specifies the coordinates of the window's upper-left corner when the window is maximized.
rcNormalPosition | Specifies the window's coordinates when the window is in the restored position.


Keyword $tagWINDOWPOS

Keyword Reference

$tagWINDOWPOS

The WINDOWPOS structure contains information about the size and position of a window

Global Const $tagWINDOWPOS = "hwnd hWnd;int InsertAfter;int X;int Y;int CX;int CY;int Flags"

Parameters

hWnd | Handle to the window
InsertAfter | Specifies the position of the window in Z order
X | Specifies the position of the left edge of the window
Y | Specifies the position of the top edge of the window
CX | Specifies the window width, in pixels
CY | Specifies the window height, in pixels
Flags | Specifies the window position. This member can be one or more of the following values: $SWP_DRAWFRAME - Draws a frame around the window $SWP_FRAMECHANGED - Sends a WM_NCCALCSIZE message to the window, even if the window's size is not being changed $SWP_HIDEWINDOW - Hides the window $SWP_NOACTIVATE - Does not activate the window $SWP_NOCOPYBITS - Discards the entire contents of the client area $SWP_NOMOVE - Retains the current position (ignores the x and y parameters) $SWP_NOOWNERZORDER - Does not change the owner window's position in the Z order $SWP_NOREDRAW - Does not redraw changes $SWP_NOREPOSITION - Same as the SWP_NOOWNERZORDER flag $SWP_NOSENDCHANGING - Prevents the window from receiving the WM_WINDOWPOSCHANGING message $SWP_NOSIZE - Retains the current size (ignores the cx and cy parameters) $SWP_NOZORDER - Retains the current Z order (ignores the InsertAfter parameter) $SWP_SHOWWINDOW - Displays the window


User Defined Functions

Timers user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <Timers.au3>.

User Defined Function | Description
_Timer_Diff | Returns the difference in time from a previous call to _Timer_Init
_Timer_GetIdleTime | Returns the number of ticks since last user activity (i.e. KYBD/Mouse)
_Timer_GetTimerID | Returns the Timer ID from $wParam
_Timer_Init | Returns a timestamp (in milliseconds)
_Timer_KillAllTimers | Destroys all the timers
_Timer_KillTimer | Destroys the specified timer
_Timer_SetTimer | Creates a timer with the specified time-out value


Function _Timer_Diff

Function Reference

_Timer_Diff

Returns the difference in time from a previous call to _Timer_Init

#include <Timers.au3>
_Timer_Diff ( $iTimeStamp )

Parameters

$iTimeStamp Timestamp returned from a previous call to _Timer_Init().

Return Value

Returns the time difference (in milliseconds) from a previous call to _Timer_Init().

Related

_Timer_Init

Example

#include <Timers.au3>

Example()

Func Example()
    HotKeySet("{ESC}", "_Quit")

    Local $hStarttime = _Timer_Init()
    While 1
        ToolTip(_Timer_Diff($hStarttime))
    WEnd
EndFunc   ;==>Example

Func _Quit()
    Exit
EndFunc   ;==>_Quit


Function _Timer_GetIdleTime

Function Reference

_Timer_GetIdleTime

Returns the number of ticks since last user activity (i.e. KYBD/Mouse)

#include <Timers.au3>
_Timer_GetIdleTime ( )

Return Value

Success: | integer ticks since last (approx. milliseconds) since last activity
Failure: | Sets @extended = 1 if rollover occurs (see remarks)

Remarks

The current ticks since last system restart will roll over to 0 every 50 days or so, which makes it possible for last user activity to be before the rollover, but run time of this function to be after the rollover.
If this happens, @extended = 1 and the returned value is ticks since rollover occured.

Example

#include <MsgBoxConstants.au3>
#include <Timers.au3>

; Mouse/Keyboard action during this 10 sec delay will change reported idle time
Sleep(10 * 1000); 10sec

Local $iIdleTime = _Timer_GetIdleTime()

MsgBox($MB_SYSTEMMODAL, "_Timer_GetIdleTime", "Idle time = " & $iIdleTime & "ms")


Function _Timer_GetTimerID

Function Reference

_Timer_GetTimerID

Returns the Timer ID from $wParam

#include <Timers.au3>
_Timer_GetTimerID ( $wParam )

Parameters

$wParam Specifies the timer identifier event.

Return Value

Success: | The Timer ID
Failure: | 0

Related

_Timer_SetTimer

Example

#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>
#include <Timers.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_hStatus, $g_idProgress, $g_iPercent = 0, $g_iDirection = 1
Global $g_iTimer1, $g_iTimer2

_Example_Events()

Func _Example_Events()
    Local $hGUI, $idChange, $iWait = 10, $idState
    Local $aParts[3] = [75, 330, -1]

    $hGUI = GUICreate("Timers Using WM_TIMER Events", 400, 320)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    $idState = GUICtrlCreateButton("Start Progress Bar", 70, 270, 100, 25)
    $idChange = GUICtrlCreateButton("Change", 215, 270, 90, 25)
    GUICtrlSetState($idChange, $GUI_DISABLE)
    $g_hStatus = _GUICtrlStatusBar_Create($hGUI, $aParts)
    _GUICtrlStatusBar_SetText($g_hStatus, "Timers")
    _GUICtrlStatusBar_SetText($g_hStatus, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)
    $g_idProgress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_SMOOTH)
    GUICtrlSetColor($g_idProgress, 0xff0000)
    _GUICtrlStatusBar_EmbedControl($g_hStatus, 1, GUICtrlGetHandle($g_idProgress))
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_TIMER, "WM_TIMER")

    $g_iTimer1 = _Timer_SetTimer($hGUI, 1000)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idState
                If GUICtrlRead($idState) = "Start Progress Bar" Then
                    $g_iTimer2 = _Timer_SetTimer($hGUI, $iWait) ; create timer
                    If @error Or $g_iTimer2 = 0 Then ContinueLoop
                    GUICtrlSetData($idState, "Stop Progress Bar")
                    GUICtrlSetState($idChange, $GUI_ENABLE)
                Else
                    GUICtrlSetState($idChange, $GUI_DISABLE)
                    _Timer_KillTimer($hGUI, $g_iTimer2)
                    GUICtrlSetData($idState, "Start Progress Bar")
                EndIf

            Case $idChange
                If $iWait = 10 Then
                    $iWait = 250
                Else
                    $iWait = 10
                EndIf
                MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & " milliseconds")
                $g_iTimer2 = _Timer_SetTimer($hGUI, $iWait, "", $g_iTimer2) ; reuse timer with different interval
        EndSwitch
    WEnd

    ConsoleWrite("Killed All Timers? " & _Timer_KillAllTimers($hGUI) & @CRLF)
    GUIDelete()
EndFunc   ;==>_Example_Events

; Timer Events
Func WM_TIMER($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam

    Switch _Timer_GetTimerID($wParam)
        Case $g_iTimer1
            _UpdateStatusBarClock()
        Case $g_iTimer2
            _UpdateProgressBar()
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_TIMER

Func _UpdateStatusBarClock()
    _GUICtrlStatusBar_SetText($g_hStatus, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)
EndFunc   ;==>_UpdateStatusBarClock

Func _UpdateProgressBar()
    $g_iPercent += 5 * $g_iDirection
    GUICtrlSetData($g_idProgress, $g_iPercent)
    If $g_iPercent = 100 Or $g_iPercent = 0 Then $g_iDirection *= -1
    If $g_iPercent = 100 Then
        GUICtrlSetColor($g_idProgress, 0xff0000)
    ElseIf $g_iPercent = 0 Then
        GUICtrlSetColor($g_idProgress, 0x0000ff)
    EndIf
EndFunc   ;==>_UpdateProgressBar

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _Timer_Init

Function Reference

_Timer_Init

Returns a timestamp (in milliseconds)

#include <Timers.au3>
_Timer_Init ( )

Return Value

Returns a timestamp number (in milliseconds).

Related

_Timer_Diff

Example

#include <Timers.au3>

Example()

Func Example()
    HotKeySet("{ESC}", "_Quit")

    Local $hStarttime = _Timer_Init()
    While 1
        ToolTip(_Timer_Diff($hStarttime))
    WEnd
EndFunc   ;==>Example

Func _Quit()
    Exit
EndFunc   ;==>_Quit


Function _Timer_KillAllTimers

Function Reference

_Timer_KillAllTimers

Destroys all the timers

#include <Timers.au3>
_Timer_KillAllTimers ( $hWnd )

Parameters

$hWnd Handle to the window associated with the timers.
This value must be the same as the $hWnd value passed to the _Timer_SetTimer() function that created the timer

Return Value

Success: | True
Failure: | False

Remarks

The _Timer_KillAllTimers() function does not remove WM_TIMER messages already posted to the message queue

Related

_Timer_KillTimer, _Timer_SetTimer

Example

Example 1

#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>
#include <Timers.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_hStatus, $g_idProgress, $g_iPercent = 0, $g_iDirection = 1

_Example_CallBack()

Func _Example_CallBack()
    Local $hGUI, $iTimerProgress, $idChange, $iWait = 10, $idState
    Local $aParts[3] = [75, 330, -1]

    $hGUI = GUICreate("Timers Using CallBack Function(s)", 400, 320)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    $idState = GUICtrlCreateButton("Start Progress Bar", 70, 270, 100, 25)
    $idChange = GUICtrlCreateButton("Change", 215, 270, 90, 25)
    GUICtrlSetState($idChange, $GUI_DISABLE)
    $g_hStatus = _GUICtrlStatusBar_Create($hGUI, $aParts)
    _GUICtrlStatusBar_SetText($g_hStatus, "Timers")
    _GUICtrlStatusBar_SetText($g_hStatus, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)
    $g_idProgress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_SMOOTH)
    GUICtrlSetColor($g_idProgress, 0xff0000)
    _GUICtrlStatusBar_EmbedControl($g_hStatus, 1, GUICtrlGetHandle($g_idProgress))
    GUISetState(@SW_SHOW)

    _Timer_SetTimer($hGUI, 1000, "_UpdateStatusBarClock") ; create timer

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idState
                If GUICtrlRead($idState) = "Start Progress Bar" Then
                    $iTimerProgress = _Timer_SetTimer($hGUI, $iWait, "_UpdateProgressBar") ; create timer
                    If @error Or $iTimerProgress = 0 Then ContinueLoop
                    GUICtrlSetData($idState, "Stop Progress Bar")
                    GUICtrlSetState($idChange, $GUI_ENABLE)
                Else
                    GUICtrlSetState($idChange, $GUI_DISABLE)
                    _Timer_KillTimer($hGUI, $iTimerProgress)
                    GUICtrlSetData($idState, "Start Progress Bar")
                EndIf

            Case $idChange
                If $iWait = 10 Then
                    $iWait = 250
                Else
                    $iWait = 10
                EndIf
                MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & " milliseconds")
                $iTimerProgress = _Timer_SetTimer($hGUI, $iWait, "", $iTimerProgress) ; reuse timer with different interval
        EndSwitch
    WEnd
    ConsoleWrite("Killed All Timers? " & _Timer_KillAllTimers($hGUI) & @CRLF) ; must be True as the timer to "_UpdateStatusBarClock" have not been killed
    GUIDelete()
EndFunc   ;==>_Example_CallBack

; call back function
Func _UpdateStatusBarClock($hWnd, $iMsg, $iIDTimer, $iTime)
    #forceref $hWnd, $iMsg, $iIDTimer, $iTime
    _GUICtrlStatusBar_SetText($g_hStatus, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)
EndFunc   ;==>_UpdateStatusBarClock

; call back function
Func _UpdateProgressBar($hWnd, $iMsg, $iIDTimer, $iTime)
    #forceref $hWnd, $iMsg, $iIDTimer, $iTime
    $g_iPercent += 5 * $g_iDirection
    GUICtrlSetData($g_idProgress, $g_iPercent)
    If $g_iPercent = 100 Or $g_iPercent = 0 Then $g_iDirection *= -1
    If $g_iPercent = 100 Then
        GUICtrlSetColor($g_idProgress, 0xff0000)
    ElseIf $g_iPercent = 0 Then
        GUICtrlSetColor($g_idProgress, 0x0000ff)
    EndIf
EndFunc   ;==>_UpdateProgressBar

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Example 2

#include <Timers.au3>

Global $g_iMsecs = 0, $g_sResult = '', $g_sCDdrv

_Example_TimeOut()

Func _Example_TimeOut()
    $g_sCDdrv = DriveGetDrive("CDROM")
    $g_sCDdrv = $g_sCDdrv[1]

    Local $hGUI = GUICreate("", 140, 64, -1, -1, 0)
    GUICtrlCreateLabel("Insert a CD into the tray", 8, 8, 115, 17)
    GUISetState(@SW_SHOW)

    Local $iIDtimer = _Timer_SetTimer($hGUI, 1000, "Check_mounted") ; create timer
    While $g_sResult = ''
        Sleep(200)
    WEnd

    _Timer_KillTimer($hGUI, $iIDtimer)
    MsgBox(0, '', $g_sResult, 5)

    ConsoleWrite("Killed All Timers? " & _Timer_KillAllTimers($hGUI) & @CRLF) ; must be False as all timer have already been killed
    GUIDelete($hGUI)
EndFunc   ;==>_Example_TimeOut

Func Check_mounted($hWnd, $iMsg, $iIDtimer, $iTime)
    #forceref $hWnd, $iMsg, $iIDTimer,$iTime
    $g_sResult = ''
    If FileExists($g_sCDdrv & '\') Then
        $g_sResult = DriveGetLabel($g_sCDdrv) & ' inserted' & @CRLF
        $g_sResult &= 'on drive ' & $g_sCDdrv
    Else
        $g_iMsecs += 1000
        If $g_iMsecs = 10000 Then
            $g_sResult = 'timed out'
        EndIf
    EndIf
EndFunc   ;==>Check_mounted


Function _Timer_KillTimer

Function Reference

_Timer_KillTimer

Destroys the specified timer

#include <Timers.au3>
_Timer_KillTimer ( $hWnd, $iTimerID )

Parameters

$hWnd | Handle to the window associated with the specified timer. This value must be the same as the $hWnd value passed to the _Timer_SetTimer() function that created the timer
$iTimerID | Specifies the timer to be destroyed

Return Value

Success: | True
Failure: | False

Remarks

The _Timer_KillTimer() function does not remove WM_TIMER messages already posted to the message queue

Related

_Timer_KillAllTimers, _Timer_SetTimer

See Also

Search KillTimer in MSDN Library.

Example

Example 1

#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>
#include <Timers.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_hStatus, $g_idProgress, $g_iPercent = 0, $g_iDirection = 1

_Example_CallBack()

Func _Example_CallBack()
    Local $hGUI, $iTimerProgress, $idChange, $iWait = 10, $idState
    Local $aParts[3] = [75, 330, -1]

    $hGUI = GUICreate("Timers Using CallBack Function(s)", 400, 320)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    $idState = GUICtrlCreateButton("Start Progress Bar", 70, 270, 100, 25)
    $idChange = GUICtrlCreateButton("Change", 215, 270, 90, 25)
    GUICtrlSetState($idChange, $GUI_DISABLE)
    $g_hStatus = _GUICtrlStatusBar_Create($hGUI, $aParts)
    _GUICtrlStatusBar_SetText($g_hStatus, "Timers")
    _GUICtrlStatusBar_SetText($g_hStatus, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)
    $g_idProgress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_SMOOTH)
    GUICtrlSetColor($g_idProgress, 0xff0000)
    _GUICtrlStatusBar_EmbedControl($g_hStatus, 1, GUICtrlGetHandle($g_idProgress))
    GUISetState(@SW_SHOW)

    _Timer_SetTimer($hGUI, 1000, "_UpdateStatusBarClock") ; create timer

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idState
                If GUICtrlRead($idState) = "Start Progress Bar" Then
                    $iTimerProgress = _Timer_SetTimer($hGUI, $iWait, "_UpdateProgressBar") ; create timer
                    If @error Or $iTimerProgress = 0 Then ContinueLoop
                    GUICtrlSetData($idState, "Stop Progress Bar")
                    GUICtrlSetState($idChange, $GUI_ENABLE)
                Else
                    GUICtrlSetState($idChange, $GUI_DISABLE)
                    _Timer_KillTimer($hGUI, $iTimerProgress)
                    GUICtrlSetData($idState, "Start Progress Bar")
                EndIf

            Case $idChange
                If $iWait = 10 Then
                    $iWait = 250
                Else
                    $iWait = 10
                EndIf
                MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & " milliseconds")
                $iTimerProgress = _Timer_SetTimer($hGUI, $iWait, "", $iTimerProgress) ; reuse timer with different interval
        EndSwitch
    WEnd
    ConsoleWrite("Killed All Timers? " & _Timer_KillAllTimers($hGUI) & @CRLF) ; must be True as the timer to "_UpdateStatusBarClock" have not been killed
    GUIDelete()
EndFunc   ;==>_Example_CallBack

; call back function
Func _UpdateStatusBarClock($hWnd, $iMsg, $iIDTimer, $iTime)
    #forceref $hWnd, $iMsg, $iIDTimer, $iTime
    _GUICtrlStatusBar_SetText($g_hStatus, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)
EndFunc   ;==>_UpdateStatusBarClock

; call back function
Func _UpdateProgressBar($hWnd, $iMsg, $iIDTimer, $iTime)
    #forceref $hWnd, $iMsg, $iIDTimer, $iTime
    $g_iPercent += 5 * $g_iDirection
    GUICtrlSetData($g_idProgress, $g_iPercent)
    If $g_iPercent = 100 Or $g_iPercent = 0 Then $g_iDirection *= -1
    If $g_iPercent = 100 Then
        GUICtrlSetColor($g_idProgress, 0xff0000)
    ElseIf $g_iPercent = 0 Then
        GUICtrlSetColor($g_idProgress, 0x0000ff)
    EndIf
EndFunc   ;==>_UpdateProgressBar

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Example 2

#include <Timers.au3>

Global $g_iMsecs = 0, $g_sResult = '', $g_sCDdrv

_Example_TimeOut()

Func _Example_TimeOut()
    $g_sCDdrv = DriveGetDrive("CDROM")
    $g_sCDdrv = $g_sCDdrv[1]

    Local $hGUI = GUICreate("", 140, 64, -1, -1, 0)
    GUICtrlCreateLabel("Insert a CD into the tray", 8, 8, 115, 17)
    GUISetState(@SW_SHOW)

    Local $iIDtimer = _Timer_SetTimer($hGUI, 1000, "Check_mounted") ; create timer
    While $g_sResult = ''
        Sleep(200)
    WEnd

    _Timer_KillTimer($hGUI, $iIDtimer)
    MsgBox(0, '', $g_sResult, 5)

    ConsoleWrite("Killed All Timers? " & _Timer_KillAllTimers($hGUI) & @CRLF) ; must be False as all timer have already been killed
    GUIDelete($hGUI)
EndFunc   ;==>_Example_TimeOut

Func Check_mounted($hWnd, $iMsg, $iIDtimer, $iTime)
    #forceref $hWnd, $iMsg, $iIDTimer,$iTime
    $g_sResult = ''
    If FileExists($g_sCDdrv & '\') Then
        $g_sResult = DriveGetLabel($g_sCDdrv) & ' inserted' & @CRLF
        $g_sResult &= 'on drive ' & $g_sCDdrv
    Else
        $g_iMsecs += 1000
        If $g_iMsecs = 10000 Then
            $g_sResult = 'timed out'
        EndIf
    EndIf
EndFunc   ;==>Check_mounted


Function _Timer_SetTimer

Function Reference

_Timer_SetTimer

Creates a timer with the specified time-out value

#include <Timers.au3>
_Timer_SetTimer ( $hWnd [, $iElapse = 250 [, $sTimerFunc = "" [, $iTimerID = -1]]] )

Parameters

$hWnd | Handle to the window to be associated with the timer. This window must be owned by the calling thread
$iElapse | [optional] Specifies the time-out value, in milliseconds
$sTimerFunc | [optional] Function name to be notified when the time-out value elapses
$iTimerID | [optional] Specifies a timer identifier. If $iTimerID = -1 then a new timer is created If $iTimerID matches an existing timer then the timer is replaced If $iTimerID = -1 and $sTimerFunc = "" then timer will use WM_TIMER events

Return Value

Success: | Integer identifying the new timer
Failure: | 0

Remarks

The callback function is called with the following parameters:
$hWnd, $iMsg, $iIDTimer, $iTime
$hWnd - A handle to the window associated with the timer.
$iMsg - The WM_TIMER (0x113) message.
$iIDTimer - The timer's identifier.
$iTime - The number of milliseconds that have elapsed since the system was started. This is the value returned by the _Date_Time_GetTickCount() function.

Related

_Timer_GetTimerID, _Timer_KillAllTimers, _Timer_KillTimer

See Also

Search SetTimer in MSDN Library.

Example

Example 1

#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>
#include <Timers.au3>
#include <WindowsConstants.au3>

Global $g_idMemo, $g_hStatus, $g_idProgress, $g_iPercent = 0, $g_iDirection = 1

_Example_CallBack()

Func _Example_CallBack()
    Local $hGUI, $iTimerProgress, $idChange, $iWait = 10, $idState
    Local $aParts[3] = [75, 330, -1]

    $hGUI = GUICreate("Timers Using CallBack Function(s)", 400, 320)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, BitOR($WS_HSCROLL, $WS_VSCROLL))
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    $idState = GUICtrlCreateButton("Start Progress Bar", 70, 270, 100, 25)
    $idChange = GUICtrlCreateButton("Change", 215, 270, 90, 25)
    GUICtrlSetState($idChange, $GUI_DISABLE)
    $g_hStatus = _GUICtrlStatusBar_Create($hGUI, $aParts)
    _GUICtrlStatusBar_SetText($g_hStatus, "Timers")
    _GUICtrlStatusBar_SetText($g_hStatus, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)
    $g_idProgress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_SMOOTH)
    GUICtrlSetColor($g_idProgress, 0xff0000)
    _GUICtrlStatusBar_EmbedControl($g_hStatus, 1, GUICtrlGetHandle($g_idProgress))
    GUISetState(@SW_SHOW)

    _Timer_SetTimer($hGUI, 1000, "_UpdateStatusBarClock") ; create timer

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idState
                If GUICtrlRead($idState) = "Start Progress Bar" Then
                    $iTimerProgress = _Timer_SetTimer($hGUI, $iWait, "_UpdateProgressBar") ; create timer
                    If @error Or $iTimerProgress = 0 Then ContinueLoop
                    GUICtrlSetData($idState, "Stop Progress Bar")
                    GUICtrlSetState($idChange, $GUI_ENABLE)
                Else
                    GUICtrlSetState($idChange, $GUI_DISABLE)
                    _Timer_KillTimer($hGUI, $iTimerProgress)
                    GUICtrlSetData($idState, "Start Progress Bar")
                EndIf

            Case $idChange
                If $iWait = 10 Then
                    $iWait = 250
                Else
                    $iWait = 10
                EndIf
                MemoWrite("Timer for _UpdateProgressBar set at: " & $iWait & " milliseconds")
                $iTimerProgress = _Timer_SetTimer($hGUI, $iWait, "", $iTimerProgress) ; reuse timer with different interval
        EndSwitch
    WEnd
    ConsoleWrite("Killed All Timers? " & _Timer_KillAllTimers($hGUI) & @CRLF) ; must be True as the timer to "_UpdateStatusBarClock" have not been killed
    GUIDelete()
EndFunc   ;==>_Example_CallBack

; call back function
Func _UpdateStatusBarClock($hWnd, $iMsg, $iIDTimer, $iTime)
    #forceref $hWnd, $iMsg, $iIDTimer, $iTime
    _GUICtrlStatusBar_SetText($g_hStatus, @TAB & @TAB & StringFormat("%02d:%02d:%02d", @HOUR, @MIN, @SEC), 2)
EndFunc   ;==>_UpdateStatusBarClock

; call back function
Func _UpdateProgressBar($hWnd, $iMsg, $iIDTimer, $iTime)
    #forceref $hWnd, $iMsg, $iIDTimer, $iTime
    $g_iPercent += 5 * $g_iDirection
    GUICtrlSetData($g_idProgress, $g_iPercent)
    If $g_iPercent = 100 Or $g_iPercent = 0 Then $g_iDirection *= -1
    If $g_iPercent = 100 Then
        GUICtrlSetColor($g_idProgress, 0xff0000)
    ElseIf $g_iPercent = 0 Then
        GUICtrlSetColor($g_idProgress, 0x0000ff)
    EndIf
EndFunc   ;==>_UpdateProgressBar

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

Example 2

#include <Timers.au3>

Global $g_iMsecs = 0, $g_sResult = '', $g_sCDdrv

_Example_TimeOut()

Func _Example_TimeOut()
    $g_sCDdrv = DriveGetDrive("CDROM")
    $g_sCDdrv = $g_sCDdrv[1]

    Local $hGUI = GUICreate("", 140, 64, -1, -1, 0)
    GUICtrlCreateLabel("Insert a CD into the tray", 8, 8, 115, 17)
    GUISetState(@SW_SHOW)

    Local $iIDtimer = _Timer_SetTimer($hGUI, 1000, "Check_mounted") ; create timer
    While $g_sResult = ''
        Sleep(200)
    WEnd

    _Timer_KillTimer($hGUI, $iIDtimer)
    MsgBox(0, '', $g_sResult, 5)

    ConsoleWrite("Killed All Timers? " & _Timer_KillAllTimers($hGUI) & @CRLF) ; must be False as all timer have already been killed
    GUIDelete($hGUI)
EndFunc   ;==>_Example_TimeOut

Func Check_mounted($hWnd, $iMsg, $iIDtimer, $iTime)
    #forceref $hWnd, $iMsg, $iIDTimer,$iTime
    $g_sResult = ''
    If FileExists($g_sCDdrv & '\') Then
        $g_sResult = DriveGetLabel($g_sCDdrv) & ' inserted' & @CRLF
        $g_sResult &= 'on drive ' & $g_sCDdrv
    Else
        $g_iMsecs += 1000
        If $g_iMsecs = 10000 Then
            $g_sResult = 'timed out'
        EndIf
    EndIf
EndFunc   ;==>Check_mounted


User Defined Functions

Visa user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <Visa.au3>.

User Defined Function | Description
_viClose | Closes a VISA connection to an Instrument/Device
_viExecCommand | Send a Command/Query to an Instrument/Device through the VISA interface (GPIB / TCP)
_viFindGpib | Send a Command/Query to an Instrument/Device through the VISA interface (GPIB / TCP)
_viGpibBusReset | GPIB BUS "reset": Use this function when the GPIB BUS gets stuck for some reason. You might be lucky and resolve the problem by calling this function
_viGTL | Go To Local mode: Instruments that accept this command will exit the "Remote Control mode" and go to "Local mode". If the instrument is already in "Local mode" this is simply ignored. Normally, if an instrument does not support this command it will simply stay in the "Remote Control mode"
_viInteractiveControl | Interactive VISA control to test your SCPI commands
_viOpen | Opens a VISA connection to an Instrument/Device
_viSetAttribute | Set any VISA attribute This function, which is called by _viSetTimeout, can ALSO be used to set the other VISA specific attributes. Read the VISA documentation for more information and a list of VISA attributes and their corresponding values
_viSetTimeout | Sets the VISA timeout in MILISECONDS


Function _viClose

Function Reference

_viClose

Closes a VISA connection to an Instrument/Device

#include <Visa.au3>
_viClose ( $hSession )

Parameters

$hSession A VISA session handle as returned by _viOpen()

Return Value

Success: | 0.
Failure: | -1 if the VISA DLL could not be open or a NON ZERO value representing the VISA error code (see the VISA programmer's guide).

Remarks

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32) and a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) must be installed

Related

_viExecCommand, _viFindGpib, _viGpibBusReset, _viGTL, _viOpen, _viSetAttribute, _viSetTimeout

Example

; - This assumes that you have instrument set to GPIB address 1
; It shows how to use the _viExecCommand function in stand alone mode and combined
; with _viOpen and _viClose.
; It also shows the _viGTL function

#include <MsgBoxConstants.au3>
#include <Visa.au3>

Local $h_Session = 0

; Query the ID of the instrument in GPIB address 3
MsgBox($MB_SYSTEMMODAL, "Step 1", "Open the instrument connection with _viOpen")
Local $h_Instr = _viOpen("GPIB::3::0")
MsgBox($MB_SYSTEMMODAL, "Instrument Handle obtained", "$h_Instr = " & $h_Instr) ; Show the Session Handle
; Query the instrument

MsgBox($MB_SYSTEMMODAL, "Step 2", "Query the instrument using the VISA instrument handle")
Local $s_Answer = _viExecCommand($h_Instr, "*IDN?") ; $h_Instr is NOT A STRING now!
MsgBox($MB_SYSTEMMODAL, "GPIB QUERY result", $s_Answer) ; Show the answer
; Query again. There is no need to OPEN the link again

MsgBox($MB_SYSTEMMODAL, "Step 3", "Query again. There is no need to OPEN the link again")
$s_Answer = _viExecCommand($h_Instr, "*IDN?")
MsgBox($MB_SYSTEMMODAL, "GPIB QUERY result", $s_Answer) ; Show the answer

MsgBox($MB_SYSTEMMODAL, "Step 4", "Close the instrument connection using _viClose")
_viClose($h_Instr) ; Close the instrument connection


Function _viExecCommand

Function Reference

_viExecCommand

Send a Command/Query to an Instrument/Device through the VISA interface (GPIB / TCP)

#include <Visa.au3>
_viExecCommand ( $hSession, $sCommand [, $iTimeoutMS = -1 [, $sMode = @LF]] )

Parameters

$hSession A VISA descriptor (STRING) OR a VISA session handle (INTEGER)
This it can be a string or an integer (a handle):
* STRING -&gr; A VISA DESCRIPTOR is a string which specifies the resource with which to establish a communication session.
An example descriptor is "GPIB::20::0".
This function supports all valid VISA descriptors, including GPIB, TCP, VXI and Serial Interface instruments (ASRL).
A detailed explanation of VISA descriptors is shown in the Remarks section of this function.
As a SHORTCUT you can also use a STRING containing the address number (e.g. "20") of a GPIB instrument instead of typing the full descriptor (in that case, "GPIB::20::0")
* INTEGER -&gr; A VISA session handle is an integer value returned by _viOpen().
It is recommended that instead you use _viOpen() and VISA session handles instead of descriptors if you plan to communicate repeteadly with an Instrument or Device, as otherwise each time that you contact the instrument you would incur the overhead of opening and closing the communication link.
Once you are done using the instrument you must remember to close the link with _viClose().
$sCommand Command/Query to execute (e.g. "*IDN?" or "SOURCE:POWER -20 dBM")
A query MUST contain a QUESTION MARK (?)
When the command is a QUERY the function will automatically wait for the instrument's answer (or until the operation times out)
$iTimeoutMS [optional] The operation timeout in MILISECONDS.
This is mostly important for QUERIES only.
If it is not specified the last set timeout will be used. If it was never set before the default timeout (which depends on the VISA implementation) will be used.
Timeouts can also be set separatelly with the _viSetTimeout() function.
Depending on the bus type (GPIB, TCP, etc) the timeout might not be set to the exact value that you request. Instead the closest valid timeout bigger than the one that you requested will be used.
$sMode [optional] Control the mode in which the VISA viPrintf is called when $sCommand is not a query.
Default is @LF, which means "attach @LF mode".
Some instruments and in particular many GPIB cards do not honor the terminator character attribute in those cases an @LF terminator needs to be added.
As this is the most common case, by default the mode is set to @LF, which appends @LF to the SCPI command you can also set this mode to @CR and @CRLF if your card uses those terminators.
If you do not want to use a terminator, set this parameter to an empty string ("")
Also, some cards support the execution of a "sprintf" on the SCPI string prior to sending it through the VISA interface.
For those who do, it is possible, by setting this parameter to "str" to "protect" the VISa interface from accidentally applying an escape sequence when a "/" is found within the VISA command string.
This is normally NOT necessary and should only be set if your GPIB card or instrument require it.

Return Value

Returns a value which depends on whether the command is a QUERY or not and in whether the operation was successful or not.

* Command, NON QUERY:
Success: | 0.
Failure: | -1 if the VISA DLL could not be open or a NON ZERO value representing the VISA error code (see the VISA programmer's guide)

Success: | the answer of the instrument to the QUERY
Failure: | -1 if the VISA DLL could not be open -3 if the VISA DLL returned an unexpected number of results or a NON ZERO value representing the VISA error code (see the VISA programmer's guide)

Remarks

* The VISA queries only return the 1st line of the device answer.
This is not a problem in most cases, as most devices will always answer with a single line.

* The following is a description of the MOST COMMON VISA DESCRIPTORS
Note that there are some more types. For more info please refer to a VISA programmer's guide (available at www.ni.com).
Optional segments are shown in square brackets ([]).
Required segments that must be filled in are denoted by angle brackets (<&gr;).

Interface Syntax
------------------------------------------------------------
GPIB INSTR GPIB[board]::primary address
[::secondary address] [::INSTR]
GPIB INTFC GPIB[board]::INTFC
TCPIP SOCKET TCPIP[board]::host address::port::SOCKET
Serial INSTR ASRL[board][::INSTR]
PXI INSTR PXI[board]::device[::function][::INSTR]
VXI INSTR VXI[board]::VXI logical address[::INSTR]
GPIB-VXI INSTR GPIB-VXI[board]::VXI logical address[::INSTR]
TCPIP INSTR TCPIP[board]::host address[::LAN device name]
[::INSTR]

The GPIB keyword is used for GPIB instruments.
The TCPIP keyword is used for TCP/IP communication.
The ASRL keyword is used for serial instruments.
The PXI keyword is used for PXI instruments.
The VXI keyword is used for VXI instruments via either embedded or MXIbus controllers.
The GPIB-VXI keyword is used for VXI instruments via a GPIB-VXI controller.

The default values for optional parameters are shown below.

Optional Segment Default Value
---------------------------------------
board 0
secondary address none
LAN device name inst0

Example Resource Strings:
--------------------------------------------------------------
GPIB::1::0::INSTR A GPIB device at primary address 1 and
secondary address 0 in GPIB interface 0.

GPIB2::INTFC Interface or raw resource for GPIB
interface 2.

TCPIP0::1.2.3.4::999::SOCKET Raw TCP/IP access to port 999
at the specified IP address.

ASRL1::INSTR A serial device attached to interface
ASRL1. VXI::MEMACC Board-level register
access to the VXI interface.

PXI::15::INSTR PXI device number 15 on bus 0.

VXI0::1::INSTR A VXI device at logical address 1 in VXI
interface VXI0.

GPIB-VXI::9::INSTR A VXI device at logical address 9 in a
GPIB-VXI controlled system.

Related

_viClose, _viFindGpib, _viGpibBusReset, _viGTL, _viOpen, _viSetAttribute, _viSetTimeout

Example

; - This assumes that you have instrument set to GPIB address 3
; If you have an instrument in a different address change "GPIB::3::0" to the
; corresponding descriptor. Do the same for the call to _viOpen
; It shows how to use the _viExecCommand function in stand alone mode and combined
; with _viOpen and _viClose.
; It also shows the _viGTL function

#include <MsgBoxConstants.au3>
#include <Visa.au3>

Local $h_Session = 0

; Query the ID of the instrument in GPIB address 3
MsgBox($MB_SYSTEMMODAL, "Step 1", "Simple GPIB query using a VISA Descriptor")
Local $s_Answer = _viExecCommand("GPIB::3::0", "*IDN?", 10000) ; 10 secs timeout
MsgBox($MB_SYSTEMMODAL, "GPIB QUERY result", $s_Answer) ; Show the answer

MsgBox($MB_SYSTEMMODAL, "Step 2", "Go to LOCAL using VISA Descriptor")
_viGTL("GPIB::1::0") ; Go to local (exit remote control mode)

MsgBox($MB_SYSTEMMODAL, "Step 3", "Simple GPIB query using a VISA address shortcut")
$s_Answer = _viExecCommand("1", "*IDN?") ; The address MUST BE A STRING
MsgBox($MB_SYSTEMMODAL, "GPIB QUERY result", $s_Answer) ; Show the answer
MsgBox($MB_SYSTEMMODAL, "Info", "Now let's use _viOpen and _viClose")

MsgBox($MB_SYSTEMMODAL, "Step 4", "Open the instrument connection with _viOpen")
Local $h_Instr = _viOpen(3)
MsgBox($MB_SYSTEMMODAL, "Instrument Handle obtained", "$h_Instr = " & $h_Instr) ; Show the Session Handle
; Query the instrument

MsgBox($MB_SYSTEMMODAL, "Step 5", "Query the instrument using the VISA instrument handle")
$s_Answer = _viExecCommand($h_Instr, "*IDN?") ; $h_Instr is NOT A STRING now!
MsgBox($MB_SYSTEMMODAL, "GPIB QUERY result", $s_Answer) ; Show the answer
; Query again. There is no need to OPEN the link again

MsgBox($MB_SYSTEMMODAL, "Step 6", "Query again. There is no need to OPEN the link again")
$s_Answer = _viExecCommand($h_Instr, "*IDN?")
MsgBox($MB_SYSTEMMODAL, "GPIB QUERY result", $s_Answer) ; Show the answer

MsgBox($MB_SYSTEMMODAL, "Step 7", "Go to LOCAL using VISA instrument handle")
_viGTL($h_Instr); Go to local (this is optional)

MsgBox($MB_SYSTEMMODAL, "Step 8", "Close the Instrument connection using _viClose")
_viClose($h_Instr) ; Close the instrument connection


Function _viFindGpib

Function Reference

_viFindGpib

Send a Command/Query to an Instrument/Device through the VISA interface (GPIB / TCP)

#include <Visa.au3>
_viFindGpib ( ByRef $aDescriptorList, ByRef $aIDNList [, $iShow_Search_Results = 0] )

Parameters

$aDescriptorList | RETURNS an array of the VISA resource descriptors of the instruments that were found in the GPIB bus (see the Remarks of the _viExecCommand() for more info)
$aIDNList | RETURNS an array of the IDNs (i.e names) of the instruments that were found in the GPIB bus
$iShow_Search_Results | [optional] If 1 a message box showing the results of the search will be shown. The default is 0, which means that the results are not shown

Return Value

Success: | the number of instruments found (0 or more).
Failure: | a NEGATIVE value and sets the @error flag to non-zero.

Remarks

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32) and a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) must be installed

* For a detailed description of the most common VISA DESCRIPTORS look at the Remarks of the help on the _viExecCommand() function

Related

_viClose, _viExecCommand, _viGpibBusReset, _viGTL, _viOpen

Example

; This example performs a search on the GPIB bus and shows the results in a MsgBox

#include <Visa.au3>

Local $a_Descriptor_list[1], $a_Idn_list[1]
_viFindGpib($a_Descriptor_list, $a_Idn_list, 1)


Function _viGpibBusReset

Function Reference

_viGpibBusReset

GPIB BUS "reset": Use this function when the GPIB BUS gets stuck for some reason. You might be lucky and resolve the problem by calling this function

#include <Visa.au3>
_viGpibBusReset ( )

Return Value

Success: | 0.
Failure: | -1 if the VISA DLL could not be open or a NON ZERO value representing the VISA error code (see the VISA programmer's guide)

Remarks

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32) and a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) must be installed

Related

_viClose, _viExecCommand, _viFindGpib, _viGTL, _viOpen

Example

; This example tries to "reset" the GPIB bus after a BUS "lock". This is rare,
; but it might happen if one of the instruments connected to the BUS has crashed

#include <Visa.au3>

_viGpibBusReset()


Function _viGTL

Function Reference

_viGTL

Go To Local mode: Instruments that accept this command will exit the "Remote Control mode" and go to "Local mode". If the instrument is already in "Local mode" this is simply ignored. Normally, if an instrument does not support this command it will simply stay in the "Remote Control mode"

#include <Visa.au3>
_viGTL ( $hSession )

Parameters

$hSession A VISA descriptor (STRING) OR a VISA session handle (INTEGER).
See the Remarks of the _viExecCommand() for more info.

Return Value

Success: | 0.
Failure: | -1 if the VISA DLL could not be open or a NON ZERO value representing the VISA error code (see the VISA programmer's guide).

Remarks

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32) and a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) must be installed

* For a detailed description of the most common VISA DESCRIPTORS look at the Remarks of the help on the _viExecCommand() function

Related

_viClose, _viExecCommand, _viFindGpib, _viGpibBusReset, _viOpen

Example

; - This assumes that you have instrument set to GPIB address 3
; If you have an instrument in a different address change "GPIB::3::0" to the
; corresponding descriptor. Do the same for the call to _viOpen
; It shows how to use the _viGTL function with a VISA descriptor and with a
; VISA device handler. We use _viExecCommand first to force the instrument to go
; into "Remote mode"

#include <MsgBoxConstants.au3>
#include <Visa.au3>

Local $h_Session = 0

; Query the ID of the instrument in GPIB address 3
MsgBox($MB_SYSTEMMODAL, "Step 1", "Simple GPIB query using a VISA Descriptor")
Local $s_Answer = _viExecCommand("GPIB::3::0", "*IDN?", 10)
MsgBox($MB_SYSTEMMODAL, "GPIB QUERY result", $s_Answer) ; Show the answer

MsgBox($MB_SYSTEMMODAL, "Step 2", "Go to LOCAL using VISA Descriptor")
_viGTL("GPIB::1::0") ; Go to local (exit remote control mode)

MsgBox($MB_SYSTEMMODAL, "Step 4", "Open the instrument connection with _viOpen")
Local $h_Instr = _viOpen(3)
MsgBox($MB_SYSTEMMODAL, "Instrument Handle obtained", "$h_Instr = " & $h_Instr) ; Show the Session Handle
; Query the instrument

MsgBox($MB_SYSTEMMODAL, "Step 5", "Query the instrument using the VISA instrument handle")
$s_Answer = _viExecCommand($h_Instr, "*IDN?") ; $h_Instr is NOT A STRING now!
MsgBox($MB_SYSTEMMODAL, "GPIB QUERY result", $s_Answer) ; Show the answer
; Query again. There is no need to OPEN the link again

MsgBox($MB_SYSTEMMODAL, "Step 6", "Query again. There is no need to OPEN the link again")
$s_Answer = _viExecCommand($h_Instr, "*IDN?")
MsgBox($MB_SYSTEMMODAL, "GPIB QUERY result", $s_Answer) ; Show the answer

MsgBox($MB_SYSTEMMODAL, "Step 7", "Go to LOCAL using VISA instrument handle")
_viGTL($h_Instr); Go to local (this is optional)

MsgBox($MB_SYSTEMMODAL, "Step 8", "Close the Instrument connection using _viClose")
_viClose($h_Instr) ; Close the instrument connection


Function _viInteractiveControl

Function Reference

_viInteractiveControl

Interactive VISA control to test your SCPI commands

#include <Visa.au3>
_viInteractiveControl ( [$sCommand_Save_FilePath = ""] )

Parameters

$sCommand_Save_FilePath [optional] The name of the file in which the SCPI commands issued during the interactive session will be saved.
If no filename is passed the funcion asks the user where does he wants to save the issued commands.

Return Value

Returns the list of AutoIt3 VISA commands that were executed by the tool.
This is the same list that is saved into the file if the a filename is passed to the function.

Remarks

Type "FIND" in the Device Descriptor query to perform a GPIB search.

This function lets you easily test your SCPI commands interactively.
It also lets you save these commands into a file.
Simply answer the questions (Device Descriptor, SCPI command and timeout).
* If you click Cancel on the 1st question the interactive control ends.
* If you click Cancel to the other queries, you will go back to the Device Descriptor question.


Function _viOpen

Function Reference

_viOpen

Opens a VISA connection to an Instrument/Device

#include <Visa.au3>
_viOpen ( $sVisa_Address [, $sVisa_Secondary_Address = 0] )

Parameters

$sVisa_Address | A VISA resource descriptor STRING (see the NOTES of _viExecCommand() above for more info) As as shortcut you can also directly pass a GPIB address as an integer
$sVisa_Secondary_Address | [optional] The "secondary GPIB address". Only used if the primary address is passed as an integer. Only some GPIB instruments have secondary addresses. In those cases this optional parameter can be used to specify it. This parameter is ZERO by default, which means NO SECONDARY ADDRESS.

Return Value

Success: | a (POSITIVE) VISA Instrument Handle.
Failure: | -1 and sets the @error flag to non-zero.

Remarks

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32) and a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) must be installed

* For a detailed description of the most common VISA DESCRIPTORS look at the Remarks of the help on the _viExecCommand() function

Related

_viClose, _viExecCommand, _viFindGpib, _viGpibBusReset, _viGTL, _viSetAttribute, _viSetTimeout

Example

; - This assumes that you have instrument set to GPIB address 1
; It shows how to use the _viExecCommand function in stand alone mode and combined
; with _viOpen and _viClose.
; It also shows the _viGTL function

#include <MsgBoxConstants.au3>
#include <Visa.au3>

Local $h_Session = 0

; Query the ID of the instrument in GPIB address 3
MsgBox($MB_SYSTEMMODAL, "Step 1", "Open the instrument connection with _viOpen")
Local $h_Instr = _viOpen("GPIB::3::0")
MsgBox($MB_SYSTEMMODAL, "Instrument Handle obtained", "$h_Instr = " & $h_Instr) ; Show the Session Handle
; Query the instrument

MsgBox($MB_SYSTEMMODAL, "Step 2", "Query the instrument using the VISA instrument handle")
Local $s_Answer = _viExecCommand($h_Instr, "*IDN?") ; $h_Instr is NOT A STRING now!
MsgBox($MB_SYSTEMMODAL, "GPIB QUERY result", $s_Answer) ; Show the answer
; Query again. There is no need to OPEN the link again

MsgBox($MB_SYSTEMMODAL, "Step 3", "Query again. There is no need to OPEN the link again")
$s_Answer = _viExecCommand($h_Instr, "*IDN?")
MsgBox($MB_SYSTEMMODAL, "GPIB QUERY result", $s_Answer) ; Show the answer

MsgBox($MB_SYSTEMMODAL, "Step 4", "Close the instrument connection using _viClose")
_viClose($h_Instr) ; Close the instrument connection

MsgBox($MB_SYSTEMMODAL, "Step 5", "Open the Instrument connection using only the address number")
$h_Instr = _viOpen(3)
MsgBox($MB_SYSTEMMODAL, "Instrument Handle obtained", "$h_Instr = " & $h_Instr) ; Show the Session Handle
; Query the instrument

MsgBox($MB_SYSTEMMODAL, "Step 6", "Query the instrument using the VISA instrument handle")
$s_Answer = _viExecCommand($h_Instr, "*IDN?") ; $h_Instr is NOT A STRING now!
MsgBox($MB_SYSTEMMODAL, "GPIB QUERY result", $s_Answer) ; Show the answer
; Query again. There is no need to OPEN the link again

MsgBox($MB_SYSTEMMODAL, "Step 7", "Query again. There is no need to OPEN the link again")
$s_Answer = _viExecCommand($h_Instr, "*IDN?")
MsgBox($MB_SYSTEMMODAL, "GPIB QUERY result", $s_Answer) ; Show the answer

MsgBox($MB_SYSTEMMODAL, "Step 8", "Close the instrument connection using _viClose")
_viClose($h_Instr) ; Close the instrument connection


Function _viSetAttribute

Function Reference

_viSetAttribute

Set any VISA attribute This function, which is called by _viSetTimeout, can ALSO be used to set the other VISA specific attributes. Read the VISA documentation for more information and a list of VISA attributes and their corresponding values

#include <Visa.au3>
_viSetAttribute ( $hSession, $iAttribute, $iValue )

Parameters

$hSession | A VISA descriptor (STRING) OR a VISA session handle (INTEGER). See the Remarks of the _viExecCommand() for more info.
$iAttribute | The index of the attribute that must be changed. Attributes are defined in the VISA library. This AutoIt library only defines a CONSTANT for the TIMEOUT attribute ($VI_ATTR_TMO_VALUE) and for the Serial Interface attributes and values (see the remarks) but you can pass any other valid index (as an integer) if you want to.
$iValue | The value of the attribute. It must be an integer and the possible values depend on the attribute type and are defined in the VISA documentation.

Return Value

Success: | 0.
Failure: | -1 and sets the @error flag to non-zero if the VISA DLL could not be open or a NON ZERO value representing the VISA error code (see the VISA programmer's guide).

Remarks

This is a list of the currently pre-defined attributes and values. Remember that you can use any other valid attribute/value by passing the corresponding integer index (as defined in the VISA programmer's guide) to this function.

* Attribute: $VI_ATTR_TMO_VALUE -> Set Timeout
* Values:
A timeout in MILLISECONDS or
$VI_TMO_IMMEDIATE (or 0) for "Return immediatly"
VI_TMO_INFINITE (or "INF") for "No timeout"

* Attribute: $VI_ATTR_ASRL_BAUD
* Values:
Any valid baudrate (9600, 115200, etc)

* Attribute: $VI_ATTR_ASRL_DATA_BITS
* Values:
From 5 to 8

* Attribute: $VI_ATTR_ASRL_PARITY
* Values:
$VI_ASRL_PAR_NONE
$VI_ASRL_PAR_ODD
$VI_ASRL_PAR_EVEN
$VI_ASRL_PAR_MARK
$VI_ASRL_PAR_SPACE

* Attribute: $VI_ATTR_ASRL_STOP_BITS
* Values:
$VI_ASRL_STOP_ONE
$VI_ASRL_STOP_ONE5
$VI_ASRL_STOP_TWO

* Attribute: $VI_ATTR_ASRL_FLOW_CNTRL
* Values:
$VI_ASRL_FLOW_NONE
$VI_ASRL_FLOW_XON_XOFF
$VI_ASRL_FLOW_RTS_CTS
$VI_ASRL_FLOW_DTR_DSR

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32).
You onlly need a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) if you use the GPIB related functions.

* For a detailed description of the most common VISA DESCRIPTORS look at the Remarks of the help on the _viExecCommand() function

Related

_viClose, _viExecCommand, _viOpen, _viSetTimeout

Example

; - This assumes that you have instrument set to GPIB address 3.
; If you have an instrument in a different address change "GPIB::3::0" to the
; corresponding descriptor. Do the same for the call to _viOpen
; It shows how to use the _viSetAttribute. In this example we use _viSetAttribute
; instead of _viSetTimeout to set the GPIB timeout of a _viExecCommand operation.

#include <MsgBoxConstants.au3>
#include <Visa.au3>

Local $h_Session = 0

; Query the ID of the instrument in GPIB address 3
MsgBox($MB_SYSTEMMODAL, "Step 1", "Simple GPIB query with explicit TIMEOUT set")
Local $s_Answer = _viExecCommand("GPIB::3::0", "*IDN?", 10000) ; 10 secs timeout
MsgBox($MB_SYSTEMMODAL, "GPIB QUERY result", $s_Answer) ; Show the answer

; This is the same as using the _viSetAttribute function first:
MsgBox($MB_SYSTEMMODAL, "Step 2", "_vOpen + timeout using _viSetAttribute + GPIB query")
Local $h_Instr = _viOpen(3)
; NOTE - This is the same as: _viSetTimeout($h_Instr, 10000)
_viSetAttribute($h_Instr, $VI_ATTR_TMO_VALUE, 10000) ; 10000 ms = 10 secs

$s_Answer = _viExecCommand($h_Instr, "*IDN?") ; No need to set the timeout now
MsgBox($MB_SYSTEMMODAL, "GPIB QUERY result", $s_Answer) ; Show the answer

MsgBox($MB_SYSTEMMODAL, "Step 3", "Close the Instrument connection using _viClose")
_viClose($h_Instr) ; Close the instrument connection


Function _viSetTimeout

Function Reference

_viSetTimeout

Sets the VISA timeout in MILISECONDS

#include <Visa.au3>
_viSetTimeout ( $hSession, $iTimeoutMS )

Parameters

$hSession | A VISA descriptor (STRING) OR a VISA session handle (INTEGER). See the Remarks of the _viExecCommand() for more info.
$iTimeoutMS | The timeout IN MILISECONDS for VISA operations (mainly for GPIB queries) If you set it to 0 the tiemouts are DISABLED. If you set it to "INF" the VISA operations will NEVER timeout. Be careful with this as it could easly hung your program ifv your instrument does not respond to one of your queries. Depending on the bus type (GPIB, TCP, etc) the timeout might not be set to the exact value that you request. Instead the closest valid timeout bigger than the one that you requested will be used.

Return Value

Success: | 0.
Failure: | -1 and sets the @error flag to non-zero if the VISA DLL could not be open or a NON ZERO value representing the VISA error code (see the VISA programmer's guide).

Remarks

Most of the time it is not necessary to call this function, as _viExecCommand() has a third OPTIONAL parameter $iTimeoutMS which can also be used to set the VISA timeout.

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32) and a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) must be installed

* For a detailed description of the most common VISA DESCRIPTORS look at the Remarks of the help on the _viExecCommand() function

Related

_viClose, _viExecCommand, _viOpen, _viSetAttribute

Example

; - This assumes that you have instrument set to GPIB address 3.
; If you have an instrument in a different address change "GPIB::3::0" to the
; corresponding descriptor. Do the same for the call to _viOpen
; It shows how to use the _viExecCommand function with a timeout or how to
; call _viSetTimeout instead.

#include <MsgBoxConstants.au3>
#include <Visa.au3>

Local $h_Session = 0

; Query the ID of the instrument in GPIB address 3
MsgBox($MB_SYSTEMMODAL, "Step 1", "Simple GPIB query with explicit TIMEOUT set")
Local $s_Answer = _viExecCommand("GPIB::3::0", "*IDN?", 10000) ; 10 secs timeout
MsgBox($MB_SYSTEMMODAL, "GPIB QUERY result", $s_Answer) ; Show the answer

; This is the same as using the _viSetTimeout function first:
MsgBox($MB_SYSTEMMODAL, "Step 2", "_vOpen + timeout using _viSetTimeout + GPIB query")
Local $h_Instr = _viOpen(3)
_viSetTimeout($h_Instr, 10000) ; 10000 ms = 10 secs
$s_Answer = _viExecCommand($h_Instr, "*IDN?") ; No need to set the timeout now
MsgBox($MB_SYSTEMMODAL, "GPIB QUERY result", $s_Answer) ; Show the answer

MsgBox($MB_SYSTEMMODAL, "Step 3", "Close the Instrument connection using _viClose")
_viClose($h_Instr) ; Close the instrument connection


User Defined Functions

WinAPI user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPI.au3>.

User Defined Function | Description
_WinAPI_AttachConsole | Attaches the calling process to the console of the specified process
_WinAPI_AttachThreadInput | Attaches the input processing mechanism of one thread to that of another thread
_WinAPI_Beep | Generates simple tones on the speaker
_WinAPI_BitBlt | Performs a bit-block transfer of color data
_WinAPI_CallNextHookEx | Passes the hook information to the next hook procedure in the current hook chain
_WinAPI_CallWindowProc | Passes the hook information to the next hook procedure in the current hook chain
_WinAPI_ClientToScreen | Converts the client coordinates of a specified point to screen coordinates
_WinAPI_CloseHandle | Closes an open object handle
_WinAPI_CombineRgn | Combines two regions and stores the result in a third region
_WinAPI_CommDlgExtendedError | Returns a common dialog box error string. This string indicates the most recent error to occur during the execution of one of the common dialog box functions
_WinAPI_CopyIcon | Copies the specified icon from another module
_WinAPI_CreateBitmap | Creates a bitmap with the specified width, height, and color format
_WinAPI_CreateCompatibleBitmap | Creates a bitmap compatible with the specified device context
_WinAPI_CreateCompatibleDC | Creates a memory device context compatible with the specified device
_WinAPI_CreateEvent | Creates or opens a named or unnamed event object
_WinAPI_CreateFile | Creates or opens a file or other device
_WinAPI_CreateFont | Creates a logical font with the specified characteristics
_WinAPI_CreateFontIndirect | Creates a logical font that has specific characteristics
_WinAPI_CreatePen | Creates a logical pen that has the specified style, width, and color
_WinAPI_CreateProcess | Creates a new process and its primary thread
_WinAPI_CreateRectRgn | Creates a rectangular region
_WinAPI_CreateRoundRectRgn | Creates a rectangular region with rounded corners
_WinAPI_CreateSolidBitmap | Creates a solid color bitmap
_WinAPI_CreateSolidBrush | Creates a logical brush that has the specified solid color
_WinAPI_CreateWindowEx | Creates an overlapped, pop-up, or child window
_WinAPI_DefWindowProc | Call the default window procedure to provide default processing
_WinAPI_DeleteDC | Deletes the specified device context
_WinAPI_DeleteObject | Deletes a logical pen, brush, font, bitmap, region, or palette
_WinAPI_DestroyIcon | Destroys an icon and frees any memory the icon occupied
_WinAPI_DestroyWindow | Destroys the specified window
_WinAPI_DrawEdge | Draws one or more edges of rectangle
_WinAPI_DrawFrameControl | Draws a frame control of the specified type and style
_WinAPI_DrawIcon | Draws an icon or cursor into the specified device context
_WinAPI_DrawIconEx | Draws an icon or cursor into the specified device context
_WinAPI_DrawLine | Draws a line
_WinAPI_DrawText | Draws formatted text in the specified rectangle
_WinAPI_DuplicateHandle | Duplicates an object handle
_WinAPI_EnableWindow | Enables or disables mouse and keyboard input to the specified window or control
_WinAPI_EnumDisplayDevices | Obtains information about the display devices in a system
_WinAPI_EnumWindows | Enumerates all windows
_WinAPI_EnumWindowsPopup | Enumerates popup windows
_WinAPI_EnumWindowsTop | Enumerates all top level windows
_WinAPI_ExpandEnvironmentStrings | Expands environment variable strings and replaces them with their defined values
_WinAPI_ExtractIconEx | Creates an array of handles to large or small icons extracted from a file
_WinAPI_FatalAppExit | Displays a message box and terminates the application
_WinAPI_FillRect | Fills a rectangle by using the specified brush
_WinAPI_FindExecutable | Retrieves the name of the executable file associated with the specified file name
_WinAPI_FindWindow | Retrieves the handle to the top-level window whose class name and window name match
_WinAPI_FlashWindow | Flashes the specified window one time
_WinAPI_FlashWindowEx | Flashes the specified window
_WinAPI_FloatToInt | Returns a 4 byte float as an integer value
_WinAPI_FlushFileBuffers | Flushes the buffers of a specified file and causes all buffered data to be written
_WinAPI_FormatMessage | Formats a message string
_WinAPI_FrameRect | Draws a border around the specified rectangle by using the specified brush
_WinAPI_FreeLibrary | Decrements the reference count of the loaded dynamic-link library (DLL) module
_WinAPI_GetAncestor | Retrieves the handle to the ancestor of the specified window
_WinAPI_GetAsyncKeyState | Determines whether a key is up or down at the time the function is called
_WinAPI_GetBkMode | Returns the current background mix mode for a specified device context
_WinAPI_GetClassName | Retrieves the name of the class to which the specified window belongs
_WinAPI_GetClientHeight | Retrieves the height of a window's client area
_WinAPI_GetClientRect | Retrieves the coordinates of a window's client area
_WinAPI_GetClientWidth | Retrieves the width of a window's client area
_WinAPI_GetCurrentProcess | Returns the process handle of the calling process
_WinAPI_GetCurrentProcessID | Returns the process identifier of the calling process
_WinAPI_GetCurrentThread | Retrieves a pseudo handle for the calling thread
_WinAPI_GetCurrentThreadId | Returns the thread identifier of the calling thread
_WinAPI_GetCursorInfo | Retrieves information about the global cursor
_WinAPI_GetDC | Retrieves a handle of a display device context for the client area a window
_WinAPI_GetDesktopWindow | Returns the handle of the Windows desktop window
_WinAPI_GetDeviceCaps | Retrieves device specific information about a specified device
_WinAPI_GetDIBits | Retrieves the bits of the specified bitmap and copies them into a buffer as a DIB
_WinAPI_GetDlgCtrlID | Returns the identifier of the specified control
_WinAPI_GetDlgItem | Retrieves the handle of a control in the specified dialog box
_WinAPI_GetFileSizeEx | Retrieves the size of the specified file
_WinAPI_GetFocus | Retrieves the handle of the window that has the keyboard focus
_WinAPI_GetForegroundWindow | Returns the handle of the foreground window
_WinAPI_GetGuiResources | Retrieves the count of handles to graphical user interface (GUI) objects in use by the specified process
_WinAPI_GetIconInfo | Retrieves information about the specified icon or cursor
_WinAPI_GetLastError | Returns the calling thread's lasterror code value
_WinAPI_GetLastErrorMessage | Returns the calling threads last error message
_WinAPI_GetLayeredWindowAttributes | Gets Layered Window Attributes
_WinAPI_GetModuleHandle | Returns a module handle for the specified module
_WinAPI_GetMousePos | Returns the current mouse position
_WinAPI_GetMousePosX | Returns the current mouse X position
_WinAPI_GetMousePosY | Returns the current mouse Y position
_WinAPI_GetObject | Retrieves information for the specified graphics object
_WinAPI_GetOpenFileName | Creates an Open dialog box that lets the user specify the drive, directory, and the name of a file or set of files to open
_WinAPI_GetOverlappedResult | Retrieves the results of an overlapped operation
_WinAPI_GetParent | Retrieves the handle of the specified child window's parent window
_WinAPI_GetProcAddress | Retrieves the address of an exported function or variable from the specified module
_WinAPI_GetProcessAffinityMask | Obtains the affinity masks for the process and the system
_WinAPI_GetSaveFileName | Creates a Save dialog box that lets the user specify the drive, directory, and name of a file to save
_WinAPI_GetStdHandle | Retrieves a handle for the standard input, standard output, or standard error device
_WinAPI_GetStockObject | Retrieves a handle to one of the predefined stock pens, brushes, fonts, or palettes
_WinAPI_GetSysColor | Retrieves the current color of the specified display element
_WinAPI_GetSysColorBrush | Retrieves a handle identifying a logical brush that corresponds to the specified color index
_WinAPI_GetSystemMetrics | Retrieves the specified system metric or system configuration setting
_WinAPI_GetTextExtentPoint32 | Computes the width and height of the specified string of text
_WinAPI_GetTextMetrics | Retrieves basic information for the currently selected font
_WinAPI_GetWindow | Retrieves the handle of a window that has a specified relationship to the specified window
_WinAPI_GetWindowDC | Retrieves the device context (DC) for the entire window
_WinAPI_GetWindowHeight | Returns the height of the window
_WinAPI_GetWindowLong | Retrieves information about the specified window
_WinAPI_GetWindowPlacement | Retrieves the placement of the window for Min, Max, and normal positions
_WinAPI_GetWindowRect | Retrieves the dimensions of the bounding rectangle of the specified window
_WinAPI_GetWindowRgn | Obtains a copy of the window region of a window
_WinAPI_GetWindowText | Retrieves the text of the specified window's title bar
_WinAPI_GetWindowThreadProcessId | Retrieves the identifier of the thread that created the specified window
_WinAPI_GetWindowWidth | Returns the width of the window
_WinAPI_GetXYFromPoint | Returns the X/Y values from a $tagPOINT structure
_WinAPI_GlobalMemoryStatus | Retrieves information about current available memory
_WinAPI_GUIDFromString | Converts a string GUID to binary form
_WinAPI_GUIDFromStringEx | Converts a string GUID to binary form
_WinAPI_HiWord | Returns the high word of a longword value
_WinAPI_InProcess | Determines whether a window belongs to the current process
_WinAPI_IntToFloat | Returns a 4 byte integer as a float value
_WinAPI_InvalidateRect | Adds a rectangle to the specified window's update region
_WinAPI_IsClassName | Wrapper to check ClassName of the control
_WinAPI_IsWindow | Determines whether the specified window handle identifies an existing window
_WinAPI_IsWindowVisible | Retrieves the visibility state of the specified window
_WinAPI_LineTo | Draws a line from the current position up to, but not including, the specified point
_WinAPI_LoadBitmap | Loads the specified bitmap resource from a module's executable file
_WinAPI_LoadImage | Loads an icon, cursor, or bitmap
_WinAPI_LoadLibrary | Maps a specified executable module into the address space of the calling process
_WinAPI_LoadLibraryEx | Maps a specified executable module into the address space of the calling process
_WinAPI_LoadShell32Icon | Extracts an icon from the shell32.dll file
_WinAPI_LoadString | loads a string resource from the executable file associated with a specified module
_WinAPI_LocalFree | Frees the specified local memory object and invalidates its handle
_WinAPI_LoWord | Returns the low word of a longword
_WinAPI_MAKELANGID | Construct language id from a primary language id and a sublanguage id
_WinAPI_MAKELCID | Construct locale id from a language id and a sort id
_WinAPI_MakeLong | Returns a long int value from two int values
_WinAPI_MakeQWord | Returns a QWORD value from two int values
_WinAPI_MessageBeep | Plays a waveform sound
_WinAPI_Mouse_Event | Synthesizes mouse motion and button clicks
_WinAPI_MoveTo | Updates the current position to the specified point
_WinAPI_MoveWindow | Changes the position and dimensions of the specified window
_WinAPI_MsgBox | Displays a message box with wider margin than original
_WinAPI_MulDiv | Multiplies two 32-bit values and then divides the 64-bit result by a third 32-bit value
_WinAPI_MultiByteToWideChar | Maps a character string to a wide-character (Unicode) string
_WinAPI_MultiByteToWideCharEx | Maps a character string to a wide-character (Unicode) string
_WinAPI_OpenProcess | Returns a handle of an existing process object
_WinAPI_PathFindOnPath | Searchs for a file in the default system paths
_WinAPI_PointFromRect | Returns the top/left coordinates of a $tagRECT as a $tagPOINT structure
_WinAPI_PostMessage | Places a message in the message queue and then returns
_WinAPI_PrimaryLangId | Extract primary language id from a language id
_WinAPI_PtInRect | Determines whether the specified point lies within the specified rectangle
_WinAPI_ReadFile | Reads data from a file
_WinAPI_ReadProcessMemory | Reads memory in a specified process
_WinAPI_RectIsEmpty | Determins whether a rectangle is empty
_WinAPI_RedrawWindow | Updates the specified rectangle or region in a window's client area
_WinAPI_RegisterWindowMessage | Defines a new window message that is guaranteed to be unique throughout the system
_WinAPI_ReleaseCapture | Releases the mouse capture from a window in the current thread and restores normal mouse input processing
_WinAPI_ReleaseDC | Releases a device context
_WinAPI_ScreenToClient | Converts screen coordinates of a specified point on the screen to client coordinates
_WinAPI_SelectObject | Selects an object into the specified device context
_WinAPI_SetBkColor | Sets the current background color to the specified color value
_WinAPI_SetBkMode | Sets the background mix mode of the specified device context
_WinAPI_SetCapture | Sets the mouse capture to the specified window belonging to the current thread
_WinAPI_SetCursor | Establishes the cursor shape
_WinAPI_SetDefaultPrinter | Sets the default printer for the current user on the local computer
_WinAPI_SetDIBits | Sets the pixels in a compatible bitmap using the color data found in a DIB
_WinAPI_SetEndOfFile | Sets the physical file size for the specified file to the current position of the file pointer
_WinAPI_SetEvent | Sets the specified event object to the signaled state
_WinAPI_SetFilePointer | Moves the file pointer of the specified file
_WinAPI_SetFocus | Sets the keyboard focus to the specified window
_WinAPI_SetFont | Sets a window font
_WinAPI_SetHandleInformation | Sets certain properties of an object handle
_WinAPI_SetLastError | Sets the last-error code for the calling thread
_WinAPI_SetLayeredWindowAttributes | Sets Layered Window Attributes
_WinAPI_SetParent | Changes the parent window of the specified child window
_WinAPI_SetProcessAffinityMask | Sets a processor affinity mask for the threads of a specified process
_WinAPI_SetSysColors | Obtains information about the display devices in a system
_WinAPI_SetTextColor | Sets the current text color to the specified color value
_WinAPI_SetWindowLong | Sets information about the specified window
_WinAPI_SetWindowPlacement | Sets the placement of the window for Min, Max, and normal positions
_WinAPI_SetWindowPos | Changes the size, position, and Z order of a child, pop-up, or top-level window
_WinAPI_SetWindowRgn | Sets the window region of a window
_WinAPI_SetWindowsHookEx | Installs an application-defined hook procedure into a hook chain
_WinAPI_SetWindowText | Changes the text of the specified window's title bar
_WinAPI_ShowCursor | Displays or hides the cursor
_WinAPI_ShowError | Displays an error message box with an optional exit
_WinAPI_ShowMsg | Displays an "Information" message box
_WinAPI_ShowWindow | Sets the specified window's show state
_WinAPI_StringFromGUID | Converts a binary GUID to string form
_WinAPI_StringLenA | Calculates the size of ANSI string
_WinAPI_StringLenW | Calculates the size of wide string
_WinAPI_SubLangId | Extract sublanguage id from a language id
_WinAPI_SystemParametersInfo | Retrieves or sets the value of one of the system-wide parameters
_WinAPI_TwipsPerPixelX | Returns the width of a pixel, in twips
_WinAPI_TwipsPerPixelY | Returns the height of a pixel, in twips
_WinAPI_UnhookWindowsHookEx | Removes a hook procedure installed in a hook chain by the _WinAPI_SetWindowsHookEx function
_WinAPI_UpdateLayeredWindow | Updates the position, size, shape, content, and translucency of a layered window
_WinAPI_UpdateWindow | Updates the client area of a window by sending a WM_PAINT message to the window
_WinAPI_WaitForInputIdle | Waits until a process is waiting for user input with no input pending, or a time out
_WinAPI_WaitForMultipleObjects | Waits until one or all of the specified objects are in the signaled state
_WinAPI_WaitForSingleObject | Waits until the specified object is in the signaled state
_WinAPI_WideCharToMultiByte | Converts a Unicode string to a multibyte string
_WinAPI_WindowFromPoint | Retrieves the handle of the window that contains the specified point
_WinAPI_WriteConsole | Writes a character string to a console screen buffer
_WinAPI_WriteFile | Writes data to a file at the position specified by the file pointer
_WinAPI_WriteProcessMemory | Writes memory in a specified process


Function _WinAPI_AttachConsole

Function Reference

_WinAPI_AttachConsole

Attaches the calling process to the console of the specified process

#include <WinAPI.au3>
_WinAPI_AttachConsole ( [$iPID = -1] )

Parameters

$iPID [optional] Identifier of the process. Set to -1 to attach to the current process.

Return Value

Success: | True
Failure: | False

See Also

Search AttachConsole in MSDN Library.


Function _WinAPI_AttachThreadInput

Function Reference

_WinAPI_AttachThreadInput

Attaches the input processing mechanism of one thread to that of another thread

#include <WinAPI.au3>
_WinAPI_AttachThreadInput ( $iAttach, $iAttachTo, $bAttach )

Parameters

$iAttach | Identifier of the thread to be attached to another thread
$iAttachTo | Identifier of the thread to be attached to
$bAttach | Attachment mode: True - The threads are attached False - The threads are detached

Return Value

Success: | True
Failure: | False

See Also

Search AttachThreadInput in MSDN Library.


Function _WinAPI_Beep

Function Reference

_WinAPI_Beep

Generates simple tones on the speaker

#include <WinAPI.au3>
_WinAPI_Beep ( [$iFreq = 500 [, $iDuration = 1000]] )

Parameters

$iFreq | [optional] The frequency of the sound, in hertz. This parameter must be in the range 37 through 32,767.
$iDuration | [optional] The duration of the sound, in milliseconds. Windows Me/98/95: This parameter is ignored.

Return Value

Success: | True
Failure: | False

Remarks

Muting and volume control have no effect on Beep. You will still hear the tone.

See Also

Search Beep in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $iFreqStart = 100
    Local $iFreqEnd = 250

    MsgBox($MB_SYSTEMMODAL, "_WinAPI_Beep Example", "Ascending")

    For $iFreq = $iFreqStart To $iFreqEnd
        _WinAPI_Beep($iFreq, 100)
        ToolTip("Frequency = " & $iFreq)
    Next

    MsgBox($MB_SYSTEMMODAL, "_WinAPI_Beep Example", "Descending")

    For $iFreq = $iFreqEnd To $iFreqStart Step -1
        _WinAPI_Beep($iFreq, 100)
        ToolTip("Frequency = " & $iFreq)
    Next
EndFunc   ;==>Example


Function _WinAPI_BitBlt

Function Reference

_WinAPI_BitBlt

Performs a bit-block transfer of color data

#include <WinAPI.au3>
_WinAPI_BitBlt ( $hDestDC, $iXDest, $iYDest, $iWidth, $iHeight, $hSrcDC, $iXSrc, $iYSrc, $iROP )

Parameters

$hDestDC | Handle to the destination device context
$iXDest | X value of the upper-left corner of the destination rectangle
$iYDest | Y value of the upper-left corner of the destination rectangle
$iWidth | Width of the source and destination rectangles
$iHeight | Height of the source and destination rectangles
$hSrcDC | Handle to the source device context
$iXSrc | X value of the upper-left corner of the source rectangle
$iYSrc | Y value of the upper-left corner of the source rectangle
$iROP Specifies a raster operation code. These codes define how the color data for the source rectangle is to be combined with the color data for the destination rectangle to achieve the final color:
$BLACKNESS - Fills the destination rectangle using the color associated with palette index 0
$CAPTUREBLT - Includes any window that are layered on top of your window in the resulting image
$DSTINVERT - Inverts the destination rectangle
$MERGECOPY - Merges the color of the source rectangle with the brush currently selected in hDest, by using the AND operator.
$MERGEPAINT - Merges the color of the inverted source rectangle with the colors of the destination rectangle by using the OR operator.
$NOMIRRORBITMAP - Prevents the bitmap from being mirrored
$NOTSRCCOPY - Copies the inverted source rectangle to the destination
$NOTSRCERASE - Combines the colors of the source and destination rectangles by using the OR operator and then inverts the resultant color.
$PATCOPY - Copies the brush selected in hdcDest, into the destination bitmap
$PATINVERT - Combines the colors of the brush currently selected in hDest, with the colors of the destination rectangle by using the XOR operator.
$PATPAINT - Combines the colors of the brush currently selected in hDest, with the colors of the inverted source rectangle by using the OR operator. The result of this operation is combined with the color of the destination rectangle by using the OR operator.
$SRCAND - Combines the colors of the source and destination rectangles by using the AND operator
$SRCCOPY - Copies the source rectangle directly to the destination rectangle
$SRCERASE - Combines the inverted color of the destination rectangle with the colors of the source rectangle by using the AND operator.
$SRCINVERT - Combines the colors of the source and destination rectangles by using the XOR operator
$SRCPAINT - Combines the colors of the source and destination rectangles by using the OR operator
$WHITENESS - Fills the destination rectangle using the color associated with index 1 in the physical palette.

Return Value

Success: | True
Failure: | False

See Also

Search BitBlt in MSDN Library.

Example

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

Global $g_hGUI, $g_hHBITMAP, $g_hDC, $g_hDC_Backbuffer, $g_oDC_Obj, $g_hGfxCtxt, $g_hPen

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    _GDIPlus_Startup() ;initialize GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x202020 ;$iBGColor format RRGGBB

    $g_hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $g_hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    ;create a faster buffered graphics frame set for smoother gfx object movements
    Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) ;create an empty bitmap
    $g_hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ;convert GDI+ bitmap to GDI bitmap
    _GDIPlus_BitmapDispose($hBitmap) ;delete GDI+ bitmap because not needed anymore

    $g_hDC = _WinAPI_GetDC($g_hGUI) ;get device context from GUI
    $g_hDC_Backbuffer = _WinAPI_CreateCompatibleDC($g_hDC) ;creates a memory device context compatible with the specified device
    $g_oDC_Obj = _WinAPI_SelectObject($g_hDC_Backbuffer, $g_hHBITMAP) ;selects an object into the specified device context
    $g_hGfxCtxt = _GDIPlus_GraphicsCreateFromHDC($g_hDC_Backbuffer) ;create a graphics object from a device context (DC)
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;set smoothing mode (8 X 4 box filter)
    _GDIPlus_GraphicsSetPixelOffsetMode($g_hGfxCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)

    $g_hPen = _GDIPlus_PenCreate() ;create a pen object

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

    Local Const $fDeg = ACos(-1) / 180 ;ACos(-1) is nearly pi
    Local $iX_Center = $iWidth / 2, $iY_Center = $iHeight / 2, $iXPos, $iYPos, $fAngle = 0, $iRound = 0
    Local Const $iDots = 7, $fAngelDist = 360 / $iDots, $iRadius = 250
    Local $aCoordinates[$iDots][2] ;create an array to save coordinates of the x/y coordinates
    Do
        _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ;clear bitmap with given color (AARRGGBB format)
        For $i = 0 To $iDots - 1
            $iXPos = $iX_Center + Cos($fAngle * $fDeg) * $iRadius ;calculate x position
            $iYPos = $iY_Center + Sin($fAngle * $fDeg) * $iRadius ;calculate y position
            $aCoordinates[$i][0] = $iXPos
            $aCoordinates[$i][1] = $iYPos
            _GDIPlus_PenSetColor($g_hPen, 0xFFFFFF00) ;set pen color for inner lines
            _GDIPlus_PenSetWidth($g_hPen, 2) ;set pen size for outer lines
            _GDIPlus_GraphicsDrawLine($g_hGfxCtxt, $aCoordinates[$i][0], $aCoordinates[$i][1], _ ;draw inner lines
                    $aCoordinates[Mod(($i + $iDots / 2), $iDots)][0], $aCoordinates[Mod(($i + $iDots / 2), $iDots)][1], $g_hPen) ;draw to opposite side
            _GDIPlus_PenSetColor($g_hPen, 0xFFFF8000) ;set pen color
            _GDIPlus_PenSetWidth($g_hPen, 3) ;set pen size
            ;array of coordinates should be filled before first draw to screen
            If $i < $iDots - 1 Then _GDIPlus_GraphicsDrawLine($g_hGfxCtxt, $aCoordinates[$i][0], $aCoordinates[$i][1], $aCoordinates[$i + 1][0], $aCoordinates[$i + 1][1], $g_hPen) ;;draw outer lines
            $fAngle += $fAngelDist ;increase angle to next dot
        Next
        ;draw last line to 1st line
        _GDIPlus_GraphicsDrawLine($g_hGfxCtxt, $aCoordinates[$i - 1][0], $aCoordinates[$i - 1][1], $aCoordinates[0][0], $aCoordinates[0][1], $g_hPen)

        If $iRound Then _WinAPI_BitBlt($g_hDC, 0, 0, $iWidth, $iHeight, $g_hDC_Backbuffer, 0, 0, $SRCCOPY) ;copy backbuffer to screen (GUI)
        $fAngle -= 0.5 ;decrease overall angle
        $iRound += 1
    Until Not Sleep(30) ;Sleep() always returns 1 and Not 1 is 0 correspond to False

    _Exit()
EndFunc   ;==>Example

Func _Exit() ;cleanup GDI+ resources
    _GDIPlus_PenDispose($g_hPen)
    _WinAPI_SelectObject($g_hDC_Backbuffer, $g_oDC_Obj)
    _GDIPlus_GraphicsDispose($g_hGfxCtxt)
    _WinAPI_DeleteObject($g_hHBITMAP)
    _WinAPI_ReleaseDC($g_hGUI, $g_hDC)
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit


Function _WinAPI_CallNextHookEx

Function Reference

_WinAPI_CallNextHookEx

Passes the hook information to the next hook procedure in the current hook chain

#include <WinAPI.au3>
_WinAPI_CallNextHookEx ( $hHook, $iCode, $wParam, $lParam )

Parameters

$hHook | Parameter ignored.
$iCode | Specifies the hook code passed to the current hook procedure. The next hook procedure uses this code to determine how to process the hook information
$wParam | Specifies the wParam value passed to the current hook procedure. The meaning of this parameter depends on the type of hook associated with the current hook chain
$lParam | Specifies the lParam value passed to the current hook procedure. The meaning of this parameter depends on the type of hook associated with the current hook chain

Return Value

Returned by the next hook procedure in the chain.

Related

$tagKBDLLHOOKSTRUCT, _WinAPI_SetWindowsHookEx

See Also

Search CallNextHookEx in MSDN Library.


Function _WinAPI_CallWindowProc

Function Reference

_WinAPI_CallWindowProc

Passes the hook information to the next hook procedure in the current hook chain

#include <WinAPI.au3>
_WinAPI_CallWindowProc ( $pPrevWndFunc, $hWnd, $iMsg, $wParam, $lParam )

Parameters

$pPrevWndFunc | Pointer to the previous window procedure. If this value is obtained by calling the _WinAPI_GetWindowLong() function with the $iIndex parameter set to $GWL_WNDPROC or $DWL_DLGPROC, it is actually either the address of a window or dialog box procedure, or a special internal value meaningful only to _WinAPI_CallWindowProc().
$hWnd | Handle to the window procedure to receive the message
$iMsg | Specifies the message
$wParam | Specifies additional message-specific information. The contents of this parameter depend on the value of the Msg parameter
$lParam | Specifies additional message-specific information. The contents of this parameter depend on the value of the Msg parameter

Return Value

Returns the return value specifies the result of the message processing and depends on the message sent

Remarks

Use the _WinAPI_CallWindowProc() function for window subclassing. Usually, all windows with the same class share one window procedure.
A subclass is a window or set of windows with the same class whose messages are intercepted and processed by another window procedure (or procedures) before being passed to the window procedure of the class.

The _WinAPI_SetWindowLong() function creates the subclass by changing the window procedure associated with a particular window, causing the system to call the new window procedure instead of the previous one.
An application must pass any messages not processed by the new window procedure to the previous window procedure by calling _WinAPI_CallWindowProc().
This allows the application to create a chain of window procedures.

Related

_WinAPI_SetWindowLong

See Also

Search CallWindowProc in MSDN Library.

Example

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

Global $g_idContextMenu, $g_idCommonMenuItem, $g_idFileMenuItem, $g_idExitMenuItem
Global $g_hGui, $g_idInput, $g_hProcOld

Example()

Func Example()
    Local $idInput2, $hProcNew, $idDummyMenu

    $g_hGui = GUICreate("Type or paste some stuff", 400, 200, -1, -1, $WS_THICKFRAME, -1)
    $g_idInput = GUICtrlCreateInput("", 20, 20, 360, 20)
    $idInput2 = GUICtrlCreateInput("", 20, 50, 360, 20)

    GUICtrlCreateLabel("abcd", 1, 1, 30, 18)
    GUICtrlSetCursor(-1, 9)

    $hProcNew = DllCallbackRegister("_MyWindowProc", "ptr", "hwnd;uint;long;ptr")
    $g_hProcOld = _WinAPI_SetWindowLong(GUICtrlGetHandle($g_idInput), $GWL_WNDPROC, DllCallbackGetPtr($hProcNew))
    _WinAPI_SetWindowLong(GUICtrlGetHandle($idInput2), $GWL_WNDPROC, DllCallbackGetPtr($hProcNew))
    ;_WinAPI_SetWindowLong(GUICtrlGetHandle($g_idInput3), $GWL_WNDPROC, DllCallbackGetPtr($hProcNew)) and so on

    $idDummyMenu = GUICtrlCreateDummy()
    $g_idContextMenu = GUICtrlCreateContextMenu($idDummyMenu)
    $g_idCommonMenuItem = GUICtrlCreateMenuItem("Common", $g_idContextMenu)
    $g_idFileMenuItem = GUICtrlCreateMenuItem("File", $g_idContextMenu)
    GUICtrlCreateMenuItem("", $g_idContextMenu)
    $g_idExitMenuItem = GUICtrlCreateMenuItem("Exit", $g_idContextMenu)

    GUISetState(@SW_SHOW)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func do_clever_stuff_with_clipboard($hWnd)
    Local $sData
    $sData = ClipGet()
    If @error Then Return 0;clip data is not text or clip empty
    ;do whatever
    $sData = StringUpper($sData)
    ;set text
    GUICtrlSetData(_WinAPI_GetDlgCtrlID($hWnd), $sData);or _GUICtrlEdit_SetText($hWnd, $sData)
    Return 1
EndFunc   ;==>do_clever_stuff_with_clipboard

; Show a menu in a given GUI window which belongs to a given GUI ctrl
Func ShowMenu($hWnd, $idContext)
    Local $iSelected = _GUICtrlMenu_TrackPopupMenu(GUICtrlGetHandle($idContext), $hWnd, -1, -1, -1, -1, 2)
    Switch $iSelected
        Case $g_idCommonMenuItem
            ConsoleWrite("Common" & @CRLF)
        Case $g_idFileMenuItem
            ConsoleWrite("File" & @CRLF)
        Case $g_idExitMenuItem
            ConsoleWrite("Exit" & @CRLF)
    EndSwitch
EndFunc   ;==>ShowMenu

Func _MyWindowProc($hWnd, $iMsg, $wParam, $lParam)
    Switch $iMsg
        Case $WM_PASTE
            Return do_clever_stuff_with_clipboard($hWnd)
        Case $WM_CONTEXTMENU
            If $hWnd = GUICtrlGetHandle($g_idInput) Then
                ShowMenu($g_hGui, $g_idContextMenu)
                Return 0
            EndIf
        Case $WM_SETCURSOR
            GUICtrlSetCursor(_WinAPI_GetDlgCtrlID($hWnd), 5);;set Ibeam cursor
            Return 1;;and don't let default windowproc mess things up
    EndSwitch

    ;pass the unhandled messages to default WindowProc
    Return _WinAPI_CallWindowProc($g_hProcOld, $hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_MyWindowProc


Function _WinAPI_ClientToScreen

Function Reference

_WinAPI_ClientToScreen

Converts the client coordinates of a specified point to screen coordinates

#include <WinAPI.au3>
_WinAPI_ClientToScreen ( $hWnd, ByRef $tPoint )

Parameters

$hWnd | Identifies the window that will be used for the conversion
$tPoint | $tagPOINT structure that contains the client coordinates to be converted

Return Value

Success: | a $tagPOINT.
Failure: | sets the @error flag to non-zero.

Remarks

The function replaces the client coordinates in the $tagPOINT structure with the screen coordinates.
The screen coordinates are relative to the upper-left corner of the screen.

Related

$tagPOINT, _WinAPI_ScreenToClient

See Also

Search ClientToScreen in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hWnd = GUICreate("Example", 200, 200)
    Local $tPoint = DllStructCreate("int X;int Y")
    DllStructSetData($tPoint, "X", 100)
    DllStructSetData($tPoint, "Y", 160)
    GUISetState(@SW_SHOW)
    Sleep(1000)
    _WinAPI_ClientToScreen($hWnd, $tPoint)
    MsgBox($MB_SYSTEMMODAL, "_WinAPI_ClientToScreen Example", "Screen Cordinates of client's x,y position: 100,160 is: " & @CRLF & _
            "X: " & DllStructGetData($tPoint, "X") & @CRLF & _
            "Y: " & DllStructGetData($tPoint, "Y") & @CRLF)
EndFunc   ;==>Example


Function _WinAPI_CloseHandle

Function Reference

_WinAPI_CloseHandle

Closes an open object handle

#include <WinAPI.au3>
_WinAPI_CloseHandle ( $hObject )

Parameters

$hObject Handle of object to close

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Related

_WinAPI_CreateFile, _WinAPI_FlushFileBuffers, _WinAPI_GetFileSizeEx, _WinAPI_ReadFile, _WinAPI_SetEndOfFile, _WinAPI_SetFilePointer, _WinAPI_WriteFile

See Also

Search CloseHandle in MSDN Library.

Example

#include <WinAPI.au3>

Local $sTempFile, $hFile, $sText, $nBytes, $tBuffer, $iSize

; 1) create file and write data to it
$sTempFile = @TempDir & '\test.txt'
$sText = 'abcdefghijklmnopqrstuvwxyz'
$tBuffer = DllStructCreate("byte[" & StringLen($sText) & "]")
DllStructSetData($tBuffer, 1, $sText)
$hFile = _WinAPI_CreateFile($sTempFile, 1)
_WinAPI_WriteFile($hFile, $tBuffer, StringLen($sText), $nBytes)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_CloseHandle($hFile)
ConsoleWrite('1):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

; 2) read 6 bytes from position 3
$tBuffer = DllStructCreate("byte[6]")
$hFile = _WinAPI_CreateFile($sTempFile, 2, 2)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_SetFilePointer($hFile, 3)
_WinAPI_ReadFile($hFile, $tBuffer, 6, $nBytes)
_WinAPI_CloseHandle($hFile)
$sText = BinaryToString(DllStructGetData($tBuffer, 1))
ConsoleWrite('2):' & $iSize & ' ' & $sText & @CRLF)

; 3) write previously read 6 bytes from position 3 to the same position but in UpperCase
DllStructSetData($tBuffer, 1, StringUpper($sText))
$hFile = _WinAPI_CreateFile($sTempFile, 2, 4)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_SetFilePointer($hFile, 3)
_WinAPI_WriteFile($hFile, $tBuffer, 6, $nBytes)
_WinAPI_CloseHandle($hFile)
$tBuffer = 0
ConsoleWrite('3):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

; 4) truncate file size to 12 bytes
$hFile = _WinAPI_CreateFile($sTempFile, 2, 4)
_WinAPI_SetFilePointer($hFile, 12)
_WinAPI_SetEndOfFile($hFile)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_CloseHandle($hFile)
ConsoleWrite('4):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

FileDelete($sTempFile)


Function _WinAPI_CombineRgn

Function Reference

_WinAPI_CombineRgn

Combines two regions and stores the result in a third region

#include <WinAPI.au3>
_WinAPI_CombineRgn ( $hRgnDest, $hRgnSrc1, $hRgnSrc2, $iCombineMode )

Parameters

$hRgnDest | Handle to a new region with dimensions defined by combining two other regions. (This region must exist before CombineRgn is called.)
$hRgnSrc1 | Handle to the first of two regions to be combined.
$hRgnSrc2 | Handle to the second of two regions to be combined.
$iCombineMode | Specifies a mode indicating how the two regions will be combined. This parameter can be one of the following values. $RGN_AND - Creates the intersection of the two combined regions. $RGN_COPY - Creates a copy of the region identified by $hRgnSrc1. $RGN_DIFF - Combines the parts of $hRgnSrc1 that are not part of $hRgnSrc2. $RGN_OR - Creates the union of two combined regions. $RGN_XOR - Creates the union of two combined regions except for any overlapping areas.

Return Value

Success: | Specifies the type of the resulting region. It can be one of the following values. $NULLREGION - The region is empty. $SIMPLEREGION - The region is a single rectangle. $COMPLEXREGION - The region is more than a single rectangle.
Failure: | 0 - No region is created.

Remarks

The two regions are combined according to the specified mode.
The three regions need not be distinct. For example, the $hRgnSrc1 parameter can equal the $hRgnDest parameter.

Related

_WinAPI_CreateRectRgn, _WinAPI_CreateRoundRectRgn, _WinAPI_GetWindowRgn, _WinAPI_SetWindowRgn

See Also

Search CombineRgn in MSDN Library.

Example

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

; get height of window title and width of window frame - may be different when XP theme is ON/OFF
Global $g_iHtit = _WinAPI_GetSystemMetrics($SM_CYCAPTION)
Global $g_iFrame = _WinAPI_GetSystemMetrics($SM_CXDLGFRAME)

Global $g_hGui = GUICreate("Test Windows regions", 350, 210)
Local $id_Default = GUICtrlCreateButton("Default region", 100, 30, 150)
Local $id_Round = GUICtrlCreateButton("Round region", 100, 60, 150)
Local $id_Buble = GUICtrlCreateButton("Buble region ", 100, 90, 150)
Local $id_Transparent = GUICtrlCreateButton("Transparent region", 100, 120, 150)
Local $id_Exit = GUICtrlCreateButton("Exit", 100, 150, 150)
GUISetState(@SW_SHOW)

Local $aPos = WinGetPos($g_hGui) ; get whole window size (no client size defined in GUICreate)
Global $g_iWidth = $aPos[2]
Global $g_iHeight = $aPos[3]

Local $iMsg, $hRgn
While 1
    $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE Or $iMsg = $id_Exit
            ExitLoop

        Case $iMsg = $id_Default
            $hRgn = _WinAPI_CreateRectRgn(0, 0, $g_iWidth, $g_iHeight)
            _WinAPI_SetWindowRgn($g_hGui, $hRgn)

        Case $iMsg = $id_Round
            $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $g_iWidth, $g_iHeight, $g_iWidth / 3, $g_iHeight / 3)
            _WinAPI_SetWindowRgn($g_hGui, $hRgn)

        Case $iMsg = $id_Buble
            Local $hRgn1 = _WinAPI_CreateRoundRectRgn(0, 0, $g_iWidth / 2, $g_iHeight / 2, $g_iWidth / 2, $g_iHeight / 2) ; left-top
            Local $hRgn2 = _WinAPI_CreateRoundRectRgn($g_iWidth / 2, 0, $g_iWidth, $g_iHeight / 2, $g_iWidth / 2, $g_iHeight / 2) ; right-top
            _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR)
            _WinAPI_DeleteObject($hRgn2)
            $hRgn2 = _WinAPI_CreateRoundRectRgn(0, $g_iHeight / 2, $g_iWidth / 2, $g_iHeight, $g_iWidth / 2, $g_iHeight / 2) ; left-bottom
            _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR)
            _WinAPI_DeleteObject($hRgn2)
            $hRgn2 = _WinAPI_CreateRoundRectRgn($g_iWidth / 2, $g_iHeight / 2, $g_iWidth, $g_iHeight, $g_iWidth / 2, $g_iHeight / 2) ; right-bottom
            _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR)
            _WinAPI_DeleteObject($hRgn2)
            $hRgn2 = _WinAPI_CreateRoundRectRgn(10, 10, $g_iWidth - 10, $g_iHeight - 10, $g_iWidth, $g_iHeight) ; middle
            _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR)
            _WinAPI_DeleteObject($hRgn2)
            _WinAPI_SetWindowRgn($g_hGui, $hRgn1)

        Case $iMsg = $id_Transparent
            _GuiHole($g_hGui, 40, 40, 260, 170)

    EndSelect
WEnd

; make inner transparent area but add controls
Func _GuiHole($hWin, $iX, $iY, $iSizeW, $iSizeH)
    Local $hOuter_rgn, $hInner_rgn, $hCombined_rgn

    $hOuter_rgn = _WinAPI_CreateRectRgn(0, 0, $g_iWidth, $g_iHeight)
    $hInner_rgn = _WinAPI_CreateRectRgn($iX, $iY, $iX + $iSizeW, $iY + $iSizeH)
    $hCombined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0)
    _WinAPI_CombineRgn($hCombined_rgn, $hOuter_rgn, $hInner_rgn, $RGN_DIFF)
    _WinAPI_DeleteObject($hOuter_rgn)
    _WinAPI_DeleteObject($hInner_rgn)
    _AddCtrlRegion($hCombined_rgn, $id_Default)
    _AddCtrlRegion($hCombined_rgn, $id_Round)
    _AddCtrlRegion($hCombined_rgn, $id_Buble)
    _AddCtrlRegion($hCombined_rgn, $id_Transparent)
    _AddCtrlRegion($hCombined_rgn, $id_Exit)
    _WinAPI_SetWindowRgn($hWin, $hCombined_rgn)
EndFunc   ;==>_GuiHole

; add control's area to given region
; respecting also window title/frame sizes
Func _AddCtrlRegion($hFull_rgn, $idCtrl)
    Local $aCtrl_pos, $hCtrl_rgn

    $aCtrl_pos = ControlGetPos($g_hGui, "", $idCtrl)
    $hCtrl_rgn = _WinAPI_CreateRectRgn($aCtrl_pos[0] + $g_iFrame, $aCtrl_pos[1] + $g_iHtit + $g_iFrame, _
            $aCtrl_pos[0] + $aCtrl_pos[2] + $g_iFrame, $aCtrl_pos[1] + $aCtrl_pos[3] + $g_iHtit + $g_iFrame)
    _WinAPI_CombineRgn($hFull_rgn, $hFull_rgn, $hCtrl_rgn, $RGN_OR)
    _WinAPI_DeleteObject($hCtrl_rgn)
EndFunc   ;==>_AddCtrlRegion


Function _WinAPI_CommDlgExtendedError

Function Reference

_WinAPI_CommDlgExtendedError

Returns a common dialog box error string. This string indicates the most recent error to occur during the execution of one of the common dialog box functions

#include <WinAPI.au3>
_WinAPI_CommDlgExtendedError ( )

Return Value

Success: | An error string
Failure: | An hexa string of the extended error

Remarks

Can return general error strings for any of the common dialog box functions.

Related

_WinAPI_GetOpenFileName, _WinAPI_GetSaveFileName

See Also

Search CommDlgExtendedError in MSDN Library.


Function _WinAPI_CopyIcon

Function Reference

_WinAPI_CopyIcon

Copies the specified icon from another module

#include <WinAPI.au3>
_WinAPI_CopyIcon ( $hIcon )

Parameters

$hIcon Handle to the icon to be copied

Return Value

Success: | The handle to the duplicate icon
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

Remarks

The CopyIcon function enables an application or DLL to get its own handle to an icon owned by another module.
If the other module is freed, the application icon will still be able to use the icon.
Before closing, call the _WinAPI_DestroyIcon() function to free any system resources associated with the icon.

Related

_WinAPI_DestroyIcon

See Also

Search CopyIcon in MSDN Library.


Function _WinAPI_CreateBitmap

Function Reference

_WinAPI_CreateBitmap

Creates a bitmap with the specified width, height, and color format

#include <WinAPI.au3>
_WinAPI_CreateBitmap ( $iWidth, $iHeight [, $iPlanes = 1 [, $iBitsPerPel = 1 [, $pBits = 0]]] )

Parameters

$iWidth | Specifies the bitmap width, in pixels
$iHeight | Specifies the bitmap height, in pixels
$iPlanes | [optional] Specifies the number of color planes used by the device
$iBitsPerPel | [optional] Specifies the number of bits required to identify the color of a single pixel
$pBits | [optional] Pointer to an array of color data used to set the colors in a rectangle of pixels. Each scan line in the rectangle must be word aligned (scan lines that are not word aligned must be padded with zeros). If this parameter is 0, the contents of the new bitmap is undefined.

Return Value

Success: | the handle to a bitmap.
Failure: | 0.

See Also

Search CreateBitmap in MSDN Library.


Function _WinAPI_CreateCompatibleBitmap

Function Reference

_WinAPI_CreateCompatibleBitmap

Creates a bitmap compatible with the specified device context

#include <WinAPI.au3>
_WinAPI_CreateCompatibleBitmap ( $hDC, $iWidth, $iHeight )

Parameters

$hDC | Identifies a device context
$iWidth | Specifies the bitmap width, in pixels
$iHeight | Specifies the bitmap height, in pixels

Return Value

Success: | The handle to the bitmap
Failure: | 0

Remarks

When you no longer need the bitmap, call the _WinAPI_DeleteObject() function to delete it

Related

_WinAPI_CreateSolidBitmap, _WinAPI_DeleteObject

See Also

Search CreateCompatibleBitmap in MSDN Library.


Function _WinAPI_CreateCompatibleDC

Function Reference

_WinAPI_CreateCompatibleDC

Creates a memory device context compatible with the specified device

#include <WinAPI.au3>
_WinAPI_CreateCompatibleDC ( $hDC )

Parameters

$hDC Handle to an existing DC. If this handle is 0, the function creates a memory DC compatible with the application's current screen.

Return Value

Success: | Handle to a memory DC
Failure: | 0

Remarks

When you no longer need the memory DC, call the _WinAPI_DeleteDC() function

Related

_WinAPI_DeleteDC

See Also

Search CreateCompatibleDC in MSDN Library.


Function _WinAPI_CreateEvent

Function Reference

_WinAPI_CreateEvent

Creates or opens a named or unnamed event object

#include <WinAPI.au3>
_WinAPI_CreateEvent ( [$tAttributes = 0 [, $bManualReset = True [, $bInitialState = True [, $sName = ""]]]] )

Parameters

$tAttributes | [optional] a $tagSECURITY_ATTRIBUTES structure or a pointer to it. If 0, the handle cannot be inherited by child processes. The Descriptor member of the structure specifies a security descriptor for the new event. If $tAttributes is 0, the event gets a default security descriptor. The ACLs in the default security descriptor for an event come from the primary or impersonation token of the creator.
$bManualReset | [optional] If True, the function creates a manual-reset event object, which requires the use of the ResetEvent function to set the event state to nonsignaled. If False, the function creates an auto-reset event object and system automatically resets the event state to nonsignaled after a single waiting thread has been released.
$bInitialState | [optional] If True, the initial state of the event object is signaled; otherwise, it is nonsignaled
$sName | [optional] The name of the event object. Name comparison is case sensitive. If $sName matches the name of an existing named event object, this function requests the EVENT_ALL_ACCESS access right. In this case the $bManualReset and $bInitialState parameters are ignored because they have already been set by the creating process. If the $tAttributes parameter is not 0, it determines whether the handle can be inherited, but its security-descriptor member is ignored. If Name is blank, the event object is created without a name.

Return Value

Success: | The handle to the event object. If the named event object existed before the function call the function returns a handle to the existing object and GetLastError returns ERROR_ALREADY_EXISTS.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

Related

$tagSECURITY_ATTRIBUTES

See Also

Search CreateEvent in MSDN Library.

Example

#include <WinAPI.au3>
#include <WinAPIProc.au3> ;needed for _WinAPI_ResetEvent()

Global $g_tEvents = DllStructCreate("handle Event[3];")
$g_tEvents.Event(1) = _WinAPI_CreateEvent(0, True, False)
$g_tEvents.Event(2) = _WinAPI_CreateEvent(0, True, False)
$g_tEvents.Event(3) = _WinAPI_CreateEvent(0, True, False)

HotKeySet("{ESC}", "_Exit")
AdlibRegister("_FireEvent_1", 500)
AdlibRegister("_FireEvent_2", 800)

Local $iEvent
While 1
    $iEvent = _WinAPI_WaitForMultipleObjects(3, $g_tEvents, False, 100)
    Switch $iEvent
        Case 0
            ConsoleWrite("+ First Event" & @CRLF)
            _WinAPI_ResetEvent($g_tEvents.Event(1))
        Case 1
            ConsoleWrite("> Second Event" & @CRLF)
            _WinAPI_ResetEvent($g_tEvents.Event(2))
        Case 2
            ConsoleWrite("! Exit Event" & @CRLF)
            AdlibUnRegister("_FireEvent_1")
            AdlibUnRegister("_FireEvent_2")
            _WinAPI_CloseHandle($g_tEvents.Event(1))
            _WinAPI_CloseHandle($g_tEvents.Event(2))
            _WinAPI_CloseHandle($g_tEvents.Event(3))
            ExitLoop
        Case -1 ;Error
            ExitLoop
    EndSwitch
WEnd

Func _Exit()
    _WinAPI_SetEvent($g_tEvents.Event(3))
EndFunc   ;==>_Exit

Func _FireEvent_1()
    _WinAPI_SetEvent($g_tEvents.Event(1))
EndFunc   ;==>_FireEvent_1

Func _FireEvent_2()
    _WinAPI_SetEvent($g_tEvents.Event(2))
EndFunc   ;==>_FireEvent_2


Function _WinAPI_CreateFile

Function Reference

_WinAPI_CreateFile

Creates or opens a file or other device

#include <WinAPI.au3>
_WinAPI_CreateFile ( $sFileName, $iCreation [, $iAccess = 4 [, $iShare = 0 [, $iAttributes = 0 [, $tSecurity = 0]]]] )

Parameters

$sFileName | Name of an object to create or open
$iCreation | Action to take on files that exist and do not exist: 0 - Creates a new file. The function fails if the file exists 1 - Creates a new file. If a file exists, it is overwritten 2 - Opens a file. The function fails if the file does not exist 3 - Opens a file. If the file does not exist, the function creates the file 4 - Opens a file and truncates it so that its size is 0 bytes. The function fails if the file does not exist.
$iAccess | [optional] Access to the object: 1 - Execute 2 - Read 4 - Write
$iShare | [optional] Sharing mode of an object: 1 - Delete 2 - Read 4 - Write
$iAttributes | [optional] The file attributes: 1 - File should be archived 2 - File is hidden 4 - File is read only 8 - File is part of or used exclusively by an operating system.
$tSecurity | [optional] a $tagSECURITY_ATTRIBUTES structure or a pointer to it that determines if the returned handle can be inherited by child processes. If $tSecurity is 0, the handle cannot be inherited.

Return Value

Success: | The open handle to a specified file
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

Related

$tagSECURITY_ATTRIBUTES, _WinAPI_CloseHandle, _WinAPI_FlushFileBuffers, _WinAPI_GetFileSizeEx, _WinAPI_ReadFile, _WinAPI_SetEndOfFile, _WinAPI_SetFilePointer, _WinAPI_WriteFile

See Also

Search CreateFile in MSDN Library.

Example

#include <WinAPI.au3>

Local $sTempFile, $hFile, $sText, $nBytes, $tBuffer, $iSize

; 1) create file and write data to it
$sTempFile = @TempDir & '\test.txt'
$sText = 'abcdefghijklmnopqrstuvwxyz'
$tBuffer = DllStructCreate("byte[" & StringLen($sText) & "]")
DllStructSetData($tBuffer, 1, $sText)
$hFile = _WinAPI_CreateFile($sTempFile, 1)
_WinAPI_WriteFile($hFile, $tBuffer, StringLen($sText), $nBytes)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_CloseHandle($hFile)
ConsoleWrite('1):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

; 2) read 6 bytes from position 3
$tBuffer = DllStructCreate("byte[6]")
$hFile = _WinAPI_CreateFile($sTempFile, 2, 2)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_SetFilePointer($hFile, 3)
_WinAPI_ReadFile($hFile, $tBuffer, 6, $nBytes)
_WinAPI_CloseHandle($hFile)
$sText = BinaryToString(DllStructGetData($tBuffer, 1))
ConsoleWrite('2):' & $iSize & ' ' & $sText & @CRLF)

; 3) write previously read 6 bytes from position 3 to the same position but in UpperCase
DllStructSetData($tBuffer, 1, StringUpper($sText))
$hFile = _WinAPI_CreateFile($sTempFile, 2, 4)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_SetFilePointer($hFile, 3)
_WinAPI_WriteFile($hFile, $tBuffer, 6, $nBytes)
_WinAPI_CloseHandle($hFile)
$tBuffer = 0
ConsoleWrite('3):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

; 4) truncate file size to 12 bytes
$hFile = _WinAPI_CreateFile($sTempFile, 2, 4)
_WinAPI_SetFilePointer($hFile, 12)
_WinAPI_SetEndOfFile($hFile)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_CloseHandle($hFile)
ConsoleWrite('4):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

FileDelete($sTempFile)


Function _WinAPI_CreateFont

Function Reference

_WinAPI_CreateFont

Creates a logical font with the specified characteristics

#include <WinAPI.au3>
_WinAPI_CreateFont ( $iHeight, $iWidth [, $iEscape = 0 [, $iOrientn = 0 [, $iWeight = $FW_NORMAL [, $bItalic = False [, $bUnderline = False [, $bStrikeout = False [, $iCharset = $DEFAULT_CHARSET [, $iOutputPrec = $OUT_DEFAULT_PRECIS [, $iClipPrec = $CLIP_DEFAULT_PRECIS [, $iQuality = $DEFAULT_QUALITY [, $iPitch = 0 [, $sFace = 'Arial']]]]]]]]]]]] )

Parameters

$iHeight | height of font
$iWidth | average character width
$iEscape | [optional] angle of escapement
$iOrientn | [optional] base-line orientation angle
$iWeight [optional] font weight, The following values are defined for convenience:
$FW_DONTCARE - 0
$FW_THIN - 100
$FW_EXTRALIGHT - 200
$FW_LIGHT - 300
$FW_NORMAL - 400
$FW_MEDIUM - 500
$FW_SEMIBOLD - 600
$FW_BOLD - 700
$FW_EXTRABOLD - 800
$FW_HEAVY - 900
$bItalic | [optional] italic attribute option
$bUnderline | [optional] underline attribute option
$bStrikeout | [optional] strikeout attribute option
$iCharset [optional] Specifies the character set. The following values are predefined:
$ANSI_CHARSET - 0
$BALTIC_CHARSET - 186
$CHINESEBIG5_CHARSET - 136
$DEFAULT_CHARSET - 1
$EASTEUROPE_CHARSET - 238
$GB2312_CHARSET - 134
$GREEK_CHARSET - 161
$HANGEUL_CHARSET - 129
$MAC_CHARSET - 77
$OEM_CHARSET - 255
$RUSSIAN_CHARSET - 204
$SHIFTJIS_CHARSET - 128
$SYMBOL_CHARSET - 2
$TURKISH_CHARSET - 162
$VIETNAMESE_CHARSET - 163
$iOutputPrec [optional] Specifies the output precision, It can be one of the following values:
$OUT_CHARACTER_PRECIS - Not used
$OUT_DEFAULT_PRECIS - Specifies the default font mapper behavior
$OUT_DEVICE_PRECIS - Instructs the font mapper to choose a Device font when the system contains multiple fonts with the same name
$OUT_OUTLINE_PRECIS - This value instructs the font mapper to choose from TrueType and other outline-based fonts
$OUT_PS_ONLY_PRECIS - Instructs the font mapper to choose from only PostScript fonts.
If there are no PostScript fonts installed in the system, the font mapper returns to default behavior
$OUT_RASTER_PRECIS - Instructs the font mapper to choose a raster font when the system contains multiple fonts with the same name
$OUT_STRING_PRECIS - This value is not used by the font mapper, but it is returned when raster fonts are enumerated
$OUT_STROKE_PRECIS - This value is not used by the font mapper, but it is returned when TrueType, other outline-based fonts, and vector fonts are enumerated
$OUT_TT_ONLY_PRECIS - Instructs the font mapper to choose from only TrueType fonts. If there are no TrueType fonts installed in the system, the font mapper returns to default behavior
$OUT_TT_PRECIS - Instructs the font mapper to choose a TrueType font when the system contains multiple fonts with the same name
$iClipPrec [optional] Specifies the clipping precision, It can be one or more of the following values:
$CLIP_CHARACTER_PRECIS - Not used
$CLIP_DEFAULT_PRECIS - Specifies default clipping behavior
$CLIP_EMBEDDED - You must specify this flag to use an embedded read-only font
$CLIP_LH_ANGLES - When this value is used, the rotation for all fonts depends on whether the orientation of the coordinate system is left-handed or right-handed.
If not used, device fonts always rotate counterclockwise, but the rotation of other fonts is dependent on the orientation of the coordinate system.
$CLIP_MASK - Not used
$CLIP_STROKE_PRECIS - Not used by the font mapper, but is returned when raster, vector, or TrueType fonts are enumerated
For compatibility, this value is always returned when enumerating fonts
$CLIP_TT_ALWAYS - Not used
$iQuality [optional] Specifies the output quality, It can be one of the following values:
$ANTIALIASED_QUALITY - Font is antialiased, or smoothed, if the font supports it and the size of the font is not too small or too large.
In addition, you must select a TrueType font into a screen DC prior to using it in a DIBSection, otherwise antialiasing does not happen
$DEFAULT_QUALITY - Appearance of the font does not matter
$DRAFT_QUALITY - Appearance of the font is less important than when the PROOF_QUALITY value is used.
For GDI raster fonts, scaling is enabled, which means that more font sizes are available, but the quality may be lower.
Bold, italic, underline, and strikeout fonts are synthesized, if necessary
$NONANTIALIASED_QUALITY - Font is never antialiased, that is, font smoothing is not done
$PROOF_QUALITY - Character quality of the font is more important than exact matching of the logical-font attributes.
For GDI raster fonts, scaling is disabled and the font closest in size is chosen.
Although the chosen font size may not be mapped exactly when PROOF_QUALITY is used, the quality of the font is high and there is no distortion of appearance.
Bold, italic, underline, and strikeout fonts are synthesized, if necessary
$iPitch [optional] Specifies the pitch and family of the font. The two low-order bits specify the pitch of the font and can be one of the following values:
$DEFAULT_PITCH, $FIXED_PITCH, $VARIABLE_PITCH
The four high-order bits specify the font family and can be one of the following values:
$FF_DECORATIVE - Novelty fonts. Old English is an example
$FF_DONTCARE - Use default font
$FF_MODERN - Fonts with constant stroke width, with or without serifs. Pica, Elite, and Courier New are examples
$FF_ROMAN - Fonts with variable stroke width and with serifs. MS Serif is an example
$FF_SCRIPT - Fonts designed to look like handwriting. Script and Cursive are examples
$FF_SWISS - Fonts with variable stroke width and without serifs. MS Sans Serif is an example
$sFace | [optional] typeface name

Return Value

Success: | The handle to a logical font
Failure: | 0

Remarks

When you no longer need the font, call the _WinAPI_DeleteObject() function to delete it

Above constants require #include <FontConstants.au3>

See Also

Search CreateFont in MSDN Library.

Example

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

Global $g_tRECT, $g_hFont, $g_hOldFont, $g_hDC

HotKeySet("{ESC}", "_Exit")

$g_tRECT = DllStructCreate($tagRect)
DllStructSetData($g_tRECT, "Left", 5)
DllStructSetData($g_tRECT, "Top", 5)
DllStructSetData($g_tRECT, "Right", 250)
DllStructSetData($g_tRECT, "Bottom", 50)

$g_hDC = _WinAPI_GetDC(0)
$g_hFont = _WinAPI_CreateFont(50, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _
        $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')
$g_hOldFont = _WinAPI_SelectObject($g_hDC, $g_hFont)

_WinAPI_SetTextColor($g_hDC, 0x0000FF)
_WinAPI_SetBkColor($g_hDC, 0x000000)
; comment next line to get black background instead of transparent one
_WinAPI_SetBkMode($g_hDC, $TRANSPARENT)

While 1
    _WinAPI_DrawText($g_hDC, "Hello world!", $g_tRECT, $DT_CENTER)
    Sleep(100)
WEnd

Func _Exit()
    _WinAPI_SelectObject($g_hDC, $g_hOldFont)
    _WinAPI_DeleteObject($g_hFont)
    _WinAPI_ReleaseDC(0, $g_hDC)
    _WinAPI_InvalidateRect(0, 0)
    $g_tRECT = 0
    Exit
EndFunc   ;==>_Exit


Function _WinAPI_CreateFontIndirect

Function Reference

_WinAPI_CreateFontIndirect

Creates a logical font that has specific characteristics

#include <WinAPI.au3>
_WinAPI_CreateFontIndirect ( $tLogFont )

Parameters

$tLogFont $tagLOGFONT structure that defines the characteristics of the logical font

Return Value

Success: | Handle to a logical font
Failure: | 0

Remarks

This function creates a logical font with the characteristics specified in the $tagLOGFONT structure.
When this font is selected by using the SelectObject function, GDI's font mapper attempts to match the logical font with an existing physical font.
If it fails to find an exact match it provides an alternative whose characteristics match as many of the requested characteristics as possible.

Related

$tagLOGFONT

See Also

Search CreateFontIndirect in MSDN Library.


Function _WinAPI_CreatePen

Function Reference

_WinAPI_CreatePen

Creates a logical pen that has the specified style, width, and color

#include <WinAPI.au3>
_WinAPI_CreatePen ( $iPenStyle, $iWidth, $iColor )

Parameters

$iPenStyle | Specifies the pen style. It can be any one of the following values. PS_SOLID - The pen is solid. PS_DASH - The pen is dashed. This style is valid only when the pen width is one or less in device units. PS_DOT - The pen is dotted. This style is valid only when the pen width is one or less in device units. PS_DASHDOT - The pen has alternating dashes and dots. This style is valid only when the pen width is one or less in device units. PS_DASHDOTDOT - The pen has alternating dashes and double dots. This style is valid only when the pen width is one or less in device units. PS_NULL - The pen is invisible. PS_INSIDEFRAME - The pen is solid. When this pen is used in any GDI drawing function that takes a bounding rectangle, the dimensions of the figure are shrunk so that it fits entirely in the bounding rectangle, taking into account the width of the pen. This applies only to geometric pens.
$iWidth | Specifies the width of the pen, in logical units.
$iColor | Specifies the color of the pen (BGR)

Return Value

Success: | HPEN Value that identifies a logical pen
Failure: | 0

Remarks

The pen can subsequently be selected into a device context and used to draw lines and curves.
After an application creates a logical pen, it can select that pen into a device context by calling the _WinAPI_SelectObject() function. After a pen is selected into a device context, it can be used to draw lines and curves.
If the value specified by the $iWidth parameter is zero, a line drawn with the created pen always is a single pixel wide regardless of the current transformation.
If the value specified by $iWidth is greater than 1, the $iPenStyle parameter must be PS_NULL, PS_SOLID, or PS_INSIDEFRAME.
When you no longer need the pen, call the DeleteObject function to delete it.

Related

_WinAPI_DeleteObject, _WinAPI_DrawLine, _WinAPI_GetBkMode, _WinAPI_LineTo, _WinAPI_MoveTo, _WinAPI_SelectObject, _WinAPI_SetBkMode

See Also

Search CreatePen in MSDN Library.

Example

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

ShowCross(@DesktopWidth / 2, @DesktopHeight / 2, 20, 2, 0xFF, 3000)

Func ShowCross($iStart_x, $iStart_y, $iLength, $iWidth, $iColor, $iTime)
    Local $hDC, $hPen, $o_Orig

    $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop)
    $hPen = _WinAPI_CreatePen($PS_SOLID, $iWidth, $iColor)
    $o_Orig = _WinAPI_SelectObject($hDC, $hPen)

    _WinAPI_DrawLine($hDC, $iStart_x - $iLength, $iStart_y, $iStart_x - 5, $iStart_y) ; horizontal left
    _WinAPI_DrawLine($hDC, $iStart_x + $iLength, $iStart_y, $iStart_x + 5, $iStart_y) ; horizontal right
    _WinAPI_DrawLine($hDC, $iStart_x, $iStart_y - $iLength, $iStart_x, $iStart_y - 5) ; vertical up
    ;   _WinAPI_DrawLine($hDC, $iStart_x, $iStart_y + $iLength, $iStart_x, $iStart_y + 5) ; vertical down
    _WinAPI_MoveTo($hDC, $iStart_x, $iStart_y + $iLength)
    _WinAPI_LineTo($hDC, $iStart_x, $iStart_y + 5)

    Sleep($iTime) ; show cross over screen for defined seconds

    ; refresh desktop (clear cross)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)

    ; clear resources
    _WinAPI_SelectObject($hDC, $o_Orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
EndFunc   ;==>ShowCross


Function _WinAPI_CreateProcess

Function Reference

_WinAPI_CreateProcess

Creates a new process and its primary thread

#include <WinAPI.au3>
_WinAPI_CreateProcess ( $sAppName, $sCommand, $tSecurity, $tThread, $bInherit, $iFlags, $pEnviron, $sDir, $tStartupInfo, $tProcess )

Parameters

$sAppName | The name of the module to be executed
$sCommand | The command line to be executed
$tSecurity | a $tagSECURITY_ATTRIBUTES structure or a pointer to it that determines whether the returned handle to the new process can be inherited by child processes.
$tThread | a $tagSECURITY_ATTRIBUTES structure or a pointer to it that determines whether the returned handle to the new thread can be inherited by child processes.
$bInherit | If True, each inheritable handle in the calling process is inherited by the new process
$iFlags | Flags that control the priority class and creation of the process
$pEnviron | Pointer to the environment block for the new process
$sDir | The full path to the current directory for the process
$tStartupInfo | a $tagSTARTUPINFO structure or a pointer to it
$tProcess | a $tagPROCESS_INFORMATION structure or a pointer to it

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Related

$tagPROCESS_INFORMATION, $tagSECURITY_ATTRIBUTES, $tagSTARTUPINFO

See Also

Search CreateProcess in MSDN Library.


Function _WinAPI_CreateRectRgn

Function Reference

_WinAPI_CreateRectRgn

Creates a rectangular region

#include <WinAPI.au3>
_WinAPI_CreateRectRgn ( $iLeftRect, $iTopRect, $iRightRect, $iBottomRect )

Parameters

$iLeftRect | X-coordinate of the upper-left corner of the region
$iTopRect | Y-coordinate of the upper-left corner of the region
$iRightRect | X-coordinate of the lower-right corner of the region
$iBottomRect | Y-coordinate of the lower-right corner of the region

Return Value

Success: | the handle to the region.
Failure: | 0.

Remarks

When you no longer need the HRGN object call the _WinAPI_DeleteObject() function to delete it.
Region coordinates are represented as 27-bit signed integers.
The region will be exclusive of the bottom and right edges.

Related

_WinAPI_CombineRgn, _WinAPI_CreateRoundRectRgn, _WinAPI_DeleteObject, _WinAPI_GetWindowRgn, _WinAPI_SetWindowRgn

See Also

Search CreateRectRgn in MSDN Library.

Example

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

; get height of window title and width of window frame - may be different when XP theme is ON/OFF
Global $g_iHtit = _WinAPI_GetSystemMetrics($SM_CYCAPTION)
Global $g_iFrame = _WinAPI_GetSystemMetrics($SM_CXDLGFRAME)

Global $g_hGui = GUICreate("Test Windows regions", 350, 210)
Local $id_Default = GUICtrlCreateButton("Default region", 100, 30, 150)
Local $id_Round = GUICtrlCreateButton("Round region", 100, 60, 150)
Local $id_Buble = GUICtrlCreateButton("Buble region ", 100, 90, 150)
Local $id_Transparent = GUICtrlCreateButton("Transparent region", 100, 120, 150)
Local $id_Exit = GUICtrlCreateButton("Exit", 100, 150, 150)
GUISetState(@SW_SHOW)

Local $aPos = WinGetPos($g_hGui) ; get whole window size (no client size defined in GUICreate)
Global $g_iWidth = $aPos[2]
Global $g_iHeight = $aPos[3]

Local $iMsg, $hRgn
While 1
    $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE Or $iMsg = $id_Exit
            ExitLoop

        Case $iMsg = $id_Default
            $hRgn = _WinAPI_CreateRectRgn(0, 0, $g_iWidth, $g_iHeight)
            _WinAPI_SetWindowRgn($g_hGui, $hRgn)

        Case $iMsg = $id_Round
            $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $g_iWidth, $g_iHeight, $g_iWidth / 3, $g_iHeight / 3)
            _WinAPI_SetWindowRgn($g_hGui, $hRgn)

        Case $iMsg = $id_Buble
            Local $hRgn1 = _WinAPI_CreateRoundRectRgn(0, 0, $g_iWidth / 2, $g_iHeight / 2, $g_iWidth / 2, $g_iHeight / 2) ; left-top
            Local $hRgn2 = _WinAPI_CreateRoundRectRgn($g_iWidth / 2, 0, $g_iWidth, $g_iHeight / 2, $g_iWidth / 2, $g_iHeight / 2) ; right-top
            _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR)
            _WinAPI_DeleteObject($hRgn2)
            $hRgn2 = _WinAPI_CreateRoundRectRgn(0, $g_iHeight / 2, $g_iWidth / 2, $g_iHeight, $g_iWidth / 2, $g_iHeight / 2) ; left-bottom
            _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR)
            _WinAPI_DeleteObject($hRgn2)
            $hRgn2 = _WinAPI_CreateRoundRectRgn($g_iWidth / 2, $g_iHeight / 2, $g_iWidth, $g_iHeight, $g_iWidth / 2, $g_iHeight / 2) ; right-bottom
            _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR)
            _WinAPI_DeleteObject($hRgn2)
            $hRgn2 = _WinAPI_CreateRoundRectRgn(10, 10, $g_iWidth - 10, $g_iHeight - 10, $g_iWidth, $g_iHeight) ; middle
            _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR)
            _WinAPI_DeleteObject($hRgn2)
            _WinAPI_SetWindowRgn($g_hGui, $hRgn1)

        Case $iMsg = $id_Transparent
            _GuiHole($g_hGui, 40, 40, 260, 170)

    EndSelect
WEnd

; make inner transparent area but add controls
Func _GuiHole($hWin, $iX, $iY, $iSizeW, $iSizeH)
    Local $hOuter_rgn, $hInner_rgn, $hCombined_rgn

    $hOuter_rgn = _WinAPI_CreateRectRgn(0, 0, $g_iWidth, $g_iHeight)
    $hInner_rgn = _WinAPI_CreateRectRgn($iX, $iY, $iX + $iSizeW, $iY + $iSizeH)
    $hCombined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0)
    _WinAPI_CombineRgn($hCombined_rgn, $hOuter_rgn, $hInner_rgn, $RGN_DIFF)
    _WinAPI_DeleteObject($hOuter_rgn)
    _WinAPI_DeleteObject($hInner_rgn)
    _AddCtrlRegion($hCombined_rgn, $id_Default)
    _AddCtrlRegion($hCombined_rgn, $id_Round)
    _AddCtrlRegion($hCombined_rgn, $id_Buble)
    _AddCtrlRegion($hCombined_rgn, $id_Transparent)
    _AddCtrlRegion($hCombined_rgn, $id_Exit)
    _WinAPI_SetWindowRgn($hWin, $hCombined_rgn)
EndFunc   ;==>_GuiHole

; add control's area to given region
; respecting also window title/frame sizes
Func _AddCtrlRegion($hFull_rgn, $idCtrl)
    Local $aCtrl_pos, $hCtrl_rgn

    $aCtrl_pos = ControlGetPos($g_hGui, "", $idCtrl)
    $hCtrl_rgn = _WinAPI_CreateRectRgn($aCtrl_pos[0] + $g_iFrame, $aCtrl_pos[1] + $g_iHtit + $g_iFrame, _
            $aCtrl_pos[0] + $aCtrl_pos[2] + $g_iFrame, $aCtrl_pos[1] + $aCtrl_pos[3] + $g_iHtit + $g_iFrame)
    _WinAPI_CombineRgn($hFull_rgn, $hFull_rgn, $hCtrl_rgn, $RGN_OR)
    _WinAPI_DeleteObject($hCtrl_rgn)
EndFunc   ;==>_AddCtrlRegion


Function _WinAPI_CreateRoundRectRgn

Function Reference

_WinAPI_CreateRoundRectRgn

Creates a rectangular region with rounded corners

#include <WinAPI.au3>
_WinAPI_CreateRoundRectRgn ( $iLeftRect, $iTopRect, $iRightRect, $iBottomRect, $iWidthEllipse, $iHeightEllipse )

Parameters

$iLeftRect | X-coordinate of the upper-left corner of the region
$iTopRect | Y-coordinate of the upper-left corner of the region
$iRightRect | X-coordinate of the lower-right corner of the region
$iBottomRect | Y-coordinate of the lower-right corner of the region
$iWidthEllipse | Width of the ellipse used to create the rounded corners
$iHeightEllipse | Height of the ellipse used to create the rounded corners

Return Value

Success: | the handle to the region.
Failure: | 0.

Remarks

When you no longer need the HRGN object call the _WinAPI_DeleteObject() function to delete it.
Region coordinates are represented as 27-bit signed integers.

Related

_WinAPI_CombineRgn, _WinAPI_CreateRectRgn, _WinAPI_DeleteObject, _WinAPI_GetWindowRgn, _WinAPI_SetWindowRgn

See Also

Search CreateRoundRectRgn in MSDN Library.

Example

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

; get height of window title and width of window frame - may be different when XP theme is ON/OFF
Global $g_iHtit = _WinAPI_GetSystemMetrics($SM_CYCAPTION)
Global $g_iFrame = _WinAPI_GetSystemMetrics($SM_CXDLGFRAME)

Global $g_hGui = GUICreate("Test Windows regions", 350, 210)
Local $id_Default = GUICtrlCreateButton("Default region", 100, 30, 150)
Local $id_Round = GUICtrlCreateButton("Round region", 100, 60, 150)
Local $id_Buble = GUICtrlCreateButton("Buble region ", 100, 90, 150)
Local $id_Transparent = GUICtrlCreateButton("Transparent region", 100, 120, 150)
Local $id_Exit = GUICtrlCreateButton("Exit", 100, 150, 150)
GUISetState(@SW_SHOW)

Local $aPos = WinGetPos($g_hGui) ; get whole window size (no client size defined in GUICreate)
Global $g_iWidth = $aPos[2]
Global $g_iHeight = $aPos[3]

Local $iMsg, $hRgn
While 1
    $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE Or $iMsg = $id_Exit
            ExitLoop

        Case $iMsg = $id_Default
            $hRgn = _WinAPI_CreateRectRgn(0, 0, $g_iWidth, $g_iHeight)
            _WinAPI_SetWindowRgn($g_hGui, $hRgn)

        Case $iMsg = $id_Round
            $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $g_iWidth, $g_iHeight, $g_iWidth / 3, $g_iHeight / 3)
            _WinAPI_SetWindowRgn($g_hGui, $hRgn)

        Case $iMsg = $id_Buble
            Local $hRgn1 = _WinAPI_CreateRoundRectRgn(0, 0, $g_iWidth / 2, $g_iHeight / 2, $g_iWidth / 2, $g_iHeight / 2) ; left-top
            Local $hRgn2 = _WinAPI_CreateRoundRectRgn($g_iWidth / 2, 0, $g_iWidth, $g_iHeight / 2, $g_iWidth / 2, $g_iHeight / 2) ; right-top
            _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR)
            _WinAPI_DeleteObject($hRgn2)
            $hRgn2 = _WinAPI_CreateRoundRectRgn(0, $g_iHeight / 2, $g_iWidth / 2, $g_iHeight, $g_iWidth / 2, $g_iHeight / 2) ; left-bottom
            _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR)
            _WinAPI_DeleteObject($hRgn2)
            $hRgn2 = _WinAPI_CreateRoundRectRgn($g_iWidth / 2, $g_iHeight / 2, $g_iWidth, $g_iHeight, $g_iWidth / 2, $g_iHeight / 2) ; right-bottom
            _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR)
            _WinAPI_DeleteObject($hRgn2)
            $hRgn2 = _WinAPI_CreateRoundRectRgn(10, 10, $g_iWidth - 10, $g_iHeight - 10, $g_iWidth, $g_iHeight) ; middle
            _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR)
            _WinAPI_DeleteObject($hRgn2)
            _WinAPI_SetWindowRgn($g_hGui, $hRgn1)

        Case $iMsg = $id_Transparent
            _GuiHole($g_hGui, 40, 40, 260, 170)

    EndSelect
WEnd

; make inner transparent area but add controls
Func _GuiHole($hWin, $iX, $iY, $iSizeW, $iSizeH)
    Local $hOuter_rgn, $hInner_rgn, $hCombined_rgn

    $hOuter_rgn = _WinAPI_CreateRectRgn(0, 0, $g_iWidth, $g_iHeight)
    $hInner_rgn = _WinAPI_CreateRectRgn($iX, $iY, $iX + $iSizeW, $iY + $iSizeH)
    $hCombined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0)
    _WinAPI_CombineRgn($hCombined_rgn, $hOuter_rgn, $hInner_rgn, $RGN_DIFF)
    _WinAPI_DeleteObject($hOuter_rgn)
    _WinAPI_DeleteObject($hInner_rgn)
    _AddCtrlRegion($hCombined_rgn, $id_Default)
    _AddCtrlRegion($hCombined_rgn, $id_Round)
    _AddCtrlRegion($hCombined_rgn, $id_Buble)
    _AddCtrlRegion($hCombined_rgn, $id_Transparent)
    _AddCtrlRegion($hCombined_rgn, $id_Exit)
    _WinAPI_SetWindowRgn($hWin, $hCombined_rgn)
EndFunc   ;==>_GuiHole

; add control's area to given region
; respecting also window title/frame sizes
Func _AddCtrlRegion($hFull_rgn, $idCtrl)
    Local $aCtrl_pos, $hCtrl_rgn

    $aCtrl_pos = ControlGetPos($g_hGui, "", $idCtrl)
    $hCtrl_rgn = _WinAPI_CreateRectRgn($aCtrl_pos[0] + $g_iFrame, $aCtrl_pos[1] + $g_iHtit + $g_iFrame, _
            $aCtrl_pos[0] + $aCtrl_pos[2] + $g_iFrame, $aCtrl_pos[1] + $aCtrl_pos[3] + $g_iHtit + $g_iFrame)
    _WinAPI_CombineRgn($hFull_rgn, $hFull_rgn, $hCtrl_rgn, $RGN_OR)
    _WinAPI_DeleteObject($hCtrl_rgn)
EndFunc   ;==>_AddCtrlRegion


Function _WinAPI_CreateSolidBitmap

Function Reference

_WinAPI_CreateSolidBitmap

Creates a solid color bitmap

#include <WinAPI.au3>
_WinAPI_CreateSolidBitmap ( $hWnd, $iColor, $iWidth, $iHeight [, $bRGB = 1] )

Parameters

$hWnd | Handle to the window where the bitmap will be displayed
$iColor | The color of the bitmap, stated in RGB
$iWidth | The width of the bitmap
$iHeight | The height of the bitmap
$bRGB | [optional] If True converts to COLOREF (0x00bbggrr)

Return Value

Success: | Handle to the bitmap
Failure: | 0

Related

_WinAPI_CreateCompatibleBitmap


Function _WinAPI_CreateSolidBrush

Function Reference

_WinAPI_CreateSolidBrush

Creates a logical brush that has the specified solid color

#include <WinAPI.au3>
_WinAPI_CreateSolidBrush ( $iColor )

Parameters

$iColor Specifies the color of the brush

Return Value

Success: | HBRUSH Value that identifies a logical brush
Failure: | 0

Remarks

When you no longer need the HBRUSH object call the _WinAPI_DeleteObject() function to delete it

See Also

Search CreateSolidBrush in MSDN Library.


Function _WinAPI_CreateWindowEx

Function Reference

_WinAPI_CreateWindowEx

Creates an overlapped, pop-up, or child window

#include <WinAPI.au3>
_WinAPI_CreateWindowEx ( $iExStyle, $sClass, $sName, $iStyle, $iX, $iY, $iWidth, $iHeight, $hParent [, $hMenu = 0 [, $hInstance = 0 [, $pParam = 0]]] )

Parameters

$iExStyle | Extended window style
$sClass | Registered class name
$sName | Window name
$iStyle | Window style
$iX | Horizontal position of window
$iY | Vertical position of window
$iWidth | Window width
$iHeight | Window height
$hParent | Handle to parent or owner window
$hMenu | [optional] Handle to menu or child-window identifier
$hInstance | [optional] Handle to application instance
$pParam | [optional] Pointer to window-creation data

Return Value

Success: | The handle to the new window
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

Related

_WinAPI_DestroyWindow

See Also

Search CreateWindowEx in MSDN Library.


Function _WinAPI_DefWindowProc

Function Reference

_WinAPI_DefWindowProc

Call the default window procedure to provide default processing

#include <WinAPI.au3>
_WinAPI_DefWindowProc ( $hWnd, $iMsg, $wParam, $lParam )

Parameters

$hWnd | Handle to the window procedure that received the message
$iMsg | Specifies the message
$wParam | Specifies additional message information
$lParam | Specifies additional message information

Return Value

Returns the return value is the result of the message processing and depends on the message

See Also

Search DefWindowProc in MSDN Library.


Function _WinAPI_DeleteDC

Function Reference

_WinAPI_DeleteDC

Deletes the specified device context

#include <WinAPI.au3>
_WinAPI_DeleteDC ( $hDC )

Parameters

$hDC Identifies the device context to be deleted

Return Value

Success: | True
Failure: | False

Remarks

An application must not delete a DC whose handle was obtained by calling the _WinAPI_GetDC() function.
Instead, it must call the _WinAPI_ReleaseDC() function to free the DC.

Related

_WinAPI_CreateCompatibleDC, _WinAPI_GetDC, _WinAPI_ReleaseDC

See Also

Search DeleteDC in MSDN Library.


Function _WinAPI_DeleteObject

Function Reference

_WinAPI_DeleteObject

Deletes a logical pen, brush, font, bitmap, region, or palette

#include <WinAPI.au3>
_WinAPI_DeleteObject ( $hObject )

Parameters

$hObject Identifies a logical pen, brush, font, bitmap, region, or palette

Return Value

Success: | True
Failure: | False

Remarks

Do not delete a drawing object while it is still selected into a device context.
When a pattern brush is deleted the bitmap associated with the brush is not deleted.
The bitmap must be deleted independently.

Related

_GDIPlus_BitmapCloneArea, _GDIPlus_BitmapCreateDIBFromBitmap, _GDIPlus_BitmapCreateFromFile, _GDIPlus_BitmapCreateFromGraphics, _GDIPlus_BitmapCreateFromHBITMAP, _GDIPlus_BitmapCreateHBITMAPFromBitmap, _GDIPlus_BitmapLockBits, _GDIPlus_BitmapUnlockBits, _ScreenCapture_Capture, _ScreenCapture_CaptureWnd, _WinAPI_CreateCompatibleBitmap, _WinAPI_CreatePen, _WinAPI_CreateRectRgn, _WinAPI_CreateRoundRectRgn

See Also

Search DeleteObject in MSDN Library.

Example

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

ShowCross(@DesktopWidth / 2, @DesktopHeight / 2, 20, 2, 0xFF, 3000)

Func ShowCross($iStart_x, $iStart_y, $iLength, $iWidth, $iColor, $iTime)
    Local $hDC, $hPen, $o_Orig

    $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop)
    $hPen = _WinAPI_CreatePen($PS_SOLID, $iWidth, $iColor)
    $o_Orig = _WinAPI_SelectObject($hDC, $hPen)

    _WinAPI_DrawLine($hDC, $iStart_x - $iLength, $iStart_y, $iStart_x - 5, $iStart_y) ; horizontal left
    _WinAPI_DrawLine($hDC, $iStart_x + $iLength, $iStart_y, $iStart_x + 5, $iStart_y) ; horizontal right
    _WinAPI_DrawLine($hDC, $iStart_x, $iStart_y - $iLength, $iStart_x, $iStart_y - 5) ; vertical up
    ;   _WinAPI_DrawLine($hDC, $iStart_x, $iStart_y + $iLength, $iStart_x, $iStart_y + 5) ; vertical down
    _WinAPI_MoveTo($hDC, $iStart_x, $iStart_y + $iLength)
    _WinAPI_LineTo($hDC, $iStart_x, $iStart_y + 5)

    Sleep($iTime) ; show cross over screen for defined seconds

    ; refresh desktop (clear cross)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)

    ; clear resources
    _WinAPI_SelectObject($hDC, $o_Orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
EndFunc   ;==>ShowCross


Function _WinAPI_DestroyIcon

Function Reference

_WinAPI_DestroyIcon

Destroys an icon and frees any memory the icon occupied

#include <WinAPI.au3>
_WinAPI_DestroyIcon ( $hIcon )

Parameters

$hIcon Handle to the icon to be destroyed. The icon must not be in use.

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Related

_WinAPI_CopyIcon, _WinAPI_LoadShell32Icon

See Also

Search DestroyIcon in MSDN Library.


Function _WinAPI_DestroyWindow

Function Reference

_WinAPI_DestroyWindow

Destroys the specified window

#include <WinAPI.au3>
_WinAPI_DestroyWindow ( $hWnd )

Parameters

$hWnd Handle to the window to be destroyed

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

You cannot use _WinAPI_DestroyWindow() to destroy a window created by a different thread

Related

_WinAPI_CreateWindowEx

See Also

Search DestroyWindow in MSDN Library.


Function _WinAPI_DrawEdge

Function Reference

_WinAPI_DrawEdge

Draws one or more edges of rectangle

#include <WinAPI.au3>
_WinAPI_DrawEdge ( $hDC, $tRECT, $iEdgeType, $iFlags )

Parameters

$hDC | Handle to the device context into which the edge is drawn
$tRECT | a $tagRECT structure or a pointer to it that contains the logical coordinates of the rectangle
$iEdgeType Specifies the type of inner and outer edges to draw. This parameter must be a combination of one inner-border flag and one outer-border flag.
The inner-border flags are as follows:
$BDR_RAISEDINNER - Raised inner edge
$BDR_SUNKENINNER - Sunken inner edge
The outer-border flags are as follows:
$BDR_RAISEDOUTER - Raised outer edge
$BDR_SUNKENOUTER - Sunken outer edge
Alternatively, the edge parameter can specify one of the following flags:
$EDGE_BUMP - Combination of $BDR_RAISEDOUTER and $BDR_SUNKENINNER
$EDGE_ETCHED - Combination of $BDR_SUNKENOUTER and $BDR_RAISEDINNER
$EDGE_RAISED - Combination of $BDR_RAISEDOUTER and $BDR_RAISEDINNER
$EDGE_SUNKEN - Combination of $BDR_SUNKENOUTER and $BDR_SUNKENINNER
$iFlags Specifies the type of border. This parameter can be a combination of the following values:
$BF_ADJUST - If this flag is passed, shrink the rectangle pointed to by the $pRECT parameter to exclude the edges that were drawn.
If this flag is not passed, then do not change the rectangle pointed to by the $pRECT parameter
$BF_BOTTOM - Bottom of border rectangle
$BF_BOTTOMLEFT - Bottom and left side of border rectangle
$BF_BOTTOMRIGHT - Bottom and right side of border rectangle
$BF_DIAGONAL - Diagonal border
$BF_DIAGONAL_ENDBOTTOMLEFT - Diagonal border. The end point is the bottom-left corner of the rectangle; the origin is top-right corner
$BF_DIAGONAL_ENDBOTTOMRIGHT - Diagonal border. The end point is the bottom-right corner of the rectangle; the origin is top-left corner
$BF_DIAGONAL_ENDTOPLEFT - Diagonal border. The end point is the top-left corner of the rectangle; the origin is bottom-right corner
$BF_DIAGONAL_ENDTOPRIGHT - Diagonal border. The end point is the top-right corner of the rectangle; the origin is bottom-left corner
$BF_FLAT - Flat border
$BF_LEFT - Left side of border rectangle
$BF_MIDDLE - Interior of rectangle to be filled
$BF_MONO - One-dimensional border
$BF_RECT - Entire border rectangle
$BF_RIGHT - Right side of border rectangle
$BF_SOFT - Soft buttons instead of tiles
$BF_TOP - Top of border rectangle
$BF_TOPLEFT - Top and left side of border rectangle
$BF_TOPRIGHT - Top and right side of border rectangle

Return Value

Success: | True
Failure: | False

Remarks

Above constants require #include <BorderConstants.au3>

Related

$tagRECT

See Also

Search DrawEdge in MSDN Library.


Function _WinAPI_DrawFrameControl

Function Reference

_WinAPI_DrawFrameControl

Draws a frame control of the specified type and style

#include <WinAPI.au3>
_WinAPI_DrawFrameControl ( $hDC, $tRECT, $iType, $iState )

Parameters

$hDC | Handle to the device context into which the frame is drawn
$tRECT | a $tagRECT structure or a pointer to it that contains the logical coordinates of the rectangle
$iType Specifies the type of frame control to draw. This parameter can be one of the following values:
$DFC_BUTTON - Standard button
$DFC_CAPTION - Title bar
$DFC_MENU - Menu bar
$DFC_POPUPMENU - Popup menu item
$DFC_SCROLL - Scroll bar
$iState Specifies the initial state of the frame control. If $iType is $DFC_BUTTON, $iState can be one of the following values:
$DFCS_BUTTON3STATE - Three-state button
$DFCS_BUTTONCHECK - Check box
$DFCS_BUTTONPUSH - Push button
$DFCS_BUTTONRADIO - Radio button
$DFCS_BUTTONRADIOIMAGE - Image for radio button (nonsquare needs image)
$DFCS_BUTTONRADIOMASK - Mask for radio button (nonsquare needs mask)
If $iType is $DFC_CAPTION, $iState can be one of the following values:
$DFCS_CAPTIONCLOSE - Close button
$DFCS_CAPTIONHELP - Help button
$DFCS_CAPTIONMAX - Maximize button
$DFCS_CAPTIONMIN - Minimize button
$DFCS_CAPTIONRESTORE - Restore button
If $iType is $DFC_MENU, $iState can be one of the following values:
$DFCS_MENUARROW - Submenu arrow
$DFCS_MENUARROWRIGHT - Submenu arrow pointing left. This is used for the right-to-left cascading menus used with right-to-left languages such as Arabic or Hebrew
$DFCS_MENUBULLET - Bullet
$DFCS_MENUCHECK - Check mark
If $iType is $DFC_SCROLL, $iState can be one of the following values:
$DFCS_SCROLLCOMBOBOX - Combo box scroll bar
$DFCS_SCROLLDOWN - Down arrow of scroll bar
$DFCS_SCROLLLEFT - Left arrow of scroll bar
$DFCS_SCROLLRIGHT - Right arrow of scroll bar
$DFCS_SCROLLSIZEGRIP - Size grip in bottom-right corner of window
$DFCS_SCROLLSIZEGRIPRIGHT - Size grip in bottom-left corner of window. This is used with right-to-left languages such as Arabic or Hebrew
$DFCS_SCROLLUP - Up arrow of scroll bar
The following style can be used to adjust the bounding rectangle of the push button:
$DFCS_ADJUSTRECT - Bounding rectangle is adjusted to exclude the surrounding edge of the push button
One or more of the following values can be used to set the state of the control to be drawn:
$DFCS_CHECKED - Button is checked
$DFCS_FLAT - Button has a flat border
$DFCS_HOT - Button is hot-tracked
$DFCS_INACTIVE - Button is inactive (grayed)
$DFCS_PUSHED - Button is pushed
$DFCS_TRANSPARENT - The background remains untouched. This flag can only be combined with $DFCS_MENUARROWUP or $DFCS_MENUARROWDOWN

Return Value

Success: | True
Failure: | False

Remarks

Above constants require #include <FrameConstants.au3>

Related

$tagRECT

See Also

Search DrawFrameControl in MSDN Library.


Function _WinAPI_DrawIcon

Function Reference

_WinAPI_DrawIcon

Draws an icon or cursor into the specified device context

#include <WinAPI.au3>
_WinAPI_DrawIcon ( $hDC, $iX, $iY, $hIcon )

Parameters

$hDC | Handle to the device context into which the icon or cursor is drawn
$iX | X coordinate of the upper-left corner of the icon
$iY | Y coordinate of the upper-left corner of the icon
$hIcon | Handle to the icon to be drawn

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Related

_WinAPI_DrawIconEx

See Also

Search DrawIcon in MSDN Library.


Function _WinAPI_DrawIconEx

Function Reference

_WinAPI_DrawIconEx

Draws an icon or cursor into the specified device context

#include <WinAPI.au3>
_WinAPI_DrawIconEx ( $hDC, $iX, $iY, $hIcon [, $iWidth = 0 [, $iHeight = 0 [, $iStep = 0 [, $hBrush = 0 [, $iFlags = 3]]]]] )

Parameters

$hDC | Handle to the device context into which the icon or cursor is drawn
$iX | X coordinate of the upper-left corner of the icon
$iY | Y coordinate of the upper-left corner of the icon
$hIcon | Handle to the icon to be drawn
$iWidth | [optional] Specifies the logical width of the icon or cursor. If this parameter is zero and the $iFlags parameter is "default size", the function uses the $SM_CXICON or $SM_CXCURSOR system metric value to set the width. If this is zero and "default size" is not used, the function uses the actual resource width.
$iHeight | [optional] Specifies the logical height of the icon or cursor. If this parameter is zero and the $iFlags parameter is "default size", the function uses the $SM_CYICON or $SM_CYCURSOR system metric value to set the width. If this is zero and "default size" is not used, the function uses the actual resource height.
$iStep | [optional] Specifies the index of the frame to draw if $hIcon identifies an animated cursor. This parameter is ignored if $hIcon does not identify an animated cursor.
$hBrush | [optional] Handle to a brush that the system uses for flicker-free drawing. If $hBrush is a valid brush handle, the system creates an offscreen bitmap using the specified brush for the background color, draws the icon or cursor into the bitmap, and then copies the bitmap into the device context identified by $hDC. If $hBrush is 0, the system draws the icon or cursor directly into the device context.
$iFlags | [optional] Specifies the drawing flags. This parameter can be one of the following values: 1 - Draws the icon or cursor using the mask 2 - Draws the icon or cursor using the image 3 - Draws the icon or cursor using the mask and image 4 - Draws the icon or cursor using the system default image rather than the user-specified image 5 - Draws the icon or cursor using the width and height specified by the system metric values for cursors or icons, if the width and height parameters are set to zero. If this flag is not specified and width and height are set to zero, the function uses the actual resource size. 6 - Draws the icon as an unmirrored icon

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Related

_WinAPI_DrawIcon

See Also

Search DrawIconEx in MSDN Library.


Function _WinAPI_DrawLine

Function Reference

_WinAPI_DrawLine

Draws a line

#include <WinAPI.au3>
_WinAPI_DrawLine ( $hDC, $iX1, $iY1, $iX2, $iY2 )

Parameters

$hDC | Handle to device context
$iX1 | X coordinate of the line's starting point.
$iY1 | Y coordinate of the line's starting point.
$iX2 | X coordinate of the line's ending point.
$iY2 | Y coordinate of the line's ending point.

Return Value

Success: | True
Failure: | False

Remarks

Internally calls _WinAPI_MoveTo() and _WinAPI_LineTo(), see _WinAPI_LineTo() for details

Related

_WinAPI_CreatePen, _WinAPI_LineTo, _WinAPI_MoveTo, _WinAPI_SelectObject

Example

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

ShowCross(@DesktopWidth / 2, @DesktopHeight / 2, 20, 2, 0xFF, 3000)

Func ShowCross($iStart_x, $iStart_y, $iLength, $iWidth, $iColor, $iTime)
    Local $hDC, $hPen, $o_Orig

    $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop)
    $hPen = _WinAPI_CreatePen($PS_SOLID, $iWidth, $iColor)
    $o_Orig = _WinAPI_SelectObject($hDC, $hPen)

    _WinAPI_DrawLine($hDC, $iStart_x - $iLength, $iStart_y, $iStart_x - 5, $iStart_y) ; horizontal left
    _WinAPI_DrawLine($hDC, $iStart_x + $iLength, $iStart_y, $iStart_x + 5, $iStart_y) ; horizontal right
    _WinAPI_DrawLine($hDC, $iStart_x, $iStart_y - $iLength, $iStart_x, $iStart_y - 5) ; vertical up
    ;   _WinAPI_DrawLine($hDC, $iStart_x, $iStart_y + $iLength, $iStart_x, $iStart_y + 5) ; vertical down
    _WinAPI_MoveTo($hDC, $iStart_x, $iStart_y + $iLength)
    _WinAPI_LineTo($hDC, $iStart_x, $iStart_y + 5)

    Sleep($iTime) ; show cross over screen for defined seconds

    ; refresh desktop (clear cross)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)

    ; clear resources
    _WinAPI_SelectObject($hDC, $o_Orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
EndFunc   ;==>ShowCross


Function _WinAPI_DrawText

Function Reference

_WinAPI_DrawText

Draws formatted text in the specified rectangle

#include <WinAPI.au3>
_WinAPI_DrawText ( $hDC, $sText, ByRef $tRECT, $iFlags )

Parameters

$hDC | Identifies the device context
$sText | The string to be drawn
$tRECT | $tagRECT structure that contains the rectangle for the text
$iFlags Specifies the method of formatting the text:
$DT_BOTTOM - Justifies the text to the bottom of the rectangle
$DT_CALCRECT - Determines the width and height of the rectangle
$DT_CENTER - Centers text horizontally in the rectangle
$DT_EDITCONTROL - Duplicates the text-displaying characteristics of a multiline edit control
$DT_END_ELLIPSIS - Replaces part of the given string with ellipses if necessary
$DT_EXPANDTABS - Expands tab characters
$DT_EXTERNALLEADING - Includes the font external leading in line height
$DT_HIDEPREFIX - Ignores the ampersand (&) prefix character in the text.
The letter that follows will not be underlined, but other mnemonic-prefix characters are still processed.
$DT_INTERNAL - Uses the system font to calculate text metrics
$DT_LEFT - Aligns text to the left
$DT_MODIFYSTRING - Modifies the given string to match the displayed text
$DT_NOCLIP - Draws without clipping
$DT_NOFULLWIDTHCHARBREAK - Prevents a line break at a DBCS (double-wide character string), so that the line breaking rule is equivalent to SBCS strings.
For example, this can be used in Korean windows, for more readability of icon labels.
This value has no effect unless $DT_WORDBREAK is specified
$DT_NOPREFIX - Turns off processing of prefix characters
$DT_PATH_ELLIPSIS - For displayed text, replaces characters in the middle of the string with ellipses so that the result fits in the specified rectangle.
If the string contains backslash (\) characters, $DT_PATH_ELLIPSIS preserves as much as possible of the text after the last backslash.
The string is not modified unless the $DT_MODIFYSTRING flag is specified
$DT_PREFIXONLY - Draws only an underline at the position of the character following the ampersand (&) prefix character.
Does not draw any other characters in the string
$DT_RIGHT - Aligns text to the right
$DT_RTLREADING - Layout in right to left reading order for bi-directional text
$DT_SINGLELINE - Displays text on a single line only
$DT_TABSTOP - Sets tab stops. Bits 15-8 of $iFlags specify the number of characters for each tab
$DT_TOP - Top-justifies text (single line only)
$DT_VCENTER - Centers text vertically (single line only)
$DT_WORDBREAK - Breaks words
$DT_WORD_ELLIPSIS - Truncates any word that does not fit in the rectangle and adds ellipses

Return Value

Success: | The height of the text
Failure: | 0

Remarks

The DrawText function uses the device context's selected font, text color, and background color to draw the text.
Unless the $DT_NOCLIP format is used, DrawText clips the text so that it does not appear outside the specified rectangle.
All formatting is assumed to have multiple lines unless the $DT_SINGLELINE format is specified.
If the selected font is too large, DrawText does not attempt to substitute a smaller font.

Above constants require #include <WindowsConstants.au3>

Related

$tagRECT, _WinAPI_GetBkMode, _WinAPI_SetBkMode

See Also

Search DrawText in MSDN Library.

Example

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

Global $g_tRECT, $g_hFont, $g_hOldFont, $g_hDC

HotKeySet("{ESC}", "_Exit")

$g_tRECT = DllStructCreate($tagRect)
DllStructSetData($g_tRECT, "Left", 5)
DllStructSetData($g_tRECT, "Top", 5)
DllStructSetData($g_tRECT, "Right", 250)
DllStructSetData($g_tRECT, "Bottom", 50)

$g_hDC = _WinAPI_GetDC(0)
$g_hFont = _WinAPI_CreateFont(50, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _
        $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')
$g_hOldFont = _WinAPI_SelectObject($g_hDC, $g_hFont)

_WinAPI_SetTextColor($g_hDC, 0x0000FF)
_WinAPI_SetBkColor($g_hDC, 0x000000)
; comment next line to get black background instead of transparent one
_WinAPI_SetBkMode($g_hDC, $TRANSPARENT)

While 1
    _WinAPI_DrawText($g_hDC, "Hello world!", $g_tRECT, $DT_CENTER)
    Sleep(100)
WEnd

Func _Exit()
    _WinAPI_SelectObject($g_hDC, $g_hOldFont)
    _WinAPI_DeleteObject($g_hFont)
    _WinAPI_ReleaseDC(0, $g_hDC)
    _WinAPI_InvalidateRect(0, 0)
    $g_tRECT = 0
    Exit
EndFunc   ;==>_Exit


Function _WinAPI_DuplicateHandle

Function Reference

_WinAPI_DuplicateHandle

Duplicates an object handle

#include <WinAPI.au3>
_WinAPI_DuplicateHandle ( $hSourceProcessHandle, $hSourceHandle, $hTargetProcessHandle, $iDesiredAccess, $iInheritHandle, $iOptions )

Parameters

$hSourceProcessHandle | A handle to the process with the handle to be duplicated
$hSourceHandle | The handle to be duplicated
$hTargetProcessHandle | A handle to the process that is to receive the duplicated handle
$iDesiredAccess | The access requested for the new handle
$iInheritHandle | A variable that indicates whether the handle is inheritable
$iOptions | Optional actions

Return Value

Success: | New handle
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

Related

_WinAPI_CloseHandle, _WinAPI_OpenProcess

See Also

Search DuplicateHandle in MSDN Library.

Example

#include <WinAPI.au3>

Local $hCurProcessPseudo = _WinAPI_GetCurrentProcess()
ConsoleWrite("Pseudo handle for current process = " & $hCurProcessPseudo & @CRLF)

Local $hCurProcess = _WinAPI_DuplicateHandle($hCurProcessPseudo, $hCurProcessPseudo, $hCurProcessPseudo, Default, True, $DUPLICATE_SAME_ACCESS)
ConsoleWrite("Real handle for current process = " & $hCurProcess & @CRLF)

; ...

; Close handle when no longer needed
_WinAPI_CloseHandle($hCurProcess)


Function _WinAPI_EnableWindow

Function Reference

_WinAPI_EnableWindow

Enables or disables mouse and keyboard input to the specified window or control

#include <WinAPI.au3>
_WinAPI_EnableWindow ( $hWnd [, $bEnable = True] )

Parameters

$hWnd | Handle to the window to be enabled or disabled
$bEnable | [optional] Specifies whether to enable or disable the window: True - The window or control is enabled False - The window or control is disabled

Return Value

True: | The window or control was previously disabled
False: | The window or control was previously enabled

See Also

Search EnableWindow in MSDN Library.


Function _WinAPI_EnumDisplayDevices

Function Reference

_WinAPI_EnumDisplayDevices

Obtains information about the display devices in a system

#include <WinAPI.au3>
_WinAPI_EnumDisplayDevices ( $sDevice, $iDevNum )

Parameters

$sDevice | Device name. If blank, the function returns information for the display adapters on the machine based on $iDevNum.
$iDevNum | 0-based index value that specifies the display device of interest

Return Value

Success: | an array with the following format: $aDevice[0] - True $aDevice[1] - Either the adapter device or the monitor device $aDevice[2] - Either a description of the adapter or the monitor $aDevice[3] - Device state flags: 1 - The device is part of the desktop 2 - The primary desktop is on the device 4 - Represents a pseudo device used to mirror application drawing for remoting 8 - The device is VGA compatible 16 - The device is removable; it cannot be the primary display 32 - The device has more display modes than its output devices support $aDevice[4] - reserved
Failure: | sets the @error flag to non-zero.

See Also

Search EnumDisplayDevices in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $aDevice, $i = 0, $sText
    While 1
        $aDevice = _WinAPI_EnumDisplayDevices("", $i)
        If @error Or Not $aDevice[0] Then ExitLoop
        $sText = "Successful? " & $aDevice[0] & @CRLF
        $sText &= "Device (Adapter or Monitor): " & $aDevice[1] & @CRLF
        $sText &= "Description (Adapter or Monitor): " & $aDevice[2] & @CRLF
        $sText &= "Device State Flag: " & $aDevice[3] & @CRLF
        If BitAND($aDevice[3], 32) Then $sText &= @TAB & "- The device has more display modes than its output devices support" & @CRLF

        If BitAND($aDevice[3], 16) Then $sText &= @TAB & "- The device is removable; it cannot be the primary display" & @CRLF
        If BitAND($aDevice[3], 8) Then $sText &= @TAB & "- The device is VGA compatible" & @CRLF
        If BitAND($aDevice[3], 4) Then $sText &= @TAB & "- Represents a pseudo device used to mirror application drawing for remoting" & @CRLF
        If BitAND($aDevice[3], 2) Then $sText &= @TAB & "- The primary desktop is on the device" & @CRLF
        If BitAND($aDevice[3], 1) Then $sText &= @TAB & "- The device is part of the desktop" & @CRLF

        $sText &= "Plug and Play identifier string: " & $aDevice[4] & @CRLF
        MsgBox($MB_SYSTEMMODAL, "", $sText)
        $i += 1
    WEnd
EndFunc   ;==>Example


Function _WinAPI_EnumWindows

Function Reference

_WinAPI_EnumWindows

Enumerates all windows

#include <WinAPI.au3>
_WinAPI_EnumWindows ( [$bVisible = True [, $hWnd = Default]] )

Parameters

$bVisible | [optional] Window selection flag: True - Returns only visible windows False - Returns all windows
$hWnd | [optional] Handle of the starting windows (default Desktop windows)

Return Value

Returns an array with the following format:
[0][0] - Number of rows in array (n)
[1][0] - Window handle
[1][1] - Window class name
[n][0] - Window handle
[n][1] - Window class name

Related

_WinAPI_EnumWindowsPopup, _WinAPI_EnumWindowsTop

Example

#include <Array.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $aWindows = _WinAPI_EnumWindows()
    Local $aResult[$aWindows[0][0]][5]
    For $i = 1 To $aWindows[0][0]
        $aResult[$i - 1][0] = $aWindows[$i][0]
        $aResult[$i - 1][1] = $aWindows[$i][1]
        $aResult[$i - 1][2] = WinGetTitle($aWindows[$i][0])
        $aResult[$i - 1][3] = WinGetText($aWindows[$i][0])
        $aResult[$i - 1][4] = WinGetProcess($aWindows[$i][0])
    Next
    _ArrayDisplay($aResult, "_WinAPI_EnumWindows", Default, Default, Default, Default, "#|Handle|Class|Title|Text|Process")
EndFunc   ;==>Example


Function _WinAPI_EnumWindowsPopup

Function Reference

_WinAPI_EnumWindowsPopup

Enumerates popup windows

#include <WinAPI.au3>
_WinAPI_EnumWindowsPopup ( )

Return Value

Returns an array with the following format:
[0][0] - Number of rows in array (n)
[1][0] - Window handle
[1][1] - Window class name
[n][0] - Window handle
[n][1] - Window class name

Related

_WinAPI_EnumWindows, _WinAPI_EnumWindowsTop

Example

#include <Array.au3>
#include <WinAPI.au3>

ToolTip("test Popup") ; to have at least one popup window

Example()

Func Example()
    Local $aWindows = _WinAPI_EnumWindowsPopup()
    Local $aResult[$aWindows[0][0]][5]
    For $i = 1 To $aWindows[0][0]
        $aResult[$i - 1][0] = $aWindows[$i][0]
        $aResult[$i - 1][1] = $aWindows[$i][1]
        $aResult[$i - 1][2] = WinGetTitle($aWindows[$i][0])
        $aResult[$i - 1][3] = WinGetText($aWindows[$i][0])
        $aResult[$i - 1][4] = WinGetProcess($aWindows[$i][0])
    Next
    _ArrayDisplay($aResult, "_WinAPI_EnumWindowsPopup", Default, Default, Default, Default, "#|Handle|Class|Title|Text|Process")
EndFunc   ;==>Example


Function _WinAPI_EnumWindowsTop

Function Reference

_WinAPI_EnumWindowsTop

Enumerates all top level windows

#include <WinAPI.au3>
_WinAPI_EnumWindowsTop ( )

Return Value

Returns an array with the following format:
[0][0] - Number of rows in array (n)
[1][0] - Window handle
[1][1] - Window class name
[n][0] - Window handle
[n][1] - Window class name

Related

_WinAPI_EnumWindows, _WinAPI_EnumWindowsPopup

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $aWindows, $i, $sText
    $aWindows = _WinAPI_EnumWindowsTop()
    For $i = 1 To $aWindows[0][0]
        $sText = "Window Handle: " & $aWindows[$i][0] & @CRLF
        $sText &= "Window Class: " & $aWindows[$i][1] & @CRLF
        $sText &= "Window Title: " & WinGetTitle($aWindows[$i][0]) & @CRLF
        $sText &= "Window Text: " & WinGetText($aWindows[$i][0]) & @CRLF
        $sText &= "Window Process: " & WinGetProcess($aWindows[$i][0])
        MsgBox($MB_SYSTEMMODAL, "Item " & $i & " of " & $aWindows[0][0], $sText)
    Next
EndFunc   ;==>Example


Function _WinAPI_ExpandEnvironmentStrings

Function Reference

_WinAPI_ExpandEnvironmentStrings

Expands environment variable strings and replaces them with their defined values

#include <WinAPI.au3>
_WinAPI_ExpandEnvironmentStrings ( $sString )

Parameters

$sString String to convert for environment variables

Return Value

Success: | Converted string
Failure: | Set the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information

See Also

Search ExpandEnvironmentStrings in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

MsgBox($MB_SYSTEMMODAL, "Environment string", "%windir% = " & _WinAPI_ExpandEnvironmentStrings("%windir%"))


Function _WinAPI_ExtractIconEx

Function Reference

_WinAPI_ExtractIconEx

Creates an array of handles to large or small icons extracted from a file

#include <WinAPI.au3>
_WinAPI_ExtractIconEx ( $sFilePath, $iIndex, $paLarge, $paSmall, $iIcons )

Parameters

$sFilePath | Name of an executable file, DLL, or icon file from which icons will be extracted
$iIndex | Specifies the 0-based index of the first icon to extract
$paLarge | Pointer to an array of icon handles that receives handles to the large icons extracted from the file. If this parameter is 0, no large icons are extracted from the file.
$paSmall | Pointer to an array of icon handles that receives handles to the small icons extracted from the file. If this parameter is 0, no small icons are extracted from the file.
$iIcons | Specifies the number of icons to extract from the file

Return Value

Returns the number of icons contained in the specified file, when $iIndex is -1, $paLarge parameter is 0, and $paSmall is 0.
Otherwise, the return value is the number of icons successfully extracted from the file.

See Also

Search ExtractIconEx in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

MsgBox($MB_SYSTEMMODAL, "ExtractIconEx", "# of Icons in file shell32.dll: " & _WinAPI_ExtractIconEx("shell32.dll", -1, 0, 0, 0))


Function _WinAPI_FatalAppExit

Function Reference

_WinAPI_FatalAppExit

Displays a message box and terminates the application

#include <WinAPI.au3>
_WinAPI_FatalAppExit ( $sMessage )

Parameters

$sMessage The string that is displayed in the message box

Return Value

None.

Remarks

An application calls FatalAppExit only when it is not capable of terminating any other way.
FatalAppExit may not always free an application's memory or close its files, and it may cause a general failure of the system.
An application that encounters an unexpected error should terminate by freeing all its memory and returning from its main message loop.

See Also

Search FatalAppExit in MSDN Library.


Function _WinAPI_FillRect

Function Reference

_WinAPI_FillRect

Fills a rectangle by using the specified brush

#include <WinAPI.au3>
_WinAPI_FillRect ( $hDC, $tRECT, $hBrush )

Parameters

$hDC | Handle to the device context
$tRECT | a $tagRECT structure or pointer to it that contains the logical coordinates of the rectangle to be filled
$hBrush | Handle to the brush used to fill the rectangle

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

The brush identified by the $hBrush parameter may be either a handle to a logical brush or a color value.
If specifying a handle to a logical brush, call _WinAPI_CreateSolidBrush().
Additionally, you may retrieve a handle to one of the stock brushes by using the _WinAPI_GetStockObject() function.
If specifying a color value for the $hBrush parameter, it must be one of the standard system colors (the value 1 must be added to the chosen color)

See Also

Search FillRect in MSDN Library.


Function _WinAPI_FindExecutable

Function Reference

_WinAPI_FindExecutable

Retrieves the name of the executable file associated with the specified file name

#include <WinAPI.au3>
_WinAPI_FindExecutable ( $sFileName [, $sDirectory = ""] )

Parameters

$sFileName | Fully qualified path to existing file
$sDirectory | [optional] Default directory

Return Value

Success: | The Full path to the executable file started when an "open" by association is run on the file specified
Failure: | Empty string if no association was found, @extended contains an error code as $SE_ERR_*

Remarks

$SE_ERR_* constants require #include <APIShellExConstants.au3>

See Also

Search FindExecutable in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

; Find the executable that is associated with the AutoIt script.
MsgBox($MB_SYSTEMMODAL, "Find Executable", "File: " & @ScriptFullPath & @CRLF & "Executable: " & _WinAPI_FindExecutable(@ScriptName))


Function _WinAPI_FindWindow

Function Reference

_WinAPI_FindWindow

Retrieves the handle to the top-level window whose class name and window name match

#include <WinAPI.au3>
_WinAPI_FindWindow ( $sClassName, $sWindowName )

Parameters

$sClassName | A string that specifies the class name or is an atom that identifies the class-name string. If this parameter is an atom, it must be a global atom created by a call to the GlobalAddAtom function. The atom, a 16-bit value, must be placed in the low-order word of the $sClassName string and the high-order word must be zero.
$sWindowName | A string that specifies the window name. If this parameter is blank, all window names match.

Return Value

Success: | The handle to the window
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

See Also

Search FindWindow in MSDN Library.


Function _WinAPI_FlashWindow

Function Reference

_WinAPI_FlashWindow

Flashes the specified window one time

#include <WinAPI.au3>
_WinAPI_FlashWindow ( $hWnd [, $bInvert = True] )

Parameters

$hWnd | Handle to the window to be flashed. The window can be either open or minimized.
$bInvert | [optional] If True, the window is flashed from one state to the other. If False the window is returned to its original state. When an application is minimized and this parameter is True, the taskbar window button flashes active/inactive. If it is False, the taskbar window button flashes inactive, meaning that it does not change colors. It flashes as if it were being redrawn, but it does not provide the visual invert clue to the user.

Return Value

Success: | True
Failure: | False

Remarks

This function does not change the active state of the window.
To flash the window a specified number of times, use the FlashWindowEx function.

Related

_WinAPI_FlashWindowEx

See Also

Search FlashWindow in MSDN Library.

Example

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

Example()

Func Example()
    Local $hWnd, $iMsg, $idBtnFlash
    $hWnd = GUICreate("_WinAPI_FlashWindow Example", 200, 200)
    $idBtnFlash = GUICtrlCreateButton("Flash Window", 50, 85, 100, 30)
    GUISetState(@SW_SHOW)
    While 1
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                Exit
            Case $iMsg = $idBtnFlash
                GUISetState(@SW_MINIMIZE)
                Sleep(1000)
                _WinAPI_FlashWindow($hWnd)
                Sleep(6000)
        EndSelect
    WEnd
EndFunc   ;==>Example


Function _WinAPI_FlashWindowEx

Function Reference

_WinAPI_FlashWindowEx

Flashes the specified window

#include <WinAPI.au3>
_WinAPI_FlashWindowEx ( $hWnd [, $iFlags = 3 [, $iCount = 3 [, $iTimeout = 0]]] )

Parameters

$hWnd | Handle to the window to be flashed. The window can be either open or minimized.
$iFlags | [optional] The flash status. Can be one or more of the following values: 0 - Stop flashing. The system restores the window to its original state. 1 - Flash the window caption 2 - Flash the taskbar button 4 - Flash continuously until stopped 8 - Flash continuously until the window comes to the foreground
$iCount | [optional] The number of times to flash the window
$iTimeout | [optional] The rate at which the window is to be flashed, in milliseconds. If 0, the function uses the default cursor blink rate.

Return Value

Success: | True
Failure: | False

Remarks

Typically, you flash a window to inform the user that the window requires attention but does not currently have the keyboard focus.
When a window flashes, it appears to change from inactive to active status.
An inactive caption bar changes to an active caption bar; an active caption bar changes to an inactive caption bar.

Related

_WinAPI_FlashWindow

See Also

Search FlashWindowEx in MSDN Library.

Example

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

Example()

Func Example()
    Local $hWnd, $idFlash, $idTimeout, $idBtnFlash, $iMsg, $iFlashrate, $iTimeoutrate, $bFlashing = False
    $hWnd = GUICreate("Form1", 229, 170, 193, 125)
    $idFlash = GUICtrlCreateInput("20", 80, 72, 121, 21)
    $idTimeout = GUICtrlCreateInput("500", 80, 103, 121, 21)
    GUICtrlCreateLabel("Please input the flash rate, and the time between flashes", 8, 24, 214, 41)
    GUICtrlCreateLabel("Flash Rate:", 16, 72, 58, 17)
    GUICtrlCreateLabel("Timeout (ms)", 16, 104, 64, 17)
    $idBtnFlash = GUICtrlCreateButton("Flash Window", 80, 136, 75, 25, 0)
    GUISetState(@SW_SHOW)

    While 1
        $iMsg = GUIGetMsg()
        Switch $iMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $idBtnFlash
                If $bFlashing Then
                    _WinAPI_FlashWindowEx($hWnd, 0)
                    $bFlashing = False
                Else
                    $iFlashrate = GUICtrlRead($idFlash)
                    $iTimeoutrate = GUICtrlRead($idTimeout)
                    _WinAPI_FlashWindowEx($hWnd, 2, $iFlashrate, $iTimeoutrate)
                    GUICtrlSetData($idBtnFlash, "Stop Flashing")
                    $bFlashing = True
                EndIf
        EndSwitch
    WEnd
EndFunc   ;==>Example


Function _WinAPI_FloatToInt

Function Reference

_WinAPI_FloatToInt

Returns a 4 byte float as an integer value

#include <WinAPI.au3>
_WinAPI_FloatToInt ( $nFloat )

Parameters

$nFloat Float value

Return Value

Returns an 4 byte float value as an integer

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $fFloat, $sText, $iInt
    $fFloat = 10.55
    $iInt = _WinAPI_FloatToInt($fFloat)
    $sText = "The float " & $fFloat & " is converted to the Integer " & $iInt & " (Hex = " & Hex($iInt) & ")"
    MsgBox($MB_SYSTEMMODAL, "_WinAPI_FloatToInt Example Results", $sText)
EndFunc   ;==>Example


Function _WinAPI_FlushFileBuffers

Function Reference

_WinAPI_FlushFileBuffers

Flushes the buffers of a specified file and causes all buffered data to be written

#include <WinAPI.au3>
_WinAPI_FlushFileBuffers ( $hFile )

Parameters

$hFile Handle to an open file. The file handle must have the $GENERIC_WRITE access right.
If $hFile is a handle to a communications device, the function only flushes the transmit buffer.
If $hFile is a handle to the server end of a named pipe the function does not return until the client has read all buffered data from the pipe.

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Related

_WinAPI_CloseHandle, _WinAPI_CreateFile, _WinAPI_GetFileSizeEx, _WinAPI_ReadFile, _WinAPI_SetEndOfFile, _WinAPI_SetFilePointer, _WinAPI_WriteFile

See Also

Search FlushFileBuffers in MSDN Library.


Function _WinAPI_FormatMessage

Function Reference

_WinAPI_FormatMessage

Formats a message string

#include <WinAPI.au3>
_WinAPI_FormatMessage ( $iFlags, $pSource, $iMessageID, $iLanguageID, ByRef $pBuffer, $iSize, $vArguments )

Parameters

$iFlags | Contains a set of bit flags that specify aspects of the formatting process and how to interpret the $pSource parameter. The low-order byte of $iFlags specifies how the function handles line breaks in the output buffer. The low-order byte can also specify the maximum width of a formatted output line.
$pSource | Pointer to message source
$iMessageID | Requested message identifier
$iLanguageID | Language identifier for requested message
$pBuffer | Pointer to message buffer or string variable that will contain the message
$iSize | Maximum size of message buffer
$vArguments | Address of array of message inserts

Return Value

Success: | Number of bytes stored in message buffer
Failure: | Set the @error flag to on-zero, call _WinAPI_GetLastError() to get extended error information

See Also

Search FormatMessage in MSDN Library.


Function _WinAPI_FrameRect

Function Reference

_WinAPI_FrameRect

Draws a border around the specified rectangle by using the specified brush

#include <WinAPI.au3>
_WinAPI_FrameRect ( $hDC, $tRECT, $hBrush )

Parameters

$hDC | Handle to the device context in which the border is drawn
$tRECT | A $tagRECT structure or a pointer to it that contains the logical coordinates of the upper-left and lower-right corners of the rectangle
$hBrush | Handle to the brush used to draw the border

Return Value

Success: | True
Failure: | False

Remarks

The brush identified by the $hBrush parameter must have been created by using the _WinAPI_CreateSolidBrush() function, or retrieved by using the _WinAPI_GetStockObject() function

Related

$tagRECT

See Also

Search FrameRect in MSDN Library.


Function _WinAPI_FreeLibrary

Function Reference

_WinAPI_FreeLibrary

Decrements the reference count of the loaded dynamic-link library (DLL) module

#include <WinAPI.au3>
_WinAPI_FreeLibrary ( $hModule )

Parameters

$hModule Identifies the loaded library module

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Related

_WinAPI_LoadLibrary, _WinAPI_LoadLibraryEx, _WinAPI_LoadString

See Also

Search FreeLibrary in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $idInput, $id_Get, $hReBar, $hInstance, $sText
    ; Create GUI
    $hGUI = GUICreate("WinAPI", 400, 396)

    $idInput = GUICtrlCreateInput("4209", 0, 0, 100, 20)

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGUI, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 55, 396, 200, BitOR($WS_VSCROLL, $WS_HSCROLL))
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ;add band containing the  control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "String ID:")

    $id_Get = GUICtrlCreateButton("Get String", 0, 0, 90, 20)

    ;add band containing the  control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($id_Get), 120, 200)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $id_Get
                GUICtrlSetData($g_idMemo, "")
                $hInstance = _WinAPI_LoadLibraryEx("shell32.dll", $LOAD_LIBRARY_AS_DATAFILE)
                If $hInstance Then
                    $sText = _WinAPI_LoadString($hInstance, GUICtrlRead($idInput))
                    If Not @error Then
                        MemoWrite('Got the String (chars: ' & @extended & '): ' & @CRLF & $sText)
                    Else
                        MemoWrite("Last Error Message: " & @CRLF & _WinAPI_GetLastErrorMessage())
                    EndIf
                    MemoWrite(@CRLF & "Success Freeing? " & _WinAPI_FreeLibrary($hInstance))
                EndIf
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _WinAPI_GetAncestor

Function Reference

_WinAPI_GetAncestor

Retrieves the handle to the ancestor of the specified window

#include <WinAPI.au3>
_WinAPI_GetAncestor ( $hWnd [, $iFlags = 1] )

Parameters

$hWnd | Handle to the window whose ancestor is to be retrieved. If this is the desktop window, the function returns 0.
$iFlags | [optional] Specifies the ancestor to be retrieved. This parameter can be one of the following values: $GA_PARENT - Retrieves the parent window $GA_ROOT - Retrieves the root window by walking the chain of parent windows $GA_ROOTOWNER - Retrieves the owned root window by walking the chain of parent and owner windows returned by GetParent.

Return Value

Returns the handle of the ancestor window

Remarks

Above constants require #include <WindowsConstants.au3>

Related

_WinAPI_GetParent

See Also

Search GetAncestor in MSDN Library.

Example

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

Example()

Func Example()
    Local $hWnd, $hParent
    $hWnd = GUICreate("test")
    $hParent = _WinAPI_GetAncestor($hWnd, $GA_PARENT)
    MsgBox($MB_SYSTEMMODAL, "Parent", "Get Ancestor of " & $hWnd & ": " & $hParent)
    MsgBox($MB_SYSTEMMODAL, "Root", "Get Ancestor of " & $hParent & ": " & _WinAPI_GetAncestor($hWnd, $GA_ROOT))
    MsgBox($MB_SYSTEMMODAL, "Root Owner", "Get Ancestor of " & $hParent & ": " & _WinAPI_GetAncestor($hWnd, $GA_ROOTOWNER))
EndFunc   ;==>Example


Function _WinAPI_GetAsyncKeyState

Function Reference

_WinAPI_GetAsyncKeyState

Determines whether a key is up or down at the time the function is called

#include <WinAPI.au3>
_WinAPI_GetAsyncKeyState ( $iKey )

Parameters

$iKey Key to test for

Return Value

Success: | If the most significant bit is set the key is down, and if the least significant bit is set, the key was pressed after the previous call to _WinAPI_GetAsyncKeyState(). However, you should not rely on this last behavior; for more information, see the Remarks.
Failure: | The return value is zero if the key isn't down, or for the following cases: The current desktop is not the active desktop The foreground thread belongs to another process and the desktop does not allow the hook or the journal record.

Remarks

The constants to use for $iKey can be found in WinAPIvkeysConstants.au3

The GetAsyncKeyState function works with mouse buttons. However, it checks on the state of the physical mouse buttons, not on the logical mouse buttons that the physical buttons are mapped to. For example, the call _WinAPI_GetAsyncKeyState($VK_LBUTTON) always returns the state of the left physical mouse button, regardless of whether it is mapped to the left or right logical mouse button. You can determine the system's current mapping of physical mouse buttons to logical mouse buttons by calling _WinAPI_GetSystemMetrics($SM_SWAPBUTTON), which returns TRUE if the mouse buttons have been swapped.

Although the least significant bit of the return value indicates whether the key has been pressed since the last query, due to the pre-emptive multitasking nature of Windows, another application can call GetAsyncKeyState and receive the "recently pressed" bit instead of your application. The behavior of the least significant bit of the return value is retained strictly for compatibility with 16-bit Windows applications (which are non-preemptive) and should not be relied upon.

You can use the virtual-key code constants $VK_SHIFT, $VK_CONTROL, and $VK_MENU as values for the vKey parameter. This gives the state of the SHIFT, CTRL, or ALT keys without distinguishing between left and right.

See Also

Search GetAsyncKeyState in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIvkeysConstants.au3>

Example()

Func Example()
    Local $hGUI = GUICreate("_WinAPI_GetAsyncKeyState Demo", 500, 300)
    GUICtrlCreateLabel("Press the number to select the task you wish to use from list below", 10, 30)
    GUICtrlCreateLabel("Press 1 key for task 1" & @CRLF & @CRLF & _
            "Press 2 key for task 2" & @CRLF & @CRLF & _
            "Press 3 key for task 3" & @CRLF & @CRLF & _
            "Press the ESCAPE key, or click the close button, to exit", 10, 60)
    GUISetState(@SW_SHOW)

    Local Const $iBitMask = 0x8000 ; a bit mask to strip the high word bits from the return of the function.
    While GUIGetMsg() <> $GUI_EVENT_CLOSE
        If BitAND(_WinAPI_GetAsyncKeyState($VK_1), $iBitMask) <> 0 Or BitAND(_WinAPI_GetAsyncKeyState($VK_NUMPAD1), $iBitMask) <> 0 Then
            MsgBox($MB_SYSTEMMODAL, "_WinAPI_GetAsyncKeyState", "Task 1")
        ElseIf BitAND(_WinAPI_GetAsyncKeyState($VK_2), $iBitMask) <> 0 Or BitAND(_WinAPI_GetAsyncKeyState($VK_NUMPAD2), $iBitMask) <> 0 Then
            MsgBox($MB_SYSTEMMODAL, "_WinAPI_GetAsyncKeyState", "Task 2")
        ElseIf BitAND(_WinAPI_GetAsyncKeyState($VK_3), $iBitMask) <> 0 Or BitAND(_WinAPI_GetAsyncKeyState($VK_NUMPAD3), $iBitMask) <> 0 Then
            MsgBox($MB_SYSTEMMODAL, "_WinAPI_GetAsyncKeyState", "Task 3")
        ElseIf BitAND(_WinAPI_GetAsyncKeyState($VK_ESCAPE), $iBitMask) <> 0 Then
            MsgBox($MB_SYSTEMMODAL, "_WinAPI_GetAsyncKeyState", "The Esc Key was pressed, exiting.")
            ExitLoop
        EndIf
    WEnd
    GUIDelete($hGUI)
EndFunc   ;==>Example


Function _WinAPI_GetBkMode

Function Reference

_WinAPI_GetBkMode

Returns the current background mix mode for a specified device context

#include <WinAPI.au3>
_WinAPI_GetBkMode ( $hDC )

Parameters

$hDC Handle to the device context whose background mode is to be returned

Return Value

Success: | Value specifies the current background mix mode, either OPAQUE or TRANSPARENT
Failure: | 0

Remarks

The background mix mode of a device context affects text, hatched brushes, and pen styles that are not solid lines.

Related

_WinAPI_CreatePen, _WinAPI_DrawText, _WinAPI_SelectObject, _WinAPI_SetBkMode

See Also

Search GetBkMode in MSDN Library.

Example

#include <FontConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global $g_tRECT, $g_hFont, $g_hOldFont, $g_hDC

HotKeySet("{ESC}", "_Exit")

$g_tRECT = DllStructCreate($tagRect)
DllStructSetData($g_tRECT, "Left", 5)
DllStructSetData($g_tRECT, "Top", 5)
DllStructSetData($g_tRECT, "Right", 250)
DllStructSetData($g_tRECT, "Bottom", 50)

$g_hDC = _WinAPI_GetDC(0)
$g_hFont = _WinAPI_CreateFont(50, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _
        $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')
$g_hOldFont = _WinAPI_SelectObject($g_hDC, $g_hFont)

_WinAPI_SetTextColor($g_hDC, 0x0000FF)
_WinAPI_SetBkColor($g_hDC, 0x000000)

MsgBox($MB_SYSTEMMODAL, "Information", "GetBkMode: " & _WinAPI_GetBkMode($g_hDC))

; comment next line to get black background instead of transparent one
_WinAPI_SetBkMode($g_hDC, $TRANSPARENT)

MsgBox($MB_SYSTEMMODAL, "Information", "GetBkMode: " & _WinAPI_GetBkMode($g_hDC))

While 1
    _WinAPI_DrawText($g_hDC, "Hello world!", $g_tRECT, $DT_CENTER)
    Sleep(100)
WEnd

Func _Exit()
    _WinAPI_SelectObject($g_hDC, $g_hOldFont)
    _WinAPI_DeleteObject($g_hFont)
    _WinAPI_ReleaseDC(0, $g_hDC)
    _WinAPI_InvalidateRect(0, 0)
    $g_tRECT = 0
    Exit
EndFunc   ;==>_Exit


Function _WinAPI_GetClassName

Function Reference

_WinAPI_GetClassName

Retrieves the name of the class to which the specified window belongs

#include <WinAPI.au3>
_WinAPI_GetClassName ( $hWnd )

Parameters

$hWnd Handle of window

Return Value

Success: | The window class name
Failure: | Empty string, call _WinAPI_GetLastError() to get extended error information

See Also

Search GetClassName in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hWnd
    $hWnd = GUICreate("test")
    MsgBox($MB_SYSTEMMODAL, "Get ClassName", "ClassName of " & $hWnd & ": " & _WinAPI_GetClassName($hWnd))
EndFunc   ;==>Example


Function _WinAPI_GetClientHeight

Function Reference

_WinAPI_GetClientHeight

Retrieves the height of a window's client area

#include <WinAPI.au3>
_WinAPI_GetClientHeight ( $hWnd )

Parameters

$hWnd Handle of window

Return Value

Success: | the client area height.
Failure: | sets the @error flag to non-zero.

Related

_WinAPI_GetClientWidth

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hWnd
    $hWnd = GUICreate("test")
    MsgBox($MB_SYSTEMMODAL, "Client", "Client Height: " & _WinAPI_GetClientHeight($hWnd))
EndFunc   ;==>Example


Function _WinAPI_GetClientRect

Function Reference

_WinAPI_GetClientRect

Retrieves the coordinates of a window's client area

#include <WinAPI.au3>
_WinAPI_GetClientRect ( $hWnd )

Parameters

$hWnd Handle of window

Return Value

Success: | $tagRECT structure that receives the client coordinates
Failure: | Sets the @error flag to non-zero. call _WinAPI_GetLastError() to get extended error information.

Related

$tagRECT

See Also

Search GetClientRect in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hWnd, $tRECT
    $hWnd = GUICreate("test")
    $tRECT = _WinAPI_GetClientRect($hWnd)
    MsgBox($MB_SYSTEMMODAL, "Rect", _
            "Left..: " & DllStructGetData($tRECT, "Left") & @CRLF & _
            "Right.: " & DllStructGetData($tRECT, "Right") & @CRLF & _
            "Top...: " & DllStructGetData($tRECT, "Top") & @CRLF & _
            "Bottom: " & DllStructGetData($tRECT, "Bottom"))
EndFunc   ;==>Example


Function _WinAPI_GetClientWidth

Function Reference

_WinAPI_GetClientWidth

Retrieves the width of a window's client area

#include <WinAPI.au3>
_WinAPI_GetClientWidth ( $hWnd )

Parameters

$hWnd Handle of window

Return Value

Success: | the client area width.
Failure: | sets the @error flag to non-zero.

Related

_WinAPI_GetClientHeight

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hWnd
    $hWnd = GUICreate("test")
    MsgBox($MB_SYSTEMMODAL, "Client", "Client Width: " & _WinAPI_GetClientWidth($hWnd))
EndFunc   ;==>Example


Function _WinAPI_GetCurrentProcess

Function Reference

_WinAPI_GetCurrentProcess

Returns the process handle of the calling process

#include <WinAPI.au3>
_WinAPI_GetCurrentProcess ( )

Return Value

Returns the Process handle of the calling process

Related

_WinAPI_GetCurrentProcessID

See Also

Search GetCurrentProcess in MSDN Library.


Function _WinAPI_GetCurrentProcessID

Function Reference

_WinAPI_GetCurrentProcessID

Returns the process identifier of the calling process

#include <WinAPI.au3>
_WinAPI_GetCurrentProcessID ( )

Return Value

Returns the Process identifier of the calling process

Related

_WinAPI_GetCurrentProcess, _WinAPI_GetWindowThreadProcessId

See Also

Search GetCurrentProcessId in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

MsgBox($MB_SYSTEMMODAL, "ID", "Get Current Process: " & _WinAPI_GetCurrentProcessID())


Function _WinAPI_GetCurrentThread

Function Reference

_WinAPI_GetCurrentThread

Retrieves a pseudo handle for the calling thread

#include <WinAPI.au3>
_WinAPI_GetCurrentThread ( )

Return Value

Returns the Pseudo handle for the current thread

Remarks

A pseudo handle is a special constant that is interpreted as the current thread handle.
The calling thread can use this handle to specify itself whenever a thread handle is required.

See Also

Search GetCurrentThread in MSDN Library.


Function _WinAPI_GetCurrentThreadId

Function Reference

_WinAPI_GetCurrentThreadId

Returns the thread identifier of the calling thread

#include <WinAPI.au3>
_WinAPI_GetCurrentThreadId ( )

Return Value

Returns the Thread identifier of the calling thread

See Also

Search GetCurrentThreadId in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

MsgBox($MB_SYSTEMMODAL, "ID", "Get Current Thread: " & _WinAPI_GetCurrentThreadId())


Function _WinAPI_GetCursorInfo

Function Reference

_WinAPI_GetCursorInfo

Retrieves information about the global cursor

#include <WinAPI.au3>
_WinAPI_GetCursorInfo ( )

Return Value

Success: | Array with the following format: $aCursor[0] - True $aCursor[1] - True if cursor is showing, otherwise False $aCursor[2] - Handle to the cursor $aCursor[3] - X coordinate of the cursor $aCursor[4] - Y coordinate of the cursor
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information

See Also

Search GetCursorInfo in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $aCursor, $sText
    $aCursor = _WinAPI_GetCursorInfo()
    $sText = "Was the operation sucessful? " & $aCursor[0] & @CRLF
    $sText &= "Is the cursor showing? " & $aCursor[1] & @CRLF & @CRLF
    $sText &= "Cursor Handle: " & $aCursor[2] & @CRLF
    $sText &= "X Coordinate: " & $aCursor[3] & @CRLF
    $sText &= "Y Coordinate: " & $aCursor[4]
    MsgBox($MB_SYSTEMMODAL, "_WinAPI_GetCursorInfo Example", $sText)
EndFunc   ;==>Example


Function _WinAPI_GetDC

Function Reference

_WinAPI_GetDC

Retrieves a handle of a display device context for the client area a window

#include <WinAPI.au3>
_WinAPI_GetDC ( $hWnd )

Parameters

$hWnd Handle of window

Return Value

Success: | The device context for the given window's client area
Failure: | 0

Remarks

After painting with a common device context, the _WinAPI_ReleaseDC() function must be called to release the DC

Related

_WinAPI_DeleteDC, _WinAPI_ReleaseDC

See Also

Search GetDC in MSDN Library.

Example

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

Example()

Func Example()
    Local $hWnd, $hDC
    $hWnd = GUICreate("test")
    $hDC = _WinAPI_GetDC($hWnd)
    MsgBox($MB_SYSTEMMODAL, "Handle", "Display Device: " & $hDC)
    _WinAPI_ReleaseDC($hWnd, $hDC)
EndFunc   ;==>Example


Function _WinAPI_GetDesktopWindow

Function Reference

_WinAPI_GetDesktopWindow

Returns the handle of the Windows desktop window

#include <WinAPI.au3>
_WinAPI_GetDesktopWindow ( )

Return Value

Returns the Handle of the desktop window

See Also

Search GetDesktopWindow in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hWin = _WinAPI_GetDesktopWindow()
    MsgBox($MB_SYSTEMMODAL, "", WinGetTitle($hWin))
    MsgBox($MB_SYSTEMMODAL, "", $hWin)
EndFunc   ;==>Example


Function _WinAPI_GetDeviceCaps

Function Reference

_WinAPI_GetDeviceCaps

Retrieves device specific information about a specified device

#include <WinAPI.au3>
_WinAPI_GetDeviceCaps ( $hDC, $iIndex )

Parameters

$hDC | Identifies the device context
$iIndex | Specifies the item to return

Return Value

Returns the value of the desired item

See Also

Search GetDeviceCaps in MSDN Library.


Function _WinAPI_GetDIBits

Function Reference

_WinAPI_GetDIBits

Retrieves the bits of the specified bitmap and copies them into a buffer as a DIB

#include <WinAPI.au3>
_WinAPI_GetDIBits ( $hDC, $hBitmap, $iStartScan, $iScanLines, $pBits, $tBI, $iUsage )

Parameters

$hDC | Handle to the device context
$hBitmap | Handle to the bitmap. This must be a compatible bitmap (DDB).
$iStartScan | Specifies the first scan line to retrieve
$iScanLines | Specifies the number of scan lines to retrieve
$pBits | Pointer to a buffer to receive the bitmap data. If this parameter is 0, the function passes the dimensions and format of the bitmap to the $tagBITMAPINFO structure pointed to by the $tBI parameter.
$tBI | A $tagBITMAPINFO structure or a pointer to it that specifies the desired format for the DIB data
$iUsage | Specifies the format of the bmiColors member of the $tagBITMAPINFO structure. It must be one of the following values: $DIB_PAL_COLORS - The color table should consist of an array of 16-bit indexes into the current palette $DIB_RGB_COLORS - The color table should consist of literal red, green, blue values

Return Value

Success: | If $pBits is not 0 and the function succeeds, the return value is the number of scan lines copied from the bitmap. If $pBits is 0 and GetDIBits successfully fills the structure, the return value is True.
Failure: | False

Related

$tagBITMAPINFO

See Also

Search GetDIBits in MSDN Library.


Function _WinAPI_GetDlgCtrlID

Function Reference

_WinAPI_GetDlgCtrlID

Returns the identifier of the specified control

#include <WinAPI.au3>
_WinAPI_GetDlgCtrlID ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: | Identifier of the control
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

Remarks

GetDlgCtrlID accepts child window handles as well as handles of controls in dialog boxes.
An application sets the identifier for a child window when it creates the window by assigning the identifier value to the hmenu parameter when calling the CreateWindow or CreateWindowEx function.
Although GetDlgCtrlID may return a value if $hWnd identifies a top-level window, top-level windows cannot have identifiers and such a return value is never valid.

See Also

Search GetDlgCtrlID in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $idButton
    GUICreate("test")
    $idButton = GUICtrlCreateButton("testing", 0, 0)
    MsgBox($MB_SYSTEMMODAL, "ID", "Dialog Control ID: " & _WinAPI_GetDlgCtrlID(GUICtrlGetHandle($idButton)))
EndFunc   ;==>Example


Function _WinAPI_GetDlgItem

Function Reference

_WinAPI_GetDlgItem

Retrieves the handle of a control in the specified dialog box

#include <WinAPI.au3>
_WinAPI_GetDlgItem ( $hWnd, $iItemID )

Parameters

$hWnd | Handle to the dialog box
$iItemID | Specifies the identifier of the control to be retrieved

Return Value

Success: | The window handle of the given control
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

Remarks

You can use the GetDlgItem function with any parent-child window pair, not just with dialog boxes.
As long as the $hWnd parameter specifies a parent window and the child window has a unique identifier, GetDlgItem returns a valid handle to the child window.

See Also

Search GetDlgItem in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hWnd, $idButton
    $hWnd = GUICreate("test")
    $idButton = GUICtrlCreateButton("button", 0, 0)
    MsgBox($MB_SYSTEMMODAL, "Handle", "Get Dialog Item: " & _WinAPI_GetDlgItem($hWnd, $idButton))
EndFunc   ;==>Example


Function _WinAPI_GetFileSizeEx

Function Reference

_WinAPI_GetFileSizeEx

Retrieves the size of the specified file

#include <WinAPI.au3>
_WinAPI_GetFileSizeEx ( $hFile )

Parameters

$hFile Handle to the file whose size is to be returned

Return Value

Success: | File size
Failure: | (-1), call _WinAPI_GetLastError() to get extended error information

Related

_WinAPI_CloseHandle, _WinAPI_CreateFile, _WinAPI_FlushFileBuffers, _WinAPI_ReadFile, _WinAPI_SetEndOfFile, _WinAPI_SetFilePointer, _WinAPI_WriteFile

See Also

Search GetFileSizeEx in MSDN Library.

Example

#include <WinAPI.au3>

Local $sTempFile, $hFile, $sText, $nBytes, $tBuffer, $iSize

; 1) create file and write data to it
$sTempFile = @TempDir & '\test.txt'
$sText = 'abcdefghijklmnopqrstuvwxyz'
$tBuffer = DllStructCreate("byte[" & StringLen($sText) & "]")
DllStructSetData($tBuffer, 1, $sText)
$hFile = _WinAPI_CreateFile($sTempFile, 1)
_WinAPI_WriteFile($hFile, $tBuffer, StringLen($sText), $nBytes)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_CloseHandle($hFile)
ConsoleWrite('1):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

; 2) read 6 bytes from position 3
$tBuffer = DllStructCreate("byte[6]")
$hFile = _WinAPI_CreateFile($sTempFile, 2, 2)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_SetFilePointer($hFile, 3)
_WinAPI_ReadFile($hFile, $tBuffer, 6, $nBytes)
_WinAPI_CloseHandle($hFile)
$sText = BinaryToString(DllStructGetData($tBuffer, 1))
ConsoleWrite('2):' & $iSize & ' ' & $sText & @CRLF)

; 3) write previously read 6 bytes from position 3 to the same position but in UpperCase
DllStructSetData($tBuffer, 1, StringUpper($sText))
$hFile = _WinAPI_CreateFile($sTempFile, 2, 4)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_SetFilePointer($hFile, 3)
_WinAPI_WriteFile($hFile, $tBuffer, 6, $nBytes)
_WinAPI_CloseHandle($hFile)
$tBuffer = 0
ConsoleWrite('3):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

; 4) truncate file size to 12 bytes
$hFile = _WinAPI_CreateFile($sTempFile, 2, 4)
_WinAPI_SetFilePointer($hFile, 12)
_WinAPI_SetEndOfFile($hFile)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_CloseHandle($hFile)
ConsoleWrite('4):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

FileDelete($sTempFile)


Function _WinAPI_GetFocus

Function Reference

_WinAPI_GetFocus

Retrieves the handle of the window that has the keyboard focus

#include <WinAPI.au3>
_WinAPI_GetFocus ( )

Return Value

Success: | The handle of the window with the keyboard focus
Failure: | 0

See Also

Search GetFocus in MSDN Library.

Example

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

Example()

Func Example()
    Local $iMsg, $idBtnFocus, $hWin, $sText
    GUICreate("__WinAPI_GetFocus Example", 200, 200)
    $idBtnFocus = GUICtrlCreateButton("Get Focus", 50, 85, 100, 30)
    GUISetState(@SW_SHOW)
    While 1
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                Exit
            Case $iMsg = $idBtnFocus
                $hWin = _WinAPI_GetFocus()
                $sText = "Full Title: " & WinGetTitle($hWin) & @CRLF
                $sText &= "Full Text: " & WinGetText($hWin) & @CRLF
                $sText &= "Handle: " & WinGetHandle($hWin) & @CRLF
                $sText &= "Process: " & WinGetProcess($hWin) & @CRLF
                MsgBox($MB_SYSTEMMODAL, "", $sText)
        EndSelect
    WEnd
EndFunc   ;==>Example


Function _WinAPI_GetForegroundWindow

Function Reference

_WinAPI_GetForegroundWindow

Returns the handle of the foreground window

#include <WinAPI.au3>
_WinAPI_GetForegroundWindow ( )

Return Value

Success: | Handle of the foreground window
Failure: | The foreground window can be NULL in certain circumstances, such as when a window is losing activation

See Also

Search GetForegroundWindow in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

MsgBox($MB_SYSTEMMODAL, "Handle", "Get Foreground Window: " & _WinAPI_GetForegroundWindow())


Function _WinAPI_GetGuiResources

Function Reference

_WinAPI_GetGuiResources

Retrieves the count of handles to graphical user interface (GUI) objects in use by the specified process

#include <WinAPI.au3>
_WinAPI_GetGuiResources ( [$iFlag = 0 [, $hProcess = -1]] )

Parameters

$iFlag | [optional] 0 (Default) Return the count of GDI objects. 1 Return the count of USER objects.
$hProcess | [optional] A handle to the process. By default the current process.

Return Value

Success: | The count of handles to GUI objects in use by the process, according to $iFlag
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

See Also

Search GetGuiResources in MSDN Library.


Function _WinAPI_GetIconInfo

Function Reference

_WinAPI_GetIconInfo

Retrieves information about the specified icon or cursor

#include <WinAPI.au3>
_WinAPI_GetIconInfo ( $hIcon )

Parameters

$hIcon Handle to the icon or cursor.
To retrieve information on a standard icon or cursor, specify one of the following values:
$IDC_APPSTARTING - Standard arrow and small hourglass cursor
$IDC_ARROW - Standard arrow cursor
$IDC_CROSS - Crosshair cursor
$IDC_HAND - Hand cursor
$IDC_HELP - Arrow and question mark cursor
$IDC_IBEAM - I-beam cursor
$IDC_NO - Slashed circle cursor
$IDC_SIZEALL - Four-pointed arrow cursor
$IDC_SIZENESW - Double-pointed arrow cursor pointing NE and SW
$IDC_SIZENS - Double-pointed arrow cursor pointing N and S
$IDC_SIZENWSE - Double-pointed arrow cursor pointing NW and SE
$IDC_SIZEWE - Double-pointed arrow cursor pointing W and E
$IDC_UPARROW - Vertical arrow cursor
$IDC_WAIT - Hourglass cursor
$IDI_APPLICATION - Application icon
$IDI_ASTERISK - Asterisk icon
$IDI_EXCLAMATION - Exclamation point icon
$IDI_HAND - Stop sign icon
$IDI_QUESTION - Question-mark icon
$IDI_WINLOGO - Windows logo icon

Return Value

Success: | Array with the following format: $aIcon[0] - True $aIcon[1] - True specifies an icon, False specifies a cursor $aIcon[2] - Specifies the X coordinate of a cursor's hot spot $aIcon[3] - Specifies the Y coordinate of a cursor's hot spot $aIcon[4] - Specifies the icon bitmask bitmap $aIcon[5] - Handle to the icon color bitmap
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information

Remarks

This function creates bitmaps for the bitmask and color members.
You must manage these bitmaps and delete them when they are no longer necessary.

See Also

Search GetIconInfo in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $aInfo, $sInfo = ""
    $aInfo = _WinAPI_GetIconInfo($IDC_WAIT)
    For $x = 0 To UBound($aInfo) - 1
        $sInfo &= $aInfo[$x] & @CRLF
    Next
    MsgBox($MB_SYSTEMMODAL, "Icon", "Get Icon Info: " & @CRLF & $sInfo)
EndFunc   ;==>Example


Function _WinAPI_GetLastError

Function Reference

_WinAPI_GetLastError

Returns the calling thread's lasterror code value

#include <WinAPI.au3>
_WinAPI_GetLastError ( )

Return Value

Returns the Last error code

Related

_WinAPI_GetLastErrorMessage

See Also

Search GetLastError in MSDN Library.


Function _WinAPI_GetLastErrorMessage

Function Reference

_WinAPI_GetLastErrorMessage

Returns the calling threads last error message

#include <WinAPI.au3>
_WinAPI_GetLastErrorMessage ( )

Return Value

Success: | the last error message.
Failure: | sets the @error flag to non-zero.

Related

_WinAPI_GetLastError


Function _WinAPI_GetLayeredWindowAttributes

Function Reference

_WinAPI_GetLayeredWindowAttributes

Gets Layered Window Attributes

#include <WinAPI.au3>
_WinAPI_GetLayeredWindowAttributes ( $hWnd, ByRef $iTransColor, ByRef $iTransGUI [, $bColorRef = False] )

Parameters

$hWnd | Handle of GUI to work on
$iTransColor | Returns Transparent color ( dword as 0x00bbggrr or string "0xRRGGBB")
$iTransGUI | Returns Transparancy of GUI
$bColorRef | [optional] If True, $iTransColor will be a COLORREF( 0x00bbggrr ), else an RGB-Color

Return Value

Success: | Usage of LWA_ALPHA and LWA_COLORKEY (use BitAND)
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

Related

_WinAPI_GetLastError, _WinAPI_SetLayeredWindowAttributes

See Also

Search GetLayeredWindowAttributes in MSDN Library.

Example

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

Local $hGui = GUICreate("trans", 300, 400, -1, -1, -1, $WS_EX_LAYERED)
GUICtrlCreateLabel("This is text on a transparent Layered GUI", 10, 10, 200, 20, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetTip(-1, "Click label to drag layered window")
Local $idLayButt = GUICtrlCreateButton("Button", 10, 40, 40)
GUISetBkColor(0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($hGui, 0x010101)
GUISetState(@SW_SHOW)

Local $hGuicontrol = GUICreate("ControlGUI", 300, 400, 100, 100)
Local $idCheckTrans = GUICtrlCreateCheckbox("Transparent color 0xABCDEF (Checked) Or 0x010101", 10, 10)
Local $idCheckBorder = GUICtrlCreateCheckbox("POPUP-Style", 10, 30)
GUICtrlCreateLabel("Transparency for Layered GUI", 10, 50)
Local $idSlTrans = GUICtrlCreateSlider(10, 70, 200, 30)
GUICtrlSetLimit($idSlTrans, 255, 0)
GUICtrlSetData(-1, 255)
GUISetState(@SW_SHOW)

While 1
    Local $aExtMsg = GUIGetMsg(1)
    Local $iMsg = $aExtMsg[0]
    Switch $aExtMsg[1]
        Case $hGuicontrol
            Select
                Case $iMsg = $GUI_EVENT_CLOSE
                    Exit
                Case $iMsg = $idCheckTrans Or $iMsg = $idSlTrans

                    ; Change Attributes of Trans-Color and Window Transparency

                    If BitAND(GUICtrlRead($idCheckTrans), $GUI_CHECKED) = $GUI_CHECKED Then
                        _WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF, GUICtrlRead($idSlTrans))
                    Else
                        _WinAPI_SetLayeredWindowAttributes($hGui, 0x010101, GUICtrlRead($idSlTrans))
                    EndIf

                Case $iMsg = $idCheckBorder
                    If BitAND(GUICtrlRead($idCheckBorder), $GUI_CHECKED) = $GUI_CHECKED Then
                        GUISetStyle($WS_POPUP, -1, $hGui)
                    Else
                        GUISetStyle($GUI_SS_DEFAULT_GUI, -1, $hGui)
                    EndIf
            EndSelect
        Case $hGui
            Select
                Case $iMsg = $idLayButt
                    Local $iTransColor, $iAlpha
                    Local $iInfo = _WinAPI_GetLayeredWindowAttributes($hGui, $iTransColor, $iAlpha)
                    MsgBox($MB_SYSTEMMODAL, 'Layered GUI', "Button on layered Window Clicked" & @CRLF & "Information about this window: " & @CRLF & _
                            "Transparent Color: " & $iTransColor & @CRLF & _
                            "Alpha Value: " & $iAlpha & @CRLF & _
                            "LWA_COLORKEY: " & (BitAND($iInfo, $LWA_COLORKEY) = $LWA_COLORKEY) & @CRLF & _
                            "LWA_ALPHA: " & (BitAND($iInfo, $LWA_ALPHA) = $LWA_ALPHA))
                Case $iMsg = $GUI_EVENT_CLOSE
                    Exit MsgBox($MB_SYSTEMMODAL, '', "Close from Layered GUI")
            EndSelect
    EndSwitch
WEnd


Function _WinAPI_GetModuleHandle

Function Reference

_WinAPI_GetModuleHandle

Returns a module handle for the specified module

#include <WinAPI.au3>
_WinAPI_GetModuleHandle ( $sModuleName )

Parameters

$sModuleName Names a Win32 module (either a .dll or .exe file). If the filename extension is omitted, the
default library extension .dll is appended. The filename string can include a trailing point character (.) to
indicate that the module name has no extension. The string does not have to specify a path. The name is
compared (case independently) to the names of modules currently mapped into the address space of the calling
process. If this parameter is the Null keyword then the function returns a handle of the file used to create the calling process.

Return Value

Success: | The handle to the specified module
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

See Also

Search GetModuleHandle in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global $g_hHook, $g_hStub_KeyProc, $g_sBuffer = ""

Example()

Func Example()
    OnAutoItExitRegister("Cleanup")

    Local $hMod

    $g_hStub_KeyProc = DllCallbackRegister("_KeyProc", "long", "int;wparam;lparam")
    $hMod = _WinAPI_GetModuleHandle(0)
    $g_hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($g_hStub_KeyProc), $hMod)

    MsgBox($MB_SYSTEMMODAL, "", "Click OK, then in notepad type..." & _
            @CRLF & @CRLF & "Jon" & @CRLF & "AutoIt" & @CRLF & @CRLF & "Press Esc to exit script")

    Run("notepad.exe")
    WinWait("[CLASS:Notepad]")
    WinActivate("[CLASS:Notepad]")

    While 1
        Sleep(10)
    WEnd
EndFunc   ;==>Example

Func EvaluateKey($iKeycode)
    If (($iKeycode > 64) And ($iKeycode < 91)) _ ; a - z
            Or (($iKeycode > 96) And ($iKeycode < 123)) _ ; A - Z
            Or (($iKeycode > 47) And ($iKeycode < 58)) Then ; 0 - 9
        $g_sBuffer &= Chr($iKeycode)
        Switch $g_sBuffer
            Case "Jon"
                ToolTip("What can you say?")
            Case "AutoIt"
                ToolTip("AutoIt Rocks")
        EndSwitch
    ElseIf ($iKeycode > 159) And ($iKeycode < 164) Then
        Return
    ElseIf ($iKeycode = 27) Then ; esc key
        Exit
    Else
        $g_sBuffer = ""
    EndIf
EndFunc   ;==>EvaluateKey

; ===========================================================
; callback function
; ===========================================================
Func _KeyProc($nCode, $wParam, $lParam)
    Local $tKEYHOOKS
    $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam)
    If $nCode < 0 Then
        Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam)
    EndIf
    If $wParam = $WM_KEYDOWN Then
        EvaluateKey(DllStructGetData($tKEYHOOKS, "vkCode"))
    Else
        Local $iFlags = DllStructGetData($tKEYHOOKS, "flags")
        Switch $iFlags
            Case $LLKHF_ALTDOWN
                ConsoleWrite("$LLKHF_ALTDOWN" & @CRLF)
            Case $LLKHF_EXTENDED
                ConsoleWrite("$LLKHF_EXTENDED" & @CRLF)
            Case $LLKHF_INJECTED
                ConsoleWrite("$LLKHF_INJECTED" & @CRLF)
            Case $LLKHF_UP
                ConsoleWrite("$LLKHF_UP: scanCode - " & DllStructGetData($tKEYHOOKS, "scanCode") & @TAB & "vkCode - " & DllStructGetData($tKEYHOOKS, "vkCode") & @CRLF)
        EndSwitch
    EndIf
    Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam)
EndFunc   ;==>_KeyProc

Func Cleanup()
    _WinAPI_UnhookWindowsHookEx($g_hHook)
    DllCallbackFree($g_hStub_KeyProc)
EndFunc   ;==>Cleanup


Function _WinAPI_GetMousePos

Function Reference

_WinAPI_GetMousePos

Returns the current mouse position

#include <WinAPI.au3>
_WinAPI_GetMousePos ( [$bToClient = False [, $hWnd = 0]] )

Parameters

$bToClient | [optional] If True, the coordinates will be converted to client coordinates
$hWnd | [optional] Window handle used to convert coordinates if $bToClient is True

Return Value

Success: | a $tagPOINT structure with current mouse position.
Failure: | sets the @error flag to non-zero.

Remarks

This function takes into account the current MouseCoordMode setting when obtaining the mouse position. It
will also convert screen to client coordinates based on the parameters passed.

Related

$tagPOINT, _WinAPI_GetMousePosX, _WinAPI_GetMousePosY

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hWnd = GUICreate("test")
    Local $tPoint = _WinAPI_GetMousePos()
    Local $tPoint2 = _WinAPI_GetMousePos(True, $hWnd)

    MsgBox($MB_SYSTEMMODAL, "Mouse Pos", _
            "X = " & DllStructGetData($tPoint, "X") & @CRLF & "Y = " & DllStructGetData($tPoint, "Y") & @CRLF & @CRLF & _
            "Client" & @CRLF & "X = " & DllStructGetData($tPoint2, "X") & @CRLF & "Y = " & DllStructGetData($tPoint2, "Y"))
EndFunc   ;==>Example


Function _WinAPI_GetMousePosX

Function Reference

_WinAPI_GetMousePosX

Returns the current mouse X position

#include <WinAPI.au3>
_WinAPI_GetMousePosX ( [$bToClient = False [, $hWnd = 0]] )

Parameters

$bToClient | [optional] If True, the coordinates will be converted to client coordinates
$hWnd | [optional] Window handle used to convert coordinates if $bToClient is True

Return Value

Success: | the mouse X position
Failure: | sets the @error flag to non-zero.

Remarks

This function takes into account the current MouseCoordMode setting when obtaining the mouse position. It
will also convert screen to client coordinates based on the parameters passed.

Related

_WinAPI_GetMousePos

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hWnd = GUICreate("test")
    Local $iX = _WinAPI_GetMousePosX()
    Local $iX2 = _WinAPI_GetMousePosX(True, $hWnd)
    Local $iY = _WinAPI_GetMousePosY()
    Local $iY2 = _WinAPI_GetMousePosY(True, $hWnd)

    MsgBox($MB_SYSTEMMODAL, "Mouse Pos", "X = " & $iX & @CRLF & "Y = " & $iY & @CRLF & @CRLF & _
            "Client" & @CRLF & "X = " & $iX2 & @CRLF & "Y = " & $iY2)
EndFunc   ;==>Example


Function _WinAPI_GetMousePosY

Function Reference

_WinAPI_GetMousePosY

Returns the current mouse Y position

#include <WinAPI.au3>
_WinAPI_GetMousePosY ( [$bToClient = False [, $hWnd = 0]] )

Parameters

$bToClient | [optional] If True, the coordinates will be converted to client coordinates
$hWnd | [optional] Window handle used to convert coordinates if $bToClient is True

Return Value

Success: | the mouse Y position.
Failure: | sets the @error flag to non-zero.

Remarks

This function takes into account the current MouseCoordMode setting when obtaining the mouse position. It
will also convert screen to client coordinates based on the parameters passed.

Related

_WinAPI_GetMousePos

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hWnd = GUICreate("test")
    Local $iX = _WinAPI_GetMousePosX()
    Local $iX2 = _WinAPI_GetMousePosX(True, $hWnd)
    Local $iY = _WinAPI_GetMousePosY()
    Local $iY2 = _WinAPI_GetMousePosY(True, $hWnd)

    MsgBox($MB_SYSTEMMODAL, "Mouse Pos", "X = " & $iX & @CRLF & "Y = " & $iY & @CRLF & @CRLF & _
            "Client" & @CRLF & "X = " & $iX2 & @CRLF & "Y = " & $iY2)
EndFunc   ;==>Example


Function _WinAPI_GetObject

Function Reference

_WinAPI_GetObject

Retrieves information for the specified graphics object

#include <WinAPI.au3>
_WinAPI_GetObject ( $hObject, $iSize, $pObject )

Parameters

$hObject | Identifies a logical pen, brush, font, bitmap, region, or palette
$iSize | Specifies the number of bytes to be written to the buffer
$pObject | Pointer to a buffer that receives the information. The following shows the type of information the buffer receives for each type of graphics object you can specify: HBITMAP - BITMAP or DIBSECTION HPALETTE - A count of the number of entries in the logical palette HPEN - EXTLOGPEN or LOGPEN HBRUSH - LOGBRUSH HFONT - LOGFONT If $pObject is 0 the function return value is the number of bytes required to store the information it writes to the buffer for the specified graphics object.

Return Value

Success: | If $pObject is a valid pointer, the return value is the number of bytes stored into the buffer. If the function succeeds, and $pObject is 0, the return value is the number of bytes required to hold the information the function would store into the buffer.
Failure: | 0

See Also

Search GetObject in MSDN Library.


Function _WinAPI_GetOpenFileName

Function Reference

_WinAPI_GetOpenFileName

Creates an Open dialog box that lets the user specify the drive, directory, and the name of a file or set of files to open

#include <WinAPI.au3>
_WinAPI_GetOpenFileName ( [$sTitle = "" [, $sFilter = "All files (*.*)" [, $sInitalDir = "." [, $sDefaultFile = "" [, $sDefaultExt = "" [, $iFilterIndex = 1 [, $iFlags = 0 [, $iFlagsEx = 0 [, $hWndOwner = 0]]]]]]]]] )

Parameters

$sTitle | [optional] string to be placed in the title bar of the dialog box
$sFilter | [optional] Pairs of filter strings (for example "Text Files (*.txt)|All Files (*.*)") The first string in each pair is a display string that describes the filter (for example, "Text Files") The second string specifies the filter pattern (for example, "*.TXT") To specify multiple filter patterns for a single display string, use a semicolon to separate the patterns (for example, "*.TXT;*.DOC;*.BAK") A pattern string can be a combination of valid file name characters and the asterisk (*) wildcard character Do not include spaces in the pattern string.
$sInitalDir | [optional] String that can specify the initial directory
$sDefaultFile | [optional] A file name used to initialize the File Name edit control
$sDefaultExt | [optional] String that contains the default extension
$iFilterIndex | [optional] Specifies the index of the currently selected filter in the File Types control
$iFlags | [optional] See Flags in $tagOPENFILENAME information
$iFlagsEx | [optional] See FlagEx in $tagOPENFILENAME information
$hWndOwner | [optional] Handle to the window that owns the dialog box. This member can be any valid window handle, or it can be 0 if the dialog box has no owner

Return Value

Success: | an array in the following format: [0] - Contains the number of strings [1] - Contains the path selected [2] - Contains file selected [n] - Contains file selected
Failure: | sets the @error flag to non zero, call _WinAPI_CommDlgExtendedError() to get extended error information.

Related

$tagOPENFILENAME, _WinAPI_CommDlgExtendedError, _WinAPI_GetSaveFileName

See Also

Search GetOpenFileName in MSDN Library.

Example

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

Global $g_idMemo

_Example_Defaults()
_Example_ExplorerStyleMultiSelect()
_Example_OldStyle()
_Example_ExplorerStyleSinglSelect()
_Example_ExplorerStyle_NoPlaceBar()

Func _Example_Defaults()
    Local $hGui, $id_Dialog, $aFile, $sError

    ; Create GUI
    $hGui = GUICreate("GetOpenFileName use defaults", 400, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, $WS_HSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    $id_Dialog = GUICtrlCreateButton("Open Dialog", 155, 270, 90, 20)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $id_Dialog
                $aFile = _WinAPI_GetOpenFileName() ; use defaults
                If $aFile[0] = 0 Then
                    $sError = _WinAPI_CommDlgExtendedError()
                    MemoWrite("CommDlgExtendedError (" & @error & "): " & $sError)
                Else
                    For $x = 1 To $aFile[0]
                        MemoWrite($aFile[$x])
                    Next
                EndIf
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete($hGui)
EndFunc   ;==>_Example_Defaults

Func _Example_ExplorerStyleMultiSelect()
    Local $hGui, $id_Dialog, $aFile, $sError

    ; Create GUI
    $hGui = GUICreate("GetOpenFileName use Explorer Style (Multi Select)", 400, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, $WS_HSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    $id_Dialog = GUICtrlCreateButton("Open Dialog", 155, 270, 90, 20)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $id_Dialog
                $aFile = _WinAPI_GetOpenFileName("My Open File Dialog", _
                        "Text File (*.txt;*.au3)", ".", @ScriptName, "", 1, _
                        BitOR($OFN_ALLOWMULTISELECT, $OFN_EXPLORER), 0, $hGui)
                If $aFile[0] = 0 Then
                    $sError = _WinAPI_CommDlgExtendedError()
                    MemoWrite("CommDlgExtendedError (" & @error & "): " & $sError)
                Else
                    For $x = 1 To $aFile[0]
                        MemoWrite($aFile[$x])
                    Next
                EndIf
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete($hGui)
EndFunc   ;==>_Example_ExplorerStyleMultiSelect

Func _Example_OldStyle()
    Local $hGui, $id_Dialog, $aFile, $sError

    ; Create GUI
    $hGui = GUICreate("GetOpenFileName use Old Style (Multi Select)", 400, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, $WS_HSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    $id_Dialog = GUICtrlCreateButton("Open Dialog", 155, 270, 90, 20)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $id_Dialog
                $aFile = _WinAPI_GetOpenFileName("My Open File Dialog", _
                        "Text File (*.txt)|AutoIt File (*.au3)", ".", @ScriptName, _
                        "", 2, $OFN_ALLOWMULTISELECT, 0, $hGui)
                If $aFile[0] = 0 Then
                    $sError = _WinAPI_CommDlgExtendedError()
                    MemoWrite("CommDlgExtendedError (" & @error & "): " & $sError)
                Else
                    For $x = 1 To $aFile[0]
                        MemoWrite($aFile[$x])
                    Next
                EndIf
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete($hGui)
EndFunc   ;==>_Example_OldStyle

Func _Example_ExplorerStyleSinglSelect()
    Local $hGui, $id_Dialog, $aFile, $sError

    ; Create GUI
    $hGui = GUICreate("GetOpenFileName use Explorer Style (Single Select)", 400, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, $WS_HSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    $id_Dialog = GUICtrlCreateButton("Open Dialog", 155, 270, 90, 20)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $id_Dialog
                $aFile = _WinAPI_GetOpenFileName("My Open File Dialog", _
                        "Text File (*.txt)|AutoIt File (*.au3)", ".", @ScriptName, _
                        "", 2, 0, 0, $hGui)
                If $aFile[0] = 0 Then
                    $sError = _WinAPI_CommDlgExtendedError()
                    MemoWrite("CommDlgExtendedError (" & @error & "): " & $sError)
                Else
                    For $x = 1 To $aFile[0]
                        MemoWrite($aFile[$x])
                    Next
                EndIf
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete($hGui)
EndFunc   ;==>_Example_ExplorerStyleSinglSelect

Func _Example_ExplorerStyle_NoPlaceBar()
    Local $hGui, $id_Dialog, $aFile, $sError

    ; Create GUI
    $hGui = GUICreate("GetOpenFileName use Explorer Style (Single Select)", 400, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, $WS_HSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    $id_Dialog = GUICtrlCreateButton("Open Dialog", 155, 270, 90, 20)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $id_Dialog
                $aFile = _WinAPI_GetOpenFileName("My Open File Dialog", _
                        "Text File (*.txt)|AutoIt File (*.au3)", ".", @ScriptName, _
                        "", 2, BitOR($OFN_ALLOWMULTISELECT, $OFN_EXPLORER), $OFN_EX_NOPLACESBAR, $hGui)
                If $aFile[0] = 0 Then
                    $sError = _WinAPI_CommDlgExtendedError()
                    MemoWrite("CommDlgExtendedError (" & @error & "): " & $sError)
                Else
                    For $x = 1 To $aFile[0]
                        MemoWrite($aFile[$x])
                    Next
                EndIf
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete($hGui)
EndFunc   ;==>_Example_ExplorerStyle_NoPlaceBar

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _WinAPI_GetOverlappedResult

Function Reference

_WinAPI_GetOverlappedResult

Retrieves the results of an overlapped operation

#include <WinAPI.au3>
_WinAPI_GetOverlappedResult ( $hFile, $tOverlapped, ByRef $iBytes [, $bWait = False] )

Parameters

$hFile | Handle to the file, named pipe, or communications device. This is the same handle that was specified when the overlapped operation was started by a call to ReadFile, WriteFile, ConnectNamedPipe, TransactNamedPipe, DeviceIoControl, or WaitCommEvent.
$tOverlapped | A $tagOVERLAPPED structure or a pointer to it that was specified when the overlapped operation was started.
$iBytes | The number of bytes that were actually transferred by a read or write operation. For a TransactNamedPipe operation, this is the number of bytes that were read from the pipe. For a DeviceIoControl operation this is the number of bytes of output data returned by the device driver. For a ConnectNamedPipe or WaitCommEvent operation, this value is undefined.
$bWait | [optional] If True, the function does not return until the operation has been completed. If False and the operation is still pending, the function returns False and the GetLastError function will return ERROR_IO_INCOMPLETE.

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Related

$tagOVERLAPPED

See Also

Search GetOverlappedResult in MSDN Library.


Function _WinAPI_GetParent

Function Reference

_WinAPI_GetParent

Retrieves the handle of the specified child window's parent window

#include <WinAPI.au3>
_WinAPI_GetParent ( $hWnd )

Parameters

$hWnd Window handle of child window

Return Value

Success: | The handle of the parent window
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

Related

_WinAPI_GetAncestor

See Also

Search GetParent in MSDN Library.


Function _WinAPI_GetProcAddress

Function Reference

_WinAPI_GetProcAddress

Retrieves the address of an exported function or variable from the specified module

#include <WinAPI.au3>
_WinAPI_GetProcAddress ( $hModule, $vName )

Parameters

$hModule | A handle to the module that contains the function or variable
$vName | The function or variable name, or the function's ordinal value

Return Value

Success: | The address of the exported function or variable
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

Related

_WinAPI_GetModuleHandle, _WinAPI_LoadLibrary, _WinAPI_LoadLibraryEx

See Also

Search GetProcAddress in MSDN Library.

Example

#include <WinAPI.au3>

; Get handle of the loaded module
Local $hModule = _WinAPI_GetModuleHandle("kernel32.dll")

If $hModule Then
    Local $pFunction = _WinAPI_GetProcAddress($hModule, "CreateFiber")
    ConsoleWrite("The address of the function is " & $pFunction & @CRLF)

    ; Do whatever here

EndIf


Function _WinAPI_GetProcessAffinityMask

Function Reference

_WinAPI_GetProcessAffinityMask

Obtains the affinity masks for the process and the system

#include <WinAPI.au3>
_WinAPI_GetProcessAffinityMask ( $hProcess )

Parameters

$hProcess An open handle to the process whose affinity mask is desired.

Return Value

Success: | Array with the following format: $aMask[0] - True on success, otherwise False $aMask[1] - Process affinity mask $aMask[2] - System affinity mask
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information

Remarks

An affinity mask is a bit mask in which each bit represents a processor on which the threads of the process
are allowed to run. For example, if you pass a mask of 0x05, processors 1 and 3 are allowed to run.

See Also

Search GetProcessAffinityMask in MSDN Library.


Function _WinAPI_GetSaveFileName

Function Reference

_WinAPI_GetSaveFileName

Creates a Save dialog box that lets the user specify the drive, directory, and name of a file to save

#include <WinAPI.au3>
_WinAPI_GetSaveFileName ( [$sTitle = "" [, $sFilter = "All files (*.*)" [, $sInitalDir = "." [, $sDefaultFile = "" [, $sDefaultExt = "" [, $iFilterIndex = 1 [, $iFlags = 0 [, $iFlagsEx = 0 [, $hWndOwner = 0]]]]]]]]] )

Parameters

$sTitle | [optional] string to be placed in the title bar of the dialog box
$sFilter | [optional] Pairs of filter strings (for example "Text Files (*.txt)|All Files (*.*)") The first string in each pair is a display string that describes the filter (for example, "Text Files") The second string specifies the filter pattern (for example, "*.TXT") To specify multiple filter patterns for a single display string, use a semicolon to separate the patterns (for example, "*.TXT;*.DOC;*.BAK") A pattern string can be a combination of valid file name characters and the asterisk (*) wildcard character Do not include spaces in the pattern string.
$sInitalDir | [optional] String that can specify the initial directory
$sDefaultFile | [optional] A file name used to initialize the File Name edit control
$sDefaultExt | [optional] String that contains the default extension
$iFilterIndex | [optional] Specifies the index of the currently selected filter in the File Types control
$iFlags | [optional] See Flags in $tagOPENFILENAME information
$iFlagsEx | [optional] See FlagEx in $tagOPENFILENAME information
$hWndOwner | [optional] Handle to the window that owns the dialog box. This member can be any valid window handle, or it can be 0 if the dialog box has no owner

Return Value

Success: | an array in the following format: [0] - Contains the number of strings (2) [1] - Contains the path selected [2] - Contains file selected
Failure: | sets the @error flag to non-zero, call _WinAPI_CommDlgExtendedError() to get extended error information.

Related

$tagOPENFILENAME, _WinAPI_CommDlgExtendedError, _WinAPI_GetOpenFileName

See Also

Search GetSaveFileName in MSDN Library.

Example

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

Global $g_idMemo

_Example_Defaults()
_Example_ExplorerStyle()
_Example_OldStyle()
_Example_ExplorerStyle_NoPlaceBar()

Func _Example_Defaults()
    Local $hGui, $id_Dialog, $aFile, $sError

    ; Create GUI
    $hGui = GUICreate("GetSaveFileName use defaults", 400, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, $WS_HSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    $id_Dialog = GUICtrlCreateButton("Save Dialog", 155, 270, 90, 20)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $id_Dialog
                $aFile = _WinAPI_GetSaveFileName() ; use defaults
                If $aFile[0] = 0 Then
                    $sError = _WinAPI_CommDlgExtendedError()
                    MemoWrite("CommDlgExtendedError (" & @error & "): " & $sError)
                Else
                    For $x = 1 To $aFile[0]
                        MemoWrite($aFile[$x])
                    Next
                EndIf
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete($hGui)
EndFunc   ;==>_Example_Defaults

Func _Example_ExplorerStyle()
    Local $hGui, $id_Dialog, $aFile, $sError

    ; Create GUI
    $hGui = GUICreate("GetSaveFileName use Explorer Style", 400, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, $WS_HSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    $id_Dialog = GUICtrlCreateButton("Save Dialog", 155, 270, 90, 20)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $id_Dialog
                $aFile = _WinAPI_GetSaveFileName("My Save File Dialog", _
                        "Text File (*.txt)|AutoIt File (*.au3)", ".", _
                        "", "au3", 2, 0, 0, $hGui)
                If $aFile[0] = 0 Then
                    $sError = _WinAPI_CommDlgExtendedError()
                    MemoWrite("CommDlgExtendedError (" & @error & "): " & $sError)
                Else
                    For $x = 1 To $aFile[0]
                        MemoWrite($aFile[$x])
                    Next
                EndIf
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete($hGui)
EndFunc   ;==>_Example_ExplorerStyle

Func _Example_OldStyle()
    Local $hGui, $id_Dialog, $aFile, $sError

    ; Create GUI
    $hGui = GUICreate("GetSaveFileName use Old Style", 400, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, $WS_HSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    $id_Dialog = GUICtrlCreateButton("Save Dialog", 155, 270, 90, 20)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $id_Dialog
                $aFile = _WinAPI_GetSaveFileName("My Save File Dialog", _
                        "Text File (*.txt)|AutoIt File (*.au3)", ".", "", _
                        "", 2, $OFN_ALLOWMULTISELECT, 0, $hGui)
                If $aFile[0] = 0 Then
                    $sError = _WinAPI_CommDlgExtendedError()
                    MemoWrite("CommDlgExtendedError (" & @error & "): " & $sError)
                Else
                    For $x = 1 To $aFile[0]
                        MemoWrite($aFile[$x])
                    Next
                EndIf
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete($hGui)
EndFunc   ;==>_Example_OldStyle

Func _Example_ExplorerStyle_NoPlaceBar()
    Local $hGui, $id_Dialog, $aFile, $sError

    ; Create GUI
    $hGui = GUICreate("GetSaveFileName use Explorer Style No Place Bar", 400, 296)
    $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, $WS_HSCROLL)
    GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New")
    $id_Dialog = GUICtrlCreateButton("Save Dialog", 155, 270, 90, 20)
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $id_Dialog
                $aFile = _WinAPI_GetSaveFileName("My Save File Dialog", _
                        "Text File (*.txt)|AutoIt File (*.au3)", ".", "", _
                        "", 2, 0, $OFN_EX_NOPLACESBAR, $hGui)
                If $aFile[0] = 0 Then
                    $sError = _WinAPI_CommDlgExtendedError()
                    MemoWrite("CommDlgExtendedError (" & @error & "): " & $sError)
                Else
                    For $x = 1 To $aFile[0]
                        MemoWrite($aFile[$x])
                    Next
                EndIf
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete($hGui)
EndFunc   ;==>_Example_ExplorerStyle_NoPlaceBar

; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _WinAPI_GetStdHandle

Function Reference

_WinAPI_GetStdHandle

Retrieves a handle for the standard input, standard output, or standard error device

#include <WinAPI.au3>
_WinAPI_GetStdHandle ( $iStdHandle )

Parameters

$iStdHandle Standard device for which a handle is to be returned. This can be one of the following values:
0 - Handle to the standard input device
1 - Handle to the standard output device
2 - Handle to the standard error device

Return Value

Success: | Handle to the specified device
Failure: | (-1), call _WinAPI_GetLastError() to get extended error information

Remarks

The handle has GENERIC_READ and GENERIC_WRITE access rights, unless the application has used SetStdHandle to
set a standard handle with lesser access. If an application does not have associated standard handles, the
return value is 0.

See Also

Search GetStdHandle in MSDN Library.


Function _WinAPI_GetStockObject

Function Reference

_WinAPI_GetStockObject

Retrieves a handle to one of the predefined stock pens, brushes, fonts, or palettes

#include <WinAPI.au3>
_WinAPI_GetStockObject ( $iObject )

Parameters

$iObject Specifies the type of stock object. This parameter can be any one of the following values:
$BLACK_BRUSH - Black brush
$DKGRAY_BRUSH - Dark gray brush
$GRAY_BRUSH - Gray brush
$HOLLOW_BRUSH - Hollow brush (equivalent to NULL_BRUSH)
$LTGRAY_BRUSH - Light gray brush
$NULL_BRUSH - Null brush (equivalent to HOLLOW_BRUSH)
$WHITE_BRUSH - White brush
$BLACK_PEN - Black pen
$NULL_PEN - Null pen
$WHITE_PEN - White pen
$ANSI_FIXED_FONT - Windows fixed-pitch (monospace) system font
$ANSI_VAR_FONT - Windows variable-pitch (proportional space) system font
$DEVICE_DEFAULT_FONT - Device-dependent font
$DEFAULT_GUI_FONT - Default font for user interface objects
$OEM_FIXED_FONT - OEM dependent fixed-pitch (monospace) font
$SYSTEM_FONT - System font
$SYSTEM_FIXED_FONT - Fixed-pitch (monospace) system font used in Windows versions earlier than 3.0
$DEFAULT_PALETTE - Default palette. This palette consists of the static colors in the system palette.

Return Value

Success: | The logical object requested
Failure: | 0

See Also

Search GetStockObject in MSDN Library.


Function _WinAPI_GetSysColor

Function Reference

_WinAPI_GetSysColor

Retrieves the current color of the specified display element

#include <WinAPI.au3>
_WinAPI_GetSysColor ( $iIndex )

Parameters

$iIndex The display element whose color is to be retrieved. Can be one of the following:
$COLOR_3DDKSHADOW - Dark shadow for three-dimensional display elements.
$COLOR_3DFACE - Face color for three-dimensional display elements and for dialog box backgrounds.
$COLOR_3DHIGHLIGHT - Highlight color for three-dimensional display elements (for edges facing the light source.)
$COLOR_3DHILIGHT - Highlight color for three-dimensional display elements (for edges facing the light source.)
$COLOR_3DLIGHT - Light color for three-dimensional display elements (for edges facing the light source.)
$COLOR_3DSHADOW - Shadow color for three-dimensional display elements (for edges facing away from the light source).
$COLOR_ACTIVEBORDER - Active window border.
$COLOR_ACTIVECAPTION - Active window title bar.
Specifies the left side color in the color gradient of an active window's title bar if the gradient effect is enabled.
$COLOR_APPWORKSPACE - Background color of multiple document interface (MDI) applications.
$COLOR_BACKGROUND - Desktop.
$COLOR_BTNFACE - Face color for three-dimensional display elements and for dialog box backgrounds.
$COLOR_BTNHIGHLIGHT - Highlight color for three-dimensional display elements (for edges facing the light source.)
$COLOR_BTNHILIGHT - Highlight color for three-dimensional display elements (for edges facing the light source.)
$COLOR_BTNSHADOW - Shadow color for three-dimensional display elements (for edges facing away from the light source).
$COLOR_BTNTEXT - Text on push buttons.
$COLOR_CAPTIONTEXT - Text in caption, size box, and scroll bar arrow box.
$COLOR_DESKTOP - Desktop.
$COLOR_GRADIENTACTIVECAPTION - Right side color in the color gradient of an active window's title bar.
$COLOR_ACTIVECAPTION specifies the left side color.
Use SPI_GETGRADIENTCAPTIONS with the SystemParametersInfo function to determine whether the gradient effect is enabled.
$COLOR_GRADIENTINACTIVECAPTION - Right side color in the color gradient of an inactive window's title bar.
$COLOR_INACTIVECAPTION specifies the left side color.
$COLOR_GRAYTEXT - Grayed (disabled) text. This color is set to 0 if the current display driver does not support a solid gray color.
$COLOR_HIGHLIGHT - Item(s) selected in a control.
$COLOR_HIGHLIGHTTEXT - Text of item(s) selected in a control.
$COLOR_HOTLIGHT - Color for a hyperlink or hot-tracked item.
$COLOR_INACTIVEBORDER - Inactive window border.
$COLOR_INACTIVECAPTION - Inactive window caption.
Specifies the left side color in the color gradient of an inactive window's title bar if the gradient effect is enabled.
$COLOR_INACTIVECAPTIONTEXT - Color of text in an inactive caption.
$COLOR_INFOBK - Background color for tooltip controls.
$COLOR_INFOTEXT - Text color for tooltip controls.
$COLOR_MENU - Menu background.
$COLOR_MENUHILIGHT - The color used to highlight menu items when the menu appears as a flat menu.
The highlighted menu item is outlined with $COLOR_HIGHLIGHT.
$COLOR_MENUBAR - The background color for the menu bar when menus appear as flat menus.
However, $COLOR_MENU continues to specify the background color of the menu popup.
$COLOR_MENUTEXT - Text in menus.
$COLOR_SCROLLBAR - Scroll bar gray area.
$COLOR_WINDOW - Window background.
$COLOR_WINDOWFRAME - Window frame.
$COLOR_WINDOWTEXT - Text in windows.

Return Value

Returns the red, green, blue (RGB) color value of the given element

Remarks

Above constants require #include <WindowsConstants.au3>

If the $iIndex parameter is out of range, the return value is zero. Because zero is also a valid RGB value, you cannot use GetSysColor to determine whether a system color is supported by the current platform. Instead, use the GetSysColorBrush function, which returns NULL if the color is not supported.

Related

_WinAPI_SetSysColors

See Also

Search GetSysColor in MSDN Library.

Example

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

Example()

Func Example()
    Local $aElements[2] = [$COLOR_ACTIVECAPTION, $COLOR_GRADIENTACTIVECAPTION]
    ; Red and Yellow
    Local $aColors[2] = [255, 65535], $aSaveColors[2]

    GUICreate("My GUI", 300, 200)

    $aSaveColors[0] = _WinAPI_GetSysColor($COLOR_ACTIVECAPTION)
    $aSaveColors[1] = _WinAPI_GetSysColor($COLOR_GRADIENTACTIVECAPTION)

    _WinAPI_SetSysColors($aElements, $aColors)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    GUIDelete()

    _WinAPI_SetSysColors($aElements, $aSaveColors)

    Exit
EndFunc   ;==>Example


Function _WinAPI_GetSysColorBrush

Function Reference

_WinAPI_GetSysColorBrush

Retrieves a handle identifying a logical brush that corresponds to the specified color index

#include <WinAPI.au3>
_WinAPI_GetSysColorBrush ( $iIndex )

Parameters

$iIndex The display element whose color is to be retrieved

Return Value

Success: | A logical brush if $iIndex is supported by the current platform
Failure: | 0

See Also

Search GetSysColorBrush in MSDN Library.


Function _WinAPI_GetSystemMetrics

Function Reference

_WinAPI_GetSystemMetrics

Retrieves the specified system metric or system configuration setting

#include <WinAPI.au3>
_WinAPI_GetSystemMetrics ( $iIndex )

Parameters

$iIndex The system metric or configuration setting to be retrieved

Return Value

Success: | The requested system metric
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

See Also

Search GetSystemMetrics in MSDN Library.


Function _WinAPI_GetTextExtentPoint32

Function Reference

_WinAPI_GetTextExtentPoint32

Computes the width and height of the specified string of text

#include <WinAPI.au3>
_WinAPI_GetTextExtentPoint32 ( $hDC, $sText )

Parameters

$hDC | Identifies the device contex
$sText | String of text

Return Value

Success: | a $tagSIZE structure in which the dimensions of the string are to be returned.
Failure: | sets the @error flag to non-zero.

Related

$tagSIZE

See Also

Search GetTextExtentPoint32 in MSDN Library.

Example

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

Example()

Func Example()
    Local $hGUI = GUICreate("String height & width.")
    GUISetState(@SW_SHOW, $hGUI)

    Local $sText = "This is  some text" ; The text we want to find the height & width of.
    Local $aStringDimension = GetStringDimensions($hGUI, $sText) ; Retrieve a 1 dimensional array with $aArray[0] = width & $aArray[1] = height.
    MsgBox($MB_SYSTEMMODAL, "String Height and Width", 'The height and width of the string "' & $sText & '" is:' & @CRLF & _
            "Width: " & $aStringDimension[0] & @CRLF & _
            "Height: " & $aStringDimension[1] & @CRLF)
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func GetStringDimensions($hWnd, $sText)
    Local $hDC = _WinAPI_GetDC($hWnd) ; Get the device context handle of the current window.
    Local $hFont = _SendMessage($hWnd, $WM_GETFONT) ; Retrieve the font with which the control is currently drawing its text.
    Local $hSelectObject = _WinAPI_SelectObject($hDC, $hFont) ; Select the object of the context device.
    Local $tSIZE = _WinAPI_GetTextExtentPoint32($hDC, $sText) ; Retrieve the height & width of a string.

    _WinAPI_SelectObject($hDC, $hSelectObject)
    _WinAPI_ReleaseDC($hWnd, $hDC) ; Release the device context.
    Local $aReturn[2] = [DllStructGetData($tSIZE, 1), DllStructGetData($tSIZE, 2)] ; Set an array with the width & height of the string.
    Return $aReturn
EndFunc   ;==>GetStringDimensions


Function _WinAPI_GetTextMetrics

Function Reference

_WinAPI_GetTextMetrics

Retrieves basic information for the currently selected font

#include <WinAPI.au3>
_WinAPI_GetTextMetrics ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | $tagTEXTMETRIC structure that contains the information about the currently selected font.
Failure: | 0 and sets the @error flag to non-zero.

Related

$tagTEXTMETRIC

See Also

Search GetTextMetrics in MSDN Library.


Function _WinAPI_GetWindow

Function Reference

_WinAPI_GetWindow

Retrieves the handle of a window that has a specified relationship to the specified window

#include <WinAPI.au3>
_WinAPI_GetWindow ( $hWnd, $iCmd )

Parameters

$hWnd Handle of the window
$iCmd Specifies the relationship between the specified window and the window whose handle is to be retrieved.
This parameter can be one of the following values:
$GW_CHILD - The retrieved handle identifies the child window at the top of the Z order, if the specified
window is a parent window; otherwise, the retrieved handle is 0.
The function examines only child windows of the specified window. It does not examine descendant windows.
$GW_HWNDFIRST - The retrieved handle identifies the window of the same type that is highest in the Z order.
If the specified window is a topmost window, the handle identifies the topmost window that is highest in the Z order.
If the specified window is a top-level window, the handle identifies the top level window that is highest in the Z order.
If the specified window is a child window, the handle identifies the sibling window that is highest in the Z order.
$GW_HWNDLAST - The retrieved handle identifies the window of the same type that is lowest in the Z order.
If the specified window is a topmost window, the handle identifies the topmost window that is lowest in the Z order.
If the specified window is a top-level window the handle identifies the top-level window that's lowest in the Z order.
If the specified window is a child window, the handle identifies the sibling window that is lowest in the Z order.
$GW_HWNDNEXT - The retrieved handle identifies the window below the specified window in the Z order.
If the specified window is a topmost window, the handle identifies the topmost window below the specified window.
If the specified window is a top-level window, the handle identifies the top-level window below the specified window.
If the specified window is a child window the handle identifies the sibling window below the specified window.
$GW_HWNDPREV - The retrieved handle identifies the window above the specified window in the Z order.
If the specified window is a topmost window, the handle identifies the topmost window above the specified window.
If the specified window is a top-level window, the handle identifies the top-level window above the specified window.
If the specified window is a child window, the handle identifies the sibling window above the specified window.
$GW_OWNER - The retrieved handle identifies the specified window's owner window if any.

Return Value

Success: | The window handle
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

Remarks

Above constants require #include <WinAPIConstants.au3>

See Also

Search GetWindow in MSDN Library.


Function _WinAPI_GetWindowDC

Function Reference

_WinAPI_GetWindowDC

Retrieves the device context (DC) for the entire window

#include <WinAPI.au3>
_WinAPI_GetWindowDC ( $hWnd )

Parameters

$hWnd Handle of window

Return Value

Success: | The handle of a device context for the specified window
Failure: | 0

Remarks

GetWindowDC is intended for special painting effects within a window's nonclient area. Painting in nonclient
areas of any window is normally not recommended. The GetSystemMetrics function can be used to retrieve the
dimensions of various parts of the nonclient area, such as the title bar, menu, and scroll bars. After
painting is complete, the _WinAPI_ReleaseDC() function must be called to release the device context. Not releasing
the window device context has serious effects on painting requested by applications.

Related

_WinAPI_ReleaseDC

See Also

Search GetWindowDC in MSDN Library.

Example

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

ShowCross(@DesktopWidth / 2, @DesktopHeight / 2, 20, 2, 0xFF, 3000)

Func ShowCross($iStart_x, $iStart_y, $iLength, $iWidth, $iColor, $iTime)
    Local $hDC, $hPen, $o_Orig

    $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop)
    $hPen = _WinAPI_CreatePen($PS_SOLID, $iWidth, $iColor)
    $o_Orig = _WinAPI_SelectObject($hDC, $hPen)

    _WinAPI_DrawLine($hDC, $iStart_x - $iLength, $iStart_y, $iStart_x - 5, $iStart_y) ; horizontal left
    _WinAPI_DrawLine($hDC, $iStart_x + $iLength, $iStart_y, $iStart_x + 5, $iStart_y) ; horizontal right
    _WinAPI_DrawLine($hDC, $iStart_x, $iStart_y - $iLength, $iStart_x, $iStart_y - 5) ; vertical up
    ;   _WinAPI_DrawLine($hDC, $iStart_x, $iStart_y + $iLength, $iStart_x, $iStart_y + 5) ; vertical down
    _WinAPI_MoveTo($hDC, $iStart_x, $iStart_y + $iLength)
    _WinAPI_LineTo($hDC, $iStart_x, $iStart_y + 5)

    Sleep($iTime) ; show cross over screen for defined seconds

    ; refresh desktop (clear cross)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)

    ; clear resources
    _WinAPI_SelectObject($hDC, $o_Orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
EndFunc   ;==>ShowCross


Function _WinAPI_GetWindowHeight

Function Reference

_WinAPI_GetWindowHeight

Returns the height of the window

#include <WinAPI.au3>
_WinAPI_GetWindowHeight ( $hWnd )

Parameters

$hWnd Handle to a window

Return Value

Success: | the height of window.
Failure: | sets the @error flag to non-zero.

Related

_WinAPI_GetWindowWidth


Function _WinAPI_GetWindowLong

Function Reference

_WinAPI_GetWindowLong

Retrieves information about the specified window

#include <WinAPI.au3>
_WinAPI_GetWindowLong ( $hWnd, $iIndex )

Parameters

$hWnd | Handle of the window
$iIndex | Specifies the 0-based offset to the value to be retrieved. Valid values are in the range zero through the number of bytes of extra window memory, minus four; for example, if you specified 12 or more bytes of extra memory, a value of 8 would be an index to the third 32 bit integer. To retrieve any other value, specify one of the following values: $GWL_EXSTYLE - Retrieves the extended window styles $GWL_STYLE - Retrieves the window styles $GWL_WNDPROC - Retrieves the address of the window procedure $GWL_HINSTANCE - Retrieves the handle of the application instance $GWL_HWNDPARENT - Retrieves the handle of the parent window, if any $GWL_ID - Retrieves the identifier of the window $GWL_USERDATA - Retrieves the 32-bit value associated with the window

Return Value

Success: | the requested value.
Failure: | sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

Above constants require #include <Constants.au3>

Related

_WinAPI_SetWindowLong

See Also

Search GetWindowLongPtr in MSDN Library.


Function _WinAPI_GetWindowPlacement

Function Reference

_WinAPI_GetWindowPlacement

Retrieves the placement of the window for Min, Max, and normal positions

#include <WinAPI.au3>
_WinAPI_GetWindowPlacement ( $hWnd )

Parameters

$hWnd Handle of the window

Return Value

Success: | $tagWINDOWPLACEMENT structure with the placement coordinates
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information

Related

$tagWINDOWPLACEMENT, _WinAPI_SetWindowPlacement

See Also

Search GetWindowPlacement in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Local $hWnd, $iRET, $sMsg, $tRET

; Create an instance of notepad to play with
Run("notepad.exe")
$hWnd = WinWait("[CLASS:Notepad]")
WinMove($hWnd, "", 256, 256, 400, 400)
Sleep(1000)

; Minimize and then check the placement values returned by _WinAPI_GetWindowPlacement()
WinSetState($hWnd, "", @SW_MINIMIZE)
$tRET = _WinAPI_GetWindowPlacement($hWnd)
If @error = 0 Then
    $sMsg = "$stWindowPlacement:" & @CRLF & @CRLF
    $sMsg &= @TAB & "length = " & DllStructGetData($tRET, "length") & @CRLF
    $sMsg &= @TAB & "flags = " & DllStructGetData($tRET, "flags") & @CRLF
    $sMsg &= @TAB & "showCmd = " & DllStructGetData($tRET, "showCmd") & @CRLF & @CRLF
    $sMsg &= "ptMinPosition:" & @CRLF
    $sMsg &= @TAB & "MinX = " & DllStructGetData($tRET, "ptMinPosition", 1) & @CRLF
    $sMsg &= @TAB & "MinY = " & DllStructGetData($tRET, "ptMinPosition", 2) & @CRLF & @CRLF
    $sMsg &= "ptMaxPosition:" & @CRLF
    $sMsg &= @TAB & "MaxX = " & DllStructGetData($tRET, "ptMaxPosition", 1) & @CRLF
    $sMsg &= @TAB & "MaxY = " & DllStructGetData($tRET, "ptMaxPosition", 2) & @CRLF & @CRLF
    $sMsg &= "rcNormalPosition:" & @CRLF
    $sMsg &= @TAB & "left = " & DllStructGetData($tRET, "rcNormalPosition", 1) & @CRLF
    $sMsg &= @TAB & "top = " & DllStructGetData($tRET, "rcNormalPosition", 2) & @CRLF
    $sMsg &= @TAB & "right = " & DllStructGetData($tRET, "rcNormalPosition", 3) & @CRLF
    $sMsg &= @TAB & "bottom = " & DllStructGetData($tRET, "rcNormalPosition", 4)
    MsgBox($MB_SYSTEMMODAL, "Success", $sMsg)

    ; Change the normalized rectangle with _WinAPI_SetWindowPlacement() and then restore
    DllStructSetData($tRET, "rcNormalPosition", 128, 1); left
    DllStructSetData($tRET, "rcNormalPosition", 128, 2); top
    DllStructSetData($tRET, "rcNormalPosition", @DesktopWidth - 128, 3); right
    DllStructSetData($tRET, "rcNormalPosition", @DesktopHeight - 128, 4); bottom
    $iRET = _WinAPI_SetWindowPlacement($hWnd, $tRET)
    If @error = 0 Then
        WinSetState($hWnd, "", @SW_RESTORE)
        ControlSetText($hWnd, "", "Edit1", "_WinAPI_SetWindowPlacement() succeeded!")
    Else
        MsgBox($MB_SYSTEMMODAL, "Error", "_WinAPI_SetWindowPlacement() failed!" & @CRLF & _
                "$iRET = " & $iRET & @CRLF & _
                "@error = " & @error & @CRLF & _
                "@extended = " & @extended)
    EndIf
Else
    MsgBox($MB_SYSTEMMODAL, "Error", "_WinAPI_GetWindowPlacement() failed!" & @CRLF & _
            "$tRET = " & $tRET & @CRLF & _
            "@error = " & @error & @CRLF & _
            "@extended = " & @extended)
EndIf


Function _WinAPI_GetWindowRect

Function Reference

_WinAPI_GetWindowRect

Retrieves the dimensions of the bounding rectangle of the specified window

#include <WinAPI.au3>
_WinAPI_GetWindowRect ( $hWnd )

Parameters

$hWnd Handle of the window

Return Value

Success: | $tagRECT structure that receives the screen coordinates
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information

Related

$tagRECT

See Also

Search GetWindowRect in MSDN Library.


Function _WinAPI_GetWindowRgn

Function Reference

_WinAPI_GetWindowRgn

Obtains a copy of the window region of a window

#include <WinAPI.au3>
_WinAPI_GetWindowRgn ( $hWnd, $hRgn )

Parameters

$hWnd | Handle to the window whose window region is to be obtained.
$hRgn | Handle to the region which will be modified to represent the window region.

Return Value

Success: | Specifies the type of the region that the function obtains. It can be one of the following values $NULLREGION - The region is empty. $SIMPLEREGION - The region is a single rectangle. $COMPLEXREGION - The region is more than one rectangle.
Failure: | 0 The specified window does not have a region, or an error occurred while attempting to return the region.

Remarks

The window region of a window is set by calling the SetWindowRgn function.
The window region determines the area within the window where the system permits drawing.
The system does not display any portion of a window that lies outside of the window region
The coordinates of a window's window region are relative to the upper-left corner of the window, not the client area of the window.
To set the window region of a window, call the SetWindowRgn function.

Related

_WinAPI_CombineRgn, _WinAPI_CreateRectRgn, _WinAPI_CreateRoundRectRgn, _WinAPI_SetWindowRgn

See Also

Search GetWindowRgn in MSDN Library.


Function _WinAPI_GetWindowText

Function Reference

_WinAPI_GetWindowText

Retrieves the text of the specified window's title bar

#include <WinAPI.au3>
_WinAPI_GetWindowText ( $hWnd )

Parameters

$hWnd Handle of the window

Return Value

Success: | Windows title bar
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information

See Also

Search GetWindowText in MSDN Library.


Function _WinAPI_GetWindowThreadProcessId

Function Reference

_WinAPI_GetWindowThreadProcessId

Retrieves the identifier of the thread that created the specified window

#include <WinAPI.au3>
_WinAPI_GetWindowThreadProcessId ( $hWnd, ByRef $iPID )

Parameters

$hWnd | Window handle
$iPID | Variable to hold the return the process ID (PID) of the thread.

Return Value

Returns the Thread ID of the specified window

Related

_WinAPI_GetCurrentProcessID

See Also

Search GetWindowThreadProcessId in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    WinWait("[CLASS:Notepad]", "", 10)

    ; Retrieve the handle of the Notepad window using the classname of Notepad.
    Local $hWnd = WinGetHandle("[CLASS:Notepad]")
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when trying to retrieve the window handle of Notepad.")
        Exit
    EndIf

    ; Retrieve the identifier of the thread and pass a variable to the $iPID parameter to store the PID.
    Local $iPID = 0
    Local $iThread = _WinAPI_GetWindowThreadProcessId($hWnd, $iPID)

    ; Display the process thread and PID of the Notepad window.
    MsgBox($MB_SYSTEMMODAL, '', "Process thread: " & $iThread & @CRLF & _
            "Process ID (PID): " & $iPID)

    ; Close the Notepad window using the handle returned by WinGetHandle.
    WinClose($hWnd)
EndFunc   ;==>Example


Function _WinAPI_GetWindowWidth

Function Reference

_WinAPI_GetWindowWidth

Returns the width of the window

#include <WinAPI.au3>
_WinAPI_GetWindowWidth ( $hWnd )

Parameters

$hWnd Handle to a window

Return Value

Success: | the width of window.
Failure: | sets the @error flag to non-zero.

Related

_WinAPI_GetWindowHeight


Function _WinAPI_GetXYFromPoint

Function Reference

_WinAPI_GetXYFromPoint

Returns the X/Y values from a $tagPOINT structure

#include <WinAPI.au3>
_WinAPI_GetXYFromPoint ( ByRef $tPoint, ByRef $iX, ByRef $iY )

Parameters

$tPoint | $tagPOINT structure
$iX | Returns X value
$iY | Returns Y value

Return Value

None.

Remarks

This function extracts the X/Y values from a $tagPOINT structure


Function _WinAPI_GlobalMemoryStatus

Function Reference

_WinAPI_GlobalMemoryStatus

Retrieves information about current available memory

#include <WinAPI.au3>
_WinAPI_GlobalMemoryStatus ( )

Return Value

Success: | Array with the following format: $aMem[0] - Percent of Mem in use $aMem[1] - Physical Mem: Total $aMem[2] - Physical Mem: Free $aMem[3] - Paging file: Total $aMem[4] - Paging file: Free $aMem[5] - User Mem: Total $aMem[6] - User Mem: Free
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information

Remarks

Unlike the AutoIt MemGetStats() function, this function returns the values in bytes

See Also

Search GlobalMemoryStatusEx in MSDN Library.


Function _WinAPI_GUIDFromString

Function Reference

_WinAPI_GUIDFromString

Converts a string GUID to binary form

#include <WinAPI.au3>
_WinAPI_GUIDFromString ( $sGUID )

Parameters

$sGUID GUID in string form

Return Value

Success: | a $tagGUID structure.
Failure: | sets the @error flag to non-zero.

Related

$tagGUID, _WinAPI_StringFromGUID


Function _WinAPI_GUIDFromStringEx

Function Reference

_WinAPI_GUIDFromStringEx

Converts a string GUID to binary form

#include <WinAPI.au3>
_WinAPI_GUIDFromStringEx ( $sGUID, $tGUID )

Parameters

$sGUID | GUID in string form
$tGUID | A $tagGUID structure or a ptr to it where the GUID will be stored

Return Value

Success: | True
Failure: | False

Related

$tagGUID, _WinAPI_StringFromGUID

See Also

Search CLSIDFromString in MSDN Library.


Function _WinAPI_HiWord

Function Reference

_WinAPI_HiWord

Returns the high word of a longword value

#include <WinAPI.au3>
_WinAPI_HiWord ( $iLong )

Parameters

$iLong Longword value

Return Value

Returns an High order word of the longword value

Related

_WinAPI_LoWord, _WinAPI_MakeLong

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $iWord = 11 * 65535
    MsgBox($MB_SYSTEMMODAL, $iWord, "HiWord: " & _WinAPI_HiWord($iWord) & @CRLF & "LoWord: " & _WinAPI_LoWord($iWord))
EndFunc   ;==>Example


Function _WinAPI_InProcess

Function Reference

_WinAPI_InProcess

Determines whether a window belongs to the current process

#include <WinAPI.au3>
_WinAPI_InProcess ( $hWnd, ByRef $hLastWnd )

Parameters

$hWnd | Window handle to be tested
$hLastWnd | Last window tested. If $hWnd = $hLastWnd, this process will immediately return True. Otherwise, _WinAPI_InProcess() will be called. If $hWnd is in process, $hLastWnd will be set to $hWnd on return.

Return Value

True: | Window handle belongs to the current process
False: | Window handle does not belong to the current process

Remarks

This is one of the key functions to the control memory mapping technique. It checks the process ID of the
window to determine if it belongs to the current process, which means it can be accessed without mapping the control memory.


Function _WinAPI_IntToFloat

Function Reference

_WinAPI_IntToFloat

Returns a 4 byte integer as a float value

#include <WinAPI.au3>
_WinAPI_IntToFloat ( $iInt )

Parameters

$iInt Integer value

Return Value

Returns a 4 byte integer value as a float

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

MsgBox($MB_SYSTEMMODAL, "", _WinAPI_IntToFloat(12389654))


Function _WinAPI_InvalidateRect

Function Reference

_WinAPI_InvalidateRect

Adds a rectangle to the specified window's update region

#include <WinAPI.au3>
_WinAPI_InvalidateRect ( $hWnd [, $tRECT = 0 [, $bErase = True]] )

Parameters

$hWnd | Handle to windows
$tRECT | [optional] $tagRECT structure that contains the client coordinates of the rectangle to be added to the update region. If this parameter is 0 the entire client area is added to the update region.
$bErase | [optional] Specifies whether the background within the update region is to be erased when the update region is processed. If this parameter is True the background is erased when the BeginPaint function is called. If this parameter is False, the background remains unchanged.

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Related

$tagRECT

See Also

Search InvalidateRect in MSDN Library.


Function _WinAPI_IsClassName

Function Reference

_WinAPI_IsClassName

Wrapper to check ClassName of the control

#include <WinAPI.au3>
_WinAPI_IsClassName ( $hWnd, $sClassName )

Parameters

$hWnd | Handle to a control
$sClassName | Class name to check

Return Value

True: | $sClassName matches ClassName retrieved from $hWnd
False: | $sClassName does not match ClassName retrieved from $hWnd

Remarks

Used for checking correct $hWnd is passed into function


Function _WinAPI_IsWindow

Function Reference

_WinAPI_IsWindow

Determines whether the specified window handle identifies an existing window

#include <WinAPI.au3>
_WinAPI_IsWindow ( $hWnd )

Parameters

$hWnd Handle to be tested

Return Value

True: | window is existing.
False: | window is not existing.

See Also

Search IsWindow in MSDN Library.


Function _WinAPI_IsWindowVisible

Function Reference

_WinAPI_IsWindowVisible

Retrieves the visibility state of the specified window

#include <WinAPI.au3>
_WinAPI_IsWindowVisible ( $hWnd )

Parameters

$hWnd Handle of window

Return Value

True: | window is visible
False: | window is not visible

Remarks

The visibility state of a window is indicated by the $WS_VISIBLE style bit. When $WS_VISIBLE is set, the window
is displayed and subsequent drawing into it is displayed as long as the window has the $WS_VISIBLE style.

See Also

Search IsWindowVisible in MSDN Library.


Function _WinAPI_LineTo

Function Reference

_WinAPI_LineTo

Draws a line from the current position up to, but not including, the specified point

#include <WinAPI.au3>
_WinAPI_LineTo ( $hDC, $iX, $iY )

Parameters

$hDC | Handle to device context
$iX | X coordinate of the line's ending point.
$iY | Y coordinate of the line's ending point.

Return Value

Success: | True
Failure: | False

Remarks

The line is drawn by using the current pen and, if the pen is a geometric pen, the current brush.
If LineTo succeeds, the current position is set to the specified ending point.

Related

_WinAPI_CreatePen, _WinAPI_DrawLine, _WinAPI_MoveTo, _WinAPI_SelectObject

See Also

Search LineTo in MSDN Library.

Example

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

ShowCross(@DesktopWidth / 2, @DesktopHeight / 2, 20, 2, 0xFF, 3000)

Func ShowCross($iStart_x, $iStart_y, $iLength, $iWidth, $iColor, $iTime)
    Local $hDC, $hPen, $o_Orig

    $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop)
    $hPen = _WinAPI_CreatePen($PS_SOLID, $iWidth, $iColor)
    $o_Orig = _WinAPI_SelectObject($hDC, $hPen)

    _WinAPI_DrawLine($hDC, $iStart_x - $iLength, $iStart_y, $iStart_x - 5, $iStart_y) ; horizontal left
    _WinAPI_DrawLine($hDC, $iStart_x + $iLength, $iStart_y, $iStart_x + 5, $iStart_y) ; horizontal right
    _WinAPI_DrawLine($hDC, $iStart_x, $iStart_y - $iLength, $iStart_x, $iStart_y - 5) ; vertical up
    ;   _WinAPI_DrawLine($hDC, $iStart_x, $iStart_y + $iLength, $iStart_x, $iStart_y + 5) ; vertical down
    _WinAPI_MoveTo($hDC, $iStart_x, $iStart_y + $iLength)
    _WinAPI_LineTo($hDC, $iStart_x, $iStart_y + 5)

    Sleep($iTime) ; show cross over screen for defined seconds

    ; refresh desktop (clear cross)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)

    ; clear resources
    _WinAPI_SelectObject($hDC, $o_Orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
EndFunc   ;==>ShowCross


Function _WinAPI_LoadBitmap

Function Reference

_WinAPI_LoadBitmap

Loads the specified bitmap resource from a module's executable file

#include <WinAPI.au3>
_WinAPI_LoadBitmap ( $hInstance, $sBitmap )

Parameters

$hInstance | Handle to the instance of the module whose executable file contains the bitmap to be loaded
$sBitmap | The name of the bitmap resource to be loaded. Alternatively this can consist of the resource identifier in the low order word and 0 in the high order word.

Return Value

Success: | The handle to the specified bitmap
Failure: | 0

See Also

Search LoadBitmap in MSDN Library.


Function _WinAPI_LoadImage

Function Reference

_WinAPI_LoadImage

Loads an icon, cursor, or bitmap

#include <WinAPI.au3>
_WinAPI_LoadImage ( $hInstance, $sImage, $iType, $iXDesired, $iYDesired, $iLoad )

Parameters

$hInstance Identifies an instance of the module that contains the image to be loaded. To load an OEM
image, set this parameter to zero.
$sImage Identifies the image to load. If the $hInstance parameter is not 0 and the $iLoad parameter
does not include $LR_LOADFROMFILE $sImage is a string that contains the name of the image resource in the
$hInstance module. If $hInstance is 0 and $LR_LOADFROMFILE is not specified, the low-order word of this
parameter must be the identifier of the OEM image to load.
$iType Specifies the type of image to be loaded. This parameter can be one of the following values:
$IMAGE_BITMAP - Loads a bitmap
$IMAGE_CURSOR - Loads a cursor
$IMAGE_ICON - Loads an icon
$iXDesired Specifies the width, in pixels, of the icon or cursor. If this is 0
and $iLoad is $LR_DEFAULTSIZE the function uses the SM_CXICON or SM_CXCURSOR system
metric value to set the width. If this parameter is 0 and $LR_DEFAULTSIZE is not
used, the function uses the actual resource width.
$iYDesired Specifies the height, in pixels, of the icon or cursor. If this is 0
and $iLoad is $LR_DEFAULTSIZE the function uses the SM_CYICON or SM_CYCURSOR system
metric value to set the height. If this parameter is 0 and $LR_DEFAULTSIZE is not
used, the function uses the actual resource height.
$iLoad Specifies a combination of the following values:
$LR_DEFAULTCOLOR - The default flag
$LR_CREATEDIBSECTION - When the $iType parameter specifies $IMAGE_BITMAP, causes the function to return a DIB
section bitmap rather than a compatible bitmap. This flag is useful for loading a bitmap without mapping it
to the colors of the display device.
$LR_DEFAULTSIZE - Uses the width or height specified by the system metric values for cursors or icons if
the $iXDesired or $iYDesired values are set to 0. If this flag is not specified and $iXDesired and $iYDesired
are set to zero, the function uses the actual resource size. If the resource contains multiple images the
function uses the size of the first image.
$LR_LOADFROMFILE - Loads the image from the file specified by the $sImage parameter. If this flag is not
specified, $sImage is the name of the resource.
$LR_LOADMAP3DCOLORS - Searches the color table for the image and replaces the following shades of gray with
the corresponding 3D color:
Dk Gray: RGB(128,128,128) COLOR_3DSHADOW
Gray : RGB(192,192,192) COLOR_3DFACE
Lt Gray: RGB(223,223,223) COLOR_3DLIGHT
$LR_LOADTRANSPARENT - Gets the color value of the first pixel in the image and replaces the corresponding
entry in the color table with the default window color. All pixels in the image that use that entry become
the default window color. This value applies only to images that have corresponding color tables. If $iLoad
includes both the $LR_LOADTRANSPARENT and $LR_LOADMAP3DCOLORS values, $LRLOADTRANSPARENT takes precedence.
However, the color table entry is replaced with COLOR_3DFACE rather than COLOR_WINDOW.
$LR_MONOCHROME - Loads the image in black and white
$LR_SHARED - Shares the image handle if the image is loaded multiple times. If LR_SHARED is not set,
a second call to LoadImage for the same resource will load the image again and return a different handle. Do
not use $LR_SHARED for images that have non-standard sizes, that may change after loading, or that are loaded
from a file.

Return Value

Success: | The handle of the newly loaded image
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

Remarks

Above constants require #include <WinAPIConstants.au3>

See Also

Search LoadImage in MSDN Library.


Function _WinAPI_LoadLibrary

Function Reference

_WinAPI_LoadLibrary

Maps a specified executable module into the address space of the calling process

#include <WinAPI.au3>
_WinAPI_LoadLibrary ( $sFileName )

Parameters

$sFileName Names a Win32 executable module (either a .dll or an .exe file). The name specified is the
filename of the executable module.

Return Value

Success: | A handle to the executable module
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

Related

_WinAPI_FreeLibrary, _WinAPI_LoadLibraryEx

See Also

Search LoadLibrary in MSDN Library.


Function _WinAPI_LoadLibraryEx

Function Reference

_WinAPI_LoadLibraryEx

Maps a specified executable module into the address space of the calling process

#include <WinAPI.au3>
_WinAPI_LoadLibraryEx ( $sFileName [, $iFlags = 0] )

Parameters

$sFileName | Names a Win32 executable module (either a .dll or an .exe file). The name specified is the filename of the executable module.
$iFlags | [optional] Specifies the action to take when loading the module. This parameter can be one of the following values: $DONT_RESOLVE_DLL_REFERENCES - If this value is used and the executable module is a DLL the system does not call DllMain for process and thread initialization and termination. Also, the system does not load additional executable modules that are referenced by the specified module. $LOAD_LIBRARY_AS_DATAFILE - If this value is used, the system maps the file into the calling process's address space as if it were a data file. Nothing is done to execute or prepare to execute the mapped file. $LOAD_WITH_ALTERED_SEARCH_PATH - If this value is used, and $FileName specifies a path, the system uses the alternate file search strategy to find the associated executable modules that the specified module causes to be loaded.

Return Value

Success: | A handle to the executable module
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

Remarks

Above constants require #include <WinAPIConstants.au3>

Related

_WinAPI_FreeLibrary, _WinAPI_LoadLibrary, _WinAPI_LoadString

See Also

Search LoadLibraryEx in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $idInput, $id_Get, $hReBar, $hInstance, $sText
    ; Create GUI
    $hGUI = GUICreate("WinAPI", 400, 396)

    $idInput = GUICtrlCreateInput("4209", 0, 0, 100, 20)

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGUI, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 55, 396, 200, BitOR($WS_VSCROLL, $WS_HSCROLL))
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ;add band containing the  control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "String ID:")

    $id_Get = GUICtrlCreateButton("Get String", 0, 0, 90, 20)

    ;add band containing the  control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($id_Get), 120, 200)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $id_Get
                GUICtrlSetData($g_idMemo, "")
                $hInstance = _WinAPI_LoadLibraryEx("shell32.dll", $LOAD_LIBRARY_AS_DATAFILE)
                If $hInstance Then
                    $sText = _WinAPI_LoadString($hInstance, GUICtrlRead($idInput))
                    If Not @error Then
                        MemoWrite('Got the String (chars: ' & @extended & '): ' & @CRLF & $sText)
                    Else
                        MemoWrite("Last Error Message: " & @CRLF & _WinAPI_GetLastErrorMessage())
                    EndIf
                    MemoWrite(@CRLF & "Success Freeing? " & _WinAPI_FreeLibrary($hInstance))
                EndIf
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _WinAPI_LoadShell32Icon

Function Reference

_WinAPI_LoadShell32Icon

Extracts an icon from the shell32.dll file

#include <WinAPI.au3>
_WinAPI_LoadShell32Icon ( $iIconID )

Parameters

$iIconID ID of the icon to extract

Return Value

Success: | Handle to the specified icon
Failure: | 0

Remarks

When you are done with the icon, call _WinAPI_DestroyIcon() to release the icon handle

Related

_WinAPI_DestroyIcon


Function _WinAPI_LoadString

Function Reference

_WinAPI_LoadString

loads a string resource from the executable file associated with a specified module

#include <WinAPI.au3>
_WinAPI_LoadString ( $hInstance, $iStringID )

Parameters

$hInstance | Handle to an instance of the module whose executable file contains the string resource
$iStringID | Specifies the integer identifier of the string to be loaded

Return Value

Success: | The string requested, @extended is the number of TCHARS copied
Failure: | Sets the @error flag to non-zero

Related

_WinAPI_FreeLibrary, _WinAPI_LoadLibraryEx

See Also

Search LoadString in MSDN Library.

Example

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

Global $g_idMemo

Example()

Func Example()
    Local $hGUI, $idInput, $id_Get, $hReBar, $hInstance, $sText
    ; Create GUI
    $hGUI = GUICreate("WinAPI", 400, 396)

    $idInput = GUICtrlCreateInput("4209", 0, 0, 100, 20)

    ; create the rebar control
    $hReBar = _GUICtrlRebar_Create($hGUI, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    $g_idMemo = GUICtrlCreateEdit("", 2, 55, 396, 200, BitOR($WS_VSCROLL, $WS_HSCROLL))
    GUICtrlSetFont($g_idMemo, 10, 400, 0, "Courier New")

    ;add band containing the  control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($idInput), 120, 200, "String ID:")

    $id_Get = GUICtrlCreateButton("Get String", 0, 0, 90, 20)

    ;add band containing the  control
    _GUICtrlRebar_AddBand($hReBar, GUICtrlGetHandle($id_Get), 120, 200)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $id_Get
                GUICtrlSetData($g_idMemo, "")
                $hInstance = _WinAPI_LoadLibraryEx("shell32.dll", $LOAD_LIBRARY_AS_DATAFILE)
                If $hInstance Then
                    $sText = _WinAPI_LoadString($hInstance, GUICtrlRead($idInput))
                    If Not @error Then
                        MemoWrite('Got the String (chars: ' & @extended & '): ' & @CRLF & $sText)
                    Else
                        MemoWrite("Last Error Message: " & @CRLF & _WinAPI_GetLastErrorMessage())
                    EndIf
                    MemoWrite(@CRLF & "Success Freeing? " & _WinAPI_FreeLibrary($hInstance))
                EndIf
        EndSwitch
    WEnd
EndFunc   ;==>Example

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


Function _WinAPI_LocalFree

Function Reference

_WinAPI_LocalFree

Frees the specified local memory object and invalidates its handle

#include <WinAPI.au3>
_WinAPI_LocalFree ( $hMemory )

Parameters

$hMemory A handle to the local memory object

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

See Also

Search LocalFree in MSDN Library.


Function _WinAPI_LoWord

Function Reference

_WinAPI_LoWord

Returns the low word of a longword

#include <WinAPI.au3>
_WinAPI_LoWord ( $iLong )

Parameters

$iLong Longword value

Return Value

Returns an low order word of the longword value

Related

_WinAPI_HiWord, _WinAPI_MakeLong

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $iWord = 11 * 65535
    MsgBox($MB_SYSTEMMODAL, $iWord, "HiWord: " & _WinAPI_HiWord($iWord) & @CRLF & "LoWord: " & _WinAPI_LoWord($iWord))
EndFunc   ;==>Example


Function _WinAPI_MAKELANGID

Function Reference

_WinAPI_MAKELANGID

Construct language id from a primary language id and a sublanguage id

#include <WinAPI.au3>
_WinAPI_MAKELANGID ( $iLngIDPrimary, $iLngIDSub )

Parameters

$iLngIDPrimary | Primary Language id
$iLngIDSub | Sub-Language id

Return Value

Returns the Language identifier


Function _WinAPI_MAKELCID

Function Reference

_WinAPI_MAKELCID

Construct locale id from a language id and a sort id

#include <WinAPI.au3>
_WinAPI_MAKELCID ( $iLngID, $iSortID )

Parameters

$iLngID | Language id
$iSortID | Sort id

Return Value

Returns a Locale identifier


Function _WinAPI_MakeLong

Function Reference

_WinAPI_MakeLong

Returns a long int value from two int values

#include <WinAPI.au3>
_WinAPI_MakeLong ( $iLo, $iHi )

Parameters

$iLo | Low word
$iHi | Hi word

Return Value

Returns a long int value

Related

_WinAPI_HiWord, _WinAPI_LoWord


Function _WinAPI_MakeQWord

Function Reference

_WinAPI_MakeQWord

Returns a QWORD value from two int values

#include <WinAPI.au3>
_WinAPI_MakeQWord ( $iLoDWORD, $iHiDWORD )

Parameters

$iLoDWORD | Low DWORD (int)
$iHiDWORD | Hi DWORD (int)

Return Value

Returns a QWORD (int64) value


Function _WinAPI_MessageBeep

Function Reference

_WinAPI_MessageBeep

Plays a waveform sound

#include <WinAPI.au3>
_WinAPI_MessageBeep ( [$iType = 1] )

Parameters

$iType [optional] The sound type, as identified by an entry in the registry. This can be one of the following
values:
0 - Simple beep. If a sound card is not available, the speaker is used.
1 - OK
2 - Hand
3 - Question
4 - Exclamation
5 - Asterisk

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

After queuing the sound, the MessageBeep function returns control to the calling function and plays the sound
asynchronously. If it cannot play the specified alert sound, MessageBeep attempts to play the system default
sound. If it cannot play the system default sound, the function produces a standard beep sound through the
computer speaker.

See Also

Search MessageBeep in MSDN Library.


Function _WinAPI_Mouse_Event

Function Reference

_WinAPI_Mouse_Event

Synthesizes mouse motion and button clicks

#include <WinAPI.au3>
_WinAPI_Mouse_Event ( $iFlags [, $iX = 0 [, $iY = 0 [, $iData = 0 [, $iExtraInfo = 0]]]] )

Parameters

$iFlags A set of flag bits that specify various aspects of mouse motion and button clicking. The bits
in this parameter can be any reasonable combination of the following values:
$MOUSEEVENTF_ABSOLUTE - Specifies that the $iX and $iY parameters contain normal absolute coordinates. If
not set, those parameters contain relative data. The change in position since the last reported position.
This flag can be set, or not set, regardless of what kind of mouse or mouse-like device, if any, is connected
to the system.
$MOUSEEVENTF_MOVE - Specifies that movement occurred
$MOUSEEVENTF_LEFTDOWN - Specifies that the left button changed to down
$MOUSEEVENTF_LEFTUP - Specifies that the left button changed to up
$MOUSEEVENTF_RIGHTDOWN - Specifies that the right button changed to down
$MOUSEEVENTF_RIGHTUP - Specifies that the right button changed to up
$MOUSEEVENTF_MIDDLEDOWN - Specifies that the middle button changed to down
$MOUSEEVENTF_MIDDLEUP - Specifies that the middle button changed to up
$MOUSEEVENTF_WHEEL - Specifies that the wheel has been moved, if the mouse has a wheel
$MOUSEEVENTF_XDOWN - Specifies that an X button was pressed
$MOUSEEVENTF_XUP - Specifies that an X button was released
$iX [optional] Specifies the mouse's absolute position along the X axis or its amount of motion since the
last mouse event was generated depending on the setting of $MOUSEEVENTF_ABSOLUTE. Absolute data is given as
the mouse's actual X coordinate relative data is given as the number of mickeys moved.
$iY [optional] Specifies the mouse's absolute position along the Y axis or its amount of motion since the
last mouse event was generated depending on the setting of $MOUSEEVENTF_ABSOLUTE. Absolute data is given as
the mouse's actual Y coordinate relative data is given as the number of mickeys moved.
$iData [optional] If $iFlags is $MOUSEEVENTF_WHEEL, then $iData specifies the amount of wheel movement. A positive
value indicates that the wheel was rotated forward away from the user. A negative value indicates that the
wheel was rotated backward, toward the user. One wheel click is defined as $WHEEL_DELTA, which is 120. If
$iFlags is not $MOUSEEVENTF_WHEEL, then $iData should be zero.
$iExtraInfo [optional] Specifies a 32 bit value associated with the mouse event

Return Value

None.

Remarks

Above constants require #include <Constants.au3>

See Also

Search mouse_event in MSDN Library.


Function _WinAPI_MoveTo

Function Reference

_WinAPI_MoveTo

Updates the current position to the specified point

#include <WinAPI.au3>
_WinAPI_MoveTo ( $hDC, $iX, $iY )

Parameters

$hDC | Handle to device context
$iX | X coordinate of the new position.
$iY | Y coordinate of the new position.

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

The MoveTo function affects all drawing functions.

Related

_WinAPI_CreatePen, _WinAPI_DrawLine, _WinAPI_LineTo, _WinAPI_SelectObject

See Also

Search MoveToEx in MSDN Library.

Example

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

ShowCross(@DesktopWidth / 2, @DesktopHeight / 2, 20, 2, 0xFF, 3000)

Func ShowCross($iStart_x, $iStart_y, $iLength, $iWidth, $iColor, $iTime)
    Local $hDC, $hPen, $o_Orig

    $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop)
    $hPen = _WinAPI_CreatePen($PS_SOLID, $iWidth, $iColor)
    $o_Orig = _WinAPI_SelectObject($hDC, $hPen)

    _WinAPI_DrawLine($hDC, $iStart_x - $iLength, $iStart_y, $iStart_x - 5, $iStart_y) ; horizontal left
    _WinAPI_DrawLine($hDC, $iStart_x + $iLength, $iStart_y, $iStart_x + 5, $iStart_y) ; horizontal right
    _WinAPI_DrawLine($hDC, $iStart_x, $iStart_y - $iLength, $iStart_x, $iStart_y - 5) ; vertical up
    ;   _WinAPI_DrawLine($hDC, $iStart_x, $iStart_y + $iLength, $iStart_x, $iStart_y + 5) ; vertical down
    _WinAPI_MoveTo($hDC, $iStart_x, $iStart_y + $iLength)
    _WinAPI_LineTo($hDC, $iStart_x, $iStart_y + 5)

    Sleep($iTime) ; show cross over screen for defined seconds

    ; refresh desktop (clear cross)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)

    ; clear resources
    _WinAPI_SelectObject($hDC, $o_Orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
EndFunc   ;==>ShowCross


Function _WinAPI_MoveWindow

Function Reference

_WinAPI_MoveWindow

Changes the position and dimensions of the specified window

#include <WinAPI.au3>
_WinAPI_MoveWindow ( $hWnd, $iX, $iY, $iWidth, $iHeight [, $bRepaint = True] )

Parameters

$hWnd | Handle of window
$iX | New position of the left side of the window
$iY | New position of the top of the window
$iWidth | New width of the window
$iHeight | New height of the window
$bRepaint | [optional] Specifies whether the window is to be repainted. If True, the window receives a $WM_PAINT message. If False, no repainting of any kind occurs. This applies to the client area, the nonclient area, and any part of the parent window uncovered as a result of moving a child window. If False, the application must explicitly invalidate or redraw any parts of the window and parent window that need redrawing.

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

See Also

Search MoveWindow in MSDN Library.


Function _WinAPI_MsgBox

Function Reference

_WinAPI_MsgBox

Displays a message box with wider margin than original

#include <WinAPI.au3>
_WinAPI_MsgBox ( $iFlags, $sTitle, $sText )

Parameters

$iFlags | Flags to use during window creation
$sTitle | Window title
$sText | Window text

Return Value

None.

Remarks

This function produces (IMO) a better looking message box. It also makes sure that BlockInput is turned off
so the user can move the mouse.

Related

_WinAPI_ShowError, _WinAPI_ShowMsg


Function _WinAPI_MulDiv

Function Reference

_WinAPI_MulDiv

Multiplies two 32-bit values and then divides the 64-bit result by a third 32-bit value

#include <WinAPI.au3>
_WinAPI_MulDiv ( $iNumber, $iNumerator, $iDenominator )

Parameters

$iNumber | Specifies the multiplicand
$iNumerator | Specifies the multiplier
$iDenominator | Specifies the number by which the result of the multiplication is to be divided

Return Value

Success: | The result of the multiplication and division
Failure: | (-1), if either an overflow occurred or $iDenominator was 0

Remarks

If the result is a positive half integer (ends in .5), it is rounded up.
If the result is a negative half integer, it is rounded down.

See Also

Search MulDiv in MSDN Library.


Function _WinAPI_MultiByteToWideChar

Function Reference

_WinAPI_MultiByteToWideChar

Maps a character string to a wide-character (Unicode) string

#include <WinAPI.au3>
_WinAPI_MultiByteToWideChar ( $vText [, $iCodePage = 0 [, $iFlags = 0 [, $bRetString = False]]] )

Parameters

$vText | Text or DllStruct containing multibyte text to be converted
$iCodePage | [optional] Specifies the code page to be used to perform the conversion: 0 - ANSI code page 1 - OEM code page 2 - Macintosh code page 3 - The Windows ANSI code page for the current thread 42 - Symbol code page 65000 - UTF-7 65001 - UTF-8
$iFlags | [optional] Flags that indicate whether to translate to precomposed or composite wide characters: $MB_PRECOMPOSED - Always use precomposed characters $MB_COMPOSITE - Always use composite characters $MB_USEGLYPHCHARS - Use glyph characters instead of control characters
$bRetString | [optional] Flags that indicate whether to return a String or a DllStruct (default False : Structure)

Return Value

Success: | String or DllStruct that contains the Unicode character string
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information

Related

_WinAPI_MultiByteToWideCharEx, _WinAPI_WideCharToMultiByte

See Also

Search MultiByteToWideChar in MSDN Library.


Function _WinAPI_MultiByteToWideCharEx

Function Reference

_WinAPI_MultiByteToWideCharEx

Maps a character string to a wide-character (Unicode) string

#include <WinAPI.au3>
_WinAPI_MultiByteToWideCharEx ( $sText, $pText [, $iCodePage = 0 [, $iFlags = 0]] )

Parameters

$sText | Text to be converted
$pText | Pointer to a byte structure where the converted string will be stored
$iCodePage | [optional] Specifies the code page to be used to perform the conversion: 0 - ANSI code page 1 - OEM code page 2 - Macintosh code page
$iFlags | [optional] Flags that indicate whether to translate to precomposed or composite wide characters: $MB_PRECOMPOSED - Always use precomposed characters $MB_COMPOSITE - Always use composite characters $MB_USEGLYPHCHARS - Use glyph characters instead of control characters

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

The byte structure must be at least twice the length of $sText.

Related

_WinAPI_MultiByteToWideChar


Function _WinAPI_OpenProcess

Function Reference

_WinAPI_OpenProcess

Returns a handle of an existing process object

#include <WinAPI.au3>
_WinAPI_OpenProcess ( $iAccess, $bInherit, $iPID [, $bDebugPriv = False] )

Parameters

$iAccess | Specifies the access to the process object
$bInherit | Specifies whether the returned handle can be inherited
$iPID | Specifies the process identifier of the process to open
$bDebugPriv | [optional] Certain system processes can not be opened unless you have the debug security privilege. If True, this function will attempt to open the process with debug privileges if the process can not be opened with standard access privileges.

Return Value

Success: | the process handle to the object.
Failure: | sets the @error flag to non-zero.

Related

_WinAPI_CloseHandle, _WinAPI_ReadProcessMemory, _WinAPI_WriteProcessMemory

See Also

Search OpenProcess in MSDN Library.

Example

#include <ProcessConstants.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>

; _WinAPI_CreateProcess() will be the best solution
Local $iPID = Run('cmd.exe /k')
If Not $iPID Then
    Exit
EndIf

; Note, immediately open the process
Local $hProcess
If _WinAPI_GetVersion() >= 6.0 Then
    $hProcess = _WinAPI_OpenProcess($PROCESS_QUERY_LIMITED_INFORMATION, 0, $iPID)
Else
    $hProcess = _WinAPI_OpenProcess($PROCESS_QUERY_INFORMATION, 0, $iPID)
EndIf
If Not $hProcess Then
    Exit
EndIf

; Wait until the process exists, try enter "exit 6"
While ProcessExists($iPID)
    Sleep(100)
WEnd

ConsoleWrite('Exit code: ' & _WinAPI_GetExitCodeProcess($hProcess) & @CRLF)

_WinAPI_CloseHandle($hProcess)


Function _WinAPI_PathFindOnPath

Function Reference

_WinAPI_PathFindOnPath

Searchs for a file in the default system paths

#include <WinAPI.au3>
_WinAPI_PathFindOnPath ( $sFilePath [, $aExtraPaths = "" [, $sPathDelimiter = @LF]] )

Parameters

$sFilePath | Filename to search for
$aExtraPaths | [optional] Extra paths to check before any others.
$sPathDelimiter | [optional] Delimiter used to split $aExtraPaths if it's an non-empty string (StringSplit() with flag $STR_NOCOUNT (2)).

Return Value

Success: | the full path of found file.
Failure: | sets the @error flag to non-zero, filename Unchanged.

Remarks

$aExtraPaths can contain a list of paths to be checked before any system defaults.
It can be an array or a string. If the former, it shall not have a count in it's first element.
If the latter, it will be split using $sPathDelimiter as the delimiter, that defaults to @LF.

See Also

Search PathFindOnPath in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

MsgBox($MB_SYSTEMMODAL, "PathFindOnPath Example", _
        StringFormat("Full path of notepad.exe:\n%s\n\n" & _
        "Find ntuser.dat in profile folder, using custom paths:\n%s", _
        _WinAPI_PathFindOnPath("notepad.exe"), _WinAPI_PathFindOnPath("ntuser.dat", @UserProfileDir) _
        ))


Function _WinAPI_PointFromRect

Function Reference

_WinAPI_PointFromRect

Returns the top/left coordinates of a $tagRECT as a $tagPOINT structure

#include <WinAPI.au3>
_WinAPI_PointFromRect ( ByRef $tRECT [, $bCenter = True] )

Parameters

$tRECT | $tagRECT structure
$bCenter | [optional] If True, the return will be a point at the center of the rectangle, otherwise the left/top coordinates are returned.

Return Value

Returns a $tagPOINT structure

Remarks

This function is used to get the click position for many of the click functions


Function _WinAPI_PostMessage

Function Reference

_WinAPI_PostMessage

Places a message in the message queue and then returns

#include <WinAPI.au3>
_WinAPI_PostMessage ( $hWnd, $iMsg, $wParam, $lParam )

Parameters

$hWnd | Identifies the window whose window procedure will receive the message. If this parameter is 0xFFFF (HWND_BROADCAST), the message is sent to all top-level windows in the system, including disabled or invisible windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.
$iMsg | Specifies the message to be sent
$wParam | First message parameter
$lParam | Second message parameter

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

See Also

Search PostMessage in MSDN Library.


Function _WinAPI_PrimaryLangId

Function Reference

_WinAPI_PrimaryLangId

Extract primary language id from a language id

#include <WinAPI.au3>
_WinAPI_PrimaryLangId ( $iLngID )

Parameters

$iLngID Language id

Return Value

Returns an Primary language id


Function _WinAPI_PtInRect

Function Reference

_WinAPI_PtInRect

Determines whether the specified point lies within the specified rectangle

#include <WinAPI.au3>
_WinAPI_PtInRect ( ByRef $tRECT, ByRef $tPoint )

Parameters

$tRECT | $tagRECT structure that contains the specified rectangle
$tPoint | $tagPOINT structure that contains the specified point

Return Value

True: | point lies within the rectangle
False: | point does not lie within the rectangle

Related

$tagPOINT, $tagRECT

See Also

Search PtInRect in MSDN Library.


Function _WinAPI_ReadFile

Function Reference

_WinAPI_ReadFile

Reads data from a file

#include <WinAPI.au3>
_WinAPI_ReadFile ( $hFile, $pBuffer, $iToRead, ByRef $iRead [, $tOverlapped = 0] )

Parameters

$hFile | Handle to the file to be read
$pBuffer | Pointer to the buffer that receives the data read from a file
$iToRead | Maximum number of bytes to read
$iRead | Number of bytes read
$tOverlapped | [optional] A $tagOVERLAPPED structure or a pointer to it

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Related

$tagOVERLAPPED, _WinAPI_CloseHandle, _WinAPI_CreateFile, _WinAPI_FlushFileBuffers, _WinAPI_GetFileSizeEx, _WinAPI_SetEndOfFile, _WinAPI_SetFilePointer, _WinAPI_WriteFile

See Also

Search ReadFile in MSDN Library.

Example

#include <WinAPI.au3>

Local $sTempFile, $hFile, $sText, $nBytes, $tBuffer, $iSize

; 1) create file and write data to it
$sTempFile = @TempDir & '\test.txt'
$sText = 'abcdefghijklmnopqrstuvwxyz'
$tBuffer = DllStructCreate("byte[" & StringLen($sText) & "]")
DllStructSetData($tBuffer, 1, $sText)
$hFile = _WinAPI_CreateFile($sTempFile, 1)
_WinAPI_WriteFile($hFile, $tBuffer, StringLen($sText), $nBytes)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_CloseHandle($hFile)
ConsoleWrite('1):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

; 2) read 6 bytes from position 3
$tBuffer = DllStructCreate("byte[6]")
$hFile = _WinAPI_CreateFile($sTempFile, 2, 2)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_SetFilePointer($hFile, 3)
_WinAPI_ReadFile($hFile, $tBuffer, 6, $nBytes)
_WinAPI_CloseHandle($hFile)
$sText = BinaryToString(DllStructGetData($tBuffer, 1))
ConsoleWrite('2):' & $iSize & ' ' & $sText & @CRLF)

; 3) write previously read 6 bytes from position 3 to the same position but in UpperCase
DllStructSetData($tBuffer, 1, StringUpper($sText))
$hFile = _WinAPI_CreateFile($sTempFile, 2, 4)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_SetFilePointer($hFile, 3)
_WinAPI_WriteFile($hFile, $tBuffer, 6, $nBytes)
_WinAPI_CloseHandle($hFile)
$tBuffer = 0
ConsoleWrite('3):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

; 4) truncate file size to 12 bytes
$hFile = _WinAPI_CreateFile($sTempFile, 2, 4)
_WinAPI_SetFilePointer($hFile, 12)
_WinAPI_SetEndOfFile($hFile)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_CloseHandle($hFile)
ConsoleWrite('4):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

FileDelete($sTempFile)


Function _WinAPI_ReadProcessMemory

Function Reference

_WinAPI_ReadProcessMemory

Reads memory in a specified process

#include <WinAPI.au3>
_WinAPI_ReadProcessMemory ( $hProcess, $pBaseAddress, $pBuffer, $iSize, ByRef $iRead )

Parameters

$hProcess | Identifies an open handle of a process whose memory is read
$pBaseAddress | Points to the base address in the specified process to be read
$pBuffer | Points to a buffer that receives the contents from the address space
$iSize | Specifies the requested number of bytes to read from the specified process
$iRead | The actual number of bytes transferred into the specified buffer

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Related

_WinAPI_WriteProcessMemory

See Also

Search ReadProcessMemory in MSDN Library.


Function _WinAPI_RectIsEmpty

Function Reference

_WinAPI_RectIsEmpty

Determins whether a rectangle is empty

#include <WinAPI.au3>
_WinAPI_RectIsEmpty ( ByRef $tRECT )

Parameters

$tRECT $tagRect structure

Return Value

True: | Rectangle is empty (all values are zero)
False: | Rectangle is not empty

Related

$tagRect


Function _WinAPI_RedrawWindow

Function Reference

_WinAPI_RedrawWindow

Updates the specified rectangle or region in a window's client area

#include <WinAPI.au3>
_WinAPI_RedrawWindow ( $hWnd [, $tRECT = 0 [, $hRegion = 0 [, $iFlags = 5]]] )

Parameters

$hWnd Handle to a Window
$tRECT [optional] $tagRECT structure containing the coordinates of the update rectangle. This parameter is
ignored if the $hRegion parameter identifies a region.
$hRegion [optional] Identifies the update region. If the $hRegion and $tRECT parameters are 0, the entire client
area is added to the update region.
$iFlags [optional] Specifies the redraw flags. This parameter can be a combination of flags that invalidate or validate a window, control repainting, and control which windows are affected:
$RDW_ERASE - Causes the window to receive a WM_ERASEBKGND message when the window is repainted
$RDW_FRAME - Causes any part of the nonclient area of the window that intersects the update region to receive a WM_NCPAINT message.
$RDW_INTERNALPAINT - Causes a WM_PAINT message to be posted to the window regardless of whether any portion of the window is invalid.
$RDW_INVALIDATE - Invalidates $tRECT or $hRegion. If both are 0, the entire window is invalidated.
$RDW_NOERASE - Suppresses any pending $WM_ERASEBKGND messages
$RDW_NOFRAME - Suppresses any pending $WM_NCPAINT messages
$RDW_NOINTERNALPAINT - Suppresses any pending internal $WM_PAINT messages
$RDW_VALIDATE - Validates $tRECT or $hRegion
$RDW_ERASENOW - Causes the affected windows to receive $WM_NCPAINT and $WM_ERASEBKGND messages, if necessary, before the function returns
$RDW_UPDATENOW - Causes the affected windows to receive $WM_NCPAINT, $WM_ERASEBKGND, and $WM_PAINT messages, if necessary, before the function returns.
$RDW_ALLCHILDREN - Includes child windows in the repainting operation
$RDW_NOCHILDREN - Excludes child windows from the repainting operation

Return Value

Success: | True
Failure: | False

Remarks

When RedrawWindow is used to invalidate part of the desktop window, the desktop window does not receive a $WM_PAINT message.
To repaint the desktop an application uses the $RDW_ERASE flag to generate a $WM_ERASEBKGND message.

Above constants require #include <WindowsConstants.au3>

Related

$tagRECT

See Also

Search RedrawWindow in MSDN Library.

Example

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

ShowCross(@DesktopWidth / 2, @DesktopHeight / 2, 20, 2, 0xFF, 3000)

Func ShowCross($iStart_x, $iStart_y, $iLength, $iWidth, $iColor, $iTime)
    Local $hDC, $hPen, $o_Orig

    $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop)
    $hPen = _WinAPI_CreatePen($PS_SOLID, $iWidth, $iColor)
    $o_Orig = _WinAPI_SelectObject($hDC, $hPen)

    _WinAPI_DrawLine($hDC, $iStart_x - $iLength, $iStart_y, $iStart_x - 5, $iStart_y) ; horizontal left
    _WinAPI_DrawLine($hDC, $iStart_x + $iLength, $iStart_y, $iStart_x + 5, $iStart_y) ; horizontal right
    _WinAPI_DrawLine($hDC, $iStart_x, $iStart_y - $iLength, $iStart_x, $iStart_y - 5) ; vertical up
    ;   _WinAPI_DrawLine($hDC, $iStart_x, $iStart_y + $iLength, $iStart_x, $iStart_y + 5) ; vertical down
    _WinAPI_MoveTo($hDC, $iStart_x, $iStart_y + $iLength)
    _WinAPI_LineTo($hDC, $iStart_x, $iStart_y + 5)

    Sleep($iTime) ; show cross over screen for defined seconds

    ; refresh desktop (clear cross)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)

    ; clear resources
    _WinAPI_SelectObject($hDC, $o_Orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
EndFunc   ;==>ShowCross


Function _WinAPI_RegisterWindowMessage

Function Reference

_WinAPI_RegisterWindowMessage

Defines a new window message that is guaranteed to be unique throughout the system

#include <WinAPI.au3>
_WinAPI_RegisterWindowMessage ( $sMessage )

Parameters

$sMessage String that specifies the message to be registered

Return Value

Success: | A message identifier in the range 0xC000 through 0xFFFF
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

Remarks

The RegisterWindowMessage function is used to register messages for communicating between two cooperating
applications. If two different applications register the same message string, the applications return the same
message value. The message remains registered until the session ends.

See Also

Search RegisterWindowMessage in MSDN Library.


Function _WinAPI_ReleaseCapture

Function Reference

_WinAPI_ReleaseCapture

Releases the mouse capture from a window in the current thread and restores normal mouse input processing

#include <WinAPI.au3>
_WinAPI_ReleaseCapture ( )

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

See Also

Search ReleaseCapture in MSDN Library.


Function _WinAPI_ReleaseDC

Function Reference

_WinAPI_ReleaseDC

Releases a device context

#include <WinAPI.au3>
_WinAPI_ReleaseDC ( $hWnd, $hDC )

Parameters

$hWnd | Handle of window
$hDC | Identifies the device context to be released

Return Value

Success: | True
Failure: | False

Remarks

The application must call the _WinAPI_ReleaseDC() function for each call to the _WinAPI_GetWindowDC() function and for
each call to the _WinAPI_GetDC() function that retrieves a common device context.

Related

_WinAPI_DeleteDC, _WinAPI_GetDC, _WinAPI_GetWindowDC

See Also

Search ReleaseDC in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hWnd, $hDC
    $hWnd = GUICreate("test")
    $hDC = _WinAPI_GetDC($hWnd)
    MsgBox($MB_SYSTEMMODAL, "Handle", "Display Device: " & $hDC)
    _WinAPI_ReleaseDC($hWnd, $hDC)
EndFunc   ;==>Example


Function _WinAPI_ScreenToClient

Function Reference

_WinAPI_ScreenToClient

Converts screen coordinates of a specified point on the screen to client coordinates

#include <WinAPI.au3>
_WinAPI_ScreenToClient ( $hWnd, ByRef $tPoint )

Parameters

$hWnd | Identifies the window that be used for the conversion
$tPoint | $tagPOINT structure that contains the screen coordinates to be converted

Return Value

Success: | True
Failure: | False

Remarks

The function uses the window identified by the $hWnd parameter and the screen coordinates given in the
$tagPOINT structure to compute client coordinates. It then replaces the screen coordinates with the client
coordinates. The new coordinates are relative to the upper-left corner of the specified window's client area.

Related

$tagPOINT, _WinAPI_ClientToScreen

See Also

Search ScreenToClient in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Example()

Func Example()
    Local $hWnd = GUICreate("Example", 200, 200)
    Local $tPoint = DllStructCreate("int X;int Y")
    DllStructSetData($tPoint, "X", 641)
    DllStructSetData($tPoint, "Y", 459)
    GUISetState(@SW_SHOW)
    Sleep(1000)
    _WinAPI_ScreenToClient($hWnd, $tPoint)
    MsgBox($MB_SYSTEMMODAL, "_WinAPI_ClientToScreen Example", "Screen Cordinates of 641,459 is x,y position of client: " & @CRLF & _
            "X: " & DllStructGetData($tPoint, "X") & @CRLF & _
            "Y: " & DllStructGetData($tPoint, "Y") & @CRLF)
EndFunc   ;==>Example


Function _WinAPI_SelectObject

Function Reference

_WinAPI_SelectObject

Selects an object into the specified device context

#include <WinAPI.au3>
_WinAPI_SelectObject ( $hDC, $hGDIObj )

Parameters

$hDC | Identifies the device context
$hGDIObj | Identifies the object to be selected

Return Value

Success: | The handle of the object being replaced
Failure: | <= 0

Related

_WinAPI_CreatePen, _WinAPI_DrawLine, _WinAPI_GetBkMode, _WinAPI_LineTo, _WinAPI_MoveTo, _WinAPI_SetBkMode

See Also

Search SelectObject in MSDN Library.

Example

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

ShowCross(@DesktopWidth / 2, @DesktopHeight / 2, 20, 2, 0xFF, 3000)

Func ShowCross($iStart_x, $iStart_y, $iLength, $iWidth, $iColor, $iTime)
    Local $hDC, $hPen, $o_Orig

    $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop)
    $hPen = _WinAPI_CreatePen($PS_SOLID, $iWidth, $iColor)
    $o_Orig = _WinAPI_SelectObject($hDC, $hPen)

    _WinAPI_DrawLine($hDC, $iStart_x - $iLength, $iStart_y, $iStart_x - 5, $iStart_y) ; horizontal left
    _WinAPI_DrawLine($hDC, $iStart_x + $iLength, $iStart_y, $iStart_x + 5, $iStart_y) ; horizontal right
    _WinAPI_DrawLine($hDC, $iStart_x, $iStart_y - $iLength, $iStart_x, $iStart_y - 5) ; vertical up
    ;   _WinAPI_DrawLine($hDC, $iStart_x, $iStart_y + $iLength, $iStart_x, $iStart_y + 5) ; vertical down
    _WinAPI_MoveTo($hDC, $iStart_x, $iStart_y + $iLength)
    _WinAPI_LineTo($hDC, $iStart_x, $iStart_y + 5)

    Sleep($iTime) ; show cross over screen for defined seconds

    ; refresh desktop (clear cross)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)

    ; clear resources
    _WinAPI_SelectObject($hDC, $o_Orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
EndFunc   ;==>ShowCross


Function _WinAPI_SetBkColor

Function Reference

_WinAPI_SetBkColor

Sets the current background color to the specified color value

#include <WinAPI.au3>
_WinAPI_SetBkColor ( $hDC, $iColor )

Parameters

$hDC | Handle to the device context
$iColor | Specifies the new background color

Return Value

Success: | The previous background color
Failure: | -1

See Also

Search SetBkColor in MSDN Library.

Example

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

Global $g_tRECT, $g_hFont, $g_hOldFont, $g_hDC

HotKeySet("{ESC}", "_Exit")

$g_tRECT = DllStructCreate($tagRect)
DllStructSetData($g_tRECT, "Left", 5)
DllStructSetData($g_tRECT, "Top", 5)
DllStructSetData($g_tRECT, "Right", 250)
DllStructSetData($g_tRECT, "Bottom", 50)

$g_hDC = _WinAPI_GetDC(0)
$g_hFont = _WinAPI_CreateFont(50, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _
        $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')
$g_hOldFont = _WinAPI_SelectObject($g_hDC, $g_hFont)

_WinAPI_SetTextColor($g_hDC, 0x0000FF)
_WinAPI_SetBkColor($g_hDC, 0x000000)
; comment next line to get black background instead of transparent one
_WinAPI_SetBkMode($g_hDC, $TRANSPARENT)

While 1
    _WinAPI_DrawText($g_hDC, "Hello world!", $g_tRECT, $DT_CENTER)
    Sleep(100)
WEnd

Func _Exit()
    _WinAPI_SelectObject($g_hDC, $g_hOldFont)
    _WinAPI_DeleteObject($g_hFont)
    _WinAPI_ReleaseDC(0, $g_hDC)
    _WinAPI_InvalidateRect(0, 0)
    $g_tRECT = 0
    Exit
EndFunc   ;==>_Exit


Function _WinAPI_SetBkMode

Function Reference

_WinAPI_SetBkMode

Sets the background mix mode of the specified device context

#include <WinAPI.au3>
_WinAPI_SetBkMode ( $hDC, $iBkMode )

Parameters

$hDC | Handle to device context
$iBkMode | Specifies the background mix mode. This parameter can be one of the following values. OPAQUE - Background is filled with the current background color before the text, hatched brush, or pen is drawn. TRANSPARENT - Background remains untouched.

Return Value

Success: | Value specifies the previous background mix mode.
Failure: | 0

Remarks

The background mix mode is used with text, hatched brushes, and pen styles that are not solid lines.
The SetBkMode function affects the line styles for lines drawn using a pen created by the CreatePen function.
SetBkMode does not affect lines drawn using a pen created by the ExtCreatePen function.
The $iBkMode parameter can also be set to driver-specific values. GDI passes such values to the device driver and otherwise ignores them.

Related

_WinAPI_CreatePen, _WinAPI_DrawText, _WinAPI_GetBkMode, _WinAPI_SelectObject

See Also

Search SetBkMode in MSDN Library.

Example

#include <FontConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global $g_tRECT, $g_hFont, $g_hOldFont, $g_hDC

HotKeySet("{ESC}", "_Exit")

$g_tRECT = DllStructCreate($tagRect)
DllStructSetData($g_tRECT, "Left", 5)
DllStructSetData($g_tRECT, "Top", 5)
DllStructSetData($g_tRECT, "Right", 250)
DllStructSetData($g_tRECT, "Bottom", 50)

$g_hDC = _WinAPI_GetDC(0)
$g_hFont = _WinAPI_CreateFont(50, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _
        $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')
$g_hOldFont = _WinAPI_SelectObject($g_hDC, $g_hFont)

_WinAPI_SetTextColor($g_hDC, 0x0000FF)
_WinAPI_SetBkColor($g_hDC, 0x000000)

MsgBox($MB_SYSTEMMODAL, "Information", "GetBkMode: " & _WinAPI_GetBkMode($g_hDC))

; comment next line to get black background instead of transparent one
_WinAPI_SetBkMode($g_hDC, $TRANSPARENT)

MsgBox($MB_SYSTEMMODAL, "Information", "GetBkMode: " & _WinAPI_GetBkMode($g_hDC))

While 1
    _WinAPI_DrawText($g_hDC, "Hello world!", $g_tRECT, $DT_CENTER)
    Sleep(100)
WEnd

Func _Exit()
    _WinAPI_SelectObject($g_hDC, $g_hOldFont)
    _WinAPI_DeleteObject($g_hFont)
    _WinAPI_ReleaseDC(0, $g_hDC)
    _WinAPI_InvalidateRect(0, 0)
    $g_tRECT = 0
    Exit
EndFunc   ;==>_Exit


Function _WinAPI_SetCapture

Function Reference

_WinAPI_SetCapture

Sets the mouse capture to the specified window belonging to the current thread

#include <WinAPI.au3>
_WinAPI_SetCapture ( $hWnd )

Parameters

$hWnd Handle to the window in the current thread that is to capture the mouse

Return Value

Success: | handle to the window that had previously captured the mouse
Failure: | 0

See Also

Search SetCapture in MSDN Library.


Function _WinAPI_SetCursor

Function Reference

_WinAPI_SetCursor

Establishes the cursor shape

#include <WinAPI.au3>
_WinAPI_SetCursor ( $hCursor )

Parameters

$hCursor Identifies the cursor

Return Value

Success: | The handle of the previous cursor, if there was one.
Failure: | 0, if there was no previous cursor.

See Also

Search SetCursor in MSDN Library.


Function _WinAPI_SetDefaultPrinter

Function Reference

_WinAPI_SetDefaultPrinter

Sets the default printer for the current user on the local computer

#include <WinAPI.au3>
_WinAPI_SetDefaultPrinter ( $sPrinter )

Parameters

$sPrinter The default printer name. For a remote printer, the name format is \\server\printername. For a
local printer, the name format is printername. If this parameter is "", this function does nothing if there
is already a default printer. However, if there is no default printer, this function sets the default printer
to the first printer, if any, in an enumeration of printers installed on the local computer.

Return Value

Success: | True
Failure: | False

See Also

Search SetDefaultPrinter in MSDN Library.


Function _WinAPI_SetDIBits

Function Reference

_WinAPI_SetDIBits

Sets the pixels in a compatible bitmap using the color data found in a DIB

#include <WinAPI.au3>
_WinAPI_SetDIBits ( $hDC, $hBitmap, $iStartScan, $iScanLines, $pBits, $tBMI [, $iColorUse = 0] )

Parameters

$hDC | Handle to a device context
$hBitmap | Handle to the compatible bitmap (DDB) that is to be altered using the color data from the DIB
$iStartScan | Specifies the starting scan line for the device-independent color data in the array pointed to by the $pBits parameter.
$iScanLines | Specifies the number of scan lines found in the array containing device-independent color data
$pBits | Pointer to the DIB color data, stored as an array of bytes. The format of the bitmap values depends on the biBitCount member of the $tagBITMAPINFO structure pointed to by the $pBMI parameter.
$tBMI | A $tagBITMAPINFO structure or a pointer to it that contains information about the DIB
$iColorUse | [optional] Specifies whether the iColors member of the $tagBITMAPINFO structure was provided and, if so, whether iColors contains explicit red, green, blue (RGB) values or palette indexes. The $iColorUse parameter must be one of the following values: 0 - The color table is provided and contains literal RGB values 1 - The color table consists of an array of 16-bit indexes into the logical palette of $hDC

Return Value

Success: | True
Failure: | False

Remarks

The device context identified by the $hDC parameter is used only if the $iColorUse is set to 1, otherwise it is ignored.
The bitmap identified by the hBmp parameter must not be selected into a device context when this function is called.
The scan lines must be aligned on a DWORD except for RLE compressed bitmaps.
The origin for bottom up DIBs is the lower left corner of the bitmap; the origin for top down DIBs is the upper left corner of the bitmap.

Related

$tagBITMAPINFO

See Also

Search SetDIBits in MSDN Library.


Function _WinAPI_SetEndOfFile

Function Reference

_WinAPI_SetEndOfFile

Sets the physical file size for the specified file to the current position of the file pointer

#include <WinAPI.au3>
_WinAPI_SetEndOfFile ( $hFile )

Parameters

$hFile Handle to the file to be extended or truncated.
The file handle must have the $GENERIC_WRITE access right.

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

This function can be used to truncate or extend a file.
If the file is extended, the contents of the file between the old end of the file and the new end of the file are not defined.
This function sets the file size.

Related

_WinAPI_CloseHandle, _WinAPI_CreateFile, _WinAPI_FlushFileBuffers, _WinAPI_GetFileSizeEx, _WinAPI_ReadFile, _WinAPI_SetFilePointer, _WinAPI_WriteFile

See Also

Search SetEndOfFile in MSDN Library.

Example

#include <WinAPI.au3>

Local $sTempFile, $hFile, $sText, $nBytes, $tBuffer, $iSize

; 1) create file and write data to it
$sTempFile = @TempDir & '\test.txt'
$sText = 'abcdefghijklmnopqrstuvwxyz'
$tBuffer = DllStructCreate("byte[" & StringLen($sText) & "]")
DllStructSetData($tBuffer, 1, $sText)
$hFile = _WinAPI_CreateFile($sTempFile, 1)
_WinAPI_WriteFile($hFile, $tBuffer, StringLen($sText), $nBytes)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_CloseHandle($hFile)
ConsoleWrite('1):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

; 2) read 6 bytes from position 3
$tBuffer = DllStructCreate("byte[6]")
$hFile = _WinAPI_CreateFile($sTempFile, 2, 2)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_SetFilePointer($hFile, 3)
_WinAPI_ReadFile($hFile, $tBuffer, 6, $nBytes)
_WinAPI_CloseHandle($hFile)
$sText = BinaryToString(DllStructGetData($tBuffer, 1))
ConsoleWrite('2):' & $iSize & ' ' & $sText & @CRLF)

; 3) write previously read 6 bytes from position 3 to the same position but in UpperCase
DllStructSetData($tBuffer, 1, StringUpper($sText))
$hFile = _WinAPI_CreateFile($sTempFile, 2, 4)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_SetFilePointer($hFile, 3)
_WinAPI_WriteFile($hFile, $tBuffer, 6, $nBytes)
_WinAPI_CloseHandle($hFile)
$tBuffer = 0
ConsoleWrite('3):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

; 4) truncate file size to 12 bytes
$hFile = _WinAPI_CreateFile($sTempFile, 2, 4)
_WinAPI_SetFilePointer($hFile, 12)
_WinAPI_SetEndOfFile($hFile)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_CloseHandle($hFile)
ConsoleWrite('4):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

FileDelete($sTempFile)


Function _WinAPI_SetEvent

Function Reference

_WinAPI_SetEvent

Sets the specified event object to the signaled state

#include <WinAPI.au3>
_WinAPI_SetEvent ( $hEvent )

Parameters

$hEvent Handle to the event object

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

The state of a manual-reset event object remains signaled until it is set explicitly to the nonsignaled state
by the ResetEvent function. Any number of waiting threads, or threads that subsequently begin wait operations
for the specified event object by calling one of the wait functions, can be released when the object's state
is signaled.

See Also

Search SetEvent in MSDN Library.

Example

#include <WinAPI.au3>
#include <WinAPIProc.au3> ;needed for _WinAPI_ResetEvent()

Global $g_tEvents = DllStructCreate("handle Event[3];")
$g_tEvents.Event(1) = _WinAPI_CreateEvent(0, True, False)
$g_tEvents.Event(2) = _WinAPI_CreateEvent(0, True, False)
$g_tEvents.Event(3) = _WinAPI_CreateEvent(0, True, False)

HotKeySet("{ESC}", "_Exit")
AdlibRegister("_FireEvent_1", 500)
AdlibRegister("_FireEvent_2", 800)

Local $iEvent
While 1
    $iEvent = _WinAPI_WaitForMultipleObjects(3, $g_tEvents, False, 100)
    Switch $iEvent
        Case 0
            ConsoleWrite("+ First Event" & @CRLF)
            _WinAPI_ResetEvent($g_tEvents.Event(1))
        Case 1
            ConsoleWrite("> Second Event" & @CRLF)
            _WinAPI_ResetEvent($g_tEvents.Event(2))
        Case 2
            ConsoleWrite("! Exit Event" & @CRLF)
            AdlibUnRegister("_FireEvent_1")
            AdlibUnRegister("_FireEvent_2")
            _WinAPI_CloseHandle($g_tEvents.Event(1))
            _WinAPI_CloseHandle($g_tEvents.Event(2))
            _WinAPI_CloseHandle($g_tEvents.Event(3))
            ExitLoop
        Case -1 ;Error
            ExitLoop
    EndSwitch
WEnd

Func _Exit()
    _WinAPI_SetEvent($g_tEvents.Event(3))
EndFunc   ;==>_Exit

Func _FireEvent_1()
    _WinAPI_SetEvent($g_tEvents.Event(1))
EndFunc   ;==>_FireEvent_1

Func _FireEvent_2()
    _WinAPI_SetEvent($g_tEvents.Event(2))
EndFunc   ;==>_FireEvent_2


Function _WinAPI_SetFilePointer

Function Reference

_WinAPI_SetFilePointer

Moves the file pointer of the specified file

#include <WinAPI.au3>
_WinAPI_SetFilePointer ( $hFile, $iPos [, $iMethod = 0] )

Parameters

$hFile | Handle to the file to be processed
$iPos | Number of bytes to move the file pointer. Maximum value is 2^32 A positive value moves the file pointer forward in the file, and a negative value moves the file pointer back.
$iMethod | [optional] The starting point for the file pointer move. Can be one of the predefined values: $FILE_BEGIN (0) = (default) The starting point is zero (0) or the beginning of the file $FILE_CURRENT (1) = The starting point is the current value of the file pointer. $FILE_END (2) = The starting point is the current end-of-file position.

Return Value

Success: | New file pointer.
Failure: | (-1) INVALID_SET_FILE_POINTER, call _WinAPI_GetLastError() to get extended error information

Remarks

This function can also be used to query the current file pointer position by specifying a move method of FILE_CURRENT and a distance of zero.
This function stores the file pointer in LONG value. To work with file pointers that are larger than a single LONG value, it must be used the SetFilePointerEx function.
File pointer is the position in the file to read/write to/from by _WinAPI_ReadFile()/_WinAPI_WriteFile()

Related

_WinAPI_CloseHandle, _WinAPI_CreateFile, _WinAPI_FlushFileBuffers, _WinAPI_GetFileSizeEx, _WinAPI_ReadFile, _WinAPI_SetEndOfFile, _WinAPI_WriteFile

See Also

Search SetFilePointer in MSDN Library.

Example

#include <WinAPI.au3>

Local $sTempFile, $hFile, $sText, $nBytes, $tBuffer, $iSize

; 1) create file and write data to it
$sTempFile = @TempDir & '\test.txt'
$sText = 'abcdefghijklmnopqrstuvwxyz'
$tBuffer = DllStructCreate("byte[" & StringLen($sText) & "]")
DllStructSetData($tBuffer, 1, $sText)
$hFile = _WinAPI_CreateFile($sTempFile, 1)
_WinAPI_WriteFile($hFile, $tBuffer, StringLen($sText), $nBytes)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_CloseHandle($hFile)
ConsoleWrite('1):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

; 2) read 6 bytes from position 3
$tBuffer = DllStructCreate("byte[6]")
$hFile = _WinAPI_CreateFile($sTempFile, 2, 2)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_SetFilePointer($hFile, 3)
_WinAPI_ReadFile($hFile, $tBuffer, 6, $nBytes)
_WinAPI_CloseHandle($hFile)
$sText = BinaryToString(DllStructGetData($tBuffer, 1))
ConsoleWrite('2):' & $iSize & ' ' & $sText & @CRLF)

; 3) write previously read 6 bytes from position 3 to the same position but in UpperCase
DllStructSetData($tBuffer, 1, StringUpper($sText))
$hFile = _WinAPI_CreateFile($sTempFile, 2, 4)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_SetFilePointer($hFile, 3)
_WinAPI_WriteFile($hFile, $tBuffer, 6, $nBytes)
_WinAPI_CloseHandle($hFile)
$tBuffer = 0
ConsoleWrite('3):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

; 4) truncate file size to 12 bytes
$hFile = _WinAPI_CreateFile($sTempFile, 2, 4)
_WinAPI_SetFilePointer($hFile, 12)
_WinAPI_SetEndOfFile($hFile)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_CloseHandle($hFile)
ConsoleWrite('4):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

FileDelete($sTempFile)


Function _WinAPI_SetFocus

Function Reference

_WinAPI_SetFocus

Sets the keyboard focus to the specified window

#include <WinAPI.au3>
_WinAPI_SetFocus ( $hWnd )

Parameters

$hWnd Identifies the window that will receive the keyboard input. If this parameter is 0, keystrokes
are ignored.

Return Value

Success: | The handle of the window that had the keyboard focus
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

See Also

Search SetFocus in MSDN Library.


Function _WinAPI_SetFont

Function Reference

_WinAPI_SetFont

Sets a window font

#include <WinAPI.au3>
_WinAPI_SetFont ( $hWnd, $hFont [, $bRedraw = True] )

Parameters

$hWnd | Window handle
$hFont | Font handle
$bRedraw | [optional] True to redraw the control

Return Value

None.


Function _WinAPI_SetHandleInformation

Function Reference

_WinAPI_SetHandleInformation

Sets certain properties of an object handle

#include <WinAPI.au3>
_WinAPI_SetHandleInformation ( $hObject, $iMask, $iFlags )

Parameters

$hObject | Handle to an object
$iMask | Specifies the bit flags to be changed
$iFlags | Specifies properties of the object handle

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

See Also

Search SetHandleInformation in MSDN Library.


Function _WinAPI_SetLastError

Function Reference

_WinAPI_SetLastError

Sets the last-error code for the calling thread

#include <WinAPI.au3>
_WinAPI_SetLastError ( $iErrorCode )

Parameters

$iErrorCode The last error code for the thread

Return Value

None.

Remarks

The last error code is kept in thread local storage so that multiple threads do not overwrite each other's
values.

See Also

Search SetLastError in MSDN Library.


Function _WinAPI_SetLayeredWindowAttributes

Function Reference

_WinAPI_SetLayeredWindowAttributes

Sets Layered Window Attributes

#include <WinAPI.au3>
_WinAPI_SetLayeredWindowAttributes ( $hWnd, $iTransColor [, $iTransGUI = 255 [, $iFlags = 0x03 [, $bColorRef = False]]] )

Parameters

$hWnd | Handle of GUI to work on
$iTransColor | Transparent color
$iTransGUI | [optional] Set Transparancy of GUI
$iFlags | [optional] Flags.
$bColorRef | [optional] If True, $iTransColor is a COLORREF( 0x00bbggrr ), else an RGB-Color

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Related

_WinAPI_GetLastError, _WinAPI_GetLayeredWindowAttributes

See Also

Search SetLayeredWindowAttributes in MSDN Library.

Example

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

Local $hGui = GUICreate("trans", 300, 400, -1, -1, -1, $WS_EX_LAYERED)
GUICtrlCreateLabel("This is text on a transparent Layered GUI", 10, 10, 200, 20, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetTip(-1, "Click label to drag layered window")
Local $idLayButt = GUICtrlCreateButton("Button", 10, 40, 40)
GUISetBkColor(0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($hGui, 0x010101)
GUISetState(@SW_SHOW)

Local $hGuicontrol = GUICreate("ControlGUI", 300, 400, 100, 100)
Local $idCheckTrans = GUICtrlCreateCheckbox("Transparent color 0xABCDEF (Checked) Or 0x010101", 10, 10)
Local $idCheckBorder = GUICtrlCreateCheckbox("POPUP-Style", 10, 30)
GUICtrlCreateLabel("Transparency for Layered GUI", 10, 50)
Local $idSlTrans = GUICtrlCreateSlider(10, 70, 200, 30)
GUICtrlSetLimit($idSlTrans, 255, 0)
GUICtrlSetData(-1, 255)
GUISetState(@SW_SHOW)

While 1
    Local $aExtMsg = GUIGetMsg(1)
    Local $iMsg = $aExtMsg[0]
    Switch $aExtMsg[1]
        Case $hGuicontrol
            Select
                Case $iMsg = $GUI_EVENT_CLOSE
                    Exit
                Case $iMsg = $idCheckTrans Or $iMsg = $idSlTrans

                    ; Change Attributes of Trans-Color and Window Transparency

                    If BitAND(GUICtrlRead($idCheckTrans), $GUI_CHECKED) = $GUI_CHECKED Then
                        _WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF, GUICtrlRead($idSlTrans))
                    Else
                        _WinAPI_SetLayeredWindowAttributes($hGui, 0x010101, GUICtrlRead($idSlTrans))
                    EndIf

                Case $iMsg = $idCheckBorder
                    If BitAND(GUICtrlRead($idCheckBorder), $GUI_CHECKED) = $GUI_CHECKED Then
                        GUISetStyle($WS_POPUP, -1, $hGui)
                    Else
                        GUISetStyle($GUI_SS_DEFAULT_GUI, -1, $hGui)
                    EndIf
            EndSelect
        Case $hGui
            Select
                Case $iMsg = $idLayButt
                    Local $iTransColor, $iAlpha
                    Local $iInfo = _WinAPI_GetLayeredWindowAttributes($hGui, $iTransColor, $iAlpha)
                    MsgBox($MB_SYSTEMMODAL, 'Layered GUI', "Button on layered Window Clicked" & @CRLF & "Information about this window: " & @CRLF & _
                            "Transparent Color: " & $iTransColor & @CRLF & _
                            "Alpha Value: " & $iAlpha & @CRLF & _
                            "LWA_COLORKEY: " & (BitAND($iInfo, $LWA_COLORKEY) = $LWA_COLORKEY) & @CRLF & _
                            "LWA_ALPHA: " & (BitAND($iInfo, $LWA_ALPHA) = $LWA_ALPHA))
                Case $iMsg = $GUI_EVENT_CLOSE
                    Exit MsgBox($MB_SYSTEMMODAL, '', "Close from Layered GUI")
            EndSelect
    EndSwitch
WEnd


Function _WinAPI_SetParent

Function Reference

_WinAPI_SetParent

Changes the parent window of the specified child window

#include <WinAPI.au3>
_WinAPI_SetParent ( $hWndChild, $hWndParent )

Parameters

$hWndChild | Window handle of child window
$hWndParent | Handle to the new parent window. If 0, the desktop window becomes the new parent window.

Return Value

Success: | A handle to the previous parent window
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

Remarks

An application can use the SetParent function to set the parent window of a pop-up, overlapped, or child
window. The new parent window and the child window must belong to the same application.

See Also

Search SetParent in MSDN Library.

Example

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

Local $hParent = WinGetHandle('[CLASS:Progman;TITLE:Program Manager]')

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400, 100, 100, -1, $WS_EX_TOOLWINDOW)

; Attach window to the desktop (always on bottom)
_WinAPI_SetParent($hForm, $hParent)

GUISetState(@SW_SHOWNOACTIVATE)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_SetProcessAffinityMask

Function Reference

_WinAPI_SetProcessAffinityMask

Sets a processor affinity mask for the threads of a specified process

#include <WinAPI.au3>
_WinAPI_SetProcessAffinityMask ( $hProcess, $iMask )

Parameters

$hProcess | A handle to the process whose affinity mask the function sets
$iMask | Affinity mask

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

An affinity mask is a bit mask in which each bit represents a processor on which the threads of the process
are allowed to run. For example, if you pass a mask of 0x05, processors 1 and 3 are allowed to run.

See Also

Search SetProcessAffinityMask in MSDN Library.


Function _WinAPI_SetSysColors

Function Reference

_WinAPI_SetSysColors

Obtains information about the display devices in a system

#include <WinAPI.au3>
_WinAPI_SetSysColors ( $vElements, $vColors )

Parameters

$vElements | Single element or Array of elements
$vColors | Single Color or Array of colors

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

See _WinAPI_GetSysColor() for list of Element indexes and requirements.

Related

_WinAPI_GetSysColor

See Also

Search SetSysColors in MSDN Library.

Example

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

Example()

Func Example()
    Local $aElements[2] = [$COLOR_ACTIVECAPTION, $COLOR_GRADIENTACTIVECAPTION]
    ; Red and Yellow
    Local $aColors[2] = [255, 65535], $aSaveColors[2]

    GUICreate("My GUI", 300, 200)

    $aSaveColors[0] = _WinAPI_GetSysColor($COLOR_ACTIVECAPTION)
    $aSaveColors[1] = _WinAPI_GetSysColor($COLOR_GRADIENTACTIVECAPTION)

    _WinAPI_SetSysColors($aElements, $aColors)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    GUIDelete()

    _WinAPI_SetSysColors($aElements, $aSaveColors)

    Exit
EndFunc   ;==>Example


Function _WinAPI_SetTextColor

Function Reference

_WinAPI_SetTextColor

Sets the current text color to the specified color value

#include <WinAPI.au3>
_WinAPI_SetTextColor ( $hDC, $iColor )

Parameters

$hDC | Handle to the device context
$iColor | Specifies the new text color

Return Value

Success: | The previous text color
Failure: | -1

See Also

Search SetTextColor in MSDN Library.

Example

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

Global $g_tRECT, $g_hFont, $g_hOldFont, $g_hDC

HotKeySet("{ESC}", "_Exit")

$g_tRECT = DllStructCreate($tagRect)
DllStructSetData($g_tRECT, "Left", 5)
DllStructSetData($g_tRECT, "Top", 5)
DllStructSetData($g_tRECT, "Right", 250)
DllStructSetData($g_tRECT, "Bottom", 50)

$g_hDC = _WinAPI_GetDC(0)
$g_hFont = _WinAPI_CreateFont(50, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _
        $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')
$g_hOldFont = _WinAPI_SelectObject($g_hDC, $g_hFont)

_WinAPI_SetTextColor($g_hDC, 0x0000FF)
_WinAPI_SetBkColor($g_hDC, 0x000000)
; comment next line to get black background instead of transparent one
_WinAPI_SetBkMode($g_hDC, $TRANSPARENT)

While 1
    _WinAPI_DrawText($g_hDC, "Hello world!", $g_tRECT, $DT_CENTER)
    Sleep(100)
WEnd

Func _Exit()
    _WinAPI_SelectObject($g_hDC, $g_hOldFont)
    _WinAPI_DeleteObject($g_hFont)
    _WinAPI_ReleaseDC(0, $g_hDC)
    _WinAPI_InvalidateRect(0, 0)
    $g_tRECT = 0
    Exit
EndFunc   ;==>_Exit


Function _WinAPI_SetWindowLong

Function Reference

_WinAPI_SetWindowLong

Sets information about the specified window

#include <WinAPI.au3>
_WinAPI_SetWindowLong ( $hWnd, $iIndex, $iValue )

Parameters

$hWnd | Handle of the window
$iIndex | Specifies the 0-based offset to the value to be set. Valid values are in the range zero through the number of bytes of extra window memory, minus four; for example, if you specified 12 or more bytes of extra memory, a value of 8 would be an index to the third 32-bit integer. To retrieve any other value specify one of the following values: $GWL_EXSTYLE - Sets the extended window styles $GWL_STYLE - Sets the window styles $GWL_WNDPROC - Sets the address of the window procedure $GWL_HINSTANCE - Sets the handle of the application instance $GWL_HWNDPARENT - Sets the handle of the parent window, if any $GWL_ID - Sets the identifier of the window $GWL_USERDATA - Sets the 32-bit value associated with the window
$iValue | Specifies the replacement value

Return Value

Success: | the previous value.
Failure: | 0.

Remarks

Above constants require #include <WinAPIConstants.au3>

Related

_WinAPI_CallWindowProc, _WinAPI_GetWindowLong

See Also

Search SetWindowLongPtr in MSDN Library.


Function _WinAPI_SetWindowPlacement

Function Reference

_WinAPI_SetWindowPlacement

Sets the placement of the window for Min, Max, and normal positions

#include <WinAPI.au3>
_WinAPI_SetWindowPlacement ( $hWnd, $tWindowPlacement )

Parameters

$hWnd | Handle of the window
$tWindowPlacement | A $tagWINDOWPLACEMENT structure or a pointer to it

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Related

$tagWINDOWPLACEMENT, _WinAPI_GetWindowPlacement

See Also

Search SetWindowPlacement in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

Local $hWnd, $iRET, $sMsg, $tRET

; Create an instance of notepad to play with
Run("notepad.exe")
$hWnd = WinWait("[CLASS:Notepad]")
WinMove($hWnd, "", 256, 256, 400, 400)
Sleep(1000)

; Minimize and then check the placement values returned by _WinAPI_GetWindowPlacement()
WinSetState($hWnd, "", @SW_MINIMIZE)
$tRET = _WinAPI_GetWindowPlacement($hWnd)
If @error = 0 Then
    $sMsg = "$stWindowPlacement:" & @CRLF & @CRLF
    $sMsg &= @TAB & "length = " & DllStructGetData($tRET, "length") & @CRLF
    $sMsg &= @TAB & "flags = " & DllStructGetData($tRET, "flags") & @CRLF
    $sMsg &= @TAB & "showCmd = " & DllStructGetData($tRET, "showCmd") & @CRLF & @CRLF
    $sMsg &= "ptMinPosition:" & @CRLF
    $sMsg &= @TAB & "MinX = " & DllStructGetData($tRET, "ptMinPosition", 1) & @CRLF
    $sMsg &= @TAB & "MinY = " & DllStructGetData($tRET, "ptMinPosition", 2) & @CRLF & @CRLF
    $sMsg &= "ptMaxPosition:" & @CRLF
    $sMsg &= @TAB & "MaxX = " & DllStructGetData($tRET, "ptMaxPosition", 1) & @CRLF
    $sMsg &= @TAB & "MaxY = " & DllStructGetData($tRET, "ptMaxPosition", 2) & @CRLF & @CRLF
    $sMsg &= "rcNormalPosition:" & @CRLF
    $sMsg &= @TAB & "left = " & DllStructGetData($tRET, "rcNormalPosition", 1) & @CRLF
    $sMsg &= @TAB & "top = " & DllStructGetData($tRET, "rcNormalPosition", 2) & @CRLF
    $sMsg &= @TAB & "right = " & DllStructGetData($tRET, "rcNormalPosition", 3) & @CRLF
    $sMsg &= @TAB & "bottom = " & DllStructGetData($tRET, "rcNormalPosition", 4)
    MsgBox($MB_SYSTEMMODAL, "Success", $sMsg)

    ; Change the normalized rectangle with _WinAPI_SetWindowPlacement() and then restore
    DllStructSetData($tRET, "rcNormalPosition", 128, 1); left
    DllStructSetData($tRET, "rcNormalPosition", 128, 2); top
    DllStructSetData($tRET, "rcNormalPosition", @DesktopWidth - 128, 3); right
    DllStructSetData($tRET, "rcNormalPosition", @DesktopHeight - 128, 4); bottom
    $iRET = _WinAPI_SetWindowPlacement($hWnd, $tRET)
    If @error = 0 Then
        WinSetState($hWnd, "", @SW_RESTORE)
        ControlSetText($hWnd, "", "Edit1", "_WinAPI_SetWindowPlacement() succeeded!")
    Else
        MsgBox($MB_SYSTEMMODAL, "Error", "_WinAPI_SetWindowPlacement() failed!" & @CRLF & _
                "$iRET = " & $iRET & @CRLF & _
                "@error = " & @error & @CRLF & _
                "@extended = " & @extended)
    EndIf
Else
    MsgBox($MB_SYSTEMMODAL, "Error", "_WinAPI_GetWindowPlacement() failed!" & @CRLF & _
            "$tRET = " & $tRET & @CRLF & _
            "@error = " & @error & @CRLF & _
            "@extended = " & @extended)
EndIf


Function _WinAPI_SetWindowPos

Function Reference

_WinAPI_SetWindowPos

Changes the size, position, and Z order of a child, pop-up, or top-level window

#include <WinAPI.au3>
_WinAPI_SetWindowPos ( $hWnd, $hAfter, $iX, $iY, $iCX, $iCY, $iFlags )

Parameters

$hWnd | Handle of window
$hAfter | Identifies the window to precede the positioned window in the Z order. This parameter must be a window handle or one of the following values: $HWND_BOTTOM - Places the window at the bottom of the Z order $HWND_NOTOPMOST - Places the window above all non-topmost windows $HWND_TOP - Places the window at the top of the Z order $HWND_TOPMOST - Places the window above all non-topmost windows
$iX | Specifies the new position of the left side of the window
$iY | Specifies the new position of the top of the window
$iCX | Specifies the new width of the window, in pixels
$iCY | Specifies the new height of the window, in pixels
$iFlags | Specifies the window sizing and positioning flags: $SWP_DRAWFRAME - Draws a frame around the window $SWP_FRAMECHANGED - Sends a $WM_NCCALCSIZE message to the window, even if the window's size is not changed $SWP_HIDEWINDOW - Hides the window $SWP_NOACTIVATE - Does not activate the window $SWP_NOCOPYBITS - Discards the entire contents of the client area $SWP_NOMOVE - Retains the current position $SWP_NOOWNERZORDER - Does not change the owner window's position in the Z order $SWP_NOREDRAW - Does not redraw changes $SWP_NOREPOSITION - Same as the $SWP_NOOWNERZORDER flag $SWP_NOSENDCHANGING - Prevents the window from receiving $WM_WINDOWPOSCHANGING $SWP_NOSIZE - Retains the current size $SWP_NOZORDER - Retains the current Z order $SWP_SHOWWINDOW - Displays the window

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

Above constants require #include <AutoItConstants.au3>

See Also

Search SetWindowPos in MSDN Library.

Example

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

Example()

Func Example()
    ; Assign a Local variable the handle of the NotePad window
    Local $hWnd = WinGetHandle("[CLASS:Notepad]")

    ; If the window does not exists, display a message and return False.
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "Notepad window not found.")
        Return False
    EndIf

    ; Assign a Local variable the style of the Notepad window.
    Local $iStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)

    ; Remove from the window style the MAXIMIZEBOX, MINIMIZEBOX and SIZEBOX styles.
    $iStyle = BitXOR($iStyle, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX)

    ; Set the style of the window.
    _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $iStyle)

    ; Apply the style
    _WinAPI_SetWindowPos($hWnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE))
EndFunc   ;==>Example


Function _WinAPI_SetWindowRgn

Function Reference

_WinAPI_SetWindowRgn

Sets the window region of a window

#include <WinAPI.au3>
_WinAPI_SetWindowRgn ( $hWnd, $hRgn [, $bRedraw = True] )

Parameters

$hWnd | Handle to the window whose window region is to be set.
$hRgn | Handle to a region. The function sets the window region of the window to this region.
$bRedraw | [optional] Specifies whether the system redraws the window after setting the window region.

Return Value

Success: | True
Failure: | False

Remarks

The window region determines the area within the window where the system permits drawing.
The system does not display any portion of a window that lies outside of the window region
When this function is called, the system sends the WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED messages to the window.
The coordinates of a window's window region are relative to the upper-left corner of the window, not the client area of the window.
After a successful call to SetWindowRgn, the system owns the region specified by the region handle $hRgn.
The system does not make a copy of the region. Thus, you should not make any further function calls with this region handle.
In particular, do not delete this region handle. The system deletes the region handle when it no longer needed.

Related

_WinAPI_CombineRgn, _WinAPI_CreateRectRgn, _WinAPI_CreateRoundRectRgn, _WinAPI_GetWindowRgn

See Also

Search SetWindowRgn in MSDN Library.

Example

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

; get height of window title and width of window frame - may be different when XP theme is ON/OFF
Global $g_iHtit = _WinAPI_GetSystemMetrics($SM_CYCAPTION)
Global $g_iFrame = _WinAPI_GetSystemMetrics($SM_CXDLGFRAME)

Global $g_hGui = GUICreate("Test Windows regions", 350, 210)
Local $id_Default = GUICtrlCreateButton("Default region", 100, 30, 150)
Local $id_Round = GUICtrlCreateButton("Round region", 100, 60, 150)
Local $id_Buble = GUICtrlCreateButton("Buble region ", 100, 90, 150)
Local $id_Transparent = GUICtrlCreateButton("Transparent region", 100, 120, 150)
Local $id_Exit = GUICtrlCreateButton("Exit", 100, 150, 150)
GUISetState(@SW_SHOW)

Local $aPos = WinGetPos($g_hGui) ; get whole window size (no client size defined in GUICreate)
Global $g_iWidth = $aPos[2]
Global $g_iHeight = $aPos[3]

Local $iMsg, $hRgn
While 1
    $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE Or $iMsg = $id_Exit
            ExitLoop

        Case $iMsg = $id_Default
            $hRgn = _WinAPI_CreateRectRgn(0, 0, $g_iWidth, $g_iHeight)
            _WinAPI_SetWindowRgn($g_hGui, $hRgn)

        Case $iMsg = $id_Round
            $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $g_iWidth, $g_iHeight, $g_iWidth / 3, $g_iHeight / 3)
            _WinAPI_SetWindowRgn($g_hGui, $hRgn)

        Case $iMsg = $id_Buble
            Local $hRgn1 = _WinAPI_CreateRoundRectRgn(0, 0, $g_iWidth / 2, $g_iHeight / 2, $g_iWidth / 2, $g_iHeight / 2) ; left-top
            Local $hRgn2 = _WinAPI_CreateRoundRectRgn($g_iWidth / 2, 0, $g_iWidth, $g_iHeight / 2, $g_iWidth / 2, $g_iHeight / 2) ; right-top
            _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR)
            _WinAPI_DeleteObject($hRgn2)
            $hRgn2 = _WinAPI_CreateRoundRectRgn(0, $g_iHeight / 2, $g_iWidth / 2, $g_iHeight, $g_iWidth / 2, $g_iHeight / 2) ; left-bottom
            _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR)
            _WinAPI_DeleteObject($hRgn2)
            $hRgn2 = _WinAPI_CreateRoundRectRgn($g_iWidth / 2, $g_iHeight / 2, $g_iWidth, $g_iHeight, $g_iWidth / 2, $g_iHeight / 2) ; right-bottom
            _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR)
            _WinAPI_DeleteObject($hRgn2)
            $hRgn2 = _WinAPI_CreateRoundRectRgn(10, 10, $g_iWidth - 10, $g_iHeight - 10, $g_iWidth, $g_iHeight) ; middle
            _WinAPI_CombineRgn($hRgn1, $hRgn1, $hRgn2, $RGN_OR)
            _WinAPI_DeleteObject($hRgn2)
            _WinAPI_SetWindowRgn($g_hGui, $hRgn1)

        Case $iMsg = $id_Transparent
            _GuiHole($g_hGui, 40, 40, 260, 170)

    EndSelect
WEnd

; make inner transparent area but add controls
Func _GuiHole($hWin, $iX, $iY, $iSizeW, $iSizeH)
    Local $hOuter_rgn, $hInner_rgn, $hCombined_rgn

    $hOuter_rgn = _WinAPI_CreateRectRgn(0, 0, $g_iWidth, $g_iHeight)
    $hInner_rgn = _WinAPI_CreateRectRgn($iX, $iY, $iX + $iSizeW, $iY + $iSizeH)
    $hCombined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0)
    _WinAPI_CombineRgn($hCombined_rgn, $hOuter_rgn, $hInner_rgn, $RGN_DIFF)
    _WinAPI_DeleteObject($hOuter_rgn)
    _WinAPI_DeleteObject($hInner_rgn)
    _AddCtrlRegion($hCombined_rgn, $id_Default)
    _AddCtrlRegion($hCombined_rgn, $id_Round)
    _AddCtrlRegion($hCombined_rgn, $id_Buble)
    _AddCtrlRegion($hCombined_rgn, $id_Transparent)
    _AddCtrlRegion($hCombined_rgn, $id_Exit)
    _WinAPI_SetWindowRgn($hWin, $hCombined_rgn)
EndFunc   ;==>_GuiHole

; add control's area to given region
; respecting also window title/frame sizes
Func _AddCtrlRegion($hFull_rgn, $idCtrl)
    Local $aCtrl_pos, $hCtrl_rgn

    $aCtrl_pos = ControlGetPos($g_hGui, "", $idCtrl)
    $hCtrl_rgn = _WinAPI_CreateRectRgn($aCtrl_pos[0] + $g_iFrame, $aCtrl_pos[1] + $g_iHtit + $g_iFrame, _
            $aCtrl_pos[0] + $aCtrl_pos[2] + $g_iFrame, $aCtrl_pos[1] + $aCtrl_pos[3] + $g_iHtit + $g_iFrame)
    _WinAPI_CombineRgn($hFull_rgn, $hFull_rgn, $hCtrl_rgn, $RGN_OR)
    _WinAPI_DeleteObject($hCtrl_rgn)
EndFunc   ;==>_AddCtrlRegion


Function _WinAPI_SetWindowsHookEx

Function Reference

_WinAPI_SetWindowsHookEx

Installs an application-defined hook procedure into a hook chain

#include <WinAPI.au3>
_WinAPI_SetWindowsHookEx ( $iHook, $pProc, $hDll [, $iThreadId = 0] )

Parameters

$iHook Specifies the type of hook procedure to be installed. This parameter can be one of the following values:
$WH_CALLWNDPROC - Installs a hook procedure that monitors messages before the system sends them to the destination window procedure
$WH_CALLWNDPROCRET - Installs a hook procedure that monitors messages after they have been processed by the destination window procedure
$WH_CBT - Installs a hook procedure that receives notifications useful to a computer-based training (CBT) application
$WH_DEBUG - Installs a hook procedure useful for debugging other hook procedures
$WH_FOREGROUNDIDLE - Installs a hook procedure that will be called when the application's foreground thread is about to become idle
$WH_GETMESSAGE - Installs a hook procedure that monitors messages posted to a message queue
$WH_JOURNALPLAYBACK - Installs a hook procedure that posts messages previously recorded by a $WH_JOURNALRECORD hook procedure
$WH_JOURNALRECORD - Installs a hook procedure that records input messages posted to the system message queue
$WH_KEYBOARD - Installs a hook procedure that monitors keystroke messages
$WH_KEYBOARD_LL - Installs a hook procedure that monitors low-level keyboard input events
$WH_MOUSE - Installs a hook procedure that monitors mouse messages
$WH_MOUSE_LL - Installs a hook procedure that monitors low-level mouse input events
$WH_MSGFILTER - Installs a hook procedure that monitors messages generated as a result of an input event in a dialog box, message box, menu, or scroll bar
$WH_SHELL - Installs a hook procedure that receives notifications useful to shell applications
$WH_SYSMSGFILTER - Installs a hook procedure that monitors messages generated as a result of an input event in a dialog box, message box, menu, or scroll bar
$pProc Pointer to the hook procedure. If the $iThreadId parameter is zero or specifies the identifier of a thread created by a different process,
the $pProc parameter must point to a hook procedure in a DLL.
Otherwise, $pProc can point to a hook procedure in the code associated with the current process
$hDll Handle to the DLL containing the hook procedure pointed to by the $pProc parameter.
The $hMod parameter must be set to NULL if the $iThreadId parameter specifies a thread created by the current process and if the hook procedure is within the code associated with the current process
$iThreadId [optional] Specifies the identifier of the thread with which the hook procedure is to be associated.
If this parameter is zero, the hook procedure is associated with all existing threads running in the same desktop as the calling thread

Return Value

Success: | Handle to the hook procedure
Failure: | 0, call _WinAPI_GetLastError() to get extended error informationt

Related

_WinAPI_CallNextHookEx, _WinAPI_UnhookWindowsHookEx

See Also

Search SetWindowsHookEx in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global $g_hHook, $g_hStub_KeyProc, $g_sBuffer = ""

Example()

Func Example()
    OnAutoItExitRegister("Cleanup")

    Local $hMod

    $g_hStub_KeyProc = DllCallbackRegister("_KeyProc", "long", "int;wparam;lparam")
    $hMod = _WinAPI_GetModuleHandle(0)
    $g_hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($g_hStub_KeyProc), $hMod)

    MsgBox($MB_SYSTEMMODAL, "", "Click OK, then in notepad type..." & _
            @CRLF & @CRLF & "Jon" & @CRLF & "AutoIt" & @CRLF & @CRLF & "Press Esc to exit script")

    Run("notepad.exe")
    WinWait("[CLASS:Notepad]")
    WinActivate("[CLASS:Notepad]")

    While 1
        Sleep(10)
    WEnd
EndFunc   ;==>Example

Func EvaluateKey($iKeycode)
    If (($iKeycode > 64) And ($iKeycode < 91)) _ ; a - z
            Or (($iKeycode > 96) And ($iKeycode < 123)) _ ; A - Z
            Or (($iKeycode > 47) And ($iKeycode < 58)) Then ; 0 - 9
        $g_sBuffer &= Chr($iKeycode)
        Switch $g_sBuffer
            Case "Jon"
                ToolTip("What can you say?")
            Case "AutoIt"
                ToolTip("AutoIt Rocks")
        EndSwitch
    ElseIf ($iKeycode > 159) And ($iKeycode < 164) Then
        Return
    ElseIf ($iKeycode = 27) Then ; esc key
        Exit
    Else
        $g_sBuffer = ""
    EndIf
EndFunc   ;==>EvaluateKey

; ===========================================================
; callback function
; ===========================================================
Func _KeyProc($nCode, $wParam, $lParam)
    Local $tKEYHOOKS
    $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam)
    If $nCode < 0 Then
        Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam)
    EndIf
    If $wParam = $WM_KEYDOWN Then
        EvaluateKey(DllStructGetData($tKEYHOOKS, "vkCode"))
    Else
        Local $iFlags = DllStructGetData($tKEYHOOKS, "flags")
        Switch $iFlags
            Case $LLKHF_ALTDOWN
                ConsoleWrite("$LLKHF_ALTDOWN" & @CRLF)
            Case $LLKHF_EXTENDED
                ConsoleWrite("$LLKHF_EXTENDED" & @CRLF)
            Case $LLKHF_INJECTED
                ConsoleWrite("$LLKHF_INJECTED" & @CRLF)
            Case $LLKHF_UP
                ConsoleWrite("$LLKHF_UP: scanCode - " & DllStructGetData($tKEYHOOKS, "scanCode") & @TAB & "vkCode - " & DllStructGetData($tKEYHOOKS, "vkCode") & @CRLF)
        EndSwitch
    EndIf
    Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam)
EndFunc   ;==>_KeyProc

Func Cleanup()
    _WinAPI_UnhookWindowsHookEx($g_hHook)
    DllCallbackFree($g_hStub_KeyProc)
EndFunc   ;==>Cleanup


Function _WinAPI_SetWindowText

Function Reference

_WinAPI_SetWindowText

Changes the text of the specified window's title bar

#include <WinAPI.au3>
_WinAPI_SetWindowText ( $hWnd, $sText )

Parameters

$hWnd | Handle to the window or control whose text is to be changed
$sText | String to be used as the new title or control text

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

If the target window is owned by the current process, SetWindowText causes a $WM_SETTEXT message to be sent to
the specified window or control. If the control is a list box control created with the $WS_CAPTION style,
however, SetWindowText sets the text for the control, not for the list box entries. To set the text of a
control in another process, send the $WM_SETTEXT message directly instead of calling SetWindowText.

See Also

Search SetWindowText in MSDN Library.


Function _WinAPI_ShowCursor

Function Reference

_WinAPI_ShowCursor

Displays or hides the cursor

#include <WinAPI.au3>
_WinAPI_ShowCursor ( $bShow )

Parameters

$bShow If True, the cursor is shown, otherwise it is hidden

Return Value

Returns the new display counter

Remarks

This function sets an internal display counter that determines whether the cursor should be displayed.
The cursor is displayed only if the display count is greater than or equal to 0.
If a mouse is installed, the initial display count is 0.
If no mouse is installed, the display count is -1.

See Also

Search ShowCursor in MSDN Library.


Function _WinAPI_ShowError

Function Reference

_WinAPI_ShowError

Displays an error message box with an optional exit

#include <WinAPI.au3>
_WinAPI_ShowError ( $sText [, $bExit = True] )

Parameters

$sText | Error text to display
$bExit | [optional] Specifies whether to exit after the display: True - Exit program after display False - Return normally after display

Return Value

None.

Related

_WinAPI_MsgBox, _WinAPI_ShowMsg


Function _WinAPI_ShowMsg

Function Reference

_WinAPI_ShowMsg

Displays an "Information" message box

#include <WinAPI.au3>
_WinAPI_ShowMsg ( $sText )

Parameters

$sText "Information" text to display

Return Value

None.

Related

_WinAPI_MsgBox, _WinAPI_ShowError


Function _WinAPI_ShowWindow

Function Reference

_WinAPI_ShowWindow

Sets the specified window's show state

#include <WinAPI.au3>
_WinAPI_ShowWindow ( $hWnd [, $iCmdShow = 5] )

Parameters

$hWnd | Handle of window
$iCmdShow | [optional] Specifies how the window is to be shown: @SW_HIDE - Hides the window and activates another window @SW_MAXIMIZE - Maximizes the specified window @SW_MINIMIZE - Minimizes the specified window and activates the next top-level window in the Z order @SW_RESTORE - Activates and displays the window @SW_SHOW - Activates the window and displays it in its current size and position @SW_SHOWDEFAULT - Sets the show state based on the SW_ flag specified in the STARTUPINFO structure @SW_SHOWMAXIMIZED - Activates the window and displays it as a maximized window @SW_SHOWMINIMIZED - Activates the window and displays it as a minimized window @SW_SHOWMINNOACTIVE - Displays the window as a minimized window @SW_SHOWNA - Displays the window in its current state @SW_SHOWNOACTIVATE - Displays a window in its most recent size and position @SW_SHOWNORMAL - Activates and displays a window

Return Value

Success: | True
Failure: | False

See Also

Search ShowWindow in MSDN Library.


Function _WinAPI_StringFromGUID

Function Reference

_WinAPI_StringFromGUID

Converts a binary GUID to string form

#include <WinAPI.au3>
_WinAPI_StringFromGUID ( $tGUID )

Parameters

$tGUID A $tagGUID structure or a pointer to it

Return Value

Success: | GUID in string form
Failure: | Empty string

Related

$tagGUID, _WinAPI_GUIDFromString, _WinAPI_GUIDFromStringEx

See Also

Search StringFromGUID2 in MSDN Library.


Function _WinAPI_StringLenA

Function Reference

_WinAPI_StringLenA

Calculates the size of ANSI string

#include <WinAPI.au3>
_WinAPI_StringLenA ( Const ByRef $tString )

Parameters

$tString String Structure to process

Return Value

Success: | String length in characters
Failure: | 0

Remarks

Returned length does not include terminating null character.

Related

_WinAPI_StringLenW

See Also

Search lstrlenA in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

; Make the string buffer. It's "char" type structure. Choosing the size of 64 characters.
Local $tStringBuffer = DllStructCreate("char Data[64]")
; Fill it with some data
DllStructSetData($tStringBuffer, "Data", "Callipygian")

MsgBox($MB_SYSTEMMODAL, "_WinAPI_StringLenA", "Length of a string inside the buffer is " & _WinAPI_StringLenA($tStringBuffer) & " characters.")


Function _WinAPI_StringLenW

Function Reference

_WinAPI_StringLenW

Calculates the size of wide string

#include <WinAPI.au3>
_WinAPI_StringLenW ( Const ByRef $tString )

Parameters

$tString String structure to process

Return Value

Success: | String length in characters
Failure: | 0

Remarks

Returned length does not include terminating null character.

Related

_WinAPI_StringLenA

See Also

Search lstrlenW in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>

; Make the string buffer. It's "wchar" type structure. Choosing the size of 64 characters.
Local $tStringBuffer = DllStructCreate("wchar Data[64]")
; Fill it with some data
DllStructSetData($tStringBuffer, "Data", "Gongoozle")

MsgBox($MB_SYSTEMMODAL, "_WinAPI_StringLenW", "Length of a string inside the buffer is " & _WinAPI_StringLenW($tStringBuffer) & " characters.")


Function _WinAPI_SubLangId

Function Reference

_WinAPI_SubLangId

Extract sublanguage id from a language id

#include <WinAPI.au3>
_WinAPI_SubLangId ( $iLngID )

Parameters

$iLngID Language id

Return Value

Returns a Sub-Language id


Function _WinAPI_SystemParametersInfo

Function Reference

_WinAPI_SystemParametersInfo

Retrieves or sets the value of one of the system-wide parameters

#include <WinAPI.au3>
_WinAPI_SystemParametersInfo ( $iAction [, $iParam = 0 [, $vParam = 0 [, $iWinIni = 0]]] )

Parameters

$iAction | The system-wide parameter to be retrieved or set
$iParam | [optional] A parameter whose usage and format depends on the parameter being queried or set
$vParam | [optional] A parameter whose usage and format depends on the parameter being queried or set
$iWinIni | [optional] If a system parameter is being set, specifies whether the user profile is to be updated, and if so, whether the $WM_SETTINGCHANGE message is to be broadcast. This parameter can be zero if you don't want to update the user profile or it can be one or more of the following values: $SPIF_UPDATEINIFILE - Writes the new setting to the user profile $SPIF_SENDCHANGE - Broadcasts the $WM_SETTINGCHANGE message after updating the user profile

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

This function always call the Unicode version so $vParam must be inaccordance when using strings.

See Also

Search SystemParametersInfo in MSDN Library.

Example

#include <Array.au3>
#include <WinAPI.au3>
#include <WinAPIsysinfoConstants.au3>
#include <WindowsConstants.au3>

Local $aArray = GetWorkArea()
_ArrayDisplay($aArray, _WinAPI_GetSystemMetrics($SM_CXVIRTUALSCREEN) & ', ' & _WinAPI_GetSystemMetrics($SM_CYVIRTUALSCREEN))

; Get the working visible area of the desktop, this doesn't include the area covered by the taskbar.
Func GetWorkArea()
    Local $tWorkArea = DllStructCreate($tagRECT)
    _WinAPI_SystemParametersInfo($SPI_GETWORKAREA, 0, $tWorkArea)
    Local $aReturn[4] = [DllStructGetData($tWorkArea, 'Left'), DllStructGetData($tWorkArea, 'Top'), _
            DllStructGetData($tWorkArea, 'Right') - DllStructGetData($tWorkArea, 'Left'), DllStructGetData($tWorkArea, 'Bottom') - DllStructGetData($tWorkArea, 'Top')]
    Return $aReturn
EndFunc   ;==>GetWorkArea


Function _WinAPI_TwipsPerPixelX

Function Reference

_WinAPI_TwipsPerPixelX

Returns the width of a pixel, in twips

#include <WinAPI.au3>
_WinAPI_TwipsPerPixelX ( )

Return Value

Returns the width of a pixel, in twips


Function _WinAPI_TwipsPerPixelY

Function Reference

_WinAPI_TwipsPerPixelY

Returns the height of a pixel, in twips

#include <WinAPI.au3>
_WinAPI_TwipsPerPixelY ( )

Return Value

Returns the height of a pixel, in twips


Function _WinAPI_UnhookWindowsHookEx

Function Reference

_WinAPI_UnhookWindowsHookEx

Removes a hook procedure installed in a hook chain by the _WinAPI_SetWindowsHookEx function

#include <WinAPI.au3>
_WinAPI_UnhookWindowsHookEx ( $hHook )

Parameters

$hHook Handle to the hook to be removed

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Related

_WinAPI_SetWindowsHookEx

See Also

Search UnhookWindowsHookEx in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global $g_hHook, $g_hStub_KeyProc, $g_sBuffer = ""

Example()

Func Example()
    OnAutoItExitRegister("Cleanup")

    Local $hMod

    $g_hStub_KeyProc = DllCallbackRegister("_KeyProc", "long", "int;wparam;lparam")
    $hMod = _WinAPI_GetModuleHandle(0)
    $g_hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($g_hStub_KeyProc), $hMod)

    MsgBox($MB_SYSTEMMODAL, "", "Click OK, then in notepad type..." & _
            @CRLF & @CRLF & "Jon" & @CRLF & "AutoIt" & @CRLF & @CRLF & "Press Esc to exit script")

    Run("notepad.exe")
    WinWait("[CLASS:Notepad]")
    WinActivate("[CLASS:Notepad]")

    While 1
        Sleep(10)
    WEnd
EndFunc   ;==>Example

Func EvaluateKey($iKeycode)
    If (($iKeycode > 64) And ($iKeycode < 91)) _ ; a - z
            Or (($iKeycode > 96) And ($iKeycode < 123)) _ ; A - Z
            Or (($iKeycode > 47) And ($iKeycode < 58)) Then ; 0 - 9
        $g_sBuffer &= Chr($iKeycode)
        Switch $g_sBuffer
            Case "Jon"
                ToolTip("What can you say?")
            Case "AutoIt"
                ToolTip("AutoIt Rocks")
        EndSwitch
    ElseIf ($iKeycode > 159) And ($iKeycode < 164) Then
        Return
    ElseIf ($iKeycode = 27) Then ; esc key
        Exit
    Else
        $g_sBuffer = ""
    EndIf
EndFunc   ;==>EvaluateKey

; ===========================================================
; callback function
; ===========================================================
Func _KeyProc($nCode, $wParam, $lParam)
    Local $tKEYHOOKS
    $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam)
    If $nCode < 0 Then
        Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam)
    EndIf
    If $wParam = $WM_KEYDOWN Then
        EvaluateKey(DllStructGetData($tKEYHOOKS, "vkCode"))
    Else
        Local $iFlags = DllStructGetData($tKEYHOOKS, "flags")
        Switch $iFlags
            Case $LLKHF_ALTDOWN
                ConsoleWrite("$LLKHF_ALTDOWN" & @CRLF)
            Case $LLKHF_EXTENDED
                ConsoleWrite("$LLKHF_EXTENDED" & @CRLF)
            Case $LLKHF_INJECTED
                ConsoleWrite("$LLKHF_INJECTED" & @CRLF)
            Case $LLKHF_UP
                ConsoleWrite("$LLKHF_UP: scanCode - " & DllStructGetData($tKEYHOOKS, "scanCode") & @TAB & "vkCode - " & DllStructGetData($tKEYHOOKS, "vkCode") & @CRLF)
        EndSwitch
    EndIf
    Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam)
EndFunc   ;==>_KeyProc

Func Cleanup()
    _WinAPI_UnhookWindowsHookEx($g_hHook)
    DllCallbackFree($g_hStub_KeyProc)
EndFunc   ;==>Cleanup


Function _WinAPI_UpdateLayeredWindow

Function Reference

_WinAPI_UpdateLayeredWindow

Updates the position, size, shape, content, and translucency of a layered window

#include <WinAPI.au3>
_WinAPI_UpdateLayeredWindow ( $hWnd, $hDestDC, $tPTDest, $tSize, $hSrcDC, $tPTSrce, $iRGB, $tBlend, $iFlags )

Parameters

$hWnd | Handle to a layered window. A layered window is created by specifying $WS_EX_LAYERED when creating the window.
$hDestDC | Handle to a device context for the screen
$tPTDest | A $tagPOINT structure or a pointer to it that specifies the new screen position of the layered window. If the current position is not changing, this can be zero.
$tSize | A $tagSIZE structure or a pointer to it that specifies the new size of the layered window. If the size of the window is not changing, this can be 0.
$hSrcDC | Handle to a device context for the surface that defines the layered window. This handle can be obtained by calling the _WinAPI_CreateCompatibleDC() function.
$tPTSrce | A $tagPOINT structure or a pointer to it that specifies the location of the layer in the device context
$iRGB | The color key to be used when composing the layered window
$tBlend | A $tagBLENDFUNCTION structure or a pointer to it that specifies the transparency value to be used when composing the layered window.
$iFlags | This parameter can be one of the following values. $ULW_ALPHA - Use $tblend as the blend function $ULW_COLORKEY - Use $iRGB as the transparency color $ULW_OPAQUE - Draw an opaque layered window

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Related

$tagBLENDFUNCTION, $tagPOINT, $tagSIZE

See Also

Search UpdateLayeredWindow in MSDN Library.


Function _WinAPI_UpdateWindow

Function Reference

_WinAPI_UpdateWindow

Updates the client area of a window by sending a WM_PAINT message to the window

#include <WinAPI.au3>
_WinAPI_UpdateWindow ( $hWnd )

Parameters

$hWnd Handle of window to update

Return Value

Success: | True
Failure: | False

See Also

Search UpdateWindow in MSDN Library.


Function _WinAPI_WaitForInputIdle

Function Reference

_WinAPI_WaitForInputIdle

Waits until a process is waiting for user input with no input pending, or a time out

#include <WinAPI.au3>
_WinAPI_WaitForInputIdle ( $hProcess [, $iTimeout = -1] )

Parameters

$hProcess | A handle to the process. If this process is a console application or does not have a message queue, this function returns immediately.
$iTimeOut | [optional] The time out interval, in milliseconds. If set to -1, the function does not return until the process is idle.

Return Value

Success: | True
Failure: | False

Remarks

This function causes a thread to suspend execution until the specified process has finished its initialization
and is waiting for user input with no input pending. This can be useful for synchronizing a parent process and
a newly created child process. When a parent process creates a child process, the CreateProcess function
returns without waiting for the child process to finish its initialization. Before trying to communicate with
the child process, the parent process can use this function to determine when the child's initialization has
been completed. This function can be used at any time, not just during application startup.

See Also

Search WaitForInputIdle in MSDN Library.


Function _WinAPI_WaitForMultipleObjects

Function Reference

_WinAPI_WaitForMultipleObjects

Waits until one or all of the specified objects are in the signaled state

#include <WinAPI.au3>
_WinAPI_WaitForMultipleObjects ( $iCount, $paHandles [, $bWaitAll = False [, $iTimeout = -1]] )

Parameters

$iCount | The number of object handles in the array pointed to by $paHandles
$paHandles | Pointer to an array of object handles
$bWaitAll | [optional] If True, the function returns when the state of all objects in the $paHandles array is signaled. If False, the function returns when the state of any one of the objects is set to signaled. In the latter case, the return value indicates the object whose state caused the function to return.
$iTimeout | [optional] The time-out interval, in milliseconds. The function returns if the interval elapses, even if the conditions specified by the $bWaitAll parameter are not met. If 0, the function tests the states of the specified objects and returns immediately. If -1, the function's time-out interval never elapses.

Return Value

Success: | indicates the event that caused the function to return.
Failure: | (-1) WAIT_FAILED, call _WinAPI_GetLastError() to get extended error information.

Related

_WinAPI_WaitForSingleObject

See Also

Search WaitForMultipleObjects in MSDN Library.

Example

#include <WinAPI.au3>
#include <WinAPIProc.au3> ;needed for _WinAPI_ResetEvent()

Global $g_tEvents = DllStructCreate("handle Event[3];")
$g_tEvents.Event(1) = _WinAPI_CreateEvent(0, True, False)
$g_tEvents.Event(2) = _WinAPI_CreateEvent(0, True, False)
$g_tEvents.Event(3) = _WinAPI_CreateEvent(0, True, False)

HotKeySet("{ESC}", "_Exit")
AdlibRegister("_FireEvent_1", 500)
AdlibRegister("_FireEvent_2", 800)

Local $iEvent
While 1
    $iEvent = _WinAPI_WaitForMultipleObjects(3, $g_tEvents, False, 100)
    Switch $iEvent
        Case 0
            ConsoleWrite("+ First Event" & @CRLF)
            _WinAPI_ResetEvent($g_tEvents.Event(1))
        Case 1
            ConsoleWrite("> Second Event" & @CRLF)
            _WinAPI_ResetEvent($g_tEvents.Event(2))
        Case 2
            ConsoleWrite("! Exit Event" & @CRLF)
            AdlibUnRegister("_FireEvent_1")
            AdlibUnRegister("_FireEvent_2")
            _WinAPI_CloseHandle($g_tEvents.Event(1))
            _WinAPI_CloseHandle($g_tEvents.Event(2))
            _WinAPI_CloseHandle($g_tEvents.Event(3))
            ExitLoop
        Case -1 ;Error
            ExitLoop
    EndSwitch
WEnd

Func _Exit()
    _WinAPI_SetEvent($g_tEvents.Event(3))
EndFunc   ;==>_Exit

Func _FireEvent_1()
    _WinAPI_SetEvent($g_tEvents.Event(1))
EndFunc   ;==>_FireEvent_1

Func _FireEvent_2()
    _WinAPI_SetEvent($g_tEvents.Event(2))
EndFunc   ;==>_FireEvent_2


Function _WinAPI_WaitForSingleObject

Function Reference

_WinAPI_WaitForSingleObject

Waits until the specified object is in the signaled state

#include <WinAPI.au3>
_WinAPI_WaitForSingleObject ( $hHandle [, $iTimeout = -1] )

Parameters

$hHandle | A handle to the object
$iTimeout | [optional] The time-out interval, in milliseconds. The function returns if the interval elapses, even if the conditions specified by the fWaitAll parameter are not met. If 0, the function tests the states of the specified objects and returns immediately. If -1, the function's time-out interval never elapses.

Return Value

Success: | Indicates the event that caused the function to return
Failure: | (-1) WAIT_FAILED, call _WinAPI_GetLastError() to get extended error information

Related

_WinAPI_WaitForMultipleObjects

See Also

Search WaitForSingleObject in MSDN Library.


Function _WinAPI_WideCharToMultiByte

Function Reference

_WinAPI_WideCharToMultiByte

Converts a Unicode string to a multibyte string

#include <WinAPI.au3>
_WinAPI_WideCharToMultiByte ( $vUnicode [, $iCodePage = 0 [, $bRetString = True]] )

Parameters

$vUnicode | String, DllStruct or Pointer to a byte array structure containing Unicode text to be converted
$iCodePage | [optional] Code page to use in performing the conversion: 0 - The current system Windows ANSI code page 1 - The current system OEM code page 2 - The current system Macintosh code page 3 - The Windows ANSI code page for the current thread 42 - Symbol code page 65000 - UTF-7 65001 - UTF-8
$bRetString | [optional] Flags that indicate whether to return a String or a DllStruct (default True : String)

Return Value

Success: | A string or a DllStruct containing a multibyte string
Failure: | Sets the @error flag to non-zero

Related

_WinAPI_MultiByteToWideChar

See Also

Search WideCharToMultiByte in MSDN Library.


Function _WinAPI_WindowFromPoint

Function Reference

_WinAPI_WindowFromPoint

Retrieves the handle of the window that contains the specified point

#include <WinAPI.au3>
_WinAPI_WindowFromPoint ( ByRef $tPoint )

Parameters

$tPoint $tagPOINT structure that defines the point to be checked

Return Value

Success: | The handle of the window that contains the point
Failure: | 0

Remarks

The WindowFromPoint function does not retrieve the handle of a hidden or disabled window, even if the point is
within the window.

Related

$tagPOINT

See Also

Search WindowFromPoint in MSDN Library.

Example

#include <WinAPI.au3>

HotKeySet("{ESC}", "Close") ; Set ESC as a hotkey to exit the script.

Global $g_tStruct = DllStructCreate($tagPOINT) ; Create a structure that defines the point to be checked.

Example()

Func Example()
    Local $hWnd

    While 1
        ToolTip("")
        Position() ; Update the X and Y elements with the X and Y co-ordinates of the mouse.
        $hWnd = _WinAPI_WindowFromPoint($g_tStruct) ; Retrieve the window handle.
        ToolTip($hWnd) ; Set the tooltip with the handle under the mouse pointer.
        Sleep(100)
    WEnd
EndFunc   ;==>Example

Func Position()
    DllStructSetData($g_tStruct, "x", MouseGetPos(0))
    DllStructSetData($g_tStruct, "y", MouseGetPos(1))
EndFunc   ;==>Position

Func Close()
    Exit
EndFunc   ;==>Close


Function _WinAPI_WriteConsole

Function Reference

_WinAPI_WriteConsole

Writes a character string to a console screen buffer

#include <WinAPI.au3>
_WinAPI_WriteConsole ( $hConsole, $sText )

Parameters

$hConsole | Handle to the console screen buffer
$sText | Text to be written to the console screen buffer

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

See Also

Search WriteConsole in MSDN Library.


Function _WinAPI_WriteFile

Function Reference

_WinAPI_WriteFile

Writes data to a file at the position specified by the file pointer

#include <WinAPI.au3>
_WinAPI_WriteFile ( $hFile, $pBuffer, $iToWrite, ByRef $iWritten [, $tOverlapped = 0] )

Parameters

$hFile | Handle to the file to be written
$pBuffer | Pointer to the buffer containing the data to be written
$iToWrite | Number of bytes to be written to the file
$iWritten | The number of bytes written
$tOverlapped | [optional] A $tagOVERLAPPED structure or a pointer to it

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Related

$tagOVERLAPPED, _WinAPI_CloseHandle, _WinAPI_CreateFile, _WinAPI_FlushFileBuffers, _WinAPI_GetFileSizeEx, _WinAPI_ReadFile, _WinAPI_SetEndOfFile, _WinAPI_SetFilePointer

See Also

Search WriteFile in MSDN Library.

Example

#include <WinAPI.au3>

Local $sTempFile, $hFile, $sText, $nBytes, $tBuffer, $iSize

; 1) create file and write data to it
$sTempFile = @TempDir & '\test.txt'
$sText = 'abcdefghijklmnopqrstuvwxyz'
$tBuffer = DllStructCreate("byte[" & StringLen($sText) & "]")
DllStructSetData($tBuffer, 1, $sText)
$hFile = _WinAPI_CreateFile($sTempFile, 1)
_WinAPI_WriteFile($hFile, $tBuffer, StringLen($sText), $nBytes)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_CloseHandle($hFile)
ConsoleWrite('1):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

; 2) read 6 bytes from position 3
$tBuffer = DllStructCreate("byte[6]")
$hFile = _WinAPI_CreateFile($sTempFile, 2, 2)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_SetFilePointer($hFile, 3)
_WinAPI_ReadFile($hFile, $tBuffer, 6, $nBytes)
_WinAPI_CloseHandle($hFile)
$sText = BinaryToString(DllStructGetData($tBuffer, 1))
ConsoleWrite('2):' & $iSize & ' ' & $sText & @CRLF)

; 3) write previously read 6 bytes from position 3 to the same position but in UpperCase
DllStructSetData($tBuffer, 1, StringUpper($sText))
$hFile = _WinAPI_CreateFile($sTempFile, 2, 4)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_SetFilePointer($hFile, 3)
_WinAPI_WriteFile($hFile, $tBuffer, 6, $nBytes)
_WinAPI_CloseHandle($hFile)
$tBuffer = 0
ConsoleWrite('3):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

; 4) truncate file size to 12 bytes
$hFile = _WinAPI_CreateFile($sTempFile, 2, 4)
_WinAPI_SetFilePointer($hFile, 12)
_WinAPI_SetEndOfFile($hFile)
$iSize = _WinAPI_GetFileSizeEx($hFile)
_WinAPI_CloseHandle($hFile)
ConsoleWrite('4):' & $iSize & ' ' & FileRead($sTempFile) & @CRLF)

FileDelete($sTempFile)


Function _WinAPI_WriteProcessMemory

Function Reference

_WinAPI_WriteProcessMemory

Writes memory in a specified process

#include <WinAPI.au3>
_WinAPI_WriteProcessMemory ( $hProcess, $pBaseAddress, $pBuffer, $iSize, ByRef $iWritten [, $sBuffer = "ptr"] )

Parameters

$hProcess | Identifies an open handle to a process whose memory is to be written to
$pBaseAddress | Points to the base address in the specified process to be written to
$pBuffer | Points to the buffer that supplies data to be written into the address space
$iSize | Specifies the number of bytes to write into the specified process
$iWritten | The actual number of bytes transferred into the specified process
$sBuffer | [optional] Contains the data type that $pBuffer represents

Return Value

Success: | True
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Related

_WinAPI_ReadProcessMemory

See Also

Search WriteProcessMemory in MSDN Library.


WinAPIEx Reference

  • COM Management
  • Diagnostic Management
  • Dialog Management
  • Files & Devices Reference
  • GDI Reference
  • Internationalization Management
  • Menus & Resources Reference
  • Miscellaneous Reference
  • Process & Synchronization Reference
  • Registry Management
  • ShellEx Management
  • ShellPath Management
  • System Reference
  • Theme Management


User Defined Functions

COM user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPICom.au3>.

User Defined Function | Description
_WinAPI_CLSIDFromProgID | Looks up a CLSID in the registry, given a ProgID
_WinAPI_CoInitialize | Initializes the COM library for use by the calling process
_WinAPI_CoTaskMemAlloc | Allocates a block of task memory
_WinAPI_CoTaskMemFree | Frees a block of task memory
_WinAPI_CoTaskMemRealloc | Changes the size of a previously allocated block of task memory
_WinAPI_CoUninitialize | Closes the COM library on the current process
_WinAPI_CreateGUID | Creates a globally unique identifier (GUID)
_WinAPI_CreateStreamOnHGlobal | Creates a stream object that uses a memory handle to store the stream contents
_WinAPI_GetHGlobalFromStream | Retrieves the global memory handle to a stream
_WinAPI_ProgIDFromCLSID | Retrieves the ProgID for a given CLSID
_WinAPI_ReleaseStream | Releases a stream object


Function _WinAPI_CLSIDFromProgID

Function Reference

_WinAPI_CLSIDFromProgID

Looks up a CLSID in the registry, given a ProgID

#include <WinAPICom.au3>
_WinAPI_CLSIDFromProgID ( $sProgID )

Parameters

$sProgID The string containing the ProgID whose CLSID is requested.

Return Value

Success: | The string representation of the CLSID.
Failure: | Empty string and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search CLSIDFromProgID in MSDN Library.

Example

#include <WinAPICom.au3>

ConsoleWrite(_WinAPI_CLSIDFromProgID('AutoItX3.Control.1') & @CRLF)


Function _WinAPI_CoInitialize

Function Reference

_WinAPI_CoInitialize

Initializes the COM library for use by the calling process

#include <WinAPICom.au3>
_WinAPI_CoInitialize ( [$iFlags = 0] )

Parameters

$iFlags [optional] This parameter can be one or more of the following values.
$COINIT_APARTMENTTHREADED
$COINIT_DISABLE_OLE1DDE
$COINIT_MULTITHREADED (Default)
$COINIT_SPEED_OVER_MEMORY

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search CoInitializeEx in MSDN Library.


Function _WinAPI_CoTaskMemAlloc

Function Reference

_WinAPI_CoTaskMemAlloc

Allocates a block of task memory

#include <WinAPICom.au3>
_WinAPI_CoTaskMemAlloc ( $iSize )

Parameters

$iSize The size of the memory block to be allocated, in bytes.

Return Value

Success: | The allocated memory block.
Failure: | 0.

Remarks

If $iSize is 0, _WinAPI_CoTaskMemAlloc() allocates a zero-length item and returns a valid pointer to that item.
The allocated block may be larger than $iSize bytes because of the space required for alignment and for maintenance information.

See Also

Search CoTaskMemAlloc in MSDN Library.


Function _WinAPI_CoTaskMemFree

Function Reference

_WinAPI_CoTaskMemFree

Frees a block of task memory

#include <WinAPICom.au3>
_WinAPI_CoTaskMemFree ( $pMemory )

Parameters

$pMemory The pointer to the memory block to be freed.

Return Value

None.

See Also

Search CoTaskMemFree in MSDN Library.


Function _WinAPI_CoTaskMemRealloc

Function Reference

_WinAPI_CoTaskMemRealloc

Changes the size of a previously allocated block of task memory

#include <WinAPICom.au3>
_WinAPI_CoTaskMemRealloc ( $pMemory, $iSize )

Parameters

$pMemory | The pointer to the memory block to be reallocated.
$iSize | The size of the memory block to be reallocated, in bytes.

Return Value

Success: | The reallocated memory block.
Failure: | 0.

Remarks

If $pMemory is 0, function allocates a new memory block in the same way as the _WinAPI_CoTaskMemAlloc() function.
If $pMemory is not 0, it should be a pointer returned by a prior call to _WinAPI_CoTaskMemAlloc().

The contents of the block are unchanged up to the shorter of the new and old sizes, although the new block can be in a different location.
If $pMemory is not 0 and $iSize is 0, then the memory pointed to by $pMemory is freed.

See Also

Search CoTaskMemRealloc in MSDN Library.


Function _WinAPI_CoUninitialize

Function Reference

_WinAPI_CoUninitialize

Closes the COM library on the current process

#include <WinAPICom.au3>
_WinAPI_CoUninitialize ( )

Return Value

None.

See Also

Search CoUninitialize in MSDN Library.


Function _WinAPI_CreateGUID

Function Reference

_WinAPI_CreateGUID

Creates a globally unique identifier (GUID)

#include <WinAPICom.au3>
_WinAPI_CreateGUID ( )

Return Value

Success: | The string representation of the GUID.
Failure: | Empty string and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search CoCreateGuid in MSDN Library.

Example

#include <WinAPICom.au3>

For $i = 1 To 3
    ConsoleWrite(_WinAPI_CreateGUID() & @CRLF)
Next


Function _WinAPI_CreateStreamOnHGlobal

Function Reference

_WinAPI_CreateStreamOnHGlobal

Creates a stream object that uses a memory handle to store the stream contents

#include <WinAPICom.au3>
_WinAPI_CreateStreamOnHGlobal ( [$hGlobal = 0 [, $bDeleteOnRelease = True]] )

Parameters

$hGlobal | [optional] The memory handle, or if 0 (Default) a new handle is to be allocated instead. The handle must be allocated as moveable and nondiscardable.
$bDeleteOnRelease | [optional] Specifies whether the underlying handle for this stream object should be automatically freed when the stream object is released, valid values: True - The final release will automatically free the $hGlobal parameter (Default). False - The user must free the $hGlobal after the final release.

Return Value

Success: | The pointer to the new stream object.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

If $hGlobal is 0, the function allocates a new memory handle and the stream is initially empty, otherwise, the initial contents of the stream are the current contents of the memory block.
Thus, _WinAPI_CreateStreamOnHGlobal() can be used to open an existing stream in memory. The memory handle and its contents are undisturbed by the creation of the new stream object.

After creating the stream object with _WinAPI_CreateStreamOnHGlobal(), call _WinAPI_GetHGlobalFromStream() to retrieve the memory handle associated with the stream object.

To release the stream object, use the _WinAPI_ReleaseStream() function.

Related

_WinAPI_GetHGlobalFromStream, _WinAPI_ReleaseStream

See Also

Search CreateStreamOnHGlobal in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <Memory.au3>
#include <StaticConstants.au3>
#include <WinAPICom.au3>

; Create bitmap (MSDNLogo.png)
Local $dData = _Image_MSDNLogo()
Local $iLength = BinaryLen($dData)
Local $hData = _MemGlobalAlloc($iLength, $GMEM_MOVEABLE)
Local $pData = _MemGlobalLock($hData)
Local $tData = DllStructCreate('byte[' & $iLength & ']', $pData)
DllStructSetData($tData, 1, $dData)
_MemGlobalUnlock($hData)
Local $pStream = _WinAPI_CreateStreamOnHGlobal($hData)
_GDIPlus_Startup()
Local $hImage = _GDIPlus_BitmapCreateFromStream($pStream)
Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
Local $iWidth = _GDIPlus_ImageGetWidth($hImage)
Local $iHeight = _GDIPlus_ImageGetHeight($hImage)
_WinAPI_ReleaseStream($pStream)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), $iWidth, $iHeight)
Local $idPic = GUICtrlCreatePic('', 0, 0, $iWidth, $iHeight)
Local $hPic = GUICtrlGetHandle($idPic)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _Image_MSDNLogo()
    Local $sImage = _
            '0x89504E470D0A1A0A0000000D49484452000000BE000000460802000000FDD7B9' & _
            'BE000000097048597300000B1300000B1301009A9C180000000467414D410000' & _
            'B18E7CFB5193000000206348524D00007A25000080830000F9FF000080E90000' & _
            '75300000EA6000003A980000176F925FC546000014444944415478DAEC5D795C' & _
            '545796BE6FABBDA028A0100B011111177430B82088C10D4D2409C6AD21064D8C' & _
            '11C1D89A31C14E3A6A667E331AED98C42191884D121BD456034651B15DB22806' & _
            'C2A68080C5BED7BE507BBD65FE28BBAC201465679C60F2BE3FF855BD77EE79EF' & _
            'DCF3D53DE79E7BDF03A2280AD0A0F1E880E92EA0415387064D1D1A347568D0D4' & _
            'A14183A60E0D9A3A3468EAD0A0A94383A60E0D1A3475683C2EA0BF317B6EB6A9' & _
            '4E54774B65FA17C7F9AC5E309E76304D1DB770BE41F6D97549FD1589A2457D85' & _
            '243DF73DBB644938ED633A600D83920EF5E73F34579EAAE9AD9552246903D0B1' & _
            'BC4ADAC13475864197CEFC79597BCD85066D5F3FC6C620088220D0D2AA321AAD' & _
            'B48F69EA0C099CA4FE56D353F36D8BAA43CBE23321040200008A62333104A6E7' & _
            '0174AE33347EEAD57E5FD1D555276372192441020008880406EBF810219385D2' & _
            '3EA6A933386C24552C51B455F40008200C04B24100000A8680C1161F1F4A3B98' & _
            'A6CE9068521B2B6AFB74723DC6C6289C0214051004E82C61A33D963D37897630' & _
            '4D9D2151A730485BD5100223084C0002C01865B52132FDEECF57F2784CDAC174' & _
            '9A3C24DA55867EA51165621002232C148228BC45B57DD39CC54B26D0DEA5471D' & _
            '57F0E3320186A06C9424489BDC40352BDECD88F9E39BF37EF39EC371BCA3A383' & _
            'A2288220B85CAE582CA6A9E32E280020009E19E7739A246FB7A980D61C335194' & _
            'B1EB0F31B1637F0F3FFA9E9E9ED8D8589BCD86E3785C5CDCD9B36769EA0C0F13' & _
            '4E16B42B5BEB659BE78C150A39F99FBCD0D2ACE47BB08282BD7E3FF18224C9BE' & _
            'BE3EFB63746AB59A0E586EF1E6AF777B2F977534DFEC88429084A5E11C2E63CA' & _
            '54FFDF5BAA014110866156AB150080A2284D9D614050D44989FC724947478B12' & _
            '97EB7D7D7974BA4ACFB0DC4271A7FA625967678B0AA6C0243E33629ABF8352BD' & _
            '46ABCC64A33D4A8F3A83E08ED25050D9DD764F817118DA5B6D193BE661180200' & _
            '68549B8A5AE4D51285CD4AAC08F57971CE58DAAF34751E406DC1CFDC9536D5CB' & _
            '3136AAAAECDEF0F4B8F90BC30000D77AB4272ABBEE55F52ABAB50441D5144BC4' & _
            '303C7B7610ED5A3A600100004581ABDD9A5A89C26A2514B7DA574EF4FDF79DF3' & _
            '0100FFE8D1E4DE6CABBED1A6ECEB47300463222486DC2C69A3FD4A8F3AF7A1B4' & _
            'D8AED5F5B59775723BD57B92A7AF4E990E00A85419F27FEC68ACECC17192C1C6' & _
            '4882A400003849118FF0DA17994CD6D5D565341A4522516060208BC51A4A52AF' & _
            'D7777676AA542A168B251289020202200872F32A2A95AAB7B757AD56B3582CA1' & _
            '5028168B994CB71649D46A756F6FAF46A3613018229168F4E8D1BF703265B158' & _
            'DADBDB150A058220762B300CFBCD52C764C59938196D22626382973CB354E8CD' & _
            '010028ADF889DB3D929A3E92245114254912A660804256B53124583840435656' & _
            '5643430382203C1E6FDBB66DDEDEDE0080C2C2C29C9C9CEAEA6AB55A6DB55A79' & _
            '3C5E7070F0EAD5ABD3D2D23C3D3D9D9B5754541C3972E4DAB56B3299CC683462' & _
            '18C6E3F1C2C3C35352525253535D908024C9C2C2C22FBFFCF2F6EDDB1A8DC660' & _
            '306018C6E170FCFDFDE7CC99B36EDDBAE8E8E8411B5AADD6828282E3C78F5757' & _
            '576B341AA3D188A2288FC70B090959B56AD5BA75EB8442A18B1ECBCBCBBB75EB' & _
            '168AA2300C6FDEBC393434140070EFDEBD9C9C9C4B972E757575E9F57A0441B8' & _
            '5C6E7070F08A152B5E7FFD752FAF472F895123185682BCAED4BFB1F7AAD58A0F' & _
            '38F575B3FCD9433FCCC82C9AF5EEC5199917A2DE2E8A7AABE8A91DE7A7CE3924' & _
            '93F50F108E8A8AB21BCB6030BABABA341A4D7272F2501D3263C68CE6E66647DB' & _
            'BD7BF772B9DCA184172E5C28954A07BDF9E6E6E6848404173DBF68D12292241F' & _
            '6E585E5E1E1B1BEBA2E1942953AAAAAAE4723983C1B01F898F8F77D6B062C50A' & _
            '87F0B56BD7288ACACACAF2F5F51D4A616464647D7DFDA37A67E4E63A3A1B51D0' & _
            'AD39F459C9384F1682C02D466B69BFB9B5570700D0D8881FEEC9350A038385C2' & _
            '300421108440301BD3DDED5BFBDCE4878B3D0EDF7B7B7BF7F7F7A7A4A4E4E7E7' & _
            'DB8FB058AC0121E0A79F7E7AF1C517552A1500203333333333D3603038841104' & _
            '7116BE72E54A6A6AAAD96C1E70C5B6B6B665CB961517173F482A6198CD663B5F' & _
            '0B1E6C07E3D9B3671312126EDCB8E17C10C330E7485A5B5B9B9898F8E38F3FB2' & _
            'D9EC41BBCE71DC3EB41C3C78303D3D5D2E970F654555555552529242A1B00F25' & _
            '4F76C0925AF033CDF2D3FF73333E50189F38E9B454FB5D7997CE68436BA547DF' & _
            '4F505BF1EEDE7E18822018021400280C30485B279DC644D3B7B8FABDC230BC73' & _
            'E7CEA2A22200C0CB2FBFBC6AD5AAF1E3C76BB5DACACACA23478E545454D8C5AA' & _
            'ABABB3B2B2222222F6EDDB67EFEB575E7925292969CC98314AA5B2BCBCFCC891' & _
            '23B5B5B576E14B972EE5E7E7BFF2CA2B0FEA9604B17DFBF6FAFA7AFB575F5FDF' & _
            '8C8C8CF8F8783F3F3FB55A2D91488A8B8B0B0A0A1C8C74A0B4B434353555ABD5' & _
            '3A18B37CF9F2C4C4C4F0F0703E9FDFDDDD7DE3C68DBCBCBCC6C6C6AEAEAEF4F4' & _
            '748BC5E2BA1B391CCEA953A70E1D3A0400080C0C5CBF7EFDBC79F3FCFDFD351A' & _
            '4D5959594E4E4E4D4D8D5DB2A1A161D7AE5D595959EE2770232E60111455AF37' & _
            'BF79AA6AE9DABF9DBDDC58DCAECCFCBE69E5915BCF7CFC7DE26737E7BE906BB1' & _
            'E25A9C78F544E58203D717FCE5DBF8FDD76377158727FE75F5CAAF140AFDA03A' & _
            'E7CD9B37A0438F1F3F3E4046ABD53A8FF3BEBEBE2291080020140A2F5EBC3840' & _
            '582A95C6C4C43884636262CC66B3E36C6969A9637419356A547979F9C3B7545D' & _
            '5D7DF8F061E756FDFDFD4F3DF59443E7D8B163AF5EBDFA7043994CB671E3C601' & _
            '4E1C10B0D6AE5DEB1875EC77327FFEFCD6D6D687AD58BA74A943894020904824' & _
            'EE7B6AC451A7B947BB75F7A58F3FFEAE43D67F5EA64B3B5BF3C2673792B24B56' & _
            '7EF553DC1F0BF7FEF7FDDE3C75AE6EF6CBF991A9C7A7241E9DB3E0F04707BE33' & _
            '9B6C43E91C409D03070E0C2A2697CBC78C19E32C8920C8C9932707152E2D2D75' & _
            '04113E9FDFD8D8E838F5D1471F3934BCF9E69B2E8C75CE750E1E3CE868E5E7E7' & _
            '575D5DEDA2E1FAF5EBDDA18E83D92A956A503D3D3D3DCEBB353EFDF4D327923A' & _
            '2449A9ADB85461C0091227C86F64DA8D5FDF5EF36559727EC5EAAFCA62D3CFA4' & _
            '677C6D363FE047437D5FD13775653FB66B3426D79A9DA93375EA54936948F9B7' & _
            'DE7ACBB9D357AE5CE9C2EBCE034F6161A1E3D4EEDDBB1DC7F7EDDBE78EED0683' & _
            '61F2E4C98E56D9D9D9AEE5150A454848883BD4E170386565652E546DDDBAD521' & _
            '9C9A9AFA84A5C9668294F49B2FF46A8ED4F49C3A5B8BC090CC682DFEBEB55F6B' & _
            '26F45659558FB4F0EE9AF1A2439FBCC0643E48CE2684FB3D933869C6AC404F4F' & _
            '96FBD74A49497151BC71261982201B366C184A128220C7C40D00D0D9D9E9F8EC' & _
            '98F800002412893B77555A5A5A575767FF1C1111F1D24B2FB996F7F6F65EBD7A' & _
            'B53B9A172E5C3863C60C1702CE314B2A953E31D5640341D6E9CC855DEABCAAEE' & _
            'DCBCCAA25D97674F1B0500F066A2A3250A9F3B7DA1DDBAD722C5F98792D2B7C6' & _
            '3E420637041004898C8C7421E0EFEFEF989E88C5E2E9D3A7BB101E3FFEC133ED' & _
            '36DB8395D7F0F0074F2B9F3C79D29D4D58D7AF5F777C4E4C4CE47038C336898B' & _
            '8B73C7E4458B16B916080A0A7298AC56AB874DBD7FFD19164152A5ADCA1F9A15' & _
            '8D0DF2F63BBD817C6C636244FCB6A73114262880A1C89F32173CDCCA8893BD26' & _
            'ABDC64B3E00403412608D842E62398C0E7F383825C2D6F0904022E976B329900' & _
            '002291482010B89EBF380F42CE4E0D0E0E6E6B6B0300F4F7F7AF59B3E68D37DE' & _
            'C8C8C818904839C3315F0300CC9E3DDB1D5BC4623182200441B8160B0E0E1E76' & _
            '16C6E7F3ED261B0C06B3D9EC66A5FB57A00E050049513849B1703250639E14EC' & _
            '353B399227E0A86D44838DE85318543A1382C0C1BEDC081E8B09DF7789D64654' & _
            '2AF477FA746D52BD4E67B15A7192046383BCD68FF71937DAD3DD1F0A8A3A4793' & _
            '87C164321D857904415C173948921C2A9AECDEBD7BDDBA75F7C3B1D9FCC1071F' & _
            'E4E5E5252727A7A4A44C9B366D80BCCD66EBE9E971145D020202DCB1C5D3D373' & _
            '58EA4010C4E3F186A58E402090C9647679F787F6FF0FEAE8F4568AC75099AC7A' & _
            '9232E2A48D20CD048931502F7FFEAAF1D3101852E0C4E55E6D5D9746A3B798AD' & _
            '044E902449F105EC4A8D65E30B530000DD66DBB926796DAB4AAD36D96CF7E725' & _
            '044ED6DD931F2A69FBF0EDF930EC96C1F7A706EE09FC927F81909A9AAAD7EB33' & _
            '3333F57ABDFD487777F7FEFDFB3FFDF4D3E5CB97EFD8B1232222C27975CC5E81' & _
            'B48F8B0396415CDCEAFFA1D8085AC32208D264B2DA6C388A221DDDBAEBA51D1D' & _
            '9D1A03003A234E10008108AB8DF443E0FFF8D30281805DD1AA2E95696D568282' & _
            '20048351060261B04167B971A961E30B538C0479AE595E794F6E32E1080A4330' & _
            '441214499208020114E96AD7E038C9602023ADAA999E9E1E1515B567CF9E8B17' & _
            '2F3EC8ED0C8663C78E9D3F7FFEFDF7DFCFC8C8708C5E388E3B8A96B07BCFC9FF' & _
            'F2CC6FA45047ADD6575634DFABE9ECBE27D549F5FA3E3DA1348FF1F45C90111B' & _
            'FFF26C9190D5D3229F302980EDC1C271B2A345EA2DE47BFADC1F4B056AA3EC7A' & _
            '0B1A24E078712840990D36458B12342AFEBC2D0E00A0C289A66E1D8E934C2642' & _
            '92144190100010805116A2EDD04CF6628F40DED8316BD6AC0B172E1417171F3D' & _
            '7AB4A8A8C868343AB2D12D5BB6180C86B7DF7E7B0009088218367DB91FC1B55A' & _
            '37254716754892B2D9702613B37FCE3A78AEE4B35B5E2D5601CC64234818C614' & _
            '84787926050922FD5A14EA9796EE6BF8B17BB138F0BD928CBADB6DD9FB2FF497' & _
            '48F71765807F5267D6CCC09060E18D9BAD77EB6426934DC444132346C76D996B' & _
            '7F7C93450118062C0E46D80800410040304A4128D2DFA3EBFFB6E58D9C95237C' & _
            'E53F2121212121A1BCBCFCC30F3F3C7EFCB8E3F87BEFBD171717171D1DCDE170' & _
            'BCBCBC5A5B5B01001A8D46A9548E1B376E58B50A85E2C9A00E4551F7EEF55455' & _
            '34D757B4A95A55B8C28CAB2DC251FCF403AB4685FB816F7BFE60F2634C667984' & _
            '09BDA303B8B1626C0CFF74DE0F477715689BF44C80AE9916FA5CCEF3D99F17E7' & _
            'EEBEEC65C6D2926385E3BD9DF5FB8A7849491149835DDA878505F51A7E2208BE' & _
            '3F1F0080E3A44161ECAE6AE77468B20F3E375AEC099E04444545E5E7E7272525' & _
            'A5A5A529954A0080D56ACDCDCD8D8E8E66B1587E7E7E76311CC72512C9CC9933' & _
            '8755D8D8D838D20396566B3C73EAE63F4E95E94BFAC406D41F7082010A288885' & _
            'C0A3BBACFC4E23631A96767A03A1B3C03C06C6C600001D1DF2D796EE173510DE' & _
            '001233B86B5E9D1BB97BDEDE0305973EB82580B0E7674F58F6E13330FA0825A5' & _
            'B494E99C2FCBBFBDD0A8B391B8DEE2CD405F7D3A64F9DE65AC27ED1D282B57AE' & _
            '944AA55BB66CB17FADACACA4280A82A0C993273B52A24B972EA5A4A40CABCA79' & _
            '597E2452E7DCD9D24FDE3B2DAC314F05023EF021012001C540212F1612FA9478' & _
            'E25B733D9686020050268AFAA2562BAEEF37F1F8ECA6FAEED94AAE603473C2FC' & _
            'D0A9EBA6FBC6059D3CF6DDD5FD25013067E9D3E1295FACE2F8701EE92E61185A' & _
            'BF7EC65AFC298DDA8420909790039E582C5BB6EC9D77DED1E97400009D4E67B1' & _
            '58582CD682050B0E1C386017F8E69B6FEEDEBD3B6992ABD774DCBA756BA45367' & _
            '6F4ACE6283C80BE251304011E0C9407CBC39E2B981E2E5933D168D43780C0040' & _
            '4343D7E5F3154D375A8CB54A968E5AB831FAF9F79F8DBD1B0E28C010DC2FF9FB' & _
            '8F12AE7B76C6B498D0E99B6731788C7FF15E51D8C7973BF2C9A1D56A5D4CB0CD' & _
            '66B32347E1F3F9F6FADBDCB973C3C3C31B1A1AEC7CCACCCC3C73E6CC505B3F35' & _
            '1ACD8E1D3BEC45BC914B9DFD6B96A0DFF79820922FE67B86F9784407F26605B0' & _
            'C37DEC675B5BA51FFEE719F9D74DA15A6608C442008302805DDC43FD996078B2' & _
            '00000683F9DAD53B9E38323B21226E5104F87D60CF9E3D288A6666660EBA0DF4' & _
            '8B2FBE70ECD499356B967D7AC5E572D3D2D21C2B91E7CE9D7BFDF5D70F1E3CF8' & _
            '30053B3A3A366EDC78F3E64DFB1C7EA8B2E4AF4F9DE8C34978AF9E82002A60C1' & _
            '3F1F2D24929E2D4BFF32B385311112D820CA06480B09841C247C5314CC440100' & _
            '57AE547FB5F32CF7B69E0F63D87675F47F2D7C1C06D8FB0E1E49EF0CECEFEFCF' & _
            'C9C9292C2C4C4E4E9E376FDEC48913994C26499277EFDE3D71E2447676B6A370' & _
            'ECBC416CC3860D8585858EC5ACDCDCDC3B77EE6CDAB4292E2E4E24129124D9DA' & _
            'DA7AE5CA95ECEC6CFB5C6CEBD6ADB9B9B91A8D6684520742616C8CC7A0A7BEC8' & _
            '2A9EDECA10416C0320488A8200E4CD46676E9E11B82E1200505070EB54EADFA7' & _
            '9A3D2C804950C0A2323E26037EF5CAD86099190C009048247BF6EC8120C8C3C3' & _
            'C37E44A7D3394FA7DF7DF75DE7B5770E8773F4E8D1C58B17373535D98F545454' & _
            'BCF6DA6B1C0EC71ED40C0683FD097300C0ABAFBEBA7DFBF6C3870FFF9A66FECB' & _
            '2DC3C68DF684300B454210E03390D040CFA7DF9F1FB12F0142A09696BE2F37FD' & _
            '3DDAE005480A10408020C18BC63D3EEA0CCB1EC7DE61A3D1E87A84A728CA51B8' & _
            '1B3699709480C1CF57CE9D978DECFB0FD56AB55AAD76F086CBE5EEDBB7EF9D77' & _
            'DE19A070ECD8B14545450B17FE6C78361A8DF6E676DEC030BC6DDB36FB4E50C7' & _
            '1D0ED81CED58FDB6BF7D67D8B28B438F7D27D363AF26AF4D5FDCC6F6565F6BA3' & _
            '6020FCB751A2651378E1F7F7DC97DCA80F5330488A8228888FA0E17382029686' & _
            'FD8ABF8F9898182E970BC3308FC773F178833D882C5EBC58AD5653143571E244' & _
            'D77170CC9831F1F1F1288ADA6C36E78D573B77EE0C0A0A3A7DFAF4EDDBB7ED33' & _
            'A97FA6F9A8582C4E4848D8B469D3507B3FC2C2C22E5CB870ECD8B1DCDCDCAAAA' & _
            '2AE7FDCB3E3E3EF3E7CFDFB469537C7CBC5DDB92254B701C27086280B6C8C848' & _
            'B95C8E200804413E3E3EAE3B87C964C6C7C77777775314151212E2FE6359D0E3' & _
            '581EABAD693FF5629E5F2B0EA120242630FAB3448F9F17007F33B05765EC7F1F' & _
            '4EC23A3B3B9B9A9A944A2545510C06232020202C2CCCCDD54D92249B9A9A1A1B' & _
            '1B8D46A39D0193264D1A356AD4C8B11D7A4C2BAB25672AF17C09C6C7C236CFF4' & _
            '9E190068FCE6003DBE45791ABF6DD0EFC1A7415387064D1D1A347568D0D4A141' & _
            '83A60E0D9A3A3468EAD0A0A94383A60E0D1A3475683C36FCEF00A7516BFF8067' & _
            'B69A0000000049454E44AE426082'

    Return Binary($sImage)
EndFunc   ;==>_Image_MSDNLogo


Function _WinAPI_GetHGlobalFromStream

Function Reference

_WinAPI_GetHGlobalFromStream

Retrieves the global memory handle to a stream

#include <WinAPICom.au3>
_WinAPI_GetHGlobalFromStream ( $pStream )

Parameters

$pStream Pointer to the stream object previously created by a call to the _WinAPI_CreateStreamOnHGlobal() function.

Return Value

Success: | Pointer to the current memory handle used by the specified stream object.
Failure: | 0 and sets the@error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function can be called only from within the same process from which the byte array was created.

Related

_WinAPI_CreateStreamOnHGlobal

See Also

Search GetHGlobalFromStream in MSDN Library.


Function _WinAPI_ProgIDFromCLSID

Function Reference

_WinAPI_ProgIDFromCLSID

Retrieves the ProgID for a given CLSID

#include <WinAPICom.au3>
_WinAPI_ProgIDFromCLSID ( $sCLSID )

Parameters

$sCLSID The string that represents the CLSID for which ProgID is to be retrieved.

Return Value

Success: | The string that contains a ProgID.
Failure: | Empty string and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search ProgIDFromCLSID in MSDN Library.

Example

#include <WinAPICom.au3>

ConsoleWrite(_WinAPI_ProgIDFromCLSID('{1A671297-FA74-4422-80FA-6C5D8CE4DE04}') & @CRLF)


Function _WinAPI_ReleaseStream

Function Reference

_WinAPI_ReleaseStream

Releases a stream object

#include <WinAPICom.au3>
_WinAPI_ReleaseStream ( $pStream )

Parameters

$pStream Pointer to the stream object previously created by a call to the _WinAPI_CreateStreamOnHGlobal() function.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Related

_WinAPI_CreateStreamOnHGlobal

See Also

Search DispCallFunc in MSDN Library.


User Defined Functions

Diagnostic user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIDiag.au3>.

User Defined Function | Description
_WinAPI_DisplayStruct | Displays data from the specified structure or memory address as a list
_WinAPI_EnumDllProc | Enumerates an exported functions of the specified dynamic-link library (DLL)
_WinAPI_FatalExit | Transfers execution control to the debugger
_WinAPI_GetApplicationRestartSettings | Retrieves the restart information registered for the specified process
_WinAPI_GetErrorMessage | Retrieves a text error message for the specified system error code
_WinAPI_GetErrorMode | Retrieves the error mode for the current process
_WinAPI_IsInternetConnected | Determines whether the current user is connected to the Internet
_WinAPI_IsNetworkAlive | Determines whether or not a local system is connected to a network, and identifies the type of network connection
_WinAPI_NtStatusToDosError | Converts the specified NTSTATUS error code to its equivalent system error code
_WinAPI_RegisterApplicationRestart | Registers the active instance of an application for restart
_WinAPI_SetErrorMode | Controls whether the system will handle the specified types of serious errors or whether the process will handle them
_WinAPI_ShowLastError | Shows the last error code and message
_WinAPI_UniqueHardwareID | Generates a unique hardware identifier (ID) for local computer
_WinAPI_UnregisterApplicationRestart | Removes the active instance of an application from the restart list


Function _WinAPI_DisplayStruct

Function Reference

_WinAPI_DisplayStruct

Displays data from the specified structure or memory address as a list

#include <WinAPIDiag.au3>
_WinAPI_DisplayStruct ( $tStruct [, $sStruct = '' [, $sTitle = '' [, $iItem = 0 [, $iSubItem = 0 [, $iFlags = 0 [, $bTop = True [, $hParent = 0]]]]]]] )

Parameters

$tStruct | A structure that was created by DllStructCreate(), or memory address to be display its data.
$sStruct [optional] A string representing the structure.
If $tStruct is a structure, this parameter can be omitted or be an empty string. In this case, the structure will display as "byte[n]" structure.
If $tStruct is a memory address, $sStruct should be a string representing the structure, otherwise, the function fail, and @error set to 10.
$sTitle | [optional] The title of the window, deault is "Structure: ListView Display".
$iItem [optional] The 1-based index or name of the structure member to be selected in the list.
If this parameter is 0 (Default), or an incorrect index or name, the first element of the structure will be selected.
$iSubItem [optional] The 1-based index of the array in the structure member pointed to by the $iItem parameter to be selected.
If $iItem was not defined as an array in the $sStruct, or invalid array index, the element pointed to by the $iItem parameter will be selected.
$iFlags [optional] A set of bit flags that specifies an additional displaying options.
This parameter can be 0, or any combination of the following values:
1 - Prevent displaying "" and "" fields at the beginning and end of the list.
2 - Prevent displaying "" fields.
4 - Prevent displaying "" in "Member" column of the list if the structure element has no name.
8 - Prevent highlighting structure elements that are defined as an array.
16 - Prevent perceiving structure elements named "Reserved*" as unused elements.
32 - Prevent using double-click to copy values of the structure elements to the clipboard.
64 - Forced to expand structure elements of BYTE[n] and BOOLEAN[n] types (elements of CHAR[n] and WCHAR[n] types always displays as a string).
128 - Forced to display the values of the structure elements in the hexadecimal representation, if possible.
256 - Forced to return error code instead of displaying a message box if a memory access error occurred.
512 - Forced to disable checking the read access memory allocated to a given structure.
$bTop [optional] Specifies whether create a window with "Always On Top" attribute, valid values:
True - The window is created with the $WS_EX_TOPMOST extended style (Default).
False - The window will not have the "TOPMOST" flag set.
$hParent | [optional] Handle to the parent window.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 2 - There is an unknown data type in the string passed. 3 - Failed to allocate the memory needed for the structure, or invalid pointer. 4 - Error allocating memory for the passed string. 10 - The $sStruct parameter is not a string. 15 - Error accessing memory to read data.

Remarks

This function is intended primarily for debugging and should not be used in the final script, since no useful information for the end user does not carry.

Example

#include <WinAPIDiag.au3>

Local $sStruct = 'dword Length;short State;uint Flags;handle hBitmap;hwnd hDC;long Rect[4];byte[14];int Reserved[10];wchar Text[80]'
Local $tStruct = DllStructCreate($sStruct)

DllStructSetData($tStruct, 1, 80)
DllStructSetData($tStruct, 2, 6)
DllStructSetData($tStruct, 3, 1)
DllStructSetData($tStruct, 4, 0x00010014)
DllStructSetData($tStruct, 5, 0x01010057)
DllStructSetData($tStruct, 6, 20, 1)
DllStructSetData($tStruct, 6, 20, 2)
DllStructSetData($tStruct, 6, 60, 3)
DllStructSetData($tStruct, 6, 80, 4)
DllStructSetData($tStruct, 7, Binary('0x656A6D633835206C6A6764206200'))
DllStructSetData($tStruct, 8, 0)
DllStructSetData($tStruct, 9, 'Simple Text')

_WinAPI_DisplayStruct($tStruct, $sStruct)


Function _WinAPI_EnumDllProc

Function Reference

_WinAPI_EnumDllProc

Enumerates an exported functions of the specified dynamic-link library (DLL)

#include <WinAPIDiag.au3>
_WinAPI_EnumDllProc ( $sFilePath [, $sMask = '' [, $iFlags = 0]] )

Parameters

$sFilePath | The path to the library. Although this function searches for a file path when it specified as the relative path or the name without a path, will better to specify a fully qualified path to the library for an unequivocal result.
$sMask | [optional] A wildcard string that indicates the function names to be enumerated. This string can optionally contain the wildcards, "*" and "?". If this parameter is an empty string or omitted (Default), all the exported functions will be enumerated.
$iFlags | [optional] The optional flags. This parameter can be one or more of the following values: $SYMOPT_CASE_INSENSITIVE $SYMOPT_UNDNAME

Return Value

Success: | The 2D array containing the following information, @extended flag will contain one of the $IMAGE_FILE_MACHINE_* constants. [0][0] - Number of rows in array (n) [0][1] - Unused [n][0] - The function address relative to the library base address (UINT64). [n][1] - The function name.
Failure: | Sets the @error flag to non-zero.

Remarks

This function works with 32- and 64-bit DLLs regardless of the system (32- or 64-bit), although 64-bit executables cannot load 32-bit DLLs and vice-versa.

Call _WinAPI_GetExtended() to retrieve a fully qualified path to the found DLL that was loaded for enumerating functions.

Note, use the fully qualified path to be sure that the _WinAPI_EnumDllProc() loads the DLL that is of interest.
In addition, this function does not use the file system redirection.

This function requires dbghelp.dll version 5.1 or later.

Related

_WinAPI_GetExtended

See Also

Search SymEnumSymbols in MSDN Library.

Example

#include <APIDiagConstants.au3>
#include <Array.au3>
#include <WinAPIDiag.au3>

Local $aData = _WinAPI_EnumDllProc('ntdll.dll', 'Rtl*', $SYMOPT_CASE_INSENSITIVE)

If IsArray($aData) Then
    For $i = 1 To $aData[0][0]
        $aData[$i][0] = '0x' & Hex($aData[$i][0])
    Next
EndIf

_ArrayDisplay($aData, _WinAPI_GetExtended())


Function _WinAPI_FatalExit

Function Reference

_WinAPI_FatalExit

Transfers execution control to the debugger

#include <WinAPIDiag.au3>
_WinAPI_FatalExit ( $iCode )

Parameters

$iCode The error code associated with the exit.

Return Value

None.

Remarks

@error can be return if a Windows error occured.

See Also

Search FatalExit in MSDN Library.


Function _WinAPI_GetApplicationRestartSettings

Function Reference

_WinAPI_GetApplicationRestartSettings

Retrieves the restart information registered for the specified process

#include <WinAPIDiag.au3>
_WinAPI_GetApplicationRestartSettings ( [$iPID = 0] )

Parameters

$iPID [optional] The PID of the process. Default (0) is the current process.

Return Value

Success: | The array that contains the following information: [0] - The restart command line. [1] - The flags.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This information is available only for the current process; you cannot call _WinAPI_GetApplicationRestartSettings() function after your program is restarted to get the restart command line.

This function requires Windows Vista or later.

See Also

Search GetApplicationRestartSettings in MSDN Library.


Function _WinAPI_GetErrorMessage

Function Reference

_WinAPI_GetErrorMessage

Retrieves a text error message for the specified system error code

#include <WinAPIDiag.au3>
_WinAPI_GetErrorMessage ( $iCode [, $iLanguage = 0] )

Parameters

$iCode | The system error code to retrieve a message.
$iLanguage | [optional] The language identifier.

Return Value

Success: | The requested message.
Failure: | Empty string.

See Also

Search FormatMessage in MSDN Library.


Function _WinAPI_GetErrorMode

Function Reference

_WinAPI_GetErrorMode

Retrieves the error mode for the current process

#include <WinAPIDiag.au3>
_WinAPI_GetErrorMode ( )

Return Value

Success: | The process error mode ($SEM_*).
Failure: | 0.

Remarks

This function requires Windows Vista or later.

See Also

Search GetErrorMode in MSDN Library.


Function _WinAPI_IsInternetConnected

Function Reference

_WinAPI_IsInternetConnected

Determines whether the current user is connected to the Internet

#include <WinAPIDiag.au3>
_WinAPI_IsInternetConnected ( )

Return Value

Success: | True - The user is connected to the Internet. False - Otherwise.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

See Also

Search IsInternetConnected in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPIDlg.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

If _WinAPI_IsInternetConnected() Then
    ConsoleWrite('Internet is already connected.' & @CRLF)
    Exit
EndIf

; Launch the Get Connected wizard within the calling application to enable Internet connectivity
_WinAPI_GetConnectedDlg(1, 1 + 4)


Function _WinAPI_IsNetworkAlive

Function Reference

_WinAPI_IsNetworkAlive

Determines whether or not a local system is connected to a network, and identifies the type of network connection

#include <WinAPIDiag.au3>
_WinAPI_IsNetworkAlive ( )

Return Value

Success: | The type of network connection ($NETWORK_ALIVE_*) if a local system is connected to a network.
Failure: | 0 and sets the @error flag to non-zero, @extended flag contains last error code.

Remarks

Always check @error flag before checking the return value of this function. If the @error is not 0,
the function has failed and the following values do not apply.

This function is only available for TCP/IP connections.

See Also

Search IsNetworkAlive in MSDN Library.

Example

#include <WinAPIDiag.au3>

ConsoleWrite('Internet connected: ' & (_WinAPI_IsNetworkAlive() <> 0) & @CRLF)


Function _WinAPI_NtStatusToDosError

Function Reference

_WinAPI_NtStatusToDosError

Converts the specified NTSTATUS error code to its equivalent system error code

#include <WinAPIDiag.au3>
_WinAPI_NtStatusToDosError ( $iStatus )

Parameters

$iStatus The NTSTATUS error code to be converted.

Return Value

Returns the system error code. ERROR_MR_MID_NOT_FOUND (317) is returned when the specified NTSTATUS error
code does not have a corresponding system error code.

See Also

Search RtlNtStatusToDosError in MSDN Library.

Example

#include <WinAPIDiag.au3>

Local $iError = _WinAPI_NtStatusToDosError(0xC0000023) ; STATUS_BUFFER_TOO_SMALL

ConsoleWrite($iError & ' - ' & _WinAPI_GetErrorMessage($iError) & @CRLF)


Function _WinAPI_RegisterApplicationRestart

Function Reference

_WinAPI_RegisterApplicationRestart

Registers the active instance of an application for restart

#include <WinAPIDiag.au3>
_WinAPI_RegisterApplicationRestart ( [$iFlags = 0 [, $sCmd = '']] )

Parameters

$iFlags | [optional] The flags that specifies an events when application will not be restarted. This parameter can be 0 or one or more of the following values. $RESTART_NO_CRASH $RESTART_NO_HANG $RESTART_NO_PATCH $RESTART_NO_REBOOT
$sCmd | [optional] The command-line arguments for the application when it is restarted. The maximum size of the command line that you can specify is 2048 characters. If this parameter is empty string (Default), the previously registered command line is removed.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

Your initial registration for restart must occur before the application encounters an unhandled exception
or becomes unresponsive. You could then call this function from inside your recovery callback to update the
command line. To prevent cyclical restarts, the system will only restart the application if it has been
running for a minimum of 60 seconds.

If you register for restart and the application encounters an unhandled exception or is not responsive,
the user is offered the opportunity to restart the application; the application is not automatically restarted
without the user's consent.

This function requires Windows Vista or later.

See Also

Search RegisterApplicationRestart in MSDN Library.

Example

#include <APIDiagConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

Global $g_iCount = 10

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 300, 100)
Local $idLabel = GUICtrlCreateLabel('The application will be crashes after ' & $g_iCount & ' seconds.', 10, 43, 280, 14, $SS_CENTER)
GUISetState(@SW_SHOW)

If $CmdLine[0] And ($CmdLine[1] = '/crash') Then
    MsgBox(BitOR($MB_ICONWARNING, $MB_SYSTEMMODAL), 'Attention', 'The application has been restarted after an abnormal exit.', 0, $hForm)
EndIf

If Not @Compiled Then
    _WinAPI_RegisterApplicationRestart(BitOR($RESTART_NO_PATCH, $RESTART_NO_REBOOT), '"' & @ScriptFullPath & '" /crash')
Else
    _WinAPI_RegisterApplicationRestart(BitOR($RESTART_NO_PATCH, $RESTART_NO_REBOOT), '/crash')
EndIf

AdlibRegister('_Countdown', 1000)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _Countdown()
    Local $iData
    #forceref $iData

    $g_iCount -= 1
    If $g_iCount Then
        GUICtrlSetData($idLabel, 'The application will be crashes after ' & $g_iCount & ' seconds.')
    Else
        Local $tData
        ; Forced script crash due to a memory access violation
        $tData = DllStructCreate('int', 0x12345678)
        $iData = DllStructGetData($tData, 1)
    EndIf
EndFunc   ;==>_Countdown


Function _WinAPI_SetErrorMode

Function Reference

_WinAPI_SetErrorMode

Controls whether the system will handle the specified types of serious errors or whether the process will handle them

#include <WinAPIDiag.au3>
_WinAPI_SetErrorMode ( $iMode )

Parameters

$iMode The process error mode. This parameter can be one or more of the following values.
$SEM_FAILCRITICALERRORS
$SEM_NOALIGNMENTFAULTEXCEPT
$SEM_NOGPFAULTERRORBOX
$SEM_NOOPENFILEERRORBOX

Return Value

Returns the previous state of the error-mode bit flags ($SEM_*).

See Also

Search SetErrorMode in MSDN Library.


Function _WinAPI_ShowLastError

Function Reference

_WinAPI_ShowLastError

Shows the last error code and message

#include <WinAPIDiag.au3>
_WinAPI_ShowLastError ( [$sText = '' [, $bAbort = False [, $iLanguage = 0]]] )

Parameters

$sText | [optional] The user's text that to be displayed with the message.
$bAbort | [optional] Specifies whether to exit the script after displaying an error message, valid values: True - Exit the script after displaying a message if it indicates an error. False - Always return normally (Default).
$iLanguage | [optional] The language identifier for the message.

Return Value

None.

Remarks

@error and @extended are preserved on return.


Function _WinAPI_UniqueHardwareID

Function Reference

_WinAPI_UniqueHardwareID

Generates a unique hardware identifier (ID) for local computer

#include <WinAPIDiag.au3>
_WinAPI_UniqueHardwareID ( [$iFlags = 0] )

Parameters

$iFlags [optional] The flags that specifies what information would be used to generate ID. This parameter can be one or more of the following values.
$UHID_MB - Uses information about your motherboard. This flag is used by default regardless of whether specified or not.
$UHID_BIOS - Uses information from BIOS.
$UHID_CPU - Uses information about your processor(s). Note that $UHID_CPU flag reduces the function speed.
$UHID_HDD - Uses information about the installed hard drives. Any change in the configuration disks will change ID returned by this function. Taken into account only non-removable disks with an ATA or SATA interfaces.
$UHID_All - The sum of all the previous flags.

Return Value

Success: | The string representation of the ID. @extended returns the value that contains a combination of flags specified in the $iFlags parameter. If flag is set, appropriate information is received successfully, otherwise fails. The function checks only flags that were specified in the $iFlags parameter.
Failure: | Empty string and sets the @error flag to non-zero.

Remarks

This function uses the Windows Management Instrumentation (WMI).

Example

#include <APIDiagConstants.au3>
#include <WinAPIDiag.au3>

ConsoleWrite('Hardware1: ' & _WinAPI_UniqueHardwareID() & @CRLF)
ConsoleWrite('Hardware2: ' & _WinAPI_UniqueHardwareID(BitOR($UHID_MB, $UHID_BIOS)) & @CRLF)
ConsoleWrite('Hardware3: ' & _WinAPI_UniqueHardwareID(BitOR($UHID_MB, $UHID_BIOS, $UHID_CPU)) & @CRLF)
ConsoleWrite('Hardware4: ' & _WinAPI_UniqueHardwareID($UHID_All) & @CRLF)


Function _WinAPI_UnregisterApplicationRestart

Function Reference

_WinAPI_UnregisterApplicationRestart

Removes the active instance of an application from the restart list

#include <WinAPIDiag.au3>
_WinAPI_UnregisterApplicationRestart ( )

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

You do not need to call this function before exiting. You need to remove the registration only if you choose to
not restart the application. For example, you could remove the registration if your application entered a corrupted
state where a future restart would also fail. You must call _WinAPI_UnregisterApplicationRestart() before the
application fails abnormally.

This function requires Windows Vista or later.

Related

_WinAPI_RegisterApplicationRestart

See Also

Search UnregisterApplicationRestart in MSDN Library.


User Defined Functions

Dialog user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIDlg.au3>.

User Defined Function | Description
_WinAPI_BrowseForFolderDlg | Displays a dialog box that enables the user to select a Shell folder
_WinAPI_CommDlgExtendedErrorEx | Returns a common dialog box error code
_WinAPI_ConfirmCredentials | Confirms the validity of the credential harvested
_WinAPI_FindTextDlg | Creates a system-defined modeless Find dialog box to search for text in a document
_WinAPI_FlushFRBuffer | Destroys the internal buffer that used the _WinAPI_FindTextDlg() and _WinAPI_ReplaceTextDlg() functions
_WinAPI_FormatDriveDlg | Opens the Shell's Format dialog
_WinAPI_GetConnectedDlg | Launches the Get Connected wizard within the calling application to enable network connectivity
_WinAPI_GetFRBuffer | Retrieves the current size of the internal buffer that used the _WinAPI_FindTextDlg() and _WinAPI_ReplaceTextDlg() functions
_WinAPI_MessageBoxCheck | Displays a message box that gives the user the option of suppressing further occurrences
_WinAPI_MessageBoxIndirect | Creates, displays, and operates a message box
_WinAPI_OpenFileDlg | Creates a dialog box that lets the user specify the drive, directory, and the name of a file or set of files to be opened
_WinAPI_PageSetupDlg | Creates a Page Setup dialog box that enables the user to specify the attributes of a printed page
_WinAPI_PickIconDlg | Displays a dialog box that allows the user to choose an icon
_WinAPI_PrintDlg | Displays a Print dialog box
_WinAPI_PrintDlgEx | Displays a Print property sheet that enables the user to specify the properties of a particular print job
_WinAPI_ReplaceTextDlg | Creates a system-defined modeless dialog box that lets the user specify a string to search for and a replacement string
_WinAPI_RestartDlg | Displays a dialog box that prompts the user to restart Microsoft Windows
_WinAPI_SaveFileDlg | Creates a dialog box that lets the user specify the drive, directory, and name of a file to save
_WinAPI_SetFRBuffer | Sets the size of the internal buffer that used the _WinAPI_FindTextDlg() and _WinAPI_ReplaceTextDlg() functions
_WinAPI_ShellAboutDlg | Displays a Windows About dialog box
_WinAPI_ShellOpenWithDlg | Displays the Open With dialog box
_WinAPI_ShellStartNetConnectionDlg | Displays a general browsing dialog box for a network resource connection
_WinAPI_ShellUserAuthenticationDlg | Creates and displays a configurable dialog box that accepts credentials information from a user
_WinAPI_ShellUserAuthenticationDlgEx | Creates and displays a configurable dialog box that accepts credentials information from a user


Function _WinAPI_BrowseForFolderDlg

Function Reference

_WinAPI_BrowseForFolderDlg

Displays a dialog box that enables the user to select a Shell folder

#include <WinAPIDlg.au3>
_WinAPI_BrowseForFolderDlg ( [$sRoot = '' [, $sText = '' [, $iFlags = 0 [, $pBrowseProc = 0 [, $lParam = 0 [, $hParent = 0]]]]]] )

Parameters

$sRoot | [optional] The root folder from which to start browsing. Only the specified folder and its subfolders in the namespace hierarchy appear in the dialog box. If this parameter is 0, the namespace root (the Desktop folder) is used.
$sText | [optional] The string that is displayed above the tree view control in the dialog box.
$iFlags | [optional] Flags that specify the options for the dialog box. This parameter can a combination of the following values: $BIF_BROWSEFORCOMPUTER $BIF_BROWSEFORPRINTER $BIF_BROWSEINCLUDEFILES $BIF_BROWSEINCLUDEURLS $BIF_DONTGOBELOWDOMAIN $BIF_EDITBOX $BIF_NEWDIALOGSTYLE $BIF_NONEWFOLDERBUTTON $BIF_NOTRANSLATETARGETS $BIF_RETURNFSANCESTORS $BIF_RETURNONLYFSDIRS $BIF_SHAREABLE $BIF_STATUSTEXT $BIF_USENEWUI $BIF_UAHINT $BIF_VALIDATE Windows 7 or later $BIF_BROWSEFILEJUNCTIONS
$pBrowseProc | [optional] Pointer to a callback function that the dialog box calls when an event occurs. This function will receive one of the following event messages: $BFFM_INITIALIZED $BFFM_IUNKNOWN $BFFM_SELCHANGED $BFFM_VALIDATEFAILED (See MSDN for more information)
$lParam | [optional] The value that the dialog box passes to the callback function.
$hParent | [optional] Handle to the parent window for the dialog box.

Return Value

Success: | The full path for chosen folder, or an empty string if user cancels/closes the dialog.
Failure: | Empty string.

See Also

Search SHBrowseForFolder in MSDN Library.

Example

#include <APIDlgConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDlg.au3>
#include <WinAPISys.au3>

Local Const $sInitDir = @ProgramFilesDir

Local $hBrowseProc = DllCallbackRegister('_BrowseProc', 'int', 'hwnd;uint;lparam;ptr')
Local $pBrowseProc = DllCallbackGetPtr($hBrowseProc)

Local $pText = _WinAPI_CreateString($sInitDir)
Local $sPath = _WinAPI_BrowseForFolderDlg(_WinAPI_PathStripToRoot($sInitDir), 'Select a folder from the list below.', BitOR($BIF_RETURNONLYFSDIRS, $BIF_EDITBOX, $BIF_VALIDATE), $pBrowseProc, $pText)
_WinAPI_FreeMemory($pText)

If $sPath Then
    ConsoleWrite('--------------------------------------------------' & @CRLF)
    ConsoleWrite($sPath & @CRLF)
EndIf

DllCallbackFree($hBrowseProc)

Func _BrowseProc($hWnd, $iMsg, $wParam, $lParam)
    Local $sPath

    Switch $iMsg
        Case $BFFM_INITIALIZED
            _WinAPI_SetWindowText($hWnd, 'MyTitle')
            _SendMessage($hWnd, $BFFM_SETSELECTIONW, 1, $lParam)
        Case $BFFM_SELCHANGED
            $sPath = _WinAPI_ShellGetPathFromIDList($wParam)
            If Not @error Then
                ConsoleWrite($sPath & @CRLF)
            EndIf
        Case $BFFM_VALIDATEFAILED
            MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', _WinAPI_GetString($wParam) & ' is invalid.', 0, $hWnd)
            Return 1
    EndSwitch
    Return 0
EndFunc   ;==>_BrowseProc


Function _WinAPI_CommDlgExtendedErrorEx

Function Reference

_WinAPI_CommDlgExtendedErrorEx

Returns a common dialog box error code

#include <WinAPIDlg.au3>
_WinAPI_CommDlgExtendedErrorEx ( )

Return Value

Returns the general error codes for any of the common dialog box functions ($CDERR_*, $PDERR_*, $CFERR_*, $FNERR_*, and $FRERR_*).

Remarks

If the common dialog box function returned False because the user closed or cancelled the dialog box, the return value is zero.

See Also

Search CommDlgExtendedError in MSDN Library.


Function _WinAPI_ConfirmCredentials

Function Reference

_WinAPI_ConfirmCredentials

Confirms the validity of the credential harvested

#include <WinAPIDlg.au3>
_WinAPI_ConfirmCredentials ( $sTarget, $bConfirm )

Parameters

$sTarget | The string that contains the name of the target for the credentials, typically a domain or server name. This must be the same value passed to _WinAPI_ShellUserAuthenticationDlg() function.
$bConfirm | Specifies whether the credentials returned from the prompt function are valid, valid values: True - The credentials are stored in the credential manager. False - The credentials are not stored and various pieces of memory are cleaned up.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

This function function must be called after each successful call to _WinAPI_ShellUserAuthenticationDlg() with the $CREDUI_FLAGS_EXPECT_CONFIRMATION flag set.

Related

_WinAPI_ShellUserAuthenticationDlg

See Also

Search CredUIConfirmCredentials in MSDN Library.

Example

#include <APIDlgConstants.au3>
#include <Crypt.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIDlg.au3>

Local $hBitmap = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Authentication.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Local $aData[3] = ['', '', 0]

While 1
    $aData = _WinAPI_ShellUserAuthenticationDlg('Authentication', 'To continue, type a login and password, and then click OK.', $aData[0], $aData[1], 'MyScript', BitOR($CREDUI_FLAGS_ALWAYS_SHOW_UI, $CREDUI_FLAGS_EXPECT_CONFIRMATION, $CREDUI_FLAGS_GENERIC_CREDENTIALS, $CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX), 0, $aData[2], $hBitmap)
    If @error Then Exit

    If (StringCompare($aData[0], 'AutoIt')) Or (StringCompare($aData[1], StringEncrypt(False, 'DC7E430A1C88', '123'))) Then
        If $aData[2] Then
            _WinAPI_ConfirmCredentials('MyScript', 0)
        EndIf
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'You have typed an incorrect login or password, it should be "AutoIt" and "123".')
    Else
        If $aData[2] Then
            _WinAPI_ConfirmCredentials('MyScript', 1)
        EndIf
        ExitLoop
    EndIf
WEnd

Func StringEncrypt($bEncrypt, $sData, $sPassword)
    _Crypt_Startup() ; Start the Crypt library.
    Local $sReturn = ''
    If $bEncrypt Then ; If the flag is set to True then encrypt, otherwise decrypt.
        $sReturn = _Crypt_EncryptData($sData, $sPassword, $CALG_RC4)
    Else
        $sReturn = BinaryToString(_Crypt_DecryptData($sData, $sPassword, $CALG_RC4))
    EndIf
    _Crypt_Shutdown() ; Shutdown the Crypt library.
    Return $sReturn
EndFunc   ;==>StringEncrypt


Function _WinAPI_FindTextDlg

Function Reference

_WinAPI_FindTextDlg

Creates a system-defined modeless Find dialog box to search for text in a document

#include <WinAPIDlg.au3>
_WinAPI_FindTextDlg ( $hOwner [, $sFindWhat = '' [, $iFlags = 0 [, $pFindProc = 0 [, $lParam = 0]]]] )

Parameters

$hOwner | A handle to the window that owns the dialog box. The window procedure of the specified window receives FINDMSGSTRING messages from the dialog box. This parameter can be any valid window handle, but it must not be 0.
$sFindWhat | [optional] The search string that is displayed when you initialize the dialog box.
$iFlags | [optional] A set of bit flags that used to initialize the dialog box. The dialog box sets these flags when it sends the FINDMSGSTRING registered message to indicate the user's input. This parameter can be one or more of the following values. $FR_DIALOGTERM $FR_DOWN $FR_ENABLEHOOK $FR_ENABLETEMPLATE $FR_ENABLETEMPLATEHANDLE $FR_FINDNEXT $FR_HIDEUPDOWN $FR_HIDEMATCHCASE $FR_HIDEWHOLEWORD $FR_MATCHCASE $FR_NOMATCHCASE $FR_NOUPDOWN $FR_NOWHOLEWORD $FR_REPLACE $FR_REPLACEALL $FR_SHOWHELP $FR_WHOLEWORD
$pFindProc | [optional] Pointer to an hook procedure that can process messages intended for the dialog box. This parameter is ignored unless the $FR_ENABLEHOOK flag is not set. (See MSDN for more information)
$lParam | [optional] Application-defined data that the system passes to the hook procedure.

Return Value

Success: | The window handle to the dialog box.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the dialog box error code.

Remarks

The _WinAPI_FindTextDlg() does not perform a search operation. Instead, the dialog box sends FINDMSGSTRING registered messages to the window procedure of the owner window of the dialog box.

Before calling _WinAPI_FindTextDlg(), you must call the _WinAPI_RegisterWindowMessage() function to get the identifier for the FINDMSGSTRING message. The dialog box procedure uses this identifier to send messages when the user clicks the "Find Next" button, or when the dialog box is closing. The "lParam" parameter of the FINDMSGSTRING message contains a pointer to a $tagFINDREPLACE structure. The "Flags" member of this structure indicates the event that caused the message. Other members of the structure indicate the user's input.

The _WinAPI_FindTextDlg() uses an internal buffer to hold the string that the user typed in the "Find What" edit controls. You can increase the size of this buffer by using the _WinAPI_SetFRBuffer() function. In addition to free the memory allocated for the internal buffer, you must call the _WinAPI_FlushFRBuffer() in response to the FINDMSGSTRING message with $FR_DIALOGTERM flag set.

Related

_WinAPI_FlushFRBuffer, _WinAPI_RegisterWindowMessage, _WinAPI_SetFRBuffer

See Also

Search FindText in MSDN Library.

Example

#include <APIDlgConstants.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIRichEdit.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDlg.au3>
#include <WindowsConstants.au3>

Local Const $e_sText = 'AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying "runtimes" required!' & @CRLF & @CRLF & _
        'AutoIt was initially designed for PC "roll out" situations to reliably automate and configure thousands of PCs. Over time it has become a powerful language that supports complex expressions, user functions, loops and everything else that veteran scripters would expect.'

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 800, 600)

; Create main menu
Local $idMenu = GUICtrlCreateMenu('&File')
Local $idExitItem = GUICtrlCreateMenuItem('E&xit...', $idMenu)
$idMenu = GUICtrlCreateMenu('&Edit')
Local $idFindItem = GUICtrlCreateMenuItem('&Find...', $idMenu)
Local $idReplaceItem = GUICtrlCreateMenuItem('R&eplace...', $idMenu)

; Create Rich Edit control with always visible text selection, and set "Courier New" font to the control
Local $hRichEdit = _GUICtrlRichEdit_Create($hForm, $e_sText, 0, 0, 800, 600, BitOR($ES_AUTOVSCROLL, $ES_NOHIDESEL, $ES_MULTILINE, $WS_VSCROLL), 0)
Local $hFont = _WinAPI_CreateFont(17, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, 'Courier New')
_SendMessage($hRichEdit, $WM_SETFONT, $hFont, 1)
_SendMessage($hRichEdit, $EM_SETSEL)

; Register FINDMSGSTRING message to receive the messages from the dialog box
GUIRegisterMsg(_WinAPI_RegisterWindowMessage('commdlg_FindReplace'), 'WM_FINDMSGSTRING')

; Show GUI
GUISetState(@SW_SHOW)

Global $g_hDlg
Local $iMsg, $sText
While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE, $idExitItem
            ExitLoop
        Case $idFindItem, $idReplaceItem
            $sText = _GUICtrlRichEdit_GetSelText($hRichEdit)
            If @error Then
                $sText = ''
            EndIf
            ; Disable "Find..." and "Replace..." menu items, otherwise, the script maay crash
            GUICtrlSetState($idFindItem, $GUI_DISABLE)
            GUICtrlSetState($idReplaceItem, $GUI_DISABLE)
            Switch $iMsg
                Case $idFindItem
                    $g_hDlg = _WinAPI_FindTextDlg($hForm, $sText, $FR_DOWN, 0, $hRichEdit)
                Case $idReplaceItem
                    $g_hDlg = _WinAPI_ReplaceTextDlg($hForm, $sText, '', 0, 0, $hRichEdit)
            EndSwitch
        Case $idReplaceItem
    EndSwitch
WEnd

GUIDelete()

Func _IsMatchSelection($hWnd, $sText, $iBehavior)
    Local $aPos = _GUICtrlRichEdit_GetSel($hWnd)
    If @error Then Return 0

    $aPos = _GUICtrlRichEdit_FindTextInRange($hWnd, $sText, $aPos[0], $aPos[1], BitAND($iBehavior, $FR_MATCHCASE) = $FR_MATCHCASE, BitAND($iBehavior, $FR_WHOLEWORD) = $FR_WHOLEWORD, BitAND($iBehavior, BitOR($FR_MATCHALEFHAMZA, $FR_MATCHDIAC, $FR_MATCHKASHIDA)))
    If @error Or ($aPos[0] = -1) Or ($aPos[1] = -1) Then
        Return 0
    Else
        Return 1
    EndIf
EndFunc   ;==>_IsMatchSelection

Func WM_FINDMSGSTRING($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam

    Local $tFINDREPLACE = DllStructCreate($tagFINDREPLACE, $lParam)
    Local $sReplace = _WinAPI_GetString(DllStructGetData($tFINDREPLACE, 'ReplaceWith'))
    Local $sFind = _WinAPI_GetString(DllStructGetData($tFINDREPLACE, 'FindWhat'))
    Local $hRichEdit = Ptr(DllStructGetData($tFINDREPLACE, 'lParam'))
    Local $iFlags = DllStructGetData($tFINDREPLACE, 'Flags')
    Local $aPos, $iCur = -1

    Select
        ; The user clicked the "Replace" button in a Replace dialog box
        Case BitAND($iFlags, $FR_REPLACE)
            If _IsMatchSelection($hRichEdit, $sFind, $iFlags) Then
                _GUICtrlRichEdit_ReplaceText($hRichEdit, $sReplace)
            EndIf
            ContinueCase
            ; The user clicked the "Find Next" button in a Find or Replace dialog box
        Case BitAND($iFlags, $FR_FINDNEXT)
            $aPos = _GUICtrlRichEdit_GetSel($hRichEdit)
            If @error Then Return

            If BitAND($iFlags, $FR_DOWN) Then
                $aPos = _GUICtrlRichEdit_FindTextInRange($hRichEdit, $sFind, $aPos[1], -1, BitAND($iFlags, $FR_MATCHCASE) = $FR_MATCHCASE, BitAND($iFlags, $FR_WHOLEWORD) = $FR_WHOLEWORD)
            Else
                $aPos = _GUICtrlRichEdit_FindTextInRange($hRichEdit, $sFind, $aPos[0], 0, BitAND($iFlags, $FR_MATCHCASE) = $FR_MATCHCASE, BitAND($iFlags, $FR_WHOLEWORD) = $FR_WHOLEWORD, BitAND($iFlags, $FR_DOWN))
            EndIf
            If @error Or ($aPos[0] = -1) Or ($aPos[1] = -1) Then
                Local $iError = @error
                MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), WinGetTitle($g_hDlg), 'Cannot find "' & $sFind & '" (' & $iError & ')', 0, $g_hDlg)
                Return
            EndIf
            ; Here and below used the EM_SETSEL message directly because _GUICtrlRichEdit_SetSel() sets a focus to the Rich Edit control
            _SendMessage($hRichEdit, $EM_SETSEL, $aPos[0], $aPos[1])
            ;           _GUICtrlRichEdit_ScrollToCaret($hRichEdit)
            ; The user clicked the "Replace All" button in a Replace dialog box
        Case BitAND($iFlags, $FR_REPLACEALL)
            Dim $aPos[2] = [0, -1]
            While 1
                $aPos = _GUICtrlRichEdit_FindTextInRange($hRichEdit, $sFind, $aPos[0], -1, BitAND($iFlags, $FR_MATCHCASE) = $FR_MATCHCASE, BitAND($iFlags, $FR_WHOLEWORD) = $FR_WHOLEWORD)
                If ($aPos[0] = -1) Or ($aPos[1] = -1) Then
                    If $iCur = -1 Then
                        MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), WinGetTitle($g_hDlg), 'Cannot find "' & $sFind & '"', 0, $g_hDlg)
                        Return
                    EndIf
                    ExitLoop
                EndIf
                If $iCur = -1 Then
                    _GUICtrlRichEdit_PauseRedraw($hRichEdit)
                EndIf
                _SendMessage($hRichEdit, $EM_SETSEL, $aPos[0], $aPos[1])
                If _GUICtrlRichEdit_ReplaceText($hRichEdit, $sReplace) Then
                    $iCur = $aPos[0] + StringLen($sReplace)
                Else
                    ExitLoop
                EndIf
            WEnd
            _SendMessage($hRichEdit, $EM_SETSEL, $iCur, $iCur)
            ;           _GUICtrlRichEdit_ScrollToCaret($hRichEdit)
            _GUICtrlRichEdit_ResumeRedraw($hRichEdit)
            ; The dialog box is closing
        Case BitAND($iFlags, $FR_DIALOGTERM)
            ; Destroy internal buffer, and free allocated memory
            _WinAPI_FlushFRBuffer()
            ; Enable "Find..." and "Replace..." menu items
            GUICtrlSetState($idReplaceItem, $GUI_ENABLE)
            GUICtrlSetState($idFindItem, $GUI_ENABLE)
    EndSelect
EndFunc   ;==>WM_FINDMSGSTRING


Function _WinAPI_FlushFRBuffer

Function Reference

_WinAPI_FlushFRBuffer

Destroys the internal buffer that used the _WinAPI_FindTextDlg() and _WinAPI_ReplaceTextDlg() functions

#include <WinAPIDlg.au3>
_WinAPI_FlushFRBuffer ( )

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

The _WinAPI_FlushFRBuffer() can be called only in response to the FINDMSGSTRING message with $FR_DIALOGTERM flag set.
For more information, see _WinAPI_FindTextDlg() and _WinAPI_ReplaceTextDlg() functions.

Related

_WinAPI_FindTextDlg, _WinAPI_ReplaceTextDlg, _WinAPI_SetFRBuffer

Example

#include <APIDlgConstants.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIRichEdit.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDlg.au3>
#include <WindowsConstants.au3>

Local Const $sTxt = 'AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying "runtimes" required!' & @CRLF & @CRLF & _
        'AutoIt was initially designed for PC "roll out" situations to reliably automate and configure thousands of PCs. Over time it has become a powerful language that supports complex expressions, user functions, loops and everything else that veteran scripters would expect.'

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 800, 600)

; Create main menu
Local $idMenu = GUICtrlCreateMenu('&File')
Local $idExitItem = GUICtrlCreateMenuItem('E&xit...', $idMenu)
$idMenu = GUICtrlCreateMenu('&Edit')
Local $idFindItem = GUICtrlCreateMenuItem('&Find...', $idMenu)
Local $idReplaceItem = GUICtrlCreateMenuItem('R&eplace...', $idMenu)

; Create Rich Edit control with always visible text selection, and set "Courier New" font to the control
Local $hRichEdit = _GUICtrlRichEdit_Create($hForm, $sTxt, 0, 0, 800, 600, BitOR($ES_AUTOVSCROLL, $ES_NOHIDESEL, $ES_MULTILINE, $WS_VSCROLL), 0)
Local $hFont = _WinAPI_CreateFont(17, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, 'Courier New')
_SendMessage($hRichEdit, $WM_SETFONT, $hFont, 1)
_SendMessage($hRichEdit, $EM_SETSEL)

; Register FINDMSGSTRING message to receive the messages from the dialog box
GUIRegisterMsg(_WinAPI_RegisterWindowMessage('commdlg_FindReplace'), 'WM_FINDMSGSTRING')

; Show GUI
GUISetState(@SW_SHOW)

Global $g_hDlg
Local $iMsg, $sText
While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE, $idExitItem
            ExitLoop
        Case $idFindItem, $idReplaceItem
            $sText = _GUICtrlRichEdit_GetSelText($hRichEdit)
            If @error Then
                $sText = ''
            EndIf
            ; Disable "Find..." and "Replace..." menu items, otherwise, the script maay crash
            GUICtrlSetState($idFindItem, $GUI_DISABLE)
            GUICtrlSetState($idReplaceItem, $GUI_DISABLE)
            Switch $iMsg
                Case $idFindItem
                    $g_hDlg = _WinAPI_FindTextDlg($hForm, $sText, $FR_DOWN, 0, $hRichEdit)
                Case $idReplaceItem
                    $g_hDlg = _WinAPI_ReplaceTextDlg($hForm, $sText, '', 0, 0, $hRichEdit)
            EndSwitch
        Case $idReplaceItem
    EndSwitch
WEnd

GUIDelete()

Func _IsMatchSelection($hWnd, $sText, $iBehavior)
    Local $aPos = _GUICtrlRichEdit_GetSel($hWnd)
    If @error Then Return 0

    $aPos = _GUICtrlRichEdit_FindTextInRange($hWnd, $sText, $aPos[0], $aPos[1], BitAND($iBehavior, $FR_MATCHCASE) = $FR_MATCHCASE, BitAND($iBehavior, $FR_WHOLEWORD) = $FR_WHOLEWORD, BitAND($iBehavior, BitOR($FR_MATCHALEFHAMZA, $FR_MATCHDIAC, $FR_MATCHKASHIDA)))
    If @error Or ($aPos[0] = -1) Or ($aPos[1] = -1) Then
        Return 0
    Else
        Return 1
    EndIf
EndFunc   ;==>_IsMatchSelection

Func WM_FINDMSGSTRING($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam

    Local $tFINDREPLACE = DllStructCreate($tagFINDREPLACE, $lParam)
    Local $sReplace = _WinAPI_GetString(DllStructGetData($tFINDREPLACE, 'ReplaceWith'))
    Local $sFind = _WinAPI_GetString(DllStructGetData($tFINDREPLACE, 'FindWhat'))
    Local $hRichEdit = Ptr(DllStructGetData($tFINDREPLACE, 'lParam'))
    Local $iFlags = DllStructGetData($tFINDREPLACE, 'Flags')
    Local $aPos, $iCur = -1

    Select
        ; The user clicked the "Replace" button in a Replace dialog box
        Case BitAND($iFlags, $FR_REPLACE)
            If _IsMatchSelection($hRichEdit, $sFind, $iFlags) Then
                _GUICtrlRichEdit_ReplaceText($hRichEdit, $sReplace)
            EndIf
            ContinueCase
            ; The user clicked the "Find Next" button in a Find or Replace dialog box
        Case BitAND($iFlags, $FR_FINDNEXT)
            $aPos = _GUICtrlRichEdit_GetSel($hRichEdit)
            If @error Then Return

            If BitAND($iFlags, $FR_DOWN) Then
                $aPos = _GUICtrlRichEdit_FindTextInRange($hRichEdit, $sFind, $aPos[1], -1, BitAND($iFlags, $FR_MATCHCASE) = $FR_MATCHCASE, BitAND($iFlags, $FR_WHOLEWORD) = $FR_WHOLEWORD)
            Else
                $aPos = _GUICtrlRichEdit_FindTextInRange($hRichEdit, $sFind, $aPos[0], 0, BitAND($iFlags, $FR_MATCHCASE) = $FR_MATCHCASE, BitAND($iFlags, $FR_WHOLEWORD) = $FR_WHOLEWORD, BitAND($iFlags, $FR_DOWN))
            EndIf
            If @error Or ($aPos[0] = -1) Or ($aPos[1] = -1) Then
                Local $iError = @error
                MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), WinGetTitle($g_hDlg), 'Cannot find "' & $sFind & '" (' & $iError & ')', 0, $g_hDlg)
                Return
            EndIf
            ; Here and below used the EM_SETSEL message directly because _GUICtrlRichEdit_SetSel() sets a focus to the Rich Edit control
            _SendMessage($hRichEdit, $EM_SETSEL, $aPos[0], $aPos[1])
            ;           _GUICtrlRichEdit_ScrollToCaret($hRichEdit)
            ; The user clicked the "Replace All" button in a Replace dialog box
        Case BitAND($iFlags, $FR_REPLACEALL)
            Dim $aPos[2] = [0, -1]
            While 1
                $aPos = _GUICtrlRichEdit_FindTextInRange($hRichEdit, $sFind, $aPos[0], -1, BitAND($iFlags, $FR_MATCHCASE) = $FR_MATCHCASE, BitAND($iFlags, $FR_WHOLEWORD) = $FR_WHOLEWORD)
                If ($aPos[0] = -1) Or ($aPos[1] = -1) Then
                    If $iCur = -1 Then
                        MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), WinGetTitle($g_hDlg), 'Cannot find "' & $sFind & '"', 0, $g_hDlg)
                        Return
                    EndIf
                    ExitLoop
                EndIf
                If $iCur = -1 Then
                    _GUICtrlRichEdit_PauseRedraw($hRichEdit)
                EndIf
                _SendMessage($hRichEdit, $EM_SETSEL, $aPos[0], $aPos[1])
                If _GUICtrlRichEdit_ReplaceText($hRichEdit, $sReplace) Then
                    $iCur = $aPos[0] + StringLen($sReplace)
                Else
                    ExitLoop
                EndIf
            WEnd
            _SendMessage($hRichEdit, $EM_SETSEL, $iCur, $iCur)
            ;           _GUICtrlRichEdit_ScrollToCaret($hRichEdit)
            _GUICtrlRichEdit_ResumeRedraw($hRichEdit)
            ; The dialog box is closing
        Case BitAND($iFlags, $FR_DIALOGTERM)
            ; Destroy internal buffer, and free allocated memory
            _WinAPI_FlushFRBuffer()
            ; Enable "Find..." and "Replace..." menu items
            GUICtrlSetState($idReplaceItem, $GUI_ENABLE)
            GUICtrlSetState($idFindItem, $GUI_ENABLE)
    EndSelect
EndFunc   ;==>WM_FINDMSGSTRING


Function _WinAPI_FormatDriveDlg

Function Reference

_WinAPI_FormatDriveDlg

Opens the Shell's Format dialog

#include <WinAPIDlg.au3>
_WinAPI_FormatDriveDlg ( $sDrive [, $iOption = 0 [, $hParent = 0]] )

Parameters

$sDrive | The drive to format, in the format D:, E:, etc.
$iOption | [optional] This parameter must be 0 or one of the following values that alter the default format options in the dialog. $SHFMT_OPT_FULL (Default) $SHFMT_OPT_QUICKFORMAT $SHFMT_OPT_SYSONLY
$hParent | [optional] Handle of the parent window of the dialog.

Return Value

Success: | The format ID of the last successful format. The LOWORD of this value can be passed on subsequent calls as the fmtID parameter to repeat the last format.
Failure: | 0 and sets the @error flag to one of the following constant. $SHFMT_ERROR $SHFMT_CANCEL $SHFMT_NOFORMAT

Remarks

The format is controlled by the dialog interface.
That is, the user must click the OK button to actually begin the format—the format cannot be started programmatically.

See Also

Search SHFormatDrive in MSDN Library.

Example

#include <Array.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIDlg.au3>

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 200, 100)
Local $vDrive = DriveGetDrive('ALL')
$vDrive = StringUpper(_ArrayToString($vDrive, '|', 1))
GUICtrlCreateLabel('Select drive:', 15, 29, 62, 14)
Local $idCombo = GUICtrlCreateCombo('', 79, 25, 40, 21, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, $vDrive, StringLeft($vDrive, 2))
Local $idButton = GUICtrlCreateButton('Format...', 65, 70, 70, 23)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            _WinAPI_FormatDriveDlg(GUICtrlRead($idCombo), 0, $hForm)
    EndSwitch
WEnd


Function _WinAPI_GetConnectedDlg

Function Reference

_WinAPI_GetConnectedDlg

Launches the Get Connected wizard within the calling application to enable network connectivity

#include <WinAPIDlg.au3>
_WinAPI_GetConnectedDlg ( $iDlg [, $iFlags = 0 [, $hParent = 0]] )

Parameters

$iDlg | Specifies which the dialog should be launched, valid values: 0 - Local area network connectivity. 1 - Internet connectivity. 2 - Virtual private network (VPN) connectivity.
$iFlags | [optional] Specifies an additional options. This parameter can be one or more of the following values. 0 - Default. 1 - Do not display the Get Connected wizard page that shows whether or not the user has a working or active Internet connection. 2 - Do not display the Get Connected wizard page that shows a list of existing internet connections. 4 - Hide the finish page of the Get Connected wizard.
$hParent | [optional] Handle to the parent window that called this API.

Return Value

Success: | 1 - The Internet is connected. 0 - Otherwise.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPIDlg.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

If _WinAPI_IsInternetConnected() Then
    ConsoleWrite('Internet is already connected.' & @CRLF)
    Exit
EndIf

; Launch the Get Connected wizard within the calling application to enable Internet connectivity
_WinAPI_GetConnectedDlg(1, 1 + 4)


Function _WinAPI_GetFRBuffer

Function Reference

_WinAPI_GetFRBuffer

Retrieves the current size of the internal buffer that used the _WinAPI_FindTextDlg() and _WinAPI_ReplaceTextDlg() functions

#include <WinAPIDlg.au3>
_WinAPI_GetFRBuffer ( )

Return Value

Returns the size, in TCHARs, of the internal buffer.


Function _WinAPI_MessageBoxCheck

Function Reference

_WinAPI_MessageBoxCheck

Displays a message box that gives the user the option of suppressing further occurrences

#include <WinAPIDlg.au3>
_WinAPI_MessageBoxCheck ( $iType, $sTitle, $sText, $sRegVal [, $iDefault = -1 [, $hParent = 0]] )

Parameters

$iType | The flags that specify the contents and behavior of the message box. You must specify the buttons to be displayed by setting one and only one of the following flags. $MB_OK $MB_OKCANCEL $MB_YESNO You can display an optional icon by setting one and only one of the following flags. $MB_ICONEXCLAMATION $MB_ICONHAND $MB_ICONINFORMATION $MB_ICONQUESTION
$sTitle | The string that contains the title of the message box.
$sText | The string that contains the message to be displayed.
$sRegVal | The string that contains a unique string value to associate with this message.
$iDefault | [optional] The value that the function returns when the user has opted not to have the message box displayed again. If the user has not opted to suppress the message box, the message box is displayed and the function ignores $iDefault.
$hParent | [optional] The window handle to the message box's owner.

Return Value

Success: | If the user has already chosen to suppress the message box, the function immediately returns the value assigned to $iDefault, otherwise, returns one of the $ID_* constants.
Failure: | (-1).

Remarks

This function records the message boxes that the user has chosen to suppress under the following registry key.

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\LowRegistry\DontShowMeThisDialogAgain

See Also

Search SHMessageBoxCheck in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIDlg.au3>

Local $iResult = _WinAPI_MessageBoxCheck($MB_ICONINFORMATION, 'MyProg', '_WinAPI_MessageBoxCheck()', 'MyProg')

ConsoleWrite('Return: ' & $iResult & @CRLF)


Function _WinAPI_MessageBoxIndirect

Function Reference

_WinAPI_MessageBoxIndirect

Creates, displays, and operates a message box

#include <WinAPIDlg.au3>
_WinAPI_MessageBoxIndirect ( $tMSGBOXPARAMS )

Parameters

$tMSGBOXPARAMS $tagMSGBOXPARAMS structure that contains information used to display the message box.

Return Value

Success: | One of the $ID* constants.
Failure: | 0.

Remarks

When you use a system-modal message box to indicate that the system is low on memory, the strings pointed to by the
"Text" and "Caption" members of the $tagMSGBOXPARAMS structure should not be taken from a resource file, because
an attempt to load the resource may fail.

If you create a message box while a dialog box is present, use a handle to the dialog box as the hWnd parameter.
The hWnd parameter should not identify a child window, such as a control in a dialog box.

See Also

Search MessageBoxIndirect in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIDlg.au3>

Local Const $sTitle = 'Message'
Local Const $sText = 'This is a simple message box with a custom icon.'

Local $tMBP = DllStructCreate($tagMSGBOXPARAMS & ';wchar szCaption[' & (StringLen($sTitle) + 1) & '];wchar szText[' & (StringLen($sText) + 1) & ']')
DllStructSetData($tMBP, 'Size', DllStructGetPtr($tMBP, 'szCaption') - DllStructGetPtr($tMBP))
DllStructSetData($tMBP, 'hOwner', 0)
DllStructSetData($tMBP, 'hInstance', _WinAPI_GetModuleHandle(@SystemDir & '\shell32.dll'))
DllStructSetData($tMBP, 'Text', DllStructGetPtr($tMBP, 'szText'))
DllStructSetData($tMBP, 'Caption', DllStructGetPtr($tMBP, 'szCaption'))
DllStructSetData($tMBP, 'Style', BitOR($MB_OKCANCEL, $MB_USERICON))
DllStructSetData($tMBP, 'Icon', 239)
DllStructSetData($tMBP, 'ContextHelpId', 0)
DllStructSetData($tMBP, 'MsgBoxCallback', 0)
DllStructSetData($tMBP, 'LanguageId', 0)
DllStructSetData($tMBP, 'szCaption', $sTitle)
DllStructSetData($tMBP, 'szText', $sText)

Local $iResult = _WinAPI_MessageBoxIndirect($tMBP)

ConsoleWrite('Return: ' & $iResult & @CRLF)


Function _WinAPI_OpenFileDlg

Function Reference

_WinAPI_OpenFileDlg

Creates a dialog box that lets the user specify the drive, directory, and the name of a file or set of files to be opened

#include <WinAPIDlg.au3>
_WinAPI_OpenFileDlg ( [$sTitle = '' [, $sInitDir = '' [, $sFilters = '' [, $iDefaultFilter = 0 [, $sDefaultFilePath = '' [, $sDefaultExt = '' [, $iFlags = 0 [, $iFlagsEx = 0 [, $pOFNProc = 0 [, $pData = 0 [, $hParent = 0]]]]]]]]]]] )

Parameters

$sTitle | [optional] A string to be placed in the title bar of the dialog box. If this parameter is empty string (Default), the system uses the default title (that is, "Open").
$sInitDir | [optional] The initial directory.
$sFilters | [optional] The pairs of filter strings (for example, "Text Files (*.txt)"). To specify multiple filter patterns for a single display string, use a semicolon to separate the patterns (for example, "*.txt;*.doc;*.bak"). Do not include spaces in the pattern. To specify multiple groups of filters, use the "|" character as a delimiter (for example, "Text Files (*.txt)|All Files (*.*)"). If this parameter is omitted or an empty string (Default), the dialog box does not display any filters.
$iDefaultFilter | [optional] The 1-based index of the currently selected filter to initialize the combo box control.
$sDefaultFilePath | [optional] The file name to initialize the edit control.
$sDefaultExt | [optional] The default extension that appends to the file name if the user fails to type an extension. This string can be any length, but only the first three characters are appended. The string should not contain a period (.). If this parameter is empty string (Default), no extension is appended.
$iFlags | [optional] A set of bit flags you can use to initialize the dialog box. This parameter can be 0 or combination of the following values. $OFN_ALLOWMULTISELECT $OFN_CREATEPROMPT $OFN_DONTADDTORECENT $OFN_ENABLEHOOK $OFN_ENABLEINCLUDENOTIFY $OFN_ENABLESIZING $OFN_EXPLORER $OFN_FILEMUSTEXIST $OFN_FORCESHOWHIDDEN $OFN_HIDEREADONLY $OFN_LONGNAMES $OFN_NODEREFERENCELINKS $OFN_NOLONGNAMES $OFN_NONETWORKBUTTON $OFN_NOREADONLYRETURN $OFN_NOTESTFILECREATE $OFN_NOVALIDATE $OFN_PATHMUSTEXIST $OFN_READONLY $OFN_SHAREAWARE $OFN_SHOWHELP
$iFlagsEx | [optional] A set of bit flags you can use to initialize the dialog box. It can be 0 or the following value: $OFN_EX_NOPLACESBAR
$pOFNProc | [optional] A pointer to a hook procedure. This parameter is ignored unless the $OFN_ENABLEHOOK flag is set.
$pData | [optional] Application-defined data pointer that the system passes to the hook procedure.
$hParent | [optional] A handle to the parent window for the dialog box.

Return Value

Success: | the full path of the input file if the $OFN_ALLOWMULTISELECT flag is not set, otherwise always an array of paths. The zeroth array element contains the number of files.
Failure: | sets the @error flag to non-zero, @extended flag may contain the dialog box error code ($CDERR_* or $FNERR_*).

Remarks

Call _WinAPI_GetExtended() to retrieve internal $tagOPENFILENAME structure containing the user's selection information after closing the dialog box.

If you use a hook, you can not preserve the UI of the dialog box like in Windows Vista or later.

Related

_WinAPI_GetExtended

See Also

Search GetOpenFileName in MSDN Library.

Example

#include <WinAPI.au3>
#include <WinAPIDlg.au3>

; Single file selection (returns the fully qualified path)
Local $sFile = _WinAPI_OpenFileDlg('', @WorkingDir, 'AutoIt v3 Scripts (*.au3)|All Files (*.*)', 1, '', '', BitOR($OFN_PATHMUSTEXIST, $OFN_FILEMUSTEXIST, $OFN_HIDEREADONLY))
If Not @error Then
    ConsoleWrite($sFile & @CRLF)
EndIf

; Multiple file selection (returns an array)
$sFile = _WinAPI_OpenFileDlg('', @WorkingDir, 'AutoIt v3 Scripts (*.au3)|All Files (*.*)', 1, '', '', BitOR($OFN_PATHMUSTEXIST, $OFN_FILEMUSTEXIST, $OFN_HIDEREADONLY, $OFN_ALLOWMULTISELECT, $OFN_EXPLORER))
If Not @error Then
    ConsoleWrite('--------------------------------------------------' & @CRLF)
    For $i = 1 To $sFile[0]
        ConsoleWrite($sFile[$i] & @CRLF)
    Next
EndIf


Function _WinAPI_PageSetupDlg

Function Reference

_WinAPI_PageSetupDlg

Creates a Page Setup dialog box that enables the user to specify the attributes of a printed page

#include <WinAPIDlg.au3>
_WinAPI_PageSetupDlg ( ByRef $tPAGESETUPDLG )

Parameters

$tPAGESETUPDLG $tagPAGESETUPDLG structure that contains information used to initialize the Page Setup dialog box.
The structure receives information about the user's selections when the function returns,
and must be initialized before function call.
(See MSDN for more information)

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended flag may contain the dialog box error code.

Remarks

Note that the values of "hDevMode" and "hDevNames" member in $tagPAGESETUPDLG may change when they are passed into
_WinAPI_PageSetupDlg(). This is because these members are filled on both input and output.

Starting with Windows Vista, the _WinAPI_PageSetupDlg() does not contain the "Printer" button. To switch printer
selection, use _WinAPI_PrintDlg() or _WinAPI_PrintDlgEx().

Related

_WinAPI_PrintDlg, _WinAPI_PrintDlgEx

See Also

Search PageSetupDlg in MSDN Library.

Example

#include <APIDlgConstants.au3>
#include <Memory.au3>
#include <WinAPIDlg.au3>

; Create PAGESETUPDLG structure and set initial margin values for 10.00 mm at all
Local $tPAGESETUPDLG = DllStructCreate($tagPAGESETUPDLG)
DllStructSetData($tPAGESETUPDLG, 'Size', DllStructGetSize($tPAGESETUPDLG))
DllStructSetData($tPAGESETUPDLG, 'Flags', BitOR($PSD_INHUNDREDTHSOFMILLIMETERS, $PSD_MARGINS))
DllStructSetData($tPAGESETUPDLG, 'MarginLeft', 10 * 100)
DllStructSetData($tPAGESETUPDLG, 'MarginTop', 10 * 100)
DllStructSetData($tPAGESETUPDLG, 'MarginRight', 10 * 100)
DllStructSetData($tPAGESETUPDLG, 'MarginBottom', 10 * 100)

; Create Page Setup dialog box
If Not _WinAPI_PageSetupDlg($tPAGESETUPDLG) Then
    Exit
EndIf

; Show results
ConsoleWrite('Paper width: ' & DllStructGetData($tPAGESETUPDLG, 'PaperWidth') / 100 & ' mm' & @CRLF)
ConsoleWrite('Paper height: ' & DllStructGetData($tPAGESETUPDLG, 'PaperHeight') / 100 & ' mm' & @CRLF)
ConsoleWrite('Margin left: ' & DllStructGetData($tPAGESETUPDLG, 'MarginLeft') / 100 & ' mm' & @CRLF)
ConsoleWrite('Margin top: ' & DllStructGetData($tPAGESETUPDLG, 'MarginTop') / 100 & ' mm' & @CRLF)
ConsoleWrite('Margin right: ' & DllStructGetData($tPAGESETUPDLG, 'MarginRight') / 100 & ' mm' & @CRLF)
ConsoleWrite('Margin bottom: ' & DllStructGetData($tPAGESETUPDLG, 'MarginBottom') / 100 & ' mm' & @CRLF)

; Free global memory objects that contains a DEVMODE and DEVNAMES structures
_MemGlobalFree(DllStructGetData($tPAGESETUPDLG, 'hDevMode'))
_MemGlobalFree(DllStructGetData($tPAGESETUPDLG, 'hDevNames'))


Function _WinAPI_PickIconDlg

Function Reference

_WinAPI_PickIconDlg

Displays a dialog box that allows the user to choose an icon

#include <WinAPIDlg.au3>
_WinAPI_PickIconDlg ( [$sIcon = '' [, $iIndex = 0 [, $hParent = 0]]] )

Parameters

$sIcon | [optional] The fully-qualified path of the file that contains the initial icon.
$iIndex | [optional] The index of the initial icon. Default is 0.
$hParent | [optional] Handle of the parent window.

Return Value

Success: | The array containing the following information: [0] - The path of the file that contains the selected icon. [1] - The index of the selected icon.
Failure: | Sets the @error flag to non-zero.

Remarks

This function also sets the @error flag to 1 if the icon was not selected.

See Also

Search PickIconDlg in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <WinAPIDlg.au3>

Local $aLast[2] = [@SystemDir & '\shell32.dll', 3]

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 160, 160)
Local $idButton = GUICtrlCreateButton('Change Icon...', 25, 130, 110, 23)
Local $idIcon = GUICtrlCreateIcon($aLast[0], -(1 + $aLast[1]), 64, 54, 32, 32)
GUISetState(@SW_SHOW)

Local $aData
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            $aData = _WinAPI_PickIconDlg($aLast[0], $aLast[1], $hForm)
            If IsArray($aData) Then
                GUICtrlSetImage($idIcon, $aData[0], -(1 + $aData[1]))
                $aLast = $aData
            EndIf
    EndSwitch
WEnd


Function _WinAPI_PrintDlg

Function Reference

_WinAPI_PrintDlg

Displays a Print dialog box

#include <WinAPIDlg.au3>
_WinAPI_PrintDlg ( ByRef $tPRINTDLG )

Parameters

$tPRINTDLG $tagPRINTDLG structure that contains information used to initialize the dialog box. When the function
returns, it contains information about the user's selections. This structure must be initialized
before function call.
(See MSDN for more information)

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended flag may contain the dialog box error code.

Remarks

Note that the values of "hDevMode" and "hDevNames" member in $tagPRINTDLG may change when they are passed into
_WinAPI_PrintDlg(). This is because these members are filled on both input and output.

See Also

Search PrintDlg in MSDN Library.

Example

#include <APIDlgConstants.au3>
#include <Memory.au3>
#include <WinAPIDlg.au3>
#include <WinAPIFiles.au3>

; Create PRINTDLG structure and set initial values for the number of copies, starting, and ending page
Local $tPRINTDLG = DllStructCreate($tagPRINTDLG)
DllStructSetData($tPRINTDLG, 'Size', DllStructGetSize($tPRINTDLG))
DllStructSetData($tPRINTDLG, 'Flags', $PD_PAGENUMS)
DllStructSetData($tPRINTDLG, 'FromPage', 2)
DllStructSetData($tPRINTDLG, 'ToPage', 3)
DllStructSetData($tPRINTDLG, 'MinPage', 1)
DllStructSetData($tPRINTDLG, 'MaxPage', 9)
DllStructSetData($tPRINTDLG, 'Copies', 4)

; Create Print dialog box

If Not _WinAPI_PrintDlg($tPRINTDLG) Then
    Exit
EndIf

; Show results
Local $hDevNames = DllStructGetData($tPRINTDLG, 'hDevNames')
Local $pDevNames = _MemGlobalLock($hDevNames)
Local $tDEVNAMES = DllStructCreate($tagDEVNAMES, $pDevNames)
ConsoleWrite('Printer: ' & _WinAPI_GetString($pDevNames + 2 * DllStructGetData($tDEVNAMES, 'DeviceOffset')))
If DllStructGetData($tDEVNAMES, 'Default') Then
    ConsoleWrite(' (Default)' & @CRLF)
Else
    ConsoleWrite(@CRLF)
EndIf
ConsoleWrite('First page: ' & DllStructGetData($tPRINTDLG, 'FromPage') & @CRLF)
ConsoleWrite('Last page: ' & DllStructGetData($tPRINTDLG, 'ToPage') & @CRLF)
ConsoleWrite('Copies: ' & DllStructGetData($tPRINTDLG, 'Copies') & @CRLF)

; Free global memory objects that contains a DEVMODE and DEVNAMES structures
_MemGlobalFree(DllStructGetData($tPRINTDLG, 'hDevMode'))
_MemGlobalFree($hDevNames)


Function _WinAPI_PrintDlgEx

Function Reference

_WinAPI_PrintDlgEx

Displays a Print property sheet that enables the user to specify the properties of a particular print job

#include <WinAPIDlg.au3>
_WinAPI_PrintDlgEx ( ByRef $tPRINTDLGEX )

Parameters

$tPRINTDLGEX $tagPRINTDLGEX structure that contains information used to initialize the property sheet. When the
function returns, it contains information about the user's selections. This structure must be
initialized before function call.
(See MSDN for more information)

Return Value

Success: | 1, @extended flag will contain one of the following values. $PD_RESULT_APPLY $PD_RESULT_CANCEL $PD_RESULT_PRINT
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

Note that the values of "hDevMode" and "hDevNames" member in $tagPRINTDLGEX may change when they are passed into
_WinAPI_PrintDlgEx(). This is because these members are filled on both input and output.

See Also

Search PrintDlgEx in MSDN Library.

Example

#include <APIDlgConstants.au3>
#include <Memory.au3>
#include <WinAPIDlg.au3>
#include <WinAPIFiles.au3>

Opt('WinTitleMatchMode', 3)

; Create PRINTDLGEX structure and set initial values for the number of copies, starting, and ending page
Local $tPRINTPAGERANGE = DllStructCreate($tagPRINTPAGERANGE)
DllStructSetData($tPRINTPAGERANGE, 'FromPage', 2)
DllStructSetData($tPRINTPAGERANGE, 'ToPage', 3)
Local $tPRINTDLGEX = DllStructCreate($tagPRINTDLGEX)
DllStructSetData($tPRINTDLGEX, 'Size', DllStructGetSize($tPRINTDLGEX))
DllStructSetData($tPRINTDLGEX, 'hOwner', WinGetHandle(AutoItWinGetTitle()))
DllStructSetData($tPRINTDLGEX, 'Flags', BitOR($PD_PAGENUMS, $PD_NOCURRENTPAGE, $PD_NOSELECTION))
DllStructSetData($tPRINTDLGEX, 'NumPageRanges', 1)
DllStructSetData($tPRINTDLGEX, 'MaxPageRanges', 1)
DllStructSetData($tPRINTDLGEX, 'PageRanges', DllStructGetPtr($tPRINTPAGERANGE))
DllStructSetData($tPRINTDLGEX, 'MinPage', 1)
DllStructSetData($tPRINTDLGEX, 'MaxPage', 9)
DllStructSetData($tPRINTDLGEX, 'Copies', 4)
DllStructSetData($tPRINTDLGEX, 'StartPage', -1)

; Display Print property sheet
If Not _WinAPI_PrintDlgEx($tPRINTDLGEX) Then
    Exit
EndIf

Switch @extended
    Case $PD_RESULT_PRINT
        ; The user clicked the "Print" button
    Case $PD_RESULT_APPLY
        ; The user clicked the "Apply" button and later clicked the "Cancel" button
    Case $PD_RESULT_CANCEL
        Exit
EndSwitch

; Show results
Local $hDevNames = DllStructGetData($tPRINTDLGEX, 'hDevNames')
Local $pDevNames = _MemGlobalLock($hDevNames)
Local $tDEVNAMES = DllStructCreate($tagDEVNAMES, $pDevNames)
ConsoleWrite('Printer: ' & _WinAPI_GetString($pDevNames + 2 * DllStructGetData($tDEVNAMES, 'DeviceOffset')))
If DllStructGetData($tDEVNAMES, 'Default') Then
    ConsoleWrite(' (Default)' & @CRLF)
Else
    ConsoleWrite(@CRLF)
EndIf
Local $aPage[2]
If BitAND(DllStructGetData($tPRINTDLGEX, 'Flags'), $PD_PAGENUMS) Then
    $aPage[0] = DllStructGetData($tPRINTPAGERANGE, 'FromPage')
    $aPage[1] = DllStructGetData($tPRINTPAGERANGE, 'ToPage')
Else
    $aPage[0] = DllStructGetData($tPRINTDLGEX, 'MinPage')
    $aPage[1] = DllStructGetData($tPRINTDLGEX, 'MaxPage')
EndIf
ConsoleWrite('First page: ' & $aPage[0] & @CRLF)
ConsoleWrite('Last page: ' & $aPage[1] & @CRLF)
ConsoleWrite('Copies: ' & DllStructGetData($tPRINTDLGEX, 'Copies') & @CRLF)

; Free global memory objects that contains a DEVMODE and DEVNAMES structures
_MemGlobalFree(DllStructGetData($tPRINTDLGEX, 'hDevMode'))
_MemGlobalFree($hDevNames)


Function _WinAPI_ReplaceTextDlg

Function Reference

_WinAPI_ReplaceTextDlg

Creates a system-defined modeless dialog box that lets the user specify a string to search for and a replacement string

#include <WinAPIDlg.au3>
_WinAPI_ReplaceTextDlg ( $hOwner [, $sFindWhat = '' [, $sReplaceWith = '' [, $iFlags = 0 [, $pReplaceProc = 0 [, $lParam = 0]]]]] )

Parameters

$hOwner | A handle to the window that owns the dialog box. The window procedure of the specified window receives FINDMSGSTRING messages from the dialog box. This parameter can be any valid window handle, but it must not be 0.
$sFindWhat | [optional] The search string that is displayed when you initialize the dialog box.
$sReplaceWith | [optional] The replacement string that is displayed when you initialize the dialog box.
$iFlags | [optional] A set of bit flags that used to initialize the dialog box. The dialog box sets these flags when it sends the FINDMSGSTRING registered message to indicate the user's input. This parameter can be one or more of the following values: $FR_DIALOGTERM $FR_DOWN $FR_ENABLEHOOK $FR_ENABLETEMPLATE $FR_ENABLETEMPLATEHANDLE $FR_FINDNEXT $FR_HIDEUPDOWN $FR_HIDEMATCHCASE $FR_HIDEWHOLEWORD $FR_MATCHCASE $FR_NOMATCHCASE $FR_NOUPDOWN $FR_NOWHOLEWORD $FR_REPLACE $FR_REPLACEALL $FR_SHOWHELP $FR_WHOLEWORD
$pReplaceProc | [optional] Pointer to an hook procedure that can process messages intended for the dialog box. This parameter is ignored unless the $FR_ENABLEHOOK flag is not set. (See MSDN for more information)
$lParam | [optional] Application-defined data that the system passes to the hook procedure.

Return Value

Success: | The window handle to the dialog box.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the dialog box error code.

Remarks

The _WinAPI_ReplaceTextDlg() does not perform a text replacement operation. Instead, the dialog box sends FINDMSGSTRING registered messages to the window procedure of the owner window of the dialog box.

Before calling _WinAPI_ReplaceTextDlg(), you must call the _WinAPI_RegisterWindowMessage() function to get the identifier for the FINDMSGSTRING message.
The dialog box procedure uses this identifier to send messages when the user clicks the "Find Next", "Replace", or "Replace All" buttons, or when the dialog box is closing.
The "lParam" parameter of the FINDMSGSTRING message contains a pointer to a $tagFINDREPLACE structure.
The "Flags" member of this structure indicates the event that caused the message.
Other members of the structure indicate the user's input.

The _WinAPI_ReplaceTextDlg() uses an internal buffer to hold the string that the user typed in the "Find What" and "Replace With" edit controls.
You can increase the size of this buffer by using the _WinAPI_SetFRBuffer() function.
In addition to free the memory allocated for the internal buffer, you must call the _WinAPI_FlushFRBuffer() in response to the FINDMSGSTRING message with $FR_DIALOGTERM flag set.

Related

_WinAPI_FlushFRBuffer, _WinAPI_RegisterWindowMessage, _WinAPI_SetFRBuffer

See Also

Search ReplaceText in MSDN Library.

Example

#include <APIDlgConstants.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIRichEdit.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDlg.au3>
#include <WindowsConstants.au3>

Local Const $sTxt = 'AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying "runtimes" required!' & @CRLF & @CRLF & _
        'AutoIt was initially designed for PC "roll out" situations to reliably automate and configure thousands of PCs. Over time it has become a powerful language that supports complex expressions, user functions, loops and everything else that veteran scripters would expect.'

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 800, 600)

; Create main menu
Local $idMenu = GUICtrlCreateMenu('&File')
Local $idExitItem = GUICtrlCreateMenuItem('E&xit...', $idMenu)
$idMenu = GUICtrlCreateMenu('&Edit')
Local $idFindItem = GUICtrlCreateMenuItem('&Find...', $idMenu)
Local $idReplaceItem = GUICtrlCreateMenuItem('R&eplace...', $idMenu)

; Create Rich Edit control with always visible text selection, and set "Courier New" font to the control
Local $hRichEdit = _GUICtrlRichEdit_Create($hForm, $sTxt, 0, 0, 800, 600, BitOR($ES_AUTOVSCROLL, $ES_NOHIDESEL, $ES_MULTILINE, $WS_VSCROLL), 0)
Local $hFont = _WinAPI_CreateFont(17, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, 'Courier New')
_SendMessage($hRichEdit, $WM_SETFONT, $hFont, 1)
_SendMessage($hRichEdit, $EM_SETSEL)

; Register FINDMSGSTRING message to receive the messages from the dialog box
GUIRegisterMsg(_WinAPI_RegisterWindowMessage('commdlg_FindReplace'), 'WM_FINDMSGSTRING')

; Show GUI
GUISetState(@SW_SHOW)

Global $g_hDlg
Local $iMsg, $sText
While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE, $idExitItem
            ExitLoop
        Case $idFindItem, $idReplaceItem
            $sText = _GUICtrlRichEdit_GetSelText($hRichEdit)
            If @error Then
                $sText = ''
            EndIf
            ; Disable "Find..." and "Replace..." menu items, otherwise, the script maay crash
            GUICtrlSetState($idFindItem, $GUI_DISABLE)
            GUICtrlSetState($idReplaceItem, $GUI_DISABLE)
            Switch $iMsg
                Case $idFindItem
                    $g_hDlg = _WinAPI_FindTextDlg($hForm, $sText, $FR_DOWN, 0, $hRichEdit)
                Case $idReplaceItem
                    $g_hDlg = _WinAPI_ReplaceTextDlg($hForm, $sText, '', 0, 0, $hRichEdit)
            EndSwitch
        Case $idReplaceItem
    EndSwitch
WEnd

GUIDelete()

Func _IsMatchSelection($hWnd, $sText, $iBehavior)
    Local $aPos = _GUICtrlRichEdit_GetSel($hWnd)
    If @error Then Return 0

    $aPos = _GUICtrlRichEdit_FindTextInRange($hWnd, $sText, $aPos[0], $aPos[1], BitAND($iBehavior, $FR_MATCHCASE) = $FR_MATCHCASE, BitAND($iBehavior, $FR_WHOLEWORD) = $FR_WHOLEWORD, BitAND($iBehavior, BitOR($FR_MATCHALEFHAMZA, $FR_MATCHDIAC, $FR_MATCHKASHIDA)))
    If @error Or ($aPos[0] = -1) Or ($aPos[1] = -1) Then
        Return 0
    Else
        Return 1
    EndIf
EndFunc   ;==>_IsMatchSelection

Func WM_FINDMSGSTRING($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam

    Local $tFINDREPLACE = DllStructCreate($tagFINDREPLACE, $lParam)
    Local $sReplace = _WinAPI_GetString(DllStructGetData($tFINDREPLACE, 'ReplaceWith'))
    Local $sFind = _WinAPI_GetString(DllStructGetData($tFINDREPLACE, 'FindWhat'))
    Local $hRichEdit = Ptr(DllStructGetData($tFINDREPLACE, 'lParam'))
    Local $iFlags = DllStructGetData($tFINDREPLACE, 'Flags')
    Local $aPos, $iCur = -1

    Select
        ; The user clicked the "Replace" button in a Replace dialog box
        Case BitAND($iFlags, $FR_REPLACE)
            If _IsMatchSelection($hRichEdit, $sFind, $iFlags) Then
                _GUICtrlRichEdit_ReplaceText($hRichEdit, $sReplace)
            EndIf
            ContinueCase
            ; The user clicked the "Find Next" button in a Find or Replace dialog box
        Case BitAND($iFlags, $FR_FINDNEXT)
            $aPos = _GUICtrlRichEdit_GetSel($hRichEdit)
            If @error Then Return

            If BitAND($iFlags, $FR_DOWN) Then
                $aPos = _GUICtrlRichEdit_FindTextInRange($hRichEdit, $sFind, $aPos[1], -1, BitAND($iFlags, $FR_MATCHCASE) = $FR_MATCHCASE, BitAND($iFlags, $FR_WHOLEWORD) = $FR_WHOLEWORD)
            Else
                $aPos = _GUICtrlRichEdit_FindTextInRange($hRichEdit, $sFind, $aPos[0], 0, BitAND($iFlags, $FR_MATCHCASE) = $FR_MATCHCASE, BitAND($iFlags, $FR_WHOLEWORD) = $FR_WHOLEWORD, BitAND($iFlags, $FR_DOWN))
            EndIf
            If @error Or ($aPos[0] = -1) Or ($aPos[1] = -1) Then
                Local $iError = @error
                MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), WinGetTitle($g_hDlg), 'Cannot find "' & $sFind & '" (' & $iError & ')', 0, $g_hDlg)
                Return
            EndIf
            ; Here and below used the EM_SETSEL message directly because _GUICtrlRichEdit_SetSel() sets a focus to the Rich Edit control
            _SendMessage($hRichEdit, $EM_SETSEL, $aPos[0], $aPos[1])
            ;           _GUICtrlRichEdit_ScrollToCaret($hRichEdit)
            ; The user clicked the "Replace All" button in a Replace dialog box
        Case BitAND($iFlags, $FR_REPLACEALL)
            Dim $aPos[2] = [0, -1]
            While 1
                $aPos = _GUICtrlRichEdit_FindTextInRange($hRichEdit, $sFind, $aPos[0], -1, BitAND($iFlags, $FR_MATCHCASE) = $FR_MATCHCASE, BitAND($iFlags, $FR_WHOLEWORD) = $FR_WHOLEWORD)
                If ($aPos[0] = -1) Or ($aPos[1] = -1) Then
                    If $iCur = -1 Then
                        MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), WinGetTitle($g_hDlg), 'Cannot find "' & $sFind & '"', 0, $g_hDlg)
                        Return
                    EndIf
                    ExitLoop
                EndIf
                If $iCur = -1 Then
                    _GUICtrlRichEdit_PauseRedraw($hRichEdit)
                EndIf
                _SendMessage($hRichEdit, $EM_SETSEL, $aPos[0], $aPos[1])
                If _GUICtrlRichEdit_ReplaceText($hRichEdit, $sReplace) Then
                    $iCur = $aPos[0] + StringLen($sReplace)
                Else
                    ExitLoop
                EndIf
            WEnd
            _SendMessage($hRichEdit, $EM_SETSEL, $iCur, $iCur)
            ;           _GUICtrlRichEdit_ScrollToCaret($hRichEdit)
            _GUICtrlRichEdit_ResumeRedraw($hRichEdit)
            ; The dialog box is closing
        Case BitAND($iFlags, $FR_DIALOGTERM)
            ; Destroy internal buffer, and free allocated memory
            _WinAPI_FlushFRBuffer()
            ; Enable "Find..." and "Replace..." menu items
            GUICtrlSetState($idReplaceItem, $GUI_ENABLE)
            GUICtrlSetState($idFindItem, $GUI_ENABLE)
    EndSelect
EndFunc   ;==>WM_FINDMSGSTRING


Function _WinAPI_RestartDlg

Function Reference

_WinAPI_RestartDlg

Displays a dialog box that prompts the user to restart Microsoft Windows

#include <WinAPIDlg.au3>
_WinAPI_RestartDlg ( [$sText = '' [, $iFlags = 2 [, $hParent = 0]]] )

Parameters

$sText | [optional] The text that displays in the dialog box which prompts the user.
$iFlags | [optional] The flags that specify the type of shutdown. This parameter must include one of the following values. $EWX_LOGOFF $EWX_POWEROFF $EWX_REBOOT (Default) $EWX_SHUTDOWN This parameter can optionally include the following values. $EWX_FORCE $EWX_FORCEIFHUNG
$hParent | [optional] Handle to the parent window.

Return Value

Returns the identifier of the button that was pressed to close the dialog box.

See Also

Search RestartDialog in MSDN Library.


Function _WinAPI_SaveFileDlg

Function Reference

_WinAPI_SaveFileDlg

Creates a dialog box that lets the user specify the drive, directory, and name of a file to save

#include <WinAPIDlg.au3>
_WinAPI_SaveFileDlg ( [$sTitle = "" [, $sInitDir = "" [, $sFilters = "" [, $iDefaultFilter = 0 [, $sDefaultFilePath = "" [, $sDefaultExt = "" [, $iFlags = 0 [, $iFlagsEx = 0 [, $pOFNProc = 0 [, $pData = 0 [, $hParent = 0]]]]]]]]]]] )

Parameters

$sTitle | [optional] A string to be placed in the title bar of the dialog box. If this parameter is empty string (Default), the system uses the default title (that is, "Save As").
$sInitDir | [optional] The initial directory.
$sFilters | [optional] The pairs of filter strings (for example, "Text Files (*.txt)"). To specify multiple filter patterns for a single display string, use a semicolon to separate the patterns (for example, "*.txt;*.doc;*.bak"). Do not include spaces in the pattern. To specify multiple groups of filters, use the "|" character as a delimiter (for example, "Text Files (*.txt)|All Files (*.*)"). If this parameter is omitted or an empty string (Default), the dialog box does not display any filters
$iDefaultFilter | [optional] The 1-based index of the currently selected filter to initialize the combo box control.
$sDefaultFilePath | [optional] The file name to initialize the edit control.
$sDefaultExt | [optional] The default extension that appends to the file name if the user fails to type an extension. This string can be any length, but only the first three characters are appended. The string should not contain a period (.). If this parameter is empty string (Default), no extension is appended.
$iFlags | [optional] A set of bit flags you can use to initialize the dialog box. This parameter can be 0 or combination of the following values: $OFN_ALLOWMULTISELECT $OFN_CREATEPROMPT $OFN_DONTADDTORECENT $OFN_ENABLEHOOK $OFN_ENABLEINCLUDENOTIFY $OFN_ENABLESIZING $OFN_EXPLORER $OFN_FORCESHOWHIDDEN $OFN_HIDEREADONLY $OFN_LONGNAMES $OFN_NOCHANGEDIR $OFN_NODEREFERENCELINKS $OFN_NOLONGNAMES $OFN_NONETWORKBUTTON $OFN_NOREADONLYRETURN $OFN_NOTESTFILECREATE $OFN_NOVALIDATE $OFN_OVERWRITEPROMPT $OFN_PATHMUSTEXIST $OFN_READONLY $OFN_SHAREAWARE $OFN_SHOWHELP
$iFlagsEx | [optional] A set of bit flags you can use to initialize the dialog box. It can be 0 or the following value: $OFN_EX_NOPLACESBAR
$pOFNProc | [optional] A pointer to a hook procedure. This parameter is ignored unless the $OFN_ENABLEHOOK flag is set.
$pData | [optional] Application-defined pointer to data that the system passes to the hook procedure.
$hParent | [optional] A handle to the parent window for the dialog box.

Return Value

Success: | If the $OFN_ALLOWMULTISELECT flag is not set, the function returns the full path of the input file, otherwise always an array of paths. The zeroth array element contains the number of files.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the dialog box error code ($CDERR_* or $FNERR_*).

Remarks

Call _WinAPI_GetExtended() to retrieve internal $tagOPENFILENAME structure containing the user's selection information after closing the dialog box.

If you use a hook, you can not preserve the UI of the dialog box like in Windows Vista or later.

Related

_WinAPI_GetExtended

See Also

Search GetSaveFileName in MSDN Library.

Example

#include <WinAPI.au3>
#include <WinAPIDlg.au3>

Local $sFile = _WinAPI_SaveFileDlg('', @WorkingDir, 'AutoIt v3 Scripts (*.au3)|All Files (*.*)', 1, 'MyScript.au3', '.', BitOR($OFN_PATHMUSTEXIST, $OFN_OVERWRITEPROMPT))

If Not @error Then
    ConsoleWrite($sFile & @CRLF)
EndIf


Function _WinAPI_SetFRBuffer

Function Reference

_WinAPI_SetFRBuffer

Sets the size of the internal buffer that used the _WinAPI_FindTextDlg() and _WinAPI_ReplaceTextDlg() functions

#include <WinAPIDlg.au3>
_WinAPI_SetFRBuffer ( $iChars )

Parameters

$iChars The size, in TCHARs, of the internal buffer. The buffer should be at least 80 characters long.
The default buffer size is 16384 wide characters (32 KB).

Return Value

None.

Remarks

This function does not initialize the buffer, just sets its size. Actually, this buffer is initialized only by
_WinAPI_FindTextDlg() and _WinAPI_ReplaceTextDlg() functions. The _WinAPI_SetFRBuffer() must be called before
using the _WinAPI_FindTextDlg() or _WinAPI_ReplaceTextDlg().

You can destroy the internal buffer by calling the _WinAPI_FlushFRBuffer() function.

Related

_WinAPI_FindTextDlg, _WinAPI_FlushFRBuffer, _WinAPI_ReplaceTextDlg


Function _WinAPI_ShellAboutDlg

Function Reference

_WinAPI_ShellAboutDlg

Displays a Windows About dialog box

#include <WinAPIDlg.au3>
_WinAPI_ShellAboutDlg ( $sTitle, $sName, $sText [, $hIcon = 0 [, $hParent = 0]] )

Parameters

$sTitle | The title of the Windows About dialog box.
$sName | The first line after the text "Microsoft".
$sText | The text to be displayed in the dialog box after the version and copyright information.
$hIcon | [optional] Handle to the icon that the function displays in the dialog box.
$hParent | [optional] Handle to a parent window.

Return Value

Success: | True.
Failure: | False.

See Also

Search ShellAbout in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <WinAPIDlg.au3>

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idButton = GUICtrlCreateButton('About', 165, 366, 70, 23)
GUICtrlSetState($idButton, $GUI_DEFBUTTON)
GUISetState(@SW_SHOW)
Send('{Enter}')

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            _WinAPI_ShellAboutDlg('About', 'About Dialog Box Test', 'Simple Text', _WinAPI_ShellExtractIcon(@AutoItExe, 0, 32, 32), $hForm)
    EndSwitch
WEnd


Function _WinAPI_ShellOpenWithDlg

Function Reference

_WinAPI_ShellOpenWithDlg

Displays the Open With dialog box

#include <WinAPIDlg.au3>
_WinAPI_ShellOpenWithDlg ( $sFilePath [, $iFlags = 0 [, $hParent = 0]] )

Parameters

$sFilePath | The file name.
$iFlags | [optional] The characteristics of the Open With dialog box. This parameter can be one or more of the following values. $OAIF_ALLOW_REGISTRATION $OAIF_REGISTER_EXT $OAIF_EXEC $OAIF_FORCE_REGISTRATION $OAIF_HIDE_REGISTRATION $OAIF_URL_PROTOCOL
$hParent | [optional] Handle of the parent window.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

See Also

Search SHOpenWithDialog in MSDN Library.

Example

#include <APIDlgConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDlg.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

_WinAPI_ShellOpenWithDlg(@ScriptFullPath, $OAIF_EXEC)


Function _WinAPI_ShellStartNetConnectionDlg

Function Reference

_WinAPI_ShellStartNetConnectionDlg

Displays a general browsing dialog box for a network resource connection

#include <WinAPIDlg.au3>
_WinAPI_ShellStartNetConnectionDlg ( [$sRemote = '' [, $iFlags = 0 [, $hParent = 0]]] )

Parameters

$sRemote | [optional] The remote network name.
$iFlags | [optional] The flags that identify the type of resource that the dialog is set to find. This parameter can be one or more of the following values.
$hParent | [optional] Handle of the parent window.

Return Value

None.

See Also

Search SHStartNetConnectionDialog in MSDN Library.


Function _WinAPI_ShellUserAuthenticationDlg

Function Reference

_WinAPI_ShellUserAuthenticationDlg

Creates and displays a configurable dialog box that accepts credentials information from a user

#include <WinAPIDlg.au3>
_WinAPI_ShellUserAuthenticationDlg ( $sCaption, $sMessage, $sUser, $sPassword, $sTarget [, $iFlags = 0 [, $iError = 0 [, $bSave = False [, $hBitmap = 0 [, $hParent = 0]]]]] )

Parameters

$sCaption | The title for the dialog box.
$sMessage | A brief message to display in the dialog box.
$sUser | The user name to populate the credential fields in the dialog box. For domain users, the string must be in the following format (if domain is not specified, the trget string is used as the domain): DomainName\UserName
$sPassword | The initial password.
$sTarget | The name of the target, typically a server name. This parameter is used to identify target information when storing and retrieving credentials.
$iFlags | [optional] The flags that specifies behavior for this function. It can be a bitwise-OR combination of zero or more of the following values. $CREDUI_FLAGS_ALWAYS_SHOW_UI $CREDUI_FLAGS_COMPLETE_USERNAME $CREDUI_FLAGS_DO_NOT_PERSIST $CREDUI_FLAGS_EXCLUDE_CERTIFICATES $CREDUI_FLAGS_EXPECT_CONFIRMATION $CREDUI_FLAGS_GENERIC_CREDENTIALS $CREDUI_FLAGS_INCORRECT_PASSWORD $CREDUI_FLAGS_KEEP_USERNAME $CREDUI_FLAGS_PASSWORD_ONLY_OK $CREDUI_FLAGS_PERSIST $CREDUI_FLAGS_REQUEST_ADMINISTRATOR $CREDUI_FLAGS_REQUIRE_CERTIFICATE $CREDUI_FLAGS_REQUIRE_SMARTCARD $CREDUI_FLAGS_SERVER_CREDENTIAL $CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX $CREDUI_FLAGS_USERNAME_TARGET_CREDENTIALS $CREDUI_FLAGS_VALIDATE_USERNAME
$iError | [optional] The system error code that specifies why the credential dialog box is needed.
$bSave | [optional] Specifies whether the "Save" check box is selected in the dialog box (it makes sense only if the $CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX flag is used), valid values: True - Selected. False - Deselected (Default).
$hBitmap | [optional] A bitmap handle to display in the dialog box. If this parameter is 0, the default bitmap is used. The bitmap size is limited to 320x60 pixels.
$hParent | [optional] The dialog box is modal with respect to the parent window. If this parameter is 0, the desktop is the parent window of the dialog box.

Return Value

Success: | The array containing the following information: [0] - The user name, including domain name (if necessary). [1] - The password. [2] - The state of the "Save" check box.
Failure: | Sets the @error flag to non-zero. If the function is cancelled by the user, @extended flag will contain the ERROR_CANCELLED (1223) system error code. Any other value indicates that the function failed to load.

Remarks

Credentials are stored in the credential manager based on target name. Each target name is stored as generally as
possible without colliding with credentials already stored in the credential manager. Because credentials are stored
by target name, a particular user can only have one credential per target stored in the credential manager.

Related

_WinAPI_ConfirmCredentials

See Also

Search CredUIPromptForCredentials in MSDN Library.

Example

#include <APIDlgConstants.au3>
#include <Crypt.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIDlg.au3>

Local $hBitmap = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Authentication.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Local $aData[3] = ['', '', 0]

While 1
    $aData = _WinAPI_ShellUserAuthenticationDlg('Authentication', 'To continue, type a login and password, and then click OK.', $aData[0], $aData[1], 'MyScript', BitOR($CREDUI_FLAGS_ALWAYS_SHOW_UI, $CREDUI_FLAGS_EXPECT_CONFIRMATION, $CREDUI_FLAGS_GENERIC_CREDENTIALS, $CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX), 0, $aData[2], $hBitmap)
    If @error Then Exit

    If (StringCompare($aData[0], 'AutoIt')) Or (StringCompare($aData[1], StringEncrypt(False, 'DC7E430A1C88', '123'))) Then
        If $aData[2] Then
            _WinAPI_ConfirmCredentials('MyScript', 0)
        EndIf
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'You have typed an incorrect login or password, it should be "AutoIt" and "123".')
    Else
        If $aData[2] Then
            _WinAPI_ConfirmCredentials('MyScript', 1)
        EndIf
        ExitLoop
    EndIf
WEnd

Func StringEncrypt($bEncrypt, $sData, $sPassword)
    _Crypt_Startup() ; Start the Crypt library.
    Local $sReturn = ''
    If $bEncrypt Then ; If the flag is set to True then encrypt, otherwise decrypt.
        $sReturn = _Crypt_EncryptData($sData, $sPassword, $CALG_RC4)
    Else
        $sReturn = BinaryToString(_Crypt_DecryptData($sData, $sPassword, $CALG_RC4))
    EndIf
    _Crypt_Shutdown() ; Shutdown the Crypt library.
    Return $sReturn
EndFunc   ;==>StringEncrypt


Function _WinAPI_ShellUserAuthenticationDlgEx

Function Reference

_WinAPI_ShellUserAuthenticationDlgEx

Creates and displays a configurable dialog box that accepts credentials information from a user

#include <WinAPIDlg.au3>
_WinAPI_ShellUserAuthenticationDlgEx ( $sCaption, $sMessage, $sUser, $sPassword [, $iFlags = 0 [, $iAuthError = 0 [, $bSave = False [, $iPackage = 0 [, $hParent = 0]]]]] )

Parameters

$sCaption | The title for the dialog box.
$sMessage | A brief message to display in the dialog box.
$sUser | The user name to populate the credential fields in the dialog box. For domain users, the string must be in the following format: DomainName\UserName
$sPassword | The initial password.
$iFlags | [optional] The flags that specifies behavior for this function. It can be a combination of the following values. $CREDUIWIN_AUTHPACKAGE_ONLY $CREDUIWIN_CHECKBOX $CREDUIWIN_ENUMERATE_ADMINS $CREDUIWIN_ENUMERATE_CURRENT_USER $CREDUIWIN_GENERIC $CREDUIWIN_IN_CRED_ONLY $CREDUIWIN_SECURE_PROMPT $CREDUIWIN_PACK_32_WOW $CREDUIWIN_PREPROMPTING
$iAuthError | [optional] The system error code that is displayed in the dialog box.
$bSave | [optional] Specifies whether the "Save" check box is selected in the dialog box (it makes sense only if the $CREDUIWIN_CHECKBOX flag is used), valid values: True - Selected. False - Deselected (Default).
$iPackage | [optional] The authentication package for which the credentials are serialized.
$hParent | [optional] The dialog box is modal with respect to the parent window. If this parameter is 0 (Default), the desktop is the parent window of the dialog box.

Return Value

Success: | The array containing the following information: [0] - The user name, including domain name (if necessary). [1] - The password. [2] - The state of the "Save" check box. [3] - The authentication package.
Failure: | Sets the @error flag to non-zero. If the function is cancelled by the user, @extended flag will contain the ERROR_CANCELLED (1223) system error code. Any other value indicates that the function failed to load.

Remarks

This function requires Windows Vista or later.

See Also

Search CredUIPromptForWindowsCredentials in MSDN Library.

Example

#include <APIDlgConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDlg.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

Local $aData = _WinAPI_ShellUserAuthenticationDlgEx('Authentication', 'To continue, type a login and password, and then click OK.', '', '', BitOR($CREDUIWIN_ENUMERATE_CURRENT_USER, $CREDUIWIN_CHECKBOX))
If @error Then Exit

Local $aUser = _WinAPI_ParseUserName($aData[0])
If @error Then
    Exit
EndIf

ConsoleWrite('Domain:   ' & $aUser[0] & @CRLF)
ConsoleWrite('User:     ' & $aUser[1] & @CRLF)
ConsoleWrite('Password: ' & $aData[1] & @CRLF)
ConsoleWrite('Save:     ' & $aData[2] & @CRLF)
ConsoleWrite('Package:  ' & $aData[3] & @CRLF)


Files & Devices Reference

  • DataAccess & Storage Management
  • DevicesIoCtl Management
  • Files Management


User Defined Functions

DataAccess & Storage user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIFiles.au3>.

User Defined Function | Description
_WinAPI_BackupRead | Backs up a file or directory, including the security information
_WinAPI_BackupReadAbort | Finishes the use of _WinAPI_BackupRead() on the handle
_WinAPI_BackupSeek | Seeks forward in a data stream initially accessed by using the _WinAPI_BackupRead() or _WinAPI_BackupWrite() function
_WinAPI_BackupWrite | Restore a file or directory that was backed up using _WinAPI_BackupRead()
_WinAPI_BackupWriteAbort | Finishes the use of _WinAPI_BackupWrite() on the handle
_WinAPI_DefineDosDevice | Defines, redefines, or deletes MS-DOS device names
_WinAPI_GetDriveType | Determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive
_WinAPI_GetLogicalDrives | Retrieves a bitmask representing the currently available disk drives
_WinAPI_GetPEType | Retrieves a type of the machine for the specified portable executable (PE)
_WinAPI_QueryDosDevice | Retrieves the current mapping for a particular MS-DOS device name
_WinAPI_Wow64EnableWow64FsRedirection | Enables or disables file system redirection for the calling thread


Function _WinAPI_BackupRead

Function Reference

_WinAPI_BackupRead

Backs up a file or directory, including the security information

#include <WinAPIFiles.au3>
_WinAPI_BackupRead ( $hFile, $pBuffer, $iLength, ByRef $iBytes, ByRef $pContext [, $bSecurity = False] )

Parameters

$hFile | Handle to the file or directory to be backed up. To obtain the handle, call the _WinAPI_CreateFileEx() function. The SACLs are not read unless the file handle was created with the $ACCESS_SYSTEM_SECURITY access right.
$pBuffer | A pointer to a buffer that receives the data.
$iLength | The size of the buffer, in bytes. The buffer size must be greater than the size of the $tagWIN32_STREAM_ID structure. (see also MSDN for more information)
$iBytes | The number of bytes read.
$pContext | A pointer to an internal data structure used by this function to maintain context information during a backup operation. You must set this variable to 0 before the first call to _WinAPI_BackupRead() for the specified file or directory. The function allocates memory for the data structure, and then sets the variable to point to that structure. You must not change this variable or the variable that it points to between calls to _WinAPI_BackupRead().
$bSecurity | [optional] Specifies whether the function will backup the access-control list (ACL) data, valid values: True - The ACL data will be backed up. False - The ACL data will be omitted (Default).

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

The _WinAPI_BackupRead() is not intended for use in backing up files encrypted under the Encrypted File System (EFS).

If an error occurs during the data reading, the calling process can skip the bad data by calling the _WinAPI_BackupSeek() function.

When you are done using _WinAPI_BackupRead(), you must call _WinAPI_BackupReadAbort() function with the appropriate parameter to release the memory used by the internal data structure.

The file or directory should be restored using the _WinAPI_BackupWrite() function.

Related

_WinAPI_BackupReadAbort, _WinAPI_BackupSeek, _WinAPI_BackupWrite

See Also

Search BackupRead in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIFiles.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>

Local Const $sFile = @ScriptFullPath

; Enable "SeBackupPrivilege" and "SeRestorePrivilege" privileges to perform backup and restore operation
Local $hToken = _WinAPI_OpenProcessToken(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))
Local $aAdjust, $aPrivileges[2] = [$SE_BACKUP_NAME, $SE_RESTORE_NAME]
_WinAPI_AdjustTokenPrivileges($hToken, $aPrivileges, $SE_PRIVILEGE_ENABLED, $aAdjust)
If @error Or @extended Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'You do not have the required privileges.')
    Exit
EndIf

; Create a memory buffer where to store the backup data
Local $iBytes = 4096 + FileGetSize($sFile)
Local $pBuffer = _WinAPI_CreateBuffer($iBytes)

; Back up a file, including the security information
Local $pContext = 0
Local $hFile = _WinAPI_CreateFileEx($sFile, $OPEN_EXISTING, $GENERIC_READ)
If Not _WinAPI_BackupRead($hFile, $pBuffer, $iBytes, $iBytes, $pContext, 1) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to back up a file.')
    Exit
EndIf
_WinAPI_BackupReadAbort($pContext)
_WinAPI_CloseHandle($hFile)

; Restore a file (.bak) and the ACL data
$pContext = 0
$hFile = _WinAPI_CreateFileEx(_WinAPI_PathRenameExtension($sFile, '.bak'), $CREATE_ALWAYS, BitOR($GENERIC_WRITE, $WRITE_DAC, $WRITE_OWNER))
If Not _WinAPI_BackupWrite($hFile, $pBuffer, $iBytes, $iBytes, $pContext, 1) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to restore a file.')
    Exit
EndIf
_WinAPI_BackupWriteAbort($pContext)
_WinAPI_CloseHandle($hFile)

; Free the used memory
_WinAPI_FreeMemory($pBuffer)

; Restore "SeBackupPrivilege" and "SeRestorePrivilege" privileges by default
_WinAPI_AdjustTokenPrivileges($hToken, $aAdjust, 0, $aAdjust)
_WinAPI_CloseHandle($hToken)


Function _WinAPI_BackupReadAbort

Function Reference

_WinAPI_BackupReadAbort

Finishes the use of _WinAPI_BackupRead() on the handle

#include <WinAPIFiles.au3>
_WinAPI_BackupReadAbort ( ByRef $pContext )

Parameters

$pContext A pointer to an internal data structure used by _WinAPI_BackupRead() function to maintain context information during a backup operation.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Related

_WinAPI_BackupRead

See Also

Search BackupRead in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIFiles.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>

Local Const $sFile = @ScriptFullPath

; Enable "SeBackupPrivilege" and "SeRestorePrivilege" privileges to perform backup and restore operation
Local $hToken = _WinAPI_OpenProcessToken(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))
Local $aAdjust, $aPrivileges[2] = [$SE_BACKUP_NAME, $SE_RESTORE_NAME]
_WinAPI_AdjustTokenPrivileges($hToken, $aPrivileges, $SE_PRIVILEGE_ENABLED, $aAdjust)
If @error Or @extended Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'You do not have the required privileges.')
    Exit
EndIf

; Create a memory buffer where to store the backup data
Local $iBytes = 4096 + FileGetSize($sFile)
Local $pBuffer = _WinAPI_CreateBuffer($iBytes)

; Back up a file, including the security information
Local $pContext = 0
Local $hFile = _WinAPI_CreateFileEx($sFile, $OPEN_EXISTING, $GENERIC_READ)
If Not _WinAPI_BackupRead($hFile, $pBuffer, $iBytes, $iBytes, $pContext, 1) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to back up a file.')
    Exit
EndIf
_WinAPI_BackupReadAbort($pContext)
_WinAPI_CloseHandle($hFile)

; Restore a file (.bak) and the ACL data
$pContext = 0
$hFile = _WinAPI_CreateFileEx(_WinAPI_PathRenameExtension($sFile, '.bak'), $CREATE_ALWAYS, BitOR($GENERIC_WRITE, $WRITE_DAC, $WRITE_OWNER))
If Not _WinAPI_BackupWrite($hFile, $pBuffer, $iBytes, $iBytes, $pContext, 1) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to restore a file.')
    Exit
EndIf
_WinAPI_BackupWriteAbort($pContext)
_WinAPI_CloseHandle($hFile)

; Free the used memory
_WinAPI_FreeMemory($pBuffer)

; Restore "SeBackupPrivilege" and "SeRestorePrivilege" privileges by default
_WinAPI_AdjustTokenPrivileges($hToken, $aAdjust, 0, $aAdjust)
_WinAPI_CloseHandle($hToken)


Function _WinAPI_BackupSeek

Function Reference

_WinAPI_BackupSeek

Seeks forward in a data stream initially accessed by using the _WinAPI_BackupRead() or _WinAPI_BackupWrite() function

#include <WinAPIFiles.au3>
_WinAPI_BackupSeek ( $hFile, $iSeek, ByRef $iBytes, ByRef $pContext )

Parameters

$hFile | Handle to the file or directory.
$iSeek | The number of bytes to seek.
$iBytes | The number of bytes the function actually seeks.
$pContext | A pointer to an internal data structure. This structure must be the same structure that was initialized by the _WinAPI_BackupRead(). An application must not touch the contents of this structure.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

Applications use the _WinAPI_BackupSeek() to skip portions of a data stream that cause errors.
This function does not seek across stream headers.

Related

_WinAPI_BackupRead

See Also

Search BackupSeek in MSDN Library.


Function _WinAPI_BackupWrite

Function Reference

_WinAPI_BackupWrite

Restore a file or directory that was backed up using _WinAPI_BackupRead()

#include <WinAPIFiles.au3>
_WinAPI_BackupWrite ( $hFile, $pBuffer, $iLength, ByRef $iBytes, ByRef $pContext [, $bSecurity = False] )

Parameters

$hFile | Handle to the file or directory to be restored. To obtain the handle, call the _WinAPI_CreateFileEx() function. The SACLs are not restored unless the file handle was created with the $ACCESS_SYSTEM_SECURITY access right. To ensure that the integrity ACEs are restored correctly, the file handle must also have been created with the $WRITE_OWNER access right.
$pBuffer | A pointer to a buffer that the function writes data from.
$iLength | The size of the buffer, in bytes. The buffer size must be greater than the size of the $tagWIN32_STREAM_ID structure. (see MSDN for more information)
$iBytes | The number of bytes written.
$pContext | A pointer to an internal data structure used by this function to maintain context information during a restore operation. You must set this variable to 0 before the first call to _WinAPI_BackupWrite() for the specified file or directory. The function allocates memory for the data structure, and then sets the variable to point to that structure. You must not change this variable or the variable that it points to between calls to _WinAPI_BackupWrite().
$bSecurity | [optional] Specifies whether the function will restore the access-control list (ACL) data, valid values: True - The ACL data will be restored. Furthermore, you need to specify $WRITE_OWNER and $WRITE_DAC access when opening the file or directory handle. If the handle does not have those access rights, the operating system denies access to the ACL data, and ACL data restoration will not occur. False - The ACL data will be omitted (Default).

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

The _WinAPI_BackupWrite() is not intended for use in restoring files encrypted under the Encrypted File System (EFS).

When you are done using _WinAPI_BackupWrite(), you must call _WinAPI_BackupWriteAbort() function with the appropriate parameter to release the memory used by the internal data structure.

Related

_WinAPI_BackupWriteAbort

See Also

Search BackupRead in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIFiles.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>

Local Const $sFile = @ScriptFullPath

; Enable "SeBackupPrivilege" and "SeRestorePrivilege" privileges to perform backup and restore operation
Local $hToken = _WinAPI_OpenProcessToken(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))
Local $aAdjust, $aPrivileges[2] = [$SE_BACKUP_NAME, $SE_RESTORE_NAME]
_WinAPI_AdjustTokenPrivileges($hToken, $aPrivileges, $SE_PRIVILEGE_ENABLED, $aAdjust)
If @error Or @extended Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'You do not have the required privileges.')
    Exit
EndIf

; Create a memory buffer where to store the backup data
Local $iBytes = 4096 + FileGetSize($sFile)
Local $pBuffer = _WinAPI_CreateBuffer($iBytes)

; Back up a file, including the security information
Local $pContext = 0
Local $hFile = _WinAPI_CreateFileEx($sFile, $OPEN_EXISTING, $GENERIC_READ)
If Not _WinAPI_BackupRead($hFile, $pBuffer, $iBytes, $iBytes, $pContext, 1) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to back up a file.')
    Exit
EndIf
_WinAPI_BackupReadAbort($pContext)
_WinAPI_CloseHandle($hFile)

; Restore a file (.bak) and the ACL data
$pContext = 0
$hFile = _WinAPI_CreateFileEx(_WinAPI_PathRenameExtension($sFile, '.bak'), $CREATE_ALWAYS, BitOR($GENERIC_WRITE, $WRITE_DAC, $WRITE_OWNER))
If Not _WinAPI_BackupWrite($hFile, $pBuffer, $iBytes, $iBytes, $pContext, 1) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to restore a file.')
    Exit
EndIf
_WinAPI_BackupWriteAbort($pContext)
_WinAPI_CloseHandle($hFile)

; Free the used memory
_WinAPI_FreeMemory($pBuffer)

; Restore "SeBackupPrivilege" and "SeRestorePrivilege" privileges by default
_WinAPI_AdjustTokenPrivileges($hToken, $aAdjust, 0, $aAdjust)
_WinAPI_CloseHandle($hToken)


Function _WinAPI_BackupWriteAbort

Function Reference

_WinAPI_BackupWriteAbort

Finishes the use of _WinAPI_BackupWrite() on the handle

#include <WinAPIFiles.au3>
_WinAPI_BackupWriteAbort ( ByRef $pContext )

Parameters

$pContext A pointer to an internal data structure used by _WinAPI_BackupWrite() function to maintain context information during a restore operation.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Related

_WinAPI_BackupWrite

See Also

Search BackupWrite in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIFiles.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>

Local Const $sFile = @ScriptFullPath

; Enable "SeBackupPrivilege" and "SeRestorePrivilege" privileges to perform backup and restore operation
Local $hToken = _WinAPI_OpenProcessToken(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))
Local $aAdjust, $aPrivileges[2] = [$SE_BACKUP_NAME, $SE_RESTORE_NAME]
_WinAPI_AdjustTokenPrivileges($hToken, $aPrivileges, $SE_PRIVILEGE_ENABLED, $aAdjust)
If @error Or @extended Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'You do not have the required privileges.')
    Exit
EndIf

; Create a memory buffer where to store the backup data
Local $iBytes = 4096 + FileGetSize($sFile)
Local $pBuffer = _WinAPI_CreateBuffer($iBytes)

; Back up a file, including the security information
Local $pContext = 0
Local $hFile = _WinAPI_CreateFileEx($sFile, $OPEN_EXISTING, $GENERIC_READ)
If Not _WinAPI_BackupRead($hFile, $pBuffer, $iBytes, $iBytes, $pContext, 1) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to back up a file.')
    Exit
EndIf
_WinAPI_BackupReadAbort($pContext)
_WinAPI_CloseHandle($hFile)

; Restore a file (.bak) and the ACL data
$pContext = 0
$hFile = _WinAPI_CreateFileEx(_WinAPI_PathRenameExtension($sFile, '.bak'), $CREATE_ALWAYS, BitOR($GENERIC_WRITE, $WRITE_DAC, $WRITE_OWNER))
If Not _WinAPI_BackupWrite($hFile, $pBuffer, $iBytes, $iBytes, $pContext, 1) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to restore a file.')
    Exit
EndIf
_WinAPI_BackupWriteAbort($pContext)
_WinAPI_CloseHandle($hFile)

; Free the used memory
_WinAPI_FreeMemory($pBuffer)

; Restore "SeBackupPrivilege" and "SeRestorePrivilege" privileges by default
_WinAPI_AdjustTokenPrivileges($hToken, $aAdjust, 0, $aAdjust)
_WinAPI_CloseHandle($hToken)


Function _WinAPI_DefineDosDevice

Function Reference

_WinAPI_DefineDosDevice

Defines, redefines, or deletes MS-DOS device names

#include <WinAPIFiles.au3>
_WinAPI_DefineDosDevice ( $sDevice, $iFlags [, $sFilePath = ''] )

Parameters

$sDevice | The name of the MS-DOS device.
$iFlags | This parameter can be one or more of the following values. $DDD_EXACT_MATCH_ON_REMOVE $DDD_NO_BROADCAST_SYSTEM $DDD_RAW_TARGET_PATH $DDD_REMOVE_DEFINITION
$sFilePath | [optional] The path that will implement device.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

See Also

Search DefineDosDevice in MSDN Library.

Example

#include <APIFilesConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Local $sDevice = 'Z:'
Local Const $sPath = @ScriptDir

If _WinAPI_DefineDosDevice($sDevice, $DDD_RAW_TARGET_PATH, '\DosDevices\' & $sPath) Then
    MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), '', 'The drive "' & $sDevice & '" has been created.' & @CRLF & @CRLF & 'Press OK to release drive.')
EndIf
_WinAPI_DefineDosDevice($sDevice, BitOR($DDD_EXACT_MATCH_ON_REMOVE, $DDD_RAW_TARGET_PATH, $DDD_REMOVE_DEFINITION), '\DosDevices\' & $sPath)


Function _WinAPI_GetDriveType

Function Reference

_WinAPI_GetDriveType

Determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive

#include <WinAPIFiles.au3>
_WinAPI_GetDriveType ( [$sDrive = ''] )

Parameters

$sDrive [optional] The drive letter to retrieve information, in the format D:, E:, etc.

Return Value

Success: | The type of drive ($DRIVE_*).
Failure: | 0.

Remarks

$DRIVE_* constants require #include <APIFilesConstants.au3>

See Also

Search GetDriveType in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Example()

Func Example()
    ; Find the drive type of the home drive, generally this is the C:\ drive.
    Local $iTypeOfDrive = _WinAPI_GetDriveType(@HomeDrive) ; For example C:

    ; Create a variable to hold the display message.
    Local $sMessage = ""
    Switch $iTypeOfDrive
        Case $DRIVE_UNKNOWN
            $sMessage = "The drive type cannot be determined."
        Case $DRIVE_NO_ROOT_DIR
            $sMessage = "The root path is invalid."
        Case $DRIVE_REMOVABLE
            $sMessage = "The drive is removable media."
        Case $DRIVE_FIXED
            $sMessage = "The drive is a fixed drive."
        Case $DRIVE_REMOTE
            $sMessage = "The drive is a remote (network) drive."
        Case $DRIVE_CDROM
            $sMessage = "The drive is a CD-ROM drive."
        Case $DRIVE_RAMDISK
            $sMessage = "The drive is a RAM disk."
    EndSwitch

    ; Display the message about the drive type.
    MsgBox($MB_SYSTEMMODAL, "", $sMessage)
EndFunc   ;==>Example


Function _WinAPI_GetLogicalDrives

Function Reference

_WinAPI_GetLogicalDrives

Retrieves a bitmask representing the currently available disk drives

#include <WinAPIFiles.au3>
_WinAPI_GetLogicalDrives ( )

Return Value

Success: | The value is a bitmask representing the currently available disk drives. Bit position 0 (the least-significant bit) is drive A, bit position 1 is drive B, bit position 2 is drive C, and so on.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetLogicalDrives in MSDN Library.


Function _WinAPI_GetPEType

Function Reference

_WinAPI_GetPEType

Retrieves a type of the machine for the specified portable executable (PE)

#include <WinAPIFiles.au3>
_WinAPI_GetPEType ( $sFilePath )

Parameters

$sFilePath The full path of the PE whose machine type is to be retrieved.

Return Value

Success: | The machine type ($IMAGE_FILE_MACHINE_*).
Failure: | 0 and sets the @error flag to non-zero.

Remarks

$IMAGE_FILE_MACHINE_* constants require #include <APIFilesConstants.au3>


Function _WinAPI_QueryDosDevice

Function Reference

_WinAPI_QueryDosDevice

Retrieves the current mapping for a particular MS-DOS device name

#include <WinAPIFiles.au3>
_WinAPI_QueryDosDevice ( $sDevice )

Parameters

$sDevice The name of the MS-DOS device.

Return Value

Success: | The current mapping for the specified device. If the $sDevice parameter is empty string, return array of all existing MS-DOS device names (for example, "\Device\HarddiskVolume1" or "\Device\Floppy0"). The zeroth array element contains the number of names.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search QueryDosDevice in MSDN Library.

Example

#include <WinAPIFiles.au3>

Local $aDrive = DriveGetDrive('ALL')

If IsArray($aDrive) Then
    For $i = 1 To $aDrive[0]
        ConsoleWrite(StringUpper($aDrive[$i]) & ' => ' & _WinAPI_QueryDosDevice($aDrive[$i]) & @CRLF)
    Next
EndIf


Function _WinAPI_Wow64EnableWow64FsRedirection

Function Reference

_WinAPI_Wow64EnableWow64FsRedirection

Enables or disables file system redirection for the calling thread

#include <WinAPIFiles.au3>
_WinAPI_Wow64EnableWow64FsRedirection ( $bEnable )

Parameters

$bEnable Specifies whether enable or disable the WOW64 system folder redirection, valid values:
True - Enable.
False - Disable.

Return Value

Success: | True
Failure: | False

Remarks

This function is useful for 32-bit applications that want to gain access to the native system32 directory.
By default, WOW64 file system redirection is enabled.

This function may not work reliably when there are nested calls.
Therefore, this function has been replaced
by the Wow64DisableWow64FsRedirection and Wow64RevertWow64FsRedirection functions.

See Also

Search Wow64EnableWow64FsRedirection in MSDN Library.


User Defined Functions

DevicesIoCtl user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIFiles.au3>.

User Defined Function | Description
_WinAPI_CreateObjectID | Creates or retrieves the object identifier for the specified file or directory
_WinAPI_DeleteObjectID | Removes the object identifier from a specified file or directory
_WinAPI_DeviceIoControl | Sends a control code directly to a specified device driver
_WinAPI_EjectMedia | Ejects media from a device
_WinAPI_GetCDType | Retrieves a type of the media which is loaded into a specified CD-ROM device
_WinAPI_GetDriveBusType | Retrieves a bus type for the specified drive
_WinAPI_GetDriveGeometryEx | Retrieves extended information about the disk's geometry
_WinAPI_GetDriveNumber | Retrieves a device type, device number, and partition number for the specified drive
_WinAPI_GetObjectID | Retrieves the object identifier for the specified file or directory
_WinAPI_IOCTL | Create a unique system I/O control code (IOCTL)
_WinAPI_IsDoorOpen | Checks if a CD (DVD) tray is open
_WinAPI_IsWritable | Determines whether a disk is writable
_WinAPI_LoadMedia | Loads media into a device


Function _WinAPI_CreateObjectID

Function Reference

_WinAPI_CreateObjectID

Creates or retrieves the object identifier for the specified file or directory

#include <WinAPIFiles.au3>
_WinAPI_CreateObjectID ( $sFilePath )

Parameters

$sFilePath Path to the file or directory to create or retrieve object identifier.

Return Value

Success: | $tagGUID structure that contains the object identifier for the file or directory within the volume on which it resides.
Failure: | Sets the @error flag to non-zero.

Remarks

If the object identifier of a file or directory does not already have one, the _WinAPI_CreateObjectID() creates it.
If the object identifier already exists, the function just returns it.

See Also

Search FSCTL_CREATE_OR_GET_OBJECT_ID in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIFiles.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

; Create temporary file
Local $sFile = _WinAPI_GetTempFileName(@TempDir)

; Create unique object ID for a file
Local $tGUID = _WinAPI_CreateObjectID($sFile)

ConsoleWrite('GUID: ' & _WinAPI_StringFromGUID($tGUID) & @CRLF)

; Open file by object ID and retrieve its full path
Local $hFile = _WinAPI_OpenFileById(_WinAPI_PathStripToRoot(@TempDir), $tGUID, 0, BitOR($FILE_SHARE_DELETE, $FILE_SHARE_READ, $FILE_SHARE_WRITE))
$sFile = _WinAPI_GetFinalPathNameByHandleEx($hFile)
_WinAPI_CloseHandle($hFile)

ConsoleWrite('Path: ' & StringRegExpReplace($sFile, '\\+.\\', '') & @CRLF)

; Delete file
FileDelete($sFile)


Function _WinAPI_DeleteObjectID

Function Reference

_WinAPI_DeleteObjectID

Removes the object identifier from a specified file or directory

#include <WinAPIFiles.au3>
_WinAPI_DeleteObjectID ( $sFilePath )

Parameters

$sFilePath Path to the file or directory from the object identifier that is to be deleted.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

The calling process must have $SE_BACKUP_NAME privilege, otherwise, the function fails, and _WinAPI_GetLastError() returns ERROR_ACCESS_DENIED (5).

See Also

Search FSCTL_DELETE_OBJECT_ID in MSDN Library.


Function _WinAPI_DeviceIoControl

Function Reference

_WinAPI_DeviceIoControl

Sends a control code directly to a specified device driver

#include <WinAPIFiles.au3>
_WinAPI_DeviceIoControl ( $hDevice, $iControlCode [, $pInBuffer = 0 [, $iInBufferSize = 0 [, $pOutBuffer = 0 [, $iOutBufferSize = 0]]]] )

Parameters

$hDevice | Handle to the device on which the operation is to be performed. The device is typically a volume, directory, file, or stream. To retrieve a device handle, use the _WinAPI_CreateFileEx() function. To specify a device name, use the following format: _WinAPI_CreateFileEx("\\.\DeviceName", ...)
$iControlCode | The control code for the operation. This value identifies the specific operation to be performed and the type of device on which to perform it.
$pInBuffer | [optional] A pointer to the input buffer that contains the data required to perform the operation.
$iInBufferSize | [optional] The size of the input buffer, in bytes. Default is 0.
$pOutBuffer | [optional] A pointer to the output buffer that is to receive the data returned by the operation.
$iOutBufferSize | [optional] The size of the output buffer, in bytes. Default is 0.

Return Value

Success: | True and @extended flag contains the size of the data stored in the output buffer, in bytes.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Related

_WinAPI_CreateFileEx

See Also

Search DeviceIoControl in MSDN Library.


Function _WinAPI_EjectMedia

Function Reference

_WinAPI_EjectMedia

Ejects media from a device

#include <WinAPIFiles.au3>
_WinAPI_EjectMedia ( $sDrive )

Parameters

$sDrive The drive letter of the CD tray to eject, in the format D:, E:, etc.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

See Also

Search IOCTL_STORAGE_EJECT_MEDIA in MSDN Library.

Example

#include <WinAPIFiles.au3>

Local $aDrive = DriveGetDrive('CDROM')

If IsArray($aDrive) Then
    ConsoleWrite('Open...' & @CRLF)
    _WinAPI_EjectMedia($aDrive[1])
    ConsoleWrite('Tray is open: ' & _WinAPI_IsDoorOpen($aDrive[1]) & @CRLF)
    Sleep(1000)
    ConsoleWrite('Close...' & @CRLF)
    _WinAPI_LoadMedia($aDrive[1])
    ConsoleWrite('Tray is open: ' & _WinAPI_IsDoorOpen($aDrive[1]) & @CRLF)
EndIf


Function _WinAPI_GetCDType

Function Reference

_WinAPI_GetCDType

Retrieves a type of the media which is loaded into a specified CD-ROM device

#include <WinAPIFiles.au3>
_WinAPI_GetCDType ( $sDrive )

Parameters

$sDrive The drive letter of the CD tray to retrieve information, in the format D:, E:, etc.

Return Value

Success: | The type of the media, it must be one of the following values. 0x0000 - No media 0x0008 - CD-ROM 0x0009 - CD-R 0x000A - CD-RW 0x0010 - DVD-ROM 0x0011 - DVD-R Sequential Recording 0x0012 - DVD-RAM 0x0013 - DVD-RW Restricted Overwrite 0x0014 - DVD-RW Sequential Recording 0x0015 - DVD-R Dual Layer 0x0016 - DVD-R Dual Layer Jump Recording 0x0017 - DVD-RW Dual Layer 0x0018 - DVD-Download Disc Recording 0x001A - DVD+RW 0x001B - DVD+R 0x0040 - BD-ROM 0x0041 - BD-R Sequential Recording Mode (SRM) 0x0042 - BD-R Random Recording Mode (RRM) 0x0043 - BD-RE 0x0050 - HD DVD-ROM 0x0051 - HD DVD-R 0x0052 - HD DVD-RAM 0x0053 - HD DVD-RW 0x0058 - HD DVD-R Dual Layer 0x005A - HD DVD-RW Dual Layer 0xFFFF - Unknown
Failure: | 0 and sets the @error flag to non-zero.

See Also

Search IOCTL_SCSI_PASS_THROUGH in MSDN Library.

Example

#include <WinAPIFiles.au3>

Local $sText, $iType, $aDrive = DriveGetDrive('CDROM')
If IsArray($aDrive) Then
    For $i = 1 To $aDrive[0]
        $sText = 'Unknown'
        $iType = _WinAPI_GetCDType($aDrive[$i])
        If Not @error Then
            Switch $iType
                Case 0x0000
                    $sText = 'No media'
                Case 0x0008
                    $sText = 'CD-ROM'
                Case 0x0009
                    $sText = 'CD-R'
                Case 0x000A
                    $sText = 'CD-RW'
                Case 0x0010
                    $sText = 'DVD-ROM'
                Case 0x0011
                    $sText = 'DVD-R SR'
                Case 0x0012
                    $sText = 'DVD-RAM'
                Case 0x0013
                    $sText = 'DVD-RW RO'
                Case 0x0014
                    $sText = 'DVD-RW SR'
                Case 0x0015
                    $sText = 'DVD-R DL'
                Case 0x0016
                    $sText = 'DVD-R DL JR'
                Case 0x0017
                    $sText = 'DVD-RW DL'
                Case 0x0018
                    $sText = 'DVD-DDR'
                Case 0x001A
                    $sText = 'DVD+RW'
                Case 0x001B
                    $sText = 'DVD+R'
                Case 0x0040
                    $sText = 'BD-ROM'
                Case 0x0041
                    $sText = 'BD-R SRM'
                Case 0x0042
                    $sText = 'BD-R RRM'
                Case 0x0043
                    $sText = 'BD-RE'
                Case 0x0050
                    $sText = 'HD DVD-ROM'
                Case 0x0051
                    $sText = 'HD DVD-R'
                Case 0x0052
                    $sText = 'HD DVD-RAM'
                Case 0x0053
                    $sText = 'HD DVD-RW'
                Case 0x0058
                    $sText = 'HD DVD-R DL'
                Case 0x005A
                    $sText = 'HD DVD-RW DL'
            EndSwitch
        EndIf
        ConsoleWrite(StringUpper($aDrive[$i]) & ' => ' & $sText & @CRLF)
    Next
EndIf


Function _WinAPI_GetDriveBusType

Function Reference

_WinAPI_GetDriveBusType

Retrieves a bus type for the specified drive

#include <WinAPIFiles.au3>
_WinAPI_GetDriveBusType ( $sDrive )

Parameters

$sDrive The drive letter to retrieve information, in the format D:, E:, etc.

Return Value

Success: | The bus type constant ($DRIVE_BUS_TYPE_*).
Failure: | (-1) and sets the @error flag to non-zero.

Remarks

$DRIVE_BUS_TYPE_* constants require #include <APIFilesConstants.au3>

This function works with the Plug and Play drivers only.

See Also

Search IOCTL_STORAGE_QUERY_PROPERTY in MSDN Library.

Example

#include <APIFilesConstants.au3>
#include <WinAPIFiles.au3>

Local $iBus, $sText, $aDrive = DriveGetDrive('ALL')
For $i = 1 To $aDrive[0]
    $iBus = _WinAPI_GetDriveBusType($aDrive[$i])
    Switch $iBus
        Case $DRIVE_BUS_TYPE_UNKNOWN
            $sText = 'UNKNOWN'
        Case $DRIVE_BUS_TYPE_SCSI
            $sText = 'SCSI'
        Case $DRIVE_BUS_TYPE_ATAPI
            $sText = 'ATAPI'
        Case $DRIVE_BUS_TYPE_ATA
            $sText = 'ATA'
        Case $DRIVE_BUS_TYPE_1394
            $sText = '1394'
        Case $DRIVE_BUS_TYPE_SSA
            $sText = 'SSA'
        Case $DRIVE_BUS_TYPE_FIBRE
            $sText = 'FIBRE'
        Case $DRIVE_BUS_TYPE_USB
            $sText = 'USB'
        Case $DRIVE_BUS_TYPE_RAID
            $sText = 'RAID'
        Case $DRIVE_BUS_TYPE_ISCSI
            $sText = 'ISCSI'
        Case $DRIVE_BUS_TYPE_SAS
            $sText = 'SAS'
        Case $DRIVE_BUS_TYPE_SATA
            $sText = 'SATA'
        Case $DRIVE_BUS_TYPE_SD
            $sText = 'SD'
        Case $DRIVE_BUS_TYPE_MMC
            $sText = 'MMC'
    EndSwitch
    ConsoleWrite(StringUpper($aDrive[$i]) & ' => ' & $sText & @CRLF)
Next


Function _WinAPI_GetDriveGeometryEx

Function Reference

_WinAPI_GetDriveGeometryEx

Retrieves extended information about the disk's geometry

#include <WinAPIFiles.au3>
_WinAPI_GetDriveGeometryEx ( $iDrive )

Parameters

$iDrive The physical drive number (0, 1, 2, etc) to retrieve information.

Return Value

Success: | The array containing the following information: [0] - The number of cylinders. [1] - The type of media. [2] - The number of tracks per cylinder. [3] - The number of sectors per track. [4] - The number of bytes per sector. [5] - The disk size, in bytes.
Failure: | Sets the @error flag to non-zero.

See Also

Search IOCTL_DISK_GET_DRIVE_GEOMETRY_EX in MSDN Library.

Example

#include <WinAPIFiles.au3>

Local $aData, $iDrive = 0

While 1
    $aData = _WinAPI_GetDriveGeometryEx($iDrive)
    If @error Then
        ExitLoop
    EndIf
    If Not $iDrive Then
        ConsoleWrite('-------------------------------' & @CRLF)
    EndIf
    ConsoleWrite('Drive: ' & $iDrive & @CRLF)
    ConsoleWrite('Cylinders: ' & $aData[0] & @CRLF)
    ConsoleWrite('Tracks per Cylinder: ' & $aData[2] & @CRLF)
    ConsoleWrite('Sectors per Track: ' & $aData[3] & @CRLF)
    ConsoleWrite('Bytes per Sector: ' & $aData[4] & @CRLF)
    ConsoleWrite('Total Space: ' & $aData[5] & ' bytes' & @CRLF)
    ConsoleWrite('-------------------------------' & @CRLF)
    $iDrive += 1
WEnd


Function _WinAPI_GetDriveNumber

Function Reference

_WinAPI_GetDriveNumber

Retrieves a device type, device number, and partition number for the specified drive

#include <WinAPIFiles.au3>
_WinAPI_GetDriveNumber ( $sDrive )

Parameters

$sDrive The drive letter to retrieve information, in the format D:, E:, etc.

Return Value

Success: | The array containing the following information: [0] - The type of device ($FILE_DEVICE_*). [1] - The device number. [2] - The partition number, or (-1) if device cannot be partitioned.
Failure: | Sets the @error flag to non-zero.

See Also

Search IOCTL_STORAGE_GET_DEVICE_NUMBER in MSDN Library.

Example

#include <WinAPIFiles.au3>

Local $aData, $aDrive = DriveGetDrive('FIXED')
Local $aList[10]

For $i = 0 To UBound($aDrive) - 1
    $aList[$i] = ''
Next
If IsArray($aDrive) Then
    For $i = 1 To $aDrive[0]
        $aData = _WinAPI_GetDriveNumber($aDrive[$i])
        If IsArray($aData) Then
            $aList[$aData[1]] &= StringUpper($aDrive[$i]) & ' '
        EndIf
    Next
EndIf
For $i = 0 To UBound($aDrive) - 1
    If $aList[$i] Then
        ConsoleWrite('Drive' & $i & ' => ' & $aList[$i] & @CRLF)
    EndIf
Next


Function _WinAPI_GetObjectID

Function Reference

_WinAPI_GetObjectID

Retrieves the object identifier for the specified file or directory

#include <WinAPIFiles.au3>
_WinAPI_GetObjectID ( $sFilePath )

Parameters

$sFilePath Path to the file or directory from which the object identifier is to be retrieved.

Return Value

Success: | $tagGUID structure that contains the object identifier for the file or directory within the volume on which it resides.
Failure: | Sets the @error flag to non-zero.

Remarks

Unlike _WinAPI_CreateObjectID(), this function only returns the object identifier. If a file or directory does not
have an object identifier, the function fails.

Related

_WinAPI_CreateObjectID

See Also

Search FSCTL_GET_OBJECT_ID in MSDN Library.


Function _WinAPI_IOCTL

Function Reference

_WinAPI_IOCTL

Create a unique system I/O control code (IOCTL)

#include <WinAPIFiles.au3>
_WinAPI_IOCTL ( $iDeviceType, $iFunction, $iMethod, $iAccess )

Parameters

$iDeviceType | The type of device.
$iFunction | The action within the device category.
$iMethod | The method codes for how buffers are passed for I/O and file system controls.
$iAccess | The access check value for any access.

Return Value

Returns the IOCTL (DWORD) value.

See Also

See Defining I/O Control Codes.


Function _WinAPI_IsDoorOpen

Function Reference

_WinAPI_IsDoorOpen

Checks if a CD (DVD) tray is open

#include <WinAPIFiles.au3>
_WinAPI_IsDoorOpen ( $sDrive )

Parameters

$sDrive The drive letter of the CD tray to check, in the format D:, E:, etc.

Return Value

Success: | True - CD (DVD) tray is open. False - Otherwise.
Failure: | Sets the @error flag to non-zero.

See Also

Search IOCTL_SCSI_PASS_THROUGH in MSDN Library.

Example

#include <WinAPIFiles.au3>

Local $aDrive = DriveGetDrive('CDROM')

If IsArray($aDrive) Then
    ConsoleWrite('Open...' & @CRLF)
    _WinAPI_EjectMedia($aDrive[1])
    ConsoleWrite('Tray is open: ' & _WinAPI_IsDoorOpen($aDrive[1]) & @CRLF)
    Sleep(1000)
    ConsoleWrite('Close...' & @CRLF)
    _WinAPI_LoadMedia($aDrive[1])
    ConsoleWrite('Tray is open: ' & _WinAPI_IsDoorOpen($aDrive[1]) & @CRLF)
EndIf


Function _WinAPI_IsWritable

Function Reference

_WinAPI_IsWritable

Determines whether a disk is writable

#include <WinAPIFiles.au3>
_WinAPI_IsWritable ( $sDrive )

Parameters

$sDrive The drive letter of the disk to check, in the format D:, E:, etc.

Return Value

Success: | True - The disk is writable. False - Otherwise.
Failure: | Sets the @error flag to non-zero, @extended is set to last system error code.

Remarks

The last error code = 41 means that the device is not ready, no media mounted.

See Also

Search IOCTL_DISK_IS_WRITABLE in MSDN Library.

Example

#include <WinAPI.au3>
#include <WinAPIFiles.au3>

Local $aDrive = DriveGetDrive('ALL')

If IsArray($aDrive) Then
    Local $sText
    For $i = 1 To $aDrive[0]
        If _WinAPI_IsWritable($aDrive[$i]) Then
            $sText = 'Writable'
        Else
            If @error Then
                $sText = 'No media'
                If @extended Then $sText &= ' ( @error=' & @error & ' LastError=' & _WinAPI_GetLastErrorMessage() & ')'
            Else
                $sText = 'Not writable'
            EndIf
        EndIf
        ConsoleWrite(StringUpper($aDrive[$i]) & ' => ' & $sText & @CRLF)
    Next
EndIf


Function _WinAPI_LoadMedia

Function Reference

_WinAPI_LoadMedia

Loads media into a device

#include <WinAPIFiles.au3>
_WinAPI_LoadMedia ( $sDrive )

Parameters

$sDrive The drive letter of the CD tray to load, in the format D:, E:, etc.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.

See Also

Search IOCTL_STORAGE_LOAD_MEDIA in MSDN Library.

Example

#include <WinAPIFiles.au3>

Local $aDrive = DriveGetDrive('CDROM')

If IsArray($aDrive) Then
    ConsoleWrite('Open...' & @CRLF)
    _WinAPI_EjectMedia($aDrive[1])
    ConsoleWrite('Tray is open: ' & _WinAPI_IsDoorOpen($aDrive[1]) & @CRLF)
    Sleep(1000)
    ConsoleWrite('Close...' & @CRLF)
    _WinAPI_LoadMedia($aDrive[1])
    ConsoleWrite('Tray is open: ' & _WinAPI_IsDoorOpen($aDrive[1]) & @CRLF)
EndIf


User Defined Functions

Files user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIFiles.au3>.

User Defined Function | Description
_WinAPI_CopyFileEx | Copies an existing file to a new file, notifying the application of its progress through a callback function
_WinAPI_CreateDirectory | Creates a new directory
_WinAPI_CreateDirectoryEx | Creates a new directory with the attributes of a specified template directory
_WinAPI_CreateFileEx | Creates or opens a file or I/O device
_WinAPI_CreateFileMapping | Creates or opens a named or unnamed file mapping object for a specified file
_WinAPI_CreateHardLink | Establishes a hard link between an existing file and a new file
_WinAPI_CreateSymbolicLink | Creates a symbolic link
_WinAPI_DecryptFile | Decrypts an encrypted file or directory
_WinAPI_DeleteFile | Deletes an existing file
_WinAPI_DeleteVolumeMountPoint | Deletes a drive letter or mounted folder
_WinAPI_DuplicateEncryptionInfoFile | Copies the EFS metadata from one file or directory to another
_WinAPI_EncryptFile | Encrypts a file or directory
_WinAPI_EncryptionDisable | Disables or enables encryption of the specified directory and the files in it
_WinAPI_EnumFiles | Enumerates the files and subdirectories for the specified directory with a name that matches the template
_WinAPI_EnumFileStreams | Enumerates all streams with a ::$DATA stream type in the specified file or directory
_WinAPI_EnumHardLinks | Enumerates all the hard links to the specified file
_WinAPI_FileEncryptionStatus | Retrieves the encryption status of the specified file
_WinAPI_FileExists | Tests whether the specified path is existing file
_WinAPI_FileInUse | Tests whether the specified file in use by another application
_WinAPI_FindClose | Closes a file search handle
_WinAPI_FindCloseChangeNotification | Stops change notification handle monitoring
_WinAPI_FindFirstChangeNotification | Creates a change notification handle and sets up initial change notification filter conditions
_WinAPI_FindFirstFile | Searches a directory for a file or subdirectory with a name that matches a specific name
_WinAPI_FindFirstFileName | Creates an enumeration of all the hard links to the specified file
_WinAPI_FindFirstStream | Enumerates the first stream with a ::$DATA stream type in the specified file or directory
_WinAPI_FindNextChangeNotification | Requests that the operating system signal a change notification handle the next time it detects an appropriate change
_WinAPI_FindNextFile | Continues a file or directory search
_WinAPI_FindNextFileName | Continues enumerating the hard links
_WinAPI_FindNextStream | Continues a stream search
_WinAPI_FlushViewOfFile | Writes to the disk a byte range within a mapped view of a file
_WinAPI_GetBinaryType | Determines whether a file is an executable (.exe) file, and if so, which subsystem runs the executable file
_WinAPI_GetCompressedFileSize | Retrieves the actual number of bytes of disk storage used to store a specified file
_WinAPI_GetCompression | Retrieves the current compression state of a file or directory
_WinAPI_GetCurrentDirectory | Retrieves the current directory for the current process
_WinAPI_GetDiskFreeSpaceEx | Retrieves information about the amount of space that is available on a disk volume
_WinAPI_GetFileAttributes | Retrieves file system attributes for a specified file or directory
_WinAPI_GetFileID | Retrieves the file system's 8-byte file reference number for a file
_WinAPI_GetFileInformationByHandle | Retrieves file information for the specified file
_WinAPI_GetFileInformationByHandleEx | Retrieves file information for the specified file
_WinAPI_GetFilePointerEx | Retrieves the file pointer of the specified file
_WinAPI_GetFileSizeOnDisk | Retrieves the file allocation size on disk
_WinAPI_GetFileTitle | Retrieves the name of the specified file
_WinAPI_GetFileType | Retrieves the file type of the specified file
_WinAPI_GetFinalPathNameByHandle | Retrieves the final path of the specified file
_WinAPI_GetFinalPathNameByHandleEx | Retrieves the final path of the specified file
_WinAPI_GetFullPathName | Retrieves the full path and file name of the specified file
_WinAPI_GetProfilesDirectory | Retrieves the path to the root directory where user profiles are stored
_WinAPI_GetTempFileName | Creates a name for a temporary file
_WinAPI_GetVolumeInformation | Retrieves information about the file system and volume associated with the specified root directory
_WinAPI_GetVolumeInformationByHandle | Retrieves information about the file system and volume associated with the specified file
_WinAPI_GetVolumeNameForVolumeMountPoint | Retrieves a volume GUID path for the volume that is associated with the specified volume mount point
_WinAPI_IsPathShared | Determines whether the path is shared
_WinAPI_LockDevice | Enables or disables the mechanism that ejects media, for those devices possessing that locking capability
_WinAPI_LockFile | Locks the specified file for exclusive access by the calling process
_WinAPI_MapViewOfFile | Maps a view of a file mapping into the address space of a calling process
_WinAPI_MoveFileEx | Moves a file or directory, notifying the application of its progress through a callback function
_WinAPI_OpenFileById | Opens the file that matches the specified object identifier
_WinAPI_OpenFileMapping | Opens a named file mapping object
_WinAPI_PathIsDirectory | Verifies that a path is a valid directory
_WinAPI_PathIsDirectoryEmpty | Determines whether a specified path is an empty directory
_WinAPI_ReadDirectoryChanges | Retrieves information that describes the changes within the specified directory
_WinAPI_RemoveDirectory | Deletes an existing empty directory
_WinAPI_ReOpenFile | Reopens the specified file system object with different access rights, sharing mode, and flags
_WinAPI_ReplaceFile | Replaces one file with another file, and creates a backup copy of the original file
_WinAPI_SearchPath | Searches for a specified file in a specified path
_WinAPI_SetCompression | Sets the compression state of a file or directory
_WinAPI_SetCurrentDirectory | Changes the current directory for the current process
_WinAPI_SetFileAttributes | Sets the attributes for a file or directory
_WinAPI_SetFileInformationByHandleEx | Sets the file information for the specified file
_WinAPI_SetFilePointerEx | Moves the file pointer of the specified file
_WinAPI_SetFileShortName | Sets the short name for the specified file
_WinAPI_SetFileValidData | Sets the valid data length of the specified file
_WinAPI_SetSearchPathMode | Sets the per-process mode that the _WinAPI_SearchPath() function uses when locating files
_WinAPI_SetVolumeMountPoint | Associates a volume with a drive letter or a directory on another volume
_WinAPI_SfcIsFileProtected | Determines whether the specified file is protected
_WinAPI_UnlockFile | Unlocks a region in an open file
_WinAPI_UnmapViewOfFile | Unmaps a mapped view of a file from the calling process's address space


Function _WinAPI_CopyFileEx

Function Reference

_WinAPI_CopyFileEx

Copies an existing file to a new file, notifying the application of its progress through a callback function

#include <WinAPIFiles.au3>
_WinAPI_CopyFileEx ( $sExistingFile, $sNewFile [, $iFlags = 0 [, $pProgressProc = 0 [, $pData = 0]]] )

Parameters

$sExistingFile | The name of an existing file.
$sNewFile | The name of the new file.
$iFlags | [optional] The flags that specify how the file is to be copied. This parameter can be a combination of the following values: $COPY_FILE_ALLOW_DECRYPTED_DESTINATION (0x0008) $COPY_FILE_COPY_SYMLINK (0x0800) $COPY_FILE_FAIL_IF_EXISTS (0x0001) $COPY_FILE_NO_BUFFERING (0x1000) $COPY_FILE_OPEN_SOURCE_FOR_WRITE (0x0004) $COPY_FILE_RESTARTABLE (0x0002)
$pProgressProc | [optional] The address of a callback function that is called each time another portion of the file has been copied. (See MSDN for more information)
$pData | [optional] pointer to an argument to be passed to the callback function. Can be NULL.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

$COPY_* , $PROGRESS_* constants require #include <APIFilesConstants.au3>

See Also

Search CopyFileEx in MSDN Library.

Example

#include <APIFilesConstants.au3>
#include <Misc.au3>
#include <WinAPIDiag.au3>
#include <WinAPIFiles.au3>

Opt('TrayAutoPause', 0)

Local $hProgressProc = DllCallbackRegister('_ProgressProc', 'bool', 'uint64;uint64;uint64;uint64;dword;dword;handle;handle;ptr')

FileDelete(@TempDir & '\Test*.tmp')

ProgressOn('_WinAPI_CopyFileEx()', 'Bigfile Creation...', '')
Local $sFile = @TempDir & '\Test.tmp'
Local $hFile = FileOpen($sFile, 2)
For $i = 1 To 1000000
    FileWriteLine($hFile, "                                                     ")
Next
FileClose($hFile)

ProgressOn('_WinAPI_CopyFileEx()', 'Copying...', '0%')

If Not _WinAPI_CopyFileEx($sFile, @TempDir & '\Test1.tmp', 0, DllCallbackGetPtr($hProgressProc)) Then
    _WinAPI_ShowLastError('Error copying ' & $sFile)
EndIf

DllCallbackFree($hProgressProc)

ProgressOff()

FileDelete(@TempDir & '\Test*.tmp')

Func _ProgressProc($iTotalFileSize, $iTotalBytesTransferred, $iStreamSize, $iStreamBytesTransferred, $iStreamNumber, $iCallbackReason, $hSourceFile, $hDestinationFile, $pData)
    #forceref $iStreamSize, $iStreamBytesTransferred, $iStreamNumber, $iCallbackReason, $hSourceFile, $hDestinationFile, $pData

    Local $iPercent = Round($iTotalBytesTransferred / $iTotalFileSize * 100)
    If $iPercent = 100 Then
        ProgressSet($iPercent, '', 'Complete')
    Else
        ProgressSet($iPercent, $iPercent & '%')
    EndIf
    Sleep(10) ; to slow down to see the progress bar

    If _IsPressed('1B') Then
        Return $PROGRESS_CANCEL
    Else
        Return $PROGRESS_CONTINUE
    EndIf
EndFunc   ;==>_ProgressProc


Function _WinAPI_CreateDirectory

Function Reference

_WinAPI_CreateDirectory

Creates a new directory

#include <WinAPIFiles.au3>
_WinAPI_CreateDirectory ( $sDir [, $tSecurity = 0] )

Parameters

$sDir | The path of the directory to be created.
$tSecurity | [optional] $tagSECURITY_ATTRIBUTES structure that specifies a security descriptor for the new directory. If this parameter is 0 (Default), the directory gets a default security descriptor. The ACL in the default security descriptor for a directory are inherited from its parent directory.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

See Also

Search CreateDirectory in MSDN Library.


Function _WinAPI_CreateDirectoryEx

Function Reference

_WinAPI_CreateDirectoryEx

Creates a new directory with the attributes of a specified template directory

#include <WinAPIFiles.au3>
_WinAPI_CreateDirectoryEx ( $sNewDir, $sTemplateDir [, $tSecurity = 0] )

Parameters

$sNewDir | The path of the directory to be created.
$sTemplateDir | The path of the directory to use as a template when creating the new directory.
$tSecurity | [optional] $tagSECURITY_ATTRIBUTES structure that specifies a security descriptor for the new directory. If this parameter is 0 (Default), the directory gets a default security descriptor. The ACL in the default security descriptor for a directory are inherited from its parent directory.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

The _WinAPI_CreateDirectoryEx() function allows you to create directories that inherit stream information from other directories.
This function is useful, for example, when you are using Macintosh directories, which have a resource stream that is needed to properly identify directory contents as an attribute.

See Also

Search CreateDirectoryEx in MSDN Library.


Function _WinAPI_CreateFileEx

Function Reference

_WinAPI_CreateFileEx

Creates or opens a file or I/O device

#include <WinAPIFiles.au3>
_WinAPI_CreateFileEx ( $sFilePath, $iCreation [, $iAccess = 0 [, $iShare = 0 [, $iFlagsAndAttributes = 0 [, $tSecurity = 0 [, $hTemplate = 0]]]]] )

Parameters

$sFilePath | The name of the file or device to be created or opened.
$iCreation | The action to take on a file or device that exists or does not exist. This parameter must be one of the following values, which cannot be combined. $CREATE_NEW $CREATE_ALWAYS $OPEN_EXISTING $OPEN_ALWAYS $TRUNCATE_EXISTING
$iAccess | [optional] The requested access to the file or device, which can be summarized as read, write, both or neither (zero) (Default). $GENERIC_READ $GENERIC_WRITE (See MSDN for more information)
$iShare | [optional] The requested sharing mode of the file or device, which can be read, write, both, delete, all of these, or none. If this parameter is 0 (Default) and _WinAPI_CreateFileEx() succeeds, the file or device cannot be shared and cannot be opened again until the handle to the file or device is closed. $FILE_SHARE_DELETE $FILE_SHARE_READ $FILE_SHARE_WRITE
$iFlagsAndAttributes | [optional] The file or device attributes and flags. This parameter can be one or more of the following values: $FILE_ATTRIBUTE_READONLY $FILE_ATTRIBUTE_HIDDEN $FILE_ATTRIBUTE_SYSTEM $FILE_ATTRIBUTE_DIRECTORY $FILE_ATTRIBUTE_ARCHIVE $FILE_ATTRIBUTE_DEVICE $FILE_ATTRIBUTE_NORMAL $FILE_ATTRIBUTE_TEMPORARY $FILE_ATTRIBUTE_SPARSE_FILE $FILE_ATTRIBUTE_REPARSE_POINT $FILE_ATTRIBUTE_COMPRESSED $FILE_ATTRIBUTE_OFFLINE $FILE_ATTRIBUTE_NOT_CONTENT_INDEXED $FILE_ATTRIBUTE_ENCRYPTED $FILE_FLAG_BACKUP_SEMANTICS $FILE_FLAG_DELETE_ON_CLOSE $FILE_FLAG_NO_BUFFERING $FILE_FLAG_OPEN_NO_RECALL $FILE_FLAG_OPEN_REPARSE_POINT $FILE_FLAG_OVERLAPPED $FILE_FLAG_POSIX_SEMANTICS $FILE_FLAG_RANDOM_ACCESS $FILE_FLAG_SEQUENTIAL_SCAN $FILE_FLAG_WRITE_THROUGH $SECURITY_ANONYMOUS (Default) $SECURITY_CONTEXT_TRACKING $SECURITY_DELEGATION $SECURITY_EFFECTIVE_ONLY $SECURITY_IDENTIFICATION $SECURITY_IMPERSONATION
$tSecurity | [optional] $tagSECURITY_ATTRIBUTES structure that contains two separate but related data members: an optional security descriptor, and a Boolean value that determines whether the returned handle can be inherited by child processes. If this parameter is 0 (Default), the handle cannot be inherited by any child processes the application may create and the file or device associated with the returned handle gets a default security descriptor.
$hTemplate | [optional] Handle to a template file with the $GENERIC_READ access right. The template file supplies file attributes and extended attributes for the file that is being created.

Return Value

Success: | Handle to the specified file, device, named pipe, or mail slot.
Failure: | 0 and sets the @error flag to non-zero, @extended contains _WinAPI_GetLastError().

Remarks

When an application is finished using the object handle returned by this function, use the _WinAPI_CloseHandle() function to close the handle.
This not only frees up system resources, but can have wider influence on things like sharing the file or device and committing data to disk.

Related

_WinAPI_CloseHandle

See Also

Search CreateFile in MSDN Library.


Function _WinAPI_CreateFileMapping

Function Reference

_WinAPI_CreateFileMapping

Creates or opens a named or unnamed file mapping object for a specified file

#include <WinAPIFiles.au3>
_WinAPI_CreateFileMapping ( $hFile [, $iSize = 0 [, $sName = '' [, $iProtect = 0x0004 [, $tSecurity = 0]]]] )

Parameters

$hFile | Handle to the file from which to create a file mapping object. If this parameter is (-1), the calling process must also specify a size for the file mapping object in the $iSize parameters. In this scenario, _WinAPI_CreateFileMapping() creates a file mapping object of a specified size that is backed by the system paging file instead of by a file in the file system.
$iSize | [optional] The maximum size of the file mapping object. If this parameter is 0 (Default), the maximum size of the file mapping object is equal to the current size of the file that $hFile identifies.
$sName | [optional] The name of the file mapping object.
$iProtect | [optional] Specifies the page protection of the file mapping object and can be one of the following values. $PAGE_EXECUTE_READ $PAGE_EXECUTE_READWRITE $PAGE_EXECUTE_WRITECOPY $PAGE_READONLY $PAGE_READWRITE (Default) $PAGE_WRITECOPY An application can specify one or more of the following attributes for the file mapping object by combining them with one of the preceding page protection values. $SEC_COMMIT $SEC_IMAGE $SEC_LARGE_PAGES $SEC_NOCACHE $SEC_RESERVE $SEC_WRITECOMBINE
$tSecurity | [optional] $tagSECURITY_ATTRIBUTES structure that determines whether a returned handle can be inherited by child processes. If this parameter is 0 (Default), the handle cannot be inherited and the file mapping object gets a default security descriptor.

Return Value

Success: | Handle to the newly created file mapping object. If the object exists before the function call, the function returns a handle to the existing object (with its current size, not the specified size), and sets the @extended flag to $ERROR_ALREADY_EXISTS (183).
Failure: | 0, @extended flag is set to _WinAPI_GetLastError().

Remarks

After a file mapping object is created, the size of the file must not exceed the size of the file mapping object; if it does, not all of the file contents are available for sharing.

Multiple processes can share a view of the same file by either using a single shared file mapping object or creating separate file mapping objects backed by the same file. A single file mapping object can be shared by multiple processes through inheriting the handle at process creation, duplicating the handle, or opening the file mapping object by name.

A file mapping object does not actually map the view into a process address space. The _WinAPI_MapViewOfFile() functions map a view of a file into a process address space.

Mapped views of a file mapping object maintain internal references to the object, and a file mapping object does not close until all references to it are released.
Therefore, to fully close a file mapping object, an application must unmap all mapped views of the file mapping object by calling _WinAPI_UnmapViewOfFile() and close the file mapping object handle by calling _WinAPI_CloseHandle().
These functions can be called in any order.

Related

_WinAPI_CloseHandle, _WinAPI_UnmapViewOfFile

See Also

Search CreateFileMapping in MSDN Library.

Example

#NoTrayIcon

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIFiles.au3>

Opt('WinWaitDelay', 0)

Global Const $g_sTitle = '_WinAPI_MapViewOfFile' & ChrW(160)

If Not $CmdLine[0] Then
    If WinExists($g_sTitle) Then
        Exit
    EndIf
    For $i = 1 To 2
        If Not @Compiled Then
            Run(@AutoItExe & ' "' & @ScriptFullPath & '" /' & $i)
        Else
            Run(@AutoItExe & ' /' & $i)
        EndIf
        Sleep(500)
    Next
    Exit
EndIf

Opt('TrayIconHide', 0)

Switch $CmdLine[1]
    Case '/1'
        _Sender()
    Case '/2'
        _Receiver()
    Case Else
        Exit
EndSwitch

Func _Receiver()
    Local $hMapping = _WinAPI_OpenFileMapping('MyFileMapping')
    If Not $hMapping Then Return

    Local $pAddress = _WinAPI_MapViewOfFile($hMapping)
    Local $tData = DllStructCreate('wchar[1024]', $pAddress)
    Local $sText
    While WinWait($g_sTitle, '', 1)
        Sleep(200)
        $sText = DllStructGetData($tData, 1)
        DllStructSetData($tData, 1, '')
        If $sText Then MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), $g_sTitle & " (receiver)", "                                               " & @CRLF & $sText)
    WEnd
    _WinAPI_UnmapViewOfFile($pAddress)
    _WinAPI_CloseHandle($hMapping)
EndFunc   ;==>_Receiver

Func _Sender()
    Local $hMapping = _WinAPI_CreateFileMapping(-1, 2048, 'MyFileMapping')
    If Not $hMapping Or @extended Then
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create file mapping (@extended=' & @extended & ').')
        Return
    EndIf

    Local $pAddress = _WinAPI_MapViewOfFile($hMapping)
    Local $tData = DllStructCreate('wchar[1024]', $pAddress)
    Local $sText
    While WinWaitClose($g_sTitle)
        $sText = StringStripWS(InputBox($g_sTitle & " (sender)", 'Type some text message.', '', '', -1, 171), 3)
        If Not $sText Then
            ExitLoop
        EndIf
        DllStructSetData($tData, 1, $sText)
        If Not WinWait($g_sTitle, '', 1) Then
            ExitLoop
        EndIf
    WEnd
    _WinAPI_UnmapViewOfFile($pAddress)
    _WinAPI_CloseHandle($hMapping)
EndFunc   ;==>_Sender


Function _WinAPI_CreateHardLink

Function Reference

_WinAPI_CreateHardLink

Establishes a hard link between an existing file and a new file

#include <WinAPIFiles.au3>
_WinAPI_CreateHardLink ( $sNewFile, $sExistingFile )

Parameters

$sNewFile | The name of the new file.
$sExistingFile | The name of the existing file.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

The _WinAPI_CreateHardLink() is only supported on the NTFS file system, and only for files, not directories.

The security descriptor belongs to the file to which a hard link points. The link itself is only a directory entry, and does not have a security descriptor.
Therefore, when you change the security descriptor of a hard link, you a change the security descriptor of the underlying file, and all hard links that point to the file allow the newly specified access.
You cannot give a file different security descriptors on a per-hard-link basis.

Use _WinAPI_DeleteFile() function to delete hard links. You can delete them in any order regardless of the order in which they are created.

Related

_WinAPI_DeleteFile

See Also

Search CreateHardLink in MSDN Library.

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Local $sFile = @DesktopDir & '\' & StringRegExpReplace(_WinAPI_PathFindFileName(@ScriptName), '\A_+', '@')

; Create hard link to the current file with prefix "@" on your Desktop
If Not _WinAPI_CreateHardLink($sFile, @ScriptFullPath) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create hard link.')
    Exit
EndIf

; Enumerate all hard links to the file
Local $aData = _WinAPI_EnumHardLinks($sFile)

_ArrayDisplay($aData, '_WinAPI_EnumHardLinks')

FileDelete($sFile)


Function _WinAPI_CreateSymbolicLink

Function Reference

_WinAPI_CreateSymbolicLink

Creates a symbolic link

#include <WinAPIFiles.au3>
_WinAPI_CreateSymbolicLink ( $sSymlink, $sTarget [, $bDirectory = False] )

Parameters

$sSymlink | The name of the new file.
$sTarget | The name of the existing file.
$bDirectory | [optional] Specifies whether the link target is a directory. True - The link target is a directory. False - The link target is a file (Default).

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

To remove a symbolic link, delete the file (using _WinAPI_DeleteFile() or similar APIs) or remove the directory
(using _WinAPI_RemoveDirectory() or similar APIs) depending on what type of symbolic link is used.

The calling process must have $SE_CREATE_SYMBOLIC_LINK_NAME privilege, otherwise, the function fails, and
_WinAPI_GetLastError() returns ERROR_PRIVILEGE_NOT_HELD (1314).

This function requires Windows Vista or later.

Related

_WinAPI_DeleteFile, _WinAPI_RemoveDirectory

See Also

Search CreateSymbolicLink in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPIFiles.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

; Enable "SeCreateSymbolicLinkPrivilege" privilege to create a symbolic links
Local $hToken = _WinAPI_OpenProcessToken(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))
Local $aAdjust
_WinAPI_AdjustTokenPrivileges($hToken, $SE_CREATE_SYMBOLIC_LINK_NAME, $SE_PRIVILEGE_ENABLED, $aAdjust)
If @error Or @extended Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'You do not have the required privileges.')
    Exit
EndIf

; Create symbolic link to the directory where this file is located with prefix "@" on your Desktop
If Not _WinAPI_CreateSymbolicLink(@DesktopDir & '\' & StringRegExpReplace(@ScriptDir, '^.*\\', '@'), @ScriptDir, 1) Then
    _WinAPI_ShowLastError()
EndIf

; Restore "SeCreateSymbolicLinkPrivilege" privilege by default
_WinAPI_AdjustTokenPrivileges($hToken, $aAdjust, 0, $aAdjust)
_WinAPI_CloseHandle($hToken)


Function _WinAPI_DecryptFile

Function Reference

_WinAPI_DecryptFile

Decrypts an encrypted file or directory

#include <WinAPIFiles.au3>
_WinAPI_DecryptFile ( $sFilePath )

Parameters

$sFilePath The name of the file or directory to be decrypted. If $sFilePath specifies a read-only file, the function fails and the last error code is ERROR_FILE_READ_ONLY (6009). If $sFilePath specifies a directory that contains a read-only file, the functions succeeds but the directory is not decrypted.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

The _WinAPI_DecryptFile() function requires exclusive access to the file being decrypted, and will fail if another process is using the file.

If the file is not encrypted, the function simply returns a nonzero value, which indicates success.

See Also

Search DecryptFile in MSDN Library.

Example

#include <APIFilesConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Local $sFile = FileOpenDialog('Select File', @ScriptDir, 'All Files (*.*)', 1 + 2)
If @error Then Exit

Switch _WinAPI_FileEncryptionStatus($sFile)
    Case $FILE_ENCRYPTABLE
        If _WinAPI_EncryptFile($sFile) Then
            MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), 'Encryption File', 'The file encrypted is successfully.')
        Else
            MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Encryption File', 'Unable to encrypt file.')
        EndIf
    Case $FILE_IS_ENCRYPTED
        If MsgBox(BitOR($MB_YESNO, $MB_ICONQUESTION, $MB_SYSTEMMODAL), 'Encryption File', 'The file is already encrypted.' & @CRLF & @CRLF & 'Decrypt?') = 6 Then
            If _WinAPI_DecryptFile($sFile) Then
                MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), 'Encryption File', 'The file decrypted is successfully.')
            Else
                MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Encryption File', 'Unable to decrypt file.')
            EndIf
        EndIf
    Case Else
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Encryption File', 'Unable to perform operation.')
EndSwitch


Function _WinAPI_DeleteFile

Function Reference

_WinAPI_DeleteFile

Deletes an existing file

#include <WinAPIFiles.au3>
_WinAPI_DeleteFile ( $sFilePath )

Parameters

$sFilePath The name of the file to be deleted.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

See Also

Search DeleteFile in MSDN Library.


Function _WinAPI_DeleteVolumeMountPoint

Function Reference

_WinAPI_DeleteVolumeMountPoint

Deletes a drive letter or mounted folder

#include <WinAPIFiles.au3>
_WinAPI_DeleteVolumeMountPoint ( $sMountedPath )

Parameters

$sMountedPath The drive letter or mounted folder to be deleted (for example, X:\ or Y:\MountX\).

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

Deleting a mounted folder does not cause the underlying directory to be deleted.

See Also

Search DeleteVolumeMountPoint in MSDN Library.


Function _WinAPI_DuplicateEncryptionInfoFile

Function Reference

_WinAPI_DuplicateEncryptionInfoFile

Copies the EFS metadata from one file or directory to another

#include <WinAPIFiles.au3>
_WinAPI_DuplicateEncryptionInfoFile ( $sSrcFilePath, $sDestFilePath [, $iCreation = 2 [, $iAttributes = 0 [, $tSecurity = 0]]] )

Parameters

$sSrcFilePath | The name of the file or directory from which the EFS metadata is to be copied. This source file or directory must be encrypted.
$sDestFilePath | The name of the file or directory to which the EFS metadata is to be copied. This destination file or directory does not have to be encrypted before the call to this function. If the source is a file, this parameter must also specify a file, and likewise for directories.
$iCreation | [optional] Specifies how the destination file or directory is to be opened. The following are the valid values of this parameter: $CREATE_NEW $CREATE_ALWAYS (Default)
$iAttributes | [optional] The file attributes of the destination file or directory. The $FILE_READ_ONLY attribute is currently not processed by this function.
$tSecurity | [optional] $tagSECURITY_ATTRIBUTES structure that specifies the security attributes of the destination file or directory, if it does not already exist. If this parameter is 0 (Default), the file or directory gets a default security descriptor. The access-control lists (ACL) in the default security descriptor for a file or directory are inherited from its parent directory.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

The caller should have the EFS key for the source file or directory, and at least the $READ_ATTRIBUTE ACL for the source file or directory.

The specified source and destination file or directories should reside on the same computer; otherwise, the function fails.

See Also

Search DuplicateEncryptionInfoFile in MSDN Library.


Function _WinAPI_EncryptFile

Function Reference

_WinAPI_EncryptFile

Encrypts a file or directory

#include <WinAPIFiles.au3>
_WinAPI_EncryptFile ( $sFilePath )

Parameters

$sFilePath The name of the file or directory to be encrypted.
If $sFilePath specifies a read-only file, the function fails and the last error code is ERROR_FILE_READ_ONLY (6009).
If $sFilePath specifies a directory that contains a read-only file, the functions succeeds but the directory is not encrypted.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

The _WinAPI_EncryptFile() function requires exclusive access to the file being encrypted, and will fail if another process is using the file.

If the file is already encrypted, the function simply returns a nonzero value, which indicates success.
If the file is compressed, the function will decompress the file before encrypting it.

To decrypt an encrypted file, use the _WinAPI_DecryptFile() function.

Related

_WinAPI_DecryptFile

See Also

Search EncryptFile in MSDN Library.

Example

#include <APIFilesConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Local $sFile = FileOpenDialog('Select File', @ScriptDir, 'All Files (*.*)', 1 + 2)
If @error Then Exit

Switch _WinAPI_FileEncryptionStatus($sFile)
    Case $FILE_ENCRYPTABLE
        If _WinAPI_EncryptFile($sFile) Then
            MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), 'Encryption File', 'The file encrypted is successfully.')
        Else
            MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Encryption File', 'Unable to encrypt file.')
        EndIf
    Case $FILE_IS_ENCRYPTED
        If MsgBox(BitOR($MB_YESNO, $MB_ICONQUESTION, $MB_SYSTEMMODAL), 'Encryption File', 'The file is already encrypted.' & @CRLF & @CRLF & 'Decrypt?') = 6 Then
            If _WinAPI_DecryptFile($sFile) Then
                MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), 'Encryption File', 'The file decrypted is successfully.')
            Else
                MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Encryption File', 'Unable to decrypt file.')
            EndIf
        EndIf
    Case Else
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Encryption File', 'Unable to perform operation.')
EndSwitch


Function _WinAPI_EncryptionDisable

Function Reference

_WinAPI_EncryptionDisable

Disables or enables encryption of the specified directory and the files in it

#include <WinAPIFiles.au3>
_WinAPI_EncryptionDisable ( $sDir, $bDisable )

Parameters

$sDir | The name of the directory for which to enable or disable encryption. If this parameter specifies a file, the attempt will fail.
$bDisable | Specifies whether to disable or enable encryption, valid values: True - Disable. False - Enable.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

If encryption is disabled, the function will write the following to the Desktop.ini file in the directory (creating it if necessary):

[Encryption]
Disable=1

The user can also manually add or edit the above lines in the Desktop.ini file and produce the same effect.
Thereafter, _WinAPI_EncryptFile() function will fail on the directory and the files in it, and the last error code will be ERROR_DIR_EFS_DISALLOWED (6010).
This function does not affect encryption of subdirectories within the given directory.

If encryption is enabled, the function will write the following to the Desktop.ini file:

[Encryption]
Disable=0

Related

_WinAPI_EncryptFile

See Also

Search EncryptionDisable in MSDN Library.


Function _WinAPI_EnumFiles

Function Reference

_WinAPI_EnumFiles

Enumerates the files and subdirectories for the specified directory with a name that matches the template

#include <WinAPIFiles.au3>
_WinAPI_EnumFiles ( $sDir [, $iFlag = 0 [, $sTemplate = '' [, $bExclude = False]]] )

Parameters

$sDir | The path to the directory.
$iFlag | [optional] The flag that specifies whether to enumerate files, subdirectories, or both. This parameter can be one of the following values: 0 - Enumerate both files and subdirectories (Default). 1 - Enumerate files only. 2 - Enumerate subdirectories only.
$sTemplate | [optional] A template that using to enumerating files and directories. For example, "*.jpe;*.jpeg;*.jpg".
$bExclude | [optional] Specifies whether the specified template is used to exclude files, valid values: True - The files matching the template will not be enumerated. False - The only those files that match the template will be enumerated (Default).

Return Value

Success: | a 2D array containing the following information: [0][0] - Number of rows in array (n) [0][i] - Unused [n][0] - The name of the file. [n][1] - The time (UTC) when the file was created. [n][2] - The time (UTC) when the file was last accessed. [n][3] - The time (UTC) when the file was last changed. [n][4] - The size of the file, in bytes. [n][5] - The allocation size of the file, in bytes. [n][6] - The file attributes ($FILE_ATTRIBUTE_*).
Failure: | Sets the @error flag to non-zero, @extended flag may contain the NTSTATUS error code.

Remarks

If the target directory is empty or no files matched the specified criteria, the function still returns an array where zeroth array element set to 0.

See Also

Search ZwQueryDirectoryFile in MSDN Library.

Example

#include <Array.au3>
#include <WinAPIFiles.au3>

Local $aData = _WinAPI_EnumFiles(@SystemDir, 1, '*.ax;*.cpl;*.dll;*.drv;*.exe;*.ocx;*.scr')

_ArrayDisplay($aData, '_WinAPI_EnumFiles')


Function _WinAPI_EnumFileStreams

Function Reference

_WinAPI_EnumFileStreams

Enumerates all streams with a ::$DATA stream type in the specified file or directory

#include <WinAPIFiles.au3>
_WinAPI_EnumFileStreams ( $sFilePath )

Parameters

$sFilePath The path to the file or directory. The file must be located on volume with NTFS file system.

Return Value

Success: | The 2D array of the stream names and its sizes. [0][0] - Number of rows in array (n) [0][1] - Unused [n][0] - Stream name. [n][1] - Stream size, in bytes.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the NTSTATUS error code.

See Also

Search ZwQueryInformationFile in MSDN Library.

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <WinAPISys.au3>

Local Const $sFile = @TempDir & '\Test.txt'

; Check NTFS file system
If StringCompare(DriveGetFileSystem(_WinAPI_PathStripToRoot($sFile)), 'NTFS') Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'The file must be on an NTFS file system volume.')
    Exit
EndIf

Local $hFile, $pData, $sName, $iBytes
; Create text file with three alternative streams named AS1, AS2, and AS3 respectively
For $i = 0 To 3
    If $i Then
        $pData = _WinAPI_CreateString('Alternative stream ' & $i)
        $sName = ':AS' & $i
    Else
        $pData = _WinAPI_CreateString('Main stream')
        $sName = ''
    EndIf
    $hFile = _WinAPI_CreateFile($sFile & $sName, 1, 4)
    _WinAPI_WriteFile($hFile, $pData, _WinAPI_GetMemorySize($pData) - 2, $iBytes)
    _WinAPI_CloseHandle($hFile)
    _WinAPI_FreeMemory($pData)
Next

; Enumerate all existing streams in the file
Local $aData = _WinAPI_EnumFileStreams($sFile)

_ArrayDisplay($aData, '_WinAPI_EnumFileStreams')

; Read text data from each stream
$pData = _WinAPI_CreateBuffer(1024)
For $i = 1 To $aData[0][0]
    $hFile = _WinAPI_CreateFile($sFile & $aData[$i][0], 2, 2, 6)
    _WinAPI_ReadFile($hFile, $pData, $aData[$i][1], $iBytes)
    _WinAPI_CloseHandle($hFile)
    $aData[$i][1] = _WinAPI_GetString($pData)
Next
_WinAPI_FreeMemory($pData)

_ArrayDisplay($aData, '_WinAPI_EnumFileStreams')

FileDelete($sFile)


Function _WinAPI_EnumHardLinks

Function Reference

_WinAPI_EnumHardLinks

Enumerates all the hard links to the specified file

#include <WinAPIFiles.au3>
_WinAPI_EnumHardLinks ( $sFilePath )

Parameters

$sFilePath The path to the file whose links are to be enumerated.

Return Value

Success: | The array of the full paths to the links. The zeroth array element contains the number of links.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the NTSTATUS error code.

Remarks

The _WinAPI_CreateHardLink() function is only supported on the NTFS file system.

This function requires Windows Vista or later.

See Also

Search ZwQueryInformationFile in MSDN Library.

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Local $sFile = @DesktopDir & '\' & StringRegExpReplace(_WinAPI_PathFindFileName(@ScriptName), '\A_+', '@')

; Create hard link to the current file with prefix "@" on your Desktop
If Not _WinAPI_CreateHardLink($sFile, @ScriptFullPath) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create hard link.')
    Exit
EndIf

; Enumerate all hard links to the file
Local $aData = _WinAPI_EnumHardLinks($sFile)

_ArrayDisplay($aData, '_WinAPI_EnumHardLinks')

FileDelete($sFile)


Function _WinAPI_FileEncryptionStatus

Function Reference

_WinAPI_FileEncryptionStatus

Retrieves the encryption status of the specified file

#include <WinAPIFiles.au3>
_WinAPI_FileEncryptionStatus ( $sFilePath )

Parameters

$sFilePath The name of the file to retrieve encryption status.

Return Value

Success: | The encryption status ($FILE_*).
Failure: | (-1) and sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended code information.

Remarks

$FILE_* constants require #include <APIFilesConstants.au3>

See Also

Search FileEncryptionStatus in MSDN Library.

Example

#include <APIFilesConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Local $sFile = FileOpenDialog('Select File', @ScriptDir, 'All Files (*.*)', 1 + 2)
If @error Then Exit

Switch _WinAPI_FileEncryptionStatus($sFile)
    Case $FILE_ENCRYPTABLE
        If _WinAPI_EncryptFile($sFile) Then
            MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), 'Encryption File', 'The file encrypted is successfully.')
        Else
            MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Encryption File', 'Unable to encrypt file.')
        EndIf
    Case $FILE_IS_ENCRYPTED
        If MsgBox(BitOR($MB_YESNO, $MB_ICONQUESTION, $MB_SYSTEMMODAL), 'Encryption File', 'The file is already encrypted.' & @CRLF & @CRLF & 'Decrypt?') = 6 Then
            If _WinAPI_DecryptFile($sFile) Then
                MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), 'Encryption File', 'The file decrypted is successfully.')
            Else
                MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Encryption File', 'Unable to decrypt file.')
            EndIf
        EndIf
    Case Else
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Encryption File', 'Unable to perform operation.')
EndSwitch


Function _WinAPI_FileExists

Function Reference

_WinAPI_FileExists

Tests whether the specified path is existing file

#include <WinAPIFiles.au3>
_WinAPI_FileExists ( $sFilePath )

Parameters

$sFilePath The path to the file to test.

Return Value

Success: | 1 - The path is an existing file.
Failure: | 0.

Remarks

The function sets the @extended flag to 1 if the specified path is an existing directory (not a file).

Example

#include <WinAPIFiles.au3>

ConsoleWrite(@ScriptName & ' exists : ' & _WinAPI_FileExists(@ScriptFullPath) & @CRLF)


Function _WinAPI_FileInUse

Function Reference

_WinAPI_FileInUse

Tests whether the specified file in use by another application

#include <WinAPIFiles.au3>
_WinAPI_FileInUse ( $sFilePath )

Parameters

$sFilePath The name of the file to test. If the path specifies a directory, the function fails.

Return Value

Success: | 1 - File in use by another application.
Failure: | 0.

Example

#include <WinAPIFiles.au3>

Local $hFile = FileOpen(@ScriptFullPath)

ConsoleWrite(@ScriptName & ' in use: ' & _WinAPI_FileInUse(@ScriptFullPath) & @CRLF)
FileClose($hFile)
ConsoleWrite(@ScriptName & ' in use: ' & _WinAPI_FileInUse(@ScriptFullPath) & @CRLF)


Function _WinAPI_FindClose

Function Reference

_WinAPI_FindClose

Closes a file search handle

#include <WinAPIFiles.au3>
_WinAPI_FindClose ( $hSearch )

Parameters

$hSearch The file search handle opened by the _WinAPI_FindFirst... functions.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

See Also

Search FindClose in MSDN Library.


Function _WinAPI_FindCloseChangeNotification

Function Reference

_WinAPI_FindCloseChangeNotification

Stops change notification handle monitoring

#include <WinAPIFiles.au3>
_WinAPI_FindCloseChangeNotification ( $hChange )

Parameters

$hChange A handle to a change notification handle created by the _WinAPI_FindFirstChangeNotification() function.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

See Also

Search FindCloseChangeNotification in MSDN Library.

Example

#include <APIFilesConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIFiles.au3>

Opt('TrayAutoPause', 0)

Global Const $g_sPath = @TempDir & '\~TEST~'

DirCreate($g_sPath)
If Not FileExists($g_sPath) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create folder.')
    Exit
EndIf
ShellExecute($g_sPath) ; to ease a file creation in this folder

OnAutoItExitRegister('OnAutoItExit')

Global $g_ahObj[2]
$g_ahObj[0] = _WinAPI_FindFirstChangeNotification($g_sPath, $FILE_NOTIFY_CHANGE_FILE_NAME)
$g_ahObj[1] = _WinAPI_FindFirstChangeNotification($g_sPath, $FILE_NOTIFY_CHANGE_DIR_NAME)

If (Not $g_ahObj[0]) Or (Not $g_ahObj[1]) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create change notification.')
    Exit
EndIf

Local $tObjs = DllStructCreate('ptr;ptr')
Local $paObj = DllStructGetPtr($tObjs)
For $i = 0 To 1
    DllStructSetData($tObjs, $i + 1, $g_ahObj[$i])
Next

Local $iID
While 1
    Sleep(100)
    $iID = _WinAPI_WaitForMultipleObjects(2, $paObj, 0, 0)
    Switch $iID
        Case 0 ; WAIT_OBJECT_0
            ConsoleWrite('A file was created, renamed, or deleted in the directory.' & @CRLF)
        Case 1 ; WAIT_OBJECT_0 + 1
            ConsoleWrite('A directory was created, renamed, or deleted.' & @CRLF)
        Case Else
            ContinueLoop
    EndSwitch
    If Not _WinAPI_FindNextChangeNotification($g_ahObj[$iID]) Then
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unexpected error.')
        Exit
    EndIf
WEnd

Func OnAutoItExit()
    For $i = 0 To 1
        If $g_ahObj[$i] Then
            _WinAPI_FindCloseChangeNotification($g_ahObj[$i])
        EndIf
    Next
    DirRemove($g_sPath, 1)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_FindFirstChangeNotification

Function Reference

_WinAPI_FindFirstChangeNotification

Creates a change notification handle and sets up initial change notification filter conditions

#include <WinAPIFiles.au3>
_WinAPI_FindFirstChangeNotification ( $sDirectory, $iFlags [, $bSubtree = False] )

Parameters

$sDirectory | The full path of the directory to be watched.
$iFlags | The filter conditions that satisfy a change notification wait. This parameter can be one or more of the following values: $FILE_NOTIFY_CHANGE_FILE_NAME $FILE_NOTIFY_CHANGE_DIR_NAME $FILE_NOTIFY_CHANGE_ATTRIBUTES $FILE_NOTIFY_CHANGE_SIZE $FILE_NOTIFY_CHANGE_LAST_WRITE $FILE_NOTIFY_CHANGE_SECURITY
$bSubtree | [optional] Specifies whether to monitor the subdirectories of the specified directory, valid values: True - Monitor the directory tree rooted at the specified directory. False - Monitor only the specified directory (Default).

Return Value

Success: | A handle to a find change notification object.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

The _WinAPI_Wait... functions can monitor the specified directory or subtree by using the handle returned by this function.
A wait is satisfied when one of the filter conditions occurs in the monitored directory or subtree.

After the wait has been satisfied, the application can respond to this condition and continue monitoring the directory by calling the _WinAPI_FindNextChangeNotification() function and the appropriate wait function.
When the handle is no longer needed, it can be closed by using the _WinAPI_FindCloseChangeNotification() function.

Notifications may not be returned when calling _WinAPI_FindFirstChangeNotification() for a remote file system.

Related

_WinAPI_FindCloseChangeNotification, _WinAPI_FindNextChangeNotification

See Also

Search FindFirstChangeNotification in MSDN Library.

Example

#include <APIFilesConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIFiles.au3>

Opt('TrayAutoPause', 0)

Global Const $g_sPath = @TempDir & '\~TEST~'

DirCreate($g_sPath)
If Not FileExists($g_sPath) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create folder.')
    Exit
EndIf
ShellExecute($g_sPath) ; to ease a file creation in this folder

OnAutoItExitRegister('OnAutoItExit')

Global $g_ahObj[2]
$g_ahObj[0] = _WinAPI_FindFirstChangeNotification($g_sPath, $FILE_NOTIFY_CHANGE_FILE_NAME)
$g_ahObj[1] = _WinAPI_FindFirstChangeNotification($g_sPath, $FILE_NOTIFY_CHANGE_DIR_NAME)

If (Not $g_ahObj[0]) Or (Not $g_ahObj[1]) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create change notification.')
    Exit
EndIf

Local $tObjs = DllStructCreate('ptr;ptr')
Local $paObj = DllStructGetPtr($tObjs)
For $i = 0 To 1
    DllStructSetData($tObjs, $i + 1, $g_ahObj[$i])
Next

Local $iID
While 1
    Sleep(100)
    $iID = _WinAPI_WaitForMultipleObjects(2, $paObj, 0, 0)
    Switch $iID
        Case 0 ; WAIT_OBJECT_0
            ConsoleWrite('A file was created, renamed, or deleted in the directory.' & @CRLF)
        Case 1 ; WAIT_OBJECT_0 + 1
            ConsoleWrite('A directory was created, renamed, or deleted.' & @CRLF)
        Case Else
            ContinueLoop
    EndSwitch
    If Not _WinAPI_FindNextChangeNotification($g_ahObj[$iID]) Then
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unexpected error.')
        Exit
    EndIf
WEnd

Func OnAutoItExit()
    For $i = 0 To 1
        If $g_ahObj[$i] Then
            _WinAPI_FindCloseChangeNotification($g_ahObj[$i])
        EndIf
    Next
    DirRemove($g_sPath, 1)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_FindFirstFile

Function Reference

_WinAPI_FindFirstFile

Searches a directory for a file or subdirectory with a name that matches a specific name

#include <WinAPIFiles.au3>
_WinAPI_FindFirstFile ( $sFilePath, $tData )

Parameters

$sFilePath | The directory or path, and the file name, which can include wildcard characters, for example, an asterisk "*" or a question mark "?". If the string ends with a wildcard, period ".", or directory name, the user must have access permissions to the root and all subdirectories on the path.
$tData | A $tagWIN32_FIND_DATA structure or a pointer to it that receives information about a found file or directory.

Return Value

Success: | The search handle.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

This function opens a search handle and returns information about the first file that the file system finds with a name that matches the specified pattern.
This may or may not be the first file or directory that appears in a directory-listing application when given the same file name string pattern.

After the search handle is established, you can use it to search for other files that match the same pattern by using the _WinAPI_FindNextFile() function.

If the function fails because no matching files can be found, the @extended flag will contain ERROR_FILE_NOT_FOUND (2) system error code.

When the search handle is no longer needed, close it by using the _WinAPI_FindClose() function.

Related

_WinAPI_FindClose, _WinAPI_FindNextFile

See Also

Search FindFirstFile in MSDN Library.

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIDiag.au3>
#include <WinAPIFiles.au3>

Local $aList[101][2] = [[0]]

Local $tData = DllStructCreate($tagWIN32_FIND_DATA)

Local $sFile
Local $hSearch = _WinAPI_FindFirstFile(@ScriptDir & '\*', $tData)
While Not @error
    $sFile = DllStructGetData($tData, 'cFileName')
    Switch $sFile
        Case '.', '..'

        Case Else
            If Not BitAND(DllStructGetData($tData, 'dwFileAttributes'), $FILE_ATTRIBUTE_DIRECTORY) Then
                $aList[0][0] += 1
                If $aList[0][0] > UBound($aList) - 1 Then
                    ReDim $aList[UBound($aList) + 100][2]
                EndIf
                $aList[$aList[0][0]][0] = $sFile
                $aList[$aList[0][0]][1] = _WinAPI_MakeQWord(DllStructGetData($tData, 'nFileSizeLow'), DllStructGetData($tData, 'nFileSizeHigh'))
            EndIf
    EndSwitch
    _WinAPI_FindNextFile($hSearch, $tData)
WEnd

Switch @extended
    Case 18 ; ERROR_NO_MORE_FILES

    Case Else
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))
        Exit
EndSwitch

_WinAPI_FindClose($hSearch)

_ArrayDisplay($aList, '_WinAPI_Find...', $aList[0][0])


Function _WinAPI_FindFirstFileName

Function Reference

_WinAPI_FindFirstFileName

Creates an enumeration of all the hard links to the specified file

#include <WinAPIFiles.au3>
_WinAPI_FindFirstFileName ( $sFilePath, ByRef $sLink )

Parameters

$sFilePath | The name of the file.
$sLink | Returns the first link name found for the specified file.

Return Value

Success: | The search handle.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

After the search handle has been established, use it in the _WinAPI_FindNextFileName() function to search for other hard links to the specified file.

When the search handle is no longer needed, it should be closed using the _WinAPI_FindClose() function.

This function requires Windows Vista or later.

Related

_WinAPI_FindClose, _WinAPI_FindNextFileName

See Also

Search FindFirstFileNameW in MSDN Library.

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPIFiles.au3>

Local $sFile = @DesktopDir & '\@' & StringRegExpReplace(_WinAPI_PathFindFileName(@ScriptName), '\A_+', '')

; Create hard link to the current file with prefix "@" on your Desktop
If Not _WinAPI_CreateHardLink($sFile, @ScriptFullPath) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create hard link.')
    Exit
EndIf

; Enumerate all hard links to the file

Local $sLink
Local $hSearch = _WinAPI_FindFirstFileName($sFile, $sLink)
While Not @error
    ConsoleWrite(_WinAPI_PathAppend(_WinAPI_PathStripToRoot($sFile), $sLink) & @CRLF)
    _WinAPI_FindNextFileName($hSearch, $sLink)
WEnd

Switch @extended
    Case 38 ; ERROR_HANDLE_EOF

    Case Else
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))
EndSwitch

FileDelete($sFile)


Function _WinAPI_FindFirstStream

Function Reference

_WinAPI_FindFirstStream

Enumerates the first stream with a ::$DATA stream type in the specified file or directory

#include <WinAPIFiles.au3>
_WinAPI_FindFirstStream ( $sFilePath, $tData )

Parameters

$sFilePath | The fully-qualified file name.
$tData | A $tagWIN32_FIND_STREAM_DATA structure or a pointer to it that receives information about the stream.

Return Value

Success: | The search handle.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

This function function opens a search handle and returns information about the first stream in the specified file or directory.
For files, this is always the default data stream, "::$DATA".
After the search handle has been established, use it in the _WinAPI_FindNextStream() function to search for other streams in the specified file or directory.

If the function fails because no streams can be found, the @extended flag will contain ERROR_HANDLE_EOF (38) system error code.

When the search handle is no longer needed, it should be closed using the _WinAPI_FindClose() function.

This function requires Windows Vista or later.

Related

_WinAPI_FindClose, _WinAPI_FindNextStream

See Also

Search FindFirstStreamW in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPIFiles.au3>
#include <WinAPISys.au3>

Local Const $sTempFile = @TempDir & '\Test.txt'

; Check NTFS file system
If StringCompare(DriveGetFileSystem(_WinAPI_PathStripToRoot($sTempFile)), 'NTFS') Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'The file must be on an NTFS file system volume.')
    Exit
EndIf

Local $sName, $iBytes, $pData, $hFile
; Create text file with three alternative streams named AS1, AS2, and AS3 respectively
For $i = 0 To 3
    If $i Then
        $pData = _WinAPI_CreateString('Alternative stream ' & $i)
        $sName = ':AS' & $i
    Else
        $pData = _WinAPI_CreateString('Main stream')
        $sName = ''
    EndIf
    $hFile = _WinAPI_CreateFile($sTempFile & $sName, 1, 4)
    _WinAPI_WriteFile($hFile, $pData, _WinAPI_GetMemorySize($pData) - 2, $iBytes)
    _WinAPI_CloseHandle($hFile)
    _WinAPI_FreeMemory($pData)
Next

; Enumerate all existing streams in the file and read text data from each stream
$pData = _WinAPI_CreateBuffer(1024)

Local $tFSD = DllStructCreate($tagWIN32_FIND_STREAM_DATA)

Local $hSearch = _WinAPI_FindFirstStream($sTempFile, $tFSD)
Local $iSize
While Not @error
    $sName = DllStructGetData($tFSD, 'StreamName')
    $iSize = DllStructGetData($tFSD, 'StreamSize')
    $hFile = _WinAPI_CreateFile($sTempFile & $sName, 2, 2, 6)
    _WinAPI_ReadFile($hFile, $pData, $iSize, $iBytes)
    _WinAPI_CloseHandle($hFile)
    ConsoleWrite(StringFormat('%10s (%s bytes) - %s', $sName, $iSize, _WinAPI_GetString($pData)) & @CRLF)
    _WinAPI_FindNextStream($hSearch, $tFSD)
WEnd

Switch @extended
    Case 38 ; ERROR_HANDLE_EOF

    Case Else
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))
EndSwitch

_WinAPI_FindClose($hSearch)

_WinAPI_FreeMemory($pData)

FileDelete($sTempFile)


Function _WinAPI_FindNextChangeNotification

Function Reference

_WinAPI_FindNextChangeNotification

Requests that the operating system signal a change notification handle the next time it detects an appropriate change

#include <WinAPIFiles.au3>
_WinAPI_FindNextChangeNotification ( $hChange )

Parameters

$hChange A handle to a change notification handle created by the _WinAPI_FindFirstChangeNotification() function.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

After the _WinAPI_FindNextChangeNotification() function returns successfully, the application can wait for notification that a change has occurred by using the _WinAPI_Wait... functions.

The _WinAPI_FindNextChangeNotification() function should not be used more than once on the same handle without using one of the wait functions.
An application may miss a change notification if it uses _WinAPI_FindNextChangeNotification() when there is a change request outstanding.

Related

_WinAPI_FindFirstChangeNotification

See Also

Search FindNextChangeNotification in MSDN Library.

Example

#include <APIFilesConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIFiles.au3>

Opt('TrayAutoPause', 0)

Global Const $g_sPath = @TempDir & '\~TEST~'

DirCreate($g_sPath)
If Not FileExists($g_sPath) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create folder.')
    Exit
EndIf
ShellExecute($g_sPath) ; to ease a file creation in this folder

OnAutoItExitRegister('OnAutoItExit')

Global $g_ahObj[2]
$g_ahObj[0] = _WinAPI_FindFirstChangeNotification($g_sPath, $FILE_NOTIFY_CHANGE_FILE_NAME)
$g_ahObj[1] = _WinAPI_FindFirstChangeNotification($g_sPath, $FILE_NOTIFY_CHANGE_DIR_NAME)

If (Not $g_ahObj[0]) Or (Not $g_ahObj[1]) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create change notification.')
    Exit
EndIf

Local $tObjs = DllStructCreate('ptr;ptr')
Local $paObj = DllStructGetPtr($tObjs)
For $i = 0 To 1
    DllStructSetData($tObjs, $i + 1, $g_ahObj[$i])
Next

Local $iID
While 1
    Sleep(100)
    $iID = _WinAPI_WaitForMultipleObjects(2, $paObj, 0, 0)
    Switch $iID
        Case 0 ; WAIT_OBJECT_0
            ConsoleWrite('A file was created, renamed, or deleted in the directory.' & @CRLF)
        Case 1 ; WAIT_OBJECT_0 + 1
            ConsoleWrite('A directory was created, renamed, or deleted.' & @CRLF)
        Case Else
            ContinueLoop
    EndSwitch
    If Not _WinAPI_FindNextChangeNotification($g_ahObj[$iID]) Then
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unexpected error.')
        Exit
    EndIf
WEnd

Func OnAutoItExit()
    For $i = 0 To 1
        If $g_ahObj[$i] Then
            _WinAPI_FindCloseChangeNotification($g_ahObj[$i])
        EndIf
    Next
    DirRemove($g_sPath, 1)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_FindNextFile

Function Reference

_WinAPI_FindNextFile

Continues a file or directory search

#include <WinAPIFiles.au3>
_WinAPI_FindNextFile ( $hSearch, $tData )

Parameters

$hSearch | The search handle returned by a previous call to the _WinAPI_FindFirstFile() function.
$tData | A $tagWIN32_FIND_DATA structure or a pointer to it that receives information about a found file or directory.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

The order in which the search returns the files, such as alphabetical order, is not guaranteed.
If the data must be sorted, the application must do the ordering after obtaining all the results.

If the function fails because no more matching files can be found, the @extended flag will contain ERROR_NO_MORE_FILES (18) system error code.

Related

_WinAPI_FindFirstFile

See Also

Search FindNextFile in MSDN Library.

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIDiag.au3>
#include <WinAPIFiles.au3>

Local $aList[101][2] = [[0]]

Local $tData = DllStructCreate($tagWIN32_FIND_DATA)

Local $sFile
Local $hSearch = _WinAPI_FindFirstFile(@ScriptDir & '\*', $tData)
While Not @error
    $sFile = DllStructGetData($tData, 'cFileName')
    Switch $sFile
        Case '.', '..'

        Case Else
            If Not BitAND(DllStructGetData($tData, 'dwFileAttributes'), $FILE_ATTRIBUTE_DIRECTORY) Then
                $aList[0][0] += 1
                If $aList[0][0] > UBound($aList) - 1 Then
                    ReDim $aList[UBound($aList) + 100][2]
                EndIf
                $aList[$aList[0][0]][0] = $sFile
                $aList[$aList[0][0]][1] = _WinAPI_MakeQWord(DllStructGetData($tData, 'nFileSizeLow'), DllStructGetData($tData, 'nFileSizeHigh'))
            EndIf
    EndSwitch
    _WinAPI_FindNextFile($hSearch, $tData)
WEnd

Switch @extended
    Case 18 ; ERROR_NO_MORE_FILES

    Case Else
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))
        Exit
EndSwitch

_WinAPI_FindClose($hSearch)

_ArrayDisplay($aList, '_WinAPI_Find...', $aList[0][0])


Function _WinAPI_FindNextFileName

Function Reference

_WinAPI_FindNextFileName

Continues enumerating the hard links

#include <WinAPIFiles.au3>
_WinAPI_FindNextFileName ( $hSearch, ByRef $sLink )

Parameters

$hSearch | A handle to the enumeration that is returned by a successful call to _WinAPI_FindFirstFileName() function.
$sLink | Returns the next link name that was found.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

If the function fails because no matching files can be found,, the @extended flag will contain ERROR_HANDLE_EOF (38) system error code.

This function requires Windows Vista or later.

Related

_WinAPI_FindFirstFileName

See Also

Search FindNextFileNameW in MSDN Library.

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPIFiles.au3>

Local $sFile = @DesktopDir & '\@' & StringRegExpReplace(_WinAPI_PathFindFileName(@ScriptName), '\A_+', '')

; Create hard link to the current file with prefix "@" on your Desktop
If Not _WinAPI_CreateHardLink($sFile, @ScriptFullPath) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create hard link.')
    Exit
EndIf

; Enumerate all hard links to the file

Local $sLink
Local $hSearch = _WinAPI_FindFirstFileName($sFile, $sLink)
While Not @error
    ConsoleWrite(_WinAPI_PathAppend(_WinAPI_PathStripToRoot($sFile), $sLink) & @CRLF)
    _WinAPI_FindNextFileName($hSearch, $sLink)
WEnd

Switch @extended
    Case 38 ; ERROR_HANDLE_EOF

    Case Else
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))
EndSwitch

FileDelete($sFile)


Function _WinAPI_FindNextStream

Function Reference

_WinAPI_FindNextStream

Continues a stream search

#include <WinAPIFiles.au3>
_WinAPI_FindNextStream ( $hSearch, $tData )

Parameters

$hSearch | The search handle returned by a previous call to the _WinAPI_FindFirstStream() function.
$tData | A $tagWIN32_FIND_STREAM_DATA structure or a pointer to it that receives information about the stream.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

If the function fails because no more streams can be found, the @extended flag will contain ERROR_HANDLE_EOF (38) system error code.

This function requires Windows Vista or later.

Related

_WinAPI_FindFirstStream

See Also

Search FindNextStreamW in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPIFiles.au3>
#include <WinAPISys.au3>

Local Const $sTempFile = @TempDir & '\Test.txt'

; Check NTFS file system
If StringCompare(DriveGetFileSystem(_WinAPI_PathStripToRoot($sTempFile)), 'NTFS') Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'The file must be on an NTFS file system volume.')
    Exit
EndIf

Local $sName, $iBytes, $pData, $hFile
; Create text file with three alternative streams named AS1, AS2, and AS3 respectively
For $i = 0 To 3
    If $i Then
        $pData = _WinAPI_CreateString('Alternative stream ' & $i)
        $sName = ':AS' & $i
    Else
        $pData = _WinAPI_CreateString('Main stream')
        $sName = ''
    EndIf
    $hFile = _WinAPI_CreateFile($sTempFile & $sName, 1, 4)
    _WinAPI_WriteFile($hFile, $pData, _WinAPI_GetMemorySize($pData) - 2, $iBytes)
    _WinAPI_CloseHandle($hFile)
    _WinAPI_FreeMemory($pData)
Next

; Enumerate all existing streams in the file and read text data from each stream
$pData = _WinAPI_CreateBuffer(1024)

Local $tFSD = DllStructCreate($tagWIN32_FIND_STREAM_DATA)

Local $hSearch = _WinAPI_FindFirstStream($sTempFile, $tFSD)
Local $iSize
While Not @error
    $sName = DllStructGetData($tFSD, 'StreamName')
    $iSize = DllStructGetData($tFSD, 'StreamSize')
    $hFile = _WinAPI_CreateFile($sTempFile & $sName, 2, 2, 6)
    _WinAPI_ReadFile($hFile, $pData, $iSize, $iBytes)
    _WinAPI_CloseHandle($hFile)
    ConsoleWrite(StringFormat('%10s (%s bytes) - %s', $sName, $iSize, _WinAPI_GetString($pData)) & @CRLF)
    _WinAPI_FindNextStream($hSearch, $tFSD)
WEnd

Switch @extended
    Case 38 ; ERROR_HANDLE_EOF

    Case Else
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))
EndSwitch

_WinAPI_FindClose($hSearch)

_WinAPI_FreeMemory($pData)

FileDelete($sTempFile)


Function _WinAPI_FlushViewOfFile

Function Reference

_WinAPI_FlushViewOfFile

Writes to the disk a byte range within a mapped view of a file

#include <WinAPIFiles.au3>
_WinAPI_FlushViewOfFile ( $pAddress [, $iBytes = 0] )

Parameters

$pAddress | A pointer to the base address of the byte range to be flushed to the disk representation of the mapped file.
$iBytes | [optional] The number of bytes to be flushed. If $iBytes is 0 (Default), the file is flushed from the base address to the end of the mapping.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

See Also

Search FlushViewOfFile in MSDN Library.


Function _WinAPI_GetBinaryType

Function Reference

_WinAPI_GetBinaryType

Determines whether a file is an executable (.exe) file, and if so, which subsystem runs the executable file

#include <WinAPIFiles.au3>
_WinAPI_GetBinaryType ( $sFilePath )

Parameters

$sFilePath The full path of the file whose executable type is to be determined.

Return Value

Success: | 1 - The file is executable, @extended flag will be contain one of the $SCS_* constants to indicate the file's executable type.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

$SCS_* constants require #include <APIFilesConstants.au3>

Symbolic link behavior : if the path points to a symbolic link, the target file is used.

In Windows 8 and Windows Server 2012, this function is supported by the following technologies:
Server Message Block (SMB) 3.0 protocol
SMB 3.0 Transparent Failover (TFO)
SMB 3.0 with Scale-out File Shares (SO)
Cluster Shared Volume File System (CsvFS)
Resilient File System (ReFS)

See Also

Search GetBinaryType in MSDN Library.

Example

#include <APIFilesConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Local $sText, $sPath = @MyDocumentsDir & '\'
While 1
    $sPath = FileOpenDialog('Select File', _WinAPI_PathRemoveFileSpec($sPath), 'All Files (*.*)', 1 + 2)
    If $sPath Then
        If _WinAPI_GetBinaryType($sPath) Then
            Switch @extended
                Case $SCS_32BIT_BINARY
                    $sText = '32-bit Windows-based application'
                Case $SCS_64BIT_BINARY
                    $sText = '64-bit Windows-based application'
                Case $SCS_DOS_BINARY
                    $sText = 'MS-DOS-based application'
                Case $SCS_OS216_BINARY
                    $sText = '16-bit OS/2-based application.'
                Case $SCS_PIF_BINARY
                    $sText = 'PIF file that executes an MS-DOS-based application'
                Case $SCS_POSIX_BINARY
                    $sText = 'POSIX-based application'
                Case $SCS_WOW_BINARY
                    $sText = '16-bit Windows-based application'
                Case Else
                    $sText = 'unknown executable type'
            EndSwitch
        Else
            $sText = 'not executable file'
        EndIf
        MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), '_WinAPI_GetBinaryType()', '"' & _WinAPI_PathStripPath($sPath) & '" is ' & $sText & ".")
    Else
        ExitLoop
    EndIf
WEnd


Function _WinAPI_GetCompressedFileSize

Function Reference

_WinAPI_GetCompressedFileSize

Retrieves the actual number of bytes of disk storage used to store a specified file

#include <WinAPIFiles.au3>
_WinAPI_GetCompressedFileSize ( $sFilePath )

Parameters

$sFilePath The name of the file.

Return Value

Success: | The actual number of bytes of disk storage.
Failure: | 0 and sets the @error flag to non-zero, @extended contain the system last error.

Remarks

If the file is not located on a volume that supports compression or sparse files, or if the file is not compressed or a sparse file, the value obtained is the actual file size.

See Also

Search GetCompressedFileSize in MSDN Library.


Function _WinAPI_GetCompression

Function Reference

_WinAPI_GetCompression

Retrieves the current compression state of a file or directory

#include <WinAPIFiles.au3>
_WinAPI_GetCompression ( $sFilePath )

Parameters

$sFilePath The path to the file or directory to retrieve compression state.

Return Value

Success: | The current compression state ($COMPRESSION_FORMAT_*).
Failure: | (-1) and sets the @error flag to non-zero.

See Also

Search FSCTL_GET_COMPRESSION in MSDN Library.

Example

#include <APISysConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Local $sFile = FileOpenDialog('Select File', @ScriptDir, 'All Files (*.*)', 1 + 2)
If @error Then Exit

Switch _WinAPI_GetCompression($sFile)
    Case -1
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Compression File', 'Unable to perform operation.')
    Case $COMPRESSION_FORMAT_NONE
        If _WinAPI_SetCompression($sFile, $COMPRESSION_FORMAT_DEFAULT) Then
            MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), 'Compression File', 'The file compressed is successfully.')
        Else
            MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Compression File', 'Unable to compress file.')
        EndIf
    Case Else
        If MsgBox(BitOR($MB_YESNO, $MB_ICONQUESTION, $MB_SYSTEMMODAL), 'Compression File', 'The file is already compressed.' & @CRLF & @CRLF & 'Decompress?') = 6 Then
            If _WinAPI_SetCompression($sFile, $COMPRESSION_FORMAT_NONE) Then
                MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), 'Compression File', 'The file decompressed is successfully.')
            Else
                MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Compression File', 'Unable to decompress file.')
            EndIf
        EndIf
EndSwitch


Function _WinAPI_GetCurrentDirectory

Function Reference

_WinAPI_GetCurrentDirectory

Retrieves the current directory for the current process

#include <WinAPIFiles.au3>
_WinAPI_GetCurrentDirectory ( )

Return Value

Success: | The absolute path to the current directory.
Failure: | Empty string, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetCurrentDirectory in MSDN Library.


Function _WinAPI_GetDiskFreeSpaceEx

Function Reference

_WinAPI_GetDiskFreeSpaceEx

Retrieves information about the amount of space that is available on a disk volume

#include <WinAPIFiles.au3>
_WinAPI_GetDiskFreeSpaceEx ( $sDrive )

Parameters

$sDrive The drive to retrieve information, in the format D:, E:, etc.

Return Value

Success: | The array containing the following information: [0] - The total number of available free bytes on a disk. If per-user quotas are being used, this value may be less than the total number of free bytes on a disk. [1] - The total number of available bytes on a disk. If per-user quotas are being used, this value may be less than the total number of bytes on a disk. [2] - The total number of free bytes on a disk.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetDiskFreeSpaceEx in MSDN Library.

Example

#include <WinAPIFiles.au3>

Local $aData = _WinAPI_GetDiskFreeSpaceEx(@HomeDrive)

ConsoleWrite('Total available free space on ' & @HomeDrive & ' => ' & $aData[0] & ' bytes' & @CRLF)
ConsoleWrite('Total available space on ' & @HomeDrive & ' => ' & $aData[1] & ' bytes' & @CRLF)
ConsoleWrite('Total free space on ' & @HomeDrive & ' => ' & $aData[2] & ' bytes' & @CRLF)


Function _WinAPI_GetFileAttributes

Function Reference

_WinAPI_GetFileAttributes

Retrieves file system attributes for a specified file or directory

#include <WinAPIFiles.au3>
_WinAPI_GetFileAttributes ( $sFilePath )

Parameters

$sFilePath The name of the file or directory.

Return Value

Success: | The value contains the attributes of the specified file or directory ($FILE_ATTRIBUTE_).
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetFileAttributes in MSDN Library.


Function _WinAPI_GetFileID

Function Reference

_WinAPI_GetFileID

Retrieves the file system's 8-byte file reference number for a file

#include <WinAPIFiles.au3>
_WinAPI_GetFileID ( $hFile )

Parameters

$hFile A handle to the file or directory whose reference number is to be retrieved.

Return Value

Success: | The 8-byte file reference number for the file.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the NTSTATUS error code.

Remarks

The file reference number is assigned by the file system and is file-system-specific.
(Note that this is not the same as the 16-byte "file object ID" that was added to NTFS.)

The file reference numbers, also called file IDs, are guaranteed to be unique only within a static file system.
They are not guaranteed to be unique over time, because file systems are free to reuse them.
Nor are they guaranteed to remain constant.
For example, the FAT file system generates the file reference number for a file from the byte offset of the file's directory entry record (DIRENT) on the disk.
Defragmentation can change this byte offset.
Thus a FAT file reference number can change over time.

See Also

Search ZwQueryInformationFile in MSDN Library.

Example

#include <WinAPI.au3>
#include <WinAPIFiles.au3>

Local $hFile = _WinAPI_CreateFile(@ScriptFullPath, 2, 0, 6)

ConsoleWrite('Handle: ' & $hFile & @CRLF)
ConsoleWrite('ID:     ' & _WinAPI_GetFileID($hFile) & @CRLF)

_WinAPI_CloseHandle($hFile)


Function _WinAPI_GetFileInformationByHandle

Function Reference

_WinAPI_GetFileInformationByHandle

Retrieves file information for the specified file

#include <WinAPIFiles.au3>
_WinAPI_GetFileInformationByHandle ( $hFile )

Parameters

$hFile Handle to the file that contains the information to be retrieved.

Return Value

Success: | The array containing the following information: [0] - The file attributes (FILE_ATTRIBUTE_*). [1] - $tagFILETIME structure that specifies when a file or directory is created. [2] - $tagFILETIME structure that specifies the last time that a file is read from or written to. [3] - $tagFILETIME structure that specifies the last time that a file is written to. [4] - The serial number of the volume that contains a file. [5] - The file size. [6] - The number of links to this file. [7] - The unique identifier that is associated with a file.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetFileInformationByHandle in MSDN Library.

Example

#include <Date.au3>
#include <WinAPIFiles.au3>

Local $hFile = _WinAPI_CreateFile(@ScriptFullPath, 2, 0, 6)
Local $aInfo = _WinAPI_GetFileInformationByHandle($hFile)
If IsArray($aInfo) Then
    For $i = 1 To 3
        If IsDllStruct($aInfo[$i]) Then
            Local $tFILETIME = _Date_Time_FileTimeToLocalFileTime($aInfo[$i])
            $aInfo[$i] = _Date_Time_FileTimeToSystemTime($tFILETIME)
            $aInfo[$i] = _Date_Time_SystemTimeToDateTimeStr($aInfo[$i])
        Else
            $aInfo[$i] = 'Unknown'
        EndIf
    Next
    ConsoleWrite('!Path:          ' & _WinAPI_GetFinalPathNameByHandle($hFile) & @CRLF)
    ConsoleWrite('!Attributes:    0x' & Hex($aInfo[0], 8) & @CRLF)
    ConsoleWrite('!Created:       ' & $aInfo[1] & @CRLF)
    ConsoleWrite('!Accessed:      ' & $aInfo[2] & @CRLF)
    ConsoleWrite('!Modified:      ' & $aInfo[3] & @CRLF)
    ConsoleWrite('!Volume serial: ' & $aInfo[4] & @CRLF)
    ConsoleWrite('!Size:          ' & $aInfo[5] & @CRLF)
    ConsoleWrite('!Links:         ' & $aInfo[6] & @CRLF)
    ConsoleWrite('!ID:            ' & $aInfo[7] & @CRLF)
EndIf
_WinAPI_CloseHandle($hFile)


Function _WinAPI_GetFileInformationByHandleEx

Function Reference

_WinAPI_GetFileInformationByHandleEx

Retrieves file information for the specified file

#include <WinAPIFiles.au3>
_WinAPI_GetFileInformationByHandleEx ( $hFile )

Parameters

$hFile Handle to the file that contains the information to be retrieved.

Return Value

Success: | $tagFILEINFO structure containing information for a file.
Failure: | Sets the@error flag to non-zero.

See Also

Search ZwQueryInformationFile in MSDN Library.


Function _WinAPI_GetFilePointerEx

Function Reference

_WinAPI_GetFilePointerEx

Retrieves the file pointer of the specified file

#include <WinAPIFiles.au3>
_WinAPI_GetFilePointerEx ( $hFile )

Parameters

$hFile Handle to the file.

Return Value

Success: | The byte offset from the beginning of the file of the current file pointer.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the NTSTATUS error code.

See Also

Search ZwQueryInformationFile in MSDN Library.


Function _WinAPI_GetFileSizeOnDisk

Function Reference

_WinAPI_GetFileSizeOnDisk

Retrieves the file allocation size on disk

#include <WinAPIFiles.au3>
_WinAPI_GetFileSizeOnDisk ( $sFilePath )

Parameters

$sFilePath The name of the file to retrieve allocation size.

Return Value

Success: | The allocation size, in bytes. This value is a multiple of the sector or cluster size of the specified physical device.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Example

#include <WinAPIFiles.au3>

Local Const $sFile = @ScriptFullPath

ConsoleWrite('Localtion:    ' & $sFile & @CRLF)
ConsoleWrite('Size:         ' & FileGetSize($sFile) & @CRLF)
ConsoleWrite('Size on disk: ' & _WinAPI_GetFileSizeOnDisk($sFile) & @CRLF)


Function _WinAPI_GetFileTitle

Function Reference

_WinAPI_GetFileTitle

Retrieves the name of the specified file

#include <WinAPIFiles.au3>
_WinAPI_GetFileTitle ( $sFilePath )

Parameters

$sFilePath The name and location of a file.

Return Value

Success: | The name of the file.
Failure: | Empty string.

Remarks

_WinAPI_GetFileTitle() should only be called with legal file names; using an illegal file name has an undefined result.

_WinAPI_GetFileTitle() returns the string that the system would use to display the file name to the user.
The display name includes an extension only if that is the user's preference for displaying file names.
This means that the returned string may not accurately identify the file if it is used in calls to file system functions.

See Also

Search GetFileTitle in MSDN Library.


Function _WinAPI_GetFileType

Function Reference

_WinAPI_GetFileType

Retrieves the file type of the specified file

#include <WinAPIFiles.au3>
_WinAPI_GetFileType ( $hFile )

Parameters

$hFile Handle to the file.

Return Value

Success: | The file type ($FILE_TYPE_*).
Failure: | (-1) and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

$FILE_TYPE_* constants require #include <APIFilesConstants.au3>

See Also

Search GetFileType in MSDN Library.


Function _WinAPI_GetFinalPathNameByHandle

Function Reference

_WinAPI_GetFinalPathNameByHandle

Retrieves the final path of the specified file

#include <WinAPIFiles.au3>
_WinAPI_GetFinalPathNameByHandle ( $hFile )

Parameters

$hFile Handle to a file or directory whose path is to be retrieved.

Return Value

Success: | The path of the file.
Failure: | Empty string and sets the @error flag to non-zero, @extended flag may contain the NTSTATUS error code.

See Also

Search ZwQueryInformationFile in MSDN Library.

Example

#include <WinAPI.au3>
#include <WinAPIFiles.au3>

Local $hFile = _WinAPI_CreateFile(@ScriptFullPath, 2, 0, 6)

ConsoleWrite(_WinAPI_GetFinalPathNameByHandle($hFile) & @CRLF)

_WinAPI_CloseHandle($hFile)


Function _WinAPI_GetFinalPathNameByHandleEx

Function Reference

_WinAPI_GetFinalPathNameByHandleEx

Retrieves the final path of the specified file

#include <WinAPIFiles.au3>
_WinAPI_GetFinalPathNameByHandleEx ( $hFile [, $iFlags = 0] )

Parameters

$hFile | Handle to a file or directory.
$iFlags | [optional] The type of result to return. This parameter can be combination of one $FILE_NAME_* and one $VOLUME_NAME_* values. $FILE_NAME_NORMALIZED $FILE_NAME_OPENED $VOLUME_NAME_DOS $VOLUME_NAME_GUID $VOLUME_NAME_NONE $VOLUME_NAME_NT

Return Value

Success: | The path of the file.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

This function requires Windows Vista or later.

See Also

Search GetFinalPathNameByHandle in MSDN Library.

Example

#include <APIFilesConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

Local $hFile = _WinAPI_CreateFile(@ScriptFullPath, 2, 0, 6)

ConsoleWrite(_WinAPI_GetFinalPathNameByHandleEx($hFile) & @CRLF)
ConsoleWrite(_WinAPI_GetFinalPathNameByHandleEx($hFile, $VOLUME_NAME_GUID) & @CRLF)
ConsoleWrite(_WinAPI_GetFinalPathNameByHandleEx($hFile, $VOLUME_NAME_NT) & @CRLF)
ConsoleWrite(_WinAPI_GetFinalPathNameByHandleEx($hFile, $VOLUME_NAME_NONE) & @CRLF)

_WinAPI_CloseHandle($hFile)


Function _WinAPI_GetFullPathName

Function Reference

_WinAPI_GetFullPathName

Retrieves the full path and file name of the specified file

#include <WinAPIFiles.au3>
_WinAPI_GetFullPathName ( $sFilePath )

Parameters

$sFilePath The name of the file.

Return Value

Success: | The drive and path.
Failure: | Empty string, call _WinAPI_GetLastError() to get extended error information.

Remarks

The _WinAPI_GetFullPathName() merges the name of the current drive and directory with a specified file name to determine the full path and file name of a specified file.
This function does not verify that the resulting path and file name are valid, or that they see an existing file on the associated volume.

See Also

Search GetFullPathName in MSDN Library.

Example

#include <WinAPIFiles.au3>

Local Const $sPath1 = 'Test.txt'
Local Const $sPath2 = 'Test\Test.txt'
Local Const $sPath3 = 'C:\Test\Test.txt'

ConsoleWrite($sPath1 & ' => ' & _WinAPI_GetFullPathName($sPath1) & @CRLF)
ConsoleWrite($sPath2 & ' => ' & _WinAPI_GetFullPathName($sPath2) & @CRLF)
ConsoleWrite($sPath3 & ' => ' & _WinAPI_GetFullPathName($sPath3) & @CRLF)


Function _WinAPI_GetProfilesDirectory

Function Reference

_WinAPI_GetProfilesDirectory

Retrieves the path to the root directory where user profiles are stored

#include <WinAPIFiles.au3>
_WinAPI_GetProfilesDirectory ( )

Return Value

Success: | The path to the directory.
Failure: | Empty string and sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetProfilesDirectory in MSDN Library.


Function _WinAPI_GetTempFileName

Function Reference

_WinAPI_GetTempFileName

Creates a name for a temporary file

#include <WinAPIFiles.au3>
_WinAPI_GetTempFileName ( $sFilePath [, $sPrefix = ''] )

Parameters

$sFilePath | The directory path for the file name. Applications typically specify a period (.) for the current directory.
$sPrefix | [optional] The prefix string. The function uses up to the first three characters of this string as the prefix of the file name.

Return Value

Success: | The temporary file name.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

Temporary files whose names have been created by this function are not automatically deleted.

Related

_TempFile

See Also

Search GetTempFileName in MSDN Library.


Function _WinAPI_GetVolumeInformation

Function Reference

_WinAPI_GetVolumeInformation

Retrieves information about the file system and volume associated with the specified root directory

#include <WinAPIFiles.au3>
_WinAPI_GetVolumeInformation ( [$sRoot = ''] )

Parameters

$sRoot [optional] The root directory of the volume to be described. If this parameter is empty string, the root
of the current directory is used. A trailing backslash is required. For example, you specify
"\\MyServer\MyShare" as "\\MyServer\MyShare\", or the "C" drive as "C:\".

Return Value

Success: | The array that contains the following information: [0] - The name of a volume. [2] - The serial number of a volume. [1] - The maximum length, in TCHARs, of a file name component that a file system supports. [3] - The flags associated with the file system ($FILE_*). [4] - The name of the file system, for example, "FAT", "NTFS", etc.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

When a user attempts to get information about a floppy drive that does not have a floppy disk, or a CD-ROM
drive that does not have a compact disc, the system displays a message box for the user to insert a floppy disk
or a compact disc, respectively. To prevent the system from displaying this message box, call the
_WinAPI_SetErrorMode() function with $SEM_FAILCRITICALERRORS.

See Also

Search GetVolumeInformation in MSDN Library.

Example

#include <WinAPIFiles.au3>

Local $aData = _WinAPI_GetVolumeInformation()

ConsoleWrite('Volume name: ' & $aData[0] & @CRLF)
ConsoleWrite('File system: ' & $aData[4] & @CRLF)
ConsoleWrite('Serial number: ' & $aData[1] & @CRLF)
ConsoleWrite('File name length: ' & $aData[2] & @CRLF)
ConsoleWrite('Flags: 0x' & Hex($aData[3]) & @CRLF)


Function _WinAPI_GetVolumeInformationByHandle

Function Reference

_WinAPI_GetVolumeInformationByHandle

Retrieves information about the file system and volume associated with the specified file

#include <WinAPIFiles.au3>
_WinAPI_GetVolumeInformationByHandle ( $hFile )

Parameters

$hFile A handle to the file.

Return Value

Success: | The array that contains the following information: [0] - The name of a volume. [2] - The serial number of a volume. [1] - The maximum length, in TCHARs, of a file name component that a file system supports. [3] - The flags associated with the file system ($FILE_*). [4] - The name of the file system, for example, "FAT", "NTFS", etc.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

This function requires Windows Vista or later.

See Also

Search GetVolumeInformationByHandleW in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

Local $hFile = _WinAPI_CreateFile(@ScriptFullPath, 2, 0, 6)
Local $aInfo = _WinAPI_GetVolumeInformationByHandle($hFile)
_WinAPI_CloseHandle($hFile)

ConsoleWrite('Volume name: ' & $aInfo[0] & @CRLF)
ConsoleWrite('File system: ' & $aInfo[4] & @CRLF)
ConsoleWrite('Serial number: ' & $aInfo[1] & @CRLF)
ConsoleWrite('File name length: ' & $aInfo[2] & @CRLF)
ConsoleWrite('Flags: 0x' & Hex($aInfo[3]) & @CRLF)


Function _WinAPI_GetVolumeNameForVolumeMountPoint

Function Reference

_WinAPI_GetVolumeNameForVolumeMountPoint

Retrieves a volume GUID path for the volume that is associated with the specified volume mount point

#include <WinAPIFiles.au3>
_WinAPI_GetVolumeNameForVolumeMountPoint ( $sMountedPath )

Parameters

$sMountedPath The path of a mounted folder (for example, Y:\MountX\) or a drive letter (for example, X:\).

Return Value

Success: | The volume GUID path. This path is of the form "\\?\Volume{GUID}\" where GUID is a GUID that identifies the volume. If there is more than one volume GUID path for the volume, only the first one in the mount manager's cache is returned.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetVolumeNameForVolumeMountPoint in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Local $sPath = @TempDir & '\Mount'
Local $iCount = 0

While FileExists($sPath & $iCount)
    $iCount += 1
WEnd

$sPath &= $iCount & '\'

If Not DirCreate($sPath) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create folder.')
    Exit
EndIf

Local $sGUID = _WinAPI_GetVolumeNameForVolumeMountPoint(@HomeDrive & '\')
If _WinAPI_SetVolumeMountPoint($sPath, $sGUID) Then
    MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), '', 'The drive "' & StringUpper(@HomeDrive) & '" has been associated with "' & $sPath & '".' & @CRLF & @CRLF & 'Press OK to unmount folder.')
    _WinAPI_DeleteVolumeMountPoint($sPath)
Else
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to mount folder.')
EndIf

DirRemove($sPath)


Function _WinAPI_IsPathShared

Function Reference

_WinAPI_IsPathShared

Determines whether the path is shared

#include <WinAPIFiles.au3>
_WinAPI_IsPathShared ( $sFilePath )

Parameters

$sFilePath The fully-qualified local path to be tested.

Return Value

Success: | True - The path is shared. False - Otherwise.
Failure: | Sets the @error flag to non-zero.

Remarks

Not documented in MSDN


Function _WinAPI_LockDevice

Function Reference

_WinAPI_LockDevice

Enables or disables the mechanism that ejects media, for those devices possessing that locking capability

#include <WinAPIFiles.au3>
_WinAPI_LockDevice ( $sDrive, $bLock )

Parameters

$sDrive | The drive letter of the device to enable or disable, in the format D:, E:, etc.
$bLock | Specifies whether the device should be disabled, valid values: True - The device is disabled. False - The device is enabled.

Return Value

Success: | True.
Failure: | False and sets the @error flag to non-zero.

Remarks

This function is valid only for devices that support removable media.

See Also

Search IOCTL_STORAGE_MEDIA_REMOVAL in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Local $aDrive = DriveGetDrive('CDROM')

If IsArray($aDrive) Then
    _WinAPI_LockDevice($aDrive[1], 1)
    MsgBox($MB_SYSTEMMODAL, '', 'The drive (' & StringUpper($aDrive[1]) & ') is locked.')
    _WinAPI_LockDevice($aDrive[1], 0)
    MsgBox($MB_SYSTEMMODAL, '', 'The drive (' & StringUpper($aDrive[1]) & ') is unlocked.')
EndIf


Function _WinAPI_LockFile

Function Reference

_WinAPI_LockFile

Locks the specified file for exclusive access by the calling process

#include <WinAPIFiles.au3>
_WinAPI_LockFile ( $hFile, $iOffset, $iLength )

Parameters

$hFile | Handle to the file.
$iOffset | The starting byte offset in the file where the lock should begin.
$iLength | The length of the byte range to be locked.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

If a process terminates with a portion of a file locked or closes a file that has outstanding locks, the locks are
unlocked by the operating system. However, the time it takes for the operating system to unlock these locks depends
upon available system resources. Therefore, it is recommended that your process explicitly unlock all files it
has locked when it terminates.

See Also

Search LockFile in MSDN Library.


Function _WinAPI_MapViewOfFile

Function Reference

_WinAPI_MapViewOfFile

Maps a view of a file mapping into the address space of a calling process

#include <WinAPIFiles.au3>
_WinAPI_MapViewOfFile ( $hMapping [, $iOffset = 0 [, $iBytes = 0 [, $iAccess = 0x0006]]] )

Parameters

$hMapping | Handle to a file mapping object. The _WinAPI_CreateFileMapping() and _WinAPI_OpenFileMapping() functions return this handle.
$iOffset | [optional] The file offset where the view is to begin.
$iBytes | [optional] The number of bytes of a file mapping to map to a view. All bytes must be within the maximum size specified by _WinAPI_CreateFileMapping(). If $iBytes is 0, the mapping extends from the specified offset to the end of the file mapping.
$iAccess | [optional] The access to the file mapping object. This parameter can be one of the following values. $FILE_MAP_ALL_ACCESS $FILE_MAP_COPY $FILE_MAP_READ (Default) $FILE_MAP_WRITE (Default) Each of the preceding values can be combined with the following value. $FILE_MAP_EXECUTE

Return Value

Success: | The starting address of the mapped view.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

For files that are larger than the address space, you can only map a small portion of the file data at one time.
When the first view is complete, then you unmap it and map a new view.

See Also

Search MapViewOfFile in MSDN Library.

Example

#NoTrayIcon

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIFiles.au3>

Opt('WinWaitDelay', 0)

Global Const $g_sTitle = '_WinAPI_MapViewOfFile' & ChrW(160)

If Not $CmdLine[0] Then
    If WinExists($g_sTitle) Then
        Exit
    EndIf
    For $i = 1 To 2
        If Not @Compiled Then
            Run(@AutoItExe & ' "' & @ScriptFullPath & '" /' & $i)
        Else
            Run(@AutoItExe & ' /' & $i)
        EndIf
        Sleep(500)
    Next
    Exit
EndIf

Opt('TrayIconHide', 0)

Switch $CmdLine[1]
    Case '/1'
        _Sender()
    Case '/2'
        _Receiver()
    Case Else
        Exit
EndSwitch

Func _Receiver()
    Local $hMapping = _WinAPI_OpenFileMapping('MyFileMapping')
    If Not $hMapping Then Return

    Local $pAddress = _WinAPI_MapViewOfFile($hMapping)
    Local $tData = DllStructCreate('wchar[1024]', $pAddress)
    Local $sText
    While WinWait($g_sTitle, '', 1)
        Sleep(200)
        $sText = DllStructGetData($tData, 1)
        DllStructSetData($tData, 1, '')
        If $sText Then MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), $g_sTitle & " (receiver)", "                                               " & @CRLF & $sText)
    WEnd
    _WinAPI_UnmapViewOfFile($pAddress)
    _WinAPI_CloseHandle($hMapping)
EndFunc   ;==>_Receiver

Func _Sender()
    Local $hMapping = _WinAPI_CreateFileMapping(-1, 2048, 'MyFileMapping')
    If Not $hMapping Or @extended Then
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create file mapping (@extended=' & @extended & ').')
        Return
    EndIf

    Local $pAddress = _WinAPI_MapViewOfFile($hMapping)
    Local $tData = DllStructCreate('wchar[1024]', $pAddress)
    Local $sText
    While WinWaitClose($g_sTitle)
        $sText = StringStripWS(InputBox($g_sTitle & " (sender)", 'Type some text message.', '', '', -1, 171), 3)
        If Not $sText Then
            ExitLoop
        EndIf
        DllStructSetData($tData, 1, $sText)
        If Not WinWait($g_sTitle, '', 1) Then
            ExitLoop
        EndIf
    WEnd
    _WinAPI_UnmapViewOfFile($pAddress)
    _WinAPI_CloseHandle($hMapping)
EndFunc   ;==>_Sender


Function _WinAPI_MoveFileEx

Function Reference

_WinAPI_MoveFileEx

Moves a file or directory, notifying the application of its progress through a callback function

#include <WinAPIFiles.au3>
_WinAPI_MoveFileEx ( $sExistingFile, $sNewFile [, $iFlags = 0 [, $pProgressProc = 0 [, $pData = 0]]] )

Parameters

$sExistingFile | The name of the existing file or directory on the local computer. If $iFlags specifies $MOVE_FILE_DELAY_UNTIL_REBOOT, the file cannot exist on a remote share because delayed operations are performed before the network is available.
$sNewFile | The new name of the file or directory on the local computer. When moving a file, $sNewFile can be on a different file system or volume. If $sNewFile is on another drive, you must set the $MOVE_FILE_COPY_ALLOWED flag in $iFlags parameter. When moving a directory, $sExistingFile and $sNewFile must be on the same drive. If $iFlags specifies $MOVE_FILE_DELAY_UNTIL_REBOOT and $sNewFile is 0, _WinAPI_MoveFileEx() registers $sExistingFile to be deleted when the system restarts. If $sExistingFile refers to a directory, the system removes the directory at restart only if the directory is empty.
$iFlags | [optional] The move options. This parameter can be one or more of the following values: $MOVE_FILE_COPY_ALLOWED (0x0002) $MOVE_FILE_CREATE_HARDLINK (0x0010) $MOVE_FILE_DELAY_UNTIL_REBOOT (0x0004) $MOVE_FILE_FAIL_IF_NOT_TRACKABLE (0x0020) $MOVE_FILE_REPLACE_EXISTING (0x0001) $MOVE_FILE_WRITE_THROUGH (0x0008)
$pProgressProc | [optional] The address of a callback function that is called each time another portion of the file has been moved. (See MSDN for more information)
$pData | [optional] Pointer to the argument to be passed to the callback function.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

$MOVE_* , $PROGRESS_* constants require #include <APIFilesConstants.au3>

If the $iFlags parameter specifies $MOVE_FILE_DELAY_UNTIL_REBOOT, _WinAPI_MoveFileEx() fails if it cannot access the registry.
The function stores the locations of the files to be renamed at restart in the following registry value:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations

See Also

Search MoveFileWithProgress in MSDN Library.

Example

#include <APIFilesConstants.au3>
#include <Misc.au3>
#include <WinAPIDiag.au3>
#include <WinAPIFiles.au3>

Opt('TrayAutoPause', 0)

Local $hProgressProc = DllCallbackRegister('_ProgressProc', 'bool', 'uint64;uint64;uint64;uint64;dword;dword;handle;handle;ptr')

FileDelete(@TempDir & '\Test*.tmp')

ProgressOn('_WinAPI_MoveFileEx()', 'Bigfile Creation...', '')
Local $sFile = @TempDir & '\Test.tmp'
Local $hFile = FileOpen($sFile, 2)
For $i = 1 To 1000000
    FileWriteLine($hFile, "                                                     ")
Next
FileClose($hFile)

ProgressOn('_WinAPI_MoveFileEx()', 'Moving...', '0%')
Sleep(500) ; to show the change as moving on same device just rename

If Not _WinAPI_MoveFileEx($sFile, @TempDir & '\Test1.tmp', $MOVE_FILE_COPY_ALLOWED, DllCallbackGetPtr($hProgressProc)) Then
    _WinAPI_ShowLastError('Error moving ' & $sFile)
EndIf

DllCallbackFree($hProgressProc)

ProgressOff()

FileDelete(@TempDir & '\Test*.tmp')

Func _ProgressProc($iTotalFileSize, $iTotalBytesTransferred, $iStreamSize, $iStreamBytesTransferred, $iStreamNumber, $iCallbackReason, $hSourceFile, $hDestinationFile, $pData)
    #forceref $iStreamSize, $iStreamBytesTransferred, $iStreamNumber, $iCallbackReason, $hSourceFile, $hDestinationFile, $pData

    Local $iPercent = Round($iTotalBytesTransferred / $iTotalFileSize * 100)
    If $iPercent = 100 Then
        ProgressSet($iPercent, '', 'Complete')
    Else
        ProgressSet($iPercent, $iPercent & "%")
    EndIf
    Sleep(100)

    If _IsPressed('1B') Then
        Return $PROGRESS_CANCEL
    Else
        Return $PROGRESS_CONTINUE
    EndIf
EndFunc   ;==>_ProgressProc


Function _WinAPI_OpenFileById

Function Reference

_WinAPI_OpenFileById

Opens the file that matches the specified object identifier

#include <WinAPIFiles.au3>
_WinAPI_OpenFileById ( $hFile, $vID [, $iAccess = 0 [, $iShare = 0 [, $iFlags = 0]]] )

Parameters

$hFile | The path or handle to any file on a volume or share on which the file to be opened is stored.
$vID | The file identifier (FileID), or $tagGUID structure (ObjectID), or GUID's string representation in the form "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" that identifies the file to open.
$iAccess | [optional] The access to the object. Access can be read, write, or both. If this parameter is 0 (Default), the application can query file and device attributes without accessing a device. $GENERIC_READ $GENERIC_WRITE (See MSDN for more information)
$iShare | [optional] The sharing mode of an object, which can be read, write, both, or none. If this parameter is 0 (Default) and function succeeds, the object cannot be shared and cannot be opened again until the handle is closed. $FILE_SHARE_DELETE $FILE_SHARE_READ $FILE_SHARE_WRITE
$iFlags | [optional] The file flags. When _WinAPI_OpenFileById() opens a file, it combines the file flags with existing file attributes, and ignores any supplied file attributes. This parameter can include any combination of the following values. $FILE_FLAG_BACKUP_SEMANTICS $FILE_FLAG_NO_BUFFERING $FILE_FLAG_OPEN_NO_RECALL $FILE_FLAG_OPEN_REPARSE_POINT $FILE_FLAG_OVERLAPPED $FILE_FLAG_RANDOM_ACCESS $FILE_FLAG_SEQUENTIAL_SCAN $FILE_FLAG_WRITE_THROUGH

Return Value

Success: | Handle to a specified file.
Failure: | 0 and sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

When an application is finished using the object handle returned by this function, use the _WinAPI_CloseHandle()
function to close the handle. This not only frees up system resources, but can have wider influence on things
like sharing the file or device and committing data to disk.

This function requires Windows Vista or later.

Related

_WinAPI_CloseHandle

See Also

Search OpenFileById in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

; Create temporary file
Local $sFile = _WinAPI_GetTempFileName(@TempDir)

; Create unique object ID for a file
Local $tGUID = _WinAPI_CreateObjectID($sFile)

ConsoleWrite('GUID: ' & _WinAPI_StringFromGUID($tGUID) & @CRLF)

; Open file by object ID and retrieve its full path
Local $hFile = _WinAPI_OpenFileById(_WinAPI_PathStripToRoot(@TempDir), $tGUID, 0, BitOR($FILE_SHARE_DELETE, $FILE_SHARE_READ, $FILE_SHARE_WRITE))
$sFile = _WinAPI_GetFinalPathNameByHandleEx($hFile)
_WinAPI_CloseHandle($hFile)

ConsoleWrite('Path: ' & StringRegExpReplace($sFile, '\\+.\\', '') & @CRLF)

; Delete file
FileDelete($sFile)


Function _WinAPI_OpenFileMapping

Function Reference

_WinAPI_OpenFileMapping

Opens a named file mapping object

#include <WinAPIFiles.au3>
_WinAPI_OpenFileMapping ( $sName [, $iAccess = 0x0006 [, $bInherit = False]] )

Parameters

$sName | The name of the file mapping object to be opened.
$iAccess | [optional] The access to the file mapping object. This parameter can be one of the following values. $FILE_MAP_ALL_ACCESS $FILE_MAP_COPY $FILE_MAP_READ (Default) $FILE_MAP_WRITE (Default) Each of the preceding values can be combined with the following value. $FILE_MAP_EXECUTE
$bInherit | [optional] Specifies whether inherites the handle by a processes, valid values: True - The processes created by this process will inherit the handle. False - The processes do not inherit this handle (Default).

Return Value

Success: | Handle to the specified file mapping object.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search OpenFileMapping in MSDN Library.

Example

#NoTrayIcon

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIFiles.au3>

Opt('WinWaitDelay', 0)

Global Const $g_sTitle = '_WinAPI_MapViewOfFile' & ChrW(160)

If Not $CmdLine[0] Then
    If WinExists($g_sTitle) Then
        Exit
    EndIf
    For $i = 1 To 2
        If Not @Compiled Then
            Run(@AutoItExe & ' "' & @ScriptFullPath & '" /' & $i)
        Else
            Run(@AutoItExe & ' /' & $i)
        EndIf
        Sleep(500)
    Next
    Exit
EndIf

Opt('TrayIconHide', 0)

Switch $CmdLine[1]
    Case '/1'
        _Sender()
    Case '/2'
        _Receiver()
    Case Else
        Exit
EndSwitch

Func _Receiver()
    Local $hMapping = _WinAPI_OpenFileMapping('MyFileMapping')
    If Not $hMapping Then Return

    Local $pAddress = _WinAPI_MapViewOfFile($hMapping)
    Local $tData = DllStructCreate('wchar[1024]', $pAddress)
    Local $sText
    While WinWait($g_sTitle, '', 1)
        Sleep(200)
        $sText = DllStructGetData($tData, 1)
        DllStructSetData($tData, 1, '')
        If $sText Then MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), $g_sTitle & " (receiver)", "                                               " & @CRLF & $sText)
    WEnd
    _WinAPI_UnmapViewOfFile($pAddress)
    _WinAPI_CloseHandle($hMapping)
EndFunc   ;==>_Receiver

Func _Sender()
    Local $hMapping = _WinAPI_CreateFileMapping(-1, 2048, 'MyFileMapping')
    If Not $hMapping Or @extended Then
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create file mapping (@extended=' & @extended & ').')
        Return
    EndIf

    Local $pAddress = _WinAPI_MapViewOfFile($hMapping)
    Local $tData = DllStructCreate('wchar[1024]', $pAddress)
    Local $sText
    While WinWaitClose($g_sTitle)
        $sText = StringStripWS(InputBox($g_sTitle & " (sender)", 'Type some text message.', '', '', -1, 171), 3)
        If Not $sText Then
            ExitLoop
        EndIf
        DllStructSetData($tData, 1, $sText)
        If Not WinWait($g_sTitle, '', 1) Then
            ExitLoop
        EndIf
    WEnd
    _WinAPI_UnmapViewOfFile($pAddress)
    _WinAPI_CloseHandle($hMapping)
EndFunc   ;==>_Sender


Function _WinAPI_PathIsDirectory

Function Reference

_WinAPI_PathIsDirectory

Verifies that a path is a valid directory

#include <WinAPIFiles.au3>
_WinAPI_PathIsDirectory ( $sFilePath )

Parameters

$sFilePath The path to verify.

Return Value

True: | $FILE_ATTRIBUTE_DIRECTORY if the path is a valid directory.
False: | is not a valid directory.

See Also

Search PathIsDirectory in MSDN Library.

Example

#include <WinAPIFiles.au3>

ConsoleWrite(@ScriptDir & ' exists : ' & _WinAPI_PathIsDirectory(@ScriptDir) & @CRLF)


Function _WinAPI_PathIsDirectoryEmpty

Function Reference

_WinAPI_PathIsDirectoryEmpty

Determines whether a specified path is an empty directory

#include <WinAPIFiles.au3>
_WinAPI_PathIsDirectoryEmpty ( $sFilePath )

Parameters

$sFilePath The path to be tested.

Return Value

True: | the path is an empty directory.
False: | not empty directory.

Remarks

"C:\" is considered a directory.

See Also

Search PathIsDirectoryEmpty in MSDN Library.


Function _WinAPI_ReadDirectoryChanges

Function Reference

_WinAPI_ReadDirectoryChanges

Retrieves information that describes the changes within the specified directory

#include <WinAPIFiles.au3>
_WinAPI_ReadDirectoryChanges ( $hDirectory, $iFilter, $pBuffer, $iLength [, $bSubtree = 0] )

Parameters

$hDirectory | A handle to the directory to be monitored. This directory must be opened with the $FILE_LIST_DIRECTORY access right.
$iFilter | The filter criteria that the function checks to determine if the wait operation has completed. This parameter can be one or more of the following values. $FILE_NOTIFY_CHANGE_FILE_NAME $FILE_NOTIFY_CHANGE_DIR_NAME $FILE_NOTIFY_CHANGE_ATTRIBUTES $FILE_NOTIFY_CHANGE_SIZE $FILE_NOTIFY_CHANGE_LAST_WRITE $FILE_NOTIFY_CHANGE_LAST_ACCESS $FILE_NOTIFY_CHANGE_CREATION $FILE_NOTIFY_CHANGE_SECURITY
$pBuffer | A pointer to the DWORD-aligned formatted buffer that internally used by this function to retrieve the data. To create a buffer, you can use _WinAPI_CreateBuffer() function. To prevent the crash of the script, use the buffer at least not less than 64 KB. If the buffer is greater than 64 KB and the application is monitoring a directory over the network, the function fails. This is due to a packet size limitation with the underlying file sharing protocols.
$iLength | The size of the buffer, in bytes.
$bSubtree | [optional] Specifies whether to monitor the subdirectories of the specified directory, valid values: True - Monitor the directory tree rooted at the specified directory. False - Monitor only the specified directory (Default).

Return Value

Success: | The 2D array containing the following information: [0][0] - Number of rows in array (n) [0][1] - Unused [n][0] - The file name relative to the directory handle. [n][1] - The type of change that has occurred (one of the $FILE_ACTION_* constants).
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

When you first call _WinAPI_ReadDirectoryChanges() function, the system allocates a buffer to store change information.
This buffer is associated with the directory handle until it is closed and its size does not change during its lifetime.
Directory changes that occur between calls to this function are added to the buffer and then returned with the next call.
If the buffer overflows, the entire contents are discarded.

To obtain a handle to a directory, use _WinAPI_CreateFileEx() function with $FILE_FLAG_BACKUP_SEMANTICS flag.

The _WinAPI_ReadDirectoryChanges() function works only in synchronous mode.

Related

_WinAPI_CreateFileEx

See Also

Search ReadDirectoryChangesW in MSDN Library.

Example

#include <APIFilesConstants.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPIFiles.au3>
#include <WinAPISys.au3>

Global $g_sPath = @TempDir & '\~TEST~'

DirCreate($g_sPath)
If Not FileExists($g_sPath) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create folder.')
    Exit
EndIf

OnAutoItExitRegister('OnAutoItExit')

Local $hDirectory = _WinAPI_CreateFileEx($g_sPath, $OPEN_EXISTING, $FILE_LIST_DIRECTORY, BitOR($FILE_SHARE_READ, $FILE_SHARE_WRITE), $FILE_FLAG_BACKUP_SEMANTICS)
If @error Then
    _WinAPI_ShowLastError('', 1)
EndIf

Local $pBuffer = _WinAPI_CreateBuffer(8388608)

Local $aData
While 1
    $aData = _WinAPI_ReadDirectoryChanges($hDirectory, BitOR($FILE_NOTIFY_CHANGE_FILE_NAME, $FILE_NOTIFY_CHANGE_DIR_NAME), $pBuffer, 8388608, 1)
    If Not @error Then
        _ArrayDisplay($aData, '_WinAPI_ReadDirectoryChanges')
    Else
        _WinAPI_ShowLastError('', 1)
    EndIf
WEnd

Func OnAutoItExit()
    DirRemove($g_sPath, 1)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_RemoveDirectory

Function Reference

_WinAPI_RemoveDirectory

Deletes an existing empty directory

#include <WinAPIFiles.au3>
_WinAPI_RemoveDirectory ( $sDirPath )

Parameters

$sDirPath The path of the empty directory to be removed.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

The _WinAPI_RemoveDirectory() function marks a directory for deletion on close. Therefore, the directory is
not removed until the last handle to the directory is closed.

See Also

Search RemoveDirectory in MSDN Library.


Function _WinAPI_ReOpenFile

Function Reference

_WinAPI_ReOpenFile

Reopens the specified file system object with different access rights, sharing mode, and flags

#include <WinAPIFiles.au3>
_WinAPI_ReOpenFile ( $hFile, $iAccess, $iShare [, $iFlags = 0] )

Parameters

$hFile | Handle to the object to be reopened. The object must have been created by the _WinAPI_CreateFileEx() function.
$iAccess | The required access to the object. If this parameter is 0, the application can query device attributes without accessing the device. $GENERIC_READ $GENERIC_WRITE (See MSDN for more information)
$iShare | The sharing mode of the object. If this parameter is 0, the object cannot be shared and cannot be opened again until the handle is closed. $FILE_SHARE_READ $FILE_SHARE_WRITE $FILE_SHARE_DELETE
$iFlags | [optional] The file or device attributes and flags. This parameter can be one or more of the following values. $FILE_FLAG_BACKUP_SEMANTICS $FILE_FLAG_DELETE_ON_CLOSE $FILE_FLAG_NO_BUFFERING $FILE_FLAG_OPEN_NO_RECALL $FILE_FLAG_OPEN_REPARSE_POINT $FILE_FLAG_OVERLAPPED $FILE_FLAG_POSIX_SEMANTICS $FILE_FLAG_RANDOM_ACCESS $FILE_FLAG_SEQUENTIAL_SCAN $FILE_FLAG_WRITE_THROUGH $SECURITY_ANONYMOUS $SECURITY_CONTEXT_TRACKING $SECURITY_DELEGATION $SECURITY_EFFECTIVE_ONLY $SECURITY_IDENTIFICATION $SECURITY_IMPERSONATION

Return Value

Success: | Handle to the specified file.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

The $iFlags parameter cannot contain any of the file attribute flags ($FILE_ATTRIBUTE_*). These can only be
specified when the file is created.

This function requires Windows Vista or later.

Related

_WinAPI_CreateFileEx

See Also

Search ReOpenFile in MSDN Library.


Function _WinAPI_ReplaceFile

Function Reference

_WinAPI_ReplaceFile

Replaces one file with another file, and creates a backup copy of the original file

#include <WinAPIFiles.au3>
_WinAPI_ReplaceFile ( $sReplacedFile, $sReplacementFile [, $sBackupFile = '' [, $iFlags = 0]] )

Parameters

$sReplacedFile | The name of the file to be replaced.
$sReplacementFile | The name of the file that will replace the $sReplacedFile file.
$sBackupFile | [optional] The name of the file that will serve as a backup copy of the $sReplacedFile file. If this parameter is empty string, no backup file is created.
$iFlags | [optional] The replacement options. This parameter can be one or more of the following values. $REPLACEFILE_WRITE_THROUGH $REPLACEFILE_IGNORE_MERGE_ERRORS $REPLACEFILE_IGNORE_ACL_ERRORS

Return Value

Success: | True.
Failure: | False (see remarks).

Remarks

If this function fails, call _WinAPI_GetLastError() function to get extended error information. The following
are possible error codes for this function.

ERROR_UNABLE_TO_MOVE_REPLACEMENT (1176)
The replacement file could not be renamed. If $sBackupFile was specified, the replaced and replacement files
retain their original file names. Otherwise, the replaced file no longer exists and the replacement file exists
under its original name.

ERROR_UNABLE_TO_MOVE_REPLACEMENT_2 (1177)
The replacement file could not be moved. The replacement file still exists under its original name; however,
it has inherited the file streams and attributes from the file it is replacing. The file to be replaced still
exists with the name specified by $sReplacedFile.

ERROR_UNABLE_TO_REMOVE_REPLACED (1175)
The replaced file could not be deleted. The replaced and replacement files retain their original file names.

If any other error is returned, such as ERROR_INVALID_PARAMETER (87), the replaced and replacement files will
retain their original file names. In this scenario, a backup file does not exist and it is not guaranteed
that the replacement file will have inherited all of the attributes and streams of the replaced file.

See Also

Search ReplaceFile in MSDN Library.


Function _WinAPI_SearchPath

Function Reference

_WinAPI_SearchPath

Searches for a specified file in a specified path

#include <WinAPIFiles.au3>
_WinAPI_SearchPath ( $sFilePath [, $sSearchPath = ''] )

Parameters

$sFilePath | The name of the file for which to search.
$sSearchPath | [optional] The path to be searched for the file. If this parameter is omitted or an empty string (Default), the function searches for a matching file using a registry-dependent system search path (see below).

Return Value

Success: | The path of the file found.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

If the path is an empty string, _WinAPI_SearchPath() searches for a matching file based on the current value
of the following registry value:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\SafeProcessSearchMode

When the value of this registry value is set to 1, _WinAPI_SearchPath() first searches the folders that are
specified in the system path, and then searches the current working folder. When the value of this registry value
is set to 0, the computer first searches the current working folder, and then searches the folders that are
specified in the system path. The system default value for this registry key is 0.

This function is not recommended as a method of locating a .dll file if the intended use of the output is in
a call to the _WinAPI_LoadLibrary() function. This can result in locating the wrong .dll file because the search
order of the _WinAPI_SearchPath() function differs from the search order used by the _WinAPI_LoadLibrary()
function. If you need to locate and load a .dll file, use the _WinAPI_LoadLibrary() function.

The search mode used by the _WinAPI_SearchPath() function can also be set per-process by calling the
_WinAPI_SetSearchPathMode() function.

Related

_WinAPI_LoadLibrary, _WinAPI_SetSearchPathMode

See Also

Search SearchPath in MSDN Library.

Example

#include <WinAPIFiles.au3>

Local $sFile = 'Notepad.exe'

ConsoleWrite(_WinAPI_SearchPath($sFile) & @CRLF)
ConsoleWrite(_WinAPI_SearchPath($sFile, @SystemDir) & @CRLF)


Function _WinAPI_SetCompression

Function Reference

_WinAPI_SetCompression

Sets the compression state of a file or directory

#include <WinAPIFiles.au3>
_WinAPI_SetCompression ( $sFilePath, $iCompression )

Parameters

$sFilePath | The path to the file or directory to be compressed.
$iCompression | The compression state. This parameter can be one of the following values. $COMPRESSION_FORMAT_NONE $COMPRESSION_FORMAT_DEFAULT $COMPRESSION_FORMAT_LZNT1

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

If the file system of the volume containing the specified file or directory does not support per-file or
per-directory compression, the function fails. File compression is supported for files of a maximum uncompressed
size of 30 gigabytes.

See Also

Search FSCTL_SET_COMPRESSION in MSDN Library.

Example

#include <APISysConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Local $sFile = FileOpenDialog('Select File', @ScriptDir, 'All Files (*.*)', 1 + 2)
If @error Then Exit

Switch _WinAPI_GetCompression($sFile)
    Case -1
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Compression File', 'Unable to perform operation.')
    Case $COMPRESSION_FORMAT_NONE
        If _WinAPI_SetCompression($sFile, $COMPRESSION_FORMAT_DEFAULT) Then
            MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), 'Compression File', 'The file compressed is successfully.')
        Else
            MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Compression File', 'Unable to compress file.')
        EndIf
    Case Else
        If MsgBox(BitOR($MB_YESNO, $MB_ICONQUESTION, $MB_SYSTEMMODAL), 'Compression File', 'The file is already compressed.' & @CRLF & @CRLF & 'Decompress?') = 6 Then
            If _WinAPI_SetCompression($sFile, $COMPRESSION_FORMAT_NONE) Then
                MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), 'Compression File', 'The file decompressed is successfully.')
            Else
                MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Compression File', 'Unable to decompress file.')
            EndIf
        EndIf
EndSwitch


Function _WinAPI_SetCurrentDirectory

Function Reference

_WinAPI_SetCurrentDirectory

Changes the current directory for the current process

#include <WinAPIFiles.au3>
_WinAPI_SetCurrentDirectory ( $sDir )

Parameters

$sDir The path to the new current directory.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

See Also

Search SetCurrentDirectory in MSDN Library.


Function _WinAPI_SetFileAttributes

Function Reference

_WinAPI_SetFileAttributes

Sets the attributes for a file or directory

#include <WinAPIFiles.au3>
_WinAPI_SetFileAttributes ( $sFilePath, $iAttributes )

Parameters

$sFilePath | The name of the file or directory whose attributes are to be set.
$iAttributes | The file attributes to set for the file. This parameter can be one or more of the following values. $FILE_ATTRIBUTE_READONLY $FILE_ATTRIBUTE_HIDDEN $FILE_ATTRIBUTE_SYSTEM $FILE_ATTRIBUTE_ARCHIVE $FILE_ATTRIBUTE_NORMAL $FILE_ATTRIBUTE_TEMPORARY $FILE_ATTRIBUTE_OFFLINE $FILE_ATTRIBUTE_NOT_CONTENT_INDEXED

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

Not all attributes are supported by this function. For more information, see MSDN library.

See Also

Search SetFileAttributes in MSDN Library.


Function _WinAPI_SetFileInformationByHandleEx

Function Reference

_WinAPI_SetFileInformationByHandleEx

Sets the file information for the specified file

#include <WinAPIFiles.au3>
_WinAPI_SetFileInformationByHandleEx ( $hFile, $tFILEINFO )

Parameters

$hFile | Handle to the file for which to change information. This handle must have an appropriate permissions for the requested change.
$tFILEINFO | $tagFILEINFO structure that contains the information to change.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the NTSTATUS error code.

See Also

Search ZwSetInformationFile in MSDN Library.


Function _WinAPI_SetFilePointerEx

Function Reference

_WinAPI_SetFilePointerEx

Moves the file pointer of the specified file

#include <WinAPIFiles.au3>
_WinAPI_SetFilePointerEx ( $hFile, $iPos [, $iMethod = 0] )

Parameters

$hFile | Handle to the file.
$iPos | The number of bytes to move the file pointer. A positive value moves the pointer forward in the file and a negative value moves the file pointer backward.
$iMethod | [optional] The starting point for the file pointer move. This parameter can be one of the following values. $FILE_BEGIN (Default) $FILE_CURRENT $FILE_END

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

See Also

Search SetFilePointerEx in MSDN Library.


Function _WinAPI_SetFileShortName

Function Reference

_WinAPI_SetFileShortName

Sets the short name for the specified file

#include <WinAPIFiles.au3>
_WinAPI_SetFileShortName ( $hFile, $sShortName )

Parameters

$hFile | A handle to the file. The file must be on an NTFS file system volume. Also, the file must be opened with either the $GENERIC_ALL access right or $GENERIC_WRITE|$DELETE, and with the $FILE_FLAG_BACKUP_SEMANTICS file attribute.
$sShortName | The valid short name for the file. If the specified short name already exists, the function fails and the last error code is ERROR_ALREADY_EXISTS (183).

Return Value

Success: | True
Failure: | False

Remarks

The caller of this function must have the $SE_RESTORE_NAME privilege.

See Also

Search SetFileShortName in MSDN Library.

Example

#include <APIFilesConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIFiles.au3>
#include <WinAPIProc.au3>

Local Const $sTemp = @TempDir & '\Temporary File.txt'

; Check NTFS file system
If StringCompare(DriveGetFileSystem(_WinAPI_PathStripToRoot($sTemp)), 'NTFS') Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'The file must be on an NTFS file system volume.')
    Exit
EndIf

; Enable "SeRestorePrivilege" privilege to perform renaming operation
Local $hToken = _WinAPI_OpenProcessToken(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))
Local $aAdjust
_WinAPI_AdjustTokenPrivileges($hToken, $SE_RESTORE_NAME, $SE_PRIVILEGE_ENABLED, $aAdjust)
If @error Or @extended Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'You do not have the required privileges.')
    Exit
EndIf

; Create temporary file
FileWrite($sTemp, '')

ConsoleWrite('Old short name: ' & _WinAPI_PathStripPath(FileGetShortName($sTemp)) & @CRLF)

; Set "TEMP.TXT" short name for the file
Local $hFile = _WinAPI_CreateFileEx($sTemp, $OPEN_EXISTING, BitOR($GENERIC_WRITE, $RIGHTS_DELETE), 0, $FILE_FLAG_BACKUP_SEMANTICS)
_WinAPI_SetFileShortName($hFile, 'TEMP.TXT')
_WinAPI_CloseHandle($hFile)

ConsoleWrite('New short name: ' & _WinAPI_PathStripPath(FileGetShortName($sTemp)) & @CRLF)

; Delete temporary file
FileDelete($sTemp)

; Restore "SeRestorePrivilege" privilege by default
_WinAPI_AdjustTokenPrivileges($hToken, $aAdjust, 0, $aAdjust)
_WinAPI_CloseHandle($hToken)


Function _WinAPI_SetFileValidData

Function Reference

_WinAPI_SetFileValidData

Sets the valid data length of the specified file

#include <WinAPIFiles.au3>
_WinAPI_SetFileValidData ( $hFile, $iLength )

Parameters

$hFile | A handle to the file. This file must have been opened with the $GENERIC_WRITE access right, and the $SE_MANAGE_VOLUME_NAME privilege enabled. The file cannot be a network file, or be compressed, sparse, or transacted.
$iLength | The new valid data length. This parameter must be a positive value that is greater than the current valid data length, but less than the current file size.

Return Value

Success: | True
Failure: | False

Remarks

This function sets the logical end of a file. To set the size of a file, use the _WinAPI_SetEndOfFile()
function. The physical file size is also referred to as the end of the file.

Typically, the _WinAPI_SetFileValidData() function is used by system-level applications on their own private
data. Not all file systems use valid data length. Some file systems can track multiple valid data ranges.
In general, most applications will never need to call this function.

Related

_WinAPI_SetEndOfFile

See Also

Search SetFileValidData in MSDN Library.


Function _WinAPI_SetSearchPathMode

Function Reference

_WinAPI_SetSearchPathMode

Sets the per-process mode that the _WinAPI_SearchPath() function uses when locating files

#include <WinAPIFiles.au3>
_WinAPI_SetSearchPathMode ( $iFlags )

Parameters

$iFlags The search mode to use. This parameter can be one of the following values.
$BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE
$BASE_SEARCH_PATH_DISABLE_SAFE_SEARCHMODE

Optionaly, $BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE can be combined with the following flag to make this
mode permanent for the current process.
$BASE_SEARCH_PATH_DISABLE_SAFE_SEARCHMODE cannot be combined with this flag.
$BASE_SEARCH_PATH_PERMANENT

Return Value

Success: | True
Failure: | False

Remarks

After the _WinAPI_SetSearchPathMode() function has been successfully called for the current process, the
setting in the system registry is ignored in favor of the mode most recently set successfully.

If the function has been successfully called for the current process with the $BASE_SEARCH_PATH_PERMANENT flag
set, safe mode is set permanently for the calling process. Any subsequent calls to _WinAPI_SetSearchPathMode()
from within that process that attempt to change the search mode will fail with ERROR_ACCESS_DENIED (5).

The _WinAPI_SetSearchPathMode() function does not modify the system registry.

This function requires Windows 7 or later.

Related

_WinAPI_SearchPath

See Also

Search SetSearchPathMode in MSDN Library.


Function _WinAPI_SetVolumeMountPoint

Function Reference

_WinAPI_SetVolumeMountPoint

Associates a volume with a drive letter or a directory on another volume

#include <WinAPIFiles.au3>
_WinAPI_SetVolumeMountPoint ( $sFilePath, $sGUID )

Parameters

$sFilePath | The user-mode path to be associated with the volume. This may be a drive letter (for example, X:\) or a directory on another volume (for example, Y:\MountX).
$sGUID | The volume GUID path for the volume. This string must be of the form "\\?\Volume{GUID}\" where GUID is a GUID that identifies the volume. The \\?\ turns off path parsing and is ignored as part of the path.

Return Value

Success: | True
Failure: | False

Remarks

It is an error to associate a volume with a directory that has any files or subdirectories in it. This error
occurs for system and hidden directories as well as other directories, and it occurs for system and hidden
files.

See Also

Search SetVolumeMountPoint in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Local Const $sPath = @TempDir & '\Mount\'

Local $sGUID = _WinAPI_GetVolumeNameForVolumeMountPoint(@HomeDrive & '\')

DirCreate($sPath)
_WinAPI_SetVolumeMountPoint($sPath, $sGUID)
MsgBox($MB_SYSTEMMODAL, '', 'The drive (' & StringUpper(@HomeDrive) & ') has been associated with "' & $sPath & '".')
_WinAPI_DeleteVolumeMountPoint($sPath)
DirRemove($sPath)


Function _WinAPI_SfcIsFileProtected

Function Reference

_WinAPI_SfcIsFileProtected

Determines whether the specified file is protected

#include <WinAPIFiles.au3>
_WinAPI_SfcIsFileProtected ( $sFilePath )

Parameters

$sFilePath The name of the file to test.

Return Value

True: | the file is protected.
False: | the file is not protected.

See Also

Search SfcIsFileProtected in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

MsgBox($MB_SYSTEMMODAL, "Title", 'File Protection Status = ' & _WinAPI_SfcIsFileProtected(@WindowsDir & "\explorer.exe"))


Function _WinAPI_UnlockFile

Function Reference

_WinAPI_UnlockFile

Unlocks a region in an open file

#include <WinAPIFiles.au3>
_WinAPI_UnlockFile ( $hFile, $iOffset, $iLength )

Parameters

$hFile | Handle to the file that contains a region locked with _WinAPI_LockFile() function.
$iOffset | The starting byte offset in the file where the locked region begins.
$iLength | The length of the byte range to be unlocked.

Return Value

Success: | True
Failure: | False

Remarks

Unlocking a region of a file releases a previously acquired lock on the file. The region to unlock must correspond
exactly to an existing locked region. Two adjacent regions of a file cannot be locked separately and then unlocked
using a single region that spans both locked regions.

Related

_WinAPI_LockFile

See Also

Search UnlockFile in MSDN Library.


Function _WinAPI_UnmapViewOfFile

Function Reference

_WinAPI_UnmapViewOfFile

Unmaps a mapped view of a file from the calling process's address space

#include <WinAPIFiles.au3>
_WinAPI_UnmapViewOfFile ( $pAddress )

Parameters

$pAddress A pointer to the base address of the mapped view of a file that is to be unmapped.
This value must be identical to the value returned by a previous call to the _WinAPI_MapViewOfFile() function.

Return Value

Success: | True
Failure: | False

Remarks

Unmapping a mapped view of a file invalidates the range occupied by the view in the address space of the process and makes the range available for other allocations.
It removes the working set entry for each unmapped virtual page that was part of the working set of the process and reduces the working set size of the process.
It also decrements the share count of the corresponding physical page.

Although an application may close the file handle used to create a file mapping object,
the system holds the corresponding file open until the last view of the file is unmapped.
Files for which the last view has not yet been unmapped are held open with no sharing restrictions.

To minimize the risk of data loss in the event of a power failure or a system crash,
you should explicitly flush modified pages using the _WinAPI_FlushViewOfFile() function.

Related

_WinAPI_FlushViewOfFile, _WinAPI_MapViewOfFile

See Also

Search UnmapViewOfFile in MSDN Library.

Example

#NoTrayIcon

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIFiles.au3>

Opt('WinWaitDelay', 0)

Global Const $g_sTitle = '_WinAPI_MapViewOfFile' & ChrW(160)

If Not $CmdLine[0] Then
    If WinExists($g_sTitle) Then
        Exit
    EndIf
    For $i = 1 To 2
        If Not @Compiled Then
            Run(@AutoItExe & ' "' & @ScriptFullPath & '" /' & $i)
        Else
            Run(@AutoItExe & ' /' & $i)
        EndIf
        Sleep(500)
    Next
    Exit
EndIf

Opt('TrayIconHide', 0)

Switch $CmdLine[1]
    Case '/1'
        _Sender()
    Case '/2'
        _Receiver()
    Case Else
        Exit
EndSwitch

Func _Receiver()
    Local $hMapping = _WinAPI_OpenFileMapping('MyFileMapping')
    If Not $hMapping Then Return

    Local $pAddress = _WinAPI_MapViewOfFile($hMapping)
    Local $tData = DllStructCreate('wchar[1024]', $pAddress)
    Local $sText
    While WinWait($g_sTitle, '', 1)
        Sleep(200)
        $sText = DllStructGetData($tData, 1)
        DllStructSetData($tData, 1, '')
        If $sText Then MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), $g_sTitle & " (receiver)", "                                               " & @CRLF & $sText)
    WEnd
    _WinAPI_UnmapViewOfFile($pAddress)
    _WinAPI_CloseHandle($hMapping)
EndFunc   ;==>_Receiver

Func _Sender()
    Local $hMapping = _WinAPI_CreateFileMapping(-1, 2048, 'MyFileMapping')
    If Not $hMapping Or @extended Then
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create file mapping (@extended=' & @extended & ').')
        Return
    EndIf

    Local $pAddress = _WinAPI_MapViewOfFile($hMapping)
    Local $tData = DllStructCreate('wchar[1024]', $pAddress)
    Local $sText
    While WinWaitClose($g_sTitle)
        $sText = StringStripWS(InputBox($g_sTitle & " (sender)", 'Type some text message.', '', '', -1, 171), 3)
        If Not $sText Then
            ExitLoop
        EndIf
        DllStructSetData($tData, 1, $sText)
        If Not WinWait($g_sTitle, '', 1) Then
            ExitLoop
        EndIf
    WEnd
    _WinAPI_UnmapViewOfFile($pAddress)
    _WinAPI_CloseHandle($hMapping)
EndFunc   ;==>_Sender


GDI Reference

  • BitMap Management
  • Brush & Pen Management
  • Clipping Management
  • Color Management
  • Coordinate & Transform Management
  • Desktop Window Manager Management
  • DeviceContext Management
  • Font & Text Management
  • Line & Curve Management
  • MetaFiles Management
  • Monitors Management
  • Paint & Draw Management
  • Path Management
  • Rectangle Management
  • Region Management
  • Shape Management


User Defined Functions

BitMap user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_WinAPI_AddIconOverlay | Creates an icon by merging the source icon and overlay mask
_WinAPI_AdjustBitmap | Creates a new device-depended bitmap (DDB) from the source bitmap with new dimensions and color adjustment
_WinAPI_AlphaBlend | Displays bitmaps that have transparent or semitransparent pixels
_WinAPI_CompressBitmapBits | Creates a compressed data block from the specified bitmap
_WinAPI_CopyBitmap | Creates a duplicate of a specified bitmap with a device-independent bitmap (DIB) section
_WinAPI_CopyImage | Creates a new image (icon, cursor, or bitmap) and copies the attributes of the specified image to the new one
_WinAPI_Create32BitHBITMAP | Creates a 32 bits-per-pixel bitmap from the specified icon
_WinAPI_Create32BitHICON | Converts an icon to a 32 bits-per-pixel format and copies to the new icon
_WinAPI_CreateANDBitmap | Creates AND bitmask device-independent bitmap (DIB) from the specified bitmap
_WinAPI_CreateBitmapIndirect | Creates a bitmap with the specified width, height, and color format (color planes and bits-per-pixel)
_WinAPI_CreateCompatibleBitmapEx | Creates a bitmap compatible with the device and fills it the specified color
_WinAPI_CreateDIB | Creates an uncompressed device-independent bitmap (DIB) with the specified width, height, and color depth
_WinAPI_CreateDIBColorTable | Creates RGB color table from the specified array of colors
_WinAPI_CreateDIBitmap | Creates a compatible bitmap (DDB) from a DIB and, optionally, sets the bitmap bits
_WinAPI_CreateDIBSection | Creates a DIB that applications can write to directly
_WinAPI_CreateEmptyIcon | Creates a fully transparent icon with the specified width, height, and color depth
_WinAPI_CreateIconIndirect | Creates an icon or cursor that has the specified size, colors, and bit patterns
_WinAPI_DrawBitmap | Draws a bitmap into the specified device context
_WinAPI_ExtFloodFill | Fills an area of the display surface with the current brush
_WinAPI_GetBitmapBits | Copies the bitmap bits of a specified device-dependent bitmap into a buffer
_WinAPI_GetBitmapDimension | Retrieves a dimension of the specified bitmap
_WinAPI_GetBitmapDimensionEx | Retrieves the dimensions of a compatible bitmap
_WinAPI_GetDIBColorTable | Retrieves RGB color table from the DIB section bitmap
_WinAPI_GetIconDimension | Retrieves a dimension of the specified icon
_WinAPI_GetPixel | Retrieves the color value of the pixel at the specified coordinates
_WinAPI_GetStretchBltMode | Retrieves the current stretching mode
_WinAPI_GradientFill | Fills rectangle or triangle gradient
_WinAPI_InvertANDBitmap | Inverts the specified AND bitmask bitmap by performing a logical NOT operation
_WinAPI_IsAlphaBitmap | Determines whether the specified bitmap has an alpha channel
_WinAPI_MaskBlt | Combines the color data for the source and destination bitmaps using the specified mask and raster operation
_WinAPI_PlgBlt | Performs a bit-block transfer of color data from the specified rectangle in the source DC to the specified parallelogram in the DC context
_WinAPI_RadialGradientFill | Fills radial gradient
_WinAPI_SaveHBITMAPToFile | Saves a specified bitmap to the specified bitmap (.bmp) file
_WinAPI_SaveHICONToFile | Saves a specified single or multiple icon (HICON) to the specified icon (.ico) file
_WinAPI_SetBitmapBits | Sets the bits of color data for a bitmap to the specified values
_WinAPI_SetBitmapDimensionEx | Assigns preferred dimensions to a compatible bitmap
_WinAPI_SetDIBColorTable | Sets RGB color table in the DIB section bitmap
_WinAPI_SetDIBitsToDevice | Sets the pixels in the specified rectangle on the device
_WinAPI_SetPixel | Sets the pixel at the specified coordinates to the specified color
_WinAPI_SetStretchBltMode | Sets the bitmap stretching mode in the specified device context
_WinAPI_StretchBlt | Copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap to fit the dimensions of the destination rectangle
_WinAPI_StretchDIBits | Copies the color data for a rectangle of pixels in a DIB, JPEG, or PNG image to the specified destination rectangle, stretching or compressing the rows and columns by using the specified raster operation
_WinAPI_TransparentBlt | Performs a bit-block transfer of the color data corresponding to a rectangle of pixels


Function _WinAPI_AddIconOverlay

Function Reference

_WinAPI_AddIconOverlay

Creates an icon by merging the source icon and overlay mask

#include <WinAPIGdi.au3>
_WinAPI_AddIconOverlay ( $hIcon, $hOverlay )

Parameters

$hIcon | Handle to the source icon.
$hOverlay | Handle to the icon to use as an overlay mask.

Return Value

Success: | Handle to the newly created icon.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

The source and overlay icons must be the same size but can have different color depth.
This function internally converts the specified icons to the 32 bits-per-pixel icon.

When you are finished using the icon, destroy it using the _WinAPI_DestroyIcon() function.

Related

_WinAPI_DestroyIcon

Example

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIShellEx.au3>
#include <WinAPISys.au3>

; Create icon with overlay mask (48x48)
Local $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 1, 32, 32)
Local $hOverlay
If _WinAPI_GetVersion() >= '6.0' Then
    $hOverlay = _WinAPI_ShellExtractIcon(@SystemDir & '\imageres.dll', 154, 32, 32)
Else
    $hOverlay = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 29, 32, 32)
EndIf
Local $hResult = _WinAPI_AddIconOverlay($hIcon, $hOverlay)
_WinAPI_DestroyIcon($hIcon)
_WinAPI_DestroyIcon($hOverlay)

; Create GUI
GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 128, 128)
GUICtrlCreateIcon('', 0, 48, 48, 32, 32)
GUICtrlSendMsg(-1, $STM_SETIMAGE, 1, $hResult)
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_AdjustBitmap

Function Reference

_WinAPI_AdjustBitmap

Creates a new device-depended bitmap (DDB) from the source bitmap with new dimensions and color adjustment

#include <WinAPIGdi.au3>
_WinAPI_AdjustBitmap ( $hBitmap, $iWidth, $iHeight [, $iMode = 3 [, $tAdjustment = 0]] )

Parameters

$hBitmap | A handle to the source bitmap.
$iWidth | The width of the new bitmap, in pixels. If this parameter is (-1), the width will be the same as in the source bitmap.
$iHeight | The height of the new bitmap, in pixels. If this parameter is (-1), the height will be the same as in the source bitmap.
$iMode | [optional] The stretching mode. This parameter can be one of the following values: $BLACKONWHITE $COLORONCOLOR (Default) $HALFTONE $WHITEONBLACK $STRETCH_ANDSCANS $STRETCH_DELETESCANS $STRETCH_HALFTONE $STRETCH_ORSCANS
$tAdjustment | [optional] $tagCOLORADJUSTMENT structure containing the color adjustment values. This color adjustment is used only if $HALFTONE ($STRETCH_HALFTONE) stretching mode are set.

Return Value

Success: | A handle to the newly created bitmap (DDB).
Failure: | 0.

Remarks

The _WinAPI_AdjustBitmap() creates a device-depended bitmaps compatible with the application's current screen.

This function does not support bitmaps with alpha channel, you can use the _WinAPI_AlphaBlend() function to work with these bitmaps.

When you are finished using the bitmap, destroy it using the _WinAPI_DeleteObject() function.
The function does not destroy the original bitmap, you must to destroy it yourself.

Related

_WinAPI_AlphaBlend, _WinAPI_DeleteObject

Example

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

; Load and resize (x2) image
Local $hBitmap = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\AutoIt.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Local $tSIZE = _WinAPI_GetBitmapDimension($hBitmap)
Local $W = 2 * DllStructGetData($tSIZE, 'X')
Local $H = 2 * DllStructGetData($tSIZE, 'Y')
Local $hResize = _WinAPI_AdjustBitmap($hBitmap, $W, $H)
_WinAPI_DeleteObject($hBitmap)

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), $W, $H)
Local $idPic = GUICtrlCreatePic('', 0, 0, $W, $H)
Local $hPic = GUICtrlGetHandle($idPic)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hResize)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hResize Then
    _WinAPI_DeleteObject($hResize)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_AlphaBlend

Function Reference

_WinAPI_AlphaBlend

Displays bitmaps that have transparent or semitransparent pixels

#include <WinAPIGdi.au3>
_WinAPI_AlphaBlend ( $hDestDC, $iXDest, $iYDest, $iWidthDest, $iHeightDest, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iAlpha [, $bAlpha = False] )

Parameters

$hDestDC | Handle to the destination device context.
$iXDest | The x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
$iYDest | The y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
$iWidthDest | The width, in logical units, of the destination rectangle.
$iHeightDest | The height, in logical units, of the destination rectangle.
$hSrcDC | Handle to the source device context.
$iXSrc | The x-coordinate, in logical units, of the upper-left corner of the source rectangle.
$iYSrc | The y-coordinate, in logical units, of the upper-left corner of the source rectangle.
$iWidthSrc | The width, in logical units, of the source rectangle.
$iHeightSrc | The height, in logical units, of the source rectangle.
$iAlpha | The alpha transparency value to be used on the entire source bitmap. This value is combined with any per-pixel alpha values in the source bitmap. If you set $iAlpha to 0, it is assumed that your image is transparent. Set $iAlpha value to 255 (opaque) when you only want to use per-pixel alpha values.
$bAlpha | [optional] Specifies whether uses an alpha channel from the source bitmap, valid values: True - Use the alpha channel (that is, per-pixel alpha). Note that the APIs use premultiplied alpha, which means that the red, green and blue channel values in the bitmap must be premultiplied with the alpha channel value. For example, if the alpha channel value is x, the red, green and blue channels must be multiplied by x and divided by 255 prior to the call. False - Do not use the alpha channel (Default).

Return Value

Success: | True.
Failure: | False.

Remarks

If the source rectangle and destination rectangle are not the same size, the source bitmap is stretched to match the destination rectangle.
If the _WinAPI_SetStretchBltMode() function is used, the stretching mode value is automatically converted to $COLORONCOLOR for this function (that is, $BLACKONWHITE, $WHITEONBLACK, and $HALFTONE are changed to $COLORONCOLOR).

If destination and source bitmaps do not have the same color format, _WinAPI_AlphaBlend() function converts the source bitmap to match the destination bitmap.

See Also

Search GdiAlphaBlend in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

Opt('TrayAutoPause', 0)

; Load image
Global $g_hBitmap = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\AutoIt.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Local $tSIZE = _WinAPI_GetBitmapDimension($g_hBitmap)
Local $W = DllStructGetData($tSIZE, 'X')
Local $H = DllStructGetData($tSIZE, 'Y')

; Create GUI
Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), $W, $H + 26)
Global $g_idPic = GUICtrlCreatePic('', 0, 0, $W, $H)
GUICtrlCreateGraphic(0, $H, $W, 1)
GUICtrlSetBkColor(-1, 0xDFDFDF)
Global $g_idSlider = GUICtrlCreateSlider(0, $H + 1, $W, 25, BitOR($TBS_BOTH, $TBS_NOTICKS))
Global $g_hSlider = GUICtrlGetHandle(-1)
GUICtrlSetLimit(-1, 255, 0)
GUICtrlSetData(-1, 255)

; Set bitmap to control with alpha
_SetBitmapAlpha($g_idPic, $g_hBitmap, 255)

; Register WM_HSCROLL message for live scrolling and show GUI
GUIRegisterMsg($WM_HSCROLL, 'WM_HSCROLL')
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _SetBitmapAlpha($hWnd, $hBitmap, $iAlpha)
    If Not IsHWnd($hWnd) Then
        $hWnd = GUICtrlGetHandle($hWnd)
        If Not $hWnd Then
            Return 0
        EndIf
    EndIf

    Local $aW[2], $aH[2]
    Local $tRECT = _WinAPI_GetClientRect($hWnd)
    $aW[0] = DllStructGetData($tRECT, 3) - DllStructGetData($tRECT, 1)
    $aH[0] = DllStructGetData($tRECT, 4) - DllStructGetData($tRECT, 2)
    Local $tSIZE = _WinAPI_GetBitmapDimension($hBitmap)
    $aW[1] = DllStructGetData($tSIZE, 1)
    $aH[1] = DllStructGetData($tSIZE, 2)
    Local $hDC = _WinAPI_GetDC($hWnd)
    Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
    Local $hBmp = _WinAPI_CreateCompatibleBitmapEx($hDC, $aW[0], $aH[0], 0xFFFFFF)
    Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBmp)
    Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC)
    Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBitmap)
    _WinAPI_AlphaBlend($hDestDC, 0, 0, $aW[0], $aH[0], $hSrcDC, 0, 0, $aW[1], $aH[1], $iAlpha, 0)
    _WinAPI_SelectObject($hDestDC, $hDestSv)
    _WinAPI_DeleteDC($hDestDC)
    _WinAPI_SelectObject($hSrcDC, $hSrcSv)
    _WinAPI_DeleteDC($hSrcDC)
    _WinAPI_ReleaseDC($hWnd, $hDC)
    Local $hObj = _SendMessage($hWnd, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp)
    If $hObj Then
        _WinAPI_DeleteObject($hObj)
    EndIf
    $hObj = _SendMessage($hWnd, $STM_GETIMAGE)
    If $hObj <> $hBmp Then
        _WinAPI_DeleteObject($hBmp)
    EndIf
    Return 1
EndFunc   ;==>_SetBitmapAlpha

Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg,$wParam

    Switch $hWnd
        Case $g_hForm
            Switch $lParam
                Case $g_hSlider
                    _SetBitmapAlpha($g_idPic, $g_hBitmap, GUICtrlRead($g_idSlider))
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_HSCROLL


Function _WinAPI_CompressBitmapBits

Function Reference

_WinAPI_CompressBitmapBits

Creates a compressed data block from the specified bitmap

#include <WinAPIGdi.au3>
_WinAPI_CompressBitmapBits ( $hBitmap, ByRef $pBuffer [, $iCompression = 0 [, $iQuality = 100]] )

Parameters

$hBitmap | A handle to the bitmap to be compressed.
$pBuffer | A pointer to a memory block (buffer) that receives the compressed data. Optionaly, you can set this parameter to 0 before function call, then the function will allocate the required memory block itself. Otherwise, it must be a valid memory pointer returned by the _WinAPI_CreateBuffer() function, or by previously calling this function.
$iCompression | [optional] The compression method. This parameter can be one of the following values. $COMPRESSION_BITMAP_PNG (Default) $COMPRESSION_BITMAP_JPEG
$iQuality | [optional] The quality of JPEG image, in percent. This value is ignored for non JPEG compression. Default is 100.

Return Value

Success: | The number of bytes copied to the buffer.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

In fact, the data that returns this function represent .jpeg or .png image file in binary form. You can use the _WinAPI_WriteFile() function to create the appropriate image file directly from this data.

The returned data always represent a 24-bit color depth .jpeg image, or 32-bit color depth (with or without alpha chanel) .png image independent on the color depth of the source bitmap.

When you no longer need the buffer allocated by this function, you must call the _WinAPI_FreeMemory() function (do not use any other memory routines) to release occupied memory.

This function internally uses the GDI+ DLL library.

Related

_WinAPI_FreeMemory, _WinAPI_WriteFile

Example

#include <APIGdiConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPISys.au3>

; Load image
Local $hSource = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\AutoIt.bmp', $IMAGE_BITMAP, 0, 0, BitOR($LR_LOADFROMFILE, $LR_CREATEDIBSECTION))

; Resize bitmap to 256x256 pixels
Local $hBitmap = _WinAPI_AdjustBitmap($hSource, 256, 256, $HALFTONE)

; Create compressed PNG data
Local $pData = 0
Local $iLength = _WinAPI_CompressBitmapBits($hBitmap, $pData, 2)

; Create .ico file
If Not @error Then
    Local $tICO = DllStructCreate('align 1;ushort Reserved;ushort Type;ushort Count;byte Header[20]')
    Local $tHDR = DllStructCreate('byte Width;byte Height;byte ColorCount;byte Reserved;ushort Planes;ushort BitCount;long Size;long Offset', DllStructGetPtr($tICO, 'Header'))
    DllStructSetData($tICO, 'Reserved', 0)
    DllStructSetData($tICO, 'Type', 1)
    DllStructSetData($tICO, 'Count', 1)
    DllStructSetData($tHDR, 'Width', 0)
    DllStructSetData($tHDR, 'Height', 0)
    DllStructSetData($tHDR, 'ColorCount', 0)
    DllStructSetData($tHDR, 'Reserved', 0)
    DllStructSetData($tHDR, 'Planes', 1)
    DllStructSetData($tHDR, 'BitCount', 32)
    DllStructSetData($tHDR, 'Size', $iLength)
    DllStructSetData($tHDR, 'Offset', DllStructGetSize($tICO))
    Local $hFile = _WinAPI_CreateFile(@TempDir & '\MyIcon.ico', 1, 4)
    Local $iBytes
    _WinAPI_WriteFile($hFile, $tICO, DllStructGetSize($tICO), $iBytes)
    _WinAPI_WriteFile($hFile, $pData, $iLength, $iBytes)
    _WinAPI_CloseHandle($hFile)
    ShellExecute("MsPaint", '"' & @TempDir & '\MyIcon.ico' & '"')
Else
    MsgBox($MB_SYSTEMMODAL, "Error", "_WinAPI_CompressBitmapBits() failed (@error = " & @error & ")")
EndIf

; Delete unnecessary bitmaps
_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteObject($hBitmap)

; Free memory
_WinAPI_FreeMemory($pData)


Function _WinAPI_CopyBitmap

Function Reference

_WinAPI_CopyBitmap

Creates a duplicate of a specified bitmap with a device-independent bitmap (DIB) section

#include <WinAPIGdi.au3>
_WinAPI_CopyBitmap ( $hBitmap )

Parameters

$hBitmap Handle to the bitmap to be duplicated.

Return Value

Success: | Handle to the new bitmap that was created.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

When you are finished using the bitmap, destroy it using the _WinAPI_DeleteObject() function.

Related

_WinAPI_DeleteObject

See Also

Search CopyImage in MSDN Library.


Function _WinAPI_CopyImage

Function Reference

_WinAPI_CopyImage

Creates a new image (icon, cursor, or bitmap) and copies the attributes of the specified image to the new one

#include <WinAPIGdi.au3>
_WinAPI_CopyImage ( $hImage [, $iType = 0 [, $iXDesiredPixels = 0 [, $iYDesiredPixels = 0 [, $iFlags = 0]]]] )

Parameters

$hImage | Handle to the image to be copied.
$iType | [optional] Specifies the type of image to be copied. This parameter can be one of the following values: $IMAGE_BITMAP 'Default) $IMAGE_CURSOR $IMAGE_ICON
$iXDesiredPixels | [optional] Specifies the desired width, in pixels, of the image. If this is zero (Default), then the returned image will have the same width as the original $hImage.
$iYDesiredPixels | [optional] Specifies the desired height, in pixels, of the image. If this is zero (Default), then the returned image will have the same height as the original $hImage.
$iFlags | [optional] This parameter can be one or more of the following values. $LR_DEFAULTCOLOR (Default) $LR_COPYDELETEORG $LR_COPYFROMRESOURCE $LR_COPYRETURNORG $LR_CREATEDIBSECTION $LR_DEFAULTSIZE $LR_MONOCHROME

Return Value

Success: | Handle to the newly created image.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

When you are finished using the resource, you can release its associated memory by calling _WinAPI_DeleteObject() function respectively for bitmaps, cursors, or icons.
The system automatically deletes the resource when its process terminates, however, calling the appropriate function saves memory and decreases the size of the process's working set.

See Also

Search CopyImage in MSDN Library.


Function _WinAPI_Create32BitHBITMAP

Function Reference

_WinAPI_Create32BitHBITMAP

Creates a 32 bits-per-pixel bitmap from the specified icon

#include <WinAPIGdi.au3>
_WinAPI_Create32BitHBITMAP ( $hIcon [, $bDib = False [, $bDelete = False]] )

Parameters

$hIcon | Handle to the source icon.
$bDib | [optional] Specifies whether to create device-independent (DIB) or device-dependent (DDB) bitmap, valid values: True - Creates DIB. False - Creates DDB (Default).
$bDelete | [optional] Specifies whether to delete the icon after the function is successful, valid values: True - Icon will be deleted if the function succeeds. False - Do not delete, you must release the icon when you are finished using it (Default).

Return Value

Success: | Handle to the created bitmap.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

The _WinAPI_Create32BitHBITMAP() creates a 32 bits-per-pixel bitmap with alpha chanel (if possible) from the icons with any color depth.
The function internally converts the specified icon to the 32 bits-per-pixel icon.

When you are finished using the bitmap, destroy it using the _WinAPI_DeleteObject() function.

Related

_WinAPI_DeleteObject

Example

#NoTrayIcon

#include <GUIMenu.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIShellEx.au3>
#include <WinAPISys.au3>

Opt('TrayMenuMode', 3)

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

Local $hMenu = TrayItemGetHandle(0)
Local $iOptions = TrayCreateItem('Options')
TrayCreateItem('')
Local $idExit = TrayCreateItem('Exit')

_GUICtrlMenu_SetItemBmp($hMenu, 0, _WinAPI_Create32BitHBITMAP(_WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 207, 16, 16), 1, 1))
_GUICtrlMenu_SetItemBmp($hMenu, 2, _WinAPI_Create32BitHBITMAP(_WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 131, 16, 16), 1, 1))

TraySetState()

Do
Until TrayGetMsg() = $idExit


Function _WinAPI_Create32BitHICON

Function Reference

_WinAPI_Create32BitHICON

Converts an icon to a 32 bits-per-pixel format and copies to the new icon

#include <WinAPIGdi.au3>
_WinAPI_Create32BitHICON ( $hIcon [, $bDelete = False] )

Parameters

$hIcon | Handle to the icon to be converted.
$bDelete | [optional] Specifies whether to delete the icon after the function is successful, valid values: True - Icon will be deleted if the function succeeds. False - Do not delete, you must release the icon themselves when you are finished using it (Default).

Return Value

Success: | Handle to the newly created icon.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

This function converts an icon with any color depth into an icon with 32 bits-per-pixel (RGB + Alpha) format.
If the source icon already is a 32 bits-per-pixel icon, and has an alpha chanel, the function generates the new AND bitmask bitmap, and copies it to a new icon.
If the source icon has a 32 bits-per-pixel color depth, and do not have an alpha chanel, the function creates an alpha chanel from its AND bitmask.
If the source icon is non 32 bits-per-pixel icon, it will be converted into a 32 bits-per-pixel format with alpha chanel.
The _WinAPI_Create32BitHICON() always creates an icon with alpha channel and AND bitmask, although it is not used to display icons that contain an alpha channel.

Note that to display the fully transparent icons used only its AND bitmask, not the alpha channel.
Therefore, its XOR and AND bitmasks will remain unchanged.

When you are finished using the icon, destroy it using the _WinAPI_DestroyIcon() function.

Related

_WinAPI_DestroyIcon


Function _WinAPI_CreateANDBitmap

Function Reference

_WinAPI_CreateANDBitmap

Creates AND bitmask device-independent bitmap (DIB) from the specified bitmap

#include <WinAPIGdi.au3>
_WinAPI_CreateANDBitmap ( $hBitmap )

Parameters

$hBitmap Handle to the bitmap from which to create AND bitmask DIB.

Return Value

Success: | Handle to the DIB.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

The _WinAPI_CreateANDBitmap() creates a 1 bits-per-pixel AND bitmask DIB from the 32 bits-per-pixel DIB or DDB.
If the source bitmap is non 32 bits-per-pixel bitmap, or is a compressed bitmap, the function fails.

You can use the bitmap returned by this function to create icon by using the _WinAPI_CreateIconIndirect().

When you are finished using the bitmap, destroy it using the _WinAPI_DeleteObject() function.

Related

_WinAPI_CreateIconIndirect, _WinAPI_DeleteObject

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIShPath.au3>

Local Const $sPng = @ScriptDir & '\Extras\Silverlight.png'

Local $a_hBitmap[2]
; Create 32 bits-per-pixel bitmap from a PNG image
Global $g_hDll = _GDIPlus_Startup(Default, True)
Local $hPng = _GDIPlus_ImageLoadFromFile($sPng)
$a_hBitmap[0] = _GDIPlus_BitmapCreateDIBFromBitmap($hPng)
Local $iWidth = _GDIPlus_ImageGetWidth($hPng)
Local $iHeight = _GDIPlus_ImageGetHeight($hPng)
_GDIPlus_ImageDispose($hPng)
_GDIPlus_Shutdown()

; Create 1 bits-per-pixel AND bitmask bitmap
$a_hBitmap[1] = _WinAPI_CreateANDBitmap($a_hBitmap[0])

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), $iWidth * 2, $iHeight)
Local $aidPic[2]
$aidPic[0] = GUICtrlCreatePic('', 0, 0, $iWidth, $iHeight)
$aidPic[1] = GUICtrlCreatePic('', $iWidth, 0, $iWidth, $iHeight)

; Set both bitmaps to controls
For $i = 0 To 1
    GUICtrlSendMsg($aidPic[$i], $STM_SETIMAGE, 0, $a_hBitmap[$i])
Next

; Show GUI
GUISetState(@SW_SHOW)

; Create and save icon to .ico file
Local $hIcon
Local $sPath = FileSaveDialog('Save Icon', @ScriptDir, 'Icon Files (*.ico)', 2 + 16, _WinAPI_PathStripPath(_WinAPI_PathRenameExtension($sPng, '.ico')), $hForm)
If $sPath Then
    $hIcon = _WinAPI_CreateIconIndirect($a_hBitmap[0], $a_hBitmap[1])
    If $hIcon Then
        _WinAPI_SaveHICONToFile($sPath, $hIcon)
        _WinAPI_DestroyIcon($hIcon)
    EndIf
EndIf

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

; Unlike _GDIPlus_BitmapCreateHBITMAPFromBitmap() that creates a device-dependent bitmap (DDB), this function creates a device-independent bitmap (DIB) which may be used for semi-transparent images

Func _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap)
    Local $aSize = DllCall($g_hDll, 'uint', 'GdipGetImageDimension', 'ptr', $hBitmap, 'float*', 0, 'float*', 0)
    If @error Or $aSize[0] Then Return 0

    Local $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $aSize[2], $aSize[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB)
    Local $pBits = DllStructGetData($tData, 'Scan0')
    If Not $pBits Then Return 0

    Local $hDIB = _WinAPI_CreateDIB($aSize[2], $aSize[3])
    If Not @error Then
        _WinAPI_SetBitmapBits($hDIB, $aSize[2] * $aSize[3] * 4, $pBits)
    EndIf
    _GDIPlus_BitmapUnlockBits($a_hBitmap, $tData)
    Return $hDIB
EndFunc   ;==>_GDIPlus_BitmapCreateDIBFromBitmap


Function _WinAPI_CreateBitmapIndirect

Function Reference

_WinAPI_CreateBitmapIndirect

Creates a bitmap with the specified width, height, and color format (color planes and bits-per-pixel)

#include <WinAPIGdi.au3>
_WinAPI_CreateBitmapIndirect ( $tBITMAP )

Parameters

$tBITMAP $tagBITMAP structure that contains information about the bitmap.
If an application sets the "bmWidth" or "bmHeight" members to zero, _WinAPI_CreateBitmapIndirect() returns the handle to a 1-by-1 pixel, monochrome bitmap.

Return Value

Success: | Handle to the device-dependent (DDB) bitmap.
Failure: | 0.

Remarks

When you no longer need the bitmap, call the _WinAPI_DeleteObject() function to delete it.

Related

_WinAPI_DeleteObject

See Also

Search CreateBitmapIndirect in MSDN Library.


Function _WinAPI_CreateCompatibleBitmapEx

Function Reference

_WinAPI_CreateCompatibleBitmapEx

Creates a bitmap compatible with the device and fills it the specified color

#include <WinAPIGdi.au3>
_WinAPI_CreateCompatibleBitmapEx ( $hDC, $iWidth, $iHeight, $iRGB )

Parameters

$hDC | Handle to a device context.
$iWidth | The bitmap width, in pixels.
$iHeight | The bitmap height, in pixels.
$iRGB | The bitmap color, in RGB.

Return Value

Success: | Handle to the compatible solid bitmap (DDB).
Failure: | 0 and sets the @error flag to non-zero.

Remarks

The color format of the bitmap created by the _WinAPI_CreateCompatibleBitmapEx() function matches the color format of the device identified by the $hDC parameter.
This bitmap can be selected into any memory device context that is compatible with the original device.

When you no longer need the bitmap, call the _WinAPI_DeleteObject() function to delete it.

Related

_WinAPI_DeleteObject


Function _WinAPI_CreateDIB

Function Reference

_WinAPI_CreateDIB

Creates an uncompressed device-independent bitmap (DIB) with the specified width, height, and color depth

#include <WinAPIGdi.au3>
_WinAPI_CreateDIB ( $iWidth, $iHeight [, $iBitsPerPel = 32 [, $tColorTable = 0 [, $iColorCount = 0]]] )

Parameters

$iWidth | The width of the bitmap, in pixels.
$iHeight | The height of the bitmap, in pixels. If this value is positive, the bitmap is a bottom-up DIB and its origin is the lower-left corner, otherwise, the bitmap is a top-down DIB and its origin is the upper-left corner.
$iBitsPerPel | [optional] The number of bits that define each pixel and the maximum number of colors in the bitmap. Default is 32.
$tColorTable | [optional] "dword[n]" structure that represents a DIB color table. The number of colors in this table depends on the values of the $iBitsPerPel parameters.
$iColorCount | [optional] The number of color indexes in the DIB color table that are actually used by the bitmap. The value of this parameter should not exceed the number of colors in the color table pointed to by the $pColorTable parameter. Default is 0.

Return Value

Success: | Handle to the DIB.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

If the bitmap is monochrome (1 bits-per-pixel), the color table should contain two entries.
If the color table is not specified, the function creates a monochrome bitmap with black and white colors. If the bitmap use 4 or 8 bits-per-pixel, the color table should contain up to 16 or 256 entries respectively.
In this case, if the color table is not specified, the function creates an empty color table (all colors is black) with the maximum possible number of entries for the specified color depth.
You can fill out this color table later by using the _WinAPI_SetDIBColorTable() function.
If the bitmap use 16, 24, or 32 bits-per-pixel, the color table is not used, and $tColorTable parameter is ignored.

This function does not create a compressed 16, 24, or 32 bits-per-pixel bitmaps, that is the "biCompression" member of $tagBITMAPINFO structure is always 0 ($BI_RGB).

When you are finished using the bitmap, destroy it using the _WinAPI_DeleteObject() function.

Call _WinAPI_GetExtended() to retrieve a pointer to the location of the DIB bit values.

Related

_WinAPI_DeleteObject, _WinAPI_GetExtended

Example

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIMisc.au3>
#include <WinAPISys.au3>

; Create array of colors of 256 entries required for 8 bits-per-pixel bitmap
Local $aColorTable[256]
For $i = 0 To 255
    $aColorTable[$i] = _WinAPI_RGB(0, $i, 255 - $i)
Next

; Create color table from an array of colors
Local $tColorTable = _WinAPI_CreateDIBColorTable($aColorTable)

; Create 8 bits-per-pixel device-independent bitmap (DIB) and retrieve a pointer to the location of its bit values
Local $hBitmap = _WinAPI_CreateDIB(256, 256, 8, $tColorTable, 256)
Local $pBits = _WinAPI_GetExtended()

; Fill bitmap color indexes
For $i = 0 To 255
    _WinAPI_FillMemory($pBits + 256 * $i, 256, $i)
Next

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 256, 256)
Local $idPic = GUICtrlCreatePic('', 0, 0, 256, 256)
Local $hPic = GUICtrlGetHandle($idPic)

; Create DDB from DIB to correct display in control
Local $hDC = _WinAPI_GetDC($hPic)
Local $hDev = _WinAPI_CreateCompatibleBitmap($hDC, 256, 256)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hDev)
_WinAPI_DrawBitmap($hMemDC, 0, 0, $hBitmap)
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hDev)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hDev Then
    _WinAPI_DeleteObject($hDev)
EndIf

; Show GUI
GUISetState(@SW_SHOW)

; Save 8 bits-per-pixel bitmap to .bmp file
Local $sPath = FileSaveDialog('Save Image', @TempDir, 'Bitmap Image Files (*.bmp)', 2 + 16, 'MyImage.bmp', $hForm)
If $sPath Then
    _WinAPI_SaveHBITMAPToFile($sPath, $hBitmap, 2834, 2834)
EndIf

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_CreateDIBColorTable

Function Reference

_WinAPI_CreateDIBColorTable

Creates RGB color table from the specified array of colors

#include <WinAPIGdi.au3>
_WinAPI_CreateDIBColorTable ( Const ByRef $aColorTable [, $iStart = 0 [, $iEnd = -1]] )

Parameters

$aColorTable | The array of colors, in RGB, that to be make up the DIB color table.
$iStart | [optional] The index of array to start creating at.
$iEnd | [optional] The index of array to stop creating at.

Return Value

Success: | "dword[n]" structure that represents a DIB color table.
Failure: | Sets the @error flag to non-zero.

Remarks

The color table created by this function is typically used in _WinAPI_CreateDIB() or _WinAPI_CreateDIBSection() function to create 1, 4, or 8 bits-per-pixel device-independent bitmap (DIB).

Related

_WinAPI_CreateDIB, _WinAPI_CreateDIBSection

Example

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIMisc.au3>
#include <WinAPISys.au3>

; Create array of colors of 256 entries required for 8 bits-per-pixel bitmap
Local $aColorTable[256]
For $i = 0 To 255
    $aColorTable[$i] = _WinAPI_RGB(0, $i, 255 - $i)
Next

; Create color table from an array of colors
Local $tColorTable = _WinAPI_CreateDIBColorTable($aColorTable)

; Create 8 bits-per-pixel device-independent bitmap (DIB) and retrieve a pointer to the location of its bit values
Local $hBitmap = _WinAPI_CreateDIB(256, 256, 8, $tColorTable, 256)
Local $pBits = _WinAPI_GetExtended()

; Fill bitmap color indexes
For $i = 0 To 255
    _WinAPI_FillMemory($pBits + 256 * $i, 256, $i)
Next

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 256, 256)
Local $idPic = GUICtrlCreatePic('', 0, 0, 256, 256)
Local $hPic = GUICtrlGetHandle($idPic)

; Create DDB from DIB to correct display in control
Local $hDC = _WinAPI_GetDC($hPic)
Local $hDev = _WinAPI_CreateCompatibleBitmap($hDC, 256, 256)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hDev)
_WinAPI_DrawBitmap($hMemDC, 0, 0, $hBitmap)
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hDev)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hDev Then
    _WinAPI_DeleteObject($hDev)
EndIf

; Show GUI
GUISetState(@SW_SHOW)

; Save 8 bits-per-pixel bitmap to .bmp file
Local $sPath = FileSaveDialog('Save Image', @TempDir, 'Bitmap Image Files (*.bmp)', 2 + 16, 'MyImage.bmp', $hForm)
If $sPath Then
    _WinAPI_SaveHBITMAPToFile($sPath, $hBitmap, 2834, 2834)
EndIf

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_CreateDIBitmap

Function Reference

_WinAPI_CreateDIBitmap

Creates a compatible bitmap (DDB) from a DIB and, optionally, sets the bitmap bits

#include <WinAPIGdi.au3>
_WinAPI_CreateDIBitmap ( $hDC, $tBITMAPINFO, $iUsage [, $pBits = 0] )

Parameters

$hDC | Handle to a device context.
$tBITMAPINFO | $tagBITMAPINFO structure that specifies various attributes of the DIB, including the bitmap dimensions and colors. Note that a positive value for the height indicates a bottom-up DIB while a negative value for the height indicates a top-down DIB.
$iUsage | The type of colors used. This parameter must be one of the following values: $DIB_PAL_COLORS $DIB_RGB_COLORS
$pBits | [optional] A pointer to an array of bytes containing the initial bitmap data.

Return Value

Success: | the handle to the compatible bitmap that will be whatever bit depth a reference DC is.
Failure: | 0.

Remarks

When you no longer need the bitmap, call the _WinAPI_DeleteObject() function to delete it.

Related

_WinAPI_DeleteObject

See Also

Search CreateDIBitmap in MSDN Library.


Function _WinAPI_CreateDIBSection

Function Reference

_WinAPI_CreateDIBSection

Creates a DIB that applications can write to directly

#include <WinAPIGdi.au3>
_WinAPI_CreateDIBSection ( $hDC, $tBITMAPINFO, $iUsage, ByRef $pBits [, $hSection = 0 [, $iOffset = 0]] )

Parameters

$hDC | Handle to a device context. If the value of $iUsage is $DIB_PAL_COLORS, the function uses this device context's logical palette to initialize the DIB colors.
$tBITMAPINFO | $tagBITMAPINFO structure that specifies various attributes of the DIB, including the bitmap dimensions and colors.
$iUsage | The type of colors used (either logical palette indexes or literal RGB values). The following values are defined: $DIB_PAL_COLORS $DIB_RGB_COLORS
$pBits | Returns a pointer to the location of the DIB bit values.
$hSection | [optional] Handle to a file-mapping object that the function will use to create the DIB.
$iOffset | [optional] The offset from the beginning of the file-mapping object referenced by $hSection where storage for the bitmap bit values is to begin. This value is ignored if $hSection is 0 (Default).

Return Value

Success: | Handle to the newly created DIB, and $pBits points to the bitmap bit values. You can create the structure by using $pBits pointer to further its filling. For example, DllStructCreate('dword[256]', $pBits).
Failure: | 0, $pBits is set to 0.

Remarks

When you no longer need the bitmap, call the _WinAPI_DeleteObject() function to delete it.

Related

_WinAPI_DeleteObject

See Also

Search CreateDIBSection in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>

; Create 32 bits-per-pixel device-independent bitmap (DIB) that use a mask
Local $tBIV5HDR = DllStructCreate($tagBITMAPV5HEADER)

DllStructSetData($tBIV5HDR, 'bV5Size', DllStructGetSize($tBIV5HDR))
DllStructSetData($tBIV5HDR, 'bV5Width', 256)
DllStructSetData($tBIV5HDR, 'bV5Height', 256)
DllStructSetData($tBIV5HDR, 'bV5Planes', 1)
DllStructSetData($tBIV5HDR, 'bV5BitCount', 32)
DllStructSetData($tBIV5HDR, 'biCompression', $BI_BITFIELDS)
DllStructSetData($tBIV5HDR, 'bV5SizeImage', 0)
DllStructSetData($tBIV5HDR, 'bV5XPelsPerMeter', 0)
DllStructSetData($tBIV5HDR, 'bV5YPelsPerMeter', 0)
DllStructSetData($tBIV5HDR, 'bV5ClrUsed', 0)
DllStructSetData($tBIV5HDR, 'bV5ClrImportant', 0)
DllStructSetData($tBIV5HDR, 'bV5RedMask', 0x00FF0000)
DllStructSetData($tBIV5HDR, 'bV5GreenMask', 0x0000FF00)
DllStructSetData($tBIV5HDR, 'bV5BlueMask', 0x000000FF)
DllStructSetData($tBIV5HDR, 'bV5AlphaMask', 0xFF000000)
DllStructSetData($tBIV5HDR, 'bV5CSType', 0)
DllStructSetData($tBIV5HDR, 'bV5Endpoints', 0, 1)
DllStructSetData($tBIV5HDR, 'bV5Endpoints', 0, 2)
DllStructSetData($tBIV5HDR, 'bV5Endpoints', 0, 3)
DllStructSetData($tBIV5HDR, 'bV5GammaRed', 0)
DllStructSetData($tBIV5HDR, 'bV5GammaGreen', 0)
DllStructSetData($tBIV5HDR, 'bV5GammaBlue', 0)
DllStructSetData($tBIV5HDR, 'bV5Intent', 0)
DllStructSetData($tBIV5HDR, 'bV5ProfileData', 0)
DllStructSetData($tBIV5HDR, 'bV5ProfileSize', 0)
DllStructSetData($tBIV5HDR, 'bV5Reserved', 0)

Local $pBits
Local $hBitmap = _WinAPI_CreateDIBSection(0, $tBIV5HDR, $DIB_RGB_COLORS, $pBits)

; Fill bitmap green with variable alpha channel
Local $tBits = DllStructCreate('dword[65536]', $pBits)
For $y = 0 To 255
    For $x = 1 To 256
        DllStructSetData($tBits, 1, BitOR(0x00FF00, BitShift($y, -24)), $x + (256 * $y))
    Next
Next

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 256, 256)
Local $idPic = GUICtrlCreatePic('', 0, 0, 256, 256)
Local $hPic = GUICtrlGetHandle($idPic)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

; Set background color to green and show GUI
GUISetBkColor(0x0000FF)
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_CreateEmptyIcon

Function Reference

_WinAPI_CreateEmptyIcon

Creates a fully transparent icon with the specified width, height, and color depth

#include <WinAPIGdi.au3>
_WinAPI_CreateEmptyIcon ( $iWidth, $iHeight [, $iBitsPerPel = 32] )

Parameters

$iWidth | The width, in pixels, of the icon.
$iHeight | The height, in pixels, of the icon.
$iBitsPerPel | [optional] The number of bits-per-pixel in the XOR bitmask of the icon. Default is 32.

Return Value

Success: | Handle to the created icon.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

This function creates an icon with black XOR, and white AND bitmask bitmaps.
This icon has no alpha channel, it will be displayed only by using its AND bitmask.

When you are finished using the icon, destroy it using the _WinAPI_DestroyIcon() function.

Related

_WinAPI_DestroyIcon


Function _WinAPI_CreateIconIndirect

Function Reference

_WinAPI_CreateIconIndirect

Creates an icon or cursor that has the specified size, colors, and bit patterns

#include <WinAPIGdi.au3>
_WinAPI_CreateIconIndirect ( $hBitmap, $hMask [, $iXHotspot = 0 [, $iYHotspot = 0 [, $bIcon = True]]] )

Parameters

$hBitmap | Handle to the icon color bitmap.
$hMask | Handle to the icon bitmask bitmap.
$iXHotspot | [optional] Specifies the x-coordinate of a cursor's hot spot. If creates an icon, the hot spot is always in the center of the icon, and this parameter is ignored. Default is 0.
$iYHotspot | [optional] Specifies the y-coordinate of a cursor's hot spot. If creates an icon, the hot spot is always in the center of the icon, and this parameter is ignored. Default is 0.
$bIcon | [optional] Specifies whether creates an icon or a cursor, valid values: True - Creates an icon (Default). False - Creates a cursor.

Return Value

Success: | Handle to the icon or cursor that is created.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

The system copies the bitmaps before creating the icon or cursor.
Because the system may temporarily select this bitmaps in a device context,
$hBitmap and $hMask should not already be selected into a device context.
The application must continue to manage the original bitmaps and delete them by using _WinAPI_DeleteObject() when they are no longer necessary.

Related

_WinAPI_DeleteObject

See Also

Search CreateIconIndirect in MSDN Library.

Example

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

; Create XOR bitmap
Local $hDC = _WinAPI_GetDC(0)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hXOR = _WinAPI_CreateCompatibleBitmapEx($hDC, 32, 32, 0)
Local $hSv = _WinAPI_SelectObject($hMemDC, $hXOR)
_WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_BRUSH))
_WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($NULL_PEN))
Local $tRECT = _WinAPI_CreateRectEx(0, 1, 22, 22)
_WinAPI_SetDCBrushColor($hMemDC, 0x0000FF)
_WinAPI_Ellipse($hMemDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 11, 0)
_WinAPI_SetDCBrushColor($hMemDC, 0x00FF00)
_WinAPI_Ellipse($hMemDC, $tRECT)
_WinAPI_OffsetRect($tRECT, -6, 9)
_WinAPI_SetDCBrushColor($hMemDC, 0xFF0000)
_WinAPI_Ellipse($hMemDC, $tRECT)
_WinAPI_ReleaseDC(0, $hDC)
_WinAPI_SelectObject($hMemDC, $hSv)
_WinAPI_DeleteDC($hMemDC)

; Create AND bitmap
$hDC = _WinAPI_GetDC(0)
$hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hAND = _WinAPI_CreateBitmap(32, 32, 1, 1)
$hSv = _WinAPI_SelectObject($hMemDC, $hAND)
_WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_BRUSH))
_WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($NULL_PEN))
_WinAPI_SetDCBrushColor($hMemDC, 0xFFFFFF)
$tRECT = _WinAPI_CreateRectEx(0, 0, 33, 33)
_WinAPI_Rectangle($hMemDC, $tRECT)
_WinAPI_SetDCBrushColor($hMemDC, 0)
$tRECT = _WinAPI_CreateRectEx(0, 1, 22, 22)
_WinAPI_Ellipse($hMemDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 11, 0)
_WinAPI_Ellipse($hMemDC, $tRECT)
_WinAPI_OffsetRect($tRECT, -6, 9)
_WinAPI_Ellipse($hMemDC, $tRECT)
_WinAPI_ReleaseDC(0, $hDC)
_WinAPI_SelectObject($hMemDC, $hSv)
_WinAPI_DeleteDC($hMemDC)

; Create icon
Local $hIcon = _WinAPI_CreateIconIndirect($hXOR, $hAND)

; Free bitmaps
_WinAPI_DeleteObject($hXOR)
_WinAPI_DeleteObject($hAND)

; Create GUI
GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 128, 128)
GUICtrlCreateIcon('', 0, 48, 48, 32, 32)
GUICtrlSendMsg(-1, $STM_SETIMAGE, 1, $hIcon)
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_DrawBitmap

Function Reference

_WinAPI_DrawBitmap

Draws a bitmap into the specified device context

#include <WinAPIGdi.au3>
_WinAPI_DrawBitmap ( $hDC, $iX, $iY, $hBitmap [, $iRop = 0x00CC0020] )

Parameters

$hDC | Handle to the device context into which the bitmap will be drawn.
$iX | Specifies the logical x-coordinate of the upper-left corner of the bitmap.
$iY | Specifies the logical y-coordinate of the upper-left corner of the bitmap.
$hBitmap | Handle to the bitmap to be drawn.
$iRop | [optional] The raster-operation code (same as for _WinAPI_BitBlt()). Default is $SRCCOPY.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

This function does not support bitmaps with alpha channel, use _WinAPI_AlphaBlend() to work with them.

Related

_WinAPI_AlphaBlend, _WinAPI_BitBlt

Example

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Load image
Local $hSource = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Hatch.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Local $tSIZE = _WinAPI_GetBitmapDimension($hSource)
Local $W = DllStructGetData($tSIZE, 'X')
Local $H = DllStructGetData($tSIZE, 'Y')

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
Local $idPic = GUICtrlCreatePic('', 0, 0, @DesktopWidth, @DesktopHeight)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDC = _WinAPI_GetDC($hPic)
Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, @DesktopWidth, @DesktopHeight)
Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap)
For $i = 0 To Ceiling(@DesktopWidth / $W) - 1
    For $j = 0 To Ceiling(@DesktopHeight / $W) - 1
        _WinAPI_DrawBitmap($hDestDC, $i * $W, $j * $H, $hSource)
    Next
Next

_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hDestDC, $hDestSv)
_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteDC($hDestDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_ExtFloodFill

Function Reference

_WinAPI_ExtFloodFill

Fills an area of the display surface with the current brush

#include <WinAPIGdi.au3>
_WinAPI_ExtFloodFill ( $hDC, $iX, $iY, $iRGB [, $iType = 0] )

Parameters

$hDC | Handle to the device context.
$iX | The x-coordinate, in logical units, of the point where filling is to start.
$iY | The y-coordinate, in logical units, of the point where filling is to start.
$iRGB | The color of the boundary or of the area to be filled, in RGB. The interpretation of color depends on the value of the $iType parameter.
$iType | [optional] The type of fill operation to be performed. This parameter must be one of the following values: $FLOODFILLBORDER (Default) $FLOODFILLSURFACE

Return Value

Success: | True
Failure: | False

See Also

Search ExtFloodFill in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <FontConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idPic = GUICtrlCreatePic('', 0, 0, 400, 400)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDev = _WinAPI_GetDC($hPic)
Local $hDC = _WinAPI_CreateCompatibleDC($hDev)
Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, 400, 400, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hSv = _WinAPI_SelectObject($hDC, $hSource)

; Draw objects
Local $hOldBrush = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hOldPen = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetDCBrushColor($hDC, 0x990404)
_WinAPI_SetDCPenColor($hDC, 0x990404)
Local $tRECT = _WinAPI_CreateRect(0, 0, 100, 100)
_WinAPI_OffsetRect($tRECT, 30, 30)
_WinAPI_Rectangle($hDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 20, 20)
_WinAPI_InvertRect($hDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 20, 20)
_WinAPI_InvertRect($hDC, $tRECT)
_WinAPI_SetDCPenColor($hDC, 0x00A820)
_WinAPI_SetBkColor($hDC, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hBrush = _WinAPI_CreateBrushIndirect($BS_HATCHED, 0x00A820, $HS_DIAGCROSS)
Local $hObj = _WinAPI_SelectObject($hDC, $hBrush)
$tRECT = _WinAPI_CreateRect(0, 0, 140, 140)
_WinAPI_OffsetRect($tRECT, 220, 118)
_WinAPI_Ellipse($hDC, $tRECT)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hBrush)
_WinAPI_SetTextColor($hDC, 0xCD0091)
_WinAPI_SetBkMode($hDC, $TRANSPARENT)
Local $hFont = _WinAPI_CreateFont(38, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, 'Arial Black')
$hObj = _WinAPI_SelectObject($hDC, $hFont)
_WinAPI_TextOut($hDC, 30, 185, 'Simple Text')
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hFont)
Local $aPoint2[6][2] = [[0, 129], [55, 75], [75, 0], [95, 75], [150, 129], [75, 108]]
Local $hRgn = _WinAPI_CreatePolygonRgn($aPoint2)
_WinAPI_SetDCBrushColor($hDC, 0x0060C4)
_WinAPI_OffsetRgn($hRgn, 25, 240)
_WinAPI_PaintRgn($hDC, $hRgn)
_WinAPI_DeleteObject($hRgn)
Local $aPoint1[19][2] = [[50, 20], [70, 0], [70, 0], [90, 20], [100, 30], [110, 40], [120, 50], [130, 60], [130, 70], [120, 70], [110, 70], [30, 70], [20, 70], [10, 70], [10, 60], [20, 50], [30, 40], [40, 30], [50, 20]]
_WinAPI_SetDCPenColor($hDC, 0xFF8000)
_WinAPI_OffsetPoints($aPoint1, 219, 25)
_WinAPI_PolyBezier($hDC, $aPoint1)
$hBrush = _WinAPI_CreateBrushIndirect($BS_SOLID, 0xFF8000)
$hObj = _WinAPI_SelectObject($hDC, $hBrush)
_WinAPI_ExtFloodFill($hDC, 70 + 219, 40 + 25, 0xFF8000, 0)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hBrush)
_WinAPI_SetDCPenColor($hDC, 0xFFFFFF)
Local $hPattern = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Pattern.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
; $hPattern = _WinAPI_LoadBitmap(_WinAPI_GetModuleHandle(@SystemDir & '\shell32.dll'), 138)
$hBrush = _WinAPI_CreateBrushIndirect($BS_PATTERN, 0, $hPattern)
$hObj = _WinAPI_SelectObject($hDC, $hBrush)
$tRECT = _WinAPI_CreateRect(0, 0, 140, 90)
_WinAPI_OffsetRect($tRECT, 220, 279)
_WinAPI_RoundRect($hDC, $tRECT, 20, 20)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hPattern)
_WinAPI_DeleteObject($hBrush)

; Merge bitmap
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDev, 400, 400)
$hBrush = _WinAPI_SelectObject($hDC, $hOldBrush)
_WinAPI_DeleteObject($hBrush)
Local $hPen = _WinAPI_SelectObject($hDC, $hOldPen)
_WinAPI_DeleteObject($hPen)
_WinAPI_SelectObject($hDC, $hBitmap)
_WinAPI_DrawBitmap($hDC, 0, 0, $hSource, $MERGECOPY)
_WinAPI_ReleaseDC($hPic, $hDev)
_WinAPI_SelectObject($hDC, $hSv)
_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteDC($hDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
$hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = -3


Function _WinAPI_GetBitmapBits

Function Reference

_WinAPI_GetBitmapBits

Copies the bitmap bits of a specified device-dependent bitmap into a buffer

#include <WinAPIGdi.au3>
_WinAPI_GetBitmapBits ( $hBitmap, $iSize, $pBits )

Parameters

$hBitmap | Handle to the device-dependent bitmap.
$iSize | The number of bytes to copy from the bitmap into the buffer.
$pBits | A pointer to a buffer to receive the bitmap bits.

Return Value

Success: | The number of bytes copied to the buffer.
Failure: | 0.

See Also

Search GetBitmapBits in MSDN Library.


Function _WinAPI_GetBitmapDimension

Function Reference

_WinAPI_GetBitmapDimension

Retrieves a dimension of the specified bitmap

#include <WinAPIGdi.au3>
_WinAPI_GetBitmapDimension ( $hBitmap )

Parameters

$hBitmap Handle to the bitmap to retrieve dimension.

Return Value

Success: | $tagSIZE structure that contains the bitmap dimension, in pixels.
Failure: | Sets the @error flag to non-zero.

Example

#include <WinAPIGdi.au3>

Local $hBitmap = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\AutoIt.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Local $tSIZE = _WinAPI_GetBitmapDimension($hBitmap)
_WinAPI_DeleteObject($hBitmap)

ConsoleWrite(DllStructGetData($tSIZE, 'X') & ' x ' & DllStructGetData($tSIZE, 'Y') & @CRLF)


Function _WinAPI_GetBitmapDimensionEx

Function Reference

_WinAPI_GetBitmapDimensionEx

Retrieves the dimensions of a compatible bitmap

#include <WinAPIGdi.au3>
_WinAPI_GetBitmapDimensionEx ( $hBitmap )

Parameters

$hBitmap Handle to a compatible bitmap (DDB).

Return Value

Success: | $tagSIZE structure that contains fields for the height and width of the bitmap, in .01-mm units.
Failure: | Sets the @error flag to non-zero.

Remarks

If the dimensions have not yet been set, the structure that is returned will have zeros in those fields.

See Also

Search GetBitmapDimensionEx in MSDN Library.


Function _WinAPI_GetDIBColorTable

Function Reference

_WinAPI_GetDIBColorTable

Retrieves RGB color table from the DIB section bitmap

#include <WinAPIGdi.au3>
_WinAPI_GetDIBColorTable ( $hBitmap )

Parameters

$hBitmap A DIB section bitmap from which to retrieve the color table.

Return Value

Success: | "dword[n]" structure that contains a color information from the DIB color table, @extended flag will contain the number of colors in this structure.
Failure: | Sets the @error flag to non-zero.

Remarks

The _WinAPI_GetDIBColorTable() function retrieves a color table for DIB section bitmaps that use 1, 4, or 8 bits-per-pixel.
A DIB section bitmaps that use bits-per-pixel value greater than eight do not have a color table, but they do have associated color masks.
Call the _WinAPI_GetObject() function to retrieve those color masks.

Related

_WinAPI_GetObject

See Also

Search GetDIBColorTable in MSDN Library.


Function _WinAPI_GetIconDimension

Function Reference

_WinAPI_GetIconDimension

Retrieves a dimension of the specified icon

#include <WinAPIGdi.au3>
_WinAPI_GetIconDimension ( $hIcon )

Parameters

$hIcon Handle to the icon to retrieve dimension.

Return Value

Success: | $tagSIZE structure that contains the icon dimension, in pixels.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Example

#include <WinAPIGdi.au3>
#include <WinAPIShellEx.au3>

Local $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 130, 48, 48)
Local $tSIZE = _WinAPI_GetIconDimension($hIcon)
_WinAPI_DestroyIcon($hIcon)

ConsoleWrite(DllStructGetData($tSIZE, 'X') & ' x ' & DllStructGetData($tSIZE, 'Y') & @CRLF)


Function _WinAPI_GetPixel

Function Reference

_WinAPI_GetPixel

Retrieves the color value of the pixel at the specified coordinates

#include <WinAPIGdi.au3>
_WinAPI_GetPixel ( $hDC, $iX, $iY )

Parameters

$hDC | Handle to the device context.
$iX | The x-coordinate, in logical units, of the pixel to be examined.
$iY | The y-coordinate, in logical units, of the pixel to be examined.

Return Value

Success: | The color of the pixel, in RGB.
Failure: | (-1).

See Also

Search GetPixel in MSDN Library.


Function _WinAPI_GetStretchBltMode

Function Reference

_WinAPI_GetStretchBltMode

Retrieves the current stretching mode

#include <WinAPIGdi.au3>
_WinAPI_GetStretchBltMode ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | The current stretching mode ($STRETCH_*).
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetStretchBltMode in MSDN Library.


Function _WinAPI_GradientFill

Function Reference

_WinAPI_GradientFill

Fills rectangle or triangle gradient

#include <WinAPIGdi.au3>
_WinAPI_GradientFill ( $hDC, Const ByRef $aVertex [, $iStart = 0 [, $iEnd = -1 [, $bRotate = False]]] )

Parameters

$hDC | Handle to the device context.
$aVertex | The 2D array ([x1, y1, $iRGB1], [x2, y2, $iRGB2], ... [xN, yN, $iRGBN]) that contains the necessary gradient vertices. Each vertex in this array contains the following parameters. x - The x-coordinate, in logical units. y - The y-coordinate, in logical units rgb - The color information at the point of x, y.
$iStart | [optional] The index of array to start filling at.
$iEnd | [optional] The index of array to stop filling at.
$bRotate | [optional] Specifies whether fills a rectangle from left to right edge (horizontal gradient). $bRotate used only for the rectangular gradients, for the triangular gradients this parameter will be ignored, valid values: True - Fills from left to right edge. False - Fills from top to bottom edge (Default).

Return Value

Success: | 1.
Failure: | 0.

Remarks

If the number of vertices defined by using $iStart and $iEnd parameters is 2, _WinAPI_GradientFill() function
fills a rectangle. If the number of vertices is 3, fills a triangle. For the rectangle, the vertices must
specify its upper left and lower right corners. Note that $aVertex array may contain any number of vertices
of the gradient, but only 2 or 3 vertices may be used at the same time from this array.
Otherwise, the function is fails.

_WinAPI_GradientFill() function can only fill the rectangle or triangle at one call. Use multiple calls this
function to fill a complex gradients.

See Also

Search GdiGradientFill in MSDN Library.

Example

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

Local $aVertex[6][3] = [[0, 0, 0xFF0000], [400, 400, 0x00FF00], [0, 400, 0x0000FF], [0, 0, 0xFF0000], [400, 0, 0xFFFF00], [400, 400, 0x00FF00]]

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idPic = GUICtrlCreatePic('', 0, 0, 400, 400)
Local $hPic = GUICtrlGetHandle($idPic)

; Create gradient
Local $hDC = _WinAPI_GetDC($hPic)
Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, 400, 400)
Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap)
_WinAPI_GradientFill($hDestDC, $aVertex, 0, 2)
_WinAPI_GradientFill($hDestDC, $aVertex, 3, 5)

_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hDestDC, $hDestSv)
_WinAPI_DeleteDC($hDestDC)

; Set gradient to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_InvertANDBitmap

Function Reference

_WinAPI_InvertANDBitmap

Inverts the specified AND bitmask bitmap by performing a logical NOT operation

#include <WinAPIGdi.au3>
_WinAPI_InvertANDBitmap ( $hBitmap [, $bDelete = False] )

Parameters

$hBitmap | Handle to the source bitmap that must be inverted.
$bDelete | [optional] Specifies whether to delete the source bitmap after the function is successful, valid values: True - The bitmap will be destroyed when the function succeeds. False - Do not delete, you must destroy a bitmap when it no longer needed (Default).

Return Value

Success: | Handle to the inverted bitmap.
Failure: | 0.

Remarks

The _WinAPI_InvertANDBitmap() creates a 1 bits-per-pixel inverted bitmask DIB from the 1 bits-per-pixel AND bitmask bitmap.
If the source bitmap is not a 1 bits-per-pixel bitmap, the function fails.

When you are finished using the bitmap, destroy it using the _WinAPI_DeleteObject() function.

Related

_WinAPI_DeleteObject

Example

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIShellEx.au3>

; Extracts icon and create AND bitmask bitmap
Local $hIcon = _WinAPI_ShellExtractIcon(@ScriptDir & '\Extras\Script.ico', 0, 128, 128)
Local $aInfo = _WinAPI_GetIconInfo($hIcon)
_WinAPI_DeleteObject($aInfo[5])
_WinAPI_DestroyIcon($hIcon)

; Create inverted bitmask bitmap
$aInfo[5] = _WinAPI_InvertANDBitmap($aInfo[4])

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 256, 128)
Local $aidPic[2], $ahPic[2]
$aidPic[0] = GUICtrlCreatePic('', 0, 0, 128, 128)
$aidPic[1] = GUICtrlCreatePic('', 128, 0, 128, 128)
For $i = 0 To 1
    $ahPic[$i] = GUICtrlGetHandle($aidPic[$i])
Next

; Set both bitmaps to controls
For $i = 0 To 1
    _SendMessage($ahPic[$i], $STM_SETIMAGE, 0, $aInfo[$i + 4])
    Local $hObj = _SendMessage($ahPic[$i], $STM_GETIMAGE)
    If $hObj <> $aInfo[$i + 4] Then
        _WinAPI_DeleteObject($aInfo[$i + 4])
    EndIf
Next

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_IsAlphaBitmap

Function Reference

_WinAPI_IsAlphaBitmap

Determines whether the specified bitmap has an alpha channel

#include <WinAPIGdi.au3>
_WinAPI_IsAlphaBitmap ( $hBitmap )

Parameters

$hBitmap Handle to the bitmap to test. This bitmap must be a 32 bits-per-pixel.

Return Value

Success: | True - The specified bitmap has an alpha channel. False - Otherwise.
Failure: | Sets the @error flag to non-zero.

Remarks

This function only works with 32 bits-per-pixel uncompressed bitmaps. If the source bitmap is non 32 bits-per-pixel
bitmap, or is a compressed bitmap, the _WinAPI_IsAlphaBitmap() always returns 0.


Function _WinAPI_MaskBlt

Function Reference

_WinAPI_MaskBlt

Combines the color data for the source and destination bitmaps using the specified mask and raster operation

#include <WinAPIGdi.au3>
_WinAPI_MaskBlt ( $hDestDC, $iXDest, $iYDest, $iWidth, $iHeight, $hSrcDC, $iXSrc, $iYSrc, $hMask, $iXMask, $iYMask, $iRop )

Parameters

$hDestDC | Handle to the destination device context.
$iXDest | The x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
$iYDest | The y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
$iWidth | The width, in logical units, of the destination rectangle and source bitmap.
$iHeight | The height, in logical units, of the destination rectangle and source bitmap.
$hSrcDC | Handle to the device context from which the bitmap is to be copied.
$iXSrc | The x-coordinate, in logical units, of the upper-left corner of the source bitmap.
$iYSrc | The y-coordinate, in logical units, of the upper-left corner of the source bitmap.
$hMask | Handle to the monochrome mask bitmap combined with the color bitmap in the source device context.
$iXMask | The horizontal pixel offset for the mask bitmap specified by the hbmMask parameter.
$iYMask | The vertical pixel offset for the mask bitmap specified by the hbmMask parameter.
$iRop | The raster-operation code (same as for _WinAPI_BitBlt()).

Return Value

Success: | True
Failure: | False

Remarks

A value of 1 in the mask specified by $hMask indicates that the foreground raster operation code specified by
$iRop should be applied at that location. A value of 0 in the mask indicates that the background raster operation
code specified by $iRop should be applied at that location.

If no mask bitmap is supplied, this function behaves exactly like _WinAPI_BitBlt(), using the foreground raster
operation code.

Related

_WinAPI_BitBlt

See Also

Search MaskBlt in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIShellEx.au3>
#include <WindowsConstants.au3>

; Extracts icon and get its AND bitmask bitmap
Local $hIcon = _WinAPI_ShellExtractIcon(@ScriptDir & '\Extras\Arrow.ico', 0, 64, 64)
Local $aInfo = _WinAPI_GetIconInfo($hIcon)
_WinAPI_DeleteObject($aInfo[5])
_WinAPI_DestroyIcon($hIcon)

; Create inverted bitmask bitmap
$aInfo[5] = _WinAPI_InvertANDBitmap($aInfo[4])

; Load pattern bitmap
Local $hPattern = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Pattern.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 320, 64)
GUICtrlCreateIcon(@ScriptDir & '\Extras\Arrow.ico', 0, 0, 0, 64, 64)
GUICtrlCreatePic(@ScriptDir & '\Extras\Pattern.bmp', 192, 0, 64, 64)
Local $idIcon = GUICtrlCreateIcon('', 0, 256, 0, 64, 64)
Local $aidPic[2], $ahPic[2]
$aidPic[0] = GUICtrlCreatePic('', 64, 0, 64, 64)
$aidPic[1] = GUICtrlCreatePic('', 128, 0, 64, 64)
For $i = 0 To 1
    $ahPic[$i] = GUICtrlGetHandle($aidPic[$i])
Next

; Create XOR bitmask bitmap
Local $hDC = _WinAPI_GetDC($ahPic)
Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hPattern)
Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hXOR = _WinAPI_CreateCompatibleBitmap($hDC, 64, 64)
Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hXOR)
_WinAPI_MaskBlt($hDestDC, 0, 0, 64, 64, $hSrcDC, 0, 0, $aInfo[5], 0, 0, $SRCCOPY)
_WinAPI_ReleaseDC($ahPic, $hDC)
_WinAPI_SelectObject($hDestDC, $hDestSv)
_WinAPI_DeleteDC($hDestDC)
_WinAPI_SelectObject($hSrcDC, $hSrcSv)
_WinAPI_DeleteObject($hPattern)
_WinAPI_DeleteDC($hSrcDC)

; Create icon

$hIcon = _WinAPI_CreateIconIndirect($hXOR, $aInfo[4])
_WinAPI_DeleteObject($hXOR)

; Set both bitmask bitmaps to controls
Local $hObj
For $i = 0 To 1
    _SendMessage($ahPic[$i], $STM_SETIMAGE, 0, $aInfo[$i + 4])
    $hObj = _SendMessage($ahPic[$i], $STM_GETIMAGE)
    If $hObj <> $aInfo[$i + 4] Then
        _WinAPI_DeleteObject($aInfo[$i + 4])
    EndIf
Next

; Set icon to control
GUICtrlSendMsg($idIcon, $STM_SETIMAGE, 1, $hIcon)

; Show GUI
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_PlgBlt

Function Reference

_WinAPI_PlgBlt

Performs a bit-block transfer of color data from the specified rectangle in the source DC to the specified parallelogram in the DC context

#include <WinAPIGdi.au3>
_WinAPI_PlgBlt ( $hDestDC, Const ByRef $aPoint, $hSrcDC, $iXSrc, $iYSrc, $iWidth, $iHeight [, $hMask = 0 [, $iXMask = 0 [, $iYMask = 0]]] )

Parameters

$hDestDC | Handle to the destination device context.
$aPoint | The 2D array ([x1, y1], [x2, y2], [x3, y3]) that identify three corners of the destination parallelogram. The upper-left corner of the source rectangle is mapped to the first point in this array, the upper-right corner to the second point in this array, and the lower-left corner to the third point. The lower-right corner of the source rectangle is mapped to the implicit fourth point in the parallelogram.
$hSrcDC | Handle to the source device context.
$iXSrc | The x-coordinate, in logical units, of the upper-left corner of the source rectangle.
$iYSrc | The y-coordinate, in logical units, of the upper-left corner of the source rectangle.
$iWidth | The width, in logical units, of the source rectangle.
$iHeight | The height, in logical units, of the source rectangle.
$hMask | [optional] Handle to the monochrome bitmap that is used to mask the colors of the source rectangle.
$iXMask | [optional] The x-coordinate, in logical units, of the upper-left corner of the monochrome bitmap. Default is 0.
$iYMask | [optional] The y-coordinate, in logical units, of the upper-left corner of the monochrome bitmap. Default is 0.

Return Value

Success: | True
Failure: | False

Remarks

The _WinAPI_PlgBlt() works with device-dependent bitmaps. If the source and destination device contexts represent
incompatible devices, the function returns an error.

The fourth vertex of the parallelogram (D) is defined by treating the first three points (A, B, and C) as vectors
and computing D = B + CA.

If the bitmask is specified, a value of 1 in the mask indicates that the source pixel color should be copied to the
destination. A value of 0 in the mask indicates that the destination pixel color is not to be changed. If the mask
rectangle is smaller than the source and destination rectangles, the function replicates the mask pattern.

Scaling, translation, and reflection transformations are allowed in the source device context; however, rotation
and shear transformations are not. If the mask bitmap is not a monochrome bitmap, an error occurs. The stretching
mode for the destination device context is used to determine how to stretch or compress the pixels, if that is
necessary.

See Also

Search PlgBlt in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

Opt('TrayAutoPause', 0)

; Load image
Global $g_hBitmap = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Compass.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Local $tSIZE = _WinAPI_GetBitmapDimension($g_hBitmap)
Local $W = DllStructGetData($tSIZE, 'X')
Local $H = DllStructGetData($tSIZE, 'Y')

; Create GUI
Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), $W, $H + 26)
Global $g_idPic = GUICtrlCreatePic('', 0, 0, $W, $H)
GUICtrlCreateGraphic(0, $H, $W, 1)
GUICtrlSetBkColor(-1, 0xDFDFDF)
Global $g_idSlider = GUICtrlCreateSlider(0, $H + 1, $W, 25, BitOR($TBS_BOTH, $TBS_NOTICKS))
Global $g_hSlider = GUICtrlGetHandle(-1)
GUICtrlSetLimit(-1, 360, 0)
GUICtrlSetData(-1, 0)

; Set bitmap to control with rotate
_SetBitmapRotate($g_idPic, $g_hBitmap, 0)

; Register WM_HSCROLL message for live scrolling and show GUI
GUIRegisterMsg($WM_HSCROLL, 'WM_HSCROLL')
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _SetBitmapRotate($hWnd, $hBitmap, $iAngle)
    If Not IsHWnd($hWnd) Then
        $hWnd = GUICtrlGetHandle($hWnd)
        If Not $hWnd Then
            Return 0
        EndIf
    EndIf

    Local $aW[2], $aH[2]
    Local $aPoint[3][2]
    Local $tRECT = _WinAPI_GetClientRect($hWnd)
    $aW[0] = DllStructGetData($tRECT, 3) - DllStructGetData($tRECT, 1)
    $aH[0] = DllStructGetData($tRECT, 4) - DllStructGetData($tRECT, 2)
    Local $tSIZE = _WinAPI_GetBitmapDimension($g_hBitmap)
    $aW[1] = DllStructGetData($tSIZE, 1)
    $aH[1] = DllStructGetData($tSIZE, 2)
    $aPoint[0][0] = ($aW[0] - $aW[1]) / 2
    $aPoint[0][1] = ($aH[0] - $aH[1]) / 2
    $aPoint[1][0] = $aPoint[0][0] + $aW[1]
    $aPoint[1][1] = $aPoint[0][1]
    $aPoint[2][0] = $aPoint[0][0]
    $aPoint[2][1] = $aPoint[0][1] + $aH[1]
    Local $hDC = _WinAPI_GetDC($hWnd)
    Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
    Local $hMask = _WinAPI_CreateBitmap($aW[0], $aH[0], 1, 1)
    Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hMask)
    Local $hBrush = _WinAPI_SelectObject($hDestDC, _WinAPI_GetStockObject($DC_BRUSH))
    Local $hPen = _WinAPI_SelectObject($hDestDC, _WinAPI_GetStockObject($DC_PEN))
    _WinAPI_SetDCBrushColor($hDestDC, 0xFFFFFF)
    _WinAPI_SetDCPenColor($hDestDC, 0xFFFFFF)
    _WinAPI_Ellipse($hDestDC, _WinAPI_CreateRectEx($aPoint[0][0] + 43, $aPoint[0][1] + 43, $aPoint[1][0] - 86, $aPoint[2][1] - 86))
    Local $hBmp = _WinAPI_CreateCompatibleBitmapEx($hDC, $aW[0], $aH[0], 0xFFFFFF)
    _WinAPI_SelectObject($hDestDC, $hBrush)
    _WinAPI_SelectObject($hDestDC, $hPen)
    _WinAPI_SelectObject($hDestDC, $hBmp)
    Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC)
    Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBitmap)
    _WinAPI_RotatePoints($aPoint, $aW[0] / 2, $aH[0] / 2, $iAngle)
    _WinAPI_PlgBlt($hDestDC, $aPoint, $hSrcDC, 0, 0, $aW[1], $aH[1])
    _WinAPI_RotatePoints($aPoint, $aW[0] / 2, $aH[0] / 2, -2 * $iAngle)
    _WinAPI_PlgBlt($hDestDC, $aPoint, $hSrcDC, 0, 0, $aW[1], $aH[1], $hMask)
    _WinAPI_SelectObject($hDestDC, $hDestSv)
    _WinAPI_DeleteDC($hDestDC)
    _WinAPI_SelectObject($hSrcDC, $hSrcSv)
    _WinAPI_DeleteDC($hSrcDC)
    _WinAPI_DeleteObject($hMask)
    _WinAPI_ReleaseDC($hWnd, $hDC)
    Local $hObj = _SendMessage($hWnd, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp)
    If $hObj Then
        _WinAPI_DeleteObject($hObj)
    EndIf
    $hObj = _SendMessage($hWnd, $STM_GETIMAGE)
    If $hObj <> $hBmp Then
        _WinAPI_DeleteObject($hBmp)
    EndIf
    Return 1
EndFunc   ;==>_SetBitmapRotate

Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam

    Switch $hWnd
        Case $g_hForm
            Switch $lParam
                Case $g_hSlider
                    _SetBitmapRotate($g_idPic, $g_hBitmap, GUICtrlRead($g_idSlider))
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_HSCROLL


Function _WinAPI_RadialGradientFill

Function Reference

_WinAPI_RadialGradientFill

Fills radial gradient

#include <WinAPIGdi.au3>
_WinAPI_RadialGradientFill ( $hDC, $iX, $iY, $iRadius, $iRGB1, $iRGB2 [, $fAngleStart = 0 [, $fAngleEnd = 360 [, $fStep = 5]]] )

Parameters

$hDC | Handle to the device context.
$iX | The x-coordinate of the central point, in logical units.
$iY | The y-coordinate of the central point, in logical units.
$iRadius | The circle radius to filling the gradient.
$iRGB1 | The color information at the central point.
$iRGB2 | The color information at the edges of circle.
$fAngleStart | [optional] The angle to start filling at, in degree. Default is 0.
$fAngleEnd | [optional] The angle to end filling at, in degree. Default is 360.
$fStep | [optional] The gradient filling step in degree. The larger value of this parameter, the gradient will be better, but it's require more time, and vice versa. Default is 5.

Return Value

Success: | 1.
Failure: | 0.

Remarks

This function does not fills gradient with transparency, and does not use antialiasing.

Example

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

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idPic = GUICtrlCreatePic('', 0, 0, 400, 400)
Local $hPic = GUICtrlGetHandle($idPic)

; Create gradient
Local $hDC = _WinAPI_GetDC($hPic)
Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 400, 400, 0xFFFFFF)
Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap)
For $i = 0 To 315 Step 45
    _WinAPI_RadialGradientFill($hDestDC, 200, 200, 180, Random(0, 0xFFFFFF, 1), 0xFFFFFF, $i, $i + 45)
Next
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hDestDC, $hDestSv)
_WinAPI_DeleteDC($hDestDC)

; Set gradient to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_SaveHBITMAPToFile

Function Reference

_WinAPI_SaveHBITMAPToFile

Saves a specified bitmap to the specified bitmap (.bmp) file

#include <WinAPIGdi.au3>
_WinAPI_SaveHBITMAPToFile ( $sFilePath, $hBitmap [, $iXPelsPerMeter = Default [, $iYPelsPerMeter = Default]] )

Parameters

$sFilePath | The name of the .bmp file in which to save the bitmap.
$hBitmap | Handle to the bitmap to be save.
$iXPelsPerMeter | [optional] The horizontal resolution, in pixels-per-meter.
$iYPelsPerMeter | [optional] The vertical resolution, in pixels-per-meter.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

This function saves the specified bitmap unchanged, except when the bitmap uses 32 bits-per-pixel color depth.
In this situation, if the bitmap contains an alpha channel, it will be saved as 32 bits-per-pixel image, and
as 24 bits-per-pixel image otherwise.

The horizontal and vertical resolutions pointed to by the $iXPelsPerMeter and $iYPelsPerMeter parameters has not
affects the image quality, but application can use this value to select a bitmap from a resource group that best
matches the characteristics of the current device. If the resolutions is not specified, the function uses the
current screen resolutions, usually 2834 pixels-per-meter which corresponds to 72 pixels-per-inch (dpi).

If the source bitmap is compressed, or use a color masks, the function fails.

Example

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIMisc.au3>
#include <WinAPISys.au3>

; Create array of colors of 256 entries required for 8 bits-per-pixel bitmap
Local $aColorTable[256]
For $i = 0 To 255
    $aColorTable[$i] = _WinAPI_RGB(0, $i, 255 - $i)
Next

; Create color table from an array of colors
Local $tColorTable = _WinAPI_CreateDIBColorTable($aColorTable)

; Create 8 bits-per-pixel device-independent bitmap (DIB) and retrieve a pointer to the location of its bit values
Local $hBitmap = _WinAPI_CreateDIB(256, 256, 8, $tColorTable, 256)
Local $pBits = _WinAPI_GetExtended()

; Fill bitmap color indexes
For $i = 0 To 255
    _WinAPI_FillMemory($pBits + 256 * $i, 256, $i)
Next

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 256, 256)
Local $idPic = GUICtrlCreatePic('', 0, 0, 256, 256)
Local $hPic = GUICtrlGetHandle($idPic)

; Create DDB from DIB to correct display in control
Local $hDC = _WinAPI_GetDC($hPic)
Local $hDev = _WinAPI_CreateCompatibleBitmap($hDC, 256, 256)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hDev)
_WinAPI_DrawBitmap($hMemDC, 0, 0, $hBitmap)
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hDev)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hDev Then
    _WinAPI_DeleteObject($hDev)
EndIf

; Show GUI
GUISetState(@SW_SHOW)

; Save 8 bits-per-pixel bitmap to .bmp file
Local $sPath = FileSaveDialog('Save Image', @TempDir, 'Bitmap Image Files (*.bmp)', 2 + 16, 'MyImage.bmp', $hForm)
If $sPath Then
    _WinAPI_SaveHBITMAPToFile($sPath, $hBitmap, 2834, 2834)
EndIf

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_SaveHICONToFile

Function Reference

_WinAPI_SaveHICONToFile

Saves a specified single or multiple icon (HICON) to the specified icon (.ico) file

#include <WinAPIGdi.au3>
_WinAPI_SaveHICONToFile ( $sFilePath, Const ByRef $vIcon [, $bCompress = 0 [, $iStart = 0 [, $iEnd = -1]]] )

Parameters

$sFilePath | The name of the .ico file in which to save the icon.
$vIcon | Handle to the icon or array of the icon handles to be save.
$bCompress | [optional] Specifies whether to use PNG compression for the 32 bits-per-pixel icons if its size exceed or equal to 256x256 pixels (262144 bytes), valid values: True - The icon will be saved as a PNG image. False - The icon will be saved directly (Default).
$iStart | [optional] The index of array to start saving at.
$iEnd | [optional] The index of array to stop saving at.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

This function works with 16, 24, and 32 bits-per-pixel icons. Since the icon handles always contains a device-depended
XOR bitmap (DDB), the resulting image that saved in .ico file may differ from the source image.

If the specified icon is a 32 bits-per-pixel icon, and uses the AND bitmask bitmap instead of alpha channel,
it will be converted to an icon with alpha channel (RGB + Alpha).

Note that the icons with PNG compression are supported starting only with Windows Vista. In addition,
not all applications can work with such icons.

Example

#include <WinAPIGdi.au3>
#include <WinAPIShellEx.au3>

Local $aIcon[3] = [48, 32, 16]

For $i = 0 To UBound($aIcon) - 1
    $aIcon[$i] = _WinAPI_Create32BitHICON(_WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 32, $aIcon[$i], $aIcon[$i]), 1)
Next
_WinAPI_SaveHICONToFile(@TempDir & '\MyIcon.ico', $aIcon)
For $i = 0 To UBound($aIcon) - 1
    _WinAPI_DestroyIcon($aIcon[$i])
Next

ShellExecute('mspaint', '"' & @TempDir & '\MyIcon.ico' & '"')


Function _WinAPI_SetBitmapBits

Function Reference

_WinAPI_SetBitmapBits

Sets the bits of color data for a bitmap to the specified values

#include <WinAPIGdi.au3>
_WinAPI_SetBitmapBits ( $hBitmap, $iSize, $pBits )

Parameters

$hBitmap | Handle to the bitmap to be set. This must be a compatible bitmap (DDB).
$iSize | The number of bytes pointed to by the $pBits parameter.
$pBits | A pointer to an array of bytes that contain color data for the specified bitmap.

Return Value

Success: | the number of bytes used in setting the bitmap bits.
Failure: | 0.

See Also

Search SetBitmapBits in MSDN Library.


Function _WinAPI_SetBitmapDimensionEx

Function Reference

_WinAPI_SetBitmapDimensionEx

Assigns preferred dimensions to a compatible bitmap

#include <WinAPIGdi.au3>
_WinAPI_SetBitmapDimensionEx ( $hBitmap, $iWidth, $iHeight )

Parameters

$hBitmap | Handle to the bitmap. This bitmap cannot be a DIB-section bitmap.
$iWidth | The width, in 0.1-millimeter units, of the bitmap.
$iHeight | The height, in 0.1-millimeter units, of the bitmap.

Return Value

Success: | True
Failure: | False

Remarks

The bitmap cannot be a DIB section, which is a bitmap created by the _WinAPI_CreateDIB() or _WinAPI_CreateDIBSection()
functions. If the bitmap is a DIB section, the _WinAPI_SetBitmapDimensionEx() function fails.

Call _WinAPI_GetExtended() to retrieve a $tagSIZE structure containing the previous dimensions of the bitmap.

Related

_WinAPI_CreateDIB, _WinAPI_CreateDIBSection, _WinAPI_GetExtended

See Also

Search SetBitmapDimensionEx in MSDN Library.


Function _WinAPI_SetDIBColorTable

Function Reference

_WinAPI_SetDIBColorTable

Sets RGB color table in the DIB section bitmap

#include <WinAPIGdi.au3>
_WinAPI_SetDIBColorTable ( $hBitmap, $tColorTable, $iColorCount )

Parameters

$hBitmap | A DIB section bitmap in which to set the color table.
$tColorTable | "dword[n]" structure that represents a DIB color table that to be set.
$iColorCount | The number of color table entries to set.

Return Value

Success: | The number of color table entries that the function sets.
Failure: | 0.

Remarks

The _WinAPI_GetDIBColorTable() function sets a color table for DIB section bitmaps that use 1, 4, or 8 bits-per-pixel.
A DIB section bitmaps that use bits-per-pixel value greater than eight do not have a color table.

See Also

Search SetDIBColorTable in MSDN Library.


Function _WinAPI_SetDIBitsToDevice

Function Reference

_WinAPI_SetDIBitsToDevice

Sets the pixels in the specified rectangle on the device

#include <WinAPIGdi.au3>
_WinAPI_SetDIBitsToDevice ( $hDC, $iXDest, $iYDest, $iWidth, $iHeight, $iXSrc, $iYSrc, $iStartScan, $iScanLines, $tBITMAPINFO, $iUsage, $pBits )

Parameters

$hDC | Handle to a device context.
$iXDest | The x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
$iYDest | The y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
$iWidth | The width, in logical units, of the image.
$iHeight | The height, in logical units, of the image.
$iXSrc | The x-coordinate, in logical units, of the lower-left corner of the image.
$iYSrc | The y-coordinate, in logical units, of the lower-left corner of the image.
$iStartScan | The starting scan line in the image.
$iScanLines | The number of DIB scan lines.
$tBITMAPINFO | $tagBITMAPINFO structure that contains information about the DIB.
$iUsage | The type of colors used. (either logical palette indexes or literal RGB values). The following values are defined: $DIB_PAL_COLORS $DIB_RGB_COLORS
$pBits | A pointer to the color data stored as an array of bytes.

Return Value

Success: | the number of scan lines set. 0 - Otherwise.
Failure: | sets the @error flag to non-zero (GDI_ERROR).

Remarks

If the driver cannot support the JPEG or PNG file image passed to SetDIBitsToDevice,
the function will fail and return GDI_ERROR.

See Also

Search SetDIBitsToDevice in MSDN Library.


Function _WinAPI_SetPixel

Function Reference

_WinAPI_SetPixel

Sets the pixel at the specified coordinates to the specified color

#include <WinAPIGdi.au3>
_WinAPI_SetPixel ( $hDC, $iX, $iY, $iRGB )

Parameters

$hDC | Handle to the device context.
$iX | The x-coordinate, in logical units, of the point to be set.
$iY | The y-coordinate, in logical units, of the point to be set.
$iRGB | The color to be used to paint the point.

Return Value

Success: | True
Failure: | False

See Also

Search SetPixelV in MSDN Library.


Function _WinAPI_SetStretchBltMode

Function Reference

_WinAPI_SetStretchBltMode

Sets the bitmap stretching mode in the specified device context

#include <WinAPIGdi.au3>
_WinAPI_SetStretchBltMode ( $hDC, $iMode )

Parameters

$hDC | Handle to the device context.
$iMode | The stretching mode. This parameter can be one of the following values. $BLACKONWHITE $COLORONCOLOR $HALFTONE $WHITEONBLACK $STRETCH_ANDSCANS $STRETCH_DELETESCANS $STRETCH_HALFTONE $STRETCH_ORSCANS

Return Value

Success: | The previous stretching mode.
Failure: | 0 and sets the @error flag to non-zero, @extended may contain ERROR_INVALID_PARAMETER.

Remarks

The $BLACKONWHITE ($STRETCH_ANDSCANS) and $WHITEONBLACK ($STRETCH_ORSCANS) modes are typically used to
preserve foreground pixels in monochrome bitmaps. The $COLORONCOLOR ($STRETCH_DELETESCANS) mode is typically
used to preserve color in color bitmaps. The $HALFTONE ($STRETCH_HALFTONE) mode is slower and requires more
processing of the source image than the other three modes; but produces higher quality images.

See Also

Search SetStretchBltMode in MSDN Library.


Function _WinAPI_StretchBlt

Function Reference

_WinAPI_StretchBlt

Copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap to fit the dimensions of the destination rectangle

#include <WinAPIGdi.au3>
_WinAPI_StretchBlt ( $hDestDC, $iXDest, $iYDest, $iWidthDest, $iHeightDest, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iRop )

Parameters

$hDestDC | Handle to the destination device context.
$iXDest | The x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
$iYDest | The y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
$iWidthDest | The width, in logical units, of the destination rectangle.
$iHeightDest | The height, in logical units, of the destination rectangle.
$hSrcDC | Handle to the source device context.
$iXSrc | The x-coordinate, in logical units, of the upper-left corner of the source rectangle.
$iYSrc | The y-coordinate, in logical units, of the upper-left corner of the source rectangle.
$iWidthSrc | The width, in logical units, of the source rectangle.
$iHeightSrc | The height, in logical units, of the source rectangle.
$iRop | The raster-operation code. These codes define how the color data for the source rectangle is to be combined with the color data for the destination rectangle to achieve the final color. This parameter must be 0 or one of the following values. $BLACKNESS $CAPTUREBLT $DSTINVERT $MERGECOPY $MERGEPAINT $NOMIRRORBITMAP $NOTSRCCOPY $NOTSRCERASE $PATCOPY $PATINVERT $PATPAINT $SRCAND $SRCCOPY $SRCERASE $SRCINVERT $SRCPAINT $WHITENESS

Return Value

Success: | True
Failure: | False

Remarks

The system stretches or compresses the bitmap according to the stretching mode currently set in the
destination device context.

See Also

Search StretchBlt in MSDN Library.


Function _WinAPI_StretchDIBits

Function Reference

_WinAPI_StretchDIBits

Copies the color data for a rectangle of pixels in a DIB, JPEG, or PNG image to the specified destination rectangle, stretching or compressing the rows and columns by using the specified raster operation

#include <WinAPIGdi.au3>
_WinAPI_StretchDIBits ( $hDestDC, $iXDest, $iYDest, $iWidthDest, $iHeightDest, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $tBITMAPINFO, $iUsage, $pBits, $iRop )

Parameters

$hDestDC | Handle to the destination device context.
$iXDest | The x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
$iYDest | The y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
$iWidthDest | The width, in logical units, of the destination rectangle.
$iHeightDest | The height, in logical units, of the destination rectangle.
$iXSrc | The x-coordinate, in pixels, of the source rectangle in the image.
$iYSrc | The y-coordinate, in pixels, of the source rectangle in the image.
$iWidthSrc | The width, in pixels, of the source rectangle in the image.
$iHeightSrc | The height, in pixels, of the source rectangle in the image.
$tBITMAPINFO | $tagBITMAPINFO structure that contains information about the DIB.
$iUsage | The type of colors used. (either logical palette indexes or literal RGB values). The following values are defined: $DIB_PAL_COLORS $DIB_RGB_COLORS
$pBits | A pointer to the image bits, which are stored as an array of bytes.
$iRop | The raster-operation code that specifies how the source pixels, the destination device context's current brush, and the destination pixels are to be combined to form the new image. It must be 0 or one of the following values: $BLACKNESS $CAPTUREBLT $DSTINVERT $MERGECOPY $MERGEPAINT $NOMIRRORBITMAP $NOTSRCCOPY $NOTSRCERASE $PATCOPY $PATINVERT $PATPAINT $SRCAND $SRCCOPY $SRCERASE $SRCINVERT $SRCPAINT $WHITENESS

Return Value

Success: | the number of scan lines copied. Note that this value can be negative for mirrored content. 0 - Otherwise.
Failure: | sets the @error flag to non-zero (GDI_ERROR).

Remarks

_WinAPI_StretchDIBits() creates a mirror image of a bitmap if the signs of the $iWidthSrc and $iWidthDest parameters,
or if the $iHeightSrc and $iHeightDest parameters differ. If $iWidthSrc and $iWidthDest have different signs,
the function creates a mirror image of the bitmap along the x-axis. If $iHeightSrc and $iHeightDest have different
signs, the function creates a mirror image of the bitmap along the y-axis.

See Also

Search StretchDIBits in MSDN Library.


Function _WinAPI_TransparentBlt

Function Reference

_WinAPI_TransparentBlt

Performs a bit-block transfer of the color data corresponding to a rectangle of pixels

#include <WinAPIGdi.au3>
_WinAPI_TransparentBlt ( $hDestDC, $iXDest, $iYDest, $iWidthDest, $iHeightDest, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iRGB )

Parameters

$hDestDC | Handle to the destination device context.
$iXDest | The x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
$iYDest | The y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
$iWidthDest | The width, in logical units, of the destination rectangle.
$iHeightDest | The height, in logical units, of the destination rectangle.
$hSrcDC | Handle to the source device context.
$iXSrc | The x-coordinate, in logical units, of the upper-left corner of the source rectangle.
$iYSrc | The y-coordinate, in logical units, of the upper-left corner of the source rectangle.
$iWidthSrc | The width, in logical units, of the source rectangle.
$iHeightSrc | The height, in logical units, of the source rectangle.
$iRGB | The RGB color in the source bitmap to treat as transparent.

Return Value

Success: | True.
Failure: | False.

Remarks

If the source and destination rectangles are not the same size, the source bitmap is stretched to match the
destination rectangle. When the _WinAPI_SetStretchBltMode() function is used, the stretching modes of
$BLACKONWHITE and $WHITEONBLACK are converted to $COLORONCOLOR for the _WinAPI_TransparentBlt() function.

This function supports all formats of source bitmaps. However, for 32 bpp bitmaps, it just copies the alpha
value over. Use _WinAPI_AlphaBlend() to specify 32 bits-per-pixel bitmaps with transparency.

Related

_WinAPI_AlphaBlend, _WinAPI_SetStretchBltMode

See Also

Search GdiTransparentBlt in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

Local $a_idPic[2], $a_hPic[2], $a_hBitmap[2]

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 260, 140)
$a_idPic[0] = GUICtrlCreatePic('', 20, 20, 100, 100)
$a_idPic[1] = GUICtrlCreatePic('', 140, 20, 100, 100)
For $i = 0 To 1
    $a_hPic[$i] = GUICtrlGetHandle($a_idPic[$i])
Next

; Create bitmap1
Local $hDC = _WinAPI_GetDC($a_hPic[0])
Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
$a_hBitmap[0] = _WinAPI_CreateCompatibleBitmapEx($hDC, 100, 100, 0xFF00FF)
Local $hDestSv = _WinAPI_SelectObject($hDestDC, $a_hBitmap[0])
Local $hObj = _WinAPI_CreateCompatibleBitmapEx($hDC, 70, 70, 0x00A060)
_WinAPI_DrawBitmap($hDestDC, 15, 15, $hObj)
_WinAPI_DeleteObject($hObj)
$hObj = _WinAPI_CreateCompatibleBitmapEx($hDC, 40, 40, 0xFF00FF)
_WinAPI_DrawBitmap($hDestDC, 30, 30, $hObj)
_WinAPI_DeleteObject($hObj)

_WinAPI_ReleaseDC($a_hPic[0], $hDC)
_WinAPI_SelectObject($hDestDC, $hDestSv)
_WinAPI_DeleteDC($hDestDC)

; Create bitmap2
$hDC = _WinAPI_GetDC($a_hPic[1])
$hDestDC = _WinAPI_CreateCompatibleDC($hDC)
$a_hBitmap[1] = _WinAPI_CreateCompatibleBitmapEx($hDC, 100, 100, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
$hDestSv = _WinAPI_SelectObject($hDestDC, $a_hBitmap[1])
Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $a_hBitmap[0])
_WinAPI_TransparentBlt($hDestDC, 0, 0, 100, 100, $hSrcDC, 0, 0, 100, 100, 0xFF00FF)

_WinAPI_ReleaseDC($a_hPic[1], $hDC)
_WinAPI_SelectObject($hDestDC, $hDestSv)
_WinAPI_SelectObject($hSrcDC, $hSrcSv)
_WinAPI_DeleteDC($hDestDC)
_WinAPI_DeleteDC($hSrcDC)

; Set both bitmaps to controls
For $i = 0 To 1
    _SendMessage($a_hPic[$i], $STM_SETIMAGE, 0, $a_hBitmap[$i])
    $hObj = _SendMessage($a_hPic[$i], $STM_GETIMAGE)
    If $hObj <> $a_hBitmap[$i] Then
        _WinAPI_DeleteObject($a_hBitmap[$i])
    EndIf
Next

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


User Defined Functions

Brush & Pen user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIGdi.au3>.

User Defined Function | Description
_WinAPI_CreateBrushIndirect | Creates a logical brush that has the specified style, color, and pattern
_WinAPI_ExtCreatePen | Creates a logical cosmetic or geometric pen that has the specified style, width, and brush attributes
_WinAPI_GetBrushOrg | Retrieves the current brush origin for the specified device context
_WinAPI_PatBlt | Paints the specified rectangle using the brush that is currently selected into the specified device context
_WinAPI_SetBrushOrg | Sets the brush origin that GDI assigns to the next brush an application selects into the specified device context
_WinAPI_SetDCBrushColor | Sets the current device context (DC) brush color to the specified color value
_WinAPI_SetDCPenColor | Sets the current device context (DC) pen color to the specified color value


Function _WinAPI_CreateBrushIndirect

Function Reference

_WinAPI_CreateBrushIndirect

Creates a logical brush that has the specified style, color, and pattern

#include <WinAPIGdi.au3>
_WinAPI_CreateBrushIndirect ( $iStyle, $iRGB [, $iHatch = 0] )

Parameters

$iStyle | The brush style. This parameter can be one of the following styles: $BS_DIBPATTERN $BS_DIBPATTERN8X8 $BS_DIBPATTERNPT $BS_HATCHED $BS_HOLLOW $BS_NULL $BS_PATTERN $BS_PATTERN8X8 $BS_SOLID
$iRGB | The color of a brush, in RGB, or one of the following values. $DIB_PAL_COLORS $DIB_RGB_COLORS
$iHatch | [optional] A hatch style. The meaning depends on the brush style defined by $iStyle parameter. $BS_DIBPATTERN Contains a handle to a packed DIB. $BS_DIBPATTERNPT Contains a pointer to a packed DIB. $BS_HATCHED Specifies the orientation of the lines used to create the hatch. It can be one of the orientation constants ($HS_*). $BS_PATTERN Contains a handle to the bitmap that defines the pattern. The bitmap cannot be a DIB section bitmap. $BS_HOLLOW $BS_SOLID (Default) Ignored.

Return Value

Success: | Handle to the brush.
Failure: | 0.

Remarks

After an application creates a brush by calling _WinAPI_CreateBrushIndirect(), it can select it into any device context by calling the _WinAPI_SelectObject() function.

When you no longer need the brush, call the _WinAPI_DeleteObject() function to delete it.

Related

_WinAPI_DeleteObject

See Also

Search CreateBrushIndirect in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <FontConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idPic = GUICtrlCreatePic('', 0, 0, 400, 400)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDev = _WinAPI_GetDC($hPic)
Local $hDC = _WinAPI_CreateCompatibleDC($hDev)
Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, 400, 400, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hSv = _WinAPI_SelectObject($hDC, $hSource)

; Draw objects
Local $hOldBrush = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hOldPen = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetDCBrushColor($hDC, 0x990404)
_WinAPI_SetDCPenColor($hDC, 0x990404)
Local $tRECT = _WinAPI_CreateRect(0, 0, 100, 100)
_WinAPI_OffsetRect($tRECT, 30, 30)
_WinAPI_Rectangle($hDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 20, 20)
_WinAPI_InvertRect($hDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 20, 20)
_WinAPI_InvertRect($hDC, $tRECT)
_WinAPI_SetDCPenColor($hDC, 0x00A820)
_WinAPI_SetBkColor($hDC, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hBrush = _WinAPI_CreateBrushIndirect($BS_HATCHED, 0x00A820, $HS_DIAGCROSS)
Local $hObj = _WinAPI_SelectObject($hDC, $hBrush)
$tRECT = _WinAPI_CreateRect(0, 0, 140, 140)
_WinAPI_OffsetRect($tRECT, 220, 118)
_WinAPI_Ellipse($hDC, $tRECT)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hBrush)
_WinAPI_SetTextColor($hDC, 0xCD0091)
_WinAPI_SetBkMode($hDC, $TRANSPARENT)
Local $hFont = _WinAPI_CreateFont(38, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, 'Arial Black')
$hObj = _WinAPI_SelectObject($hDC, $hFont)
_WinAPI_TextOut($hDC, 30, 185, 'Simple Text')
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hFont)
Local $aPoint2[6][2] = [[0, 129], [55, 75], [75, 0], [95, 75], [150, 129], [75, 108]]
Local $hRgn = _WinAPI_CreatePolygonRgn($aPoint2)
_WinAPI_SetDCBrushColor($hDC, 0x0060C4)
_WinAPI_OffsetRgn($hRgn, 25, 240)
_WinAPI_PaintRgn($hDC, $hRgn)
_WinAPI_DeleteObject($hRgn)
Local $aPoint1[19][2] = [[50, 20], [70, 0], [70, 0], [90, 20], [100, 30], [110, 40], [120, 50], [130, 60], [130, 70], [120, 70], [110, 70], [30, 70], [20, 70], [10, 70], [10, 60], [20, 50], [30, 40], [40, 30], [50, 20]]
_WinAPI_SetDCPenColor($hDC, 0xFF8000)
_WinAPI_OffsetPoints($aPoint1, 219, 25)
_WinAPI_PolyBezier($hDC, $aPoint1)
$hBrush = _WinAPI_CreateBrushIndirect($BS_SOLID, 0xFF8000)
$hObj = _WinAPI_SelectObject($hDC, $hBrush)
_WinAPI_ExtFloodFill($hDC, 70 + 219, 40 + 25, 0xFF8000, 0)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hBrush)
_WinAPI_SetDCPenColor($hDC, 0xFFFFFF)
Local $hPattern = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Pattern.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
; $hPattern = _WinAPI_LoadBitmap(_WinAPI_GetModuleHandle(@SystemDir & '\shell32.dll'), 138)
$hBrush = _WinAPI_CreateBrushIndirect($BS_PATTERN, 0, $hPattern)
$hObj = _WinAPI_SelectObject($hDC, $hBrush)
$tRECT = _WinAPI_CreateRect(0, 0, 140, 90)
_WinAPI_OffsetRect($tRECT, 220, 279)
_WinAPI_RoundRect($hDC, $tRECT, 20, 20)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hPattern)
_WinAPI_DeleteObject($hBrush)

; Merge bitmap
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDev, 400, 400)
$hBrush = _WinAPI_SelectObject($hDC, $hOldBrush)
_WinAPI_DeleteObject($hBrush)
Local $hPen = _WinAPI_SelectObject($hDC, $hOldPen)
_WinAPI_DeleteObject($hPen)
_WinAPI_SelectObject($hDC, $hBitmap)
_WinAPI_DrawBitmap($hDC, 0, 0, $hSource, $MERGECOPY)
_WinAPI_ReleaseDC($hPic, $hDev)
_WinAPI_SelectObject($hDC, $hSv)
_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteDC($hDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
$hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = -3


Function _WinAPI_ExtCreatePen

Function Reference

_WinAPI_ExtCreatePen

Creates a logical cosmetic or geometric pen that has the specified style, width, and brush attributes

#include <WinAPIGdi.au3>
_WinAPI_ExtCreatePen ( $iPenStyle, $iWidth, $iBrushStyle, $iRGB [, $iHatch = 0 [, $aUserStyle = 0 [, $iStart = 0 [, $iEnd = -1]]]] )

Parameters

$iPenStyle | A combination of type, style, end cap, and join attributes. The values from each category are combined by using the bitwise operation. The pen type can be one of the following values. $PS_GEOMETRIC $PS_COSMETIC The pen style can be one of the following values. $PS_SOLID $PS_DASH $PS_DOT $PS_DASHDOT $PS_DASHDOTDOT $PS_NULL $PS_INSIDEFRAME $PS_USERSTYLE $PS_ALTERNATE The end cap is only specified for geometric pens and can be one of the following values. $PS_ENDCAP_ROUND $PS_ENDCAP_SQUARE $PS_ENDCAP_FLAT The join is only specified for geometric pens and can be one of the following values. $PS_JOIN_BEVEL $PS_JOIN_MITER $PS_JOIN_ROUND
$iWidth | The width of the pen. If $PS_GEOMETRIC type is specified, the width is given in logical units, otherwise, the width must be set to 1.
$iBrushStyle | A brush style. This parameter can be one of the $BS_* constants.
$iRGB | The color of a pen, in RGB.
$iHatch | [optional] A hatch style. For more information, see _WinAPI_CreateBrushIndirect().
$aUserStyle | [optional] The array (dash1, space1, dash2, space2, ... dashN, spaceN) that contains the length of the dashes and spaces in a user-defined style. The first value specifies the length of the first dash, the second value specifies the length of the first space, and so on. This parameter is ignored if $PS_USERSTYLE style is not specified. The style count is limited to 16.
$iStart | [optional] The index of array to start filling at.
$iEnd | [optional] The index of array to stop filling at.

Return Value

Success: | Handle to the logical pen.
Failure: | 0.

Remarks

After an application creates a pen by calling _WinAPI_ExtCreatePen(), it can select it into any device context by calling the _WinAPI_SelectObject() function.
When an application no longer requires a specified pen, it should call the _WinAPI_DeleteObject() function to delete the pen.

Related

_WinAPI_DeleteObject, _WinAPI_SelectObject

See Also

Search ExtCreatePen in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 310, 300)
Local $idPic = GUICtrlCreatePic('', 0, 0, 310, 300)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDC = _WinAPI_GetDC($hPic)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 310, 300, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap)

; Draw a lines with a variety of type, style, end cap, and join attributes
Local $hPen = _WinAPI_ExtCreatePen(BitOR($PS_GEOMETRIC, $PS_SOLID, $PS_ENDCAP_ROUND), 5, $BS_SOLID, 0)
Local $hSv = _WinAPI_SelectObject($hMemDC, $hPen)
_WinAPI_DrawLine($hMemDC, 20, 30, 289, 30)
_WinAPI_SelectObject($hMemDC, $hSv)
_WinAPI_DeleteObject($hPen)

$hPen = _WinAPI_ExtCreatePen(BitOR($PS_GEOMETRIC, $PS_DASH, $PS_ENDCAP_ROUND), 5, $BS_SOLID, 0)
$hSv = _WinAPI_SelectObject($hMemDC, $hPen)
_WinAPI_DrawLine($hMemDC, 20, 70, 289, 70)
_WinAPI_SelectObject($hMemDC, $hSv)
_WinAPI_DeleteObject($hPen)

$hPen = _WinAPI_ExtCreatePen(BitOR($PS_GEOMETRIC, $PS_DOT, $PS_ENDCAP_ROUND), 5, $BS_SOLID, 0)
$hSv = _WinAPI_SelectObject($hMemDC, $hPen)
_WinAPI_DrawLine($hMemDC, 20, 110, 289, 110)
_WinAPI_SelectObject($hMemDC, $hSv)
_WinAPI_DeleteObject($hPen)

$hPen = _WinAPI_ExtCreatePen(BitOR($PS_GEOMETRIC, $PS_DASHDOT, $PS_ENDCAP_SQUARE), 5, $BS_SOLID, 0)
$hSv = _WinAPI_SelectObject($hMemDC, $hPen)
_WinAPI_DrawLine($hMemDC, 20, 150, 289, 150)
_WinAPI_SelectObject($hMemDC, $hSv)
_WinAPI_DeleteObject($hPen)

$hPen = _WinAPI_ExtCreatePen(BitOR($PS_GEOMETRIC, $PS_DASHDOTDOT, $PS_ENDCAP_SQUARE), 5, $BS_SOLID, 0)
$hSv = _WinAPI_SelectObject($hMemDC, $hPen)
_WinAPI_DrawLine($hMemDC, 20, 190, 289, 190)
_WinAPI_SelectObject($hMemDC, $hSv)
_WinAPI_DeleteObject($hPen)

Local $aStyle[6] = [1, 7, 1, 7, 1, 25]
$hPen = _WinAPI_ExtCreatePen(BitOR($PS_GEOMETRIC, $PS_USERSTYLE, $PS_ENDCAP_ROUND), 5, $BS_SOLID, 0, 0, $aStyle)
$hSv = _WinAPI_SelectObject($hMemDC, $hPen)
_WinAPI_DrawLine($hMemDC, 20, 230, 289, 230)
_WinAPI_SelectObject($hMemDC, $hSv)
_WinAPI_DeleteObject($hPen)

Local $hPattern = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Pen.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
$hPen = _WinAPI_ExtCreatePen(BitOR($PS_GEOMETRIC, $PS_SOLID, $PS_ENDCAP_ROUND), 5, $BS_PATTERN, 0, $hPattern, $aStyle)
$hSv = _WinAPI_SelectObject($hMemDC, $hPen)
_WinAPI_DrawLine($hMemDC, 20, 270, 289, 270)
_WinAPI_SelectObject($hMemDC, $hSv)
_WinAPI_DeleteObject($hPattern)
_WinAPI_DeleteObject($hPen)

; Release objects
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_GetBrushOrg

Function Reference

_WinAPI_GetBrushOrg

Retrieves the current brush origin for the specified device context

#include <WinAPIGdi.au3>
_WinAPI_GetBrushOrg ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | $tagPOINT structure that contains the brush origin, in device coordinates.
Failure: | Sets the @error flag to non-zero.

See Also

Search GetBrushOrgEx in MSDN Library.


Function _WinAPI_PatBlt

Function Reference

_WinAPI_PatBlt

Paints the specified rectangle using the brush that is currently selected into the specified device context

#include <WinAPIGdi.au3>
_WinAPI_PatBlt ( $hDC, $iX, $iY, $iWidth, $iHeight, $iRop )

Parameters

$hDC | Handle to the device context.
$iX | The x-coordinate, in logical units, of the upper-left corner of the rectangle to be filled.
$iY | The y-coordinate, in logical units, of the upper-left corner of the rectangle to be filled.
$iWidth | The width, in logical units, of the rectangle.
$iHeight | The height, in logical units, of the rectangle.
$iRop | The raster operation code. This code can be one of the following values. $BLACKNESS $DSTINVERT $PATCOPY $PATINVERT $WHITENESS

Return Value

Success: | True
Failure: | False

See Also

Search PatBlt in MSDN Library.


Function _WinAPI_SetBrushOrg

Function Reference

_WinAPI_SetBrushOrg

Sets the brush origin that GDI assigns to the next brush an application selects into the specified device context

#include <WinAPIGdi.au3>
_WinAPI_SetBrushOrg ( $hDC, $iX, $iY )

Parameters

$hDC | Handle to the device context.
$iX | The x-coordinate, in device units, of the new brush origin.
$iY | The y-coordinate, in device units, of the new brush origin.

Return Value

Success: | True
Failure: | False

Remarks

Call _WinAPI_GetExtended() to retrieve a $tagPOINT structure containing the previous brush origin.

Related

_WinAPI_GetExtended

See Also

Search SetBrushOrgEx in MSDN Library.


Function _WinAPI_SetDCBrushColor

Function Reference

_WinAPI_SetDCBrushColor

Sets the current device context (DC) brush color to the specified color value

#include <WinAPIGdi.au3>
_WinAPI_SetDCBrushColor ( $hDC, $iRGB )

Parameters

$hDC | Handle to the device context.
$iRGB | The new brush color, in RGB.

Return Value

Success: | The value that specifies the previous DC brush color, in RGB.
Failure: | (-1).

Remarks

The function returns the previous $DC_BRUSH color, even if the stock brush $DC_BRUSH is not selected in the DC:
however, this will not be used in drawing operations until the stock $DC_BRUSH is selected in the DC.

See Also

Search SetDCBrushColor in MSDN Library.


Function _WinAPI_SetDCPenColor

Function Reference

_WinAPI_SetDCPenColor

Sets the current device context (DC) pen color to the specified color value

#include <WinAPIGdi.au3>
_WinAPI_SetDCPenColor ( $hDC, $iRGB )

Parameters

$hDC | Handle to the device context.
$iRGB | The new pen color, in RGB.

Return Value

Success: | The value that specifies the previous DC pen color, in RGB.
Failure: | (-1).

Remarks

The function returns the previous $DC_PEN color, even if the stock pen $DC_PEN is not selected in the DC;
however, this will not be used in drawing operations until the stock $DC_PEN is selected in the DC.

See Also

Search SetDCPenColor in MSDN Library.


User Defined Functions

Clipping user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIGdi.au3>.

User Defined Function | Description
_WinAPI_ExcludeClipRect | Creates a new clipping region that consists of the existing clipping region minus the specified rectangle
_WinAPI_ExtSelectClipRgn | Combines the specified region with the current clipping region
_WinAPI_GetClipBox | Retrieves the dimensions of the bounding rectangle of the visible area
_WinAPI_GetClipRgn | Retrieves a handle identifying the current application-defined clipping region
_WinAPI_IntersectClipRect | Creates a new clipping region from the intersection of the current clipping region and the specified rectangle
_WinAPI_OffsetClipRgn | Moves the clipping region of a device context by the specified offsets
_WinAPI_PtVisible | Determines whether the specified point is within the clipping region
_WinAPI_RectVisible | Determines whether any part of the specified rectangle lies within the clipping region
_WinAPI_SelectClipPath | Selects the current path as a clipping region, combining the new region with any existing clipping region
_WinAPI_SelectClipRgn | Selects a region as the current clipping region for the specified device context


Function _WinAPI_ExcludeClipRect

Function Reference

_WinAPI_ExcludeClipRect

Creates a new clipping region that consists of the existing clipping region minus the specified rectangle

#include <WinAPIGdi.au3>
_WinAPI_ExcludeClipRect ( $hDC, $tRECT )

Parameters

$hDC | Handle to the device context.
$tRECT | $tagRECT structure that contains the logical coordinates of the specified rectangle.

Return Value

Success: | The value that specifies the new clipping region's complexity; it can be one of the following values. $COMPLEXREGION $NULLREGION $SIMPLEREGION
Failure: | 0.

See Also

Search ExcludeClipRect in MSDN Library.


Function _WinAPI_ExtSelectClipRgn

Function Reference

_WinAPI_ExtSelectClipRgn

Combines the specified region with the current clipping region

#include <WinAPIGdi.au3>
_WinAPI_ExtSelectClipRgn ( $hDC, $hRgn [, $iMode = 5] )

Parameters

$hDC | Handle to the device context.
$hRgn | Handle to the region to be selected. This parameter can only be 0 when the $RGN_COPY mode is specified.
$iMode | [optional] The operation to be performed. It must be one of the following values. $RGN_AND $RGN_COPY (Default) $RGN_DIFF $RGN_OR $RGN_XOR

Return Value

Success: | The value that specifies the new clipping region's complexity; it can be one of the following values. $COMPLEXREGION $NULLREGION $SIMPLEREGION
Failure: | 0.

See Also

Search ExtSelectClipRgn in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GUITab.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPITheme.au3>
#include <WindowsConstants.au3>

Opt('TrayAutoPause', 0)

If Not _WinAPI_DwmIsCompositionEnabled() Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later with enabled Aero theme.')
    Exit
EndIf

Global Const $PRF_CLIENT = 0x04

OnAutoItExitRegister('OnAutoItExit')

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
GUICtrlCreateTab(0, 60, 402, 341, $WS_CLIPCHILDREN)
Global $g_hTab = GUICtrlGetHandle(-1)
GUICtrlCreateTabItem('Tab 1')
GUICtrlCreateButton('Button', 150, 167, 100, 26)
_WinAPI_SetParent(GUICtrlGetHandle(-1), $g_hTab)
GUICtrlCreateTabItem('Tab 2')
GUICtrlCreateEdit('', 14, 34, 372, 292)
_WinAPI_SetParent(GUICtrlGetHandle(-1), $g_hTab)
GUICtrlCreateTabItem('Tab 3')
GUICtrlCreateTabItem('')
GUISetBkColor(0)

; Register Tab window proc
Global $g_hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam')
Local $pDll = DllCallbackGetPtr($g_hDll)
Global $g_hProc = _WinAPI_SetWindowLong($g_hTab, $GWL_WNDPROC, $pDll)

; Create the "sheet of glass" effect for the Tab client area. You must call this function whenever DWM composition is toggled.
_WinAPI_DwmExtendFrameIntoClientArea($hForm, _WinAPI_CreateMargins(2, 2, 82, 2))

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _CreateClipRgn($hWnd)
    Local $tRECT, $hTmp, $iHt
    Local $iCount = _GUICtrlTab_GetItemCount($hWnd)
    Local $iSel = _GUICtrlTab_GetCurSel($hWnd)
    Local $hRgn = _WinAPI_CreateNullRgn()
    For $i = 0 To $iCount - 1
        $tRECT = _GUICtrlTab_GetItemRectEx($hWnd, $i)
        If $i = $iSel Then
            $hTmp = _WinAPI_CreateRectRgn(DllStructGetData($tRECT, 1) - 2, DllStructGetData($tRECT, 2) - 2, DllStructGetData($tRECT, 3) + 2, DllStructGetData($tRECT, 4))
            $iHt = DllStructGetData($tRECT, 4) - DllStructGetData($tRECT, 2) + 2
        Else
            If $i = $iCount - 1 Then
                $hTmp = _WinAPI_CreateRectRgn(DllStructGetData($tRECT, 1), DllStructGetData($tRECT, 2), DllStructGetData($tRECT, 3) - 2, DllStructGetData($tRECT, 4))
            Else
                $hTmp = _WinAPI_CreateRectRgn(DllStructGetData($tRECT, 1), DllStructGetData($tRECT, 2), DllStructGetData($tRECT, 3), DllStructGetData($tRECT, 4))
            EndIf
        EndIf
        _WinAPI_CombineRgn($hRgn, $hRgn, $hTmp, $RGN_OR)
        _WinAPI_DeleteObject($hTmp)
    Next
    $tRECT = _WinAPI_GetClientRect($hWnd)
    $hTmp = _WinAPI_CreateRectRgn(DllStructGetData($tRECT, 1), DllStructGetData($tRECT, 2) + $iHt, DllStructGetData($tRECT, 3) - 2, DllStructGetData($tRECT, 4) - 1)
    _WinAPI_CombineRgn($hRgn, $hRgn, $hTmp, $RGN_OR)
    _WinAPI_DeleteObject($hTmp)
    Return $hRgn
EndFunc   ;==>_CreateClipRgn

Func _WinProc($hWnd, $iMsg, $wParam, $lParam)
    If _WinAPI_IsThemeActive() Then
        Local $hRgn
        Switch $iMsg
            Case $WM_ERASEBKGND
                Local $hPrev = _WinAPI_GetClipRgn($wParam)
                $hRgn = _CreateClipRgn($hWnd)
                _WinAPI_ExtSelectClipRgn($wParam, $hRgn, $RGN_DIFF)
                Local $tRECT = _WinAPI_GetClientRect($hWnd)
                Local $hBrush = _WinAPI_CreateSolidBrush(0)
                _WinAPI_FillRect($wParam, $tRECT, $hBrush)
                _WinAPI_SelectClipRgn($wParam, $hPrev)
                _WinAPI_DeleteObject($hBrush)
                _WinAPI_DeleteObject($hRgn)
                Return 1
            Case $WM_PAINT
                Local $tPAINTSTRUCT
                Local $hDC = _WinAPI_BeginPaint($hWnd, $tPAINTSTRUCT)
                $hRgn = _CreateClipRgn($hWnd)
                _WinAPI_ExtSelectClipRgn($hDC, $hRgn, $RGN_AND)
                _WinAPI_CallWindowProc($g_hProc, $hWnd, $WM_PRINTCLIENT, $hDC, $PRF_CLIENT)
                _WinAPI_DeleteObject($hRgn)
                _WinAPI_EndPaint($hWnd, $tPAINTSTRUCT)
                Return 0
        EndSwitch
    EndIf
    Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_WinProc

Func OnAutoItExit()
    _WinAPI_SetWindowLong($g_hTab, $GWL_WNDPROC, $g_hProc)
    DllCallbackFree($g_hDll)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_GetClipBox

Function Reference

_WinAPI_GetClipBox

Retrieves the dimensions of the bounding rectangle of the visible area

#include <WinAPIGdi.au3>
_WinAPI_GetClipBox ( $hDC, ByRef $tRECT )

Parameters

$hDC | Handle to the device context.
$tRECT | $tagRECT structure that is created by this function, and contains the rectangle dimensions, in logical units.

Return Value

Success: | The value that specifies the region's complexity; it can be one of the following values. $COMPLEXREGION $NULLREGION $SIMPLEREGION
Failure: | 0.

See Also

Search GetClipBox in MSDN Library.


Function _WinAPI_GetClipRgn

Function Reference

_WinAPI_GetClipRgn

Retrieves a handle identifying the current application-defined clipping region

#include <WinAPIGdi.au3>
_WinAPI_GetClipRgn ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | Handle to a copy of the current clipping region.
Failure: | 0.

Remarks

An application-defined clipping region is a clipping region identified by the _WinAPI_SelectClipRgn() function.
It is not a clipping region created when the application calls the _WinAPI_BeginPaint().

Related

_WinAPI_BeginPaint, _WinAPI_SelectClipRgn

See Also

Search GetClipRgn in MSDN Library.


Function _WinAPI_IntersectClipRect

Function Reference

_WinAPI_IntersectClipRect

Creates a new clipping region from the intersection of the current clipping region and the specified rectangle

#include <WinAPIGdi.au3>
_WinAPI_IntersectClipRect ( $hDC, $tRECT )

Parameters

$hDC | Handle to the device context.
$tRECT | $tagRECT structure that contains the logical coordinates of the specified rectangle.

Return Value

Success: | The value that specifies the new clipping region's complexity; it can be one of the following values. $COMPLEXREGION $NULLREGION $SIMPLEREGION
Failure: | 0.

See Also

Search IntersectClipRect in MSDN Library.


Function _WinAPI_OffsetClipRgn

Function Reference

_WinAPI_OffsetClipRgn

Moves the clipping region of a device context by the specified offsets

#include <WinAPIGdi.au3>
_WinAPI_OffsetClipRgn ( $hDC, $iXOffset, $iYOffset )

Parameters

$hDC | Handle to the device context.
$iXOffset | The number of logical units to move left or right.
$iYOffset | The number of logical units to move up or down.

Return Value

Success: | The value that specifies the new clipping region's complexity; it can be one of the following values. $COMPLEXREGION $NULLREGION $SIMPLEREGION
Failure: | 0.

See Also

Search OffsetClipRgn in MSDN Library.


Function _WinAPI_PtVisible

Function Reference

_WinAPI_PtVisible

Determines whether the specified point is within the clipping region

#include <WinAPIGdi.au3>
_WinAPI_PtVisible ( $hDC, $iX, $iY )

Parameters

$hDC | Handle to the device context.
$iX | The x-coordinate, in logical units, of the point.
$iY | The y-coordinate, in logical units, of the point.

Return Value

Success: | 1 - The specified point is within the clipping region. 0 - Otherwise.
Failure: | Sets the @error flag to non-zero.

See Also

Search PtVisible in MSDN Library.


Function _WinAPI_RectVisible

Function Reference

_WinAPI_RectVisible

Determines whether any part of the specified rectangle lies within the clipping region

#include <WinAPIGdi.au3>
_WinAPI_RectVisible ( $hDC, $tRECT )

Parameters

$hDC | Handle to the device context.
$tRECT | $tagRECT structure that contains the logical coordinates of the specified rectangle.

Return Value

Success: | 1, 2 - any portion of the given rectangle lies within the clipping region. 0 - Otherwise.
Failure: | Sets the @error flag to non-zero, @extended flag may contain an error code.

See Also

Search RectVisible in MSDN Library.


Function _WinAPI_SelectClipPath

Function Reference

_WinAPI_SelectClipPath

Selects the current path as a clipping region, combining the new region with any existing clipping region

#include <WinAPIGdi.au3>
_WinAPI_SelectClipPath ( $hDC [, $iMode = 5] )

Parameters

$hDC | Handle to the device context of the path.
$iMode | [optional] The way to use the path. This parameter can be one of the following values. $RGN_AND $RGN_COPY (Default) $RGN_DIFF $RGN_OR $RGN_XOR

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

See Also

Search SelectClipPath in MSDN Library.


Function _WinAPI_SelectClipRgn

Function Reference

_WinAPI_SelectClipRgn

Selects a region as the current clipping region for the specified device context

#include <WinAPIGdi.au3>
_WinAPI_SelectClipRgn ( $hDC, $hRgn )

Parameters

$hDC | Handle to the device context.
$hRgn | Handle to the region to be selected. To remove a device-context's clipping region, set this parameter to 0.

Return Value

Success: | The value that specifies the new clipping region's complexity; it can be one of the following values. $COMPLEXREGION $NULLREGION $SIMPLEREGION
Failure: | 0.

Remarks

Only a copy of the selected region is used. The region itself can be selected for any number of other device
contexts or it can be deleted.

See Also

Search SelectClipRgn in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 281, 281)
Local $idPic = GUICtrlCreatePic('', 0, 0, 281, 281)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDC = _WinAPI_GetDC($hPic)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 281, 281, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap)
Local $hRgn = _WinAPI_CreateEllipticRgn(_WinAPI_CreateRectEx(40, 40, 201, 201))
_WinAPI_SelectClipRgn($hMemDC, $hRgn)
Local $aVertex[3][3] = [[140, -50, 0xFFFF00], [-50, 244, 0x00F0FF], [331, 244, 0xFF00FF]]
_WinAPI_GradientFill($hMemDC, $aVertex)
_WinAPI_DeleteObject($hRgn)
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


User Defined Functions

Color user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIGdi.au3>.

User Defined Function | Description
_WinAPI_ColorAdjustLuma | Changes the luminance of a RGB value
_WinAPI_ColorHLSToRGB | Converts colors from hue-luminance-saturation (HLS) to RGB format
_WinAPI_ColorRGBToHLS | Converts colors from RGB to hue-luminance-saturation (HLS) format
_WinAPI_CreateColorAdjustment | Creates $tagCOLORADJUSTMENT structure specifies the color adjustment
_WinAPI_GetBValue | Retrieves an intensity value for the blue component of a 32-bit RGB value
_WinAPI_GetColorAdjustment | Retrieves the color adjustment for the specified device context (DC)
_WinAPI_GetDeviceGammaRamp | Gets the gamma ramp on direct color display boards that support downloadable gamma ramps in hardware
_WinAPI_GetGValue | Retrieves an intensity value for the green component of a 32-bit RGB value
_WinAPI_GetRValue | Retrieves an intensity value for the red component of a 32-bit RGB value
_WinAPI_GetUDFColorMode | Retrieves the current color mode for WinAPIEx UDF library
_WinAPI_InvertColor | Inverts (negative) the specified color
_WinAPI_RGB | Creates a RGB color value based on red, green, and blue components
_WinAPI_SetColorAdjustment | Sets the color adjustment for a device context (DC)
_WinAPI_SetDeviceGammaRamp | Sets the gamma ramp on direct color display boards that support downloadable gamma ramps in hardware
_WinAPI_SetUDFColorMode | Sets the color mode for the WinAPIEx library
_WinAPI_SwitchColor | Converts a color from BGR to RGB and vice versa


Function _WinAPI_ColorAdjustLuma

Function Reference

_WinAPI_ColorAdjustLuma

Changes the luminance of a RGB value

#include <WinAPIGdi.au3>
_WinAPI_ColorAdjustLuma ( $iRGB, $iPercent [, $bScale = True] )

Parameters

$iRGB | The initial RGB value.
$iPercent | The luminance of the total range, in percent, or absolute luminance.
$bScale | [optional] Specifies how to use the $iPercent parameter, valid values: True - The $iPercent specifies how much to increment or decrement the current luminance, $iPercent can range from -1000 to +1000. False - The $iPercent specifies the absolute luminance, $iPercent can range 0 to 1000. Available luminance values range from 0 to a maximum. If the requested value is negative or exceeds the maximum, the luminance will be set to either zero or the maximum value, respectively. Default is True.

Return Value

Returns the modified RGB value.

See Also

Search ColorAdjustLuma in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

Opt('TrayAutoPause', 0)

; Create GUI
Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 300, 327)
GUISetBkColor(0x808080)
Global $g_idGraphic = GUICtrlCreateGraphic(0, 0, 150, 300)
GUICtrlSetBkColor(-1, 0x808080)
GUICtrlCreateLabel('', 0, 300, 303, 2, $SS_ETCHEDHORZ)
Global $g_idLabel = GUICtrlCreateLabel('0%', 30, 132, 90, 37, $SS_CENTER)
GUICtrlSetFont(-1, 24, 800, 0, 'Arial')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
Global $g_idSlider = GUICtrlCreateSlider(0, 302, 300, 25, BitOR($TBS_BOTH, $TBS_NOTICKS))
Global $g_hSlider = GUICtrlGetHandle(-1)
GUICtrlSetLimit(-1, 50, -50)
GUICtrlSetData(-1, 0)

; Register WM_HSCROLL message for live scrolling and show GUI
GUIRegisterMsg($WM_HSCROLL, 'WM_HSCROLL')
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam

    Local $iPercent
    Switch $hWnd
        Case $g_hForm
            Switch $lParam
                Case $g_hSlider
                    $iPercent = GUICtrlRead($g_idSlider)
                    GUICtrlSetBkColor($g_idGraphic, _WinAPI_ColorAdjustLuma(0x808080, $iPercent))
                    GUICtrlSetData($g_idLabel, $iPercent & '%')
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_HSCROLL


Function _WinAPI_ColorHLSToRGB

Function Reference

_WinAPI_ColorHLSToRGB

Converts colors from hue-luminance-saturation (HLS) to RGB format

#include <WinAPIGdi.au3>
_WinAPI_ColorHLSToRGB ( $iHue, $iLuminance, $iSaturation )

Parameters

$iHue | HLS hue value.
$iLuminance | HLS luminance value.
$iSaturation | HLS saturation value.

Return Value

Returns the RGB value.

See Also

Search ColorHLSToRGB in MSDN Library.

Example

#include <WinAPIGdi.au3>

ConsoleWrite('RGB: 0x' & Hex(_WinAPI_ColorHLSToRGB(20, 120, 240), 6) & @CRLF)


Function _WinAPI_ColorRGBToHLS

Function Reference

_WinAPI_ColorRGBToHLS

Converts colors from RGB to hue-luminance-saturation (HLS) format

#include <WinAPIGdi.au3>
_WinAPI_ColorRGBToHLS ( $iRGB, ByRef $iHue, ByRef $iLuminance, ByRef $iSaturation )

Parameters

$iRGB | RGB color.
$iHue | Returns HLS hue value.
$iLuminance | Returns HLS luminance value.
$iSaturation | Returns HLS saturation value.

Return Value

None.

See Also

Search ColorRGBToHLS in MSDN Library.

Example

#include <WinAPIGdi.au3>

Local $iHue, $iLuminance, $iSaturation
_WinAPI_ColorRGBToHLS(0xFF8000, $iHue, $iLuminance, $iSaturation)

ConsoleWrite('Hue: ' & $iHue & @CRLF)
ConsoleWrite('Sat: ' & $iSaturation & @CRLF)
ConsoleWrite('Lum: ' & $iLuminance & @CRLF)


Function _WinAPI_CreateColorAdjustment

Function Reference

_WinAPI_CreateColorAdjustment

Creates $tagCOLORADJUSTMENT structure specifies the color adjustment

#include <WinAPIGdi.au3>
_WinAPI_CreateColorAdjustment ( [$iFlags = 0 [, $iIlluminant = 0 [, $iGammaR = 10000 [, $iGammaG = 10000 [, $iGammaB = 10000 [, $iBlack = 0 [, $iWhite = 10000 [, $iContrast = 0 [, $iBrightness = 0 [, $iColorfulness = 0 [, $iTint = 0]]]]]]]]]]] )

Parameters

$iFlags | [optional] The flags that specify how the output image should be prepared. This parameter can be 0 or any combination of the following values: $CA_NEGATIVE $CA_LOG_FILTER
$iIlluminant | [optional] The type of standard light source under which the image is viewed. This parameter can be only one of the following values: $ILLUMINANT_DEVICE_DEFAULT (Default) $ILLUMINANT_A $ILLUMINANT_B $ILLUMINANT_C $ILLUMINANT_D50 $ILLUMINANT_D55 $ILLUMINANT_D65 $ILLUMINANT_D75 $ILLUMINANT_F2 $ILLUMINANT_TUNGSTEN $ILLUMINANT_DAYLIGHT $ILLUMINANT_FLUORESCENT $ILLUMINANT_NTSC
$iGammaR | [optional] The n(th) power gamma-correction value for the red primary of the source colors. The value must be in the range from 2500 to 65,000. A value of 10,000 (Default) means no gamma correction.
$iGammaG | [optional] The n(th) power gamma-correction value for the green primary of the source colors. The value must be in the range from 2500 to 65,000. A value of 10,000 (Default) means no gamma correction.
$iGammaB | [optional] The n(th) power gamma-correction value for the blue primary of the source colors. The value must be in the range from 2500 to 65,000. A value of 10,000 (Default) means no gamma correction.
$iBlack | [optional] The black reference for the source colors. Any colors that are darker than this are treated as black. The value must be in the range from 0 to 4000. Default is 0.
$iWhite | [optional] The white reference for the source colors. Any colors that are lighter than this are treated as white. The value must be in the range from 6000 to 10,000. Default is 10,000
$iContrast | [optional] The amount of contrast to be applied to the source object. The value must be in the range from -100 to 100. A value of 0 (Default) means no contrast adjustment.
$iBrightness | [optional] The amount of brightness to be applied to the source object. The value must be in the range from -100 to 100. A value of 0 (Default) means no brightness adjustment.
$iColorfulness | [optional] The amount of colorfulness to be applied to the source object. The value must be in the range from -100 to 100. A value of 0 (Default) means no colorfulness adjustment).
$iTint | [optional] The amount of red or green tint adjustment to be applied to the source object. The value must be in the range from -100 to 100. Positive numbers adjust toward red and negative numbers adjust toward green. A value of 0 (Default) means no tint adjustment.

Return Value

Returns $tagCOLORADJUSTMENT structure containing the color adjustment values.

Example

#include <APIGdiConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GDIPlus.au3>
#include <GUIComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIShPath.au3>
#include <WindowsConstants.au3>

Opt('GUICloseOnESC', 0)
Opt('TrayAutoPause', 0)

Global $g_aDefault[11] = [10000, 10000, 10000, 0, 10000, 0, 0, 0, 0, 0, 0]
Global $g_aAdjust = $g_aDefault

_GDIPlus_Startup()

Local $hObj, $hSrc, $W, $H, $sData
While 1
    $sData = FileOpenDialog('Load Image', @ScriptDir & '\Extras', 'Image Files (*.bmp;*.dib;*.gif;*.jpg;*.tif)|All Files (*.*)', 1 + 2)
    If @error Then Exit

    $hObj = _GDIPlus_ImageLoadFromFile($sData)
    If $hObj Then
        $hSrc = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hObj)
        $W = _GDIPlus_ImageGetWidth($hObj)
        $H = _GDIPlus_ImageGetHeight($hObj)
        _GDIPlus_ImageDispose($hObj)
        If $hSrc Then
            ExitLoop
        EndIf
    EndIf
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to load image.')
WEnd

Local $hForm = GUICreate(_WinAPI_PathStripPath($sData), $W, $H)
GUICtrlCreatePic('', 0, 0, $W, $H)
GUICtrlSetState(-1, $GUI_DISABLE)
Local $hPic = GUICtrlGetHandle(-1)
Global $g_hTool = GUICreate('Adjustments', 303, 484, -1, -1, BitOR($WS_CAPTION, $WS_POPUP), 0, $hForm)
GUICtrlCreateGraphic(0, 0, 303, 436)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlCreateGraphic(0, 436, 303, 1)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetBkColor(-1, 0xDFDFDF)
Global $g_aidSlider[9][6] = [[0, 0, 'Red', 25, 650, 100], [0, 0, 'Green', 25, 650, 100], [0, 0, 'Blue', 25, 650, 100], [0, 0, 'Black', 0, 400, 10], [0, 0, 'White', 600, 1000, 10], [0, 0, 'Contrast', -100, 100, 1], [0, 0, 'Brightness', -100, 100, 1], [0, 0, 'Colorfulness', -100, 100, 1], [0, 0, 'Tint', -100, 100, 1]]
For $i = 0 To 8
    GUICtrlCreateLabel($g_aidSlider[$i][2] & ':', 10, 21 + $i * 31, 60, 14, $SS_RIGHT)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    $g_aidSlider[$i][2] = GUICtrlCreateInput('', 243, 18 + $i * 31, 49, 19, BitOR($ES_CENTER, $ES_READONLY))
    GUICtrlSetFont(-1, 9.3, 400, 0, 'Arial')
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    $g_aidSlider[$i][0] = GUICtrlCreateSlider(71, 19 + $i * 31, 170, 20, BitOR($TBS_BOTH, $TBS_NOTICKS))
    GUICtrlSetLimit(-1, $g_aidSlider[$i][4], $g_aidSlider[$i][3])
    $g_aidSlider[$i][1] = GUICtrlGetHandle(-1)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
Next
GUICtrlCreateLabel('Illuminant:', 10, 310, 60, 14, $SS_RIGHT)
GUICtrlSetBkColor(-1, 0xFFFFFF)
Global $g_idCombo = GUICtrlCreateCombo('', 77, 306, 158, 160, $CBS_DROPDOWNLIST)
Local $aLight = StringSplit('Default|Tungsten lamp|Noon sunlight|NTSC daylight|Normal print|Bond paper print|Standard daylight|Northern daylight|Cool white lamp', '|')
For $i = 1 To $aLight[0]
    _GUICtrlComboBox_AddString(-1, $aLight[$i])
Next
GUICtrlCreateLabel('Filters:', 10, 347, 60, 14, $SS_RIGHT)
GUICtrlSetBkColor(-1, 0xFFFFFF)
Global $g_aidCheck[3]
$g_aidCheck[0] = GUICtrlCreateCheckbox('Negative (invert colors)', 77, 343, 131, 21)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$g_aidCheck[1] = GUICtrlCreateCheckbox('Logarithmic', 77, 368, 76, 21)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$g_aidCheck[2] = GUICtrlCreateCheckbox('Preview', 11, 401, 60, 21)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetState(-1, $GUI_CHECKED)
Local $aidButton[2]
$aidButton[0] = GUICtrlCreateButton('Reset', 136, 448, 75, 25)
$aidButton[1] = GUICtrlCreateButton('Save...', 218, 448, 75, 25)
_Reset()
GUICtrlSetState($g_aidSlider[0][0], $GUI_FOCUS)
GUIRegisterMsg($WM_HSCROLL, 'WM_HSCROLL')
GUISetState(@SW_SHOW, $hForm)
GUISetState(@SW_SHOW, $g_hTool)

While 1
    Switch GUIGetMsg()
        Case 0
            ContinueLoop
        Case $GUI_EVENT_CLOSE
            Exit
        Case $aidButton[0]
            _Reset()
        Case $aidButton[1]
            GUISetState(@SW_DISABLE, $hForm)
            $sData = FileSaveDialog('Save Image', @WorkingDir, 'Image Files (*.bmp;*.dib;*.gif;*.jpg;*.tif)|All Files (*.*)', 2 + 16, @ScriptDir & '\MyImage.jpg', $g_hTool)
            GUICtrlSetState($aidButton[1], $GUI_FOCUS)
            GUISetState(@SW_ENABLE, $hForm)
            If Not $sData Then
                ContinueLoop
            EndIf
            $hObj = _GDIPlus_BitmapCreateFromHBITMAP(_SendMessage($hPic, $STM_GETIMAGE))
            If $hObj Then
                If _GDIPlus_ImageSaveToFile($hObj, $sData) Then
                    $sData = 0
                EndIf
                _GDIPlus_ImageDispose($hObj)
            EndIf
            If $sData Then
                MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to save image.')
            EndIf
        Case $g_aidCheck[0]
            If GUICtrlRead($g_aidCheck[0]) = $GUI_CHECKED Then
                $g_aAdjust[9] = BitOR($g_aAdjust[9], $CA_NEGATIVE)
            Else
                $g_aAdjust[9] = BitAND($g_aAdjust[9], BitNOT($CA_NEGATIVE))
            EndIf
            _Update()
        Case $g_aidCheck[1]
            If GUICtrlRead($g_aidCheck[1]) = $GUI_CHECKED Then
                $g_aAdjust[9] = BitOR($g_aAdjust[9], $CA_LOG_FILTER)
            Else
                $g_aAdjust[9] = BitAND($g_aAdjust[9], BitNOT($CA_LOG_FILTER))
            EndIf
            _Update()
        Case $g_aidCheck[2]
            If GUICtrlRead($g_aidCheck[2]) = $GUI_CHECKED Then
                _SetBitmapAdjust($hPic, $hSrc, $g_aAdjust)
            Else
                _SetBitmapAdjust($hPic, $hSrc)
            EndIf
        Case $g_idCombo
            $sData = _GUICtrlComboBox_GetCurSel($g_idCombo)
            If $g_aAdjust[10] <> $sData Then
                $g_aAdjust[10] = $sData
                _Update()
            EndIf
    EndSwitch
WEnd

Func _Reset()
    $g_aAdjust = $g_aDefault
    For $i = 0 To 8
        GUICtrlSetData($g_aidSlider[$i][0], $g_aAdjust[$i] / $g_aidSlider[$i][5])
        GUICtrlSetData($g_aidSlider[$i][2], $g_aAdjust[$i])
    Next
    _GUICtrlComboBox_SetCurSel($g_idCombo, $g_aAdjust[10])
    If BitAND($g_aAdjust[9], $CA_LOG_FILTER) Then
        GUICtrlSetState($g_aidCheck[1], $GUI_CHECKED)
    Else
        GUICtrlSetState($g_aidCheck[1], $GUI_UNCHECKED)
    EndIf
    If BitAND($g_aAdjust[9], $CA_NEGATIVE) Then
        GUICtrlSetState($g_aidCheck[0], $GUI_CHECKED)
    Else
        GUICtrlSetState($g_aidCheck[0], $GUI_UNCHECKED)
    EndIf
    _Update()
EndFunc   ;==>_Reset

Func _SetBitmapAdjust($hWnd, $hBitmap, $aAdjust = 0)
    If Not IsHWnd($hWnd) Then
        $hWnd = GUICtrlGetHandle($hWnd)
        If Not $hWnd Then
            Return 0
        EndIf
    EndIf

    Local $tAdjust = 0
    If IsArray($aAdjust) Then
        $tAdjust = _WinAPI_CreateColorAdjustment($aAdjust[9], $aAdjust[10], $aAdjust[0], $aAdjust[1], $aAdjust[2], $aAdjust[3], $aAdjust[4], $aAdjust[5], $aAdjust[6], $aAdjust[7], $aAdjust[8])
    EndIf
    $hBitmap = _WinAPI_AdjustBitmap($hBitmap, -1, -1, $HALFTONE, $tAdjust)
    If @error Then
        Return 0
    EndIf
    Local $hPrev = _SendMessage($hWnd, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)
    If $hPrev Then
        _WinAPI_DeleteObject($hPrev)
    EndIf
    $hPrev = _SendMessage($hWnd, $STM_GETIMAGE)
    If $hPrev <> $hBitmap Then
        _WinAPI_DeleteObject($hBitmap)
    EndIf
    Return 1
EndFunc   ;==>_SetBitmapAdjust

Func _Update()
    If GUICtrlRead($g_aidCheck[2]) = $GUI_CHECKED Then
        _SetBitmapAdjust($hPic, $hSrc, $g_aAdjust)
    EndIf
EndFunc   ;==>_Update

Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam

    Switch $hWnd
        Case $g_hTool
            For $i = 0 To 8
                If $g_aidSlider[$i][1] = $lParam Then
                    $g_aAdjust[$i] = $g_aidSlider[$i][5] * GUICtrlRead($g_aidSlider[$i][0])
                    GUICtrlSetData($g_aidSlider[$i][2], $g_aAdjust[$i])
                    _Update()
                    ExitLoop
                EndIf
            Next
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_HSCROLL


Function _WinAPI_GetBValue

Function Reference

_WinAPI_GetBValue

Retrieves an intensity value for the blue component of a 32-bit RGB value

#include <WinAPIGdi.au3>
_WinAPI_GetBValue ( $iRGB )

Parameters

$iRGB The color value, in RGB.

Return Value

Returns the intensity of the blue component of the specified RGB color.

Example

#include <WinAPIGdi.au3>

Local Const $RGB = 0xFF8040

Local $R = _WinAPI_GetRValue($RGB)
Local $G = _WinAPI_GetGValue($RGB)
Local $B = _WinAPI_GetBValue($RGB)

ConsoleWrite('Red:   0x' & Hex($R, 2) & @CRLF)
ConsoleWrite('Green: 0x' & Hex($G, 2) & @CRLF)
ConsoleWrite('Blue:  0x' & Hex($B, 2) & @CRLF)
ConsoleWrite('---------------' & @CRLF)
ConsoleWrite('RGB:   0x' & Hex(_WinAPI_RGB($R, $G, $B), 6) & @CRLF)


Function _WinAPI_GetColorAdjustment

Function Reference

_WinAPI_GetColorAdjustment

Retrieves the color adjustment for the specified device context (DC)

#include <WinAPIGdi.au3>
_WinAPI_GetColorAdjustment ( $hDC )

Parameters

$hDC A handle to the device context.

Return Value

Success: | $tagCOLORADJUSTMENT structure that contains the color adjustment values.
Failure: | Sets the @error flag to non-zero.

See Also

Search GetColorAdjustment in MSDN Library.


Function _WinAPI_GetDeviceGammaRamp

Function Reference

_WinAPI_GetDeviceGammaRamp

Gets the gamma ramp on direct color display boards that support downloadable gamma ramps in hardware

#include <WinAPIGdi.au3>
_WinAPI_GetDeviceGammaRamp ( $hDC, ByRef $aRamp )

Parameters

$hDC | Handle to a device context of the direct color display board in question.
$aRamp | Returns the 2D array ([r1, g1, b1], [r2, g2, b2], ... [r256, g256, b256]) that is created by this function, and where the function place the current gamma ramp of the color display board. Each element in this array is an integer value with a range from 0 to 65535 which is a mapping between RGB values in the frame buffer and digital-analog-converter (DAC) values. (See MSDN for more information)

Return Value

Success: | 1.
Failure: | 0.

Remarks

Direct color display modes do not use color lookup tables and are usually 16, 24, or 32 bit.
Not all direct color video boards support loadable gamma ramps.
The _WinAPI_GetDeviceGammaRamp() succeeds only for devices with drivers that support downloadable gamma ramps in hardware.

See Also

Search GetDeviceGammaRamp in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>

Local $aRamp, $iRgb = 0xFF0000

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 256, 256)
GUICtrlCreatePic('', 0, 0, 256, 256)
Local $hPic = GUICtrlGetHandle(-1)

; Retrieve current gamma ramp and create graph of lookup table (LUT)
Local $hDC = _WinAPI_GetDC(0)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 256, 256, 0)
Local $hSv1 = _WinAPI_SelectObject($hMemDC, $hBitmap)
Local $hPen = _WinAPI_GetStockObject($DC_PEN)
Local $hSv2 = _WinAPI_SelectObject($hMemDC, $hPen)
_WinAPI_SetROP2($hMemDC, $R2_XORPEN)
_WinAPI_GetDeviceGammaRamp($hDC, $aRamp)
_WinAPI_ReleaseDC(0, $hDC)
If IsArray($aRamp) Then
    For $i = 0 To 2
        _WinAPI_SetDCPenColor($hMemDC, BitShift($iRgb, 8 * $i))
        For $j = 0 To 255
            If $j Then
                _WinAPI_LineTo($hMemDC, $j + 1, Round(255 * (1 - $aRamp[$j][$i] / 65280)) - 1)
            Else
                _WinAPI_MoveTo($hMemDC, 0, Round(255 * (1 - $aRamp[$j][$i] / 65280)))
            EndIf
        Next
    Next
EndIf
_WinAPI_SetDCPenColor($hMemDC, 0x404040)
_WinAPI_SetROP2($hMemDC, $R2_MERGEPEN)
For $i = 64 To 192 Step 64
    _WinAPI_DrawLine($hMemDC, $i - 1, 0, $i - 1, 256)
    _WinAPI_DrawLine($hMemDC, 0, $i, 256, $i)
Next
_WinAPI_SelectObject($hMemDC, $hSv1)
_WinAPI_SelectObject($hMemDC, $hSv2)
_WinAPI_DeleteObject($hPen)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

If IsArray($aRamp) Then
    _ArrayDisplay($aRamp, '_WinAPI_GetDeviceGammaRamp')
Else
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Your video board do not support loadable gamma ramps.', 0, $hForm)
EndIf

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_GetGValue

Function Reference

_WinAPI_GetGValue

Retrieves an intensity value for the green component of a 32-bit RGB value

#include <WinAPIGdi.au3>
_WinAPI_GetGValue ( $iRGB )

Parameters

$iRGB The color value, in RGB.

Return Value

Returns the intensity of the green component of the specified RGB color.

Example

#include <WinAPIGdi.au3>

Local Const $RGB = 0xFF8040

Local $R = _WinAPI_GetRValue($RGB)
Local $G = _WinAPI_GetGValue($RGB)
Local $B = _WinAPI_GetBValue($RGB)

ConsoleWrite('Red:   0x' & Hex($R, 2) & @CRLF)
ConsoleWrite('Green: 0x' & Hex($G, 2) & @CRLF)
ConsoleWrite('Blue:  0x' & Hex($B, 2) & @CRLF)
ConsoleWrite('---------------' & @CRLF)
ConsoleWrite('RGB:   0x' & Hex(_WinAPI_RGB($R, $G, $B), 6) & @CRLF)


Function _WinAPI_GetRValue

Function Reference

_WinAPI_GetRValue

Retrieves an intensity value for the red component of a 32-bit RGB value

#include <WinAPIGdi.au3>
_WinAPI_GetRValue ( $iRGB )

Parameters

$iRGB The color value, in RGB.

Return Value

Returns the intensity of the red component of the specified RGB color.

Example

#include <WinAPIGdi.au3>

Local Const $RGB = 0xFF8040

Local $R = _WinAPI_GetRValue($RGB)
Local $G = _WinAPI_GetGValue($RGB)
Local $B = _WinAPI_GetBValue($RGB)

ConsoleWrite('Red:   0x' & Hex($R, 2) & @CRLF)
ConsoleWrite('Green: 0x' & Hex($G, 2) & @CRLF)
ConsoleWrite('Blue:  0x' & Hex($B, 2) & @CRLF)
ConsoleWrite('---------------' & @CRLF)
ConsoleWrite('RGB:   0x' & Hex(_WinAPI_RGB($R, $G, $B), 6) & @CRLF)


Function _WinAPI_GetUDFColorMode

Function Reference

_WinAPI_GetUDFColorMode

Retrieves the current color mode for WinAPIEx UDF library

#include <WinAPIGdi.au3>
_WinAPI_GetUDFColorMode ( )

Return Value

Returns the current UDF color mode ($UDF_*).


Function _WinAPI_InvertColor

Function Reference

_WinAPI_InvertColor

Inverts (negative) the specified color

#include <WinAPIGdi.au3>
_WinAPI_InvertColor ( $iColor )

Parameters

$iColor The color to be inverted. This color can be specified in RGB or BGR format.

Return Value

Returns the inverted color.

Example

#include <WinAPIGdi.au3>

Local $iColor = 0xAADDFF

$iColor = _WinAPI_InvertColor($iColor)
ConsoleWrite('0x' & Hex($iColor, 6) & @CRLF)
$iColor = _WinAPI_InvertColor($iColor)
ConsoleWrite('0x' & Hex($iColor, 6) & @CRLF)


Function _WinAPI_RGB

Function Reference

_WinAPI_RGB

Creates a RGB color value based on red, green, and blue components

#include <WinAPIGdi.au3>
_WinAPI_RGB ( $iRed, $iGreen, $iBlue )

Parameters

$iRed | The intensity of the red color.
$iGreen | The intensity of the green color.
$iBlue | The intensity of the blue color.

Return Value

Returns the resultant RGB color.

Example

#include <WinAPIGdi.au3>

Local Const $RGB = 0xFF8040

Local $R = _WinAPI_GetRValue($RGB)
Local $G = _WinAPI_GetGValue($RGB)
Local $B = _WinAPI_GetBValue($RGB)

ConsoleWrite('Red:   0x' & Hex($R, 2) & @CRLF)
ConsoleWrite('Green: 0x' & Hex($G, 2) & @CRLF)
ConsoleWrite('Blue:  0x' & Hex($B, 2) & @CRLF)
ConsoleWrite('---------------' & @CRLF)
ConsoleWrite('RGB:   0x' & Hex(_WinAPI_RGB($R, $G, $B), 6) & @CRLF)


Function _WinAPI_SetColorAdjustment

Function Reference

_WinAPI_SetColorAdjustment

Sets the color adjustment for a device context (DC)

#include <WinAPIGdi.au3>
_WinAPI_SetColorAdjustment ( $hDC, $tAdjustment )

Parameters

$hDC | A handle to the device context.
$tAdjustment | $tagCOLORADJUSTMENT structure containing the color adjustment values.

Return Value

Success: | True
Failure: | False

Remarks

The color adjustment are used to adjust the input color of the source bitmap for calls to the _WinAPI_StretchBlt()
and _WinAPI_StretchDIBits() functions when $HALFTONE ($STRETCH_HALFTONE) mode is set.

See Also

Search SetColorAdjustment in MSDN Library.


Function _WinAPI_SetDeviceGammaRamp

Function Reference

_WinAPI_SetDeviceGammaRamp

Sets the gamma ramp on direct color display boards that support downloadable gamma ramps in hardware

#include <WinAPIGdi.au3>
_WinAPI_SetDeviceGammaRamp ( $hDC, Const ByRef $aRamp )

Parameters

$hDC | Handle to a device context of the direct color display board in question.
$aRamp | The 2D array ([r1, g1, b1], [r2, g2, b2], ... [r256, g256, b256]) that contains the gamma ramp to be set. Each element in this array is an integer value with a range from 0 to 65535 which is a mapping between RGB values in the frame buffer and digital-analog-converter (DAC) values. The RGB values must be stored in the most significant bits of each WORD to increase DAC independence. (See MSDN for more information)

Return Value

Success: | True.
Failure: | False.

Remarks

Direct color display modes do not use color lookup tables and are usually 16, 24, or 32 bit. Not all direct
color video boards support loadable gamma ramps. The _WinAPI_SetDeviceGammaRamp() succeeds only for devices
with drivers that support downloadable gamma ramps in hardware.

See Also

Search SetDeviceGammaRamp in MSDN Library.


Function _WinAPI_SetUDFColorMode

Function Reference

_WinAPI_SetUDFColorMode

Sets the color mode for the WinAPIEx library

#include <WinAPIGdi.au3>
_WinAPI_SetUDFColorMode ( $iMode )

Parameters

$iMode The color mode. This parameter can be one of the following values.
$UDF_BGR
$UDF_RGB

Return Value

None.

Remarks

The functions of this library, in which passes or which returns the color values, works with the values in
accordance with the color mode that been set by this function. Initial color mode is RGB.


Function _WinAPI_SwitchColor

Function Reference

_WinAPI_SwitchColor

Converts a color from BGR to RGB and vice versa

#include <WinAPIGdi.au3>
_WinAPI_SwitchColor ( $iColor )

Parameters

$iColor The color to conversion.

Return Value

Returns the converted color (RGB or BGR - depends on the $iColor value, BGR > RGB > BGR etc).

Example

#include <WinAPIGdi.au3>

Local $iColor = 0xAADDFF

$iColor = _WinAPI_SwitchColor($iColor)
ConsoleWrite('0x' & Hex($iColor, 6) & @CRLF)
$iColor = _WinAPI_SwitchColor($iColor)
ConsoleWrite('0x' & Hex($iColor, 6) & @CRLF)


User Defined Functions

Coordinate & Transform user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIGdi.au3>.

User Defined Function | Description
_WinAPI_CombineTransform | Concatenates two world-space to page-space transformations
_WinAPI_CreateTransform | Creates $tagXFORM structure specifies a world-space to page-space transformation
_WinAPI_DPtoLP | Converts device coordinates into logical coordinates
_WinAPI_GetCurrentPosition | Retrieves the current position for the specified device context
_WinAPI_GetGraphicsMode | Retrieves the current graphics mode for the specified device context
_WinAPI_GetMapMode | Retrieves the current mapping mode
_WinAPI_GetPosFromRect | Interprets the coordinates of the rectangle as offset and position coordinates
_WinAPI_GetWindowExt | Retrieves the x-extent and y-extent of the window for the specified device context
_WinAPI_GetWindowOrg | Retrieves the x-coordinates and y-coordinates of the window origin for the specified device context
_WinAPI_GetWorldTransform | Retrieves the current world-space to page-space transformation
_WinAPI_LPtoDP | Converts a logical coordinates into device coordinates
_WinAPI_ModifyWorldTransform | Changes the world transformation for a device context using the specified mode
_WinAPI_OffsetPoints | Moves a points from the array by the specified offsets
_WinAPI_OffsetWindowOrg | Modifies the window origin for a device context using the specified horizontal and vertical offsets
_WinAPI_RotatePoints | Rotates a points from the array by the specified angle
_WinAPI_ScaleWindowExt | Modifies the window for a device context using the ratios formed by the specified multiplicands and divisors
_WinAPI_SetGraphicsMode | Sets the graphics mode for the specified device context
_WinAPI_SetMapMode | Sets the mapping mode of the specified device context
_WinAPI_SetWindowExt | Sets the horizontal and vertical extents of the window for a device context by using the specified values
_WinAPI_SetWindowOrg | Specifies which window point maps to the viewport origin (0,0)
_WinAPI_SetWorldTransform | Sets a two-dimensional linear transformation between world space and page space for the specified device context


Function _WinAPI_CombineTransform

Function Reference

_WinAPI_CombineTransform

Concatenates two world-space to page-space transformations

#include <WinAPIGdi.au3>
_WinAPI_CombineTransform ( $tXFORM1, $tXFORM2 )

Parameters

$tXFORM1 | $tagXFORM structure that specifies the first transformation.
$tXFORM2 | $tagXFORM structure that specifies the second transformation.

Return Value

Success: | $tagXFORM structure that contains the combined transformation.
Failure: | Sets the @error flag to non-zero.

Remarks

Applying the combined transformation has the same effect as applying the first transformation and then applying the second transformation.

See Also

Search CombineTransform in MSDN Library.


Function _WinAPI_CreateTransform

Function Reference

_WinAPI_CreateTransform

Creates $tagXFORM structure specifies a world-space to page-space transformation

#include <WinAPIGdi.au3>
_WinAPI_CreateTransform ( [$nM11 = 1 [, $nM12 = 0 [, $nM21 = 0 [, $nM22 = 1 [, $nDX = 0 [, $nDY = 0]]]]]] )

Parameters

$nM11 | [optional] The following. Rotation - Cosine of rotation angle. Scaling - Horizontal scaling component. Shear - Not used. Reflection - Horizontal component.
$nM12 | [optional] The following. Rotation - Sine of the rotation angle. Scaling - Not used. Shear - Horizontal proportionality constant. Reflection - Not used.
$nM21 | [optional] The following. Rotation - Negative sine of the rotation angle. Scaling - Not used. Shear - Vertical proportionality constant. Reflection - Not used.
$nM22 | [optional] The following. Rotation - Cosine of rotation angle. Scaling - Vertical scaling component. Shear - Not used. Reflection - Vertical reflection component.
$nDx | [optional] The horizontal translation component, in logical units. Default is 0.
$nDy | [optional] The vertical translation component, in logical units. Default is 0.

Return Value

Returns $tagXFORM structure that contains the transformation data.

Example

#include <APIGdiConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

Global Const $PI = 4 * ATan(1)

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 340, 340)
Local $idPic = GUICtrlCreatePic('', 0, 0, 320, 320)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDC = _WinAPI_GetDC($hPic)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 340, 340, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap)

; Set advanced graphics mode to be able to set the world transformation
_WinAPI_SetGraphicsMode($hMemDC, $GM_ADVANCED)

; Create transformation matrix for rotate of 5 degrees
Local $nAngle = $PI / 36
Local $iXc = 170
Local $iYc = 170
Local $nM11 = Cos($nAngle)
Local $nM12 = Sin($nAngle)
Local $nM21 = -$nM12
Local $nM22 = $nM11
Local $nDx = $iXc * (1 - Cos($nAngle)) + $iYc * Sin($nAngle)
Local $nDy = $iYc * (1 - Cos($nAngle)) - $iXc * Sin($nAngle)
Local $tXFORM = _WinAPI_CreateTransform($nM11, $nM12, $nM21, $nM22, $nDx, $nDy)

; Draw ellipses with rotation
Local $hBrush = _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($NULL_BRUSH))
Local $hPen = _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetDCPenColor($hMemDC, 0xDD0000)
Local $tRECT = _WinAPI_CreateRect($iXc - 150, $iYc - 40, $iXc + 150, $iYc + 40)
For $i = 0 To 350 Step 5
    _WinAPI_ModifyWorldTransform($hMemDC, $tXFORM, $MWT_LEFTMULTIPLY)
    _WinAPI_Ellipse($hMemDC, $tRECT)
Next

; Release objects
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hBrush)
_WinAPI_SelectObject($hMemDC, $hPen)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_DPtoLP

Function Reference

_WinAPI_DPtoLP

Converts device coordinates into logical coordinates

#include <WinAPIGdi.au3>
_WinAPI_DPtoLP ( $hDC, ByRef $tPOINT [, $iCount = 1] )

Parameters

$hDC | Handle to the device context.
$tPOINT | $tagPOINT structure or structure of points ("long x1;long y1;...long xN;long yN") containing the x- and y-coordinates to be transformed.
$iCount | [optional] The number of points. Default is 1.

Return Value

Success: | True
Failure: | False

Remarks

The _WinAPI_DPtoLP() function fails if the device coordinates exceed 27 bits, or if the converted logical coordinates exceed 32 bits.
In the case of such an overflow, the results for all the points are undefined.

See Also

Search DPtoLP in MSDN Library.


Function _WinAPI_GetCurrentPosition

Function Reference

_WinAPI_GetCurrentPosition

Retrieves the current position for the specified device context

#include <WinAPIGdi.au3>
_WinAPI_GetCurrentPosition ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | $tagPOINT structure that contains the logical coordinates of the current position.
Failure: | Sets the @error flag to non-zero.

See Also

Search GetCurrentPositionEx in MSDN Library.


Function _WinAPI_GetGraphicsMode

Function Reference

_WinAPI_GetGraphicsMode

Retrieves the current graphics mode for the specified device context

#include <WinAPIGdi.au3>
_WinAPI_GetGraphicsMode ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | The current graphics mode ($GM_*).
Failure: | 0.

See Also

Search GetGraphicsMode in MSDN Library.


Function _WinAPI_GetMapMode

Function Reference

_WinAPI_GetMapMode

Retrieves the current mapping mode

#include <WinAPIGdi.au3>
_WinAPI_GetMapMode ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | The value specifies the mapping mode (MM_*).
Failure: | 0.

See Also

Search GetMapMode in MSDN Library.


Function _WinAPI_GetPosFromRect

Function Reference

_WinAPI_GetPosFromRect

Interprets the coordinates of the rectangle as offset and position coordinates

#include <WinAPIGdi.au3>
_WinAPI_GetPosFromRect ( $tRECT )

Parameters

$tRECT $tagRECT structure that contains the logical coordinates of the rectangle.

Return Value

Success: | The array containing the following information: [0] - The x-coordinate of the upper-left corner of the rectangle. [1] - The y-coordinate of the upper-left corner of the rectangle. [2] - The width of the rectangle. [3] - The height of the rectangle.
Failure: | Sets the @error flag to non-zero.

Remarks

This function is inverse to the _WinAPI_CreateRectEx().

Related

_WinAPI_CreateRectEx

Example

#include <WinAPIGdi.au3>

Local $aPos = _WinAPI_GetPosFromRect(_WinAPI_CreateRectEx(10, 10, 100, 100))

ConsoleWrite('Left:   ' & $aPos[0] & @CRLF)
ConsoleWrite('Top:    ' & $aPos[1] & @CRLF)
ConsoleWrite('Width:  ' & $aPos[2] & @CRLF)
ConsoleWrite('Height: ' & $aPos[3] & @CRLF)


Function _WinAPI_GetWindowExt

Function Reference

_WinAPI_GetWindowExt

Retrieves the x-extent and y-extent of the window for the specified device context

#include <WinAPIGdi.au3>
_WinAPI_GetWindowExt ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | $tagSIZE structure that contains the x- and y-extents in page-space units, that is, logical units.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetWindowExtEx in MSDN Library.


Function _WinAPI_GetWindowOrg

Function Reference

_WinAPI_GetWindowOrg

Retrieves the x-coordinates and y-coordinates of the window origin for the specified device context

#include <WinAPIGdi.au3>
_WinAPI_GetWindowOrg ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | $tagPOINT structure that contains the coordinates, in logical units, of the window origin.
Failure: | Sets the @error flag to non-zero.

See Also

Search GetWindowOrgEx in MSDN Library.


Function _WinAPI_GetWorldTransform

Function Reference

_WinAPI_GetWorldTransform

Retrieves the current world-space to page-space transformation

#include <WinAPIGdi.au3>
_WinAPI_GetWorldTransform ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | $tagXFORM structure that contains the current world-space to page-space transformation.
Failure: | Sets the @error flag to non-zero.

Remarks

The precision of the transformation may be altered if an application calls the _WinAPI_ModifyWorldTransform()
prior to calling _WinAPI_GetWorldTransform(). This is because the internal format for storing transformation
values uses a higher precision than a FLOAT value.

Related

_WinAPI_ModifyWorldTransform

See Also

Search GetWorldTransform in MSDN Library.


Function _WinAPI_LPtoDP

Function Reference

_WinAPI_LPtoDP

Converts a logical coordinates into device coordinates

#include <WinAPIGdi.au3>
_WinAPI_LPtoDP ( $hDC, ByRef $tPOINT [, $iCount = 1] )

Parameters

$hDC | Handle to the device context.
$tPOINT | $tagPOINT structure or structure of points ("long x1;long y1;...long xN;long yN") containing the x- and y-coordinates to be transformed.
$iCount | [optional] The number of points. Default is 1.

Return Value

Success: | True
Failure: | False

Remarks

The _WinAPI_DPtoLP() function fails if the device coordinates exceed 27 bits, or if the converted logical coordinates
exceed 32 bits. In the case of such an overflow, the results for all the points are undefined.

Related

_WinAPI_DPtoLP

See Also

Search LPtoDP in MSDN Library.


Function _WinAPI_ModifyWorldTransform

Function Reference

_WinAPI_ModifyWorldTransform

Changes the world transformation for a device context using the specified mode

#include <WinAPIGdi.au3>
_WinAPI_ModifyWorldTransform ( $hDC, $tXFORM, $iMode )

Parameters

$hDC | Handle to the device context.
$tXFORM | $tagXFORM structure used to modify the world transformation for the given device context.
$iMode | Specifies how the transformation data modifies the current world transformation. This parameter must be one of the following values. $MWT_IDENTITY $MWT_LEFTMULTIPLY $MWT_RIGHTMULTIPLY

Return Value

Success: | True
Failure: | False

Remarks

The _WinAPI_ModifyWorldTransform() will fail unless graphics mode for the specified device context has been set
to $GM_ADVANCED by previously calling the _WinAPI_SetGraphicsMode(). Likewise, it will not be possible to reset
the graphics mode for the device context to the default $GM_COMPATIBLE mode, unless world transform has first
been reset to the default identity transform by calling _WinAPI_SetWorldTransform().

Related

_WinAPI_SetWorldTransform

See Also

Search ModifyWorldTransform in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

Global Const $PI = 4 * ATan(1)

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 340, 340)
Local $idPic = GUICtrlCreatePic('', 0, 0, 320, 320)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDC = _WinAPI_GetDC($hPic)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 340, 340, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap)

; Set advanced graphics mode to be able to set the world transformation
_WinAPI_SetGraphicsMode($hMemDC, $GM_ADVANCED)

; Create transformation matrix for rotate of 5 degrees
Local $nAngle = $PI / 36
Local $iXc = 170
Local $iYc = 170
Local $nM11 = Cos($nAngle)
Local $nM12 = Sin($nAngle)
Local $nM21 = -$nM12
Local $nM22 = $nM11
Local $nDx = $iXc * (1 - Cos($nAngle)) + $iYc * Sin($nAngle)
Local $nDy = $iYc * (1 - Cos($nAngle)) - $iXc * Sin($nAngle)
Local $tXFORM = _WinAPI_CreateTransform($nM11, $nM12, $nM21, $nM22, $nDx, $nDy)

; Draw ellipses with rotation
Local $hBrush = _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($NULL_BRUSH))
Local $hPen = _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetDCPenColor($hMemDC, 0xDD0000)
Local $tRECT = _WinAPI_CreateRect($iXc - 150, $iYc - 40, $iXc + 150, $iYc + 40)
For $i = 0 To 350 Step 5
    _WinAPI_ModifyWorldTransform($hMemDC, $tXFORM, $MWT_LEFTMULTIPLY)
    _WinAPI_Ellipse($hMemDC, $tRECT)
Next

; Release objects
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hBrush)
_WinAPI_SelectObject($hMemDC, $hPen)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_OffsetPoints

Function Reference

_WinAPI_OffsetPoints

Moves a points from the array by the specified offsets

#include <WinAPIGdi.au3>
_WinAPI_OffsetPoints ( ByRef $aPoint, $iXOffset, $iYOffset [, $iStart = 0 [, $iEnd = -1]] )

Parameters

$aPoint | The 2D array ([x1, y1, ...], [x2, y2, ...], ... [xN, yN, ...]). Every first two elements from this array specifies a point to be move. Other array elements (if any) do not change.
$iXOffset | The number of logical units to move left or right.
$iYOffset | The number of logical units to move up or down.
$iStart | [optional] The index of array to start moving at.
$iEnd | [optional] The index of array to stop moving at.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Example

#include <APIGdiConstants.au3>
#include <FontConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idPic = GUICtrlCreatePic('', 0, 0, 400, 400)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDev = _WinAPI_GetDC($hPic)
Local $hDC = _WinAPI_CreateCompatibleDC($hDev)
Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, 400, 400, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hSv = _WinAPI_SelectObject($hDC, $hSource)

; Draw objects
Local $hOldBrush = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hOldPen = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetDCBrushColor($hDC, 0x990404)
_WinAPI_SetDCPenColor($hDC, 0x990404)
Local $tRECT = _WinAPI_CreateRect(0, 0, 100, 100)
_WinAPI_OffsetRect($tRECT, 30, 30)
_WinAPI_Rectangle($hDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 20, 20)
_WinAPI_InvertRect($hDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 20, 20)
_WinAPI_InvertRect($hDC, $tRECT)
_WinAPI_SetDCPenColor($hDC, 0x00A820)
_WinAPI_SetBkColor($hDC, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hBrush = _WinAPI_CreateBrushIndirect($BS_HATCHED, 0x00A820, $HS_DIAGCROSS)
Local $hObj = _WinAPI_SelectObject($hDC, $hBrush)
$tRECT = _WinAPI_CreateRect(0, 0, 140, 140)
_WinAPI_OffsetRect($tRECT, 220, 118)
_WinAPI_Ellipse($hDC, $tRECT)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hBrush)
_WinAPI_SetTextColor($hDC, 0xCD0091)
_WinAPI_SetBkMode($hDC, $TRANSPARENT)
Local $hFont = _WinAPI_CreateFont(38, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, 'Arial Black')
$hObj = _WinAPI_SelectObject($hDC, $hFont)
_WinAPI_TextOut($hDC, 30, 185, 'Simple Text')
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hFont)
Local $aPoint2[6][2] = [[0, 129], [55, 75], [75, 0], [95, 75], [150, 129], [75, 108]]
Local $hRgn = _WinAPI_CreatePolygonRgn($aPoint2)
_WinAPI_SetDCBrushColor($hDC, 0x0060C4)
_WinAPI_OffsetRgn($hRgn, 25, 240)
_WinAPI_PaintRgn($hDC, $hRgn)
_WinAPI_DeleteObject($hRgn)
Local $aPoint1[19][2] = [[50, 20], [70, 0], [70, 0], [90, 20], [100, 30], [110, 40], [120, 50], [130, 60], [130, 70], [120, 70], [110, 70], [30, 70], [20, 70], [10, 70], [10, 60], [20, 50], [30, 40], [40, 30], [50, 20]]
_WinAPI_SetDCPenColor($hDC, 0xFF8000)
_WinAPI_OffsetPoints($aPoint1, 219, 25)
_WinAPI_PolyBezier($hDC, $aPoint1)
$hBrush = _WinAPI_CreateBrushIndirect($BS_SOLID, 0xFF8000)
$hObj = _WinAPI_SelectObject($hDC, $hBrush)
_WinAPI_ExtFloodFill($hDC, 70 + 219, 40 + 25, 0xFF8000, 0)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hBrush)
_WinAPI_SetDCPenColor($hDC, 0xFFFFFF)
Local $hPattern = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Pattern.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
; $hPattern = _WinAPI_LoadBitmap(_WinAPI_GetModuleHandle(@SystemDir & '\shell32.dll'), 138)
$hBrush = _WinAPI_CreateBrushIndirect($BS_PATTERN, 0, $hPattern)
$hObj = _WinAPI_SelectObject($hDC, $hBrush)
$tRECT = _WinAPI_CreateRect(0, 0, 140, 90)
_WinAPI_OffsetRect($tRECT, 220, 279)
_WinAPI_RoundRect($hDC, $tRECT, 20, 20)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hPattern)
_WinAPI_DeleteObject($hBrush)

; Merge bitmap
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDev, 400, 400)
$hBrush = _WinAPI_SelectObject($hDC, $hOldBrush)
_WinAPI_DeleteObject($hBrush)
Local $hPen = _WinAPI_SelectObject($hDC, $hOldPen)
_WinAPI_DeleteObject($hPen)
_WinAPI_SelectObject($hDC, $hBitmap)
_WinAPI_DrawBitmap($hDC, 0, 0, $hSource, $MERGECOPY)
_WinAPI_ReleaseDC($hPic, $hDev)
_WinAPI_SelectObject($hDC, $hSv)
_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteDC($hDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
$hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = -3


Function _WinAPI_OffsetWindowOrg

Function Reference

_WinAPI_OffsetWindowOrg

Modifies the window origin for a device context using the specified horizontal and vertical offsets

#include <WinAPIGdi.au3>
_WinAPI_OffsetWindowOrg ( $hDC, $iXOffset, $iYOffset )

Parameters

$hDC | Handle to the device context.
$iXOffset | The horizontal offset, in logical units.
$iYOffset | The vertical offset, in logical units.

Return Value

Success: | True
Failure: | False

Remarks

Call _WinAPI_GetExtended() to retrieve a $tagPOINT structure containing the previous window origins.

Related

_WinAPI_GetExtended

See Also

Search OffsetWindowOrgEx in MSDN Library.


Function _WinAPI_RotatePoints

Function Reference

_WinAPI_RotatePoints

Rotates a points from the array by the specified angle

#include <WinAPIGdi.au3>
_WinAPI_RotatePoints ( ByRef $aPoint, $iXC, $iYC, $fAngle [, $iStart = 0 [, $iEnd = -1]] )

Parameters

$aPoint | The 2D array ([x1, y1, ...], [x2, y2, ...], ... [xN, yN, ...]). Every first two elements from this array specifies a point to be rotate. Other array elements (if any) do not change.
$iXC | The x-coordinates of the point on which there is a rotation, in logical units.
$iYC | The y-coordinates of the point on which there is a rotation, in logical units.
$fAngle | The angle to rotate, in degree.
$iStart | [optional] The index of array to start rotating at.
$iEnd | [optional] The index of array to stop rotating at.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

This function does not round a coordinate values after transformation, it can be a float type.

Example

#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

Opt('TrayAutoPause', 0)

; Load image
Global $g_hBitmap = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Compass.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Local $tSIZE = _WinAPI_GetBitmapDimension($g_hBitmap)
Local $W = DllStructGetData($tSIZE, 'X')
Local $H = DllStructGetData($tSIZE, 'Y')

; Create GUI
Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), $W, $H + 26)
Global $g_idPic = GUICtrlCreatePic('', 0, 0, $W, $H)
GUICtrlCreateGraphic(0, $H, $W, 1)
GUICtrlSetBkColor(-1, 0xDFDFDF)
Global $g_idSlider = GUICtrlCreateSlider(0, $H + 1, $W, 25, BitOR($TBS_BOTH, $TBS_NOTICKS))
Global $g_hSlider = GUICtrlGetHandle(-1)
GUICtrlSetLimit(-1, 360, 0)
GUICtrlSetData(-1, 0)

; Set bitmap to control with rotate
_SetBitmapRotate($g_idPic, $g_hBitmap, 0)

; Register WM_HSCROLL message for live scrolling and show GUI
GUIRegisterMsg($WM_HSCROLL, 'WM_HSCROLL')
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _SetBitmapRotate($hWnd, $hBitmap, $iAngle)
    If Not IsHWnd($hWnd) Then
        $hWnd = GUICtrlGetHandle($hWnd)
        If Not $hWnd Then
            Return 0
        EndIf
    EndIf

    Local $aW[2], $aH[2]
    Local $aPoint[3][2]
    Local $tRECT = _WinAPI_GetClientRect($hWnd)
    $aW[0] = DllStructGetData($tRECT, 3) - DllStructGetData($tRECT, 1)
    $aH[0] = DllStructGetData($tRECT, 4) - DllStructGetData($tRECT, 2)
    Local $tSIZE = _WinAPI_GetBitmapDimension($g_hBitmap)
    $aW[1] = DllStructGetData($tSIZE, 1)
    $aH[1] = DllStructGetData($tSIZE, 2)
    $aPoint[0][0] = ($aW[0] - $aW[1]) / 2
    $aPoint[0][1] = ($aH[0] - $aH[1]) / 2
    $aPoint[1][0] = $aPoint[0][0] + $aW[1]
    $aPoint[1][1] = $aPoint[0][1]
    $aPoint[2][0] = $aPoint[0][0]
    $aPoint[2][1] = $aPoint[0][1] + $aH[1]
    Local $hDC = _WinAPI_GetDC($hWnd)
    Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
    Local $hMask = _WinAPI_CreateBitmap($aW[0], $aH[0], 1, 1)
    Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hMask)
    Local $hBrush = _WinAPI_SelectObject($hDestDC, _WinAPI_GetStockObject($DC_BRUSH))
    Local $hPen = _WinAPI_SelectObject($hDestDC, _WinAPI_GetStockObject($DC_PEN))
    _WinAPI_SetDCBrushColor($hDestDC, 0xFFFFFF)
    _WinAPI_SetDCPenColor($hDestDC, 0xFFFFFF)
    _WinAPI_Ellipse($hDestDC, _WinAPI_CreateRectEx($aPoint[0][0] + 43, $aPoint[0][1] + 43, $aPoint[1][0] - 86, $aPoint[2][1] - 86))
    Local $hBmp = _WinAPI_CreateCompatibleBitmapEx($hDC, $aW[0], $aH[0], 0xFFFFFF)
    _WinAPI_SelectObject($hDestDC, $hBrush)
    _WinAPI_SelectObject($hDestDC, $hPen)
    _WinAPI_SelectObject($hDestDC, $hBmp)
    Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC)
    Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBitmap)
    _WinAPI_RotatePoints($aPoint, $aW[0] / 2, $aH[0] / 2, $iAngle)
    _WinAPI_PlgBlt($hDestDC, $aPoint, $hSrcDC, 0, 0, $aW[1], $aH[1])
    _WinAPI_RotatePoints($aPoint, $aW[0] / 2, $aH[0] / 2, -2 * $iAngle)
    _WinAPI_PlgBlt($hDestDC, $aPoint, $hSrcDC, 0, 0, $aW[1], $aH[1], $hMask)
    _WinAPI_SelectObject($hDestDC, $hDestSv)
    _WinAPI_DeleteDC($hDestDC)
    _WinAPI_SelectObject($hSrcDC, $hSrcSv)
    _WinAPI_DeleteDC($hSrcDC)
    _WinAPI_DeleteObject($hMask)
    _WinAPI_ReleaseDC($hWnd, $hDC)
    Local $hObj = _SendMessage($hWnd, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp)
    If $hObj Then
        _WinAPI_DeleteObject($hObj)
    EndIf
    $hObj = _SendMessage($hWnd, $STM_GETIMAGE)
    If $hObj <> $hBmp Then
        _WinAPI_DeleteObject($hBmp)
    EndIf
    Return 1
EndFunc   ;==>_SetBitmapRotate

Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam

    Switch $hWnd
        Case $g_hForm
            Switch $lParam
                Case $g_hSlider
                    _SetBitmapRotate($g_idPic, $g_hBitmap, GUICtrlRead($g_idSlider))
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_HSCROLL


Function _WinAPI_ScaleWindowExt

Function Reference

_WinAPI_ScaleWindowExt

Modifies the window for a device context using the ratios formed by the specified multiplicands and divisors

#include <WinAPIGdi.au3>
_WinAPI_ScaleWindowExt ( $hDC, $iXNum, $iXDenom, $iYNum, $iYDenom )

Parameters

$hDC | Handle to the device context.
$iXNum | The amount by which to multiply the current horizontal extent.
$iXDenom | The amount by which to divide the current horizontal extent.
$iYNum | The amount by which to divide the current vertical extent.
$iYDenom | The amount by which to divide the current vertical extent.

Return Value

Success: | True
Failure: | False

Remarks

Call _WinAPI_GetExtended() to retrieve a $tagSIZE structure containing the previous window extents.

Related

_WinAPI_GetExtended

See Also

Search ScaleWindowExtEx in MSDN Library.


Function _WinAPI_SetGraphicsMode

Function Reference

_WinAPI_SetGraphicsMode

Sets the graphics mode for the specified device context

#include <WinAPIGdi.au3>
_WinAPI_SetGraphicsMode ( $hDC, $iMode )

Parameters

$hDC | Handle to the device context.
$iMode | The graphics mode. This parameter can be one of the following values. $GM_COMPATIBLE $GM_ADVANCED

Return Value

Success: | The previous graphics mode.
Failure: | 0.

See Also

Search SetGraphicsMode in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

Global Const $PI = 4 * ATan(1)

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 340, 340)
Local $idPic = GUICtrlCreatePic('', 0, 0, 320, 320)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDC = _WinAPI_GetDC($hPic)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 340, 340, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap)

; Set advanced graphics mode to be able to set the world transformation
_WinAPI_SetGraphicsMode($hMemDC, $GM_ADVANCED)

; Create transformation matrix for rotate of 5 degrees
Local $nAngle = $PI / 36
Local $iXc = 170
Local $iYc = 170
Local $nM11 = Cos($nAngle)
Local $nM12 = Sin($nAngle)
Local $nM21 = -$nM12
Local $nM22 = $nM11
Local $nDx = $iXc * (1 - Cos($nAngle)) + $iYc * Sin($nAngle)
Local $nDy = $iYc * (1 - Cos($nAngle)) - $iXc * Sin($nAngle)
Local $tXFORM = _WinAPI_CreateTransform($nM11, $nM12, $nM21, $nM22, $nDx, $nDy)

; Draw ellipses with rotation
Local $hBrush = _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($NULL_BRUSH))
Local $hPen = _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetDCPenColor($hMemDC, 0xDD0000)
Local $tRECT = _WinAPI_CreateRect($iXc - 150, $iYc - 40, $iXc + 150, $iYc + 40)
For $i = 0 To 350 Step 5
    _WinAPI_ModifyWorldTransform($hMemDC, $tXFORM, $MWT_LEFTMULTIPLY)
    _WinAPI_Ellipse($hMemDC, $tRECT)
Next

; Release objects
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hBrush)
_WinAPI_SelectObject($hMemDC, $hPen)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_SetMapMode

Function Reference

_WinAPI_SetMapMode

Sets the mapping mode of the specified device context

#include <WinAPIGdi.au3>
_WinAPI_SetMapMode ( $hDC, $iMode )

Parameters

$hDC | Handle to the device context.
$iMode | The new mapping mode. This parameter can be one of the following values. $MM_ANISOTROPIC $MM_HIENGLISH $MM_HIMETRIC $MM_ISOTROPIC $MM_LOENGLISH $MM_LOMETRIC $MM_TEXT $MM_TWIPS

Return Value

Success: | The previous mapping mode.
Failure: | 0.

See Also

Search SetMapMode in MSDN Library.


Function _WinAPI_SetWindowExt

Function Reference

_WinAPI_SetWindowExt

Sets the horizontal and vertical extents of the window for a device context by using the specified values

#include <WinAPIGdi.au3>
_WinAPI_SetWindowExt ( $hDC, $iXExtent, $iYExtent )

Parameters

$hDC | Handle to the device context.
$iXExtent | The window's horizontal extent in logical units.
$iYExtent | The window's vertical extent in logical units.

Return Value

Success: | True
Failure: | False

Remarks

The _WinAPI_SetWindowExt() works only if $MM_ANISOTROPIC or $MM_ISOTROPIC mapping modes are set, otherwise,
calls to this function are ignored.

Call _WinAPI_GetExtended() to retrieve a $tagSIZE structure containing the previous window extents.

Related

_WinAPI_GetExtended

See Also

Search SetWindowExtEx in MSDN Library.


Function _WinAPI_SetWindowOrg

Function Reference

_WinAPI_SetWindowOrg

Specifies which window point maps to the viewport origin (0,0)

#include <WinAPIGdi.au3>
_WinAPI_SetWindowOrg ( $hDC, $iX, $iY )

Parameters

$hDC | Handle to the device context.
$iX | The x-coordinate, in logical units, of the new window origin.
$iY | The y-coordinate, in logical units, of the new window origin.

Return Value

Success: | True
Failure: | False

Remarks

Call _WinAPI_GetExtended() to retrieve a $tagPOINT structure containing the previous window origins.

Related

_WinAPI_GetExtended

See Also

Search SetWindowOrgEx in MSDN Library.


Function _WinAPI_SetWorldTransform

Function Reference

_WinAPI_SetWorldTransform

Sets a two-dimensional linear transformation between world space and page space for the specified device context

#include <WinAPIGdi.au3>
_WinAPI_SetWorldTransform ( $hDC, $tXFORM )

Parameters

$hDC | Handle to the device context.
$tXFORM | $tagXFORM structure that contains the transformation data.

Return Value

Success: | True
Failure: | False

Remarks

The _WinAPI_SetWorldTransform() will fail unless the graphics mode for the given device context has been set
to $GM_ADVANCED by previously calling the _WinAPI_SetGraphicsMode(). Likewise, it will not be possible to reset
the graphics mode for the device context to the default $GM_COMPATIBLE mode, unless the world transformation
has first been reset to the default identity transformation by calling _WinAPI_SetWorldTransform().

For any coordinates (x, y) in world space, the transformed coordinates in page space (x', y') can be
determined by the following algorithm:
x' = x * eM11 + y * eM21 + eDx
y' = x * eM12 + y * eM22 + eDy

Related

_WinAPI_SetGraphicsMode

See Also

Search SetWorldTransform in MSDN Library.


User Defined Functions

Desktop Window Manager user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIGdi.au3>.

User Defined Function | Description
_WinAPI_DwmDefWindowProc | Default window procedure for Desktop Window Manager (DWM) hit testing within the non-client area
_WinAPI_DwmEnableBlurBehindWindow | Enables the blur effect on a specified window
_WinAPI_DwmEnableComposition | Enables or disables Desktop Window Manager (DWM) composition
_WinAPI_DwmExtendFrameIntoClientArea | Extends the window frame behind the client area
_WinAPI_DwmGetColorizationColor | Retrieves the current color used for Desktop Window Manager (DWM) glass composition
_WinAPI_DwmGetColorizationParameters | Retrieves the colorization parameters used for Desktop Window Manager (DWM)
_WinAPI_DwmGetWindowAttribute | Retrieves the current value of a specified attribute applied to the window
_WinAPI_DwmInvalidateIconicBitmaps | Indicates that all previously provided iconic bitmaps from a window, both thumbnails and peek representations, should be refreshed
_WinAPI_DwmIsCompositionEnabled | Determines whether Desktop Window Manager (DWM) composition is enabled
_WinAPI_DwmQueryThumbnailSourceSize | Returns the source size of the Desktop Window Manager (DWM) thumbnail
_WinAPI_DwmRegisterThumbnail | Creates a Desktop Window Manager (DWM) thumbnail relationship between the destination and source windows
_WinAPI_DwmSetColorizationParameters | Sets the colorization parameters for Desktop Window Manager (DWM)
_WinAPI_DwmSetIconicLivePreviewBitmap | Sets a static, iconic bitmap to display a live preview (also known as a Peek preview) of a window or tab
_WinAPI_DwmSetIconicThumbnail | Sets a static, iconic bitmap on a window or tab to use as a thumbnail representation
_WinAPI_DwmSetWindowAttribute | Sets the value of the specified attributes for non-client rendering to apply to the window
_WinAPI_DwmUnregisterThumbnail | Removes a Desktop Window Manager (DWM) thumbnail relationship
_WinAPI_DwmUpdateThumbnailProperties | Specifies Desktop Window Manager (DWM) thumbnail properties


Function _WinAPI_DwmDefWindowProc

Function Reference

_WinAPI_DwmDefWindowProc

Default window procedure for Desktop Window Manager (DWM) hit testing within the non-client area

#include <WinAPIGdi.au3>
_WinAPI_DwmDefWindowProc ( $hWnd, $iMsg, $wParam, $lParam )

Parameters

$hWnd | A handle to the window procedure that received the message.
$iMsg | The message.
$wParam | Additional message-specific information. The content of this parameter depends on the message.
$lParam | Additional message-specific information. The content of this parameter depends on the message.

Return Value

Success: | The result of the hit test.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

When creating custom frames that include the standard caption buttons, WM_NCHITTEST and other non-client hit test messages should first be passed to _WinAPI_DwmDefWindowProc().
This enables the DWM to provide hit testing for the captions buttons.
If _WinAPI_DwmDefWindowProc() does not handle the non-client hit test messages, further processing of these messages might be neccessary.

This function requires Windows Vista or later.

See Also

Search DwmDefWindowProc in MSDN Library.


Function _WinAPI_DwmEnableBlurBehindWindow

Function Reference

_WinAPI_DwmEnableBlurBehindWindow

Enables the blur effect on a specified window

#include <WinAPIGdi.au3>
_WinAPI_DwmEnableBlurBehindWindow ( $hWnd [, $bEnable = True [, $bTransition = False [, $hRgn = 0]]] )

Parameters

$hWnd | Handle to the window on which the blur behind data is applied.
$bEnable | [optional] Specifies whether register or unregister the window handle to DWM blur behind, valid values: True - Register (Default). False - Unregister.
$bTransition | [optional] Specifies whether colorize transition to match the maximized windows, valid values: True - The window's should be colorized. False - Otherwise (Default).
$hRgn | [optional] The region within the client area to apply the blur behind. A value of zero (Default) will apply the blur behind the entire client area.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

The alpha values in the window are honored and the rendering atop the blur will use these alpha values.
It is the application's responsibility for ensuring that the alpha values of all pixels in the window are correct.
Some Windows Graphics Device Interface (GDI) operations do not preserve alpha values, so care must be taken when presenting child windows because the alpha values they contribute are unpredictable.

This function must be called whenever Desktop Window Manager (DWM) composition is toggled.
Handle the WM_DWMCOMPOSITIONCHANGED message for composition change notification.

This function requires Windows Vista or later.

See Also

Search DwmEnableBlurBehindWindow in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>

If Not _WinAPI_DwmIsCompositionEnabled() Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later with enabled Aero theme.')
    Exit
EndIf

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)

GUISetBkColor(0)

; Create the "sheet of glass" effect for the specified region. You must call this function whenever DWM composition is toggled.
_WinAPI_DwmGetColorizationColor()
Local $hRgn = _WinAPI_CreateEllipticRgn(_WinAPI_CreateRectEx(50, 50, 300, 300))
_WinAPI_DwmEnableBlurBehindWindow($hForm, 1, 0, $hRgn)
If $hRgn Then
    _WinAPI_DeleteObject($hRgn)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_DwmEnableComposition

Function Reference

_WinAPI_DwmEnableComposition

Enables or disables Desktop Window Manager (DWM) composition

#include <WinAPIGdi.au3>
_WinAPI_DwmEnableComposition ( $bEnable )

Parameters

$bEnable Specifies whether enable or disable DWM composition, valid values:
True - Enable.
False - Disable.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

Disabling DWM composition disables it for the entire desktop.
DWM composition will be automatically enabled when all processes that have disabled composition have called _WinAPI_DwmEnableComposition() to enable it or have been terminated.
The WM_DWMCOMPOSITIONCHANGED notification is sent when DWM composition has enabled or disabled.

This function requires Windows Vista or later.

See Also

Search DwmEnableComposition in MSDN Library.


Function _WinAPI_DwmExtendFrameIntoClientArea

Function Reference

_WinAPI_DwmExtendFrameIntoClientArea

Extends the window frame behind the client area

#include <WinAPIGdi.au3>
_WinAPI_DwmExtendFrameIntoClientArea ( $hWnd [, $tMARGINS = 0] )

Parameters

$hWnd | Handle to the window for which the frame is extended into the client area.
$tMARGINS | [optional] $tagMARGINS structure that describes the margins to use when extending the frame into the client area. Negative margins are used to create the "sheet of glass" effect where the client area is rendered as a solid surface with no window border (Default).

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function must be called whenever Desktop Window Manager (DWM) composition is toggled.
Handle the WM_DWMCOMPOSITIONCHANGED message for composition change notification.

This function requires Windows Vista or later.

See Also

Search DwmExtendFrameIntoClientArea in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GUITab.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPITheme.au3>
#include <WindowsConstants.au3>

Opt('TrayAutoPause', 0)

If Not _WinAPI_DwmIsCompositionEnabled() Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later with enabled Aero theme.')
    Exit
EndIf

Global Const $PRF_CLIENT = 0x04

OnAutoItExitRegister('OnAutoItExit')

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
GUICtrlCreateTab(0, 60, 402, 341, $WS_CLIPCHILDREN)
Global $g_hTab = GUICtrlGetHandle(-1)
GUICtrlCreateTabItem('Tab 1')
GUICtrlCreateButton('Button', 150, 167, 100, 26)
_WinAPI_SetParent(GUICtrlGetHandle(-1), $g_hTab)
GUICtrlCreateTabItem('Tab 2')
GUICtrlCreateEdit('', 14, 34, 372, 292)
_WinAPI_SetParent(GUICtrlGetHandle(-1), $g_hTab)
GUICtrlCreateTabItem('Tab 3')
GUICtrlCreateTabItem('')
GUISetBkColor(0)

; Register Tab window proc
Global $g_hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam')
Local $pDll = DllCallbackGetPtr($g_hDll)
Global $g_hProc = _WinAPI_SetWindowLong($g_hTab, $GWL_WNDPROC, $pDll)

; Create the "sheet of glass" effect for the Tab client area. You must call this function whenever DWM composition is toggled.
_WinAPI_DwmExtendFrameIntoClientArea($hForm, _WinAPI_CreateMargins(2, 2, 82, 2))

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _CreateClipRgn($hWnd)
    Local $tRECT, $hTmp, $iHt
    Local $iCount = _GUICtrlTab_GetItemCount($hWnd)
    Local $iSel = _GUICtrlTab_GetCurSel($hWnd)
    Local $hRgn = _WinAPI_CreateNullRgn()
    For $i = 0 To $iCount - 1
        $tRECT = _GUICtrlTab_GetItemRectEx($hWnd, $i)
        If $i = $iSel Then
            $hTmp = _WinAPI_CreateRectRgn(DllStructGetData($tRECT, 1) - 2, DllStructGetData($tRECT, 2) - 2, DllStructGetData($tRECT, 3) + 2, DllStructGetData($tRECT, 4))
            $iHt = DllStructGetData($tRECT, 4) - DllStructGetData($tRECT, 2) + 2
        Else
            If $i = $iCount - 1 Then
                $hTmp = _WinAPI_CreateRectRgn(DllStructGetData($tRECT, 1), DllStructGetData($tRECT, 2), DllStructGetData($tRECT, 3) - 2, DllStructGetData($tRECT, 4))
            Else
                $hTmp = _WinAPI_CreateRectRgn(DllStructGetData($tRECT, 1), DllStructGetData($tRECT, 2), DllStructGetData($tRECT, 3), DllStructGetData($tRECT, 4))
            EndIf
        EndIf
        _WinAPI_CombineRgn($hRgn, $hRgn, $hTmp, $RGN_OR)
        _WinAPI_DeleteObject($hTmp)
    Next
    $tRECT = _WinAPI_GetClientRect($hWnd)
    $hTmp = _WinAPI_CreateRectRgn(DllStructGetData($tRECT, 1), DllStructGetData($tRECT, 2) + $iHt, DllStructGetData($tRECT, 3) - 2, DllStructGetData($tRECT, 4) - 1)
    _WinAPI_CombineRgn($hRgn, $hRgn, $hTmp, $RGN_OR)
    _WinAPI_DeleteObject($hTmp)
    Return $hRgn
EndFunc   ;==>_CreateClipRgn

Func _WinProc($hWnd, $iMsg, $wParam, $lParam)
    If _WinAPI_IsThemeActive() Then
        Local $hRgn
        Switch $iMsg
            Case $WM_ERASEBKGND
                Local $hPrev = _WinAPI_GetClipRgn($wParam)
                $hRgn = _CreateClipRgn($hWnd)
                _WinAPI_ExtSelectClipRgn($wParam, $hRgn, $RGN_DIFF)
                Local $tRECT = _WinAPI_GetClientRect($hWnd)
                Local $hBrush = _WinAPI_CreateSolidBrush(0)
                _WinAPI_FillRect($wParam, $tRECT, $hBrush)
                _WinAPI_SelectClipRgn($wParam, $hPrev)
                _WinAPI_DeleteObject($hBrush)
                _WinAPI_DeleteObject($hRgn)
                Return 1
            Case $WM_PAINT
                Local $tPAINTSTRUCT
                Local $hDC = _WinAPI_BeginPaint($hWnd, $tPAINTSTRUCT)
                $hRgn = _CreateClipRgn($hWnd)
                _WinAPI_ExtSelectClipRgn($hDC, $hRgn, $RGN_AND)
                _WinAPI_CallWindowProc($g_hProc, $hWnd, $WM_PRINTCLIENT, $hDC, $PRF_CLIENT)
                _WinAPI_DeleteObject($hRgn)
                _WinAPI_EndPaint($hWnd, $tPAINTSTRUCT)
                Return 0
        EndSwitch
    EndIf
    Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_WinProc

Func OnAutoItExit()
    _WinAPI_SetWindowLong($g_hTab, $GWL_WNDPROC, $g_hProc)
    DllCallbackFree($g_hDll)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_DwmGetColorizationColor

Function Reference

_WinAPI_DwmGetColorizationColor

Retrieves the current color used for Desktop Window Manager (DWM) glass composition

#include <WinAPIGdi.au3>
_WinAPI_DwmGetColorizationColor ( )

Return Value

Success: | The current color (0xAARRGGBB) used for glass composition, @extended flag indicates whether the color is an opaque blend: 1 - The color is an opaque blend. 0 - Otherwise.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

See Also

Search DwmGetColorizationColor in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>

If Not _WinAPI_DwmIsCompositionEnabled() Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later with enabled Aero theme.')
    Exit
EndIf

Local $iColor = _WinAPI_DwmGetColorizationColor()
Local $iBlend = @extended

ConsoleWrite('Color for glass composition: 0x' & Hex($iColor) & @CRLF)
ConsoleWrite('Transparency: ' & (Not $iBlend) & @CRLF)


Function _WinAPI_DwmGetColorizationParameters

Function Reference

_WinAPI_DwmGetColorizationParameters

Retrieves the colorization parameters used for Desktop Window Manager (DWM)

#include <WinAPIGdi.au3>
_WinAPI_DwmGetColorizationParameters ( )

Return Value

Success: | $tagDWM_COLORIZATION_PARAMETERS structure that contains the colorization parameters.
Failure: | Sets the @error flag to non-zero.

Remarks

This function requires Windows Vista or later.


Function _WinAPI_DwmGetWindowAttribute

Function Reference

_WinAPI_DwmGetWindowAttribute

Retrieves the current value of a specified attribute applied to the window

#include <WinAPIGdi.au3>
_WinAPI_DwmGetWindowAttribute ( $hWnd, $iAttribute )

Parameters

$hWnd | Handle to the window for which the attribute data is retrieved.
$iAttribute | The attribute to retrieve. This parameter can be one of the following values: $DWMWA_NCRENDERING_ENABLED $DWMWA_CAPTION_BUTTON_BOUNDS $DWMWA_EXTENDED_FRAME_BOUNDS

Return Value

Success: | The value that contains the current value of the attribute. The type of the returned value depends on the value of the $iAttribute parameter.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

See Also

Search DwmGetWindowAttribute in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>

If Not _WinAPI_DwmIsCompositionEnabled() Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later with enabled Aero theme.')
    Exit
EndIf

Run(@SystemDir & '\calc.exe')
Local $hWnd = WinWaitActive("[CLASS:CalcFrame]", '', 3)
If Not $hWnd Then
    Exit
EndIf

Local $aPos = _WinAPI_GetPosFromRect(_WinAPI_DwmGetWindowAttribute($hWnd, $DWMWA_EXTENDED_FRAME_BOUNDS))

ConsoleWrite('Left:   ' & $aPos[0] & @CRLF)
ConsoleWrite('Top:    ' & $aPos[1] & @CRLF)
ConsoleWrite('Width:  ' & $aPos[2] & @CRLF)
ConsoleWrite('Height: ' & $aPos[3] & @CRLF)


Function _WinAPI_DwmInvalidateIconicBitmaps

Function Reference

_WinAPI_DwmInvalidateIconicBitmaps

Indicates that all previously provided iconic bitmaps from a window, both thumbnails and peek representations, should be refreshed

#include <WinAPIGdi.au3>
_WinAPI_DwmInvalidateIconicBitmaps ( $hWnd )

Parameters

$hWnd Handle to the window or tab whose bitmaps are being invalidated through this call.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

Calling this function causes the Desktop Window Manager (DWM) to invalidate its current bitmaps for the window and request new bitmaps from the window when they are next needed. _WinAPI_DwmInvalidateIconicBitmaps() should not be called frequently.
Doing so can lead to poor performance as new bitmaps are created and retrieved.

This function requires Windows 7 or later.

See Also

Search DwmInvalidateIconicBitmaps in MSDN Library.


Function _WinAPI_DwmIsCompositionEnabled

Function Reference

_WinAPI_DwmIsCompositionEnabled

Determines whether Desktop Window Manager (DWM) composition is enabled

#include <WinAPIGdi.au3>
_WinAPI_DwmIsCompositionEnabled ( )

Return Value

Success: | 1 - DWM composition is enabled. 0 - Otherwise.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

See Also

Search DwmIsCompositionEnabled in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

Local $aState[2] = ['Disabled', 'Enabled']

ConsoleWrite('Aero is: ' & $aState[_WinAPI_DwmIsCompositionEnabled()] & @CRLF)


Function _WinAPI_DwmQueryThumbnailSourceSize

Function Reference

_WinAPI_DwmQueryThumbnailSourceSize

Returns the source size of the Desktop Window Manager (DWM) thumbnail

#include <WinAPIGdi.au3>
_WinAPI_DwmQueryThumbnailSourceSize ( $hThumbnail )

Parameters

$hThumbnail Handle of the thumbnail to retrieve the source window size from.

Return Value

Success: | $tagSIZE structure that contains the size of the source thumbnail.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

See Also

Search DwmQueryThumbnailSourceSize in MSDN Library.


Function _WinAPI_DwmRegisterThumbnail

Function Reference

_WinAPI_DwmRegisterThumbnail

Creates a Desktop Window Manager (DWM) thumbnail relationship between the destination and source windows

#include <WinAPIGdi.au3>
_WinAPI_DwmRegisterThumbnail ( $hDestination, $hSource )

Parameters

$hDestination | Handle to the window that will use the DWM thumbnail.
$hSource | Handle to the window to use as the thumbnail source.

Return Value

Success: | Handle that represents the registration of the DWM thumbnail.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

The window designated by $hDestination must either be the desktop window itself or be owned by the process that is calling _WinAPI_DwmRegisterThumbnail().

This function requires Windows Vista or later.

See Also

Search DwmRegisterThumbnail in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>

If Not _WinAPI_DwmIsCompositionEnabled() Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later with enabled Aero theme.')
    Exit
EndIf

Run(@SystemDir & '\calc.exe')
Local $hWnd = WinWaitActive("[CLASS:CalcFrame]", '', 3)
If Not $hWnd Then
    Exit
EndIf

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)

GUISetBkColor(0)

; Create the "sheet of glass" effect for the entire window. You must call this function whenever DWM composition is toggled.
_WinAPI_DwmExtendFrameIntoClientArea($hForm)

; Create a DWM thumbnail relationship (2:1)
Local $hThumbnail = _WinAPI_DwmRegisterThumbnail($hForm, $hWnd)
Local $tSIZE = _WinAPI_DwmQueryThumbnailSourceSize($hThumbnail)
Local $iWidth = DllStructGetData($tSIZE, 1)
Local $iHeight = DllStructGetData($tSIZE, 2)
Local $tDestRect = _WinAPI_CreateRectEx((400 - $iWidth / 2) / 2, (400 - $iHeight / 2) / 2, $iWidth / 2, $iHeight / 2)
Local $tSrcRect = _WinAPI_CreateRectEx(-20, -20, $iWidth + 40, $iHeight + 40)
_WinAPI_DwmUpdateThumbnailProperties($hThumbnail, 1, 0, 255, $tDestRect, $tSrcRect)

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

WinClose("[CLASS:CalcFrame]", "")


Function _WinAPI_DwmSetColorizationParameters

Function Reference

_WinAPI_DwmSetColorizationParameters

Sets the colorization parameters for Desktop Window Manager (DWM)

#include <WinAPIGdi.au3>
_WinAPI_DwmSetColorizationParameters ( $tDWMCP )

Parameters

$tDWMCP $tagDWM_COLORIZATION_PARAMETERS containing the colorization parameters to be set.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

This function requires Windows Vista or later.


Function _WinAPI_DwmSetIconicLivePreviewBitmap

Function Reference

_WinAPI_DwmSetIconicLivePreviewBitmap

Sets a static, iconic bitmap to display a live preview (also known as a Peek preview) of a window or tab

#include <WinAPIGdi.au3>
_WinAPI_DwmSetIconicLivePreviewBitmap ( $hWnd, $hBitmap [, $bFrame = False [, $tClient = 0]] )

Parameters

$hWnd | Handle to the window or tab.
$hBitmap | Handle to the device-independent bitmap (DIB) to represent the specified window.
$bFrame | [optional] Specifies whether display a frame around the provided bitmap, valid values: True - Display frame. False - Do not display frame (Default).
$tClient | [optional] $tagPOINT structure that contains The offset of a tab window's client region from the host window's frame. This offset enables the tab window's contents to be drawn correctly in a live preview when it is drawn without its frame.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

A window typically calls the _WinAPI_DwmSetIconicLivePreviewBitmap() function in response to a WM_DWMSENDICONICLIVEPREVIEWBITMAP message.
The returned bitmap must not be larger than the client area of the window or frame and must have 32-bit color depth.

The DWM uses a copy of the bitmap, but the caller retains ownership of the original bitmap and is responsible for freeing the resources that it uses when it is no longer needed.
The DWM does not keep its copy of the bitmap when the DWM stops displaying the live preview representation.

This function requires Windows 7 or later.

See Also

Search DwmSetIconicLivePreviewBitmap in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

If (_WinAPI_GetVersion() < '6.1') Or (Not _WinAPI_DwmIsCompositionEnabled()) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows 7 or later with enabled Aero theme.')
    Exit
EndIf

; Load bitmap to create a thumbnail
Global $g_hAutoIt = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\AutoIt.bmp', $IMAGE_BITMAP, 0, 0, BitOR($LR_LOADFROMFILE, $LR_CREATEDIBSECTION))

; Create GUI
Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)

; Set DWM window attributes to provide the iconic bitmap, and to always render the thumbnail and live preview using the iconic bitmap
_WinAPI_DwmSetWindowAttribute($g_hForm, $DWMWA_FORCE_ICONIC_REPRESENTATION, 1)
_WinAPI_DwmSetWindowAttribute($g_hForm, $DWMWA_HAS_ICONIC_BITMAP, 1)

; Register WM_DWMSENDICONICLIVEPREVIEWBITMAP window message to display live preview
GUIRegisterMsg($WM_DWMSENDICONICLIVEPREVIEWBITMAP, 'WM_DWMSENDICONICLIVEPREVIEWBITMAP')

; Register WM_DWMSENDICONICTHUMBNAIL window message to display thumbnail
GUIRegisterMsg($WM_DWMSENDICONICTHUMBNAIL, 'WM_DWMSENDICONICTHUMBNAIL')

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _CreateThumbnail($hSource, $iWidth, $iHeight)
    Local $hBitmap = _WinAPI_CreateDIB($iWidth, $iHeight)
    Local $hDestDC = _WinAPI_CreateCompatibleDC(0)
    Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap)
    Local $tSIZE = _WinAPI_GetBitmapDimension($hSource)
    Local $hSrcDC = _WinAPI_CreateCompatibleDC(0)
    Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hSource)
    _WinAPI_SetStretchBltMode($hDestDC, $HALFTONE)
    _WinAPI_StretchBlt($hDestDC, 0, 0, $iWidth, $iHeight, $hSrcDC, 0, 0, DllStructGetData($tSIZE, 'X'), DllStructGetData($tSIZE, 'Y'), $SRCCOPY)
    _WinAPI_SelectObject($hDestDC, $hDestSv)
    _WinAPI_DeleteDC($hDestDC)
    _WinAPI_SelectObject($hSrcDC, $hSrcSv)
    _WinAPI_DeleteDC($hSrcDC)
    Return $hBitmap
EndFunc   ;==>_CreateThumbnail

Func WM_DWMSENDICONICLIVEPREVIEWBITMAP($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam

    Switch $hWnd
        Case $g_hForm
            Local $hBitmap = _CreateThumbnail($g_hAutoIt, 400, 400)
            _WinAPI_DwmSetIconicLivePreviewBitmap($g_hForm, $hBitmap, 1)
            _WinAPI_DeleteObject($hBitmap)
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_DWMSENDICONICLIVEPREVIEWBITMAP

Func WM_DWMSENDICONICTHUMBNAIL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam

    Switch $hWnd
        Case $g_hForm
            Local $W, $H, $hBitmap

            $W = _WinAPI_HiWord($lParam)
            $H = _WinAPI_LoWord($lParam)
            If $W > $H Then
                $W = $H
            Else
                $H = $W
            EndIf
            $hBitmap = _CreateThumbnail($g_hAutoIt, $W, $H)
            _WinAPI_DwmSetIconicThumbnail($g_hForm, $hBitmap, 1)
            _WinAPI_DeleteObject($hBitmap)
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_DWMSENDICONICTHUMBNAIL


Function _WinAPI_DwmSetIconicThumbnail

Function Reference

_WinAPI_DwmSetIconicThumbnail

Sets a static, iconic bitmap on a window or tab to use as a thumbnail representation

#include <WinAPIGdi.au3>
_WinAPI_DwmSetIconicThumbnail ( $hWnd, $hBitmap [, $bFrame = False] )

Parameters

$hWnd | Handle to the window or tab.
$hBitmap | Handle to the device-independent bitmap (DIB) to represent the specified window.
$bFrame | [optional] Specifies whether display a frame around the provided thumbnail, valid values: True - Display frame. False - Do not display frame (Default).

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

A window typically calls the _WinAPI_DwmSetIconicThumbnail() function after it receives a WM_DWMSENDICONICTHUMBNAIL message.
The thumbnail should not exceed the maximum x-coordinate and y-cordinate that are specified in the WM_DWMSENDICONICTHUMBNAIL.
The thumbnail must also have a 32-bit color depth.

The DWM uses a copy of the bitmap, but the application can release this copy at any time because of memory constraints.
If this occurs, the window is not notified but it might receive a subsequent WM_DWMSENDICONICTHUMBNAIL request when its thumbnail is needed again.
The caller retains ownership of the original bitmap and is responsible for freeing the resources that it uses when it is no longer needed.

This function requires Windows 7 or later.

See Also

Search DwmSetIconicThumbnail in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

If (_WinAPI_GetVersion() < '6.1') Or (Not _WinAPI_DwmIsCompositionEnabled()) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows 7 or later with enabled Aero theme.')
    Exit
EndIf

; Load bitmap to create a thumbnail
Global $g_hAutoIt = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\AutoIt.bmp', $IMAGE_BITMAP, 0, 0, BitOR($LR_LOADFROMFILE, $LR_CREATEDIBSECTION))

; Create GUI
Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)

; Set DWM window attributes to provide the iconic bitmap, and to always render the thumbnail and live preview using the iconic bitmap
_WinAPI_DwmSetWindowAttribute($g_hForm, $DWMWA_FORCE_ICONIC_REPRESENTATION, 1)
_WinAPI_DwmSetWindowAttribute($g_hForm, $DWMWA_HAS_ICONIC_BITMAP, 1)

; Register WM_DWMSENDICONICLIVEPREVIEWBITMAP window message to display live preview
GUIRegisterMsg($WM_DWMSENDICONICLIVEPREVIEWBITMAP, 'WM_DWMSENDICONICLIVEPREVIEWBITMAP')

; Register WM_DWMSENDICONICTHUMBNAIL window message to display thumbnail
GUIRegisterMsg($WM_DWMSENDICONICTHUMBNAIL, 'WM_DWMSENDICONICTHUMBNAIL')

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _CreateThumbnail($hSource, $iWidth, $iHeight)
    Local $hBitmap = _WinAPI_CreateDIB($iWidth, $iHeight)
    Local $hDestDC = _WinAPI_CreateCompatibleDC(0)
    Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap)
    Local $tSIZE = _WinAPI_GetBitmapDimension($hSource)
    Local $hSrcDC = _WinAPI_CreateCompatibleDC(0)
    Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hSource)
    _WinAPI_SetStretchBltMode($hDestDC, $HALFTONE)
    _WinAPI_StretchBlt($hDestDC, 0, 0, $iWidth, $iHeight, $hSrcDC, 0, 0, DllStructGetData($tSIZE, 'X'), DllStructGetData($tSIZE, 'Y'), $SRCCOPY)
    _WinAPI_SelectObject($hDestDC, $hDestSv)
    _WinAPI_DeleteDC($hDestDC)
    _WinAPI_SelectObject($hSrcDC, $hSrcSv)
    _WinAPI_DeleteDC($hSrcDC)
    Return $hBitmap
EndFunc   ;==>_CreateThumbnail

Func WM_DWMSENDICONICLIVEPREVIEWBITMAP($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam

    Switch $hWnd
        Case $g_hForm
            Local $hBitmap = _CreateThumbnail($g_hAutoIt, 400, 400)
            _WinAPI_DwmSetIconicLivePreviewBitmap($g_hForm, $hBitmap, 1)
            _WinAPI_DeleteObject($hBitmap)
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_DWMSENDICONICLIVEPREVIEWBITMAP

Func WM_DWMSENDICONICTHUMBNAIL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam

    Switch $hWnd
        Case $g_hForm
            Local $W, $H, $hBitmap

            $W = _WinAPI_HiWord($lParam)
            $H = _WinAPI_LoWord($lParam)
            If $W > $H Then
                $W = $H
            Else
                $H = $W
            EndIf
            $hBitmap = _CreateThumbnail($g_hAutoIt, $W, $H)
            _WinAPI_DwmSetIconicThumbnail($g_hForm, $hBitmap, 1)
            _WinAPI_DeleteObject($hBitmap)
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_DWMSENDICONICTHUMBNAIL


Function _WinAPI_DwmSetWindowAttribute

Function Reference

_WinAPI_DwmSetWindowAttribute

Sets the value of the specified attributes for non-client rendering to apply to the window

#include <WinAPIGdi.au3>
_WinAPI_DwmSetWindowAttribute ( $hWnd, $iAttribute, $iData )

Parameters

$hWnd | The window handle to apply the given attribute.
$iAttribute | The attribute to apply to the window. This parameter can be one of the following values: $DWMWA_NCRENDERING_POLICY $DWMWA_TRANSITIONS_FORCEDISABLED $DWMWA_ALLOW_NCPAINT $DWMWA_NONCLIENT_RTL_LAYOUT $DWMWA_FORCE_ICONIC_REPRESENTATION $DWMWA_FLIP3D_POLICY Windows 7 or later $DWMWA_HAS_ICONIC_BITMAP $DWMWA_DISALLOW_PEEK $DWMWA_EXCLUDED_FROM_PEEK
$iData | The value of the attribute.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

See Also

Search DwmSetWindowAttribute in MSDN Library.


Function _WinAPI_DwmUnregisterThumbnail

Function Reference

_WinAPI_DwmUnregisterThumbnail

Removes a Desktop Window Manager (DWM) thumbnail relationship

#include <WinAPIGdi.au3>
_WinAPI_DwmUnregisterThumbnail ( $hThumbnail )

Parameters

$hThumbnail Handle to the thumbnail relationship to be removed.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

See Also

Search DwmUnregisterThumbnail in MSDN Library.


Function _WinAPI_DwmUpdateThumbnailProperties

Function Reference

_WinAPI_DwmUpdateThumbnailProperties

Specifies Desktop Window Manager (DWM) thumbnail properties

#include <WinAPIGdi.au3>
_WinAPI_DwmUpdateThumbnailProperties ( $hThumbnail [, $bVisible = True [, $bClientAreaOnly = False [, $iOpacity = 255 [, $tRectDest = 0 [, $tRectSrc = 0]]]]] )

Parameters

$hThumbnail | Handle of the thumbnail to retrieve the source window size from.
$bVisible | [optional] Specifies whether make the thumbnail visible or invisible, valid values: True - Visible (Default). False - Invisible.
$bClientAreaOnly | [optional] Specifies whether use only the thumbnail source's client area or entire window, valid values: True - Use only source's client area. False - Use entire window (Default).
$iOpacity | [optional] The opacity with which to render the thumbnail. 0 is fully transparent while 255 (Default) is fully opaque.
$tRectDest | [optional] $tagRECT structure containing the rectangle in the destination window the thumbnail will be rendered. By default, the size of this rectangle equal to the source size of the DWM thumbnail which returns the _WinAPI_DwmQueryThumbnailSourceSize() function.
$tRectSrc | [optional] $tagRECT structure containing the rectangle that specifies the region of the source window to use as the thumbnail. By default, the entire window is used as the thumbnail.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

Thumbnail relationships created by _WinAPI_DwmRegisterThumbnail() will not be rendered to the destination window until this function is called.
Subsequent calls will update the thumbnail according to the properties.

This function requires Windows Vista or later.

Related

_WinAPI_DwmQueryThumbnailSourceSize, _WinAPI_DwmRegisterThumbnail

See Also

Search DwmUpdateThumbnailProperties in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>

If Not _WinAPI_DwmIsCompositionEnabled() Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later with enabled Aero theme.')
    Exit
EndIf

Run(@SystemDir & '\calc.exe')
Local $hWnd = WinWaitActive("[CLASS:CalcFrame]", '', 3)
If Not $hWnd Then
    Exit
EndIf

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)

GUISetBkColor(0)

; Create the "sheet of glass" effect for the entire window. You must call this function whenever DWM composition is toggled.
_WinAPI_DwmExtendFrameIntoClientArea($hForm)

; Create a DWM thumbnail relationship (2:1)
Local $hThumbnail = _WinAPI_DwmRegisterThumbnail($hForm, $hWnd)
Local $tSIZE = _WinAPI_DwmQueryThumbnailSourceSize($hThumbnail)
Local $iWidth = DllStructGetData($tSIZE, 1)
Local $iHeight = DllStructGetData($tSIZE, 2)
Local $tDestRect = _WinAPI_CreateRectEx((400 - $iWidth / 2) / 2, (400 - $iHeight / 2) / 2, $iWidth / 2, $iHeight / 2)
Local $tSrcRect = _WinAPI_CreateRectEx(-20, -20, $iWidth + 40, $iHeight + 40)
_WinAPI_DwmUpdateThumbnailProperties($hThumbnail, 1, 0, 255, $tDestRect, $tSrcRect)

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

WinClose("[CLASS:CalcFrame]", "")


User Defined Functions

DeviceContext user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIGdi.au3>.

User Defined Function | Description
_WinAPI_EnumDisplaySettings | Retrieves information about one of the graphics modes for a display device
_WinAPI_GetCurrentObject | Retrieves a handle to an object of the specified type that has been selected into the specified device context
_WinAPI_GetDCEx | Retrieves a handle to a device context (DC) for the client area of a specified window
_WinAPI_GetObjectType | Retrieves the type of the specified object
_WinAPI_PrintWindow | Copies a visual window into the specified device context
_WinAPI_RestoreDC | Restores a device context (DC) to the specified state
_WinAPI_SaveDC | Saves the current state of the specified device context (DC) by copying data describing selected objects and graphic modes to a context stack


Function _WinAPI_EnumDisplaySettings

Function Reference

_WinAPI_EnumDisplaySettings

Retrieves information about one of the graphics modes for a display device

#include <WinAPIGdi.au3>
_WinAPI_EnumDisplaySettings ( $sDevice, $iMode )

Parameters

$sDevice | The display device about whose graphics mode the function will obtain information. An empty string specifies the current display device on the computer on which the calling process is running.
$iMode | The type of information to be retrieved. This value can be a graphics mode index or one of the following values: $ENUM_CURRENT_SETTINGS $ENUM_REGISTRY_SETTINGS The graphics mode indexes start at zero. To obtain information for all of a display device's graphics modes, make a series of calls to _WinAPI_EnumDisplaySettings(). Set $iMode to zero for the first call, and increment $iMode by one for each subsequent call. Continue calling the function until the return value is zero. When you call _WinAPI_EnumDisplaySettings() with $iMode set to zero, the operating system initializes and caches information about the display device. When you call _WinAPI_EnumDisplaySettings() with $iMode set to a non-zero value, the function returns the information that was cached the last time the function was called with $iMode set to zero.

Return Value

Success: | The array containing the following information: [0] - The width, in pixels, of the visible device surface. [1] - The height, in pixels, of the visible device surface. [2] - The color resolution, in bits per pixel, of the display device. [3] - The frequency, in hertz (cycles per second), of the display device in a particular mode. [4] - The device's display mode ($DM_*).
Failure: | Sets the @error flag to non-zero.

See Also

Search EnumDisplaySettings in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <WinAPIGdi.au3>

Local $i = 0, $aData

While 1
    $aData = _WinAPI_EnumDisplaySettings('', $i)
    If IsArray($aData) Then
        ConsoleWrite($aData[0] & ' x ' & $aData[1] & ' x ' & $aData[2] & ' bit' & @CRLF)
    Else
        ExitLoop
    EndIf
    $i += 1
WEnd

$aData = _WinAPI_EnumDisplaySettings('', $ENUM_CURRENT_SETTINGS)
ConsoleWrite('-------------------------------' & @CRLF)
ConsoleWrite('Current settings: ' & $aData[0] & ' x ' & $aData[1] & ' x ' & $aData[2] & ' bit' & @CRLF)


Function _WinAPI_GetCurrentObject

Function Reference

_WinAPI_GetCurrentObject

Retrieves a handle to an object of the specified type that has been selected into the specified device context

#include <WinAPIGdi.au3>
_WinAPI_GetCurrentObject ( $hDC, $iType )

Parameters

$hDC | Handle to the device context.
$iType | The object type to be queried. This parameter can be one of the following values. $OBJ_BITMAP $OBJ_BRUSH $OBJ_COLORSPACE $OBJ_FONT $OBJ_PAL $OBJ_PEN

Return Value

Success: | Handle to the specified object.
Failure: | 0.

See Also

Search GetCurrentObject in MSDN Library.


Function _WinAPI_GetDCEx

Function Reference

_WinAPI_GetDCEx

Retrieves a handle to a device context (DC) for the client area of a specified window

#include <WinAPIGdi.au3>
_WinAPI_GetDCEx ( $hWnd, $hRgn, $iFlags )

Parameters

$hWnd | Handle to the window whose DC is to be retrieved. If this value is 0, _WinAPI_GetDCEx() retrieves the DC for the entire screen. If the value of $iFlags parameter is $DCX_INTERSECTRGN or DCX_EXCLUDERGN, then the operating system assumes ownership of the region and will automatically delete it when it is no longer needed. In this case, the application should not use or delete the region after a successful call to _WinAPI_GetDCEx().
$hRgn | A clipping region that may be combined with the visible region of the DC.
$iFlags | Flags that specifies how the DC is created. This parameter can be one or more of the following values: $DCX_WINDOW $DCX_CACHE $DCX_PARENTCLIP $DCX_CLIPSIBLINGS $DCX_CLIPCHILDREN $DCX_NORESETATTRS $DCX_LOCKWINDOWUPDATE $DCX_EXCLUDERGN $DCX_INTERSECTRGN $DCX_INTERSECTUPDATE $DCX_VALIDATE

Return Value

Success: | Handle to the DC for the specified window.
Failure: | 0.

Remarks

Unless the display DC belongs to a window class, the _WinAPI_ReleaseDC() function must be called to release the DC after painting.

Related

_WinAPI_ReleaseDC

See Also

Search GetDCEx in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

Global $g_hFont = _WinAPI_CreateFont(16, 0, 0, 0, $FW_BOLD, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_PITCH, $ANTIALIASED_QUALITY, 'Arial')

Global $g_bDwm = False
If (_WinAPI_GetVersion() > '5.2') And (_WinAPI_DwmIsCompositionEnabled()) Then
    If MsgBox(BitOR($MB_YESNOCANCEL, $MB_ICONQUESTION, $MB_SYSTEMMODAL), 'DWM', 'This example works only if a Desktop Window Manager (DWM) composition is disabled.' & @CRLF & @CRLF & 'Do you want to disable DWM?') = 6 Then
        _WinAPI_DwmEnableComposition(0)
        $g_bDwm = True
    Else
        Exit
    EndIf
EndIf

OnAutoItExitRegister('OnAutoItExit')

; Create GUI
Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)

; Register window proc
Global $g_hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;long;ptr')
Local $pDll = DllCallbackGetPtr($g_hDll)
Global $g_hProc = _WinAPI_SetWindowLong($g_hForm, $GWL_WNDPROC, $pDll)

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _WinProc($hWnd, $iMsg, $wParam, $lParam)
    Local $vRes = _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam)

    Switch $iMsg
        Case $WM_NCACTIVATE, $WM_NCPAINT
            Local $hDC
            Switch $iMsg
                Case $WM_NCACTIVATE
                    $hDC = _WinAPI_GetWindowDC($hWnd)
                Case $WM_NCPAINT
                    $hDC = _WinAPI_GetDCEx($hWnd, $wParam, BitOR($DCX_WINDOW, $DCX_INTERSECTRGN))
            EndSwitch
            Local $hSv = _WinAPI_SelectObject($hDC, $g_hFont)
            _WinAPI_SetTextColor($hDC, 0x00FFFF)
            _WinAPI_SetBkMode($hDC, $TRANSPARENT)
            _WinAPI_TextOut($hDC, 25, 8, 'Test ' & StringReplace(@ScriptName, '.au3', '()'))
            _WinAPI_SelectObject($hDC, $hSv)
            _WinAPI_ReleaseDC($hWnd, $hDC)
    EndSwitch
    Return $vRes
EndFunc   ;==>_WinProc

Func OnAutoItExit()
    _WinAPI_SetWindowLong($g_hForm, $GWL_WNDPROC, $g_hProc)
    DllCallbackFree($g_hDll)
    If $g_bDwm Then
        _WinAPI_DwmEnableComposition(1)
    EndIf
EndFunc   ;==>OnAutoItExit


Function _WinAPI_GetObjectType

Function Reference

_WinAPI_GetObjectType

Retrieves the type of the specified object

#include <WinAPIGdi.au3>
_WinAPI_GetObjectType ( $hObject )

Parameters

$hObject Handle to the graphics object.

Return Value

Success: | The value identifies the object ($OBJ_*).
Failure: | 0.

See Also

Search GetObjectType in MSDN Library.


Function _WinAPI_PrintWindow

Function Reference

_WinAPI_PrintWindow

Copies a visual window into the specified device context

#include <WinAPIGdi.au3>
_WinAPI_PrintWindow ( $hWnd, $hDC [, $bClient = False] )

Parameters

$hWnd | Handle to the window that will be copied.
$hDC | Handle to the device context.
$bClient | [optional] Specifies whether copies only the client area of the window, valid values: True - Only the client area of the window is copied to device context. False - The entire window is copied (Default).

Return Value

Success: | True
Failure: | False

See Also

Search PrintWindow in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

Run(@SystemDir & '\calc.exe')
Local $hWnd = WinWaitActive("[CLASS:CalcFrame]", '', 3)
If Not $hWnd Then
    Exit
EndIf

; Create GUI
Local $iSize = WinGetPos($hWnd)
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), $iSize[2] + 80, $iSize[3] + 80)
Local $idPic = GUICtrlCreatePic('', 40, 40, $iSize[2], $iSize[3])
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDC = _WinAPI_GetDC($hPic)
Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iSize[2], $iSize[3])
Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap)
Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBmp = _WinAPI_CreateCompatibleBitmap($hDC, $iSize[2], $iSize[3])
Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBmp)
_WinAPI_PrintWindow($hWnd, $hSrcDC)
_WinAPI_BitBlt($hDestDC, 0, 0, $iSize[2], $iSize[3], $hSrcDC, 0, 0, $MERGECOPY)

_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hDestDC, $hDestSv)
_WinAPI_SelectObject($hSrcDC, $hSrcSv)
_WinAPI_DeleteDC($hDestDC)
_WinAPI_DeleteDC($hSrcDC)
_WinAPI_DeleteObject($hBmp)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

WinClose("[CLASS:CalcFrame]", "")


Function _WinAPI_RestoreDC

Function Reference

_WinAPI_RestoreDC

Restores a device context (DC) to the specified state

#include <WinAPIGdi.au3>
_WinAPI_RestoreDC ( $hDC, $iID )

Parameters

$hDC | Handle to the DC.
$iID | The saved state to be restored. If this parameter is positive, $DC represents a specific instance of the state to be restored. If this parameter is negative, $DC represents an instance relative to the current state. For example, (-1) restores the most recently saved state.

Return Value

Success: | True
Failure: | False

See Also

Search RestoreDC in MSDN Library.


Function _WinAPI_SaveDC

Function Reference

_WinAPI_SaveDC

Saves the current state of the specified device context (DC) by copying data describing selected objects and graphic modes to a context stack

#include <WinAPIGdi.au3>
_WinAPI_SaveDC ( $hDC )

Parameters

$hDC Handle to the DC whose state is to be saved.

Return Value

Success: | The value identifies the saved state.
Failure: | 0.

See Also

Search SaveDC in MSDN Library.


User Defined Functions

Font & Text user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIGdi.au3>.

User Defined Function | Description
_WinAPI_AddFontMemResourceEx | Adds the font resource from a memory image to the system
_WinAPI_AddFontResourceEx | Adds the font resource from the specified file to the system font table
_WinAPI_CreateFontEx | Creates a logical font with the specified characteristics
_WinAPI_EnumFontFamilies | Enumerates all uniquely-named fonts in the system that match the specified font characteristics
_WinAPI_GetFontMemoryResourceInfo | Reads out font information from a TTF loaded into the memory
_WinAPI_GetFontName | Retrieves the unique name of the font based on its typeface name, character set, and style
_WinAPI_GetFontResourceInfo | Retrieves the fontname from the specified font resource file
_WinAPI_GetGlyphOutline | Retrieves the outline or bitmap for a character in the TrueType font
_WinAPI_GetOutlineTextMetrics | Retrieves text metrics for TrueType fonts
_WinAPI_GetTabbedTextExtent | Computes the width and height of a character string which may contain one or more tab characters
_WinAPI_GetTextAlign | Retrieves the text-alignment setting for the specified device context
_WinAPI_GetTextCharacterExtra | Retrieves the current intercharacter spacing for the specified device context
_WinAPI_GetTextColor | Retrieves the current text color for the specified device context
_WinAPI_GetTextFace | Retrieves the typeface name of the font that is selected into the specified device context
_WinAPI_RemoveFontMemResourceEx | Removes the fonts added from a memory image
_WinAPI_RemoveFontResourceEx | Removes the fonts in the specified file from the system font table
_WinAPI_SetTextAlign | Sets the text-alignment flags for the specified device context
_WinAPI_SetTextCharacterExtra | Sets the intercharacter spacing for the specified device context
_WinAPI_SetTextJustification | Specifies the amount of space the system should add to the break characters in a string of text
_WinAPI_TabbedTextOut | Writes a character string at a specified location and expanding tabs to the specified tab-stop positions
_WinAPI_TextOut | Writes a string at the specified location, using the currently selected font, background color, and text color


Function _WinAPI_AddFontMemResourceEx

Function Reference

_WinAPI_AddFontMemResourceEx

Adds the font resource from a memory image to the system

#include <WinAPIGdi.au3>
_WinAPI_AddFontMemResourceEx ( $pData, $iSize )

Parameters

$pData | The pointer to a font resource.
$iSize | The number of bytes in the font resource.

Return Value

Success: | The handle uniquely identifies the fonts that were installed on the system, @extended flag will contain a number of fonts added to the system as a result of this call.
Failure: | 0.

Remarks

This function allows an application to get a font that is embedded in a document or a Web page.
A font that is added by this is always private to the process that made the call and is not enumerable.

When the function succeeds, the caller of this function can free the memory pointed to by $pData because the system has made its own copy of the memory.
To remove the fonts that were installed, call _WinAPI_RemoveFontMemResourceEx().
However, when the process goes away, the system will unload the fonts.

Related

_WinAPI_RemoveFontMemResourceEx

See Also

Search AddFontMemResourceEx in MSDN Library.

Example

#include <APIMiscConstants.au3>
#include <APIResConstants.au3>
#include <GUIConstantsEx.au3>
#include <Memory.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIMisc.au3>
#include <WinAPIRes.au3>

Local Const $sJpg = @TempDir & '\~Tech.jpg'

; Load Resources.dll to memory
Local $hInstance = _WinAPI_LoadLibraryEx(@ScriptDir & '\Extras\Resources.dll', $LOAD_LIBRARY_AS_DATAFILE)
If Not $hInstance Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', @ScriptDir & '\Extras\Resources.dll not found.')
    Exit
EndIf

; Load JPEG resource from Resources.dll library
Local $hResource = _WinAPI_FindResource($hInstance, 'JPEG', 1)
Local $iSize = _WinAPI_SizeOfResource($hInstance, $hResource)
Local $hData = _WinAPI_LoadResource($hInstance, $hResource)
Local $pData = _WinAPI_LockResource($hData)

; Save resource to .jpg file
Local $hFile = FileOpen($sJpg, 2 + 16)
Local $tData = DllStructCreate('byte[' & $iSize & ']', $pData)
FileWrite($hFile, DllStructGetData($tData, 1))
FileClose($hFile)

; Load FONT resource from Resources.dll library
$hResource = _WinAPI_FindResource($hInstance, $RT_FONT, 'TECHNOVIA_CAPS')
$iSize = _WinAPI_SizeOfResource($hInstance, $hResource)
$hData = _WinAPI_LoadResource($hInstance, $hResource)
$pData = _WinAPI_LockResource($hData)

; Add font from a memory to the system
Local $hFont = _WinAPI_AddFontMemResourceEx($pData, $iSize)

; Load SOUND resource from Resources.dll library
$hResource = _WinAPI_FindResource($hInstance, 'SOUND', 1)
$iSize = _WinAPI_SizeOfResource($hInstance, $hResource)
$hData = _WinAPI_LoadResource($hInstance, $hResource)
$pData = _WinAPI_LockResource($hData)

; Copy WAV to memory for use later
Local $hWave = _MemGlobalAlloc($iSize, $GMEM_MOVEABLE)
Local $pWave = _MemGlobalLock($hWave)
_MemMoveMemory($pData, $pWave, $iSize)
; _MemGlobalUnlock($hWave)

; Load STRING resource from Resources.dll library
Local $sText = _WinAPI_LoadString($hInstance, 1)

; Unload Resources.dll from memory
_WinAPI_FreeLibrary($hInstance)

; Create GUI
GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 350, 350)
GUICtrlCreatePic($sJpg, 0, 0, 350, 350)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateLabel($sText, 10, 18, 330, 36, $SS_CENTER)
GUICtrlSetFont(-1, 30, -1, -1, 'Technovia Caps')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xF06000)
Local $idButton = GUICtrlCreateButton('Play Sound', 125, 316, 100, 23)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            _WinAPI_PlaySound($pWave, BitOR($SND_ASYNC, $SND_MEMORY, $SND_NOWAIT))
    EndSwitch
WEnd

; Free resources
_WinAPI_RemoveFontMemResourceEx($hFont)
FileDelete($sJpg)


Function _WinAPI_AddFontResourceEx

Function Reference

_WinAPI_AddFontResourceEx

Adds the font resource from the specified file to the system font table

#include <WinAPIGdi.au3>
_WinAPI_AddFontResourceEx ( $sFont [, $iFlag = 0 [, $bNotify = False]] )

Parameters

$sFont | String that contains a valid font file name. This parameter can specify any of the following files: .fon - Font resource file. .fnt - Raw bitmap font file. .ttf - Raw TrueType file. .ttc - East Asian Windows: TrueType font collection. .fot - TrueType resource file. .otf - PostScript OpenType font. .mmm - Multiple master Type1 font resource file. It must be used with .pfm and .pfb files. .pfb - Type 1 font bits file. It is used with a .pfm file. .pfm - Type 1 font metrics file. It is used with a .pfb file. To add a font whose information comes from several resource files, they must be separated by a "|". For example, abcxxxxx.pfm|abcxxxxx.pfb.
$iFlag | [optional] The characteristics of the font to be added to the system. This parameter can be one of the following values. $FR_PRIVATE $FR_NOT_ENUM
$bNotify | [optional] Specifies whether sends a WM_FONTCHANGE message, valid values: True - Send the WM_FONTCHANGE message to all top-level windows after changing the pool of font resources. False - Don't send (Default).

Return Value

Success: | The value that specifies the number of fonts added.
Failure: | 0.

Remarks

This function installs the font only for the current session. When the system restarts, the font will not be present.
To have the font installed even after restarting the system, the font must be listed in the registry.

See Also

Search AddFontResourceEx in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>

_WinAPI_AddFontResourceEx(@ScriptDir & '\Extras\SF Square Head Bold.ttf', $FR_PRIVATE)

GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 100)
GUICtrlCreateLabel('Simple Text', 10, 25, 380, 50, $SS_CENTER)
GUICtrlSetFont(-1, 38, -1, -1, 'SF Square Head Bold')
GUICtrlSetColor(-1, 0xF06000)
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_CreateFontEx

Function Reference

_WinAPI_CreateFontEx

Creates a logical font with the specified characteristics

#include <WinAPIGdi.au3>
_WinAPI_CreateFontEx ( $iHeight [, $iWidth = 0 [, $iEscapement = 0 [, $iOrientation = 0 [, $iWeight = 400 [, $bItalic = False [, $bUnderline = False [, $bStrikeOut = False [, $iCharSet = 1 [, $iOutPrecision = 0 [, $iClipPrecision = 0 [, $iQuality = 0 [, $iPitchAndFamily = 0 [, $sFaceName = '' [, $iStyle = 0]]]]]]]]]]]]]] )

Parameters

$iHeight | The height of the font's character cell or character, in logical units.
$iWidth | [optional] The average width, in logical units. Default is 0.
$iEscapement | [optional] The angle, in tenths of degrees, between the escapement vector and the x-axis of the device. Default is 0
$iOrientation | [optional] The angle, in tenths of degrees, between each character's base line and the x-axis of the device. Default is 0
$iWeight | [optional] The weight of the font in the range 0 through 1000, or one of the following values. $FW_DONTCARE $FW_THIN $FW_EXTRALIGHT $FW_ULTRALIGHT $FW_LIGHT $FW_NORMAL (Default) $FW_REGULAR $FW_MEDIUM $FW_SEMIBOLD $FW_DEMIBOLD $FW_BOLD $FW_EXTRABOLD $FW_ULTRABOLD $FW_HEAVY $FW_BLACK
$bItalic | [optional] Specifies whether to set italic font attribute, valid values: True - The attribute is set. False - The attribute is not set (Default).
$bUnderline | [optional] Specifies whether to set underlined font attribute, valid values: True - The attribute is set. False - The attribute is not set (Default).
$bStrikeOut | [optional] Specifies whether to set strikeout font attribute, valid values: True - The attribute is set. False - The attribute is not set (Default).
$iCharSet | [optional] The character set. It can be one of the following values. $ANSI_CHARSET $BALTIC_CHARSET $CHINESEBIG5_CHARSET $DEFAULT_CHARSET (Default) $EASTEUROPE_CHARSET $GB2312_CHARSET $GREEK_CHARSET $HANGEUL_CHARSET $MAC_CHARSET $OEM_CHARSET $RUSSIAN_CHARSET $SHIFTJIS_CHARSET $SYMBOL_CHARSET $TURKISH_CHARSET $VIETNAMESE_CHARSET Korean language edition of Windows: $JOHAB_CHARSET Middle East language edition of Windows: $ARABIC_CHARSET $HEBREW_CHARSET Thai language edition of Windows: $THAI_CHARSET
$iOutPrecision | [optional] The output precision. It can be one of the following values. $OUT_CHARACTER_PRECIS $OUT_DEFAULT_PRECIS (Default) $OUT_DEVICE_PRECIS $OUT_OUTLINE_PRECIS $OUT_PS_ONLY_PRECIS $OUT_RASTER_PRECIS $OUT_STRING_PRECIS $OUT_STROKE_PRECIS $OUT_TT_ONLY_PRECIS $OUT_TT_PRECIS
$iClipPrecision | [optional] The clipping precision. It can be one or more of the following values. $CLIP_CHARACTER_PRECIS $CLIP_DEFAULT_PRECIS (Default) $CLIP_DFA_DISABLE $CLIP_EMBEDDED $CLIP_LH_ANGLES $CLIP_DFA_OVERRIDE $CLIP_STROKE_PRECIS
$iQuality | [optional] The output quality. It can be one of the following values. $ANTIALIASED_QUALITY $CLEARTYPE_QUALITY $DEFAULT_QUALITY (Default) $DRAFT_QUALITY $NONANTIALIASED_QUALITY $PROOF_QUALITY
$iPitchAndFamily | [optional] The pitch and family of the font. The two low-order bits specify the pitch of the font and can be one of the following values. $DEFAULT_PITCH (Default $FIXED_PITCH $VARIABLE_PITCH The four high-order bits specify the font family and can be one of the following values. $FF_DECORATIVE $FF_DONTCARE $FF_MODERN $FF_ROMAN $FF_SCRIPT $FF_SWISS
$sFaceName | [optional] The typeface name of the font (not including style). For example, "Arial", "Tahoma", etc.
$iStyle | [optional] The style of the font. It can be one or more of the following values. $FS_REGULAR (Default) $FS_BOLD $FS_ITALIC

Return Value

Success: | A handle to a logical font.
Failure: | 0.

Remarks

If you request a font name that is not available on the system, the font mapper will substitute a font that has similar attributes but a different name.

When you no longer need the font, call the _WinAPI_DeleteObject() function to delete it.

Related

_WinAPI_DeleteObject

See Also

Search CreateFont in MSDN Library.


Function _WinAPI_EnumFontFamilies

Function Reference

_WinAPI_EnumFontFamilies

Enumerates all uniquely-named fonts in the system that match the specified font characteristics

#include <WinAPIGdi.au3>
_WinAPI_EnumFontFamilies ( [$hDC = 0 [, $sFaceName = '' [, $iCharSet = 1 [, $iFontType = 0x07 [, $sPattern = '' [, $bExclude = False]]]]]] )

Parameters

$hDC | [optional] A handle to the device context from which to enumerate the fonts. If this parameter is 0, the function uses a DC for the application's current screen.
$sFaceName | [optional] The typeface name of the font. If this parameter is an empty string (Default), the function enumerates one font is each available typeface name. If this parameter is a valid typeface name, the function enumerates all fonts with the specified name.
$iCharSet | [optional] The character set. It can be one of the following predefined values. If this parameter is set to $DEFAULT_CHARSET (Default), the function enumerates all uniquely-named fonts in all character sets. If there are two fonts with the same name, only one is enumerated. If this parameter is set to a valid character set value, the function enumerates only fonts in the specified character set. $ANSI_CHARSET $BALTIC_CHARSET $CHINESEBIG5_CHARSET $DEFAULT_CHARSET (Default) $EASTEUROPE_CHARSET $GB2312_CHARSET $GREEK_CHARSET $HANGEUL_CHARSET $MAC_CHARSET $OEM_CHARSET $RUSSIAN_CHARSET $SHIFTJIS_CHARSET $SYMBOL_CHARSET $TURKISH_CHARSET $VIETNAMESE_CHARSET Korean language edition of Windows: $JOHAB_CHARSET Middle East language edition of Windows: $ARABIC_CHARSET $HEBREW_CHARSET Thai language edition of Windows: $THAI_CHARSET
$iFontType | [optional] The type of the fonts to enumerating. This parameter can be 0 (vector fonts), (-1) (all fonts), or any combination of the following values. $DEVICE_FONTTYPE (Default) $RASTER_FONTTYPE (Default) $TRUETYPE_FONTTYPE (Default)
$sPattern | [optional] The pattern string to include (exclude) the fonts in (from) the enumerating. This makes sense only if the typeface name is not specified. This string can contain wildcard characters. The pattern will be ignored if this parameter is omitted or an empty string.
$bExclude | [optional] Specifies whether to use the pattern to exclude the fonts, valid values: True - Exclude the matching fonts. False - Include the matching fonts (Default).

Return Value

Success: | The 2D array containing the following information: [0][0] - Number of rows in array (n) [0][1] - Unused [n][0] - The typeface name of the font. [n][1] - The style of the font. [n][2] - The unique name of the font. [n][3] - The script, that is, the character set, of the font. [n][4] - The type of the font ($*_FONTTYPE). [n][5] - The pitch, technology, and family of the font (same as in the TEXTMETRIC structure). [n][6] - The character set of the font ($*_CHARSET). [n][7] - The font flags ($NTM_*).
Failure: | Sets the @error flag to non-zero.

Remarks

The fonts for many East Asian languages have two typeface names: an English name and a localized name.
The function returns the English typeface name if the system locale does not match the language of the font.

When the graphics mode on the device context is set to $GM_ADVANCED and the $DEVICE_FONTTYPE flag is specified,
_WinAPI_EnumFontFamilies() returns a list of Type 1 and OpenType fonts on the system.
When the graphics mode is not set to $GM_ADVANCED, this function returns a list of Type 1, OpenType, and TrueType fonts on the system.

See Also

Search EnumFontFamiliesEx in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <Array.au3>
#include <FontConstants.au3>
#include <WinAPIGdi.au3>

; Enumerates all uniquely-named fonts excluding "@" fonts, which is designed for vertical text, in the ANSI character set
Local $aData = _WinAPI_EnumFontFamilies(0, '', $ANSI_CHARSET, BitOR($DEVICE_FONTTYPE, $TRUETYPE_FONTTYPE), '@*', 1)
If Not @error Then
    _ArrayDisplay($aData, '_WinAPI_EnumFontFamilies')
EndIf

; Enumerates all styles of "Arial" font in the ANSI character set
$aData = _WinAPI_EnumFontFamilies(0, 'Arial', $ANSI_CHARSET)
If Not @error Then
    _ArrayDisplay($aData, '_WinAPI_EnumFontFamilies')
EndIf


Function _WinAPI_GetFontName

Function Reference

_WinAPI_GetFontName

Retrieves the unique name of the font based on its typeface name, character set, and style

#include <WinAPIGdi.au3>
_WinAPI_GetFontName ( $sFaceName [, $iStyle = 0 [, $iCharSet = 1]] )

Parameters

$sFaceName | The typeface name of the font (not including style). For example, "Arial", "Tahoma", etc.
$iStyle | [optional] The style of the font. It can be one or more of the following values: $FS_REGULAR $FS_BOLD $FS_ITALIC
$iCharSet | [optional] The character set. It can be one of the following values: $ANSI_CHARSET $BALTIC_CHARSET $CHINESEBIG5_CHARSET $DEFAULT_CHARSET (Default) $EASTEUROPE_CHARSET $GB2312_CHARSET $GREEK_CHARSET $HANGEUL_CHARSET $MAC_CHARSET $OEM_CHARSET $RUSSIAN_CHARSET $SHIFTJIS_CHARSET $SYMBOL_CHARSET $TURKISH_CHARSET $VIETNAMESE_CHARSET Korean language edition of Windows: $JOHAB_CHARSET Middle East language edition of Windows: $ARABIC_CHARSET $HEBREW_CHARSET Thai language edition of Windows: $THAI_CHARSET

Return Value

Success: | The unique name of the font.
Failure: | Empty string and sets the @error flag to non-zero.

Remarks

This function can be used to get the appropriate font name on different language versions of the OS.
For example, in the english version you can write "Arial Bold", however, for the russian version this font must be specified as "Arial Ïîëóæèðíûé".
Nevertheless, most fonts use only english names and must be specified explicitly.

Example

#include <FontConstants.au3>
#include <WinAPIGdi.au3>

Local Const $sFaceName = 'Arial'

ConsoleWrite($sFaceName & ' Regular => ' & _WinAPI_GetFontName($sFaceName, $FS_REGULAR) & @CRLF)
ConsoleWrite($sFaceName & ' Bold => ' & _WinAPI_GetFontName($sFaceName, $FS_BOLD) & @CRLF)
ConsoleWrite($sFaceName & ' Italic => ' & _WinAPI_GetFontName($sFaceName, $FS_ITALIC) & @CRLF)
ConsoleWrite($sFaceName & ' Bold Italic => ' & _WinAPI_GetFontName($sFaceName, BitOR($FS_BOLD, $FS_ITALIC)) & @CRLF)


Function _WinAPI_GetFontResourceInfo

Function Reference

_WinAPI_GetFontResourceInfo

Retrieves the fontname from the specified font resource file

#include <WinAPIGdi.au3>
_WinAPI_GetFontResourceInfo ( $sFont [, $bForce = False [, $iFlag = Default]] )

Parameters

$sFont | String that names a font resource file. To retrieve a fontname whose information comes from several resource files, they must be separated by a "|" . For example, abcxxxxx.pfm | abcxxxxx.pfb.
$bForce | [optional] Specifies whether adds a file to the font table, valid values: True - Forced add the specified file to the system font table and remove it after retrieving the fontname. False - Don't add and remove (Default).
$iFlag | [optional] An integer value. See _WinAPI_GetFontMemoryResourceInfo() for value definition.

Return Value

Success: | The name of the font or Font information according to $iFlag.
Failure: | Empty string and sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

not documented in MSDN

Example

Example 1

#include <Array.au3>
#include <File.au3>
#include <WinAPIGdi.au3>
#include <WinAPIShellEx.au3>

Example()

Func Example()
    Local $sFileList = _FileListToArray(_WinAPI_ShellGetSpecialFolderPath($CSIDL_FONTS), '*.ttf', 1)
    Local $aFontList[UBound($sFileList) - 1][2]

    For $i = 1 To $sFileList[0]
        $aFontList[$i - 1][0] = $sFileList[$i]
        $aFontList[$i - 1][1] = _WinAPI_GetFontResourceInfo($sFileList[$i], 1)
    Next

    _ArrayDisplay($aFontList, '_WinAPI_GetFontResourceInfo')

EndFunc   ;==>Example

Example 2

#include <Array.au3>
#include <File.au3>
#include <WinAPIGdi.au3>
#include <WinAPIShellEx.au3>

Example()

Func Example()
    Local $sFileList = _FileListToArray(_WinAPI_ShellGetSpecialFolderPath($CSIDL_FONTS), '*.ttf', 1)
    Local $aFontList[UBound($sFileList) - 1][2]

    For $i = 1 To $sFileList[0]
        $aFontList[$i - 1][0] = $sFileList[$i]
        $aFontList[$i - 1][1] = _WinAPI_GetFontResourceInfo($sFileList[$i], Default, 1)
    Next

    _ArrayDisplay($aFontList, '_WinAPI_GetFontResourceInfo (Font Family name)')

EndFunc   ;==>Example

Example 3

#include <GDIPlus.au3>
#include <WinAPIGdi.au3>
#include <WinAPIMisc.au3>

Example()

Func Example()
    Local $sFile = "Extras\SF Square Head Bold.ttf"

    ConsoleWrite(_WinAPI_GetFontResourceInfo($sFile, True) & @CRLF)
    ConsoleWrite(@CRLF)

    FontGetInfoFromFile($sFile, 0, "Copyright")
    FontGetInfoFromFile($sFile, 1, "Font Family name")
    FontGetInfoFromFile($sFile, 2, "Font SubFamily name")
    FontGetInfoFromFile($sFile, 3, "Unique font identifier")
    FontGetInfoFromFile($sFile, 4, "Font full name")
    FontGetInfoFromFile($sFile, 5, "Version string")
    FontGetInfoFromFile($sFile, 6, "Postscript name")
    FontGetInfoFromFile($sFile, 7, "Trademark")
    FontGetInfoFromFile($sFile, 8, "Manufacturer Name")
    FontGetInfoFromFile($sFile, 9, "Designer")
    FontGetInfoFromFile($sFile, 10, "Description")
    FontGetInfoFromFile($sFile, 11, "URL Vendor")
    FontGetInfoFromFile($sFile, 16, "Preferred Family (Windows only)")
    FontGetInfoFromFile($sFile, 17, "Preferred SubFamily (Windows only)")
    FontGetInfoFromFile($sFile, 18, "Compatible Full (Mac OS only)")
    FontGetInfoFromFile($sFile, 19, "Sample text")
    FontGetInfoFromFile($sFile, 20, "PostScript CID findfont name")

    FontGetInfoFromFile($sFile, 256, "Font-specific names")

EndFunc   ;==>Example

Func FontGetInfoFromFile($sFile, $n, $sElement)
    Local $s = _WinAPI_GetFontResourceInfo($sFile, Default, $n)
    If Not @error And $s Then ConsoleWrite($sElement & " = " & $s & @CRLF)
EndFunc   ;==>FontGetInfoFromFile


Function _WinAPI_GetFontMemoryResourceInfo

Function Reference

_WinAPI_GetFontMemoryResourceInfo

Reads out font information from a TTF loaded into the memory

#include <GDIPlus.au3>
_WinAPI_GetFontMemoryResourceInfo ( $pMemory [, $iFlag = 1] )

Parameters

$pMemory | A pointer value the struct that contains the binary data of the TTF
$iFlag | [optional] An integer value. Default is 1 (Font Family name). See remarks for others values

Return Value

Success: | A string value of the font information.
Failure: | 0.

Remarks

$iFlag | Meaning
0 | Copyright notice
1 | Font Family name. (Default)
2 | Font Subfamily name. Font style (italic, oblique) and weight (light, bold, black, etc.). A font with no particular differences in weight or style (e.g. medium weight, not italic) should have the string "Regular" stored in this position.
3 | Unique font identifier. Usually similar to 4 but with enough additional information to be globally unique. Often includes information from Id 8 and Id 0.
4 | Full font name. This should be a combination of strings 1 and 2. Exception: if the font is “Regular” as indicated in string 2, then use only the family name contained in string 1. This is the font name that Windows will expose to users.
5 | Version string. Must begin with the syntax ‘Version n.nn ‘ (upper case, lower case, or mixed, with a space following the number).
6 | Postscript name for the font.
7 | Trademark. Used to save any trademark notice/information for this font. Such information should be based on legal advice. This is distinctly separate from the copyright.
8 | Manufacturer Name.
9 | Designer. Name of the designer of the typeface.
10 | Description. Description of the typeface. Can contain revision information, usage recommendations, history, features, etc.
11 | URL Vendor. URL of font vendor (with protocol, e.g., http://, ftp://). If a unique serial number is embedded in the URL, it can be used to register the font.
12 | URL Designer. URL of typeface designer (with protocol, e.g., http://, ftp://).
13 | License description. Description of how the font may be legally used, or different example scenarios for licensed use. This field should be written in plain language, not legalese.
14 | License information URL. Where additional licensing information can be found.
15 | Reserved; Set to zero.
16 | Preferred Family (Windows only). In Windows, the Family name is displayed in the font menu. The Subfamily name is presented as the Style name. For historical reasons, font families have contained a maximum of four styles, but font designers may group more than four fonts to a single family. The Preferred Family and Preferred Subfamily IDs allow font designers to include the preferred family/subfamily groupings. These IDs are only present if they are different from IDs 1 and 2.
17 | Preferred Subfamily (Windows only). See above.
18 | Compatible Full (Mac OS only). On the Mac OS, the menu name is constructed using the FOND resource. This usually matches the Full Name. If you want the name of the font to appear differently than the Full Name, you can insert the Compatible Full Name here.
19 | Sample text. This can be the font name, or any other text that the designer thinks is the best sample text to show what the font looks like.
20 | PostScript CID findfont name.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $bFont = _MemFont() ;load binary data (TTF) to use it later in GDI+
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout, $sFontInternalName
    Local $hCollection, $tFont

    $hGUI = GUICreate("GDI+", 720, 235)
    GUISetState()

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (anti aliasing)
    _GDIPlus_GraphicsSetTextRenderingHint($hGraphic, $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT) ;set the anti aliasing for fonts

    $hCollection = _GDIPlus_FontPrivateCreateCollection() ;create a PrivateFontCollection object to add fonts later
    $tFont = DllStructCreate('byte[' & BinaryLen($bFont) & ']') ;create byte struct to add font to collection
    DllStructSetData($tFont, 1, $bFont)
    _GDIPlus_FontPrivateAddMemoryFont($hCollection, $tFont) ;add font to collection

    $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F) ;create a brush with a defined color for the text
    $hFormat = _GDIPlus_StringFormatCreate() ;create a string format object
    $sFontInternalName = _WinAPI_GetFontMemoryResourceInfo(DllStructGetPtr($tFont)) ;get internal font name
    $hFamily = _GDIPlus_FontFamilyCreate($sFontInternalName, $hCollection) ;create a font family object
    $hFont = _GDIPlus_FontCreate($hFamily, 70) ;create a font object
    $tLayout = _GDIPlus_RectFCreate(0, 0, 720, 235) ;create a $tagGDIPRECTF structure to save x, y position of the text
    _GDIPlus_StringFormatSetAlign($hFormat, 1) ;center text
    _GDIPlus_StringFormatSetLineAlign($hFormat, 1) ;center text
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "AutoIt" & @LF & "forever", $hFont, $tLayout, $hFormat, $hBrush) ;draw the string

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontPrivateCollectionDispose($hCollection)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Func _MemFont($bSaveBinary = False, $sSavePath = @ScriptDir) ;compressed base64 saved TTL font
    Local $vMemFont
    $vMemFont &= '+LpAAAEAAAARAEAEAAAQTFRTSHBEFET0AGDEAKi3T1MALzJjo38vAAAEAZgAPGBWRE1YAGXvbW4AAHRoAAAABeBjbWFwEAm6VAMAgAQAAAAD2GN2dCADpEABxwAAFtwAXhgAZnBnbTJHc2AIAAAUAB4BYmdswHlmdq72hAA+AMYARmhoZG14PSgEGzgAS3wAAAuIAGhlYWTfoV8QJQArHAA/NmgAEAs9FAXeAA9UAA8kaG1AdHhqYhtYAA/4AAAAAsxrZXJugLrOrNgAAF4ArwALZGxvY2H2UEALkgAAXVwAI2gAbWF4cALnCnsFAAt4AD8gbmFtZQCNIdAnAABqKAAAAAodcG9zdFD/fgAUgGdIgQ9wgHJlcKaKyrqATwpAgAeago0CAAAhAEgSSF8PPPUACBkD6IAIALxe9gLnggNfJRz/7P6gvQfJA3AABwOBFQMCAIAbA3D+vQAVxAfggA+NB8mCJAkAArOCCLMBcQAgABZIgL2DDwoBNwjAAIIFgAcCA10BkIAEoAACvAKKgA2PgwPAAcUAMgD6ARYAuQcFAIDABwBMQVJBAABAACAhIgLm/4AcACoDcAFDg0mxAAL0AtaBdIAEnYABAEEANQH2ACECAD4AAQI4ACUCAFMAIgNjAAgAAPwAEwG+AAwCABMALwK1AB4CAKAAHwEsACMCAG8AJgFPADkEIAT/9APcwATzAAAvA7AAGQQlAIAoBCIACQOAwAAA5gAbAyH/9wQALgAkA/4ALgGgMgAsAUTACbfAGQB1ADADa//5AwBP//0DYgAxBACs//oEFAAtAyDJAAMD2cALIAAAEAMWAAcDyACKEcAXOkB9PwNowA4AogANAw3//wUgWAAVA8bAH34AAh/ADA0EswAWBABpABwD8AAPAwho//bAEjIEo/8A7wUlAAEEXgCAEwRKAAUDzkC3AKAADwQA//ABoNIAIAI2wBi0wDZoxAGexh+w/x/ZHwAArgBFBYYAPgAIhAAQwVwC8AF+AAKcAbgC0QFIMANuABTCIdAABq10/+3ADwHCJcgAwCU3C8EmwAAewAAhA///NvHFJdAALMIlyQBXABgFB+DARNUdpP/srAI6wErvDjbkDh1gAI4goWH2Dm0OUwAF4SEABqAAHAamABsBYQEC2AFxAw0BAOYDLQGPATsAAihgACMCQwAoAgAuACMB3wAfBwInYgssAnsAKQIgHAAvAObgADEAEivhAAF2YACCADRf4VgiaR8AHwAUABmBABjL/wQBABVfBBYYgwnhFgFgnQC4CRIEAwUBAAAIAgQFBgYDAAYDCQkECQoKAAgJBwoJAwMJAAYICAgLCQkJAAcHCQkDCAgHAAwJCgkLCgkIIAkLDAoKIAUEBQQJBvcDAg0BAwdQBgYICwIAD6AEB3QHAwAACSAMAQAABwk0ChKkAwSsA4IDCg8EDwrCAgUFBBAKgAcGAgYCAwOhjwQKFOAWBgYGCQMEBAXgAwYDCgoFAAkLCwkKCAsKMAMDCgZAECAQCggICAoKAAoIDgoMBAoMABMKDA0LCwAKBAoFBgkHDIPAAfMDAg4BAwhAGkoMAgARoAQICCETCqYKIwLBEwsUpAMFrANBggMLERELB8ECBpAGBRIM4hYEBOEWkAsWBQTAFgcKoBcACAcDBwQLCwUB4AYKCwkMCwMEGgqgLgogEEAqCwsEQWAgDwsNCw0AEwsADQ4MDAsFCwUwBgoIDcAB8wMCEIABBAgHCAoNAgB6EwEzCcAOYAwjAuEsDBoWpAMGrAOCAwwTE0wMCEA54RYUDQEUA8QEBADBAAwY4BYgMQHiFggEBwQMDAYz4AbAPA0MQAigLgoOFg3gGGAmBMATEAwOCAwODoADDhANDQAMBQwGBwsJDkOhBfIDAhECBDEjDu0CABUiFJEJDDACAQDyCTIYswAUB9wB4wwUFIoN4CIEQCQGFg5zCyIFcQsNGgWBJQgLBAMGICoECAQNDboGkQcN4AogBKEpECAE'
    $vMemFont &= 'CgowEwTgCRINDw0AEA8NCw4PEQ+gDg0FDQYQLRDRAkP/AfABAhMCBHAqCxoQAgAWUAKTCQ0ND3sCAPIJGtQBdgvUAeMMFkAWDgkKCwRgGwbAGA8JCAMI0ThwC5AOHAYFACQIDFAXIYE2BQ4OB3ADDQ7ACw8OBAUNoSkQCBQOCzATBTArEw4QBA4RgAoPERIQDwAOBg4HCA0KEYfRAv8B8AECFAIFoDJ0DBECABhQAlAoAAAO5g6zCuEJEBzUAdI72AFhwgEPGBgPUC5wCwhQBxoQCnMLBnALD4geBgUAJAkNBHAoISA5BQ8PB3ADDQ9oDBAPIAQJoBoQCA8gDAwPDwUwKxUOCBEPEoAKEBIUEQAQDwYPBwgOC5gSEA7/AfIBAxVwC5WwLhICABpQAgwMkQlMDw6zCuEJER7UAQhD3AHCARAZGhBQLgVABQkIBxsRIE4JI5AucQsQIAdxCwoOBAQHoDUFCgUQEJAIDxER4CkRECAEGgqgGhMgBLAbEAUOgA8NFg8SEBOACgARExUSEhAHEGIHkDgTEQ//AfIBAwAXAgUMCwwOEyUCABtQAg0NkQkQD/OzCuEJEiDUASES2QHCAWASGxsSDGEBsEodHBILkVdAROGzIgcFGfFSDwQATwBCBhERAAgQEhIPEQ4SEBEFBhDQIg8UEoAQEQ4NEBEG4AkgFxAUEBSAChIUABYTExEHEQgKDBAM/wH1AQMYAgXJQDsPFAIAHREBK+ASmAYREBMB4QkTItQBBgncAcIBEx0dEwyQDQ4FBTBhHxSRV0NRRHALEiQHBnALCxgQBQjgT3ALExIJABETExASDhMSASAECxAPEBYTEUASDg4REgbgCRkQERURFoAKExUYgZAFBxIIChEN/wEh9QEDGQIGQDsQFo0CAB9QApMJEhEVAgB5cRYUJNQBoR3ZAcIBFAAfHxQNDg8GBj0wViEASXALUERwCxMmHAgGgC9yC6FEBhQTAAkSFBQREw8UChMgBAwwIhcUEhMADw8SEwYREg8AGhIWEhcVExEIFBcZkAUIEwkLDBIN/wH1AQMaAwagDg0OERcCACBQAjoPIAgGsBGzCmEVFSYN1AEL3AHCARUgIBUGDmEBIGQjFg0LBMoLcAsIcAsUKHIL4GoDYFZwCwcVFAoTFUAVEhQQFRQgBA0BYCYYFRMUEBATABQHERMQGxMXABMYFxQRFRgawBYWEwgUCRBE/wEB9QEDHAMGDw0PZBIYAgAiE6E20XwUphOzCmEVFijUAQzcAQHCARYiIhYPEBDEBgawbCUXDZFu0E8hcAsVKgkHADsNEgNwC4BNDQcWFQoUQyAH4B4VBgcUoUAZABYUFRERFBUHAcAMHRQYFBkYFQASFhkcFxcUCWAWCgwUD/8B9QEESB4DB8BGEhkCACRmFKE2kQkVFLMKYRUXHirUAdJS2AHCARckJBgXDxBgAaBvJhgOy4As4IAJcAsWLHALYnYCCqBMBw4HFxYLwhUgBxYSGBYgBKFAEBoXFRYwJxYHEwAUER4VGRUaGSAWExcaHeAJCRcwCgwVEP8B9QEEH6QDB8BGExoCACYgRmQSEpEJFxWzCmEVGNos0wEl0lLRARbTAcIBwBglJRgQEWABwIMUKBlwCwx0CxcuClIHgEYOFHALEHALCAAYFwsWGBgVFwgSGRggBA4UExQAHBgWFxISFhcACBQVEh8WGhaAHBoXFBgbHuAJwAoYCw0WEP8B9QEkBCByCxQcAgAnA7wUFhIAAAgAABgWGkUCABgAABouHAIAJxoNBegXA3QBcBkZJwAnGRESEwcHDQANCyoaDw0FDAAFCQkKAAAAGAAwCggMDg4OFQAGCw0REAcPCAAZGAwXGRkWGAATGhkHCBcPFQAUFR0ZFxgTEwAXGAgVFhMhFwAcFx0bGBUZHAAgGxoXChkLDgQXERcfBCEDCBIQEBEVHQIAKRcTUwAAAZkZFwOrGQAAG2owBB0OBR0YAx0CHBoAKSkaERMU'
    $vMemFont &= 'CAgADg0MLBwPDQYsDQYDtwAAA4MBAtw0AAGCBxyABoAEAeAQAAYBxIAHIADdFACygAgCgAsEAAUAAAYABwAIAAkAAAoACwAMAA0AAA4ADwAQABEAABIAEwAUABUAABYAFwAYABkQABoAG4AlHQAeBAAfgCEhACIAIwAAJAAlACYAJwAAKAApACoAKwAALAAtAC4ALwAAMAAxADIAMwAANAA1ADYANwAAOAA5ADoAOwAAPAA9AD4APwAAQABBAEIAQwAARABFAEYARwAASABJAEoASwAATABNAE4ATwAAUABRAFIAUwAAVABVAFYAV0AAWABZAFqAXVsQAFwAXYADZwBoAABqAGwAdAB5AAB+AIIAgQCDAACFAIQAhgCIAACKAIkAiwCMAACOAI0AjwCQAACSAJQAkwCVAACXAJYAmQCYsACaAJsDSgIAqMAAAIAArACrAK4AiGAAX0ADaQB6yAcBDwCHAKoAYgBeQUgEsACxAKnAAWMAAGYAeACeAJ8BQgWmAKcApAClEcICnQCgwgGtAK8BTBNlAG0AZABuAABrAHAAcQByQABvAHYAd8AFdUAAfAB9AHtAAqFEAKPECqIAYUBs/FVAAjhAYARAZSDAKn4FQAipwi+0ALgAuwQA1sB39gD4AP0AAP8BUwF4AsYAAtoC3CAZIB0AICIgJiA6ISLU//9CgSFAGKHAP0cOoL8A2ADfQA75QA6iUkYOGCAcQg45Qw5A/+D/3/+9QBAFAP/+/6z/qf/2QP+j/6L/oUAGnwD/nv9M/yj92wD9yP3H4IzgigDghuCDAADfjFVAmzjEMDLOUyTUWQ71QgGywGSrQFxBTv8+fx8ffx9/H38ffx9sH7gAAAAsS7gAA1BYsQABAY5ZuAH/hSC4AEQduWB4A18AXi24AAEsICBARWlEsAFggAECEiwAAiohIAEDLCAARrADJUZSWCMAWSCKIIpJZIoAIEYgaGFksAQGJeIAAANlilkvICCwAFNYaaAAVFggIbBAWRtGAWVZdFk64AgE4QhABsAFijpZIAhqJAjgAEICL/0BgAQFLEsgsAMmAFBYUViwgEQbALBARFkbISEgAEWwwFBYsMBE0BshWVmgBAYmFeAAKH1pGGQWB2AWBio1AAEIowhTYAhACFmKAoqjASMhsMCKiowbiuAY5AG4AQANAg5ABAIAHwEIAyVFuAgBgFBCA4AjIRshAQIjISMhwBJZRIFADQksS1NYRQATsCFZLQDAQCCYuuA1QAMAAisBuoBMBEUBAb7AAKIAkeBzUVGgmggrvmCmvuoBBrWglEbgnCegUuEBB+AISiSgTBcgqggrgAUBVYCmGcCpDgICvkCvP1VAByiAqRHiAQOABzGXAgbhAWAQCEAEBysAEqsjJGBBFGBUWOCLIoAGgkEglgAABwLVoASiAiCsAgEYYAEHAAwSD4EYL7rACAsAAwArMDEBFRQHIwAnPQETFAYjIgAmNTQ2MzIWAQAVGa4Z40AxMgBAQDIxQALVwgBh1dVhwv2KKUA0NCkqNDQgCwIAACEB5wH2Ave3ABOhCoBJL6A7YAAAYACEBC/gCgMjESNgAAAB9jytBDutAmD3/vABEGEAYAcBQAEoAj4C+6DFHzegmgA7YAYLYBJhzQMrTrrgyCAsYBsBEOAJ3FPgCuAACdDjAA3gAASt4AAP4ADhAxHgAADgAKoT4AAa4AAV5AEX5AMSHOQFHtBgEgcjB5IzMAAjNzIANzMyACQzBzAADwGgAQI+AClhGGEpYSxpBC1IMABaKVoXWUApWSdpJ0cwAJIARxhIAptlO2WWbgAAYABgAABlO5J0gCUA/QIUAyLQDLIm0G2VukJyAQwMgAd6AgAIDYQKcQABCXEBHqX0ACD0ACrQkBAdkBB6DJAQLLB2kRBAeXIAIKuwdgEFIIACAwADCnAACA7QutAcDAAdEaASObgALBABELQPqhu0DyFwABJwACmzDwIVoB0VFAYrARWEIzWADzUj'
    $vMemFont &= 'IicAHwA3NjsBNTMVB0HgABUUMxc04AEzADICCWNrC1h2AHZYC0DWY3MPAFE3Ojo3UQ9AAEAPGBiWPAsLADwDAYAfWEhIAFUoKIA9JSlCAEEpJSEhnx8QEA+eHj0wHCIA6FACOAMZ0AkXMB4r1VB+H7ANDLANILANcVmeDDALcR6TANAJFAfgJ4HjCDMyFxYHNNIIcDIlASOQKb8BsQEBABZMGBYXGUpKABkXFhhMWR8eAB4fAW7+wrYBCEDBTRABGUlJGRHwAU1aHgAAAp1VAB4JCh9TUx4LiAkeWKCSJP6SwAIyrlABCx5XAbApCACgBQNjAtaQCSlQiXa60B0zKRbQChcZsyYYtfAVGFANA7QWMRcitRY8ByEwC1ILkgthFgciAAcGFRQXFjMTA8AWoQAzA2OGNLoAhv6QZlRgLR4AQEAeLV9UZ8MAhloQTikcIXkAeRsWH1ABxrsATLofI0QsMEgAOjxKMS1FJCAAuwEIIRgLCP5A+UwHChUm8AgTUAHnAPyyOAuUOABlEDgT0Df8PJQ3cgsMQP8oAb4DL5BCG3q6IEkPgAwQDlGdkQ0UV5IN0QuxCRFxCgdhFxEBcRcBvk1tLkppADCNTZZaaWBPAKIDL2sPGUz9ALxWGAxqMjx2oAJEfzUrMgYvMAba4DUGAECjMgYFsD0xBhYQAE4xBiUxHScyN0I20AUnJiMncR0VAAHgaFqWTY0wAGlLLW1NYKNPAF8MdjwyagwYAFYCREwZD2srBDV/YlKqAqUCf9XwS0uwDg+wDgbSTHMyrgNhDfIwsRgIEDIJFgHqERABChABCxQBYTqTAEESGxcjJwcnAUEnADMXNxcHAqVIAIVhpkWiNj+XAEiEU6Y8kzYlAAHdfKV1h4I1QHyNZnuCIBAHH0AAnQKHAjwQBSNVsAgIsAgCsAgL2EsEVVAhC3AABlEhI3E3JwIzwDYzAofH4DsAhsHgQAESdXUIu29vsXwBACP/oMsBDADbfBwlUVQQDDyt23YcJgES8AI4Ac1yAjEPMEhxGwAhJyECOP51h6ABiwESu3ECOXBf+B0AvVACcQKgGLQXmF6IHUAyUV4yQF/GXYAB//QAAwQE8GIBewgJASEBBAT8AP3+8wMLAtX9CC4C0nFgHwAEA6q9sAINkD4TUAYVUgYbUSWTHgEBR+IGOwEyKBYlIlAvFpAANjUANCYjA733vDcAvff1vze/9P4AFl14eF03XXgAeVwBc57R0Z4AnsTECWNNTV8QX01NY3ElAAQBar5wBgUyCQS1EUBmJwAhAb7fKYcBj1gEAhZgD7ACGTAJl72wAh0wCTdUsVJxAAhQSQlyEAchIkUhMjU0LiOwEyEoYSkh4C8dAQADl5D9HF5YgAABGSkp/jeQAgBZeVNYWFN5/gDnIBwnvrryaQBDPh0duzg8ZEBjPDgJDRrxmwHR4HoFA/2wQyhyB4B87fIGITArE0QTExFiBoEGTzAHEDABMKwAFxaxCAMAvUAhLl5TZf4AIJAChiMfLi4AHyP+4ZEBsBwEFyHQ4v4KkAJwAGZSXi4hAWk6gEgzLkEiHrrwQAAVCge7CAwXFwALCLsfI0IvNEJKMBoJAAQE8X8K1VAaN5QqA5AqChHekCpqAhAqBVRlCxAycBIAHggSMmBskgAzTSM1IQA1ASERIzUFBAAYkDDg/ZECPAABE+D+7gGPuwDQ0LYBS/66n6WAzQHxBgNn8AYZchALdRd1GAT0FwEHIRUFRxc3BxARA1GR/gA+ATOEV1tbVwCE/diRAZckHAAjJBsk/fAC1QC7OkBEbGxBPwC6DA4bGw4KAaqvMAwb8AbR8AYUkBZtEQcV4ncXBwVQARIHLrwAByEiByEyFxYAFRQHBiMhIiYANTQ2MwEyNTQAJyYjIRYzA50AkP7CaTsBs3IAQz4+Q3L+8b0A9/W/AQ8vCg4AF/4oLJ0C1bsAOklDYWJDStEAnp7E/ek1FREAFXAAAAAB//cAAAUDIQLVAAsA'
    $vMemFont &= 'AA8AuAAAL7oAAAUAAgADKzBAMSUhASEnBOIBACn+1wHe/qmQAAKOQCsxJwUCgBW7GRwzKy0AQgAAAwAkAAUEBgAC1gAhADMAQQAAGwC6ADQACEEAQ7oAGgAqAgciNAA6AlMBAr4CwCcmCicAwzcBAzY3NjNDAWgBaiUyNzYD1CLABwYVFBcWBuSCBwAzA7pIPzhWSABV/vVVSFY4PgBISCQvXlNlAQALVUlXOUD+qAAcGCAhFxz+yQAcFyEgGBwBNwBQIBYa/skaFgAgUAFpOUpHOQAzGRUVGDQ5RwBKOjtNNTBBIQAdFRo0OkhNIgAIDBcXCwgICwAXFwwI/vkmFUAKBwcKFSaAhC4QAAQD5IBtFAAejYJsBoB3gWgSABeCAxYVgnSAbBQAajchMs43gWyBaYBoFgcBWwJiAAPk9b/+MZEBAD5pOv5NcUQ9AD1EcQEQvffrAC2c/vAvCw0XAAFnn8S7O0lCAGJhQ0vSWXA0CBUSFYGtAgAsACACARAB5IDPFwDaE8AfFcBpwR0JwiHDHREDgzIWEcgCARBACDIyQMkAAYcqNIA0Kik0NP6vAAEGKQADwRcv/+wBGTXCFw9CgA1AgNEWFwMQIxEBF8USAkyewYYTpP7gASDBksB/oGADkwLTwA8VQBIUBi/DkwjABgYREiA5MDEtAUFGJRUADQEDk/zjVVUAAx3+YwGdYOEAGEBBGOHFdXUBwSMwALcCTwIcRUAgB8I7BwAEwjsDQ0GawSQhNSERwAACIE/94QIfwQABiRCT/puTwbL5AF5UA2vGHwTEHwJADgSBwh8nNS0BNQWBoAAHAZ3+YwMdVUBVXsZ1dcUCIACAAv/9AAIDT8DCaBoAJsJ6JMB8wR4XO0B/wQEMwiLBRUGwFSMfQUZAfMSrwsqJTANPZgBbgf7o4EMtAQCdGRgiIhgZ/gBskQIQgFxm/QinQTEBUjFBAfkAaD03QJ0mNwcACRISCQa7Nz4M/f9GZ8FDMQBbAyA3AtwAHcAk67rQABAAGUIRI8B04QAKCkQUAAA4AytBFVQAZkAEdmAAhmAAllVgAKZgALZgAMZgANYVYADmYAD2YAAKXUGiB4BZEAAWYAAmYABAA3FBBQA1AAFFiWAAAnEhTQsAAOAmVYIKI4AKI4AKI4AKI1WACiOACiOACiOACiNVgAojgAojhQojgAoj1YAKI4UKI4AKI4AKYCr2FOAKARYdoCnhAGAM4gAICAAg4AC4AAsQMLgAHtDhPOJoNjtAARUzESEiQH8WCDMhF+SeIQE1IwFDAgM3/mdHKigAUkfSR/7+cpIAknIBH1P+jqsA2dupAYL+y0AAHycnHwEHLSoAPD1VygEPdV8AXnpqrI2Nu/5AhnciGhohYUb6QAAEBKoC12BfF3VgRgrgRQEiEmBHIBEEASARJTchAwEhAQOBlGGUAQFbhwEtALv+u/7rAc4WACcrKCkqJRcBAMMEuwED/kICAIEgGBoaFyH9Kn9hNy1gq+tghx0A6ijiSSGkohYgW2MfgTcdqaIRx0lgiSOiBSEVAaUCA6tAIy9dUgBk/acCbxwYIQAhGBz9kZcBwgBlUlwvI/6x/gBxAY8jHy4uHwABaTpINS9AIQgdAcHjmrseIkHgMDZKmkyAmkCbYXXqA+CasGBdEaJsIgKiij4KY7+gzSMtAAEDLbCQAP6WvPf0vwH6gQABXHh4XL66Ycmgu2NNTGCgByTgCTq64AkT4gngHOIJEQBqDqejEQA5MuAYgxsWAAO697z+HeABAANdeHlc/h2OAAFVv/QBc57RAAHC/vhfTU1j1LvEoRIQ4Aof4tMhKLXlFATEXwhhleMVEUAVAhVhAAMfkP2BAwAPkP5hAgyQ/gCEvroC0btMuqZWIAdgiQMWYAkJYj0eB2A96wngFGMIESMRFAMWBQjggOdMuv6o8ALRoQURYAi+YAjaFeIRCeIb5wgN5CfgCJ1EVjXgguBXgikDvkEnAHl4XQEE/uiTMAKL'
    $vMemFont &= '/hwBKsALY03ATV9Dsv5RASogCdo6YAymZB7jqApimTFNMzEH9HkjEYEKQBURMwADpt/+U+DgAQCt3wQBDf7zAiDR/vcBCVIJPwAoBAEesAQD0AS4AAYCcgSyAzMBHt/fogRADQEAL/AGOTaAgzEwNYABECkBNdInATAGOf4+/rgBSABxMUDgAUz+uEC6GB9XAYkxBg0V8AOb8AMK0Eq4AAXVMAYI9AoD9FcFcESxXE2VAAqUAFGGJRXACBWB0IYDm/6s/qZQDABaAVD9/gTx8UAC0ff3/pJxUAHU//8wBg0wBgUyCnEFAzMXsx8zEQMNkf0kg9/BHv3pkQEV/4D7BTkC3gAYEBDouAAPsAgVNAnxCTEOVgKxBNIICZYAC5YAEhOUALESCwFBXScLAZAjEz4BQEAbARJxAAU59V/KKEYkAEQRy172uwtHAC5HNNzdM0cvAEYMAgF9/rs/ACQbAUX+gwKAACc1VP6ZAWdUBDUncAk5//8DkrFwDBAAJ/QY8R0LMAA2D3QX8wcOlADwBxQjmCInAZAeQWUXAYAYAJJZQDr+WuAzAC89NAGm4GFiADABYf50AnQoQDQr/p8BjXNjH7VwTV9wBg0wJBE5FhQ5EgsXOSsBYik7ATIcFiXjVKAA8TkEX/cEvNkBpNm/9P5NoNldeHhdQAB5wTm5ESrECfEqITq0H8jyMO0xNQbyKRN7EpKK13LJPwAXFgPIaWWV/gCH3wJuLj8/LgD9kpQBxZRlaQABx3pMSLUBcIAuJiYsu0hMcAyqFnAMlnJKIRI3GtQFVgzwBVFaBFBaAFFaIY4nCQ0xqzUNJyEXUg1Alv66GEVQhQ1fBP6skg2mYwFEByAfdwQTE7INnoYIZgGT8Q1TBio1NE5iUiYcMAhxgRcAtiUysnM4BzIyIXkNVILoAgAHNC0n8w5RW/QOABUUBgcET/67ANr+zOACbjklAC+N/ZKSAcepQGl2X1QEtSAPEQAWK1S7QEmHTEZ7cWmwEwQD2TAHI/dSD7MUd0YHcBB1RkCxd8EHEaj1s3SoA8KQ/gIAKSkBb4NYW1wAVoT9bJACBCMAHCQkGyT+kXogUlhYUnoQSB0dAEBEbGtCP7oMAA8aGw4KODxjqGQ8OHE39nAIaHAIRgfyHXc3uAABkBcFCZF6ByPAKSE3A2hAkdjg/teQ0AT9kOoCFrtyOwAy8ANa5fADElAosy4RMAQMAfZFISMgGQEzEQMxsmRG5f4+L/4+gN9WLo5xMEGSRgABSAGJ/ndiHAYQFEdxCe//+QSjfbJcGXIJcxnxJ7FncYswBDEJcTsnASEJAQAEo/4aPD4+PAD+JgEWAUIBRAAC1f11UVICijD+QgG+cwrQowUltALd0ARBNEwxORTyDqgFABQyOQiWAA+WAFoRlgAYlABQDQPBfCITAENyQwMzBEMbAQUgJbsLIiWEQi5HBAu7EkQlQxLKXgEgCYAmGhxUAWcA/plUNiYCgP4AgwFFQCQc/rvUAX3wCRMwKFcyWnEUF7EOMVbxQwXwXAkCIQYLcQ6hDlf+mwFVAP7j9fb+5AFUBP6coIsBAQAC1QD+kf6eAQL+/gABYgFv/vQBDNUwBQUwBUowBQi033MPGgLxBAHQrZADEwRKAP5U4P5HAR4BBA78MAQe7/AB4bD+2wElMhOxcL02f6oTlJwLFNElFCgBBTAABwEhA7386DYAIys2AbH+CY0AAmY1Jisv/k8AAY0EEhYqLi0AAWm7FxkrKygE/pfxL/+6AZYCXphxduEWwUswBhA0BgcBMjcwMQUjIjURNjQDP+A/EVAWgAABUQD+RET+HCkpHAS6ulAARjYCcTfAHBsaHP38UQDzI/DwAAMEUBF0cbEPcQ8BMe8EAP70/PwBUAYDAtJwCCBwCKj1cAgZcQgAQqtwCPMrMT9tdAgUsEfzNjugWqYAMgAVAahF/hwTFgwWE7EIcgD+RRA2Qg1QNg8NAgRzADeBcY4B0AIYApNyhRXzahEw'
    $vMemFont &= 'ABMydLgACQAvuBS8AAAHLzAxARQGICMiLwEHAFAmNQA0PwE2MzIfAQAWAhgrGRESnQCeEhEZKiTADQASFA+/IwIKGAAhCEVGCCEYHwAQVQYHVRAAAQAADP86A7T/9UAAAwALALoACgAAAAMrMDEFITUAIQO0/FgDqMYCuwAkAAEBngLj0AJcA1EETgEADgFOAAEzFyMBnm1REFIDUW4AJv///wD6AAQEqgLXAggGACEBDwAtAAVQA+sC1gAPIgIPAwAABAOwAtUABhQAIwIPJAAPugLVVQAfJAIPEAAPHwIPJVUCDwcADxYCDyYCDxFVAA++Ag8nAg86gAemBYIHKIIHPwAEAR5VggcpggcvgA85ggcqVYIHDYAHm4IHK4JX/xWABw2CByyCDxX/+1AFOQLegActggc5UP//A5KCDy6CBx9VgG9fggcvhifIggcwVYIHFoAPloIHMYIHHFWAB0+CBzKCBw+AF9lVggczgj/2gAdoggc0VYIPMoAH5YIHNYIP71D/+QSjggc2gg8BQP/5BSUC3YAHN1WCBxPAF1fCBzjCAwVVwANKwgM5xku9wgM6AcFxAEX/LABuAxIKwGETugIEAysAgLgAAC+4AALAkgAXIxEzbikp1AAD3gAAIAA+AIAABUgCDAAeQFUASwBVAF0AagAAdwB/AJUAnwAAqQC+AMoA1AAA3AD9ARIBGAEAHAEsATIBOwEAQwFMAVABVAEAWAFeAWQBaAEAbAFwCMC6AVAxApa6ALcAKMABATdEAK3CATwBQMIFx7QAT8IB0wAVwQFXgBbZwQFCAYCcwAkwAF7BA4jVATHCAY0A18IBWB0AkMABADAQADDQEQExugEUwBi3ERJQObgBFIA1A0AFA1YvwAJACAfAAgfABAUBwAIJ0LoAYACtJAE3QQoAYEAFqdywuAFh0MAAwAJNwAIgRNy4AAtADAsvgLoADABNAURCCqpNwA4QQAUQwBREwAJOFMACwBnBAgFIQA0cVUANFsAEFsAEMMAHGKvAAsEJGcABGcAEMcACqhrAHtFAOFdCFNFABYhU3LoAwNEBVEMEtcAIKMALKEAiwQLMwAJWKcEAwAPKwAMqwBjTVcABLGACLGACV2ABLlVgAS7kBTBgATBgAcxVYAExYAEx5AI24BNRteAAOWACOaEOYAE6YAG2OmAB4QI/4APhE0BgAqpA5BdDYAFDZAFFYAFqRWAJ1WABR2AFYQJKtWQGS2ADSyEnYAF4YAGqeGABTOAATOAAT2ACtlMgK2EwX+AF4QBiYBiqqeAAceAAZOAEZOAEqnHgAWhgAWjgDTdgAVptoCJ1ZTSiBpqgBXerYAAhBXwgBXygBpBgAaqBYAGN4ACF4AB34ACqluAAmuAAtOAAtGAEWpvgAJvgAGECsOAHnhXgAZ6gDEDgAaPQulQBYmBBqaIMYiACqFWgA6ikBapgAapgAbCtYAG7oQngAL7gAL5gArVhMMigCcDgAeEywuQAqt3gAN3gA8PgAMPgAKrIYALEYAHU4ADO4ABV4TLQ4CEcYEYrYBzfRcBnK6APugDl4GDHU+IQYAMA52AF52Q+7FVgAewgFitgAfFgDvjV4AHXYAH+4AD+oF7BtKodokdKoAoEoAJH4ACmDeAAYGMBFiAG8eAAVaFQFuAAG6APGyMYASodYAEdYAEqYAEe3Ci6ASOgcCyhEQEoVaBx02IKH2ADLeAELRXgBG1gATNgATMvQYAVAGYBPAB2YACqhmAAlmAApmAAtmAAqsZgANZgAOZgAPZgAEAKXUEHAAYAARYFYAAmYAADcUEFAEo1AAFFYAACccMUTrXACk5ADDlgAQFGU2ABVeECVWABVYAfUGABV1NAGIAxAVtgAlsAH1ywAJoAsIIUoQJdoAJqXaAGpmABXyAFQEwBVmNgAsA6AcBMAcBMAapIYAFlYAFlYAFhYAFWZ0BSYQJpYAJpYAJoVWABamABZ+AAa2AIYK3gAG3gAGEIb+AAHeAA'
    $vMemFont &= 'NHLcwODM4I+hkAoAjgniAIDV4gDQAM2illwxAKGb42OhkwngAA5V4AAO5IASYAESZAEVdWABCuAAF+QAITThAh+15AYi4AAiABthASZgAdYmZAFxQQRwACv0AlAanfIAL7FOcACQGgAzNAaqNrQBOLQBPHAAPHAEqQANAI8QIkJwSUWwC2rQ4hSPUAFGkUBwAEj1kAFL0A7MkgERAbE9EQKqTXQAWJQCXHQAXnQB90EY8S6QVQCRVTEBARnxCFXBFG90DHOwAHO0AHZVNA96cAB6tAt+sAB+q/ABsQWDsADQcACUcADulDQFET+xAZh0BxE/cQCqoHQBovQApbQFrrQQqrJwALJ0B7V0CbkwAaq59FO/sAC/sADNsAB6wbAAwbAAsQexPXEFxVV0Bcf0ANH0ANM0CtXV9ADW9ADYdALadAixQlVxAOFwAOGQZuUwJAdrEkCRCOlQAekQB5EK762wAO+wAJEb+rAA+lQLSxNAsgABUCYBAhMTASoGsAAGswMBcGwBC6mzAwEPsAAPkxQBUSe90AkBUSdxAPFBcQEa0xGrsUEyAyEwAyHANiPVCevSBnAoAXQoAXAoUgdwKF/yAHEokQNxaXEANfABNVvUCPBnAfBnsgA+sAA+NZQJQrAAQnQBkCcBRn10AUrUCLEm8QBgQrEUATpSMAJS9AcgQnEzAVb90FxcNCxxXdUssBxFP7EcN8U+cgTBPmp0AYA+AW0VdAFusABuYJETMzUIMzUjMgAhFSYjACIVFDMyNxUzA8AAMAARIQE1NCMEIgdwAQc1IxUjATABIzU0MzIdASWGABdBATMX8AAVI4AlFTM3NSc1MACoBRUXoQAjUQQzMABFQQEvQAMWMzICBTUsIxdgALEGBcABIwdgFR8BFSMgBFEDL3ABNTMFQgG0A5QAJQAzNj0BIxUUI8YiYgBgChQrAeADwgt9kQk3tgCACIIAcAIiDRdEBhWQBzY1I4DENRA0OwE1YQAzMhe8MyUEAsAEswFBAQGRCBQzIUAAE0IOFzcm2ifyDzOAEZAFBWDIYQjcJzdAAAICpQMFYAoxAIEQDBUTNTczF9ACgVEANzMVIz0BQAABcAE+AUMSEhIBALcHES4wDxAYAAF2IgFo+vYDAGwvGAcJExEKgCATRhMTDzMwAABROCADCTogAwD9+08LCAgLAQALCkMMC0T9ywAmCykPDwteIQEBBA4RGNs3NjYANwLFJgpCCwwAJQonC0ELDSMACvxgGikXJQ0A+BgpFyYM/v8AFTchFBMgLg4ACxwPAf0aGhoAQEAabBgYGD8AJwEWJxVR/poADwsWKxYXASwAFhkPAxYUFAoAChQUEQgPAZsAEAwSMjMkCRAAAxYXFxcCEPwATxYmPAHaJ5oADg4GBgsICRUAChMsyw8i/T4ABg8VFg4GnBYAFRUWbwYOFRYADQb+FhMDDgsA/NQTeQYCBcYABQMEXQsLC90ACwElLxxYHyUALg1NTBMRuBqAGv30AVReNqAIABd3HBw9FxdZABw9FhZZSb16AnohABU+DgMONwAUFJQVFZQUvQBTU0wVAxQxFAAaOAxMTBQSSwBOTkx/JhQUQgAUCSYcKxUVSAAVCCGbRXh4RQQkJFMA1wZBe1sAGhpbVUAIF6QAISMovSokISYAKL2VlZUoKAEABBcaKxsJCRgAKhobEw4SEhEAEBQ0FRpOSzoAFygpG/7Ok70Avb0BIkEUBiEABwEYF5OTH3QAkzIPJisQGSgQKClADoAASFhYAP53dwF1JSX+IKcTMjITMgAvTgYpAAAy5QAQAocAqHoCn8BzEzDIAYE/C/F+MAAGQTcHIycHAfAqFzd6GCEMCgAbFx0ODQKfGAwODiAA8QMCADX+ar2Qx5BgdxNw1ZEDugXwzguS6RM9ATczcBYdARPR8XDx4CgWADUZrhkDQDEyAEBAMjFA/r3CAGHV1WHCAnYqYDQ0Kik04NcwBQGAfgLyApEDSlAEaBcAGyB+'
    $vMemFont &= 'AJDqBcYMjSBGBmJ7kO8yFhWlBQIjuAACXRQgIBQQFSAglXQAA0oZgBMUGBgUExlzANQUGPL0uPD0d/T099cCAfAOAgpSUm0CBuPx9HACSP8sAmyAABgAFQCaurBXFhDACHCTOoAASgAQWrgAAAJxQRUAaQCoEAB5ADCJADCZABiqqQAYuQAYyQAY2QAMCukADPkADApdQQdUAAkAIBkADCkADAMQcboAAQAOBBESEDm6AAIEErgABAAQuAAX3AC4ACAIL7gACgAGAC9RATwIAAACPAoAPA0Q3LoAFQQiMDElADMHFhUUBwYjACInNRYzMjY1ADQmIyIHAew5AC92QDxPJjMhAAwtRjAhCAwYAC4RRC8eHAQZgAIlGxQXAQAAVAAU/ssDZQGeAEAaACYAGwABVBYAAAMrugAeACQRAgcFAAsABzAxFwA0NzYzITUzFQAUBiMhIgcGFQAUFxYzIRchIoAnJgE0NjMygD8BAD8mFGVbggEXAOBCLv5jGRghACEYGQGUkf3wAIBbZgJZQDIxAkCBAVloPTdAnQAmNwcJEhIJBgC7Nz4CASk0NAApKjQ0AP///wD6AAQEqgNRAgAmACEAAAAGAExAHgADkAtgZIkLTqmGC6FakxejiiNKhguUX0aJC3CGC6IKgwuA7QAEBpUC14COACHzAAAHACUDAnaBCwAB/ywDrqQC1cAFI/7BC2GAC1PBBcBwAx/CHSXDL4m50wVgnckFwS/DBaHKBQvBKcMFX8QFNwAEAQoewhEpAAQHAED+KpnCBT/ABULIBWD+asvCBR7ABTHCF8MFodT+rcIFIcAFNMIXwwWIX/6jwAEC//HAHYLdwDUTABcAI8CDiAgAA8KBEQAOwgEiBsKHuAAWAKEV3AgwMQHBgxEzESEBQ50hNyEyFgUhABUhA933vf4eAOABAl14eF3+AB6OAVS/9fwUAAGk/lwBc57RAAHC/vhfTU1jELvEoXDDNTn//1QDksIvLsNrxcMFH3XAZV/CBS/DU8NlzgVgbjLJBcE7wwWhw3fOC6NOFMkFwUHDBV88wwUsQAADBGwC1cEFDanBBQ9TwwUywEflwhHuNcMj5D7tAmDqAuER4wKuoeoC4Q7jAl/kAgXgEWhKA1HgSjnjCOQRD1AABAfJ4k0z4jUzPAPw4jXkXOADITa4AC4QQIUAe2I0AGA0BNABwIM3IQMBIQE2ASB4MhcWFwkBMwAXIwFbhwEtuwD+u/7rAc4WJwArKCkqJRcBwwD9Em1RUgS7AQAD/kICgSAYGgAaFyH9fwNNbguBE28NEn8NCQEjN0IzdA3EUlJtbQ0C6t9qDU5gDRbiUOMM4VBiE+gNuAAT4VB0HCcCB9UcaYJJVDc0QlQuHUpmQUFtHSN34KLgDMCwGP8d4B2BoTNYMjcz4rHhsAZ1LQ8AA1ciZRQhDA8ALxUXImcRFwsCBM4h6mM1NUAZwAs2EwYAA2WXYBKgGwAnACuoIhCkcrWlIhDgABzgAKF0IrEUYeW1NTQ2I2gBNBX5ABQgIBQVICCVA+QA7iZGGRMUGBjIFBMZ4wAUGOESZaqh5BX7uAAogCgpYABqKMASGcATGeEBYAET1aDZA8DiE+LbDCEDoAJUH9yA62YgdHZgAIZVYACWYACmYAC2YADG1WAA1mAA5mAA9mAAgusqBgABFmAAJmAAA3FEQQVgax8ARWAAAlJxI0Ul3IACOkCqSqtgAIT3JYD3JYD3JYD3qiWA9yWA9yWA9yWA96olgPclgPclhfcloBRaJUCmJeAL6i8ccgAiO3wY8RcKUFL/FzcXFyIPwHRUe/8X8hekJTg3ACYmODgmGSMjEBkXJCT+F2wxJQAmMTEmJTEfH6QYGDAAFyAxLOy0a63xF0kwLKGEEzAsGxABbdEKFNB+cQAYQA1RCxu10AoBUAsBMALhGBjiGBYPtAxxABG/JAElBzAhESEHIF8wAAFNAf8LAcMB+ZD9gQADD5D+YQIMkAT+hN0LuroC'
    $vMemFont &= '0bsYTLpWcTewTiwDraVwThEQI5y64BQioAlVQhsiQBsiRRsiQBsiVUAbIkAbIkAbIkAbIlVAGyJAGyJAGyJAGyJ1RRsisAwiQBugBBCXE1tRGhKXFJQAcxopEZcaRSASHOAPCQAKohEA2yAecQAToR6iAhySKWAQtAch4hszcA8THBdfmAHQPwOtkP6WvPcQ9L8B+oAAXHh4BFw5bZm+utGenoDEu2NNTGCmHZr3MRG0g5CYD7AsADIACoUJdgigCnEABJBjcZrZGBOpMFADH7oXNvBdvvQW7AKTs1b+BQ7/Bf8F8QVbsF38BbYwXfYFJfoFTu3wBRJSS7UFDXQoOwaYJre8DPBc7AZlc1wWB5D0W64D9ZMwB3GMM1gHDFAIV18HUBVQBxhwLhJwAB7P3Af/UrMA7AgBCYxShglijA9SAgA2s5zQCgd3kDhQNqS+BrAKkcAwCCMIETMn0Xoe39/oUaF5AtF8QRUC8p5B9bgDBrQDBVGDtwPRd7ADokqhdgLRDrMDHbADujDwGANALnF8cwMHUhB6B9APCdEPlAcxdAAEuREEcwLReSEWAwAgdTAEM/AVA9JFUSNRBATbYjMTzBCwFKHKFtUEPxSLM2fgBR8NZgLRdR8TF7ELdKLwHSQQQrgAAutwD7EPFDAAGXIMMM3SPRYOlADQBxQgOQERI4IRgcoXAREzJU96AAYDkllAOv5aAOAzLz00AabgBP3Q33lhYjABYQD+dAJ0KDQr/vCfAY0Zx3kyJzSmcC3fERGRFaFEEGFyJgsStBKzlCsBkg87YCUlI8JDB6AA8l8QFwRf97zZAL339b/Zv/T+jE3Z8bNAAHn+oPAfA7GzsULECWNNTV/5EbQBNzEdvwcwLL8HvwdvuAexIr8HsgfM4COvB8lqbnYHTnIHIpKaNQcd70F4tgdAU7AgIbAgPwj7DzcQJ28IIxD3UyivCAE0q4M/exAvkpsfkCEkvxAnfwh4CA8iBwZPCV0MuwDZXXh5/qoPAwBXImUUIQwPLwAVFyJnERcLBAABc57R0Z6exADECWNNTV9fTQBNY9RjNTVAGQALNhMGAAQAHwAABARfA0oADQAAGwAnADMAKwAAugAWAAMAA0ArugAcACICDgsEAA4ADrgAHBC4QAAo0LgAIgAOLgDQMDEBFAYrAQAiJjU0NjsBMgAWJSMiBhUUFgEACjY1NCYDMhZQFRQGIwIdIwgLBABf97zZvff1vyDZv/T+TQC0eF0BAblvFCAgFBUgDCCVBAcPtQEwGRNAFBgYFBMZAwcUABgAAAACADIAgAQD5QNRABIAtQAPALgAEy+6ABIMgAsDK4BPECEjACAZATMRFBcWADMyNzY1ETMlADMXIwPl/j4vAP4+31YujnEwAEHg/bltUVIBAEz+uAFIAYn+AHdiHBAYH1cBKIl8bpIvFZwvIzeCM4wv/iVSUm2PL2oOiS9OgC8ZgMCFLbqsABSBwoC5FoC1GIG1CZNlJwcOZ9SCSVQINzRUTxx5ZkFBFcAcA8QcSsAcHgAqtAAjSB0TQCFBHRNAHeofQHoZwAElVB8UeE0/FnhNds4ldQ92AgAFVcClSsBdCMAmKcBdCzAvuAACwF7BBgsRWBI5ukAIRQIKRAIwADEJARUjNQEhCAETJ8BhBEr+VADg/kcBHgEO/ALnwGAC1f4e7/BAAeH+2wElQF8DxcQYSsAYFAAgQMJDGFYJwHnBQAnAPhXAQA+9wAEbwEDHFpW2yBvQTD0TyR7PO///wNoEBo0AAtUAJgAv/QCgAAcAJQPBhwPAhBvDBcPnO0jnQ+W6ACRUACVGihzgFQPgAB1V4AALZDgO4AAhvHUBgAchESEHIRVhAAQEWzJ0A4mQ/YEAAw+Q/mECDJAE/oQPdP6kugLR8LtMulbiFn8rfyt/KwF/KwAAAQFxAugUAoRgbAbgW7oAAZviJ+MkBeEiw2gBueNmBANOw2QAAgHmAiDDAqEDcCAtFwCWzcBwQFAZYAAD'
    $vMemFont &= '3GABFYAHCQAYCeABD9xBqBUAZiAbdmAAhmAAqpZgAKZgALZgAMZgACrWYADmYAD2YAAKXVRBBwARD8KJJsEhcVBBBQA1AAFFYAACEnHjEhXcgAI6ABWkAEpgAAJx4AtpAAGqeWAAiWAAmWAAqWAAqrlgAMlgANlgAOlgAFb5YADiCwkAARlgAClpYAADcWAeEkAOYUUAV6BpIpdIKxcCQTPiQAIARCU4NyYmODgAJhkjIxkXJCQAA3AxJSYxMSZAJTEfHxgYYAAXAiBhIwEBjwLtArrA4HMTIABgFsAgCGAAEgBgAA0v4AsjNjMiMiGFMxQHwQwjIpAHBgGej9MC7mfRAAEAKAIjAREDajPgMwtgCgHiCWAJEQAjAwERrjsDM1D+8AEQYWUj4AQMxeAEB6AZAAJYYoJgB7QCH2IHByISoQcFJBLKBKQIISQJAfelCSIK0gBkCgIa4AcnZApgCxQBDmILAaBXvwHINAJVwCojIAsjCrgAqgbgWQLgKgBikAgkAQAwMRMfAQcXJwAHNyc38D6acwAmhYIhdpkCVQCNCmaVTlKWYgIPYA05AAIG9QAKvcA/DuALJwCyASJP4gAOAuzjAQQ7QeAABwAOBdhiEyyAAAMEbALVAmCDFA0AgUdTYTADAClA//8CVQIr4B0ncABCASRBY2ABYB4tS4BCcQAKAF4DK9IpFFXQKRTQKRTQKRTQKRRV0CkU0CkU0CkU0CkUrdApFNUpwWcU4AkU1SlaFNApFIEoUSkeUCkeVVUpHlApHlApHlApHlVQKR5QKR5QKR5QKR5VUCkeUCkeVSkeUCkeV1ApUAnRA2aACnYwAIZVMACWMACmMAC2MADG1TAA1jAA5jAA9jAAVAmqLVAJLVAJLVUJLVAJSi0yMwowM0TcgC4ZiwJGwWEjcgAwADZyAAZAgG6BLxM0PgIzADIeAhUUDgIjQCIuAjcUHvAAPhACNTQu8AAOAiXToCrkMDcXkCsukAERAwAXKSxLZjk5ZgRLLHUAISdCWjNAM1pDJydDcQBCACcBMBolIyotAYBUDDImSx4zJQAVEyQ0IE4lATYVaQNwADjRAtMDRCcAJ0RaEyQ6MzAAPBEOIj4aLz9AJSVALxpD8R0EAAAvAI4B8wI1wfIdLgA8AONxDQF62LoAMUB8cQAj8g6yFKoFsBQFsBQFsBQFsBSqBbAUBbAUBbAUBbAUqgWwFAW1FAWwFAWwFLoFtRQFsBQQdRMeDxAeq8FIEh4PEB4PEB4PEB6qDxAeDxAeDxAeDxAeeg8QHg8QHnRN4V0RGClRck24ADEEozJwADdE3LpQKRkAI0AyuNQAIxABPgEbCkEmgAyuHqIrcDpAGBVIGQMmGAFDGwMVMzI1NCMcByMAYyBGUEwHFyMAAQ4qQy8ZGS8AQyonRzQfHTMARykxUjwhITwAUjExVD0iIz0AVEkmGBgOGC0AUiAnEhQpMAIADB4wPh8gPjASHgAXJB9wAP6CIwA6TCorTToiIQA5TS0qTDojAQAUNBkbY1TlJmAjFx0NWzJPYA3C0ADFAZvgExVwQNFFBRWJBZM/FxUnNTcAFV9mnJwBLjAgPE07UT7SASsBoAQB+AIbkkmPAWjFw5YLwli6ABHAQ3EAaRAXABHSEREiYDQGDb0wABAwABFN4WaRkBJwB5YG8ARxbAfAAgPQEUh4CQAN9JCTADBKsAEOqzGA8AIPWgERUAERcFEGE3AUkBQVFwcnFQAjETMXNzMRIwCtO0fHzjxCNwBDNTRBOAHk3wDfNjZGmqCeAaAVj4/+634QApJWB3EQ8CNzECc1FxUHZDWPcRAwL3cQcAMB2llyAw0QLdMNDFIUkQ1NlxS6kA08FR8BphUuRegVL1QWAgA0sAVkv7gFMwU1BtcJsQV1CgFzCvQvAWIAAYEFwgU0C6cLAQIAKgBIALABOAABlgHwAgQCNkACZgKsAtSQhfwAAxgDLgNiA3gAA7QEAAQ4BHAABLAE0gVABYAA'
    $vMemFont &= 'BbAF1gX4BhYABjYGgAcwB14AB6wH1AgACCYACEgIegigCLIACNIJBAkcCWgACZwJ0AoACkIACnwKwArgCwwACzQLhAuuC84AC/wMLAxADHQADKYMugzODNYADN4M5gzuDPYADP4NBg0ODRYADR4NJg0uDTYADT4NRg1ODVYADV4NZg1uDXYADX4Nhg2ODZYADZ4NtBPkFAQAFC4UYhR2FOYAFS4VOhVGFVIAFV4VahV2FYIAFY4VmhWmFbIAFb4VyhXWFeIAFe4WKhY2FkIAFk4WWhZmFnIAFn4WihaWFqIAFq4WuhbGFvwAFzIXche8GBQAGNQZLhm4GegAGhgaUhqkGsJAGuAbAhs+EACMABvKHAYcThygAB0AHTAdYB2aAB3sHh4eZB5wAB7MHxIfLh+8AB/mH/ogBCAkACAyIFogciB+ACFuIjYiUiK6ACLWIwQjNCM0UVI2AAtg8IXj4HQIRAVSkB0U/2NQACFE/stQACr95FAAQVWyAEqwAANwAdpQACpU/fVQAEGyAEqwAAcVUgMH0AHvUAAq/qJVUABBsgBKsgBT8EYHBABU0GMIABD/BYlRqv7wUAAW/wlQAIgY/yVQABn/R1AAIiESASL/TFAAI/8iIlAAJP9cUAAn/yIUUAAq/rdQAC3/ig9QAC9yBDD/W1AAKDH/DlAAMlIDM/8RUbA0/2hQADr/XlVQAEEyBULSAUMyBURVMgVHMgVKMgVNMgVPVTIFUDIFUTIFUlIDUxUyBVQyBVowBQwAEea6AP9gAAwANP7wEQBQNv7ZAFA5/sRVAChUAohWAohZAEQNEAAR/0EAFBP+txEAFBf/JgAUIf9dEQAUKv13AAo0/wERAAo2/wIACjj++xEACjn+uAAKOv9JVQAKQQJSSgJSVAJSVlUCUlgCUlkCKVoAKQ5FAGVOAAUU/o4ABTRE/uIABTb+ygAFN0T/ewAFOf62AAVUVQIXVgIXVwIXWQAXD1AAEP9CAAUUAK0PEAAW/0YABRj/dBEABRn/dgAFIf5HEQAFIv9tAAUj/14RAAUn/1AABSr931GAAi3/M4ACL4IgMET/fIACMf9LgAIyVP9ugAJBgh1Cgh1DVYIdR4IdSoIdTYIdT1WCHVCCHVGCHVKAHRAVgGhkgAIhgAsQADhBgLYQADn/XIACQVWCCFiCCFmACBSAFGJRgAIT/0qAAiGAXBQQACr/IoACNP99UYACOP9sgAI5ghE6VP9xgAJBghFKghFUVYIRWIIRWYIRWoARF0WAesiAAir+tYACQVWCBUqABRmANWGAAjhVgGUZwBRaQAFYwgJZFcACGkAHV0ABNP7r1UABNsICOUBbGkBeQQSqVkIEWUAEG0AKVEABFUFqG0AKUUABOf7BW0ABwWgbQApBBFlABB9FwDV7QAEh/whAASpU/fJAAUHCAkrAAiGtwG52QAHBHSFACnhAAaoUwAshwHF6QAEvQgeINP8dQAE2/n9AAYg3/2ZAATn+kEABqk9CB1RCB1ZCB1dCB4pZQAcjwIOvACRCYaokQmEkQmEkQmEkQmGqJEJhJEJhJkBM4EABiCr970ABLf95QAFqQUIERUBHJkArwQVNQcIFT//UACrAFKRBQAFB/4sAK0AxOxFAART+/kABFv8/UUABGP9yQAEjwDUrFcCbSUABL8IIMf9EVUABQ8IFR8IFT8IFUUHCBVn/6gAswCw3EUABFP4MQAEZ/zxRQAEv/7xAATPALCxFwFz9QAE2/r1AAThVQHwsQENwQAFTQgdUVUIHVkIHWEIHWUAHLVVCWC1AalRAATfAJi1VwEE4oABWIgJXIgJZVSACLyImLyImL6AoIqugAOEmL+ImL+ImL+ImKi/iJjCgNnKgACH/ojmgACr/BaAAQWIBqEUAJaAASiACMaIPijGgD1WgADn/JKAAqlZiAVlgATKiAzLgCGJsoAA2/2WgAGETMhdgBGEBoRIzYEDvADRF4CxxoAAU/sagABYVoGA0oDbe'
    $vMemFont &= 'oAAj/84RoAAk/8WgACr+jVWgAC2gaTTgJnCgADAV4Ck0IC95oAAy/xU1oAA0oHg04DthB0UAqhygAEqiBk2iBk+iBppQ4Eo04DKhBlL/oJJFICysoABU/0egAFcQABYANaAejgA2ZaASd6AAFP+gMqASexGgACH+a6AAKv56taAALWCCNiARYQRB4gKoRQAgoABKogNNogOCT6IDUv+KADdgCqpuoAAqYCI3oAbboACiQSICRQA/oABK4gKiT+ICUv/noABW4EaKOGAQa6AAFP9PoADoFv9voAAnIGjgOeICWjFgJTjgTSECTyICUVUgAjmgBmWgABRgNDlFoAZpoAAh/qmgACdE/3OgACr+V6AALa2gVDngCCEFMSAROaAYW2EE4SY5YAohBUoiBU1VIgVPIgVRIAU6IAsQFAA8oAw3oAAR/z5VoAAT4E084AIloAAWFSBfPCBlbqAAI/9TUaAAJ/9FoAAv4gUxFP9AoAA0YBM8ADVE/02gADb+UKAAN1UgvDxgXnigAEOiBkdVogZPogZRogZUogZVVaIGVqIGV6IGWaAGQVVijkGiTkFijkFijkFVYo5BoopBoopBoopBVaKKQaKKQ6KKRGJkRFViYURiYURiYUUgADPUAEbihkYgACJgAOGGikbihkrgBZsAS2KFqktihUtihUtihUtigqpLoipLIoNLIoNLIoOqTGKCTGKCTGKCTOJ9qkzifUzifUzifUzifapNohtNontNontN4miqTyIXTyIXT5ILT5ILqlBSPFCSO1AyO1ESBKpRcjpRcjpSEgFScjpaUtAK11AAkSxS0ArJEVAAT/+6UABR/8OrUACRO1ISB1QyO1QyO+pUMjtUcjdUEjfQCRA3alQSN1QQNy5QABE3VFWwLRVQAFRQD1byNVZV8jVW8jVWcjRWEjRW3RI0VhI08BywJFcyMtAPVZBxWHIxWHIxWHIxWFVSMFhSMFhSMFlSMFlVUjBZUjBZEi5Zsi1ZVbItWbItWbItWbItWhWyLaRQAGNQACH+71FQACr+olAALzBcpF1wIB5QAHBIUABB0gFF1ABJUABGcBGkMAWRAqhN/4dQAE/yAlPwAqql0gSl0gSl0gSlsgNapfICpTQC8VqmkgKmxZACy1AAKv3kUABxB+qmcgemcgemsAPRAXEHuqZyB6bQKJECcQemcgeqpjIFp9IEp9IEp9IECqeyA6fyAgAAGAGYJgABcAAAAAEbQQAZowAADNAAswACAAcEASe0AAMAHgEuFbQABDACTLQABQASVAFYtAAGcAFqtAAIUAALAXa0AAmwAIFBtAAKAT0BjLQACxAAGwLJtAAMABlEAuRQBgEECYAHNgQC/bQAAQAYBTNBtAACAA4FS7QAA1AAPAVZtAAEMAKVQbQABQAkBa20AAYFcAHRtAAIABYF6RW0AAmwAP+0AAoCegQGFbQACwA2CI8BtAAMADIIxakgADE5OTkgUmF5ACBMYXJhYmllAC4gVGhpcyBmEG9udCBxAHJlZQh3YXJgAVJlYWQAIGF0dGFjaGUAZCB0ZXh0IGYIaWxlkAJyIGRlAHRhaWxzLiBJAG5mbyAmIHVwAGRhdGVzIHZpAHNpdCB3d3cuBmzTBWEFcy5jb20ALiBEb25hdGlAb25zIGdywAJmAHVsbHkgYWNjaGVwdPAFYW8DYQMvAmRUAy5odG1sLiAgQWxzb1QGbXkCIAACbWVyY2lhIGwgdHlwoQl1bhxkclAFwwQwAW9kZTBybWljEwiHDndhAnM0C2QgaW4gMgAwMDQuRXRobgBvY2VudHJpY3BSZWd1oAhgElQSOhog6QE6UhQZAVZlcgJzUAogMi4wMDCf8gTqBOcWqABkACBGwQ4JsRdhYuAVdG8gbwBmZmVyIHVuaRxxdTANABlCC3MgdEBocm91Z2hwAGUgIGdlbmXQAHMggHN1cHBvcnRAA+lzEW9ygAJvMgLQAHAcwE1ha2luZyQEUAYDcBOxFy10'
    $vMemFont &= 'aW1lIABqb2IgYW5kIFhldmVwE8UWLEERYQpugBRtEBV0LCBlLm6xCbAD8gljoARpbuGwCXJ1bm6xBcUGogQYY3JlQARQAW5ldwNTB2AiZiB5b3UgAHdvdWxkIGxpfmtiBJULexAvJLUgmidoQHR0cDovL38Cb+ZtqAEbIACpYGCAnRIAUQFhYQB5cABMcAByATAAYgBpAGUALlEQAVQAaLAAc5AAZsAAbwBuAHSQAPUAYnIwAmUAdzID0wJSUXAAYQBkkABhkAJ0VVAAY/ADZRIBdHAAeLXyA2YQBGzQADMFcnAArmTQANECcQFzkgRJsAYF0QEgwLsgAHUAcKswAjEFZbIHdjIIadIEencSAC6QA7kL1QrRBGO1sABtUgVEUgFxBGmSAK2xBGdSA5EFZnAGbBAA65EQkQtjMAFwkgEVDd8GW98G0wYvMAO7Bi6QEHR1kAFskghBkg7xDbkMbauyBxMEbXAFcrAAaTAEAmzyE1m3AHkAcABlACAAAGYAbwB1AG4AIGQAcgB5AHhhAGp0ACh3AgguACwBnG8FAHRlAHxtAGkAYxUAVGMARG0ADiAAVFQAaAAmcwSObgR2YVUCInUAcmQCnmUADiBFAE5uAAoyADAAAjRVAHpFABloABNvAE9lVQI7cgJfUgANZwA9bFUAO3IADWEAg0wCC2HEAGIAIWUAOgBHFT2xARsxADkCARUjVgLNrnOABYFZgUkugkowiE87l06BRyCMSJMKiwYgAF5GhJGBjoOagQ1sgg10dYANIIABZoAAgU6Bn27tgBJxgAOD03KAA4XYhSJ1gVFyguBngASDB4ERZ2+CWYEjgQ2BFHOCx4HlcqOC0oE0IAB2wiFpQh+vQUTFIcURwwZlwnpNQCtaa0JxZ0whwzJtQkBm0UJubAAtwAZpwARBEVpqwApiQjvBmSDABHa7wibBC2TCEUGJQ2MsRorrQQtDpG3EqHRCB0E2xU2/wx3HT0GmwQlBEMNNckIO70FSwy1NNkclY0JYQyLDCq1BUHfKOsFBSUJOecIkq0G7wQFsQhBsQA5rSCP/zVzZg0diR99DwMULSSFD4NdDJsGKwed0QAppwAzBB4poQAN0QB46AC9AAC/lE7MGeYAAAAOBAAAAMP97ABQjAQ4AAQACAQEAAAwA+Aj/AAAIAAj//QAJBAAJoAAKAAr//BAACwALoAAMAAwBoAANAA3/+wAOFAAOoAAPogAQAA9A//oAEQAQoAASBAARoAATABL/+UWgDROgABUAFKAAFkAAFf/4ABeiABgEABagABkAF//3EAAaABigABsAGQGgABwAGv/2AB0UABugAB6iAB8AHBT/9YAnHaAAIQAeEaAAIgAfoAAjACBA//QAJAAhoAAlAaIAJgAi//MAJ0QAI6AAKAAkoAApAAAl//IAKgAmEaAAKwAnoAAsACiM//HAXqEALgApoACgLwAq//CAiSugAAgxACygADIALf8g7wAzAC6gADQAAi+gADUAMP/uAIg2ADGgADcAMqAAKjigAO2AlzOgADoAAjSgADsANf/sAIg8ADagAD0AN6AAgD4AOP/rAD+iAIhAADmgAEEAOqAAAEIAO//qAEMAIjygAEQAPaAARQCoPv/pAE0/oABHogCgSABA/+iAWEGgAAhKAEKgAEsAQ/+K54BTRKAATQBFoACCTqAA5gBPAEagAAhQAEegAFEASf9G5cCcoQBTAEqgAFQAAEv/5ABVAEwRoABWAE2gAFcATkD/4wBYAE+gAFkBogBaAFD/4gBbRABRoABcAFKgAF0AAFP/4QBeAFRRoABfAFWgAGCgAOBFgFJWoABiAFegAGMEAFigAGQAWf/fRUBOWqAAZgBboABnMABc/96AVKEAaQCCXaAAagBe/91AbiJfoABsAGCgAG0A6GH/3MBaYqAAgI6gAKBwAGP/28CoZaAAqHIAZqAAc6AA2sBaYmegAHUAaKAAgG//itmAXWqgAHgAa6AAgHkAbP/Y'
    $vMemFont &= 'AHqiAAh7AG2gAHwAbv8g1wB9AG+gAH4AAnCgAH8Acf/WAIiAAHKgAIEAc6AAAoKiAIMAdP/VAIiEAHWgAIUAdqAAAIYAd//UAIcAonigAIgAeaAAiaAAINMAigB6oACLAAJ7oACMAHz/0gCIjQB9oACOAH6gAICPAH//0QCQogAIkQCAoACSAIL/oNAAkwCDoACUogAAlQCE/88AlgAihaAAlwCGoACYAICH/84AmQCIoAAImgCJoACbAIr/iM0AnKIAnQCLoAAAngCM/8wAnwAijVAAoACOUAChAICP/8sAogCQUAAio1IApACRUAClAICS/8oApgCTUAAIpwCUUACoAJX/oMkAqQCWUACqUgAAqwCX/8gArAAimFAArQCZUACuAICa/8cArwCbUAAIsACcUACxAJ3/IMYAsgCeUACzAAKfUAC0AKD/xQAitVIAtgChUAC3AICi/8QAuACjUAAIuQCkUAC6AKX/IMMAuwCmUAC8AAqnUAC9UADCAL4AIqhQAL8AqVAAwACAqv/BAMEAq1AAiMIArFAAwwCtUACCxFAAwADFAK5QABjGAK9QALAI/78AiMgAsVAAyQCyUACAygCz/74Ay1IACMwAtFAAzQC1/yC9AM4AtlAAzwACt1AA0AC4/7wAiNEAuVAA0gC6UAAA0wC7/7sA1AAivFAA1QC9UADWACC+/7oA11IA2AACv1AA2QDA/7kAiNoAwVAA2wDCUAAA3ADD/7gA3QAKxFAA3lIA3wDF/yC3AOAAxlAA4QAix1AA4gDIUADjAIDJ/7YA5ADKUAAC5VIA5gDL/7UAiOcAzFAA6ADNUAAA6QDO/7QA6gAiz1AA6wDQUADsACDR/7MA7VIA7gAC0lAA7wDT/7IAiPAA1FAA8QDVUAAA8gDW/7EA8wAi11AA9ADYUAD1AIDZ/7AA9gDaUAAo9wDbUAD4UACvAIj5ANxQAPoA3VAAAPsA3v+uAPwAIt9QAP0A4FAA/gAg4f+tAP9RAA=='
    $vMemFont = _WinAPI_Base64Decode($vMemFont)
    Local $tSource = DllStructCreate('byte[' & BinaryLen($vMemFont) & ']')
    DllStructSetData($tSource, 1, $vMemFont)
    Local $tDecompress
    _WinAPI_LZNTDecompress($tSource, $tDecompress, 31304)
    $tSource = 0
    Local $bString = Binary(DllStructGetData($tDecompress, 1))
    If $bSaveBinary Then
        Local $hFile = FileOpen($sSavePath & "\ETHNOCEN.TTF", 18)
        FileWrite($hFile, $bString)
        FileClose($hFile)
    EndIf
    Return $bString
EndFunc   ;==>_MemFont

Func _WinAPI_Base64Decode($sB64String)
    Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "")
    Local $tBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]")
    $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $tBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($tBuffer, 1)
EndFunc   ;==>_WinAPI_Base64Decode

Func _WinAPI_LZNTDecompress(ByRef $tInput, ByRef $tOutput, $iBufferSize)
    $tOutput = DllStructCreate("byte[" & $iBufferSize & "]")
    If @error Then Return SetError(1, 0, 0)
    Local $aRet = DllCall("ntdll.dll", "uint", "RtlDecompressBuffer", "ushort", 0x0002, "struct*", $tOutput, "ulong", $iBufferSize, "struct*", $tInput, "ulong", DllStructGetSize($tInput), "ulong*", 0)
    If @error Then Return SetError(2, 0, 0)
    If $aRet[0] Then Return SetError(3, $aRet[0], 0)
    Return $aRet[6]
EndFunc   ;==>_WinAPI_LZNTDecompress


Function _WinAPI_GetGlyphOutline

Function Reference

_WinAPI_GetGlyphOutline

Retrieves the outline or bitmap for a character in the TrueType font

#include <WinAPIGdi.au3>
_WinAPI_GetGlyphOutline ( $hDC, $sChar, $iFormat, ByRef $pBuffer [, $tMAT2 = 0] )

Parameters

$hDC | A handle to the device context which font is selected.
$sChar | The character for which data is to be returned.
$iFormat | The format of the data that the function retrieves. This parameter can be one of the following values: $GGO_BEZIER $GGO_BITMAP $GGO_GLYPH_INDEX $GGO_GRAY2_BITMAP $GGO_GRAY4_BITMAP $GGO_GRAY8_BITMAP $GGO_METRICS $GGO_NATIVE $GGO_UNHINTED
$pBuffer | Returns a pointer to a memory block (buffer) that receives the outline or bitmap data. Optionaly, you can set this parameter to 0 before function call, then the function will allocate the required memory block itself. Otherwise, it must be a valid memory pointer returned by the _WinAPI_CreateBuffer() function, or by previously calling this function. If the $GGO_METRICS is specified, this parameter is ignored, and function only returns the information about a glyph (see below).
$tMAT2 | [optional] $tagMAT2 structure specifying a transformation matrix for the character. If this parameter is 0 (Default), the transformation will not be used (it is identity matrix).

Return Value

Success: | $tagGLYPHMETRICS structure containing information about the placement and orientation of a glyph, @extended flag returns a number of bytes copied to the buffer (if used), in bytes.
Failure: | Sets the @error flag to non-zero.

Remarks

Note that, for the $GGO_GRAY... values, the function retrieves a glyph bitmap that contains n^2+1 (n squared plus one) levels of gray.

The glyph bitmap returned by _WinAPI_GetGlyphOutline() when $GGO_BITMAP is specified is a DWORD-aligned, row-oriented, monochrome bitmap.
When $GGO_GRAY2_BITMAP is specified, the bitmap returned is a DWORD-aligned, row-oriented array of bytes whose values range from 0 to 4.
When $GGO_GRAY4_BITMAP is specified, the bitmap returned is a DWORD-aligned, row-oriented array of bytes whose values range from 0 to 16.
When $GGO_GRAY8_BITMAP is specified, the bitmap returned is a DWORD-aligned, row-oriented array of bytes whose values range from 0 to 64.

When you no longer need the buffer allocated by this function, you must call the _WinAPI_FreeMemory() function (do not use any other memory routines) to release occupied memory.

Related

_WinAPI_CreateBuffer, _WinAPI_FreeMemory

See Also

Search GetGlyphOutline in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

; Creates logical font ("Times") and retrieve bitmap bits for a random character
Local $hDC = _WinAPI_CreateCompatibleDC(0)
Local $hFont = _WinAPI_CreateFont(512, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Times')
Local $hSv = _WinAPI_SelectObject($hDC, $hFont)
Local $pData = 0
Local $tGM = _WinAPI_GetGlyphOutline($hDC, ChrW(Random(65, 90, 1)), $GGO_BITMAP, $pData)
Local $W = DllStructGetData($tGM, 'BlackBoxX')
Local $H = DllStructGetData($tGM, 'BlackBoxY')
_WinAPI_SelectObject($hDC, $hSv)
_WinAPI_DeleteObject($hFont)

; Create 1 bits-per-pixel bitmap
Local $hBmp = _WinAPI_CreateBitmap(32 * Ceiling($W / 32), $H, 1, 1, $pData)

; Crop bitmap to the required size and colorize it
Local $aColorTable[2] = [0xFFFFFF, 0xC00000]
Local $hDib = _WinAPI_CreateDIB($W, $H, 1, _WinAPI_CreateDIBColorTable($aColorTable), 2)
$hSv = _WinAPI_SelectObject($hDC, $hDib)
_WinAPI_DrawBitmap($hDC, 0, 0, $hBmp, $MERGEPAINT)
_WinAPI_SelectObject($hDC, $hSv)
_WinAPI_DeleteObject($hBmp)

; Free unnecessary resources
_WinAPI_FreeMemory($pData)
_WinAPI_DeleteDC($hDC)

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), $W, $H)
Local $idPic = GUICtrlCreatePic('', 0, 0, $W, $H)
Local $hPic = GUICtrlGetHandle($idPic)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hDib)
$hBmp = _SendMessage($hPic, $STM_GETIMAGE)
If $hBmp <> $hDib Then
    _WinAPI_DeleteObject($hDib)
EndIf

; Show GUI
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_GetOutlineTextMetrics

Function Reference

_WinAPI_GetOutlineTextMetrics

Retrieves text metrics for TrueType fonts

#include <WinAPIGdi.au3>
_WinAPI_GetOutlineTextMetrics ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | $tagOUTLINETEXTMETRIC structure that contains the text metrics.
Failure: | Sets the @error flag to non-zero.

See Also

Search GetOutlineTextMetrics in MSDN Library.

Example

#include <FontConstants.au3>
#include <WinAPIGdi.au3>

; Select "Arial" font to DC and retrieve $tagOUTLINETEXTMETRIC structure
Local $hDC = _WinAPI_GetDC(0)
Local $hFont = _WinAPI_CreateFont(24, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, 'Arial')
Local $hSv = _WinAPI_SelectObject($hDC, $hFont)
Local $tOLTM = _WinAPI_GetOutlineTextMetrics($hDC)
_WinAPI_SelectObject($hDC, $hSv)
_WinAPI_ReleaseDC(0, $hDC)

If IsDllStruct($tOLTM) Then
    ConsoleWrite('Family name:   ' & _otm($tOLTM, 'otmFamilyName') & @CRLF)
    ConsoleWrite('Typeface name: ' & _otm($tOLTM, 'otmFaceName') & @CRLF)
    ConsoleWrite('Style name     ' & _otm($tOLTM, 'otmStyleName') & @CRLF)
    ConsoleWrite('Full name:     ' & _otm($tOLTM, 'otmFullName') & @CRLF)
EndIf

Func _otm(ByRef $tOLTM, $sName)
    Return _WinAPI_GetString(DllStructGetPtr($tOLTM) + DllStructGetData($tOLTM, $sName))
EndFunc   ;==>_otm


Function _WinAPI_GetTabbedTextExtent

Function Reference

_WinAPI_GetTabbedTextExtent

Computes the width and height of a character string which may contain one or more tab characters

#include <WinAPIGdi.au3>
_WinAPI_GetTabbedTextExtent ( $hDC, $sText [, $aTab = 0 [, $iStart = 0 [, $iEnd = -1]]] )

Parameters

$hDC | A handle to the device context.
$sText | A character string.
$aTab | [optional] The array containing the tab-stop positions, in device units. The tab stops must be sorted in increasing order; the smallest x-value should be the first item in the array. Also, it can be an integer value that is one tab-stop position. In this case, the tab stops are separated by the distance specified by this value. If this parameter is 0 (Default), tabs are expanded to eight times the average character width.
$iStart | [optional] The index of array element that contains the first tab-stop position.
$iEnd | [optional] The index of array element that contains the last tab-stop position.

Return Value

Success: | $tagSIZE structure that contains the dimensions of the string in logical units.
Failure: | Sets the @error flag to non-zero.

Remarks

This function uses the currently selected font to compute the dimensions of the string.

Because some devices do not place characters in regular cell arrays (that is, they kern the characters), the
sum of the extents of the characters in a string may not be equal to the extent of the string.

The current clipping region does not affect the returned result.

See Also

Search GetTabbedTextExtent in MSDN Library.

Example

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

Local Const $sTxt = 'String' & @TAB & 'with' & @TAB & 'tab' & @TAB & 'characters'

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 0, 0, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU))
GUICtrlCreateLabel($sTxt, 0, 0)
GUICtrlSetFont(-1, 26, 400, 0, 'Comic Sans MS')

; Compute dimensions of a string and resize the window
Local $iSize = _GetTabbedStringSize(-1, $sTxt)
If IsArray($iSize) Then
    GUICtrlSetPos(-1, 0, 0, $iSize[0], $iSize[1])
    Local $aPos = WinGetPos($hForm)
    If Not @error Then
        WinMove($hForm, '', (@DesktopWidth - ($aPos[2] + $iSize[0])) / 2, (@DesktopHeight - ($aPos[3] + $iSize[1])) / 2, $aPos[2] + $iSize[0], $aPos[3] + $iSize[1])
    EndIf
EndIf

; Show GUI
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _GetTabbedStringSize($hWnd, $sText)
    Local $tTM = DllStructCreate($tagTEXTMETRIC)

    If Not IsHWnd($hWnd) Then
        $hWnd = GUICtrlGetHandle($hWnd)
        If Not $hWnd Then Return 0
    EndIf

    Local $hDC = _WinAPI_GetDC($hWnd)
    Local $hFont = _SendMessage($hWnd, $WM_GETFONT)
    Local $hSv = _WinAPI_SelectObject($hDC, $hFont)
    Local $iTab = 0
    Local $aRet = DllCall('gdi32.dll', 'int', 'GetTextMetricsW', 'handle', $hDC, 'struct*', $tTM)
    If Not @error And $aRet[0] Then
        $iTab = 8 * DllStructGetData($tTM, 'tmAveCharWidth')
    EndIf
    Local $iSize = 0
    Local $tSIZE = _WinAPI_GetTabbedTextExtent($hDC, $sText, $iTab)
    If Not @error Then
        Dim $iSize[2]
        For $i = 0 To 1
            $iSize[$i] = DllStructGetData($tSIZE, $i + 1)
        Next
    EndIf
    _WinAPI_SelectObject($hDC, $hSv)
    _WinAPI_ReleaseDC($hWnd, $hDC)
    Return $iSize
EndFunc   ;==>_GetTabbedStringSize


Function _WinAPI_GetTextAlign

Function Reference

_WinAPI_GetTextAlign

Retrieves the text-alignment setting for the specified device context

#include <WinAPIGdi.au3>
_WinAPI_GetTextAlign ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | The status of the text-alignment flags. The return value is a combination of the $TA_* and $VTA_* constants.
Failure: | (-1).

See Also

Search GetTextAlign in MSDN Library.


Function _WinAPI_GetTextCharacterExtra

Function Reference

_WinAPI_GetTextCharacterExtra

Retrieves the current intercharacter spacing for the specified device context

#include <WinAPIGdi.au3>
_WinAPI_GetTextCharacterExtra ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | The current intercharacter spacing, in logical coordinates.
Failure: | (-1).

See Also

Search GetTextCharacterExtra in MSDN Library.


Function _WinAPI_GetTextColor

Function Reference

_WinAPI_GetTextColor

Retrieves the current text color for the specified device context

#include <WinAPIGdi.au3>
_WinAPI_GetTextColor ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | The value of the current text color, in RGB.
Failure: | (-1).

See Also

Search GetTextColor in MSDN Library.


Function _WinAPI_GetTextFace

Function Reference

_WinAPI_GetTextFace

Retrieves the typeface name of the font that is selected into the specified device context

#include <WinAPIGdi.au3>
_WinAPI_GetTextFace ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | The typeface name.
Failure: | Sets the @error flag to non-zero.

See Also

Search GetTextFace in MSDN Library.


Function _WinAPI_RemoveFontMemResourceEx

Function Reference

_WinAPI_RemoveFontMemResourceEx

Removes the fonts added from a memory image

#include <WinAPIGdi.au3>
_WinAPI_RemoveFontMemResourceEx ( $hFont )

Parameters

$hFont Handle to the font-resource. This handle is returned by the _WinAPI_AddFontMemResourceEx() function.

Return Value

Success: | True
Failure: | False

Related

_WinAPI_AddFontMemResourceEx

See Also

Search RemoveFontMemResourceEx in MSDN Library.


Function _WinAPI_RemoveFontResourceEx

Function Reference

_WinAPI_RemoveFontResourceEx

Removes the fonts in the specified file from the system font table

#include <WinAPIGdi.au3>
_WinAPI_RemoveFontResourceEx ( $sFont [, $iFlag = 0 [, $bNotify = False]] )

Parameters

$sFont | String that names a font resource file. To remove a font whose information comes from several resource files, they must be separated by a "|". For example, abcxxxxx.pfm|abcxxxxx.pfb.
$iFlag | [optional] The characteristics of the font to be removed from the system. In order for the font to be removed, the flags used must be the same as when the font was added with the _WinAPI_AddFontResourceEx() function.
$bNotify | [optional] Specifies whether sends a WM_FONTCHANGE message, valid values: True - Send the WM_FONTCHANGE message to all top-level windows after changing the pool of font resources. False - Don't send (Default).

Return Value

Success: | True
Failure: | False

See Also

Search RemoveFontResourceEx in MSDN Library.


Function _WinAPI_SetTextAlign

Function Reference

_WinAPI_SetTextAlign

Sets the text-alignment flags for the specified device context

#include <WinAPIGdi.au3>
_WinAPI_SetTextAlign ( $hDC [, $iMode = 0] )

Parameters

$hDC | Handle to the device context.
$iMode | [optional] The text alignment by using a mask of the values in the following list. Only one flag can be chosen from those that affect horizontal and vertical alignment. In addition, only one of the two flags that alter the current position can be chosen. $TA_BASELINE $TA_BOTTOM $TA_TOP (Default) $TA_CENTER $TA_LEFT (Default) $TA_RIGHT $TA_NOUPDATECP (Default) $TA_RTLREADING $TA_UPDATECP When the current font has a vertical default base line, as with Kanji, the following values must be used instead of $TA_BASELINE and $TA_CENTER. $VTA_BASELINE $VTA_CENTER The default values are $TA_LEFT, $TA_TOP, and $TA_NOUPDATECP.

Return Value

Success: | The previous text-alignment setting ($TA_* and $VTA_*).
Failure: | (-1) GDI_ERROR.

See Also

Search SetTextAlign in MSDN Library.


Function _WinAPI_SetTextCharacterExtra

Function Reference

_WinAPI_SetTextCharacterExtra

Sets the intercharacter spacing for the specified device context

#include <WinAPIGdi.au3>
_WinAPI_SetTextCharacterExtra ( $hDC, $iCharExtra )

Parameters

$hDC | Handle to the device context.
$iCharExtra | The amount of extra space, in logical units, to be added to each character.

Return Value

Success: | The previous intercharacter spacing.
Failure: | (-1).

Remarks

This function is supported mainly for compatibility with existing applications?

The recommended approach is that instead of calling this function and then TextOut,
applications should call ExtTextOut and use its lpDx parameter to supply widths.

See Also

Search SetTextCharacterExtra in MSDN Library.


Function _WinAPI_SetTextJustification

Function Reference

_WinAPI_SetTextJustification

Specifies the amount of space the system should add to the break characters in a string of text

#include <WinAPIGdi.au3>
_WinAPI_SetTextJustification ( $hDC, $iBreakExtra, $iBreakCount )

Parameters

$hDC | Handle to the device context.
$iBreakExtra | The total extra space, in logical units, to be added to the line of text.
$iBreakCount | The number of break characters in the line.

Return Value

Success: | True
Failure: | False

See Also

Search SetTextJustification in MSDN Library.


Function _WinAPI_TabbedTextOut

Function Reference

_WinAPI_TabbedTextOut

Writes a character string at a specified location and expanding tabs to the specified tab-stop positions

#include <WinAPIGdi.au3>
_WinAPI_TabbedTextOut ( $hDC, $iX, $iY, $sText [, $aTab = 0 [, $iStart = 0 [, $iEnd = -1 [, $iOrigin = 0]]]] )

Parameters

$hDC | A handle to the device context.
$iX | The x-coordinate of the starting point of the string, in logical units.
$iY | The y-coordinate of the starting point of the string, in logical units.
$sText | The character string to draw.
$aTab | [optional] The array containing the tab-stop positions, in logical units. The tab stops must be sorted in increasing order; the smallest x-value should be the first item in the array. Also, it can be an integer value that is one tab-stop position. In this case, the tab stops are separated by the distance specified by this value. If this parameter is 0, tabs are expanded to eight times the average character width.
$iStart | [optional] The index of array element that contains the first tab-stop position.
$iEnd | [optional] The index of array element that contains the last tab-stop position.
$iOrigin | [optional] The x-coordinate of the starting position from which tabs are expanded, in logical units. This allows an application to call the function several times for a single line. If the application calls the function more than once with the starting position set to the same value each time, the function expands all tabs relative to the position specified by this parameter.

Return Value

Success: | 1.
Failure: | 0.

Remarks

The string is written in the currently selected font, background color, and text color.

By default, the current position is not used or updated by this function. If an application needs to update the
current position when it calls the function, the application can call _WinAPI_SetTextAlign() with the $TA_UPDATECP
flag set. Then the system ignores the X and Y parameters on subsequent calls to the _WinAPI_TabbedTextOut()
function, using the current position instead.

Call _WinAPI_GetExtended() to retrieve a $tagSIZE structure containing the dimensions of the string.

Related

_WinAPI_GetExtended

See Also

Search TabbedTextOut in MSDN Library.

Example

#include <FontConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idPic = GUICtrlCreatePic('', 0, 0, 400, 400)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDev = _WinAPI_GetDC($hPic)
Local $hDC = _WinAPI_CreateCompatibleDC($hDev)
Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, 400, 400, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hSv = _WinAPI_SelectObject($hDC, $hSource)

; Draw objects
Local $hOldBrush = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hOldPen = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_PEN))

_WinAPI_SetTextColor($hDC, 0xCD0091)
_WinAPI_SetBkMode($hDC, $TRANSPARENT)
Local $hFont = _WinAPI_CreateFont(12, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, 'Arial Black')
Local $hObj = _WinAPI_SelectObject($hDC, $hFont)
_WinAPI_TextOut($hDC, 10, 15, 'Simple Text')
Local $sTabbedTextOut = 'Tabbed ' & @TAB & 'Text ' & @TAB & 'Out'
_WinAPI_TextOut($hDC, 10, 35, $sTabbedTextOut)
_WinAPI_TabbedTextOut($hDC, 10, 65, $sTabbedTextOut)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hFont)

; ; Merge bitmap
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDev, 400, 400)
Local $hBrush = _WinAPI_SelectObject($hDC, $hOldBrush)
_WinAPI_DeleteObject($hBrush)
Local $hPen = _WinAPI_SelectObject($hDC, $hOldPen)
_WinAPI_DeleteObject($hPen)
_WinAPI_SelectObject($hDC, $hBitmap)
_WinAPI_DrawBitmap($hDC, 0, 0, $hSource, $MERGECOPY)
_WinAPI_ReleaseDC($hPic, $hDev)
_WinAPI_SelectObject($hDC, $hSv)
_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteDC($hDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
$hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = -3


Function _WinAPI_TextOut

Function Reference

_WinAPI_TextOut

Writes a string at the specified location, using the currently selected font, background color, and text color

#include <WinAPIGdi.au3>
_WinAPI_TextOut ( $hDC, $iX, $iY, $sText )

Parameters

$hDC | Handle to the device context.
$iX | The x-coordinate, in logical coordinates, of the reference point that the system uses to align the string.
$iY | The y-coordinate, in logical coordinates, of the reference point that the system uses to align the string.
$sText | The string to be drawn.

Return Value

Success: | True
Failure: | False

Remarks

This function using the currently selected font, background color, and text color.

By default, the current position is not used or updated by this function. If an application needs to update the
current position when it calls the function, the application can call _WinAPI_SetTextAlign() with the $TA_UPDATECP
flag set. Then the system ignores the X and Y parameters on subsequent calls to the _WinAPI_TextOut()
function, using the current position instead.

Related

_WinAPI_SetTextAlign

See Also

Search TextOut in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <FontConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idPic = GUICtrlCreatePic('', 0, 0, 400, 400)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDev = _WinAPI_GetDC($hPic)
Local $hDC = _WinAPI_CreateCompatibleDC($hDev)
Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, 400, 400, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hSv = _WinAPI_SelectObject($hDC, $hSource)

; Draw objects
Local $hOldBrush = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hOldPen = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetDCBrushColor($hDC, 0x990404)
_WinAPI_SetDCPenColor($hDC, 0x990404)
Local $tRECT = _WinAPI_CreateRect(0, 0, 100, 100)
_WinAPI_OffsetRect($tRECT, 30, 30)
_WinAPI_Rectangle($hDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 20, 20)
_WinAPI_InvertRect($hDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 20, 20)
_WinAPI_InvertRect($hDC, $tRECT)
_WinAPI_SetDCPenColor($hDC, 0x00A820)
_WinAPI_SetBkColor($hDC, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hBrush = _WinAPI_CreateBrushIndirect($BS_HATCHED, 0x00A820, $HS_DIAGCROSS)
Local $hObj = _WinAPI_SelectObject($hDC, $hBrush)
$tRECT = _WinAPI_CreateRect(0, 0, 140, 140)
_WinAPI_OffsetRect($tRECT, 220, 118)
_WinAPI_Ellipse($hDC, $tRECT)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hBrush)
_WinAPI_SetTextColor($hDC, 0xCD0091)
_WinAPI_SetBkMode($hDC, $TRANSPARENT)
Local $hFont = _WinAPI_CreateFont(38, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, 'Arial Black')
$hObj = _WinAPI_SelectObject($hDC, $hFont)
_WinAPI_TextOut($hDC, 30, 185, 'Simple Text')
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hFont)
Local $aPoint2[6][2] = [[0, 129], [55, 75], [75, 0], [95, 75], [150, 129], [75, 108]]
Local $hRgn = _WinAPI_CreatePolygonRgn($aPoint2)
_WinAPI_SetDCBrushColor($hDC, 0x0060C4)
_WinAPI_OffsetRgn($hRgn, 25, 240)
_WinAPI_PaintRgn($hDC, $hRgn)
_WinAPI_DeleteObject($hRgn)
Local $aPoint1[19][2] = [[50, 20], [70, 0], [70, 0], [90, 20], [100, 30], [110, 40], [120, 50], [130, 60], [130, 70], [120, 70], [110, 70], [30, 70], [20, 70], [10, 70], [10, 60], [20, 50], [30, 40], [40, 30], [50, 20]]
_WinAPI_SetDCPenColor($hDC, 0xFF8000)
_WinAPI_OffsetPoints($aPoint1, 219, 25)
_WinAPI_PolyBezier($hDC, $aPoint1)
$hBrush = _WinAPI_CreateBrushIndirect($BS_SOLID, 0xFF8000)
$hObj = _WinAPI_SelectObject($hDC, $hBrush)
_WinAPI_ExtFloodFill($hDC, 70 + 219, 40 + 25, 0xFF8000, 0)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hBrush)
_WinAPI_SetDCPenColor($hDC, 0xFFFFFF)
Local $hPattern = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Pattern.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
; $hPattern = _WinAPI_LoadBitmap(_WinAPI_GetModuleHandle(@SystemDir & '\shell32.dll'), 138)
$hBrush = _WinAPI_CreateBrushIndirect($BS_PATTERN, 0, $hPattern)
$hObj = _WinAPI_SelectObject($hDC, $hBrush)
$tRECT = _WinAPI_CreateRect(0, 0, 140, 90)
_WinAPI_OffsetRect($tRECT, 220, 279)
_WinAPI_RoundRect($hDC, $tRECT, 20, 20)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hPattern)
_WinAPI_DeleteObject($hBrush)

; Merge bitmap
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDev, 400, 400)
$hBrush = _WinAPI_SelectObject($hDC, $hOldBrush)
_WinAPI_DeleteObject($hBrush)
Local $hPen = _WinAPI_SelectObject($hDC, $hOldPen)
_WinAPI_DeleteObject($hPen)
_WinAPI_SelectObject($hDC, $hBitmap)
_WinAPI_DrawBitmap($hDC, 0, 0, $hSource, $MERGECOPY)
_WinAPI_ReleaseDC($hPic, $hDev)
_WinAPI_SelectObject($hDC, $hSv)
_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteDC($hDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
$hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = -3


User Defined Functions

Line & Curve user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIGdi.au3>.

User Defined Function | Description
_WinAPI_AngleArc | Draws a line segment and an arc
_WinAPI_Arc | Draws an elliptical arc
_WinAPI_ArcTo | Draws an elliptical arc
_WinAPI_GetArcDirection | Retrieves the current arc direction for the specified device context
_WinAPI_LineDDA | Determines which pixels should be highlighted for a line
_WinAPI_MoveToEx | Updates the current position to the specified point
_WinAPI_PolyBezier | Draws one or more Bezier curves
_WinAPI_PolyBezierTo | Draws one or more Bezier curves
_WinAPI_PolyDraw | Draws a set of line segments and Bezier curves
_WinAPI_SetArcDirection | Sets the drawing arc direction


Function _WinAPI_AngleArc

Function Reference

_WinAPI_AngleArc

Draws a line segment and an arc

#include <WinAPIGdi.au3>
_WinAPI_AngleArc ( $hDC, $iX, $iY, $iRadius, $nStartAngle, $nSweepAngle )

Parameters

$hDC | Handle to a device context.
$iX | The x-coordinate, in logical units, of the center of the circle.
$iY | The y-coordinate, in logical units, of the center of the circle.
$iRadius | The radius, in logical units, of the circle.
$nStartAngle | The start angle, in degrees, relative to the x-axis.
$nSweepAngle | The sweep angle, in degrees, relative to the starting angle.

Return Value

Success: | True
Failure: | False

Remarks

The _WinAPI_AngleArc() function draws lines by using the current pen. The figure is not filled.
This function moves the current position to the ending point of the arc.

See Also

Search AngleArc in MSDN Library.


Function _WinAPI_Arc

Function Reference

_WinAPI_Arc

Draws an elliptical arc

#include <WinAPIGdi.au3>
_WinAPI_Arc ( $hDC, $tRECT, $iXStartArc, $iYStartArc, $iXEndArc, $iYEndArc )

Parameters

$hDC | Handle to the device context.
$tRECT | $tagRECT structure that contains the logical coordinates of the bounding rectangle.
$iXStartArc | The x-coordinate, in logical units, of the ending point of the radial line defining the starting point of the arc.
$iYStartArc | The y-coordinate, in logical units, of the ending point of the radial line defining the starting point of the arc.
$iXEndArc | The x-coordinate, in logical units, of the ending point of the radial line defining the ending point of the arc.
$iYEndArc | The y-coordinate, in logical units, of the ending point of the radial line defining the ending point of the arc.

Return Value

Success: | True
Failure: | False

Remarks

The arc is drawn using the current pen; it is not filled. The current position is neither used nor updated by _WinAPI_Arc() function.

Use the _WinAPI_GetArcDirection() and _WinAPI_SetArcDirection() functions to get and set the current drawing direction for a device context.
The default drawing direction is counterclockwise.

Related

_WinAPI_GetArcDirection, _WinAPI_SetArcDirection

See Also

Search Arc in MSDN Library.


Function _WinAPI_ArcTo

Function Reference

_WinAPI_ArcTo

Draws an elliptical arc

#include <WinAPIGdi.au3>
_WinAPI_ArcTo ( $hDC, $tRECT, $iXRadial1, $iYRadial1, $iXRadial2, $iYRadial2 )

Parameters

$hDC | Handle to the device context.
$tRECT | $tagRECT structure that contains the logical coordinates of the bounding rectangle.
$iXRadial1 | The x-coordinate, in logical units, of the endpoint of the radial defining the starting point of the arc.
$iYRadial1 | The y-coordinate, in logical units, of the endpoint of the radial defining the starting point of the arc.
$iXRadial2 | The x-coordinate, in logical units, of the endpoint of the radial defining the ending point of the arc.
$iYRadial2 | The y-coordinate, in logical units, of the endpoint of the radial defining the ending point of the arc.

Return Value

Success: | True
Failure: | False

Remarks

The arc is drawn using the current pen; it is not filled. _WinAPI_ArcTo() is similar to the _WinAPI_Arc() function, except that the current position is updated.

Related

_WinAPI_Arc

See Also

Search ArcTo in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 241, 241)
Local $idPic = GUICtrlCreatePic('', 0, 0, 241, 241)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDC = _WinAPI_GetDC($hPic)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 241, 241, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap)

; Create path
_WinAPI_BeginPath($hMemDC)
_WinAPI_MoveTo($hMemDC, 220, 78)
_WinAPI_LineTo($hMemDC, 170, 218)
_WinAPI_LineTo($hMemDC, 70, 218)
_WinAPI_LineTo($hMemDC, 20, 78)
_WinAPI_SetArcDirection($hMemDC, $AD_CLOCKWISE)
_WinAPI_ArcTo($hMemDC, _WinAPI_CreateRectEx(49, 22, 143, 143), 49, 78, 192, 78)
_WinAPI_CloseFigure($hMemDC)
_WinAPI_Ellipse($hMemDC, _WinAPI_CreateRectEx(70, 44, 101, 101))
_WinAPI_Ellipse($hMemDC, _WinAPI_CreateRectEx(90, 64, 61, 61))
_WinAPI_EndPath($hMemDC)

; Stroke outline, and fills path's interior
Local $hBrush = _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hPen = _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetDCBrushColor($hMemDC, 0xFFC000)
_WinAPI_SetDCPenColor($hMemDC, 0xDD0000)
_WinAPI_StrokeAndFillPath($hMemDC)

; Release objects
_WinAPI_DeleteObject(_WinAPI_SelectObject($hDC, $hBrush))
_WinAPI_DeleteObject(_WinAPI_SelectObject($hDC, $hPen))
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_GetArcDirection

Function Reference

_WinAPI_GetArcDirection

Retrieves the current arc direction for the specified device context

#include <WinAPIGdi.au3>
_WinAPI_GetArcDirection ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | The current arc direction ($AD_*).
Failure: | 0 and sets the @error flag to non-zero.

See Also

Search GetArcDirection in MSDN Library.


Function _WinAPI_LineDDA

Function Reference

_WinAPI_LineDDA

Determines which pixels should be highlighted for a line

#include <WinAPIGdi.au3>
_WinAPI_LineDDA ( $iX1, $iY1, $iX2, $iY2, $pLineProc [, $pData = 0] )

Parameters

$iX1 | Specifies the x-coordinate, in logical units, of the line's starting point.
$iY1 | Specifies the y-coordinate, in logical units, of the line's starting point.
$iX2 | Specifies the x-coordinate, in logical units, of the line's ending point.
$iY2 | Specifies the y-coordinate, in logical units, of the line's ending point.
$pLineProc | Pointer to an application-defined callback function.
$pData | [optional] Pointer to the application-defined data.

Return Value

Success: | True
Failure: | False

Remarks

The _WinAPI_LineDDA() function passes the coordinates for each point along the line, except for the line's ending
point, to the application-defined callback function. In addition to passing the coordinates of a point, this
function passes any existing application-defined data.

See Also

Search LineDDA in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

Global $g_iCount = 0, $g_bColor = True
Local $hLineProc = DllCallbackRegister('_LineProc', 'none', 'int;int;lparam')
Local $pLineProc = DllCallbackGetPtr($hLineProc)

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 280, 280)
Local $idPic = GUICtrlCreatePic('', 0, 0, 281, 281)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDC = _WinAPI_GetDC($hPic)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 280, 280, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap)
_WinAPI_LineDDA(40, 40, 240, 40, $pLineProc, $hMemDC)
_WinAPI_LineDDA(240, 40, 240, 240, $pLineProc, $hMemDC)
_WinAPI_LineDDA(240, 240, 40, 240, $pLineProc, $hMemDC)
_WinAPI_LineDDA(40, 240, 40, 40, $pLineProc, $hMemDC)
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

DllCallbackFree($hLineProc)

Func _LineProc($iX, $iY, $hDC)
    If Not Mod($g_iCount, 10) Then
        $g_bColor = Not $g_bColor
    EndIf
    If $g_bColor Then
        _WinAPI_SetPixel($hDC, $iX, $iY, 0xFF0000)
    Else
        _WinAPI_SetPixel($hDC, $iX, $iY, 0xFFFFFF)
    EndIf
    $g_iCount += 1
EndFunc   ;==>_LineProc


Function _WinAPI_MoveToEx

Function Reference

_WinAPI_MoveToEx

Updates the current position to the specified point

#include <WinAPIGdi.au3>
_WinAPI_MoveToEx ( $hDC, $iX, $iY )

Parameters

$hDC | Handle to the device context.
$iX | The x-coordinate, in logical units, of the new position, in logical units.
$iY | The y-coordinate, in logical units, of the new position, in logical units.

Return Value

Success: | $tagPOINT structure that contains the previous current position.
Failure: | Sets the @error flag to non-zero.

See Also

Search MoveToEx in MSDN Library.


Function _WinAPI_PolyBezier

Function Reference

_WinAPI_PolyBezier

Draws one or more Bezier curves

#include <WinAPIGdi.au3>
_WinAPI_PolyBezier ( $hDC, Const ByRef $aPoint [, $iStart = 0 [, $iEnd = -1]] )

Parameters

$hDC | Handle to a device context.
$aPoint | The 2D array ([x1, y1], [x2, y2], ... [xN, yN]) that contains the endpoints and control points of the curve(s), in logical units. The number of points must be one more than three times the number of curves to be drawn, because each Bezier curve requires two control points and an endpoint, and the initial curve requires an additional starting point.
$iStart | [optional] The index of array to start drawing at.
$iEnd | [optional] The index of array to stop drawing at.

Return Value

Success: | True
Failure: | False

Remarks

This function draws cubic Bezier curves by using the endpoints and control points specified by the $aPoint
parameter. The first curve is drawn from the first point to the fourth point by using the second and third points
as control points. Each subsequent curve in the sequence needs exactly three more points: the ending point of the
previous curve is used as the starting point, the next two points in the sequence are control points, and the
third is the ending point.

The current position is neither used nor updated by the _WinAPI_PolyBezier() function. The figure is not filled.

This function draws lines by using the current pen.

See Also

Search PolyBezier in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <FontConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idPic = GUICtrlCreatePic('', 0, 0, 400, 400)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDev = _WinAPI_GetDC($hPic)
Local $hDC = _WinAPI_CreateCompatibleDC($hDev)
Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, 400, 400, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hSv = _WinAPI_SelectObject($hDC, $hSource)

; Draw objects
Local $hOldBrush = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hOldPen = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetDCBrushColor($hDC, 0x990404)
_WinAPI_SetDCPenColor($hDC, 0x990404)
Local $tRECT = _WinAPI_CreateRect(0, 0, 100, 100)
_WinAPI_OffsetRect($tRECT, 30, 30)
_WinAPI_Rectangle($hDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 20, 20)
_WinAPI_InvertRect($hDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 20, 20)
_WinAPI_InvertRect($hDC, $tRECT)
_WinAPI_SetDCPenColor($hDC, 0x00A820)
_WinAPI_SetBkColor($hDC, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hBrush = _WinAPI_CreateBrushIndirect($BS_HATCHED, 0x00A820, $HS_DIAGCROSS)
Local $hObj = _WinAPI_SelectObject($hDC, $hBrush)
$tRECT = _WinAPI_CreateRect(0, 0, 140, 140)
_WinAPI_OffsetRect($tRECT, 220, 118)
_WinAPI_Ellipse($hDC, $tRECT)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hBrush)
_WinAPI_SetTextColor($hDC, 0xCD0091)
_WinAPI_SetBkMode($hDC, $TRANSPARENT)
Local $hFont = _WinAPI_CreateFont(38, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, 'Arial Black')
$hObj = _WinAPI_SelectObject($hDC, $hFont)
_WinAPI_TextOut($hDC, 30, 185, 'Simple Text')
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hFont)
Local $aPoint2[6][2] = [[0, 129], [55, 75], [75, 0], [95, 75], [150, 129], [75, 108]]
Local $hRgn = _WinAPI_CreatePolygonRgn($aPoint2)
_WinAPI_SetDCBrushColor($hDC, 0x0060C4)
_WinAPI_OffsetRgn($hRgn, 25, 240)
_WinAPI_PaintRgn($hDC, $hRgn)
_WinAPI_DeleteObject($hRgn)
Local $aPoint1[19][2] = [[50, 20], [70, 0], [70, 0], [90, 20], [100, 30], [110, 40], [120, 50], [130, 60], [130, 70], [120, 70], [110, 70], [30, 70], [20, 70], [10, 70], [10, 60], [20, 50], [30, 40], [40, 30], [50, 20]]
_WinAPI_SetDCPenColor($hDC, 0xFF8000)
_WinAPI_OffsetPoints($aPoint1, 219, 25)
_WinAPI_PolyBezier($hDC, $aPoint1)
$hBrush = _WinAPI_CreateBrushIndirect($BS_SOLID, 0xFF8000)
$hObj = _WinAPI_SelectObject($hDC, $hBrush)
_WinAPI_ExtFloodFill($hDC, 70 + 219, 40 + 25, 0xFF8000, 0)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hBrush)
_WinAPI_SetDCPenColor($hDC, 0xFFFFFF)
Local $hPattern = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Pattern.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
; $hPattern = _WinAPI_LoadBitmap(_WinAPI_GetModuleHandle(@SystemDir & '\shell32.dll'), 138)
$hBrush = _WinAPI_CreateBrushIndirect($BS_PATTERN, 0, $hPattern)
$hObj = _WinAPI_SelectObject($hDC, $hBrush)
$tRECT = _WinAPI_CreateRect(0, 0, 140, 90)
_WinAPI_OffsetRect($tRECT, 220, 279)
_WinAPI_RoundRect($hDC, $tRECT, 20, 20)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hPattern)
_WinAPI_DeleteObject($hBrush)

; Merge bitmap
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDev, 400, 400)
$hBrush = _WinAPI_SelectObject($hDC, $hOldBrush)
_WinAPI_DeleteObject($hBrush)
Local $hPen = _WinAPI_SelectObject($hDC, $hOldPen)
_WinAPI_DeleteObject($hPen)
_WinAPI_SelectObject($hDC, $hBitmap)
_WinAPI_DrawBitmap($hDC, 0, 0, $hSource, $MERGECOPY)
_WinAPI_ReleaseDC($hPic, $hDev)
_WinAPI_SelectObject($hDC, $hSv)
_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteDC($hDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
$hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = -3


Function _WinAPI_PolyBezierTo

Function Reference

_WinAPI_PolyBezierTo

Draws one or more Bezier curves

#include <WinAPIGdi.au3>
_WinAPI_PolyBezierTo ( $hDC, Const ByRef $aPoint [, $iStart = 0 [, $iEnd = -1]] )

Parameters

$hDC | Handle to a device context.
$aPoint | The 2D array ([x1, y1], [x2, y2], ... [xN, yN]) that contains the endpoints and control points of the curve(s), in logical units. The number of points must be three times the number of curves to be drawn, because each Bezier curve requires two control points and an ending point.
$iStart | [optional] The index of array to start drawing at.
$iEnd | [optional] The index of array to stop drawing at.

Return Value

Success: | True
Failure: | False

Remarks

This function draws cubic Bezier curves by using the control points specified by the $aPoint parameter.
The first curve is drawn from the current position to the third point by using the first two points as control points.
For each subsequent curve, the function needs exactly three more points, and uses the ending point of the previous
curve as the starting point for the next.

The current position moves to the ending point of the last Bezier curve. The figure is not filled.

This function draws lines by using the current pen.

See Also

Search PolyBezierTo in MSDN Library.


Function _WinAPI_PolyDraw

Function Reference

_WinAPI_PolyDraw

Draws a set of line segments and Bezier curves

#include <WinAPIGdi.au3>
_WinAPI_PolyDraw ( $hDC, Const ByRef $aPoint [, $iStart = 0 [, $iEnd = -1]] )

Parameters

$hDC | Handle to a device context.
$aPoint | The 2D array ([x1, y1, type1], [x2, y2, type2], ... [xN, yN, typeN]) that contains the endpoints for each line segment and the endpoints and control points for each Bezier curve, in logical units. In addition, the array contains a parameters that specifies how each point is used. The third parameter of the array can be one of the following values. $PT_BEZIERTO $PT_LINETO $PT_MOVETO $PT_BEZIERTO or $PT_LINETO type can be combined with the following value that the corresponding point is the last point in a figure and the figure is closed. $PT_CLOSEFIGURE
$iStart | [optional] The index of array to start drawing at.
$iEnd | [optional] The index of array to stop drawing at.

Return Value

Success: | True
Failure: | False

Remarks

This function can be used in place of consecutive calls to _WinAPI_MoveToEx(), _WinAPI_LineTo(), and _WinAPI_PolyBezierTo()
functions to draw disjoint figures. The lines and curves are drawn using the current pen and figures are not filled.
If there is an active path started by calling _WinAPI_BeginPath(), _WinAPI_PolyDraw() adds to the path.

This function updates the current position.

Related

_WinAPI_BeginPath, _WinAPI_LineTo, _WinAPI_MoveToEx, _WinAPI_PolyBezierTo

See Also

Search PolyDraw in MSDN Library.


Function _WinAPI_SetArcDirection

Function Reference

_WinAPI_SetArcDirection

Sets the drawing arc direction

#include <WinAPIGdi.au3>
_WinAPI_SetArcDirection ( $hDC, $iDirection )

Parameters

$hDC | Handle to the device context.
$iDirection | The new arc direction. This parameter can be one of the following values. $AD_COUNTERCLOCKWISE $AD_CLOCKWISE

Return Value

Success: | The previous arc direction.
Failure: | 0.

Remarks

The default direction is counterclockwise.

See Also

Search SetArcDirection in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 241, 241)
Local $idPic = GUICtrlCreatePic('', 0, 0, 241, 241)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDC = _WinAPI_GetDC($hPic)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 241, 241, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap)

; Create path
_WinAPI_BeginPath($hMemDC)
_WinAPI_MoveTo($hMemDC, 220, 78)
_WinAPI_LineTo($hMemDC, 170, 218)
_WinAPI_LineTo($hMemDC, 70, 218)
_WinAPI_LineTo($hMemDC, 20, 78)
_WinAPI_SetArcDirection($hMemDC, $AD_CLOCKWISE)
_WinAPI_ArcTo($hMemDC, _WinAPI_CreateRectEx(49, 22, 143, 143), 49, 78, 192, 78)
_WinAPI_CloseFigure($hMemDC)
_WinAPI_Ellipse($hMemDC, _WinAPI_CreateRectEx(70, 44, 101, 101))
_WinAPI_Ellipse($hMemDC, _WinAPI_CreateRectEx(90, 64, 61, 61))
_WinAPI_EndPath($hMemDC)

; Stroke outline, and fills path's interior
Local $hBrush = _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hPen = _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetDCBrushColor($hMemDC, 0xFFC000)
_WinAPI_SetDCPenColor($hMemDC, 0xDD0000)
_WinAPI_StrokeAndFillPath($hMemDC)

; Release objects
_WinAPI_DeleteObject(_WinAPI_SelectObject($hDC, $hBrush))
_WinAPI_DeleteObject(_WinAPI_SelectObject($hDC, $hPen))
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


User Defined Functions

MetaFiles user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIGdi.au3>.

User Defined Function | Description
_WinAPI_CloseEnhMetaFile | Closes an enhanced-metafile device context and returns a handle that identifies an enhanced-format metafile
_WinAPI_CopyEnhMetaFile | Copies the contents of an enhanced-format metafile to a specified file
_WinAPI_CreateEnhMetaFile | Creates a device context for an enhanced-format metafile
_WinAPI_DeleteEnhMetaFile | Deletes an enhanced-format metafile or an enhanced-format metafile handle
_WinAPI_GdiComment | Copies a comment from a buffer into a specified enhanced-format metafile
_WinAPI_GetEnhMetaFile | Creates a handle that identifies the enhanced-format metafile stored in the specified file
_WinAPI_GetEnhMetaFileBits | Retrieves the contents of the specified enhanced-format metafile
_WinAPI_GetEnhMetaFileDescription | Retrieves an optional text description from an enhanced-format metafile
_WinAPI_GetEnhMetaFileDimension | Retrieves a dimension of the specified enhanced-format metafile
_WinAPI_GetEnhMetaFileHeader | Retrieves the record containing the header for the specified enhanced-format metafile
_WinAPI_PlayEnhMetaFile | Displays the picture stored in the specified enhanced-format metafile
_WinAPI_SetEnhMetaFileBits | Creates a memory-based enhanced-format metafile from the specified data


Function _WinAPI_CloseEnhMetaFile

Function Reference

_WinAPI_CloseEnhMetaFile

Closes an enhanced-metafile device context and returns a handle that identifies an enhanced-format metafile

#include <WinAPIGdi.au3>
_WinAPI_CloseEnhMetaFile ( $hDC )

Parameters

$hDC Handle to an enhanced-metafile device context.

Return Value

Success: | Handle to an enhanced metafile.
Failure: | 0.

Remarks

When the application no longer needs an enhanced-metafile handle, it should delete the handle by calling the
_WinAPI_DeleteEnhMetaFile() function.

Related

_WinAPI_DeleteEnhMetaFile

See Also

Search CloseEnhMetaFile in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>

Local Const $sEmf = @TempDir & '\Test.emf'

If FileExists($sEmf) Then
    If MsgBox(BitOR($MB_YESNOCANCEL, $MB_ICONQUESTION, $MB_DEFBUTTON2, $MB_SYSTEMMODAL), 'Create Enhanced Metafile', $sEmf & ' is already exists.' & @CRLF & @CRLF & 'Do you want to replace it?') <> 6 Then
        Exit
    EndIf
    If Not FileDelete($sEmf) Then
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Create Enhanced Metafile', 'Unable to delete file.')
        Exit
    EndIf
EndIf

; Create device context for an enhanced-format metafile
Local $tRECT = _WinAPI_CreateRect(0, 0, 250, 250)
Local $hDC = _WinAPI_CreateEnhMetaFile(0, $tRECT, 1, @TempDir & '\Test.emf')

; Draw objects
Local $hBrush = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hPen = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($NULL_PEN))
_WinAPI_SetDCBrushColor($hDC, 0xAA0000)
_WinAPI_Rectangle($hDC, $tRECT)
_WinAPI_SetDCBrushColor($hDC, 0xFFFFFF)
Local $aPoint[10][2] = [[0, 90], [95, 90], [125, 0], [154, 90], [250, 90], [172, 147], [202, 238], [125, 181], [47, 238], [77, 147]]
Local $hRgn = _WinAPI_CreatePolygonRgn($aPoint)
_WinAPI_OffsetRgn($hRgn, 0, 6)
_WinAPI_PaintRgn($hDC, $hRgn)

; Release objects
_WinAPI_SelectObject($hDC, $hBrush)
_WinAPI_SelectObject($hDC, $hPen)
Local $hEmf = _WinAPI_CloseEnhMetaFile($hDC)
_WinAPI_DeleteEnhMetaFile($hEmf)
_WinAPI_DeleteObject($hRgn)

; Show created .emf file into the Microsoft Paint
If FileExists($sEmf) Then
    ShellExecute(@SystemDir & '\mspaint.exe', $sEmf)
EndIf


Function _WinAPI_CopyEnhMetaFile

Function Reference

_WinAPI_CopyEnhMetaFile

Copies the contents of an enhanced-format metafile to a specified file

#include <WinAPIGdi.au3>
_WinAPI_CopyEnhMetaFile ( $hEmf [, $sFilePath = ''] )

Parameters

$hEmf | Handle to the enhanced metafile to be copied.
$sFilePath | [optional] The name of the destination file (.emf). If this parameter is '' (Default), the source metafile is copied to memory.

Return Value

Success: | Handle to the copy of the enhanced metafile.
Failure: | 0.

Remarks

When the application no longer needs an enhanced-metafile handle, it should delete the handle by calling the
_WinAPI_DeleteEnhMetaFile() function.

Related

_WinAPI_DeleteEnhMetaFile

See Also

Search CopyEnhMetaFile in MSDN Library.


Function _WinAPI_CreateEnhMetaFile

Function Reference

_WinAPI_CreateEnhMetaFile

Creates a device context for an enhanced-format metafile

#include <WinAPIGdi.au3>
_WinAPI_CreateEnhMetaFile ( [$hDC = 0 [, $tRECT = 0 [, $bPixels = False [, $sFilePath = '' [, $sDescription = '']]]]] )

Parameters

$hDC | [optional] Handle to a reference device for the enhanced metafile. The system uses this device context to record the resolution and units of the device on which a picture originally appeared. If this parameter is 0 (Default), it uses the current display device for reference.
$tRECT | [optional] $tagRECT structure that specifies the dimensions of the picture to be stored in the enhanced metafile. If this parameter is 0 (Default), the graphics device interface computes the dimensions of the smallest rectangle that surrounds the picture drawn by the application.
$bPixels | [optional] Specifies whether the $tRECT structure defined in pixels, valid values: True - In logical units (pixels). False - In .01-millimeter units (Default).
$sFilePath | [optional] The file name for the enhanced metafile to be created. If this parameter is '' (Default), the enhanced metafile is memory based and its contents are lost when it is deleted by using the _WinAPI_DeleteEnhMetaFile() function.
$sDescription | [optional] The string that specifies the name of the application that created the picture, as well as the picture's title. This string must be an empty string or represented as follows: "application name|picture name"

Return Value

Success: | Handle to the device context for the enhanced metafile.
Failure: | 0.

Remarks

Applications use the device context created by this function to store a graphics picture in an enhanced metafile.
The handle identifying this device context can be passed to any GDI function.

After an application stores a picture in an enhanced metafile, it can display the picture on any output device by calling the _WinAPI_PlayEnhMetaFile() function.
When displaying the picture, the system uses the rectangle pointed to by the $tRECT parameter and the resolution data from the reference device to position and scale the picture.

The file name for the enhanced metafile should use the .emf extension.

Related

_WinAPI_PlayEnhMetaFile

See Also

Search CreateEnhMetaFile in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>

Local Const $sEmf = @TempDir & '\Test.emf'

If FileExists($sEmf) Then
    If MsgBox(BitOR($MB_YESNOCANCEL, $MB_ICONQUESTION, $MB_DEFBUTTON2, $MB_SYSTEMMODAL), 'Create Enhanced Metafile', $sEmf & ' is already exists.' & @CRLF & @CRLF & 'Do you want to replace it?') <> 6 Then
        Exit
    EndIf
    If Not FileDelete($sEmf) Then
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Create Enhanced Metafile', 'Unable to delete file.')
        Exit
    EndIf
EndIf

; Create device context for an enhanced-format metafile
Local $tRECT = _WinAPI_CreateRect(0, 0, 250, 250)
Local $hDC = _WinAPI_CreateEnhMetaFile(0, $tRECT, 1, @TempDir & '\Test.emf')

; Draw objects
Local $hBrush = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hPen = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($NULL_PEN))
_WinAPI_SetDCBrushColor($hDC, 0xAA0000)
_WinAPI_Rectangle($hDC, $tRECT)
_WinAPI_SetDCBrushColor($hDC, 0xFFFFFF)
Local $aPoint[10][2] = [[0, 90], [95, 90], [125, 0], [154, 90], [250, 90], [172, 147], [202, 238], [125, 181], [47, 238], [77, 147]]
Local $hRgn = _WinAPI_CreatePolygonRgn($aPoint)
_WinAPI_OffsetRgn($hRgn, 0, 6)
_WinAPI_PaintRgn($hDC, $hRgn)

; Release objects
_WinAPI_SelectObject($hDC, $hBrush)
_WinAPI_SelectObject($hDC, $hPen)
Local $hEmf = _WinAPI_CloseEnhMetaFile($hDC)
_WinAPI_DeleteEnhMetaFile($hEmf)
_WinAPI_DeleteObject($hRgn)

; Show created .emf file into the Microsoft Paint
If FileExists($sEmf) Then
    ShellExecute(@SystemDir & '\mspaint.exe', $sEmf)
EndIf


Function _WinAPI_DeleteEnhMetaFile

Function Reference

_WinAPI_DeleteEnhMetaFile

Deletes an enhanced-format metafile or an enhanced-format metafile handle

#include <WinAPIGdi.au3>
_WinAPI_DeleteEnhMetaFile ( $hEmf )

Parameters

$hEmf Handle to an enhanced metafile.

Return Value

Success: | True
Failure: | False

Remarks

If the $hEmf parameter identifies an enhanced metafile stored in memory, the _WinAPI_DeleteEnhMetaFile() function deletes the metafile.
If $hEmf identifies a metafile stored on a disk, the function deletes the metafile handle but does not destroy the actual metafile.
An application can retrieve the file by calling the _WinAPI_GetEnhMetaFile() function.

Related

_WinAPI_GetEnhMetaFile

See Also

Search DeleteEnhMetaFile in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>

Local Const $sEmf = @TempDir & '\Test.emf'

If FileExists($sEmf) Then
    If MsgBox(BitOR($MB_YESNOCANCEL, $MB_ICONQUESTION, $MB_DEFBUTTON2, $MB_SYSTEMMODAL), 'Create Enhanced Metafile', $sEmf & ' is already exists.' & @CRLF & @CRLF & 'Do you want to replace it?') <> 6 Then
        Exit
    EndIf
    If Not FileDelete($sEmf) Then
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Create Enhanced Metafile', 'Unable to delete file.')
        Exit
    EndIf
EndIf

; Create device context for an enhanced-format metafile
Local $tRECT = _WinAPI_CreateRect(0, 0, 250, 250)
Local $hDC = _WinAPI_CreateEnhMetaFile(0, $tRECT, 1, @TempDir & '\Test.emf')

; Draw objects
Local $hBrush = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hPen = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($NULL_PEN))
_WinAPI_SetDCBrushColor($hDC, 0xAA0000)
_WinAPI_Rectangle($hDC, $tRECT)
_WinAPI_SetDCBrushColor($hDC, 0xFFFFFF)
Local $aPoint[10][2] = [[0, 90], [95, 90], [125, 0], [154, 90], [250, 90], [172, 147], [202, 238], [125, 181], [47, 238], [77, 147]]
Local $hRgn = _WinAPI_CreatePolygonRgn($aPoint)
_WinAPI_OffsetRgn($hRgn, 0, 6)
_WinAPI_PaintRgn($hDC, $hRgn)

; Release objects
_WinAPI_SelectObject($hDC, $hBrush)
_WinAPI_SelectObject($hDC, $hPen)
Local $hEmf = _WinAPI_CloseEnhMetaFile($hDC)
_WinAPI_DeleteEnhMetaFile($hEmf)
_WinAPI_DeleteObject($hRgn)

; Show created .emf file into the Microsoft Paint
If FileExists($sEmf) Then
    ShellExecute(@SystemDir & '\mspaint.exe', $sEmf)
EndIf


Function _WinAPI_GdiComment

Function Reference

_WinAPI_GdiComment

Copies a comment from a buffer into a specified enhanced-format metafile

#include <WinAPIGdi.au3>
_WinAPI_GdiComment ( $hDC, $pBuffer, $iSize )

Parameters

$hDC | Handle to an enhanced-metafile device context.
$pBuffer | A pointer to the buffer that contains the comment.
$iSize | The length of the comment buffer, in bytes.

Return Value

Success: | True
Failure: | False

See Also

Search GdiComment in MSDN Library.


Function _WinAPI_GetEnhMetaFile

Function Reference

_WinAPI_GetEnhMetaFile

Creates a handle that identifies the enhanced-format metafile stored in the specified file

#include <WinAPIGdi.au3>
_WinAPI_GetEnhMetaFile ( $sFilePath )

Parameters

$sFilePath The name of an enhanced metafile (.emf).

Return Value

Success: | Handle to the enhanced metafile.
Failure: | 0.

Remarks

When the application no longer needs an enhanced-metafile handle, it should delete the handle by calling the
_WinAPI_DeleteEnhMetaFile() function.

Related

_WinAPI_DeleteEnhMetaFile

See Also

Search GetEnhMetaFile in MSDN Library.


Function _WinAPI_GetEnhMetaFileBits

Function Reference

_WinAPI_GetEnhMetaFileBits

Retrieves the contents of the specified enhanced-format metafile

#include <WinAPIGdi.au3>
_WinAPI_GetEnhMetaFileBits ( $hEmf, ByRef $pBuffer )

Parameters

$hEmf | Handle to the enhanced metafile.
$pBuffer | Returns a pointer to a memory block (buffer) that receives the metafile data. Optionaly, you can set this parameter to 0 before function call, then the function will allocate the required memory block itself. Otherwise, it must be a valid memory pointer returned by the _WinAPI_CreateBuffer() function, or by previously calling this function.

Return Value

Success: | The number of bytes copied to the buffer.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

After the enhanced-metafile bits are retrieved, they can be used to create a memory-based metafile by calling the _WinAPI_SetEnhMetaFileBits() function.

When you no longer need the buffer allocated by this function, you must call the _WinAPI_FreeMemory() function (do not use any other memory routines) to release occupied memory.

Related

_WinAPI_CreateBuffer, _WinAPI_FreeMemory, _WinAPI_SetEnhMetaFileBits

See Also

Search GetEnhMetaFileBits in MSDN Library.


Function _WinAPI_GetEnhMetaFileDescription

Function Reference

_WinAPI_GetEnhMetaFileDescription

Retrieves an optional text description from an enhanced-format metafile

#include <WinAPIGdi.au3>
_WinAPI_GetEnhMetaFileDescription ( $hEmf )

Parameters

$hEmf Handle to the enhanced metafile.

Return Value

Success: | 0 if the optional text description does not exist, otherwise an array that contains the following information: [0] - Application name [1] - Picture name
Failure: | sets the @error flag to non-zero.

See Also

Search GetEnhMetaFileDescription in MSDN Library.

Example

#include <WinAPIGdi.au3>

Local $hEmf = _WinAPI_GetEnhMetaFile(@ScriptDir & '\Extras\Flag.emf')
Local $aData = _WinAPI_GetEnhMetaFileDescription($hEmf)
_WinAPI_DeleteEnhMetaFile($hEmf)

ConsoleWrite('Application: ' & $aData[0] & @CRLF)
ConsoleWrite('Picture:     ' & $aData[1] & @CRLF)


Function _WinAPI_GetEnhMetaFileDimension

Function Reference

_WinAPI_GetEnhMetaFileDimension

Retrieves a dimension of the specified enhanced-format metafile

#include <WinAPIGdi.au3>
_WinAPI_GetEnhMetaFileDimension ( $hEmf )

Parameters

$hEmf Handle to the enhanced metafile to retrieve dimension.

Return Value

Success: | $tagSIZE structure that contains the enhanced metafile dimension, in pixels.
Failure: | Sets the @error flag to non-zero.

Example

#include <WinAPIGdi.au3>

Local $hEmf = _WinAPI_GetEnhMetaFile(@ScriptDir & '\Extras\Flag.emf')
Local $tSIZE = _WinAPI_GetEnhMetaFileDimension($hEmf)
_WinAPI_DeleteEnhMetaFile($hEmf)

ConsoleWrite(DllStructGetData($tSIZE, 'X') & ' x ' & DllStructGetData($tSIZE, 'Y') & @CRLF)


Function _WinAPI_GetEnhMetaFileHeader

Function Reference

_WinAPI_GetEnhMetaFileHeader

Retrieves the record containing the header for the specified enhanced-format metafile

#include <WinAPIGdi.au3>
_WinAPI_GetEnhMetaFileHeader ( $hEmf )

Parameters

$hEmf Handle to the enhanced metafile for which the header is to be retrieved.

Return Value

Success: | $tagENHMETAHEADER structure that contains the header record, @extended flag will contain the number of bytes copied to the structure, in bytes.
Failure: | Sets the @error flag to non-zero.

See Also

Search GetEnhMetaFileHeader in MSDN Library.


Function _WinAPI_PlayEnhMetaFile

Function Reference

_WinAPI_PlayEnhMetaFile

Displays the picture stored in the specified enhanced-format metafile

#include <WinAPIGdi.au3>
_WinAPI_PlayEnhMetaFile ( $hDC, $hEmf, $tRECT )

Parameters

$hDC | Handle to the device context for the output device on which the picture will appear.
$hEmf | Handle to the enhanced metafile.
$tRECT | $tagRECT structure that contains the coordinates of the bounding rectangle used to display the picture, in logical units

Return Value

Success: | True
Failure: | False

Remarks

An enhanced metafile can be embedded in a newly created enhanced metafile by calling _WinAPI_PlayEnhMetaFile()
and playing the source enhanced metafile into the device context for the new enhanced metafile.

See Also

Search PlayEnhMetaFile in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Load enhanced metafile (.emf) and retrieve it's dimension (x6)
Local $hEmf = _WinAPI_GetEnhMetaFile(@ScriptDir & '\Extras\Flag.emf')
Local $tSIZE = _WinAPI_GetEnhMetaFileDimension($hEmf)
Local $iWidth = 6 * DllStructGetData($tSIZE, 'X')
Local $iHeight = 6 * DllStructGetData($tSIZE, 'Y')

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), $iWidth, $iHeight)
Local $idPic = GUICtrlCreatePic('', 0, 0, $iWidth, $iHeight)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap from enhanced metafile
Local $hDC = _WinAPI_GetDC($hPic)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, $iWidth, $iHeight, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap)
Local $tRECT = _WinAPI_CreateRectEx(0, 0, $iWidth, $iHeight)
_WinAPI_PlayEnhMetaFile($hMemDC, $hEmf, $tRECT)

_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Release enhanced metafile
_WinAPI_DeleteEnhMetaFile($hEmf)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_SetEnhMetaFileBits

Function Reference

_WinAPI_SetEnhMetaFileBits

Creates a memory-based enhanced-format metafile from the specified data

#include <WinAPIGdi.au3>
_WinAPI_SetEnhMetaFileBits ( $pData, $iLength )

Parameters

$pData | A pointer to the buffer that contains the enhanced-metafile data. To obtain the metafile data, call the _WinAPI_GetEnhMetaFileBits() function.
$iLength | The size of the buffer, in bytes.

Return Value

Success: | Handle to a memory-based enhanced metafile.
Failure: | 0.

Remarks

When the application no longer needs an enhanced-metafile handle, it should delete the handle by calling the
_WinAPI_DeleteEnhMetaFile() function.

Related

_WinAPI_DeleteEnhMetaFile, _WinAPI_GetEnhMetaFileBits

See Also

Search SetEnhMetaFileBits in MSDN Library.


User Defined Functions

Monitors user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIGdi.au3>.

User Defined Function | Description
_WinAPI_EnumDisplayMonitors | Enumerates display monitors (including invisible pseudo-monitors associated with the mirroring drivers)
_WinAPI_MonitorFromPoint | Retrieves a handle to the display monitor that contains a specified point
_WinAPI_MonitorFromRect | Retrieves a handle to the display monitor that has the largest area of intersection with a specified rectangle
_WinAPI_MonitorFromWindow | Retrieves a handle to the display monitor that has the largest area of intersection with the specified window


Function _WinAPI_EnumDisplayMonitors

Function Reference

_WinAPI_EnumDisplayMonitors

Enumerates display monitors (including invisible pseudo-monitors associated with the mirroring drivers)

#include <WinAPIGdi.au3>
_WinAPI_EnumDisplayMonitors ( [$hDC = 0 [, $tRECT = 0]] )

Parameters

$hDC | [optional] Handle to a display device context that defines the visible region of interest. If it's 0 (Default), the visible region of interest is the virtual screen that encompasses all the displays on the desktop.
$tRECT | [optional] $tagRECT structure that specifies a clipping rectangle. This parameter can be 0 (Default) if you don't want to clip the specified region.

Return Value

Success: | The 2D array containing the following information: [0][0] - Number of rows in array (n) [0][1] - Unused [n][0] - A handle to the display monitor. [n][1] - $tagRECT structure defining a display monitor rectangle or the clipping area.
Failure: | Sets the @error flag to non-zero.

See Also

Search EnumDisplayMonitors in MSDN Library.

Example

#include <Array.au3>
#include <WinAPIGdi.au3>

Local $aPos, $aData = _WinAPI_EnumDisplayMonitors()

If IsArray($aData) Then
    ReDim $aData[$aData[0][0] + 1][5]
    For $i = 1 To $aData[0][0]
        $aPos = _WinAPI_GetPosFromRect($aData[$i][1])
        For $j = 0 To 3
            $aData[$i][$j + 1] = $aPos[$j]
        Next
    Next
EndIf

_ArrayDisplay($aData, '_WinAPI_EnumDisplayMonitors')


Function _WinAPI_MonitorFromPoint

Function Reference

_WinAPI_MonitorFromPoint

Retrieves a handle to the display monitor that contains a specified point

#include <WinAPIGdi.au3>
_WinAPI_MonitorFromPoint ( $tPOINT [, $iFlag = 1] )

Parameters

$tPOINT | $tagPOINT structure that specifies the point of interest in virtual-screen coordinates.
$iFlag | [optional] The flag that specifies the function's return value if the point is not contained within any display monitor. This parameter can be one of the following values. $MONITOR_DEFAULTTONULL $MONITOR_DEFAULTTONEAREST (Default) $MONITOR_DEFAULTTOPRIMARY

Return Value

Success: | A handle to the display monitor that contains a specified point, or the value depends on the $MONITOR_* constant.
Failure: | 0 and sets the @error flag to non-zero.

See Also

Search MonitorFromPoint in MSDN Library.

Example

#include <WinAPIGdi.au3>
#include <WinAPISys.au3>

Local $tPos = _WinAPI_GetMousePos()
DllStructSetData($tPos, 1, 12000)
Local $hMonitor = _WinAPI_MonitorFromPoint($tPos, 0)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hMonitor = ' & $hMonitor & @CRLF & '>Error code: ' & @error & '    Extended code: 0x' & Hex(@extended) & @CRLF) ;### Debug Console

Local $aData = _WinAPI_GetMonitorInfo($hMonitor)
If IsArray($aData) Then
    ConsoleWrite('Handle:      ' & $hMonitor & @CRLF)
    ConsoleWrite('Rectangle:   ' & DllStructGetData($aData[0], 1) & ', ' & DllStructGetData($aData[0], 2) & ', ' & DllStructGetData($aData[0], 3) & ', ' & DllStructGetData($aData[0], 4) & @CRLF)
    ConsoleWrite('Work area:   ' & DllStructGetData($aData[1], 1) & ', ' & DllStructGetData($aData[1], 2) & ', ' & DllStructGetData($aData[1], 3) & ', ' & DllStructGetData($aData[1], 4) & @CRLF)
    ConsoleWrite('Primary:     ' & $aData[2] & @CRLF)
    ConsoleWrite('Device name: ' & $aData[3] & @CRLF)
EndIf


Function _WinAPI_MonitorFromRect

Function Reference

_WinAPI_MonitorFromRect

Retrieves a handle to the display monitor that has the largest area of intersection with a specified rectangle

#include <WinAPIGdi.au3>
_WinAPI_MonitorFromRect ( $tRECT [, $iFlag = 1] )

Parameters

$tRECT | $tagRECT structure that specifies the rectangle of interest in virtual-screen coordinates.
$iFlag | [optional] The flag that specifies the function's return value if the rectangle does not intersect any display monitor. This parameter can be one of the following values. $MONITOR_DEFAULTTONULL $MONITOR_DEFAULTTONEAREST (Default) $MONITOR_DEFAULTTOPRIMARY

Return Value

Returns the handle to the monitor that has the largest area of intersection with the rectangle,
or the value depends on the $MONITOR_* constant.

See Also

Search MonitorFromRect in MSDN Library.


Function _WinAPI_MonitorFromWindow

Function Reference

_WinAPI_MonitorFromWindow

Retrieves a handle to the display monitor that has the largest area of intersection with the specified window

#include <WinAPIGdi.au3>
_WinAPI_MonitorFromWindow ( $hWnd [, $iFlag = 1] )

Parameters

$hWnd | A handle to the window of interest.
$iFlag | [optional] The flag that specifies the function's return value if the window does not intersect any display monitor. This parameter can be one of the following values. $MONITOR_DEFAULTTONULL $MONITOR_DEFAULTTONEAREST (Default) $MONITOR_DEFAULTTOPRIMARY

Return Value

Returns the handle to the monitor that has the largest area of intersection with the window,
or the value depends on the $MONITOR_* constant.

Remarks

If the window is currently minimized, the function uses the rectangle of the window before it was minimized.

See Also

Search MonitorFromWindow in MSDN Library.


User Defined Functions

Paint & Draw user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIGdi.au3>.

User Defined Function | Description
_WinAPI_BeginPaint | Prepares the specified window for painting
_WinAPI_DrawAnimatedRects | Animates the caption of a window to indicate the opening of an icon or the minimizing or maximizing of a window
_WinAPI_DrawShadowText | Draws formatted text in the specified rectangle with a drop shadow
_WinAPI_EndPaint | Marks the end of painting in the specified window
_WinAPI_GetBkColor | Retrieves the current background color for the specified device context
_WinAPI_GetBoundsRect | Obtains the current accumulated bounding rectangle for a specified device context
_WinAPI_GetROP2 | Retrieves the foreground mix mode of the specified device context
_WinAPI_GetUpdateRect | Retrieves the coordinates of the rectangle that completely encloses the update region of the specified window
_WinAPI_GetUpdateRgn | Retrieves the update region of a window by copying it into the specified region
_WinAPI_GetWindowRgnBox | Retrieves the dimensions of the tightest bounding rectangle for the window region of a window
_WinAPI_InvalidateRgn | Adds a region to the specified window's update region
_WinAPI_LockWindowUpdate | Disables or enables drawing in the specified window
_WinAPI_PaintDesktop | Fills the clipping region in the specified device context with the desktop pattern or wallpaper
_WinAPI_SetBoundsRect | Controls the accumulation of bounding rectangle information for the specified device context
_WinAPI_SetROP2 | Retrieves the foreground mix mode of the specified device context
_WinAPI_ValidateRect | Removes a rectangle from the current update region of the specified window
_WinAPI_ValidateRgn | Removes a region from the current update region of the specified window
_WinAPI_WindowFromDC | Retrieves a handle to the window associated with the specified display device context (DC)


Function _WinAPI_BeginPaint

Function Reference

_WinAPI_BeginPaint

Prepares the specified window for painting

#include <WinAPIGdi.au3>
_WinAPI_BeginPaint ( $hWnd, ByRef $tPAINTSTRUCT )

Parameters

$hWnd | Handle to the window to be repainted.
$tPAINTSTRUCT | $tagPAINTSTRUCT structure that will receive painting information. When the function call, this parameter should be any valid variable, the function creates this structure itself.

Return Value

Success: | Handle to a display device context for the specified window.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

This function automatically sets the clipping region of the device context to exclude any area outside the update region.
The update region is set by the _WinAPI_InvalidateRect() or _WinAPI_InvalidateRgn() function and by the system after sizing, moving, creating, scrolling, or any other operation that affects the client area.
If the update region is marked for erasing, _WinAPI_BeginPaint() sends a WM_ERASEBKGND message to the window.

An application should not call _WinAPI_BeginPaint() except in response to a WM_PAINT message.
Each call to _WinAPI_BeginPaint() must have a corresponding call to the _WinAPI_EndPaint() function.

Related

_WinAPI_InvalidateRect, _WinAPI_InvalidateRgn

See Also

Search BeginPaint in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIShellEx.au3>
#include <WindowsConstants.au3>

Opt('MouseCoordMode', 2)

Global $g_iCount = 0

OnAutoItExitRegister('OnAutoItExit')

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idPic = GUICtrlCreatePic('', 0, 0, 400, 400)
GUICtrlSetCursor(-1, 0)
Local $hPic = GUICtrlGetHandle($idPic)
Local $idLabel = GUICtrlCreateLabel('', 176, 176, 48, 48)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
Global $g_hLabel = GUICtrlGetHandle($idLabel)

; Extract icon
Local $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 130, 48, 48)

; Register label window proc
Global $g_hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam')
Local $pDll = DllCallbackGetPtr($g_hDll)
Global $g_hProc = _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $pDll)

; Create gradient
Local $hDC = _WinAPI_GetDC($hPic)
Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, 400, 400)
Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap)
Local $aVertex[2][3] = [[0, 0, 0xAA00FF], [400, 400, 0x33004D]]
_WinAPI_GradientFill($hDestDC, $aVertex)

_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hDestDC, $hDestSv)
_WinAPI_DeleteDC($hDestDC)

; Set gradient to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Local $aPos
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $GUI_EVENT_PRIMARYDOWN
            $aPos = MouseGetPos()
            If _WinAPI_PtInRectEx($aPos[0], $aPos[1], 0, 0, 400, 400) Then
                GUICtrlSetPos($idLabel, $aPos[0] - 24, $aPos[1] - 24)
            EndIf
    EndSwitch
WEnd

Func _WinProc($hWnd, $iMsg, $wParam, $lParam)
    Switch $iMsg
        Case $WM_PAINT
            If $g_iCount = 0 Then
                Local $tPAINTSTRUCT, $hDC

                $g_iCount += 1
                $hDC = _WinAPI_BeginPaint($hWnd, $tPAINTSTRUCT)
                _WinAPI_DrawIconEx($hDC, 0, 0, $hIcon, 48, 48)
                _WinAPI_EndPaint($hWnd, $tPAINTSTRUCT)
                $g_iCount -= 1
                Return 0
            EndIf
    EndSwitch
    Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_WinProc

Func OnAutoItExit()
    _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $g_hProc)
    DllCallbackFree($g_hDll)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_DrawAnimatedRects

Function Reference

_WinAPI_DrawAnimatedRects

Animates the caption of a window to indicate the opening of an icon or the minimizing or maximizing of a window

#include <WinAPIGdi.au3>
_WinAPI_DrawAnimatedRects ( $hWnd, $tRectFrom, $tRectTo )

Parameters

$hWnd | Handle to the window whose caption should be animated on the screen.
$tRectFrom | $tagRECT structure specifying the location and size of the icon or minimized window.
$tRectTo | $tagRECT structure specifying the location and size of the restored window.

Return Value

Success: | True
Failure: | False

Remarks

The window caption will animate from the position specified by $tRectFrom to the position specified by $tRectTo.
The effect is similar to minimizing or maximizing a window.

See Also

Search DrawAnimatedRects in MSDN Library.

Example

#NoTrayIcon

#include <APIGdiConstants.au3>
#include <APISysConstants.au3>
#include <GUIConstantsEx.au3>
#include <MenuConstants.au3>
#include <TrayConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPISys.au3>
#include <WIndowsConstants.au3>

Opt('TrayMenuMode', 1)

Local $hTray = ControlGetHandle('[CLASS:Shell_TrayWnd]', '', 'TrayNotifyWnd1')

Local $idTrayRestoreItem = TrayCreateItem('Restore')
TrayItemSetState(-1, $TRAY_DEFAULT)
TrayCreateItem('')
Local $idTrayExitItem = TrayCreateItem('Exit')
TraySetClick(8)

Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'))
Global $g_idDummy = GUICtrlCreateDummy()
GUIRegisterMsg($WM_SYSCOMMAND, 'WM_SYSCOMMAND')
GUISetState(@SW_SHOW)

While 1
    Switch TrayGetMsg()
        Case $idTrayRestoreItem
            _WinAPI_DrawAnimatedRects($g_hForm, _WinAPI_GetWindowRect($hTray), _WinAPI_GetWindowRect($g_hForm))
            GUISetState(@SW_SHOW, $g_hForm)
            TraySetState(2)
        Case $idTrayExitItem
            ExitLoop
    EndSwitch
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            _WinAPI_AnimateWindow($g_hForm, BitOR($AW_BLEND, $AW_HIDE))
            ExitLoop
        Case $g_idDummy ; Minimize
            _WinAPI_DrawAnimatedRects($g_hForm, _WinAPI_GetWindowRect($g_hForm), _WinAPI_GetWindowRect($hTray))
            GUISetState(@SW_HIDE, $g_hForm)
            TraySetState(1)
    EndSwitch
WEnd

Func WM_SYSCOMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $lParam

    Switch $hWnd
        Case $g_hForm
            Switch $wParam
                Case $SC_MINIMIZE
                    GUICtrlSendToDummy($g_idDummy)
                    Return 0
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SYSCOMMAND


Function _WinAPI_DrawShadowText

Function Reference

_WinAPI_DrawShadowText

Draws formatted text in the specified rectangle with a drop shadow

#include <WinAPIGdi.au3>
_WinAPI_DrawShadowText ( $hDC, $sText, $iRGBText, $iRGBShadow [, $iXOffset = 0 [, $iYOffset = 0 [, $tRECT = 0 [, $iFlags = 0]]]] )

Parameters

$hDC | Handle to a device context.
$sText | The string that contains the text to be drawn.
$iRGBText | The color of the text, in RGB.
$iRGBShadow | The color of the shadow, in RGB.
$iXOffset | [optional] The x-coordinate of where the text should begin. Default is 0.
$iYOffset | [optional] The y-coordinate of where the text should begin. Default is 0.
$tRECT | [optional] $tagRECT structure that contains, in logical coordinates, the rectangle in which the text is to be drawn. If this parameter is 0 (Default), the size will be equal size of the device context ($hDC).
$iFlags | [optional] The flags that specifies how the text is to be drawn. This parameter can be a combination of the formatting text constants ($DT_*).

Return Value

Success: | True
Failure: | False

See Also

Search DrawShadowText in MSDN Library.

Example

#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 100)
Local $idPic = GUICtrlCreatePic('', 20, 20, 360, 60)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $tRECT = _WinAPI_GetClientRect($hPic)
Local $iWidth = DllStructGetData($tRECT, 3) - DllStructGetData($tRECT, 1)
Local $iHeight = DllStructGetData($tRECT, 4) - DllStructGetData($tRECT, 2)
Local $hDC = _WinAPI_GetDC($hPic)
Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap)
Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDC, $iWidth, $iHeight, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hSource)
Local $hFont = _WinAPI_CreateFont(65, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, 'Arial')
_WinAPI_SelectObject($hSrcDC, $hFont)
_WinAPI_DrawShadowText($hSrcDC, 'Shadow Text', 0xF06000, 0x808080, 3, 3, $tRECT, BitOR($DT_CENTER, $DT_SINGLELINE, $DT_VCENTER))
_WinAPI_BitBlt($hDestDC, 0, 0, $iWidth, $iHeight, $hSrcDC, 0, 0, $MERGECOPY)

_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hDestDC, $hDestSv)
_WinAPI_DeleteDC($hDestDC)
_WinAPI_SelectObject($hSrcDC, $hSrcSv)
_WinAPI_DeleteDC($hSrcDC)
_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteObject($hFont)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_EndPaint

Function Reference

_WinAPI_EndPaint

Marks the end of painting in the specified window

#include <WinAPIGdi.au3>
_WinAPI_EndPaint ( $hWnd, ByRef $tPAINTSTRUCT )

Parameters

$hWnd | Handle to the window that has been repainted.
$tPAINTSTRUCT | $tagPAINTSTRUCT structure that contains the painting information retrieved by _WinAPI_BeginPaint().

Return Value

Returns always True

Remarks

This function is required for each call to the _WinAPI_BeginPaint() function, but only after painting is complete.

Related

_WinAPI_BeginPaint

See Also

Search EndPaint in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIShellEx.au3>
#include <WindowsConstants.au3>

Opt('MouseCoordMode', 2)

Global $g_iCount = 0

OnAutoItExitRegister('OnAutoItExit')

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idPic = GUICtrlCreatePic('', 0, 0, 400, 400)
GUICtrlSetCursor(-1, 0)
Local $hPic = GUICtrlGetHandle($idPic)
Local $idLabel = GUICtrlCreateLabel('', 176, 176, 48, 48)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
Global $g_hLabel = GUICtrlGetHandle($idLabel)

; Extract icon
Global $g_hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 130, 48, 48)

; Register label window proc
Global $g_hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam')
Local $pDll = DllCallbackGetPtr($g_hDll)
Global $g_hProc = _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $pDll)

; Create gradient
Local $hDC = _WinAPI_GetDC($hPic)
Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, 400, 400)
Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap)
Local $aVertex[2][3] = [[0, 0, 0xAA00FF], [400, 400, 0x33004D]]
_WinAPI_GradientFill($hDestDC, $aVertex)

_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hDestDC, $hDestSv)
_WinAPI_DeleteDC($hDestDC)

; Set gradient to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Local $aPos
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $GUI_EVENT_PRIMARYDOWN
            $aPos = MouseGetPos()
            If _WinAPI_PtInRectEx($aPos[0], $aPos[1], 0, 0, 400, 400) Then
                GUICtrlSetPos($idLabel, $aPos[0] - 24, $aPos[1] - 24)
            EndIf
    EndSwitch
WEnd

Func _WinProc($hWnd, $iMsg, $wParam, $lParam)
    Switch $iMsg
        Case $WM_PAINT
            If $g_iCount = 0 Then
                Local $tPAINTSTRUCT, $hDC

                $g_iCount += 1
                $hDC = _WinAPI_BeginPaint($hWnd, $tPAINTSTRUCT)
                _WinAPI_DrawIconEx($hDC, 0, 0, $g_hIcon, 48, 48)
                _WinAPI_EndPaint($hWnd, $tPAINTSTRUCT)
                $g_iCount -= 1
                Return 0
            EndIf
    EndSwitch
    Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_WinProc

Func OnAutoItExit()
    _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $g_hProc)
    DllCallbackFree($g_hDll)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_GetBkColor

Function Reference

_WinAPI_GetBkColor

Retrieves the current background color for the specified device context

#include <WinAPIGdi.au3>
_WinAPI_GetBkColor ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | The value of the current background color, in RGB.
Failure: | (-1).

See Also

Search GetBkColor in MSDN Library.


Function _WinAPI_GetBoundsRect

Function Reference

_WinAPI_GetBoundsRect

Obtains the current accumulated bounding rectangle for a specified device context

#include <WinAPIGdi.au3>
_WinAPI_GetBoundsRect ( $hDC [, $iFlags = 0] )

Parameters

$hDC | Handle to the device context whose bounding rectangle the function will return.
$iFlags | [optional] The flags that specifies how the function will behave. This parameter can be the following value: $DCB_RESET

Return Value

Success: | $tagRECT structure that contains the current bounding rectangle, @extended flag will contain the value specifies the state of the accumulated bounding rectangle ($DCB_*).
Failure: | Sets the @error flag to non-zero.

See Also

Search GetBoundsRect in MSDN Library.


Function _WinAPI_GetROP2

Function Reference

_WinAPI_GetROP2

Retrieves the foreground mix mode of the specified device context

#include <WinAPIGdi.au3>
_WinAPI_GetROP2 ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | The value that specifies the foreground mix mode ($R2_*).
Failure: | 0.

See Also

Search GetROP2 in MSDN Library.


Function _WinAPI_GetUpdateRect

Function Reference

_WinAPI_GetUpdateRect

Retrieves the coordinates of the rectangle that completely encloses the update region of the specified window

#include <WinAPIGdi.au3>
_WinAPI_GetUpdateRect ( $hWnd [, $bErase = True] )

Parameters

$hWnd | Handle to the window whose update region is to be retrieved.
$bErase | [optional] Specifies whether the background in the update region is to be erased, valid values: True - The background is erased (Default). False - The background remains unchanged.

Return Value

Success: | $tagRECT structure that contains the coordinates of the enclosing rectangle, in device units.
Failure: | Sets the @error flag to non-zero.

Remarks

The update rectangle retrieved by the _WinAPI_BeginPaint() function is identical to that retrieved by
_WinAPI_GetUpdateRect()

_WinAPI_BeginPaint() automatically validates the update region, so any call to _WinAPI_GetUpdateRect() made
immediately after the call to _WinAPI_BeginPaint() retrieves an empty update region.

See Also

Search GetUpdateRect in MSDN Library.


Function _WinAPI_GetUpdateRgn

Function Reference

_WinAPI_GetUpdateRgn

Retrieves the update region of a window by copying it into the specified region

#include <WinAPIGdi.au3>
_WinAPI_GetUpdateRgn ( $hWnd, $hRgn [, $bErase = True] )

Parameters

$hWnd | Handle to the window with an update region that is to be retrieved.
$hRgn | Handle to the region to receive the update region.
$bErase | [optional] Specifies whether the background in the update region is to be erased, valid values: True - The background is erased (Default). False - The background remains unchanged.

Return Value

Success: | The value that indicates the complexity of the resulting region; it can be one of the following values. $COMPLEXREGION $NULLREGION $SIMPLEREGION
Failure: | 0.

Remarks

_WinAPI_BeginPaint() automatically validates the update region, so any call to _WinAPI_GetUpdateRgn() made
immediately after the call to _WinAPI_BeginPaint() retrieves an empty update region.

Related

_WinAPI_BeginPaint

See Also

Search GetUpdateRgn in MSDN Library.


Function _WinAPI_GetWindowRgnBox

Function Reference

_WinAPI_GetWindowRgnBox

Retrieves the dimensions of the tightest bounding rectangle for the window region of a window

#include <WinAPIGdi.au3>
_WinAPI_GetWindowRgnBox ( $hWnd, ByRef $tRECT )

Parameters

$hWnd | Handle to the window.
$tRECT | Returns a $tagRECT structure that is created by this function, and contains the rectangle dimensions, in device units relative to the upper-left corner of the window.

Return Value

Success: | The value that specifies the region's complexity; it can be one of the following values. $COMPLEXREGION $NULLREGION $SIMPLEREGION
Failure: | 0.

See Also

Search GetWindowRgnBox in MSDN Library.


Function _WinAPI_InvalidateRgn

Function Reference

_WinAPI_InvalidateRgn

Adds a region to the specified window's update region

#include <WinAPIGdi.au3>
_WinAPI_InvalidateRgn ( $hWnd [, $hRgn = 0 [, $bErase = True]] )

Parameters

$hWnd | Handle to the window with an update region that is to be modified.
$hRgn | [optional] Handle to the region to be added to the update region. The region is assumed to have client coordinates. If this parameter is 0, the entire client area is added to the update region.
$bErase | [optional] Specifies whether the background within the update region is to be erased when the update region is processed, valid values: True - The background is erased (Default). False - The background remains unchanged.

Return Value

Returns always True

See Also

Search InvalidateRgn in MSDN Library.


Function _WinAPI_LockWindowUpdate

Function Reference

_WinAPI_LockWindowUpdate

Disables or enables drawing in the specified window

#include <WinAPIGdi.au3>
_WinAPI_LockWindowUpdate ( $hWnd )

Parameters

$hWnd Handle to the window in which drawing will be disabled. If this parameter is 0, drawing in the locked
window is enabled.

Return Value

Success: | True
Failure: | False

Remarks

Only one window can be locked at a time by using this function.

See Also

Search LockWindowUpdate in MSDN Library.


Function _WinAPI_PaintDesktop

Function Reference

_WinAPI_PaintDesktop

Fills the clipping region in the specified device context with the desktop pattern or wallpaper

#include <WinAPIGdi.au3>
_WinAPI_PaintDesktop ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | True
Failure: | False

See Also

Search PaintDesktop in MSDN Library.


Function _WinAPI_SetBoundsRect

Function Reference

_WinAPI_SetBoundsRect

Controls the accumulation of bounding rectangle information for the specified device context

#include <WinAPIGdi.au3>
_WinAPI_SetBoundsRect ( $hDC, $iFlags [, $tRECT = 0] )

Parameters

$hDC | Handle to the device context for which to accumulate bounding rectangles.
$iFlags | The flags that specifies how the new rectangle will be combined with the accumulated rectangle. This parameter can be one of more of the following values. $DCB_ACCUMULATE $DCB_DISABLE $DCB_ENABLE $DCB_RESET
$tRECT | [optional] $tagRECT structure used to set the bounding rectangle in logical coordinates.

Return Value

Success: | The value specifies the previous state of the bounding rectangle ($DCB_*).
Failure: | 0.

See Also

Search SetBoundsRect in MSDN Library.


Function _WinAPI_SetROP2

Function Reference

_WinAPI_SetROP2

Retrieves the foreground mix mode of the specified device context

#include <WinAPIGdi.au3>
_WinAPI_SetROP2 ( $hDC, $iMode )

Parameters

$hDC | Handle to the device context.
$iMode | The mix mode. This parameter can be one of the following values. $R2_BLACK $R2_COPYPEN $R2_LAST $R2_MASKNOTPEN $R2_MASKPEN $R2_MASKPENNOT $R2_MERGENOTPEN $R2_MERGEPEN $R2_MERGEPENNOT $R2_NOP $R2_NOT $R2_NOTCOPYPEN $R2_NOTMASKPEN $R2_NOTMERGEPEN $R2_NOTXORPEN $R2_WHITE $R2_XORPEN

Return Value

Success: | The value that specifies the previous mix mode.
Failure: | 0.

Remarks

Mix modes define how GDI combines source and destination colors when drawing with the current pen. The mix modes
are binary raster operation codes, representing all possible Boolean functions of two variables, using the binary
operations AND, OR, and XOR (exclusive OR), and the unary operation NOT. The mix mode is for raster devices only;
it is not available for vector devices.

See Also

Search SetROP2 in MSDN Library.


Function _WinAPI_ValidateRect

Function Reference

_WinAPI_ValidateRect

Removes a rectangle from the current update region of the specified window

#include <WinAPIGdi.au3>
_WinAPI_ValidateRect ( $hWnd [, $tRECT = 0] )

Parameters

$hWnd | Handle to the window whose update region is to be modified. If this parameter is 0, the system invalidates and redraws all windows and sends the WM_ERASEBKGND and WM_NCPAINT messages to the window procedure before the function returns.
$tRECT | [optional] $tagRECT structure that contains the client coordinates of the rectangle to be removed from the update region. If this parameter is 0 (Default), the entire client area is removed.

Return Value

Success: | True
Failure: | False

See Also

Search ValidateRect in MSDN Library.


Function _WinAPI_ValidateRgn

Function Reference

_WinAPI_ValidateRgn

Removes a region from the current update region of the specified window

#include <WinAPIGdi.au3>
_WinAPI_ValidateRgn ( $hWnd [, $hRgn = 0] )

Parameters

$hWnd | Handle to the window whose update region is to be modified.
$hRgn | [optional] Handle to a region that defines the area to be removed from the update region. If this parameter is 0 (Default), the entire client area is removed.

Return Value

Success: | True
Failure: | False

See Also

Search ValidateRgn in MSDN Library.


Function _WinAPI_WindowFromDC

Function Reference

_WinAPI_WindowFromDC

Retrieves a handle to the window associated with the specified display device context (DC)

#include <WinAPIGdi.au3>
_WinAPI_WindowFromDC ( $hDC )

Parameters

$hDC Handle to the device context from which a handle to the associated window is to be retrieved.

Return Value

Success: | Handle to the window associated with the specified DC. If no window is associated with the specified DC, the return value is 0.
Failure: | 0.

See Also

Search WindowFromDC in MSDN Library.


User Defined Functions

Path user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIGdi.au3>.

User Defined Function | Description
_WinAPI_AbortPath | Closes and discards any paths in the specified device context
_WinAPI_BeginPath | Opens a path bracket in the specified device context
_WinAPI_CloseFigure | Closes an open figure in a path
_WinAPI_EndPath | Closes a path bracket and selects the path defined by the bracket into the specified device context
_WinAPI_FillPath | Closes any open figures in the current path and fills the path's interior by using the current brush
_WinAPI_FlattenPath | Transforms any curves in the path that is selected into the current DC, turning each curve into a sequence of lines
_WinAPI_PathToRegion | Creates a region from the path that is selected into the specified device context
_WinAPI_StrokeAndFillPath | Closes any open figures in a path, strokes the outline of the path, and fills its interior
_WinAPI_StrokePath | Renders the specified path by using the current pen
_WinAPI_WidenPath | Redefines the current path as the area that would be painted if the path were stroked


Function _WinAPI_AbortPath

Function Reference

_WinAPI_AbortPath

Closes and discards any paths in the specified device context

#include <WinAPIGdi.au3>
_WinAPI_AbortPath ( $hDC )

Parameters

$hDC Handle to the device context from which a path will be discarded.

Return Value

Success: | True
Failure: | False

See Also

Search AbortPath in MSDN Library.


Function _WinAPI_BeginPath

Function Reference

_WinAPI_BeginPath

Opens a path bracket in the specified device context

#include <WinAPIGdi.au3>
_WinAPI_BeginPath ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | True
Failure: | False

Remarks

After a path bracket is open, an application can begin calling GDI drawing functions to define the points that lie in the path.
An application can close an open path bracket by calling the _WinAPI_EndPath() function.

When an application calls _WinAPI_BeginPath() for a device context, any previous paths are discarded from that device context.

Related

_WinAPI_EndPath

See Also

Search BeginPath in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 241, 241)
Local $idPic = GUICtrlCreatePic('', 0, 0, 241, 241)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDC = _WinAPI_GetDC($hPic)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 241, 241, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap)

; Create path
_WinAPI_BeginPath($hMemDC)
_WinAPI_MoveTo($hMemDC, 220, 78)
_WinAPI_LineTo($hMemDC, 170, 218)
_WinAPI_LineTo($hMemDC, 70, 218)
_WinAPI_LineTo($hMemDC, 20, 78)
_WinAPI_SetArcDirection($hMemDC, $AD_CLOCKWISE)
_WinAPI_ArcTo($hMemDC, _WinAPI_CreateRectEx(49, 22, 143, 143), 49, 78, 192, 78)
_WinAPI_CloseFigure($hMemDC)
_WinAPI_Ellipse($hMemDC, _WinAPI_CreateRectEx(70, 44, 101, 101))
_WinAPI_Ellipse($hMemDC, _WinAPI_CreateRectEx(90, 64, 61, 61))
_WinAPI_EndPath($hMemDC)

; Stroke outline, and fills path's interior
Local $hBrush = _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hPen = _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetDCBrushColor($hMemDC, 0xFFC000)
_WinAPI_SetDCPenColor($hMemDC, 0xDD0000)
_WinAPI_StrokeAndFillPath($hMemDC)

; Release objects
_WinAPI_DeleteObject(_WinAPI_SelectObject($hDC, $hBrush))
_WinAPI_DeleteObject(_WinAPI_SelectObject($hDC, $hPen))
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_CloseFigure

Function Reference

_WinAPI_CloseFigure

Closes an open figure in a path

#include <WinAPIGdi.au3>
_WinAPI_CloseFigure ( $hDC )

Parameters

$hDC Handle to the device context in which the figure will be closed.

Return Value

Success: | True
Failure: | False

Remarks

The _WinAPI_CloseFigure() function closes the figure by drawing a line from the current position to the first point of the figure (usually, the point specified by the most recent call to the _WinAPI_MoveToEx() function) and then connects the lines by using the line join style.

Related

_WinAPI_MoveToEx

See Also

Search CloseFigure in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 241, 241)
Local $idPic = GUICtrlCreatePic('', 0, 0, 241, 241)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDC = _WinAPI_GetDC($hPic)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 241, 241, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap)

; Create path
_WinAPI_BeginPath($hMemDC)
_WinAPI_MoveTo($hMemDC, 220, 78)
_WinAPI_LineTo($hMemDC, 170, 218)
_WinAPI_LineTo($hMemDC, 70, 218)
_WinAPI_LineTo($hMemDC, 20, 78)
_WinAPI_SetArcDirection($hMemDC, $AD_CLOCKWISE)
_WinAPI_ArcTo($hMemDC, _WinAPI_CreateRectEx(49, 22, 143, 143), 49, 78, 192, 78)
_WinAPI_CloseFigure($hMemDC)
_WinAPI_Ellipse($hMemDC, _WinAPI_CreateRectEx(70, 44, 101, 101))
_WinAPI_Ellipse($hMemDC, _WinAPI_CreateRectEx(90, 64, 61, 61))
_WinAPI_EndPath($hMemDC)

; Stroke outline, and fills path's interior
Local $hBrush = _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hPen = _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetDCBrushColor($hMemDC, 0xFFC000)
_WinAPI_SetDCPenColor($hMemDC, 0xDD0000)
_WinAPI_StrokeAndFillPath($hMemDC)

; Release objects
_WinAPI_DeleteObject(_WinAPI_SelectObject($hDC, $hBrush))
_WinAPI_DeleteObject(_WinAPI_SelectObject($hDC, $hPen))
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_EndPath

Function Reference

_WinAPI_EndPath

Closes a path bracket and selects the path defined by the bracket into the specified device context

#include <WinAPIGdi.au3>
_WinAPI_EndPath ( $hDC )

Parameters

$hDC Handle to the device context into which the new path is selected.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

See Also

Search EndPath in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 241, 241)
Local $idPic = GUICtrlCreatePic('', 0, 0, 241, 241)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDC = _WinAPI_GetDC($hPic)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 241, 241, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap)

; Create path
_WinAPI_BeginPath($hMemDC)
_WinAPI_MoveTo($hMemDC, 220, 78)
_WinAPI_LineTo($hMemDC, 170, 218)
_WinAPI_LineTo($hMemDC, 70, 218)
_WinAPI_LineTo($hMemDC, 20, 78)
_WinAPI_SetArcDirection($hMemDC, $AD_CLOCKWISE)
_WinAPI_ArcTo($hMemDC, _WinAPI_CreateRectEx(49, 22, 143, 143), 49, 78, 192, 78)
_WinAPI_CloseFigure($hMemDC)
_WinAPI_Ellipse($hMemDC, _WinAPI_CreateRectEx(70, 44, 101, 101))
_WinAPI_Ellipse($hMemDC, _WinAPI_CreateRectEx(90, 64, 61, 61))
_WinAPI_EndPath($hMemDC)

; Stroke outline, and fills path's interior
Local $hBrush = _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hPen = _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetDCBrushColor($hMemDC, 0xFFC000)
_WinAPI_SetDCPenColor($hMemDC, 0xDD0000)
_WinAPI_StrokeAndFillPath($hMemDC)

; Release objects
_WinAPI_DeleteObject(_WinAPI_SelectObject($hDC, $hBrush))
_WinAPI_DeleteObject(_WinAPI_SelectObject($hDC, $hPen))
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_FillPath

Function Reference

_WinAPI_FillPath

Closes any open figures in the current path and fills the path's interior by using the current brush

#include <WinAPIGdi.au3>
_WinAPI_FillPath ( $hDC )

Parameters

$hDC Handle to a device context that contains a valid path.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

After its interior is filled, the path is discarded from the DC identified by the $hDC parameter.

See Also

Search FillPath in MSDN Library.


Function _WinAPI_FlattenPath

Function Reference

_WinAPI_FlattenPath

Transforms any curves in the path that is selected into the current DC, turning each curve into a sequence of lines

#include <WinAPIGdi.au3>
_WinAPI_FlattenPath ( $hDC )

Parameters

$hDC Handle to a device context that contains a valid path.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

See Also

Search FlattenPath in MSDN Library.


Function _WinAPI_PathToRegion

Function Reference

_WinAPI_PathToRegion

Creates a region from the path that is selected into the specified device context

#include <WinAPIGdi.au3>
_WinAPI_PathToRegion ( $hDC )

Parameters

$hDC Handle to a device context that contains a closed path.

Return Value

Success: | The handle to the region.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

The device context identified by the $hDC parameter must contain a closed path.

After _WinAPI_PathToRegion() converts a path into a region, the system discards the closed path from the specified
device context.

See Also

Search PathToRegion in MSDN Library.


Function _WinAPI_StrokeAndFillPath

Function Reference

_WinAPI_StrokeAndFillPath

Closes any open figures in a path, strokes the outline of the path, and fills its interior

#include <WinAPIGdi.au3>
_WinAPI_StrokeAndFillPath ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | True
Failure: | False

Remarks

The device context identified by the $hDC parameter must contain a closed path.

See Also

Search StrokeAndFillPath in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 241, 241)
Local $idPic = GUICtrlCreatePic('', 0, 0, 241, 241)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDC = _WinAPI_GetDC($hPic)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 241, 241, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap)

; Create path
_WinAPI_BeginPath($hMemDC)
_WinAPI_MoveTo($hMemDC, 220, 78)
_WinAPI_LineTo($hMemDC, 170, 218)
_WinAPI_LineTo($hMemDC, 70, 218)
_WinAPI_LineTo($hMemDC, 20, 78)
_WinAPI_SetArcDirection($hMemDC, $AD_CLOCKWISE)
_WinAPI_ArcTo($hMemDC, _WinAPI_CreateRectEx(49, 22, 143, 143), 49, 78, 192, 78)
_WinAPI_CloseFigure($hMemDC)
_WinAPI_Ellipse($hMemDC, _WinAPI_CreateRectEx(70, 44, 101, 101))
_WinAPI_Ellipse($hMemDC, _WinAPI_CreateRectEx(90, 64, 61, 61))
_WinAPI_EndPath($hMemDC)

; Stroke outline, and fills path's interior
Local $hBrush = _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hPen = _WinAPI_SelectObject($hMemDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetDCBrushColor($hMemDC, 0xFFC000)
_WinAPI_SetDCPenColor($hMemDC, 0xDD0000)
_WinAPI_StrokeAndFillPath($hMemDC)

; Release objects
_WinAPI_DeleteObject(_WinAPI_SelectObject($hDC, $hBrush))
_WinAPI_DeleteObject(_WinAPI_SelectObject($hDC, $hPen))
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_StrokePath

Function Reference

_WinAPI_StrokePath

Renders the specified path by using the current pen

#include <WinAPIGdi.au3>
_WinAPI_StrokePath ( $hDC )

Parameters

$hDC Handle to a device context that contains the completed path.

Return Value

Success: | True
Failure: | False

Remarks

The path, if it is to be drawn by this function, must have been completed through a call to _WinAPI_EndPath().
Unlike other path drawing functions such as _WinAPI_StrokeAndFillPath(), _WinAPI_StrokePath() will not attempt
to close the path by drawing a straight line from the first point on the path to the last point on the path.

See Also

Search StrokePath in MSDN Library.


Function _WinAPI_WidenPath

Function Reference

_WinAPI_WidenPath

Redefines the current path as the area that would be painted if the path were stroked

#include <WinAPIGdi.au3>
_WinAPI_WidenPath ( $hDC )

Parameters

$hDC Handle to a device context that contains a closed path.

Return Value

Success: | True
Failure: | False

Remarks

The device context identified by the $hDC parameter must contain a closed path.

The _WinAPI_WidenPath() function is successful only if the current pen has a width, in device units, of more than one.

Any Bezier curves in the path are converted to sequences of straight lines approximating the widened curves.
As such, no Bezier curves remain in the path after _WinAPI_WidenPath() is called.

See Also

Search WidenPath in MSDN Library.


User Defined Functions

Rectangle user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIGdi.au3>.

User Defined Function | Description
_WinAPI_CopyRect | Copies the coordinates of one rectangle to another
_WinAPI_DrawFocusRect | Draws a rectangle in the style used to indicate that the rectangle has the focus
_WinAPI_EqualRect | Determines whether the two specified rectangles are equal
_WinAPI_InflateRect | Increases or decreases the width and height of the specified rectangle
_WinAPI_IntersectRect | Creates the intersection of two rectangles
_WinAPI_IsRectEmpty | Determines whether the specified rectangle is empty
_WinAPI_OffsetRect | Moves the specified rectangle by the specified offsets
_WinAPI_PtInRectEx | Determines whether the specified point lies within the specified rectangle
_WinAPI_SubtractRect | Determines the coordinates of a rectangle formed by subtracting one rectangle from another
_WinAPI_UnionRect | Creates the union of two rectangles


Function _WinAPI_CopyRect

Function Reference

_WinAPI_CopyRect

Copies the coordinates of one rectangle to another

#include <WinAPIGdi.au3>
_WinAPI_CopyRect ( $tRECT )

Parameters

$tRECT $tagRECT structure whose coordinates are to be copied in logical units.

Return Value

Success: | $tagRECT structure that contains the logical coordinates of the source rectangle.
Failure: | Sets the @error flag to non-zero.

See Also

Search CopyRect in MSDN Library.


Function _WinAPI_DrawFocusRect

Function Reference

_WinAPI_DrawFocusRect

Draws a rectangle in the style used to indicate that the rectangle has the focus

#include <WinAPIGdi.au3>
_WinAPI_DrawFocusRect ( $hDC, $tRECT )

Parameters

$hDC | A handle to the device context.
$tRECT | $tagRECT structure that specifies the logical coordinates of the rectangle that is to be drawn.

Return Value

Success: | True
Failure: | False

Remarks

The _WinAPI_DrawFocusRect() is an XOR function, so calling it a second time with the same rectangle removes the rectangle from the screen.

See Also

Search DrawFocusRect in MSDN Library.


Function _WinAPI_EqualRect

Function Reference

_WinAPI_EqualRect

Determines whether the two specified rectangles are equal

#include <WinAPIGdi.au3>
_WinAPI_EqualRect ( $tRECT1, $tRECT2 )

Parameters

$tRECT1 | $tagRECT structure that contains the logical coordinates of the first rectangle.
$tRECT2 | $tagRECT structure that contains the logical coordinates of the second rectangle.

Return Value

Success: | True - The two rectangles are identical.
Failure: | False.

Remarks

This function does not treat empty rectangles as equal if their coordinates are different.

See Also

Search EqualRect in MSDN Library.


Function _WinAPI_InflateRect

Function Reference

_WinAPI_InflateRect

Increases or decreases the width and height of the specified rectangle

#include <WinAPIGdi.au3>
_WinAPI_InflateRect ( ByRef $tRECT, $iDX, $iDY )

Parameters

$tRECT | $tagRECT structure that increases or decreases in size.
$iDX | The amount to increase or decrease (negative value) the rectangle width.
$iDY | The amount to increase or decrease (negative value) the rectangle height.

Return Value

Success: | True
Failure: | False

See Also

Search InflateRect in MSDN Library.


Function _WinAPI_IntersectRect

Function Reference

_WinAPI_IntersectRect

Creates the intersection of two rectangles

#include <WinAPIGdi.au3>
_WinAPI_IntersectRect ( $tRECT1, $tRECT2 )

Parameters

$tRECT1 | $tagRECT structure that contains the first source rectangle.
$tRECT2 | $tagRECT structure that contains the second source rectangle.

Return Value

Success: | $tagRECT structure that contains the intersection of the $tRECT1 and $tRECT2 rectangles.
Failure: | Sets the @error flag to non-zero.

Remarks

If the source rectangles do not intersect, an empty rectangle (in which all coordinates are set to zero) is
placed into the destination rectangle.

See Also

Search IntersectRect in MSDN Library.


Function _WinAPI_IsRectEmpty

Function Reference

_WinAPI_IsRectEmpty

Determines whether the specified rectangle is empty

#include <WinAPIGdi.au3>
_WinAPI_IsRectEmpty ( $tRECT )

Parameters

$tRECT $tagRECT structure that contains the logical coordinates of the rectangle.

Return Value

True: | the rectangle is empty.
False: | the rectangle is not empty.

Remarks

An empty rectangle is one that has no area; that is, the coordinate of the right side is less than or equal
to the coordinate of the left side, or the coordinate of the bottom side is less than or equal to the
coordinate of the top side.

See Also

Search IsRectEmpty in MSDN Library.


Function _WinAPI_OffsetRect

Function Reference

_WinAPI_OffsetRect

Moves the specified rectangle by the specified offsets

#include <WinAPIGdi.au3>
_WinAPI_OffsetRect ( ByRef $tRECT, $iDX, $iDY )

Parameters

$tRECT | $tagRECT structure that to be moved.
$iDX | The amount to move the rectangle left (negative value) or right.
$iDY | The amount to move the rectangle up (negative value) or down.

Return Value

Success: | True
Failure: | False

See Also

Search OffsetRect in MSDN Library.


Function _WinAPI_PtInRectEx

Function Reference

_WinAPI_PtInRectEx

Determines whether the specified point lies within the specified rectangle

#include <WinAPIGdi.au3>
_WinAPI_PtInRectEx ( $iX, $iY, $iLeft, $iTop, $iRight, $iBottom )

Parameters

$iX | The x-coordinate of the point.
$iY | The y-coordinate of the point.
$iLeft | The x-coordinate of the upper-left corner of the rectangle.
$iTop | The y-coordinate of the upper-left corner of the rectangle.
$iRight | The x-coordinate of the lower-right corner of the rectangle.
$iBottom | The y-coordinate of the lower-right corner of the rectangle.

Return Value

True: | the specified point lies within the rectangle.
False: | the specified point do not lie within the rectangle.

See Also

Search PtInRect in MSDN Library.


Function _WinAPI_SubtractRect

Function Reference

_WinAPI_SubtractRect

Determines the coordinates of a rectangle formed by subtracting one rectangle from another

#include <WinAPIGdi.au3>
_WinAPI_SubtractRect ( $tRECT1, $tRECT2 )

Parameters

$tRECT1 | $tagRECT structure from which the function subtracts the rectangle specified by $tRECT2.
$tRECT2 | $tagRECT structure that the function subtracts from the rectangle specified by $tRECT1.

Return Value

Success: | $tagRECT structure that contains the rectangle determined by subtracting the rectangle specified by $tRECT2 from the rectangle specified by $tRECT1.
Failure: | Sets the @error flag to non-zero.

Remarks

The function only subtracts the rectangle specified by $tRECT2 from the rectangle specified by $tRECT1 when the
rectangles intersect completely in either the x- or y-direction. For example, if $tRECT1 has the coordinates
(10, 10, 100, 100) and $tRECT2 has the coordinates (50, 50, 150, 150), the function returns the rectangle with
the coordinates (10, 10, 100, 100). If $tRECT1 has the coordinates (10, 10, 100, 100) and $tRECT2 has the
coordinates (50, 10, 150, 150), however, the function returns the rectangle with the coordinates (10, 10, 50, 100).
In other words, the resulting rectangle is the bounding box of the geometric difference.

See Also

Search SubtractRect in MSDN Library.


Function _WinAPI_UnionRect

Function Reference

_WinAPI_UnionRect

Creates the union of two rectangles

#include <WinAPIGdi.au3>
_WinAPI_UnionRect ( $tRECT1, $tRECT2 )

Parameters

$tRECT1 | $tagRECT structure that contains the first source rectangle.
$tRECT2 | $tagRECT structure that contains the second source rectangle.

Return Value

Success: | $tagRECT structure that contains the union of the $tRECT1 and $tRECT2 rectangles.
Failure: | Sets the @error flag to non-zero.

Remarks

The union is the smallest rectangle that contains both source rectangles. The system ignores the
dimensions of an empty rectangle that is, a rectangle in which all coordinates are set to zero, so that
it has no height or no width.

See Also

Search UnionRect in MSDN Library.


User Defined Functions

Region user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <GDIPlus.au3>.

User Defined Function | Description
_WinAPI_CreateEllipticRgn | Creates an elliptical region
_WinAPI_CreateNullRgn | Creates an empty region
_WinAPI_CreatePolygonRgn | Creates a polygonal region
_WinAPI_CreateRectRgnIndirect | Creates a rectangular region
_WinAPI_EqualRgn | Checks the two specified regions to determine whether they are identical
_WinAPI_ExtCreateRegion | Creates a region from the specified region and transformation data
_WinAPI_FillRgn | Fills a region by using the specified brush
_WinAPI_FrameRgn | Draws a border around the specified region by using the specified brush
_WinAPI_GetPolyFillMode | Retrieves the current polygon fill mode
_WinAPI_GetRegionData | Fills the specified buffer with data describing a region
_WinAPI_GetRgnBox | Retrieves the bounding rectangle of the specified region
_WinAPI_InvertRgn | Inverts the colors in the specified region
_WinAPI_OffsetRgn | Moves a region by the specified offsets
_WinAPI_PaintRgn | Paints the specified region by using the brush currently selected into the device context
_WinAPI_PtInRegion | Determines whether the specified point is inside the specified region
_WinAPI_RectInRegion | Determines whether any part of the specified rectangle is within the boundaries of a region
_WinAPI_SetPolyFillMode | Sets the polygon fill mode for functions that fill polygons
_WinAPI_SetRectRgn | Converts a region into a rectangular region with the specified coordinates


Function _WinAPI_CreateEllipticRgn

Function Reference

_WinAPI_CreateEllipticRgn

Creates an elliptical region

#include <WinAPIGdi.au3>
_WinAPI_CreateEllipticRgn ( $tRECT )

Parameters

$tRECT $tagRECT structure that contains the coordinates of the upper-left and lower-right corners of the bounding rectangle of the ellipse in logical units.

Return Value

Success: | The handle to the region.
Failure: | 0.

Remarks

A bounding rectangle defines the size, shape, and orientation of the region: The long sides of the rectangle define the length of the ellipse's major axis; the short sides define the length of the ellipse's minor axis; and the center of the rectangle defines the intersection of the major and minor axes.

When you no longer need the HRGN object, call the _WinAPI_DeleteObject() function to delete it.

Related

_WinAPI_DeleteObject

See Also

Search CreateEllipticRgnIndirect in MSDN Library.


Function _WinAPI_CreateNullRgn

Function Reference

_WinAPI_CreateNullRgn

Creates an empty region

#include <WinAPIGdi.au3>
_WinAPI_CreateNullRgn ( )

Return Value

Success: | The handle to the region.
Failure: | 0.

Remarks

When you no longer need the HRGN object, call the _WinAPI_DeleteObject() function to delete it.

Related

_WinAPI_DeleteObject


Function _WinAPI_CreatePolygonRgn

Function Reference

_WinAPI_CreatePolygonRgn

Creates a polygonal region

#include <WinAPIGdi.au3>
_WinAPI_CreatePolygonRgn ( Const ByRef $aPoint [, $iStart = 0 [, $iEnd = -1 [, $iMode = 1]]] )

Parameters

$aPoint | The 2D array ([x1, y1], [x2, y2], ... [xN, yN]) that contains the vertices of the polygon in logical units. The polygon is presumed closed. Each vertex can be specified only once.
$iStart | [optional] The index of array to start creating at.
$iEnd | [optional] The index of array to stop creating at.
$iMode | [optional] The fill mode used to determine which pixels are in the region. This parameter can be one of the following values: $ALTERNATE (Default) $WINDING

Return Value

Success: | The handle to the region.
Failure: | 0.

Remarks

When you no longer need the HRGN object, call the _WinAPI_DeleteObject() function to delete it.

Related

_WinAPI_DeleteObject

See Also

Search CreatePolygonRgn in MSDN Library.

Example

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

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 500, 475, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
Local $idButton = GUICtrlCreateButton('Exit', 215, 255, 70, 23)
GUIRegisterMsg($WM_NCHITTEST, 'WM_NCHITTEST')
GUISetBkColor(0xAA0000)

; Create polygonal region and set it to the window
Local $aPoint[10][2] = [[0, 180], [190, 180], [250, 0], [308, 180], [500, 180], [344, 294], [404, 475], [250, 362], [94, 475], [154, 294]]
Local $hRgn = _WinAPI_CreatePolygonRgn($aPoint)
_WinAPI_SetWindowRgn($hForm, $hRgn, 0)

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $idButton

Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam

    Return $HTCAPTION
EndFunc   ;==>WM_NCHITTEST


Function _WinAPI_CreateRectRgnIndirect

Function Reference

_WinAPI_CreateRectRgnIndirect

Creates a rectangular region

#include <WinAPIGdi.au3>
_WinAPI_CreateRectRgnIndirect ( $tRECT )

Parameters

$tRECT $tagRECT structure that contains the coordinates of the upper-left and lower-right corners of the rectangle that defines the region in logical units.

Return Value

Success: | The handle to the region.
Failure: | 0.

Remarks

When you no longer need the HRGN object, call the _WinAPI_DeleteObject() function to delete it.

Related

_WinAPI_DeleteObject

See Also

Search CreateRectRgnIndirect in MSDN Library.


Function _WinAPI_EqualRgn

Function Reference

_WinAPI_EqualRgn

Checks the two specified regions to determine whether they are identical

#include <WinAPIGdi.au3>
_WinAPI_EqualRgn ( $hRgn1, $hRgn2 )

Parameters

$hRgn1 | Handle to a region.
$hRgn2 | Handle to a region.

Return Value

Success: | True - The two regions are equal.
Failure: | False.

See Also

Search EqualRgn in MSDN Library.


Function _WinAPI_ExtCreateRegion

Function Reference

_WinAPI_ExtCreateRegion

Creates a region from the specified region and transformation data

#include <WinAPIGdi.au3>
_WinAPI_ExtCreateRegion ( $tRGNDATA [, $tXFORM = 0] )

Parameters

$tRGNDATA | $tagRGNDATA structure that contains the region data in logical units.
$tXFORM | [optional] $tagXFORM structure that defines the transformation to be performed on the region.

Return Value

Success: | The handle to the region.
Failure: | 0.

See Also

Search ExtCreateRegion in MSDN Library.


Function _WinAPI_FillRgn

Function Reference

_WinAPI_FillRgn

Fills a region by using the specified brush

#include <WinAPIGdi.au3>
_WinAPI_FillRgn ( $hDC, $hRgn, $hBrush )

Parameters

$hDC | Handle to the device context.
$hRgn | Handle to the region to be filled. The region's coordinates are presumed to be in logical units.
$hBrush | Handle to the brush to be used to fill the region.

Return Value

Success: | True
Failure: | False

See Also

Search FillRgn in MSDN Library.


Function _WinAPI_FrameRgn

Function Reference

_WinAPI_FrameRgn

Draws a border around the specified region by using the specified brush

#include <WinAPIGdi.au3>
_WinAPI_FrameRgn ( $hDC, $hRgn, $hBrush, $iWidth, $iHeight )

Parameters

$hDC | Handle to the device context.
$hRgn | Handle to the region to be enclosed in a border. The region's coordinates are presumed to be in logical units.
$hBrush | Handle to the brush to be used to draw the border.
$iWidth | The width, in logical units, of vertical brush strokes.
$iHeight | The height, in logical units, of horizontal brush strokes.

Return Value

Success: | True
Failure: | False

See Also

Search FrameRgn in MSDN Library.


Function _WinAPI_GetPolyFillMode

Function Reference

_WinAPI_GetPolyFillMode

Retrieves the current polygon fill mode

#include <WinAPIGdi.au3>
_WinAPI_GetPolyFillMode ( $hDC )

Parameters

$hDC Handle to the device context.

Return Value

Success: | The polygon fill mode, which can be one of the following values. $ALTERNATE $WINDING
Failure: | 0.

See Also

Search GetPolyFillMode in MSDN Library.


Function _WinAPI_GetRegionData

Function Reference

_WinAPI_GetRegionData

Fills the specified buffer with data describing a region

#include <WinAPIGdi.au3>
_WinAPI_GetRegionData ( $hRgn, ByRef $tRGNDATA )

Parameters

$hRgn | Handle to the region.
$tRGNDATA | Returns a $tagRGNDATA structure that is created by this function, and contains the region data, in logical units.

Return Value

Success: | True.
Failure: | False.

See Also

Search GetRegionData in MSDN Library.


Function _WinAPI_GetRgnBox

Function Reference

_WinAPI_GetRgnBox

Retrieves the bounding rectangle of the specified region

#include <WinAPIGdi.au3>
_WinAPI_GetRgnBox ( $hRgn, ByRef $tRECT )

Parameters

$hRgn | Handle to the region.
$tRECT | Returns a $tagRECT structure that is created by this function, and contains the bounding rectangle, in logical units.

Return Value

Success: | The value that specifies the region's complexity; it can be one of the following values. $COMPLEXREGION $NULLREGION $SIMPLEREGION
Failure: | 0.

See Also

Search GetRgnBox in MSDN Library.


Function _WinAPI_InvertRgn

Function Reference

_WinAPI_InvertRgn

Inverts the colors in the specified region

#include <WinAPIGdi.au3>
_WinAPI_InvertRgn ( $hDC, $hRgn )

Parameters

$hDC | Handle to the device context.
$hRgn | Handle to the region for which colors are inverted. The region's coordinates are presumed to be logical coordinates.

Return Value

Success: | True
Failure: | False

Remarks

On monochrome screens, the _WinAPI_InvertRgn() function makes white pixels black and black pixels white. On color
screens, this inversion is dependent on the type of technology used to generate the colors for the screen.

See Also

Search InvertRgn in MSDN Library.


Function _WinAPI_OffsetRgn

Function Reference

_WinAPI_OffsetRgn

Moves a region by the specified offsets

#include <WinAPIGdi.au3>
_WinAPI_OffsetRgn ( $hRgn, $iXOffset, $iYOffset )

Parameters

$hRgn | Handle to the region to be moved.
$iXOffset | The number of logical units to move left or right.
$iYOffset | The number of logical units to move up or down.

Return Value

Success: | The value that specifies the new region's complexity; it can be one of the following values. $COMPLEXREGION $NULLREGION $SIMPLEREGION
Failure: | 0.

See Also

Search OffsetRgn in MSDN Library.


Function _WinAPI_PaintRgn

Function Reference

_WinAPI_PaintRgn

Paints the specified region by using the brush currently selected into the device context

#include <WinAPIGdi.au3>
_WinAPI_PaintRgn ( $hDC, $hRgn )

Parameters

$hDC | Handle to the device context.
$hRgn | Handle to the region to be filled. The region's coordinates are presumed to be logical coordinates.

Return Value

Success: | True
Failure: | False

See Also

Search PaintRgn in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <FontConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idPic = GUICtrlCreatePic('', 0, 0, 400, 400)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDev = _WinAPI_GetDC($hPic)
Local $hDC = _WinAPI_CreateCompatibleDC($hDev)
Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, 400, 400, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hSv = _WinAPI_SelectObject($hDC, $hSource)

; Draw objects
Local $hOldBrush = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hOldPen = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetDCBrushColor($hDC, 0x990404)
_WinAPI_SetDCPenColor($hDC, 0x990404)
Local $tRECT = _WinAPI_CreateRect(0, 0, 100, 100)
_WinAPI_OffsetRect($tRECT, 30, 30)
_WinAPI_Rectangle($hDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 20, 20)
_WinAPI_InvertRect($hDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 20, 20)
_WinAPI_InvertRect($hDC, $tRECT)
_WinAPI_SetDCPenColor($hDC, 0x00A820)
_WinAPI_SetBkColor($hDC, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hBrush = _WinAPI_CreateBrushIndirect($BS_HATCHED, 0x00A820, $HS_DIAGCROSS)
Local $hObj = _WinAPI_SelectObject($hDC, $hBrush)
$tRECT = _WinAPI_CreateRect(0, 0, 140, 140)
_WinAPI_OffsetRect($tRECT, 220, 118)
_WinAPI_Ellipse($hDC, $tRECT)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hBrush)
_WinAPI_SetTextColor($hDC, 0xCD0091)
_WinAPI_SetBkMode($hDC, $TRANSPARENT)
Local $hFont = _WinAPI_CreateFont(38, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, 'Arial Black')
$hObj = _WinAPI_SelectObject($hDC, $hFont)
_WinAPI_TextOut($hDC, 30, 185, 'Simple Text')
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hFont)
Local $aPoint2[6][2] = [[0, 129], [55, 75], [75, 0], [95, 75], [150, 129], [75, 108]]
Local $hRgn = _WinAPI_CreatePolygonRgn($aPoint2)
_WinAPI_SetDCBrushColor($hDC, 0x0060C4)
_WinAPI_OffsetRgn($hRgn, 25, 240)
_WinAPI_PaintRgn($hDC, $hRgn)
_WinAPI_DeleteObject($hRgn)
Local $aPoint1[19][2] = [[50, 20], [70, 0], [70, 0], [90, 20], [100, 30], [110, 40], [120, 50], [130, 60], [130, 70], [120, 70], [110, 70], [30, 70], [20, 70], [10, 70], [10, 60], [20, 50], [30, 40], [40, 30], [50, 20]]
_WinAPI_SetDCPenColor($hDC, 0xFF8000)
_WinAPI_OffsetPoints($aPoint1, 219, 25)
_WinAPI_PolyBezier($hDC, $aPoint1)
$hBrush = _WinAPI_CreateBrushIndirect($BS_SOLID, 0xFF8000)
$hObj = _WinAPI_SelectObject($hDC, $hBrush)
_WinAPI_ExtFloodFill($hDC, 70 + 219, 40 + 25, 0xFF8000, 0)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hBrush)
_WinAPI_SetDCPenColor($hDC, 0xFFFFFF)
Local $hPattern = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Pattern.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
; $hPattern = _WinAPI_LoadBitmap(_WinAPI_GetModuleHandle(@SystemDir & '\shell32.dll'), 138)
$hBrush = _WinAPI_CreateBrushIndirect($BS_PATTERN, 0, $hPattern)
$hObj = _WinAPI_SelectObject($hDC, $hBrush)
$tRECT = _WinAPI_CreateRect(0, 0, 140, 90)
_WinAPI_OffsetRect($tRECT, 220, 279)
_WinAPI_RoundRect($hDC, $tRECT, 20, 20)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hPattern)
_WinAPI_DeleteObject($hBrush)

; Merge bitmap
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDev, 400, 400)
$hBrush = _WinAPI_SelectObject($hDC, $hOldBrush)
_WinAPI_DeleteObject($hBrush)
Local $hPen = _WinAPI_SelectObject($hDC, $hOldPen)
_WinAPI_DeleteObject($hPen)
_WinAPI_SelectObject($hDC, $hBitmap)
_WinAPI_DrawBitmap($hDC, 0, 0, $hSource, $MERGECOPY)
_WinAPI_ReleaseDC($hPic, $hDev)
_WinAPI_SelectObject($hDC, $hSv)
_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteDC($hDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
$hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = -3


Function _WinAPI_PtInRegion

Function Reference

_WinAPI_PtInRegion

Determines whether the specified point is inside the specified region

#include <WinAPIGdi.au3>
_WinAPI_PtInRegion ( $hRgn, $iX, $iY )

Parameters

$hRgn | Handle to the region to be examined.
$iX | The x-coordinate of the point in logical units.
$iY | The y-coordinate of the point in logical units.

Return Value

Success: | True - The specified point is in the region.
Failure: | False.

See Also

Search PtInRegion in MSDN Library.


Function _WinAPI_RectInRegion

Function Reference

_WinAPI_RectInRegion

Determines whether any part of the specified rectangle is within the boundaries of a region

#include <WinAPIGdi.au3>
_WinAPI_RectInRegion ( $hRgn, $tRECT )

Parameters

$hRgn | Handle to the region.
$tRECT | $tagRECT structure that contains the coordinates of the rectangle in logical units.

Return Value

Success: | True - Any part of the specified rectangle lies within the boundaries of the region
Failure: | False.

See Also

Search RectInRegion in MSDN Library.


Function _WinAPI_SetPolyFillMode

Function Reference

_WinAPI_SetPolyFillMode

Sets the polygon fill mode for functions that fill polygons

#include <WinAPIGdi.au3>
_WinAPI_SetPolyFillMode ( $hDC [, $iMode = 1] )

Parameters

$hDC | Handle to the device context.
$iMode | [optional] The new fill mode. This parameter can be one of the following values. $ALTERNATE (Default) $WINDING

Return Value

Success: | The previous filling mode.
Failure: | 0.

See Also

Search SetPolyFillMode in MSDN Library.


Function _WinAPI_SetRectRgn

Function Reference

_WinAPI_SetRectRgn

Converts a region into a rectangular region with the specified coordinates

#include <WinAPIGdi.au3>
_WinAPI_SetRectRgn ( $hRgn, $tRECT )

Parameters

$hRgn | Handle to the region.
$tRECT | $tagRECT structure that contains the coordinates of the rectangular region in logical units.

Return Value

Success: | True
Failure: | False

See Also

Search SetRectRgn in MSDN Library.


User Defined Functions

Shape user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIGdi.au3>.

User Defined Function | Description
_WinAPI_Ellipse | Draws an ellipse
_WinAPI_InvertRect | Inverts a rectangle in a window by performing a logical NOT operation on the color values for each pixel
_WinAPI_Polygon | Draws a polygon consisting of two or more vertices connected by straight lines
_WinAPI_Rectangle | Draws a rectangle
_WinAPI_RoundRect | Draws a rectangle with rounded corners


Function _WinAPI_Ellipse

Function Reference

_WinAPI_Ellipse

Draws an ellipse

#include <WinAPIGdi.au3>
_WinAPI_Ellipse ( $hDC, $tRECT )

Parameters

$hDC | Handle to the device context.
$tRECT | $tagRECT structure that contains the logical coordinates of the bounding rectangle.

Return Value

Success: | True
Failure: | False

Remarks

The ellipse is outlined by using the current pen and is filled by using the current brush.

See Also

Search Ellipse in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <FontConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idPic = GUICtrlCreatePic('', 0, 0, 400, 400)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDev = _WinAPI_GetDC($hPic)
Local $hDC = _WinAPI_CreateCompatibleDC($hDev)
Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, 400, 400, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hSv = _WinAPI_SelectObject($hDC, $hSource)

; Draw objects
Local $hOldBrush = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hOldPen = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetDCBrushColor($hDC, 0x990404)
_WinAPI_SetDCPenColor($hDC, 0x990404)
Local $tRECT = _WinAPI_CreateRect(0, 0, 100, 100)
_WinAPI_OffsetRect($tRECT, 30, 30)
_WinAPI_Rectangle($hDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 20, 20)
_WinAPI_InvertRect($hDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 20, 20)
_WinAPI_InvertRect($hDC, $tRECT)
_WinAPI_SetDCPenColor($hDC, 0x00A820)
_WinAPI_SetBkColor($hDC, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hBrush = _WinAPI_CreateBrushIndirect($BS_HATCHED, 0x00A820, $HS_DIAGCROSS)
Local $hObj = _WinAPI_SelectObject($hDC, $hBrush)
$tRECT = _WinAPI_CreateRect(0, 0, 140, 140)
_WinAPI_OffsetRect($tRECT, 220, 118)
_WinAPI_Ellipse($hDC, $tRECT)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hBrush)
_WinAPI_SetTextColor($hDC, 0xCD0091)
_WinAPI_SetBkMode($hDC, $TRANSPARENT)
Local $hFont = _WinAPI_CreateFont(38, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, 'Arial Black')
$hObj = _WinAPI_SelectObject($hDC, $hFont)
_WinAPI_TextOut($hDC, 30, 185, 'Simple Text')
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hFont)
Local $aPoint2[6][2] = [[0, 129], [55, 75], [75, 0], [95, 75], [150, 129], [75, 108]]
Local $hRgn = _WinAPI_CreatePolygonRgn($aPoint2)
_WinAPI_SetDCBrushColor($hDC, 0x0060C4)
_WinAPI_OffsetRgn($hRgn, 25, 240)
_WinAPI_PaintRgn($hDC, $hRgn)
_WinAPI_DeleteObject($hRgn)
Local $aPoint1[19][2] = [[50, 20], [70, 0], [70, 0], [90, 20], [100, 30], [110, 40], [120, 50], [130, 60], [130, 70], [120, 70], [110, 70], [30, 70], [20, 70], [10, 70], [10, 60], [20, 50], [30, 40], [40, 30], [50, 20]]
_WinAPI_SetDCPenColor($hDC, 0xFF8000)
_WinAPI_OffsetPoints($aPoint1, 219, 25)
_WinAPI_PolyBezier($hDC, $aPoint1)
$hBrush = _WinAPI_CreateBrushIndirect($BS_SOLID, 0xFF8000)
$hObj = _WinAPI_SelectObject($hDC, $hBrush)
_WinAPI_ExtFloodFill($hDC, 70 + 219, 40 + 25, 0xFF8000, 0)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hBrush)
_WinAPI_SetDCPenColor($hDC, 0xFFFFFF)
Local $hPattern = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Pattern.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
; $hPattern = _WinAPI_LoadBitmap(_WinAPI_GetModuleHandle(@SystemDir & '\shell32.dll'), 138)
$hBrush = _WinAPI_CreateBrushIndirect($BS_PATTERN, 0, $hPattern)
$hObj = _WinAPI_SelectObject($hDC, $hBrush)
$tRECT = _WinAPI_CreateRect(0, 0, 140, 90)
_WinAPI_OffsetRect($tRECT, 220, 279)
_WinAPI_RoundRect($hDC, $tRECT, 20, 20)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hPattern)
_WinAPI_DeleteObject($hBrush)

; Merge bitmap
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDev, 400, 400)
$hBrush = _WinAPI_SelectObject($hDC, $hOldBrush)
_WinAPI_DeleteObject($hBrush)
Local $hPen = _WinAPI_SelectObject($hDC, $hOldPen)
_WinAPI_DeleteObject($hPen)
_WinAPI_SelectObject($hDC, $hBitmap)
_WinAPI_DrawBitmap($hDC, 0, 0, $hSource, $MERGECOPY)
_WinAPI_ReleaseDC($hPic, $hDev)
_WinAPI_SelectObject($hDC, $hSv)
_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteDC($hDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
$hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = -3


Function _WinAPI_InvertRect

Function Reference

_WinAPI_InvertRect

Inverts a rectangle in a window by performing a logical NOT operation on the color values for each pixel

#include <WinAPIGdi.au3>
_WinAPI_InvertRect ( $hDC, $tRECT )

Parameters

$hDC | Handle to the device context.
$tRECT | $tagRECT structure that contains the logical coordinates of the rectangle to be inverted.

Return Value

Success: | True
Failure: | False

Remarks

On monochrome screens, the _WinAPI_InvertRect() makes white pixels black and black pixels white. On color screens,
the inversion depends on how colors are generated for the screen. Calling _WinAPI_InvertRect() twice for the same
rectangle restores the display to its previous colors.

See Also

Search InvertRect in MSDN Library.


Function _WinAPI_Polygon

Function Reference

_WinAPI_Polygon

Draws a polygon consisting of two or more vertices connected by straight lines

#include <WinAPIGdi.au3>
_WinAPI_Polygon ( $hDC, Const ByRef $aPoint [, $iStart = 0 [, $iEnd = -1]] )

Parameters

$hDC | Handle to the device context.
$aPoint | The 2D array ([x1, y1], [x2, y2], ... [xN, yN]) that contains the vertices of the polygon in logical units. The polygon is closed automatically by drawing a line from the last vertex to the first.
$iStart | [optional] The index of array to start creating at.
$iEnd | [optional] The index of array to stop creating at.

Return Value

Success: | True
Failure: | False

Remarks

The polygon is outlined by using the current pen and filled by using the current brush and polygon fill mode.

See Also

Search Polygon in MSDN Library.


Function _WinAPI_Rectangle

Function Reference

_WinAPI_Rectangle

Draws a rectangle

#include <WinAPIGdi.au3>
_WinAPI_Rectangle ( $hDC, $tRECT )

Parameters

$hDC | Handle to the device context.
$tRECT | $tagRECT structure that contains the logical coordinates of the rectangle.

Return Value

Success: | True
Failure: | False

Remarks

The rectangle is outlined by using the current pen and filled by using the current brush.

See Also

Search Rectangle in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <FontConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idPic = GUICtrlCreatePic('', 0, 0, 400, 400)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDev = _WinAPI_GetDC($hPic)
Local $hDC = _WinAPI_CreateCompatibleDC($hDev)
Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, 400, 400, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hSv = _WinAPI_SelectObject($hDC, $hSource)

; Draw objects
Local $hOldBrush = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hOldPen = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetDCBrushColor($hDC, 0x990404)
_WinAPI_SetDCPenColor($hDC, 0x990404)
Local $tRECT = _WinAPI_CreateRect(0, 0, 100, 100)
_WinAPI_OffsetRect($tRECT, 30, 30)
_WinAPI_Rectangle($hDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 20, 20)
_WinAPI_InvertRect($hDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 20, 20)
_WinAPI_InvertRect($hDC, $tRECT)
_WinAPI_SetDCPenColor($hDC, 0x00A820)
_WinAPI_SetBkColor($hDC, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hBrush = _WinAPI_CreateBrushIndirect($BS_HATCHED, 0x00A820, $HS_DIAGCROSS)
Local $hObj = _WinAPI_SelectObject($hDC, $hBrush)
$tRECT = _WinAPI_CreateRect(0, 0, 140, 140)
_WinAPI_OffsetRect($tRECT, 220, 118)
_WinAPI_Ellipse($hDC, $tRECT)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hBrush)
_WinAPI_SetTextColor($hDC, 0xCD0091)
_WinAPI_SetBkMode($hDC, $TRANSPARENT)
Local $hFont = _WinAPI_CreateFont(38, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, 'Arial Black')
$hObj = _WinAPI_SelectObject($hDC, $hFont)
_WinAPI_TextOut($hDC, 30, 185, 'Simple Text')
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hFont)
Local $aPoint2[6][2] = [[0, 129], [55, 75], [75, 0], [95, 75], [150, 129], [75, 108]]
Local $hRgn = _WinAPI_CreatePolygonRgn($aPoint2)
_WinAPI_SetDCBrushColor($hDC, 0x0060C4)
_WinAPI_OffsetRgn($hRgn, 25, 240)
_WinAPI_PaintRgn($hDC, $hRgn)
_WinAPI_DeleteObject($hRgn)
Local $aPoint1[19][2] = [[50, 20], [70, 0], [70, 0], [90, 20], [100, 30], [110, 40], [120, 50], [130, 60], [130, 70], [120, 70], [110, 70], [30, 70], [20, 70], [10, 70], [10, 60], [20, 50], [30, 40], [40, 30], [50, 20]]
_WinAPI_SetDCPenColor($hDC, 0xFF8000)
_WinAPI_OffsetPoints($aPoint1, 219, 25)
_WinAPI_PolyBezier($hDC, $aPoint1)
$hBrush = _WinAPI_CreateBrushIndirect($BS_SOLID, 0xFF8000)
$hObj = _WinAPI_SelectObject($hDC, $hBrush)
_WinAPI_ExtFloodFill($hDC, 70 + 219, 40 + 25, 0xFF8000, 0)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hBrush)
_WinAPI_SetDCPenColor($hDC, 0xFFFFFF)
Local $hPattern = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Pattern.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
; $hPattern = _WinAPI_LoadBitmap(_WinAPI_GetModuleHandle(@SystemDir & '\shell32.dll'), 138)
$hBrush = _WinAPI_CreateBrushIndirect($BS_PATTERN, 0, $hPattern)
$hObj = _WinAPI_SelectObject($hDC, $hBrush)
$tRECT = _WinAPI_CreateRect(0, 0, 140, 90)
_WinAPI_OffsetRect($tRECT, 220, 279)
_WinAPI_RoundRect($hDC, $tRECT, 20, 20)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hPattern)
_WinAPI_DeleteObject($hBrush)

; Merge bitmap
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDev, 400, 400)
$hBrush = _WinAPI_SelectObject($hDC, $hOldBrush)
_WinAPI_DeleteObject($hBrush)
Local $hPen = _WinAPI_SelectObject($hDC, $hOldPen)
_WinAPI_DeleteObject($hPen)
_WinAPI_SelectObject($hDC, $hBitmap)
_WinAPI_DrawBitmap($hDC, 0, 0, $hSource, $MERGECOPY)
_WinAPI_ReleaseDC($hPic, $hDev)
_WinAPI_SelectObject($hDC, $hSv)
_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteDC($hDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
$hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = -3


Function _WinAPI_RoundRect

Function Reference

_WinAPI_RoundRect

Draws a rectangle with rounded corners

#include <WinAPIGdi.au3>
_WinAPI_RoundRect ( $hDC, $tRECT, $iWidth, $iHeight )

Parameters

$hDC | Handle to the device context.
$tRECT | $tagRECT structure that contains the logical coordinates of the rectangle.
$iWidth | The width, in logical coordinates, of the ellipse used to draw the rounded corners.
$iHeight | The height, in logical coordinates, of the ellipse used to draw the rounded corners.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

The rectangle is outlined by using the current pen and filled by using the current brush.

See Also

Search RoundRect in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <FontConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idPic = GUICtrlCreatePic('', 0, 0, 400, 400)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDev = _WinAPI_GetDC($hPic)
Local $hDC = _WinAPI_CreateCompatibleDC($hDev)
Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, 400, 400, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hSv = _WinAPI_SelectObject($hDC, $hSource)

; Draw objects
Local $hOldBrush = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hOldPen = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_PEN))
_WinAPI_SetDCBrushColor($hDC, 0x990404)
_WinAPI_SetDCPenColor($hDC, 0x990404)
Local $tRECT = _WinAPI_CreateRect(0, 0, 100, 100)
_WinAPI_OffsetRect($tRECT, 30, 30)
_WinAPI_Rectangle($hDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 20, 20)
_WinAPI_InvertRect($hDC, $tRECT)
_WinAPI_OffsetRect($tRECT, 20, 20)
_WinAPI_InvertRect($hDC, $tRECT)
_WinAPI_SetDCPenColor($hDC, 0x00A820)
_WinAPI_SetBkColor($hDC, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hBrush = _WinAPI_CreateBrushIndirect($BS_HATCHED, 0x00A820, $HS_DIAGCROSS)
Local $hObj = _WinAPI_SelectObject($hDC, $hBrush)
$tRECT = _WinAPI_CreateRect(0, 0, 140, 140)
_WinAPI_OffsetRect($tRECT, 220, 118)
_WinAPI_Ellipse($hDC, $tRECT)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hBrush)
_WinAPI_SetTextColor($hDC, 0xCD0091)
_WinAPI_SetBkMode($hDC, $TRANSPARENT)
Local $hFont = _WinAPI_CreateFont(38, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, $DEFAULT_PITCH, 'Arial Black')
$hObj = _WinAPI_SelectObject($hDC, $hFont)
_WinAPI_TextOut($hDC, 30, 185, 'Simple Text')
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hFont)
Local $aPoint2[6][2] = [[0, 129], [55, 75], [75, 0], [95, 75], [150, 129], [75, 108]]
Local $hRgn = _WinAPI_CreatePolygonRgn($aPoint2)
_WinAPI_SetDCBrushColor($hDC, 0x0060C4)
_WinAPI_OffsetRgn($hRgn, 25, 240)
_WinAPI_PaintRgn($hDC, $hRgn)
_WinAPI_DeleteObject($hRgn)
Local $aPoint1[19][2] = [[50, 20], [70, 0], [70, 0], [90, 20], [100, 30], [110, 40], [120, 50], [130, 60], [130, 70], [120, 70], [110, 70], [30, 70], [20, 70], [10, 70], [10, 60], [20, 50], [30, 40], [40, 30], [50, 20]]
_WinAPI_SetDCPenColor($hDC, 0xFF8000)
_WinAPI_OffsetPoints($aPoint1, 219, 25)
_WinAPI_PolyBezier($hDC, $aPoint1)
$hBrush = _WinAPI_CreateBrushIndirect($BS_SOLID, 0xFF8000)
$hObj = _WinAPI_SelectObject($hDC, $hBrush)
_WinAPI_ExtFloodFill($hDC, 70 + 219, 40 + 25, 0xFF8000, 0)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hBrush)
_WinAPI_SetDCPenColor($hDC, 0xFFFFFF)
Local $hPattern = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Pattern.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
; $hPattern = _WinAPI_LoadBitmap(_WinAPI_GetModuleHandle(@SystemDir & '\shell32.dll'), 138)
$hBrush = _WinAPI_CreateBrushIndirect($BS_PATTERN, 0, $hPattern)
$hObj = _WinAPI_SelectObject($hDC, $hBrush)
$tRECT = _WinAPI_CreateRect(0, 0, 140, 90)
_WinAPI_OffsetRect($tRECT, 220, 279)
_WinAPI_RoundRect($hDC, $tRECT, 20, 20)
_WinAPI_SelectObject($hDC, $hObj)
_WinAPI_DeleteObject($hPattern)
_WinAPI_DeleteObject($hBrush)

; Merge bitmap
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDev, 400, 400)
$hBrush = _WinAPI_SelectObject($hDC, $hOldBrush)
_WinAPI_DeleteObject($hBrush)
Local $hPen = _WinAPI_SelectObject($hDC, $hOldPen)
_WinAPI_DeleteObject($hPen)
_WinAPI_SelectObject($hDC, $hBitmap)
_WinAPI_DrawBitmap($hDC, 0, 0, $hSource, $MERGECOPY)
_WinAPI_ReleaseDC($hPic, $hDev)
_WinAPI_SelectObject($hDC, $hSv)
_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteDC($hDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
$hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = -3


User Defined Functions

Internationalization user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPILocale.au3>.

User Defined Function | Description
_WinAPI_CompareString | Compares two character strings for a specified locale
_WinAPI_CreateNumberFormatInfo | Creates a $tagNUMBERFMT structure with the specified number formatting information
_WinAPI_EnumSystemGeoID | Enumerates the geographical location identifiers (GEOID) that are available on the operating system
_WinAPI_EnumSystemLocales | Enumerates the locales that are either installed on or supported by an operating system
_WinAPI_EnumUILanguages | Enumerates the user interface languages that are available on the operating system
_WinAPI_GetDateFormat | Formats a date as a date string for a locale specified by the locale identifier
_WinAPI_GetDurationFormat | Formats a duration of time as a time string for a locale specified by identifier
_WinAPI_GetGeoInfo | Retrieves information about a specified geographical location
_WinAPI_GetLocaleInfo | Retrieves information about a locale specified by identifier
_WinAPI_GetNumberFormat | Formats a number string as a number string customized for a locale specified by identifier
_WinAPI_GetSystemDefaultLangID | Returns the language identifier for the system locale
_WinAPI_GetSystemDefaultLCID | Returns the locale identifier (LCID) for the system locale
_WinAPI_GetSystemDefaultUILanguage | Retrieves the language identifier for the system default UI language of the operating system
_WinAPI_GetThreadLocale | Retrieves the locale identifier of the current locale for the calling thread
_WinAPI_GetThreadUILanguage | Retrieves the language identifier of the first user interface language for the current thread
_WinAPI_GetTimeFormat | Formats time as a time string for a locale specified by identifier
_WinAPI_GetUserDefaultLangID | Returns the language identifier for the current user locale
_WinAPI_GetUserDefaultLCID | Returns the locale identifier (LCID) for the user default locale
_WinAPI_GetUserDefaultUILanguage | Returns the language identifier for the user UI language for the current user
_WinAPI_GetUserGeoID | Retrieves information about the geographical location of the user
_WinAPI_IsValidLocale | Determines if the specified locale is installed or supported on the operating system
_WinAPI_SetLocaleInfo | Sets an item of information in the user override portion of the current locale
_WinAPI_SetThreadLocale | Sets the current locale of the calling thread
_WinAPI_SetThreadUILanguage | Sets the user interface language for the current thread
_WinAPI_SetUserGeoID | Sets the geographical location identifier for the user


Function _WinAPI_CompareString

Function Reference

_WinAPI_CompareString

Compares two character strings for a specified locale

#include <WinAPILocale.au3>
_WinAPI_CompareString ( $iLCID, $sString1, $sString2 [, $iFlags = 0] )

Parameters

$iLCID | The locale identifier (LCID) that specifies the locale or one of the following predefined values: $LOCALE_INVARIANT $LOCALE_SYSTEM_DEFAULT $LOCALE_USER_DEFAULT Windows Vista or later $LOCALE_CUSTOM_DEFAULT $LOCALE_CUSTOM_UI_DEFAULT $LOCALE_CUSTOM_UNSPECIFIED
$sString1 | The first string to compare.
$sString2 | The second string to compare.
$iFlags | [optional] The flags that indicate how the function compares the two strings. This parameter can be 0 or combination of the following values: $LINGUISTIC_IGNORECASE $LINGUISTIC_IGNOREDIACRITIC $NORM_IGNORECASE $NORM_IGNOREKANATYPE $NORM_IGNORENONSPACE $NORM_IGNORESYMBOLS $NORM_IGNOREWIDTH $NORM_LINGUISTIC_CASING $SORT_STRINGSORT Windows 7 or later $SORT_DIGITSASNUMBERS

Return Value

Success: | The one of the following values that indicates a result of the comparison strings. $CSTR_LESS_THAN $CSTR_EQUAL $CSTR_GREATER_THAN
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

Normally, for case-insensitive comparisons, _WinAPI_CompareString() maps the lowercase "i" to the uppercase "I", even when the locale is Turkish or Azeri.
The $NORM_LINGUISTIC_CASING flag overrides this behavior for Turkish or Azeri.
If this flag is specified in conjunction with Turkish or Azeri, LATIN SMALL LETTER DOTLESS I (U+0131) is the lowercase form of LATIN CAPITAL LETTER I (U+0049) and LATIN SMALL LETTER I (U+0069) is the lowercase form of LATIN CAPITAL LETTER I WITH DOT ABOVE (U+0130).

See Also

Search CompareString in MSDN Library.

Example

#include <APILocaleConstants.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <WinAPILocale.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.1' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows 7 or later.')
    Exit
EndIf

; Create array of strings ("Item*")
Local $aItem[100]
For $i = 0 To UBound($aItem) - 1
    $aItem[$i] = 'Item' & Random(0, 100, 1)
Next

_ArrayDisplay($aItem, 'Initial array')

; Simple array sorting
_ArraySort($aItem)

_ArrayDisplay($aItem, 'Simple sorting')

; Sort array (bubble sort) ignoring case sensitive and according to the digits
Local $sTemp
For $i = 0 To UBound($aItem) - 2
    For $j = $i + 1 To UBound($aItem) - 1
        Switch _WinAPI_CompareString($LOCALE_INVARIANT, $aItem[$i], $aItem[$j], BitOR($NORM_IGNORECASE, $SORT_DIGITSASNUMBERS))
            Case $CSTR_GREATER_THAN
                $sTemp = $aItem[$i]
                $aItem[$i] = $aItem[$j]
                $aItem[$j] = $sTemp
            Case Else

        EndSwitch
    Next
Next

_ArrayDisplay($aItem, 'bubble sort case insensitive')


Function _WinAPI_CreateNumberFormatInfo

Function Reference

_WinAPI_CreateNumberFormatInfo

Creates a $tagNUMBERFMT structure with the specified number formatting information

#include <WinAPILocale.au3>
_WinAPI_CreateNumberFormatInfo ( $iNumDigits, $iLeadingZero, $iGrouping, $sDecimalSep, $sThousandSep, $iNegativeOrder )

Parameters

$iNumDigits | The number of fractional digits placed after the decimal separator.
$iLeadingZero | Specifier for leading zeros in decimal fields, valid values: 0 - No leading zeros. 1 - Leading zeros.
$iGrouping | The number of digits in each group of numbers to the left of the decimal separator. The values in the range 0 through 9 and 32 are valid. Typical examples are: 0 to group digits as in 123456789.00; 3 to group digits as in 123,456,789.00; and 32 to group digits as in 12,34,56,789.00.
$sDecimalSep | The decimal separator string.
$sThousandSep | The thousand separator string.
$iNegativeOrder | The negative number mode, valid values: 0 - Left parenthesis, number, right parenthesis; for example, (1.1). 1 - Negative sign, number; for example, -1.1. 2 - Negative sign, space, number; for example, - 1.1. 3 - Number, negative sign; for example, 1.1-. 4 - Number, space, negative sign; for example, 1.1 -.

Return Value

Returns $tagNUMBERFMT structure that contains number formatting information.

Remarks

Typically, the structure returned by this function is used in the _WinAPI_GetNumberFormat() function.

Related

_WinAPI_GetNumberFormat

See Also

Search NUMBERFMT in MSDN Library.

Example

#include <WinAPILocale.au3>

Local $sNumber = '123456789'

ConsoleWrite(_WinAPI_GetNumberFormat(0, $sNumber) & @CRLF)
ConsoleWrite(_WinAPI_GetNumberFormat(0, $sNumber, _WinAPI_CreateNumberFormatInfo(0, 1, 3, '', ',', 1)) & @CRLF)


Function _WinAPI_EnumSystemGeoID

Function Reference

_WinAPI_EnumSystemGeoID

Enumerates the geographical location identifiers (GEOID) that are available on the operating system

#include <WinAPILocale.au3>
_WinAPI_EnumSystemGeoID ( )

Return Value

Success: | The array of the GEOID. The zeroth array element contains the number of identifiers.
Failure: | Sets the @error flag to non-zero.

See Also

Search EnumSystemGeoID in MSDN Library.

Example

#include <APILocaleConstants.au3>
#include <Array.au3>
#include <WinAPILocale.au3>

Local $aData = _WinAPI_EnumSystemGeoID()

If IsArray($aData) Then
    For $i = 1 To $aData[0]
        $aData[$i] = _WinAPI_GetGeoInfo($aData[$i], $GEO_FRIENDLYNAME)
    Next
EndIf

_ArrayDisplay($aData, '_WinAPI_EnumSystemGeoID')


Function _WinAPI_EnumSystemLocales

Function Reference

_WinAPI_EnumSystemLocales

Enumerates the locales that are either installed on or supported by an operating system

#include <WinAPILocale.au3>
_WinAPI_EnumSystemLocales ( $iFlag )

Parameters

$iFlag The flag specifying the locale identifiers to enumerate.
This parameter can have one of the following values:
$LCID_INSTALLED
$LCID_SUPPORTED

Return Value

Success: | The array of the locale identifiers.
Failure: | Sets the @error flag to non-zero.

See Also

Search EnumSystemLocales in MSDN Library.

Example

#include <APILocaleConstants.au3>
#include <Array.au3>
#include <WinAPILocale.au3>

Local $aData = _WinAPI_EnumSystemLocales($LCID_INSTALLED)

_ArrayDisplay($aData, '_WinAPI_EnumSystemLocales')


Function _WinAPI_EnumUILanguages

Function Reference

_WinAPI_EnumUILanguages

Enumerates the user interface languages that are available on the operating system

#include <WinAPILocale.au3>
_WinAPI_EnumUILanguages ( [$iFlag = 0] )

Parameters

$iFlag [optional] The flag identifying the language format. This parameter must be 0 or one of the following values Windows Vista or later:
$MUI_LANGUAGE_ID
$MUI_LANGUAGE_NAME

Return Value

Success: | The array of the UI language identifiers or language names.
Failure: | Sets the @error flag to non-zero.

See Also

Search EnumUILanguages in MSDN Library.

Example

#include <Array.au3>
#include <WinAPILocale.au3>

Local $aData = _WinAPI_EnumUILanguages()

_ArrayDisplay($aData, '_WinAPI_EnumUILanguages')


Function _WinAPI_GetDateFormat

Function Reference

_WinAPI_GetDateFormat

Formats a date as a date string for a locale specified by the locale identifier

#include <WinAPILocale.au3>
_WinAPI_GetDateFormat ( [$iLCID = 0 [, $tSYSTEMTIME = 0 [, $iFlags = 0 [, $sFormat = '']]]] )

Parameters

$iLCID | [optional] The locale identifier (LCID) that specifies the locale or one of the following predefined values. $LOCALE_INVARIANT $LOCALE_SYSTEM_DEFAULT $LOCALE_USER_DEFAULT (Default) Windows Vista or later $LOCALE_CUSTOM_DEFAULT $LOCALE_CUSTOM_UI_DEFAULT $LOCALE_CUSTOM_UNSPECIFIED
$tSYSTEMTIME | [optional] $tagSYSTEMTIME structure that contains the date information to format. If this parameter is 0 (Default), the function will use the current local system date.
$iFlags | [optional] The flags that specifies the date format options. This parameter can be one or more of the following values: $DATE_LONGDATE $DATE_SHORTDATE (Default) $DATE_USE_ALT_CALENDAR Windows Vista or later $DATE_LTRREADING $DATE_RTLREADING $DATE_YEARMONTH Windows 7 or later $DATE_AUTOLAYOUT
$sFormat | [optional] The string that is used to form the date. For example, "dddd MMMM, yyyy". If this parameter is omitted or an empty string (Default), the function returns the string according to the date format for the specified locale.

Return Value

Success: | The formatted date string.
Failure: | Empty string, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetDateFormat in MSDN Library.

Example

#include <APILocaleConstants.au3>
#include <WinAPILocale.au3>

ConsoleWrite(_WinAPI_GetDateFormat() & @CRLF)
ConsoleWrite(_WinAPI_GetDateFormat(0, 0, $DATE_LONGDATE) & @CRLF)
ConsoleWrite(_WinAPI_GetDateFormat(0, 0, 0, 'dddd dd, yyyy') & @CRLF)


Function _WinAPI_GetDurationFormat

Function Reference

_WinAPI_GetDurationFormat

Formats a duration of time as a time string for a locale specified by identifier

#include <WinAPILocale.au3>
_WinAPI_GetDurationFormat ( $iLCID, $iDuration [, $sFormat = ''] )

Parameters

$iLCID | The locale identifier (LCID) that specifies the locale or one of the following predefined values: $LOCALE_INVARIANT $LOCALE_SYSTEM_DEFAULT $LOCALE_USER_DEFAULT Windows Vista or later $LOCALE_CUSTOM_DEFAULT $LOCALE_CUSTOM_UI_DEFAULT $LOCALE_CUSTOM_UNSPECIFIED
$iDuration | The number of 100-nanosecond intervals in the duration. Alternatively, this parameter can be a $tagSYSTEMTIME structure that contains the time duration information to format.
$sFormat | [optional] The string that is used to form the duration. For example, "hh:mm:ss.ff". If this parameter is omitted or an empty string (Default), the function returns the string according to the duration format for the specified locale.

Return Value

Success: | The formatted duration string.
Failure: | Empty string, call _WinAPI_GetLastError() to get extended error information.

Remarks

This function requires Windows Vista or later.

See Also

Search GetDurationFormat in MSDN Library.

Example

#include <WinAPILocale.au3>

Local $iDuration = (90 * 60 + 14) * 1000 * 1000 * 10

ConsoleWrite(_WinAPI_GetDurationFormat(0, $iDuration, 'hh:mm:ss') & @CRLF)
ConsoleWrite(_WinAPI_GetDurationFormat(0, $iDuration, 'mm:ss') & @CRLF)
ConsoleWrite(_WinAPI_GetDurationFormat(0, $iDuration, 'ss') & @CRLF)


Function _WinAPI_GetGeoInfo

Function Reference

_WinAPI_GetGeoInfo

Retrieves information about a specified geographical location

#include <WinAPILocale.au3>
_WinAPI_GetGeoInfo ( $iGEOID, $iType [, $iLanguage = 0] )

Parameters

$iGEOID | The identifier for the geographical location (GEOID) for which to get information.
$iType | The type of information to retrieve. It can be one of the following values. $GEO_NATION $GEO_LATITUDE $GEO_LONGITUDE $GEO_ISO2 $GEO_ISO3 $GEO_LCID $GEO_FRIENDLYNAME $GEO_OFFICIALNAME $GEO_TIMEZONES $GEO_OFFICIALLANGUAGES Windows Vista or later $GEO_RFC1766 Windows 8 or later $GEO_ISO_UN_NUMBER $GEO_PARENT
$iLanguage | [optional] The language identifier, used with the geographical location.

Return Value

Success: | 1.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetGeoInfo in MSDN Library.

Example

#include <APILocaleConstants.au3>
#include <WinAPILocale.au3>

Local $iID = _WinAPI_GetUserGeoID()

ConsoleWrite('ID:        0x' & Hex($iID) & @CRLF)
ConsoleWrite('Latitude:  ' & _WinAPI_GetGeoInfo($iID, $GEO_LATITUDE) & @CRLF)
ConsoleWrite('Longitude: ' & _WinAPI_GetGeoInfo($iID, $GEO_LONGITUDE) & @CRLF)
ConsoleWrite('Name:      ' & _WinAPI_GetGeoInfo($iID, $GEO_FRIENDLYNAME) & @CRLF)
ConsoleWrite('ISO code:  ' & _WinAPI_GetGeoInfo($iID, $GEO_ISO3) & @CRLF)


Function _WinAPI_GetLocaleInfo

Function Reference

_WinAPI_GetLocaleInfo

Retrieves information about a locale specified by identifier

#include <WinAPILocale.au3>
_WinAPI_GetLocaleInfo ( $iLCID, $iType )

Parameters

$iLCID | The locale identifier (LCID) that specifies the locale or one of the following predefined values. $LOCALE_INVARIANT $LOCALE_SYSTEM_DEFAULT $LOCALE_USER_DEFAULT Windows Vista or later $LOCALE_CUSTOM_DEFAULT $LOCALE_CUSTOM_UI_DEFAULT $LOCALE_CUSTOM_UNSPECIFIED
$iType | The one of the locale information constants ($LOCALE_*) to retrieve.

Return Value

Success: | String containing the requested information.
Failure: | Empty string and sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetLocaleInfo in MSDN Library.

Example

#include <APILocaleConstants.au3>
#include <WinAPILocale.au3>

Local $iID = _WinAPI_GetUserDefaultLCID()

ConsoleWrite('Language => ' & _WinAPI_GetLocaleInfo($iID, $LOCALE_SLANGUAGE) & @CRLF)
ConsoleWrite('Date format => ' & _WinAPI_GetLocaleInfo($iID, $LOCALE_SSHORTDATE) & @CRLF)
ConsoleWrite('Time format => ' & _WinAPI_GetLocaleInfo($iID, $LOCALE_STIMEFORMAT) & @CRLF)
ConsoleWrite('Currency name => ' & _WinAPI_GetLocaleInfo($iID, $LOCALE_SNATIVECURRNAME) & @CRLF)
ConsoleWrite('Monetary symbol => ' & _WinAPI_GetLocaleInfo($iID, $LOCALE_SCURRENCY) & @CRLF)


Function _WinAPI_GetNumberFormat

Function Reference

_WinAPI_GetNumberFormat

Formats a number string as a number string customized for a locale specified by identifier

#include <WinAPILocale.au3>
_WinAPI_GetNumberFormat ( $iLCID, $sNumber [, $tNUMBERFMT = 0] )

Parameters

$iLCID | The locale identifier (LCID) that specifies the locale or one of the following predefined values. $LOCALE_INVARIANT $LOCALE_SYSTEM_DEFAULT $LOCALE_USER_DEFAULT Windows Vista or later $LOCALE_CUSTOM_DEFAULT $LOCALE_CUSTOM_UI_DEFAULT $LOCALE_CUSTOM_UNSPECIFIED
$sNumber | The string containing the number string to format. This string can only contain the following characters. All other characters are invalid. Characters "0" through "9". A minus sign in the first character position if the number is a negative value. One decimal point (dot) if the number is a floating-point value.
$tNUMBERFMT | [optional] $tagNUMBERFMT structure that contains number formatting information. If this parameter is 0 (Default), the function returns the string according to the number format for the specified locale. You can use the _WinAPI_CreateNumberFormatInfo() function to create this structure.

Return Value

Success: | The formatted number string.
Failure: | Empty string, call _WinAPI_GetLastError() to get extended error information.

Related

_WinAPI_CreateNumberFormatInfo

See Also

Search GetNumberFormat in MSDN Library.

Example

#include <WinAPILocale.au3>

Local $sNumber = '123456789'

ConsoleWrite(_WinAPI_GetNumberFormat(0, $sNumber) & @CRLF)
ConsoleWrite(_WinAPI_GetNumberFormat(0, $sNumber, _WinAPI_CreateNumberFormatInfo(0, 1, 3, '', ',', 1)) & @CRLF)


Function _WinAPI_GetSystemDefaultLangID

Function Reference

_WinAPI_GetSystemDefaultLangID

Returns the language identifier for the system locale

#include <WinAPILocale.au3>
_WinAPI_GetSystemDefaultLangID ( )

Return Value

Returns the language identifier for the system locale.

See Also

Search GetSystemDefaultLangID in MSDN Library.


Function _WinAPI_GetSystemDefaultLCID

Function Reference

_WinAPI_GetSystemDefaultLCID

Returns the locale identifier (LCID) for the system locale

#include <WinAPILocale.au3>
_WinAPI_GetSystemDefaultLCID ( )

Return Value

Returns the default LCID for the system.

See Also

Search GetSystemDefaultLCID in MSDN Library.


Function _WinAPI_GetSystemDefaultUILanguage

Function Reference

_WinAPI_GetSystemDefaultUILanguage

Retrieves the language identifier for the system default UI language of the operating system

#include <WinAPILocale.au3>
_WinAPI_GetSystemDefaultUILanguage ( )

Return Value

Returns the language identifier.

See Also

Search GetSystemDefaultUILanguage in MSDN Library.


Function _WinAPI_GetThreadLocale

Function Reference

_WinAPI_GetThreadLocale

Retrieves the locale identifier of the current locale for the calling thread

#include <WinAPILocale.au3>
_WinAPI_GetThreadLocale ( )

Return Value

Returns the locale identifier (LCID) of the locale associated with the current thread.

See Also

Search GetThreadLocale in MSDN Library.

Example

#include <APILocaleConstants.au3>
#include <APIResConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPILocale.au3>
#include <WinAPIRes.au3>
#include <WinAPISys.au3>

Local $hInstance = _WinAPI_LoadLibraryEx(@ScriptDir & '\Extras\Resources.dll', $LOAD_LIBRARY_AS_DATAFILE)
If Not $hInstance Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', @ScriptDir & '\Extras\Resources.dll not found.')
    Exit
EndIf

; Get the language (locale) identifier for the current process
Local $iPrev
If _WinAPI_GetVersion() >= '6.0' Then
    $iPrev = _WinAPI_GetThreadUILanguage()
Else
    $iPrev = _WinAPI_GetThreadLocale()
EndIf

; Why is the resource name for the string with ID = 6000 is 376? 6000 / 16 + 1 = 376
Local $aData = _WinAPI_EnumResourceLanguages($hInstance, $RT_STRING, 376)
If Not @error Then
    For $i = 1 To $aData[0]
        If _WinAPI_GetVersion() >= '6.0' Then
            _WinAPI_SetThreadUILanguage($aData[$i])
        Else
            _WinAPI_SetThreadLocale($aData[$i])
        EndIf
        ConsoleWrite(StringFormat('%-10s - %s', _WinAPI_GetLocaleInfo($aData[$i], $LOCALE_SENGLANGUAGE), _WinAPI_LoadString($hInstance, 6000)) & @CRLF)
    Next
EndIf

; Restore the previous language for the current process
If _WinAPI_GetVersion() >= '6.0' Then
    _WinAPI_SetThreadUILanguage($iPrev)
Else
    _WinAPI_SetThreadLocale($iPrev)
EndIf


Function _WinAPI_GetThreadUILanguage

Function Reference

_WinAPI_GetThreadUILanguage

Retrieves the language identifier of the first user interface language for the current thread

#include <WinAPILocale.au3>
_WinAPI_GetThreadUILanguage ( )

Return Value

Returns the identifier for a language associated with the current thread.

Remarks

This function requires Windows Vista or later.

See Also

Search GetThreadUILanguage in MSDN Library.

Example

#include <APILocaleConstants.au3>
#include <APIResConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPILocale.au3>
#include <WinAPIRes.au3>
#include <WinAPISys.au3>

Local $hInstance = _WinAPI_LoadLibraryEx(@ScriptDir & '\Extras\Resources.dll', $LOAD_LIBRARY_AS_DATAFILE)
If Not $hInstance Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', @ScriptDir & '\Extras\Resources.dll not found.')
    Exit
EndIf

; Get the language (locale) identifier for the current process
Local $iPrev
If _WinAPI_GetVersion() >= '6.0' Then
    $iPrev = _WinAPI_GetThreadUILanguage()
Else
    $iPrev = _WinAPI_GetThreadLocale()
EndIf

; Why is the resource name for the string with ID = 6000 is 376? 6000 / 16 + 1 = 376
Local $aData = _WinAPI_EnumResourceLanguages($hInstance, $RT_STRING, 376)
If Not @error Then
    For $i = 1 To $aData[0]
        If _WinAPI_GetVersion() >= '6.0' Then
            _WinAPI_SetThreadUILanguage($aData[$i])
        Else
            _WinAPI_SetThreadLocale($aData[$i])
        EndIf
        ConsoleWrite(StringFormat('%-10s - %s', _WinAPI_GetLocaleInfo($aData[$i], $LOCALE_SENGLANGUAGE), _WinAPI_LoadString($hInstance, 6000)) & @CRLF)
    Next
EndIf

; Restore the previous language for the current process
If _WinAPI_GetVersion() >= '6.0' Then
    _WinAPI_SetThreadUILanguage($iPrev)
Else
    _WinAPI_SetThreadLocale($iPrev)
EndIf


Function _WinAPI_GetTimeFormat

Function Reference

_WinAPI_GetTimeFormat

Formats time as a time string for a locale specified by identifier

#include <WinAPILocale.au3>
_WinAPI_GetTimeFormat ( [$iLCID = 0 [, $tSYSTEMTIME = 0 [, $iFlags = 0 [, $sFormat = '']]]] )

Parameters

$iLCID | [optional] The locale identifier (LCID) that specifies the locale or one of the following predefined values. $LOCALE_INVARIANT $LOCALE_SYSTEM_DEFAULT $LOCALE_USER_DEFAULT Windows Vista or later $LOCALE_CUSTOM_DEFAULT $LOCALE_CUSTOM_UI_DEFAULT $LOCALE_CUSTOM_UNSPECIFIED
$tSYSTEMTIME | [optional] $tagSYSTEMTIME structure that contains the time information to format. If this parameter is 0 (Default), the function will use the current local system time.
$iFlags | [optional] The flags that specifies the time format options. This parameter can be one or more of the following values. $TIME_FORCE24HOURFORMAT $TIME_NOMINUTESORSECONDS $TIME_NOSECONDS $TIME_NOTIMEMARKER
$sFormat | [optional] The string that is used to form the time. For example, "hh:mm:ss tt". If this parameter is omitted or an empty string (Default), the function returns the string according to the time format for the specified locale.

Return Value

Success: | The formatted time string.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetTimeFormat in MSDN Library.

Example

#include <APILocaleConstants.au3>
#include <WinAPILocale.au3>

ConsoleWrite(_WinAPI_GetTimeFormat() & @CRLF)
ConsoleWrite(_WinAPI_GetTimeFormat(0, 0, BitOR($TIME_FORCE24HOURFORMAT, $TIME_NOSECONDS)) & @CRLF)


Function _WinAPI_GetUserDefaultLangID

Function Reference

_WinAPI_GetUserDefaultLangID

Returns the language identifier for the current user locale

#include <WinAPILocale.au3>
_WinAPI_GetUserDefaultLangID ( )

Return Value

Returns the language identifier for the current user locale.

See Also

Search GetUserDefaultLangID in MSDN Library.


Function _WinAPI_GetUserDefaultLCID

Function Reference

_WinAPI_GetUserDefaultLCID

Returns the locale identifier (LCID) for the user default locale

#include <WinAPILocale.au3>
_WinAPI_GetUserDefaultLCID ( )

Return Value

Returns the default LCID for the user.

See Also

Search GetUserDefaultLCID in MSDN Library.


Function _WinAPI_GetUserDefaultUILanguage

Function Reference

_WinAPI_GetUserDefaultUILanguage

Returns the language identifier for the user UI language for the current user

#include <WinAPILocale.au3>
_WinAPI_GetUserDefaultUILanguage ( )

Return Value

Returns the language identifier.

Remarks

If Multilingual User Interface (MUI) is not installed on the operating system, the function returns the default
computer user interface language.

See Also

Search GetUserDefaultUILanguage in MSDN Library.


Function _WinAPI_GetUserGeoID

Function Reference

_WinAPI_GetUserGeoID

Retrieves information about the geographical location of the user

#include <WinAPILocale.au3>
_WinAPI_GetUserGeoID ( )

Return Value

Success: | The geographical location identifier of the user.
Failure: | (-1) GEOID_NOT_AVAILABLE.

See Also

Search GetUserGeoID in MSDN Library.

Example

#include <APILocaleConstants.au3>
#include <WinAPILocale.au3>

Local $iID = _WinAPI_GetUserGeoID()

ConsoleWrite('ID:        0x' & Hex($iID) & @CRLF)
ConsoleWrite('Latitude:  ' & _WinAPI_GetGeoInfo($iID, $GEO_LATITUDE) & @CRLF)
ConsoleWrite('Longitude: ' & _WinAPI_GetGeoInfo($iID, $GEO_LONGITUDE) & @CRLF)
ConsoleWrite('Name:      ' & _WinAPI_GetGeoInfo($iID, $GEO_FRIENDLYNAME) & @CRLF)
ConsoleWrite('ISO code:  ' & _WinAPI_GetGeoInfo($iID, $GEO_ISO3) & @CRLF)


Function _WinAPI_IsValidLocale

Function Reference

_WinAPI_IsValidLocale

Determines if the specified locale is installed or supported on the operating system

#include <WinAPILocale.au3>
_WinAPI_IsValidLocale ( $iLCID [, $iFlag = 0] )

Parameters

$iLCID | The locale identifier (LCID) that specifies the locale or one of the following predefined values. $LOCALE_INVARIANT $LOCALE_SYSTEM_DEFAULT $LOCALE_USER_DEFAULT Windows Vista or later $LOCALE_CUSTOM_DEFAULT $LOCALE_CUSTOM_UI_DEFAULT $LOCALE_CUSTOM_UNSPECIFIED
$iFlag | [optional] Flag specifying the validity test to apply to the locale identifier. This parameter can have one of the following values. $LCID_INSTALLED $LCID_SUPPORTED

Return Value

True: | the locale identifier passes the specified validity test.
False: | the locale identifier is invalid.

See Also

Search IsValidLocale in MSDN Library.


Function _WinAPI_SetLocaleInfo

Function Reference

_WinAPI_SetLocaleInfo

Sets an item of information in the user override portion of the current locale

#include <WinAPILocale.au3>
_WinAPI_SetLocaleInfo ( $iLCID, $iType, $sData )

Parameters

$iLCID | The locale identifier (LCID) that specifies the locale or one of the following predefined values. $LOCALE_INVARIANT $LOCALE_SYSTEM_DEFAULT $LOCALE_USER_DEFAULT Windows Vista or later $LOCALE_CUSTOM_DEFAULT $LOCALE_CUSTOM_UI_DEFAULT $LOCALE_CUSTOM_UNSPECIFIED
$iType | Type of locale information to set. This parameter can be one of the locale information constants ($LOCALE_*).
$sData | The string containing the locale information to set. The information must be in the format specific to the specified constant.

Return Value

Success: | True
Failure: | False

Remarks

$LOCALE_* constants require #include <APILocaleConstants.au3>.

See Also

Search SetLocaleInfo in MSDN Library.

Example

#include <APILocaleConstants.au3>
#include <WinAPILocale.au3>

_WinAPI_SetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_SLONGDATE, 'dddd, MMMM dd, yyyy')
_WinAPI_SetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_SSHORTDATE, 'dd-MMM-yy')


Function _WinAPI_SetThreadLocale

Function Reference

_WinAPI_SetThreadLocale

Sets the current locale of the calling thread

#include <WinAPILocale.au3>
_WinAPI_SetThreadLocale ( $iLCID )

Parameters

$iLCID The locale identifier (LCID) that specifies the locale or one of the following predefined values.
$LOCALE_INVARIANT
$LOCALE_SYSTEM_DEFAULT
$LOCALE_USER_DEFAULT

Windows Vista or later
$LOCALE_CUSTOM_DEFAULT
$LOCALE_CUSTOM_UI_DEFAULT
$LOCALE_CUSTOM_UNSPECIFIED

Return Value

Success: | True
Failure: | False

See Also

Search SetThreadLocale in MSDN Library.

Example

#include <APILocaleConstants.au3>
#include <APIResConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPILocale.au3>
#include <WinAPIRes.au3>
#include <WinAPISys.au3>

Local $hInstance = _WinAPI_LoadLibraryEx(@ScriptDir & '\Extras\Resources.dll', $LOAD_LIBRARY_AS_DATAFILE)
If Not $hInstance Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', @ScriptDir & '\Extras\Resources.dll not found.')
    Exit
EndIf

; Get the language (locale) identifier for the current process
Local $iPrev
If _WinAPI_GetVersion() >= '6.0' Then
    $iPrev = _WinAPI_GetThreadUILanguage()
Else
    $iPrev = _WinAPI_GetThreadLocale()
EndIf

; Why is the resource name for the string with ID = 6000 is 376? 6000 / 16 + 1 = 376
Local $aData = _WinAPI_EnumResourceLanguages($hInstance, $RT_STRING, 376)
If Not @error Then
    For $i = 1 To $aData[0]
        If _WinAPI_GetVersion() >= '6.0' Then
            _WinAPI_SetThreadUILanguage($aData[$i])
        Else
            _WinAPI_SetThreadLocale($aData[$i])
        EndIf
        ConsoleWrite(StringFormat('%-10s - %s', _WinAPI_GetLocaleInfo($aData[$i], $LOCALE_SENGLANGUAGE), _WinAPI_LoadString($hInstance, 6000)) & @CRLF)
    Next
EndIf

; Restore the previous language for the current process
If _WinAPI_GetVersion() >= '6.0' Then
    _WinAPI_SetThreadUILanguage($iPrev)
Else
    _WinAPI_SetThreadLocale($iPrev)
EndIf


Function _WinAPI_SetThreadUILanguage

Function Reference

_WinAPI_SetThreadUILanguage

Sets the user interface language for the current thread

#include <WinAPILocale.au3>
_WinAPI_SetThreadUILanguage ( $iLanguage )

Parameters

$iLanguage The language identifier for the user interface language.

Return Value

Success: | True
Failure: | False

Remarks

This function requires Windows Vista or later.

See Also

Search SetThreadUILanguage in MSDN Library.

Example

#include <APILocaleConstants.au3>
#include <APIResConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPILocale.au3>
#include <WinAPIRes.au3>
#include <WinAPISys.au3>

Local $hInstance = _WinAPI_LoadLibraryEx(@ScriptDir & '\Extras\Resources.dll', $LOAD_LIBRARY_AS_DATAFILE)
If Not $hInstance Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', @ScriptDir & '\Extras\Resources.dll not found.')
    Exit
EndIf

; Get the language (locale) identifier for the current process
Local $iPrev
If _WinAPI_GetVersion() >= '6.0' Then
    $iPrev = _WinAPI_GetThreadUILanguage()
Else
    $iPrev = _WinAPI_GetThreadLocale()
EndIf

; Why is the resource name for the string with ID = 6000 is 376? 6000 / 16 + 1 = 376
Local $aData = _WinAPI_EnumResourceLanguages($hInstance, $RT_STRING, 376)
If Not @error Then
    For $i = 1 To $aData[0]
        If _WinAPI_GetVersion() >= '6.0' Then
            _WinAPI_SetThreadUILanguage($aData[$i])
        Else
            _WinAPI_SetThreadLocale($aData[$i])
        EndIf
        ConsoleWrite(StringFormat('%-10s - %s', _WinAPI_GetLocaleInfo($aData[$i], $LOCALE_SENGLANGUAGE), _WinAPI_LoadString($hInstance, 6000)) & @CRLF)
    Next
EndIf

; Restore the previous language for the current process
If _WinAPI_GetVersion() >= '6.0' Then
    _WinAPI_SetThreadUILanguage($iPrev)
Else
    _WinAPI_SetThreadLocale($iPrev)
EndIf


Function _WinAPI_SetUserGeoID

Function Reference

_WinAPI_SetUserGeoID

Sets the geographical location identifier for the user

#include <WinAPILocale.au3>
_WinAPI_SetUserGeoID ( $iGEOID )

Parameters

$iGEOID The identifier for the geographical location of the user (GEOID).

Return Value

Success: | True
Failure: | False

Remarks

This function writes to the registry the geographical location for a particular user instead of an application.
This action affects the behavior of other applications run by the user. As a rule, the application should call this
function only when the user has explicitly requested changes, but not for purely application-specific reasons.

See Also

Search SetUserGeoID in MSDN Library.


Menus & Resources Reference

  • Carets Management
  • Cursors Management
  • Icons Management
  • Resources Management


User Defined Functions

Carets user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIRes.au3>.

User Defined Function | Description
_WinAPI_CreateCaret | Creates a new shape for the system caret and assigns ownership of the caret to the specified window
_WinAPI_DestroyCaret | Destroys the caret's current shape, frees the caret from the window, and removes the caret from the screen
_WinAPI_GetCaretBlinkTime | Returns the time required to invert the caret's pixels
_WinAPI_GetCaretPos | Retrieves the caret's position
_WinAPI_HideCaret | Removes the caret from the screen
_WinAPI_SetCaretBlinkTime | Sets the caret blink time
_WinAPI_SetCaretPos | Moves the caret to the specified coordinates
_WinAPI_ShowCaret | Makes the caret visible on the screen at the caret's current position


Function _WinAPI_CreateCaret

Function Reference

_WinAPI_CreateCaret

Creates a new shape for the system caret and assigns ownership of the caret to the specified window

#include <WinAPIRes.au3>
_WinAPI_CreateCaret ( $hWnd, $hBitmap [, $iWidth = 0 [, $iHeight = 0]] )

Parameters

$hWnd | Handle to the window that owns the caret.
$hBitmap | Handle to the bitmap that defines the caret shape. If this parameter is 0, the caret is solid. If this parameter is 1, the caret is gray. If this parameter is a bitmap handle, the caret is the specified bitmap.
$iWidth | [optional] The width of the caret in logical units. If this parameter is 0 (Default), the width is set to the system-defined window border width. If $hBitmap is a bitmap handle, _WinAPI_CreateCaret() ignores this parameter.
$iHeight | [optional] The height of the caret in logical units. If this parameter is 0 (Default), the height is set to the system-defined window border height. If $hBitmap is a bitmap handle, _WinAPI_CreateCaret() ignores this parameter.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

_WinAPI_CreateCaret() automatically destroys the previous caret shape, if any, regardless of the window that owns the caret.
The caret is hidden until the application calls the _WinAPI_ShowCaret() function to make the caret visible.

The system provides one caret per queue. A window should create a caret only when it has the keyboard focus or is active.
The window should destroy the caret before losing the keyboard focus or becoming inactive.

You can retrieve the width or height of the system's window border by using the _WinAPI_GetSystemMetrics() function, specifying the $SM_CXBORDER and $SM_CYBORDER values. Using the window border width or height guarantees that the caret will be visible on a high-resolution screen.

Related

_WinAPI_GetSystemMetrics, _WinAPI_ShowCaret

See Also

Search CreateCaret in MSDN Library.

Example

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIRes.au3>
#include <WindowsConstants.au3>

Global $g_vDuration = Default, $g_hBitmap = _WinAPI_CreateSolidBitmap(0, 0x00AEFF, 10, 14)

OnAutoItExitRegister('OnAutoItExit')

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 93)
Local $idInput = GUICtrlCreateInput('', 20, 20, 360, 20)
Local $idButton = GUICtrlCreateButton('Exit', 165, 59, 70, 23)
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $idButton
            ExitLoop
    EndSwitch
WEnd

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg

    Switch $hWnd
        Case $hForm
            Switch _WinAPI_LoWord($wParam)
                Case $idInput
                    Switch _WinAPI_HiWord($wParam)
                        Case $EN_KILLFOCUS
                            _WinAPI_HideCaret($lParam)
                            _WinAPI_DestroyCaret()
                            _WinAPI_SetCaretBlinkTime($g_vDuration)
                            $g_vDuration = Default
                        Case $EN_SETFOCUS
                            $g_vDuration = _WinAPI_SetCaretBlinkTime(-1)
                            _WinAPI_CreateCaret($lParam, $g_hBitmap)
                            _WinAPI_ShowCaret($lParam)
                    EndSwitch
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func OnAutoItExit()
    _WinAPI_DeleteObject($g_hBitmap)
    If Not IsKeyword($g_vDuration) Then
        _WinAPI_SetCaretBlinkTime($g_vDuration)
    EndIf
EndFunc   ;==>OnAutoItExit


Function _WinAPI_DestroyCaret

Function Reference

_WinAPI_DestroyCaret

Destroys the caret's current shape, frees the caret from the window, and removes the caret from the screen

#include <WinAPIRes.au3>
_WinAPI_DestroyCaret ( )

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

_WinAPI_DestroyCaret() destroys the caret only if a window in the current task owns the caret.
If a window that is not in the current task owns the caret, _WinAPI_DestroyCaret() does nothing and returns 0.

The window should destroy the caret before losing the keyboard focus or becoming inactive.

See Also

Search DestroyCaret in MSDN Library.


Function _WinAPI_GetCaretBlinkTime

Function Reference

_WinAPI_GetCaretBlinkTime

Returns the time required to invert the caret's pixels

#include <WinAPIRes.au3>
_WinAPI_GetCaretBlinkTime ( )

Return Value

Success: | The blink time, in milliseconds.
Failure: | 0, to get extended error information, call GetLastError.

Remarks

A return value of INFINITE indicates that the caret does not blink.

See Also

Search GetCaretBlinkTime in MSDN Library.


Function _WinAPI_GetCaretPos

Function Reference

_WinAPI_GetCaretPos

Retrieves the caret's position

#include <WinAPIRes.au3>
_WinAPI_GetCaretPos ( )

Return Value

Success: | The array that contains the client coordinates of the caret. [0] - x-coordinate of the caret. [1] - y-coordinate of the caret.
Failure: | Sets the @error flag to non-zero.

See Also

Search GetCaretPos in MSDN Library.


Function _WinAPI_HideCaret

Function Reference

_WinAPI_HideCaret

Removes the caret from the screen

#include <WinAPIRes.au3>
_WinAPI_HideCaret ( $hWnd )

Parameters

$hWnd Handle to the window that owns the caret. If this parameter is 0, _WinAPI_HideCaret() searches the
current task for the window that owns the caret.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

_WinAPI_HideCaret() hides the caret only if the specified window owns the caret. If the specified window does
not own the caret, _WinAPI_HideCaret() does nothing and returns 0.

Hiding is cumulative. If your application calls _WinAPI_HideCaret() five times in a row, it must also call
_WinAPI_ShowCaret() five times before the caret is displayed.

Related

_WinAPI_ShowCaret

See Also

Search HideCaret in MSDN Library.

Example

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIRes.au3>
#include <WindowsConstants.au3>

Global $g_vDuration = Default, $g_hBitmap = _WinAPI_CreateSolidBitmap(0, 0x00AEFF, 10, 14)

OnAutoItExitRegister('OnAutoItExit')

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 93)
Local $idInput = GUICtrlCreateInput('', 20, 20, 360, 20)
Local $idButton = GUICtrlCreateButton('Exit', 165, 59, 70, 23)
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $idButton
            ExitLoop
    EndSwitch
WEnd

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg

    Switch $hWnd
        Case $hForm
            Switch _WinAPI_LoWord($wParam)
                Case $idInput
                    Switch _WinAPI_HiWord($wParam)
                        Case $EN_KILLFOCUS
                            _WinAPI_HideCaret($lParam)
                            _WinAPI_DestroyCaret()
                            _WinAPI_SetCaretBlinkTime($g_vDuration)
                            $g_vDuration = Default
                        Case $EN_SETFOCUS
                            $g_vDuration = _WinAPI_SetCaretBlinkTime(-1)
                            _WinAPI_CreateCaret($lParam, $g_hBitmap)
                            _WinAPI_ShowCaret($lParam)
                    EndSwitch
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func OnAutoItExit()
    _WinAPI_DeleteObject($g_hBitmap)
    If Not IsKeyword($g_vDuration) Then
        _WinAPI_SetCaretBlinkTime($g_vDuration)
    EndIf
EndFunc   ;==>OnAutoItExit


Function _WinAPI_SetCaretBlinkTime

Function Reference

_WinAPI_SetCaretBlinkTime

Sets the caret blink time

#include <WinAPIRes.au3>
_WinAPI_SetCaretBlinkTime ( $iDuration )

Parameters

$iDuration The new blink time, in milliseconds. If this parameter is (-1), caret does not blink.

Return Value

Success: | The previous blink time, in milliseconds.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

The user can set the blink time using the Control Panel. Applications should respect the setting that the user
has chosen. This function should only be used by application that allow the user to set the blink time, such
as a Control Panel applet.

See Also

Search SetCaretBlinkTime in MSDN Library.

Example

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIRes.au3>
#include <WindowsConstants.au3>

Global $g_vDuration = Default, $g_hBitmap = _WinAPI_CreateSolidBitmap(0, 0x00AEFF, 10, 14)

OnAutoItExitRegister('OnAutoItExit')

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 93)
Local $idInput = GUICtrlCreateInput('', 20, 20, 360, 20)
Local $idButton = GUICtrlCreateButton('Exit', 165, 59, 70, 23)
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $idButton
            ExitLoop
    EndSwitch
WEnd

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg

    Switch $hWnd
        Case $hForm
            Switch _WinAPI_LoWord($wParam)
                Case $idInput
                    Switch _WinAPI_HiWord($wParam)
                        Case $EN_KILLFOCUS
                            _WinAPI_HideCaret($lParam)
                            _WinAPI_DestroyCaret()
                            _WinAPI_SetCaretBlinkTime($g_vDuration)
                            $g_vDuration = Default
                        Case $EN_SETFOCUS
                            $g_vDuration = _WinAPI_SetCaretBlinkTime(-1)
                            _WinAPI_CreateCaret($lParam, $g_hBitmap)
                            _WinAPI_ShowCaret($lParam)
                    EndSwitch
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func OnAutoItExit()
    _WinAPI_DeleteObject($g_hBitmap)
    If Not IsKeyword($g_vDuration) Then
        _WinAPI_SetCaretBlinkTime($g_vDuration)
    EndIf
EndFunc   ;==>OnAutoItExit


Function _WinAPI_SetCaretPos

Function Reference

_WinAPI_SetCaretPos

Moves the caret to the specified coordinates

#include <WinAPIRes.au3>
_WinAPI_SetCaretPos ( $iX, $iY )

Parameters

$iX | The new x-coordinate of the caret.
$iY | The new y-coordinate of the caret.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

See Also

Search SetCaretPos in MSDN Library.


Function _WinAPI_ShowCaret

Function Reference

_WinAPI_ShowCaret

Makes the caret visible on the screen at the caret's current position

#include <WinAPIRes.au3>
_WinAPI_ShowCaret ( $hWnd )

Parameters

$hWnd Handle to the window that owns the caret. If this parameter is 0, _WinAPI_ShowCaret() searches the
current task for the window that owns the caret.

Return Value

Success: | True
Failure: | False

Remarks

_WinAPI_ShowCaret() shows the caret only if the specified window owns the caret, the caret has a shape,
and the caret has not been hidden two or more times in a row. If one or more of these conditions is not met,
_WinAPI_ShowCaret() does nothing and returns 0.

Hiding is cumulative. If your application calls _WinAPI_HideCaret() five times in a row, it must also call
_WinAPI_ShowCaret() five times before the caret reappears.

Related

_WinAPI_HideCaret

See Also

Search ShowCaret in MSDN Library.

Example

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIRes.au3>
#include <WindowsConstants.au3>

Global $g_iDuration = Default, $g_hBitmap = _WinAPI_CreateSolidBitmap(0, 0x00AEFF, 10, 14)

OnAutoItExitRegister('OnAutoItExit')

Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 93)
Global $g_idInput = GUICtrlCreateInput('', 20, 20, 360, 20)
Local $idButton = GUICtrlCreateButton('Exit', 165, 59, 70, 23)
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $idButton
            ExitLoop
    EndSwitch
WEnd

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg

    Switch $hWnd
        Case $g_hForm
            Switch _WinAPI_LoWord($wParam)
                Case $g_idInput
                    Switch _WinAPI_HiWord($wParam)
                        Case $EN_KILLFOCUS
                            _WinAPI_HideCaret($lParam)
                            _WinAPI_DestroyCaret()
                            _WinAPI_SetCaretBlinkTime($g_iDuration)
                            $g_iDuration = Default
                        Case $EN_SETFOCUS
                            $g_iDuration = _WinAPI_SetCaretBlinkTime(-1)
                            _WinAPI_CreateCaret($lParam, $g_hBitmap)
                            _WinAPI_ShowCaret($lParam)
                    EndSwitch
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func OnAutoItExit()
    _WinAPI_DeleteObject($g_hBitmap)
    If Not IsKeyword($g_iDuration) Then
        _WinAPI_SetCaretBlinkTime($g_iDuration)
    EndIf
EndFunc   ;==>OnAutoItExit


User Defined Functions

Cursors user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIRes.au3>.

User Defined Function | Description
_WinAPI_ClipCursor | Confines the cursor to a rectangular area on the screen
_WinAPI_CopyCursor | Creates a duplicate of a specified cursor
_WinAPI_DestroyCursor | Destroys a cursor and frees any memory the cursor occupied
_WinAPI_GetClipCursor | Retrieves the screen coordinates of the rectangular area to which the cursor is confined
_WinAPI_GetCursor | Retrieves a handle to the current cursor
_WinAPI_LoadCursor | Loads the specified cursor resource from the executable (.exe) file
_WinAPI_LoadCursorFromFile | Creates a cursor based on data contained in a file
_WinAPI_SetSystemCursor | Enables an application to customize the system cursors


Function _WinAPI_ClipCursor

Function Reference

_WinAPI_ClipCursor

Confines the cursor to a rectangular area on the screen

#include <WinAPIRes.au3>
_WinAPI_ClipCursor ( $tRECT )

Parameters

$tRECT $tagRECT structure that contains the screen coordinates of the confining rectangle.
If this parameter is 0, the cursor is free to move anywhere on the screen.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

The cursor is a shared resource.
If an application confines the cursor, it must release the cursor by using _WinAPI_ClipCursor() before relinquishing control to another application.

See Also

Search ClipCursor in MSDN Library.

Example

#include <WinAPIRes.au3>

_WinAPI_ClipCursor(_WinAPI_CreateRectEx(0, 0, 400, 400))
Sleep(5000)
_WinAPI_ClipCursor(0)


Function _WinAPI_CopyCursor

Function Reference

_WinAPI_CopyCursor

Creates a duplicate of a specified cursor

#include <WinAPIRes.au3>
_WinAPI_CopyCursor ( $hCursor )

Parameters

$hCursor Handle to the cursor to be duplicated.

Return Value

Success: | Handle to the new cursor that was created.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

When you are finished using the cursor, destroy it using the _WinAPI_DestroyCursor() function.

Related

_WinAPI_DestroyCursor

See Also

Search CopyIcon in MSDN Library.


Function _WinAPI_DestroyCursor

Function Reference

_WinAPI_DestroyCursor

Destroys a cursor and frees any memory the cursor occupied

#include <WinAPIRes.au3>
_WinAPI_DestroyCursor ( $hCursor )

Parameters

$hCursor Handle to the cursor to be destroyed. The cursor must not be in use.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

This function destroys a nonshared cursor. Do not use this function to destroy a shared cursor.
A shared cursor is valid as long as the module from which it was loaded remains in memory.

See Also

Search DestroyCursor in MSDN Library.


Function _WinAPI_GetClipCursor

Function Reference

_WinAPI_GetClipCursor

Retrieves the screen coordinates of the rectangular area to which the cursor is confined

#include <WinAPIRes.au3>
_WinAPI_GetClipCursor ( )

Return Value

Success: | $tagRECT structure that contains the screen coordinates of the confining rectangle.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

The calling process must have WINSTA_READATTRIBUTES access to the window station.

See Also

Search GetClipCursor in MSDN Library.


Function _WinAPI_GetCursor

Function Reference

_WinAPI_GetCursor

Retrieves a handle to the current cursor

#include <WinAPIRes.au3>
_WinAPI_GetCursor ( )

Return Value

Success: | Handle to the current cursor. If there is no cursor, the return value is 0.
Failure: | 0.

See Also

Search GetCursor in MSDN Library.


Function _WinAPI_LoadCursor

Function Reference

_WinAPI_LoadCursor

Loads the specified cursor resource from the executable (.exe) file

#include <WinAPIRes.au3>
_WinAPI_LoadCursor ( $hInstance, $sName )

Parameters

$hInstance | Handle to an instance of the module whose executable file contains the cursor to be loaded.
$sName | The name of the cursor resource or resource identifier to be loaded. To use one of the predefined cursors, the application must set the $hInstance parameter to 0 and the $sName parameter to oneof the following values. $IDC_ARROW $IDC_IBEAM $IDC_WAIT $IDC_CROSS $IDC_UPARROW $IDC_SIZE $IDC_ICON $IDC_SIZENWSE $IDC_SIZENESW $IDC_SIZEWE $IDC_SIZENS $IDC_SIZEALL $IDC_NO $IDC_HAND $IDC_APPSTARTING $IDC_HELP

Return Value

Success: | Handle to the newly loaded cursor.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

This function loads the cursor resource only if it has not been loaded; otherwise, it retrieves the handle to
the existing resource.

See Also

Search LoadCursor in MSDN Library.


Function _WinAPI_LoadCursorFromFile

Function Reference

_WinAPI_LoadCursorFromFile

Creates a cursor based on data contained in a file

#include <WinAPIRes.au3>
_WinAPI_LoadCursorFromFile ( $sFilePath )

Parameters

$sFilePath The file data to be used to create the cursor. The data in the file must be in either .CUR or .ANI format.

Return Value

Success: | Handle to the new cursor.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search LoadCursorFromFile in MSDN Library.

Example

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

Global $g_hCursor = _WinAPI_LoadCursorFromFile(@ScriptDir & '\Extras\Lens.cur')

OnAutoItExitRegister('OnAutoItExit')

Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Global $g_idLabel = GUICtrlCreateLabel('', 100, 100, 200, 200)
GUICtrlSetBkColor(-1, 0xD3D8EF)
GUICtrlSetState(-1, $GUI_DISABLE)
GUIRegisterMsg($WM_SETCURSOR, 'WM_SETCURSOR')
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_SETCURSOR($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam

    Switch $hWnd
        Case $g_hForm

            Local $aCursor = GUIGetCursorInfo($g_hForm)

            If (Not @error) And ($aCursor[4] = $g_idLabel) Then
                _WinAPI_SetCursor($g_hCursor)
                Return 0
            EndIf
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SETCURSOR

Func OnAutoItExit()
    _WinAPI_DestroyCursor($g_hCursor)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_SetSystemCursor

Function Reference

_WinAPI_SetSystemCursor

Enables an application to customize the system cursors

#include <WinAPIRes.au3>
_WinAPI_SetSystemCursor ( $hCursor, $iID [, $bCopy = False] )

Parameters

$hCursor | Handle to a cursor.
$iID | This parameter specifies the system cursor to replace with the contents of $hCursor, and can be one of the following values. $OCR_NORMAL $OCR_IBEAM $OCR_WAIT $OCR_CROSS $OCR_UP $OCR_SIZE $OCR_ICON $OCR_SIZENWSE $OCR_SIZENESW $OCR_SIZEWE $OCR_SIZENS $OCR_SIZEALL $OCR_ICOCUR $OCR_NO $OCR_HAND $OCR_APPSTARTING $OCR_HELP
$bCopy | [optional] Specifies whether the cursor should be duplicated, valid values: True - The cursor is duplicated. False - The cursor is not duplicated (Default).

Return Value

Success: | True
Failure: | False

Remarks

The function replaces the contents of the system cursor specified by ID with the contents of the cursor handled
by $hCursor. The system destroys $hCursor by calling the _WinAPI_DestroyCursor() function. Therefore, $hCursor cannot
be a cursor loaded using the _WinAPI_LoadCursor() function. To specify a cursor loaded from a resource, copy the
cursor using the _WinAPI_CopyCursor() function, then pass the copy to _WinAPI_SetSystemCursor().

Related

_WinAPI_CopyCursor, _WinAPI_DestroyCursor, _WinAPI_LoadCursor

See Also

Search SetSystemCursor in MSDN Library.

Example

#include <WinAPIRes.au3>

Local $hPrev = _WinAPI_CopyCursor(_WinAPI_LoadCursor(0, 32512))

_WinAPI_SetSystemCursor(_WinAPI_LoadCursorFromFile(@ScriptDir & '\Extras\Lens.cur'), 32512)
Sleep(5000)
_WinAPI_SetSystemCursor($hPrev, 32512)


User Defined Functions

Icons user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIRes.au3>.

User Defined Function | Description
_WinAPI_AddIconTransparency | Adds a transparency to the specified 32 bits-per-pixel icon
_WinAPI_CreateIcon | Creates an icon that has the specified size, colors, and bit patterns
_WinAPI_CreateIconFromResourceEx | Creates an icon or cursor from resource bits describing the icon
_WinAPI_ExtractIcon | Extracts an icon from the specified executable file, DLL, or icon file
_WinAPI_FileIconInit | Initializes or reinitializes the system image list
_WinAPI_GetIconInfoEx | Retrieves information about the specified icon or cursor
_WinAPI_LoadIcon | Loads the specified icon resource from the executable (.exe) file associated with an application instance
_WinAPI_LookupIconIdFromDirectoryEx | Searches through icon or cursor data for the icon or cursor that best fits the current display device


Function _WinAPI_AddIconTransparency

Function Reference

_WinAPI_AddIconTransparency

Adds a transparency to the specified 32 bits-per-pixel icon

#include <WinAPIRes.au3>
_WinAPI_AddIconTransparency ( $hIcon [, $iPercent = 50 [, $bDelete = False]] )

Parameters

$hIcon | Handle to the icon.
$iPercent | [optional] A value (in percent) that specifies how much to decrease the values of the alpha channel for the specified icon. If this parameter is 0, the function returns a fully transparent icon. Default is 80.
$bDelete | [optional] Specifies whether to delete the icon after the function is successful, valid values: True - Icon will be deleted if the function succeeds. False - Do not delete, you must release the icon when you are finished using it (Default).

Return Value

Success: | Handle to the newly created icon.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

This function only works with 32 bits-per-pixel with alpha chanel (RGB + Alpha) icons.
If the source icon has no alpha chanel, the resulting icon will be the same as the source icon. If the source icon is non 32 bits-per-pixel, the function fails.

When you are finished using the icon, destroy it using the _WinAPI_DestroyIcon() function.

Related

_WinAPI_DestroyIcon

Example

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIRes.au3>
#include <WinAPIShellEx.au3>

Local $hIcon = _WinAPI_Create32BitHICON(_WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 1, 32, 32), 1)

GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 262, 108)
For $i = 0 To 3
    GUICtrlCreateIcon('', 0, 30 + 58 * $i, 38, 32, 32)
    GUICtrlSendMsg(-1, $STM_SETIMAGE, 1, _WinAPI_AddIconTransparency($hIcon, 100 - 25 * $i))
Next
_WinAPI_DestroyIcon($hIcon)
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_CreateIcon

Function Reference

_WinAPI_CreateIcon

Creates an icon that has the specified size, colors, and bit patterns

#include <WinAPIRes.au3>
_WinAPI_CreateIcon ( $hInstance, $iWidth, $iHeight, $iPlanes, $iBitsPixel, $pANDBits, $pXORBits )

Parameters

$hInstance | Handle to the instance of the module creating the icon.
$iWidth | The width, in pixels, of the icon.
$iHeight | The height, in pixels, of the icon.
$iPlanes | The number of planes in the XOR bitmask of the icon.
$iBitsPixel | The number of bits-per-pixel in the XOR bitmask of the icon.
$pANDBits | An array of bytes that contains the bit values for the AND bitmask of the icon. This bitmask describes a monochrome bitmap.
$pXORBits | An array of bytes that contains the bit values for the XOR bitmask of the icon. This bitmask describes a monochrome or device-dependent color bitmap.

Return Value

Success: | the handle to the icon that is created.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

When you are finished using the icon, destroy it using the _WinAPI_DestroyIcon() function.

Related

_WinAPI_DestroyIcon

See Also

Search CreateIcon in MSDN Library.

Example

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

Local Const $sANDBits = _
        'FF FF FF FF' & _
        'FF FF C3 FF' & _
        'FF FF 00 FF' & _
        'FF FE 00 7F' & _
        'FF FC 00 1F' & _
        'FF F8 00 0F' & _
        'FF F8 00 0F' & _
        'FF F0 00 07' & _
        'FF F0 00 03' & _
        'FF E0 00 03' & _
        'FF E0 00 01' & _
        'FF E0 00 01' & _
        'FF F0 00 01' & _
        'FF F0 00 00' & _
        'FF F8 00 00' & _
        'FF FC 00 00' & _
        'FF FF 00 00' & _
        'FF FF 80 00' & _
        'FF FF E0 00' & _
        'FF FF E0 01' & _
        'FF FF F0 01' & _
        'FF FF F0 01' & _
        'FF FF F0 03' & _
        'FF FF E0 03' & _
        'FF FF E0 07' & _
        'FF FF C0 0F' & _
        'FF FF C0 0F' & _
        'FF FF 80 1F' & _
        'FF FF 00 7F' & _
        'FF FC 00 FF' & _
        'FF F8 03 FF' & _
        'FF FC 3F FF'

Local Const $sXORBits = _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 38 00' & _
        '00 00 7C 00' & _
        '00 00 7C 00' & _
        '00 00 7C 00' & _
        '00 00 38 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00' & _
        '00 00 00 00'

; Create AND bitmask structure
Local $bData = Binary('0x' & StringStripWS($sANDBits, 8))
Local $tANDBits = DllStructCreate('byte[' & BinaryLen($bData) & ']')
DllStructSetData($tANDBits, 1, $bData)

; Create XOR bitmask structure
$bData = Binary('0x' & StringStripWS($sXORBits, 8))
Local $tXORBits = DllStructCreate('byte[' & BinaryLen($bData) & ']')
DllStructSetData($tXORBits, 1, $bData)

; Create monochrome icon (32x32)
Local $hIcon = _WinAPI_CreateIcon(0, 32, 32, 1, 1, $tANDBits, $tXORBits)

; Create GUI
GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 128, 128)
GUICtrlCreateIcon('', 0, 48, 48, 32, 32)
GUICtrlSendMsg(-1, $STM_SETIMAGE, 1, $hIcon)
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_CreateIconFromResourceEx

Function Reference

_WinAPI_CreateIconFromResourceEx

Creates an icon or cursor from resource bits describing the icon

#include <WinAPIRes.au3>
_WinAPI_CreateIconFromResourceEx ( $pData, $iSize [, $bIcon = True [, $iXDesiredPixels = 0 [, $iYDesiredPixels = 0 [, $iFlags = 0]]]] )

Parameters

$pData | The icon or cursor resource bits. These bits are typically loaded by calls to the _WinAPI_LookupIconIdFromDirectoryEx() and _WinAPI_LoadResource() functions.
$iSize | The size, in bytes, of the set of bits pointed to by the $pData parameter.
$bIcon | [optional] Specifies whether an icon or a cursor is to be created, valid values: True - An icon is to be created (Default). False - A cursor is to be created.
$iXDesiredPixels | [optional] The desired width, in pixels, of the icon or cursor. If this parameter is zero (Default), the function uses the system metric value to set the width.
$iYDesiredPixels | [optional] The desired height, in pixels, of the icon or cursor. If this parameter is zero (Default), the function uses the system metric value to set the height.
$iFlags | [optional] This parameter can be one or more of the following values. $LR_DEFAULTCOLOR (Default) $LR_DEFAULTSIZE $LR_MONOCHROME $LR_SHARED

Return Value

Success: | Handle to the icon or cursor.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

You should call _WinAPI_DestroyIcon() for icons created with _WinAPI_CreateIconFromResourceEx() function.

Related

_WinAPI_DestroyIcon

See Also

Search CreateIconFromResourceEx in MSDN Library.

Example

#include <APIResConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIRes.au3>

; Load Resources.dll to memory
Local $hInstance = _WinAPI_LoadLibraryEx(@ScriptDir & '\Extras\Resources.dll', $LOAD_LIBRARY_AS_DATAFILE)
If Not $hInstance Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', @ScriptDir & '\Extras\Resources.dll not found.')
    Exit
EndIf

; Load RT_GROUP_ICON resource from Resources.dll library
Local $hResource = _WinAPI_FindResource($hInstance, $RT_GROUP_ICON, 1)
Local $hData = _WinAPI_LoadResource($hInstance, $hResource)
Local $pData = _WinAPI_LockResource($hData)

; Search an integer resource name for the icon that best fits the specified size (48x48)
Local $iIcon = _WinAPI_LookupIconIdFromDirectoryEx($pData, 1, 48, 48)

; Load RT_ICON resource from Resources.dll library
$hResource = _WinAPI_FindResource($hInstance, $RT_ICON, $iIcon)
Local $iSize = _WinAPI_SizeOfResource($hInstance, $hResource)
$hData = _WinAPI_LoadResource($hInstance, $hResource)
$pData = _WinAPI_LockResource($hData)

; Create icon from resource
Local $hIcon = _WinAPI_CreateIconFromResourceEx($pData, $iSize)

; Unload Resources.dll from memory
_WinAPI_FreeLibrary($hInstance)

; Create GUI
GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 128, 128)
GUICtrlCreateIcon('', 0, 40, 40, 48, 48)
GUICtrlSendMsg(-1, $STM_SETIMAGE, 1, $hIcon)
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_ExtractIcon

Function Reference

_WinAPI_ExtractIcon

Extracts an icon from the specified executable file, DLL, or icon file

#include <WinAPIRes.au3>
_WinAPI_ExtractIcon ( $sIcon, $iIndex [, $bSmall = False] )

Parameters

$sIcon | The name of an executable file, DLL, or icon file from which icons will be extracted.
$iIndex | The 0-based index of the icon to extract. If this value is a negative number, the function extracts the icon whose resource identifier is equal to the absolute value of $iIndex.
$bSmall | [optional] Specifies whether to extract a small icon, valid values: True - Extract a small icon. False - Extract a large icon (Default).

Return Value

Success: | the handle to the extracted icon.
Failure: | 0.

Remarks

When you are finished using the icon, destroy it using the _WinAPI_DestroyIcon() function.

Related

_WinAPI_DestroyIcon

See Also

Search ExtractIconEx in MSDN Library.


Function _WinAPI_FileIconInit

Function Reference

_WinAPI_FileIconInit

Initializes or reinitializes the system image list

#include <WinAPIRes.au3>
_WinAPI_FileIconInit ( [$bRestore = True] )

Parameters

$bRestore [optional] Specifies whether to restore the system image cache, valid values:
True - Restore the system image cache from disk (Default).
False - Don't restore.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

If you are using system image lists in your own process, you must call this function at application launch, and in response to a WM_SETTINGCHANGE message when the $SPI_SETNONCLIENTMETRICS flag is set.

See Also

Search FileIconInit in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GUIImageList.au3>
#include <StaticConstants.au3>
#include <WinAPIRes.au3>
#include <WinAPIShPath.au3>

; Initialize system image list
_WinAPI_FileIconInit()

; Retrieve system image list and calculate bitmap size
Local $hImageList = _WinAPI_ShellGetImageList()
If @error Then Exit

Local $iCount = _GUIImageList_GetImageCount($hImageList)
Local $a_iSize = _GUIImageList_GetIconSize($hImageList)
Local $iCX = Sqrt($iCount)
Local $iCY
If $iCX Then
    $iCX = Ceiling($iCX)
    $iCY = Ceiling($iCount / $iCX)
Else
    $iCX = 1
    $iCY = 1
EndIf
Local $W = $iCX * ($a_iSize[0] + 14)
Local $H = $iCY * ($a_iSize[1] + 14)

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), $W, $H)
Local $idPic = GUICtrlCreatePic('', 0, 0, $W, $H)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDC = _WinAPI_GetDC($hPic)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $W, $H)
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap)

; Draw all icons from the system image list into bitmap
Local $iIndex = 0
For $y = 1 To $iCY
    For $x = 1 To $iCX
        _GUIImageList_Draw($hImageList, $iIndex, $hMemDC, ($x - 1) * ($a_iSize[0] + 14) + 7, ($y - 1) * ($a_iSize[0] + 14) + 7)
        $iIndex += 1
        If $iIndex >= $iCount Then
            ExitLoop
        EndIf
    Next
Next

; Release objects
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

; Show GUI
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_GetIconInfoEx

Function Reference

_WinAPI_GetIconInfoEx

Retrieves information about the specified icon or cursor

#include <WinAPIRes.au3>
_WinAPI_GetIconInfoEx ( $hIcon )

Parameters

$hIcon Handle to the icon or cursor. To retrieve information about a standard icon or cursor, use $IDC_* constants.

Return Value

Success: | The array that contains the following information: [0] - A value of 1 specifies an icon; 0 specifies a cursor. [1] - The x-coordinate of the cursor's hot spot. [2] - The y-coordinate of the cursor's hot spot. [3] - A handle to the icon bitmask bitmap. [4] - A handle to the icon color bitmap. [5] - The icon or cursor resource bits. [6] - The fully qualified path of the module. [7] - The fully qualified path of the resource.
Failure: | Sets the @error flag to non-zero.

Remarks

The _WinAPI_GetIconInfoEx() creates bitmaps [3] and [4].
The calling application must manage these bitmaps and delete them when they are no longer necessary.

This function requires Windows Vista or later.

See Also

Search GetIconInfoEx in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIRes.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

Local $hInstance = _WinAPI_LoadLibraryEx(@AutoItExe, $LOAD_LIBRARY_AS_DATAFILE)
Local $hIcon = _WinAPI_LoadImage($hInstance, 99, $IMAGE_ICON, 0, 0, $LR_DEFAULTSIZE)
Local $aInfo = _WinAPI_GetIconInfoEx($hIcon)
If IsArray($aInfo) Then
    ConsoleWrite('Handle: ' & $hIcon & @CRLF)
    ConsoleWrite('Path:   ' & $aInfo[6] & @CRLF)
    ConsoleWrite('ID:     ' & $aInfo[5] & @CRLF)
    For $i = 3 To 4
        _WinAPI_DestroyIcon($aInfo[$i])
    Next
EndIf
_WinAPI_FreeLibrary($hInstance)
_WinAPI_DestroyIcon($hIcon)


Function _WinAPI_LoadIcon

Function Reference

_WinAPI_LoadIcon

Loads the specified icon resource from the executable (.exe) file associated with an application instance

#include <WinAPIRes.au3>
_WinAPI_LoadIcon ( $hInstance, $sName )

Parameters

$hInstance | A handle to an instance of the module whose executable file contains the icon to be loaded.
$sName | The name of the icon resource to be loaded. Alternatively, if $hInstance is 0, it can be one of the following predefined values. $IDI_APPLICATION $IDI_HAND $IDI_QUESTION $IDI_EXCLAMATION $IDI_ASTERISK $IDI_WINLOGO $IDI_SHIELD $IDI_ERROR $IDI_INFORMATION $IDI_WARNING

Return Value

Success: | The icon handle.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

_WinAPI_LoadIcon() loads the icon resource only if it has not been loaded; otherwise, it retrieves a
handle to the existing resource.

_WinAPI_LoadIcon() can only load an icon whose size conforms to the $SM_CXICON and $SM_CYICON system metric
values. Use the _WinAPI_LoadImage() function to load icons of other sizes.

When you are finished using the icon, destroy it using the _WinAPI_DestroyIcon() function.

Related

_WinAPI_DestroyIcon, _WinAPI_LoadImage

See Also

Search LoadIcon in MSDN Library.


Function _WinAPI_LookupIconIdFromDirectoryEx

Function Reference

_WinAPI_LookupIconIdFromDirectoryEx

Searches through icon or cursor data for the icon or cursor that best fits the current display device

#include <WinAPIRes.au3>
_WinAPI_LookupIconIdFromDirectoryEx ( $pData [, $bIcon = True [, $iXDesiredPixels = 0 [, $iYDesiredPixels = 0 [, $iFlags = 0]]]] )

Parameters

$pData | The icon or cursor directory data. Because this function does not validate the resource data, it causes a general protection (GP) fault or returns an undefined value if presbits is not pointing to validresource data.
$bIcon | [optional] Specifies whether an icon or a cursor is sought, valid values: True - The function is searching for an icon (Default). False - The function is searching for a cursor.
$iXDesiredPixels | [optional] The desired width, in pixels, of the icon or cursor. If this parameter is zero (Default), the function uses the system metric value.
$iYDesiredPixels | [optional] The desired height, in pixels, of the icon or cursor. If this parameter is zero (Default), the function uses the system metric value.
$iFlags | [optional] This parameter can be one or more of the following values. $LR_DEFAULTCOLOR (Default) $LR_MONOCHROME

Return Value

Success: | An integer resource identifier for the icon or cursor that best fits the current display device.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

The icon directory is loaded from a resource file with resource type $RT_GROUP_ICON (or $RT_GROUP_CURSOR),
and an integer resource name for the specific icon to be loaded.
_WinAPI_LookupIconIdFromDirectoryEx() returns an integer identifier that is the resource name of the icon that best fits the current display device.

See Also

Search LookupIconIdFromDirectoryEx in MSDN Library.

Example

#include <APIResConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIRes.au3>

; Load Resources.dll to memory
Local $hInstance = _WinAPI_LoadLibraryEx(@ScriptDir & '\Extras\Resources.dll', $LOAD_LIBRARY_AS_DATAFILE)
If Not $hInstance Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', @ScriptDir & '\Extras\Resources.dll not found.')
    Exit
EndIf

; Load RT_GROUP_ICON resource from Resources.dll library
Local $hResource = _WinAPI_FindResource($hInstance, $RT_GROUP_ICON, 1)
Local $hData = _WinAPI_LoadResource($hInstance, $hResource)
Local $pData = _WinAPI_LockResource($hData)

; Search an integer resource name for the icon that best fits the specified size (48x48)
Local $iIcon = _WinAPI_LookupIconIdFromDirectoryEx($pData, 1, 48, 48)

; Load RT_ICON resource from Resources.dll library
$hResource = _WinAPI_FindResource($hInstance, $RT_ICON, $iIcon)
Local $iSize = _WinAPI_SizeOfResource($hInstance, $hResource)
$hData = _WinAPI_LoadResource($hInstance, $hResource)
$pData = _WinAPI_LockResource($hData)

; Create icon from resource
Local $hIcon = _WinAPI_CreateIconFromResourceEx($pData, $iSize)

; Unload Resources.dll from memory
_WinAPI_FreeLibrary($hInstance)

; Create GUI
GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 128, 128)
GUICtrlCreateIcon('', 0, 40, 40, 48, 48)
GUICtrlSendMsg(-1, $STM_SETIMAGE, 1, $hIcon)
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


User Defined Functions

Resources user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIRes.au3>.

User Defined Function | Description
_WinAPI_BeginUpdateResource | Retrieves a handle that can be used to add, delete, or replace resources in a binary module
_WinAPI_EndUpdateResource | Commits or discards a changes of the resources within module
_WinAPI_EnumResourceLanguages | Enumerates a language-specific resources, of the specified type and name, associated with a binary module
_WinAPI_EnumResourceNames | Enumerates the resources of a specified type within a binary module
_WinAPI_EnumResourceTypes | Enumerates the resource types within a binary module
_WinAPI_FindResource | Determines the location of a resource with the specified type and name in the specified module
_WinAPI_FindResourceEx | Determines the location of the resource with the specified type, name, and language in the specified module
_WinAPI_FreeResource | Decrements (decreases by one) the reference count of a loaded resource
_WinAPI_GetFileVersionInfo | Retrieves version information for the specified file
_WinAPI_LoadIndirectString | Extracts the string from the specified resource when given an indirect string
_WinAPI_LoadResource | Loads the specified resource into global memory
_WinAPI_LoadStringEx | Loads a string resource for the specified language from the specified module
_WinAPI_LockResource | Locks the specified resource in memory
_WinAPI_SizeOfResource | Returns the size, in bytes, of the specified resource
_WinAPI_UpdateResource | Adds, deletes, or replaces a resource in a portable executable (PE) file
_WinAPI_VerQueryRoot | Retrieves the fixed version information from the specified version-information resource
_WinAPI_VerQueryValue | Retrieves the non-fixed (strings) version information from the specified version-information resource
_WinAPI_VerQueryValueEx | Retrieves the text information from the version-information resource of the specified binary module


Function _WinAPI_BeginUpdateResource

Function Reference

_WinAPI_BeginUpdateResource

Retrieves a handle that can be used to add, delete, or replace resources in a binary module

#include <WinAPIRes.au3>
_WinAPI_BeginUpdateResource ( $sFilePath [, $bDelete = False] )

Parameters

$sFilePath | The binary file in which to update resources. An application must be able to obtain write-access to this file; the file referenced by $sFilePath cannot be currently executing.
$bDelete | [optional] Specifies whether to delete existing resources, valid values: True - The resources are deleted and the updated file includes only resources added with the _WinAPI_UpdateResource(). False - The updated file includes existing resources (Default).

Return Value

Success: | Handle that can be used by the _WinAPI_UpdateResource() and _WinAPI_EndUpdateResource() functions.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

It is recommended that the resource file is not loaded before this function is called. However, if that file is already loaded, it will not cause an error to be returned.

Related

_WinAPI_EndUpdateResource, _WinAPI_UpdateResource

See Also

Search BeginUpdateResource in MSDN Library.

Example

#include <APIResConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIRes.au3>

Global Const $g_sExe = @TempDir & '\MyProg.exe'

Global Const $tagICONRESDIR = 'byte Width;byte Height;byte ColorCount;byte Reserved;ushort Planes;ushort BitCount;dword BytesInRes;ushort IconId;'
Global Const $tagNEWHEADER = 'ushort Reserved;ushort ResType;ushort ResCount;' ; & $tagICONRESDIR[ResCount]

; Select icon to update resource
Local $sIcon = FileOpenDialog('Select File', @ScriptDir & '\Extras', 'Icon Files (*.ico)', 1 + 2, 'Script.ico')
If Not $sIcon Then
    Exit
EndIf

; Create simple executable file (MyProg.exe) in which will be added icon
If Not FileCopy(@ScriptDir & '\Extras\MyProg.exe', $g_sExe, $FC_OVERWRITE) Then
    If MsgBox(BitOR($MB_OKCANCEL, $MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to copy MyProg.exe or file already exist in the current directory.') <> 1 Then
        Exit
    EndIf
    FileCopy(@ScriptDir & '\Extras\MyProg.exe', $g_sExe, $FC_OVERWRITE)
EndIf

Local $iError = 1
Do
    ; Begin update resources
    Local $hUpdate = _WinAPI_BeginUpdateResource($g_sExe)
    If @error Then
        ExitLoop
    EndIf
    ; Read .ico file as raw binary data into the structure
    Local $tIcon = DllStructCreate('ushort Reserved;ushort Type;ushort Count;byte[' & (FileGetSize($sIcon) - 6) & ']')
    Local $hFile = _WinAPI_CreateFile($sIcon, 2, 2)
    If Not $hFile Then
        ExitLoop
    EndIf
    Local $iBytes = 0
    _WinAPI_ReadFile($hFile, $tIcon, DllStructGetSize($tIcon), $iBytes)
    _WinAPI_CloseHandle($hFile)
    If Not $iBytes Then
        ExitLoop
    EndIf
    ; Add all icons from .ico file into the RT_ICON resources identified as 400, 401, etc., and fill group icons structure
    Local $iCount = DllStructGetData($tIcon, 'Count')
    Local $tDir = DllStructCreate($tagNEWHEADER & 'byte[' & (14 * $iCount) & ']')
    Local $pDir = DllStructGetPtr($tDir)
    DllStructSetData($tDir, 'Reserved', 0)
    DllStructSetData($tDir, 'ResType', 1)
    DllStructSetData($tDir, 'ResCount', $iCount)
    Local $tInfo, $iSize, $tData, $iID = 400
    Local $pIcon = DllStructGetPtr($tIcon)
    For $i = 1 To $iCount
        $tInfo = DllStructCreate('byte Width;byte Heigth;byte Colors;byte Reserved;ushort Planes;ushort BPP;dword Size;dword Offset', $pIcon + 6 + 16 * ($i - 1))
        $iSize = DllStructGetData($tInfo, 'Size')
        If Not _WinAPI_UpdateResource($hUpdate, $RT_ICON, $iID, 0, $pIcon + DllStructGetData($tInfo, 'Offset'), $iSize) Then
            ExitLoop 2
        EndIf
        $tData = DllStructCreate($tagICONRESDIR, $pDir + 6 + 14 * ($i - 1))
        DllStructSetData($tData, 'Width', DllStructGetData($tInfo, 'Width'))
        DllStructSetData($tData, 'Height', DllStructGetData($tInfo, 'Heigth'))
        DllStructSetData($tData, 'ColorCount', DllStructGetData($tInfo, 'Colors'))
        DllStructSetData($tData, 'Reserved', 0)
        DllStructSetData($tData, 'Planes', DllStructGetData($tInfo, 'Planes'))
        DllStructSetData($tData, 'BitCount', DllStructGetData($tInfo, 'BPP'))
        DllStructSetData($tData, 'BytesInRes', $iSize)
        DllStructSetData($tData, 'IconId', $iID)
        $iID += 1
    Next
    ; Add new RT_GROUP_ICON resource named as "MAINICON"
    If Not _WinAPI_UpdateResource($hUpdate, $RT_GROUP_ICON, 'MAINICON', 0, $pDir, DllStructGetSize($tDir)) Then
        ExitLoop
    EndIf
    $iError = 0
Until 1

; Save or discard changes of the resources within an executable file
If Not _WinAPI_EndUpdateResource($hUpdate, $iError) Then
    $iError = 1
EndIf

; Show message if an error occurred
If $iError Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to change resources.')
EndIf


Function _WinAPI_EndUpdateResource

Function Reference

_WinAPI_EndUpdateResource

Commits or discards a changes of the resources within module

#include <WinAPIRes.au3>
_WinAPI_EndUpdateResource ( $hUpdate [, $bDiscard = False] )

Parameters

$hUpdate | A module handle returned by the _WinAPI_BeginUpdateResource(), and used by _WinAPI_UpdateResource(), referencing the file to be updated.
$bDiscard | [optional] Specifies whether to write the resource updates to the file, valid values: True - The changes are discarded. False - The changes are made: the resource updates will take effect (Default).

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Related

_WinAPI_BeginUpdateResource

See Also

Search EndUpdateResource in MSDN Library.

Example

#include <APIResConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIRes.au3>

Global Const $g_sExe = @TempDir & '\MyProg.exe'

Global Const $tagICONRESDIR = 'byte Width;byte Height;byte ColorCount;byte Reserved;ushort Planes;ushort BitCount;dword BytesInRes;ushort IconId;'
Global Const $tagNEWHEADER = 'ushort Reserved;ushort ResType;ushort ResCount;' ; & $tagICONRESDIR[ResCount]

; Select icon to update resource
Local $sIcon = FileOpenDialog('Select File', @ScriptDir & '\Extras', 'Icon Files (*.ico)', 1 + 2, 'Script.ico')
If Not $sIcon Then
    Exit
EndIf

; Create simple executable file (MyProg.exe) in which will be added icon
If Not FileCopy(@ScriptDir & '\Extras\MyProg.exe', $g_sExe, $FC_OVERWRITE) Then
    If MsgBox(BitOR($MB_OKCANCEL, $MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to copy MyProg.exe or file already exist in the current directory.') <> 1 Then
        Exit
    EndIf
    FileCopy(@ScriptDir & '\Extras\MyProg.exe', $g_sExe, $FC_OVERWRITE)
EndIf

Local $iError = 1
Do
    ; Begin update resources
    Local $hUpdate = _WinAPI_BeginUpdateResource($g_sExe)
    If @error Then
        ExitLoop
    EndIf
    ; Read .ico file as raw binary data into the structure
    Local $tIcon = DllStructCreate('ushort Reserved;ushort Type;ushort Count;byte[' & (FileGetSize($sIcon) - 6) & ']')
    Local $hFile = _WinAPI_CreateFile($sIcon, 2, 2)
    If Not $hFile Then
        ExitLoop
    EndIf
    Local $iBytes = 0
    _WinAPI_ReadFile($hFile, $tIcon, DllStructGetSize($tIcon), $iBytes)
    _WinAPI_CloseHandle($hFile)
    If Not $iBytes Then
        ExitLoop
    EndIf
    ; Add all icons from .ico file into the RT_ICON resources identified as 400, 401, etc., and fill group icons structure
    Local $iCount = DllStructGetData($tIcon, 'Count')
    Local $tDir = DllStructCreate($tagNEWHEADER & 'byte[' & (14 * $iCount) & ']')
    Local $pDir = DllStructGetPtr($tDir)
    DllStructSetData($tDir, 'Reserved', 0)
    DllStructSetData($tDir, 'ResType', 1)
    DllStructSetData($tDir, 'ResCount', $iCount)
    Local $tInfo, $iSize, $tData, $iID = 400
    Local $pIcon = DllStructGetPtr($tIcon)
    For $i = 1 To $iCount
        $tInfo = DllStructCreate('byte Width;byte Heigth;byte Colors;byte Reserved;ushort Planes;ushort BPP;dword Size;dword Offset', $pIcon + 6 + 16 * ($i - 1))
        $iSize = DllStructGetData($tInfo, 'Size')
        If Not _WinAPI_UpdateResource($hUpdate, $RT_ICON, $iID, 0, $pIcon + DllStructGetData($tInfo, 'Offset'), $iSize) Then
            ExitLoop 2
        EndIf
        $tData = DllStructCreate($tagICONRESDIR, $pDir + 6 + 14 * ($i - 1))
        DllStructSetData($tData, 'Width', DllStructGetData($tInfo, 'Width'))
        DllStructSetData($tData, 'Height', DllStructGetData($tInfo, 'Heigth'))
        DllStructSetData($tData, 'ColorCount', DllStructGetData($tInfo, 'Colors'))
        DllStructSetData($tData, 'Reserved', 0)
        DllStructSetData($tData, 'Planes', DllStructGetData($tInfo, 'Planes'))
        DllStructSetData($tData, 'BitCount', DllStructGetData($tInfo, 'BPP'))
        DllStructSetData($tData, 'BytesInRes', $iSize)
        DllStructSetData($tData, 'IconId', $iID)
        $iID += 1
    Next
    ; Add new RT_GROUP_ICON resource named as "MAINICON"
    If Not _WinAPI_UpdateResource($hUpdate, $RT_GROUP_ICON, 'MAINICON', 0, $pDir, DllStructGetSize($tDir)) Then
        ExitLoop
    EndIf
    $iError = 0
Until 1

; Save or discard changes of the resources within an executable file
If Not _WinAPI_EndUpdateResource($hUpdate, $iError) Then
    $iError = 1
EndIf

; Show message if an error occurred
If $iError Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to change resources.')
EndIf


Function _WinAPI_EnumResourceLanguages

Function Reference

_WinAPI_EnumResourceLanguages

Enumerates a language-specific resources, of the specified type and name, associated with a binary module

#include <WinAPIRes.au3>
_WinAPI_EnumResourceLanguages ( $hModule, $sType, $sName )

Parameters

$hModule | The handle to a module to be searched. Also, this parameter can specify the name of the module to load, it must be a full or relative path. If this parameter is 0 or an empty string, that is equivalent to passing in a handle to the module used to create the current process.
$sType | The type of resource for which the language is being enumerated. It can be a string or an integer value representing a predefined resource type.
$sName | The name of the resource for which the language is being enumerated. It can be a string or an integer value representing a predefined resource type.

Return Value

Success: | The array of the language identifiers for the specified resource type and name.
Failure: | Sets the @error flag to non-zero.

See Also

Search EnumResourceLanguages in MSDN Library.

Example

#include <APIResConstants.au3>
#include <Array.au3>
#include <WinAPIRes.au3>

Local $aData = _WinAPI_EnumResourceLanguages(@SystemDir & '\shell32.dll', $RT_DIALOG, 1003)

_ArrayDisplay($aData, '_WinAPI_EnumResourceLanguages')


Function _WinAPI_EnumResourceNames

Function Reference

_WinAPI_EnumResourceNames

Enumerates the resources of a specified type within a binary module

#include <WinAPIRes.au3>
_WinAPI_EnumResourceNames ( $hModule, $sType )

Parameters

$hModule | The handle to a module to be searched. Also, this parameter can specify the name of the module to load, it must be a full or relative path. If this parameter is 0 or an empty string, that is equivalent to passing in a handle to the module used to create the current process.
$sType | The type of the resource for which the name is being enumerated. It can be a string or an integer value representing a predefined resource type.

Return Value

Success: | The array of the names for the specified resource type.
Failure: | Sets the @error flag to non-zero.

See Also

Search EnumResourceNames in MSDN Library.

Example

#include <APIResConstants.au3>
#include <Array.au3>
#include <WinAPIRes.au3>

Local $aData = _WinAPI_EnumResourceNames(@SystemDir & '\shell32.dll', $RT_DIALOG)

_ArrayDisplay($aData, '_WinAPI_EnumResourceNames')


Function _WinAPI_EnumResourceTypes

Function Reference

_WinAPI_EnumResourceTypes

Enumerates the resource types within a binary module

#include <WinAPIRes.au3>
_WinAPI_EnumResourceTypes ( $hModule )

Parameters

$hModule The handle to a module to be searched.
Also, this parameter can specify the name of the module to load, it must be a full or relative path.
If this parameter is 0 or an empty string, that is equivalent to passing in a handle to the module used to create the current process.

Return Value

Success: | The array of the types of the resources for the specified module.
Failure: | Sets the @error flag to non-zero.

See Also

Search EnumResourceTypes in MSDN Library.

Example

#include <Array.au3>
#include <WinAPIRes.au3>

Local $aData = _WinAPI_EnumResourceTypes(@SystemDir & '\shell32.dll')

_ArrayDisplay($aData, '_WinAPI_EnumResourceTypes')


Function _WinAPI_FindResource

Function Reference

_WinAPI_FindResource

Determines the location of a resource with the specified type and name in the specified module

#include <WinAPIRes.au3>
_WinAPI_FindResource ( $hInstance, $sType, $sName )

Parameters

$hInstance | Handle to the module whose executable file contains the resource. A value of 0 specifies the module handle associated with the image file that the operating system used to create the current process.
$sType | The type of the resource. This parameter can be string or integer value.
$sName | The name of the resource. This parameter can be string or integer value.

Return Value

Success: | Handle to the specified resource's information block. To obtain a handle to the resource, pass this handle to the _WinAPI_LoadResource() function.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

If the first character of the string of the $sName or $sType parameter is a pound sign (#), the remaining characters represent a decimal number that specifies the integer identifier of the resource's name or type.
For example, the string "#258" represents the integer identifier 258.

To reduce the amount of memory required for a resource, an application should refer to it by integer identifier instead of by name.

An application can use _WinAPI_FindResource() to find any type of resource, but this function should be used only if the application must access the binary resource data when making subsequent calls to _WinAPI_LockResource().

Related

_WinAPI_LoadResource, _WinAPI_LockResource

See Also

Search FindResource in MSDN Library.

Example

#include <APIMiscConstants.au3>
#include <APIResConstants.au3>
#include <GUIConstantsEx.au3>
#include <Memory.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIMisc.au3>
#include <WinAPIRes.au3>

Local Const $sJpg = @TempDir & '\~Tech.jpg'

; Load Resources.dll to memory
Local $hInstance = _WinAPI_LoadLibraryEx(@ScriptDir & '\Extras\Resources.dll', $LOAD_LIBRARY_AS_DATAFILE)
If Not $hInstance Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', @ScriptDir & '\Extras\Resources.dll not found.')
    Exit
EndIf

; Load JPEG resource from Resources.dll library
Local $hResource = _WinAPI_FindResource($hInstance, 'JPEG', 1)
Local $iSize = _WinAPI_SizeOfResource($hInstance, $hResource)
Local $hData = _WinAPI_LoadResource($hInstance, $hResource)
Local $pData = _WinAPI_LockResource($hData)

; Save resource to .jpg file
Local $hFile = FileOpen($sJpg, 2 + 16)
Local $tData = DllStructCreate('byte[' & $iSize & ']', $pData)
FileWrite($hFile, DllStructGetData($tData, 1))
FileClose($hFile)

; Load FONT resource from Resources.dll library
$hResource = _WinAPI_FindResource($hInstance, $RT_FONT, 'TECHNOVIA_CAPS')
$iSize = _WinAPI_SizeOfResource($hInstance, $hResource)
$hData = _WinAPI_LoadResource($hInstance, $hResource)
$pData = _WinAPI_LockResource($hData)

; Add font from a memory to the system
Local $hFont = _WinAPI_AddFontMemResourceEx($pData, $iSize)

; Load SOUND resource from Resources.dll library
$hResource = _WinAPI_FindResource($hInstance, 'SOUND', 1)
$iSize = _WinAPI_SizeOfResource($hInstance, $hResource)
$hData = _WinAPI_LoadResource($hInstance, $hResource)
$pData = _WinAPI_LockResource($hData)

; Copy WAV to memory for use later
Local $hWave = _MemGlobalAlloc($iSize, $GMEM_MOVEABLE)
Local $pWave = _MemGlobalLock($hWave)
_MemMoveMemory($pData, $pWave, $iSize)
; _MemGlobalUnlock($hWave)

; Load STRING resource from Resources.dll library
Local $sText = _WinAPI_LoadString($hInstance, 1)

; Unload Resources.dll from memory
_WinAPI_FreeLibrary($hInstance)

; Create GUI
GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 350, 350)
GUICtrlCreatePic($sJpg, 0, 0, 350, 350)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateLabel($sText, 10, 18, 330, 36, $SS_CENTER)
GUICtrlSetFont(-1, 30, -1, -1, 'Technovia Caps')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xF06000)
Local $idButton = GUICtrlCreateButton('Play Sound', 125, 316, 100, 23)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            _WinAPI_PlaySound($pWave, BitOR($SND_ASYNC, $SND_MEMORY, $SND_NOWAIT))
    EndSwitch
WEnd

; Free resources
_WinAPI_RemoveFontMemResourceEx($hFont)
FileDelete($sJpg)


Function _WinAPI_FindResourceEx

Function Reference

_WinAPI_FindResourceEx

Determines the location of the resource with the specified type, name, and language in the specified module

#include <WinAPIRes.au3>
_WinAPI_FindResourceEx ( $hInstance, $sType, $sName, $iLanguage )

Parameters

$hInstance | Handle to the module whose executable file contains the resource. A value of 0 specifies the module handle associated with the image file that the operating system used to create the current process.
$sType | The type of the resource. This parameter can be string or integer value.
$sName | The name of the resource. This parameter can be string or integer value.
$iLanguage | The language of the resource.

Return Value

Success: | Handle to the specified resource's information block. To obtain a handle to the resource, pass this handle to the _WinAPI_LoadResource() function.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

If the first character of the string of the $sName or $sType parameter is a pound sign (#), the remaining characters represent a decimal number that specifies the integer identifier of the resource's name or type.
For example, the string "#258" represents the integer identifier 258.

To reduce the amount of memory required for a resource, an application should refer to it by integer identifier instead of by name.

An application can use _WinAPI_FindResource() to find any type of resource, but this function should be used only if the application must access the binary resource data when making subsequent calls to _WinAPI_LockResource().

Related

_WinAPI_FindResource, _WinAPI_LoadResource, _WinAPI_LockResource

See Also

Search FindResourceEx in MSDN Library.


Function _WinAPI_FreeResource

Function Reference

_WinAPI_FreeResource

Decrements (decreases by one) the reference count of a loaded resource

#include <WinAPIRes.au3>
_WinAPI_FreeResource ( $hData )

Parameters

$hData Handle of the resource was created by _WinAPI_LoadResource().

Return Value

Success: | True
Failure: | False

Remarks

The reference count for a resource is incremented (increased by one) each time an application calls the _WinAPI_LoadResource() function for the resource.
This function is obsolete and is only supported for backward compatibility with 16-bit Microsoft Windows.
For 32-bit Windows applications, it is not necessary to free the resources loaded using function _WinAPI_LoadResource().

Related

_WinAPI_LoadResource

See Also

Search FreeResource in MSDN Library.


Function _WinAPI_GetFileVersionInfo

Function Reference

_WinAPI_GetFileVersionInfo

Retrieves version information for the specified file

#include <WinAPIRes.au3>
_WinAPI_GetFileVersionInfo ( $sFilePath, ByRef $pBuffer [, $iFlags = 0] )

Parameters

$sFilePath | The name of the file.
$pBuffer | Returns a pointer to a memory block (buffer) that receives the file-version information. Optionaly, you can set this parameter to 0 before function call, then the function will allocate the required memory block itself. Otherwise, it must be a valid memory pointer returned by the _WinAPI_CreateBuffer() function, or by previously calling this function.
$iFlags | [optional] The flags that controls which MUI DLLs (if any) from which the version resource is extracted. It can be 0 or more of the following values (valid only for Windows Vista or later). $FILE_VER_GET_LOCALISED $FILE_VER_GET_NEUTRAL $FILE_VER_GET_PREFETCHED

Return Value

Success: | The number of bytes copied to the buffer.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

When you no longer need the buffer allocated by this function, you must call the _WinAPI_FreeMemory() function (do not use any other memory routines) to release occupied memory.

Related

_WinAPI_CreateBuffer, _WinAPI_FreeMemory

See Also

Search GetFileVersionInfo in MSDN Library.


Function _WinAPI_LoadIndirectString

Function Reference

_WinAPI_LoadIndirectString

Extracts the string from the specified resource when given an indirect string

#include <WinAPIRes.au3>
_WinAPI_LoadIndirectString ( $sStrIn )

Parameters

$sStrIn The input indirect string.

Return Value

Success: | The output string.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

If the string is an indirect string (a string beginning with the "@" symbol), it is in the following form.

@filename,resource

The string is extracted from the file named, using the resource value as a locator. If the resource value is
zero or greater, the number becomes the index of the string in the binary file. If the number is negative,
it becomes a resource ID. An indirect string can be appended with a version modifier, as shown here:

@filename,resource;v2

This form can be used when a string is changed but still uses the same index or resource ID as the old string.
Without a version modifier, the Multilingual User Interface (MUI) cache would not recognize that the string had
changed and would continue to use the old value. By appending the version modifier, the value is seen as a
new resource and is added to the cache. Note that it is recommended that you use a new resource ID or index
for a new string, and use a version modifier only when that is not possible.

If the input string is not an indirect string, the function returns an input string unchanged.

See Also

Search SHLoadIndirectString in MSDN Library.

Example

#include <WinAPIRes.au3>

ConsoleWrite(_WinAPI_LoadIndirectString('@"' & @AutoItExe & '",-122') & @CRLF)


Function _WinAPI_LoadResource

Function Reference

_WinAPI_LoadResource

Loads the specified resource into global memory

#include <WinAPIRes.au3>
_WinAPI_LoadResource ( $hInstance, $hResource )

Parameters

$hInstance Handle to the module whose executable file contains the resource. If this parameter is 0, the system
loads the resource from the module that was used to create the current process.
$hResource Handle to the resource to be loaded. This handle is returned by the _WinAPI_FindResource()
or _WinAPI_FindResourceEx() function.

Return Value

Success: | Handle to the data associated with the resource.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

To obtain a pointer to the resource data, call the _WinAPI_LockResource() function.

Related

_WinAPI_FindResource, _WinAPI_FindResourceEx, _WinAPI_LockResource

See Also

Search LoadResource in MSDN Library.

Example

#include <APIMiscConstants.au3>
#include <APIResConstants.au3>
#include <GUIConstantsEx.au3>
#include <Memory.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIMisc.au3>
#include <WinAPIRes.au3>

Local Const $sJpg = @TempDir & '\~Tech.jpg'

; Load Resources.dll to memory
Local $hInstance = _WinAPI_LoadLibraryEx(@ScriptDir & '\Extras\Resources.dll', $LOAD_LIBRARY_AS_DATAFILE)
If Not $hInstance Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', @ScriptDir & '\Extras\Resources.dll not found.')
    Exit
EndIf

; Load JPEG resource from Resources.dll library
Local $hResource = _WinAPI_FindResource($hInstance, 'JPEG', 1)
Local $iSize = _WinAPI_SizeOfResource($hInstance, $hResource)
Local $hData = _WinAPI_LoadResource($hInstance, $hResource)
Local $pData = _WinAPI_LockResource($hData)

; Save resource to .jpg file
Local $hFile = FileOpen($sJpg, 2 + 16)
Local $tData = DllStructCreate('byte[' & $iSize & ']', $pData)
FileWrite($hFile, DllStructGetData($tData, 1))
FileClose($hFile)

; Load FONT resource from Resources.dll library
$hResource = _WinAPI_FindResource($hInstance, $RT_FONT, 'TECHNOVIA_CAPS')
$iSize = _WinAPI_SizeOfResource($hInstance, $hResource)
$hData = _WinAPI_LoadResource($hInstance, $hResource)
$pData = _WinAPI_LockResource($hData)

; Add font from a memory to the system
Local $hFont = _WinAPI_AddFontMemResourceEx($pData, $iSize)

; Load SOUND resource from Resources.dll library
$hResource = _WinAPI_FindResource($hInstance, 'SOUND', 1)
$iSize = _WinAPI_SizeOfResource($hInstance, $hResource)
$hData = _WinAPI_LoadResource($hInstance, $hResource)
$pData = _WinAPI_LockResource($hData)

; Copy WAV to memory for use later
Local $hWave = _MemGlobalAlloc($iSize, $GMEM_MOVEABLE)
Local $pWave = _MemGlobalLock($hWave)
_MemMoveMemory($pData, $pWave, $iSize)
; _MemGlobalUnlock($hWave)

; Load STRING resource from Resources.dll library
Local $sText = _WinAPI_LoadString($hInstance, 1)

; Unload Resources.dll from memory
_WinAPI_FreeLibrary($hInstance)

; Create GUI
GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 350, 350)
GUICtrlCreatePic($sJpg, 0, 0, 350, 350)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateLabel($sText, 10, 18, 330, 36, $SS_CENTER)
GUICtrlSetFont(-1, 30, -1, -1, 'Technovia Caps')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xF06000)
Local $idButton = GUICtrlCreateButton('Play Sound', 125, 316, 100, 23)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            _WinAPI_PlaySound($pWave, BitOR($SND_ASYNC, $SND_MEMORY, $SND_NOWAIT))
    EndSwitch
WEnd

; Free resources
_WinAPI_RemoveFontMemResourceEx($hFont)
FileDelete($sJpg)


Function _WinAPI_LoadStringEx

Function Reference

_WinAPI_LoadStringEx

Loads a string resource for the specified language from the specified module

#include <WinAPIRes.au3>
_WinAPI_LoadStringEx ( $hModule, $iID [, $iLanguage = $LOCALE_USER_DEFAULT] )

Parameters

$hModule | A handle to an instance of the module whose executable file contains the string resource. Also, this parameter can specify the name of the module to load, it must be a full or relative path. If this parameter is 0 or an empty string, that is equivalent to passing in a handle to the module used to create the current process.
$iID | The identifier of the string to be loaded.
$iLanguage | [optional] The language identifier of the string resource of interest. To retrieve string for user default language set this parameter to $LOCALE_USER_DEFAULT (Default).

Return Value

Success: | The string.
Failure: | Empty string and sets the @error flag to non-zero.

Example

#include <APILocaleConstants.au3>
#include <APIResConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPILocale.au3>
#include <WinAPIRes.au3>

Local $hInstance = _WinAPI_LoadLibraryEx(@ScriptDir & '\Extras\Resources.dll', $LOAD_LIBRARY_AS_DATAFILE)
If Not $hInstance Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', @ScriptDir & '\Extras\Resources.dll not found.')
    Exit
EndIf

; Why is the resource name for the string with ID = 6000 is 376? 6000 / 16 + 1 = 376
Local $aData = _WinAPI_EnumResourceLanguages($hInstance, $RT_STRING, 376)
If IsArray($aData) Then
    For $i = 1 To $aData[0]
        ConsoleWrite(StringFormat('%-10s - %s', _WinAPI_GetLocaleInfo($aData[$i], $LOCALE_SENGLANGUAGE), _WinAPI_LoadStringEx($hInstance, 6000, $aData[$i])) & @CRLF)
    Next
EndIf


Function _WinAPI_LockResource

Function Reference

_WinAPI_LockResource

Locks the specified resource in memory

#include <WinAPIRes.au3>
_WinAPI_LockResource ( $hData )

Parameters

$hData Handle to the resource to be locked. The _WinAPI_LoadResource() function returns this handle. Do not
pass any value as a parameter other than a successful return value from the LoadResource function.

Return Value

Success: | Pointer to the first byte of the resource.
Failure: | 0.

Remarks

The pointer returned by this function is valid until the module containing the resource is unloaded. It is not
necessary to unlock resources because the system automatically deletes them when the process that created
them terminates.

Do not try to lock a resource by using the handle returned by the _WinAPI_FindResource() or _WinAPI_FindResourceEx()
function. Such a handle points to random data.

Note _WinAPI_LockResource() does not actually lock memory; it is just used to obtain a pointer to the memory
containing the resource data. The name of the function comes from versions prior to Windows XP, when it was
used to lock a global memory block allocated by _WinAPI_LoadResource().

Related

_WinAPI_FindResource, _WinAPI_FindResourceEx, _WinAPI_LoadResource, _WinAPI_UnlockFile

See Also

Search LockResource in MSDN Library.

Example

#include <APIMiscConstants.au3>
#include <APIResConstants.au3>
#include <GUIConstantsEx.au3>
#include <Memory.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIMisc.au3>
#include <WinAPIRes.au3>

Local Const $sJpg = @TempDir & '\~Tech.jpg'

; Load Resources.dll to memory
Local $hInstance = _WinAPI_LoadLibraryEx(@ScriptDir & '\Extras\Resources.dll', $LOAD_LIBRARY_AS_DATAFILE)
If Not $hInstance Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', @ScriptDir & '\Extras\Resources.dll not found.')
    Exit
EndIf

; Load JPEG resource from Resources.dll library
Local $hResource = _WinAPI_FindResource($hInstance, 'JPEG', 1)
Local $iSize = _WinAPI_SizeOfResource($hInstance, $hResource)
Local $hData = _WinAPI_LoadResource($hInstance, $hResource)
Local $pData = _WinAPI_LockResource($hData)

; Save resource to .jpg file
Local $hFile = FileOpen($sJpg, 2 + 16)
Local $tData = DllStructCreate('byte[' & $iSize & ']', $pData)
FileWrite($hFile, DllStructGetData($tData, 1))
FileClose($hFile)

; Load FONT resource from Resources.dll library
$hResource = _WinAPI_FindResource($hInstance, $RT_FONT, 'TECHNOVIA_CAPS')
$iSize = _WinAPI_SizeOfResource($hInstance, $hResource)
$hData = _WinAPI_LoadResource($hInstance, $hResource)
$pData = _WinAPI_LockResource($hData)

; Add font from a memory to the system
Local $hFont = _WinAPI_AddFontMemResourceEx($pData, $iSize)

; Load SOUND resource from Resources.dll library
$hResource = _WinAPI_FindResource($hInstance, 'SOUND', 1)
$iSize = _WinAPI_SizeOfResource($hInstance, $hResource)
$hData = _WinAPI_LoadResource($hInstance, $hResource)
$pData = _WinAPI_LockResource($hData)

; Copy WAV to memory for use later
Local $hWave = _MemGlobalAlloc($iSize, $GMEM_MOVEABLE)
Local $pWave = _MemGlobalLock($hWave)
_MemMoveMemory($pData, $pWave, $iSize)
; _MemGlobalUnlock($hWave)

; Load STRING resource from Resources.dll library
Local $sText = _WinAPI_LoadString($hInstance, 1)

; Unload Resources.dll from memory
_WinAPI_FreeLibrary($hInstance)

; Create GUI
GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 350, 350)
GUICtrlCreatePic($sJpg, 0, 0, 350, 350)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateLabel($sText, 10, 18, 330, 36, $SS_CENTER)
GUICtrlSetFont(-1, 30, -1, -1, 'Technovia Caps')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xF06000)
Local $idButton = GUICtrlCreateButton('Play Sound', 125, 316, 100, 23)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            _WinAPI_PlaySound($pWave, BitOR($SND_ASYNC, $SND_MEMORY, $SND_NOWAIT))
    EndSwitch
WEnd

; Free resources
_WinAPI_RemoveFontMemResourceEx($hFont)
FileDelete($sJpg)


Function _WinAPI_SizeOfResource

Function Reference

_WinAPI_SizeOfResource

Returns the size, in bytes, of the specified resource

#include <WinAPIRes.au3>
_WinAPI_SizeOfResource ( $hInstance, $hResource )

Parameters

$hInstance | Handle to the module whose executable file contains the resource.
$hResource | Handle to the resource. This handle must be created by using the _WinAPI_FindResource() or _WinAPI_FindResourceEx() function.

Return Value

Success: | The number of bytes in the resource.
Failure: | 0.

Related

_WinAPI_FindResource, _WinAPI_FindResourceEx

See Also

Search SizeofResource in MSDN Library.

Example

#include <APIMiscConstants.au3>
#include <APIResConstants.au3>
#include <GUIConstantsEx.au3>
#include <Memory.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIMisc.au3>
#include <WinAPIRes.au3>

Local Const $sJpg = @TempDir & '\~Tech.jpg'

; Load Resources.dll to memory
Local $hInstance = _WinAPI_LoadLibraryEx(@ScriptDir & '\Extras\Resources.dll', $LOAD_LIBRARY_AS_DATAFILE)
If Not $hInstance Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', @ScriptDir & '\Extras\Resources.dll not found.')
    Exit
EndIf

; Load JPEG resource from Resources.dll library
Local $hResource = _WinAPI_FindResource($hInstance, 'JPEG', 1)
Local $iSize = _WinAPI_SizeOfResource($hInstance, $hResource)
Local $hData = _WinAPI_LoadResource($hInstance, $hResource)
Local $pData = _WinAPI_LockResource($hData)

; Save resource to .jpg file
Local $hFile = FileOpen($sJpg, 2 + 16)
Local $tData = DllStructCreate('byte[' & $iSize & ']', $pData)
FileWrite($hFile, DllStructGetData($tData, 1))
FileClose($hFile)

; Load FONT resource from Resources.dll library
$hResource = _WinAPI_FindResource($hInstance, $RT_FONT, 'TECHNOVIA_CAPS')
$iSize = _WinAPI_SizeOfResource($hInstance, $hResource)
$hData = _WinAPI_LoadResource($hInstance, $hResource)
$pData = _WinAPI_LockResource($hData)

; Add font from a memory to the system
Local $hFont = _WinAPI_AddFontMemResourceEx($pData, $iSize)

; Load SOUND resource from Resources.dll library
$hResource = _WinAPI_FindResource($hInstance, 'SOUND', 1)
$iSize = _WinAPI_SizeOfResource($hInstance, $hResource)
$hData = _WinAPI_LoadResource($hInstance, $hResource)
$pData = _WinAPI_LockResource($hData)

; Copy WAV to memory for use later
Local $hWave = _MemGlobalAlloc($iSize, $GMEM_MOVEABLE)
Local $pWave = _MemGlobalLock($hWave)
_MemMoveMemory($pData, $pWave, $iSize)
; _MemGlobalUnlock($hWave)

; Load STRING resource from Resources.dll library
Local $sText = _WinAPI_LoadString($hInstance, 1)

; Unload Resources.dll from memory
_WinAPI_FreeLibrary($hInstance)

; Create GUI
GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 350, 350)
GUICtrlCreatePic($sJpg, 0, 0, 350, 350)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateLabel($sText, 10, 18, 330, 36, $SS_CENTER)
GUICtrlSetFont(-1, 30, -1, -1, 'Technovia Caps')
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xF06000)
Local $idButton = GUICtrlCreateButton('Play Sound', 125, 316, 100, 23)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            _WinAPI_PlaySound($pWave, BitOR($SND_ASYNC, $SND_MEMORY, $SND_NOWAIT))
    EndSwitch
WEnd

; Free resources
_WinAPI_RemoveFontMemResourceEx($hFont)
FileDelete($sJpg)


Function _WinAPI_UpdateResource

Function Reference

_WinAPI_UpdateResource

Adds, deletes, or replaces a resource in a portable executable (PE) file

#include <WinAPIRes.au3>
_WinAPI_UpdateResource ( $hUpdate, $sType, $sName, $iLanguage, $pData, $iSize )

Parameters

$hUpdate | A module handle returned by the _WinAPI_BeginUpdateResource(), referencing the file to be updated.
$sType | The resource type to be updated. Alternatively, rather than a pointer, this parameter can be an integer value representing a predefined resource type. If the first character of the string is a pound sign (#), then the remaining characters represent a decimal number that specifies the integer identifier of the resource type. For example, the string "#258" represents the identifier 258. Also, you can use a predefined resource types ($RT_*).
$sName | The name of the resource to be updated. This parameter can be string or integer value.
$iLanguage | The language identifier of the resource.
$pData | The resource data to be inserted into the file indicated by $hUpdate parameter. If the resource is one of the predefined types, the data must be valid and properly aligned. Note that this is the raw binary data, not the data provided by _WinAPI_LoadIcon(), _WinAPI_LoadString(), or other resource- specific load functions. All data containing strings or text must be in Unicode format. If $pData is 0 and $iSize is 0, the specified resource is deleted from the file indicated by $hUpdate.
$iSize | The size, in bytes, of the resource data at $pData.

Return Value

Success: | True.
Failure: | False.

Remarks

It is recommended that the resource file is not loaded before this function is called. However, if that file
is already loaded, it will not cause an error to be returned.

An application can use _WinAPI_UpdateResource() repeatedly to make changes to the resource data. Each call
to _WinAPI_UpdateResource() contributes to an internal list of additions, deletions, and replacements but does
not actually write the data to the file. The application must use the _WinAPI_EndUpdateResource() function to
write the accumulated changes.

If $pData is 0 and $iSize is 0, the specified resource is deleted from the file indicated by $hUpdate.

Related

_WinAPI_BeginUpdateResource, _WinAPI_EndUpdateResource, _WinAPI_LoadIcon, _WinAPI_LoadString

See Also

Search UpdateResource in MSDN Library.

Example

#include <APIResConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIRes.au3>

Global Const $g_sExe = @TempDir & '\MyProg.exe'

Global Const $tagICONRESDIR = 'byte Width;byte Height;byte ColorCount;byte Reserved;ushort Planes;ushort BitCount;dword BytesInRes;ushort IconId;'
Global Const $tagNEWHEADER = 'ushort Reserved;ushort ResType;ushort ResCount;' ; & $tagICONRESDIR[ResCount]

; Select icon to update resource
Local $sIcon = FileOpenDialog('Select File', @ScriptDir & '\Extras', 'Icon Files (*.ico)', 1 + 2, 'Script.ico')
If Not $sIcon Then
    Exit
EndIf

; Create simple executable file (MyProg.exe) in which will be added icon
If Not FileCopy(@ScriptDir & '\Extras\MyProg.exe', $g_sExe, $FC_OVERWRITE) Then
    If MsgBox(BitOR($MB_OKCANCEL, $MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to copy MyProg.exe or file already exist in the current directory.') <> 1 Then
        Exit
    EndIf
    FileCopy(@ScriptDir & '\Extras\MyProg.exe', $g_sExe, $FC_OVERWRITE)
EndIf

Local $iError = 1
Do
    ; Begin update resources
    Local $hUpdate = _WinAPI_BeginUpdateResource($g_sExe)
    If @error Then
        ExitLoop
    EndIf
    ; Read .ico file as raw binary data into the structure
    Local $tIcon = DllStructCreate('ushort Reserved;ushort Type;ushort Count;byte[' & (FileGetSize($sIcon) - 6) & ']')
    Local $hFile = _WinAPI_CreateFile($sIcon, 2, 2)
    If Not $hFile Then
        ExitLoop
    EndIf
    Local $iBytes = 0
    _WinAPI_ReadFile($hFile, $tIcon, DllStructGetSize($tIcon), $iBytes)
    _WinAPI_CloseHandle($hFile)
    If Not $iBytes Then
        ExitLoop
    EndIf
    ; Add all icons from .ico file into the RT_ICON resources identified as 400, 401, etc., and fill group icons structure
    Local $iCount = DllStructGetData($tIcon, 'Count')
    Local $tDir = DllStructCreate($tagNEWHEADER & 'byte[' & (14 * $iCount) & ']')
    Local $pDir = DllStructGetPtr($tDir)
    DllStructSetData($tDir, 'Reserved', 0)
    DllStructSetData($tDir, 'ResType', 1)
    DllStructSetData($tDir, 'ResCount', $iCount)
    Local $tInfo, $iSize, $tData, $iID = 400
    Local $pIcon = DllStructGetPtr($tIcon)
    For $i = 1 To $iCount
        $tInfo = DllStructCreate('byte Width;byte Heigth;byte Colors;byte Reserved;ushort Planes;ushort BPP;dword Size;dword Offset', $pIcon + 6 + 16 * ($i - 1))
        $iSize = DllStructGetData($tInfo, 'Size')
        If Not _WinAPI_UpdateResource($hUpdate, $RT_ICON, $iID, 0, $pIcon + DllStructGetData($tInfo, 'Offset'), $iSize) Then
            ExitLoop 2
        EndIf
        $tData = DllStructCreate($tagICONRESDIR, $pDir + 6 + 14 * ($i - 1))
        DllStructSetData($tData, 'Width', DllStructGetData($tInfo, 'Width'))
        DllStructSetData($tData, 'Height', DllStructGetData($tInfo, 'Heigth'))
        DllStructSetData($tData, 'ColorCount', DllStructGetData($tInfo, 'Colors'))
        DllStructSetData($tData, 'Reserved', 0)
        DllStructSetData($tData, 'Planes', DllStructGetData($tInfo, 'Planes'))
        DllStructSetData($tData, 'BitCount', DllStructGetData($tInfo, 'BPP'))
        DllStructSetData($tData, 'BytesInRes', $iSize)
        DllStructSetData($tData, 'IconId', $iID)
        $iID += 1
    Next
    ; Add new RT_GROUP_ICON resource named as "MAINICON"
    If Not _WinAPI_UpdateResource($hUpdate, $RT_GROUP_ICON, 'MAINICON', 0, $pDir, DllStructGetSize($tDir)) Then
        ExitLoop
    EndIf
    $iError = 0
Until 1

; Save or discard changes of the resources within an executable file
If Not _WinAPI_EndUpdateResource($hUpdate, $iError) Then
    $iError = 1
EndIf

; Show message if an error occurred
If $iError Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to change resources.')
EndIf


Function _WinAPI_VerQueryRoot

Function Reference

_WinAPI_VerQueryRoot

Retrieves the fixed version information from the specified version-information resource

#include <WinAPIRes.au3>
_WinAPI_VerQueryRoot ( $pData )

Parameters

$pData A pointer to the buffer that contains the version-information resource returned by the
_WinAPI_GetFileVersionInfo() function.

Return Value

Success: | $tagVS_FIXEDFILEINFO structure that contains the version information.
Failure: | Sets the @error flag to non-zero.

Related

_WinAPI_GetFileVersionInfo

See Also

Search VerQueryValue in MSDN Library.


Function _WinAPI_VerQueryValue

Function Reference

_WinAPI_VerQueryValue

Retrieves the non-fixed (strings) version information from the specified version-information resource

#include <WinAPIRes.au3>
_WinAPI_VerQueryValue ( $pData [, $sValues = ''] )

Parameters

$pData | A pointer to the buffer that contains the version-information resource returned by the _WinAPI_GetFileVersionInfo() function.
$sValues | [optional] The string containing the field names for which you want to get values. The names must be separated by a "|". For example, "name1|name2|...|namei". If some fields do not exist, the corresponding array elements is an empty string. If this parameter is not specified (empty string), uses the reserved names (12) in the following sequence: $FV_COMMENTS ("Comments") $FV_COMPANYNAME ("CompanyName") $FV_FILEDESCRIPTION ("FileDescription") $FV_FILEVERSION ("FileVersion") $FV_INTERNALNAME ("InternalName") $FV_LEGALCOPYRIGHT ("LegalCopyright") $FV_LEGALTRADEMARKS ("LegalTrademarks") $FV_ORIGINALFILENAME ("OriginalFilename") $FV_PRODUCTNAME ("ProductName") $FV_PRODUCTVERSION ("ProductVersion") $FV_PRIVATEBUILD ("PrivateBuild") $FV_SPECIALBUILD ("SpecialBuild") Constants are defined in FileConstants.au3.

Return Value

Success: | The 2D array of the string values that specified by $sValues parameter for each language. The zeroth array element [0][0] contains the number of languages of the resource. The array dimension (i) equal to the number specified parameters + 1. The zeroth array element [n][0] contains the language identifier (ID). [0][0] - Number of languages (n) [0][i] - Unused [n][0] - ID [n][i] - Value
Failure: | Sets the @error flag to non-zero.

See Also

Search VerQueryValue in MSDN Library.

Example

#include <Array.au3>
#include <WinAPIRes.au3>
#include <WinAPISys.au3>

Local $pData = 0
If Not _WinAPI_GetFileVersionInfo(@SystemDir & '\shell32.dll', $pData) Then
    Exit
EndIf

Local $aData = _WinAPI_VerQueryValue($pData)

_ArrayDisplay($aData, '_WinAPI_VerQueryValue')

_WinAPI_FreeMemory($pData)


Function _WinAPI_VerQueryValueEx

Function Reference

_WinAPI_VerQueryValueEx

Retrieves the text information from the version-information resource of the specified binary module

#include <WinAPIRes.au3>
_WinAPI_VerQueryValueEx ( $hModule [, $sValues = '' [, $iLanguage = 0x0400]] )

Parameters

$hModule | The handle to a module to retrieve information. Also, this parameter can specify the name of the module to load, it must be a full or relative path. If this parameter is 0 or an empty string, that is equivalent to passing in a handle to the module used to create the current process.
$sValues | [optional] The string containing the field names for which you want to get values. The names must be separated by a "|". For example, "name1|name2|...|namei". If some fields do not exist, the corresponding array elements is an empty string. If this parameter is not specified (empty string), uses the reserved names (12) in the following sequence: $FV_COMMENTS ("Comments") $FV_COMPANYNAME ("CompanyName") $FV_FILEDESCRIPTION ("FileDescription") $FV_FILEVERSION ("FileVersion") $FV_INTERNALNAME ("InternalName") $FV_LEGALCOPYRIGHT ("LegalCopyright") $FV_LEGALTRADEMARKS ("LegalTrademarks") $FV_ORIGINALFILENAME ("OriginalFilename") $FV_PRODUCTNAME ("ProductName") $FV_PRODUCTVERSION ("ProductVersion") $FV_PRIVATEBUILD ("PrivateBuild") $FV_SPECIALBUILD ("SpecialBuild") Constants are defined in FileConstants.au3.
$iLanguage | [optional] The language identifier of the version-information resource of interest. To retrieve information for user default language set this parameter to $LOCALE_USER_DEFAULT (Default). To retrieve information for all languages that are located in the resource set this parameter to (-1).

Return Value

Success: | The 2D array of the string values that specified by $sValues parameter for each language. The zeroth array element [0][0] contains the number of languages of the resource. The array dimension (i) equal to the number specified parameters + 1. The zeroth array element [n][0] contains the language identifier (ID). [0][0] - Number of languages (n) [0][i] - Unused [n][0] - ID [n][i] - Value
Failure: | Sets the @error flag to non-zero.

Remarks

The identifier (ID) of the version-information resource should be equal to 1, otherwise the function fails.

Example

#include <APILocaleConstants.au3>
#include <Array.au3>
#include <WinAPILocale.au3>
#include <WinAPIRes.au3>

Local $aData = _WinAPI_VerQueryValueEx(@ScriptDir & '\Extras\Resources.dll', 'FileDescription|FileVersion|OriginalFilename', -1)

If Not @error Then
    For $i = 1 To $aData[0][0]
        $aData[$i][0] = _WinAPI_GetLocaleInfo($aData[$i][0], $LOCALE_SLANGUAGE)
    Next
EndIf

_ArrayDisplay($aData, '_WinAPI_VerQueryValueEx')


Miscellaneous Reference

  • Audio Management
  • Conversion Management
  • Struct Management


Function _WinAPI_GetExtended

Function Reference

_WinAPI_GetExtended

Retrieves the last extended function return value

#include <WinAPIMisc.au3>
_WinAPI_GetExtended ( )

Return Value

Returns the last extended value.

Remarks

Note that not all the functions returns the extended value.
For example, _WinAPI_CreateDIB() function returns a pointer to the location of the DIB bit values.
The _WinAPI_GetExtended() must be called immediately after calling the appropriate function.


User Defined Functions

Audio user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIMisc.au3>.

User Defined Function | Description
_WinAPI_PlaySound | Plays a sound specified by the given file name, resource, or system event


Function _WinAPI_PlaySound

Function Reference

_WinAPI_PlaySound

Plays a sound specified by the given file name, resource, or system event

#include <WinAPIMisc.au3>
_WinAPI_PlaySound ( $sSound [, $iFlags = $SND_SYSTEM_NOSTOP [, $hInstance = 0]] )

Parameters

$sSound | The string that specifies the sound to play. The maximum length is 255 characters. If $sSound is empty, any currently playing waveform sound is stopped.
$iFlags | [optional] The flags for sound playing. This parameter can be one or more of the following values. $SND_APPLICATION $SND_ALIAS $SND_ALIAS_ID $SND_ASYNC $SND_FILENAME $SND_LOOP $SND_MEMORY $SND_NODEFAULT $SND_NOSTOP $SND_NOWAIT $SND_PURGE $SND_RESOURCE $SND_SYNC Windows Vista or later $SND_SENTRY $SND_SYSTEM Three flags ($SND_ALIAS, $SND_FILENAME, and $SND_RESOURCE) determine whether the name is interpreted as an alias for a system event, a file name, or a resource identifier. If none of these flags are specified, _WinAPI_PlaySound() searches the registry or the WIN.INI file for an association with the specified sound name. If an association is found, the sound event is played. If no association is found in the registry, the name is interpreted as a file name. If the $SND_ALIAS_ID flag is specified in $iFlags, the $sSound parameter must be one of the $SND_ALIAS_* values. (See MSDN for more information)
$hInstance | [optional] Handle to the executable file that contains the resource to be loaded. If $iFlags does not contain the $SND_RESOURCE, this parameter will be ignored.

Return Value

Success: | True
Failure: | False

See Also

Search PlaySound in MSDN Library.

Example

#include <APIMiscConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIMisc.au3>

Local Const $sWav = @ScriptDir & '\Extras\Airplane.wav'

; Read Airplane.wav to memory
Local $dWav = FileRead($sWav)
If @error Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to read "' & $sWav & '"')
    Exit
EndIf
Local $tWav = DllStructCreate('byte[' & BinaryLen($dWav) & ']')
DllStructSetData($tWav, 1, $dWav)
Local $pWav = DllStructGetPtr($tWav)

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 200, 200)
Local $idButton = GUICtrlCreateButton('Play', 70, 70, 60, 60)
GUISetState(@SW_SHOW)

Local $bPlay = False
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            $bPlay = Not $bPlay
            If $bPlay Then
                _WinAPI_PlaySound($pWav, BitOR($SND_ASYNC, $SND_LOOP, $SND_MEMORY))
;~              _WinAPI_PlaySound($sWav, BitOR($SND_ASYNC, $SND_LOOP))
                GUICtrlSetData($idButton, 'Stop')
            Else
                _WinAPI_PlaySound('')
                GUICtrlSetData($idButton, 'Play')
            EndIf
    EndSwitch
WEnd


User Defined Functions

Conversion user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIMisc.au3>.

User Defined Function | Description
_WinAPI_CharToOem | Converts a string into the OEM-defined character set
_WinAPI_DWordToFloat | Converts a value of type DWORD to a value of type FLOAT
_WinAPI_DWordToInt | Converts a value of type DWORD to a value of type INT
_WinAPI_FloatToDWord | Converts a value of type FLOAT to a value of type DWORD
_WinAPI_GetString | Returns a string located at the specified memory address
_WinAPI_HashData | Hashes a memory block
_WinAPI_HashString | Hashes a string
_WinAPI_HiByte | Returns the high BYTE of a 16-bit (2 bytes) value
_WinAPI_HiDWord | Returns the high DWORD of a 64-bit (8 bytes) value
_WinAPI_IntToDWord | Converts a value of type INT to a value of type DWORD
_WinAPI_LoByte | Returns the low BYTE of a 16-bit (2 bytes) value
_WinAPI_LoDWord | Returns the low DWORD of a 64-bit (8 bytes) value
_WinAPI_LongMid | Extracts a number of bits from a DWORD (32-bit) value
_WinAPI_MakeWord | Returns a WORD (16-bit) value from two BYTE (8-bit) values
_WinAPI_OemToChar | Converts a string from the OEM-defined character set into either an ANSI string
_WinAPI_ShortToWord | Converts a value of type SHORT to a value of type WORD
_WinAPI_StrFormatByteSize | Converts a numeric value into a string that represents the number expressed as a size value in bytes, kilobytes, megabytes, or gigabytes
_WinAPI_StrFormatByteSizeEx | Converts a numeric value into a string that represents the number expressed as separated groups of digits to the left of the decimal
_WinAPI_StrFormatKBSize | Converts a numeric value into a string that represents the number expressed as a size value in kilobytes
_WinAPI_StrFromTimeInterval | Converts a time interval to a string
_WinAPI_StrLen | Returns the length of the specified string
_WinAPI_SwapDWord | Converts a ULONG from little-endian to big-endian, and vice versa
_WinAPI_SwapQWord | Converts a ULONGLONG from little-endian to big-endian, and vice versa
_WinAPI_SwapWord | Converts a USHORT from little-endian to big-endian, and vice versa
_WinAPI_WordToShort | Converts a value of type WORD to a value of type SHORT


Function _WinAPI_CharToOem

Function Reference

_WinAPI_CharToOem

Converts a string into the OEM-defined character set

#include <WinAPIMisc.au3>
_WinAPI_CharToOem ( $sStr )

Parameters

$sStr The string that must be converted.

Return Value

Success: | The converted string.
Failure: | Empty string and sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended code information.

See Also

Search CharToOem in MSDN Library.


Function _WinAPI_DWordToFloat

Function Reference

_WinAPI_DWordToFloat

Converts a value of type DWORD to a value of type FLOAT

#include <WinAPIMisc.au3>
_WinAPI_DWordToFloat ( $iValue )

Parameters

$iValue The value to be converted.

Return Value

Returns the converted (FLOAT) value.


Function _WinAPI_DWordToInt

Function Reference

_WinAPI_DWordToInt

Converts a value of type DWORD to a value of type INT

#include <WinAPIMisc.au3>
_WinAPI_DWordToInt ( $iValue )

Parameters

$iValue The value to be converted.

Return Value

Returns the converted (INT) value.

Example

#include <WinAPIMisc.au3>

Local $iValue = 4294967295

ConsoleWrite(_WinAPI_DWordToInt($iValue) & @CRLF)


Function _WinAPI_FloatToDWord

Function Reference

_WinAPI_FloatToDWord

Converts a value of type FLOAT to a value of type DWORD

#include <WinAPIMisc.au3>
_WinAPI_FloatToDWord ( $iValue )

Parameters

$iValue The value to be converted.

Return Value

Returns the converted (DWORD) value.


Function _WinAPI_GetString

Function Reference

_WinAPI_GetString

Returns a string located at the specified memory address

#include <WinAPIMisc.au3>
_WinAPI_GetString ( $pString [, $bUnicode = True] )

Parameters

$pString | Pointer to a null-terminated string.
$bUnicode | [optional] Specifies whether a string is Unicode or ASCII code of a character, valid values: True - Unicode (Default). False - ASCII.

Return Value

Success: | a string. @extended returns the length of the string, in TCHARs (not including the null-terminating character).
Failure: | an empty string and sets the @error flag to non-zero.

Example

#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WinAPIMisc.au3>
#include <WinAPISys.au3>

Global Const $WM_MYMESSAGE = _WinAPI_RegisterWindowMessage('MyMessage')

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 93)
Local $idInput = GUICtrlCreateInput('', 20, 20, 360, 20)
Local $idButton = GUICtrlCreateButton('Send', 165, 59, 70, 23)
GUIRegisterMsg($WM_MYMESSAGE, 'WM_MYMESSAGE')
GUISetState(@SW_SHOW)

Local $pString
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            $pString = _WinAPI_CreateString(GUICtrlRead($idInput))
            _WinAPI_SetMessageExtraInfo($pString)
            _SendMessage($hForm, $WM_MYMESSAGE, 1, 255)
            _WinAPI_FreeMemory($pString)
    EndSwitch
WEnd

Func WM_MYMESSAGE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg

    Local $pString = _WinAPI_GetMessageExtraInfo()

    If _WinAPI_IsMemory($pString) Then
        ConsoleWrite('WM_MYMESSAGE | WP = ' & Number($wParam) & ' | LP = ' & Number($lParam) & ' | EXTRA = "' & _WinAPI_GetString($pString) & '"' & @CRLF)
    EndIf
EndFunc   ;==>WM_MYMESSAGE


Function _WinAPI_HashData

Function Reference

_WinAPI_HashData

Hashes a memory block

#include <WinAPIMisc.au3>
_WinAPI_HashData ( $pMemory, $iSize [, $iLength = 32] )

Parameters

$pMemory | A pointer to a memory block containing data to hash.
$iSize | The size of the memory block, in bytes.
$iLength | [optional] The length of the hash data, in bytes. It should be no larger than 256, otherwise, the function fails. Default is 32.

Return Value

Success: | The hash data in binary form.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search HashData in MSDN Library.

Example

#include <WinAPIMisc.au3>

Local $bData = Binary('0x00112233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF')
Local $iSize = BinaryLen($bData)
Local $tData = DllStructCreate('byte[' & $iSize & ']')
DllStructSetData($tData, 1, $bData)

ConsoleWrite(_WinAPI_HashData($tData, $iSize) & @CRLF)


Function _WinAPI_HashString

Function Reference

_WinAPI_HashString

Hashes a string

#include <WinAPIMisc.au3>
_WinAPI_HashString ( $sString [, $bCaseSensitive = True [, $iLength = 32]] )

Parameters

$sString | The string to hash.
$bCaseSensitive | [optional] Specifies whether to treat the string as case sensitive when computing the hash value, valid values: True - The lowercase and uppercase string hash to the different value (Default). False - The lowercase and uppercase string hash to the same value.
$iLength | [optional] The length of the hash data, in bytes. It should be no larger than 256, otherwise, the function fails. Default is 32.

Return Value

Success: | The hash data in binary form.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Example

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

Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 96)
Global $g_idInput1 = GUICtrlCreateInput('', 20, 20, 360, 20)
GUICtrlSetLimit(-1, 255)
Global $g_idInput2 = GUICtrlCreateInput('', 20, 56, 360, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY))
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $lParam

    Switch $hWnd
        Case $g_hForm
            Switch _WinAPI_LoWord($wParam)
                Case $g_idInput1
                    Switch _WinAPI_HiWord($wParam)
                        Case $EN_CHANGE
                            Local $dHash
                            $dHash = _WinAPI_HashString(GUICtrlRead($g_idInput1), False, 16)
                            If Not @error Then
                                GUICtrlSetData($g_idInput2, $dHash)
                            Else
                                GUICtrlSetData($g_idInput2, '')
                            EndIf
                    EndSwitch
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND


Function _WinAPI_HiByte

Function Reference

_WinAPI_HiByte

Returns the high BYTE of a 16-bit (2 bytes) value

#include <WinAPIMisc.au3>
_WinAPI_HiByte ( $iValue )

Parameters

$iValue 16-bit value.

Return Value

High BYTE value.


Function _WinAPI_HiDWord

Function Reference

_WinAPI_HiDWord

Returns the high DWORD of a 64-bit (8 bytes) value

#include <WinAPIMisc.au3>
_WinAPI_HiDWord ( $iValue )

Parameters

$iValue 64-bit value.

Return Value

High DWORD value.

Example

#include <WinAPIMisc.au3>

Local $iValue = Int('0x1111111122222222')

ConsoleWrite('0x' & Hex(_WinAPI_HiDWord($iValue)) & @CRLF)
ConsoleWrite('0x' & Hex(_WinAPI_LoDWord($iValue)) & @CRLF)


Function _WinAPI_IntToDWord

Function Reference

_WinAPI_IntToDWord

Converts a value of type INT to a value of type DWORD

#include <WinAPIMisc.au3>
_WinAPI_IntToDWord ( $iValue )

Parameters

$iValue The value to be converted.

Return Value

Returns the converted (DWORD) value.

Example

#include <WinAPIMisc.au3>

Local $iValue = -1

ConsoleWrite(_WinAPI_IntToDWord($iValue) & @CRLF)


Function _WinAPI_LoByte

Function Reference

_WinAPI_LoByte

Returns the low BYTE of a 16-bit (2 bytes) value

#include <WinAPIMisc.au3>
_WinAPI_LoByte ( $iValue )

Parameters

$iValue 16-bit value.

Return Value

Returns low BYTE value.


Function _WinAPI_LoDWord

Function Reference

_WinAPI_LoDWord

Returns the low DWORD of a 64-bit (8 bytes) value

#include <WinAPIMisc.au3>
_WinAPI_LoDWord ( $iValue )

Parameters

$iValue 64-bit value.

Return Value

Low DWORD value.

Example

#include <WinAPIMisc.au3>

Local $iValue = Int('0x1111111122222222')

ConsoleWrite('0x' & Hex(_WinAPI_HiDWord($iValue)) & @CRLF)
ConsoleWrite('0x' & Hex(_WinAPI_LoDWord($iValue)) & @CRLF)


Function _WinAPI_LongMid

Function Reference

_WinAPI_LongMid

Extracts a number of bits from a DWORD (32-bit) value

#include <WinAPIMisc.au3>
_WinAPI_LongMid ( $iValue, $iStart, $iCount )

Parameters

$iValue | 32-bit value.
$iStart | The bit position to start. (0 - first bit)
$iCount | The number of bits to extract.

Return Value

Returns the value that consists of a specified bits.

Remarks

This function does not check the parameters for valid values. If values is incorrect, the function may return
an unexpected results.

Example

#include <WinAPIMisc.au3>

Local $iValue = 0x00FA0000

ConsoleWrite('0x' & Hex(_WinAPI_LongMid($iValue, 16, 4)) & @CRLF)
ConsoleWrite('0x' & Hex(_WinAPI_LongMid($iValue, 20, 4)) & @CRLF)


Function _WinAPI_MakeWord

Function Reference

_WinAPI_MakeWord

Returns a WORD (16-bit) value from two BYTE (8-bit) values

#include <WinAPIMisc.au3>
_WinAPI_MakeWord ( $iLo, $iHi )

Parameters

$iLo | Low byte.
$iHi | Hi byte.

Return Value

Returns the WORD value.


Function _WinAPI_OemToChar

Function Reference

_WinAPI_OemToChar

Converts a string from the OEM-defined character set into either an ANSI string

#include <WinAPIMisc.au3>
_WinAPI_OemToChar ( $sStr )

Parameters

$sStr The string of characters from the OEM-defined character set.

Return Value

Success: | The converted string.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search OemToChar in MSDN Library.


Function _WinAPI_ShortToWord

Function Reference

_WinAPI_ShortToWord

Converts a value of type SHORT to a value of type WORD

#include <WinAPIMisc.au3>
_WinAPI_ShortToWord ( $iValue )

Parameters

$iValue The value to be converted.

Return Value

Returns the converted (WORD) value.

Example

#include <WinAPIMisc.au3>

Local $iValue = -1

ConsoleWrite(_WinAPI_ShortToWord($iValue) & @CRLF)


Function _WinAPI_StrFormatByteSize

Function Reference

_WinAPI_StrFormatByteSize

Converts a numeric value into a string that represents the number expressed as a size value in bytes, kilobytes, megabytes, or gigabytes

#include <WinAPIMisc.au3>
_WinAPI_StrFormatByteSize ( $iSize )

Parameters

$iSize The numeric value to be converted.

Return Value

Success: | The converted string.
Failure: | Empty string and sets the @error flag to non-zero.

See Also

Search StrFormatByteSizeEx in MSDN Library.

Example

#include <WinAPIMisc.au3>

Local $aVal[5] = [532, 1340, 23506, 2400016, 2400000000]

For $i = 0 To 4
    ConsoleWrite(StringFormat('%10s ' & _WinAPI_StrFormatByteSize($aVal[$i]), $aVal[$i]) & @CRLF)
Next


Function _WinAPI_StrFormatByteSizeEx

Function Reference

_WinAPI_StrFormatByteSizeEx

Converts a numeric value into a string that represents the number expressed as separated groups of digits to the left of the decimal

#include <WinAPIMisc.au3>
_WinAPI_StrFormatByteSizeEx ( $iSize )

Parameters

$iSize The numeric value to be converted.

Return Value

Success: | The converted string.
Failure: | Empty string and sets the @error flag to non-zero.

Example

#include <WinAPIMisc.au3>

Local $aVal[5] = [532, 1340, 23506, 2400016, 2400000000]

For $i = 0 To 4
    ConsoleWrite(StringFormat('%10s %19s', $aVal[$i], _WinAPI_StrFormatByteSizeEx($aVal[$i])) & @CRLF)
Next


Function _WinAPI_StrFormatKBSize

Function Reference

_WinAPI_StrFormatKBSize

Converts a numeric value into a string that represents the number expressed as a size value in kilobytes

#include <WinAPIMisc.au3>
_WinAPI_StrFormatKBSize ( $iSize )

Parameters

$iSize The numeric value to be converted.

Return Value

Success: | The converted string.
Failure: | Empty string and sets the @error flag to non-zero.

See Also

Search StrFormatKBSize in MSDN Library.

Example

#include <WinAPIMisc.au3>

Local $aVal[3] = [23506, 2400016, 2400000000]

For $i = 0 To 2
    ConsoleWrite(StringFormat('%10s %12s', $aVal[$i], _WinAPI_StrFormatKBSize($aVal[$i])) & @CRLF)
Next


Function _WinAPI_StrFromTimeInterval

Function Reference

_WinAPI_StrFromTimeInterval

Converts a time interval to a string

#include <WinAPIMisc.au3>
_WinAPI_StrFromTimeInterval ( $iTime [, $iDigits = 7] )

Parameters

$iTime | The time interval, in milliseconds.
$iDigits | [optional] The maximum number of significant digits to be represented in converted string. Default is 7.

Return Value

Success: | The converted string.
Failure: | Empty string and sets the @error flag to non-zero.

Remarks

The time value returned in converted string will always be in the form (hh) hours (mm) minutes (ss) seconds.
Times that exceed twenty four hours are not converted to days or months.

See Also

Search StrFromTimeInterval in MSDN Library.

Example

#include <WinAPIMisc.au3>
#include <WinAPISys.au3>

ConsoleWrite(_WinAPI_StrFromTimeInterval(_WinAPI_GetTickCount()) & @CRLF)

ConsoleWrite('"' & _WinAPI_StrFromTimeInterval(-1, 0) & '" @error = ' & @error & ' @extended = 0x' & Hex(@extended) & @CRLF)


Function _WinAPI_StrLen

Function Reference

_WinAPI_StrLen

Returns the length of the specified string

#include <WinAPIMisc.au3>
_WinAPI_StrLen ( $pString [, $bUnicode = True] )

Parameters

$pString | Pointer to a null-terminated string.
$bUnicode | [optional] Specifies whether a string is Unicode or ASCII code of a character, valid values: True - Unicode (Default). False - ASCII.

Return Value

Success: | The length of the string, in TCHARs values (not including the null-terminating character).
Failure: | 0.

See Also

Search lstrlen in MSDN Library.


Function _WinAPI_SwapDWord

Function Reference

_WinAPI_SwapDWord

Converts a ULONG from little-endian to big-endian, and vice versa

#include <WinAPIMisc.au3>
_WinAPI_SwapDWord ( $iValue )

Parameters

$iValue The ULONG value to convert.

Return Value

Returns the converted value.

See Also

Search RtlUlongByteSwap in MSDN Library.

Example

#include <WinAPIMisc.au3>

Local $iValue = 0x11223344

ConsoleWrite('0x' & Hex($iValue) & @CRLF)
ConsoleWrite('0x' & Hex(_WinAPI_SwapDWord($iValue)) & @CRLF)


Function _WinAPI_SwapQWord

Function Reference

_WinAPI_SwapQWord

Converts a ULONGLONG from little-endian to big-endian, and vice versa

#include <WinAPIMisc.au3>
_WinAPI_SwapQWord ( $iValue )

Parameters

$iValue The ULONGLONG value to convert.

Return Value

Returns the converted value.

Example

#include <WinAPI.au3>
#include <WinAPIMisc.au3>

Local $iValue = _WinAPI_MakeQWord(0x55667788, 0x11223344)

ConsoleWrite('0x' & Hex($iValue) & @CRLF)
ConsoleWrite('0x' & Hex(_WinAPI_SwapQWord($iValue)) & @CRLF)


Function _WinAPI_SwapWord

Function Reference

_WinAPI_SwapWord

Converts a USHORT from little-endian to big-endian, and vice versa

#include <WinAPIMisc.au3>
_WinAPI_SwapWord ( $iValue )

Parameters

$iValue The USHORT value to convert.

Return Value

Returns the converted value.

See Also

Search RtlUshortByteSwap in MSDN Library.

Example

#include <WinAPIMisc.au3>

Local $iValue = 0x1122

ConsoleWrite('0x' & Hex($iValue, 4) & @CRLF)
ConsoleWrite('0x' & Hex(_WinAPI_SwapWord($iValue), 4) & @CRLF)


Function _WinAPI_WordToShort

Function Reference

_WinAPI_WordToShort

Converts a value of type WORD to a value of type SHORT

#include <WinAPIMisc.au3>
_WinAPI_WordToShort ( $iValue )

Parameters

$iValue The value to be converted.

Return Value

Returns the converted (SHORT) value.

Example

#include <WinAPIMisc.au3>

Local $iValue = 65535

ConsoleWrite(_WinAPI_WordToShort($iValue) & @CRLF)


User Defined Functions

Struct user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIMisc.au3>.

User Defined Function | Description
_WinAPI_ArrayToStruct | Converts an array of strings to the structure
_WinAPI_CopyStruct | Creates a duplicate of a specified structure
_WinAPI_CreateMargins | Creates $tagMARGINS structure with specified left, right, top, and bottom retaining borders
_WinAPI_CreatePoint | Creates $tagPOINT structure with the x- and y-coordinates of the specified point
_WinAPI_CreateRect | Creates $tagRECT structure with the coordinates of the specified rectangle
_WinAPI_CreateRectEx | Creates $tagRECT structure with the coordinates of the specified rectangle
_WinAPI_CreateSize | Creates $tagSIZE structure with the width and height of the specified rectangle
_WinAPI_StructToArray | Converts the structure to the array of strings
_WinAPI_UnionStruct | Creates the structure of two structures


Function _WinAPI_ArrayToStruct

Function Reference

_WinAPI_ArrayToStruct

Converts an array of strings to the structure

#include <WinAPIMisc.au3>
_WinAPI_ArrayToStruct ( Const ByRef $aData [, $iStart = 0 [, $iEnd = -1]] )

Parameters

$aData | The array to convert.
$iStart | [optional] The index of array to start converting at.
$iEnd | [optional] The index of array to stop converting at.

Return Value

Success: | the structure of the type "string1;{0};string2;{0}; ... ;stringN;{0};{0}".
Failure: | sets the @error flag to non-zero.

Remarks

This function works for Unicode strings only.


Function _WinAPI_CopyStruct

Function Reference

_WinAPI_CopyStruct

Creates a duplicate of a specified structure

#include <WinAPIMisc.au3>
_WinAPI_CopyStruct ( $tStruct [, $sStruct = ''] )

Parameters

$tStruct | The structure to be duplicated.
$sStruct | [optional] The string representing the structure (same as for the DllStructCreate() function).

Return Value

Success: | "byte[n]" or $sStruct structure that was created.
Failure: | Sets the @error flag to non-zero.

Example

#include <WinAPIMisc.au3>
#include <WinAPISys.au3>

Local $tStruct1 = DllStructCreate('byte[8]')
_WinAPI_FillMemory($tStruct1, 8, 0x1D)

Local $tStruct2 = _WinAPI_CopyStruct($tStruct1)

ConsoleWrite('Source:      ' & DllStructGetData($tStruct1, 1) & @CRLF)
ConsoleWrite('Destination: ' & DllStructGetData($tStruct2, 1) & @CRLF)


Function _WinAPI_CreateMargins

Function Reference

_WinAPI_CreateMargins

Creates $tagMARGINS structure with specified left, right, top, and bottom retaining borders

#include <WinAPIMisc.au3>
_WinAPI_CreateMargins ( $iLeftWidth, $iRightWidth, $iTopHeight, $iBottomHeight )

Parameters

$iLeftWidth | The width of the left border that retains its size.
$iRightWidth | The width of the right border that retains its size.
$iTopHeight | The height of the top border that retains its size.
$iBottomHeight | The height of the bottom border that retains its size.

Return Value

Returns $tagMARGINS structure that contains the specified retaining borders.


Function _WinAPI_CreatePoint

Function Reference

_WinAPI_CreatePoint

Creates $tagPOINT structure with the x- and y-coordinates of the specified point

#include <WinAPIMisc.au3>
_WinAPI_CreatePoint ( $iX, $iY )

Parameters

$iX | The x-coordinate of the point.
$iY | The y-coordinate of the point.

Return Value

Returns $tagPOINT structure that contains the specified point.


Function _WinAPI_CreateRect

Function Reference

_WinAPI_CreateRect

Creates $tagRECT structure with the coordinates of the specified rectangle

#include <WinAPIMisc.au3>
_WinAPI_CreateRect ( $iLeft, $iTop, $iRight, $iBottom )

Parameters

$iLeft | The x-coordinate of the upper-left corner of the rectangle.
$iTop | The y-coordinate of the upper-left corner of the rectangle.
$iRight | The x-coordinate of the lower-right corner of the rectangle.
$iBottom | The y-coordinate of the lower-right corner of the rectangle.

Return Value

Returns $tagRECT structure that contains the specified rectangle.


Function _WinAPI_CreateRectEx

Function Reference

_WinAPI_CreateRectEx

Creates $tagRECT structure with the coordinates of the specified rectangle

#include <WinAPIMisc.au3>
_WinAPI_CreateRectEx ( $iX, $iY, $iWidth, $iHeight )

Parameters

$iX | The x-coordinate of the upper-left corner of the rectangle.
$iY | The y-coordinate of the upper-left corner of the rectangle.
$iWidth | The width of the rectangle.
$iHeight | The height of the rectangle.

Return Value

Returns $tagRECT structure that contains the specified rectangle.


Function _WinAPI_CreateSize

Function Reference

_WinAPI_CreateSize

Creates $tagSIZE structure with the width and height of the specified rectangle

#include <WinAPIMisc.au3>
_WinAPI_CreateSize ( $iWidth, $iHeight )

Parameters

$iWidth | The width of the rectangle.
$iHeight | The height of the rectangle.

Return Value

Returns $tagSIZE structure that contains the specified rectangle.


Function _WinAPI_StructToArray

Function Reference

_WinAPI_StructToArray

Converts the structure to the array of strings

#include <WinAPIMisc.au3>
_WinAPI_StructToArray ( $tStruct [, $iItems = 0] )

Parameters

$tStruct | The structure to convert. This structure should be same as for _WinAPI_ArrayToStruct().
$iItems | [optional] The number of strings that contains the structure. If this parameter is 0 (Default), the end of the structure determined by a double null-terminated character ("... ;{0};{0}").

Return Value

Success: | The array of strings. The zeroth array element contains the number of strings.
Failure: | Sets the @error flag to non-zero.

Remarks

This function works for Unicode strings only.

Related

_WinAPI_ArrayToStruct


Function _WinAPI_UnionStruct

Function Reference

_WinAPI_UnionStruct

Creates the structure of two structures

#include <WinAPIMisc.au3>
_WinAPI_UnionStruct ( $tStruct1, $tStruct2 [, $sStruct = ''] )

Parameters

$tStruct1 | The structure that contains the first source data.
$tStruct2 | The structure that contains the second source data.
$sStruct | [optional] The string representing the final structure (same as for the DllStructCreate() function).

Return Value

Success: | "byte[n]" structure that contains the union data of the $tStruct1 and $tStruct2.
Failure: | Sets the @error flag to non-zero.

Remarks

Important, you have to take into account the alignments of the structures. For example, "byte" & "dword" is
not equivalent to "byte;dword", but equivalent to "align 1;byte;dword".

Example

#include <WinAPIMisc.au3>
#include <WinAPISys.au3>

Local $tStruct1 = DllStructCreate('byte[4]')
_WinAPI_FillMemory($tStruct1, 4, 0xAA)

Local $tStruct2 = DllStructCreate('byte[4]')
_WinAPI_FillMemory($tStruct2, 4, 0xDD)

Local $tStruct3 = _WinAPI_UnionStruct($tStruct1, $tStruct2)

ConsoleWrite('First:  ' & DllStructGetData($tStruct1, 1) & @CRLF)
ConsoleWrite('Second: ' & DllStructGetData($tStruct2, 1) & @CRLF)
ConsoleWrite('Union:  ' & DllStructGetData($tStruct3, 1) & @CRLF)


Process & Synchronization Reference

  • Process Management
  • Synchronization Management


User Defined Functions

Process user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIProc.au3>.

User Defined Function | Description
_WinAPI_AdjustTokenPrivileges | Enables or disables privileges in the specified access token
_WinAPI_AssignProcessToJobObject | Assigns a process to an existing job object
_WinAPI_CreateJobObject | Creates or opens a job object
_WinAPI_CreateProcessWithToken | Creates a new process and its primary thread in the security context of the specified token
_WinAPI_DuplicateTokenEx | Creates a new primary or impersonation access token that duplicates an existing token
_WinAPI_EmptyWorkingSet | Removes as many pages as possible from the working set of the specified process
_WinAPI_EnumChildProcess | Enumerates a child processes that belong to the specified process
_WinAPI_EnumDeviceDrivers | Retrieves the load address for each device driver in the system
_WinAPI_EnumProcessHandles | Enumerates a handles that belong to the specified process
_WinAPI_EnumProcessModules | Retrieves a handle and name for each module in the specified process
_WinAPI_EnumProcessThreads | Enumerates a threads that belong to the specified process
_WinAPI_EnumProcessWindows | Enumerates a windows that belong to the specified process
_WinAPI_GetCurrentProcessExplicitAppUserModelID | Retrieves the application-defined, explicit Application User Model ID for the current process
_WinAPI_GetDeviceDriverBaseName | Retrieves the base name of the specified device driver
_WinAPI_GetDeviceDriverFileName | Retrieves the path available for the specified device driver
_WinAPI_GetExitCodeProcess | Retrieves the termination status of the specified process
_WinAPI_GetModuleFileNameEx | Retrieves the fully-qualified path for the file containing the specified module
_WinAPI_GetModuleInformation | Retrieves information about the specified module
_WinAPI_GetParentProcess | Retrieves the PID of the parent process for the specified process
_WinAPI_GetPriorityClass | Retrieves the priority class for the specified process
_WinAPI_GetProcessCommandLine | Retrieves the command-line string for the specified process
_WinAPI_GetProcessFileName | Retrieves the fully-qualified path of the executable file for the specified process
_WinAPI_GetProcessHandleCount | Retrieves the number of open handles that belong to the specified process
_WinAPI_GetProcessID | Retrieves the process identifier of the specified process
_WinAPI_GetProcessIoCounters | Retrieves accounting information for all I/O operations performed by the specified process
_WinAPI_GetProcessMemoryInfo | Retrieves information about the memory usage of the specified process
_WinAPI_GetProcessName | Retrieves the name for the specified process
_WinAPI_GetProcessTimes | Retrieves timing information for the specified process
_WinAPI_GetProcessUser | Retrieves the user and domain name for the specified process
_WinAPI_GetProcessWorkingDirectory | Retrieves the current working directory for the specified process
_WinAPI_GetThreadDesktop | Retrieves a handle to the desktop assigned to the specified thread
_WinAPI_GetThreadErrorMode | Retrieves the error mode for the calling thread
_WinAPI_GetWindowFileName | Retrieves the fully-qualified path of the module associated with the specified window handle
_WinAPI_IsElevated | Determines whether the current process is elevated
_WinAPI_IsProcessInJob | Determines whether the process is running in the specified job
_WinAPI_IsWow64Process | Determines whether the specified process is running under WOW64
_WinAPI_OpenJobObject | Opens an existing job object
_WinAPI_OpenProcessToken | Opens the access token associated with a process
_WinAPI_QueryInformationJobObject | Retrieves limit and job state information from the job object
_WinAPI_SetInformationJobObject | Sets limits for a job object
_WinAPI_SetPriorityClass | Sets the priority class for the specified process
_WinAPI_SetThreadDesktop | Assigns the specified desktop to the calling thread
_WinAPI_SetThreadErrorMode | Controls whether the system will handle the specified types of serious errors or whether the calling thread will handle them
_WinAPI_SetThreadExecutionState | Prevents the system from entering sleep or turning off the display while the current application is running
_WinAPI_TerminateJobObject | Terminates all processes currently associated with the job
_WinAPI_TerminateProcess | Terminates the specified process and all of its threads
_WinAPI_UserHandleGrantAccess | Grants or denies access to a handle to a User object to a job that has a user-interface restriction


Function _WinAPI_AdjustTokenPrivileges

Function Reference

_WinAPI_AdjustTokenPrivileges

Enables or disables privileges in the specified access token

#include <WinAPIProc.au3>
_WinAPI_AdjustTokenPrivileges ( $hToken, $aPrivileges, $iAttributes, ByRef $aAdjust )

Parameters

$hToken | Handle to the access token that contains the privileges to be modified. The handle must have $TOKEN_ADJUST_PRIVILEGES and $TOKEN_QUERY accesses to the token.
$aPrivileges | The variable that specifies a privileges. If this parameter is (-1), the function disables of the token's privileges and ignores the $iAttributes parameter. $aPrivileges can be one of the following types. The privilege constant ($SE_*). 1D array of $SE_* constants. 2D array of $SE_* constants and their attributes (see below). [0][0] - Privilege [0][1] - Attributes [n][0] - Privilege [n][1] - Attributes
$iAttributes | The privilege attributes. If $aPrivileges parameter is 1D array, $iAttributes applied to the entire array. If $aPrivileges parameter is (-1) or 2D array, the function ignores this parameter and will use the attributes that specified in this array. This parameter can be 0 (disables privilege) or any combination of the following values: $SE_PRIVILEGE_ENABLED $SE_PRIVILEGE_ENABLED_BY_DEFAULT $SE_PRIVILEGE_REMOVED $SE_PRIVILEGE_USED_FOR_ACCESS
$aAdjust | 2D array of the previous state of any privileges that the function modifies. That is, if a privilege has been modified by this function, the privilege and its previous state are contained in this array.

Return Value

Success: | 1 and sets the @extended flag to the following values.
@extended : | 0 - The function adjusted all specified privileges. 1 - The token does not have one or more of the privileges specified in the $aPrivileges parameter.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

This function cannot add new privileges to the access token. It can only enable or disable the token's existing privileges.

To determine whether the function success and adjusted all of the specified privileges, check the @error and @extended flags both, for example:

If Not (@error Or @extended) Then
...
EndIf

See Also

Search AdjustTokenPrivileges in MSDN Library.


Function _WinAPI_AssignProcessToJobObject

Function Reference

_WinAPI_AssignProcessToJobObject

Assigns a process to an existing job object

#include <WinAPIProc.au3>
_WinAPI_AssignProcessToJobObject ( $hJob, $hProcess )

Parameters

$hJob | Handle to the job object to which the process will be associated. The handle must have the $JOB_OBJECT_ASSIGN_PROCESS access right.
$hProcess | Handle to the process to associate with the job object. The process must not already be assigned to a job.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

After you associate a process with a job object, the process is subject to the limits set for the job.
To set limits for a job, use the _WinAPI_SetInformationJobObject() function.

The process can be associated only with a single job.
The process inherits limits from the job it is associated with and adds its accounting information to the job.
If a process is associated with a job, all processes it creates are associated with that job by default.

Related

_WinAPI_SetInformationJobObject

See Also

Search AssignProcessToJobObject in MSDN Library.

Example

#include <APIProcConstants.au3>
#include <WinAPI.au3>
#include <WinAPIMisc.au3>
#include <WinAPIProc.au3>

Local Const $sTemp = @TempDir & '\Test.au3'

; Create temporary .au3 file
Local $hFile = FileOpen($sTemp, 2)
For $i = 1 To 3
    FileWriteLine($hFile, 'Run(@SystemDir & "\calc.exe")' & @CRLF & 'Sleep(100)')
Next
FileClose($hFile)

; Run 3 times the "calc.exe" and wait until you have closed all 3 processes
_RunWaitEx(@AutoItExe & ' /AutoIt3ExecuteScript "' & $sTemp & '"')

; Delete temporary .au3 file
FileDelete($sTemp)

Func _RunWaitEx($sCmd)
    ; Original idea by amel27

    Local $tProcess = DllStructCreate($tagPROCESS_INFORMATION)
    Local $tStartup = DllStructCreate($tagSTARTUPINFO)
    Local $tInfo = DllStructCreate($tagJOBOBJECT_BASIC_ACCOUNTING_INFORMATION)

    Local $hJob = _WinAPI_CreateJobObject()
    If Not $hJob Then Return SetError(1, 0, 0)

    DllStructSetData($tStartup, 'Size', DllStructGetSize($tStartup))
    If Not _WinAPI_CreateProcess('', $sCmd, 0, 0, 0, BitOR($CREATE_BREAKAWAY_FROM_JOB, $CREATE_SUSPENDED), 0, 0, $tStartup, $tProcess) Then
        Return SetError(1, _WinAPI_CloseHandle($hJob), 0)
    EndIf
    Local $hProcess = DllStructGetData($tProcess, 'hProcess')
    Local $hThread = DllStructGetData($tProcess, 'hThread')
    _WinAPI_AssignProcessToJobObject($hJob, $hProcess)
    _WinAPI_ResumeThread($hThread)
    _WinAPI_CloseHandle($hThread)
    Do
        If Not _WinAPI_QueryInformationJobObject($hJob, 1, $tInfo) Then
            ExitLoop
        EndIf
        Sleep(100)
    Until Not DllStructGetData($tInfo, 'ActiveProcesses')
    _WinAPI_CloseHandle($hProcess)
    _WinAPI_CloseHandle($hJob)
    Return 1
EndFunc   ;==>_RunWaitEx

Func _WinAPI_ResumeThread($hThread)
    Local $aRet = DllCall('kernel32.dll', 'dword', 'ResumeThread', 'ptr', $hThread)
    If @error Or (_WinAPI_DWordToInt($aRet[0]) = -1) Then Return SetError(1, 0, -1)

    Return $aRet[0]
EndFunc   ;==>_WinAPI_ResumeThread


Function _WinAPI_CreateJobObject

Function Reference

_WinAPI_CreateJobObject

Creates or opens a job object

#include <WinAPIProc.au3>
_WinAPI_CreateJobObject ( [$sName = '' [, $tSecurity = 0]] )

Parameters

$sName | [optional] The name of the job. Name comparison is case-sensitive. If this parameter is '', the job is created without a name.
$tSecurity | [optional] $tagSECURITY_ATTRIBUTES structure that specifies the security descriptor for the job object and determines whether child processes can inherit the returned handle. If this parameter is 0 (Default), the job object gets a default security descriptor and the handle cannot be inherited.

Return Value

Success: | [optional] Handle to the job object. If the object existed before the function call, the function returns a handle to the existing job object.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

When a job is created, its accounting information is initialized to zero, all limits are inactive, and there are no associated processes. To assign a process to a job object, use the _WinAPI_AssignProcessToJobObject() function.
To set limits for a job, use the _WinAPI_SetInformationJobObject() function.
To query accounting information, use the _WinAPI_QueryInformationJobObject() function.

All processes associated with a job must run in the same session. A job is associated with the session of the first process to be assigned to the job.

To close a job object handle, use the _WinAPI_CloseHandle() function. The job is destroyed when its last handle has been closed and all associated processes have exited.

Related

_WinAPI_AssignProcessToJobObject, _WinAPI_CloseHandle, _WinAPI_QueryInformationJobObject, _WinAPI_SetInformationJobObject

See Also

Search CreateJobObject in MSDN Library.

Example

#include <APIProcConstants.au3>
#include <WinAPI.au3>
#include <WinAPIMisc.au3>
#include <WinAPIProc.au3>

Local Const $sTemp = @TempDir & '\Test.au3'

; Create temporary .au3 file
Local $hFile = FileOpen($sTemp, 2)
For $i = 1 To 3
    FileWriteLine($hFile, 'Run(@SystemDir & "\calc.exe")' & @CRLF & 'Sleep(100)')
Next
FileClose($hFile)

; Run 3 times the "calc.exe" and wait until you have closed all 3 processes
_RunWaitEx(@AutoItExe & ' /AutoIt3ExecuteScript "' & $sTemp & '"')

; Delete temporary .au3 file
FileDelete($sTemp)

Func _RunWaitEx($sCmd)
    ; Original idea by amel27

    Local $tProcess = DllStructCreate($tagPROCESS_INFORMATION)
    Local $tStartup = DllStructCreate($tagSTARTUPINFO)
    Local $tInfo = DllStructCreate($tagJOBOBJECT_BASIC_ACCOUNTING_INFORMATION)

    Local $hJob = _WinAPI_CreateJobObject()
    If Not $hJob Then Return SetError(1, 0, 0)

    DllStructSetData($tStartup, 'Size', DllStructGetSize($tStartup))
    If Not _WinAPI_CreateProcess('', $sCmd, 0, 0, 0, BitOR($CREATE_BREAKAWAY_FROM_JOB, $CREATE_SUSPENDED), 0, 0, $tStartup, $tProcess) Then
        Return SetError(1, _WinAPI_CloseHandle($hJob), 0)
    EndIf
    Local $hProcess = DllStructGetData($tProcess, 'hProcess')
    Local $hThread = DllStructGetData($tProcess, 'hThread')
    _WinAPI_AssignProcessToJobObject($hJob, $hProcess)
    _WinAPI_ResumeThread($hThread)
    _WinAPI_CloseHandle($hThread)
    Do
        If Not _WinAPI_QueryInformationJobObject($hJob, 1, $tInfo) Then
            ExitLoop
        EndIf
        Sleep(100)
    Until Not DllStructGetData($tInfo, 'ActiveProcesses')
    _WinAPI_CloseHandle($hProcess)
    _WinAPI_CloseHandle($hJob)
    Return 1
EndFunc   ;==>_RunWaitEx

Func _WinAPI_ResumeThread($hThread)
    Local $aRet = DllCall('kernel32.dll', 'dword', 'ResumeThread', 'ptr', $hThread)
    If @error Or (_WinAPI_DWordToInt($aRet[0]) = -1) Then Return SetError(1, 0, -1)

    Return $aRet[0]
EndFunc   ;==>_WinAPI_ResumeThread


Function _WinAPI_CreateProcessWithToken

Function Reference

_WinAPI_CreateProcessWithToken

Creates a new process and its primary thread in the security context of the specified token

#include <WinAPIProc.au3>
_WinAPI_CreateProcessWithToken ( $sApp, $sCmd, $iFlags, $tStartupInfo, $tProcessInfo, $hToken [, $iLogon = 0 [, $pEnvironment = 0 [, $sDir = '']]] )

Parameters

$sApp | The name of the module to be executed. If this parameter is an empty string, the module name must be the first white space–delimited token in the command line string.
$sCmd | The command line to be executed. If this parameter is an empty string, the function uses the module name as the command line.
$iFlags | The flags that control how the process is created. The $CREATE_DEFAULT_ERROR_MODE, $CREATE_NEW_CONSOLE, and $CREATE_NEW_PROCESS_GROUP are enabled by default. You can specify additional flags as noted: $CREATE_DEFAULT_ERROR_MODE $CREATE_NEW_CONSOLE $CREATE_NEW_PROCESS_GROUP $CREATE_SEPARATE_WOW_VDM $CREATE_SUSPENDED $CREATE_UNICODE_ENVIRONMENT
$tStartupInfo | a $tagSTARTUPINFO structure or a pointer to it.
$tProcessInfo | a $tagPROCESS_INFORMATION structure or a pointer to it that receives information for the new process, including a handle to the process.
$hToken | A handle to the primary token that represents a user. The handle must have the $TOKEN_QUERY, $TOKEN_DUPLICATE, and $TOKEN_ASSIGN_PRIMARY access rights.
$iLogon | [optional] The logon option. This parameter can be zero or one of the following values: $LOGON_WITH_PROFILE $LOGON_NETCREDENTIALS_ONLY
$pEnvironment | [optional] A pointer to an environment block for the new process.
$sDir | [optional] The path to the current directory for the process. If this parameter is an empty string (Default), the new process will have the same current drive and directory as the calling process.

Return Value

Success: | True
Failure: | False

Remarks

To retrieve a security token, pass the process handle in the $tagPROCESS_INFORMATION structure to the _WinAPI_OpenProcessToken() function.

This function requires Windows Vista or later.

Related

_WinAPI_OpenProcessToken

See Also

Search CreateProcessWithTokenW in MSDN Library.


Function _WinAPI_DuplicateTokenEx

Function Reference

_WinAPI_DuplicateTokenEx

Creates a new primary or impersonation access token that duplicates an existing token

#include <WinAPIProc.au3>
_WinAPI_DuplicateTokenEx ( $hToken, $iAccess, $iLevel [, $iType = 1 [, $tSecurity = 0]] )

Parameters

$hToken | A handle to an access token opened with $TOKEN_DUPLICATE access.
$iAccess | The requested access rights for the new token. To request the same access rights as the existing token, specify zero. To request all access rights that are valid for the caller, specify the $TOKEN_ALL_ACCESS access.
$iLevel | The security impersonation levels. $SECURITYANONYMOUS $SECURITYIDENTIFICATION $SECURITYIMPERSONATION $SECURITYDELEGATION
$iType | [optional] The token type. $TOKENPRIMARY $TOKENIMPERSONATION
$tSecurity | [optional] $tagSECURITY_ATTRIBUTES structure that specifies a security descriptor for the new token and determines whether child processes can inherit the token. If this parameter is 0 (Default), the token gets a default security descriptor and the handle cannot be inherited. If the security descriptor contains a system access control list, the token gets $ACCESS_SYSTEM_SECURITY access right, even if it was not requested.

Return Value

Success: | The handle to the new token.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

When you have finished using the new token, call the _WinAPI_CloseHandle() function to close the token handle.

Related

_WinAPI_CloseHandle

See Also

Search DuplicateTokenEx in MSDN Library.


Function _WinAPI_EmptyWorkingSet

Function Reference

_WinAPI_EmptyWorkingSet

Removes as many pages as possible from the working set of the specified process

#include <WinAPIProc.au3>
_WinAPI_EmptyWorkingSet ( [$iPID = 0] )

Parameters

$iPID [optional] The PID of the process. Default (0) is the current process.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

See Also

Search EmptyWorkingSet in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIProc.au3>

Run(@SystemDir & '\taskmgr.exe')
Sleep(1000)

MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), 'Step 0', 'Look at the memory used by the "' & _WinAPI_PathStripPath(FileGetLongName(@AutoItExe)) & '" (' & @AutoItPID & ') process.')

; Allocate memory to create an array
Local $aData[1000000]
For $i = 0 To UBound($aData) - 1
    $aData[$i] = 'AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying "runtimes" required!'
Next

MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), 'Step 1', 'Allocate memory to create an array')

; Empty the working set
_WinAPI_EmptyWorkingSet()

MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), 'Step 2', 'Empty the working set')

; Read data from an array
For $i = 0 To UBound($aData) - 1
    If $aData[$i] Then
        ; Something
    EndIf
Next

MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), 'Step 3', 'Read data from an array')

; Empty the working set
_WinAPI_EmptyWorkingSet()

MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), 'Step 4', 'Empty the working set')


Function _WinAPI_EnumChildProcess

Function Reference

_WinAPI_EnumChildProcess

Enumerates a child processes that belong to the specified process

#include <WinAPIProc.au3>
_WinAPI_EnumChildProcess ( [$iPID = 0] )

Parameters

$iPID [optional] The PID of the process. Default (0) is the current process.

Return Value

Success: | The 2D array of the PIDs and process names. [0][0] - Number of rows in array (n) [0][1] - Unused [n][0] - PID [n][1] - Process name
Failure: | Sets the @error flag to non-zero.

Example

#include <Array.au3>
#include <WinAPIProc.au3>

Local $aData = _WinAPI_EnumChildProcess(_WinAPI_GetParentProcess())

_ArrayDisplay($aData, '_WinAPI_EnumChildProcess')


Function _WinAPI_EnumDeviceDrivers

Function Reference

_WinAPI_EnumDeviceDrivers

Retrieves the load address for each device driver in the system

#include <WinAPIProc.au3>
_WinAPI_EnumDeviceDrivers ( )

Return Value

Success: | The array of device driver addresses. The zeroth array element contains the number of addresses.
Failure: | Sets the @error flag to non-zero.

See Also

Search EnumDeviceDrivers in MSDN Library.

Example

#include <Array.au3>
#include <WinAPIProc.au3>

Local $aInfo, $aData = _WinAPI_EnumDeviceDrivers()
If IsArray($aData) Then
    Dim $aInfo[$aData[0]][3]
    For $i = 1 To $aData[0]
        $aInfo[$i - 1][0] = $aData[$i]
        $aInfo[$i - 1][1] = _WinAPI_GetDeviceDriverBaseName($aData[$i])
        $aInfo[$i - 1][2] = _WinAPI_GetDeviceDriverFileName($aData[$i])
    Next
EndIf

_ArrayDisplay($aInfo, '_WinAPI_EnumDeviceDrivers')


Function _WinAPI_EnumProcessHandles

Function Reference

_WinAPI_EnumProcessHandles

Enumerates a handles that belong to the specified process

#include <WinAPIProc.au3>
_WinAPI_EnumProcessHandles ( [$iPID = 0 [, $iType = 0]] )

Parameters

$iPID | [optional] The PID of the process. Default (0) is the current process.
$iType | [optional] The value associated with the type of the objects that should be enumerated. This value depends on the operating system. If this parameter is 0 (Default), all handles of the specified process will be enumerated.

Return Value

Success: | The 2D array containing the following information: [0][0] - Number of rows in array (n) [0][i] - Unused [n][0] - Handle [n][1] - Type (depends on the operating system) [n][2] - Attributes [n][3] - Access
Failure: | Sets the @error flag to non-zero, @extended f lag may contain the NTSTATUS error code.

See Also

Search ZwQuerySystemInformation in MSDN Library.

Example

#include <Array.au3>
#include <ProcessConstants.au3>
#include <WinAPI.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>

Global Const $PID = @AutoItPID

Local $hSource, $hTarget, $hObject

Local $aData = _WinAPI_EnumProcessHandles($PID)

If IsArray($aData) Then
    $hTarget = _WinAPI_GetCurrentProcess()
    $hSource = _WinAPI_OpenProcess($PROCESS_DUP_HANDLE, 0, $PID)
    If $hSource Then
        For $i = 1 To $aData[0][0]
            $hObject = _WinAPI_DuplicateHandle($hSource, $aData[$i][0], $hTarget, 0, 0, 2)
            If Not @error Then
                $aData[$i][1] = _WinAPI_GetObjectNameByHandle($hObject)
                _WinAPI_CloseHandle($hObject)
            EndIf
        Next
    EndIf
EndIf

_ArrayDisplay($aData, '_WinAPI_EnumProcessHandles')


Function _WinAPI_EnumProcessModules

Function Reference

_WinAPI_EnumProcessModules

Retrieves a handle and name for each module in the specified process

#include <WinAPIProc.au3>
_WinAPI_EnumProcessModules ( [$iPID = 0 [, $iFlag = 0]] )

Parameters

$iPID | [optional] The PID of the process. Default (0) is the current process.
$iFlag | [optional] The filter criteria. This parameter is valid only for Windows Vista or later, and can be one of the following values: $LIST_MODULES_32BIT $LIST_MODULES_64BIT $LIST_MODULES_ALL $LIST_MODULES_DEFAULT (Default)

Return Value

Success: | The 2D array containing the following information: [0][0] - Number of rows in array (n) [0][1] - Unused [n][0] - Handle to the module. [n][1] - The path to the file that contains the module.
Failure: | Sets the @error flag to non-zero.

Remarks

This function does not retrieve handles for modules that were loaded with the $LOAD_LIBRARY_AS_DATAFILE flag.
For more information, see _WinAPI_LoadLibraryEx().

Do not call _WinAPI_CloseHandle() on any of the handles returned by this function.
The information comes from a snapshot, so there are no resources to be freed.

If _WinAPI_EnumProcessModules() is called from a 32-bit application running on WOW64, it can only enumerate the modules of a 32-bit process.
If the process is a 64-bit process, this function fails and the last error code is ERROR_PARTIAL_COPY (299).

See Also

Search EnumProcessModulesEx in MSDN Library.

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>

If (_WinAPI_GetVersion() < '6.0') And (@AutoItX64) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'This example works from a 64-bit system only in Windows Vista or later.')
    Exit
EndIf

Local $aData = _WinAPI_EnumProcessModules()

_ArrayDisplay($aData, '_WinAPI_EnumProcessModules')


Function _WinAPI_EnumProcessThreads

Function Reference

_WinAPI_EnumProcessThreads

Enumerates a threads that belong to the specified process

#include <WinAPIProc.au3>
_WinAPI_EnumProcessThreads ( [$iPID = 0] )

Parameters

$iPID [optional] The PID of the process. Default (0) is the current process.

Return Value

Success: | The array of threads identifiers (ID). The zeroth array element contains the number of threads.
Failure: | Sets the @error flag to non-zero.


Function _WinAPI_EnumProcessWindows

Function Reference

_WinAPI_EnumProcessWindows

Enumerates a windows that belong to the specified process

#include <WinAPIProc.au3>
_WinAPI_EnumProcessWindows ( [$iPID = 0 [, $bVisible = True]] )

Parameters

$iPID | [optional] The PID of the process. Default (0) is the current process.
$bVisible | [optional] Specifies whether enumerates the invisible window, valid values: True - Enumerate only visible windows (Default). False - Enumerate all windows.

Return Value

Success: | The 2D array of the handles to the window and class for the specified process. [0][0] - Number of rows in array (n) [0][1] - Unused [n][0] - Window handle [n][1] - Window class name
Failure: | Sets the @error flag to non-zero.

Example

#include <Array.au3>
#include <WinAPIProc.au3>

Local $aData = _WinAPI_EnumProcessWindows(0, 0)

_ArrayDisplay($aData, '_WinAPI_EnumProcessWindows')


Function _WinAPI_GetCurrentProcessExplicitAppUserModelID

Function Reference

_WinAPI_GetCurrentProcessExplicitAppUserModelID

Retrieves the application-defined, explicit Application User Model ID for the current process

#include <WinAPIProc.au3>
_WinAPI_GetCurrentProcessExplicitAppUserModelID ( )

Return Value

Success: | The string that represents an Application User Model ID (AppUserModelID).
Failure: | Empty string and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

An application can only retrieve an AppUserModelID that has been explicitly set by using the _WinAPI_SetCurrentProcessExplicitAppUserModelID() function.
System-assigned default AppUserModelIDs cannot be retrieved.

This function requires Windows 7 or later.

Related

_WinAPI_SetCurrentProcessExplicitAppUserModelID

See Also

Search GetCurrentProcessExplicitAppUserModelID in MSDN Library.


Function _WinAPI_GetDeviceDriverBaseName

Function Reference

_WinAPI_GetDeviceDriverBaseName

Retrieves the base name of the specified device driver

#include <WinAPIProc.au3>
_WinAPI_GetDeviceDriverBaseName ( $pDriver )

Parameters

$pDriver The load address of the device driver. This value can be retrieved using the _WinAPI_EnumDeviceDrivers() function.

Return Value

Success: | The base name of the device driver.
Failure: | Empty string, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetDeviceDriverBaseName in MSDN Library.

Example

#include <Array.au3>
#include <WinAPIProc.au3>

Local $aInfo, $aData = _WinAPI_EnumDeviceDrivers()
If IsArray($aData) Then
    Dim $aInfo[$aData[0]][3]
    For $i = 1 To $aData[0]
        $aInfo[$i - 1][0] = $aData[$i]
        $aInfo[$i - 1][1] = _WinAPI_GetDeviceDriverBaseName($aData[$i])
        $aInfo[$i - 1][2] = _WinAPI_GetDeviceDriverFileName($aData[$i])
    Next
EndIf

_ArrayDisplay($aInfo, '_WinAPI_EnumDeviceDrivers')


Function _WinAPI_GetDeviceDriverFileName

Function Reference

_WinAPI_GetDeviceDriverFileName

Retrieves the path available for the specified device driver

#include <WinAPIProc.au3>
_WinAPI_GetDeviceDriverFileName ( $pDriver )

Parameters

$pDriver The load address of the device driver. This value can be retrieved using the _WinAPI_EnumDeviceDrivers() function.

Return Value

Success: | The path to the device driver.
Failure: | Empty string, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetDeviceDriverFileName in MSDN Library.

Example

#include <Array.au3>
#include <WinAPIProc.au3>

Local $aInfo, $aData = _WinAPI_EnumDeviceDrivers()
If IsArray($aData) Then
    Dim $aInfo[$aData[0]][3]
    For $i = 1 To $aData[0]
        $aInfo[$i - 1][0] = $aData[$i]
        $aInfo[$i - 1][1] = _WinAPI_GetDeviceDriverBaseName($aData[$i])
        $aInfo[$i - 1][2] = _WinAPI_GetDeviceDriverFileName($aData[$i])
    Next
EndIf

_ArrayDisplay($aInfo, '_WinAPI_EnumDeviceDrivers')


Function _WinAPI_GetExitCodeProcess

Function Reference

_WinAPI_GetExitCodeProcess

Retrieves the termination status of the specified process

#include <WinAPIProc.au3>
_WinAPI_GetExitCodeProcess ( $hProcess )

Parameters

$hProcess Handle to the process.

Return Value

Success: | The process termination status. If the process has not terminated and the function succeeds, the status returned is STILL_ACTIVE (259).
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetExitCodeProcess in MSDN Library.

Example

#include <ProcessConstants.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>

; _WinAPI_CreateProcess() will be the best solution
Local $iPID = Run('cmd.exe /k')
If Not $iPID Then
    Exit
EndIf

; Note, immediately open the process
Local $hProcess
If _WinAPI_GetVersion() >= 6.0 Then
    $hProcess = _WinAPI_OpenProcess($PROCESS_QUERY_LIMITED_INFORMATION, 0, $iPID)
Else
    $hProcess = _WinAPI_OpenProcess($PROCESS_QUERY_INFORMATION, 0, $iPID)
EndIf
If Not $hProcess Then
    Exit
EndIf

; Wait until the process exists, try enter "exit 6"
While ProcessExists($iPID)
    Sleep(100)
WEnd

ConsoleWrite('Exit code: ' & _WinAPI_GetExitCodeProcess($hProcess) & @CRLF)

_WinAPI_CloseHandle($hProcess)


Function _WinAPI_GetModuleFileNameEx

Function Reference

_WinAPI_GetModuleFileNameEx

Retrieves the fully-qualified path for the file containing the specified module

#include <WinAPIProc.au3>
_WinAPI_GetModuleFileNameEx ( $hProcess [, $hModule = 0] )

Parameters

$hProcess | Handle to the process that contains the module. The handle must have the $PROCESS_QUERY_INFORMATION or $PROCESS_QUERY_LIMITED_INFORMATION access right and the $PROCESS_VM_READ access right.
$hModule | [optional] Handle to the module. If this parameter is 0 (Default), the function retrieves the path of the executable file of the process.

Return Value

Success: | The fully-qualified path to the module.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

This function does not retrieve the path for modules that were loaded using the $LOAD_LIBRARY_AS_DATAFILE flag.
For more information, see _WinAPI_LoadLibraryEx().

Related

_WinAPI_LoadLibraryEx

See Also

Search GetModuleFileNameEx in MSDN Library.


Function _WinAPI_GetModuleInformation

Function Reference

_WinAPI_GetModuleInformation

Retrieves information about the specified module

#include <WinAPIProc.au3>
_WinAPI_GetModuleInformation ( $hProcess [, $hModule = 0] )

Parameters

$hProcess | Handle to the process that contains the module. The handle must have the $PROCESS_QUERY_INFORMATION or $PROCESS_QUERY_LIMITED_INFORMATION access right and the $PROCESS_VM_READ access right.
$hModule | [optional] Handle to the module. If this parameter is 0, the function retrieves information only about the executable file ("SizeOfImage" and "EntryPoint" members of the $tagMODULEINFO structure).

Return Value

Success: | $tagMODULEINFO structure that contains information about the module.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

This function does not retrieve information for modules that were loaded with the $LOAD_LIBRARY_AS_DATAFILE flag.
For more information, see _WinAPI_LoadLibraryEx().

Related

_WinAPI_LoadLibraryEx

See Also

Search GetModuleInformation in MSDN Library.


Function _WinAPI_GetParentProcess

Function Reference

_WinAPI_GetParentProcess

Retrieves the PID of the parent process for the specified process

#include <WinAPIProc.au3>
_WinAPI_GetParentProcess ( [$iPID = 0] )

Parameters

$iPID [optional] The PID of the process. Default (0) is the current process.

Return Value

Success: | The PID of the parent process.
Failure: | 0 and sets the @error flag to non-zero.


Function _WinAPI_GetPriorityClass

Function Reference

_WinAPI_GetPriorityClass

Retrieves the priority class for the specified process

#include <WinAPIProc.au3>
_WinAPI_GetPriorityClass ( [$iPID = 0] )

Parameters

$iPID [optional] The PID of the process. Default (0) is the current process.

Return Value

Success: | The priority class of the specified process ($*_PRIORITY_CLASS).
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

$*_PRIORITY_CLASS constants require #include <APIShellExConstants.au3>

See Also

Search GetPriorityClass in MSDN Library.


Function _WinAPI_GetProcessCommandLine

Function Reference

_WinAPI_GetProcessCommandLine

Retrieves the command-line string for the specified process

#include <WinAPIProc.au3>
_WinAPI_GetProcessCommandLine ( [$iPID = 0] )

Parameters

$iPID [optional] The PID of the process. Default (0) is the current process.

Return Value

Success: | The command-line string.
Failure: | Empty string and sets the @error flag to non-zero.

Remarks

This function uses undocumented API functions and may stop working properly in future versions of Windows.

Using this function for some processes may require full access rights. Use _WinAPI_AdjustTokenPrivileges()
function to enable $SE_DEBUG_NAME privilege before calling this function.

Related

_WinAPI_AdjustTokenPrivileges

Example

#RequireAdmin

#include <Array.au3>
#include <WinAPI.au3>
#include <WinAPIProc.au3>

Local $aAdjust, $aList = 0

; Enable "SeDebugPrivilege" privilege for obtain full access rights to another processes
Local $hToken = _WinAPI_OpenProcessToken(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))

_WinAPI_AdjustTokenPrivileges($hToken, $SE_DEBUG_NAME, $SE_PRIVILEGE_ENABLED, $aAdjust)

; Retrieve command-line arguments for all processes the system
If Not (@error Or @extended) Then
    $aList = ProcessList()
    For $i = 1 To $aList[0][0]
        $aList[$i][1] = _WinAPI_GetProcessCommandLine($aList[$i][1])
    Next
EndIf

; Enable SeDebugPrivilege privilege by default
_WinAPI_AdjustTokenPrivileges($hToken, $aAdjust, 0, $aAdjust)
_WinAPI_CloseHandle($hToken)

_ArrayDisplay($aList, '_WinAPI_GetProcessCommandLine')


Function _WinAPI_GetProcessFileName

Function Reference

_WinAPI_GetProcessFileName

Retrieves the fully-qualified path of the executable file for the specified process

#include <WinAPIProc.au3>
_WinAPI_GetProcessFileName ( [$iPID = 0] )

Parameters

$iPID [optional] The PID of the process. Default (0) is the current process.

Return Value

Success: | The fully-qualified path to the file.
Failure: | Sets the @error flag to non-zero.

See Also

Search GetModuleFileNameEx in MSDN Library.

Example

#include <WinAPIProc.au3>

Local $iID = ProcessExists('SciTE.exe')

If $iID Then
    ConsoleWrite(_WinAPI_GetProcessFileName($iID) & @CRLF)
EndIf


Function _WinAPI_GetProcessHandleCount

Function Reference

_WinAPI_GetProcessHandleCount

Retrieves the number of open handles that belong to the specified process

#include <WinAPIProc.au3>
_WinAPI_GetProcessHandleCount ( [$iPID = 0] )

Parameters

$iPID [optional] The PID of the process. Default (0) is the current process.

Return Value

Success: | The number of open handles.
Failure: | 0 and sets the @error flag to non-zero.

See Also

Search GetProcessHandleCount in MSDN Library.


Function _WinAPI_GetProcessID

Function Reference

_WinAPI_GetProcessID

Retrieves the process identifier of the specified process

#include <WinAPIProc.au3>
_WinAPI_GetProcessID ( $hProcess )

Parameters

$hProcess Handle to the process. The handle must have the $PROCESS_QUERY_INFORMATION or
$PROCESS_QUERY_LIMITED_INFORMATION access right.

Return Value

Success: | The process identifier.
Failure: | 0.

See Also

Search GetProcessId in MSDN Library.


Function _WinAPI_GetProcessIoCounters

Function Reference

_WinAPI_GetProcessIoCounters

Retrieves accounting information for all I/O operations performed by the specified process

#include <WinAPIProc.au3>
_WinAPI_GetProcessIoCounters ( [$iPID = 0] )

Parameters

$iPID [optional] The PID of the process. Default (0) is the current process.

Return Value

Success: | The array that contains the following information: [0] - The number of read operations performed. [1] - The number of write operations performed. [2] - The number of I/O operations performed, other than read and write operations. [3] - The number of bytes read. [4] - The number of bytes written. [5] - The number of bytes transferred during operations other than read and write operations.
Failure: | Sets the @error flag to non-zero.

See Also

Search GetProcessIoCounters in MSDN Library.


Function _WinAPI_GetProcessMemoryInfo

Function Reference

_WinAPI_GetProcessMemoryInfo

Retrieves information about the memory usage of the specified process

#include <WinAPIProc.au3>
_WinAPI_GetProcessMemoryInfo ( [$iPID = 0] )

Parameters

$iPID [optional] The PID of the process. Default (0) is the current process.

Return Value

Success: | The array that contains the following information: [0] - The number of page faults. [1] - The peak working set size, in bytes. [2] - The current working set size, in bytes. [3] - The peak paged pool usage, in bytes. [4] - The current paged pool usage, in bytes. [5] - The peak nonpaged pool usage, in bytes. [6] - The current nonpaged pool usage, in bytes. [7] - The current space allocated for the pagefile, in bytes. [8] - The peak space allocated for the pagefile, in bytes. [9] - The current amount of memory that cannot be shared with other processes, in bytes.
Failure: | Sets the @error flag to non-zero.

See Also

Search GetProcessMemoryInfo in MSDN Library.

Example

#include <WinAPIProc.au3>

Local $aData = _WinAPI_GetProcessMemoryInfo()

ConsoleWrite('Number of page faults: ' & $aData[0] & @CRLF)
ConsoleWrite('Peak working set size: ' & $aData[1] & ' bytes' & @CRLF)
ConsoleWrite('Current working set size: ' & $aData[2] & ' bytes' & @CRLF)
ConsoleWrite('Peak paged pool usage: ' & $aData[3] & ' bytes' & @CRLF)
ConsoleWrite('Current paged pool usage: ' & $aData[4] & ' bytes' & @CRLF)
ConsoleWrite('Peak nonpaged pool usage: ' & $aData[5] & ' bytes' & @CRLF)
ConsoleWrite('Current nonpaged pool usage: ' & $aData[6] & ' bytes' & @CRLF)
ConsoleWrite('Current space allocated for the pagefile: ' & $aData[7] & ' bytes' & @CRLF)
ConsoleWrite('Peak space allocated for the pagefile: ' & $aData[8] & ' bytes' & @CRLF)
ConsoleWrite('Current private space: ' & $aData[9] & ' bytes' & @CRLF)


Function _WinAPI_GetProcessName

Function Reference

_WinAPI_GetProcessName

Retrieves the name for the specified process

#include <WinAPIProc.au3>
_WinAPI_GetProcessName ( [$iPID = 0] )

Parameters

$iPID [optional] The PID of the process. Default (0) is the current process.

Return Value

Success: | The process name.
Failure: | Empty string and sets the @error flag to non-zero.


Function _WinAPI_GetProcessTimes

Function Reference

_WinAPI_GetProcessTimes

Retrieves timing information for the specified process

#include <WinAPIProc.au3>
_WinAPI_GetProcessTimes ( [$iPID = 0] )

Parameters

$iPID [optional] The PID of the process. Default (0) is the current process.

Return Value

Success: | The array that contains the following information: [0] - $tagFILETIME structure that contains the creation time of the process. [1] - The time that the process has executed in kernel mode, in 100-nanosecond time units. [2] - The time that the process has executed in user mode, in 100-nanosecond time units.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetProcessTimes in MSDN Library.

Example

#include <Date.au3>
#include <WinAPILocale.au3>
#include <WinAPIProc.au3>

Local $aFT, $tFT, $tST, $iID = ProcessExists('SciTE.exe')

If $iID Then
    $aFT = _WinAPI_GetProcessTimes($iID)
    $tFT = _Date_Time_FileTimeToLocalFileTime($aFT[0])
    $tST = _Date_Time_FileTimeToSystemTime($tFT)
    ConsoleWrite('!SciTE was run at: ' & _WinAPI_GetTimeFormat(0, $tST) & @CRLF)
EndIf


Function _WinAPI_GetProcessUser

Function Reference

_WinAPI_GetProcessUser

Retrieves the user and domain name for the specified process

#include <WinAPIProc.au3>
_WinAPI_GetProcessUser ( [$iPID = 0] )

Parameters

$iPID [optional] [optional] The PID of the process. Default (0) is the current process.

Return Value

Success: | The array that contains the following information: [0] - The user (account) name. [1] - The domain name.
Failure: | Sets the @error flag to non-zero.

Remarks

Using this function for some processes may require full access rights. Use _WinAPI_AdjustTokenPrivileges()
function to enable $SE_DEBUG_NAME privilege before calling this function.

Related

_WinAPI_AdjustTokenPrivileges

Example

#RequireAdmin

#include <Array.au3>
#include <WinAPI.au3>
#include <WinAPIProc.au3>

Local $aAdjust, $aList = 0

; Enable "SeDebugPrivilege" privilege for obtain full access rights to another processes
Local $hToken = _WinAPI_OpenProcessToken(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))
_WinAPI_AdjustTokenPrivileges($hToken, $SE_DEBUG_NAME, $SE_PRIVILEGE_ENABLED, $aAdjust)

; Retrieve user names for all processes the system
If Not (@error Or @extended) Then
    $aList = ProcessList()
    Local $aData
    For $i = 1 To $aList[0][0]
        $aData = _WinAPI_GetProcessUser($aList[$i][1])
        If IsArray($aData) Then
            $aList[$i][1] = $aData[0]
        Else
            $aList[$i][1] = ''
        EndIf
    Next
EndIf

; Enable SeDebugPrivilege privilege by default
_WinAPI_AdjustTokenPrivileges($hToken, $aAdjust, 0, $aAdjust)
_WinAPI_CloseHandle($hToken)

_ArrayDisplay($aList, '_WinAPI_GetProcessUser')


Function _WinAPI_GetProcessWorkingDirectory

Function Reference

_WinAPI_GetProcessWorkingDirectory

Retrieves the current working directory for the specified process

#include <WinAPIProc.au3>
_WinAPI_GetProcessWorkingDirectory ( [$iPID = 0] )

Parameters

$iPID [optional] The PID of the process. Default (0) is the current process.

Return Value

Success: | The path to the working directory.
Failure: | Empty string and sets the @error flag to non-zero.

Remarks

This function uses undocumented API functions and may stop working properly in future versions of Windows.

Using this function for some processes may require full access rights. Use _WinAPI_AdjustTokenPrivileges()
function to enable $SE_DEBUG_NAME privilege before calling this function.

Related

_WinAPI_AdjustTokenPrivileges

Example

#RequireAdmin

#include <Array.au3>
#include <WinAPI.au3>
#include <WinAPIProc.au3>

Local $aAdjust, $aList = 0

; Enable "SeDebugPrivilege" privilege for obtain full access rights to another processes
Local $hToken = _WinAPI_OpenProcessToken(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))
_WinAPI_AdjustTokenPrivileges($hToken, $SE_DEBUG_NAME, $SE_PRIVILEGE_ENABLED, $aAdjust)

; Retrieve working directories for all processes the system
If Not (@error Or @extended) Then
    $aList = ProcessList()
    For $i = 1 To $aList[0][0]
        $aList[$i][1] = _WinAPI_GetProcessWorkingDirectory($aList[$i][1])
    Next
EndIf

; Restore "SeDebugPrivilege" privilege by default
_WinAPI_AdjustTokenPrivileges($hToken, $aAdjust, 0, $aAdjust)
_WinAPI_CloseHandle($hToken)

_ArrayDisplay($aList, '_WinAPI_GetProcessCommandLine')


Function _WinAPI_GetThreadDesktop

Function Reference

_WinAPI_GetThreadDesktop

Retrieves a handle to the desktop assigned to the specified thread

#include <WinAPIProc.au3>
_WinAPI_GetThreadDesktop ( $iThreadId )

Parameters

$iThreadId The thread identifier. The _WinAPI_CreateProcess() and _WinAPI_GetCurrentThreadId() return thread identifiers.

Return Value

Success: | Handle to the desktop associated with the specified thread.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

You do not need to call the _WinAPI_CloseDesktop() function to close the returned handle.

Related

_WinAPI_CreateProcess, _WinAPI_GetCurrentThreadID

See Also

Search GetThreadDesktop in MSDN Library.

Example

#include <APIProcConstants.au3>
#include <APISysConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>

; Retrieve a handle to the current desktop and create a new desktop named "MyDesktop"
Local $hPrev = _WinAPI_GetThreadDesktop(_WinAPI_GetCurrentThreadId())
Local $hDesktop = _WinAPI_CreateDesktop('MyDesktop', BitOR($DESKTOP_CREATEWINDOW, $DESKTOP_SWITCHDESKTOP))
If Not $hDesktop Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create desktop.')
    Exit
EndIf

; Switch to the newly created desktop
_WinAPI_SwitchDesktop($hDesktop)

; Run "calc.exe" on "MyDesktop" and wait until a process will not be closed by user
Local $pText = _WinAPI_CreateString('MyDesktop')
Local $tProcess = DllStructCreate($tagPROCESS_INFORMATION)
Local $tStartup = DllStructCreate($tagSTARTUPINFO)
DllStructSetData($tStartup, 'Size', DllStructGetSize($tStartup))
DllStructSetData($tStartup, 'Desktop', $pText)
If _WinAPI_CreateProcess('', @SystemDir & '\calc.exe', 0, 0, 0, $CREATE_NEW_PROCESS_GROUP, 0, 0, $tStartup, $tProcess) Then
    ProcessWaitClose(DllStructGetData($tProcess, 'ProcessID'))
EndIf

; Switch to previous desktop and close "MyDesktop"
_WinAPI_SwitchDesktop($hPrev)
_WinAPI_CloseDesktop($hDesktop)

; Free memory allocated for a string
_WinAPI_FreeMemory($pText)


Function _WinAPI_GetThreadErrorMode

Function Reference

_WinAPI_GetThreadErrorMode

Retrieves the error mode for the calling thread

#include <WinAPIProc.au3>
_WinAPI_GetThreadErrorMode ( )

Return Value

Returns the process error mode ($SEM_*).

Remarks

This function requires Windows 7 or later.

See Also

Search GetThreadErrorMode in MSDN Library.


Function _WinAPI_GetWindowFileName

Function Reference

_WinAPI_GetWindowFileName

Retrieves the fully-qualified path of the module associated with the specified window handle

#include <WinAPIProc.au3>
_WinAPI_GetWindowFileName ( $hWnd )

Parameters

$hWnd Handle to the window whose module file name will be retrieved.

Return Value

Success: | The full path and file name.
Failure: | Sets the @error flag to non-zero.


Function _WinAPI_IsElevated

Function Reference

_WinAPI_IsElevated

Determines whether the current process is elevated

#include <WinAPIProc.au3>
_WinAPI_IsElevated ( )

Return Value

Success: | True - The current process is elevated. False - Otherwise. Additionally, the function always sets the @extended flag to one of the following values (any other value indicates an unexpected error). 0 - Indicates that either the User Account Control (UAC) is disabled, or the process is started by a standard user (not a member of the Administrators group). The following two values can be returned only if both the UAC is enabled and the user is a member of the Administrators group (that is, the user has a "split" token). 1 - Indicates that the process is running elevated. 2 - Indicates that the process is not running elevated.
Failure: | Sets the @error flag to non-zero.

Remarks

This function requires Windows Vista or later.


Function _WinAPI_IsProcessInJob

Function Reference

_WinAPI_IsProcessInJob

Determines whether the process is running in the specified job

#include <WinAPIProc.au3>
_WinAPI_IsProcessInJob ( $hProcess [, $hJob = 0] )

Parameters

$hProcess | Handle to the process to be tested. The handle must have the $PROCESS_QUERY_INFORMATION or $PROCESS_QUERY_LIMITED_INFORMATION access right.
$hJob | [optional] Handle to the job. If this parameter is 0 (Default), the function tests if the process is running under any job.

Return Value

True: | the process is running in the job.
False: | the process is not running in the job, call _WinAPI_GetLastError() to get extended error information.

Remarks

An application cannot obtain a handle to the job object in which it is running unless it has the name of the job
object. However, an application can call the _WinAPI_QueryInformationJobObject() function with 0 to obtain
information about the job object.

See Also

Search IsProcessInJob in MSDN Library.


Function _WinAPI_IsWow64Process

Function Reference

_WinAPI_IsWow64Process

Determines whether the specified process is running under WOW64

#include <WinAPIProc.au3>
_WinAPI_IsWow64Process ( [$iPID = 0] )

Parameters

$iPID [optional] The PID of the process. Default (0) is the current process.

Return Value

Success: | True - The process is running under WOW64. False - Otherwise.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search IsWow64Process in MSDN Library.


Function _WinAPI_OpenJobObject

Function Reference

_WinAPI_OpenJobObject

Opens an existing job object

#include <WinAPIProc.au3>
_WinAPI_OpenJobObject ( $sName [, $iAccess = $JOB_OBJECT_ALL_ACCESS [, $bInherit = False]] )

Parameters

$sName | The name of the job to be opened. Name comparisons are case sensitive.
$iAccess | [optional] The access to the job object. This parameter can be one or more of the following values. $JOB_OBJECT_ALL_ACCESS $JOB_OBJECT_ASSIGN_PROCESS $JOB_OBJECT_QUERY $JOB_OBJECT_SET_ATTRIBUTES $JOB_OBJECT_SET_SECURITY_ATTRIBUTES $JOB_OBJECT_TERMINATE
$bInherit | [optional] Specifies whether inherites the handle by a processes, valid values: True - The processes created by this process will inherit the handle. False - The processes do not inherit this handle (Default).

Return Value

Success: | Handle to the job object.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search OpenJobObject in MSDN Library.


Function _WinAPI_OpenProcessToken

Function Reference

_WinAPI_OpenProcessToken

Opens the access token associated with a process

#include <WinAPIProc.au3>
_WinAPI_OpenProcessToken ( $iAccess [, $hProcess = 0] )

Parameters

$iAccess | Access mask that specifies the requested types of access to the access token. This parameter can be one or more of the following values. $TOKEN_ALL_ACCESS $TOKEN_ADJUST_DEFAULT $TOKEN_ADJUST_GROUPS $TOKEN_ADJUST_PRIVILEGES $TOKEN_ADJUST_SESSIONID $TOKEN_ASSIGN_PRIMARY $TOKEN_DUPLICATE $TOKEN_EXECUTE $TOKEN_IMPERSONATE $TOKEN_QUERY $TOKEN_QUERY_SOURCE $TOKEN_READ $TOKEN_WRITE
$hProcess | [optional] Handle to the process whose access token is opened. The process must have the $PROCESS_QUERY_INFORMATION access permission. If this parameter is 0 (Default), will use the current process.

Return Value

Success: | Handle that identifies the newly opened access token.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

Close the access token handle returned through this function by calling _WinAPI_CloseHandle().

Related

_WinAPI_CloseHandle

See Also

Search OpenProcessToken in MSDN Library.


Function _WinAPI_QueryInformationJobObject

Function Reference

_WinAPI_QueryInformationJobObject

Retrieves limit and job state information from the job object

#include <WinAPIProc.au3>
_WinAPI_QueryInformationJobObject ( $hJob, $iJobObjectInfoClass, ByRef $tJobObjectInfo )

Parameters

$hJob | Handle to the job whose information is being queried. The handle must have the $JOB_OBJECT_QUERY access right. If this value is 0 and the calling process is associated with a job, the job associated with the calling process is used.
$iJobObjectInfoClass | The information class for the limits to be queried. This parameter specifies the type of $tJobObjectInfo structure, valid values: 1 - $tagJOBOBJECT_BASIC_ACCOUNTING_INFORMATION 2 - $tagJOBOBJECT_BASIC_LIMIT_INFORMATION 3 - $tagJOBOBJECT_BASIC_PROCESS_ID_LIST 4 - $tagJOBOBJECT_BASIC_UI_RESTRICTIONS 5 - $tagJOBOBJECT_SECURITY_LIMIT_INFORMATION 8 - $tagJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION 9 - $tagJOBOBJECT_EXTENDED_LIMIT_INFORMATION 11 - $tagJOBOBJECT_GROUP_INFORMATION
$tJobObjectInfo | $tagJOBOBJECT_* structure (see above) that retrieves the limit and job state information. This structure must be created before function call.

Return Value

Success: | The length of data (in bytes) written to the structure pointed to by the $tJobObjectInfo parameter.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search QueryInformationJobObject in MSDN Library.

Example

#include <APIProcConstants.au3>
#include <WinAPI.au3>
#include <WinAPIMisc.au3>
#include <WinAPIProc.au3>

Local Const $sTemp = @TempDir & '\Test.au3'

; Create temporary .au3 file
Local $hFile = FileOpen($sTemp, 2)
For $i = 1 To 3
    FileWriteLine($hFile, 'Run(@SystemDir & "\calc.exe")' & @CRLF & 'Sleep(100)')
Next
FileClose($hFile)

; Run 3 times the "calc.exe" and wait until you have closed all 3 processes
_RunWaitEx(@AutoItExe & ' /AutoIt3ExecuteScript "' & $sTemp & '"')

; Delete temporary .au3 file
FileDelete($sTemp)

Func _RunWaitEx($sCmd)
    ; Original idea by amel27

    Local $tProcess = DllStructCreate($tagPROCESS_INFORMATION)
    Local $tStartup = DllStructCreate($tagSTARTUPINFO)
    Local $tInfo = DllStructCreate($tagJOBOBJECT_BASIC_ACCOUNTING_INFORMATION)

    Local $hJob = _WinAPI_CreateJobObject()
    If Not $hJob Then Return SetError(1, 0, 0)

    DllStructSetData($tStartup, 'Size', DllStructGetSize($tStartup))
    If Not _WinAPI_CreateProcess('', $sCmd, 0, 0, 0, BitOR($CREATE_BREAKAWAY_FROM_JOB, $CREATE_SUSPENDED), 0, 0, $tStartup, $tProcess) Then
        Return SetError(1, _WinAPI_CloseHandle($hJob), 0)
    EndIf
    Local $hProcess = DllStructGetData($tProcess, 'hProcess')
    Local $hThread = DllStructGetData($tProcess, 'hThread')
    _WinAPI_AssignProcessToJobObject($hJob, $hProcess)
    _WinAPI_ResumeThread($hThread)
    _WinAPI_CloseHandle($hThread)
    Do
        If Not _WinAPI_QueryInformationJobObject($hJob, 1, $tInfo) Then
            ExitLoop
        EndIf
        Sleep(100)
    Until Not DllStructGetData($tInfo, 'ActiveProcesses')
    _WinAPI_CloseHandle($hProcess)
    _WinAPI_CloseHandle($hJob)
    Return 1
EndFunc   ;==>_RunWaitEx

Func _WinAPI_ResumeThread($hThread)
    Local $aRet = DllCall('kernel32.dll', 'dword', 'ResumeThread', 'ptr', $hThread)
    If @error Or (_WinAPI_DWordToInt($aRet[0]) = -1) Then Return SetError(1, 0, -1)

    Return $aRet[0]
EndFunc   ;==>_WinAPI_ResumeThread


Function _WinAPI_SetInformationJobObject

Function Reference

_WinAPI_SetInformationJobObject

Sets limits for a job object

#include <WinAPIProc.au3>
_WinAPI_SetInformationJobObject ( $hJob, $iJobObjectInfoClass, $tJobObjectInfo )

Parameters

$hJob | Handle to the job whose limits are being set. The handle must have the $JOB_OBJECT_SET_ATTRIBUTES access right.
$iJobObjectInfoClass | The information class for the limits to be set. This parameter specifies the type of $tJobObjectInfo structure, valid values: 2 - $tagJOBOBJECT_BASIC_LIMIT_INFORMATION 4 - $tagJOBOBJECT_BASIC_UI_RESTRICTIONS 5 - $tagJOBOBJECT_SECURITY_LIMIT_INFORMATION 6 - $tagJOBOBJECT_END_OF_JOB_TIME_INFORMATION 7 - $tagJOBOBJECT_ASSOCIATE_COMPLETION_PORT 9 - $tagJOBOBJECT_EXTENDED_LIMIT_INFORMATION 11 - $tagJOBOBJECT_GROUP_INFORMATION
$tJobObjectInfo | $tagJOBOBJECT_* structure that sets the limit and job state information.

Return Value

Success: | True
Failure: | False

See Also

Search SetInformationJobObject in MSDN Library.


Function _WinAPI_SetPriorityClass

Function Reference

_WinAPI_SetPriorityClass

Sets the priority class for the specified process

#include <WinAPIProc.au3>
_WinAPI_SetPriorityClass ( $iPriority [, $iPID = 0] )

Parameters

$iPriority | The priority class for the process. This parameter can be one of the following values. $ABOVE_NORMAL_PRIORITY_CLASS $BELOW_NORMAL_PRIORITY_CLASS $HIGH_PRIORITY_CLASS $IDLE_PRIORITY_CLASS $NORMAL_PRIORITY_CLASS $REALTIME_PRIORITY_CLASS Windows Vista or later $PROCESS_MODE_BACKGROUND_BEGIN $PROCESS_MODE_BACKGROUND_END
$iPID | [optional] The PID of the process. Default (0) is the current process.

Return Value

Success: | True
Failure: | False

See Also

Search SetPriorityClass in MSDN Library.

Example

#include <APIProcConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIProc.au3>

Run(@SystemDir & '\taskmgr.exe')
Sleep(1000)

_WinAPI_SetPriorityClass($HIGH_PRIORITY_CLASS)
MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), '', 'Look what priority class has the "' & _WinAPI_PathStripPath(FileGetLongName(@AutoItExe)) & '" (' & @AutoItPID & ') process.' & @CRLF & @CRLF & 'Should be "High".')

_WinAPI_SetPriorityClass($IDLE_PRIORITY_CLASS)
MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), '', 'Look what priority class has the "' & _WinAPI_PathStripPath(FileGetLongName(@AutoItExe)) & '" (' & @AutoItPID & ') process.' & @CRLF & @CRLF & 'Should be "Low".')


Function _WinAPI_SetThreadDesktop

Function Reference

_WinAPI_SetThreadDesktop

Assigns the specified desktop to the calling thread

#include <WinAPIProc.au3>
_WinAPI_SetThreadDesktop ( $hDesktop )

Parameters

$hDesktop Handle to the desktop to be assigned to the calling thread. This desktop must be associated with the
current window station for the process.

Return Value

Success: | True
Failure: | False

Remarks

The _WinAPI_SetThreadDesktop() function will fail if the calling thread has any windows or hooks on its current
desktop (unless the $hDesktop parameter is a handle to the current desktop).

See Also

Search SetThreadDesktop in MSDN Library.


Function _WinAPI_SetThreadErrorMode

Function Reference

_WinAPI_SetThreadErrorMode

Controls whether the system will handle the specified types of serious errors or whether the calling thread will handle them

#include <WinAPIProc.au3>
_WinAPI_SetThreadErrorMode ( $iMode )

Parameters

$iMode The thread error mode. This parameter can be one or more of the following values.
$SEM_FAILCRITICALERRORS
$SEM_NOGPFAULTERRORBOX
$SEM_NOOPENFILEERRORBOX

Return Value

Success: | The thread's previous error mode ($SEM_*).
Failure: | Sets the @error flag to non-zero.

Remarks

This function requires Windows 7 or later.

See Also

Search SetThreadErrorMode in MSDN Library.


Function _WinAPI_SetThreadExecutionState

Function Reference

_WinAPI_SetThreadExecutionState

Prevents the system from entering sleep or turning off the display while the current application is running

#include <WinAPIProc.au3>
_WinAPI_SetThreadExecutionState ( $iFlags )

Parameters

$iFlags The thread's execution requirements. This parameter can be one or more of the following values.
$ES_AWAYMODE_REQUIRED
$ES_CONTINUOUS
$ES_DISPLAY_REQUIRED
$ES_SYSTEM_REQUIRED
$ES_USER_PRESENT

Return Value

Success: | The value is the previous thread execution state.
Failure: | 0.

Remarks

The _WinAPI_SetThreadExecutionState() function cannot be used to prevent the user from putting the computer to
sleep. Applications should respect that the user expects a certain behavior when they close the lid on their
laptop or press the power button.

This function does not stop the screen saver from executing.

See Also

Search SetThreadExecutionState in MSDN Library.


Function _WinAPI_TerminateJobObject

Function Reference

_WinAPI_TerminateJobObject

Terminates all processes currently associated with the job

#include <WinAPIProc.au3>
_WinAPI_TerminateJobObject ( $hJob [, $iExitCode = 0] )

Parameters

$hJob | A handle to the job whose processes will be terminated. This handle must have the $JOB_OBJECT_TERMINATE access right. Furthermore, the handle for each process in the job object must have the $PROCESS_TERMINATE access right.
$iExitCode | [optional] The exit code to be used by all processes and threads in the job object.

Return Value

Success: | True
Failure: | False

Remarks

If the job is nested, the function terminates all processes currently associated with the job and all of its
child jobs in the hierarchy.

See Also

Search TerminateJobObject in MSDN Library.


Function _WinAPI_TerminateProcess

Function Reference

_WinAPI_TerminateProcess

Terminates the specified process and all of its threads

#include <WinAPIProc.au3>
_WinAPI_TerminateProcess ( $hProcess [, $iExitCode = 0] )

Parameters

$hProcess | A handle to the process to be terminated. The handle must have the $PROCESS_TERMINATE access right.
$iExitCode | [optional] The exit code to be used by the process and threads terminated as a result of this call.

Return Value

Success: | True
Failure: | False

Remarks

This function stops execution of all threads within the process and requests cancellation of all pending I/O.
The terminated process cannot exit until all pending I/O has been completed or cancelled. When a process terminates,
its kernel object is not destroyed until all processes released their open handles.

This function is asynchronous; it initiates termination and returns immediately. If you need to be sure the
process has terminated, call the _WinAPI_WaitForSingleObject() function with a handle to the process.

A process cannot prevent itself from being terminated.

Related

_WinAPI_WaitForSingleObject

See Also

Search TerminateProcess in MSDN Library.


Function _WinAPI_UserHandleGrantAccess

Function Reference

_WinAPI_UserHandleGrantAccess

Grants or denies access to a handle to a User object to a job that has a user-interface restriction

#include <WinAPIProc.au3>
_WinAPI_UserHandleGrantAccess ( $hObject, $hJob, $bGrant )

Parameters

$hObject | Handle to the User object.
$hJob | Handle to the job to be granted access to the User handle.
$bGrant | Specifies whether to grant or deny access to the User handle, valid values: True - The processes associated with the job can recognize and use the handle. False - The processes cannot use the handle.

Return Value

Success: | True
Failure: | False

Remarks

The _WinAPI_UserHandleGrantAccess() function can be called only from a process not associated with the job
specified by the $hJob parameter. The User handle must not be owned by a process or thread associated
with the job.

See Also

Search UserHandleGrantAccess in MSDN Library.


User Defined Functions

Synchronization user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIProc.au3>.

User Defined Function | Description
_WinAPI_CreateMutex | Creates or opens a named or unnamed mutex object
_WinAPI_CreateSemaphore | Creates or opens a named or unnamed semaphore object
_WinAPI_OpenMutex | Opens an existing named mutex object
_WinAPI_OpenSemaphore | Opens an existing named semaphore object
_WinAPI_ReleaseMutex | Releases ownership of the specified mutex object
_WinAPI_ReleaseSemaphore | Increases the count of the specified semaphore object by a specified amount
_WinAPI_ResetEvent | Sets the specified event object to the nonsignaled state


Function _WinAPI_CreateMutex

Function Reference

_WinAPI_CreateMutex

Creates or opens a named or unnamed mutex object

#include <WinAPIProc.au3>
_WinAPI_CreateMutex ( $sMutex [, $bInitial = True [, $tSecurity = 0]] )

Parameters

$sMutex | The name of the mutex object. Name comparisons are case sensitive.
$bInitial | [optional] Specifies whether the calling process obtains the initial ownership of the mutex object, valid values: True - The calling thread obtains initial ownership of the mutex object (Default). False - The calling thread does not obtain ownership of the mutex object.
$tSecurity | [optional] $tagSECURITY_ATTRIBUTES structure that specifies a security descriptor for the new mutex. If this parameter is 0 (Default), the mutex gets a default security descriptor.

Return Value

Success: | The handle to the newly created mutex object.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

If the mutex is a named mutex and the object existed before this function call, the return value is a handle to the existing object, _WinAPI_GetLastError() returns ERROR_ALREADY_EXISTS (183), $bInitial is ignored, and the calling thread is not granted ownership.
However, if the caller has limited access rights, the function will fail with ERROR_ACCESS_DENIED (5) and the caller should use the _WinAPI_OpenMutex() function.

Any process can specify the mutex-object handle in a call to one of the wait functions.
The single-object wait functions return when the state of the specified object is signaled.
The multiple-object wait functions can be instructed to return either when any one or when all of the specified objects are signaled.
When a wait function returns, the waiting thread is released to continue its execution.

Two or more processes can call _WinAPI_CreateMutex() to create the same named mutex.
The first process actually creates the mutex, and subsequent processes with sufficient access rights simply open a handle to the existing mutex.
This enables multiple processes to get handles of the same mutex, while relieving the user of the responsibility of ensuring that the creating process is started first.
When using this technique, you should set the $bInitial parameter to False; otherwise, it can be difficult to be certain which process has initial ownership.

Use the _WinAPI_CloseHandle() function to close the handle.
The system closes the handle automatically when the process terminates.
The mutex object is destroyed when its last handle has been closed.

Related

_WinAPI_CloseHandle, _WinAPI_OpenMutex

See Also

Search CreateMutex in MSDN Library.


Function _WinAPI_CreateSemaphore

Function Reference

_WinAPI_CreateSemaphore

Creates or opens a named or unnamed semaphore object

#include <WinAPIProc.au3>
_WinAPI_CreateSemaphore ( $sSemaphore, $iInitial, $iMaximum [, $tSecurity = 0] )

Parameters

$sSemaphore | The name of the semaphore to be opened. Name comparisons are case sensitive.
$iInitial | The initial count for the semaphore object. This value must be greater than or equal to zero and less than or equal to $iMaximum.
$iMaximum | The maximum count for the semaphore object. This value must be greater than zero.
$tSecurity | [optional] $tagSECURITY_ATTRIBUTES structure that specifies a security descriptor for the new semaphore. If this parameter is 0 (Default), the semaphore gets a default security descriptor.

Return Value

Success: | The handle to the newly created semaphore object.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

If the named semaphore object existed before the function call, the function returns a handle to the existing object.

Any process can specify the semaphore-object handle in a call to _WinAPI_WaitFor... functions. The single-object wait functions return when the state of the specified object is signaled. The multiple-object wait functions can be instructed to return either when any one or when all of the specified objects are signaled. When a wait function returns, the waiting process is released to continue its execution.

The state of a semaphore object is signaled when its count is greater than zero, and nonsignaled when its count is equal to zero.
The $iInitial parameter specifies the initial count. Each time a waiting process is released because of the semaphore's signaled state, the count of the semaphore is decreased by one.
Use the _WinAPI_ReleaseSemaphore() function to increment a semaphore's count by a specified amount.
The count can never be less than zero or greater than the value specified in the $iMaximum parameter.

Use the _WinAPI_CloseHandle() function to close the handle. The system closes the handle automatically when the process terminates. The semaphore object is destroyed when its last handle has been closed.

Related

_WinAPI_CloseHandle, _WinAPI_ReleaseSemaphore

See Also

Search CreateSemaphore in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIProc.au3>

If Not @Compiled Then
    MsgBox($MB_SYSTEMMODAL, '', 'To run this script, you must first compile it and then run the (.exe) file.')
    Exit
EndIf

Local $hSemaphore = _WinAPI_CreateSemaphore('MySemaphore', 2, 2)

_WinAPI_WaitForSingleObject($hSemaphore)
_MyGUI()
_WinAPI_ReleaseSemaphore($hSemaphore)
_WinAPI_CloseHandle($hSemaphore)

Func _MyGUI()
    GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'))
    GUISetState(@SW_SHOW)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>_MyGUI


Function _WinAPI_OpenMutex

Function Reference

_WinAPI_OpenMutex

Opens an existing named mutex object

#include <WinAPIProc.au3>
_WinAPI_OpenMutex ( $sMutex [, $iAccess = $MUTEX_ALL_ACCESS [, $bInherit = False]] )

Parameters

$sMutex | The name of the mutex to be opened. Name comparisons are case sensitive.
$iAccess | [optional] The access to the mutex object. The function fails if the security descriptor of the specified object does not permit the requested access for the calling process. This parameter can be one of the following values. $MUTEX_ALL_ACCESS $MUTEX_MODIFY_STATE
$bInherit | [optional] Specifies whether inherites the handle by a processes, valid values: True - The processes created by this process will inherit the handle. False - The processes do not inherit this handle (Default).

Return Value

Success: | The handle to the mutex object.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

The function succeeds only if some process has already created the mutex by using the _WinAPI_CreateMutex()
function. The calling process can use the returned handle in any function that requires a handle to
a mutex object.

Related

_WinAPI_CreateMutex

See Also

Search OpenMutex in MSDN Library.


Function _WinAPI_OpenSemaphore

Function Reference

_WinAPI_OpenSemaphore

Opens an existing named semaphore object

#include <WinAPIProc.au3>
_WinAPI_OpenSemaphore ( $sSemaphore [, $iAccess = 0x001F0003 [, $bInherit = False]] )

Parameters

$sSemaphore | The name of the semaphore to be opened. Name comparisons are case sensitive.
$iAccess | [optional] The access to the semaphore object. The function fails if the security descriptor of the specified object does not permit the requested access for the calling process. This parameter can be one of the following values. $SEMAPHORE_ALL_ACCESS (Default) $SEMAPHORE_MODIFY_STATE
$bInherit | [optional] Specifies whether inherites the handle by a processes, valid values: True - The processes created by this process will inherit the handle. False - The processes do not inherit this handle (Default).

Return Value

Success: | The handle to the semaphore object.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

The function succeeds only if some process has already created the semaphore by using the _WinAPI_CreateSemaphore()
function. The calling process can use the returned handle in any function that requires a handle to
a semaphore object.

Related

_WinAPI_CreateSemaphore

See Also

Search OpenSemaphore in MSDN Library.


Function _WinAPI_ReleaseMutex

Function Reference

_WinAPI_ReleaseMutex

Releases ownership of the specified mutex object

#include <WinAPIProc.au3>
_WinAPI_ReleaseMutex ( $hMutex )

Parameters

$hMutex Handle to the mutex object. The _WinAPI_CreateMutex() or _WinAPI_OpenMutex() function returns this handle.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

The _WinAPI_ReleaseMutex() function fails if the calling thread does not own the mutex object.

Related

_WinAPI_CreateMutex, _WinAPI_OpenMutex

See Also

Search ReleaseMutex in MSDN Library.


Function _WinAPI_ReleaseSemaphore

Function Reference

_WinAPI_ReleaseSemaphore

Increases the count of the specified semaphore object by a specified amount

#include <WinAPIProc.au3>
_WinAPI_ReleaseSemaphore ( $hSemaphore [, $iIncrease = 1] )

Parameters

$hSemaphore | Handle to the semaphore object. The _WinAPI_CreateSemaphore() or _WinAPI_OpenSemaphore() function returns this handle.
$iIncrease | [optional] The amount by which the semaphore object's current count is to be increased. The value must be greater than zero. If the specified amount would cause the semaphore's count to exceed the maximum count that was specified when the semaphore was created, the count is not changed and the function returns 0. Default is 1.

Return Value

Success: | The previous count for the semaphore.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to et extendd error information.

Remarks

The state of a semaphore object is signaled when its count is greater than zero and nonsignaled when its count
is equal to zero. The process that calls the _WinAPI_CreateSemaphore() function specifies the semaphore's initial
count. Each time a waiting process is released because of the semaphore's signaled state, the count of the
semaphore is decreased by one.

Related

_WinAPI_CreateSemaphore, _WinAPI_OpenSemaphore

See Also

Search ReleaseSemaphore in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIProc.au3>

If Not @Compiled Then
    MsgBox($MB_SYSTEMMODAL, '', 'To run this script, you must first compile it and then run the (.exe) file.')
    Exit
EndIf

Local $hSemaphore = _WinAPI_CreateSemaphore('MySemaphore', 2, 2)

_WinAPI_WaitForSingleObject($hSemaphore)
_MyGUI()
_WinAPI_ReleaseSemaphore($hSemaphore)
_WinAPI_CloseHandle($hSemaphore)

Func _MyGUI()
    GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'))
    GUISetState(@SW_SHOW)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>_MyGUI


Function _WinAPI_ResetEvent

Function Reference

_WinAPI_ResetEvent

Sets the specified event object to the nonsignaled state

#include <WinAPIProc.au3>
_WinAPI_ResetEvent ( $hEvent )

Parameters

$hEvent Handle to the event object. The _WinAPI_CreateEvent() function returns this handle.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

The state of an event object remains nonsignaled until it is explicitly set to signaled by the _WinAPI_SetEvent() function.
This nonsignaled state blocks the execution of any threads that have specified the event object in a call to one of the _WinAPI_Wait... functions.

The _WinAPI_ResetEvent() function is used primarily for manual-reset event objects, which must be set explicitly to the nonsignaled state.
Auto-reset event objects automatically change from signaled to nonsignaled after a single waiting thread is released.

Related

_WinAPI_CreateEvent, _WinAPI_SetEvent

See Also

Search ResetEvent in MSDN Library.

Example

#include <WinAPI.au3>
#include <WinAPIProc.au3> ;needed for _WinAPI_ResetEvent()

Global $g_tEvents = DllStructCreate("handle Event[3];")
$g_tEvents.Event(1) = _WinAPI_CreateEvent(0, True, False)
$g_tEvents.Event(2) = _WinAPI_CreateEvent(0, True, False)
$g_tEvents.Event(3) = _WinAPI_CreateEvent(0, True, False)

HotKeySet("{ESC}", "_Exit")
AdlibRegister("_FireEvent_1", 500)
AdlibRegister("_FireEvent_2", 800)

Local $iEvent
While 1
    $iEvent = _WinAPI_WaitForMultipleObjects(3, $g_tEvents, False, 100)
    Switch $iEvent
        Case 0
            ConsoleWrite("+ First Event" & @CRLF)
            _WinAPI_ResetEvent($g_tEvents.Event(1))
        Case 1
            ConsoleWrite("> Second Event" & @CRLF)
            _WinAPI_ResetEvent($g_tEvents.Event(2))
        Case 2
            ConsoleWrite("! Exit Event" & @CRLF)
            AdlibUnRegister("_FireEvent_1")
            AdlibUnRegister("_FireEvent_2")
            _WinAPI_CloseHandle($g_tEvents.Event(1))
            _WinAPI_CloseHandle($g_tEvents.Event(2))
            _WinAPI_CloseHandle($g_tEvents.Event(3))
            ExitLoop
        Case -1 ;Error
            ExitLoop
    EndSwitch
WEnd

Func _Exit()
    _WinAPI_SetEvent($g_tEvents.Event(3))
EndFunc   ;==>_Exit

Func _FireEvent_1()
    _WinAPI_SetEvent($g_tEvents.Event(1))
EndFunc   ;==>_FireEvent_1

Func _FireEvent_2()
    _WinAPI_SetEvent($g_tEvents.Event(2))
EndFunc   ;==>_FireEvent_2


User Defined Functions

Registry user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIReg.au3>.

User Defined Function | Description
_WinAPI_AddMRUString | Adds a string to the top of the most recently used (MRU) list
_WinAPI_AssocGetPerceivedType | Retrieves a file's perceived type based on its extension
_WinAPI_AssocQueryString | Searches for and retrieves a file or protocol association-related string from the registry
_WinAPI_CreateMRUList | Creates a new most recently used (MRU) list
_WinAPI_DllInstall | Registers OLE controls such as DLL or ActiveX Controls (OCX) files
_WinAPI_DllUninstall | Unregisters OLE controls such as DLL or ActiveX Controls (OCX) files
_WinAPI_EnumMRUList | Enumerates the contents of the most recently used (MRU) list
_WinAPI_FreeMRUList | Frees the handle associated with the most recently used (MRU) list and writes cached data to the registry
_WinAPI_GetRegKeyNameByHandle | Retrieves a name of the specified registry key
_WinAPI_RegCloseKey | Closes a handle to the specified registry key
_WinAPI_RegConnectRegistry | Establishes a connection to a predefined registry key on another computer
_WinAPI_RegCopyTree | Recursively copies the subkeys and values of the source subkey to the destination key
_WinAPI_RegCopyTreeEx | Copies the specified registry key, along with its values and subkeys, to the specified destination key
_WinAPI_RegCreateKey | Creates the specified registry key
_WinAPI_RegDeleteEmptyKey | Deletes an empty key
_WinAPI_RegDeleteKey | Deletes a subkey and its values
_WinAPI_RegDeleteKeyValue | Removes the specified value from the specified registry key and subkey
_WinAPI_RegDeleteTree | Deletes a subkey and all its descendants
_WinAPI_RegDeleteTreeEx | Deletes the subkeys and values of the specified key recursively
_WinAPI_RegDeleteValue | Removes a named value from the specified registry key
_WinAPI_RegDisableReflectionKey | Disables registry reflection for the specified key
_WinAPI_RegDuplicateHKey | Duplicates a registry key's handle
_WinAPI_RegEnableReflectionKey | Restores registry reflection for the specified disabled key
_WinAPI_RegEnumKey | Enumerates the subkeys of the specified open registry key
_WinAPI_RegEnumValue | Enumerates the values for the specified open registry key
_WinAPI_RegFlushKey | Writes all the attributes of the specified open registry key into the registry
_WinAPI_RegLoadMUIString | Loads the specified string from the specified key and subkey
_WinAPI_RegNotifyChangeKeyValue | Notifies the caller about changes to the attributes or contents of a specified registry key
_WinAPI_RegOpenKey | Opens the specified registry key
_WinAPI_RegQueryInfoKey | Retrieves information about the specified registry key
_WinAPI_RegQueryLastWriteTime | Retrieves information about the last write time to the specified registry key
_WinAPI_RegQueryMultipleValues | Retrieves the type and data for a list of value names associated with an open registry key
_WinAPI_RegQueryReflectionKey | Determines whether reflection has been disabled or enabled for the specified key
_WinAPI_RegQueryValue | Retrieves the type and data for the specified value name associated with an open registry key
_WinAPI_RegRestoreKey | Reads the registry information in a specified file and copies it over the specified key
_WinAPI_RegSaveKey | Saves the specified key and all of its subkeys and values to a new file, in the standard format
_WinAPI_RegSetValue | Sets the data and type of a specified value under a registry key
_WinAPI_SfcIsKeyProtected | Determines whether the specified registry key is protected


Function _WinAPI_AddMRUString

Function Reference

_WinAPI_AddMRUString

Adds a string to the top of the most recently used (MRU) list

#include <WinAPIReg.au3>
_WinAPI_AddMRUString ( $hMRU, $sStr )

Parameters

$hMRU | Handle of the MRU list.
$sStr | The string be added.

Return Value

Success: | Non negative value.
Failure: | (-1).

Related

_WinAPI_CreateMRUList, _WinAPI_FreeMRUList

See Also

Search AddMRUStringW in MSDN Library.

Example

#include <APIRegConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIReg.au3>

Local $hMRU = _WinAPI_CreateMRUList($HKEY_CURRENT_USER, 'Software\MyProg\MRU', 5)

; Create MRU list in the registry (only at first start example)
RegRead('HKCU\Software\MyProg\MRU', 'MRUList')
If @error Then
    For $i = 5 To 1 Step -1
        _WinAPI_AddMRUString($hMRU, 'String' & $i)
    Next
EndIf

GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 320, 92)
Local $idCombo = GUICtrlCreateCombo(_WinAPI_EnumMRUList($hMRU, 0), 10, 20, 300, 21, $CBS_DROPDOWNLIST)
Local $iCount = _WinAPI_EnumMRUList($hMRU, -1)
Local $sData = ''
For $i = 1 To $iCount - 1
    $sData &= _WinAPI_EnumMRUList($hMRU, $i) & '|'
Next
GUICtrlSetData(-1, $sData)
Local $idButton = GUICtrlCreateButton('OK', 125, 58, 70, 23)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            _WinAPI_AddMRUString($hMRU, GUICtrlRead($idCombo))
            ExitLoop
    EndSwitch
WEnd

_WinAPI_FreeMRUList($hMRU)


Function _WinAPI_AssocGetPerceivedType

Function Reference

_WinAPI_AssocGetPerceivedType

Retrieves a file's perceived type based on its extension

#include <WinAPIReg.au3>
_WinAPI_AssocGetPerceivedType ( $sExt )

Parameters

$sExt The file's extension. This should include the leading period, for example ".txt".

Return Value

Success: | The array containing the following information: [0] - The perceived type ($PERCEIVED_TYPE_*). [1] - The source of the perceived type information ($PERCEIVEDFLAG_*). [2] - The perceived type string, for instance "text" or "video".
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search AssocGetPerceivedType in MSDN Library.

Example

#include <WinAPIReg.au3>

Local $sExt = '.wav'
Local $aData = _WinAPI_AssocGetPerceivedType($sExt)

If IsArray($aData) Then
    ConsoleWrite('(' & $sExt & ')' & @CRLF)
    ConsoleWrite('--------------------' & @CRLF)
    ConsoleWrite('Type:   ' & $aData[0] & @CRLF)
    ConsoleWrite('Source: ' & $aData[1] & @CRLF)
    ConsoleWrite('String: ' & $aData[2] & @CRLF)
EndIf


Function _WinAPI_AssocQueryString

Function Reference

_WinAPI_AssocQueryString

Searches for and retrieves a file or protocol association-related string from the registry

#include <WinAPIReg.au3>
_WinAPI_AssocQueryString ( $sAssoc, $iType [, $iFlags = 0 [, $sExtra = '']] )

Parameters

$sAssoc | The string that is used to determine the root key. The following four types of strings can be used. The file name extension, such as ".txt". The class identifier (CLSID) GUID in the standard "{GUID}" format. The application's ProgID, such as Word.Document.8. The name of an application's .exe file. The $ASSOCF_OPEN_BYEXENAME flag must be set.
$iType | The value that specifies the type of string that is to be returned. This parameter can be one of the following values: $ASSOCSTR_COMMAND $ASSOCSTR_EXECUTABLE $ASSOCSTR_FRIENDLYDOCNAME $ASSOCSTR_FRIENDLYAPPNAME $ASSOCSTR_NOOPEN $ASSOCSTR_SHELLNEWVALUE $ASSOCSTR_DDECOMMAND $ASSOCSTR_DDEIFEXEC $ASSOCSTR_DDEAPPLICATION $ASSOCSTR_DDETOPIC $ASSOCSTR_INFOTIP $ASSOCSTR_QUICKTIP $ASSOCSTR_TILEINFO $ASSOCSTR_CONTENTTYPE $ASSOCSTR_DEFAULTICON $ASSOCSTR_SHELLEXTENSION
$iFlags | [optional] The flags that can be used to control the search. It can be any combination of the following values, except that only one $ASSOCF_INIT_* value can be included. $ASSOCF_INIT_NOREMAPCLSID $ASSOCF_INIT_BYEXENAME $ASSOCF_OPEN_BYEXENAME $ASSOCF_INIT_DEFAULTTOSTAR $ASSOCF_INIT_DEFAULTTOFOLDER $ASSOCF_NOUSERSETTINGS $ASSOCF_NOTRUNCATE $ASSOCF_VERIFY $ASSOCF_REMAPRUNDLL $ASSOCF_NOFIXUPS $ASSOCF_IGNOREBASECLASS $ASSOCF_INIT_IGNOREUNKNOWN
$sExtra | [optional] The string with additional information about the location of the string. It is typically set to a Shell verb such as open.

Return Value

Success: | The string that contains the requested ($ASSOCSTR_*) information.
Failure: | Empty string and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search AssocQueryString in MSDN Library.

Example

#include <APIRegConstants.au3>
#include <WinAPIReg.au3>

Local $sExt = '.au3'

ConsoleWrite('(' & $sExt & ')' & @CRLF)
ConsoleWrite('--------------------' & @CRLF)
ConsoleWrite('Type: ' & _WinAPI_AssocQueryString($sExt, $ASSOCSTR_FRIENDLYDOCNAME) & @CRLF)
ConsoleWrite('Command: ' & _WinAPI_AssocQueryString($sExt, $ASSOCSTR_COMMAND) & @CRLF)
ConsoleWrite('Executable: ' & _WinAPI_AssocQueryString($sExt, $ASSOCSTR_EXECUTABLE) & @CRLF)
ConsoleWrite('Icon: ' & _WinAPI_AssocQueryString($sExt, $ASSOCSTR_DEFAULTICON) & @CRLF)


Function _WinAPI_CreateMRUList

Function Reference

_WinAPI_CreateMRUList

Creates a new most recently used (MRU) list

#include <WinAPIReg.au3>
_WinAPI_CreateMRUList ( $hKey, $sSubKey [, $iMax = 26] )

Parameters

$hKey | Handle to the currently open key, or one of the following predefined values under which to store the MRU data. $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE
$sSubKey | The subkey under which to store the MRU data.
$iMax | [optional] The maximum number of entries in the MRU list. Default is 26 (A..Z).

Return Value

Success: | Handle to the new MRU list.
Failure: | 0.

Remarks

The handle is an integer!!!.

Related

_WinAPI_AddMRUString, _WinAPI_FreeMRUList

See Also

Search CreateMRUListW in MSDN Library.

Example

#include <APIRegConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIReg.au3>

Local $hMRU = _WinAPI_CreateMRUList($HKEY_CURRENT_USER, 'Software\MyProg\MRU', 5)

; Create MRU list in the registry (only at first start example)
RegRead('HKCU\Software\MyProg\MRU', 'MRUList')
If @error Then
    For $i = 5 To 1 Step -1
        _WinAPI_AddMRUString($hMRU, 'String' & $i)
    Next
EndIf

GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 320, 92)
Local $idCombo = GUICtrlCreateCombo(_WinAPI_EnumMRUList($hMRU, 0), 10, 20, 300, 21, $CBS_DROPDOWNLIST)
Local $iCount = _WinAPI_EnumMRUList($hMRU, -1)
Local $sData = ''
For $i = 1 To $iCount - 1
    $sData &= _WinAPI_EnumMRUList($hMRU, $i) & '|'
Next
GUICtrlSetData(-1, $sData)
Local $idButton = GUICtrlCreateButton('OK', 125, 58, 70, 23)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            _WinAPI_AddMRUString($hMRU, GUICtrlRead($idCombo))
            ExitLoop
    EndSwitch
WEnd

_WinAPI_FreeMRUList($hMRU)


Function _WinAPI_DllInstall

Function Reference

_WinAPI_DllInstall

Registers OLE controls such as DLL or ActiveX Controls (OCX) files

#include <WinAPIReg.au3>
_WinAPI_DllInstall ( $sFilePath )

Parameters

$sFilePath The path to the DLL file that will be registered.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.


Function _WinAPI_DllUninstall

Function Reference

_WinAPI_DllUninstall

Unregisters OLE controls such as DLL or ActiveX Controls (OCX) files

#include <WinAPIReg.au3>
_WinAPI_DllUninstall ( $sFilePath )

Parameters

$sFilePath The path to the DLL file that will be unregistered.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.


Function _WinAPI_EnumMRUList

Function Reference

_WinAPI_EnumMRUList

Enumerates the contents of the most recently used (MRU) list

#include <WinAPIReg.au3>
_WinAPI_EnumMRUList ( $hMRU, $iItem )

Parameters

$hMRU | Handle of the MRU list, obtained when the list was created.
$iItem | The item to return. If this value is (-1), the function returns the number of items in the MRU list.

Return Value

Success: | The item requested in $iItem. If $iItem is (-1), the number of items in the MRU list.
Failure: | 0 and sets the @error flag to non-zero.

See Also

Search EnumMRUListW in MSDN Library.

Example

#include <APIRegConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIReg.au3>

Local $hMRU = _WinAPI_CreateMRUList($HKEY_CURRENT_USER, 'Software\MyProg\MRU', 5)

; Create MRU list in the registry (only at first start example)
RegRead('HKCU\Software\MyProg\MRU', 'MRUList')
If @error Then
    For $i = 5 To 1 Step -1
        _WinAPI_AddMRUString($hMRU, 'String' & $i)
    Next
EndIf

GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 320, 92)
Local $idCombo = GUICtrlCreateCombo(_WinAPI_EnumMRUList($hMRU, 0), 10, 20, 300, 21, $CBS_DROPDOWNLIST)
Local $iCount = _WinAPI_EnumMRUList($hMRU, -1)
Local $sData = ''
For $i = 1 To $iCount - 1
    $sData &= _WinAPI_EnumMRUList($hMRU, $i) & '|'
Next
GUICtrlSetData(-1, $sData)
Local $idButton = GUICtrlCreateButton('OK', 125, 58, 70, 23)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            _WinAPI_AddMRUString($hMRU, GUICtrlRead($idCombo))
            ExitLoop
    EndSwitch
WEnd

_WinAPI_FreeMRUList($hMRU)


Function _WinAPI_FreeMRUList

Function Reference

_WinAPI_FreeMRUList

Frees the handle associated with the most recently used (MRU) list and writes cached data to the registry

#include <WinAPIReg.au3>
_WinAPI_FreeMRUList ( $hMRU )

Parameters

$hMRU Handle of the MRU list to free.

Return Value

Success: | True
Failure: | False

Related

_WinAPI_AddMRUString, _WinAPI_CreateMRUList

See Also

Search FreeMRUList in MSDN Library.


Function _WinAPI_GetRegKeyNameByHandle

Function Reference

_WinAPI_GetRegKeyNameByHandle

Retrieves a name of the specified registry key

#include <WinAPIReg.au3>
_WinAPI_GetRegKeyNameByHandle ( $hKey )

Parameters

$hKey Handle to an open registry key.

Return Value

Success: | The name of the key.
Failure: | Empty string and sets the @error flag to non-zero, @extended flag may contain the NTSTATUS error code.

See Also

Search ZwQueryKey in MSDN Library.

Example

#include <APIRegConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPIReg.au3>

Local $hKey = _WinAPI_RegOpenKey($HKEY_CURRENT_USER, 'Software\AutoIt v3', $KEY_QUERY_VALUE)
If @error Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))
    Exit
EndIf

ConsoleWrite(_WinAPI_GetRegKeyNameByHandle($hKey) & @CRLF)

_WinAPI_RegCloseKey($hKey)


Function _WinAPI_RegCloseKey

Function Reference

_WinAPI_RegCloseKey

Closes a handle to the specified registry key

#include <WinAPIReg.au3>
_WinAPI_RegCloseKey ( $hKey [, $bFlush = False] )

Parameters

$hKey Handle to the open key to be closed. The handle must have been opened by the _WinAPI_RegCreateKey()
or _WinAPI_RegOpenKey() function.
$bFlush [optional] Specifies whether writes all the attributes of the specified registry key into the registry, valid values:
True - Write changes to disk before close the handle.
False - Don't write (Default).

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Related

_WinAPI_RegCreateKey

See Also

Search RegCloseKey in MSDN Library.


Function _WinAPI_RegConnectRegistry

Function Reference

_WinAPI_RegConnectRegistry

Establishes a connection to a predefined registry key on another computer

#include <WinAPIReg.au3>
_WinAPI_RegConnectRegistry ( $sComputer, $hKey )

Parameters

$sComputer | The name of the remote computer. The string has the form as "\\computername". The caller must have access to the remote computer or the function fails. If this parameter is 0, the local computer name is used.
$hKey | The predefined registry handle. This parameter can be one of the following predefined keys on the remote computer. $HKEY_LOCAL_MACHINE $HKEY_PERFORMANCE_DATA $HKEY_USERS

Return Value

Success: | Handle to the key on the remote computer.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

This function requires the Remote Registry service to be running on the remote computer.

If the current user does not have proper access to the remote computer, the call to _WinAPI_RegConnectRegistry()
fails. If the computer is joined to a workgroup and the "Force network logons using local accounts to authenticate
as Guest" policy is enabled, the function fails. Note that this policy is enabled by default if the computer is
joined to a workgroup.

When a handle returned by _WinAPI_RegConnectRegistry() is no longer needed, it should be closed by
calling _WinAPI_RegCloseKey().

Related

_WinAPI_RegCloseKey

See Also

Search RegConnectRegistry in MSDN Library.


Function _WinAPI_RegCopyTree

Function Reference

_WinAPI_RegCopyTree

Recursively copies the subkeys and values of the source subkey to the destination key

#include <WinAPIReg.au3>
_WinAPI_RegCopyTree ( $hSrcKey, $sSrcSubKey, $hDestKey )

Parameters

$hSrcKey | Handle to the source key or one of the predefined registry keys ($HKEY_*).
$sSrcSubKey | The subkey whose subkeys and values are to be copied.
$hDestKey | Handle to the destination key.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

This function does not duplicate the security attributes of the keys and values that it copies. Rather,
all security attributes in the destination key are the default attributes.

See Also

Search SHCopyKey in MSDN Library.


Function _WinAPI_RegCopyTreeEx

Function Reference

_WinAPI_RegCopyTreeEx

Copies the specified registry key, along with its values and subkeys, to the specified destination key

#include <WinAPIReg.au3>
_WinAPI_RegCopyTreeEx ( $hSrcKey, $sSrcSubKey, $hDestKey )

Parameters

$hSrcKey | Handle to an open registry key. The key must have been opened with the $KEY_READ access right. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function, or it can be one of the predefined registry keys ($HKEY_*).
$sSrcSubKey | The name of the key. This key must be a subkey of the key identified by the $hSrcKey parameter.
$hDestKey | Handle to the destination key. The calling process must have $KEY_CREATE_SUB_KEY access to the key. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function, or it can be one of the predefined registry keys ($HKEY_*).

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

This function also copies the security descriptor for the key.

This function requires Windows Vista or later.

See Also

Search RegCopyTree in MSDN Library.


Function _WinAPI_RegCreateKey

Function Reference

_WinAPI_RegCreateKey

Creates the specified registry key

#include <WinAPIReg.au3>
_WinAPI_RegCreateKey ( $hKey [, $sSubKey = '' [, $iAccess = $KEY_ALL_ACCESS [, $iOptions = 0 [, $tSecurity = 0]]]] )

Parameters

$hKey | Handle to an open registry key. If the key already exists, the function opens it. The calling process must have $KEY_CREATE_SUB_KEY access to the key. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function, or it can be one of the following predefined keys. $HKEY_CLASSES_ROOT $HKEY_CURRENT_CONFIG $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
$sSubKey | [optional] The name of a subkey that this function opens or creates. The subkey specified must be a subkey of the key identified by the $hKey parameter; it can be up to 32 levels deep in the registry tree. If an empty string (Default), the return is a new handle to the key specified by $hKey.
$iAccess | [optional] The mask that specifies the access rights for the key. This parameter can be one or more of the following values. $KEY_ALL_ACCESS $KEY_CREATE_LINK $KEY_CREATE_SUB_KEY $KEY_ENUMERATE_SUB_KEYS $KEY_EXECUTE $KEY_NOTIFY $KEY_QUERY_VALUE $KEY_READ $KEY_SET_VALUE $KEY_WOW64_32KEY $KEY_WOW64_64KEY $KEY_WRITE
$iOptions | [optional] This parameter can be one of the following values. $REG_OPTION_BACKUP_RESTORE $REG_OPTION_CREATE_LINK $REG_OPTION_NON_VOLATILE (Default) $REG_OPTION_VOLATILE
$tSecurity | [optional] $tagSECURITY_ATTRIBUTES structure that determines whether the returned handle can be inherited by child processes. If this parameter is 0 (Default), the handle cannot be inherited.

Return Value

Success: | Handle to the opened or created key, @extended flag will contain one of the following disposition values: 0 (False) - The key existed and was simply opened without being changed. 1 (True) - The key did not exist and was created.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

An application cannot create a key that is a direct child of HKEY_USERS or HKEY_LOCAL_MACHINE. An application
can create subkeys in lower levels of the HKEY_USERS or HKEY_LOCAL_MACHINE trees.

If the key is not one of the predefined registry keys ($HKEY_*) you must call the _WinAPI_RegCloseKey()
function after finished using the handle.

Related

_WinAPI_RegOpenKey

See Also

Search RegCreateKeyEx in MSDN Library.


Function _WinAPI_RegDeleteEmptyKey

Function Reference

_WinAPI_RegDeleteEmptyKey

Deletes an empty key

#include <WinAPIReg.au3>
_WinAPI_RegDeleteEmptyKey ( $hKey [, $sSubKey = ''] )

Parameters

$hKey | Handle to an open registry key, or any of the following predefined keys. $HKEY_CLASSES_ROOT $HKEY_CURRENT_CONFIG $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
$sSubKey | [optional] The name of the key to delete.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

_WinAPI_RegDeleteEmptyKey() does not delete a key if it contains any subkeys or values. Use _WinAPI_RegDeleteTree() instead.

Related

_WinAPI_RegDeleteTree

See Also

Search SHDeleteEmptyKey in MSDN Library.


Function _WinAPI_RegDeleteKey

Function Reference

_WinAPI_RegDeleteKey

Deletes a subkey and its values

#include <WinAPIReg.au3>
_WinAPI_RegDeleteKey ( $hKey [, $sSubKey = ''] )

Parameters

$hKey | Handle to an open registry key. The access rights of this key do not affect the delete operation. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function, or it can be one of the following predefined keys. $HKEY_CLASSES_ROOT $HKEY_CURRENT_CONFIG $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
$sSubKey | [optional] The name of the key to be deleted. It must be a subkey of the key that $hKey identifies, but it cannot have subkeys.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

A deleted key is not removed until the last handle to it is closed.

Related

_WinAPI_RegCreateKey, _WinAPI_RegOpenKey

See Also

Search RegDeleteKey in MSDN Library.


Function _WinAPI_RegDeleteKeyValue

Function Reference

_WinAPI_RegDeleteKeyValue

Removes the specified value from the specified registry key and subkey

#include <WinAPIReg.au3>
_WinAPI_RegDeleteKeyValue ( $hKey, $sSubKey, $sValueName )

Parameters

$hKey | Handle to an open registry key. The key must have been opened with the $KEY_SET_VALUE access right. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function, or it can be one of the following predefined keys. $HKEY_CLASSES_ROOT $HKEY_CURRENT_CONFIG $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
$sSubKey | The name of the registry key. This key must be a subkey of the key identified by the $hKey parameter.
$sValueName | The registry value to be removed from the key.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

This function requires Windows Vista or later.

Related

_WinAPI_RegCreateKey, _WinAPI_RegOpenKey

See Also

Search RegDeleteKeyValue in MSDN Library.


Function _WinAPI_RegDeleteTree

Function Reference

_WinAPI_RegDeleteTree

Deletes a subkey and all its descendants

#include <WinAPIReg.au3>
_WinAPI_RegDeleteTree ( $hKey [, $sSubKey = ''] )

Parameters

$hKey | Handle to an open registry key, or any of the following predefined keys. $HKEY_CLASSES_ROOT $HKEY_CURRENT_CONFIG $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_PERFORMANCE_DATA $HKEY_USERS
$sSubKey | [optional] The name of the key to delete.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

See Also

Search SHDeleteKey in MSDN Library.


Function _WinAPI_RegDeleteTreeEx

Function Reference

_WinAPI_RegDeleteTreeEx

Deletes the subkeys and values of the specified key recursively

#include <WinAPIReg.au3>
_WinAPI_RegDeleteTreeEx ( $hKey [, $sSubKey = 0] )

Parameters

$hKey | Handle to an open registry key. The key must have been opened with the following access rights: $DELETE, $KEY_ENUMERATE_SUB_KEYS, and $KEY_QUERY_VALUE. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function, or it can be one of the following predefined keys. $HKEY_CLASSES_ROOT $HKEY_CURRENT_CONFIG $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
$sSubKey | [optional] The name of the key to delete. This key must be a subkey of the key identified by the $hKey parameter. If this parameter is not specified (Default), the subkeys and values of $hKey are deleted.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

If the key has values, it must be opened with $KEY_SET_VALUE or this function will fail.

This function requires Windows Vista or later.

Related

_WinAPI_RegCreateKey, _WinAPI_RegOpenKey

See Also

Search RegDeleteTree in MSDN Library.


Function _WinAPI_RegDeleteValue

Function Reference

_WinAPI_RegDeleteValue

Removes a named value from the specified registry key

#include <WinAPIReg.au3>
_WinAPI_RegDeleteValue ( $hKey, $sValueName )

Parameters

$hKey | Handle to an open registry key. The key must have been opened with the $KEY_SET_VALUE access right. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function, or it can be one of the following predefined keys. $HKEY_CLASSES_ROOT $HKEY_CURRENT_CONFIG $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
$sValueName | The registry value to be removed. If this parameter is empty string, the key's unnamed or default value is removed.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Related

_WinAPI_RegCreateKey, _WinAPI_RegOpenKey

See Also

Search RegDeleteValue in MSDN Library.


Function _WinAPI_RegDisableReflectionKey

Function Reference

_WinAPI_RegDisableReflectionKey

Disables registry reflection for the specified key

#include <WinAPIReg.au3>
_WinAPI_RegDisableReflectionKey ( $hKey )

Parameters

$hKey Handle to an open registry key. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey()
function; it cannot specify a key on a remote computer. If the key is not on the reflection list,
the function succeeds but has no effect.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

On WOW64, 32-bit applications view a registry tree that is separate from the registry tree that 64-bit applications
view. Registry reflection copies specific registry keys and values between the two views.

To restore registry reflection for a disabled key, use the _WinAPI_RegEnableReflectionKey().

Related

_WinAPI_RegCreateKey, _WinAPI_RegEnableReflectionKey, _WinAPI_RegOpenKey

See Also

Search RegDisableReflectionKey in MSDN Library.


Function _WinAPI_RegDuplicateHKey

Function Reference

_WinAPI_RegDuplicateHKey

Duplicates a registry key's handle

#include <WinAPIReg.au3>
_WinAPI_RegDuplicateHKey ( $hKey )

Parameters

$hKey Handle to an open registry key to be duplicated.

Return Value

Returns a duplicate of the handle.

See Also

Search SHRegDuplicateHKey in MSDN Library.


Function _WinAPI_RegEnableReflectionKey

Function Reference

_WinAPI_RegEnableReflectionKey

Restores registry reflection for the specified disabled key

#include <WinAPIReg.au3>
_WinAPI_RegEnableReflectionKey ( $hKey )

Parameters

$hKey Handle to an open registry key. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey()
function; it cannot specify a key on a remote computer. If the key is not on the reflection list,
the function succeeds but has no effect.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

On WOW64, 32-bit applications view a registry tree that is separate from the registry tree that 64-bit applications
view. Registry reflection copies specific registry keys and values between the two views.

Related

_WinAPI_RegCreateKey, _WinAPI_RegOpenKey

See Also

Search RegEnableReflectionKey in MSDN Library.


Function _WinAPI_RegEnumKey

Function Reference

_WinAPI_RegEnumKey

Enumerates the subkeys of the specified open registry key

#include <WinAPIReg.au3>
_WinAPI_RegEnumKey ( $hKey, $iIndex )

Parameters

$hKey | Handle to an open registry key. The key must have been opened with the $KEY_ENUMERATE_SUB_KEYS access right. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function. It can also be one of the following predefined keys. $HKEY_CLASSES_ROOT $HKEY_CURRENT_CONFIG $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_PERFORMANCE_DATA $HKEY_USERS
$iIndex | The index of the subkey to retrieve. This parameter should be zero for the first call to the _WinAPI_RegEnumKey() function and then incremented for subsequent calls.

Return Value

Success: | The string that contains the name of the subkey.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

To enumerate subkeys, an application should initially call the _WinAPI_RegEnumKey() function with the $iIndex
parameter set to zero. The application should then increment the $iIndex parameter and call _WinAPI_RegEnumKey()
until there are no more subkeys (meaning the @extended flag sets to ERROR_NO_MORE_ITEMS (259)).

The application can also set $iIndex to the index of the last subkey on the first call to the function and
decrement the index until the subkey with the index 0 is enumerated. To retrieve the index of the last subkey,
use the _WinAPI_RegQueryInfoKey() function.

While an application is using the _WinAPI_RegEnumKey() function, it should not make calls to any registration
functions that might change the key being enumerated.

Related

_WinAPI_RegCreateKey, _WinAPI_RegOpenKey, _WinAPI_RegQueryInfoKey

See Also

Search RegEnumKeyEx in MSDN Library.

Example

#include <APIRegConstants.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPIReg.au3>

Local $hKey = _WinAPI_RegOpenKey($HKEY_CLASSES_ROOT, 'CLSID', $KEY_READ)
If @error Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))
    Exit
EndIf
Local $iCount = _WinAPI_RegQueryInfoKey($hKey)
Local $aKey[$iCount[0]]
For $i = 0 To UBound($aKey) - 1
    $aKey[$i] = _WinAPI_RegEnumKey($hKey, $i)
Next

_WinAPI_RegCloseKey($hKey)

_ArrayDisplay($aKey, '_WinAPI_RegEnumKey')


Function _WinAPI_RegEnumValue

Function Reference

_WinAPI_RegEnumValue

Enumerates the values for the specified open registry key

#include <WinAPIReg.au3>
_WinAPI_RegEnumValue ( $hKey, $iIndex )

Parameters

$hKey | Handle to an open registry key. The key must have been opened with the $KEY_QUERY_VALUE access right. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function. It can also be one of the following predefined keys. $HKEY_CLASSES_ROOT $HKEY_CURRENT_CONFIG $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_PERFORMANCE_DATA $HKEY_USERS
$iIndex | The index of the value to be retrieved. This parameter should be zero for the first call to the _WinAPI_RegEnumValue() function and then be incremented for subsequent calls.

Return Value

Success: | The string that contains the name of the value, @extended flag will contain the code indicating the type of data ($REG_*) stored in the specified value.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

To enumerate values, an application should initially call the _WinAPI_RegEnumValue() function with the $iIndex
parameter set to zero. The application should then increment $iIndex and call the _WinAPI_RegEnumValue() function
until there are no more values (until the @extended flag sets to ERROR_NO_MORE_ITEMS (259)).

The application can also set $iIndex to the index of the last value on the first call to the function and
decrement the index until the value with index 0 is enumerated. To retrieve the index of the last value,
use the _WinAPI_RegQueryInfoKey() function.

While using _WinAPI_RegEnumValue(), an application should not call any registry functions that might change the
key being queried.

Related

_WinAPI_RegCreateKey, _WinAPI_RegOpenKey, _WinAPI_RegQueryInfoKey

See Also

Search RegEnumValue in MSDN Library.

Example

#include <APIRegConstants.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPIReg.au3>

Local $hKey = _WinAPI_RegOpenKey($HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Run', $KEY_READ)
If @error Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))
    Exit
EndIf
Local $iCount = _WinAPI_RegQueryInfoKey($hKey)
Local $aKey[$iCount[2]]
For $i = 0 To UBound($aKey) - 1
    $aKey[$i] = _WinAPI_RegEnumValue($hKey, $i)
Next

_WinAPI_RegCloseKey($hKey)

_ArrayDisplay($aKey, '_WinAPI_RegEnumValue')


Function _WinAPI_RegFlushKey

Function Reference

_WinAPI_RegFlushKey

Writes all the attributes of the specified open registry key into the registry

#include <WinAPIReg.au3>
_WinAPI_RegFlushKey ( $hKey )

Parameters

$hKey Handle to an open registry key. The key must have been opened with the $KEY_QUERY_VALUE access right.
This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function. It can also
be one of the following predefined keys.
$HKEY_CLASSES_ROOT
$HKEY_CURRENT_CONFIG
$HKEY_CURRENT_USER
$HKEY_LOCAL_MACHINE
$HKEY_PERFORMANCE_DATA
$HKEY_USERS

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

The _WinAPI_RegFlushKey() function returns only when all the data for the hive that contains the specified key
has been written to the registry store on disk. The _WinAPI_RegFlushKey() function writes out the data for other
keys in the hive that have been modified since the last lazy flush or system start. After _WinAPI_RegFlushKey()
returns, use _WinAPI_RegCloseKey() to close the handle to the registry key.

Related

_WinAPI_RegCloseKey, _WinAPI_RegCreateKey, _WinAPI_RegOpenKey

See Also

Search RegFlushKey in MSDN Library.


Function _WinAPI_RegLoadMUIString

Function Reference

_WinAPI_RegLoadMUIString

Loads the specified string from the specified key and subkey

#include <WinAPIReg.au3>
_WinAPI_RegLoadMUIString ( $hKey, $sValueName [, $sDirectory = ''] )

Parameters

$hKey | Handle to an open registry key. The key must have been opened with the $KEY_QUERY_VALUE access right. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function. It can also be one of the following predefined keys. $HKEY_CLASSES_ROOT $HKEY_CURRENT_CONFIG $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
$sValueName | The name of the registry value.
$sDirectory | [optional] The directory path.

Return Value

Success: | The loaded string.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

The strings of the following form receive special handling:

@[path]\dllname,-strID

The string with identifier strID is loaded from dllname; the path is optional. If the $sDirectory parameter is
empty string, the directory is prepended to the path specified in the registry data. Note that dllname can contain
environment variables to be expanded.

This function requires Windows Vista or later.

Related

_WinAPI_RegCreateKey, _WinAPI_RegOpenKey

See Also

Search RegLoadMUIString in MSDN Library.


Function _WinAPI_RegNotifyChangeKeyValue

Function Reference

_WinAPI_RegNotifyChangeKeyValue

Notifies the caller about changes to the attributes or contents of a specified registry key

#include <WinAPIReg.au3>
_WinAPI_RegNotifyChangeKeyValue ( $hKey, $iFilter [, $bSubtree = False [, $bAsync = False [, $hEvent = 0]]] )

Parameters

$hKey | Handle to an open registry key. The key must have been opened with the KEY_NOTIFY access right. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function. It can also be one of the following predefined keys. $HKEY_CLASSES_ROOT $HKEY_CURRENT_CONFIG $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
$iFilter | Indicates the changes that should be reported. This parameter can be one or more of the following values. $REG_NOTIFY_CHANGE_NAME $REG_NOTIFY_CHANGE_ATTRIBUTES $REG_NOTIFY_CHANGE_LAST_SET $REG_NOTIFY_CHANGE_SECURITY
$bSubtree | [optional] Specifies whether report changes in the subkeys of the specified key, valid values: True - The function reports changes in the specified key and all its subkeys. False - The function reports changes only in the specified key (Default).
$bAsync | [optional] Specifies whether return immediately, valid values: True - The function returns immediately and reports changes by signaling the specified event. False - The function does not return until a change has occurred (Default).
$hEvent | [optional] Handle to an event. If the $fAsync parameter is True, the function returns immediately and changes are reported by signaling this event, otherwise this parameter is ignored (Default).

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

If the specified key is closed, the event is signaled. This means that an application should not depend on the
key being open after returning from a wait operation on the event.

Related

_WinAPI_RegCreateKey, _WinAPI_RegOpenKey

See Also

Search RegNotifyChangeKeyValue in MSDN Library.

Example

#include <APIRegConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPIReg.au3>

Opt('TrayAutoPause', 0)

Local $hKey = _WinAPI_RegOpenKey($HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Run', $KEY_NOTIFY)
If @error Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))
    Exit
EndIf
Local $hEvent = _WinAPI_CreateEvent()
If Not _WinAPI_RegNotifyChangeKeyValue($hKey, $REG_NOTIFY_CHANGE_LAST_SET, 0, 1, $hEvent) Then
    Exit
EndIf

While 1
    If Not _WinAPI_WaitForSingleObject($hEvent, 0) Then
        Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(4096, ''Registry'', ''The registry hive has been modified.'' & @CRLF & @CRLF & ''HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run'', 5)"')
        If Not _WinAPI_RegNotifyChangeKeyValue($hKey, $REG_NOTIFY_CHANGE_LAST_SET, 0, 1, $hEvent) Then
            ExitLoop
        EndIf
    EndIf
    Sleep(100)
WEnd

_WinAPI_CloseHandle($hEvent)
_WinAPI_RegCloseKey($hKey)


Function _WinAPI_RegOpenKey

Function Reference

_WinAPI_RegOpenKey

Opens the specified registry key

#include <WinAPIReg.au3>
_WinAPI_RegOpenKey ( $hKey [, $sSubKey = '' [, $iAccess = 0x000F003F]] )

Parameters

$hKey | Handle to an open registry key. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function, or it can be one of the following predefined keys. $HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
$sSubKey | [optional] The name of the registry subkey to be opened (see remarks).
$iAccess | [optional] A mask that specifies the desired access rights to the key. The function fails if the security descriptor of the key does not permit the requested access for the calling process. This parameter can be one or more of the $KEY_* constants. Default is $KEY_ALL_ACCESS.

Return Value

Success: | Handle to the opened key.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

Unlike the _WinAPI_RegCreateKey() function, the _WinAPI_RegOpenKey() function does not create the specified key
if the key does not exist in the registry.

If the key is not one of the predefined registry keys ($HKEY_*) you must call the _WinAPI_RegCloseKey()
function after finished using the handle.

Key names are not case sensitive.

The $sSubKey parameter can be an an empty string.
If $sSubKey is an empty string and $hKey is HKEY_CLASSES_ROOT, the return is the same $hKey handle passed into the function.
Otherwise, the return is a new handle to the key specified by $hKey.

The $sSubKey parameter can be NULL only if $hKey is one of the predefined keys.
If $sSubKey is NULL and $hKey is HKEY_CLASSES_ROOT, the return is a new handle to the key specified by $hKey.
Otherwise, the return is the same $hKey handle passed in to the function.

Related

_WinAPI_RegCloseKey, _WinAPI_RegCreateKey

See Also

Search RegOpenKeyEx in MSDN Library.


Function _WinAPI_RegQueryInfoKey

Function Reference

_WinAPI_RegQueryInfoKey

Retrieves information about the specified registry key

#include <WinAPIReg.au3>
_WinAPI_RegQueryInfoKey ( $hKey )

Parameters

$hKey Handle to an open registry key. The key must have been opened with the $KEY_QUERY_VALUE access right.
This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function. It can also
be one of the following predefined keys.
$HKEY_CLASSES_ROOT
$HKEY_CURRENT_CONFIG
$HKEY_CURRENT_USER
$HKEY_LOCAL_MACHINE
$HKEY_PERFORMANCE_DATA
$HKEY_USERS

Return Value

Success: | The array containing the following information: [0] - The number of subkeys that are contained by the specified key. [1] - The size of the key's subkey with the longest name, in characters, not including the terminating null character. [2] - The number of values that are associated with the key. [3] - The size of the key's longest value name, in characters. The size does not include the terminating null character. [4] - The size of the longest data component among the key's values, in bytes.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the system error code.

Related

_WinAPI_RegCreateKey, _WinAPI_RegOpenKey

See Also

Search RegQueryInfoKey in MSDN Library.


Function _WinAPI_RegQueryLastWriteTime

Function Reference

_WinAPI_RegQueryLastWriteTime

Retrieves information about the last write time to the specified registry key

#include <WinAPIReg.au3>
_WinAPI_RegQueryLastWriteTime ( $hKey )

Parameters

$hKey Handle to an open registry key. The key must have been opened with the $KEY_QUERY_VALUE access right.
This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function. It can also
be one of the following predefined keys.
$HKEY_CLASSES_ROOT
$HKEY_CURRENT_CONFIG
$HKEY_CURRENT_USER
$HKEY_LOCAL_MACHINE
$HKEY_PERFORMANCE_DATA
$HKEY_USERS

Return Value

Success: | $tagFILETIME structure that contains the last write time.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the system error code.

Related

_WinAPI_RegCreateKey, _WinAPI_RegOpenKey

See Also

Search RegQueryInfoKey in MSDN Library.

Example

#include <APIRegConstants.au3>
#include <Date.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPILocale.au3>
#include <WinAPIReg.au3>

; X64 running support
Local $sWow64 = ""
If @AutoItX64 Then $sWow64 = "\Wow6432Node"

Local $hKey = _WinAPI_RegOpenKey($HKEY_LOCAL_MACHINE, 'SOFTWARE' & $sWow64 & '\AutoIt v3\AutoIt', $KEY_QUERY_VALUE)
If @error Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))
    Exit
EndIf

Local $tFT = _WinAPI_RegQueryLastWriteTime($hKey)
$tFT = _Date_Time_FileTimeToLocalFileTime($tFT)
Local $tST = _Date_Time_FileTimeToSystemTime($tFT)
_WinAPI_RegCloseKey($hKey)

ConsoleWrite('!Last modified at: ' & _WinAPI_GetDateFormat(0, $tST) & ' ' & _WinAPI_GetTimeFormat(0, $tST) & @CRLF)


Function _WinAPI_RegQueryMultipleValues

Function Reference

_WinAPI_RegQueryMultipleValues

Retrieves the type and data for a list of value names associated with an open registry key

#include <WinAPIReg.au3>
_WinAPI_RegQueryMultipleValues ( $hKey, ByRef $aValent, ByRef $pBuffer [, $iStart = 0 [, $iEnd = -1]] )

Parameters

$hKey | Handle to an open registry key. The key must have been opened with the KEY_QUERY_VALUE access right. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function. It can also be one of the following predefined keys : $HKEY_CLASSES_ROOT $HKEY_CURRENT_CONFIG $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_PERFORMANCE_DATA $HKEY_USERS
$aValent | The 2D array ([valuename1, *, *, *], ... [valuenameN, *, *, *]) that contains a value names to be retrieved. On input, 1, 2, and 3 array elements are not used, but array dimensions should be [n][4], otherwise the function fails. Also, this function fails if any of the specified values do not exist in the specified registry key.
$pBuffer | A pointer to a memory buffer that contains a registry data. Typically, you should not use this buffer directly (see remarks).
$iStart | [optional] The index of array to start querying at.
$iEnd | [optional] The index of array to stop querying at.

Return Value

Success: | The number of bytes copied to the buffer. The $aValent array will contain the following data: [n][0] - The name of the value (remain unchanged). [n][1] - The size of the data, in bytes. [n][2] - The pointer to the data in buffer pointed to by the $pBuffer parameter. [n][3] - The type of data ($REG_*).
Failure: | Sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

To prevent excessive serialization, the aggregate data returned by the function cannot exceed one megabyte.

When a returned registry data are no longer needed, you must free the allocated memory pointed to by the
$pBuffer parameter by calling the _WinAPI_FreeMemory() function.

Related

_WinAPI_RegCreateKey, _WinAPI_RegOpenKey

See Also

Search RegQueryMultipleValues in MSDN Library.

Example

#include <APIRegConstants.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPIReg.au3>
#include <WinAPISys.au3>

Local $aValent[19][4]

; Note that if at least one of the following value names is not found in the specified registry key, the function fails!

; HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

$aValent[0][0] = 'AppData'
$aValent[1][0] = 'Cache'
$aValent[2][0] = 'Cookies'
$aValent[3][0] = 'Desktop'
$aValent[4][0] = 'Favorites'
$aValent[5][0] = 'History'
$aValent[6][0] = 'Local AppData'
$aValent[7][0] = 'My Music'
$aValent[8][0] = 'My Pictures'
$aValent[9][0] = 'My Video'
$aValent[10][0] = 'NetHood'
$aValent[11][0] = 'Personal'
$aValent[12][0] = 'PrintHood'
$aValent[13][0] = 'Programs'
$aValent[14][0] = 'Recent'
$aValent[15][0] = 'SendTo'
$aValent[16][0] = 'Start Menu'
$aValent[17][0] = 'Startup'
$aValent[18][0] = 'Templates'

_ArrayDisplay($aValent, '_WinAPI_RegQueryMultipleValues')

Local $hKey = _WinAPI_RegOpenKey($HKEY_CURRENT_USER, 'Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders', $KEY_QUERY_VALUE)
If @error Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))
    Exit
EndIf

Local $pBuffer
_WinAPI_RegQueryMultipleValues($hKey, $aValent, $pBuffer)
If @error Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))
    Exit
EndIf

_WinAPI_RegCloseKey($hKey)

_ArrayDisplay($aValent, '_WinAPI_RegQueryMultipleValues')

For $i = 0 To UBound($aValent) - 1
    $aValent[$i][2] = DllStructGetData(DllStructCreate('wchar[' & $aValent[$i][1] & ']', $aValent[$i][2]), 1)
Next

_WinAPI_FreeMemory($pBuffer)

_ArrayDisplay($aValent, '_WinAPI_RegQueryMultipleValues')


Function _WinAPI_RegQueryReflectionKey

Function Reference

_WinAPI_RegQueryReflectionKey

Determines whether reflection has been disabled or enabled for the specified key

#include <WinAPIReg.au3>
_WinAPI_RegQueryReflectionKey ( $hKey )

Parameters

$hKey Handle to an open registry key. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey()
function; it cannot specify a key on a remote computer. If the key is not on the reflection list,
the function succeeds but has no effect.

Return Value

Success: | 1 - The reflection disabled 0 - enabled.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

On WOW64, 32-bit applications view a registry tree that is separate from the registry tree that 64-bit applications
view. Registry reflection copies specific registry keys and values between the two views.

Related

_WinAPI_RegCreateKey, _WinAPI_RegOpenKey

See Also

Search RegQueryReflectionKey in MSDN Library.


Function _WinAPI_RegQueryValue

Function Reference

_WinAPI_RegQueryValue

Retrieves the type and data for the specified value name associated with an open registry key

#include <WinAPIReg.au3>
_WinAPI_RegQueryValue ( $hKey, $sValueName, ByRef $tValueData )

Parameters

$hKey | Handle to an open registry key. The key must have been opened with the KEY_QUERY_VALUE access right. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function. It can also be one of the following predefined keys. $HKEY_CLASSES_ROOT $HKEY_CURRENT_CONFIG $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_PERFORMANCE_DATA $HKEY_PERFORMANCE_NLSTEXT $HKEY_PERFORMANCE_TEXT $HKEY_USERS
$sValueName | The name of the registry value. If $sValueName is empty string, the function retrieves the type and data for the key's unnamed or default value, if any.
$tValueData | The structure (buffer) that receives the value data. This structure must be created before function call.

Return Value

Success: | The size of the data copied to $tValueData, in bytes, @extended flag will contain the code that indicates the data type ($REG_*).
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, returned size includes any terminating null
character or characters unless the data was stored without them.

If the buffer specified by $tValueData parameter is not large enough to hold the data, the function returns
ERROR_MORE_DATA (234) and returns the required buffer size. In this case, the contents of the buffer are
undefined.

Related

_WinAPI_RegCreateKey, _WinAPI_RegOpenKey

See Also

Search RegQueryValueEx in MSDN Library.

Example

#include <APIRegConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPIReg.au3>

; X64 running support
Local $sWow64 = ""
If @AutoItX64 Then $sWow64 = "\Wow6432Node"

Local $hKey = _WinAPI_RegOpenKey($HKEY_LOCAL_MACHINE, 'SOFTWARE' & $sWow64 & '\AutoIt v3\AutoIt', $KEY_QUERY_VALUE)
If @error Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), @extended, _WinAPI_GetErrorMessage(@extended))
    Exit
EndIf

Local $tData = DllStructCreate('wchar[260]')
_WinAPI_RegQueryValue($hKey, 'InstallDir', $tData)
_WinAPI_RegCloseKey($hKey)

ConsoleWrite(DllStructGetData($tData, 1) & @CRLF)


Function _WinAPI_RegRestoreKey

Function Reference

_WinAPI_RegRestoreKey

Reads the registry information in a specified file and copies it over the specified key

#include <WinAPIReg.au3>
_WinAPI_RegRestoreKey ( $hKey, $sFilePath )

Parameters

$hKey | Handle to an open registry key. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function. It can also be one of the following predefined keys. $HKEY_CLASSES_ROOT $HKEY_CURRENT_CONFIG $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
$sFilePath | The name of the file with the registry information. This file is typically created by using the _WinAPI_RegSaveKey() function.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

The calling process must have $SE_RESTORE_NAME privilege, otherwise, the function fails, and _WinAPI_GetLastError()
returns ERROR_PRIVILEGE_NOT_HELD (1314).

If any subkeys of the specified registry key are open, the _WinAPI_RegRestoreKey() fails.

Related

_WinAPI_RegCreateKey, _WinAPI_RegOpenKey, _WinAPI_RegSaveKey

See Also

Search RegRestoreKey in MSDN Library.

Example

#include <APIRegConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPIReg.au3>

Local $aPrivileges[2] = [$SE_BACKUP_NAME, $SE_RESTORE_NAME]

; Enable "SeBackupPrivilege" and "SeRestorePrivilege" privileges to save and restore registry hive
Local $hToken = _WinAPI_OpenProcessToken(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))
Local $aAdjust
_WinAPI_AdjustTokenPrivileges($hToken, $aPrivileges, $SE_PRIVILEGE_ENABLED, $aAdjust)
If @error Or @extended Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'You do not have the required privileges.')
    Exit
EndIf

; Save "HKEY_CURRENT_USER\Software\AutoIt v3" to reg.dat
Local $hKey = _WinAPI_RegOpenKey($HKEY_CURRENT_USER, 'Software\AutoIt v3', $KEY_READ)
If _WinAPI_RegSaveKey($hKey, @TempDir & '\reg.dat', 1) Then
    MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), '', '"HKEY_CURRENT_USER\Software\AutoIt v3" has been saved to reg.dat.')
Else
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), '', _WinAPI_GetErrorMessage(@extended))
EndIf
_WinAPI_RegCloseKey($hKey)

; Restore "HKEY_CURRENT_USER\Software\AutoIt v3" to "HKEY_CURRENT_USER\Software\AutoIt v3 (Duplicate)"
$hKey = _WinAPI_RegCreateKey($HKEY_CURRENT_USER, 'Software\AutoIt v3 (Duplicate)', $KEY_WRITE)
If _WinAPI_RegRestoreKey($hKey, @TempDir & '\reg.dat') Then
    MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), '', '"HKEY_CURRENT_USER\Software\AutoIt v3" has been restored to "HKEY_CURRENT_USER\Software\AutoIt v3 (Duplicate)".')
Else
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), '', _WinAPI_GetErrorMessage(@extended))
EndIf
_WinAPI_RegCloseKey($hKey)

; Restore "SeBackupPrivilege" and "SeRestorePrivilege" privileges by default
_WinAPI_AdjustTokenPrivileges($hToken, $aAdjust, 0, $aAdjust)
_WinAPI_CloseHandle($hToken)

FileDelete(@TempDir & '\reg.dat')


Function _WinAPI_RegSaveKey

Function Reference

_WinAPI_RegSaveKey

Saves the specified key and all of its subkeys and values to a new file, in the standard format

#include <WinAPIReg.au3>
_WinAPI_RegSaveKey ( $hKey, $sFilePath [, $bReplace = False [, $tSecurity = 0]] )

Parameters

$hKey | Handle to an open registry key.
$sFilePath | The name of the file in which the specified key and subkeys are to be saved.
$bReplace | [optional] Specifies whether to replace the file if it already exists, valid values: True - The function attempts to replace the existing file. False - The function fails if the file already exists (Default).
$tSecurity | [optional] $tagSECURITY_ATTRIBUTES structure that specifies a security descriptor for the new file. If this parameter is 0 (Default), the file gets a default security descriptor.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

The calling process must have $SE_BACKUP_NAME privilege, otherwise, the function fails, and _WinAPI_GetLastError()
returns ERROR_PRIVILEGE_NOT_HELD (1314).

You can use the file created by this function in subsequent calls to the _WinAPI_RegRestoreKey() functions.

Related

_WinAPI_RegRestoreKey

See Also

Search RegSaveKey in MSDN Library.

Example

#include <APIRegConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIDiag.au3>
#include <WinAPIReg.au3>

Local $aPrivileges[2] = [$SE_BACKUP_NAME, $SE_RESTORE_NAME]

; Enable "SeBackupPrivilege" and "SeRestorePrivilege" privileges to save and restore registry hive
Local $hToken = _WinAPI_OpenProcessToken(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))
Local $aAdjust
_WinAPI_AdjustTokenPrivileges($hToken, $aPrivileges, $SE_PRIVILEGE_ENABLED, $aAdjust)
If @error Or @extended Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'You do not have the required privileges.')
    Exit
EndIf

; Save "HKEY_CURRENT_USER\Software\AutoIt v3" to reg.dat
Local $hKey = _WinAPI_RegOpenKey($HKEY_CURRENT_USER, 'Software\AutoIt v3', $KEY_READ)
If _WinAPI_RegSaveKey($hKey, @TempDir & '\reg.dat', 1) Then
    MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), '', '"HKEY_CURRENT_USER\Software\AutoIt v3" has been saved to reg.dat.')
Else
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), '', _WinAPI_GetErrorMessage(@extended))
EndIf
_WinAPI_RegCloseKey($hKey)

; Restore "HKEY_CURRENT_USER\Software\AutoIt v3" to "HKEY_CURRENT_USER\Software\AutoIt v3 (Duplicate)"
$hKey = _WinAPI_RegCreateKey($HKEY_CURRENT_USER, 'Software\AutoIt v3 (Duplicate)', $KEY_WRITE)
If _WinAPI_RegRestoreKey($hKey, @TempDir & '\reg.dat') Then
    MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), '', '"HKEY_CURRENT_USER\Software\AutoIt v3" has been restored to "HKEY_CURRENT_USER\Software\AutoIt v3 (Duplicate)".')
Else
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), '', _WinAPI_GetErrorMessage(@extended))
EndIf
_WinAPI_RegCloseKey($hKey)

; Restore "SeBackupPrivilege" and "SeRestorePrivilege" privileges by default
_WinAPI_AdjustTokenPrivileges($hToken, $aAdjust, 0, $aAdjust)
_WinAPI_CloseHandle($hToken)

FileDelete(@TempDir & '\reg.dat')


Function _WinAPI_RegSetValue

Function Reference

_WinAPI_RegSetValue

Sets the data and type of a specified value under a registry key

#include <WinAPIReg.au3>
_WinAPI_RegSetValue ( $hKey, $sValueName, $iType, $tValueData, $iBytes )

Parameters

$hKey | Handle to an open registry key. The key must have been opened with the $KEY_SET_VALUE access right. This handle is returned by the _WinAPI_RegCreateKey() or _WinAPI_RegOpenKey() function. It can also be one of the following predefined keys. $HKEY_CLASSES_ROOT $HKEY_CURRENT_CONFIG $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_PERFORMANCE_DATA $HKEY_USERS
$sValueName | The name of the value to be set. If a value with this name is not already present in the key, the function adds it to the key. If $sValueName is empty string, the function sets the type and data for the key's unnamed or default value.
$iType | The type of data. This parameter can be one of the following values. $REG_BINARY $REG_DWORD $REG_DWORD_BIG_ENDIAN $REG_DWORD_LITTLE_ENDIAN $REG_EXPAND_SZ $REG_LINK $REG_MULTI_SZ $REG_NONE $REG_QWORD $REG_QWORD_LITTLE_ENDIAN $REG_SZ
$tValueData | The structure (buffer) that contains the data to be stored. For string-based types, such as REG_SZ, the string must be null-terminated. With the REG_MULTI_SZ data type, the string must be terminated with two null characters. A backslash must be preceded by another backslash as an escape character. For example, specify "C:\\mydir\\myfile" to store the string "C:\mydir\myfile".
$iBytes | The size of the data, in bytes. If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, this size includes any terminating null character or characters unless the data was stored without them.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Related

_WinAPI_RegCreateKey, _WinAPI_RegOpenKey

See Also

Search RegSetValueEx in MSDN Library.


Function _WinAPI_SfcIsKeyProtected

Function Reference

_WinAPI_SfcIsKeyProtected

Determines whether the specified registry key is protected

#include <WinAPIReg.au3>
_WinAPI_SfcIsKeyProtected ( $hKey [, $sSubKey = Default [, $iFlag = 0]] )

Parameters

$hKey | Handle to the root registry key, it must be one of the following predefined keys: $HKEY_CLASSES_ROOT $HKEY_CURRENT_USER $HKEY_LOCAL_MACHINE $HKEY_USERS
$sSubKey | [optional] The name of the key to test. This key must be a subkey of the key identified by the $hKey parameter. If this parameter is not specified (Default), the function only checks whether the root registry key is protected.
$iFlag | [optional] The flag that specifies the alternate registry view that should be used by applications that run on 64-bit Windows. This flag is ignored on the x86 platform. It can be one of the following values: $KEY_WOW64_32KEY $KEY_WOW64_64KEY

Return Value

True: | the key is protected.
False: | the key is not protected.

Remarks

This function requires Windows Vista or later.

See Also

Search SfcIsKeyProtected in MSDN Library.


User Defined Functions

ShellEx user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIShellEx.au3>.

User Defined Function | Description
_WinAPI_DefSubclassProc | Calls the next handler in a window's subclass chain
_WinAPI_DllGetVersion | Retrieves a DLL-specific version information
_WinAPI_GetAllUsersProfileDirectory | Retrieves the path to the root of the directory that contains program data shared by all users
_WinAPI_GetDefaultUserProfileDirectory | Retrieves the path to the root of the default user's profile
_WinAPI_GetWindowSubclass | Retrieves the reference data for the specified window subclass callback
_WinAPI_RemoveWindowSubclass | Removes a subclass callback from a window
_WinAPI_SetCurrentProcessExplicitAppUserModelID | Specifies a unique application-defined Application User Model ID that identifies the current process to the taskbar
_WinAPI_SetWindowSubclass | Installs or updates a window subclass callback
_WinAPI_ShellAddToRecentDocs | Adds a file to the most recently and frequently item list
_WinAPI_ShellChangeNotify | Notifies the system of an event that an application has performed
_WinAPI_ShellChangeNotifyDeregister | Unregisters the client's window
_WinAPI_ShellChangeNotifyRegister | Registers a window to receive notifications from the file system or Shell
_WinAPI_ShellCreateDirectory | Creates a new file system folder
_WinAPI_ShellEmptyRecycleBin | Empties the Recycle Bin on the specified drive
_WinAPI_ShellExecute | Performs an operation on a specified file
_WinAPI_ShellExecuteEx | Performs an operation on a specified file
_WinAPI_ShellExtractAssociatedIcon | Returns a handle to the icon that associated with the specified file's
_WinAPI_ShellExtractIcon | Extracts the icon with the specified dimension from the specified file
_WinAPI_ShellFileOperation | Copies, moves, renames, or deletes a file system object
_WinAPI_ShellFlushSFCache | Flushes the special folder cache
_WinAPI_ShellGetFileInfo | Retrieves information about an object in the file system
_WinAPI_ShellGetIconOverlayIndex | Retrieves the index of the overlay icon in the system image list
_WinAPI_ShellGetKnownFolderIDList | Retrieves the path of a known folder as an ITEMIDLIST structure
_WinAPI_ShellGetKnownFolderPath | Retrieves the full path of a known folder identified
_WinAPI_ShellGetLocalizedName | Retrieves the localized name of a file in a Shell folder
_WinAPI_ShellGetPathFromIDList | Converts an item identifier list to a file system path
_WinAPI_ShellGetSetFolderCustomSettings | Sets or retrieves custom folder settings
_WinAPI_ShellGetSettings | Retrieves Shell state settings
_WinAPI_ShellGetSpecialFolderLocation | Retrieves a pointer to the ITEMIDLIST structure (PIDL) of a special folder
_WinAPI_ShellGetSpecialFolderPath | Retrieves the path of a special folder
_WinAPI_ShellGetStockIconInfo | Retrieves information about system-defined Shell icons
_WinAPI_ShellILCreateFromPath | Creates a pointer to an item identifier list (PIDL) from a path
_WinAPI_ShellNotifyIcon | Sends a message to the taskbar's status area
_WinAPI_ShellNotifyIconGetRect | Gets the screen coordinates of the bounding rectangle of a notification icon
_WinAPI_ShellObjectProperties | Invokes the Properties context menu command on a Shell object
_WinAPI_ShellOpenFolderAndSelectItems | Opens a Windows Explorer window with specified items in a particular folder selected
_WinAPI_ShellQueryRecycleBin | Retrieves the size of the Recycle Bin and the number of items in it, for a specified drive
_WinAPI_ShellQueryUserNotificationState | Checks the state of the computer for the current user
_WinAPI_ShellRemoveLocalizedName | Removes the localized name of a file in a Shell folder
_WinAPI_ShellRestricted | Determines whether a specified administrator policy is in effect
_WinAPI_ShellSetKnownFolderPath | Redirects a known folder to a new location
_WinAPI_ShellSetLocalizedName | Sets the localized name of a file in a Shell folder
_WinAPI_ShellSetSettings | Sets Shell state settings
_WinAPI_ShellUpdateImage | Notifies the Shell that an image in the system image list has changed


Function _WinAPI_DefSubclassProc

Function Reference

_WinAPI_DefSubclassProc

Calls the next handler in a window's subclass chain

#include <WinAPIShellEx.au3>
_WinAPI_DefSubclassProc ( $hWnd, $iMsg, $wParam, $lParam )

Parameters

$hWnd | Handle to the window being subclassed.
$iMsg | The message to be sent.
$wParam | The message-specific information.
$lParam | The message-specific information.

Return Value

Returns the returned value specific to the message sent.

Remarks

The last handler in the subclass chain is the original window procedure for the specified window.
You do not need to call the default window procedure; this function calls it automatically.

See Also

Search DefSubclassProc in MSDN Library.

Example

#include <Extras\WMDebug.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIShellEx.au3>

OnAutoItExitRegister('OnAutoItExit')

; Create GUI
Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'))

; Register DLL callback that will be used as window subclass procedure
Global $g_hDll = DllCallbackRegister('_SubclassProc', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr')
Global $g_pDll = DllCallbackGetPtr($g_hDll)

; Install window subclass callback
_WinAPI_SetWindowSubclass($g_hForm, $g_pDll, 1000, 0)

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _SubclassProc($hWnd, $iMsg, $wParam, $lParam, $iID, $pData)
    #forceref $iID, $pData
    ; Declared in WMDebug.au3
    _WM_Debug($hWnd, $iMsg, $wParam, $lParam)
    Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_SubclassProc

Func OnAutoItExit()
    _WinAPI_RemoveWindowSubclass($g_hForm, $g_pDll, 1000)
    DllCallbackFree($g_hDll)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_DllGetVersion

Function Reference

_WinAPI_DllGetVersion

Retrieves a DLL-specific version information

#include <WinAPIShellEx.au3>
_WinAPI_DllGetVersion ( $sFilePath )

Parameters

$sFilePath The path to the DLL file from which information is retrieved.

Return Value

Success: | The array containing the following information: [0] - The major version. [1] - The minor version. [2] - The build number. [3] - The platform for which the DLL was built ($DLLVER_PLATFORM_*).
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function is not an API. It is exported by name from each DLL that implements it.
Currently, most of the Windows Shell and common controls DLLs implement DllGetVersion.
These include, but are not limited to, shell32.dll, comctl32.dll, shdocvw.dll, and shlwapi.dll.

See Also

Search DllGetVersion in MSDN Library.

Example

#include <APIShellExConstants.au3>
#include <WinAPIShellEx.au3>

Local Const $sDll = @SystemDir & '\comctl32.dll'

Local $sText
Local $aData = _WinAPI_DllGetVersion($sDll)
Switch @error
    Case 0
        Switch $aData[3]
            Case $DLLVER_PLATFORM_WINDOWS
                $sText = 'Windows 95/98'
            Case $DLLVER_PLATFORM_NT
                $sText = 'NT-based'
            Case Else
                $sText = 'Unknown platform'
        EndSwitch
        ConsoleWrite($sDll & ' => ' & $aData[0] & '.' & $aData[1] & '.' & $aData[2] & ' (' & $sText & ')' & @CRLF)
    Case 3
        ConsoleWrite('DllGetVersion not implemented in ' & $sDll & '.' & @CRLF)
    Case Else
        ConsoleWrite('Unable to retrieve version information.' & @CRLF)
EndSwitch


Function _WinAPI_GetAllUsersProfileDirectory

Function Reference

_WinAPI_GetAllUsersProfileDirectory

Retrieves the path to the root of the directory that contains program data shared by all users

#include <WinAPIShellEx.au3>
_WinAPI_GetAllUsersProfileDirectory ( )

Return Value

Success: | The path to the directory.
Failure: | Empty string, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetAllUsersProfileDirectory in MSDN Library.


Function _WinAPI_GetDefaultUserProfileDirectory

Function Reference

_WinAPI_GetDefaultUserProfileDirectory

Retrieves the path to the root of the default user's profile

#include <WinAPIShellEx.au3>
_WinAPI_GetDefaultUserProfileDirectory ( )

Return Value

Success: | The path to the directory.
Failure: | Empty string, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetDefaultUserProfileDirectory in MSDN Library.


Function _WinAPI_GetWindowSubclass

Function Reference

_WinAPI_GetWindowSubclass

Retrieves the reference data for the specified window subclass callback

#include <WinAPIShellEx.au3>
_WinAPI_GetWindowSubclass ( $hWnd, $pSubclassProc, $idSubClass )

Parameters

$hWnd | Handle of the window being subclassed.
$pSubclassProc | A pointer to a window procedure. This pointer and the subclass ID uniquely identify this subclass callback. (See MSDN for more information)
$idSubClass | The subclass ID.

Return Value

Success: | The reference data for the window subclass callback.
Failure: | Sets the @error flag to non-zero.

See Also

Search GetWindowSubclass in MSDN Library.


Function _WinAPI_RemoveWindowSubclass

Function Reference

_WinAPI_RemoveWindowSubclass

Removes a subclass callback from a window

#include <WinAPIShellEx.au3>
_WinAPI_RemoveWindowSubclass ( $hWnd, $pSubclassProc, $idSubClass )

Parameters

$hWnd | Handle of the window being subclassed.
$pSubclassProc | A pointer to a window procedure. This pointer and the subclass ID uniquely identify this subclass callback. (See MSDN for more information)
$idSubClass | The subclass ID.

Return Value

Success: | True.
Failure: | False.

See Also

Search RemoveWindowSubclass in MSDN Library.

Example

#include <Extras\WMDebug.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIShellEx.au3>

OnAutoItExitRegister('OnAutoItExit')

; Create GUI
Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'))

; Register DLL callback that will be used as window subclass procedure
Global $g_hDll = DllCallbackRegister('_SubclassProc', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr')
Global $g_pDll = DllCallbackGetPtr($g_hDll)

; Install window subclass callback
_WinAPI_SetWindowSubclass($g_hForm, $g_pDll, 1000, 0)

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _SubclassProc($hWnd, $iMsg, $wParam, $lParam, $iID, $pData)
    #forceref $iID, $pData
    ; Declared in WMDebug.au3
    _WM_Debug($hWnd, $iMsg, $wParam, $lParam)
    Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_SubclassProc

Func OnAutoItExit()
    _WinAPI_RemoveWindowSubclass($g_hForm, $g_pDll, 1000)
    DllCallbackFree($g_hDll)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_SetCurrentProcessExplicitAppUserModelID

Function Reference

_WinAPI_SetCurrentProcessExplicitAppUserModelID

Specifies a unique application-defined Application User Model ID that identifies the current process to the taskbar

#include <WinAPIShellEx.au3>
_WinAPI_SetCurrentProcessExplicitAppUserModelID ( $sAppID )

Parameters

$sAppID The string that represents an Application User Model ID (AppUserModelID). This identifier allows an
application to group its associated processes and windows under a single taskbar button. An application
must provide its AppUserModelID in the following form and can have no more than 128 characters and
cannot contain spaces.

CompanyName.ProductName.SubProduct.VersionInformation
(See MSDN for more information)

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This method must be called during an application's initial startup routine before the application presents any
UI or makes any manipulation of its Jump Lists.

This function requires Windows 7 or later.

See Also

Search SetCurrentProcessExplicitAppUserModelID in MSDN Library.

Example

#NoTrayIcon

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIShellEx.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.1' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows 7 or later.')
    Exit
EndIf

Local $sAppID = 'Yashied.WinAPIEx.UDF'

Local $sParam
If Not $CmdLine[0] Then
    For $i = 1 To 5
        Switch $i
            Case 1 To 2
                $sParam = $sAppID & '.' & $i
            Case Else
                $sParam = $sAppID & '.3'
        EndSwitch
        If Not @Compiled Then
            Run(@AutoItExe & ' "' & @ScriptFullPath & '" ' & $sParam)
        Else
            Run(@AutoItExe & ' ' & $sParam)
        EndIf
        Sleep(100)
    Next
    Exit
EndIf

_WinAPI_SetCurrentProcessExplicitAppUserModelID($CmdLine[1])

GUICreate($CmdLine[1], 400, 400)
GUISetState(@SW_SHOWMINIMIZED)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_SetWindowSubclass

Function Reference

_WinAPI_SetWindowSubclass

Installs or updates a window subclass callback

#include <WinAPIShellEx.au3>
_WinAPI_SetWindowSubclass ( $hWnd, $pSubclassProc, $idSubClass [, $pData = 0] )

Parameters

$hWnd | Handle of the window being subclassed.
$pSubclassProc | A pointer to a window procedure. This pointer and the subclass ID uniquely identify this subclass callback. (See MSDN for more information)
$idSubClass | The subclass ID.
$pData | [optional] The reference data. This value is passed to the subclass procedure. The meaning of this value is determined by the calling application.

Return Value

Success: | True.
Failure: | False.

Remarks

Subclass callbacks are identified by the combination of the callback address and the caller-defined subclass ID.
If the callback address and ID pair have not yet been installed, then this function installs the subclass,
otherwise, this function just updates the reference data.

See Also

Search SetWindowSubclass in MSDN Library.

Example

#include <Extras\WMDebug.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIShellEx.au3>

OnAutoItExitRegister('OnAutoItExit')

; Create GUI
Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'))

; Register DLL callback that will be used as window subclass procedure
Global $g_hDll = DllCallbackRegister('_SubclassProc', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr')
Global $g_pDll = DllCallbackGetPtr($g_hDll)

; Install window subclass callback
_WinAPI_SetWindowSubclass($g_hForm, $g_pDll, 1000, 0)

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _SubclassProc($hWnd, $iMsg, $wParam, $lParam, $iID, $pData)
    #forceref $iID, $pData
    ; Declared in WMDebug.au3
    _WM_Debug($hWnd, $iMsg, $wParam, $lParam)
    Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_SubclassProc

Func OnAutoItExit()
    _WinAPI_RemoveWindowSubclass($g_hForm, $g_pDll, 1000)
    DllCallbackFree($g_hDll)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_ShellAddToRecentDocs

Function Reference

_WinAPI_ShellAddToRecentDocs

Adds a file to the most recently and frequently item list

#include <WinAPIShellEx.au3>
_WinAPI_ShellAddToRecentDocs ( $sFilePath )

Parameters

$sFilePath The name of the file to be added. Set this parameter to empty string to clear all usage data on all items.

Return Value

None.

See Also

Search SHAddToRecentDocs in MSDN Library.

Example

#include <WinAPIShellEx.au3>

_WinAPI_ShellAddToRecentDocs(@ScriptFullPath)


Function _WinAPI_ShellChangeNotify

Function Reference

_WinAPI_ShellChangeNotify

Notifies the system of an event that an application has performed

#include <WinAPIShellEx.au3>
_WinAPI_ShellChangeNotify ( $iEvent, $iFlags [, $iItem1 = 0 [, $iItem2 = 0]] )

Parameters

$iEvent | Describes the event that has occurred. Typically, only one event is specified at a time. If more than one event is specified, the values contained in the $iItem1 and $iItem2 parameters must be the same, respectively, for all specified events. This parameter can be one or more of the following values. $SHCNE_ALLEVENTS $SHCNE_ASSOCCHANGED $SHCNE_ATTRIBUTES $SHCNE_CREATE $SHCNE_DELETE $SHCNE_DRIVEADD $SHCNE_DRIVEADDGUI $SHCNE_DRIVEREMOVED $SHCNE_EXTENDED_EVENT $SHCNE_FREESPACE $SHCNE_MEDIAINSERTED $SHCNE_MEDIAREMOVED $SHCNE_MKDIR $SHCNE_NETSHARE $SHCNE_NETUNSHARE $SHCNE_RENAMEFOLDER $SHCNE_RENAMEITEM $SHCNE_RMDIR $SHCNE_SERVERDISCONNECT $SHCNE_UPDATEDIR $SHCNE_UPDATEIMAGE $SHCNE_UPDATEITEM $SHCNE_DISKEVENTS $SHCNE_GLOBALEVENTS $SHCNE_INTERRUPT (See MSDN for more information)
$iFlags | Flags that indicate the meaning of the $iItem1 and $iItem2 parameters. This parameter must be one of the following values. $SHCNF_DWORD $SHCNF_IDLIST $SHCNF_PATH $SHCNF_PRINTER $SHCNF_FLUSH $SHCNF_FLUSHNOWAIT $SHCNF_NOTIFYRECURSIVE (See MSDN for more information)
$iItem1 | [optional] First event-dependent value. Default is 0.
$iItem2 | [optional] Second event-dependent value. Default is 0.

Return Value

None.

See Also

Search SHChangeNotify in MSDN Library.

Example

#include <APIShellExConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIShellEx.au3>

Local $sIcon = RegRead('HKCR\AutoIt3Script\DefaultIcon', '')

If Not @error Then
    RegWrite('HKCR\AutoIt3Script\DefaultIcon', '', 'REG_SZ', @SystemDir & '\shell32.dll,-152')
    _WinAPI_ShellChangeNotify($SHCNE_ASSOCCHANGED, $SHCNF_FLUSH)
    MsgBox($MB_SYSTEMMODAL, '', 'The icon for .au3 files has been changed. Press OK to restore it.')
    RegWrite('HKCR\AutoIt3Script\DefaultIcon', '', 'REG_SZ', $sIcon)
    _WinAPI_ShellChangeNotify($SHCNE_ASSOCCHANGED, $SHCNF_FLUSH)
EndIf


Function _WinAPI_ShellChangeNotifyDeregister

Function Reference

_WinAPI_ShellChangeNotifyDeregister

Unregisters the client's window

#include <WinAPIShellEx.au3>
_WinAPI_ShellChangeNotifyDeregister ( $iID )

Parameters

$iID The value that specifies the registration ID returned by _WinAPI_ShellChangeNotifyRegister().

Return Value

Success: | True.
Failure: | False.

Related

_WinAPI_ShellChangeNotifyRegister

See Also

Search SHChangeNotifyDeregister in MSDN Library.


Function _WinAPI_ShellChangeNotifyRegister

Function Reference

_WinAPI_ShellChangeNotifyRegister

Registers a window to receive notifications from the file system or Shell

#include <WinAPIShellEx.au3>
_WinAPI_ShellChangeNotifyRegister ( $hWnd, $iMsg, $iEvents, $iSources, $aPaths [, $bRecursive = False] )

Parameters

$hWnd | Handle to the window that receives the change or notification messages.
$iMsg | Message to be posted to the window procedure.
$iEvents | Change notification events for which to receive notification. This parameter can be one or more of the $SHCNE_* values.
$iSources | One or more of the following values that indicate the type of events for which to receive notifications. $SHCNRF_INTERRUPTLEVEL $SHCNRF_SHELLLEVEL $SHCNRF_RECURSIVEINTERRUPT $SHCNRF_NEWDELIVERY
$aPaths | Single path or array of paths for which to receive notifications. These names should be fully-qualified paths to prevent unexpected results.
$bRecursive | [optional] Specifies whether to post notifications for children paths in $aPaths parameter, valid values: True - Notifications would come from the folder's children. False - Notifications would come from the specified folder's only (Default).

Return Value

Success: | The registration ID.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

When a change notification event is raised, the message indicated by $iMsg is delivered to the window
specified by the $hWnd parameter.

For performance reasons, multiple notifications can be combined into a single notification. For example,
if a large number of $SHCNE_UPDATEITEM notifications are generated for files in the same folder, they can be
joined into a single $SHCNE_UPDATEDIR notification.

Related

_WinAPI_ShellChangeNotifyDeregister

See Also

Search SHChangeNotifyRegister in MSDN Library.

Example

#include <APIShellExConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIShellEx.au3>

Opt('TrayAutoPause', 0)

Global Const $g_sPath = @TempDir & '\~TEST~'

DirCreate($g_sPath)
If Not FileExists($g_sPath) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create folder.')
    Exit
EndIf

OnAutoItExitRegister('OnAutoItExit')

Local $hWnd = GUICreate('')
Local $iMsg = _WinAPI_RegisterWindowMessage('SHELLCHANGENOTIFY')
GUIRegisterMsg($iMsg, 'WM_SHELLCHANGENOTIFY')
Global $g_iID = _WinAPI_ShellChangeNotifyRegister($hWnd, $iMsg, $SHCNE_ALLEVENTS, BitOR($SHCNRF_INTERRUPTLEVEL, $SHCNRF_SHELLLEVEL, $SHCNRF_RECURSIVEINTERRUPT), $g_sPath, 1)
If @error Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Window does not registered.')
    Exit
EndIf

While 1
    Sleep(1000)
WEnd

Func WM_SHELLCHANGENOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg

    Local $sPath = _WinAPI_ShellGetPathFromIDList(DllStructGetData(DllStructCreate('dword Item1; dword Item2', $wParam), 'Item1'))
    If $sPath Then
        ConsoleWrite('Event: 0x' & Hex($lParam) & ' | Path: ' & $sPath & @CRLF)
    Else
        ConsoleWrite('Event: 0x' & Hex($lParam) & @CRLF)
    EndIf
EndFunc   ;==>WM_SHELLCHANGENOTIFY

Func OnAutoItExit()
    If $g_iID Then
        _WinAPI_ShellChangeNotifyDeregister($g_iID)
    EndIf
    DirRemove($g_sPath)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_ShellCreateDirectory

Function Reference

_WinAPI_ShellCreateDirectory

Creates a new file system folder

#include <WinAPIShellEx.au3>
_WinAPI_ShellCreateDirectory ( $sFilePath [, $hParent = 0 [, $tSecurity = 0]] )

Parameters

$sFilePath | The fully qualified path of the directory.
$hParent | [optional] A handle to a parent window.
$tSecurity | [optional] $tagSECURITY_ATTRIBUTES structure with the directory's security attribute. If this parameter is 0 (Default), no security attributes are set.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

Remarks

If one or more of the intermediate folders do not exist, they are created as well. Also, this function verifies that the
files in the directory will be visible if the path is a network path to deal with network drivers which might have a
limited but unknown maximum path length.

See Also

Search SHCreateDirectoryEx in MSDN Library.


Function _WinAPI_ShellEmptyRecycleBin

Function Reference

_WinAPI_ShellEmptyRecycleBin

Empties the Recycle Bin on the specified drive

#include <WinAPIShellEx.au3>
_WinAPI_ShellEmptyRecycleBin ( [$sRoot = '' [, $iFlags = 0 [, $hParent = 0]]] )

Parameters

$sRoot | [optional] The string that contains the path of the root drive on which the Recycle Bin is located. This string can be formatted with the drive, folder, and subfolder names, for example "c:\windows\system\". If this parameter is empty string (Default), all Recycle Bins on all drives will be emptied.
$iFlags | [optional] This parameter can be one or more of the following values. $SHERB_NOCONFIRMATION $SHERB_NOPROGRESSUI $SHERB_NOSOUND $SHERB_NO_UI
$hParent | [optional] Handle to the parent window of any dialog boxes that might be displayed during the operation.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search SHEmptyRecycleBin in MSDN Library.


Function _WinAPI_ShellExecute

Function Reference

_WinAPI_ShellExecute

Performs an operation on a specified file

#include <WinAPIShellEx.au3>
_WinAPI_ShellExecute ( $sFilePath [, $sArgs = '' [, $sDir = '' [, $sVerb = '' [, $iShow = 1 [, $hParent = 0]]]]] )

Parameters

$sFilePath | The string that specifies the file or object on which to execute the specified verb. Note that not all verbs are supported on all objects. For example, not all document types support the "print" verb.
$sArgs | [optional] The string that specifies the parameters to be passed to the application.
$sDir | [optional] The string that specifies the working directory for the action.
$sVerb | [optional] The string, referred to as a verb, that specifies the action to be performed. The set of available verbs depends on the particular file or folder. Generally, the actions available from an object's shortcut menu are available verbs. The following verbs are commonly used: "edit" "explore" "find" "open" "edit" "print"
$iShow | [optional] The flags that specify how an application is to be displayed when it is opened ($SW_*).
$hParent | [optional] Handle to the owner window used for displaying a UI or error messages.

Return Value

Success: | True.
Failure: | False, @extended flag may contain an error value that indicates the cause of the failure. It can be one of the following values (excluding (-1)). The operating system is out of memory or resources (0) ERROR_FILE_NOT_FOUND (2) ERROR_PATH_NOT_FOUND (3) ERROR_BAD_FORMAT (11) SE_ERR_*

See Also

Search ShellExecute in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIShellEx.au3>

Local $sFile = InputBox('Run', 'Type the name of a program, folder, document, or Internet resource to open it', '', '', 368, 152)

If $sFile Then
    _WinAPI_ShellExecute($sFile, '', '', 'open')
    If @error Then
        MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to open "' & $sFile & '".' & @CRLF & @CRLF & @extended)
    EndIf
EndIf


Function _WinAPI_ShellExecuteEx

Function Reference

_WinAPI_ShellExecuteEx

Performs an operation on a specified file

#include <WinAPIShellEx.au3>
_WinAPI_ShellExecuteEx ( ByRef $tSHEXINFO )

Parameters

$tSHEXINFO $tagSHELLEXECUTEINFO structure that contains and receives information about the application being executed.

Return Value

Success: | True.
Failure: | False.

Remarks

$SE_ERR_* constants require #include <APIShellExConstants.au3>
If the function succeeds, it sets the "hInstApp" member of the $tagSHELLEXECUTEINFO structure to a value greater than 32,
If the function fails, "hInstApp" is set to one of the $SE_ERR_* constants that best indicates the cause of the failure.
The $SE_ERR_* error values are provided for compatibility with _WinAPI_ShellExecute(). To retrieve more accurate
error information, use _WinAPI_GetLastError().

Related

_WinAPI_ShellExecute

See Also

Search ShellExecuteEx in MSDN Library.


Function _WinAPI_ShellExtractAssociatedIcon

Function Reference

_WinAPI_ShellExtractAssociatedIcon

Returns a handle to the icon that associated with the specified file's

#include <WinAPIShellEx.au3>
_WinAPI_ShellExtractAssociatedIcon ( $sFilePath [, $bSmall = False] )

Parameters

$sFilePath | The full path and file name of the file that contains the icon, or its extension, such as ".txt".
$bSmall | [optional] Specifies whether to extract a small icon, valid values: True - Extract a small icon. False - Extract a large icon (Default).

Return Value

Success: | The icon handle.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

When you are finished using the icon, destroy it using the _WinAPI_DestroyIcon() function.

Related

_WinAPI_DestroyIcon

Example

#include <GUIConstantsEx.au3>
#include <GUIImageList.au3>
#include <GUIListView.au3>
#include <WinAPIShellEx.au3>
#include <WindowsConstants.au3>

Local $hIcon, $sKey, $iCount = 1, $bFirst = False
Local $tSHFILEINFO = DllStructCreate($tagSHFILEINFO)
Local $aExt[101] = [0]

RegRead('HKCR\.x', '')

While 1
    $sKey = RegEnumKey('HKCR', $iCount)
    If @error Then
        ExitLoop
    EndIf
    If StringLeft($sKey, 1) = '.' Then
        RegRead('HKCR\' & $sKey, '')
        If Abs(@error) <> 1 Then
            $aExt[0] += 1
            If $aExt[0] > UBound($aExt) - 1 Then
                ReDim $aExt[UBound($aExt) + 100]
            EndIf
            $aExt[$aExt[0]] = $sKey
        EndIf
        $bFirst = True
    Else
        If $bFirst Then
            ExitLoop
        EndIf
    EndIf
    $iCount += 1
WEnd

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 280, 391)

Local $idListview = GUICtrlCreateListView('', 10, 10, 260, 344, BitOR($LVS_DEFAULT, $LVS_NOCOLUMNHEADER), $WS_EX_CLIENTEDGE)
_GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_INFOTIP))
_GUICtrlListView_InsertColumn($idListview, 0, '', 238)
Local $hImageList = _GUIImageList_Create(16, 16, 5, 1)
_GUICtrlListView_SetImageList($idListview, $hImageList, 1)
Local $idButton = GUICtrlCreateButton('OK', 105, 361, 70, 23)

For $i = 1 To $aExt[0]
    $hIcon = _WinAPI_ShellExtractAssociatedIcon($aExt[$i], 1)
    _GUIImageList_ReplaceIcon($hImageList, -1, $hIcon)
    _GUICtrlListView_AddItem($idListview, $aExt[$i], $i - 1)
    _WinAPI_DestroyIcon($hIcon)
Next

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $idButton
            ExitLoop
    EndSwitch
WEnd


Function _WinAPI_ShellExtractIcon

Function Reference

_WinAPI_ShellExtractIcon

Extracts the icon with the specified dimension from the specified file

#include <WinAPIShellEx.au3>
_WinAPI_ShellExtractIcon ( $sIcon, $iIndex, $iWidth, $iHeight )

Parameters

$sIcon | Path and name of the file from which the icon are to be extracted.
$iIndex | The 0-based index of the icon to extract. If this value is a negative number, the function extracts the icon whose resource identifier is equal to the absolute value of $iIndex.
$iWidth | Horizontal icon size wanted.
$iHeight | Vertical icon size wanted.

Return Value

Success: | the handle to the extracted icon.
Failure: | 0.

Remarks

If the icon with the specified dimension is not found in the file, it will choose the nearest appropriate icon
and change to the specified dimension.

When you are finished using the icon, destroy it using the _WinAPI_DestroyIcon() function.

Related

_WinAPI_DestroyIcon

See Also

Search SHExtractIcons in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WinAPIShellEx.au3>

Local $iIndex = 0, $iTotal = _WinAPI_ExtractIconEx(@SystemDir & '\shell32.dll', -1, 0, 0, 0)

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 160, 160)
Local $idButton = GUICtrlCreateButton('Next', 50, 130, 70, 23)
Local $idIcon = GUICtrlCreateIcon(@SystemDir & '\shell32.dll', 0, 69, 54, 32, 32)
Local $hIcon = GUICtrlGetHandle(-1)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            $iIndex += 1
            If $iIndex > $iTotal - 1 Then
                $iIndex = 0
            EndIf
            _WinAPI_DestroyIcon(_SendMessage($hIcon, $STM_SETIMAGE, 1, _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', $iIndex, 32, 32)))
    EndSwitch
WEnd


Function _WinAPI_ShellFileOperation

Function Reference

_WinAPI_ShellFileOperation

Copies, moves, renames, or deletes a file system object

#include <WinAPIShellEx.au3>
_WinAPI_ShellFileOperation ( $sFrom, $sTo, $iFunc, $iFlags [, $sTitle = '' [, $hParent = 0]] )

Parameters

$sFrom | Single string or array of string that contains the source file name(s). These names should be fully-qualified paths to prevent unexpected results.
$sTo | Single string or array of string that contains the destination file or directory name(s) (if used). These names should be fully-qualified paths to prevent unexpected results.
$iFunc | A value that indicates which operation to perform. This parameter can be one of the following values. $FO_COPY $FO_DELETE $FO_MOVE $FO_RENAME
$iFlags | Flags that control the file operation. This parameter can be one of the following values. $FOF_ALLOWUNDO $FOF_CONFIRMMOUSE $FOF_FILESONLY $FOF_MULTIDESTFILES $FOF_NOCONFIRMATION $FOF_NOCONFIRMMKDIR $FOF_NO_CONNECTED_ELEMENTS $FOF_NOCOPYSECURITYATTRIBS $FOF_NOERRORUI $FOF_NORECURSEREPARSE $FOF_NORECURSION $FOF_RENAMEONCOLLISION $FOF_SILENT $FOF_SIMPLEPROGRESS $FOF_WANTMAPPINGHANDLE $FOF_WANTNUKEWARNING $FOF_NO_UI
$sTitle | [optional] The title of a progress dialog box. This parameter is used only if $iFlags includes the $FOF_SIMPLEPROGRESS flag.
$hParent | [optional] Handle to the dialog box to display information about the status of the file operation.

Return Value

Success: $tagSHFILEOPSTRUCT structure that contains the additional information.
Failure: Sets the @error flag, @extended may be set to the one of the following values.
113 - The source and destination files are the same file.
114 - Multiple file paths were specified in the source buffer, but only one destination file path.
115 - Rename operation was specified but the destination path is a different directory. Use the move operation instead.
116 - The source is a root directory, which cannot be moved or renamed.
117 - The operation was cancelled by the user, or silently cancelled if the appropriate flags were supplied to _WinAPI_ShellFileOperation().
118 - The destination is a subtree of the source.
120 - Security settings denied access to the source.
121 - The source or destination path exceeded or would exceed MAX_PATH.
122 - The operation involved multiple destination paths, which can fail in the case of a move operation.
124 - The path in the source or destination or both was invalid.
125 - The source and destination have the same parent folder.
126 - The destination path is an existing file.
128 - The destination path is an existing folder.
129 - The name of the file exceeds MAX_PATH.
130 - The destination is a read-only CD-ROM, possibly unformatted.
131 - The destination is a read-only DVD, possibly unformatted.
132 - The destination is a writable CD-ROM, possibly unformatted.
133 - The file involved in the operation is too large for the destination media or file system.
134 - The source is a read-only CD-ROM, possibly unformatted.
135 - The source is a read-only DVD, possibly unformatted.
136 - The source is a writable CD-ROM, possibly unformatted.
183 - MAX_PATH was exceeded during the operation.
026 - An unknown error occurred. This is typically due to an invalid path in the source or destination.
536 - An unspecified error occurred on the destination.
652 - Destination is a root directory and cannot be renamed.

Remarks

You should use fully-qualified path names with this function. Using it with relative path names is not thread safe.

See Also

Search SHFileOperation in MSDN Library.

Example

#include <APIShellExConstants.au3>
#include <WinAPIFiles.au3>
#include <WinAPIShellEx.au3>

; Create temporary file
Local $sTemp = _WinAPI_GetTempFileName(@TempDir)

ShellExecute('::{645FF040-5081-101B-9F08-00AA002F954E}')

; Delete file to Recycle Bin
If FileExists($sTemp) Then
    _WinAPI_ShellFileOperation($sTemp, '', $FO_DELETE, BitOR($FOF_ALLOWUNDO, $FOF_NO_UI))
EndIf


Function _WinAPI_ShellFlushSFCache

Function Reference

_WinAPI_ShellFlushSFCache

Flushes the special folder cache

#include <WinAPIShellEx.au3>
_WinAPI_ShellFlushSFCache ( )

Return Value

None.

Remarks

This function is called when the path to a special folder is changed. This ensures that the updated path stored
in the registry is used rather than the cached value.

See Also

Search SHFlushSFCache in MSDN Library.


Function _WinAPI_ShellGetFileInfo

Function Reference

_WinAPI_ShellGetFileInfo

Retrieves information about an object in the file system

#include <WinAPIShellEx.au3>
_WinAPI_ShellGetFileInfo ( $sFilePath, $iFlags, $iAttributes, ByRef $tSHFILEINFO )

Parameters

$sFilePath | String that contains the absolute or relative path and file name. This string can use either short (the 8.3 form) or long file names. If the $iFlags parameter includes the $SHGFI_PIDL flag, this parameter must be the address of an ITEMIDLIST (PIDL) structure that contains the list of item identifiers that uniquely identifies the file within the Shell's namespace. The pointer to an item identifier list (PIDL) must be a fully qualified PIDL. Relative PIDLs are not allowed. If the $iFlags parameter includes the $SHGFI_USEFILEATTRIBUTES flag, this parameter does not have to be a valid file name. The function will proceed as if the file exists with the specified name and with the file attributes passed in the $iAttributes parameter. This allows you to obtain information about a file type by passing just the extension for $sFilePath and passing $FILE_ATTRIBUTE_NORMAL in $iAttributes.
$iFlags | The flags that specify the file information to retrieve. This parameter can be a combination of the following values. $SHGFI_ATTR_SPECIFIED $SHGFI_ATTRIBUTES $SHGFI_DISPLAYNAME $SHGFI_EXETYPE $SHGFI_ICON $SHGFI_ICONLOCATION $SHGFI_LARGEICON $SHGFI_LINKOVERLAY $SHGFI_OPENICON $SHGFI_OVERLAYINDEX $SHGFI_PIDL $SHGFI_SELECTED $SHGFI_SHELLICONSIZE $SHGFI_SMALLICON $SHGFI_SYSICONINDEX $SHGFI_TYPENAME $SHGFI_USEFILEATTRIBUTES
$iAttributes | A combination of one or more file attribute flags ($FILE_ATTRIBUTE_*).
$tSHFILEINFO | $tagSHFILEINFO structure to receive the file information. This structure must be created before function call.

Return Value

Success: | If $iFlags contains the $SHGFI_EXETYPE flag, return type of the executable file. If $iFlags contains the $SHGFI_SYSICONINDEX flag, return handle to the system image list.
Failure: | 0.

Remarks

If this function returns an icon handle in the "hIcon" member of the $tagSHFILEINFO structure, you are responsible
for freeing it with _WinAPI_DestroyIcon() when you no longer need it.

Related

_WinAPI_DestroyIcon

See Also

Search SHGetFileInfo in MSDN Library.


Function _WinAPI_ShellGetIconOverlayIndex

Function Reference

_WinAPI_ShellGetIconOverlayIndex

Retrieves the index of the overlay icon in the system image list

#include <WinAPIShellEx.au3>
_WinAPI_ShellGetIconOverlayIndex ( $sIcon, $iIndex )

Parameters

$sIcon | The fully qualified path of the file that contains the icon.
$iIndex | The index of the icon. To request a standard overlay icon, set the path to an empty string, and index to one of the following values. $IDO_SHGIOI_LINK $IDO_SHGIOI_SHARE $IDO_SHGIOI_SLOWFILE Windows 7 or later $IDO_SHGIOI_DEFAULT

Return Value

Success: | The index of the overlay icon.
Failure: | (-1).

Remarks

To use this function, you must call _WinAPI_FileIconInit() at application launch.

Related

_WinAPI_FileIconInit

See Also

Search SHGetIconOverlayIndex in MSDN Library.


Function _WinAPI_ShellGetKnownFolderIDList

Function Reference

_WinAPI_ShellGetKnownFolderIDList

Retrieves the path of a known folder as an ITEMIDLIST structure

#include <WinAPIShellEx.au3>
_WinAPI_ShellGetKnownFolderIDList ( $sGUID [, $iFlags = 0 [, $hToken = 0]] )

Parameters

$sGUID | The GUID ($FOLDERID_*) that identifies the standard folders registered with the system.
$iFlags | [optional] The flags that specify special retrieval options. This parameter can be one or more of the following values. $KF_FLAG_CREATE $KF_FLAG_DONT_VERIFY $KF_FLAG_DONT_UNEXPAND $KF_FLAG_NO_ALIAS $KF_FLAG_INIT $KF_FLAG_DEFAULT_PATH $KF_FLAG_NOT_PARENT_RELATIVE $KF_FLAG_SIMPLE_IDLIST Windows 7 or later $KF_FLAG_ALIAS_ONLY
$hToken | [optional] The access token that represents a particular user. If this parameter is 0, the function requests the known folder for the current user. Assigning the $hToken parameter a value of (-1) indicates the Default User. Note that access to the Default User folders requires administrator privileges.

Return Value

Success: | The PIDL of the folder.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

To free the returned PIDL, call the _WinAPI_CoTaskMemFree() function.

This function requires Windows Vista or later.

Related

_WinAPI_CoTaskMemFree

See Also

Search SHGetKnownFolderIDList in MSDN Library.


Function _WinAPI_ShellGetKnownFolderPath

Function Reference

_WinAPI_ShellGetKnownFolderPath

Retrieves the full path of a known folder identified

#include <WinAPIShellEx.au3>
_WinAPI_ShellGetKnownFolderPath ( $sGUID [, $iFlags = 0 [, $hToken = 0]] )

Parameters

$sGUID | The GUID ($FOLDERID_*) that identifies the standard folders registered with the system.
$iFlags | [optional] The flags that specify special retrieval options. This parameter can be one or more of the following values. $KF_FLAG_CREATE $KF_FLAG_DONT_VERIFY $KF_FLAG_DONT_UNEXPAND $KF_FLAG_NO_ALIAS $KF_FLAG_INIT $KF_FLAG_DEFAULT_PATH $KF_FLAG_NOT_PARENT_RELATIVE $KF_FLAG_SIMPLE_IDLIST Windows 7 or later $KF_FLAG_ALIAS_ONLY
$hToken | [optional] The access token that represents a particular user. If this parameter is 0, the function requests the known folder for the current user. Assigning the $hToken parameter a value of (-1) indicates the Default User. Note that access to the Default User folders requires administrator privileges.

Return Value

Success: | The path of the known folder.
Failure: | Empty string and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

See Also

Search SHGetKnownFolderPath in MSDN Library.

Example

#include <APIShellExConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIShellEx.au3>
#include <WinAPISYs.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

ConsoleWrite(_WinAPI_ShellGetKnownFolderPath($FOLDERID_SendTo, 0, -1) & @CRLF)
ConsoleWrite(_WinAPI_ShellGetKnownFolderPath($FOLDERID_SendTo) & @CRLF)

Local Const $sFOLDERID_wrong = '{8983036C-27C0-404B-8F08-102D10DCFD75}'
ConsoleWrite('"' & _WinAPI_ShellGetKnownFolderPath($sFOLDERID_wrong) & '" @error = ' & @error & ' @extended = 0x' & Hex(@extended) & @CRLF)


Function _WinAPI_ShellGetLocalizedName

Function Reference

_WinAPI_ShellGetLocalizedName

Retrieves the localized name of a file in a Shell folder

#include <WinAPIShellEx.au3>
_WinAPI_ShellGetLocalizedName ( $sFilePath )

Parameters

$sFilePath The path to the target file.

Return Value

Success: | The array that contains the following information: [0] - The path to the module containing string resource that specifies the localized version of the file name. [1] - ID of the localized file name resource.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

See Also

Search SHGetLocalizedName in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIShellEx.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

Local $aData = _WinAPI_ShellGetLocalizedName(@MyDocumentsDir)
If Not IsArray($aData) Then
    Exit
EndIf

Local $hModule = _WinAPI_LoadLibraryEx($aData[0], $LOAD_LIBRARY_AS_DATAFILE)
ConsoleWrite('Path: ' & $aData[0] & @CRLF)
ConsoleWrite('ID:   ' & $aData[1] & @CRLF)
ConsoleWrite('Name: ' & _WinAPI_LoadString($hModule, $aData[1]) & @CRLF)
_WinAPI_FreeLibrary($hModule)


Function _WinAPI_ShellGetPathFromIDList

Function Reference

_WinAPI_ShellGetPathFromIDList

Converts an item identifier list to a file system path

#include <WinAPIShellEx.au3>
_WinAPI_ShellGetPathFromIDList ( $pPIDL )

Parameters

$pPIDL The address of an item identifier list that specifies a file or directory location relative to the root of the namespace (the desktop).

Return Value

Success: | The file system path.
Failure: | Empty string.

See Also

Search SHGetPathFromIDList in MSDN Library.


Function _WinAPI_ShellGetSetFolderCustomSettings

Function Reference

_WinAPI_ShellGetSetFolderCustomSettings

Sets or retrieves custom folder settings

#include <WinAPIShellEx.au3>
_WinAPI_ShellGetSetFolderCustomSettings ( $sFilePath, $iFlag, ByRef $tSHFCS )

Parameters

$sFilePath | The path to the folder.
$iFlag | A flag controlling the action of the function. It may be one of the following values. $FCS_READ $FCS_FORCEWRITE $FCS_WRITE
$tSHFCS | $tagSHFOLDERCUSTOMSETTINGS structure that provides or receives the custom folder settings. This structure must be created before function call.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function reads from and writes to Desktop.ini.

See Also

Search SHGetSetFolderCustomSettings in MSDN Library.

Example

#include <APIShellExConstants.au3>
#include <WinAPIDlg.au3>
#include <WinAPIShellEx.au3>

; Select folder
Local $sPath = FileSelectFolder('Select Folder', '', 0, @ScriptDir)
If Not $sPath Then
    Exit
EndIf

; Select icon
Local $aIcon = _WinAPI_PickIconDlg()
If @error Then Exit

; Set icon to selected folder
Local $tSHFCS = DllStructCreate($tagSHFOLDERCUSTOMSETTINGS & ';wchar szIconFile[' & (StringLen($aIcon[0]) + 1) & ']')
DllStructSetData($tSHFCS, 'Size', DllStructGetPtr($tSHFCS, 'szIconFile') - DllStructGetPtr($tSHFCS))
DllStructSetData($tSHFCS, 'Mask', $FCSM_ICONFILE)
DllStructSetData($tSHFCS, 'IconFile', DllStructGetPtr($tSHFCS, 'szIconFile'))
DllStructSetData($tSHFCS, 'SizeIF', 260)
DllStructSetData($tSHFCS, 'IconIndex', $aIcon[1])
DllStructSetData($tSHFCS, 'szIconFile', $aIcon[0])

_WinAPI_ShellGetSetFolderCustomSettings($sPath, $FCS_FORCEWRITE, $tSHFCS)


Function _WinAPI_ShellGetSettings

Function Reference

_WinAPI_ShellGetSettings

Retrieves Shell state settings

#include <WinAPIShellEx.au3>
_WinAPI_ShellGetSettings ( $iFlags )

Parameters

$iFlags The flags that indicate which settings should be retrieved. This parameter can be one or
more of the following values (use ONLY this flags).
$SSF_DESKTOPHTML
$SSF_DONTPRETTYPATH
$SSF_DOUBLECLICKINWEBVIEW
$SSF_HIDEICONS
$SSF_MAPNETDRVBUTTON
$SSF_NOCONFIRMRECYCLE
$SSF_NONETCRAWLING
$SSF_SEPPROCESS
$SSF_SHOWALLOBJECTS
$SSF_SHOWCOMPCOLOR
$SSF_SHOWEXTENSIONS
$SSF_SHOWINFOTIP
$SSF_SHOWSUPERHIDDEN
$SSF_SHOWSYSFILES
$SSF_STARTPANELON
$SSF_WIN95CLASSIC
$SSF_WEBVIEW

Windows Vista or later
$SSF_AUTOCHECKSELECT
$SSF_ICONSONLY
$SSF_SHOWTYPEOVERLAY

Return Value

Returns the value that contains a combination of flags specified in the $iFlags parameter. If flag is set,
appropriate setting is enabled, otherwise disabled. The function checks only flags that were
specified in the $iFlags parameter.

See Also

Search SHGetSetSettings in MSDN Library.

Example

#include <APIShellExConstants.au3>
#include <WinAPIShellEx.au3>

_WinAPI_ShellSetSettings($SSF_SHOWEXTENSIONS, Not _WinAPI_ShellGetSettings($SSF_SHOWEXTENSIONS))

ConsoleWrite('Hide extensions for known file types: ' & (Not _WinAPI_ShellGetSettings($SSF_SHOWEXTENSIONS)) & @CRLF)


Function _WinAPI_ShellGetSpecialFolderLocation

Function Reference

_WinAPI_ShellGetSpecialFolderLocation

Retrieves a pointer to the ITEMIDLIST structure (PIDL) of a special folder

#include <WinAPIShellEx.au3>
_WinAPI_ShellGetSpecialFolderLocation ( $iCSIDL )

Parameters

$iCSIDL The CSIDL ($CSIDL_*) that identifies the folder of interest.

Return Value

Success: | The PIDL specifying the folder's location relative to the root of the namespace (the desktop).
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

To free the returned PIDL, call the _WinAPI_CoTaskMemFree() function.

See Also

Search SHGetSpecialFolderLocation in MSDN Library.


Function _WinAPI_ShellGetSpecialFolderPath

Function Reference

_WinAPI_ShellGetSpecialFolderPath

Retrieves the path of a special folder

#include <WinAPIShellEx.au3>
_WinAPI_ShellGetSpecialFolderPath ( $iCSIDL [, $bCreate = False] )

Parameters

$iCSIDL | The CSIDL ($iCSIDL_*) that identifies the folder of interest.
$bCreate | [optional] Specifies whether the folder should be created if it does not already exist, valid values: True - The folder is created. False - The folder is not created (Default).

Return Value

Success: | The full path of a special folder.
Failure: | Empty string and sets the @error flag to non-zero.

See Also

Search SHGetSpecialFolderPath in MSDN Library.

Example

#include <APIShellExConstants.au3>
#include <WinAPIShellEx.au3>

ConsoleWrite('Windows => ' & _WinAPI_ShellGetSpecialFolderPath($CSIDL_WINDOWS) & @CRLF)
ConsoleWrite('System => ' & _WinAPI_ShellGetSpecialFolderPath($CSIDL_SYSTEM) & @CRLF)
ConsoleWrite('Fonts => ' & _WinAPI_ShellGetSpecialFolderPath($CSIDL_FONTS) & @CRLF)
ConsoleWrite('Program Files => ' & _WinAPI_ShellGetSpecialFolderPath($CSIDL_PROGRAM_FILES) & @CRLF)
ConsoleWrite('Profile => ' & _WinAPI_ShellGetSpecialFolderPath($CSIDL_PROFILE) & @CRLF)
ConsoleWrite('My Documents => ' & _WinAPI_ShellGetSpecialFolderPath($CSIDL_PERSONAL) & @CRLF)
ConsoleWrite('Start Menu => ' & _WinAPI_ShellGetSpecialFolderPath($CSIDL_STARTMENU) & @CRLF)
ConsoleWrite('Favorites => ' & _WinAPI_ShellGetSpecialFolderPath($CSIDL_FAVORITES) & @CRLF)
ConsoleWrite('Desktop => ' & _WinAPI_ShellGetSpecialFolderPath($CSIDL_DESKTOP) & @CRLF)

ConsoleWrite('Invalid CSIDL => "' & _WinAPI_ShellGetSpecialFolderPath(-1) & '" @error = ' & @error & ' @extended = 0x' & Hex(@extended) & @CRLF)


Function _WinAPI_ShellGetStockIconInfo

Function Reference

_WinAPI_ShellGetStockIconInfo

Retrieves information about system-defined Shell icons

#include <WinAPIShellEx.au3>
_WinAPI_ShellGetStockIconInfo ( $iSIID, $iFlags )

Parameters

$iSIID | One of the $SIID_* constants that specifies which icon should be retrieved. Those constants are defined in APIShellExConstants.au3.
$iFlags | The flags that specify which information is requested. This parameter can be a combination of the following values. $SHGSI_ICONLOCATION $SHGSI_ICON $SHGSI_SYSICONINDEX $SHGSI_LINKOVERLAY $SHGSI_SELECTED $SHGSI_LARGEICON $SHGSI_SMALLICON $SHGSI_SHELLICONSIZE

Return Value

Success: | $tagSHSTOCKICONINFO structure that contains the requested information.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

If this function returns an icon handle in the "hIcon" member of the $tagSHSTOCKICONINFO structure, you are
responsible for freeing the icon with _WinAPI_DestroyIcon() when you no longer need it.

This function requires Windows Vista or later.

Related

_WinAPI_DestroyIcon

See Also

Search SHGetStockIconInfo in MSDN Library.

Example

#include <APIShellExConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIShellEx.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 200, 236)
GUICtrlCreateIcon('', 0, 36, 36, 128, 128)
Local $h_Icon = GUICtrlGetHandle(-1)
GUICtrlSetState(-1, $GUI_DISABLE)
Local $idLabel = GUICtrlCreateLabel('', 70, 174, 60, 14, $SS_CENTER)
Local $idPrev = GUICtrlCreateButton('<', 32, 200, 60, 24)
Local $idNext = GUICtrlCreateButton('>', 108, 200, 60, 24)
GUISetState(@SW_SHOW)

Local $tSHSTOCKICONINFO, $hIcon, $hOld, $iCount = 0, $bUpdate = True
While 1
    If $bUpdate Then
        GUICtrlSetData($idLabel, 'SIID: ' & $iCount)
        $tSHSTOCKICONINFO = _WinAPI_ShellGetStockIconInfo($iCount, $SHGSI_ICONLOCATION)
        $hIcon = _WinAPI_ShellExtractIcon(DllStructGetData($tSHSTOCKICONINFO, 'Path'), DllStructGetData($tSHSTOCKICONINFO, 'iIcon'), 128, 128)
        $hOld = _SendMessage($h_Icon, $STM_SETIMAGE, 1, $hIcon)
        If $hOld Then
            _WinAPI_DestroyIcon($hOld)
        EndIf
        $bUpdate = 0
    EndIf
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idPrev
            $iCount -= 1
            If $iCount < 0 Then
                $iCount = $SIID_MAX_ICONS - 1
            EndIf
            $bUpdate = 1
        Case $idNext
            $iCount += 1
            If $iCount > $SIID_MAX_ICONS - 1 Then
                $iCount = 0
            EndIf
            $bUpdate = 1
    EndSwitch
WEnd


Function _WinAPI_ShellILCreateFromPath

Function Reference

_WinAPI_ShellILCreateFromPath

Creates a pointer to an item identifier list (PIDL) from a path

#include <WinAPIShellEx.au3>
_WinAPI_ShellILCreateFromPath ( $sFilePath )

Parameters

$sFilePath The path to be converted.

Return Value

Success: | a PIDL to the path in $sFilePath.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

To free the returned PIDL, call the _WinAPI_CoTaskMemFree() function.

Related

_WinAPI_CoTaskMemFree

See Also

Search SHILCreateFromPath in MSDN Library.


Function _WinAPI_ShellNotifyIcon

Function Reference

_WinAPI_ShellNotifyIcon

Sends a message to the taskbar's status area

#include <WinAPIShellEx.au3>
_WinAPI_ShellNotifyIcon ( $iMessage, $tNOTIFYICONDATA )

Parameters

$iMessage | The variable that specifies the action to be taken. It can have one of the following values. $NIM_ADD $NIM_MODIFY $NIM_DELETE $NIM_SETFOCUS $NIM_SETVERSION
$tNOTIFYICONDATA | $tagNOTIFYICONDATA structure. The content and size of this structure depends on the value of the $iMessage and version of the operating system.

Return Value

Success: | True.
Failure: | False.

See Also

Search Shell_NotifyIcon in MSDN Library.

Example

#include <APIShellExConstants.au3>
#include <WinAPIShellEx.au3>

Local $tNOTIFYICONDATA = DllStructCreate($tagNOTIFYICONDATA)

OnAutoItExitRegister('OnAutoItExit')

DllStructSetData($tNOTIFYICONDATA, 'Size', DllStructGetSize($tNOTIFYICONDATA))
DllStructSetData($tNOTIFYICONDATA, 'hWnd', WinGetHandle(AutoItWinGetTitle()))
DllStructSetData($tNOTIFYICONDATA, 'Flags', $NIF_ICON)

DllStructSetData($tNOTIFYICONDATA, 'ID', 2)
DllStructSetData($tNOTIFYICONDATA, 'hIcon', _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 166, 16, 16))
_WinAPI_ShellNotifyIcon($NIM_ADD, $tNOTIFYICONDATA)

DllStructSetData($tNOTIFYICONDATA, 'ID', 3)
DllStructSetData($tNOTIFYICONDATA, 'hIcon', _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 130, 16, 16))
_WinAPI_ShellNotifyIcon($NIM_ADD, $tNOTIFYICONDATA)

While 1
    Sleep(1000)
WEnd

Func OnAutoItExit()
    DllStructSetData($tNOTIFYICONDATA, 'ID', 2)
    _WinAPI_ShellNotifyIcon($NIM_DELETE, $tNOTIFYICONDATA)
    DllStructSetData($tNOTIFYICONDATA, 'ID', 3)
    _WinAPI_ShellNotifyIcon($NIM_DELETE, $tNOTIFYICONDATA)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_ShellNotifyIconGetRect

Function Reference

_WinAPI_ShellNotifyIconGetRect

Gets the screen coordinates of the bounding rectangle of a notification icon

#include <WinAPIShellEx.au3>
_WinAPI_ShellNotifyIconGetRect ( $hWnd, $iID [, $tGUID = 0] )

Parameters

$hWnd | Handle to the parent window used by the notification's callback function. For more information, see the "hWnd" member of the $tagNOTIFYICONDATA structure.
$iID | Application-defined identifier of the notification icon. Multiple icons can be associated with a single $hWnd, each with their own $iID.
$tGUID | [optional] $tagGUID structure that identifies the icon.

Return Value

Success: | $tagRECT structure that contains the coordinates of the icon.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

The icon can be identified through $hWnd plus $iID, or $tGUID alone (recommended).

This function requires Windows 7 or later.

See Also

Search Shell_NotifyIconGetRect in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIShellEx.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.1' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows 7 or later.')
    Exit
EndIf

Local $tRECT = _WinAPI_ShellNotifyIconGetRect(WinGetHandle(AutoItWinGetTitle()), 1)

Local $aPos
If Not @error Then
    $aPos = _WinAPI_GetPosFromRect($tRECT)
    MouseMove($aPos[0] + 12, $aPos[1] + 12)
    MouseClick('left')
    While 1
        Sleep(1000)
    WEnd
EndIf


Function _WinAPI_ShellObjectProperties

Function Reference

_WinAPI_ShellObjectProperties

Invokes the Properties context menu command on a Shell object

#include <WinAPIShellEx.au3>
_WinAPI_ShellObjectProperties ( $sFilePath [, $iType = 2 [, $sProperty = '' [, $hParent = 0]]] )

Parameters

$sFilePath | The object name.
$iType | [optional] The value that specifies the type of object. $SHOP_PRINTERNAME $SHOP_FILEPATH (Default) $SHOP_VOLUMEGUID
$sProperty | [optional] The name of the property sheet page to be opened initially.
$hParent | [optional] Handle of the parent window of the dialog box.

Return Value

Success: | True.
Failure: | False.

See Also

Search SHObjectProperties in MSDN Library.

Example

#include <WinAPIShellEx.au3>

Opt('WinTitleMatchMode', 4)

If Not _WinAPI_ShellObjectProperties(@ScriptFullPath) Then Exit

Local $hWnd = WinWaitActive(@ScriptName, '', 3)
If Not $hWnd Then
    Exit
EndIf

While WinExists($hWnd)
    Sleep(100)
WEnd


Function _WinAPI_ShellOpenFolderAndSelectItems

Function Reference

_WinAPI_ShellOpenFolderAndSelectItems

Opens a Windows Explorer window with specified items in a particular folder selected

#include <WinAPIShellEx.au3>
_WinAPI_ShellOpenFolderAndSelectItems ( $sFilePath [, $aNames = 0 [, $iStart = 0 [, $iEnd = -1 [, $iFlags = 0]]]] )

Parameters

$sFilePath | The fully qualified path that specifies the folder or file. If $aNames parameter is used, $sFilePath should specified only to a folder, otherwise, the function fails. This parameter can be an empty string.
$aNames | [optional] The array of the folder or file names to be selected. It should be just names in the specified folder, without its path.
$iStart | [optional] The index of array to start selecting at.
$iEnd | [optional] The index of array to stop selecting at.
$iFlags | [optional] The optional flags. This parameter can be one or more of the following values. Windows Vista or later $OFASI_EDIT $OFASI_OPENDESKTOP

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search SHOpenFolderAndSelectItems in MSDN Library.

Example

#include <File.au3>
#include <WinAPIShellEx.au3>

; X64 running support
Local $sWow64 = ""
If @AutoItX64 Then $sWow64 = "\Wow6432Node"

Local $sPath = RegRead('HKLM\SOFTWARE' & $sWow64 & '\AutoIt v3\AutoIt', 'InstallDir')

Local $aList = _FileListToArray($sPath, '*.exe', 1)

If IsArray($aList) Then
    _WinAPI_ShellOpenFolderAndSelectItems($sPath, $aList, 1)
EndIf


Function _WinAPI_ShellQueryRecycleBin

Function Reference

_WinAPI_ShellQueryRecycleBin

Retrieves the size of the Recycle Bin and the number of items in it, for a specified drive

#include <WinAPIShellEx.au3>
_WinAPI_ShellQueryRecycleBin ( [$sRoot = ''] )

Parameters

$sRoot [optional] The string that contains the path of the root drive on which the Recycle Bin is located. This string
can be formatted with the drive, folder, and subfolder names, for example "c:\windows\system\".
If this parameter is empty string, information is retrieved for all Recycle Bins on all drives.

Return Value

Success: | The array that contains the following information: [0] - The total size of all the objects in the specified Recycle Bin, in bytes. [1] - The total number of items in the specified Recycle Bin.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search SHQueryRecycleBin in MSDN Library.


Function _WinAPI_ShellQueryUserNotificationState

Function Reference

_WinAPI_ShellQueryUserNotificationState

Checks the state of the computer for the current user

#include <WinAPIShellEx.au3>
_WinAPI_ShellQueryUserNotificationState ( )

Return Value

Success: | The current computer state ($QUNS_*).
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

See Also

Search SHQueryUserNotificationState in MSDN Library.


Function _WinAPI_ShellRemoveLocalizedName

Function Reference

_WinAPI_ShellRemoveLocalizedName

Removes the localized name of a file in a Shell folder

#include <WinAPIShellEx.au3>
_WinAPI_ShellRemoveLocalizedName ( $sFilePath )

Parameters

$sFilePath The path to the target file.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

See Also

Search SHRemoveLocalizedName in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIShellEx.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

Local Const $sDll = @ScriptDir & '\Extras\Resources.dll'
Local Const $sDir = @TempDir & '\Temporary Folder'

If Not FileExists($sDll) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', $sDll & ' not found.')
    Exit
EndIf

If Not DirCreate($sDir) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create folder.')
    Exit
EndIf

_WinAPI_ShellOpenFolderAndSelectItems($sDir)
MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), '', 'Press OK to set localized name for "' & _WinAPI_PathStripPath($sDir) & '".')
_WinAPI_ShellSetLocalizedName($sDir, $sDll, 6000)
MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), '', 'Press OK to remove localized name.')
_WinAPI_ShellRemoveLocalizedName($sDir)
MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), '', 'Press OK to exit.')

DirRemove($sDir, 1)


Function _WinAPI_ShellRestricted

Function Reference

_WinAPI_ShellRestricted

Determines whether a specified administrator policy is in effect

#include <WinAPIShellEx.au3>
_WinAPI_ShellRestricted ( $iRestriction )

Parameters

$iRestriction A restriction. This parameter can be one of the $REST_* constants defined in APIShellExConstants.au3.

Return Value

Success: | True - The specified restriction is in effect.
Failure: | False.

See Also

Search SHRestricted in MSDN Library.


Function _WinAPI_ShellSetKnownFolderPath

Function Reference

_WinAPI_ShellSetKnownFolderPath

Redirects a known folder to a new location

#include <WinAPIShellEx.au3>
_WinAPI_ShellSetKnownFolderPath ( $sGUID, $sFilePath [, $iFlags = 0 [, $hToken = 0]] )

Parameters

$sGUID | The GUID ($FOLDERID_*) that identifies the known folder.
$sFilePath | The folder's new path.
$iFlags | [optional] This parameter can be 0 or the following value. $KF_FLAG_DONT_UNEXPAND
$hToken | [optional] The access token that represents a particular user. If this parameter is 0, the function requests the known folder for the current user. Assigning the $hToken parameter a value of (-1) indicates the Default User. Note that access to the Default User folders requires administrator privileges.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

To call this function on public known folders, the caller must have Administrator privileges. For per-user known
folders the caller only requires User privileges.

To call this function on a folder of type $KF_CATEGORY_COMMON, the calling application must be running with
elevated privileges.

This function cannot be called on folders of type $KF_CATEGORY_FIXED and $KF_CATEGORY_VIRTUAL.

This function requires Windows Vista or later.

See Also

Search SHSetKnownFolderPath in MSDN Library.


Function _WinAPI_ShellSetLocalizedName

Function Reference

_WinAPI_ShellSetLocalizedName

Sets the localized name of a file in a Shell folder

#include <WinAPIShellEx.au3>
_WinAPI_ShellSetLocalizedName ( $sFilePath, $sModule, $iResID )

Parameters

$sFilePath | The path to the target file.
$sModule | The path to the module containing string resource that specifies the localized version of the file name.
$iResID | ID of the localized file name resource.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

When this string is set, Windows Explorer displays this string instead of the file name. The path to the file
is unchanged.

This function requires Windows Vista or later.

See Also

Search SHSetLocalizedName in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIShellEx.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

Local Const $sDll = @ScriptDir & '\Extras\Resources.dll'
Local Const $sDir = @TempDir & '\Temporary Folder'

If Not FileExists($sDll) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', $sDll & ' not found.')
    Exit
EndIf

If Not DirCreate($sDir) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create folder.')
    Exit
EndIf

_WinAPI_ShellOpenFolderAndSelectItems($sDir)
MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), '', 'Press OK to set localized name for "' & _WinAPI_PathStripPath($sDir) & '".')
_WinAPI_ShellSetLocalizedName($sDir, $sDll, 6000)
MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), '', 'Press OK to remove localized name.')
_WinAPI_ShellRemoveLocalizedName($sDir)
MsgBox(BitOR($MB_ICONINFORMATION, $MB_SYSTEMMODAL), '', 'Press OK to exit.')

DirRemove($sDir, 1)


Function _WinAPI_ShellSetSettings

Function Reference

_WinAPI_ShellSetSettings

Sets Shell state settings

#include <WinAPIShellEx.au3>
_WinAPI_ShellSetSettings ( $iFlags, $bSet )

Parameters

$iFlags | The flags that indicate which settings should be set. This parameter can be one or more of the following values (use ONLY this flags). $SSF_SHOWALLOBJECTS $SSF_SHOWEXTENSIONS $SSF_SHOWCOMPCOLOR $SSF_SHOWSYSFILES $SSF_DOUBLECLICKINWEBVIEW $SSF_DESKTOPHTML $SSF_WIN95CLASSIC $SSF_DONTPRETTYPATH $SSF_MAPNETDRVBUTTON $SSF_SHOWINFOTIP $SSF_HIDEICONS $SSF_NOCONFIRMRECYCLE $SSF_WEBVIEW $SSF_SHOWSUPERHIDDEN $SSF_SEPPROCESS $SSF_NONETCRAWLING $SSF_STARTPANELON Windows Vista or later $SSF_AUTOCHECKSELECT $SSF_ICONSONLY $SSF_SHOWTYPEOVERLAY
$bSet | Specifies whether a settings ($SSF_*) is enable or disable, valid values: True - Enable. False - Disable.

Return Value

None.

See Also

Search SHGetSetSettings in MSDN Library.

Example

#include <APIShellExConstants.au3>
#include <WinAPIShellEx.au3>

_WinAPI_ShellSetSettings($SSF_SHOWEXTENSIONS, Not _WinAPI_ShellGetSettings($SSF_SHOWEXTENSIONS))

ConsoleWrite('Hide extensions for known file types: ' & (Not _WinAPI_ShellGetSettings($SSF_SHOWEXTENSIONS)) & @CRLF)


Function _WinAPI_ShellUpdateImage

Function Reference

_WinAPI_ShellUpdateImage

Notifies the Shell that an image in the system image list has changed

#include <WinAPIShellEx.au3>
_WinAPI_ShellUpdateImage ( $sIcon, $iIndex, $iImage [, $iFlags = 0] )

Parameters

$sIcon | The fully qualified path of the file that contains the icon.
$iIndex | The 0-based index of the icon.
$iImage | The 0-based index in the system image list of the icon that is being updated.
$iFlags | [optional] The flags that determine the icon attributes. It can be 0 or a combination of the following values. $GIL_NOTFILENAME $GIL_SIMULATEDOC

Return Value

None.

Remarks

If you do not know the index in the system image list of the icon that you want to update, use the
_WinAPI_ShellGetFileInfo() function with the $SHGFI_SYSICONINDEX flag set.

To use this function, you must call _WinAPI_FileIconInit() at application launch.

Related

_WinAPI_FileIconInit, _WinAPI_ShellGetFileInfo

See Also

Search SHUpdateImage in MSDN Library.


User Defined Functions

ShellPath user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPIShPath.au3>.

User Defined Function | Description
_WinAPI_CommandLineToArgv | Parses a command-line string and returns an array of the command-line arguments
_WinAPI_IsNameInExpression | Determines whether a string matches the specified pattern
_WinAPI_ParseURL | Performs rudimentary parsing of a URL
_WinAPI_ParseUserName | Extracts the domain and user account name from a fully qualified user name
_WinAPI_PathAddBackslash | Adds a backslash to the end of a string to create the correct syntax for a path
_WinAPI_PathAddExtension | Adds a file name extension to a path string
_WinAPI_PathAppend | Appends one path to the end of another
_WinAPI_PathBuildRoot | Creates a root path from a given drive number
_WinAPI_PathCanonicalize | Removes elements of a file path according to special strings inserted into that path
_WinAPI_PathCommonPrefix | Compares two paths to determine if they share a common prefix
_WinAPI_PathCompactPath | Truncates a file path to fit within a given pixel width by replacing path components with ellipses
_WinAPI_PathCompactPathEx | Truncates a path to fit within a certain number of characters by replacing path components with ellipses
_WinAPI_PathCreateFromUrl | Converts a file URL to a Microsoft MS-DOS path
_WinAPI_PathFindExtension | Searches a path for an extension
_WinAPI_PathFindFileName | Searches a path for a file name
_WinAPI_PathFindNextComponent | Parses a path and returns the portion of that path that follows the first backslash
_WinAPI_PathGetArgs | Finds the command-line arguments within a given path
_WinAPI_PathGetCharType | Determines the type of character in relation to a path
_WinAPI_PathGetDriveNumber | Searches a path for a drive letter within the range of 'A' to 'Z' and returns the corresponding drive number
_WinAPI_PathIsContentType | Determines if a file's registered content type matches the specified content type
_WinAPI_PathIsExe | Determines whether a file is an executable by examining the file extension
_WinAPI_PathIsFileSpec | Searches a path for any path-delimiting characters
_WinAPI_PathIsLFNFileSpec | Determines whether a file name is in long format
_WinAPI_PathIsRelative | Searches a path and determines if it is relative
_WinAPI_PathIsRoot | Parses a path to determine if it is a directory root
_WinAPI_PathIsSameRoot | Compares two paths to determine if they have a common root component
_WinAPI_PathIsSystemFolder | Determines if an existing folder contains the attributes that make it a system folder
_WinAPI_PathIsUNC | Determines if the string is a valid Universal Naming Convention (UNC) for a server and share path
_WinAPI_PathIsUNCServer | Determines if a string is a valid Universal Naming Convention (UNC) for a server path only
_WinAPI_PathIsUNCServerShare | Determines if a string is a valid Universal Naming Convention (UNC) share path
_WinAPI_PathMakeSystemFolder | Gives an existing folder the proper attributes to become a system folder
_WinAPI_PathMatchSpec | Searches a string using a Microsoft MS-DOS wild card match type
_WinAPI_PathParseIconLocation | Parses a file location string that contains a file location and icon index
_WinAPI_PathRelativePathTo | Creates a relative path from one file or folder to another
_WinAPI_PathRemoveArgs | Removes any arguments from a given path
_WinAPI_PathRemoveBackslash | Removes the trailing backslash from a given path
_WinAPI_PathRemoveExtension | Removes the file name extension from a path, if one is present
_WinAPI_PathRemoveFileSpec | Removes the trailing file name and backslash from a path, if they are present
_WinAPI_PathRenameExtension | Replaces the extension of a file name with a new extension
_WinAPI_PathSearchAndQualify | Formats a path to the fully qualified path
_WinAPI_PathSkipRoot | Parses a path, ignoring the drive letter or Universal Naming Convention (UNC) server/share path elements
_WinAPI_PathStripPath | Removes the path portion of a fully qualified path and file
_WinAPI_PathStripToRoot | Removes all parts of the path except for the root information
_WinAPI_PathUndecorate | Removes the decoration from a path string
_WinAPI_PathUnExpandEnvStrings | Replaces folder names in a fully-qualified path with their associated environment string
_WinAPI_PathUnmakeSystemFolder | Removes the attributes from a folder that make it a system folder
_WinAPI_PathUnquoteSpaces | Removes quotes from the beginning and end of a path
_WinAPI_PathYetAnotherMakeUniqueName | Creates a unique filename based on an existing filename
_WinAPI_ShellGetImageList | Retrieves the system image list for small or large icons
_WinAPI_UrlApplyScheme | Determines a scheme for a specified URL string, and returns a string with an appropriate prefix
_WinAPI_UrlCanonicalize | Converts a URL string into canonical form
_WinAPI_UrlCombine | Combines the base an relative URLs in canonical form
_WinAPI_UrlCompare | Makes a case-sensitive comparison of two URL strings
_WinAPI_UrlCreateFromPath | Converts a Microsoft MS-DOS path to a canonicalized URL
_WinAPI_UrlFixup | Attempts to correct a URL whose protocol identifier is incorrect
_WinAPI_UrlGetPart | Retrieves a specified part from the URL
_WinAPI_UrlHash | Hashes a URL string
_WinAPI_UrlIs | Tests whether or not a URL is a specified type


Function _WinAPI_CommandLineToArgv

Function Reference

_WinAPI_CommandLineToArgv

Parses a command-line string and returns an array of the command-line arguments

#include <WinAPIShPath.au3>
_WinAPI_CommandLineToArgv ( $sCmd )

Parameters

$sCmd The string that contains the full command line. If this parameter is an empty string the function returns an empty array (zeroth element is 0).

Return Value

Success: | the array of the command-line arguments. The zeroth array element contains the number of arguments.
Failure: | sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search CommandLineToArgvW in MSDN Library.

Example

#include <Array.au3>
#include <WinAPIShPath.au3>

Local $aData = _WinAPI_CommandLineToArgv('"a b" c d')
_ArrayDisplay($aData, '_WinAPI_CommandLineToArgv')


Function _WinAPI_IsNameInExpression

Function Reference

_WinAPI_IsNameInExpression

Determines whether a string matches the specified pattern

#include <WinAPIShPath.au3>
_WinAPI_IsNameInExpression ( $sString, $sPattern [, $bCaseSensitive = False] )

Parameters

$sString | The string to be compared against the pattern. This string cannot contain wildcard characters.
$sPattern | The pattern string. This string can contain wildcard characters.
$bCaseSensitive | [optional] Specifies whether to treat the string as case sensitive when matching, valid values: True - The case-sensitive matching. False - The case-insensitive matching (Default).

Return Value

True: | the string matches the specified pattern.
False: | the string does not match the specified pattern.

Remarks

If only one of the parameters is an empty string, the function returns 0 (False). This means that "*" does not
match an empty string. If both parameters are empty strings, the function returns 1 (True).

This function requires Windows 7 or later.

See Also

Search RtlIsNameInExpression in MSDN Library.


Function _WinAPI_ParseURL

Function Reference

_WinAPI_ParseURL

Performs rudimentary parsing of a URL

#include <WinAPIShPath.au3>
_WinAPI_ParseURL ( $sUrl )

Parameters

$sUrl The URL to be parsed.

Return Value

Success: | The array containing the following information: [0] - The protocol part of the URL. [1] - The section of the URL that follows the protocol and colon (":"). [2] - The URL scheme (one of the $URL_SCHEME_* constants).
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search ParseURL in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $aData = _WinAPI_ParseURL('http://www.microsoft.com')

ConsoleWrite('Protocol: ' & $aData[0] & @CRLF)
ConsoleWrite('Suffix:   ' & $aData[1] & @CRLF)
ConsoleWrite('Scheme:   ' & $aData[2] & @CRLF)


Function _WinAPI_ParseUserName

Function Reference

_WinAPI_ParseUserName

Extracts the domain and user account name from a fully qualified user name

#include <WinAPIShPath.au3>
_WinAPI_ParseUserName ( $sUser )

Parameters

$sUser The user name to be parsed. The name must be in UPN or down-level format, or a certificate.

Return Value

Success: | The array containing the following information: [0] - The domain name (if present). [1] - The user account name.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the system error code.

See Also

Search CredUIParseUserName in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $aData = _WinAPI_ParseUserName('ALX\Alexander')

ConsoleWrite('Domain: ' & $aData[0] & @CRLF)
ConsoleWrite('User:   ' & $aData[1] & @CRLF)


Function _WinAPI_PathAddBackslash

Function Reference

_WinAPI_PathAddBackslash

Adds a backslash to the end of a string to create the correct syntax for a path

#include <WinAPIShPath.au3>
_WinAPI_PathAddBackslash ( $sFilePath )

Parameters

$sFilePath The path to which the backslash will be appended. If this path already has a trailing backslash,
no backslash will be added.

Return Value

Success: | The resulting path.
Failure: | Sets the @error flag to non-zero.

See Also

Search PathAddBackslash in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $aPath[2] = ['C:\Documents\', 'C:\Documents']

For $i = 0 To 1
    ConsoleWrite($aPath[$i] & ' => ' & _WinAPI_PathAddBackslash($aPath[$i]) & @CRLF)
Next


Function _WinAPI_PathAddExtension

Function Reference

_WinAPI_PathAddExtension

Adds a file name extension to a path string

#include <WinAPIShPath.au3>
_WinAPI_PathAddExtension ( $sFilePath [, $sExt = ''] )

Parameters

$sFilePath | The path to which the file name extension will be appended. If there is already a file name extension present, no extension will be added.
$sExt | [optional] The file name extension. If this parameter is empty string, an ".exe" extension will be added.

Return Value

Returns the resulting path, @extended will set to 1 if an extension was added, or 0 otherwise.

Remarks

If there is already a file name extension present, no extension will be added.
If the $sFilePath is an empty string, the result will be the file name extension only.
If $sExt is an empty string, an ".exe" extension will be added.

See Also

Search PathAddExtension in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $aPath[2] = ['C:\Documents\Test.txt', 'C:\Documents\Test']

For $i = 0 To 1
    ConsoleWrite($aPath[$i] & ' => ' & _WinAPI_PathAddExtension($aPath[$i], '.doc') & @CRLF)
Next


Function _WinAPI_PathAppend

Function Reference

_WinAPI_PathAppend

Appends one path to the end of another

#include <WinAPIShPath.au3>
_WinAPI_PathAppend ( $sFilePath, $sMore )

Parameters

$sFilePath | The string to which the path is appended.
$sMore | The path to be appended.

Return Value

Returns the resulting path string.

Remarks

This function automatically inserts a backslash between the two strings, if one is not already present.

The first path cannot begin with "..\\" or ".\\" to produce a relative path string. If present, those periods are
stripped from the output string. For example, appending "path3" to "..\\path1\\path2" results in an output
of "\path1\path2\path3" rather than "..\path1\path2\path3".

See Also

Search PathAppend in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $sPath1 = 'C:\Documents\Text'
Local $sPath2 = '..\Test.txt'

ConsoleWrite('Path1 : ' & $sPath1 & @CRLF)
ConsoleWrite('Path2 : ' & $sPath2 & @CRLF)
ConsoleWrite('Result: ' & _WinAPI_PathAppend($sPath1, $sPath2) & @CRLF)


Function _WinAPI_PathBuildRoot

Function Reference

_WinAPI_PathBuildRoot

Creates a root path from a given drive number

#include <WinAPIShPath.au3>
_WinAPI_PathBuildRoot ( $iDrive )

Parameters

$iDrive The desired drive number. It should be between 0 and 25.

Return Value

Success: | The constructed root path.
Failure: | Empty string.

See Also

Search PathBuildRoot in MSDN Library.

Example

#include <WinAPIShPath.au3>

For $i = 0 To 2
    ConsoleWrite(_WinAPI_PathBuildRoot($i) & @CRLF)
Next


Function _WinAPI_PathCanonicalize

Function Reference

_WinAPI_PathCanonicalize

Removes elements of a file path according to special strings inserted into that path

#include <WinAPIShPath.au3>
_WinAPI_PathCanonicalize ( $sFilePath )

Parameters

$sFilePath The path to be canonicalized.

Return Value

Success: | The canonicalized path.
Failure: | The original $sFilePath parameter, call _WinAPI_GetLastError() to get extended error information.

Remarks

This function allows the user to specify what to remove from a path by inserting special character sequences
into the path. The ".." sequence indicates to remove a path segment from the current position to the previous path
segment. The "." sequence indicates to skip over the next path segment to the following path segment. The root
segment of the path cannot be removed.

If there are more ".." sequences than there are path segments, the function returns just the root, "\".

See Also

Search PathCanonicalize in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $aPath[5] = ['A:\Dir1\.\Dir2\..\Dir3', 'A:\Dir1\..\Dir2\.\Dir3', 'A:\Dir1\Dir2\.\Dir3\..\Dir4', 'A:\Dir1\.\Dir2\.\Dir3\..\Dir4\..', 'A:\..']

For $i = 0 To 4
    ConsoleWrite($aPath[$i] & ' => ' & _WinAPI_PathCanonicalize($aPath[$i]) & @CRLF)
Next


Function _WinAPI_PathCommonPrefix

Function Reference

_WinAPI_PathCommonPrefix

Compares two paths to determine if they share a common prefix

#include <WinAPIShPath.au3>
_WinAPI_PathCommonPrefix ( $sPath1, $sPath2 )

Parameters

$sPath1 | The first path name.
$sPath2 | The second path name.

Return Value

Returns the common prefix, @extended flag will contain the count of common prefix characters in the path.

See Also

Search PathCommonPrefix in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $sPath1 = 'C:\Documents\Test.txt'
Local $sPath2 = 'C:\Documents\Archive\Sample.txt'

ConsoleWrite('Path1 : ' & $sPath1 & @CRLF)
ConsoleWrite('Path2 : ' & $sPath2 & @CRLF)
ConsoleWrite('Prefix: ' & _WinAPI_PathCommonPrefix($sPath1, $sPath2) & @CRLF)


Function _WinAPI_PathCompactPath

Function Reference

_WinAPI_PathCompactPath

Truncates a file path to fit within a given pixel width by replacing path components with ellipses

#include <WinAPIShPath.au3>
_WinAPI_PathCompactPath ( $hWnd, $sFilePath [, $iWidth = 0] )

Parameters

$hWnd | Handle to the window used for font metrics.
$sFilePath | The path to be modified.
$iWidth | [optional] The width, in pixels, in which the string must fit. If this parameter is 0 (Default), width will be equal to the width of the window's client area. If this parameter is a negative number, the width will be decreased to its absolute value.

Return Value

Success: | The modified path.
Failure: | The original $sFilePath parameter and sets the @error flag to non-zero.

Remarks

This function will not compact the path beyond the base file name preceded by ellipses.

See Also

Search PathCompactPath in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <WinAPIShPath.au3>

GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 260, 60)
Local $idLabel = GUICtrlCreateLabel('', 10, 22, 240, 16)
Local $hLabel = GUICtrlGetHandle($idLabel)
GUICtrlSetData(-1, _WinAPI_PathCompactPath($hLabel, @ScriptFullPath))
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_PathCompactPathEx

Function Reference

_WinAPI_PathCompactPathEx

Truncates a path to fit within a certain number of characters by replacing path components with ellipses

#include <WinAPIShPath.au3>
_WinAPI_PathCompactPathEx ( $sFilePath, $iMax )

Parameters

$sFilePath | The path to be modified.
$iMax | The maximum number of characters to be contained in the modified path.

Return Value

Success: | The modified path.
Failure: | The original $sFilePath parameter and sets the @error flag to non-zero.

See Also

Search PathCompactPathEx in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $sPath = @ScriptFullPath

ConsoleWrite('Before: ' & $sPath & @CRLF)
ConsoleWrite('After : ' & _WinAPI_PathCompactPathEx($sPath, 40) & @CRLF)


Function _WinAPI_PathCreateFromUrl

Function Reference

_WinAPI_PathCreateFromUrl

Converts a file URL to a Microsoft MS-DOS path

#include <WinAPIShPath.au3>
_WinAPI_PathCreateFromUrl ( $sUrl )

Parameters

$sUrl The URL.

Return Value

Success: | The MS-DOS path.
Failure: | Empty string and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search PathCreateFromUrl in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $sPath = @ScriptFullPath

$sPath = _WinAPI_UrlCreateFromPath($sPath)
ConsoleWrite($sPath & @CRLF)

$sPath = _WinAPI_PathCreateFromUrl($sPath)
ConsoleWrite($sPath & @CRLF)


Function _WinAPI_PathFindExtension

Function Reference

_WinAPI_PathFindExtension

Searches a path for an extension

#include <WinAPIShPath.au3>
_WinAPI_PathFindExtension ( $sFilePath )

Parameters

$sFilePath The path to search, including the extension being searched for.

Return Value

Success: | The string that contains the extension.
Failure: | Empty string.

See Also

Search PathFindExtension in MSDN Library.


Function _WinAPI_PathFindFileName

Function Reference

_WinAPI_PathFindFileName

Searches a path for a file name

#include <WinAPIShPath.au3>
_WinAPI_PathFindFileName ( $sFilePath )

Parameters

$sFilePath The path to search.

Return Value

Returns the string that contains the filename.
Otherwise the original $sFilePath.

See Also

Search PathFindFileName in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $aPath[7] = ['c:\path\file', 'c:\path', 'c:\path\', 'c:\', 'c:', 'path', StringFormat('Long String %270s', '1')]

For $i = 0 To UBound($aPath) - 2
    ConsoleWrite($aPath[$i] & ' => ' & _WinAPI_PathFindFileName($aPath[$i]) & @CRLF)
Next

Local $iRet = _WinAPI_PathFindFileName($aPath[UBound($aPath) - 1])
ConsoleWrite('@error = ' & @error & ' => "' & $iRet & '"' & @CRLF)


Function _WinAPI_PathFindNextComponent

Function Reference

_WinAPI_PathFindNextComponent

Parses a path and returns the portion of that path that follows the first backslash

#include <WinAPIShPath.au3>
_WinAPI_PathFindNextComponent ( $sFilePath )

Parameters

$sFilePath The path to parse. Path components are delimited by backslashes. For instance, the path
"c:\path1\path2\file.txt" has four components: c:, path1, path2, and file.txt.

Return Value

Success: | The truncated path.
Failure: | Empty string and sets the @error flag to non-zero.

Remarks

This function walks a path string until it encounters a backslash ("\"), ignores everything up to that point
including the backslash, and returns the rest of the path. Therefore, if a path begins with a backslash (such as \path1\path2),
the function simply removes the initial backslash and returns the rest (path1\path2).

See Also

Search PathFindNextComponent in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $sPath = @ScriptFullPath

While $sPath
    ConsoleWrite($sPath & @CRLF)
    $sPath = _WinAPI_PathFindNextComponent($sPath)
WEnd
$sPath = _WinAPI_PathFindNextComponent("")
ConsoleWrite('Path = "' & $sPath & '" -> @error = ' & @error & @CRLF)


Function _WinAPI_PathGetArgs

Function Reference

_WinAPI_PathGetArgs

Finds the command-line arguments within a given path

#include <WinAPIShPath.au3>
_WinAPI_PathGetArgs ( $sFilePath )

Parameters

$sFilePath The path to be searched.

Return Value

Success: | The string that contains the arguments portion of the path if successful.
Failure: | Empty string.

Remarks

This function should not be used on generic command path templates (from users or the registry), but rather
should be used only on templates that the application knows to be well formed.

See Also

Search PathGetArgs in MSDN Library.

Example

#include <APIRegConstants.au3>
#include <WinAPIReg.au3>
#include <WinAPIShPath.au3>

Local $sPath = _WinAPI_AssocQueryString('.txt', $ASSOCSTR_COMMAND)
ConsoleWrite('Command: ' & $sPath & @CRLF)
ConsoleWrite('Path: ' & _WinAPI_PathRemoveArgs($sPath) & @CRLF)
ConsoleWrite('Arguments: ' & _WinAPI_PathGetArgs($sPath) & @CRLF & @CRLF)

$sPath = '1 2 3'
ConsoleWrite('Command: ' & $sPath & @CRLF)
ConsoleWrite('Path: ' & _WinAPI_PathRemoveArgs($sPath) & @CRLF)
ConsoleWrite('Arguments: ' & _WinAPI_PathGetArgs($sPath) & @CRLF & @CRLF)

$sPath = StringFormat('very long string %260s', "1")
ConsoleWrite('Command: ' & $sPath & @CRLF)
ConsoleWrite('Path: ' & _WinAPI_PathRemoveArgs($sPath) & @CRLF)
ConsoleWrite('Arguments: "' & _WinAPI_PathGetArgs($sPath) & '"' & @CRLF & @CRLF)


Function _WinAPI_PathGetCharType

Function Reference

_WinAPI_PathGetCharType

Determines the type of character in relation to a path

#include <WinAPIShPath.au3>
_WinAPI_PathGetCharType ( $sChar )

Parameters

$sChar The character for which to determine the type.

Return Value

Returns one or more of the following values that define the type of character.
$GCT_INVALID
$GCT_LFNCHAR
$GCT_SEPARATOR
$GCT_SHORTCHAR
$GCT_WILD

See Also

Search PathGetCharType in MSDN Library.


Function _WinAPI_PathGetDriveNumber

Function Reference

_WinAPI_PathGetDriveNumber

Searches a path for a drive letter within the range of 'A' to 'Z' and returns the corresponding drive number

#include <WinAPIShPath.au3>
_WinAPI_PathGetDriveNumber ( $sFilePath )

Parameters

$sFilePath The path to be searched.

Return Value

Success: | The string that contains the drive letter (A:, B:, etc).
Failure: | Empty string.

See Also

Search PathGetDriveNumber in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $aPath[5] = ['c:\path\file', 'c:\', 'c:', 'nodrive', StringFormat('d: %270s', '2')]

For $i = 0 To UBound($aPath) - 2
    ConsoleWrite($aPath[$i] & ' => ' & _WinAPI_PathGetDriveNumber($aPath[$i]) & @CRLF)
Next

Local $iRet = _WinAPI_PathGetDriveNumber($aPath[UBound($aPath) - 1])
ConsoleWrite('TOO LONG STRING : @error = ' & @error & ' => "' & $iRet & '"' & @CRLF)


Function _WinAPI_PathIsContentType

Function Reference

_WinAPI_PathIsContentType

Determines if a file's registered content type matches the specified content type

#include <WinAPIShPath.au3>
_WinAPI_PathIsContentType ( $sFilePath, $sType )

Parameters

$sFilePath | The file whose content type will be compared.
$sType | The content type string. For example, "application/x-msdownload", "image/jpeg", "text/plain", etc.

Return Value

True: | the file's content type matches the specified content type.
False: | the file's content type do not match.

See Also

Search PathIsContentType in MSDN Library.

Example

#include <Array.au3>
#include <File.au3>
#include <WinAPIShPath.au3>

Local $sFileList = _FileListToArray(@SystemDir, '*.*', 1)
Local $aSortList[UBound($sFileList) - 1]
Local $iCount = 0

For $i = 1 To $sFileList[0]
    If _WinAPI_PathIsContentType($sFileList[$i], 'text/xml') Then
        $aSortList[$iCount] = $sFileList[$i]
        $iCount += 1
    EndIf
Next
If $iCount Then
    ReDim $aSortList[$iCount]
Else
    Exit
EndIf

_ArrayDisplay($aSortList, '_WinAPI_PathIsContentType')


Function _WinAPI_PathIsExe

Function Reference

_WinAPI_PathIsExe

Determines whether a file is an executable by examining the file extension

#include <WinAPIShPath.au3>
_WinAPI_PathIsExe ( $sFilePath )

Parameters

$sFilePath The path to be searched.

Return Value

True: | the file extension is .cmd, .bat, .pif, .scf, .exe, .com, or .scr.
False: | no the file extension.

See Also

Search PathIsExe in MSDN Library.

Example

#include <Array.au3>
#include <File.au3>
#include <WinAPIShPath.au3>

Local $sFileList = _FileListToArray(@SystemDir, '*.*', 1)
Local $aSortList[UBound($sFileList) - 1]
Local $iCount = 0

For $i = 1 To $sFileList[0]
    If _WinAPI_PathIsExe($sFileList[$i]) Then
        $aSortList[$iCount] = $sFileList[$i]
        $iCount += 1
    EndIf
Next
If $iCount Then
    ReDim $aSortList[$iCount]
Else
    Exit
EndIf

_ArrayDisplay($aSortList, '_WinAPI_PathIsContentType')


Function _WinAPI_PathIsFileSpec

Function Reference

_WinAPI_PathIsFileSpec

Searches a path for any path-delimiting characters

#include <WinAPIShPath.au3>
_WinAPI_PathIsFileSpec ( $sFilePath )

Parameters

$sFilePath The path to be searched.

Return Value

True: | there are no path-delimiting characters (":" or "\") within the path.
False: | there are path-delimiting characters.

See Also

Search PathIsFileSpec in MSDN Library.


Function _WinAPI_PathIsLFNFileSpec

Function Reference

_WinAPI_PathIsLFNFileSpec

Determines whether a file name is in long format

#include <WinAPIShPath.au3>
_WinAPI_PathIsLFNFileSpec ( $sFilePath )

Parameters

$sFilePath The file name to be tested.

Return Value

True: | the file exceeds the number of characters allowed by the 8.3 format.
False: | the file is in 8.3 format.

See Also

Search PathIsLFNFileSpec in MSDN Library.


Function _WinAPI_PathIsRelative

Function Reference

_WinAPI_PathIsRelative

Searches a path and determines if it is relative

#include <WinAPIShPath.au3>
_WinAPI_PathIsRelative ( $sFilePath )

Parameters

$sFilePath The path to be searched.

Return Value

True: | the path is relative.
False: | the path is not relative.

See Also

Search PathIsRelative in MSDN Library.


Function _WinAPI_PathIsRoot

Function Reference

_WinAPI_PathIsRoot

Parses a path to determine if it is a directory root

#include <WinAPIShPath.au3>
_WinAPI_PathIsRoot ( $sFilePath )

Parameters

$sFilePath The path to be validated.

Return Value

True: | the path is a root.
False: | the path is not a root.

Remarks

Returns True for paths such as "\", "X:\" or "\\server\share". Paths such as "..\path2" or "\\server\" return False.

See Also

Search PathIsRoot in MSDN Library.


Function _WinAPI_PathIsSameRoot

Function Reference

_WinAPI_PathIsSameRoot

Compares two paths to determine if they have a common root component

#include <WinAPIShPath.au3>
_WinAPI_PathIsSameRoot ( $sPath1, $sPath2 )

Parameters

$sPath1 | The first path to be compared.
$sPath2 | The second path to be compared.

Return Value

True: | both strings have the same root component.
False: | both strings does not have the same root component.

See Also

Search PathIsSameRoot in MSDN Library.


Function _WinAPI_PathIsSystemFolder

Function Reference

_WinAPI_PathIsSystemFolder

Determines if an existing folder contains the attributes that make it a system folder

#include <WinAPIShPath.au3>
_WinAPI_PathIsSystemFolder ( $sFilePath )

Parameters

$sFilePath The name of an existing folder to check the system folder attributes.

Return Value

True: | the path is a system folder.
False: | the path is not a system folder.

See Also

Search PathIsSystemFolder in MSDN Library.


Function _WinAPI_PathIsUNC

Function Reference

_WinAPI_PathIsUNC

Determines if the string is a valid Universal Naming Convention (UNC) for a server and share path

#include <WinAPIShPath.au3>
_WinAPI_PathIsUNC ( $sFilePath )

Parameters

$sFilePath The path to validate.

Return Value

True: | the path is a valid UNC path.
False: | the path is not a valid UNC path.

See Also

Search PathIsUNC in MSDN Library.


Function _WinAPI_PathIsUNCServer

Function Reference

_WinAPI_PathIsUNCServer

Determines if a string is a valid Universal Naming Convention (UNC) for a server path only

#include <WinAPIShPath.au3>
_WinAPI_PathIsUNCServer ( $sFilePath )

Parameters

$sFilePath The path to validate.

Return Value

True: | the path is a valid UNC path for a server only (no share name).
False: | the path is not a valid UNC path.

See Also

Search PathIsUNCServer in MSDN Library.


Function _WinAPI_PathIsUNCServerShare

Function Reference

_WinAPI_PathIsUNCServerShare

Determines if a string is a valid Universal Naming Convention (UNC) share path

#include <WinAPIShPath.au3>
_WinAPI_PathIsUNCServerShare ( $sFilePath )

Parameters

$sFilePath The path to validate.

Return Value

True: | the path is in the form "\\server\share".
False: | the path is not in the form "\\server\share".

See Also

Search PathIsUNCServerShare in MSDN Library.


Function _WinAPI_PathMakeSystemFolder

Function Reference

_WinAPI_PathMakeSystemFolder

Gives an existing folder the proper attributes to become a system folder

#include <WinAPIShPath.au3>
_WinAPI_PathMakeSystemFolder ( $sFilePath )

Parameters

$sFilePath The name of an existing folder that will be made into a system folder.

Return Value

Success: | True
Failure: | False

See Also

Search PathMakeSystemFolder in MSDN Library.


Function _WinAPI_PathMatchSpec

Function Reference

_WinAPI_PathMatchSpec

Searches a string using a Microsoft MS-DOS wild card match type

#include <WinAPIShPath.au3>
_WinAPI_PathMatchSpec ( $sFilePath, $sSpec )

Parameters

$sFilePath | The path to be searched.
$sSpec | The file type for which to search. For example, to test whether $sFilePath is a .doc file, $sSpec should be set to "*.doc".

Return Value

Success: | True - The string matches.
Failure: | False.

See Also

Search PathMatchSpec in MSDN Library.

Example

#include <Array.au3>
#include <File.au3>
#include <WinAPIShPath.au3>

Local $sFileList = _FileListToArray(@SystemDir, '*.dll', 1)
Local $aSortList[UBound($sFileList) - 1]
Local $iCount = 0

For $i = 1 To $sFileList[0]
    If _WinAPI_PathMatchSpec($sFileList[$i], 'net*.dll') Then
        $aSortList[$iCount] = $sFileList[$i]
        $iCount += 1
    EndIf
Next
If $iCount Then
    ReDim $aSortList[$iCount]
Else
    Exit
EndIf

_ArrayDisplay($aSortList, '_WinAPI_PathMatchSpec')


Function _WinAPI_PathParseIconLocation

Function Reference

_WinAPI_PathParseIconLocation

Parses a file location string that contains a file location and icon index

#include <WinAPIShPath.au3>
_WinAPI_PathParseIconLocation ( $sFilePath )

Parameters

$sFilePath The path that contains a file location string. It should be in the form "path,iconindex".

Return Value

Returns the array containing the following information:
[0] - The path of the file that contains the icon.
[1] - The index of the icon.

Remarks

This function is useful for taking a DefaultIcon value from the registry and separating the icon index from the path.

See Also

Search PathParseIconLocation in MSDN Library.

Example

#include <APIRegConstants.au3>
#include <WinAPIReg.au3>
#include <WinAPIShPath.au3>

Local $sData = _WinAPI_AssocQueryString('.txt', $ASSOCSTR_DEFAULTICON)
Local $aIcon = _WinAPI_PathParseIconLocation($sData)

If IsArray($aIcon) Then
    ConsoleWrite('DefaultIcon: ' & $sData & @CRLF)
    ConsoleWrite('Icon: ' & $aIcon[0] & @CRLF)
    ConsoleWrite('Index: ' & $aIcon[1] & @CRLF)
EndIf


Function _WinAPI_PathRelativePathTo

Function Reference

_WinAPI_PathRelativePathTo

Creates a relative path from one file or folder to another

#include <WinAPIShPath.au3>
_WinAPI_PathRelativePathTo ( $sPathFrom, $bDirFrom, $sPathTo, $bDirTo )

Parameters

$sPathFrom | The path to the file or directory that defines the start of the relative path.
$bDirFrom | Specifies whether is $sPathFrom path to the directory, valid values: True - Directory. False - File.
$sPathTo | The path to the file or directory that defines the endpoint of the relative path.
$bDirTo | Specifies whether is $fDirTo path to the directory, valid values: True - Directory. False - File.

Return Value

Success: | The relative path.
Failure: | Empty string.

Remarks

This function takes a pair of paths and generates a relative path from one to the other. The paths do not have
to be fully-qualified, but they must have a common prefix, otherwise, the function fails.

For example, let the starting point, $sPathFrom, be "C:\A\B\C", and the ending point, $sPathTo, be "C:\A\D".
_WinAPI_PathRelativePathTo() will return the relative path from $sPathFrom to $sPathTo as: "..\..\D\E". You will
get the same result if you set $sPathFrom to "\A\B\C" and $sPathTo to "\A\D\E". On the other hand, "C:\A\B\C"
and "D:\A\D" do not share a common prefix, and the function will fail. Note that "\" is not considered a prefix
and is ignored. If you set $sPathFrom to "\\A\B\C", and $sPathTo to "\\C\D", the function will fail.

See Also

Search PathRelativePathTo in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $sPath = _WinAPI_PathRelativePathTo(@ScriptDir, 1, @MyDocumentsDir, 1)

ConsoleWrite('Relative path: ' & $sPath & @CRLF)

If $sPath Then
    ShellExecute($sPath)
EndIf


Function _WinAPI_PathRemoveArgs

Function Reference

_WinAPI_PathRemoveArgs

Removes any arguments from a given path

#include <WinAPIShPath.au3>
_WinAPI_PathRemoveArgs ( $sFilePath )

Parameters

$sFilePath The path that contains the path from which to remove arguments.

Return Value

Returns the path of no arguments.

Remarks

This function should not be used on generic command path templates (from users or the registry), but rather
it should be used only on templates that the application knows to be well formed.

See Also

Search PathRemoveArgs in MSDN Library.

Example

#include <APIRegConstants.au3>
#include <WinAPIReg.au3>
#include <WinAPIShPath.au3>

Local $sPath = _WinAPI_AssocQueryString('.txt', $ASSOCSTR_COMMAND)

ConsoleWrite('Command: ' & $sPath & @CRLF)
ConsoleWrite('Path: ' & _WinAPI_PathRemoveArgs($sPath) & @CRLF)
ConsoleWrite('Arguments: ' & _WinAPI_PathGetArgs($sPath) & @CRLF)


Function _WinAPI_PathRemoveBackslash

Function Reference

_WinAPI_PathRemoveBackslash

Removes the trailing backslash from a given path

#include <WinAPIShPath.au3>
_WinAPI_PathRemoveBackslash ( $sFilePath )

Parameters

$sFilePath The path from which to remove the backslash.

Return Value

Returns the altered path.

See Also

Search PathRemoveBackslash in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $sPath = 'C:\Documents\'

ConsoleWrite('Before: ' & $sPath & @CRLF)
ConsoleWrite('After : ' & _WinAPI_PathRemoveBackslash($sPath) & @CRLF)


Function _WinAPI_PathRemoveExtension

Function Reference

_WinAPI_PathRemoveExtension

Removes the file name extension from a path, if one is present

#include <WinAPIShPath.au3>
_WinAPI_PathRemoveExtension ( $sFilePath )

Parameters

$sFilePath The path from which to remove the extension.

Return Value

Returns the path without extension.

See Also

Search PathRemoveExtension in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $sPath = 'C:\Documents\Test.txt'

ConsoleWrite('Before: ' & $sPath & @CRLF)
ConsoleWrite('After : ' & _WinAPI_PathRemoveExtension($sPath) & @CRLF)


Function _WinAPI_PathRemoveFileSpec

Function Reference

_WinAPI_PathRemoveFileSpec

Removes the trailing file name and backslash from a path, if they are present

#include <WinAPIShPath.au3>
_WinAPI_PathRemoveFileSpec ( $sFilePath )

Parameters

$sFilePath The path from which to remove the file name.

Return Value

Returns the path without file name, @extended non zero if something have been removed.

See Also

Search PathRemoveFileSpec in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $sPath = 'C:\Documents\Test.txt'

ConsoleWrite('Before: ' & $sPath & @CRLF)
ConsoleWrite('After : ' & _WinAPI_PathRemoveFileSpec($sPath) & @CRLF)


Function _WinAPI_PathRenameExtension

Function Reference

_WinAPI_PathRenameExtension

Replaces the extension of a file name with a new extension

#include <WinAPIShPath.au3>
_WinAPI_PathRenameExtension ( $sFilePath, $sExt )

Parameters

$sFilePath | The path in which to replace the extension.
$sExt | The string that contains a "." character followed by the new extension.

Return Value

Success: | The path with new extension.
Failure: | Empty string.

Remarks

If the file name does not contain an extension, the extension will be attached to the end of the string.

See Also

Search PathRenameExtension in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $sPath = 'C:\Documents\Test.txt'

ConsoleWrite('Before: ' & $sPath & @CRLF)
ConsoleWrite('After : ' & _WinAPI_PathRenameExtension($sPath, '.doc') & @CRLF)


Function _WinAPI_PathSearchAndQualify

Function Reference

_WinAPI_PathSearchAndQualify

Formats a path to the fully qualified path

#include <WinAPIShPath.au3>
_WinAPI_PathSearchAndQualify ( $sFilePath [, $bExists = False] )

Parameters

$sFilePath | The path to be formated.
$bExists | [optional] Specifies whether the path should be existing, valid values: True - The path must be an existing path, otherwise, the function fails. False - The path may not exist (Default).

Return Value

Success: | The formated path.
Failure: | Empty string and sets the @error flag to non-zero.

See Also

Search PathSearchAndQualify in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local Const $sPath1 = 'C:\\Test\\'
Local Const $sPath2 = 'C:/Test/Test.txt'
Local Const $sPath3 = 'Notepad.exe'

ConsoleWrite($sPath1 & ' => ' & _WinAPI_PathSearchAndQualify($sPath1) & @CRLF)
ConsoleWrite($sPath2 & ' => ' & _WinAPI_PathSearchAndQualify($sPath2) & @CRLF)
ConsoleWrite($sPath3 & ' => ' & _WinAPI_PathSearchAndQualify($sPath3) & @CRLF)


Function _WinAPI_PathSkipRoot

Function Reference

_WinAPI_PathSkipRoot

Parses a path, ignoring the drive letter or Universal Naming Convention (UNC) server/share path elements

#include <WinAPIShPath.au3>
_WinAPI_PathSkipRoot ( $sFilePath )

Parameters

$sFilePath The path to parse.

Return Value

Returns the string contains only subpath that follows the root (drive letter or UNC server/share).

See Also

Search PathSkipRoot in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $sPath = 'C:\Documents\Test.txt'

ConsoleWrite('Before: ' & $sPath & @CRLF)
ConsoleWrite('After : ' & _WinAPI_PathSkipRoot($sPath) & @CRLF)


Function _WinAPI_PathStripPath

Function Reference

_WinAPI_PathStripPath

Removes the path portion of a fully qualified path and file

#include <WinAPIShPath.au3>
_WinAPI_PathStripPath ( $sFilePath )

Parameters

$sFilePath The path and file name.

Return Value

Returns the string contains only the file name, with the path removed.

See Also

Search PathStripPath in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $sPath = 'C:\Documents\Test.txt'

ConsoleWrite('Before: ' & $sPath & @CRLF)
ConsoleWrite('After : ' & _WinAPI_PathStripPath($sPath) & @CRLF)


Function _WinAPI_PathStripToRoot

Function Reference

_WinAPI_PathStripToRoot

Removes all parts of the path except for the root information

#include <WinAPIShPath.au3>
_WinAPI_PathStripToRoot ( $sFilePath )

Parameters

$sFilePath The path to be converted.

Return Value

Success: | The string contains only the root information taken from that path.
Failure: | Empty string.

See Also

Search PathStripToRoot in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $sPath = 'C:\Documents\Test.txt'

ConsoleWrite('Before: ' & $sPath & @CRLF)
ConsoleWrite('After : ' & _WinAPI_PathStripToRoot($sPath) & @CRLF)


Function _WinAPI_PathUndecorate

Function Reference

_WinAPI_PathUndecorate

Removes the decoration from a path string

#include <WinAPIShPath.au3>
_WinAPI_PathUndecorate ( $sFilePath )

Parameters

$sFilePath The path.

Return Value

Returns the undecorated string.

See Also

Search PathUndecorate in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $aPath[4] = ['C:\Path\File[5].txt', 'C:\Path\File[12]', 'C:\Path\File.txt', 'C:\Path\[3].txt']

For $i = 0 To 3
    ConsoleWrite(StringFormat('%-22s' & _WinAPI_PathUndecorate($aPath[$i]), $aPath[$i]) & @CRLF)
Next


Function _WinAPI_PathUnExpandEnvStrings

Function Reference

_WinAPI_PathUnExpandEnvStrings

Replaces folder names in a fully-qualified path with their associated environment string

#include <WinAPIShPath.au3>
_WinAPI_PathUnExpandEnvStrings ( $sFilePath )

Parameters

$sFilePath The path to be unexpanded.

Return Value

Success: | The unexpanded string.
Failure: | Empty string.

See Also

Search PathUnExpandEnvStrings in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $sPath = @SystemDir

ConsoleWrite('Before: ' & $sPath & @CRLF)
ConsoleWrite('After : ' & _WinAPI_PathUnExpandEnvStrings($sPath) & @CRLF)


Function _WinAPI_PathUnmakeSystemFolder

Function Reference

_WinAPI_PathUnmakeSystemFolder

Removes the attributes from a folder that make it a system folder

#include <WinAPIShPath.au3>
_WinAPI_PathUnmakeSystemFolder ( $sFilePath )

Parameters

$sFilePath The name of an existing folder that will have the system folder attributes removed.

Return Value

Success: | True
Failure: | False

See Also

Search PathUnmakeSystemFolder in MSDN Library.


Function _WinAPI_PathUnquoteSpaces

Function Reference

_WinAPI_PathUnquoteSpaces

Removes quotes from the beginning and end of a path

#include <WinAPIShPath.au3>
_WinAPI_PathUnquoteSpaces ( $sFilePath )

Parameters

$sFilePath The path.

Return Value

Returns the path with beginning and ending quotation marks removed.

See Also

Search PathUnquoteSpaces in MSDN Library.

Example

#include <APIREgConstants.au3>
#include <WinAPIReg.au3>
#include <WinAPIShPath.au3>

Local $sPath = _WinAPI_AssocQueryString('.txt', $ASSOCSTR_COMMAND)

ConsoleWrite('Command: ' & $sPath & @CRLF)
ConsoleWrite('Path: ' & _WinAPI_PathUnquoteSpaces(_WinAPI_PathRemoveArgs($sPath)) & @CRLF)
ConsoleWrite('Arguments: ' & _WinAPI_PathGetArgs($sPath) & @CRLF)


Function _WinAPI_PathYetAnotherMakeUniqueName

Function Reference

_WinAPI_PathYetAnotherMakeUniqueName

Creates a unique filename based on an existing filename

#include <WinAPIShPath.au3>
_WinAPI_PathYetAnotherMakeUniqueName ( $sFilePath )

Parameters

$sFilePath The file name that the unique name will be based on.

Return Value

Success: | the fully qualified path of the unique file name.
Failure: | Empty string.

See Also

Search PathYetAnotherMakeUniqueName in MSDN Library.

Example

#include <WinAPIShPath.au3>

DirRemove(@TempDir & '\Temp', 1)
DirCreate(@TempDir & '\Temp')
For $i = 1 To 4
    FileClose(FileOpen(_WinAPI_PathYetAnotherMakeUniqueName(@TempDir & '\Temp\My File.txt'), 2))
Next
ShellExecute(@TempDir & '\Temp')


Function _WinAPI_ShellGetImageList

Function Reference

_WinAPI_ShellGetImageList

Retrieves the system image list for small or large icons

#include <WinAPIShPath.au3>
_WinAPI_ShellGetImageList ( [$bSmall = False] )

Parameters

$bSmall [optional] Specifies whether to retrieve an image list for small or large icons, valid values:
True - The small icons.
False - The large icons (Default).

Return Value

Success: | Handle to the image list.
Failure: | 0.

Remarks

The image list retrieved through this function are global system image list; do not destroy it.

To use this function, you must call _WinAPI_FileIconInit() at application launch.

Related

_WinAPI_FileIconInit

See Also

Search Shell_GetImageLists in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GUIImageList.au3>
#include <StaticConstants.au3>
#include <WinAPIRes.au3>
#include <WinAPIShPath.au3>

; Initialize system image list
_WinAPI_FileIconInit()

; Retrieve system image list and calculate bitmap size
Local $hImageList = _WinAPI_ShellGetImageList()
If @error Then Exit

Local $iCount = _GUIImageList_GetImageCount($hImageList)
Local $a_iSize = _GUIImageList_GetIconSize($hImageList)
Local $iCX = Sqrt($iCount)
Local $iCY
If $iCX Then
    $iCX = Ceiling($iCX)
    $iCY = Ceiling($iCount / $iCX)
Else
    $iCX = 1
    $iCY = 1
EndIf
Local $W = $iCX * ($a_iSize[0] + 14)
Local $H = $iCY * ($a_iSize[1] + 14)

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), $W, $H)
Local $idPic = GUICtrlCreatePic('', 0, 0, $W, $H)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDC = _WinAPI_GetDC($hPic)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $W, $H)
Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap)

; Draw all icons from the system image list into bitmap
Local $iIndex = 0
For $y = 1 To $iCY
    For $x = 1 To $iCX
        _GUIImageList_Draw($hImageList, $iIndex, $hMemDC, ($x - 1) * ($a_iSize[0] + 14) + 7, ($y - 1) * ($a_iSize[0] + 14) + 7)
        $iIndex += 1
        If $iIndex >= $iCount Then
            ExitLoop
        EndIf
    Next
Next

; Release objects
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_SelectObject($hMemDC, $hMemSv)
_WinAPI_DeleteDC($hMemDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

; Show GUI
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_UrlApplyScheme

Function Reference

_WinAPI_UrlApplyScheme

Determines a scheme for a specified URL string, and returns a string with an appropriate prefix

#include <WinAPIShPath.au3>
_WinAPI_UrlApplyScheme ( $sUrl [, $iFlags = 1] )

Parameters

$sUrl | The URL.
$iFlags | [optional] The flags that specify how to determine the scheme. It can be a combination of the following values. $URL_APPLY_DEFAULT (Default) $URL_APPLY_GUESSSCHEME $URL_APPLY_GUESSFILE $URL_APPLY_FORCEAPPLY

Return Value

Success: | The URL converted to the "//URL_string format" scheme.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search UrlApplyScheme in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $sUrl = 'www.microsoft.com'

ConsoleWrite(_WinAPI_UrlApplyScheme($sUrl) & @CRLF)

ConsoleWrite(_WinAPI_UrlApplyScheme('') & @CRLF)


Function _WinAPI_UrlCanonicalize

Function Reference

_WinAPI_UrlCanonicalize

Converts a URL string into canonical form

#include <WinAPIShPath.au3>
_WinAPI_UrlCanonicalize ( $sUrl, $iFlags )

Parameters

$sUrl | The URL.
$iFlags | The flags that specify how the URL is to be converted. It can be a combination of the following values. $URL_DONT_SIMPLIFY $URL_ESCAPE_PERCENT $URL_ESCAPE_SPACES_ONLY $URL_ESCAPE_UNSAFE $URL_NO_META $URL_PLUGGABLE_PROTOCOL $URL_UNESCAPE Windows 7 or later $URL_ESCAPE_AS_UTF8

Return Value

Success: | The converted URL.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

If a URL string contains "/../" or "/./", _WinAPI_UrlCanonicalize() usually treats the characters as if they
indicated navigation in the URL hierarchy. The function simplifies the URLs before combining them. For instance,
"/hello/cruel/../world" is simplified to "/hello/world". If the $URL_DONT_SIMPLIFY flag is set, the function
does not simplify URLs. In this case, "/hello/cruel/../world" is left as it is.

See Also

Search UrlCanonicalize in MSDN Library.

Example

#include <APIShPathConstants.au3>
#include <WinAPIShPath.au3>

Local $sUrl = 'http://msdn.microsoft.com/en-us/library/ee663300%28VS.85%29.aspx'

ConsoleWrite(_WinAPI_UrlCanonicalize($sUrl, $URL_UNESCAPE) & @CRLF)


Function _WinAPI_UrlCombine

Function Reference

_WinAPI_UrlCombine

Combines the base an relative URLs in canonical form

#include <WinAPIShPath.au3>
_WinAPI_UrlCombine ( $sUrl, $sPart [, $iFlags = 0] )

Parameters

$sUrl | The base URL.
$sPart | The relative URL.
$iFlags | [optional] The flags that specify how the URL is to be converted. It can be a combination of the following values. $URL_DONT_SIMPLIFY $URL_ESCAPE_PERCENT $URL_ESCAPE_SPACES_ONLY $URL_ESCAPE_UNSAFE $URL_NO_META $URL_PLUGGABLE_PROTOCOL $URL_UNESCAPE Windows 7 or later $URL_ESCAPE_AS_UTF8

Return Value

Success: | The combined URL.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

Items between slashes are treated as hierarchical identifiers; the last item specifies the document itself.
You must enter a slash ("/" ) after the document name to append more items; otherwise, the function exchanges
one document for another.

If a URL string contains "/../" or "/./", _WinAPI_UrlCombine() usually treats the characters as if they
indicated navigation in the URL hierarchy. The function simplifies the URLs before combining them. For instance,
"/hello/cruel/../world" is simplified to "/hello/world". If the $URL_DONT_SIMPLIFY flag is set, the function
does not simplify URLs. In this case, "/hello/cruel/../world" is left as it is.

See Also

Search UrlCombine in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $sUrl1 = 'http://xyz/abc/'
Local $sUrl2 = 'http://xyz/abc'

ConsoleWrite(_WinAPI_UrlCombine($sUrl1, 'bar') & @CRLF)
ConsoleWrite(_WinAPI_UrlCombine($sUrl2, 'bar') & @CRLF)


Function _WinAPI_UrlCompare

Function Reference

_WinAPI_UrlCompare

Makes a case-sensitive comparison of two URL strings

#include <WinAPIShPath.au3>
_WinAPI_UrlCompare ( $sUrl1, $sUrl2 [, $bIgnoreSlash = False] )

Parameters

$sUrl1 | The first URL.
$sUrl2 | The second URL.
$bIgnoreSlash | [optional] Specifies whether to ignore a trailing '/' character on either or both URLs, valid values: True - The function ignores a trailing characters. False - The function takes into account the trailing characters (Default).

Return Value

Returns 0 - The URLs are equal.
>0 - The first URL is greater than the second URL.
<0 - The first URL is less than the second URL.

Remarks

For best results, you should first canonicalize the URLs with _WinAPI_UrlCanonicalize(). Then, compare the
canonicalized URLs with _WinAPI_UrlCompare().

See Also

Search UrlCompare in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $sUrl1 = 'http://xyz/abc/'
Local $sUrl2 = 'http://xyz/abc'

ConsoleWrite('URLs comparison result: ' & _WinAPI_UrlCompare($sUrl1, $sUrl2) & @CRLF)


Function _WinAPI_UrlCreateFromPath

Function Reference

_WinAPI_UrlCreateFromPath

Converts a Microsoft MS-DOS path to a canonicalized URL

#include <WinAPIShPath.au3>
_WinAPI_UrlCreateFromPath ( $sFilePath )

Parameters

$sFilePath The MS-DOS path.

Return Value

Success: | The URL.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search UrlCreateFromPath in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $sPath = @ScriptFullPath

$sPath = _WinAPI_UrlCreateFromPath($sPath)
ConsoleWrite($sPath & @CRLF)

$sPath = _WinAPI_PathCreateFromUrl($sPath)
ConsoleWrite($sPath & @CRLF)


Function _WinAPI_UrlFixup

Function Reference

_WinAPI_UrlFixup

Attempts to correct a URL whose protocol identifier is incorrect

#include <WinAPIShPath.au3>
_WinAPI_UrlFixup ( $sUrl )

Parameters

$sUrl The URL to be corrected.

Return Value

Success: | The corrected URL, or the original URL if no correction was needed.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search UrlFixupW in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $asUrl[3] = ['http://www.microsoft.com', 'htps:\\www.microsoft.com', 'http:www.microsoft.com']

For $i = 0 To 2
    ConsoleWrite(StringFormat('%-27s' & _WinAPI_UrlFixup($asUrl[$i]), $asUrl[$i]) & @CRLF)
Next


Function _WinAPI_UrlGetPart

Function Reference

_WinAPI_UrlGetPart

Retrieves a specified part from the URL

#include <WinAPIShPath.au3>
_WinAPI_UrlGetPart ( $sUrl, $iPart )

Parameters

$sUrl | The URL.
$iPart | The part of the URL to retrieve. It can be one of the following values. $URL_PART_HOSTNAME $URL_PART_PASSWORD $URL_PART_PORT $URL_PART_QUERY $URL_PART_SCHEME $URL_PART_USERNAME

Return Value

Success: | The part of the URL.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the s error code.

See Also

Search UrlGetPart in MSDN Library.

Example

#include <APIShPathConstants.au3>
#include <WinAPIShPath.au3>

Local $sUrl = 'http://social.msdn.microsoft.com/search/en-us?query=UrlGetPart'

ConsoleWrite('Scheme: ' & _WinAPI_UrlGetPart($sUrl, $URL_PART_SCHEME) & @CRLF)
ConsoleWrite('Host:   ' & _WinAPI_UrlGetPart($sUrl, $URL_PART_HOSTNAME) & @CRLF)
ConsoleWrite('Query:  ' & _WinAPI_UrlGetPart($sUrl, $URL_PART_QUERY) & @CRLF & @CRLF)

$sUrl = 'http://social.msdn.microsoft.com/search/en-ust'

ConsoleWrite('Scheme: ' & _WinAPI_UrlGetPart($sUrl, $URL_PART_SCHEME) & @CRLF)
ConsoleWrite('Host:   ' & _WinAPI_UrlGetPart($sUrl, $URL_PART_HOSTNAME) & @CRLF)
ConsoleWrite('Query:  ' & _WinAPI_UrlGetPart($sUrl, $URL_PART_QUERY) & ' @error = ' & @error & ' @extended = 0x' & Hex(@extended) & @CRLF)


Function _WinAPI_UrlHash

Function Reference

_WinAPI_UrlHash

Hashes a URL string

#include <WinAPIShPath.au3>
_WinAPI_UrlHash ( $sUrl [, $iLength = 32] )

Parameters

$sUrl | The URL.
$iLength | [optional] The length of the hash data, in bytes. It should be no larger than 256, otherwise, the function fails. Default is 32.

Return Value

Success: | The hash data in binary form.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search UrlHash in MSDN Library.

Example

#include <WinAPIShPath.au3>

Local $sUrl = 'http://www.microsoft.com'

ConsoleWrite(_WinAPI_UrlHash($sUrl) & @CRLF)


Function _WinAPI_UrlIs

Function Reference

_WinAPI_UrlIs

Tests whether or not a URL is a specified type

#include <WinAPIShPath.au3>
_WinAPI_UrlIs ( $sUrl [, $iType = 0] )

Parameters

$sUrl | The URL.
$iType | [optional] The type of URL to be tested for. It can be one of the following values. $URLIS_APPLIABLE $URLIS_DIRECTORY $URLIS_FILEURL $URLIS_HASQUERY $URLIS_NOHISTORY $URLIS_OPAQUE $URLIS_URL (Default)

Return Value

Success: | True - The URL is the specified type.
Failure: | False.

See Also

Search UrlIs in MSDN Library.


System Reference

  • Administration Management
  • Automation Management
  • Clipboard Management
  • Controls Management
  • DLLLib Management
  • Heap Management
  • Memory Management
  • Power Management
  • Station & Desktop Management
  • SysInfo Management
  • UserInteraction Management
  • Windows Management


User Defined Functions

Administration user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPISys.au3>.

User Defined Function | Description
_WinAPI_LockWorkStation | Locks the workstation's display
_WinAPI_ShutdownBlockReasonCreate | Indicates that the system cannot be shut down and sets a reason string to be displayed to the user if system shutdown is initiated
_WinAPI_ShutdownBlockReasonDestroy | Indicates that the system can be shut down and frees the reason string
_WinAPI_ShutdownBlockReasonQuery | Retrieves the reason string set by the _WinAPI_ShutdownBlockReasonCreate() function


Function _WinAPI_LockWorkStation

Function Reference

_WinAPI_LockWorkStation

Locks the workstation's display

#include <WinAPISys.au3>
_WinAPI_LockWorkStation ( )

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

See Also

Search LockWorkStation in MSDN Library.


Function _WinAPI_ShutdownBlockReasonCreate

Function Reference

_WinAPI_ShutdownBlockReasonCreate

Indicates that the system cannot be shut down and sets a reason string to be displayed to the user if system shutdown is initiated

#include <WinAPISys.au3>
_WinAPI_ShutdownBlockReasonCreate ( $hWnd, $sText )

Parameters

$hWnd | Handle to the main window of the application.
$sText | The string which explaining the reason the application must block system shutdown.

Return Value

Success: | True
Failure: | False

Remarks

This function can only be called from the thread that created the window specified by the $hWnd parameter,
otherwise, the function fails and the last error code is ERROR_ACCESS_DENIED (5).

Applications should call this function as they begin an operation that cannot be interrupted, such as burning
a CD or DVD. When the operation has completed, call the _WinAPI_ShutdownBlockReasonDestroy() function to
indicate that the system can be shut down.

This function requires Windows Vista or later.

Related

_WinAPI_ShutdownBlockReasonDestroy

See Also

Search ShutdownBlockReasonCreate in MSDN Library.

Example

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 200, 200)
Local $idButton = GUICtrlCreateButton('', 73, 62, 54, 54, $BS_ICON)
GUICtrlSetImage(-1, @SystemDir & '\shell32.dll', 45)
GUICtrlSetTip(-1, 'Log off ' & @UserName)
Local $idCheck = GUICtrlCreateCheckbox('Block Windows shutdown', 10, 173, 144, 21)
GUIRegisterMsg($WM_QUERYENDSESSION, 'WM_QUERYENDSESSION')
GUISetState(@SW_SHOW)

; Set the highest shutdown priority for the current process to prevent closure the other processes.
_WinAPI_SetProcessShutdownParameters(0x03FF)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            Shutdown(0)
        Case $idCheck
            If GUICtrlRead($idCheck) = $GUI_CHECKED Then
                _WinAPI_ShutdownBlockReasonCreate($g_hForm, 'This application is blocking system shutdown because the saving critical data is in progress.')
            Else
                _WinAPI_ShutdownBlockReasonDestroy($g_hForm)
            EndIf
    EndSwitch
WEnd

Func WM_QUERYENDSESSION($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam

    Switch $hWnd
        Case $g_hForm
            If _WinAPI_ShutdownBlockReasonQuery($g_hForm) Then
                Return 0
            EndIf
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_QUERYENDSESSION


Function _WinAPI_ShutdownBlockReasonDestroy

Function Reference

_WinAPI_ShutdownBlockReasonDestroy

Indicates that the system can be shut down and frees the reason string

#include <WinAPISys.au3>
_WinAPI_ShutdownBlockReasonDestroy ( $hWnd )

Parameters

$hWnd Handle to the main window of the application.

Return Value

Success: | True
Failure: | False

Remarks

This function can only be called from the thread that created the window specified by the $hWnd parameter,
otherwise, the function fails and the last error code is ERROR_ACCESS_DENIED (5).

This function requires Windows Vista or later.

See Also

Search ShutdownBlockReasonDestroy in MSDN Library.

Example

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 200, 200)
Local $idButton = GUICtrlCreateButton('', 73, 62, 54, 54, $BS_ICON)
GUICtrlSetImage(-1, @SystemDir & '\shell32.dll', 45)
GUICtrlSetTip(-1, 'Log off ' & @UserName)
Local $idCheck = GUICtrlCreateCheckbox('Block Windows shutdown', 10, 173, 144, 21)
GUIRegisterMsg($WM_QUERYENDSESSION, 'WM_QUERYENDSESSION')
GUISetState(@SW_SHOW)

; Set the highest shutdown priority for the current process to prevent closure the other processes.
_WinAPI_SetProcessShutdownParameters(0x03FF)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            Shutdown(0)
        Case $idCheck
            If GUICtrlRead($idCheck) = $GUI_CHECKED Then
                _WinAPI_ShutdownBlockReasonCreate($g_hForm, 'This application is blocking system shutdown because the saving critical data is in progress.')
            Else
                _WinAPI_ShutdownBlockReasonDestroy($g_hForm)
            EndIf
    EndSwitch
WEnd

Func WM_QUERYENDSESSION($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam

    Switch $hWnd
        Case $g_hForm
            If _WinAPI_ShutdownBlockReasonQuery($g_hForm) Then
                Return 0
            EndIf
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_QUERYENDSESSION


Function _WinAPI_ShutdownBlockReasonQuery

Function Reference

_WinAPI_ShutdownBlockReasonQuery

Retrieves the reason string set by the _WinAPI_ShutdownBlockReasonCreate() function

#include <WinAPISys.au3>
_WinAPI_ShutdownBlockReasonQuery ( $hWnd )

Parameters

$hWnd Handle to the main window of the application.

Return Value

Success: | The reason string.
Failure: | Sets the @error flag to non-zero.

Remarks

This function can only be called from the thread that created the window specified by the $hWnd parameter,
otherwise, the function fails and the last error code is ERROR_ACCESS_DENIED (5).

This function requires Windows Vista or later.

See Also

Search ShutdownBlockReasonQuery in MSDN Library.

Example

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 200, 200)
Local $idButton = GUICtrlCreateButton('', 73, 62, 54, 54, $BS_ICON)
GUICtrlSetImage(-1, @SystemDir & '\shell32.dll', 45)
GUICtrlSetTip(-1, 'Log off ' & @UserName)
Local $idCheck = GUICtrlCreateCheckbox('Block Windows shutdown', 10, 173, 144, 21)
GUIRegisterMsg($WM_QUERYENDSESSION, 'WM_QUERYENDSESSION')
GUISetState(@SW_SHOW)

; Set the highest shutdown priority for the current process to prevent closure the other processes.
_WinAPI_SetProcessShutdownParameters(0x03FF)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            Shutdown(0)
        Case $idCheck
            If GUICtrlRead($idCheck) = $GUI_CHECKED Then
                _WinAPI_ShutdownBlockReasonCreate($hForm, 'This application is blocking system shutdown because the saving critical data is in progress.')
            Else
                _WinAPI_ShutdownBlockReasonDestroy($hForm)
            EndIf
    EndSwitch
WEnd

Func WM_QUERYENDSESSION($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam

    Switch $hWnd
        Case $hForm
            If _WinAPI_ShutdownBlockReasonQuery($hForm) Then
                Return 0
            EndIf
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_QUERYENDSESSION


User Defined Functions

Automation user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPISys.au3>.

User Defined Function | Description
_WinAPI_SetWinEventHook | Sets an event hook function for a range of events
_WinAPI_UnhookWinEvent | Removes an event hook function


Function _WinAPI_SetWinEventHook

Function Reference

_WinAPI_SetWinEventHook

Sets an event hook function for a range of events

#include <WinAPISys.au3>
_WinAPI_SetWinEventHook ( $iEventMin, $iEventMax, $pEventProc [, $iPID = 0 [, $iThreadId = 0 [, $iFlags = 0]]] )

Parameters

$iEventMin | The lowest event value in the range of events ($EVENT_*) that are handled by the hook function.
$iEventMax | The highest event value in the range of events ($EVENT_*) that are handled by the hook function.
$pEventProc | The address of an application-defined hook function that the system calls in response to events generated by an accessible object.
$iPID | [optional] The ID of the process from which the hook function receives events. If this parameter is 0 (Default), the hook function is associated with all existing processes on the current desktop.
$iThreadId | [optional] The ID of the thread from which the hook function receives events. If this parameter is 0 (Default), the hook function is associated with all existing threads on the current desktop.
$iFlags | [optional] The flags that specify the location of the hook function and of the events to be skipped. The following flags are valid: $WINEVENT_INCONTEXT $WINEVENT_OUTOFCONTEXT (Default) $WINEVENT_SKIPOWNPROCESS $WINEVENT_SKIPOWNTHREAD The following single flags, or flag combinations are valid: $WINEVENT_INCONTEXT $WINEVENT_OUTOFCONTEXT $WINEVENT_INCONTEXT | $WINEVENT_SKIPOWNPROCESS $WINEVENT_INCONTEXT | $WINEVENT_SKIPOWNTHREAD $WINEVENT_OUTOFCONTEXT | $WINEVENT_SKIPOWNPROCESS $WINEVENT_OUTOFCONTEXT | $WINEVENT_SKIPOWNTHREAD

Return Value

Success: | A value that identifies this event hook instance.
Failure: | 0.

Remarks

Clients can call _WinAPI_SetWinEventHook() multiple times if they want to register additional hook functions
or listen for additional events.

See Also

Search SetWinEventHook in MSDN Library.

Example

#include <APISysConstants.au3>
#include <GUIMenu.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

Local $hEventProc = DllCallbackRegister('_EventProc', 'none', 'ptr;dword;hwnd;long;long;dword;dword')
Global $g_tRECT, $g_iIndex, $g_hMenu = 0

OnAutoItExitRegister('OnAutoItExit')

Local $hEventHook = _WinAPI_SetWinEventHook($EVENT_SYSTEM_MENUPOPUPSTART, $EVENT_SYSTEM_MENUPOPUPEND, DllCallbackGetPtr($hEventProc))

Run(@SystemDir & '\notepad.exe')

While 1
    Sleep(1000)
WEnd

Func OnAutoItExit()
    _WinAPI_UnhookWinEvent($hEventHook)
    DllCallbackFree($hEventProc)
EndFunc   ;==>OnAutoItExit

Func _EventProc($hEventHook, $iEvent, $hWnd, $iObjectID, $iChildID, $iThreadId, $iEventTime)
    #forceref $hEventHook, $iObjectID, $iChildID, $iThreadId, $iEventTime

    Switch $iEvent
        Case $EVENT_SYSTEM_MENUPOPUPSTART
            ; Add "View - Calculator"
            $g_hMenu = _SendMessage($hWnd, $MN_GETHMENU)
            If (_GUICtrlMenu_IsMenu($g_hMenu)) And (StringInStr(_GUICtrlMenu_GetItemText($g_hMenu, 0), 'Status Bar')) And (StringInStr(_WinAPI_GetWindowFileName($hWnd), 'notepad.exe')) Then
                $g_iIndex = _GUICtrlMenu_GetItemCount($g_hMenu)
                _GUICtrlMenu_InsertMenuItem($g_hMenu, $g_iIndex, 'Calculator' & @TAB & ':-)')
                $g_tRECT = _GUICtrlMenu_GetItemRectEx($hWnd, $g_hMenu, $g_iIndex)
            Else
                $g_hMenu = 0
            EndIf
        Case $EVENT_SYSTEM_MENUPOPUPEND
            If $g_hMenu Then
                _GUICtrlMenu_DeleteMenu($g_hMenu, $g_iIndex)
                Local $tPOINT = _WinAPI_GetMousePos()
                If _WinAPI_PtInRect($g_tRECT, $tPOINT) Then
                    Run(@SystemDir & '\calc.exe')
                EndIf
                $g_hMenu = 0
            EndIf
    EndSwitch
EndFunc   ;==>_EventProc


Function _WinAPI_UnhookWinEvent

Function Reference

_WinAPI_UnhookWinEvent

Removes an event hook function

#include <WinAPISys.au3>
_WinAPI_UnhookWinEvent ( $hEventHook )

Parameters

$hEventHook Handle to the event hook returned in the previous call to _WinAPI_SetWinEventHook().

Return Value

Success: | True.
Failure: | False.

Related

_WinAPI_SetWinEventHook

See Also

Search UnhookWinEvent in MSDN Library.


User Defined Functions

Clipboard user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPISys.au3>.

User Defined Function | Description
_WinAPI_AddClipboardFormatListener | Places the given window in the system-maintained clipboard format listener list
_WinAPI_GetClipboardSequenceNumber | Retrieves the clipboard sequence number for the current window station
_WinAPI_RemoveClipboardFormatListener | Removes the given window from the system-maintained clipboard format listener list


Function _WinAPI_AddClipboardFormatListener

Function Reference

_WinAPI_AddClipboardFormatListener

Places the given window in the system-maintained clipboard format listener list

#include <WinAPISys.au3>
_WinAPI_AddClipboardFormatListener ( $hWnd )

Parameters

$hWnd Handle to the window to be placed.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

This function requires Windows Vista or later.

See Also

Search AddClipboardFormatListener in MSDN Library.

Example

#include <Clipboard.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400, 10, 10, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX), $WS_EX_TOPMOST)
Global $g_idEdit = GUICtrlCreateEdit('', 0, 0, 400, 400, BitOR($GUI_SS_DEFAULT_EDIT, $ES_READONLY))
GUIRegisterMsg($WM_CLIPBOARDUPDATE, 'WM_CLIPBOARDUPDATE')
GUISetState(@SW_SHOW)

_WinAPI_AddClipboardFormatListener($hForm)
_SendMessage($hForm, $WM_CLIPBOARDUPDATE)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_CLIPBOARDUPDATE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam

    _ClipBoard_Open(0)
    GUICtrlSetData($g_idEdit, _ClipBoard_GetData($CF_TEXT))
    _ClipBoard_Close()
    Return 0
EndFunc   ;==>WM_CLIPBOARDUPDATE


Function _WinAPI_GetClipboardSequenceNumber

Function Reference

_WinAPI_GetClipboardSequenceNumber

Retrieves the clipboard sequence number for the current window station

#include <WinAPISys.au3>
_WinAPI_GetClipboardSequenceNumber ( )

Return Value

Success: | The clipboard sequence number.
Failure: | 0.

Remarks

The calling process must have WINSTA_READATTRIBUTES access to the window station.
This function requires Windows Vista or later.

See Also

Search GetClipboardSequenceNumber in MSDN Library.


Function _WinAPI_RemoveClipboardFormatListener

Function Reference

_WinAPI_RemoveClipboardFormatListener

Removes the given window from the system-maintained clipboard format listener list

#include <WinAPISys.au3>
_WinAPI_RemoveClipboardFormatListener ( $hWnd )

Parameters

$hWnd Handle to the window to be removed.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

This function requires Windows Vista or later.

See Also

Search RemoveClipboardFormatListener in MSDN Library.


User Defined Functions

Controls user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPISys.au3>.

User Defined Function | Description
_WinAPI_GetEffectiveClientRect | Calculates the dimensions of a rectangle in the client area that contains all the specified controls
_WinAPI_GetMUILanguage | Gets the language currently in use by the common controls for a particular process
_WinAPI_InitMUILanguage | Enables an application to specify a language to be used with the common controls that is different from the system language
_WinAPI_LoadIconMetric | Loads a specified icon resource with a client-specified system metric
_WinAPI_LoadIconWithScaleDown | Loads an icon and scales down a larger image instead of scaling up a smaller image
_WinAPI_MirrorIcon | Reverses (mirrors) icons so that they are displayed correctly on a mirrored device context


Function _WinAPI_GetEffectiveClientRect

Function Reference

_WinAPI_GetEffectiveClientRect

Calculates the dimensions of a rectangle in the client area that contains all the specified controls

#include <WinAPISys.au3>
_WinAPI_GetEffectiveClientRect ( $hWnd, $aCtrl [, $iStart = 0 [, $iEnd = -1]] )

Parameters

$hWnd | A handle to the window that has the client area to check.
$aCtrl | The array containing the handles or identifiers of the controls that should be included in the calculation of the client area. Also, it can be a single handle or control identifier.
$iStart | [optional] The index of array element that contains the first control.
$iEnd | [optional] The index of array element that contains the last control.

Return Value

Success: | $tagRECT structure that contains the rectangle with effective client area.
Failure: | Sets the @error flag to non-zero.

Remarks

If the control in the array is visible, or will be visible when its parent becomes visible, its rectangle is subtracted from the effective client rectangle.

If all the specified controls is missing, the function returns the client area of the parent window.

See Also

Search GetEffectiveClientRect in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GUIStatusBar.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPISys.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 600, 400)
Local $idMenu = GUICtrlCreateMenu("&File")
Local $idExit = GUICtrlCreateMenuItem("E&xit", $idMenu)
Local $a_vID[2]
$a_vID[0] = _GUICtrlStatusBar_Create($hForm)
$a_vID[1] = GUICtrlCreateListView('', 0, 0, 600, 200, -1, 0)

; Calculate effective client area (excluding Menu, ListView, and StatusBar controls)
Local $tRECT = _WinAPI_GetEffectiveClientRect($hForm, $a_vID)
Local $aPos = _WinAPI_GetPosFromRect($tRECT)
GUICtrlCreateLabel($aPos[2] & 'x' & $aPos[3], $aPos[0], $aPos[1], $aPos[2], $aPos[3], BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 25, 400, 0, 'Tahoma')
GUICtrlSetBkColor(-1, 0xFFD0D0)

; Show GUI
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $idExit
            ExitLoop
    EndSwitch
WEnd


Function _WinAPI_GetMUILanguage

Function Reference

_WinAPI_GetMUILanguage

Gets the language currently in use by the common controls for a particular process

#include <WinAPISys.au3>
_WinAPI_GetMUILanguage ( )

Return Value

Returns the language identifier that is used by the common controls.

Remarks

Note that this function fails if the _WinAPI_InitMUILanguage() function has not been called or was not called
from the same process.

Related

_WinAPI_InitMUILanguage

See Also

Search GetMUILanguage in MSDN Library.


Function _WinAPI_InitMUILanguage

Function Reference

_WinAPI_InitMUILanguage

Enables an application to specify a language to be used with the common controls that is different from the system language

#include <WinAPISys.au3>
_WinAPI_InitMUILanguage ( $iLanguage )

Parameters

$iLanguage The language identifier to be used by the common controls.

Return Value

None.

Remarks

This function enables an application to override the system language setting, and specify a different language
for the common controls. The selected language only applies to the current process.

See Also

Search InitMUILanguage in MSDN Library.


Function _WinAPI_LoadIconMetric

Function Reference

_WinAPI_LoadIconMetric

Loads a specified icon resource with a client-specified system metric

#include <WinAPISys.au3>
_WinAPI_LoadIconMetric ( $hInstance, $sName, $iMetric )

Parameters

$hInstance | Handle to the module of either a DLL or executable (.exe) file that contains the icon to be loaded.
$sName | The information about the icon to load. If $hInstance is not 0, $sName specifies the icon resource either by name or ordinal, otherwise, $sName specifies either the name of a standalone icon (.ico) file or the identifier of a predefined icon to load. $IDI_APPLICATION $IDI_HAND $IDI_QUESTION $IDI_EXCLAMATION $IDI_ASTERISK $IDI_WINLOGO $IDI_SHIELD $IDI_ERROR $IDI_INFORMATION $IDI_WARNING
$iMetric | The desired metric. It can be one of the following values. $LIM_SMALL $LIM_LARGE

Return Value

Success: | The icon handle.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

When you are finished using the icon, destroy it using the _WinAPI_DestroyIcon() function.

This function requires Windows Vista or later.

Related

_WinAPI_DestroyIcon

See Also

Search LoadIconMetric in MSDN Library.


Function _WinAPI_LoadIconWithScaleDown

Function Reference

_WinAPI_LoadIconWithScaleDown

Loads an icon and scales down a larger image instead of scaling up a smaller image

#include <WinAPISys.au3>
_WinAPI_LoadIconWithScaleDown ( $hInstance, $sName, $iWidth, $iHeight )

Parameters

$hInstance | Handle to the module of either a DLL or executable (.exe) file that contains the icon to be loaded.
$sName | The information about the icon to load. If $hInstance is not 0, $sName specifies the icon resource either by name or ordinal, otherwise, $sName specifies either the name of a standalone icon (.ico) file or the identifier of a predefined icon to load. $IDI_APPLICATION $IDI_HAND $IDI_QUESTION $IDI_EXCLAMATION $IDI_ASTERISK $IDI_WINLOGO $IDI_SHIELD $IDI_ERROR $IDI_INFORMATION $IDI_WARNING
$iWidth | The desired width, in pixels, of the icon.
$iHeight | The desired height, in pixels, of the icon.

Return Value

Success: | The icon handle.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

When you are finished using the icon, destroy it using the _WinAPI_DestroyIcon() function.

This function requires Windows Vista or later.

Related

_WinAPI_DestroyIcon

See Also

Search LoadIconWithScaleDown in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WinAPISys.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 324, 324)
GUICtrlCreateIcon('', 0, 64, 64, 196, 196)
Local $h_Icon = GUICtrlGetHandle(-1)
GUISetState(@SW_SHOW)

Local $hIcon = _WinAPI_LoadIconWithScaleDown(0, @ScriptDir & '\Extras\Soccer.ico', 196, 196)
Local $hPrev = _SendMessage($h_Icon, $STM_SETIMAGE, 1, $hIcon)
If $hPrev Then
    _WinAPI_DestroyIcon($hPrev)
EndIf

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_MirrorIcon

Function Reference

_WinAPI_MirrorIcon

Reverses (mirrors) icons so that they are displayed correctly on a mirrored device context

#include <WinAPISys.au3>
_WinAPI_MirrorIcon ( $hIcon [, $bDelete = False] )

Parameters

$hIcon | Handle to the icon.
$bDelete | [optional] Specifies whether to delete the icon after the function is successful, valid values: True - Icon will be deleted if the function succeeds. False - Do not delete, you must release the icon when you are finished using it (Default).

Return Value

Success: | Handle to the newly created icon.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

When you are finished using the icon, destroy it using the _WinAPI_DestroyIcon() function.

Related

_WinAPI_DestroyIcon

See Also

Search MirrorIcon in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIShellEx.au3>
#include <WinAPISys.au3>

Local $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 4, 32, 32)

GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 156, 108)
GUICtrlCreateIcon('', 0, 30, 38, 32, 32)
GUICtrlSendMsg(-1, $STM_SETIMAGE, 1, $hIcon)
GUICtrlCreateIcon('', 0, 88, 38, 32, 32)
GUICtrlSendMsg(-1, $STM_SETIMAGE, 1, _WinAPI_MirrorIcon($hIcon))
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


User Defined Functions

DLLLib user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPISys.au3>.

User Defined Function | Description
_WinAPI_GetDllDirectory | Retrieves the application-specific portion of the search path used to locate DLLs for the application
_WinAPI_GetModuleHandleEx | Retrieves a module handle for the specified module
_WinAPI_SetDllDirectory | Adds a directory to the search path used to locate DLLs for the application


Function _WinAPI_GetDllDirectory

Function Reference

_WinAPI_GetDllDirectory

Retrieves the application-specific portion of the search path used to locate DLLs for the application

#include <WinAPISys.au3>
_WinAPI_GetDllDirectory ( )

Return Value

Success: | The search path.
Failure: | Empty string, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetDllDirectory in MSDN Library.

Example

#include <WinAPISys.au3>

If Not _WinAPI_SetDllDirectory(@ScriptDir & '\Extras') Then
    Exit
EndIf

Local $hModule = _WinAPI_LoadLibraryEx('Resources.dll', $LOAD_LIBRARY_AS_DATAFILE)

ConsoleWrite('Path:   ' & _WinAPI_GetDllDirectory() & @CRLF)
ConsoleWrite('Module: ' & $hModule & @CRLF)

_WinAPI_FreeLibrary($hModule)


Function _WinAPI_GetModuleHandleEx

Function Reference

_WinAPI_GetModuleHandleEx

Retrieves a module handle for the specified module

#include <WinAPISys.au3>
_WinAPI_GetModuleHandleEx ( $sModule [, $iFlags = 0] )

Parameters

$sModule | The name of the loaded module (either a .dll or .exe file), or a pointer to an address in the module (if the $GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS flag is specified). If this parameter is 0 or an empty string, the function returns a handle to the file used to create the calling process (.exe file).
$iFlags | [optional] This parameter can be one or more of the following values. $GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS $GET_MODULE_HANDLE_EX_FLAG_PIN $GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT $GET_MODULE_HANDLE_EX_FLAG_DEFAULT (Default)

Return Value

Success: | Handle to the specified module.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetModuleHandleEx in MSDN Library.


Function _WinAPI_SetDllDirectory

Function Reference

_WinAPI_SetDllDirectory

Adds a directory to the search path used to locate DLLs for the application

#include <WinAPISys.au3>
_WinAPI_SetDllDirectory ( [$sDirPath = Default] )

Parameters

$sDirPath [optional] The directory to be added to the search path. If this parameter is an empty string (""), the call
removes the current directory from the default DLL search order. If this parameter is not specified,
the function restores the default search order (Default).

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

This function affects all subsequent calls to the _WinAPI_LoadLibrary() and _WinAPI_LoadLibraryEx() functions.
It also effectively disables safe DLL search mode while the specified directory is in the search path.

After calling _WinAPI_SetDllDirectory(), the DLL search path is:

1. The directory from which the application was loaded.
2. The directory specified by the $sFilePath parameter.
3. The system directory.
4. The 16-bit system directory.
5. The Windows directory.
6. The directories that are listed in the PATH environment variable.

Related

_WinAPI_LoadLibrary, _WinAPI_LoadLibraryEx

See Also

Search SetDllDirectory in MSDN Library.

Example

#include <WinAPISys.au3>

If Not _WinAPI_SetDllDirectory(@ScriptDir & '\Extras') Then
    Exit
EndIf

Local $hModule = _WinAPI_LoadLibraryEx('Resources.dll', $LOAD_LIBRARY_AS_DATAFILE)

ConsoleWrite('Path:   ' & _WinAPI_GetDllDirectory() & @CRLF)
ConsoleWrite('Module: ' & $hModule & @CRLF)

_WinAPI_FreeLibrary($hModule)


User Defined Functions

Heap user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPISys.au3>.

User Defined Function | Description
_WinAPI_CreateBuffer | Allocates a block of memory from the internal library heap
_WinAPI_CreateBufferFromStruct | Allocates a block of memory from the internal library heap and initializes it with the structure's data
_WinAPI_CreateString | Copies a specified string to the newly allocated memory block and returns its pointer
_WinAPI_FreeMemory | Frees a memory block in the internal library heap
_WinAPI_GetMemorySize | Retrieves the size of a memory block allocated from the internal library heap
_WinAPI_IsMemory | Determines whether the specified pointer points to the memory block in the internal library heap


Function _WinAPI_CreateBuffer

Function Reference

_WinAPI_CreateBuffer

Allocates a block of memory from the internal library heap

#include <WinAPISys.au3>
_WinAPI_CreateBuffer ( $iLength [, $pBuffer = 0 [, $bAbort = True]] )

Parameters

$iLength | The required buffer length, in bytes.
$pBuffer | [optional] A pointer to the existing buffer that to be replaced by a new buffer. If this parameter is a valid buffer pointer, the memory will be reallocated for a new buffer. However, the new memory is allocated at a different location. Therefore, you should always use the pointer that returns this function. If this parameter is 0 (Default) or invalid buffer pointer, the function just allocates a new memory.
$bAbort | [optional] Specifies whether to exit the script if not enough memory, valid values: True - Displaying an error message and exit the script with error code 1 (Default). False - Continue the script and return an error.

Return Value

Success: | A pointer to the new buffer.
Failure: | 0 and sets the @error flag to non-zero (if an exceptions is not set).

Remarks

When a buffer is no longer needed, you must destroy it by calling the _WinAPI_FreeMemory() function.

Related

_WinAPI_FreeMemory


Function _WinAPI_CreateBufferFromStruct

Function Reference

_WinAPI_CreateBufferFromStruct

Allocates a block of memory from the internal library heap and initializes it with the structure's data

#include <WinAPISys.au3>
_WinAPI_CreateBufferFromStruct ( $tStruct [, $pBuffer = 0 [, $bAbort = True]] )

Parameters

$tStruct | The structure that contains data to initialize the buffer.
$pBuffer | [optional] A pointer to the existing buffer that to be replaced by a new buffer. If this parameter is a valid buffer pointer, the memory will be reallocated for a new buffer. However, the new memory is allocated at a different location. Therefore, you should always use the pointer that returns this function. If this parameter is 0 (Default) or invalid buffer pointer, the function just allocates a new memory.
$bAbort | [optional] Specifies whether to exit the script if not enough memory, valid values: True - Displaying an error message and exit the script with error code 1 (Default). False - Continue the script and return an error.

Return Value

Success: | A pointer to the new buffer.
Failure: | 0 and sets the @error flag to non-zero (if an exceptions is not set).

Remarks

This function creates a buffer of size equal to the size of the specified structure and then copies all data from this structure.

When a buffer is no longer needed, you must destroy it by calling the _WinAPI_FreeMemory() function.

Related

_WinAPI_FreeMemory


Function _WinAPI_CreateString

Function Reference

_WinAPI_CreateString

Copies a specified string to the newly allocated memory block and returns its pointer

#include <WinAPISys.au3>
_WinAPI_CreateString ( $sString [, $pString = 0 [, $iLength = -1 [, $bUnicode = True [, $bAbort = True]]]] )

Parameters

$sString | The source string to be copied.
$pString | [optional] A pointer to the existing string that to be replaced by a new string. If this parameter is a valid string pointer, the memory will be reallocated for a new string. However, the new memory is allocated at a different location. Therefore, you should always use the pointer that returns this function. If this parameter is 0 (Default) or invalid string pointer, the function just allocates a new memory.
$iLength | [optional] The required buffer length, in TCHARs, without null-terminating character. If this parameter is (-1), the buffer length will be equal to the length of the source string. If $iLength is less than a source string, the string will be truncated to the specified length. Default is 1.
$bUnicode | [optional] Specifies whether a string is Unicode or ASCII code of a character, valid values: True - Unicode (Default). False - ASCII.
$bAbort | [optional] Specifies whether to exit the script if not enough memory, valid values: True - Displaying an error message and exit the script with error code 1 (Default). False - Continue the script and return an error.

Return Value

Success: A pointer to the new null-terminated string, @extended returns the length of the string buffer, in TCHARs (not including the null-terminating character).
Failure: 0.

Remarks

When a string is no longer needed, you must destroy it by calling the _WinAPI_FreeMemory() function.

Related

_WinAPI_FreeMemory

Example

#include <GUIConstantsEx.au3>
#include <WinAPISys.au3>

Global Const $WM_MYMESSAGE = _WinAPI_RegisterWindowMessage('MyMessage')

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 93)
Local $idInput = GUICtrlCreateInput('', 20, 20, 360, 20)
Local $idButton = GUICtrlCreateButton('Send', 165, 59, 70, 23)
GUIRegisterMsg($WM_MYMESSAGE, 'WM_MYMESSAGE')
GUISetState(@SW_SHOW)

Local $pString
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            $pString = _WinAPI_CreateString(GUICtrlRead($idInput))
            _WinAPI_SetMessageExtraInfo($pString)
            _SendMessage($hForm, $WM_MYMESSAGE, 1, 255)
            _WinAPI_FreeMemory($pString)
    EndSwitch
WEnd

Func WM_MYMESSAGE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg

    Local $pString = _WinAPI_GetMessageExtraInfo()

    If _WinAPI_IsMemory($pString) Then
        ConsoleWrite('WM_MYMESSAGE | WP = ' & Number($wParam) & ' | LP = ' & Number($lParam) & ' | EXTRA = "' & _WinAPI_GetString($pString) & '"' & @CRLF)
    EndIf
EndFunc   ;==>WM_MYMESSAGE


Function _WinAPI_FreeMemory

Function Reference

_WinAPI_FreeMemory

Frees a memory block in the internal library heap

#include <WinAPISys.au3>
_WinAPI_FreeMemory ( $pMemory )

Parameters

$pMemory A pointer to the valid memory block to be freed.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

The _WinAPI_FreeMemory() function accepts only the pointers returned by some _WinAPI_* functions (see description).


Function _WinAPI_GetMemorySize

Function Reference

_WinAPI_GetMemorySize

Retrieves the size of a memory block allocated from the internal library heap

#include <WinAPISys.au3>
_WinAPI_GetMemorySize ( $pMemory )

Parameters

$pMemory A pointer to the valid memory block whose size to be retrieved.

Return Value

Success: | The size of the specified memory block, in bytes.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

The _WinAPI_GetMemorySize() function accepts only the pointers returned by some _WinAPI_* functions (see description).


Function _WinAPI_IsMemory

Function Reference

_WinAPI_IsMemory

Determines whether the specified pointer points to the memory block in the internal library heap

#include <WinAPISys.au3>
_WinAPI_IsMemory ( $pMemory )

Parameters

$pMemory A pointer to the memory block that to be tested.

Return Value

True: | the specified pointer is a valid memory pointer.
False: | the specified pointer is not a valid memory pointer.

Remarks

The _WinAPI_IsMemory() function accepts only the pointers returned by some _WinAPI_* functions (see description),
otherwise always returns False.


User Defined Functions

Memory user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPISys.au3>.

User Defined Function | Description
_WinAPI_CompressBuffer | Compresses a buffer with specified compression format and engine type
_WinAPI_ComputeCrc32 | Calculates the CRC32 checksum of a block of memory
_WinAPI_DecompressBuffer | Decompresses an entire compressed buffer
_WinAPI_EqualMemory | Compares two blocks of memory to determine whether the specified number of bytes are identical
_WinAPI_FillMemory | Fills a block of memory with the given value
_WinAPI_GetPhysicallyInstalledSystemMemory | Retrieves the amount of RAM that is physically installed on the computer
_WinAPI_GetSystemDEPPolicy | Gets the data execution prevention (DEP) policy setting for the system
_WinAPI_IsBadCodePtr | Determines whether the calling process has read access to the memory at the specified address
_WinAPI_IsBadReadPtr | Verifies that the calling process has read access to the specified range of memory
_WinAPI_IsBadStringPtr | Verifies that the calling process has read access to the specified range of memory
_WinAPI_IsBadWritePtr | Verifies that the calling process has write access to the specified range of memory
_WinAPI_MoveMemory | Moves a block of memory from one location to another
_WinAPI_ZeroMemory | Fills a block of memory with zeros


Function _WinAPI_CompressBuffer

Function Reference

_WinAPI_CompressBuffer

Compresses a buffer with specified compression format and engine type

#include <WinAPISys.au3>
_WinAPI_CompressBuffer ( $pUncompressedBuffer, $iUncompressedSize, $pCompressedBuffer, $iCompressedSize [, $iFormatAndEngine = 0x0002] )

Parameters

$pUncompressedBuffer | A pointer to a caller-allocated buffer that contains the data to be compressed.
$iUncompressedSize | The size of the uncompressed buffer, in bytes.
$pCompressedBuffer | A pointer to a caller-allocated buffer that receives the compressed data.
$iCompressedSize | The size of the compressed buffer, in bytes.
$iFormatAndEngine | [optional] A bitmask that specifies the compression format and engine type. This parameter must be set to a valid bitwise OR combination of one format type and one engine type. $COMPRESSION_FORMAT_LZNT1 (Default) $COMPRESSION_FORMAT_XPRESS $COMPRESSION_FORMAT_XPRESS_HUFF $COMPRESSION_ENGINE_STANDARD (Default) $COMPRESSION_ENGINE_MAXIMUM

Return Value

Success: | The size of the compressed data stored in compressed buffer, in bytes.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the NTSTATUS error code.

Remarks

The _WinAPI_CompressBuffer() function takes as input an uncompressed buffer and produces its compressed equivalent provided that the compressed data fits within the specified destination buffer.

To decompress a compressed buffer, use the _WinAPI_DecompressBuffer() function.

Related

_WinAPI_DecompressBuffer

See Also

Search RtlCompressBuffer in MSDN Library.

Example

#include <APISysConstants.au3>
#include <WinAPISys.au3>

; Create compressed and uncompressed buffers
Local $a_pBuffer[2]
For $i = 0 To 1
    $a_pBuffer[$i] = _WinAPI_CreateBuffer(1024)
Next

; Compress binary data
Local $dData = Binary('0x00112233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF')
Local $iSize = BinaryLen($dData)
DllStructSetData(DllStructCreate('byte[' & $iSize & ']', $a_pBuffer[0]), 1, $dData)
$iSize = _WinAPI_CompressBuffer($a_pBuffer[0], $iSize, $a_pBuffer[1], 1024, BitOR($COMPRESSION_FORMAT_LZNT1, $COMPRESSION_ENGINE_MAXIMUM))
If Not @error Then
    ConsoleWrite('Compressed:   ' & DllStructGetData(DllStructCreate('byte[' & $iSize & ']', $a_pBuffer[1]), 1) & @CRLF)
EndIf

; Decompress data
$iSize = _WinAPI_DecompressBuffer($a_pBuffer[0], 1024, $a_pBuffer[1], $iSize)
If Not @error Then
    ConsoleWrite('Uncompressed: ' & DllStructGetData(DllStructCreate('byte[' & $iSize & ']', $a_pBuffer[0]), 1) & @CRLF)
EndIf

; Free memory
For $i = 0 To 1
    _WinAPI_FreeMemory($a_pBuffer[$i])
Next


Function _WinAPI_ComputeCrc32

Function Reference

_WinAPI_ComputeCrc32

Calculates the CRC32 checksum of a block of memory

#include <WinAPISys.au3>
_WinAPI_ComputeCrc32 ( $pMemory, $iLength )

Parameters

$pMemory | A pointer to the memory block to calculate the checksum.
$iLength | The number of bytes to be calculated.

Return Value

Success: | The CRC32 checksum (DWORD).
Failure: | 0 and sets the @error flag to non-zero.

Remarks

Not documented in MSDN

Example

#include <WinAPISys.au3>

Local $tData = DllStructCreate('byte[4096]')

ConsoleWrite(Hex(_WinAPI_ComputeCrc32($tData, 4096)) & @CRLF)

_WinAPI_FillMemory($tData, 4096, Random(0, 255, 1))

ConsoleWrite(Hex(_WinAPI_ComputeCrc32($tData, 4096)) & @CRLF)

_WinAPI_ZeroMemory($tData, 4096)

ConsoleWrite(Hex(_WinAPI_ComputeCrc32($tData, 4096)) & @CRLF & @CRLF)

ConsoleWrite('Invalid pointer -> ' & _WinAPI_ComputeCrc32(0, 4) & ' @error = ' & @error & ' @extended = 0x' & Hex(@extended) & @CRLF)


Function _WinAPI_DecompressBuffer

Function Reference

_WinAPI_DecompressBuffer

Decompresses an entire compressed buffer

#include <WinAPISys.au3>
_WinAPI_DecompressBuffer ( $pUncompressedBuffer, $iUncompressedSize, $pCompressedBuffer, $iCompressedSize [, $iFormat = 0x0002] )

Parameters

$pUncompressedBuffer | A pointer to a caller-allocated buffer that receives the decompressed data from compressed buffer.
$iUncompressedSize | The size of the uncompressed buffer, in bytes.
$pCompressedBuffer | A pointer to the buffer that contains the data to decompress.
$iCompressedSize | The size of the compressed buffer, in bytes.
$iFormat | [optional] The compression format of the data in compressed buffer. This parameter must be one of the following values: $COMPRESSION_FORMAT_LZNT1 (Default) $COMPRESSION_FORMAT_XPRESS $COMPRESSION_FORMAT_XPRESS_HUFF

Return Value

Success: | The size of the decompressed data stored in uncompressed buffer, in bytes.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the NTSTATUS error code.

Remarks

The _WinAPI_DecompressBuffer() function takes as input an entire compressed buffer and produces its decompressed equivalent provided that the uncompressed data fits within the specified destination buffer.

To compress an uncompressed buffer, use the _WinAPI_CompressBuffer() function.

Related

_WinAPI_CompressBuffer

See Also

Search RtlDecompressBuffer in MSDN Library.

Example

#include <APISysConstants.au3>
#include <WinAPISys.au3>

; Create compressed and uncompressed buffers
Local $a_pBuffer[2]
For $i = 0 To 1
    $a_pBuffer[$i] = _WinAPI_CreateBuffer(1024)
Next

; Compress binary data
Local $dData = Binary('0x00112233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF')
Local $iSize = BinaryLen($dData)
DllStructSetData(DllStructCreate('byte[' & $iSize & ']', $a_pBuffer[0]), 1, $dData)
$iSize = _WinAPI_CompressBuffer($a_pBuffer[0], $iSize, $a_pBuffer[1], 1024, BitOR($COMPRESSION_FORMAT_LZNT1, $COMPRESSION_ENGINE_MAXIMUM))
If Not @error Then
    ConsoleWrite('Compressed:   ' & DllStructGetData(DllStructCreate('byte[' & $iSize & ']', $a_pBuffer[1]), 1) & @CRLF)
EndIf

; Decompress data
$iSize = _WinAPI_DecompressBuffer($a_pBuffer[0], 1024, $a_pBuffer[1], $iSize)
If Not @error Then
    ConsoleWrite('Uncompressed: ' & DllStructGetData(DllStructCreate('byte[' & $iSize & ']', $a_pBuffer[0]), 1) & @CRLF)
EndIf

; Free memory
For $i = 0 To 1
    _WinAPI_FreeMemory($a_pBuffer[$i])
Next


Function _WinAPI_EqualMemory

Function Reference

_WinAPI_EqualMemory

Compares two blocks of memory to determine whether the specified number of bytes are identical

#include <WinAPISys.au3>
_WinAPI_EqualMemory ( $pSource1, $pSource2, $iLength )

Parameters

$pSource1 | A pointer to the block of memory to compare.
$pSource2 | A pointer to the block of memory that is compared to the block of memory to which $pSource1 points.
$iLength | The number of bytes to be compared.

Return Value

Success: | 1 - The two memory blocks are equivalent.
Failure: | 0 and sets the @error flag to non-zero.

See Also

Search RtlCompareMemory in MSDN Library.

Example

#include <WinAPISys.au3>

Local $tStruct1 = DllStructCreate('byte[8]')
Local $tStruct2 = DllStructCreate('byte[8]')

_WinAPI_FillMemory($tStruct1, 8, 0x1D)
_WinAPI_FillMemory($tStruct2, 8, 0x1D)

ConsoleWrite('Two structures are equivalent: ' & _WinAPI_EqualMemory($tStruct1, $tStruct2, 8) & @CRLF)


Function _WinAPI_FillMemory

Function Reference

_WinAPI_FillMemory

Fills a block of memory with the given value

#include <WinAPISys.au3>
_WinAPI_FillMemory ( $pMemory, $iLength [, $iValue = 0] )

Parameters

$pMemory | A pointer to the starting address of a memory to be filled.
$iLength | The number of bytes to be filled.
$iValue | [optional] The value to fill the memory. Default is 0.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

See Also

Search RtlFillMemory in MSDN Library.

Example

#include <WinAPISys.au3>

Local $tStruct = DllStructCreate('byte[8]')
ConsoleWrite(DllStructGetData($tStruct, 1) & @CRLF)

_WinAPI_FillMemory($tStruct, 8, 0xAB)
ConsoleWrite(DllStructGetData($tStruct, 1) & @CRLF)

_WinAPI_ZeroMemory($tStruct, 8)
ConsoleWrite(DllStructGetData($tStruct, 1) & @CRLF)


Function _WinAPI_GetPhysicallyInstalledSystemMemory

Function Reference

_WinAPI_GetPhysicallyInstalledSystemMemory

Retrieves the amount of RAM that is physically installed on the computer

#include <WinAPISys.au3>
_WinAPI_GetPhysicallyInstalledSystemMemory ( )

Return Value

Success: | The amount of physically installed RAM, in kilobytes.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

The amount of memory available to the operating system can be less than the amount of memory physically installed
in the computer because the BIOS and some drivers may reserve memory as I/O regions for memory-mapped devices,
making the memory unavailable to the operating system and applications.

This function requires Windows Vista with SP1 or later.

See Also

Search GetPhysicallyInstalledSystemMemory in MSDN Library.


Function _WinAPI_GetSystemDEPPolicy

Function Reference

_WinAPI_GetSystemDEPPolicy

Gets the data execution prevention (DEP) policy setting for the system

#include <WinAPISys.au3>
_WinAPI_GetSystemDEPPolicy ( )

Return Value

Returns The DEP policy setting, which can be one of the following values.

0 - AlwaysOff
DEP is disabled for all parts of the system, regardless of hardware support for DEP. The processor
runs in PAE mode with 32-bit versions of Windows unless PAE is disabled in the boot configuration data.

1 - AlwaysOn
DEP is enabled for all parts of the system. All processes always run with DEP enabled. DEP cannot
be explicitly disabled for selected applications. System compatibility fixes are ignored.

2 - OptIn
On systems with processors that are capable of hardware-enforced DEP, DEP is automatically enabled
only for operating system components. This is the default setting for client versions of Windows.
DEP can be explicitly enabled for selected applications or the current process.

3 - OptOut
DEP is automatically enabled for operating system components and all processes. This is the default
setting for Windows Server versions. DEP can be explicitly disabled for selected applications or
the current process. System compatibility fixes for DEP are in effect.

Remarks

This function requires Windows XP with SP3, Windows Vista with SP1 or later.

See Also

Search GetSystemDEPPolicy in MSDN Library.


Function _WinAPI_IsBadCodePtr

Function Reference

_WinAPI_IsBadCodePtr

Determines whether the calling process has read access to the memory at the specified address

#include <WinAPISys.au3>
_WinAPI_IsBadCodePtr ( $pAddress )

Parameters

$pAddress A pointer to a memory address.

Return Value

True: | the calling process does not have read access to the specified memory.
False: | the calling process have read access, call _WinAPI_GetLastError() to get extended error information.

See Also

Search IsBadCodePtr in MSDN Library.


Function _WinAPI_IsBadReadPtr

Function Reference

_WinAPI_IsBadReadPtr

Verifies that the calling process has read access to the specified range of memory

#include <WinAPISys.au3>
_WinAPI_IsBadReadPtr ( $pAddress, $iLength )

Parameters

$pAddress | A pointer to the first byte of the memory block.
$iLength | The size of the memory block, in bytes.

Return Value

True: | the calling process does not have read access to all bytes in the specified memory range.
False: | the calling process have read access.

See Also

Search IsBadReadPtr in MSDN Library.


Function _WinAPI_IsBadStringPtr

Function Reference

_WinAPI_IsBadStringPtr

Verifies that the calling process has read access to the specified range of memory

#include <WinAPISys.au3>
_WinAPI_IsBadStringPtr ( $pAddress, $iLength )

Parameters

$pAddress | A pointer to a null-terminated string, either Unicode or ASCII.
$iLength | The maximum size of the string, in TCHARs.

Return Value

True: | the calling process does not have read access to all characters up to the string's terminating null character or up to the number of specified characters.
False: | the calling process have read access.

Remarks

This function checks for read access in all characters up to the string's terminating null character or up to the
number of characters specified by this parameter, whichever is smaller.

See Also

Search IsBadStringPtr in MSDN Library.


Function _WinAPI_IsBadWritePtr

Function Reference

_WinAPI_IsBadWritePtr

Verifies that the calling process has write access to the specified range of memory

#include <WinAPISys.au3>
_WinAPI_IsBadWritePtr ( $pAddress, $iLength )

Parameters

$pAddress | A pointer to the first byte of the memory block.
$iLength | The size of the memory block, in bytes.

Return Value

True: | the calling process does not have write access to all bytes in the specified memory range.
False: | the calling process have write access.

See Also

Search IsBadWritePtr in MSDN Library.


Function _WinAPI_MoveMemory

Function Reference

_WinAPI_MoveMemory

Moves a block of memory from one location to another

#include <WinAPISys.au3>
_WinAPI_MoveMemory ( $pDestination, $pSource, $iLength )

Parameters

$pDestination | A pointer to the starting address of the move destination.
$pSource | A pointer to the starting address of the block of memory to be moved.
$iLength | The size of the block of memory to move, in bytes.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

Remarks

The source and destination blocks may overlap.

See Also

Search RtlMoveMemory in MSDN Library.

Example

#include <WinAPISys.au3>

Local $tStruct1 = DllStructCreate('int')
Local $tStruct2 = DllStructCreate('byte[4]')

DllStructSetData($tStruct1, 1, 0x11223344)

_WinAPI_MoveMemory($tStruct2, $tStruct1, 4)

ConsoleWrite('0x' & Hex(DllStructGetData($tStruct1, 1)) & @CRLF)
ConsoleWrite(DllStructGetData($tStruct2, 1) & @CRLF)


Function _WinAPI_ZeroMemory

Function Reference

_WinAPI_ZeroMemory

Fills a block of memory with zeros

#include <WinAPISys.au3>
_WinAPI_ZeroMemory ( $pMemory, $iLength )

Parameters

$pMemory | A pointer to the starting address of a memory to be filled.
$iLength | The number of bytes to be filled.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

See Also

Search RtlZeroMemory in MSDN Library.

Example

#include <WinAPISys.au3>

Local $tStruct = DllStructCreate('byte[8]')
ConsoleWrite(DllStructGetData($tStruct, 1) & @CRLF)

_WinAPI_FillMemory($tStruct, 8, 0xAB)
ConsoleWrite(DllStructGetData($tStruct, 1) & @CRLF)

_WinAPI_ZeroMemory($tStruct, 8)
ConsoleWrite(DllStructGetData($tStruct, 1) & @CRLF)


User Defined Functions

Power user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPISys.au3>.

User Defined Function | Description
_WinAPI_GetDefaultPrinter | Retrieves the printer name of the default printer for the current user on the local computer
_WinAPI_GetPwrCapabilities | Retrieves information about the system power capabilities
_WinAPI_GetSystemPowerStatus | Retrieves the power status of the system
_WinAPI_RegisterPowerSettingNotification | Registers the application to receive power setting notifications for the specific power setting event
_WinAPI_UnregisterPowerSettingNotification | Unregisters the power setting notification


Function _WinAPI_GetDefaultPrinter

Function Reference

_WinAPI_GetDefaultPrinter

Retrieves the printer name of the default printer for the current user on the local computer

#include <WinAPISys.au3>
_WinAPI_GetDefaultPrinter ( )

Return Value

Success: | String containing the default printer name.
Failure: | Empty string and sets the @error flag to non-zero, @extended may contains system error: 2 - No default printer

See Also

Search GetDefaultPrinter in MSDN Library.


Function _WinAPI_GetPwrCapabilities

Function Reference

_WinAPI_GetPwrCapabilities

Retrieves information about the system power capabilities

#include <WinAPISys.au3>
_WinAPI_GetPwrCapabilities ( )

Return Value

Success: The array that contains the following information:
[0] - If True, there is a system power button.
[1] - If True, there is a system sleep button.
[2] - If True, there is a lid switch.
[3] - If True, the operating system supports sleep state S1.
[4] - If True, the operating system supports sleep state S2.
[5] - If True, the operating system supports sleep state S3.
[6] - If True, the operating system supports sleep state S4 (hibernation).
[7] - If True, the operating system supports power off state S5 (soft off).
[8] - If True, the system hibernation file is present.
[9] - If True, the system supports wake capabilities.
[10] - If True, the system supports video display dimming capabilities.
[11] - If True, the system supports APM BIOS power management features.
[12] - If True, there is an uninterruptible power supply (UPS).
[13] - If True, the system supports thermal zones.
[14] - If True, the system supports processor throttling.
[15] - The minimum level of system processor throttling supported, expressed as a percentage.
[16] - The maximum level of system processor throttling supported, expressed as a percentage.
[17] - If True, the system supports the hybrid sleep state.
[18] - If True, the system supports allowing the removal of power to fixed disk devices.
[19] - If True, there are one or more batteries in the system.
[20] - If True, the system batteries are short-term. Short-term batteries are used in uninterruptible power supplies (UPS).
[21] - The lowest system sleep state (Sx) that will generate a wake event when the system is on AC power.
[22] - The lowest system sleep state (Sx) that will generate a wake event via the lid switch.
[23] - The lowest system sleep state (Sx) supported by hardware that will generate a wake event via the RTC.
[24] - The minimum allowable system power state supporting wake events.
Failure: Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetPwrCapabilities in MSDN Library.

Example

#include <Array.au3>
#include <WinAPISys.au3>

Local $aInfo[25][2] = _
        [['Power button', 0], _
        ['Sleep button', 0], _
        ['Lid switch', 0], _
        ['S1', 0], _
        ['S2', 0], _
        ['S3', 0], _
        ['S4', 0], _
        ['S5', 0], _
        ['HIBERFIL.SYS', 0], _
        ['Wake', 0], _
        ['Video display dimming', 0], _
        ['APM BIOS', 0], _
        ['UPS', 0], _
        ['Thermal zones', 0], _
        ['Throttling', 0], _
        ['Throttling min level', 0], _
        ['Throttling max level', 0], _
        ['Hibernation', 0], _
        ['HDD power down', 0], _
        ['Batteries', 0], _
        ['Batteries short-term', 0], _
        ['AC lowest wake state', 0], _
        ['Lid lowest wake state', 0], _
        ['RTC lowest wake state', 0], _
        ['Minimum device wake state', 0]]
Local $aData = _WinAPI_GetPwrCapabilities()

If @error Then
    For $i = 0 To UBound($aInfo) - 1
        $aInfo[$i][1] = $aData[$i]
    Next
Else
    Exit
EndIf

_ArrayDisplay($aInfo, '_WinAPI_GetPwrCapabilities')


Function _WinAPI_GetSystemPowerStatus

Function Reference

_WinAPI_GetSystemPowerStatus

Retrieves the power status of the system

#include <WinAPISys.au3>
_WinAPI_GetSystemPowerStatus ( )

Return Value

Success: | The array containing the following information: [0] - The AC power status. This parameter can be one of the following values. 0 - Offline 1 - Online 255 - Unknown status [1] - The battery charge status. This parameter can be a combination of the following values. 0 - The battery is not being charged and its capacity is between low and high 1 - High - the battery capacity is at more than 66 percent 2 - Low - the battery capacity is at less than 33 percent 4 - Critical - the battery capacity is at less than 5 percent 8 - Charging 128 - No system battery 255 - Unknown status - unable to read the battery flag information [2] - The percentage of full battery charge remaining. This member can be a value in the range 0 to 100, or 255 if status is unknown. [3] - The number of seconds of battery life remaining, or (–1) if remaining seconds are unknown. [4] - The number of seconds of battery life when at full charge, or (–1) if full battery lifetime is unknown.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetSystemPowerStatus in MSDN Library.

Example

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

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 180, 135, -1, -1, -1, $WS_EX_TOPMOST)
Local $idButton = GUICtrlCreateButton('OK', 55, 101, 70, 23)
GUICtrlCreateLabel('AC power:', 10, 14, 90, 14)
GUICtrlCreateLabel('Status:', 10, 34, 70, 14)
GUICtrlCreateLabel('Charge:', 10, 54, 90, 14)
GUICtrlCreateLabel('Time remaining:', 10, 74, 90, 14)
Global $g_aidLabel[4]
For $i = 0 To 3
    $g_aidLabel[$i] = GUICtrlCreateLabel('Unknown', 110, 14 + 20 * $i, 60, 14)
Next
GUISetState(@SW_SHOW)

AdlibRegister('_BatteryStatus', 1000)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $idButton
            ExitLoop
    EndSwitch
WEnd

Func _BatteryStatus()
    Local $aData = _WinAPI_GetSystemPowerStatus()
    If @error Then Return

    If BitAND($aData[1], 128) Then
        $aData[0] = 'Not present'
        For $i = 1 To 3
            $aData[$i] = 'Unknown'
        Next
    Else
        Switch $aData[0]
            Case 0
                $aData[0] = 'Offline'
            Case 1
                $aData[0] = 'Online'
            Case Else
                $aData[0] = 'Unknown'
        EndSwitch
        Switch $aData[2]
            Case 0 To 100
                $aData[2] &= '%'
            Case Else
                $aData[2] = 'Unknown'
        EndSwitch
        Switch $aData[3]
            Case -1
                $aData[3] = 'Unknown'
            Case Else
                Local $H, $M
                $H = ($aData[3] - Mod($aData[3], 3600)) / 3600
                $M = ($aData[3] - Mod($aData[3], 60)) / 60 - $H * 60
                $aData[3] = StringFormat($H & ':%02d', $M)
        EndSwitch
        If BitAND($aData[1], 8) Then
            $aData[1] = 'Charging'
        Else
            Switch BitAND($aData[1], 0xF)
                Case 1
                    $aData[1] = 'High'
                Case 2
                    $aData[1] = 'Low'
                Case 4
                    $aData[1] = 'Critical'
                Case Else
                    $aData[1] = 'Unknown'
            EndSwitch
        EndIf
    EndIf
    For $i = 0 To 3
        GUICtrlSetData($g_aidLabel[$i], $aData[$i])
    Next
EndFunc   ;==>_BatteryStatus


Function _WinAPI_RegisterPowerSettingNotification

Function Reference

_WinAPI_RegisterPowerSettingNotification

Registers the application to receive power setting notifications for the specific power setting event

#include <WinAPISys.au3>
_WinAPI_RegisterPowerSettingNotification ( $hWnd, $sGUID )

Parameters

$hWnd | Handle to the window that receives the change or notification messages.
$sGUID | The string that represents a GUID of the power setting for which notifications are to be sent. It may be one of the following values. $GUID_ACDC_POWER_SOURCE $GUID_BATTERY_PERCENTAGE_REMAINING $GUID_IDLE_BACKGROUND_TASK $GUID_MONITOR_POWER_ON $GUID_POWERSCHEME_PERSONALITY $GUID_SYSTEM_AWAYMODE

Return Value

Success: | A notification handle for unregistering for power notifications.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

After calling this function, notifications are sent to the specified window using WM_POWERBROADCAST
messages with a wParam parameter of PBT_POWERSETTINGCHANGE.
(see MSDN for more information)

This function requires Windows Vista or later.

See Also

Search RegisterPowerSettingNotification in MSDN Library.


Function _WinAPI_UnregisterPowerSettingNotification

Function Reference

_WinAPI_UnregisterPowerSettingNotification

Unregisters the power setting notification

#include <WinAPISys.au3>
_WinAPI_UnregisterPowerSettingNotification ( $hNotify )

Parameters

$hNotify Handle returned from the _WinAPI_RegisterPowerSettingNotification() function.

Return Value

Success: | True
Failure: | False

Remarks

This function requires Windows Vista or later.

Related

_WinAPI_RegisterPowerSettingNotification

See Also

Search UnregisterPowerSettingNotification in MSDN Library.


User Defined Functions

Station & Desktop user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPISys.au3>.

User Defined Function | Description
_WinAPI_CloseDesktop | Closes an open handle to a desktop object
_WinAPI_CloseWindowStation | Closes an open window station handle
_WinAPI_CreateDesktop | Creates a new desktop, associates it with the current window station of the calling process
_WinAPI_CreateWindowStation | Creates a window station object, associates it with the calling process, and assigns it to the current session
_WinAPI_EnumDesktops | Enumerates all desktops associated with the specified window station of the calling process
_WinAPI_EnumDesktopWindows | Enumerates all top-level windows associated with the specified desktop
_WinAPI_EnumWindowStations | Enumerates all window stations in the current session
_WinAPI_GetProcessWindowStation | Retrieves a handle to the current window station for the calling process
_WinAPI_GetUserObjectInformation | Retrieves information about the specified window station or desktop object
_WinAPI_OpenDesktop | Opens the specified desktop object
_WinAPI_OpenInputDesktop | Opens the desktop that receives user input
_WinAPI_OpenWindowStation | Opens the specified window station
_WinAPI_SetProcessWindowStation | Assigns the specified window station to the calling process
_WinAPI_SetUserObjectInformation | Sets information about the specified window station or desktop object
_WinAPI_SwitchDesktop | Makes the specified desktop visible and activates it


Function _WinAPI_CloseDesktop

Function Reference

_WinAPI_CloseDesktop

Closes an open handle to a desktop object

#include <WinAPISys.au3>
_WinAPI_CloseDesktop ( $hDesktop )

Parameters

$hDesktop Handle to the desktop to be closed.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

The _WinAPI_CloseDesktop() function will fail if any thread in the calling process is using the specified desktop handle or if the handle refers to the initial desktop of the calling process.

See Also

Search CloseDesktop in MSDN Library.

Example

#include <APIProcConstants.au3>
#include <APISysConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>

; Retrieve a handle to the current desktop and create a new desktop named "MyDesktop"
Local $hPrev = _WinAPI_GetThreadDesktop(_WinAPI_GetCurrentThreadId())
Local $hDesktop = _WinAPI_CreateDesktop('MyDesktop', BitOR($DESKTOP_CREATEWINDOW, $DESKTOP_SWITCHDESKTOP))
If Not $hDesktop Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create desktop.')
    Exit
EndIf

; Switch to the newly created desktop
_WinAPI_SwitchDesktop($hDesktop)

; Run "calc.exe" on "MyDesktop" and wait until a process will not be closed by user
Local $pText = _WinAPI_CreateString('MyDesktop')
Local $tProcess = DllStructCreate($tagPROCESS_INFORMATION)
Local $tStartup = DllStructCreate($tagSTARTUPINFO)
DllStructSetData($tStartup, 'Size', DllStructGetSize($tStartup))
DllStructSetData($tStartup, 'Desktop', $pText)
If _WinAPI_CreateProcess('', @SystemDir & '\calc.exe', 0, 0, 0, $CREATE_NEW_PROCESS_GROUP, 0, 0, $tStartup, $tProcess) Then
    ProcessWaitClose(DllStructGetData($tProcess, 'ProcessID'))
EndIf

; Switch to previous desktop and close "MyDesktop"
_WinAPI_SwitchDesktop($hPrev)
_WinAPI_CloseDesktop($hDesktop)

; Free memory allocated for a string
_WinAPI_FreeMemory($pText)


Function _WinAPI_CloseWindowStation

Function Reference

_WinAPI_CloseWindowStation

Closes an open window station handle

#include <WinAPISys.au3>
_WinAPI_CloseWindowStation ( $hStation )

Parameters

$hStation Handle to the window station to be closed.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

The _WinAPI_CloseWindowStation() function will fail if the handle being closed is for the window station assigned to the calling process.

Related

_WinAPI_CreateWindowStation, _WinAPI_OpenWindowStation

See Also

Search CloseWindowStation in MSDN Library.


Function _WinAPI_CreateDesktop

Function Reference

_WinAPI_CreateDesktop

Creates a new desktop, associates it with the current window station of the calling process

#include <WinAPISys.au3>
_WinAPI_CreateDesktop ( $sName [, $iAccess = 0x0002 [, $iFlags = 0 [, $iHeap = 0 [, $tSecurity = 0]]]] )

Parameters

$sName | The name of the desktop to be created. Desktop names are case-insensitive and may not contain backslash characters (\).
$iAccess | [optional] The requested access to the desktop. This parameter can be one or more of the following values: $DESKTOP_ALL_ACCESS $DESKTOP_CREATEMENU $DESKTOP_CREATEWINDOW (Default) $DESKTOP_ENUMERATE $DESKTOP_HOOKCONTROL $DESKTOP_JOURNALPLAYBACK $DESKTOP_JOURNALRECORD $DESKTOP_READOBJECTS $DESKTOP_SWITCHDESKTOP $DESKTOP_WRITEOBJECTS
$iFlags | [optional] The optional flags. It can be zero or the following value: $DF_ALLOWOTHERACCOUNTHOOK
$iHeap | [optional] The size of the desktop heap, in kilobytes. Default is 0.
$tSecurity | [optional] $tagSECURITY_ATTRIBUTES structure that determines whether the returned handle can be inherited by child processes. If this parameter is 0 (Default), the handle cannot be inherited .

Return Value

Success: | Handle to the newly created desktop. If the specified desktop already exists, the function succeeds and returns a handle to the existing desktop.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

The number of desktops that can be created is limited by the size of the system desktop heap.
You can increase the number of desktops that can be created by increasing the size of the desktop heap or by reducing the default heap reserved for each desktop in the interactive window station.
The default size of the desktop heap depends on factors such as hardware architecture.
To retrieve the size of the heap, call the _WinAPI_GetUserObjectInformation() function with $UOI_HEAPSIZE.

When you are finished using the desktop, call the _WinAPI_CloseDesktop() function to close it.

Related

_WinAPI_CloseDesktop, _WinAPI_GetUserObjectInformation

See Also

Search CreateDesktopEx in MSDN Library.

Example

#include <APIProcConstants.au3>
#include <APISysConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>

; Retrieve a handle to the current desktop and create a new desktop named "MyDesktop"
Local $hPrev = _WinAPI_GetThreadDesktop(_WinAPI_GetCurrentThreadId())
Local $hDesktop = _WinAPI_CreateDesktop('MyDesktop', BitOR($DESKTOP_CREATEWINDOW, $DESKTOP_SWITCHDESKTOP))
If Not $hDesktop Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create desktop.')
    Exit
EndIf

; Switch to the newly created desktop
_WinAPI_SwitchDesktop($hDesktop)

; Run "calc.exe" on "MyDesktop" and wait until a process will not be closed by user
Local $pText = _WinAPI_CreateString('MyDesktop')
Local $tProcess = DllStructCreate($tagPROCESS_INFORMATION)
Local $tStartup = DllStructCreate($tagSTARTUPINFO)
DllStructSetData($tStartup, 'Size', DllStructGetSize($tStartup))
DllStructSetData($tStartup, 'Desktop', $pText)
If _WinAPI_CreateProcess('', @SystemDir & '\calc.exe', 0, 0, 0, $CREATE_NEW_PROCESS_GROUP, 0, 0, $tStartup, $tProcess) Then
    ProcessWaitClose(DllStructGetData($tProcess, 'ProcessID'))
EndIf

; Switch to previous desktop and close "MyDesktop"
_WinAPI_SwitchDesktop($hPrev)
_WinAPI_CloseDesktop($hDesktop)

; Free memory allocated for a string
_WinAPI_FreeMemory($pText)


Function _WinAPI_CreateWindowStation

Function Reference

_WinAPI_CreateWindowStation

Creates a window station object, associates it with the calling process, and assigns it to the current session

#include <WinAPISys.au3>
_WinAPI_CreateWindowStation ( [$sName = '' [, $iAccess = 0 [, $iFlags = 0 [, $tSecurity = 0]]]] )

Parameters

$sName | [optional] The name of the window station to be created. Window station names are case-insensitive and cannot contain backslash characters (\). Only members of the Administrators group are allowed to specify a name. If this parameter is empty string (Default), the system forms a window station name using the logon session identifier for the calling process.
$iAccess | [optional] The type of access the returned handle has to the window station. This parameter can be one or more of the following values: $WINSTA_ALL_ACCESS $WINSTA_ACCESSCLIPBOARD $WINSTA_ACCESSGLOBALATOMS $WINSTA_CREATEDESKTOP $WINSTA_ENUMDESKTOPS $WINSTA_ENUMERATE $WINSTA_EXITWINDOWS $WINSTA_READATTRIBUTES $WINSTA_READSCREEN $WINSTA_WRITEATTRIBUTES
$iFlags | [optional] The optional flags. It can be zero (Default) or the following value: $CWF_CREATE_ONLY
$tSecurity | [optional] $tagSECURITY_ATTRIBUTES structure that determines whether the returned handle can be inherited by child processes. If this parameter is 0 (Default), the handle cannot be inherited.

Return Value

Success: | Handle to the newly created window station. If the specified window station already exists, the function succeeds and returns a handle to the existing window station.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

After you are done with the handle, you must call _WinAPI_CloseWindowStation() to free the handle.

Related

_WinAPI_CloseWindowStation

See Also

Search CreateWindowStation in MSDN Library.


Function _WinAPI_EnumDesktops

Function Reference

_WinAPI_EnumDesktops

Enumerates all desktops associated with the specified window station of the calling process

#include <WinAPISys.au3>
_WinAPI_EnumDesktops ( $hStation )

Parameters

$hStation Handle to the window station whose desktops are to be enumerated. This handle must have the
$WINSTA_ENUMDESKTOPS access right.

Return Value

Success: | The array of the desktop names. The zeroth array element contains the number of desktop.
Failure: | Sets the @error flag to non-zero.

Remarks

The _WinAPI_EnumDesktops() enumerates only those desktops for which the calling process has the
$DESKTOP_ENUMERATE access right.

See Also

Search EnumDesktops in MSDN Library.

Example

#include <Array.au3>
#include <WinAPISys.au3>

Local $aData = _WinAPI_EnumDesktops(_WinAPI_GetProcessWindowStation())

_ArrayDisplay($aData, '_WinAPI_EnumDesktops')


Function _WinAPI_EnumDesktopWindows

Function Reference

_WinAPI_EnumDesktopWindows

Enumerates all top-level windows associated with the specified desktop

#include <WinAPISys.au3>
_WinAPI_EnumDesktopWindows ( $hDesktop [, $bVisible = True] )

Parameters

$hDesktop | Handle to the desktop whose top-level windows are to be enumerated. This handle must have the $DESKTOP_READOBJECTS access right.
$bVisible | [optional] Specifies whether enumerates the invisible window, valid values: True - Enumerate only visible windows (Default). False - Enumerate all windows.

Return Value

Success: | The 2D array of the handles to the window and its class associated with the specified desktop. [0][0] - Number of rows in array (n) [0][1] - Unused [n][0] - Window handle [n][1] - Window class name
Failure: | Sets the @error flag to non-zero.

See Also

Search EnumDesktopWindows in MSDN Library.

Example

#include <Array.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>

Local $aData = _WinAPI_EnumDesktopWindows(_WinAPI_GetThreadDesktop(_WinAPI_GetCurrentThreadId()))

_ArrayDisplay($aData, '_WinAPI_EnumDesktopWindows')


Function _WinAPI_EnumWindowStations

Function Reference

_WinAPI_EnumWindowStations

Enumerates all window stations in the current session

#include <WinAPISys.au3>
_WinAPI_EnumWindowStations ( )

Return Value

Success: | The array of the window station names. The zeroth array element contains the number of window station.
Failure: | Sets the @error flag to non-zero.

Remarks

The _WinAPI_EnumWindowStations() enumerates only those window stations for which the calling process has the
$WINSTA_ENUMERATE access right.

See Also

Search EnumWindowStations in MSDN Library.

Example

#include <Array.au3>
#include <WinAPISys.au3>

Local $aData = _WinAPI_EnumWindowStations()

_ArrayDisplay($aData, '_WinAPI_EnumWindowStations')


Function _WinAPI_GetProcessWindowStation

Function Reference

_WinAPI_GetProcessWindowStation

Retrieves a handle to the current window station for the calling process

#include <WinAPISys.au3>
_WinAPI_GetProcessWindowStation ( )

Return Value

Success: | Handle to the window station for the current process.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

Do not close the handle returned by this function.

See Also

Search GetProcessWindowStation in MSDN Library.

Example

#include <APISysConstants.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>

Local $a_hObj[2] = [_WinAPI_GetProcessWindowStation(), _WinAPI_GetThreadDesktop(_WinAPI_GetCurrentThreadId())]

For $i = 0 To 1
    If Not $i Then
        ConsoleWrite('-------------------------------' & @CRLF)
    EndIf
    ConsoleWrite('Handle: ' & $a_hObj[$i] & @CRLF)
    ConsoleWrite('Type:   ' & _WinAPI_GetUserObjectInformation($a_hObj[$i], $UOI_TYPE) & @CRLF)
    ConsoleWrite('Name:   ' & _WinAPI_GetUserObjectInformation($a_hObj[$i], $UOI_NAME) & @CRLF)
    ConsoleWrite('-------------------------------' & @CRLF)
Next


Function _WinAPI_GetUserObjectInformation

Function Reference

_WinAPI_GetUserObjectInformation

Retrieves information about the specified window station or desktop object

#include <WinAPISys.au3>
_WinAPI_GetUserObjectInformation ( $hObject, $iIndex )

Parameters

$hObject | Handle to the window station or desktop object.
$iIndex | The information to be retrieved. The parameter can be one of the following values. $UOI_FLAGS $tagUSEROBJECTFLAGS structure containing information about a window station or desktop handle. $UOI_HEAPSIZE The size of the desktop heap, in KB. $UOI_IO 1 if the object is a handle to the desktop that is receiving input from the user, 0 otherwise. $UOI_NAME The name of the object, as a string. $UOI_TYPE The type of the object, as a string. $UOI_USER_SID The security identifier (SID) structure as "byte[n]".

Return Value

Success: | The object information. Return type depends on the information type (see above).
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetUserObjectInformation in MSDN Library.

Example

#include <APISysConstants.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>

Local $a_hObj[2] = [_WinAPI_GetProcessWindowStation(), _WinAPI_GetThreadDesktop(_WinAPI_GetCurrentThreadId())]

For $i = 0 To 1
    If Not $i Then
        ConsoleWrite('-------------------------------' & @CRLF)
    EndIf
    ConsoleWrite('Handle: ' & $a_hObj[$i] & @CRLF)
    ConsoleWrite('Type:   ' & _WinAPI_GetUserObjectInformation($a_hObj[$i], $UOI_TYPE) & @CRLF)
    ConsoleWrite('Name:   ' & _WinAPI_GetUserObjectInformation($a_hObj[$i], $UOI_NAME) & @CRLF)
    ConsoleWrite('-------------------------------' & @CRLF)
Next


Function _WinAPI_OpenDesktop

Function Reference

_WinAPI_OpenDesktop

Opens the specified desktop object

#include <WinAPISys.au3>
_WinAPI_OpenDesktop ( $sName [, $iAccess = 0 [, $iFlags = 0 [, $bInherit = False]]] )

Parameters

$sName | The name of the desktop to be opened. Desktop names are case-insensitive. This desktop must belong to the current window station.
$iAccess | [optional] The access to the desktop. This parameter can be one or more of the following values. $DESKTOP_ALL_ACCESS $DESKTOP_CREATEMENU $DESKTOP_CREATEWINDOW $DESKTOP_ENUMERATE $DESKTOP_HOOKCONTROL $DESKTOP_JOURNALPLAYBACK $DESKTOP_JOURNALRECORD $DESKTOP_READOBJECTS $DESKTOP_SWITCHDESKTOP $DESKTOP_WRITEOBJECTS
$iFlags | [optional] The optional flags. It can be zero or the following value. $DF_ALLOWOTHERACCOUNTHOOK
$bInherit | [optional] Specifies whether inherites the handle by a processes, valid values: True - The processes created by this process will inherit the handle. False - The processes do not inherit this handle (Default).

Return Value

Success: | Handle to the opened desktop.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

When you are finished using the desktop, call the _WinAPI_CloseDesktop() function to close it.

Related

_WinAPI_CloseDesktop

See Also

Search OpenDesktop in MSDN Library.


Function _WinAPI_OpenInputDesktop

Function Reference

_WinAPI_OpenInputDesktop

Opens the desktop that receives user input

#include <WinAPISys.au3>
_WinAPI_OpenInputDesktop ( [$iAccess = 0 [, $iFlags = 0 [, $bInherit = False]]] )

Parameters

$iAccess | [optional] The access to the desktop. This parameter can be one or more of the following values. $DESKTOP_ALL_ACCESS $DESKTOP_CREATEMENU $DESKTOP_CREATEWINDOW $DESKTOP_ENUMERATE $DESKTOP_HOOKCONTROL $DESKTOP_JOURNALPLAYBACK $DESKTOP_JOURNALRECORD $DESKTOP_READOBJECTS $DESKTOP_SWITCHDESKTOP $DESKTOP_WRITEOBJECTS
$iFlags | [optional] The optional flags. It can be zero or the following value. $DF_ALLOWOTHERACCOUNTHOOK
$bInherit | [optional] Specifies whether inherites the handle by a processes, valid values: True - The processes created by this process will inherit the handle. False - The processes do not inherit this handle (Default).

Return Value

Success: | Handle to the opened desktop.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

When you are finished using the desktop, call the _WinAPI_CloseDesktop() function to close it.

Related

_WinAPI_CloseDesktop

See Also

Search OpenInputDesktop in MSDN Library.


Function _WinAPI_OpenWindowStation

Function Reference

_WinAPI_OpenWindowStation

Opens the specified window station

#include <WinAPISys.au3>
_WinAPI_OpenWindowStation ( $sName [, $iAccess = 0 [, $bInherit = False]] )

Parameters

$sName | The name of the window station to be opened. Window station names are case-insensitive. This window station must belong to the current session.
$iAccess | [optional] The access to the window station. This parameter can be one or more of the following values. $WINSTA_ALL_ACCESS $WINSTA_ACCESSCLIPBOARD $WINSTA_ACCESSGLOBALATOMS $WINSTA_CREATEDESKTOP $WINSTA_ENUMDESKTOPS $WINSTA_ENUMERATE $WINSTA_EXITWINDOWS $WINSTA_READATTRIBUTES $WINSTA_READSCREEN $WINSTA_WRITEATTRIBUTES
$bInherit | [optional] Specifies whether inherites the handle by a processes, valid values: True - The processes created by this process will inherit the handle. False - The processes do not inherit this handle (Default).

Return Value

Success: | Handle to the specified window station.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

After you are done with the handle, you must call _WinAPI_CloseWindowStation() to free the handle.

Related

_WinAPI_CloseWindowStation

See Also

Search OpenWindowStation in MSDN Library.


Function _WinAPI_SetProcessWindowStation

Function Reference

_WinAPI_SetProcessWindowStation

Assigns the specified window station to the calling process

#include <WinAPISys.au3>
_WinAPI_SetProcessWindowStation ( $hStation )

Parameters

$hStation Handle to the window station. This window station must be associated with the current session.

Return Value

Success: | True
Failure: | False

See Also

Search SetProcessWindowStation in MSDN Library.


Function _WinAPI_SetUserObjectInformation

Function Reference

_WinAPI_SetUserObjectInformation

Sets information about the specified window station or desktop object

#include <WinAPISys.au3>
_WinAPI_SetUserObjectInformation ( $hObject, $iIndex, $tData )

Parameters

$hObject | Handle to the window station or desktop object.
$iIndex | The object information to be set. This parameter can be one of the following values. $UOI_FLAGS
$tData | The data of the object information. The data type depends on the information type. For more information, see _WinAPI_GetUserObjectInformation() function.

Return Value

Success: | True
Failure: | False

See Also

Search SetUserObjectInformation in MSDN Library.


Function _WinAPI_SwitchDesktop

Function Reference

_WinAPI_SwitchDesktop

Makes the specified desktop visible and activates it

#include <WinAPISys.au3>
_WinAPI_SwitchDesktop ( $hDesktop )

Parameters

$hDesktop Handle to the desktop. This desktop must be associated with the current window station for the process.

Return Value

Success: | True
Failure: | False

Remarks

The _WinAPI_SwitchDesktop() function fails if the desktop belongs to an invisible window station. This function
also fails when called from a process that is associated with a secured desktop such as the WinLogon and ScreenSaver
desktops. Processes that are associated with a secured desktop include custom UserInit processes. Such calls
typically fail with an "access denied" error.

See Also

Search SwitchDesktop in MSDN Library.

Example

#include <APIProcConstants.au3>
#include <APISysConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIProc.au3>
#include <WinAPISys.au3>

; Retrieve a handle to the current desktop and create a new desktop named "MyDesktop"
Local $hPrev = _WinAPI_GetThreadDesktop(_WinAPI_GetCurrentThreadId())
Local $hDesktop = _WinAPI_CreateDesktop('MyDesktop', BitOR($DESKTOP_CREATEWINDOW, $DESKTOP_SWITCHDESKTOP))
If Not $hDesktop Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Unable to create desktop.')
    Exit
EndIf

; Switch to the newly created desktop
_WinAPI_SwitchDesktop($hDesktop)

; Run "calc.exe" on "MyDesktop" and wait until a process will not be closed by user
Local $pText = _WinAPI_CreateString('MyDesktop')
Local $tProcess = DllStructCreate($tagPROCESS_INFORMATION)
Local $tStartup = DllStructCreate($tagSTARTUPINFO)
DllStructSetData($tStartup, 'Size', DllStructGetSize($tStartup))
DllStructSetData($tStartup, 'Desktop', $pText)
If _WinAPI_CreateProcess('', @SystemDir & '\calc.exe', 0, 0, 0, $CREATE_NEW_PROCESS_GROUP, 0, 0, $tStartup, $tProcess) Then
    ProcessWaitClose(DllStructGetData($tProcess, 'ProcessID'))
EndIf

; Switch to previous desktop and close "MyDesktop"
_WinAPI_SwitchDesktop($hPrev)
_WinAPI_CloseDesktop($hDesktop)

; Free memory allocated for a string
_WinAPI_FreeMemory($pText)


User Defined Functions

SysInfo user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPISys.au3>.

User Defined Function | Description
_WinAPI_EnumPageFiles | Retrieves information for each installed pagefile in the system
_WinAPI_GetCurrentHwProfile | Retrieves information about the current hardware profile for the local computer
_WinAPI_GetHandleInformation | Retrieves certain properties of an object handle
_WinAPI_GetPerformanceInfo | Retrieves the performance information
_WinAPI_GetProcessShutdownParameters | Retrieves the shutdown parameters for the currently calling process
_WinAPI_GetStartupInfo | Retrieves the contents of the STARTUPINFO structure that was specified when the calling process was created
_WinAPI_GetSystemInfo | Retrieves information about the current system
_WinAPI_GetSystemTimes | Retrieves system timing information
_WinAPI_GetSystemWow64Directory | Retrieves the path of the system directory used by WOW64
_WinAPI_GetTickCount | Retrieves the number of milliseconds that have elapsed since the system was started
_WinAPI_GetTickCount64 | Retrieves the number of milliseconds that have elapsed since the system was started
_WinAPI_GetVersion | Retrieves version of the current operating system
_WinAPI_GetVersionEx | Retrieves information about the current operating system
_WinAPI_IsProcessorFeaturePresent | Determines whether the specified processor feature is supported by the current computer
_WinAPI_QueryPerformanceCounter | Retrieves the current value of the high-resolution performance counter
_WinAPI_QueryPerformanceFrequency | Retrieves the frequency of the high-resolution performance counter
_WinAPI_SetProcessShutdownParameters | Sets a shutdown order for a process relative to the other processes in the system


Function _WinAPI_EnumPageFiles

Function Reference

_WinAPI_EnumPageFiles

Retrieves information for each installed pagefile in the system

#include <WinAPISys.au3>
_WinAPI_EnumPageFiles ( )

Return Value

Success: | The 2D array containing pagefile's information. [0][0] - Number of rows in array (n) [0][i] - Unused [n][0] - The path to pagefile. [n][1] - The total size of the pagefile, in bytes. [n][2] - The current pagefile usage, in bytes. [n][3] - The peak pagefile usage, in bytes.
Failure: | Sets the @error flag to non-zero.

See Also

Search EnumPageFiles in MSDN Library.

Example

#include <Array.au3>
#include <WinAPISys.au3>

Local $aData = _WinAPI_EnumPageFiles()

_ArrayDisplay($aData, '_WinAPI_EnumPageFiles')


Function _WinAPI_GetCurrentHwProfile

Function Reference

_WinAPI_GetCurrentHwProfile

Retrieves information about the current hardware profile for the local computer

#include <WinAPISys.au3>
_WinAPI_GetCurrentHwProfile ( )

Return Value

Success: | The array that contains the following information: [0] - The reported docking state of the computer (DOCKINFO_*). [1] - The globally unique identifier (GUID) string for the current hardware profile. [2] - The display name for the current hardware profile.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetCurrentHwProfile in MSDN Library.

Example

#include <WinAPISys.au3>

Local $aData = _WinAPI_GetCurrentHwProfile()
If IsArray($aData) Then
    ConsoleWrite('State: ' & $aData[0] & @CRLF)
    ConsoleWrite('GUID:  ' & $aData[1] & @CRLF)
    ConsoleWrite('Name:  ' & $aData[2] & @CRLF)
EndIf


Function _WinAPI_GetHandleInformation

Function Reference

_WinAPI_GetHandleInformation

Retrieves certain properties of an object handle

#include <WinAPISys.au3>
_WinAPI_GetHandleInformation ( $hObject )

Parameters

$hObject Handle to an object whose information is to be retrieved.

Return Value

Success: | The value that specifies the properties of the object handle ($HANDLE_FLAG_*).
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetHandleInformation in MSDN Library.


Function _WinAPI_GetPerformanceInfo

Function Reference

_WinAPI_GetPerformanceInfo

Retrieves the performance information

#include <WinAPISys.au3>
_WinAPI_GetPerformanceInfo ( )

Return Value

Success: | The array containing the following information: [0] - The memory that currently committed by the system, in bytes. [1] - The current maximum memory that can be committed by the system without extending the paging file(s), in bytes. [2] - The maximum memory that were simultaneously in the committed state since the last system reboot, in bytes. [3] - The amount of actual physical memory, in bytes. [4] - The amount of physical memory currently available, in bytes. [5] - The amount of system cache memory, in bytes. [6] - The sum of the memory currently in the paged and nonpaged kernel pools, in bytes. [7] - The memory currently in the paged kernel pool, in bytes. [8] - The memory currently in the nonpaged kernel pool, in bytes. [9] - The size of a page, in bytes. [10] - The current number of open handles. [11] - The current number of processes. [12] - The current number of threads.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetPerformanceInfo in MSDN Library.

Example

#include <WinAPISys.au3>

Local $aData = _WinAPI_GetPerformanceInfo()

ConsoleWrite('Physical Memory (MB)' & @CRLF)
ConsoleWrite('--------------------' & @CRLF)
ConsoleWrite('Total:     ' & Floor($aData[3] / 1024 / 1024) & @CRLF)
ConsoleWrite('Available: ' & Floor($aData[4] / 1024 / 1024) & @CRLF)
ConsoleWrite('Cached:    ' & Floor($aData[5] / 1024 / 1024) & @CRLF)
ConsoleWrite('Free:      ' & Floor($aData[6] / 1024 / 1024) & @CRLF)

ConsoleWrite(@CRLF)

ConsoleWrite('Kernel Memory (MB)' & @CRLF)
ConsoleWrite('--------------------' & @CRLF)
ConsoleWrite('Paged:     ' & Floor($aData[7] / 1024 / 1024) & @CRLF)
ConsoleWrite('Nonpaged:  ' & Floor($aData[8] / 1024 / 1024) & @CRLF)

ConsoleWrite(@CRLF)

ConsoleWrite('System' & @CRLF)
ConsoleWrite('--------------------' & @CRLF)
ConsoleWrite('Handles:   ' & $aData[10] & @CRLF)
ConsoleWrite('Processes: ' & $aData[11] & @CRLF)
ConsoleWrite('Threads:   ' & $aData[12] & @CRLF)


Function _WinAPI_GetProcessShutdownParameters

Function Reference

_WinAPI_GetProcessShutdownParameters

Retrieves the shutdown parameters for the currently calling process

#include <WinAPISys.au3>
_WinAPI_GetProcessShutdownParameters ( )

Return Value

Success: | The shutdown priority level (see _WinAPI_SetProcessShutdownParameters()). If @extended flag is set, a retry dialog box for the user will be display.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Related

_WinAPI_SetProcessShutdownParameters

See Also

Search GetProcessShutdownParameters in MSDN Library.


Function _WinAPI_GetStartupInfo

Function Reference

_WinAPI_GetStartupInfo

Retrieves the contents of the STARTUPINFO structure that was specified when the calling process was created

#include <WinAPISys.au3>
_WinAPI_GetStartupInfo ( )

Return Value

Returns an $tagSTARTUPINFO structure that contains the startup information.

See Also

Search GetStartupInfo in MSDN Library.


Function _WinAPI_GetSystemInfo

Function Reference

_WinAPI_GetSystemInfo

Retrieves information about the current system

#include <WinAPISys.au3>
_WinAPI_GetSystemInfo ( )

Return Value

Returns the array containing the following information:
[0] - The processor architecture of the installed operating system ($PROCESSOR_ARCHITECTURE_*).
[1] - The page size and the granularity of page protection and commitment.
[2] - A pointer to the lowest memory address accessible to applications and dynamic-link libraries (DLLs).
[3] - A pointer to the highest memory address accessible to applications and DLLs.
[4] - A mask representing the set of processors configured into the system. Bit 0 is processor 0; bit 31 is processor 31.
[5] - The number of physical processors in the system.
[6] - An obsolete member that is retained for compatibility ($PROCESSOR_*).
[7] - The granularity for the starting address at which virtual memory can be allocated.
[8] - The architecture-dependent processor level.
[9] - The architecture-dependent processor revision (0x0000xxyy; xx - model; yy - stepping).

See Also

Search GetSystemInfo in MSDN Library.


Function _WinAPI_GetSystemTimes

Function Reference

_WinAPI_GetSystemTimes

Retrieves system timing information

#include <WinAPISys.au3>
_WinAPI_GetSystemTimes ( )

Return Value

Success: | The array that contains the following information: [0] - The time that the system has been idle. [1] - The time that the system has spent executing in kernel mode, in 100-nanosecond time units. [2] - The time that the system has spent executing in user mode, in 100-nanosecond time units.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

On a multiprocessor system, the _WinAPI_GetSystemTimes() returns a values are the sum of the designated times
across all processors.

See Also

Search GetSystemTimes in MSDN Library.


Function _WinAPI_GetSystemWow64Directory

Function Reference

_WinAPI_GetSystemWow64Directory

Retrieves the path of the system directory used by WOW64

#include <WinAPISys.au3>
_WinAPI_GetSystemWow64Directory ( )

Return Value

Success: | The path of the system directory. This path does not end with a backslash.
Failure: | Sets the @error flag to non-zero, @extended flag may contain last error code.

Remarks

the function always fails on 32-bit Windows, @extended is set to ERROR_CALL_NOT_IMPLEMENTED.

See Also

Search GetSystemWow64Directory in MSDN Library.


Function _WinAPI_GetTickCount

Function Reference

_WinAPI_GetTickCount

Retrieves the number of milliseconds that have elapsed since the system was started

#include <WinAPISys.au3>
_WinAPI_GetTickCount ( )

Return Value

Returns the number of milliseconds that have elapsed since the system was started.

Remarks

The time will wrap around to zero if the system is run continuously for 49.7 days. You should check for an
overflow condition when comparing times. To obtain the time elapsed since the computer was started, retrieve the
System Up Time counter in the performance data in the registry key HKEY_PERFORMANCE_DATA.

See Also

Search GetTickCount in MSDN Library.

Example

#include <WinAPIMisc.au3>
#include <WinAPIShellEx.au3>
#include <WinAPISys.au3>

ConsoleWrite(_WinAPI_StrFromTimeInterval(_WinAPI_GetTickCount()) & @CRLF)


Function _WinAPI_GetTickCount64

Function Reference

_WinAPI_GetTickCount64

Retrieves the number of milliseconds that have elapsed since the system was started

#include <WinAPISys.au3>
_WinAPI_GetTickCount64 ( )

Return Value

Returns the number of milliseconds that have elapsed since the system was started.

Remarks

This function requires Windows Vista or later.

See Also

Search GetTickCount64 in MSDN Library.


Function _WinAPI_GetVersion

Function Reference

_WinAPI_GetVersion

Retrieves version of the current operating system

#include <WinAPISys.au3>
_WinAPI_GetVersion ( )

Return Value

Returns The string containing the current OS version.

"6.3" - Windows 8.1
"6.2" - Windows 8 / Windows Server 2012
"6.1" - Windows 7 / Windows Server 2008 R2
"6.0" - Windows Vista / Windows Server 2008
"5.2" - Windows XP 64-bit Edition / Windows Server 2003 / Windows Server 2003 R2
"5.1" - Windows XP

Example

#include <WinAPISys.au3>

ConsoleWrite('Windows version: ' & _WinAPI_GetVersion() & @CRLF)


Function _WinAPI_GetVersionEx

Function Reference

_WinAPI_GetVersionEx

Retrieves information about the current operating system

#include <WinAPISys.au3>
_WinAPI_GetVersionEx ( )

Return Value

Success: | $tagOSVERSIONINFOEX structure that contains the information about the current operating system.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

When using the _WinAPI_GetVersionEx() function to determine whether your application is running on a particular
version of the operating system, check for the version numbers that are greater than or equal to the desired version
numbers. This ensures that the test succeeds for later versions of the operating system.

See Also

Search GetVersionEx in MSDN Library.


Function _WinAPI_IsProcessorFeaturePresent

Function Reference

_WinAPI_IsProcessorFeaturePresent

Determines whether the specified processor feature is supported by the current computer

#include <WinAPISys.au3>
_WinAPI_IsProcessorFeaturePresent ( $iFeature )

Parameters

$iFeature The processor feature to be tested. This parameter can be one of the $PF_* constants defined in APISysConstants.au3.

Return Value

True: | the feature is supported.
False: | the feature is not supported.

See Also

Search IsProcessorFeaturePresent in MSDN Library.


Function _WinAPI_QueryPerformanceCounter

Function Reference

_WinAPI_QueryPerformanceCounter

Retrieves the current value of the high-resolution performance counter

#include <WinAPISys.au3>
_WinAPI_QueryPerformanceCounter ( )

Return Value

Success: | The current performance-counter value, in counts.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search QueryPerformanceCounter in MSDN Library.


Function _WinAPI_QueryPerformanceFrequency

Function Reference

_WinAPI_QueryPerformanceFrequency

Retrieves the frequency of the high-resolution performance counter

#include <WinAPISys.au3>
_WinAPI_QueryPerformanceFrequency ( )

Return Value

Success: | The current performance-counter frequency, in counts per second.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search QueryPerformanceFrequency in MSDN Library.


Function _WinAPI_SetProcessShutdownParameters

Function Reference

_WinAPI_SetProcessShutdownParameters

Sets a shutdown order for a process relative to the other processes in the system

#include <WinAPISys.au3>
_WinAPI_SetProcessShutdownParameters ( $iLevel [, $bDialog = False] )

Parameters

$iLevel | The shutdown priority. The system shuts down processes from high $iLevel values to low. The highest and lowest shutdown priorities are reserved for system components. This parameter must be in the following range of values. 0x0000-0x00FF - System reserved last shutdown range. 0x0100-0x01FF - Application reserved last shutdown range. 0x0200-0x02FF - Application reserved "in between" shutdown range. 0x0300-0x03FF - Application reserved first shutdown range. 0x0400-0x04FF - System reserved first shutdown range. All processes start at shutdown level 0x0280.
$bDialog | [optional] Specifies whether display a retry dialog box for the user, valid values: True - Display a retry dialog box if process takes longer than the specified timeout to shutdown. False - Directly terminates the process (Default).

Return Value

Success: | True
Failure: | False

See Also

Search SetProcessShutdownParameters in MSDN Library.

Example

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 200, 200)
Local $idButton = GUICtrlCreateButton('', 73, 62, 54, 54, $BS_ICON)
GUICtrlSetImage(-1, @SystemDir & '\shell32.dll', 45)
GUICtrlSetTip(-1, 'Log off ' & @UserName)
Local $idCheck = GUICtrlCreateCheckbox('Block Windows shutdown', 10, 173, 144, 21)
GUIRegisterMsg($WM_QUERYENDSESSION, 'WM_QUERYENDSESSION')
GUISetState(@SW_SHOW)

; Set the highest shutdown priority for the current process to prevent closure the other processes.
_WinAPI_SetProcessShutdownParameters(0x03FF)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            Shutdown(0)
        Case $idCheck
            If GUICtrlRead($idCheck) = $GUI_CHECKED Then
                _WinAPI_ShutdownBlockReasonCreate($g_hForm, 'This application is blocking system shutdown because the saving critical data is in progress.')
            Else
                _WinAPI_ShutdownBlockReasonDestroy($g_hForm)
            EndIf
    EndSwitch
WEnd

Func WM_QUERYENDSESSION($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam

    Switch $hWnd
        Case $g_hForm
            If _WinAPI_ShutdownBlockReasonQuery($g_hForm) Then
                Return 0
            EndIf
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_QUERYENDSESSION


User Defined Functions

UserInteraction user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPISys.au3>.

User Defined Function | Description
_WinAPI_ActivateKeyboardLayout | Sets the input locale identifier for the calling thread or the current process
_WinAPI_DefRawInputProc | Calls the default raw input procedure to process the raw input messages that an application does not process
_WinAPI_EnumRawInputDevices | Enumerates the raw input devices attached to the system
_WinAPI_GetActiveWindow | Retrieves the window handle to the active window attached to the calling process's message queue
_WinAPI_GetIdleTime | Retrieves the time that has elapsed since the last input
_WinAPI_GetKeyboardLayout | Retrieves the active input locale identifier for the specified window
_WinAPI_GetKeyboardLayoutList | Retrieves the all input locale identifiers corresponding to the current set of input locales in the system
_WinAPI_GetKeyboardState | Copies the status of the 256 virtual keys to the specified buffer
_WinAPI_GetKeyboardType | Retrieves information about the current keyboard
_WinAPI_GetKeyNameText | Retrieves a string that represents the name of a key
_WinAPI_GetKeyState | Retrieves the status of the specified virtual key
_WinAPI_GetRawInputBuffer | Performs a buffered read of the raw input data
_WinAPI_GetRawInputBufferLength | Retrieves the required buffer size to call the _WinAPI_GetRawInputBuffer() function
_WinAPI_GetRawInputData | Retrieves the raw input from the specified device
_WinAPI_GetRawInputDeviceInfo | Retrieves information about the raw input device
_WinAPI_GetRegisteredRawInputDevices | Retrieves the information about the raw input devices for the current application
_WinAPI_IsLoadKBLayout | Determines whether the specified input locale loaded into the system
_WinAPI_IsWindowEnabled | Determines whether the specified window is enabled for mouse and keyboard input
_WinAPI_Keybd_Event | Synthesizes a keystroke
_WinAPI_LoadKeyboardLayout | Loads a new input locale identifier into the system
_WinAPI_MapVirtualKey | Translates a virtual-key code into a scan code or character value, or translates a scan code into a virtual-key code
_WinAPI_RegisterHotKey | Defines a system-wide hot key
_WinAPI_RegisterRawInputDevices | Registers the devices that supply the raw input data
_WinAPI_SetActiveWindow | Activates the specified window
_WinAPI_SetKeyboardLayout | Sets an input locale identifier to the specified window
_WinAPI_SetKeyboardState | Copies a 256-byte array of keyboard key states into the calling process's keyboard input-state table
_WinAPI_TrackMouseEvent | Posts messages when the mouse pointer leaves a window or hovers over a window for a specified amount of time
_WinAPI_UnloadKeyboardLayout | Unloads an input locale identifier
_WinAPI_UnregisterHotKey | Frees a hot key previously registered by the calling thread


Function _WinAPI_ActivateKeyboardLayout

Function Reference

_WinAPI_ActivateKeyboardLayout

Sets the input locale identifier for the calling thread or the current process

#include <WinAPISys.au3>
_WinAPI_ActivateKeyboardLayout ( $hLocale [, $iFlag = 0] )

Parameters

$hLocale | The input locale identifier to be activated. This parameter must be either the handle to a keyboard layout or one of the following values: $HKL_NEXT $HKL_PREV
$iFlag | [optional] The flag that specifies how the input locale identifier is to be activated. This parameter can be one of the following values: $KLF_REORDER $KLF_RESET $KLF_SETFORPROCESS $KLF_SHIFTLOCK

Return Value

Success: | The previous input locale identifier.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search ActivateKeyboardLayout in MSDN Library.

Example

#include <APILocaleConstants.au3>
#include <APISysConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPILocale.au3>
#include <WinAPISys.au3>

GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 300, 200)
Local $idLabel = GUICtrlCreateLabel('', 10, 66, 280, 40, $SS_CENTER)
GUICtrlSetFont(-1, 12, 800, 0, 'Tahoma')
Local $idPrev = GUICtrlCreateButton('<', 82, 164, 60, 24)
Local $idNext = GUICtrlCreateButton('>', 158, 164, 60, 24)
GUISetState(@SW_SHOW)

Local $iUpdate = 1
While 1
    If $iUpdate Then
        GUICtrlSetData($idLabel, '0x' & StringRight(@KBLayout, 4) & @CRLF & _WinAPI_GetLocaleInfo(Number('0x' & @KBLayout), $LOCALE_SLANGUAGE))
        $iUpdate = 0
    EndIf

    Switch GUIGetMsg()
        Case -3
            ExitLoop
        Case $idNext
            _WinAPI_ActivateKeyboardLayout($HKL_NEXT)
            $iUpdate = 1
        Case $idPrev
            _WinAPI_ActivateKeyboardLayout($HKL_PREV)
            $iUpdate = 1
    EndSwitch
WEnd


Function _WinAPI_DefRawInputProc

Function Reference

_WinAPI_DefRawInputProc

Calls the default raw input procedure to process the raw input messages that an application does not process

#include <WinAPISys.au3>
_WinAPI_DefRawInputProc ( $paRawInput, $iInput )

Parameters

$paRawInput | A pointer to an array of $tagRAWINPUT structures that is returned by _WinAPI_GetRawInputBuffer().
$iInput | The number of structures in array.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the error code.

Related

_WinAPI_GetRawInputBuffer

See Also

Search DefRawInputProc in MSDN Library.


Function _WinAPI_EnumRawInputDevices

Function Reference

_WinAPI_EnumRawInputDevices

Enumerates the raw input devices attached to the system

#include <WinAPISys.au3>
_WinAPI_EnumRawInputDevices ( )

Return Value

Success: | The 2D array of the device handles and types. [0][0] - Number of rows in array (n) [0][1] - Unused [n][0] - A handle to the raw input device. [n][1] - A type of device ($RIM_*).
Failure: | Sets the @error flag to non-zero.

See Also

Search GetRawInputDeviceList in MSDN Library.

Example

#include <APISysConstants.au3>
#include <Array.au3>
#include <WinAPISys.au3>

Local $tText, $aData = _WinAPI_EnumRawInputDevices()

If IsArray($aData) Then
    ReDim $aData[$aData[0][0] + 1][3]
    $tText = DllStructCreate('wchar[256]')
    For $i = 1 To $aData[0][0]
        If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $tText, 256, $RIDI_DEVICENAME) Then
            $aData[$i][2] = DllStructGetData($tText, 1)
        Else
            $aData[$i][2] = ''
        EndIf
    Next

EndIf

_ArrayDisplay($aData, '_WinAPI_EnumRawInputDevices')


Function _WinAPI_GetActiveWindow

Function Reference

_WinAPI_GetActiveWindow

Retrieves the window handle to the active window attached to the calling process's message queue

#include <WinAPISys.au3>
_WinAPI_GetActiveWindow ( )

Return Value

Success: | Handle to the active window attached to the calling process's message queue.
Failure: | 0.

See Also

Search GetActiveWindow in MSDN Library.


Function _WinAPI_GetIdleTime

Function Reference

_WinAPI_GetIdleTime

Retrieves the time that has elapsed since the last input

#include <WinAPISys.au3>
_WinAPI_GetIdleTime ( )

Return Value

Success: | The elapsed time, in milliseconds.
Failure: | 0.

See Also

Search GetLastInputInfo in MSDN Library.

Example

#include <WinAPISys.au3>

For $i = 1 To 5
    ConsoleWrite('Idle time (ms): ' & _WinAPI_GetIdleTime() & @CRLF)
    Sleep(1000)
Next


Function _WinAPI_GetKeyboardLayout

Function Reference

_WinAPI_GetKeyboardLayout

Retrieves the active input locale identifier for the specified window

#include <WinAPISys.au3>
_WinAPI_GetKeyboardLayout ( $hWnd )

Parameters

$hWnd Handle to the window to retrieve the input locale identifier.

Return Value

Success: | The input locale identifier.
Failure: | 0.

See Also

Search GetKeyboardLayout in MSDN Library.


Function _WinAPI_GetKeyboardLayoutList

Function Reference

_WinAPI_GetKeyboardLayoutList

Retrieves the all input locale identifiers corresponding to the current set of input locales in the system

#include <WinAPISys.au3>
_WinAPI_GetKeyboardLayoutList ( )

Return Value

Success: | The array of input locale identifiers. The zeroth array element contains the number of identifiers.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetKeyboardLayoutList in MSDN Library.

Example

#include <APILocaleConstants.au3>
#include <Array.au3>
#include <WinAPILocale.au3>
#include <WinAPISys.au3>

Local $aData = _WinAPI_GetKeyboardLayoutList()
If IsArray($aData) Then
    For $i = 1 To $aData[0]
        $aData[$i] = '0x' & Hex($aData[$i]) & ' (' & _WinAPI_GetLocaleInfo(BitAND($aData[$i], 0xFFFF), $LOCALE_SENGLANGUAGE) & ')'
    Next
EndIf

_ArrayDisplay($aData, '_WinAPI_GetKeyboardLayoutList')


Function _WinAPI_GetKeyboardState

Function Reference

_WinAPI_GetKeyboardState

Copies the status of the 256 virtual keys to the specified buffer

#include <WinAPISys.au3>
_WinAPI_GetKeyboardState ( )

Return Value

Success: | The structure of "byte[256]" that receives the status data for each virtual key.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

An application can call this function to retrieve the current status of all the virtual keys. The status changes
as a process removes keyboard messages from its message queue. The status does not change as keyboard messages are
posted to the process's message queue, nor does it change as keyboard messages are posted to or retrieved from
message queues of other processes.

When the function returns, each member of the array contains status data for a virtual key. If the high-order
bit is 1, the key is down; otherwise, it is up. If the key is a toggle key, for example CAPS LOCK, then the
low-order bit is 1 when the key is toggled and is 0 if the key is untoggled. The low-order bit is meaningless for
non-toggle keys. A toggle key is said to be toggled when it is turned on. A toggle key's indicator light (if any)
on the keyboard will be on when the key is toggled, and off when the key is untoggled.

To retrieve status information for an individual key, use the _WinAPI_GetKeyState() function. To retrieve the
current state for an individual key regardless of whether the corresponding keyboard message has been retrieved
from the message queue, use the _WinAPI_GetAsyncKeyState() function.

Related

_WinAPI_GetAsyncKeyState, _WinAPI_GetKeyState

See Also

Search GetKeyboardState in MSDN Library.


Function _WinAPI_GetKeyboardType

Function Reference

_WinAPI_GetKeyboardType

Retrieves information about the current keyboard

#include <WinAPISys.au3>
_WinAPI_GetKeyboardType ( $iType )

Parameters

$iType The type of keyboard information to be retrieved, valid values:
0 - Keyboard type.
1 - Keyboard subtype (original equipment manufacturer (OEM)-dependent value).
2 - The number of function keys on the keyboard.

Return Value

Success: | The value that specifies the requested information. If $iType is 0, return value may be one of the following values. 1 - IBM PC/XT or compatible (83-key) keyboard. 2 - Olivetti "ICO" (102-key) keyboard. 3 - IBM PC/AT (84-key) or similar keyboard. 4 - IBM enhanced (101- or 102-key) keyboard. 5 - Nokia 1050 and similar keyboards. 6 - Nokia 9140 and similar keyboards. 7 - Japanese keyboard. Zero is a valid return value when $iType is one (keyboard subtype).
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

When a single USB keyboard is connected to the computer, this function returns the code 81.

See Also

Search GetKeyboardType in MSDN Library.

Example

#include <WinAPISys.au3>

Local $sText
Local $iData = _WinAPI_GetKeyboardType(0)
Switch $iData
    Case 1
        $sText = 'IBM PC/XT or compatible (83-key) keyboard'
    Case 2
        $sText = 'Olivetti "ICO" (102-key) keyboard'
    Case 3
        $sText = 'IBM PC/AT (84-key) or similar keyboard'
    Case 4
        $sText = 'IBM enhanced (101- or 102-key) keyboard'
    Case 5
        $sText = 'Nokia 1050 and similar keyboards'
    Case 6
        $sText = 'Nokia 9140 and similar keyboards'
    Case 7
        $sText = 'Japanese keyboard'
EndSwitch

ConsoleWrite('Type   : ' & $sText & @CRLF)
ConsoleWrite('Subtype: ' & _WinAPI_GetKeyboardType(1) & @CRLF)
ConsoleWrite('F-keys : ' & _WinAPI_GetKeyboardType(2) & @CRLF)


Function _WinAPI_GetKeyNameText

Function Reference

_WinAPI_GetKeyNameText

Retrieves a string that represents the name of a key

#include <WinAPISys.au3>
_WinAPI_GetKeyNameText ( $lParam )

Parameters

$lParam Specifies the second parameter of the keyboard message (such as WM_KEYDOWN) to be processed.

Return Value

Success: | String containing the name of the key.
Failure: | Empty string, call _WinAPI_GetLastError() to get extended error information.

Remarks

The format of the key-name string depends on the current keyboard layout. The keyboard driver maintains a list
of names in the form of character strings for keys with names longer than a single character. The key name
is translated according to the layout of the currently installed keyboard, thus the function may give different
results for different input locales. The name of a character key is the character itself. The names of dead
keys are spelled out in full.

See Also

Search GetKeyNameText in MSDN Library.

Example

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

GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'))
GUIRegisterMsg($WM_KEYDOWN, 'WM_KEYDOWN')
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_KEYDOWN($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam

    ConsoleWrite(_WinAPI_GetKeyNameText($lParam) & @CRLF)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_KEYDOWN


Function _WinAPI_GetKeyState

Function Reference

_WinAPI_GetKeyState

Retrieves the status of the specified virtual key

#include <WinAPISys.au3>
_WinAPI_GetKeyState ( $vKey )

Parameters

$vKey Specifies a virtual key ($VK_*). If the desired virtual key is a letter or digit (A through Z,
a through z, or 0 through 9).

Return Value

Returns the value that specifies the status of the specified virtual key. If the high-order bit is 1, the key is
down; otherwise, it is up. If the low-order bit is 1, the key is toggled. A key, such as the
CAPS LOCK key, is toggled if it is turned on. The key is off and untoggled if the low-order bit is 0.
A toggle key's indicator light (if any) on the keyboard will be on when the key is toggled, and off
when the key is untoggled.

Remarks

The key status returned from this function changes as a process reads key messages from its message queue.
The status does not reflect the interrupt-level state associated with the hardware. Use the _WinAPI_GetAsyncKeyState()
function to retrieve that information.

Related

_WinAPI_GetAsyncKeyState

See Also

Search GetKeyState in MSDN Library.

Example

#include <WinAPISys.au3>
#include <WinAPIvkeysConstants.au3>

Local $aOnOff[2] = ['OFF', 'ON']

ConsoleWrite('NumLock: ' & $aOnOff[BitAND(_WinAPI_GetKeyState($VK_NUMLOCK), 1)] & @CRLF)
Sleep(1500)
Send('{NUMLOCK toggle}')
ConsoleWrite('NumLock: ' & $aOnOff[BitAND(_WinAPI_GetKeyState($VK_NUMLOCK), 1)] & @CRLF)
Sleep(1500)
Send('{NUMLOCK toggle}')
ConsoleWrite('NumLock: ' & $aOnOff[BitAND(_WinAPI_GetKeyState($VK_NUMLOCK), 1)] & @CRLF)


Function _WinAPI_GetRawInputBuffer

Function Reference

_WinAPI_GetRawInputBuffer

Performs a buffered read of the raw input data

#include <WinAPISys.au3>
_WinAPI_GetRawInputBuffer ( $pBuffer, $iLength )

Parameters

$pBuffer | A pointer to the buffer to receive an array of $tagRAWINPUT structures containing the raw input data.
$iLength | The size of the buffer, in bytes.

Return Value

Success: | The number of $tagRAWINPUT structures written to the buffer.
Failure: | 0 and sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

To obtain the minimum required buffer size to call this function, use _WinAPI_GetRawInputBufferLength().

To ensure the _WinAPI_GetRawInputBuffer() function behaves properly on WOW64,
you must align the $tagRAWINPUT structure by 8 bytes.

Related

_WinAPI_GetRawInputBufferLength

See Also

Search GetRawInputBuffer in MSDN Library.


Function _WinAPI_GetRawInputBufferLength

Function Reference

_WinAPI_GetRawInputBufferLength

Retrieves the required buffer size to call the _WinAPI_GetRawInputBuffer() function

#include <WinAPISys.au3>
_WinAPI_GetRawInputBufferLength ( )

Return Value

Success: | The minimum required buffer size, in bytes.
Failure: | 0 and sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetRawInputBuffer in MSDN Library.


Function _WinAPI_GetRawInputData

Function Reference

_WinAPI_GetRawInputData

Retrieves the raw input from the specified device

#include <WinAPISys.au3>
_WinAPI_GetRawInputData ( $hRawInput, $pBuffer, $iLength, $iFlag )

Parameters

$hRawInput | A handle to the $tagRAWINPUT structure (not a pointer). This comes from the "lParam" in WM_INPUT.
$pBuffer | A pointer to the buffer to receive a data that comes from the $tagRAWINPUT structure. This depends on the value of a command flag (see below). If this parameter is 0, the function returns the required size of the buffer, in bytes.
$iLength | The size of the buffer, in bytes.
$iFlag | The command flag. This parameter can be one of the following values. $RID_HEADER $RID_INPUT

Return Value

Success: | The number of bytes required or copied into the buffer.
Failure: | 0 and sets the @error flag to non-zero.

Related

_WinAPI_RegisterRawInputDevices

See Also

Search GetRawInputData in MSDN Library.

Example

#include <APISysConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIMisc.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

Opt('TrayAutoPause', 0)

Global $g_ahPart[9]
; Load bitmaps (Mice*.bmp) that are required to display picture
For $i = 0 To 6
    $g_ahPart[$i] = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Mice' & $i & '.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Next

; Copy some bitmaps for proper "Mice" drawing
$g_ahPart[7] = _WinAPI_CopyBitmap($g_ahPart[0])
$g_ahPart[8] = _WinAPI_CopyBitmap($g_ahPart[6])

; Create GUI
Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 160, 212, @DesktopWidth - 179, @DesktopHeight - 283, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU), $WS_EX_TOPMOST)
Global $g_idPic = GUICtrlCreatePic('', 0, 0, 160, 160)
GUICtrlCreateGraphic(0, 160, 160, 1)
GUICtrlSetBkColor(-1, 0xDFDFDF)
GUICtrlCreateLabel('X:', 10, 170, 12, 14)
Global $g_aidLabel[3]
$g_aidLabel[0] = GUICtrlCreateLabel('', 23, 170, 30, 14)
GUICtrlCreateLabel('Y:', 10, 190, 12, 14)
$g_aidLabel[1] = GUICtrlCreateLabel('', 23, 190, 30, 14)
GUICtrlCreateLabel('Wheel:', 80, 170, 36, 14)
$g_aidLabel[2] = GUICtrlCreateLabel('', 117, 170, 30, 14)

_SetBitmap($g_idPic, $g_ahPart[0])

; To obtain the values of "UsagePage" and "Usage" members of this structure read HID Usage Tables documentation
; http://www.usb.org/developers/devclass_docs/HID1_11.pdf
Local $tRID = DllStructCreate($tagRAWINPUTDEVICE)
DllStructSetData($tRID, 'UsagePage', 0x01) ; Generic Desktop Controls
DllStructSetData($tRID, 'Usage', 0x02) ; Mouse
DllStructSetData($tRID, 'Flags', $RIDEV_INPUTSINK)
DllStructSetData($tRID, 'hTarget', $g_hForm)

; Register HID input to obtain row input from mice
_WinAPI_RegisterRawInputDevices($tRID)

; Register WM_INPUT message
GUIRegisterMsg($WM_INPUT, 'WM_INPUT')

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _SetBitmap($hWnd, $hBitmap, $bUpdate = False)
    If Not IsHWnd($hWnd) Then
        $hWnd = GUICtrlGetHandle($hWnd)
        If Not $hWnd Then
            Return 0
        EndIf
    EndIf

    $hBitmap = _WinAPI_CopyBitmap($hBitmap)
    If @error Then
        Return 0
    EndIf
    Local $hPrev = _SendMessage($hWnd, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)
    If $hPrev Then
        _WinAPI_DeleteObject($hPrev)
    EndIf
    $hPrev = _SendMessage($hWnd, $STM_GETIMAGE)
    If $hPrev <> $hBitmap Then
        _WinAPI_DeleteObject($hBitmap)
    EndIf
    If $bUpdate Then
        _WinAPI_UpdateWindow($hWnd)
    EndIf
    Return 1
EndFunc   ;==>_SetBitmap

Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam

    Switch $hWnd
        Case $g_hForm
            Local $tRIM = DllStructCreate($tagRAWINPUTMOUSE)
            If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_INPUT) Then
                Local $iFlags = DllStructGetData($tRIM, 'Flags')
                Select
                    Case BitAND($iFlags, $MOUSE_ATTRIBUTES_CHANGED)
                        ; You need to query the mouse attributes and update bitmap...
                    Case Else

                EndSelect
                $iFlags = DllStructGetData($tRIM, 'ButtonFlags')
                If BitAND($iFlags, BitOR($RI_MOUSE_MIDDLE_BUTTON_DOWN, $RI_MOUSE_MIDDLE_BUTTON_UP, $RI_MOUSE_LEFT_BUTTON_DOWN, $RI_MOUSE_LEFT_BUTTON_UP, $RI_MOUSE_RIGHT_BUTTON_DOWN, $RI_MOUSE_RIGHT_BUTTON_UP)) Then
                    Local $hDC = _WinAPI_CreateCompatibleDC(0)
                    Local $hSv = _WinAPI_SelectObject($hDC, $g_ahPart[8])
                    Select
                        Case BitAND($iFlags, $RI_MOUSE_MIDDLE_BUTTON_DOWN)
                            _WinAPI_DrawBitmap($hDC, 0, 0, $g_ahPart[5])
                        Case BitAND($iFlags, $RI_MOUSE_MIDDLE_BUTTON_UP)
                            _WinAPI_DrawBitmap($hDC, 0, 0, $g_ahPart[6])
                    EndSelect
                    _WinAPI_SelectObject($hDC, $g_ahPart[7])
                    Select
                        Case BitAND($iFlags, $RI_MOUSE_LEFT_BUTTON_DOWN)
                            _WinAPI_DrawBitmap($hDC, 39, 25, $g_ahPart[1])
                        Case BitAND($iFlags, $RI_MOUSE_LEFT_BUTTON_UP)
                            _WinAPI_DrawBitmap($hDC, 39, 25, $g_ahPart[2])
                        Case BitAND($iFlags, $RI_MOUSE_RIGHT_BUTTON_DOWN)
                            _WinAPI_DrawBitmap($hDC, 81, 25, $g_ahPart[3])
                        Case BitAND($iFlags, $RI_MOUSE_RIGHT_BUTTON_UP)
                            _WinAPI_DrawBitmap($hDC, 81, 25, $g_ahPart[4])
                    EndSelect
                    _WinAPI_DrawBitmap($hDC, 74, 33, $g_ahPart[8])
                    _WinAPI_SelectObject($hDC, $hSv)
                    _WinAPI_DeleteDC($hDC)
                    _SetBitmap($g_idPic, $g_ahPart[7])
                EndIf
                Local $aData = MouseGetPos()
                For $i = 0 To 1
                    If StringCompare(GUICtrlRead($g_aidLabel[$i]), $aData[$i]) Then
                        GUICtrlSetData($g_aidLabel[$i], $aData[$i])
                    EndIf
                Next
                If BitAND($iFlags, $RI_MOUSE_WHEEL) Then
                    $aData = _WinAPI_WordToShort(DllStructGetData($tRIM, 'ButtonData'))
                    If $aData > 0 Then
                        $aData = 'Up'
                    Else
                        $aData = 'Down'
                    EndIf
                Else
                    $aData = ''
                EndIf
                If StringCompare(GUICtrlRead($g_aidLabel[2]), $aData) Then
                    GUICtrlSetData($g_aidLabel[2], $aData)
                EndIf
            EndIf
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_INPUT


Function _WinAPI_GetRawInputDeviceInfo

Function Reference

_WinAPI_GetRawInputDeviceInfo

Retrieves information about the raw input device

#include <WinAPISys.au3>
_WinAPI_GetRawInputDeviceInfo ( $hDevice, $pBuffer, $iLength, $iFlag )

Parameters

$hDevice | A handle to the raw input device. This comes from the "lParam" of the WM_INPUT message, from the "$hDevice" member of the $tagRAWINPUTHEADER structure, or from the _WinAPI_EnumRawInputDevices() function.
$pBuffer | A pointer to the buffer that receives an information specified by a command flag (see below). If this parameter is 0, the function returns the required size of the buffer, in bytes or characters.
$iLength | The size of the buffer, in bytes. For $RIDI_DEVICENAME only, this value is the character count, including null-terminating character (not the byte count).
$iFlag | The command flag that specifies what information will be returned. This parameter can be one of the following values. $RIDI_DEVICENAME $RIDI_DEVICEINFO $RIDI_PREPARSEDDATA

Return Value

Success: | The number of bytes or characters required or copied into the buffer.
Failure: | 0 and sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetRawInputDeviceInfo in MSDN Library.

Example

#include <APISysConstants.au3>
#include <Array.au3>
#include <WinAPISys.au3>

Local $tText, $aData = _WinAPI_EnumRawInputDevices()

If IsArray($aData) Then
    ReDim $aData[$aData[0][0] + 1][3]
    $tText = DllStructCreate('wchar[256]')
    For $i = 1 To $aData[0][0]
        If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $tText, 256, $RIDI_DEVICENAME) Then
            $aData[$i][2] = DllStructGetData($tText, 1)
        Else
            $aData[$i][2] = ''
        EndIf
    Next

EndIf

_ArrayDisplay($aData, '_WinAPI_EnumRawInputDevices')


Function _WinAPI_GetRegisteredRawInputDevices

Function Reference

_WinAPI_GetRegisteredRawInputDevices

Retrieves the information about the raw input devices for the current application

#include <WinAPISys.au3>
_WinAPI_GetRegisteredRawInputDevices ( $pBuffer, $iLength )

Parameters

$pBuffer | A pointer to the buffer to receive an array of $tagRAWINPUTDEVICE structures for the application. If this parameter is 0, the function returns the required buffer size, in bytes.
$iLength | The size of the buffer, in bytes.

Return Value

Success: | the number of $tagRAWINPUTDEVICE structures written to the buffer.
Failure: | 0 and sets the @error flag to non-zero, @extended flag contains the last error code.

See Also

Search GetRegisteredRawInputDevices in MSDN Library.


Function _WinAPI_IsLoadKBLayout

Function Reference

_WinAPI_IsLoadKBLayout

Determines whether the specified input locale loaded into the system

#include <WinAPISys.au3>
_WinAPI_IsLoadKBLayout ( $iLanguage )

Parameters

$iLanguage The input locale identifier to check.

Return Value

True: | Input locale is loaded.
False: | Input locale is not loaded.


Function _WinAPI_IsWindowEnabled

Function Reference

_WinAPI_IsWindowEnabled

Determines whether the specified window is enabled for mouse and keyboard input

#include <WinAPISys.au3>
_WinAPI_IsWindowEnabled ( $hWnd )

Parameters

$hWnd Handle to the window to test.

Return Value

True: | the window is enabled.
False: | the window is not enabled.

Remarks

A child window receives input only if it is both enabled and visible.

See Also

Search IsWindowEnabled in MSDN Library.


Function _WinAPI_Keybd_Event

Function Reference

_WinAPI_Keybd_Event

Synthesizes a keystroke

#include <WinAPISys.au3>
_WinAPI_Keybd_Event ( $vKey, $iFlags [, $iScanCode = 0 [, $iExtraInfo = 0]] )

Parameters

$vKey The virtual-key code ($VK_*). The code must be a value in the range 1 to 254.

0x01 - Left mouse button
0x02 - Right mouse button
0x03 - Control-break processing
0x04 - Middle mouse button (three-button mouse)
0x05 - X1 mouse button
0x06 - X2 mouse button

0x08 - BACKSPACE key
0x09 - TAB key

0x0C - CLEAR key
0x0D - ENTER key

0x10 - SHIFT key
0x11 - CTRL key
0x12 - ALT key
0x13 - PAUSE key
0x14 - CAPS LOCK key

0x1B - ESC key

0x20 - SPACEBAR key
0x21 - PAGE UP key
0x22 - PAGE DOWN key
0x23 - END key
0x24 - HOME key
0x25 - LEFT ARROW key
0x26 - UP ARROW key
0x27 - RIGHT ARROW key
0x28 - DOWN ARROW key
0x29 - SELECT key
0x2A - PRINT key
0x2B - EXECUTE key
0x2C - PRINT SCREEN key
0x2D - INS key
0x2E - DEL key
0x2F - HELP key
0x30 - 0x39 - (0 - 9) key

0x41 - 0x5A - (A - Z) key
0x5B - Left Windows key
0x5C - Right Windows key
0x5D - Applications key

0x5F - Computer Sleep key
0x60 - 0x69 - Numeric keypad (0 - 9) key
0x6A - Multiply key
0x6B - Add key
0x6C - Separator key
0x6D - Subtract key
0x6E - Decimal key
0x6F - Divide key
0x70 - 0x87 - (F1 - F24) key

0x90 - NUM LOCK key
0x91 - SCROLL LOCK key

0xA0 - Left SHIFT key
0xA1 - Right SHIFT key
0xA2 - Left CONTROL key
0xA3 - Right CONTROL key
0xA4 - Left MENU key
0xA5 - Right MENU key
0xA6 - Browser Back key
0xA7 - Browser Forward key
0xA8 - Browser Refresh key
0xA9 - Browser Stop key
0xAA - Browser Search key
0xAB - Browser Favorites key
0xAC - Browser Start and Home key
0xAD - Volume Mute key
0xAE - Volume Down key
0xAF - Volume Up key
0xB0 - Next Track key
0xB1 - Previous Track key
0xB2 - Stop Media key
0xB3 - Play/Pause Media key
0xB4 - Start Mail key
0xB5 - Select Media key
0xB6 - Start Application 1 key
0xB7 - Start Application 2 key

0xBA - ';:' key
0xBB - '+' key
0xBC - ',' key
0xBD - '-' key
0xBE - '.' key
0xBF - '/?' key
0xC0 - '`~' key

0xDB - '[{' key
0xDC - '\|' key
0xDD - ']}' key
0xDE - 'single-quote/double-quote' key

0xE2 - Either the angle bracket key or the backslash key on the RT 102-key keyboard

0xE7 - Used to pass Unicode characters as if they were keystrokes

0xF6 - Attn key
0xF7 - CrSel key
0xF8 - ExSel key
0xF9 - Erase EOF key
0xFA - Play key
0xFB - Zoom key

0xFD - PA1 key
0xFE - Clear key
$iFlags This parameter can be one or more of the following values.
$KEYEVENTF_EXTENDEDKEY
$KEYEVENTF_KEYUP
$iScanCode | [optional] The hardware scan code for the key. Default is 0.
$iExtraInfo | [optional] The additional value associated with the key stroke. Default is 0.

Return Value

None.

See Also

Search keybd_event in MSDN Library.


Function _WinAPI_LoadKeyboardLayout

Function Reference

_WinAPI_LoadKeyboardLayout

Loads a new input locale identifier into the system

#include <WinAPISys.au3>
_WinAPI_LoadKeyboardLayout ( $iLanguage [, $iFlag = 0] )

Parameters

$iLanguage | The input locale identifier to load.
$iFlag | [optional] The flag that specifies how the input locale identifier is to be loaded. This parameter can be one of the following values. $KLF_ACTIVATE $KLF_NOTELLSHELL $KLF_REORDER $KLF_REPLACELANG $KLF_SUBSTITUTE_OK $KLF_SETFORPROCESS

Return Value

Success: | The input locale identifier to the locale matched with the requested name.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search LoadKeyboardLayout in MSDN Library.


Function _WinAPI_MapVirtualKey

Function Reference

_WinAPI_MapVirtualKey

Translates a virtual-key code into a scan code or character value, or translates a scan code into a virtual-key code

#include <WinAPISys.au3>
_WinAPI_MapVirtualKey ( $iCode, $iType [, $hLocale = 0] )

Parameters

$iCode | The virtual key code or scan code for a key. How this value is interpreted depends on the $iType parameter.
$iType | The translation to be performed. This value depends on the value of the $iCode parameter and can be one of the following values. $MAPVK_VK_TO_CHAR $MAPVK_VK_TO_VSC $MAPVK_VK_TO_VSC_EX $MAPVK_VSC_TO_VK $MAPVK_VSC_TO_VK_EX
$hLocale | [optional] The input locale identifier to use for translating the specified code.

Return Value

Success: | A scan code, a virtual-key code, or a character value, depending on the above parameters.
Failure: | 0.

Remarks

An application can use _WinAPI_MapVirtualKey() to translate scan codes to the virtual-key code constants
$VK_SHIFT, $VK_CONTROL, and $VK_MENU, and vice versa. These translations do not distinguish between the left and
right instances of the SHIFT, CTRL, or ALT keys.

An application can get the scan code corresponding to the left or right instance of one of these keys by calling
_WinAPI_MapVirtualKey() with $iCode set to one of the following virtual-key code constants.
$VK_LSHIFT
$VK_RSHIFT
$VK_LCONTROL
$VK_RCONTROL
$VK_LMENU
$VK_RMENU

See Also

Search MapVirtualKey in MSDN Library.

Example

#include <APISysConstants.au3>
#include <WinAPISys.au3>
#include <WinAPIvkeysConstants.au3>

ConsoleWrite('Virtual-key code: 0x' & Hex($VK_A) & @CRLF)
ConsoleWrite('Scan code: 0x' & Hex(_WinAPI_MapVirtualKey($VK_A, $MAPVK_VK_TO_VSC)) & @CRLF)


Function _WinAPI_RegisterHotKey

Function Reference

_WinAPI_RegisterHotKey

Defines a system-wide hot key

#include <WinAPISys.au3>
_WinAPI_RegisterHotKey ( $hWnd, $iID, $iModifiers, $vKey )

Parameters

$hWnd | Handle to the window that will receive WM_HOTKEY messages generated by the hot key. If this parameter is 0, WM_HOTKEY messages are posted to the message queue of the calling thread and must be processed in the message loop.
$iID | Specifies the identifier of the hot key. An application must specify an id value in the range 0x0000 through 0xBFFF.
$iModifiers | Specifies keys that must be pressed in combination with the key specified by the $vKey parameter in order to generate the WM_HOTKEY message. The $iModifiers parameter can be a combination of the following values. $MOD_ALT $MOD_CONTROL $MOD_SHIFT $MOD_WIN Windows 7 or later $MOD_NOREPEAT
$vKey | Specifies the virtual-key code of the hot key ($VK_*).

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

When a key is pressed, the system looks for a match against all hot keys. Upon finding a match, the system posts
the WM_HOTKEY message to the message queue of the window with which the hot key is associated. If the hot key is
not associated with a window, then the WM_HOTKEY message is posted to the thread associated with the hot key.

_WinAPI_RegisterHotKey() fails if the keystrokes specified for the hot key have already been registered by
another hot key.

In Windows XP, if a hot key already exists with the same $hWnd and $iID parameters,
it is replaced by the new hot key.

In Windows Vista and subsequent versions of Windows, if a hot key already exists with the same $hWnd and $iID
parameters, it is maintained along with the new hot key. In these versions of Windows, the application must
explicitly call _WinAPI_UnregisterHotKey() to unregister the old hot key.

Related

_WinAPI_UnregisterHotKey

See Also

Search RegisterHotKey in MSDN Library.

Example

#include <APISysConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

Opt('TrayAutoPause', 0)

OnAutoItExitRegister('OnAutoItExit')

Local $hWnd = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'))
GUIRegisterMsg($WM_HOTKEY, 'WM_HOTKEY')

; Set ALT-D
_WinAPI_RegisterHotKey($hWnd, 0x0144, $MOD_ALT, 0x44)
; Set ESC
_WinAPI_RegisterHotKey($hWnd, 0x011B, 0, 0x1B)

While 1
    Sleep(1000)
WEnd

Func WM_HOTKEY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam

    Switch _WinAPI_HiWord($lParam)
        Case 0x44
            MsgBox($MB_SYSTEMMODAL, '', 'You pressed ALT-D')
        Case 0x1B
            MsgBox($MB_SYSTEMMODAL, '', 'You pressed ESC')
            Exit
    EndSwitch
EndFunc   ;==>WM_HOTKEY

Func OnAutoItExit()
    _WinAPI_UnregisterHotKey($hWnd, 0x0144)
    _WinAPI_UnregisterHotKey($hWnd, 0x011B)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_RegisterRawInputDevices

Function Reference

_WinAPI_RegisterRawInputDevices

Registers the devices that supply the raw input data

#include <WinAPISys.au3>
_WinAPI_RegisterRawInputDevices ( $paDevice [, $iCount = 1] )

Parameters

$paDevice | A pointer to an array of $tagRAWINPUTDEVICE structures that represent the devices that supply the raw input.
$iCount | [optional] The number of entries in the array. Default is 1.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

Remarks

To receive WM_INPUT messages, an application must first register the raw input devices using the _WinAPI_RegisterRawInputDevices().

To receive WM_INPUT_DEVICE_CHANGE messages, an application must specify the $RIDEV_DEVNOTIFY flag for each device
class that is specified by the "UsagePage" and "Usage" fields of the $tagRAWINPUTDEVICE structure.

Related

_WinAPI_GetRawInputData

See Also

Search RegisterRawInputDevices in MSDN Library.

Example

#include <APISysConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIMisc.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

Opt('TrayAutoPause', 0)

Global $g_ahPart[9]
; Load bitmaps (Mice*.bmp) that are required to display picture
For $i = 0 To 6
    $g_ahPart[$i] = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Mice' & $i & '.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Next

; Copy some bitmaps for proper "Mice" drawing
$g_ahPart[7] = _WinAPI_CopyBitmap($g_ahPart[0])
$g_ahPart[8] = _WinAPI_CopyBitmap($g_ahPart[6])

; Create GUI
Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 160, 212, @DesktopWidth - 179, @DesktopHeight - 283, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU), $WS_EX_TOPMOST)
Global $g_idPic = GUICtrlCreatePic('', 0, 0, 160, 160)
GUICtrlCreateGraphic(0, 160, 160, 1)
GUICtrlSetBkColor(-1, 0xDFDFDF)
GUICtrlCreateLabel('X:', 10, 170, 12, 14)
Global $g_aidLabel[3]
$g_aidLabel[0] = GUICtrlCreateLabel('', 23, 170, 30, 14)
GUICtrlCreateLabel('Y:', 10, 190, 12, 14)
$g_aidLabel[1] = GUICtrlCreateLabel('', 23, 190, 30, 14)
GUICtrlCreateLabel('Wheel:', 80, 170, 36, 14)
$g_aidLabel[2] = GUICtrlCreateLabel('', 117, 170, 30, 14)

_SetBitmap($g_idPic, $g_ahPart[0])

; To obtain the values of "UsagePage" and "Usage" members of this structure read HID Usage Tables documentation
; http://www.usb.org/developers/devclass_docs/HID1_11.pdf
Local $tRID = DllStructCreate($tagRAWINPUTDEVICE)
DllStructSetData($tRID, 'UsagePage', 0x01) ; Generic Desktop Controls
DllStructSetData($tRID, 'Usage', 0x02) ; Mouse
DllStructSetData($tRID, 'Flags', $RIDEV_INPUTSINK)
DllStructSetData($tRID, 'hTarget', $g_hForm)

; Register HID input to obtain row input from mice
_WinAPI_RegisterRawInputDevices($tRID)

; Register WM_INPUT message
GUIRegisterMsg($WM_INPUT, 'WM_INPUT')

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _SetBitmap($hWnd, $hBitmap, $bUpdate = False)
    If Not IsHWnd($hWnd) Then
        $hWnd = GUICtrlGetHandle($hWnd)
        If Not $hWnd Then
            Return 0
        EndIf
    EndIf

    $hBitmap = _WinAPI_CopyBitmap($hBitmap)
    If @error Then
        Return 0
    EndIf
    Local $hPrev = _SendMessage($hWnd, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)
    If $hPrev Then
        _WinAPI_DeleteObject($hPrev)
    EndIf
    $hPrev = _SendMessage($hWnd, $STM_GETIMAGE)
    If $hPrev <> $hBitmap Then
        _WinAPI_DeleteObject($hBitmap)
    EndIf
    If $bUpdate Then
        _WinAPI_UpdateWindow($hWnd)
    EndIf
    Return 1
EndFunc   ;==>_SetBitmap

Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam

    Switch $hWnd
        Case $g_hForm
            Local $tRIM = DllStructCreate($tagRAWINPUTMOUSE)
            If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_INPUT) Then
                Local $iFlags = DllStructGetData($tRIM, 'Flags')
                Select
                    Case BitAND($iFlags, $MOUSE_ATTRIBUTES_CHANGED)
                        ; You need to query the mouse attributes and update bitmap...
                    Case Else

                EndSelect
                $iFlags = DllStructGetData($tRIM, 'ButtonFlags')
                If BitAND($iFlags, BitOR($RI_MOUSE_MIDDLE_BUTTON_DOWN, $RI_MOUSE_MIDDLE_BUTTON_UP, $RI_MOUSE_LEFT_BUTTON_DOWN, $RI_MOUSE_LEFT_BUTTON_UP, $RI_MOUSE_RIGHT_BUTTON_DOWN, $RI_MOUSE_RIGHT_BUTTON_UP)) Then
                    Local $hDC = _WinAPI_CreateCompatibleDC(0)
                    Local $hSv = _WinAPI_SelectObject($hDC, $g_ahPart[8])
                    Select
                        Case BitAND($iFlags, $RI_MOUSE_MIDDLE_BUTTON_DOWN)
                            _WinAPI_DrawBitmap($hDC, 0, 0, $g_ahPart[5])
                        Case BitAND($iFlags, $RI_MOUSE_MIDDLE_BUTTON_UP)
                            _WinAPI_DrawBitmap($hDC, 0, 0, $g_ahPart[6])
                    EndSelect
                    _WinAPI_SelectObject($hDC, $g_ahPart[7])
                    Select
                        Case BitAND($iFlags, $RI_MOUSE_LEFT_BUTTON_DOWN)
                            _WinAPI_DrawBitmap($hDC, 39, 25, $g_ahPart[1])
                        Case BitAND($iFlags, $RI_MOUSE_LEFT_BUTTON_UP)
                            _WinAPI_DrawBitmap($hDC, 39, 25, $g_ahPart[2])
                        Case BitAND($iFlags, $RI_MOUSE_RIGHT_BUTTON_DOWN)
                            _WinAPI_DrawBitmap($hDC, 81, 25, $g_ahPart[3])
                        Case BitAND($iFlags, $RI_MOUSE_RIGHT_BUTTON_UP)
                            _WinAPI_DrawBitmap($hDC, 81, 25, $g_ahPart[4])
                    EndSelect
                    _WinAPI_DrawBitmap($hDC, 74, 33, $g_ahPart[8])
                    _WinAPI_SelectObject($hDC, $hSv)
                    _WinAPI_DeleteDC($hDC)
                    _SetBitmap($g_idPic, $g_ahPart[7])
                EndIf
                Local $aData = MouseGetPos()
                For $i = 0 To 1
                    If StringCompare(GUICtrlRead($g_aidLabel[$i]), $aData[$i]) Then
                        GUICtrlSetData($g_aidLabel[$i], $aData[$i])
                    EndIf
                Next
                If BitAND($iFlags, $RI_MOUSE_WHEEL) Then
                    $aData = _WinAPI_WordToShort(DllStructGetData($tRIM, 'ButtonData'))
                    If $aData > 0 Then
                        $aData = 'Up'
                    Else
                        $aData = 'Down'
                    EndIf
                Else
                    $aData = ''
                EndIf
                If StringCompare(GUICtrlRead($g_aidLabel[2]), $aData) Then
                    GUICtrlSetData($g_aidLabel[2], $aData)
                EndIf
            EndIf
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_INPUT


Function _WinAPI_SetActiveWindow

Function Reference

_WinAPI_SetActiveWindow

Activates the specified window

#include <WinAPISys.au3>
_WinAPI_SetActiveWindow ( $hWnd )

Parameters

$hWnd Handle to the top-level window to be activated.

Return Value

Success: | Handle to the window that was previously active.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search SetActiveWindow in MSDN Library.


Function _WinAPI_SetKeyboardLayout

Function Reference

_WinAPI_SetKeyboardLayout

Sets an input locale identifier to the specified window

#include <WinAPISys.au3>
_WinAPI_SetKeyboardLayout ( $hWnd, $iLanguage [, $iFlags = 0] )

Parameters

$hWnd Handle to the window to set input locale identifier.
$iLanguage The input locale identifier.

0x0436 - Afrikaans
0x041C - Albanian
0x0401 - Arabic
0x1401 - Arabic Algeria
0x3C01 - Arabic Bahrain
0x0C01 - Arabic Egypt
0x0801 - Arabic Iraq
0x2C01 - Arabic Jordan
0x3401 - Arabic Kuwait
0x3001 - Arabic Lebanon
0x1001 - Arabic Libya
0x1801 - Arabic Morocco
0x2001 - Arabic Oman
0x4001 - Arabic Qatar
0x0401 - Arabic Saudi Arabia
0x2801 - Arabic Syria
0x1C01 - Arabic Tunisia
0x3801 - Arabic U.A.E
0x2401 - Arabic Yemen
0x042B - Armenian
0x044D - Assamese
0x082C - Azeri Cyrillic
0x042C - Azeri Latin
0x042D - Basque
0x0813 - Belgian Dutch
0x080C - Belgian French
0x0445 - Bengali
0x0416 - Portuguese (Brazil)
0x0402 - Bulgarian
0x0455 - Burmese
0x0423 - Byelorussian (Belarusian)
0x0403 - Catalan
0x0C04 - Chinese Hong Kong SAR
0x1404 - Chinese Macau SAR
0x0804 - Chinese Simplified
0x1004 - Chinese Singapore
0x0404 - Chinese Traditional
0x041A - Croatian
0x0405 - Czech
0x0406 - Danish
0x0413 - Dutch
0x0C09 - English Australia
0x2809 - English Belize
0x1009 - English Canadian
0x2409 - English Caribbean
0x1813 - English Ireland
0x2009 - English Jamaica
0x1409 - English New Zealand
0x3409 - English Philippines
0x1C09 - English South Africa
0x2C09 - English Trinidad
0x0809 - English U.K.
0x0409 - English U.S.
0x3009 - English Zimbabwe
0x0425 - Estonian
0x0438 - Faeroese
0x0429 - Farsi
0x040B - Finnish
0x040C - French
0x2C0C - French Cameroon
0x0C0C - French Canadian
0x300C - French Cote d'Ivoire
0x140C - French Luxembourg
0x340C - French Mali
0x180C - French Monaco
0x200C - French Reunion
0x280C - French Senegal
0x1C0C - French West Indies
0x240C - French Congo (DRC)
0x0462 - Frisian Netherlands
0x083C - Gaelic Ireland
0x043C - Gaelic Scotland
0x0456 - Galician
0x0437 - Georgian
0x0407 - German
0x0C07 - German Austria
0x1407 - German Liechtenstein
0x1007 - German Luxembourg
0x0408 - Greek
0x0447 - Gujarati
0x040D - Hebrew
0x0439 - Hindi
0x040E - Hungarian
0x040F - Icelandic
0x0421 - Indonesian
0x0410 - Italian
0x0411 - Japanese
0x044B - Kannada
0x0460 - Kashmiri
0x043F - Kazakh
0x0453 - Khmer
0x0440 - Kirghiz
0x0457 - Konkani
0x0412 - Korean
0x0454 - Lao
0x0426 - Latvian
0x0427 - Lithuanian
0x042F - FYRO Macedonian
0x044C - Malayalam
0x083E - Malay Brunei Darussalam
0x043E - Malaysian
0x043A - Maltese
0x0458 - Manipuri
0x044E - Marathi
0x0450 - Mongolian
0x0461 - Nepali
0x0414 - Norwegian Bokmol
0x0814 - Norwegian Nynorsk
0x0448 - Oriya
0x0415 - Polish
0x0816 - Portuguese
0x0446 - Punjabi
0x0417 - Rhaeto-Romanic
0x0418 - Romanian
0x0818 - Romanian Moldova
0x0419 - Russian
0x0819 - Russian Moldova
0x043B - Sami Lappish
0x044F - Sanskrit
0x0C1A - Serbian Cyrillic
0x081A - Serbian Latin
0x0430 - Sesotho
0x0459 - Sindhi
0x041B - Slovak
0x0424 - Slovenian
0x042E - Sorbian
0x040A - Spanish (Traditional)
0x2C0A - Spanish Argentina
0x400A - Spanish Bolivia
0x340A - Spanish Chile
0x240A - Spanish Colombia
0x140A - Spanish Costa Rica
0x1C0A - Spanish Dominican Republic
0x300A - Spanish Ecuador
0x440A - Spanish El Salvador
0x100A - Spanish Guatemala
0x480A - Spanish Honduras
0x4C0A - Spanish Nicaragua
0x180A - Spanish Panama
0x3C0A - Spanish Paraguay
0x280A - Spanish Peru
0x500A - Spanish Puerto Rico
0x0C0A - Spanish Spain (Modern Sort)
0x380A - Spanish Uruguay
0x200A - Spanish Venezuela
0x0430 - Sutu
0x0441 - Swahili
0x041D - Swedish
0x081D - Swedish Finland
0x100C - Swiss French
0x0807 - Swiss German
0x0810 - Swiss Italian
0x0428 - Tajik
0x0449 - Tamil
0x0444 - Tatar
0x044A - Telugu
0x041E - Thai
0x0451 - Tibetan
0x0431 - Tsonga
0x0432 - Tswana
0x041F - Turkish
0x0442 - Turkmen
0x0422 - Ukrainian
0x0420 - Urdu
0x0843 - Uzbek Cyrillic
0x0443 - Uzbek Latin
0x0433 - Venda
0x042A - Vietnamese
0x0452 - Welsh
0x0434 - Xhosa
0x0435 - Zulu
$iFlags [optional] The new input locale. This parameter can be one or more of the following values.
$INPUTLANGCHANGE_BACKWARD
$INPUTLANGCHANGE_FORWARD
$INPUTLANGCHANGE_SYSCHARSET

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.

See Also

Search WM_INPUTLANGCHANGEREQUEST in MSDN Library.


Function _WinAPI_SetKeyboardState

Function Reference

_WinAPI_SetKeyboardState

Copies a 256-byte array of keyboard key states into the calling process's keyboard input-state table

#include <WinAPISys.au3>
_WinAPI_SetKeyboardState ( $tState )

Parameters

$tState "byte[256]" structure that contains keyboard key states.

Return Value

Success: | True
Failure: | False

Remarks

This function alters the input state of the calling process and not the global input state of the system.
You cannot use this function to set the NUM LOCK, CAPS LOCK, or SCROLL LOCK indicator lights on the
keyboard.

See Also

Search SetKeyboardState in MSDN Library.


Function _WinAPI_TrackMouseEvent

Function Reference

_WinAPI_TrackMouseEvent

Posts messages when the mouse pointer leaves a window or hovers over a window for a specified amount of time

#include <WinAPISys.au3>
_WinAPI_TrackMouseEvent ( $hWnd, $iFlags [, $iTime = -1] )

Parameters

$hWnd | Handle to the window to track.
$iFlags | The services requested. This parameter can be a combination of the following values. $TME_CANCEL $TME_HOVER $TME_LEAVE $TME_NONCLIENT $TME_QUERY
$iTime | [optional] The hover time-out (if $TME_HOVER was specified in $Flags), in milliseconds. Can be (-1) (Default), which means to use the system default hover time-out.

Return Value

Success: | True
Failure: | False

See Also

Search TrackMouseEvent in MSDN Library.


Function _WinAPI_UnloadKeyboardLayout

Function Reference

_WinAPI_UnloadKeyboardLayout

Unloads an input locale identifier

#include <WinAPISys.au3>
_WinAPI_UnloadKeyboardLayout ( $hLocale )

Parameters

$hLocale The input locale identifier to be unloaded.

Return Value

Success: | True
Failure: | False

Remarks

_WinAPI_UnloadKeyboardLayout() cannot unload the system default input locale identifier if it is the only
keyboard layout loaded. You must first load another input locale identifier before unloading the default input
locale identifier.

See Also

Search UnloadKeyboardLayout in MSDN Library.


Function _WinAPI_UnregisterHotKey

Function Reference

_WinAPI_UnregisterHotKey

Frees a hot key previously registered by the calling thread

#include <WinAPISys.au3>
_WinAPI_UnregisterHotKey ( $hWnd, $iID )

Parameters

$hWnd | Handle to the window associated with the hot key to be freed. This parameter should be 0 if the hot key is not associated with a window.
$iID | Specifies the identifier of the hot key to be freed.

Return Value

Success: | True
Failure: | False

Related

_WinAPI_RegisterHotKey

See Also

Search UnregisterHotKey in MSDN Library.


User Defined Functions

Windows user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPISys.au3>.

User Defined Function | Description
_WinAPI_AdjustWindowRectEx | Calculates the required size of the window rectangle, based on the desired size of the client rectangle
_WinAPI_AnimateWindow | Enables you to produce special effects when showing or hiding windows
_WinAPI_BeginDeferWindowPos | Allocates memory for a multiple-window-position structure
_WinAPI_BringWindowToTop | Brings the specified window to the top of the Z order
_WinAPI_BroadcastSystemMessage | Sends a message to the specified recipients
_WinAPI_CallWindowProcW | Passes message information to the specified window procedure
_WinAPI_CascadeWindows | Cascades the specified child windows of the specified parent window
_WinAPI_ChangeWindowMessageFilterEx | Modifies the User Interface Privilege Isolation (UIPI) message filter for a specified window
_WinAPI_ChildWindowFromPointEx | Determines which, if any, of the child windows belonging to the specified parent window contains the specified point
_WinAPI_CloseWindow | Minimizes (but does not destroy) the specified window
_WinAPI_DeferWindowPos | Updates the specified multiple-window-position structure for the specified window
_WinAPI_DefWindowProcW | Calls the default window procedure to provide default processing for any window messages
_WinAPI_DeregisterShellHookWindow | Unregisters a specified Shell window that is registered to receive Shell hook messages
_WinAPI_DragAcceptFiles | Registers whether a window accepts dropped files
_WinAPI_DragFinish | Releases memory that the system allocated for use in transferring file names to the application
_WinAPI_DragQueryFileEx | Retrieves the names of dropped files that result from a successful drag-and-drop operation
_WinAPI_DragQueryPoint | Retrieves the position of the mouse pointer at the time a file was dropped during a drag-and-drop operation
_WinAPI_EndDeferWindowPos | Simultaneously updates the position and size of one or more windows in a single screen-refreshing cycle
_WinAPI_EnumChildWindows | Enumerates a child windows that belong to the specified parent window
_WinAPI_GetClassInfoEx | Retrieves information about a window class
_WinAPI_GetClassLongEx | Retrieves the specified value associated with the specified window
_WinAPI_GetGUIThreadInfo | Retrieves information about the active window or a specified GUI thread
_WinAPI_GetLastActivePopup | Determines which pop-up window owned by the specified window was most recently active
_WinAPI_GetMessageExtraInfo | Retrieves the extra message information for the current thread
_WinAPI_GetMonitorInfo | Retrieves information about a display monitor
_WinAPI_GetObjectInfoByHandle | Retrieves information about a specified object
_WinAPI_GetObjectNameByHandle | Retrieves a name of the specified object
_WinAPI_GetShellWindow | Retrieves a handle to the Shell's desktop window
_WinAPI_GetTopWindow | Retrieves a handle to the child window at the top of the Z order
_WinAPI_GetWindowDisplayAffinity | Retrieves the current display affinity setting, from any process, for a given window
_WinAPI_GetWindowInfo | Retrieves information about the specified window
_WinAPI_GetWorkArea | Retrieves the size of the working area on the primary display monitor
_WinAPI_IsChild | Tests whether a window is a child window of a specified parent window
_WinAPI_IsHungAppWindow | Determines whether the specified application is not responding
_WinAPI_IsIconic | Determines whether the specified window is minimized (iconic)
_WinAPI_IsWindowUnicode | Determines whether the specified window is a native Unicode window
_WinAPI_IsZoomed | Determines whether a window is maximized
_WinAPI_KillTimer | Destroys the specified timer
_WinAPI_OpenIcon | Restores a minimized (iconic) window to its previous size and position and activates the window
_WinAPI_RegisterClass | Registers a window class
_WinAPI_RegisterClassEx | Registers a window class
_WinAPI_RegisterShellHookWindow | Registers a specified Shell window to receive certain messages for events or notifications
_WinAPI_SendMessageTimeout | Sends the specified message to one of more windows
_WinAPI_SetClassLongEx | Replaces the specified value into the specified window belongs
_WinAPI_SetForegroundWindow | Puts the specified window into the foreground and activates its
_WinAPI_SetMessageExtraInfo | Sets the extra message information for the current thread
_WinAPI_SetTimer | Creates a timer with the specified time-out value
_WinAPI_SetWindowDisplayAffinity | Stores the display affinity setting in kernel mode on the specified window
_WinAPI_ShowOwnedPopups | Shows or hides all pop-up windows owned by the specified window
_WinAPI_SwitchToThisWindow | Switches the focus to a specified window and bring it to the foreground
_WinAPI_TileWindows | Tiles the specified child windows of the specified parent window
_WinAPI_UnregisterClass | Unregisters a window class, freeing the memory required for the class
_WinAPI_UpdateLayeredWindowEx | Updates a bitmap translucency of a layered window
_WinAPI_UpdateLayeredWindowIndirect | Updates the position, size, shape, content, and translucency of a layered window


Function _WinAPI_AdjustWindowRectEx

Function Reference

_WinAPI_AdjustWindowRectEx

Calculates the required size of the window rectangle, based on the desired size of the client rectangle

#include <WinAPISys.au3>
_WinAPI_AdjustWindowRectEx ( ByRef $tRECT, $iStyle [, $iExStyle = 0 [, $bMenu = False]] )

Parameters

$tRECT | $tagRECT structure that contains the coordinates of the desired client area. This structure must be created before function call.
$iStyle | The window style of the window whose required size is to be calculated. Note that you cannot specify the $WS_OVERLAPPED style.
$iExStyle | [optional] The extended window style of the window whose required size is to be calculated.
$bMenu | [optional] Specifies whether the window has a menu, valid values: True - The window has a menu. False - The window does not has a menu (Default).

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

See Also

Search AdjustWindowRectEx in MSDN Library.


Function _WinAPI_AnimateWindow

Function Reference

_WinAPI_AnimateWindow

Enables you to produce special effects when showing or hiding windows

#include <WinAPISys.au3>
_WinAPI_AnimateWindow ( $hWnd, $iFlags [, $iDuration = 1000] )

Parameters

$hWnd | Handle to the window to animate.
$iFlags | The flags that specify the type of animation. This parameter can be one or more of the following values. Note that, by default, these flags take effect when showing a window. To take effect when hiding a window, use AW_HIDE and a logical OR operator with the appropriate flags: $AW_ACTIVATE $AW_BLEND $AW_CENTER $AW_HIDE $AW_HOR_NEGATIVE $AW_HOR_POSITIVE $AW_SLIDE $AW_VER_NEGATIVE $AW_VER_POSITIVE
$iDuration | [optional] Specifies how long it takes to play the animation, in milliseconds. Default is 1000.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

See Also

Search AnimateWindow in MSDN Library.

Example

#NoTrayIcon

#include <APISysConstants.au3>
#include <GUIConstantsEx.au3>
#include <MenuConstants.au3>
#include <TrayConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

Opt('TrayMenuMode', 1)

Local $hTray = ControlGetHandle('[CLASS:Shell_TrayWnd]', '', 'TrayNotifyWnd1')

Local $idTrayRestoreItem = TrayCreateItem('Restore')
TrayItemSetState(-1, $TRAY_DEFAULT)
TrayCreateItem('')
Local $idTrayExitItem = TrayCreateItem('Exit')
TraySetClick(8)

Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'))
Global $g_idDummy = GUICtrlCreateDummy()
GUIRegisterMsg($WM_SYSCOMMAND, 'WM_SYSCOMMAND')
GUISetState(@SW_SHOW)

While 1
    Switch TrayGetMsg()
        Case $idTrayRestoreItem
            _WinAPI_DrawAnimatedRects($g_hForm, _WinAPI_GetWindowRect($hTray), _WinAPI_GetWindowRect($g_hForm))
            GUISetState(@SW_SHOW, $g_hForm)
            TraySetState(2)
        Case $idTrayExitItem
            ExitLoop
    EndSwitch
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            _WinAPI_AnimateWindow($g_hForm, BitOR($AW_BLEND, $AW_HIDE))
            ExitLoop
        Case $g_idDummy ; Minimize
            _WinAPI_DrawAnimatedRects($g_hForm, _WinAPI_GetWindowRect($g_hForm), _WinAPI_GetWindowRect($hTray))
            GUISetState(@SW_HIDE, $g_hForm)
            TraySetState(1)
    EndSwitch
WEnd

Func WM_SYSCOMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $lParam

    Switch $hWnd
        Case $g_hForm
            Switch $wParam
                Case $SC_MINIMIZE
                    GUICtrlSendToDummy($g_idDummy)
                    Return 0
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SYSCOMMAND


Function _WinAPI_BeginDeferWindowPos

Function Reference

_WinAPI_BeginDeferWindowPos

Allocates memory for a multiple-window-position structure

#include <WinAPISys.au3>
_WinAPI_BeginDeferWindowPos ( [$iAmount = 1] )

Parameters

$iAmount [optional] The initial number of windows for which to store position information. Default is 1.

Return Value

Success: | The value identifies the multiple-window-position structure.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search BeginDeferWindowPos in MSDN Library.


Function _WinAPI_BringWindowToTop

Function Reference

_WinAPI_BringWindowToTop

Brings the specified window to the top of the Z order

#include <WinAPISys.au3>
_WinAPI_BringWindowToTop ( $hWnd )

Parameters

$hWnd Handle to the window to bring to the top of the Z order.

Return Value

Success: | True
Failure: | False

See Also

Search BringWindowToTop in MSDN Library.


Function _WinAPI_BroadcastSystemMessage

Function Reference

_WinAPI_BroadcastSystemMessage

Sends a message to the specified recipients

#include <WinAPISys.au3>
_WinAPI_BroadcastSystemMessage ( $iMsg [, $wParam = 0 [, $lParam = 0 [, $iFlags = 0 [, $iRecipients = 0]]]] )

Parameters

$iMsg | The message to be sent.
$wParam | [optional] The message-specific information.
$lParam | [optional] The message-specific information.
$iFlags | [optional] The broadcast option. This parameter can be one or more of the following values: $BSF_ALLOWSFW $BSF_FLUSHDISK $BSF_FORCEIFHUNG $BSF_IGNORECURRENTTASK $BSF_NOHANG $BSF_NOTIMEOUTIFNOTHUNG $BSF_POSTMESSAGE $BSF_QUERY $BSF_SENDNOTIFYMESSAGE
$iRecipients | [optional] The recipients of the message. This parameter can be one or more of the following values: $BSM_ALLCOMPONENTS (Default) $BSM_ALLDESKTOPS $BSM_APPLICATIONS $BSM_INSTALLABLEDRIVERS $BSM_NETDRIVER $BSM_VXDS

Return Value

Success: | >0 or 0 (see below), @extended flag receives a combination of $BSM_* values identifying which recipients actually received the message.
Failure: | (-1), call _WinAPI_GetLastError() to get extended error information.

Remarks

If the $iFlags parameter is $BSF_QUERY and at least one recipient returned BROADCAST_QUERY_DENY to the corresponding message, the return value is 0.

The system only does marshalling for system messages (those in the range 0 to (WM_USER-1)).
To send other messages (those >= WM_USER) to another process, you must do custom marshalling.

See Also

Search BroadcastSystemMessage in MSDN Library.


Function _WinAPI_CallWindowProcW

Function Reference

_WinAPI_CallWindowProcW

Passes message information to the specified window procedure

#include <WinAPISys.au3>
_WinAPI_CallWindowProcW ( $pPrevWndProc, $hWnd, $iMsg, $wParam, $lParam )

Parameters

$pPrevWndProc | The address of a previous window procedure, or a special internal value meaningful only to _WinAPI_CallWindowProcW() function.
$hWnd | A handle to the window procedure that received the message.
$iMsg | The message.
$wParam | Additional message-specific information. The content of this parameter depends on the message.
$lParam | Additional message-specific information. The content of this parameter depends on the message.

Return Value

Returns the result of the message processing and depends on the message sent.

Remarks

Use this function for window subclassing. Usually, all windows with the same class share one window procedure.
A subclass is a window or set of windows with the same class whose messages are intercepted and processed by another window procedure (or procedures) before being passed to the window procedure of the class.

The _WinAPI_CallWindowProcW() function handles Unicode-to-ANSI conversion.
You cannot take advantage of this conversion if you call the window procedure directly.

See Also

Search CallWindowProc in MSDN Library.


Function _WinAPI_CascadeWindows

Function Reference

_WinAPI_CascadeWindows

Cascades the specified child windows of the specified parent window

#include <WinAPISys.au3>
_WinAPI_CascadeWindows ( $aWnds [, $tRECT = 0 [, $hParent = 0 [, $iFlags = 0 [, $iStart = 0 [, $iEnd = -1]]]]] )

Parameters

$aWnds | The array of handles to the child windows to arrange. If a specified child window is a top-level window with the style $WS_EX_TOPMOST or $WS_EX_TOOLWINDOW, the child window is not arranged. If this parameter is 0, all child windows of the specified parent window (or of the desktop window) are arranged.
$tRECT | [optional] $tagRECT structure that specifies the rectangular area, in client coordinates, within which the windows are arranged. This parameter can be 0 (Default), in which case the client area of the parent window is used.
$hParent | [optional] Handle to the parent window. If this parameter is 0 (Default), the desktop window is assumed.
$iFlags | [optional] A cascade flag. This parameter can be one or more of the following values: $MDITILE_SKIPDISABLED $MDITILE_ZORDER
$iStart | [optional] The index of array to start arranging at.
$iEnd | [optional] The index of array to stop arranging at.

Return Value

Success: | The value is the number of windows arranged.
Failure: | 0 and sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended code information.

See Also

Search CascadeWindows in MSDN Library.

Example

#include <APISysConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

Local $aWnds[4]
For $i = 0 To UBound($aWnds) - 1
    $aWnds[$i] = GUICreate('#' & ($i + 1), 400, 400, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_SIZEBOX, $WS_SYSMENU))
    GUISetState(@SW_SHOW)
Next

_WinAPI_CascadeWindows($aWnds, _WinAPI_CreateRectEx(20, 20, 600, 600), 0, $MDITILE_ZORDER)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_ChangeWindowMessageFilterEx

Function Reference

_WinAPI_ChangeWindowMessageFilterEx

Modifies the User Interface Privilege Isolation (UIPI) message filter for a specified window

#include <WinAPISys.au3>
_WinAPI_ChangeWindowMessageFilterEx ( $hWnd, $iMsg, $iAction )

Parameters

$hWnd | Handle to the window whose UIPI message filter is to be modified. If this parameter is 0, the UIPI message filter will be modified in a process-wide manner. Moreover, under Windows Vista this parameter is not used and should be set to 0.
$iMsg | The message that the message filter allows through or blocks.
$iAction | The action to be performed. This parameter can be one of the following values: $MSGFLT_ALLOW $MSGFLT_DISALLOW Windows 7 or later $MSGFLT_RESET

Return Value

Success: | 1 and sets the @extended flag to 0 or one of the following values (only under Windows 7 or later). $MSGFLTINFO_ALLOWED_HIGHER $MSGFLTINFO_ALREADYALLOWED_FORWND $MSGFLTINFO_ALREADYDISALLOWED_FORWND $MSGFLTINFO_NONE (See MSDN for more information)
Failure: | 0 and sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended code information.

Remarks

UIPI is a security feature that prevents messages from being received from a lower-integrity-level sender.
You can use this function to allow specific messages to be delivered to a window even if the message originates from a process at a lower integrity level.

Certain messages whose value is smaller than WM_USER are required to be passed through the filter, regardless of the filter setting. There will be no effect when you attempt to use this function to allow or block such messages.

This function requires Windows Vista or later.

See Also

Search ChangeWindowMessageFilterEx in MSDN Library.


Function _WinAPI_ChildWindowFromPointEx

Function Reference

_WinAPI_ChildWindowFromPointEx

Determines which, if any, of the child windows belonging to the specified parent window contains the specified point

#include <WinAPISys.au3>
_WinAPI_ChildWindowFromPointEx ( $hWnd, $tPOINT [, $iFlags = 0] )

Parameters

$hWnd | Handle to the parent window.
$tPOINT | $tagPOINT structure that defines the client coordinates (relative to hwndParent) of the point to be checked.
$iFlags | [optional] The flags that specify which child windows to skip. This parameter can be one or more of the following values: $CWP_ALL (Default) $CWP_SKIPINVISIBLE $CWP_SKIPDISABLED $CWP_SKIPTRANSPARENT

Return Value

Success: | Handle to the first child window. If the point is within the parent window but not within any child window that meets the criteria, the return value is a handle to the parent window. If the point lies outside the parent window, the return value is 0.
Failure: | 0.

Remarks

The system maintains an internal list that contains the handles of the child windows associated with a parent window.
The order of the handles in the list depends on the Z order of the child windows.
If more than one child window contains the specified point, the system returns a handle to the first window in the list that contains the point and meets the criteria specified by $iFlags.

See Also

Search ChildWindowFromPointEx in MSDN Library.


Function _WinAPI_CloseWindow

Function Reference

_WinAPI_CloseWindow

Minimizes (but does not destroy) the specified window

#include <WinAPISys.au3>
_WinAPI_CloseWindow ( $hWnd )

Parameters

$hWnd Handle to the window to be minimized.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information.

See Also

Search CloseWindow in MSDN Library.


Function _WinAPI_DeferWindowPos

Function Reference

_WinAPI_DeferWindowPos

Updates the specified multiple-window-position structure for the specified window

#include <WinAPISys.au3>
_WinAPI_DeferWindowPos ( $hInfo, $hWnd, $hAfter, $iX, $iY, $iWidth, $iHeight, $iFlags )

Parameters

$hInfo | Handle to a multiple-window-position structure that contains size and position information for one or more windows. This structure is returned by _WinAPI_BeginDeferWindowPos() or by the most recent call to _WinAPI_DeferWindowPos().
$hWnd | Handle to the window for which update information is stored in the structure. All windows in a multiple-window-position structure must have the same parent.
$hAfter | Handle to the window that precedes the positioned window in the Z order. This parameter must be a window handle or one of the following values. This parameter is ignored if the $SWP_NOZORDER flag is set in the $iFlags parameter. $HWND_BOTTOM $HWND_NOTOPMOST $HWND_TOP $HWND_TOPMOST
$iX | The x-coordinate of the window's upper-left corner.
$iY | The y-coordinate of the window's upper-left corner.
$iWidth | The window's new width, in pixels.
$iHeight | The window's new height, in pixels.
$iFlags | A combination of the following values that affect the size and position of the window. $SWP_DRAWFRAME $SWP_FRAMECHANGED $SWP_HIDEWINDOW $SWP_NOACTIVATE $SWP_NOCOPYBITS $SWP_NOMOVE $SWP_NOOWNERZORDER $SWP_NOREDRAW $SWP_NOREPOSITION $SWP_NOSENDCHANGING $SWP_NOSIZE $SWP_NOZORDER $SWP_SHOWWINDOW

Return Value

Success: | The return value identifies the updated multiple-window-position structure.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search DeferWindowPos in MSDN Library.


Function _WinAPI_DefWindowProcW

Function Reference

_WinAPI_DefWindowProcW

Calls the default window procedure to provide default processing for any window messages

#include <WinAPISys.au3>
_WinAPI_DefWindowProcW ( $hWnd, $iMsg, $wParam, $lParam )

Parameters

$hWnd | A handle to the window procedure that received the message.
$iMsg | The message.
$wParam | Additional message-specific information. The content of this parameter depends on the message.
$lParam | Additional message-specific information. The content of this parameter depends on the message.

Return Value

Returns the result of the message processing and depends on the message sent.

See Also

Search DefWindowProc in MSDN Library.


Function _WinAPI_DeregisterShellHookWindow

Function Reference

_WinAPI_DeregisterShellHookWindow

Unregisters a specified Shell window that is registered to receive Shell hook messages

#include <WinAPISys.au3>
_WinAPI_DeregisterShellHookWindow ( $hWnd )

Parameters

$hWnd Handle to the window to unregister from receiving Shell hook messages.

Return Value

Success: | True.
Failure: | False.

See Also

Search DeregisterShellHookWindow in MSDN Library.


Function _WinAPI_DragAcceptFiles

Function Reference

_WinAPI_DragAcceptFiles

Registers whether a window accepts dropped files

#include <WinAPISys.au3>
_WinAPI_DragAcceptFiles ( $hWnd [, $bAccept = True] )

Parameters

$hWnd | Handle to the window that is registering whether it will accept dropped files.
$bAccept | [optional] Specifies whether a window accepts dropped files, valid values: True - Accept dropped files (Default). False - Discontinue accepting dropped files.

Return Value

None.

See Also

Search DragAcceptFiles in MSDN Library.

Example

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

OnAutoItExitRegister('OnAutoItExit')

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idCheck = GUICtrlCreateCheckbox('Enable Drag && Drop', 10, 370, 120, 19)
Local $idLabel = GUICtrlCreateLabel('', 100, 100, 200, 200)
Global $g_hLabel = GUICtrlGetHandle($idLabel)
GUICtrlSetBkColor(-1, 0xD3D8EF)
GUICtrlCreateLabel('Drop here', 175, 193, 50, 14)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

; Allow WM_DROPFILES to be received from lower privileged processes (Windows Vista or later)
#cs
If IsAdmin() Then
    _WinAPI_ChangeWindowMessageFilterEx($g_hLabel, $WM_COPYGLOBALDATA, $MSGFLT_ALLOW)
    _WinAPI_ChangeWindowMessageFilterEx($g_hLabel, $WM_DROPFILES, $MSGFLT_ALLOW)
EndIf
#ce

; Register label window proc
Global $g_hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam')
Global $g_pDll = DllCallbackGetPtr($g_hDll)
Global $g_hProc = _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $g_pDll)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idCheck
            _WinAPI_DragAcceptFiles($g_hLabel, GUICtrlRead($idCheck) = $GUI_CHECKED)
    EndSwitch
WEnd

Func _WinProc($hWnd, $iMsg, $wParam, $lParam)
    Switch $iMsg
        Case $WM_DROPFILES
            Local $sFileList = _WinAPI_DragQueryFileEx($wParam)
            If Not @error Then
                ConsoleWrite('--------------------------------------------------' & @CRLF)
                For $i = 1 To $sFileList[0]
                    ConsoleWrite($sFileList[$i] & @CRLF)
                Next
            EndIf
            _WinAPI_DragFinish($wParam)
            Return 0
    EndSwitch
    Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_WinProc

Func OnAutoItExit()
    _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $g_hProc)
    DllCallbackFree($g_hDll)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_DragFinish

Function Reference

_WinAPI_DragFinish

Releases memory that the system allocated for use in transferring file names to the application

#include <WinAPISys.au3>
_WinAPI_DragFinish ( $hDrop )

Parameters

$hDrop Handle of the drop structure that describes the dropped file. This parameter is passed to
WM_DROPFILES message with WPARAM parameter.

Return Value

None.

See Also

Search DragFinish in MSDN Library.

Example

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

OnAutoItExitRegister('OnAutoItExit')

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idCheck = GUICtrlCreateCheckbox('Enable Drag && Drop', 10, 370, 120, 19)
Local $idLabel = GUICtrlCreateLabel('', 100, 100, 200, 200)
Global $g_hLabel = GUICtrlGetHandle($idLabel)
GUICtrlSetBkColor(-1, 0xD3D8EF)
GUICtrlCreateLabel('Drop here', 175, 193, 50, 14)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

; Allow WM_DROPFILES to be received from lower privileged processes (Windows Vista or later)
#cs
If IsAdmin() Then
    _WinAPI_ChangeWindowMessageFilterEx($g_hLabel, $WM_COPYGLOBALDATA, $MSGFLT_ALLOW)
    _WinAPI_ChangeWindowMessageFilterEx($g_hLabel, $WM_DROPFILES, $MSGFLT_ALLOW)
EndIf
#ce

; Register label window proc
Global $g_hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam')
Global $g_pDll = DllCallbackGetPtr($g_hDll)
Global $g_hProc = _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $g_pDll)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idCheck
            _WinAPI_DragAcceptFiles($g_hLabel, GUICtrlRead($idCheck) = $GUI_CHECKED)
    EndSwitch
WEnd

Func _WinProc($hWnd, $iMsg, $wParam, $lParam)
    Switch $iMsg
        Case $WM_DROPFILES
            Local $sFileList = _WinAPI_DragQueryFileEx($wParam)
            If Not @error Then
                ConsoleWrite('--------------------------------------------------' & @CRLF)
                For $i = 1 To $sFileList[0]
                    ConsoleWrite($sFileList[$i] & @CRLF)
                Next
            EndIf
            _WinAPI_DragFinish($wParam)
            Return 0
    EndSwitch
    Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_WinProc

Func OnAutoItExit()
    _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $g_hProc)
    DllCallbackFree($g_hDll)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_DragQueryFileEx

Function Reference

_WinAPI_DragQueryFileEx

Retrieves the names of dropped files that result from a successful drag-and-drop operation

#include <WinAPISys.au3>
_WinAPI_DragQueryFileEx ( $hDrop [, $iFlag = 0] )

Parameters

$hDrop | Handle of the drop structure that describes the dropped file. This parameter is passed to WM_DROPFILES message with WPARAM parameter.
$iFlag | [optional] The flag that specifies whether to return files folders or both, valid values: 0 - Return both files and folders (Default). 1 - Return files only. 2 - Return folders only.

Return Value

Success: | The array of the names of a dropped files. The zeroth array element contains the number of file names. If no files that satisfy the condition ($iFlag), the function fails.
Failure: | Sets the @error flag to non-zero.

See Also

Search DragQueryFile in MSDN Library.

Example

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

OnAutoItExitRegister('OnAutoItExit')

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
Local $idCheck = GUICtrlCreateCheckbox('Enable Drag && Drop', 10, 370, 120, 19)
Local $idLabel = GUICtrlCreateLabel('', 100, 100, 200, 200)
Global $g_hLabel = GUICtrlGetHandle($idLabel)
GUICtrlSetBkColor(-1, 0xD3D8EF)
GUICtrlCreateLabel('Drop here', 175, 193, 50, 14)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

; Allow WM_DROPFILES to be received from lower privileged processes (Windows Vista or later)
#cs
If IsAdmin() Then
    _WinAPI_ChangeWindowMessageFilterEx($g_hLabel, $WM_COPYGLOBALDATA, $MSGFLT_ALLOW)
    _WinAPI_ChangeWindowMessageFilterEx($g_hLabel, $WM_DROPFILES, $MSGFLT_ALLOW)
EndIf
#ce

; Register label window proc
Global $g_hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam')
Global $g_pDll = DllCallbackGetPtr($g_hDll)
Global $g_hProc = _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $g_pDll)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idCheck
            _WinAPI_DragAcceptFiles($g_hLabel, GUICtrlRead($idCheck) = $GUI_CHECKED)
    EndSwitch
WEnd

Func _WinProc($hWnd, $iMsg, $wParam, $lParam)
    Switch $iMsg
        Case $WM_DROPFILES
            Local $sFileList = _WinAPI_DragQueryFileEx($wParam)
            If Not @error Then
                ConsoleWrite('--------------------------------------------------' & @CRLF)
                For $i = 1 To $sFileList[0]
                    ConsoleWrite($sFileList[$i] & @CRLF)
                Next
            EndIf
            _WinAPI_DragFinish($wParam)
            Return 0
    EndSwitch
    Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_WinProc

Func OnAutoItExit()
    _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $g_hProc)
    DllCallbackFree($g_hDll)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_DragQueryPoint

Function Reference

_WinAPI_DragQueryPoint

Retrieves the position of the mouse pointer at the time a file was dropped during a drag-and-drop operation

#include <WinAPISys.au3>
_WinAPI_DragQueryPoint ( $hDrop )

Parameters

$hDrop Handle of the drop structure that describes the dropped file. This parameter is passed to WM_DROPFILES message with WPARAM parameter.

Return Value

Success: | $tagPOINT structure that contains the coordinates of the mouse pointer at the time the file was dropped.
Failure: | Sets the @error flag to non-zero.

See Also

Search DragQueryPoint in MSDN Library.


Function _WinAPI_EndDeferWindowPos

Function Reference

_WinAPI_EndDeferWindowPos

Simultaneously updates the position and size of one or more windows in a single screen-refreshing cycle

#include <WinAPISys.au3>
_WinAPI_EndDeferWindowPos ( $hInfo )

Parameters

$hInfo Handle to a multiple-window-position structure that contains size and position information for one or more windows.
This internal structure is returned by the _WinAPI_BeginDeferWindowPos() function or by the most recent call to the _WinAPI_DeferWindowPos() function.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

The _WinAPI_EndDeferWindowPos() function sends the WM_WINDOWPOSCHANGING and WM_WINDOWPOSCHANGED messages to each window identified in the internal structure.

Related

_WinAPI_BeginDeferWindowPos

See Also

Search EndDeferWindowPos in MSDN Library.


Function _WinAPI_EnumChildWindows

Function Reference

_WinAPI_EnumChildWindows

Enumerates a child windows that belong to the specified parent window

#include <WinAPISys.au3>
_WinAPI_EnumChildWindows ( $hWnd [, $bVisible = True] )

Parameters

$hWnd | Handle to the parent window whose child windows are to be enumerated. If this parameter is 0, this function is equivalent to _WinAPI_EnumWindows().
$bVisible | [optional] Specifies whether enumerates the invisible window, valid values: True - Enumerate only visible windows (Default). False - Enumerate all windows.

Return Value

Success: | The 2D array of the handles to the child windows and classes for the specified parent window. [0][0] - Number of rows in array (n) [0][1] - Unused [n][0] - Window handle [n][1] - Window class name
Failure: | Sets the @error flag to non-zero.

See Also

Search EnumChildWindows in MSDN Library.

Example

#include <Array.au3>
#include <WinAPISys.au3>

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 310, 360)
GUISetFont(8.5, 400, 0, 'MS Shell Dlg', $hForm)
GUICtrlCreateGroup('Group', 10, 10, 140, 95)
GUICtrlCreateCheckbox('Check1', 22, 26, 120, 23)
GUICtrlCreateCheckbox('Check2', 22, 49, 120, 23)
GUICtrlCreateCheckbox('Check3', 22, 72, 120, 23)
GUICtrlCreateGroup('Group', 160, 10, 140, 95)
GUICtrlCreateRadio('Radio1', 172, 26, 120, 23)
GUICtrlCreateRadio('Radio2', 172, 49, 120, 23)
GUICtrlCreateRadio('Radio3', 172, 72, 120, 23)
GUICtrlCreateButton('OK', 120, 330, 70, 23)
GUICtrlCreateTab(10, 118, 292, 206)
GUICtrlCreateTabItem('Tab1')
GUICtrlCreateTabItem('Tab2')
GUICtrlCreateTabItem('')
GUISetState(@SW_SHOW)

Local $aData = _WinAPI_EnumChildWindows($hForm)

_ArrayDisplay($aData, '_WinAPI_EnumChildWindows')

GUIDelete()


Function _WinAPI_GetClassInfoEx

Function Reference

_WinAPI_GetClassInfoEx

Retrieves information about a window class

#include <WinAPISys.au3>
_WinAPI_GetClassInfoEx ( $sClass [, $hInstance = 0] )

Parameters

$sClass | The class name. The name must be that of a preregistered class or a class registered by a previous call to the _WinAPI_RegisterClass() or _WinAPI_RegisterClassEx() function. Alternatively, this parameter can be a class atom. The atom must be in the low-order word of $sClass; the high-order word must be zero.
$hInstance | [optional] Handle to the instance of the application that created the class. To retrieve information about classes defined by the system (such as buttons or list boxes), set this parameter to 0 (Default).

Return Value

Success: | $tagWNDCLASSEX structure that contains the information about the class.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Related

_WinAPI_RegisterClass, _WinAPI_RegisterClassEx

See Also

Search GetClassInfoEx in MSDN Library.


Function _WinAPI_GetClassLongEx

Function Reference

_WinAPI_GetClassLongEx

Retrieves the specified value associated with the specified window

#include <WinAPISys.au3>
_WinAPI_GetClassLongEx ( $hWnd, $iIndex )

Parameters

$hWnd | Handle to the window.
$iIndex | The value to retrieve. This parameter can be one of the following values. $GCL_CBCLSEXTRA $GCL_CBWNDEXTRA $GCL_HBRBACKGROUND $GCL_HCURSOR $GCL_HICON $GCL_HICONSM $GCL_HMODULE $GCL_MENUNAME $GCL_STYLE $GCL_WNDPROC

Return Value

Success: | The requested value.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetClassLong in MSDN Library.


Function _WinAPI_GetGUIThreadInfo

Function Reference

_WinAPI_GetGUIThreadInfo

Retrieves information about the active window or a specified GUI thread

#include <WinAPISys.au3>
_WinAPI_GetGUIThreadInfo ( $iThreadId )

Parameters

$iThreadId The identifier for the thread for which information is to be retrieved.

Return Value

Success: | The array that contains the following information: [0] - The thread state. It can be one or more of the $GUI_* values. [1] - A handle to the active window within the thread. [2] - A handle to the window that has the keyboard focus. [3] - A handle to the window that has captured the mouse. [4] - A handle to the window that owns any active menus. [5] - A handle to the window in a move or size loop. [6] - A handle to the window that is displaying the caret. [7] - The x-coordinate of the upper-left corner of the caret's bounding rectangle, in client coordinates. [8] - The y-coordinate of the upper-left corner of the caret's bounding rectangle, in client coordinates. [9] - The width of the caret's bounding rectangle. [10] - The height of the caret's bounding rectangle.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetGUIThreadInfo in MSDN Library.

Example

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

Local $hForm = GUICreate('', 240, 268, 10, 10, BitOR($WS_CAPTION, $WS_POPUP), $WS_EX_TOPMOST)
GUICtrlCreateLabel('Thread state:', 20, 18, 90, 14)
GUICtrlCreateLabel('Active window:', 20, 40, 90, 14)
GUICtrlCreateLabel('Keyboard focus:', 20, 62, 90, 14)
GUICtrlCreateLabel('Mouse capture:', 20, 84, 90, 14)
GUICtrlCreateLabel('Active menu:', 20, 106, 90, 14)
GUICtrlCreateLabel('Move or size loop:', 20, 128, 90, 14)
GUICtrlCreateLabel('Caret:', 20, 150, 90, 14)
GUICtrlCreateLabel('Left:', 20, 172, 90, 14)
GUICtrlCreateLabel('Top:', 20, 194, 90, 14)
GUICtrlCreateLabel('Width:', 20, 216, 90, 14)
GUICtrlCreateLabel('Height:', 20, 238, 90, 14)
Local $a_idInput[11]
For $i = 0 To 10
    $a_idInput[$i] = GUICtrlCreateLabel('', 114, 18 + 22 * $i, 116, 14)
Next
GUISetState(@SW_SHOWNOACTIVATE)

Local $hWnd, $aInfo, $iPID
Do
    $hWnd = WinGetHandle('[ACTIVE]')
    $aInfo = _WinAPI_GetGUIThreadInfo(_WinAPI_GetWindowThreadProcessId($hWnd, $iPID))
    If Not @error Then
        WinSetTitle($hForm, '', WinGetTitle($hWnd))
        $aInfo[0] = '0x' & Hex($aInfo[0], 8)
    Else
        WinSetTitle($hForm, '', '')
        Dim $aInfo[11]
        For $i = 0 To 10
            $aInfo[$i] = ''
        Next
        $hWnd = 0
    EndIf
    For $i = 0 To 10
        If StringCompare(GUICtrlRead($a_idInput[$i]), $aInfo[$i]) Then
            GUICtrlSetData($a_idInput[$i], $aInfo[$i])
        EndIf
    Next
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_GetLastActivePopup

Function Reference

_WinAPI_GetLastActivePopup

Determines which pop-up window owned by the specified window was most recently active

#include <WinAPISys.au3>
_WinAPI_GetLastActivePopup ( $hWnd )

Parameters

$hWnd Handle to the owner window.

Return Value

Success: | Handle of the most recently active pop-up window.
Failure: | 0 and sets the @error flag to non-zero.

See Also

Search GetLastActivePopup in MSDN Library.


Function _WinAPI_GetMessageExtraInfo

Function Reference

_WinAPI_GetMessageExtraInfo

Retrieves the extra message information for the current thread

#include <WinAPISys.au3>
_WinAPI_GetMessageExtraInfo ( )

Return Value

Returns the value associated with the current thread.

See Also

Search GetMessageExtraInfo in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <WinAPISys.au3>

Global Const $WM_MYMESSAGE = _WinAPI_RegisterWindowMessage('MyMessage')

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 93)
Local $idInput = GUICtrlCreateInput('', 20, 20, 360, 20)
Local $idButton = GUICtrlCreateButton('Send', 165, 59, 70, 23)
GUIRegisterMsg($WM_MYMESSAGE, 'WM_MYMESSAGE')
GUISetState(@SW_SHOW)

Local $pString
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            $pString = _WinAPI_CreateString(GUICtrlRead($idInput))
            _WinAPI_SetMessageExtraInfo($pString)
            _SendMessage($hForm, $WM_MYMESSAGE, 1, 255)
            _WinAPI_FreeMemory($pString)
    EndSwitch
WEnd

Func WM_MYMESSAGE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg

    Local $pString = _WinAPI_GetMessageExtraInfo()

    If _WinAPI_IsMemory($pString) Then
        ConsoleWrite('WM_MYMESSAGE | WP = ' & Number($wParam) & ' | LP = ' & Number($lParam) & ' | EXTRA = "' & _WinAPI_GetString($pString) & '"' & @CRLF)
    EndIf
EndFunc   ;==>WM_MYMESSAGE


Function _WinAPI_GetMonitorInfo

Function Reference

_WinAPI_GetMonitorInfo

Retrieves information about a display monitor

#include <WinAPISys.au3>
_WinAPI_GetMonitorInfo ( $hMonitor )

Parameters

$hMonitor A handle to the display monitor of interest.

Return Value

Success: | The array containing the following information: [0] - $tagRECT structure that specifies the display monitor rectangle, in virtual-screen coordinates. [1] - $tagRECT structure that specifies the work area rectangle of the display monitor that can be used by applications, in virtual-screen coordinates. [2] - 1 (True) for the primary display monitor, or 0 (False) otherwise. [3] - The device name of the monitor being used, e.g. "\\.\DISPLAY1".
Failure: | Sets the @error flag to non-zero.

See Also

Search GetMonitorInfo in MSDN Library.

Example

#include <WinAPIGdi.au3>
#include <WinAPISys.au3>

Local $tPos = _WinAPI_GetMousePos()
Local $hMonitor = _WinAPI_MonitorFromPoint($tPos)

Local $aData = _WinAPI_GetMonitorInfo($hMonitor)
If IsArray($aData) Then
    ConsoleWrite('Handle:      ' & $hMonitor & @CRLF)
    ConsoleWrite('Rectangle:   ' & DllStructGetData($aData[0], 1) & ', ' & DllStructGetData($aData[0], 2) & ', ' & DllStructGetData($aData[0], 3) & ', ' & DllStructGetData($aData[0], 4) & @CRLF)
    ConsoleWrite('Work area:   ' & DllStructGetData($aData[1], 1) & ', ' & DllStructGetData($aData[1], 2) & ', ' & DllStructGetData($aData[1], 3) & ', ' & DllStructGetData($aData[1], 4) & @CRLF)
    ConsoleWrite('Primary:     ' & $aData[2] & @CRLF)
    ConsoleWrite('Device name: ' & $aData[3] & @CRLF)
EndIf


Function _WinAPI_GetObjectInfoByHandle

Function Reference

_WinAPI_GetObjectInfoByHandle

Retrieves information about a specified object

#include <WinAPISys.au3>
_WinAPI_GetObjectInfoByHandle ( $hObject )

Parameters

$hObject A handle to the object to obtain information about.

Return Value

Success: | The array containing the following information: [0] - The attributes of the object. [1] - A mask that represents the granted access to the object. [2] - The number of handles to the object. [3] - The number of pointers to the object.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the NTSTATUS error code.

See Also

Search ZwQueryObject in MSDN Library.

Example

#include <WinAPISys.au3>

Local $sFile = @ScriptFullPath
Local $hFile = _WinAPI_CreateFile($sFile, 2, 0, 6)
If @error Then Exit

Local $aInfo = _WinAPI_GetObjectInfoByHandle($hFile)
If IsArray($aInfo) Then
    ConsoleWrite('File:       ' & $sFile & @CRLF)
    ConsoleWrite('Handle:     ' & $hFile & @CRLF)
    ConsoleWrite('Attributes: 0x' & Hex($aInfo[0]) & @CRLF)
    ConsoleWrite('Access:     0x' & Hex($aInfo[1]) & @CRLF)
    ConsoleWrite('Handles:    ' & $aInfo[2] & @CRLF)
    ConsoleWrite('Pointers:   ' & $aInfo[3] & @CRLF)
EndIf

_WinAPI_CloseHandle($hFile)


Function _WinAPI_GetObjectNameByHandle

Function Reference

_WinAPI_GetObjectNameByHandle

Retrieves a name of the specified object

#include <WinAPISys.au3>
_WinAPI_GetObjectNameByHandle ( $hObject )

Parameters

$hObject A handle to the object to obtain its name.

Return Value

Success: | The name of the object.
Failure: | Empty string and sets the @error flag to non-zero, @extended flag may contain the NTSTATUS error code.

See Also

Search ZwQueryObject in MSDN Library.

Example

#include <WinAPISys.au3>

Local $sFile = @ScriptFullPath
Local $hFile = _WinAPI_CreateFile(@ScriptFullPath, 2, 0, 6)

ConsoleWrite('File:   ' & $sFile & @CRLF)
ConsoleWrite('Handle: ' & $hFile & @CRLF)
ConsoleWrite('Type:   ' & _WinAPI_GetObjectNameByHandle($hFile) & @CRLF)

_WinAPI_CloseHandle($hFile)


Function _WinAPI_GetShellWindow

Function Reference

_WinAPI_GetShellWindow

Retrieves a handle to the Shell's desktop window

#include <WinAPISys.au3>
_WinAPI_GetShellWindow ( )

Return Value

Success: | The handle of the Shell's desktop window.
Failure: | 0.

See Also

Search GetShellWindow in MSDN Library.


Function _WinAPI_GetTopWindow

Function Reference

_WinAPI_GetTopWindow

Retrieves a handle to the child window at the top of the Z order

#include <WinAPISys.au3>
_WinAPI_GetTopWindow ( $hWnd )

Parameters

$hWnd Handle to the parent window whose child windows are to be examined. If this parameter is 0, the function
returns a handle to the window at the top of the Z order.

Return Value

Success: | Handle to the child window at the top of the Z order. If the specified window has no child windows, the return value is 0.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetTopWindow in MSDN Library.


Function _WinAPI_GetWindowDisplayAffinity

Function Reference

_WinAPI_GetWindowDisplayAffinity

Retrieves the current display affinity setting, from any process, for a given window

#include <WinAPISys.au3>
_WinAPI_GetWindowDisplayAffinity ( $hWnd )

Parameters

$hWnd Handle to the window for which display affinity setting is retrieved.

Return Value

Success: | The current window's display affinity setting ($WDA_*).
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

This function succeeds only when the window is layered and Desktop Windows Manager (DWM) is composing the desktop.
For more information, see _WinAPI_SetWindowDisplayAffinity().

This function requires Windows 7 or later.

Related

_WinAPI_SetWindowDisplayAffinity

See Also

Search GetWindowDisplayAffinity in MSDN Library.


Function _WinAPI_GetWindowInfo

Function Reference

_WinAPI_GetWindowInfo

Retrieves information about the specified window

#include <WinAPISys.au3>
_WinAPI_GetWindowInfo ( $hWnd )

Parameters

$hWnd Handle to the window whose information is to be retrieved.

Return Value

Success: | $tagWINDOWINFO structure that contains the information about the specified window.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetWindowInfo in MSDN Library.

Example

#include <WinAPISys.au3>

Local $tWINDOWINFO = _WinAPI_GetWindowInfo(_WinAPI_GetDesktopWindow())

ConsoleWrite('Left:   ' & DllStructGetData($tWINDOWINFO, 'rWindow', 1) & @CRLF)
ConsoleWrite('Top:    ' & DllStructGetData($tWINDOWINFO, 'rWindow', 2) & @CRLF)
ConsoleWrite('Right:  ' & DllStructGetData($tWINDOWINFO, 'rWindow', 3) & @CRLF)
ConsoleWrite('Bottom: ' & DllStructGetData($tWINDOWINFO, 'rWindow', 4) & @CRLF)


Function _WinAPI_GetWorkArea

Function Reference

_WinAPI_GetWorkArea

Retrieves the size of the working area on the primary display monitor

#include <WinAPISys.au3>
_WinAPI_GetWorkArea ( )

Return Value

Success: | $tagRECT structure that contains the screen coordinates of the working area.
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search SystemParametersInfo in MSDN Library.

Example

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

Local $tRECT = _WinAPI_GetWorkArea()
Local $iWidth = DllStructGetData($tRECT, 'Right') - DllStructGetData($tRECT, 'Left')
Local $iHeight = DllStructGetData($tRECT, 'Bottom') - DllStructGetData($tRECT, 'Top')
Local $X = DllStructGetData($tRECT, 'Left')
Local $Y = DllStructGetData($tRECT, 'Top')

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), $iWidth, $iHeight, $X, $Y, $WS_POPUP, $WS_EX_TOPMOST)
GUISetBkColor(0, $hForm)
WinSetTrans($hForm, '', 128)
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_IsChild

Function Reference

_WinAPI_IsChild

Tests whether a window is a child window of a specified parent window

#include <WinAPISys.au3>
_WinAPI_IsChild ( $hWnd, $hWndParent )

Parameters

$hWnd | Handle to the window to be tested.
$hWndParent | Handle to the parent window.

Return Value

True: | the window is a child window of the specified parent window.
False: | the window is not a child window of the specified parent window.

See Also

Search IsChild in MSDN Library.


Function _WinAPI_IsHungAppWindow

Function Reference

_WinAPI_IsHungAppWindow

Determines whether the specified application is not responding

#include <WinAPISys.au3>
_WinAPI_IsHungAppWindow ( $hWnd )

Parameters

$hWnd Handle to the window.

Return Value

True: | the window stops responding.
False: | the window is responding.

Remarks

An application is considered to be not responding if it is not waiting for input, is not in startup processing,
and did not respond to messages within the internal timeout period of 5 seconds.

See Also

Search IsHungAppWindow in MSDN Library.


Function _WinAPI_IsIconic

Function Reference

_WinAPI_IsIconic

Determines whether the specified window is minimized (iconic)

#include <WinAPISys.au3>
_WinAPI_IsIconic ( $hWnd )

Parameters

$hWnd Handle to the window to test.

Return Value

True: | the window is iconic.
False: | the window is not iconic.

See Also

Search IsIconic in MSDN Library.


Function _WinAPI_IsWindowUnicode

Function Reference

_WinAPI_IsWindowUnicode

Determines whether the specified window is a native Unicode window

#include <WinAPISys.au3>
_WinAPI_IsWindowUnicode ( $hWnd )

Parameters

$hWnd Handle to the window to test.

Return Value

True: | the window is a native Unicode window.
False: | the window is an ANSI window.

See Also

Search IsWindowUnicode in MSDN Library.


Function _WinAPI_IsZoomed

Function Reference

_WinAPI_IsZoomed

Determines whether a window is maximized

#include <WinAPISys.au3>
_WinAPI_IsZoomed ( $hWnd )

Parameters

$hWnd Handle to the window to test.

Return Value

True: | the window is zoomed.
False: | the window is not zoomed.

See Also

Search IsZoomed in MSDN Library.


Function _WinAPI_KillTimer

Function Reference

_WinAPI_KillTimer

Destroys the specified timer

#include <WinAPISys.au3>
_WinAPI_KillTimer ( $hWnd, $iTimerID )

Parameters

$hWnd | Handle to the window associated with the specified timer. This value must be the same as the $hWnd value passed to the _WinAPI_SetTimer() function that created the timer.
$iTimerID | The timer identifier which specifies the timer to be destroyed.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

Remarks

This function does not remove WM_TIMER messages already posted to the message queue.

Related

_WinAPI_SetTimer

See Also

Search KillTimer in MSDN Library.


Function _WinAPI_OpenIcon

Function Reference

_WinAPI_OpenIcon

Restores a minimized (iconic) window to its previous size and position and activates the window

#include <WinAPISys.au3>
_WinAPI_OpenIcon ( $hWnd )

Parameters

$hWnd Handle to the window to be restored and activated.

Return Value

Success: | True.
Failure: | False, call _WinAPI_GetLastError() to get extended error information

See Also

Search OpenIcon in MSDN Library.


Function _WinAPI_RegisterClass

Function Reference

_WinAPI_RegisterClass

Registers a window class

#include <WinAPISys.au3>
_WinAPI_RegisterClass ( $tWNDCLASS )

Parameters

$tWNDCLASS $tagWNDCLASS structure.

Return Value

Success: | The value is a class atom that uniquely identifies the class being registered.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search RegisterClass in MSDN Library.


Function _WinAPI_RegisterClassEx

Function Reference

_WinAPI_RegisterClassEx

Registers a window class

#include <WinAPISys.au3>
_WinAPI_RegisterClassEx ( $tWNDCLASSEX )

Parameters

$tWNDCLASSEX $tagWNDCLASSEX structure.

Return Value

Success: | The value is a class atom that uniquely identifies the class being registered.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

See Also

Search RegisterClassEx in MSDN Library.

Example

#include <WinAPIRes.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

Local Const $sClass = 'MyWindowClass'
Local Const $sName = 'Test ' & StringReplace(@ScriptName, '.au3', '()')

Global $g_bExit = False

; Get module handle for the current process
Local $hInstance = _WinAPI_GetModuleHandle(0)

; Create a class cursor
Local $hCursor = _WinAPI_LoadCursor(0, 32512) ; IDC_ARROW

; Create a class icons (large and small)
Local $tIcons = DllStructCreate('ptr;ptr')
_WinAPI_ExtractIconEx(@SystemDir & '\shell32.dll', 130, DllStructGetPtr($tIcons, 1), DllStructGetPtr($tIcons, 2), 1)
Local $hIcon = DllStructGetData($tIcons, 1)
Local $hIconSm = DllStructGetData($tIcons, 2)

; Create DLL callback function (window procedure)
Local $hProc = DllCallbackRegister('_WndProc', 'lresult', 'hwnd;uint;wparam;lparam')

; Create and fill $tagWNDCLASSEX structure
Local $tWCEX = DllStructCreate($tagWNDCLASSEX & ';wchar szClassName[' & (StringLen($sClass) + 1) & ']')
DllStructSetData($tWCEX, 'Size', DllStructGetPtr($tWCEX, 'szClassName') - DllStructGetPtr($tWCEX))
DllStructSetData($tWCEX, 'Style', 0)
DllStructSetData($tWCEX, 'hWndProc', DllCallbackGetPtr($hProc))
DllStructSetData($tWCEX, 'ClsExtra', 0)
DllStructSetData($tWCEX, 'WndExtra', 0)
DllStructSetData($tWCEX, 'hInstance', $hInstance)
DllStructSetData($tWCEX, 'hIcon', $hIcon)
DllStructSetData($tWCEX, 'hCursor', $hCursor)
DllStructSetData($tWCEX, 'hBackground', _WinAPI_CreateSolidBrush(_WinAPI_GetSysColor($COLOR_3DFACE)))
DllStructSetData($tWCEX, 'MenuName', 0)
DllStructSetData($tWCEX, 'ClassName', DllStructGetPtr($tWCEX, 'szClassName'))
DllStructSetData($tWCEX, 'hIconSm', $hIconSm)
DllStructSetData($tWCEX, 'szClassName', $sClass)

; Register a window class
_WinAPI_RegisterClassEx($tWCEX)

; Create a window
_WinAPI_CreateWindowEx(0, $sClass, $sName, BitOR($WS_CAPTION, $WS_POPUPWINDOW, $WS_VISIBLE), (@DesktopWidth - 400) / 2, (@DesktopHeight - 400) / 2, 400, 400, 0)

While 1
    Sleep(100)
    If $g_bExit Then
        ExitLoop
    EndIf
WEnd

; Unregister window class and release unnecessary resources
_WinAPI_UnregisterClass($sClass, $hInstance)
_WinAPI_DestroyCursor($hCursor)
_WinAPI_DestroyIcon($hIcon)
_WinAPI_DestroyIcon($hIconSm)

DllCallbackFree($hProc)

; Func _WinAPI_DefWindowProcW($hWnd, $iMsg, $wParam, $lParam)
; Local $aRet = DllCall('user32.dll', 'lresult', 'DefWindowProcW', 'hwnd', $hWnd, 'uint', $iMsg, 'wparam', $wParam, 'lparam', $lParam)

; If @error Then
; Return SetError(1, 0, 0)
; EndIf
; Return $aRet[0]
; EndFunc   ;==>_WinAPI_DefWindowProcW

Func _WndProc($hWnd, $iMsg, $wParam, $lParam)
    Switch $iMsg
        Case $WM_CLOSE
            $g_bExit = True
    EndSwitch
    Return _WinAPI_DefWindowProcW($hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_WndProc


Function _WinAPI_RegisterShellHookWindow

Function Reference

_WinAPI_RegisterShellHookWindow

Registers a specified Shell window to receive certain messages for events or notifications

#include <WinAPISys.au3>
_WinAPI_RegisterShellHookWindow ( $hWnd )

Parameters

$hWnd Handle to the window to register for Shell hook messages.

Return Value

Success: | True.
Failure: | False.

See Also

Search RegisterShellHookWindow in MSDN Library.

Example

#include <APISysConstants.au3>
#include <WinAPISys.au3>

Opt('TrayAutoPause', 0)

OnAutoItExitRegister('OnAutoItExit')

Global $g_hForm = GUICreate('')
GUIRegisterMsg(_WinAPI_RegisterWindowMessage('SHELLHOOK'), 'WM_SHELLHOOK')
_WinAPI_RegisterShellHookWindow($g_hForm)

While 1
    Sleep(1000)
WEnd

Func WM_SHELLHOOK($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg

    Switch $hWnd
        Case $g_hForm
            Local $sTitle = WinGetTitle($lParam)
            Switch $wParam
                Case $HSHELL_REDRAW
                    If IsString($sTitle) Then
                        ConsoleWrite('Redrawn: ' & $sTitle & @CRLF)
                    EndIf
                Case Else
                    If BitAND($wParam, $HSHELL_WINDOWACTIVATED) = $HSHELL_WINDOWACTIVATED And IsString($sTitle) Then
                        ConsoleWrite('Activated: ' & $sTitle & @CRLF)
                    EndIf
            EndSwitch
    EndSwitch
EndFunc   ;==>WM_SHELLHOOK

Func OnAutoItExit()
    _WinAPI_DeregisterShellHookWindow($g_hForm)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_SendMessageTimeout

Function Reference

_WinAPI_SendMessageTimeout

Sends the specified message to one of more windows

#include <WinAPISys.au3>
_WinAPI_SendMessageTimeout ( $hWnd, $iMsg [, $wParam = 0 [, $lParam = 0 [, $iTimeout = 1000 [, $iFlags = 0]]]] )

Parameters

$hWnd | Handle to the window whose window procedure will receive the message.
$iMsg | The message to be sent.
$wParam | [optional] The message-specific information.
$lParam | [optional] The message-specific information.
$iTimeout | [optional] The duration, in milliseconds, of the time-out period. If the message is a broadcast message, each window can use the full time-out period. Default is 1000.
$iFlags | [optional] The flags that specifies how to send the message. This parameter can be one or more of the following values. $SMTO_BLOCK $SMTO_NORMAL $SMTO_ABORTIFHUNG $SMTO_NOTIMEOUTIFNOTHUNG $SMTO_ERRORONEXIT

Return Value

Success: | The result of the message processing, depends on the message sent.
Failure: | Sets the @error flag to non-zero, @extended contains _WinAPI_GetLastError().

Remarks

This function does not provide information about individual windows timing out if $HWND_BROADCAST is used.

If times out, function fails. If @extended is $ERROR_TIMEOUT (1460), then the function timed out.
This function considers a thread is not responding if it has not responds within five seconds.

The system only does marshalling for system messages (those in the range 0 to (WM_USER-1)). To send other messages
(those >= WM_USER) to another process, you must do custom marshalling.

See Also

Search SendMessageTimeout in MSDN Library.


Function _WinAPI_SetClassLongEx

Function Reference

_WinAPI_SetClassLongEx

Replaces the specified value into the specified window belongs

#include <WinAPISys.au3>
_WinAPI_SetClassLongEx ( $hWnd, $iIndex, $iNewLong )

Parameters

$hWnd | Handle to the window.
$iIndex | The value to be replaced. This parameter can be one of the following values. $GCL_CBCLSEXTRA $GCL_CBWNDEXTRA $GCL_HBRBACKGROUND $GCL_HCURSOR $GCL_HICON $GCL_HICONSM $GCL_HMODULE $GCL_MENUNAME $GCL_STYLE $GCL_WNDPROC
$iNewLong | The replacement value.

Return Value

Success: | The previous value.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

If this was not previously set, the return value is zero.

See Also

Search SetClassLong in MSDN Library.

Example

#NoTrayIcon

#include <APISysConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

Local $hParent = GUICreate('', 0, 0, 0, 0, 0, $WS_EX_TOOLWINDOW)
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU), BitOR($WS_EX_DLGMODALFRAME, $WS_EX_TOPMOST), $hParent)

; Remove window icon
_WinAPI_SetClassLongEx($hForm, $GCL_HICONSM, 0)
_WinAPI_SetClassLongEx($hForm, $GCL_HICON, 0)

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_SetForegroundWindow

Function Reference

_WinAPI_SetForegroundWindow

Puts the specified window into the foreground and activates its

#include <WinAPISys.au3>
_WinAPI_SetForegroundWindow ( $hWnd )

Parameters

$hWnd Handle to the window that should be activated and brought to the foreground.

Return Value

Success: | True
Failure: | False

See Also

Search SetForegroundWindow in MSDN Library.


Function _WinAPI_SetMessageExtraInfo

Function Reference

_WinAPI_SetMessageExtraInfo

Sets the extra message information for the current thread

#include <WinAPISys.au3>
_WinAPI_SetMessageExtraInfo ( $lParam )

Parameters

$lParam The value of lParam type to be associated with the current thread.

Return Value

Returns the previous value associated with the current thread.

See Also

Search SetMessageExtraInfo in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <WinAPISys.au3>

Global Const $WM_MYMESSAGE = _WinAPI_RegisterWindowMessage('MyMessage')

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 93)
Local $idInput = GUICtrlCreateInput('', 20, 20, 360, 20)
Local $idButton = GUICtrlCreateButton('Send', 165, 59, 70, 23)
GUIRegisterMsg($WM_MYMESSAGE, 'WM_MYMESSAGE')
GUISetState(@SW_SHOW)

Local $pString
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            $pString = _WinAPI_CreateString(GUICtrlRead($idInput))
            _WinAPI_SetMessageExtraInfo($pString)
            _SendMessage($hForm, $WM_MYMESSAGE, 1, 255)
            _WinAPI_FreeMemory($pString)
    EndSwitch
WEnd

Func WM_MYMESSAGE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg

    Local $pString = _WinAPI_GetMessageExtraInfo()

    If _WinAPI_IsMemory($pString) Then
        ConsoleWrite('WM_MYMESSAGE | WP = ' & Number($wParam) & ' | LP = ' & Number($lParam) & ' | EXTRA = "' & _WinAPI_GetString($pString) & '"' & @CRLF)
    EndIf
EndFunc   ;==>WM_MYMESSAGE


Function _WinAPI_SetTimer

Function Reference

_WinAPI_SetTimer

Creates a timer with the specified time-out value

#include <WinAPISys.au3>
_WinAPI_SetTimer ( $hWnd, $iTimerID, $iElapse, $pTimerFunc )

Parameters

$hWnd | Handle to the window to be associated with the timer. This window must be owned by the calling process. If a 0 value for $hWnd is passed in along with an $iTimerID of an existing timer, that timer will be replaced in the same way that an existing non-zero $hWnd timer will be.
$iTimerID | The timer identifier. If the $hWnd parameter is 0, and the $iTimerID does not match an existing timer then it is ignored and a new timer ID is generated. If the $hWnd parameter is not 0 and the window specified by $hWnd already has a timer with the value $iTimerID, then the existing timer is replaced by the new timer. When _WinAPI_SetTimer() replaces a timer, the timer is reset. Therefore, a message will be sent after the current time-out value elapses, but the previously set time-out value is ignored. If the call is not intended to replace an existing timer, $iTimerID should be 0 if the $hWnd is 0.
$iElapse | The time-out value, in milliseconds.
$pTimerFunc | The address of a callback function to be notified when the time-out value elapses. If this parameter is 0, the system posts a WM_TIMER message to the application queue. (See MSDN for more information)

Return Value

Success: | The timer identifier. An application can pass this value to the _WinAPI_KillTimer() function to destroy the timer.
Failure: | 0.

Remarks

The timer identifier, $iTimerID, is specific to the associated window. Another window can have its own timer
which has the same identifier as a timer owned by another window. The timers are distinct.

See Also

Search SetTimer in MSDN Library.

Example

#include <Misc.au3>
#include <WinAPISys.au3>

Opt('TrayAutoPause', 0)

Local $hTimerProc = DllCallbackRegister('_TimerProc', 'none', 'hwnd;uint;uint_ptr;dword')
Global $g_iCount = 0

Local $iTimerID = _WinAPI_SetTimer(0, 0, 1000, DllCallbackGetPtr($hTimerProc))

Do
    Sleep(100)
Until _IsPressed('1B')

_WinAPI_KillTimer(0, $iTimerID)
DllCallbackFree($hTimerProc)

Func _TimerProc($hWnd, $iMsg, $iTimerID, $iTime)
    #forceref $hWnd, $iMsg, $iTimerId, $iTime

    ConsoleWrite($g_iCount & @CRLF)
    $g_iCount += 1
EndFunc   ;==>_TimerProc


Function _WinAPI_SetWindowDisplayAffinity

Function Reference

_WinAPI_SetWindowDisplayAffinity

Stores the display affinity setting in kernel mode on the specified window

#include <WinAPISys.au3>
_WinAPI_SetWindowDisplayAffinity ( $hWnd, $iAffinity )

Parameters

$hWnd | Handle to the window.
$iAffinity | The display affinity setting. This setting specifies where the window's contents are can be displayed. Set this value to $WDA_MONITOR to display the window's contents only on a monitor. Set this value to $WDA_NONE to remove the monitor-only affinity.

Return Value

Success: | True.
Failure: | False.

Remarks

_WinAPI_SetWindowDisplayAffinity() are designed to support the window content protection. This functions
enables applications to protect their own onscreen window content from being captured or copied through a specific
set of public operating system features and APIs. However, it works only when the Desktop Window Manager(DWM)
is composing the desktop.

This function requires Windows 7 or later.

See Also

Search SetWindowDisplayAffinity in MSDN Library.

Example

#include <APIGdiConstants.au3>
#include <APISysConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <ScreenCapture.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

If (_WinAPI_GetVersion() < '6.1') Or (Not _WinAPI_DwmIsCompositionEnabled()) Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows 7 or later with enabled Aero theme.')
    Exit
EndIf

Global $g_iWidth = @DesktopWidth / 2, $g_iHeight = @DesktopHeight / 2

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), $g_iWidth + 116, $g_iHeight + 51)
GUICtrlCreatePic('', 14, 14, $g_iWidth + 2, $g_iHeight + 2, -1, $WS_EX_STATICEDGE)
GUICtrlSetState(-1, $GUI_DISABLE)
Global $g_hPic = GUICtrlGetHandle(-1)
Local $idCheck = GUICtrlCreateCheckbox('Protect against capture of window', 14, $g_iHeight + 23, 182, 21)
Local $idButton = GUICtrlCreateButton('Capture', $g_iWidth + 29, 13, 74, 25)
GUICtrlSetState(-1, BitOR($GUI_DEFBUTTON, $GUI_FOCUS))
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            _Capture()
        Case $idCheck
            If GUICtrlRead($idCheck) = $GUI_CHECKED Then
                _WinAPI_SetWindowDisplayAffinity($hForm, $WDA_MONITOR)
            Else
                _WinAPI_SetWindowDisplayAffinity($hForm, 0)
            EndIf
    EndSwitch
WEnd

Func _Capture()
    Local $hObj = _SendMessage($g_hPic, $STM_SETIMAGE, 0, 0)
    If $hObj Then
        _WinAPI_DeleteObject($hObj)
    EndIf
    Local $hDC = _WinAPI_GetDC($g_hPic)
    Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
    Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $g_iWidth, $g_iHeight)
    Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap)
    Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC)
    $hObj = _ScreenCapture_Capture('', 0, 0, -1, -1, 0)
    Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hObj)
    _WinAPI_SetStretchBltMode($hDestDC, $HALFTONE)
    _WinAPI_StretchBlt($hDestDC, 0, 0, $g_iWidth, $g_iHeight, $hSrcDC, 0, 0, @DesktopWidth, @DesktopHeight, $SRCCOPY)
    _WinAPI_ReleaseDC($g_hPic, $hDC)
    _WinAPI_SelectObject($hDestDC, $hDestSv)
    _WinAPI_DeleteDC($hDestDC)
    _WinAPI_SelectObject($hSrcDC, $hSrcSv)
    _WinAPI_DeleteObject($hObj)
    _WinAPI_DeleteDC($hSrcDC)
    _SendMessage($g_hPic, $STM_SETIMAGE, 0, $hBitmap)
    $hObj = _SendMessage($g_hPic, $STM_GETIMAGE)
    If $hObj <> $hBitmap Then
        _WinAPI_DeleteObject($hBitmap)
    EndIf
EndFunc   ;==>_Capture


Function _WinAPI_ShowOwnedPopups

Function Reference

_WinAPI_ShowOwnedPopups

Shows or hides all pop-up windows owned by the specified window

#include <WinAPISys.au3>
_WinAPI_ShowOwnedPopups ( $hWnd, $bShow )

Parameters

$hWnd | A handle to the window that owns the pop-up windows to be shown or hidden.
$bShow | Specifies whether pop-up windows are to be shown or hidden, valid values: True - All hidden pop-up windows are shown. False - All visible pop-up windows are hidden.

Return Value

Success: | True
Failure: | False

Remarks

This function shows only windows hidden by a previous call to _WinAPI_ShowOwnedPopups().

See Also

Search ShowOwnedPopups in MSDN Library.


Function _WinAPI_SwitchToThisWindow

Function Reference

_WinAPI_SwitchToThisWindow

Switches the focus to a specified window and bring it to the foreground

#include <WinAPISys.au3>
_WinAPI_SwitchToThisWindow ( $hWnd [, $bAltTab = False] )

Parameters

$hWnd | Handle to the window being switched to.
$bAltTab | [optional] Specifies whether switches to using the Alt/Ctl+Tab key sequence, valid values: True - The window is being switched to using the Alt/Ctl+Tab key sequence. False - Otherwise (Default).

Return Value

None.

See Also

Search SwitchToThisWindow in MSDN Library.


Function _WinAPI_TileWindows

Function Reference

_WinAPI_TileWindows

Tiles the specified child windows of the specified parent window

#include <WinAPISys.au3>
_WinAPI_TileWindows ( $aWnds [, $tRECT = 0 [, $hParent = 0 [, $iFlags = 0 [, $iStart = 0 [, $iEnd = -1]]]]] )

Parameters

$aWnds | The array of handles to the child windows to arrange. If a specified child window is a top-level window with the style $WS_EX_TOPMOST or $WS_EX_TOOLWINDOW, the child window is not arranged. If this parameter is 0, all child windows of the specified parent window (or of the desktop window) are arranged.
$tRECT | [optional] $tagRECT structure that specifies the rectangular area, in client coordinates, within which the windows are arranged. If this parameter is 0 (Default), the client area of the parent window is used.
$hParent | [optional] Handle to the parent window. If this parameter is 0 (Default), the desktop window is assumed.
$iFlags | [optional] A cascade flag. This parameter can be one or more of the following values. $MDITILE_HORIZONTAL $MDITILE_VERTICAL (Default)
$iStart | [optional] The index of array to start arranging at.
$iEnd | [optional] The index of array to stop arranging at.

Return Value

Success: | The value is the number of windows arranged.
Failure: | 0.

See Also

Search TileWindows in MSDN Library.

Example

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

Local $aWnds[4]

For $i = 0 To UBound($aWnds) - 1
    $aWnds[$i] = GUICreate('#' & ($i + 1), 400, 400, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_SIZEBOX, $WS_SYSMENU))
    GUISetState(@SW_SHOW)
Next

_WinAPI_TileWindows($aWnds, _WinAPI_CreateRectEx(20, 20, 600, 600))

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_UnregisterClass

Function Reference

_WinAPI_UnregisterClass

Unregisters a window class, freeing the memory required for the class

#include <WinAPISys.au3>
_WinAPI_UnregisterClass ( $sClass [, $hInstance = 0] )

Parameters

$sClass | A null-terminated string or a class atom. If $sClass is a string, it specifies the window class name. This class name must have been registered by a previous call to the _WinAPI_RegisterClass() or _WinAPI_RegisterClassEx() function. If this parameter is an atom, it must be in the low-order word of $sClass; the high-order word must be zero.
$hInstance | [optional] Handle to the instance of the module that created the class.

Return Value

Success: | True
Failure: | False

Remarks

Before calling this function, an application must destroy all windows created with the specified class.
All window classes that an application registers are unregistered when it terminates.

Related

_WinAPI_RegisterClass, _WinAPI_RegisterClassEx

See Also

Search UnregisterClass in MSDN Library.


Function _WinAPI_UpdateLayeredWindowEx

Function Reference

_WinAPI_UpdateLayeredWindowEx

Updates a bitmap translucency of a layered window

#include <WinAPISys.au3>
_WinAPI_UpdateLayeredWindowEx ( $hWnd, $iX, $iY, $hBitmap [, $iOpacity = 255 [, $bDelete = False]] )

Parameters

$hWnd | Handle to a layered window. A layered window is created by specifying $WS_EX_LAYERED when its creating.
$iX | The new position of the left side of the window.
$iY | The new position of the top of the window.
$hBitmap | Handle to the bitmap that will be set to the layered window.
$iOpacity | [optional] The alpha transparency value to be used on the entire source bitmap. Default is 255.
$bDelete | [optional] Specifies whether to delete the bitmap after updated the window, valid values: True - Bitmap will be deleted if the function succeeds. False - Do not delete, you must release the bitmap when you are finished using it (Default).

Return Value

Success: | True
Failure: | False

Remarks

For best drawing performance by the layered window and any underlying windows, the layered window should be
as small as possible.

If $iX and $iY are both equal to (-1), the current window position will not change.

Example

#include <GDIPlus.au3>
#include <Misc.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

_GDIPlus_Startup()
Local $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\Extras\Exclamation.png')
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), _GDIPlus_ImageGetWidth($hImage), _GDIPlus_ImageGetHeight($hImage), -1, -1, $WS_POPUPWINDOW, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
GUISetState(@SW_SHOW)

Local $iOpacity = 0, $iStep = 3
Do
    _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hBitmap, $iOpacity)
    $iOpacity += $iStep
    If ($iOpacity = 0) Or ($iOpacity = 255) Then
        $iStep = -$iStep
        Sleep(500)
    EndIf
    Sleep(10)
Until _IsPressed('1B')

_WinAPI_DeleteObject($hBitmap)


Function _WinAPI_UpdateLayeredWindowIndirect

Function Reference

_WinAPI_UpdateLayeredWindowIndirect

Updates the position, size, shape, content, and translucency of a layered window

#include <WinAPISys.au3>
_WinAPI_UpdateLayeredWindowIndirect ( $hWnd, $tULWINFO )

Parameters

$hWnd | Handle to a layered window. A layered window is created by specifying $WS_EX_LAYERED when its creating.
$tULWINFO | $tagUPDATELAYEREDWINDOWINFO structure that contains the information for the window.

Return Value

Success: | True
Failure: | False

Remarks

For best drawing performance by the layered window and any underlying windows, the layered window should be
as small as possible.

This function requires Windows Vista or later.

See Also

Search UpdateLayeredWindowIndirect in MSDN Library.


User Defined Functions

Theme user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinAPITheme.au3>.

User Defined Function | Description
_WinAPI_BeginBufferedPaint | Begins a buffered paint operation
_WinAPI_BufferedPaintClear | Clears a specified rectangle in the buffer to ARGB = {0,0,0,0}
_WinAPI_BufferedPaintInit | Initialize buffered painting for the current thread
_WinAPI_BufferedPaintSetAlpha | Sets the alpha to a specified value in a given rectangle
_WinAPI_BufferedPaintUnInit | Closes down buffered painting for the current thread
_WinAPI_CloseThemeData | Closes the theme data handle
_WinAPI_DrawThemeBackground | Draws the border and fill defined by the visual style for the specified control part
_WinAPI_DrawThemeEdge | Draws one or more edges defined by the visual style of a rectangle
_WinAPI_DrawThemeIcon | Draws an image from an image list with the icon effect defined by the visual style
_WinAPI_DrawThemeParentBackground | Draws the part of a parent control that is covered by a partially-transparent or alpha-blended child control
_WinAPI_DrawThemeText | Draws text using the color and font defined by the visual style
_WinAPI_DrawThemeTextEx | Draws text using the color and font defined by the visual style
_WinAPI_EndBufferedPaint | Completes a buffered paint operation and frees the associated buffered paint handle
_WinAPI_GetBufferedPaintBits | Retrieves a pointer to the buffer bitmap if the buffer is a device-independent bitmap (DIB)
_WinAPI_GetBufferedPaintDC | Gets the paint device context (DC)
_WinAPI_GetBufferedPaintTargetDC | Retrieves the target device context (DC)
_WinAPI_GetBufferedPaintTargetRect | Retrieves the target rectangle
_WinAPI_GetCurrentThemeName | Retrieves the name of the current visual styles, color scheme name, and size name
_WinAPI_GetThemeAppProperties | Retrieves the property flags that control how visual styles are applied in the current application
_WinAPI_GetThemeBackgroundContentRect | Retrieves the size of the content area for the background defined by the visual style
_WinAPI_GetThemeBackgroundExtent | Calculates the size and location of the background, defined by the visual style, given the content area
_WinAPI_GetThemeBackgroundRegion | Computes the region for a regular or partially transparent background that is bounded by a specified rectangle
_WinAPI_GetThemeBitmap | Retrieves the bitmap associated with a particular theme, part, state, and property
_WinAPI_GetThemeBool | Retrieves the value of a BOOL property from the SysMetrics section of theme data
_WinAPI_GetThemeColor | Retrieves the value of a color property
_WinAPI_GetThemeDocumentationProperty | Retrieves the value for a theme property from the documentation section of the specified theme file
_WinAPI_GetThemeEnumValue | Retrieves the value of an enumerated type property
_WinAPI_GetThemeFilename | Retrieves the value of a filename property
_WinAPI_GetThemeFont | Retrieves the value of a font property
_WinAPI_GetThemeInt | Retrieves the value of an INT property
_WinAPI_GetThemeMargins | Retrieves the value of a margins property
_WinAPI_GetThemeMetric | Retrieves the value of a metric property
_WinAPI_GetThemePartSize | Calculates the original size of the part defined by a visual style
_WinAPI_GetThemePosition | Retrieves the value of a position property
_WinAPI_GetThemePropertyOrigin | Retrieves the location of the theme property definition for a property
_WinAPI_GetThemeRect | Retrieves the value of a RECT property
_WinAPI_GetThemeString | Retrieves the value of a string property
_WinAPI_GetThemeSysBool | Retrieves the Boolean value of a system metric
_WinAPI_GetThemeSysColor | Retrieves the value of a system color
_WinAPI_GetThemeSysColorBrush | Retrieves a system color brush
_WinAPI_GetThemeSysFont | Retrieves the font information of a system font
_WinAPI_GetThemeSysInt | Retrieves the value of a system INT
_WinAPI_GetThemeSysSize | Retrieves the value of a system size metric from theme data
_WinAPI_GetThemeSysString | Retrieves the value of a system string
_WinAPI_GetThemeTextExtent | Calculates the size and location of the specified text when rendered in the visual style font
_WinAPI_GetThemeTextMetrics | Retrieves information about the font specified by a visual style for a particular part
_WinAPI_GetThemeTransitionDuration | Gets the duration for the specified transition
_WinAPI_GetWindowTheme | Retrieves a theme handle to a window that has visual styles applied
_WinAPI_IsThemeActive | Tests if a visual style for the current application is active
_WinAPI_IsThemeBackgroundPartiallyTransparent | Retrieves whether the background specified by the visual style has transparent pieces or alpha-blended pieces
_WinAPI_IsThemePartDefined | Retrieves whether a visual style has defined parameters for the specified part
_WinAPI_OpenThemeData | Opens the theme data for a window and its associated class
_WinAPI_SetThemeAppProperties | Sets the flags that determine how visual styles are implemented in the calling application
_WinAPI_SetWindowTheme | Causes a window to use a different set of visual style information than its class normally uses


Function _WinAPI_BeginBufferedPaint

Function Reference

_WinAPI_BeginBufferedPaint

Begins a buffered paint operation

#include <WinAPITheme.au3>
_WinAPI_BeginBufferedPaint ( $hDC, $tTarget, ByRef $hNewDC [, $iFormat = 0 [, $iFlags = 0 [, $tExclude = 0 [, $iAlpha = -1]]]] )

Parameters

$hDC | Handle of the target DC on which the buffer will be painted.
$tTarget | $tagRECT structure that specifies the area of the target DC in which to paint.
$hNewDC | Handle of the new device context.
$iFormat | [optional] The format of the buffer. This parameter can be one of the following values. $BPBF_COMPATIBLEBITMAP (Default) $BPBF_DIB $BPBF_TOPDOWNDIB $BPBF_TOPDOWNMONODIB
$iFlags | [optional] The additional flags, one or more of the following values. $BPPF_ERASE $BPPF_NOCLIP $BPPF_NONCLIENT
$tExclude | [optional] $tagRECT structure that specifies the area which is excluded from the clipping region.
$iAlpha | [optional] The alpha transparency value to be used on the entire source bitmap. If this parameter is not specified or (-1) (Default), the source buffer is copied to the destination with no blending.

Return Value

Success: | The handle to the buffered paint context.
Failure: | 0, call _WinAPI_GetLastError() to get extended error information.

Remarks

This function requires Windows Vista or later.

See Also

Search BeginBufferedPaint in MSDN Library.

Example

#include <APIThemeConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIShellEx.au3>
#include <WinAPISys.au3>
#include <WinAPITheme.au3>
#include <WindowsConstants.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

; Load bitmap and icon
Local $hTech = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Tech.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Local $hIcon = _WinAPI_ShellExtractIcon(@ScriptDir & '\Extras\NVIDIA.ico', 0, 256, 256)

; Create GUI
GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 302, 302, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
GUICtrlCreatePic('', 0, 0, 302, 302)
Local $hPic = GUICtrlGetHandle(-1)

; Initialize buffered painting
_WinAPI_BufferedPaintInit()

; Select bitmap into DC
Local $hDC = _WinAPI_GetDC($hPic)
Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hTech)

; Begin buffered paint operation
Local $hNewDC
Local $hBP = _WinAPI_BeginBufferedPaint($hSrcDC, _WinAPI_CreateRectEx(22, 22, 256, 256), $hNewDC, $BPBF_COMPATIBLEBITMAP, 0, 0, 160)

; Draw icon with alpha
_WinAPI_DrawIconEx($hNewDC, 22, 22, $hIcon)

; End buffered paint operation and update the reference DC
_WinAPI_EndBufferedPaint($hBP)

; Merge bitmap and release resources
Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 302, 302, 0x606060)
Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap)
_WinAPI_BitBlt($hDestDC, 1, 1, 300, 300, $hSrcDC, 0, 0, $MERGECOPY)
_WinAPI_SelectObject($hDestDC, $hDestSv)
_WinAPI_DeleteDC($hDestDC)
_WinAPI_SelectObject($hSrcDC, $hSrcSv)
_WinAPI_DeleteDC($hSrcDC)
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_DeleteObject($hTech)
_WinAPI_DestroyIcon($hIcon)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

; Closes down buffered painting
_WinAPI_BufferedPaintUnInit()

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_BufferedPaintClear

Function Reference

_WinAPI_BufferedPaintClear

Clears a specified rectangle in the buffer to ARGB = {0,0,0,0}

#include <WinAPITheme.au3>
_WinAPI_BufferedPaintClear ( $hBP [, $tRECT = 0] )

Parameters

$hBP | Handle of the buffered paint context.
$tRECT | [optional] $tagRECT structure that specifies the rectangle to clear. If this parameter is 0 (Default), the entire buffer is used.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

See Also

Search BufferedPaintClear in MSDN Library.


Function _WinAPI_BufferedPaintInit

Function Reference

_WinAPI_BufferedPaintInit

Initialize buffered painting for the current thread

#include <WinAPITheme.au3>
_WinAPI_BufferedPaintInit ( )

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

Each call to _WinAPI_BufferedPaintInit() should be matched with a call to _WinAPI_BufferedPaintUnInit() when calls to buffered paint APIs are no longer needed.

This function requires Windows Vista or later.

Related

_WinAPI_BufferedPaintUnInit

See Also

Search BufferedPaintInit in MSDN Library.

Example

#include <APIThemeConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIShellEx.au3>
#include <WinAPISys.au3>
#include <WinAPITheme.au3>
#include <WindowsConstants.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

; Load bitmap and icon
Local $hTech = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Tech.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Local $hIcon = _WinAPI_ShellExtractIcon(@ScriptDir & '\Extras\NVIDIA.ico', 0, 256, 256)

; Create GUI
GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 302, 302, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
GUICtrlCreatePic('', 0, 0, 302, 302)
Local $hPic = GUICtrlGetHandle(-1)

; Initialize buffered painting
_WinAPI_BufferedPaintInit()

; Select bitmap into DC
Local $hDC = _WinAPI_GetDC($hPic)
Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hTech)

; Begin buffered paint operation
Local $hNewDC
Local $hBP = _WinAPI_BeginBufferedPaint($hSrcDC, _WinAPI_CreateRectEx(22, 22, 256, 256), $hNewDC, $BPBF_COMPATIBLEBITMAP, 0, 0, 160)

; Draw icon with alpha
_WinAPI_DrawIconEx($hNewDC, 22, 22, $hIcon)

; End buffered paint operation and update the reference DC
_WinAPI_EndBufferedPaint($hBP)

; Merge bitmap and release resources
Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 302, 302, 0x606060)
Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap)
_WinAPI_BitBlt($hDestDC, 1, 1, 300, 300, $hSrcDC, 0, 0, $MERGECOPY)
_WinAPI_SelectObject($hDestDC, $hDestSv)
_WinAPI_DeleteDC($hDestDC)
_WinAPI_SelectObject($hSrcDC, $hSrcSv)
_WinAPI_DeleteDC($hSrcDC)
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_DeleteObject($hTech)
_WinAPI_DestroyIcon($hIcon)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

; Closes down buffered painting
_WinAPI_BufferedPaintUnInit()

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_BufferedPaintSetAlpha

Function Reference

_WinAPI_BufferedPaintSetAlpha

Sets the alpha to a specified value in a given rectangle

#include <WinAPITheme.au3>
_WinAPI_BufferedPaintSetAlpha ( $hBP [, $iAlpha = 255 [, $tRECT = 0]] )

Parameters

$hBP | Handle of the buffered paint context.
$iAlpha | [optional] The alpha value to set. The alpha value can range from zero (fully transparent) to 255 (Default)(fully opaque).
$tRECT | [optional] $tagRECT structure that specifies the rectangle in which to set the alpha. If this parameter is 0 (Default), the entire buffer is used.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

See Also

Search BufferedPaintSetAlpha in MSDN Library.


Function _WinAPI_BufferedPaintUnInit

Function Reference

_WinAPI_BufferedPaintUnInit

Closes down buffered painting for the current thread

#include <WinAPITheme.au3>
_WinAPI_BufferedPaintUnInit ( )

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

Related

_WinAPI_BufferedPaintInit

See Also

Search BufferedPaintUnInit in MSDN Library.

Example

#include <APIThemeConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIShellEx.au3>
#include <WinAPISys.au3>
#include <WinAPITheme.au3>
#include <WindowsConstants.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

; Load bitmap and icon
Local $hTech = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Tech.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Local $hIcon = _WinAPI_ShellExtractIcon(@ScriptDir & '\Extras\NVIDIA.ico', 0, 256, 256)

; Create GUI
GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 302, 302, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
GUICtrlCreatePic('', 0, 0, 302, 302)
Local $hPic = GUICtrlGetHandle(-1)

; Initialize buffered painting
_WinAPI_BufferedPaintInit()

; Select bitmap into DC
Local $hDC = _WinAPI_GetDC($hPic)
Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hTech)

; Begin buffered paint operation
Local $hNewDC
Local $hBP = _WinAPI_BeginBufferedPaint($hSrcDC, _WinAPI_CreateRectEx(22, 22, 256, 256), $hNewDC, $BPBF_COMPATIBLEBITMAP, 0, 0, 160)

; Draw icon with alpha
_WinAPI_DrawIconEx($hNewDC, 22, 22, $hIcon)

; End buffered paint operation and update the reference DC
_WinAPI_EndBufferedPaint($hBP)

; Merge bitmap and release resources
Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 302, 302, 0x606060)
Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap)
_WinAPI_BitBlt($hDestDC, 1, 1, 300, 300, $hSrcDC, 0, 0, $MERGECOPY)
_WinAPI_SelectObject($hDestDC, $hDestSv)
_WinAPI_DeleteDC($hDestDC)
_WinAPI_SelectObject($hSrcDC, $hSrcSv)
_WinAPI_DeleteDC($hSrcDC)
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_DeleteObject($hTech)
_WinAPI_DestroyIcon($hIcon)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

; Closes down buffered painting
_WinAPI_BufferedPaintUnInit()

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_CloseThemeData

Function Reference

_WinAPI_CloseThemeData

Closes the theme data handle

#include <WinAPITheme.au3>
_WinAPI_CloseThemeData ( $hTheme )

Parameters

$hTheme Handle to a window's specified theme data.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Related

_WinAPI_OpenThemeData

See Also

Search CloseThemeData in MSDN Library.


Function _WinAPI_DrawThemeBackground

Function Reference

_WinAPI_DrawThemeBackground

Draws the border and fill defined by the visual style for the specified control part

#include <WinAPITheme.au3>
_WinAPI_DrawThemeBackground ( $hTheme, $iPartID, $iStateID, $hDC, $tRECT [, $tCLIP = 0] )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part to draw.
$iStateID | The state of the part to draw.
$hDC | Handle to the device context for drawing the theme-defined background image.
$tRECT | $tagRECT structure that contains the rectangle in which the background image is drawn.
$tCLIP | [optional] $tagRECT structure that contains a clipping rectangle.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the system error code.

See Also

Search DrawThemeBackground in MSDN Library.

Example

#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WinAPIGdi.au3>
#include <WinAPITheme.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 160, 199)
Local $idPic = GUICtrlCreatePic('', 0, 0, 160, 199)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDev = _WinAPI_GetDC($hPic)
Local $hDC = _WinAPI_CreateCompatibleDC($hDev)
Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, 160, 199, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hSv = _WinAPI_SelectObject($hDC, $hSource)

; Draw objects
Local $tRECT = _WinAPI_CreateRectEx(25, 25, 110, 25)
Local $hFont = _WinAPI_CreateFont(12, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'MS Shell Dlg')
_WinAPI_SetBkMode($hDC, $TRANSPARENT)
_WinAPI_SelectObject($hDC, $hFont)
Local $hTheme = _WinAPI_OpenThemeData($hForm, 'Button')
If Not @error Then
    For $i = 1 To 5
        _WinAPI_DrawThemeBackground($hTheme, 1, $i, $hDC, $tRECT)
        _WinAPI_DrawThemeText($hTheme, 1, $i, $hDC, 'OK', $tRECT, BitOR($DT_CENTER, $DT_SINGLELINE, $DT_VCENTER))
        _WinAPI_OffsetRect($tRECT, 0, 31)
    Next
    _WinAPI_CloseThemeData($hTheme)
EndIf

; Merge bitmap
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDev, 160, 199)
_WinAPI_SelectObject($hDC, $hBitmap)
_WinAPI_DrawBitmap($hDC, 0, 0, $hSource, $MERGECOPY)
_WinAPI_ReleaseDC($hPic, $hDev)
_WinAPI_SelectObject($hDC, $hSv)
_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteDC($hDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_DrawThemeEdge

Function Reference

_WinAPI_DrawThemeEdge

Draws one or more edges defined by the visual style of a rectangle

#include <WinAPITheme.au3>
_WinAPI_DrawThemeEdge ( $hTheme, $iPartID, $iStateID, $hDC, $tRECT, $iEdge, $iFlags [, $tAREA = 0] )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part that contains the rectangle.
$iStateID | The state of the part.
$hDC | Handle to the device context.
$tRECT | $tagRECT structure that contains the rectangle.
$iEdge | The type of inner and outer edges to draw. This parameter must be a combination of one inner-border flag and one outer-border flag ($BDR_*), or one of the combination flags ($EDGE_*).
$iFlags | The type of border to draw. It can be a combination of the $BF_* constants.
$tAREA | [optional] $tagRECT structure that contains the rectangle that receives the interior rectangle, if $BF_ADJUST is used.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

$BDR_* , $EDGE_* , $BF_* constants require #include <BorderConstants.au3>.

See Also

Search DrawThemeEdge in MSDN Library.


Function _WinAPI_DrawThemeIcon

Function Reference

_WinAPI_DrawThemeIcon

Draws an image from an image list with the icon effect defined by the visual style

#include <WinAPITheme.au3>
_WinAPI_DrawThemeIcon ( $hTheme, $iPartID, $iStateID, $hDC, $tRECT, $hIL, $iIndex )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part in which the image is drawn.
$iStateID | The state of the part.
$hDC | Handle to the device context.
$tRECT | $tagRECT structure that contains the rectangle in which the image is drawn.
$hIL | Handle to an image list that contains the image to draw.
$iIndex | The index of the image to draw.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search DrawThemeIcon in MSDN Library.


Function _WinAPI_DrawThemeParentBackground

Function Reference

_WinAPI_DrawThemeParentBackground

Draws the part of a parent control that is covered by a partially-transparent or alpha-blended child control

#include <WinAPITheme.au3>
_WinAPI_DrawThemeParentBackground ( $hWnd, $hDC [, $tRECT = 0] )

Parameters

$hWnd | Handle of the child control.
$hDC | Handle to the child control's DC.
$tRECT | [optional] $tagRECT structure that defines the area, in the child window's coordinates, to be drawn.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search DrawThemeParentBackground in MSDN Library.


Function _WinAPI_DrawThemeText

Function Reference

_WinAPI_DrawThemeText

Draws text using the color and font defined by the visual style

#include <WinAPITheme.au3>
_WinAPI_DrawThemeText ( $hTheme, $iPartID, $iStateID, $hDC, $sText, $tRECT, $iFlags )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part that has the desired text appearance. If this value is 0, the text is drawn in the default font, or a font selected into the device context.
$iStateID | The state of the part.
$hDC | Handle to the device context to use for drawing.
$sText | The string that contains the text to draw.
$tRECT | $tagRECT structure that contains the rectangle in which the text is to be drawn.
$iFlags | The string's formatting flags ($DT_*).

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search DrawThemeText in MSDN Library.

Example

#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WinAPIGdi.au3>
#include <WinAPITheme.au3>
#include <WindowsConstants.au3>

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 160, 199)
Local $idPic = GUICtrlCreatePic('', 0, 0, 160, 199)
Local $hPic = GUICtrlGetHandle($idPic)

; Create bitmap
Local $hDev = _WinAPI_GetDC($hPic)
Local $hDC = _WinAPI_CreateCompatibleDC($hDev)
Local $hSource = _WinAPI_CreateCompatibleBitmapEx($hDev, 160, 199, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE)))
Local $hSv = _WinAPI_SelectObject($hDC, $hSource)

; Draw objects
Local $tRECT = _WinAPI_CreateRectEx(25, 25, 110, 25)
Local $hFont = _WinAPI_CreateFont(12, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'MS Shell Dlg')
_WinAPI_SetBkMode($hDC, $TRANSPARENT)
_WinAPI_SelectObject($hDC, $hFont)
Local $hTheme = _WinAPI_OpenThemeData($hForm, 'Button')
If Not @error Then
    For $i = 1 To 5
        _WinAPI_DrawThemeBackground($hTheme, 1, $i, $hDC, $tRECT)
        _WinAPI_DrawThemeText($hTheme, 1, $i, $hDC, 'OK', $tRECT, BitOR($DT_CENTER, $DT_SINGLELINE, $DT_VCENTER))
        _WinAPI_OffsetRect($tRECT, 0, 31)
    Next
    _WinAPI_CloseThemeData($hTheme)
EndIf

; Merge bitmap
Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDev, 160, 199)
_WinAPI_SelectObject($hDC, $hBitmap)
_WinAPI_DrawBitmap($hDC, 0, 0, $hSource, $MERGECOPY)
_WinAPI_ReleaseDC($hPic, $hDev)
_WinAPI_SelectObject($hDC, $hSv)
_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteDC($hDC)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_DrawThemeTextEx

Function Reference

_WinAPI_DrawThemeTextEx

Draws text using the color and font defined by the visual style

#include <WinAPITheme.au3>
_WinAPI_DrawThemeTextEx ( $hTheme, $iPartID, $iStateID, $hDC, $sText, $tRECT, $iFlags, $tDTTOPTS )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part that has the desired text appearance. If this value is 0, the text is drawn in the default font, or a font selected into the device context.
$iStateID | The state of the part.
$hDC | Handle to the device context to use for drawing.
$sText | The string that contains the text to draw.
$tRECT | $tagRECT structure that contains the rectangle in which the text is to be drawn.
$iFlags | The string's formatting flags ($DT_*).
$tDTTOPTS | $tagDTTOPTS structure that defines additional formatting options.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

See Also

Search DrawThemeTextEx in MSDN Library.

Example

#include <APIThemeConstants.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WinAPIGdi.au3>
#include <WinAPITheme.au3>
#include <WindowsConstants.au3>

If Not _WinAPI_DwmIsCompositionEnabled() Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later with enabled Aero theme.')
    Exit
EndIf

OnAutoItExitRegister('OnAutoItExit')

; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 240, 240)
GUICtrlCreateIcon(@ScriptDir & '\Extras\Soccer.ico', 0, 88, 68, 64, 64)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateLabel('', 70, 130, 100, 30)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetState(-1, $GUI_DISABLE)
Global $g_hLabel = GUICtrlGetHandle(-1)
GUISetBkColor(0)

; Register label window proc
Global $g_hDll = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam')
Local $pDll = DllCallbackGetPtr($g_hDll)
Global $g_hProc = _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $pDll)

; Create the "sheet of glass" effect for the entire window. You must call this function whenever DWM composition is toggled.
_WinAPI_DwmExtendFrameIntoClientArea($hForm)

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func _DrawText($hDC, $sText, $tRECT)
    ; Original idea by Authenticity
    Local $iWidth = DllStructGetData($tRECT, 3) - DllStructGetData($tRECT, 1)
    Local $iHeight = DllStructGetData($tRECT, 4) - DllStructGetData($tRECT, 2)

    Local $tDTTOPTS = DllStructCreate($tagDTTOPTS)
    DllStructSetData($tDTTOPTS, 'Size', DllStructGetSize($tDTTOPTS))
    DllStructSetData($tDTTOPTS, 'Flags', BitOR($DTT_TEXTCOLOR, $DTT_GLOWSIZE, $DTT_COMPOSITED))
    DllStructSetData($tDTTOPTS, 'clrText', 0x0000C0)
    DllStructSetData($tDTTOPTS, 'GlowSize', 12)

    Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
    Local $hBitmap = _WinAPI_CreateDIB($iWidth, -$iHeight)
    Local $hSv1 = _WinAPI_SelectObject($hMemDC, $hBitmap)
    Local $hFont = _WinAPI_CreateFont(26, 0, 0, 0, $FW_NORMAL, 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'Segoe Script')
    Local $hSv2 = _WinAPI_SelectObject($hMemDC, $hFont)
    $tRECT = _WinAPI_CreateRect(0, 0, $iWidth, $iHeight)
    Local $hTheme = _WinAPI_OpenThemeData($hForm, 'Globals')

    _WinAPI_DrawThemeTextEx($hTheme, 0, 0, $hMemDC, $sText, $tRECT, BitOR($DT_CENTER, $DT_SINGLELINE, $DT_VCENTER), $tDTTOPTS)
    _WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hMemDC, 0, 0, $SRCCOPY)

    _WinAPI_CloseThemeData($hTheme)
    _WinAPI_SelectObject($hMemDC, $hSv1)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_SelectObject($hMemDC, $hSv2)
    _WinAPI_DeleteObject($hFont)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>_DrawText

Func _WinProc($hWnd, $iMsg, $wParam, $lParam)
    Switch $iMsg
        Case $WM_PAINT
            Local $tPAINTSTRUCT
            Local $hDC = _WinAPI_BeginPaint($hWnd, $tPAINTSTRUCT)
            _DrawText($hDC, 'Soccer', _WinAPI_GetClientRect($hWnd))
            _WinAPI_EndPaint($hWnd, $tPAINTSTRUCT)
            Return 0
    EndSwitch
    Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_WinProc

Func OnAutoItExit()
    _WinAPI_SetWindowLong($g_hLabel, $GWL_WNDPROC, $g_hProc)
    DllCallbackFree($g_hDll)
EndFunc   ;==>OnAutoItExit


Function _WinAPI_EndBufferedPaint

Function Reference

_WinAPI_EndBufferedPaint

Completes a buffered paint operation and frees the associated buffered paint handle

#include <WinAPITheme.au3>
_WinAPI_EndBufferedPaint ( $hBP [, $bUpdate = True] )

Parameters

$hBP | Handle of the buffered paint context.
$bUpdate | [optional] Specifies whether copy the buffer to the target DC, valid values: True - The target DC will be updated from the buffer (Default). False - The target DC remains unchanged.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

See Also

Search EndBufferedPaint in MSDN Library.

Example

#include <APIThemeConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIShellEx.au3>
#include <WinAPISys.au3>
#include <WinAPITheme.au3>
#include <WindowsConstants.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

; Load bitmap and icon
Local $hTech = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Tech.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Local $hIcon = _WinAPI_ShellExtractIcon(@ScriptDir & '\Extras\NVIDIA.ico', 0, 256, 256)

; Create GUI
GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 302, 302, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
GUICtrlCreatePic('', 0, 0, 302, 302)
Local $hPic = GUICtrlGetHandle(-1)

; Initialize buffered painting
_WinAPI_BufferedPaintInit()

; Select bitmap into DC
Local $hDC = _WinAPI_GetDC($hPic)
Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hTech)

; Begin buffered paint operation
Local $hNewDC
Local $hBP = _WinAPI_BeginBufferedPaint($hSrcDC, _WinAPI_CreateRectEx(22, 22, 256, 256), $hNewDC, $BPBF_COMPATIBLEBITMAP, 0, 0, 160)

; Draw icon with alpha
_WinAPI_DrawIconEx($hNewDC, 22, 22, $hIcon)

; End buffered paint operation and update the reference DC
_WinAPI_EndBufferedPaint($hBP)

; Merge bitmap and release resources
Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 302, 302, 0x606060)
Local $hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap)
_WinAPI_BitBlt($hDestDC, 1, 1, 300, 300, $hSrcDC, 0, 0, $MERGECOPY)
_WinAPI_SelectObject($hDestDC, $hDestSv)
_WinAPI_DeleteDC($hDestDC)
_WinAPI_SelectObject($hSrcDC, $hSrcSv)
_WinAPI_DeleteDC($hSrcDC)
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_DeleteObject($hTech)
_WinAPI_DestroyIcon($hIcon)

; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

; Closes down buffered painting
_WinAPI_BufferedPaintUnInit()

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_GetBufferedPaintBits

Function Reference

_WinAPI_GetBufferedPaintBits

Retrieves a pointer to the buffer bitmap if the buffer is a device-independent bitmap (DIB)

#include <WinAPITheme.au3>
_WinAPI_GetBufferedPaintBits ( $hBP )

Parameters

$hBP Handle of the buffered paint context.

Return Value

Success: | A pointer to the address of the buffer bitmap pixels, @extended flag will contain the width of the buffer bitmap, in pixels.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

See Also

Search GetBufferedPaintBits in MSDN Library.


Function _WinAPI_GetBufferedPaintDC

Function Reference

_WinAPI_GetBufferedPaintDC

Gets the paint device context (DC)

#include <WinAPITheme.au3>
_WinAPI_GetBufferedPaintDC ( $hBP )

Parameters

$hBP Handle of the buffered paint context.

Return Value

Success: | Handle of the requested DC. This is the same DC that is returned by _WinAPI_BeginBufferedPaint().
Failure: | 0.

Remarks

This function requires Windows Vista or later.

Related

_WinAPI_BeginBufferedPaint

See Also

Search GetBufferedPaintDC in MSDN Library.


Function _WinAPI_GetBufferedPaintTargetDC

Function Reference

_WinAPI_GetBufferedPaintTargetDC

Retrieves the target device context (DC)

#include <WinAPITheme.au3>
_WinAPI_GetBufferedPaintTargetDC ( $hBP )

Parameters

$hBP Handle of the buffered paint context.

Return Value

Success: | Handle of the requested DC. This is the same DC that was passed to _WinAPI_BeginBufferedPaint().
Failure: | 0.

Remarks

This function requires Windows Vista or later.

Related

_WinAPI_BeginBufferedPaint

See Also

Search GetBufferedPaintTargetDC in MSDN Library.


Function _WinAPI_GetBufferedPaintTargetRect

Function Reference

_WinAPI_GetBufferedPaintTargetRect

Retrieves the target rectangle

#include <WinAPITheme.au3>
_WinAPI_GetBufferedPaintTargetRect ( $hBP )

Parameters

$hBP Handle of the buffered paint context.

Return Value

Success: | $tagRECT structure that contains the rectangle specified by _WinAPI_BeginBufferedPaint() function.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

Related

_WinAPI_BeginBufferedPaint

See Also

Search GetBufferedPaintTargetRect in MSDN Library.


Function _WinAPI_GetCurrentThemeName

Function Reference

_WinAPI_GetCurrentThemeName

Retrieves the name of the current visual styles, color scheme name, and size name

#include <WinAPITheme.au3>
_WinAPI_GetCurrentThemeName ( )

Return Value

Success: | The array that contains the following information: [0] - The theme path and file name. [1] - The color scheme name. [2] - The size name.
Failure: | Set the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetCurrentThemeName in MSDN Library.

Example

#include <APIThemeConstants.au3>
#include <WinAPITheme.au3>

Local $aData = _WinAPI_GetCurrentThemeName()
If IsArray($aData) Then
    ConsoleWrite('File:    ' & $aData[0] & @CRLF)
    ConsoleWrite('Color:   ' & $aData[1] & @CRLF)
    ConsoleWrite('Size:    ' & $aData[2] & @CRLF)
    ConsoleWrite('Name:    ' & _WinAPI_GetThemeDocumentationProperty($aData[0], $SZ_THDOCPROP_CANONICALNAME) & @CRLF)
    ConsoleWrite('Display: ' & _WinAPI_GetThemeDocumentationProperty($aData[0], $SZ_THDOCPROP_DISPLAYNAME) & @CRLF)
    ConsoleWrite('Tooltip: ' & _WinAPI_GetThemeDocumentationProperty($aData[0], $SZ_THDOCPROP_TOOLTIP) & @CRLF)
    ConsoleWrite('Author:  ' & _WinAPI_GetThemeDocumentationProperty($aData[0], $SZ_THDOCPROP_AUTHOR) & @CRLF)
EndIf


Function _WinAPI_GetThemeAppProperties

Function Reference

_WinAPI_GetThemeAppProperties

Retrieves the property flags that control how visual styles are applied in the current application

#include <WinAPITheme.au3>
_WinAPI_GetThemeAppProperties ( )

Return Value

Returns the property bit flags ($STAP_ALLOW_*) combined with a logical OR operator.

Remarks

Individual flags can be extracted from the result by combining the result with the logical
AND of the desired flag.

See Also

Search GetThemeAppProperties in MSDN Library.

Example

#include <APIThemeConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPITheme.au3>

Local $iTheme = _WinAPI_GetThemeAppProperties()

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 310, 360)
GUISetFont(8.5, 400, 0, 'MS Shell Dlg', $hForm)
GUICtrlCreateGroup('Group', 10, 10, 140, 95)
GUICtrlCreateCheckbox('Check1', 22, 26, 120, 23)
GUICtrlCreateCheckbox('Check2', 22, 49, 120, 23)
GUICtrlCreateCheckbox('Check3', 22, 72, 120, 23)
GUICtrlCreateGroup('Group', 160, 10, 140, 95)
GUICtrlCreateRadio('Radio1', 172, 26, 120, 23)
GUICtrlCreateRadio('Radio2', 172, 49, 120, 23)
GUICtrlCreateRadio('Radio3', 172, 72, 120, 23)
GUICtrlCreateButton('OK', 120, 330, 70, 23)
_WinAPI_SetThemeAppProperties($STAP_ALLOW_NONCLIENT)
GUICtrlCreateTab(10, 118, 292, 206)
GUICtrlCreateTabItem('Tab1')
GUICtrlCreateTabItem('Tab2')
GUICtrlCreateTabItem('')
_WinAPI_SetThemeAppProperties($iTheme)

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_GetThemeBackgroundContentRect

Function Reference

_WinAPI_GetThemeBackgroundContentRect

Retrieves the size of the content area for the background defined by the visual style

#include <WinAPITheme.au3>
_WinAPI_GetThemeBackgroundContentRect ( $hTheme, $iPartID, $iStateID, $hDC, $tRECT )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part that contains the content area.
$iStateID | The state of the part.
$hDC | Handle to the device context to use when drawing.
$tRECT | $tagRECT structure that contains the total background rectangle. This is the area inside the borders or margins.

Return Value

Success: | $tagRECT structure that contains the content area background rectangle.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetThemeBackgroundContentRect in MSDN Library.


Function _WinAPI_GetThemeBackgroundExtent

Function Reference

_WinAPI_GetThemeBackgroundExtent

Calculates the size and location of the background, defined by the visual style, given the content area

#include <WinAPITheme.au3>
_WinAPI_GetThemeBackgroundExtent ( $hTheme, $iPartID, $iStateID, $hDC, $tRECT )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part that contains the content area.
$iStateID | The state of the part.
$hDC | Handle to the device context to use when drawing.
$tRECT | $tagRECT structure that contains the content background rectangle.

Return Value

Success: | $tagRECT structure that contains the background rectangle.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetThemeBackgroundExtent in MSDN Library.


Function _WinAPI_GetThemeBackgroundRegion

Function Reference

_WinAPI_GetThemeBackgroundRegion

Computes the region for a regular or partially transparent background that is bounded by a specified rectangle

#include <WinAPITheme.au3>
_WinAPI_GetThemeBackgroundRegion ( $hTheme, $iPartID, $iStateID, $hDC, $tRECT )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part that contains the region.
$iStateID | The state of the part.
$hDC | Handle to the device context to draw into.
$tRECT | $tagRECT structure that contains the specified rectangle used to compute the region.

Return Value

Success: | Handle to the computed region.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

The region handle that is returned by this function should be released when it is no longer needed,
using _WinAPI_DeleteObject().

Related

_WinAPI_DeleteObject

See Also

Search GetThemeBackgroundRegion in MSDN Library.


Function _WinAPI_GetThemeBitmap

Function Reference

_WinAPI_GetThemeBitmap

Retrieves the bitmap associated with a particular theme, part, state, and property

#include <WinAPITheme.au3>
_WinAPI_GetThemeBitmap ( $hTheme, $iPartID, $iStateID, $iPropID [, $iFlag = 0x01] )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part that contains the bitmap.
$iStateID | The state of the part.
$iPropID | The property to retrieve. Set this parameter to 0 to automatically select the first available bitmap for this part and state, or use one of the following values. $TMT_DIBDATA $TMT_GLYPHDIBDATA $TMT_HBITMAP
$iFlag | [optional] This parameter can be one of the following values. $GBF_DIRECT $GBF_COPY $GBF_VALIDBITS

Return Value

Success: | Handle to the requested bitmap.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

If $iFlag is set to $GBF_COPY, release the bitmap returned by this function when no longer needed by calling
_WinAPI_DeleteObject().

This function requires Windows Vista or later.

Related

_WinAPI_DeleteObject

See Also

Search GetThemeBitmap in MSDN Library.


Function _WinAPI_GetThemeBool

Function Reference

_WinAPI_GetThemeBool

Retrieves the value of a BOOL property from the SysMetrics section of theme data

#include <WinAPITheme.au3>
_WinAPI_GetThemeBool ( $hTheme, $iPartID, $iStateID, $iPropID )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part that contains the BOOL property.
$iStateID | The state of the part.
$iPropID | The property to retrieve. It can be one of the following values. $TMT_TRANSPARENT $TMT_AUTOSIZE $TMT_BORDERONLY $TMT_COMPOSITED $TMT_BGFILL $TMT_GLYPHTRANSPARENT $TMT_GLYPHONLY $TMT_ALWAYSSHOWSIZINGBAR $TMT_MIRRORIMAGE $TMT_UNIFORMSIZING $TMT_INTEGRALSIZING $TMT_SOURCEGROW $TMT_SOURCESHRINK $TMT_USERPICTURE

Return Value

Success: | The retrieved property value.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetThemeBool in MSDN Library.


Function _WinAPI_GetThemeColor

Function Reference

_WinAPI_GetThemeColor

Retrieves the value of a color property

#include <WinAPITheme.au3>
_WinAPI_GetThemeColor ( $hTheme, $iPartID, $iStateID, $iPropID )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part that contains the color property.
$iStateID | The state of the part.
$iPropID | The property to retrieve ($TMT_*).

Return Value

Success: | The color value, in RGB.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetThemeColor in MSDN Library.

Example

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

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)
GUISetFont(8.5, 400, 0, 'MS Shell Dlg', $hForm)
Local $idButton = GUICtrlCreateButton('Set Theme Color', 140, 368, 115, 23)
GUICtrlCreateTab(7, 7, 388, 354)
GUICtrlCreateTabItem('About')
Local $idSlider = GUICtrlCreateSlider(20, 45, 360, 26)
GUICtrlCreateTabItem('')
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $idButton
            GUICtrlSetBkColor($idSlider, _GetTabBodyColor($hForm))
            GUICtrlSetState($idButton, $GUI_DISABLE)
    EndSwitch
WEnd

Func _GetTabBodyColor($hForm)
    Local $iDefault = _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE))

    Local $hTheme = _WinAPI_OpenThemeData($hForm, 'TAB')
    If @error Then
        Return $iDefault
    EndIf
    Local $iPart
    Switch @OSVersion
        Case 'WIN_XP', 'WIN_2003'
            $iPart = 10 ; TABP_BODY
        Case Else
            $iPart = 11 ; TABP_AEROWIZARDBODY
    EndSwitch
    Local $iColor = _WinAPI_GetThemeColor($hTheme, $iPart, 1, $TMT_FILLCOLORHINT)
    _WinAPI_CloseThemeData($hTheme)
    If $iColor < 0 Then
        Return $iDefault
    EndIf
    Return $iColor
EndFunc   ;==>_GetTabBodyColor


Function _WinAPI_GetThemeDocumentationProperty

Function Reference

_WinAPI_GetThemeDocumentationProperty

Retrieves the value for a theme property from the documentation section of the specified theme file

#include <WinAPITheme.au3>
_WinAPI_GetThemeDocumentationProperty ( $sFilePath, $sProperty )

Parameters

$sFilePath | The name of the theme file that will be opened to query for the property.
$sProperty | The name of the theme property to query. This parameter can be one of the following values. $SZ_THDOCPROP_AUTHOR $SZ_THDOCPROP_CANONICALNAME $SZ_THDOCPROP_DISPLAYNAME $SZ_THDOCPROP_TOOLTIP

Return Value

Success: | The property string value.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetThemeDocumentationProperty in MSDN Library.

Example

#include <APIThemeConstants.au3>
#include <WinAPITheme.au3>

Local $aData = _WinAPI_GetCurrentThemeName()
If IsArray($aData) Then
    ConsoleWrite('File:    ' & $aData[0] & @CRLF)
    ConsoleWrite('Color:   ' & $aData[1] & @CRLF)
    ConsoleWrite('Size:    ' & $aData[2] & @CRLF)
    ConsoleWrite('Name:    ' & _WinAPI_GetThemeDocumentationProperty($aData[0], $SZ_THDOCPROP_CANONICALNAME) & @CRLF)
    ConsoleWrite('Display: ' & _WinAPI_GetThemeDocumentationProperty($aData[0], $SZ_THDOCPROP_DISPLAYNAME) & @CRLF)
    ConsoleWrite('Tooltip: ' & _WinAPI_GetThemeDocumentationProperty($aData[0], $SZ_THDOCPROP_TOOLTIP) & @CRLF)
    ConsoleWrite('Author:  ' & _WinAPI_GetThemeDocumentationProperty($aData[0], $SZ_THDOCPROP_AUTHOR) & @CRLF)
EndIf


Function _WinAPI_GetThemeEnumValue

Function Reference

_WinAPI_GetThemeEnumValue

Retrieves the value of an enumerated type property

#include <WinAPITheme.au3>
_WinAPI_GetThemeEnumValue ( $hTheme, $iPartID, $iStateID, $iPropID )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part that contains the enumerated type property.
$iStateID | The state of the part.
$iPropID | The property to retrieve ($TMT_*).

Return Value

Success: | The enumerated type value.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetThemeEnumValue in MSDN Library.


Function _WinAPI_GetThemeFilename

Function Reference

_WinAPI_GetThemeFilename

Retrieves the value of a filename property

#include <WinAPITheme.au3>
_WinAPI_GetThemeFilename ( $hTheme, $iPartID, $iStateID, $iPropID )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part that contains the filename property.
$iStateID | The state of the part.
$iPropID | The property to retrieve ($TMT_*).

Return Value

Success: | The retrieved file name.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetThemeFilename in MSDN Library.


Function _WinAPI_GetThemeFont

Function Reference

_WinAPI_GetThemeFont

Retrieves the value of a font property

#include <WinAPITheme.au3>
_WinAPI_GetThemeFont ( $hTheme, $iPartID, $iStateID, $iPropID [, $hDC = 0] )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part that contains the font property.
$iStateID | The state of the part.
$iPropID | The property to retrieve ($TMT_*).
$hDC | [optional] Handle to the device context.

Return Value

Success: | $tagLOGFONT structure that contains a font property value.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetThemeFont in MSDN Library.


Function _WinAPI_GetThemeInt

Function Reference

_WinAPI_GetThemeInt

Retrieves the value of an INT property

#include <WinAPITheme.au3>
_WinAPI_GetThemeInt ( $hTheme, $iPartID, $iStateID, $iPropID )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part that contains the INT property.
$iStateID | The state of the part.
$iPropID | The property to retrieve ($TMT_*).

Return Value

Success: | The retrieved property value.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetThemeInt in MSDN Library.


Function _WinAPI_GetThemeMargins

Function Reference

_WinAPI_GetThemeMargins

Retrieves the value of a margins property

#include <WinAPITheme.au3>
_WinAPI_GetThemeMargins ( $hTheme, $iPartID, $iStateID, $iPropID, $hDC, $tRECT )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part that contains the MARGINS property.
$iStateID | The state of the part.
$iPropID | The property to retrieve ($TMT_*).
$hDC | Handle to a device context to select fonts into.
$tRECT | $tagRECT structure that contains the rectangle that specifies the area to be drawn into.

Return Value

Success: | $tagMARGINS structure that contains a margins value.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetThemeMargins in MSDN Library.


Function _WinAPI_GetThemeMetric

Function Reference

_WinAPI_GetThemeMetric

Retrieves the value of a metric property

#include <WinAPITheme.au3>
_WinAPI_GetThemeMetric ( $hTheme, $iPartID, $iStateID, $iPropID [, $hDC = 0] )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part that contains the metric property.
$iStateID | The state of the part.
$iPropID | The property to retrieve. It can be one of the following values. $TMT_ALPHALEVEL $TMT_ALPHATHRESHOLD $TMT_BORDERSIZE $TMT_GLYPHINDEX $TMT_GRADIENTRATIO1 $TMT_GRADIENTRATIO2 $TMT_GRADIENTRATIO3 $TMT_GRADIENTRATIO4 $TMT_GRADIENTRATIO5 $TMT_HEIGHT $TMT_IMAGECOUNT $TMT_MINDPI1 $TMT_MINDPI2 $TMT_MINDPI3 $TMT_MINDPI4 $TMT_MINDPI5 $TMT_PROGRESSCHUNKSIZE $TMT_PROGRESSSPACESIZE $TMT_ROUNDCORNERWIDTH $TMT_ROUNDCORNERHEIGHT $TMT_SATURATION $TMT_TEXTBORDERSIZE $TMT_TRUESIZESTRETCHMARK $TMT_WIDTH
$hDC | [optional] Handle to the device context.

Return Value

Success: | The metric property value.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetThemeMetric in MSDN Library.


Function _WinAPI_GetThemePartSize

Function Reference

_WinAPI_GetThemePartSize

Calculates the original size of the part defined by a visual style

#include <WinAPITheme.au3>
_WinAPI_GetThemePartSize ( $hTheme, $iPartID, $iStateID, $hDC, $tRECT, $iType )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part part to calculate the size of.
$iStateID | The state of the part.
$hDC | Handle to a device context to select fonts into.
$tRECT | $tagRECT structure that contains the rectangle used for the part drawing destination.
$iType | The type of size to retrieve. This parameter can be one of the following values. $TS_MIN $TS_TRUE $TS_DRAW

Return Value

Success: | $tagSIZE structure that contains a dimensions of the specified part.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetThemePartSize in MSDN Library.


Function _WinAPI_GetThemePosition

Function Reference

_WinAPI_GetThemePosition

Retrieves the value of a position property

#include <WinAPITheme.au3>
_WinAPI_GetThemePosition ( $hTheme, $iPartID, $iStateID, $iPropID )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part that contains the position property.
$iStateID | The state of the part.
$iPropID | The property to retrieve ($TMT_*).

Return Value

Success: | $tagPOINT structure that contains a position value.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetThemePosition in MSDN Library.


Function _WinAPI_GetThemePropertyOrigin

Function Reference

_WinAPI_GetThemePropertyOrigin

Retrieves the location of the theme property definition for a property

#include <WinAPITheme.au3>
_WinAPI_GetThemePropertyOrigin ( $hTheme, $iPartID, $iStateID, $iPropID )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part that contains the theme.
$iStateID | The state of the part.
$iPropID | The property to retrieve ($TMT_*).

Return Value

Success: | The value that indicates where the property was found. It can be one of the following values. 0 - Property was found in the state section. 1 - Property was found in the part section. 2 - Property was found in the class section. 3 - Property was found in the list of global variables. 4 - Property was not found.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetThemePropertyOrigin in MSDN Library.


Function _WinAPI_GetThemeRect

Function Reference

_WinAPI_GetThemeRect

Retrieves the value of a RECT property

#include <WinAPITheme.au3>
_WinAPI_GetThemeRect ( $hTheme, $iPartID, $iStateID, $iPropID )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part containing the RECT property.
$iStateID | The state of the part.
$iPropID | The property to retrieve ($TMT_*).

Return Value

Success: | $tagRECT structure that contains a rectangle.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetThemeRect in MSDN Library.


Function _WinAPI_GetThemeString

Function Reference

_WinAPI_GetThemeString

Retrieves the value of a string property

#include <WinAPITheme.au3>
_WinAPI_GetThemeString ( $hTheme, $iPartID, $iStateID, $iPropID )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part that contains the string property.
$iStateID | The state of the part.
$iPropID | The property to retrieve ($TMT_*).

Return Value

Success: | The retrieved string value.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetThemeString in MSDN Library.


Function _WinAPI_GetThemeSysBool

Function Reference

_WinAPI_GetThemeSysBool

Retrieves the Boolean value of a system metric

#include <WinAPITheme.au3>
_WinAPI_GetThemeSysBool ( $hTheme, $iBoolID )

Parameters

$hTheme | Handle to the theme data.
$iBoolID | The value that specifies the system Boolean metric desired. It may be the following value. $TMT_FLATMENUS

Return Value

Returns the value of desired system metric.

Remarks

If the theme data handle is not 0, this function returns the desired BOOL from the SysMetrics section of the
visual style, otherwise, the function returns the value of the specified system Boolean.

See Also

Search GetThemeSysBool in MSDN Library.


Function _WinAPI_GetThemeSysColor

Function Reference

_WinAPI_GetThemeSysColor

Retrieves the value of a system color

#include <WinAPITheme.au3>
_WinAPI_GetThemeSysColor ( $hTheme, $iColorID )

Parameters

$hTheme | Handle to the theme data.
$iColorID | The value that specifies the color number. It may be one of the $COLOR_* constants.

Return Value

Returns the value of the specified system color.

Remarks

If the theme data handle is not 0, this function returns the color from the SysMetrics section of the current
visual style, otherwise, the function returns the color matching the global system color.

See Also

Search GetThemeSysColor in MSDN Library.


Function _WinAPI_GetThemeSysColorBrush

Function Reference

_WinAPI_GetThemeSysColorBrush

Retrieves a system color brush

#include <WinAPITheme.au3>
_WinAPI_GetThemeSysColorBrush ( $hTheme, $iColorID )

Parameters

$hTheme | Handle to the theme data.
$iColorID | The value that specifies the number of the desired system color. It may be one of the following values. $TMT_SCROLLBAR $TMT_BACKGROUND $TMT_ACTIVECAPTION $TMT_INACTIVECAPTION $TMT_WINDOW $TMT_WINDOWFRAME $TMT_MENUTEXT $TMT_WINDOWTEXT $TMT_CAPTIONTEXT $TMT_ACTIVEBORDER $TMT_INACTIVEBORDER $TMT_APPWORKSPACE $TMT_HIGHLIGHT $TMT_HIGHLIGHTTEXT $TMT_BTNFACE $TMT_BTNSHADOW $TMT_GRAYTEXT $TMT_BTNTEXT $TMT_INACTIVECAPTIONTEXT $TMT_BTNHIGHLIGHT $TMT_DKSHADOW3D $TMT_LIGHT3D $TMT_INFOTEXT $TMT_INFOBK $TMT_BUTTONALTERNATEFACE $TMT_HOTTRACKING $TMT_GRADIENTACTIVECAPTION $TMT_GRADIENTINACTIVECAPTION $TMT_MENUHILIGHT $TMT_MENUBAR

Return Value

Returns an Handle to the brush.

Remarks

If the theme data handle is not 0, this function returns the brush that matches the specified color from the SysMetrics
section of the visual style, otherwise, the function returns the brush matching the global system color.

See Also

Search GetThemeSysColorBrush in MSDN Library.


Function _WinAPI_GetThemeSysFont

Function Reference

_WinAPI_GetThemeSysFont

Retrieves the font information of a system font

#include <WinAPITheme.au3>
_WinAPI_GetThemeSysFont ( $hTheme, $iFontID )

Parameters

$hTheme | Handle to the theme data.
$iFontID | The value that specifies a system font. It may be one of the following values. $TMT_CAPTIONFONT $TMT_SMALLCAPTIONFONT $TMT_MENUFONT $TMT_STATUSFONT $TMT_MSGBOXFONT $TMT_ICONTITLEFONT

Return Value

Success: | $tagLOGFONT structure that contains the font information.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

If the theme data handle is not 0, this function returns the font information from the SysMetrics section of the
visual style, otherwise, the function returns the value of the global system metric.

See Also

Search GetThemeSysFont in MSDN Library.


Function _WinAPI_GetThemeSysInt

Function Reference

_WinAPI_GetThemeSysInt

Retrieves the value of a system INT

#include <WinAPITheme.au3>
_WinAPI_GetThemeSysInt ( $hTheme, $iIntID )

Parameters

$hTheme | Handle to the theme data.
$iIntID | The value that specifies the desired system INT. It may be the following value. $TMT_MINCOLORDEPTH

Return Value

Success: | The system integer value.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetThemeSysInt in MSDN Library.


Function _WinAPI_GetThemeSysSize

Function Reference

_WinAPI_GetThemeSysSize

Retrieves the value of a system size metric from theme data

#include <WinAPITheme.au3>
_WinAPI_GetThemeSysSize ( $hTheme, $iSizeID )

Parameters

$hTheme | Handle to the theme data.
$iSizeID | The value that specifies the system size metric desired. The following values are valid. $SM_CXBORDER $SM_CXVSCROLL $SM_CXHSCROLL $SM_CXSIZE $SM_CYSIZE $SM_CXSMSIZE $SM_CYSMSIZE $SM_CXMENUSIZE $SM_CYMENUSIZE $SM_CXPADDEDBORDER

Return Value

Returns the size in pixels.

Remarks

If $hTheme is not 0, this function returns the size stored in the current visual style (SysMetrics section
of the visual style) scaled to the current screen dpi. If $hTheme is 0, this function returns the global system
metric in pixels that is scaled to the current dpi only if the application is marked as dpi-aware; otherwise,
the pixels returned are unscaled.

See Also

Search GetThemeSysSize in MSDN Library.


Function _WinAPI_GetThemeSysString

Function Reference

_WinAPI_GetThemeSysString

Retrieves the value of a system string

#include <WinAPITheme.au3>
_WinAPI_GetThemeSysString ( $hTheme, $iStringID )

Parameters

$hTheme | Handle to the theme data.
$iStringID | The value that specifies a system string. It may be one of the following values. $TMT_CSSNAME $TMT_XMLNAME

Return Value

Success: | The string value.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

If the theme data handle is not 0, this function returns the desired string from the SysMetrics section of the
visual style, otherwise, the function returns the value of the global system metric.

See Also

Search GetThemeSysString in MSDN Library.


Function _WinAPI_GetThemeTextExtent

Function Reference

_WinAPI_GetThemeTextExtent

Calculates the size and location of the specified text when rendered in the visual style font

#include <WinAPITheme.au3>
_WinAPI_GetThemeTextExtent ( $hTheme, $iPartID, $iStateID, $hDC, $sText, $tRECT, $iFlags )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part in which the text will be drawn.
$iStateID | The state of the part.
$hDC | Handle to the device context to select the font into.
$sText | The string that contains the text to draw.
$tRECT | $tagRECT structure that contains the rectangle used to control layout of the text. This parameter may be set to 0.
$iFlags | The string's formatting flags ($DT_*).

Return Value

Success: | $tagRECT structure that contains, in logical coordinates, the rectangle required to fit the rendered text.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetThemeTextExtent in MSDN Library.


Function _WinAPI_GetThemeTextMetrics

Function Reference

_WinAPI_GetThemeTextMetrics

Retrieves information about the font specified by a visual style for a particular part

#include <WinAPITheme.au3>
_WinAPI_GetThemeTextMetrics ( $hTheme, $iPartID, $iStateID [, $hDC = 0] )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part to retrieve font information about.
$iStateID | The state of the part.
$hDC | [optional] Handle to the device context to use for screen context.

Return Value

Success: | $tagTEXTMETRIC structure that contains the font information.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

See Also

Search GetThemeTextMetrics in MSDN Library.


Function _WinAPI_GetThemeTransitionDuration

Function Reference

_WinAPI_GetThemeTransitionDuration

Gets the duration for the specified transition

#include <WinAPITheme.au3>
_WinAPI_GetThemeTransitionDuration ( $hTheme, $iPartID, $iStateIDFrom, $iStateIDTo, $iPropID )

Parameters

$hTheme | Handle of the theme data.
$iPartID | ID of the part.
$iStateIDFrom | The state ID of the part before the transition.
$iStateIDTo | The state ID of the part after the transition.
$iPropID | The property ID ($TMT_*).

Return Value

Success: | The transition duration, in milliseconds.
Failure: | Sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

This function requires Windows Vista or later.

See Also

Search GetThemeTransitionDuration in MSDN Library.

Example

#include <APIThemeConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPISys.au3>
#include <WinAPITheme.au3>

Global Const $BP_PUSHBUTTON = 1
Global Const $PBS_NORMAL = 1
Global Const $PBS_HOT = 2

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

Local $hTheme = _WinAPI_OpenThemeData(0, 'Button')
Local $iVal = _WinAPI_GetThemeTransitionDuration($hTheme, $BP_PUSHBUTTON, $PBS_NORMAL, $PBS_HOT, $TMT_TRANSITIONDURATIONS)
_WinAPI_CloseThemeData($hTheme)

ConsoleWrite('Transition from "Hot" to "Normal" state: ' & $iVal & ' ms' & @CRLF)


Function _WinAPI_GetWindowTheme

Function Reference

_WinAPI_GetWindowTheme

Retrieves a theme handle to a window that has visual styles applied

#include <WinAPITheme.au3>
_WinAPI_GetWindowTheme ( $hWnd )

Parameters

$hWnd Handle to the window.

Return Value

Success: | Handle to the theme.
Failure: | 0.

See Also

Search GetWindowTheme in MSDN Library.


Function _WinAPI_IsThemeActive

Function Reference

_WinAPI_IsThemeActive

Tests if a visual style for the current application is active

#include <WinAPITheme.au3>
_WinAPI_IsThemeActive ( )

Return Value

True: | the visual style is enabled.
False: | the visual style is disabled.

See Also

Search IsThemeActive in MSDN Library.


Function _WinAPI_IsThemeBackgroundPartiallyTransparent

Function Reference

_WinAPI_IsThemeBackgroundPartiallyTransparent

Retrieves whether the background specified by the visual style has transparent pieces or alpha-blended pieces

#include <WinAPITheme.au3>
_WinAPI_IsThemeBackgroundPartiallyTransparent ( $hTheme, $iPartID, $iStateID )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part.
$iStateID | The state of the part.

Return Value

True: | the theme-specified background has transparent pieces or alpha-blended pieces.
False: | not specified in background.

See Also

Search IsThemeBackgroundPartiallyTransparent in MSDN Library.


Function _WinAPI_IsThemePartDefined

Function Reference

_WinAPI_IsThemePartDefined

Retrieves whether a visual style has defined parameters for the specified part

#include <WinAPITheme.au3>
_WinAPI_IsThemePartDefined ( $hTheme, $iPartID )

Parameters

$hTheme | Handle to a window's specified theme data.
$iPartID | The part.

Return Value

True: | the theme has defined parameters for the specified $iPartID.
False: | no defined parameters.

See Also

Search IsThemePartDefined in MSDN Library.


Function _WinAPI_OpenThemeData

Function Reference

_WinAPI_OpenThemeData

Opens the theme data for a window and its associated class

#include <WinAPITheme.au3>
_WinAPI_OpenThemeData ( $hWnd, $sClass )

Parameters

$hWnd | Handle of the window for which theme data is required.
$sClass | The string that contains a semicolon-separated list of classes. This parameter may contain a list, not just a single name, to provide the class an opportunity to get the best match between the class and the current visual style.

Return Value

Success: | The handle to the theme.
Failure: | 0.

See Also

Search OpenThemeData in MSDN Library.


Function _WinAPI_SetThemeAppProperties

Function Reference

_WinAPI_SetThemeAppProperties

Sets the flags that determine how visual styles are implemented in the calling application

#include <WinAPITheme.au3>
_WinAPI_SetThemeAppProperties ( $iFlags )

Parameters

$iFlags This parameter can be one or more of the following values.
$STAP_ALLOW_NONCLIENT
$STAP_ALLOW_CONTROLS
$STAP_ALLOW_WEBCONTENT

Return Value

None.

Remarks

After you set the flags, you must send a WM_THEMECHANGED message for the changes to take effect.

See Also

Search SetThemeAppProperties in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <WinAPITheme.au3>

GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 310, 360)
GUICtrlCreateGroup('Group', 10, 10, 140, 95)
GUICtrlCreateCheckbox('Check1', 22, 26, 120, 23)
GUICtrlCreateCheckbox('Check2', 22, 49, 120, 23)
GUICtrlCreateCheckbox('Check3', 22, 72, 120, 23)
GUICtrlCreateGroup('Group', 160, 10, 140, 95)
GUICtrlCreateRadio('Radio1', 172, 26, 120, 23)
GUICtrlCreateRadio('Radio2', 172, 49, 120, 23)
GUICtrlCreateRadio('Radio3', 172, 72, 120, 23)
GUICtrlCreateButton('OK', 120, 330, 70, 23)
_WinAPI_SetThemeAppProperties(0)
GUICtrlCreateTab(10, 118, 292, 206)
GUICtrlCreateTabItem('Tab1')
GUICtrlCreateTabItem('Tab2')
GUICtrlCreateTabItem('')

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


Function _WinAPI_SetWindowTheme

Function Reference

_WinAPI_SetWindowTheme

Causes a window to use a different set of visual style information than its class normally uses

#include <WinAPITheme.au3>
_WinAPI_SetWindowTheme ( $hWnd [, $sName = 0 [, $sList = 0]] )

Parameters

$hWnd | Handle to the window whose visual style information is to be changed.
$sName | [optional] A string that contains the application name. If this parameter is 0 (Default), the calling application's name is used.
$sList | [optional] A string that contains a semicolon-separated list of CLSID names to use in place of the actual list passed by the window's class. If this parameter is 0 (Default), the ID list from the calling class is used.

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

Remarks

The theme manager retains the $sName and the $sList associations through the lifetime of the window, even
if visual styles subsequently change.

When $sName and $sList are 0, the theme manager removes the previously applied associations. To prevent visual
styles from being applied to a specified window, pass an empty string ("") which will not match any section
entries.

See Also

Search SetWindowTheme in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WinAPISys.au3>
#include <WinAPITheme.au3>

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 332, 400)

Local $idListview = GUICtrlCreateListView('Column 1|Column 2|Column 3|Column 4', 10, 10, 312, 380)
For $i = 1 To 9
    GUICtrlCreateListViewItem('Item ' & $i & '|' & 'Sub ' & $i & '|' & 'Sub ' & $i & '|' & 'Sub ' & $i, $idListview)
Next

_WinAPI_SetWindowTheme(GUICtrlGetHandle($idListview), 'Explorer')

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE


User Defined Functions

WinNet user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <WinNet.au3>.

User Defined Function | Description
_WinNet_AddConnection | Connects a local device to a network resource
_WinNet_AddConnection2 | Connects a local device to a network resource
_WinNet_AddConnection3 | Connects a local device to a network resource
_WinNet_CancelConnection | Cancels an existing network connection
_WinNet_CancelConnection2 | Cancels an existing network connection
_WinNet_CloseEnum | Ends a network resource enumeration started by a call to _WinNet_OpenEnum()
_WinNet_ConnectionDialog | Starts a general browsing dialog box for connecting to network resources
_WinNet_ConnectionDialog1 | Starts a general browsing dialog box for connecting to network resources
_WinNet_DisconnectDialog | Starts a general browsing dialog box for disconnecting from network resources
_WinNet_DisconnectDialog1 | Starts a general browsing dialog box for disconnecting from network resources
_WinNet_EnumResource | Continues an enumeration of network resources
_WinNet_GetConnection | Retrieves the name of the network resource associated with a local device
_WinNet_GetConnectionPerformance | Returns information about the performance of a network connection resource
_WinNet_GetLastError | Retrieves the most recent extended error
_WinNet_GetNetworkInformation | Returns extended information about a specific network provider
_WinNet_GetProviderName | Obtains the provider name for a specific type of network
_WinNet_GetResourceInformation | Identifies the network provider that owns the resource
_WinNet_GetResourceParent | Returns the parent of a network resource in the network browse hierarchy
_WinNet_GetUniversalName | Converts drived based path to universal form
_WinNet_GetUser | Retrieves the default user name, or the user name used to establish a connection
_WinNet_OpenEnum | Starts an enumeration of network resources or existing connections
_WinNet_RestoreConnection | Restores the connection to a network resource
_WinNet_UseConnection | Connects a local device to a network resource


Function _WinNet_AddConnection

Function Reference

_WinNet_AddConnection

Connects a local device to a network resource

#include <WinNet.au3>
_WinNet_AddConnection ( $sLocalName, $sRemoteName [, $sPassword = 0] )

Parameters

$sLocalName | Name of a local device to be redirected, such as "F:" or "LPT1". The string is treated in a case-insensitive manner. If the Null keyword or an empty, a connection to the network resource is made without redirecting the local device.
$sRemoteName | Name of the network resource to connect to
$sPassword | [optional] Password to be used to make a connection. This parameter is usually the password associated with the current user. If 0, the default password is used. If the string is empty, no password is used.

Return Value

Success: | True.
Failure: | False.

Remarks

This function is provided only for compatibility with 16-bit versions of Windows.
Applications should call the _WinNet_AddConnection2() or the _WinNet_AddConnection3() function.
A successful connection is persistent meaning that the system automatically restores the connection during subsequent logon operations.

Related

_WinNet_AddConnection2, _WinNet_AddConnection3

See Also

Search WNetAddConnection in MSDN Library.


Function _WinNet_AddConnection2

Function Reference

_WinNet_AddConnection2

Connects a local device to a network resource

#include <WinNet.au3>
_WinNet_AddConnection2 ( $sLocalName, $sRemoteName [, $sUserName = 0 [, $sPassword = 0 [, $iType = 1 [, $iOptions = 1]]]] )

Parameters

$sLocalName Name of a local device to be redirected, such as "F:" or "LPT1". The string is treated in a
case-insensitive manner. If the Null keyword or an empty, a connection to the network resource is made without redirecting the local
device.
$sRemoteName | Name of the network resource to connect to
$sUsername | [optional] User name for making the connection. If 0, the function uses the default user name.
$sPassword [optional] Password to be used to make a connection. If 0, the default password is used. If the string is
empty, no password is used.
$iType [optional] Specifies the type of network resource to connect to:
0 - Any (only if $sLocalName is 0)
1 - Disk
2 - Print
$iOptions [optional] Connection options. Can be one or more of the following:
1 - The network resource connection should be remembered
2 - The operating system may interact with the user for authentication purposes
4 - The system not to use any default setting for user names or passwords without offering the user the
opportunity to supply an alternative. This flag is ignored unless bit 2 (interactive) is also set.
8 - Forces the redirection of a local device when making the connection
16 - The operating system prompts the user for authentication using the command line instead of a GUI.
This flag is ignored unless bit 2 (interactive) is also set.
32 - If this bit is set, and the operating system prompts for a credential, the credential is saved by the credential manager.
If the credential manager is disabled for the caller's logon session, or if the network
provider does not support saving credentials, this flag is ignored.
This flag is also ignored unless you set
bit 5 (command line instead of GUI).

Return Value

Success: | True.
Failure: | False.

Related

_WinNet_AddConnection, _WinNet_AddConnection3

See Also

Search WNetAddConnection2 in MSDN Library.


Function _WinNet_AddConnection3

Function Reference

_WinNet_AddConnection3

Connects a local device to a network resource

#include <WinNet.au3>
_WinNet_AddConnection3 ( $hWnd, $sLocalName, $sRemoteName [, $sUserName = 0 [, $sPassword = 0 [, $iType = 1 [, $iOptions = 1]]]] )

Parameters

$hWnd Handle to a window that the provider of network resources can use as an owner window for
dialogs. Use this parameter if you set bit 2 (interactive) in the Options parameter. This parameter can be 0.
$sLocalName Name of a local device to be redirected, such as "F:" or "LPT1". The string is treated in a
case-insensitive manner. If the Null keyword or an empty, a connection to the network resource is made without redirecting the local
device.
$sRemoteName | Name of the network resource to connect to
$sUsername | [optional] User name for making the connection. If 0, the function uses the default user name.
$sPassword [optional] Password to be used to make a connection. If 0, the default password is used. If the string is
empty, no password is used.
$iType [optional] Specifies the type of network resource to connect to:
0 - Any (only if $sLocalName is 0)
1 - Disk
2 - Print
$iOptions [optional] Connection options. Can be one or more of the following:
1 - The network resource connection should be remembered
2 - The operating system may interact with the user for authentication purposes
4 - The system not to use any default setting for user names or passwords without offering the user the opportunity to supply an alternative. This flag is ignored unless bit 2 (interactive) is also set.
8 - Forces the redirection of a local device when making the connection
16 - The operating system prompts the user for authentication using the command line instead of a GUI.
This flag is ignored unless bit 2 (interactive) is also set.
32 - If this bit is set, and the operating system prompts for a credential, the credential is saved by the credential manager.
If the credential manager is disabled for the caller's logon session, or if the network
provider does not support saving credentials, this flag is ignored.
This flag is also ignored unless you set
bit 5 (command line instead of GUI).

Return Value

Success: | True.
Failure: | False.

Related

_WinNet_AddConnection, _WinNet_AddConnection2

See Also

Search WNetAddConnection3 in MSDN Library.


Function _WinNet_CancelConnection

Function Reference

_WinNet_CancelConnection

Cancels an existing network connection

#include <WinNet.au3>
_WinNet_CancelConnection ( $sName [, $bForce = True] )

Parameters

$sName | Name of either the redirected local device or the remote network resource to disconnect from. When this parameter specifies a redirected local device, the function cancels only the specified device redirection. If the parameter specifies a remote network resource, only the connections to remote networks without devices are cancelled.
$bForce | [optional] Specifies whether or not the disconnection should occur if there are open files or jobs on the connection. If this parameter is False, the function fails if there are open files or jobs.

Return Value

Success: | True.
Failure: | False.

Remarks

This function is provided for compatibility with 16-bit versions of Windows.
Other Windows-based applications should call the _WinNet_CancelConnection2() function.

Related

_WinNet_CancelConnection2

See Also

Search WNetCancelConnection in MSDN Library.


Function _WinNet_CancelConnection2

Function Reference

_WinNet_CancelConnection2

Cancels an existing network connection

#include <WinNet.au3>
_WinNet_CancelConnection2 ( $sName [, $bUpdate = True [, $bForce = True]] )

Parameters

$sName | Name of either the redirected local device or the remote network resource to disconnect from. When this parameter specifies a redirected local device, the function cancels only the specified device redirection. If the parameter specifies a remote network resource, only the connections to remote networks without devices are cancelled.
$bUpdate | [optional] If True, the users profile is updated with the information that the connection is no longer a persistent one.
$bForce | [optional] Specifies whether or not the disconnection should occur if there are open files or jobs on the connection. If this parameter is False, the function fails if there are open files or jobs.

Return Value

Success: | True.
Failure: | False.

Related

_WinNet_CancelConnection

See Also

Search WNetCancelConnection2 in MSDN Library.


Function _WinNet_CloseEnum

Function Reference

_WinNet_CloseEnum

Ends a network resource enumeration started by a call to _WinNet_OpenEnum()

#include <WinNet.au3>
_WinNet_CloseEnum ( $hEnum )

Parameters

$hEnum Handle that identifies an enumeration instance. The handle is returned by the _WinNet_OpenEnum() function

Return Value

Success: | True.
Failure: | False.

Related

_WinNet_OpenEnum

See Also

Search WNetCloseEnum in MSDN Library.


Function _WinNet_ConnectionDialog

Function Reference

_WinNet_ConnectionDialog

Starts a general browsing dialog box for connecting to network resources

#include <WinNet.au3>
_WinNet_ConnectionDialog ( $hWnd )

Parameters

$hWnd Handle to the owner window for the dialog box

Return Value

Success: | True.
Failure: | False.

Related

_WinNet_ConnectionDialog1

See Also

Search WNetConnectionDialog in MSDN Library.


Function _WinNet_ConnectionDialog1

Function Reference

_WinNet_ConnectionDialog1

Starts a general browsing dialog box for connecting to network resources

#include <WinNet.au3>
_WinNet_ConnectionDialog1 ( $hWnd [, $sRemoteName = "" [, $iFlags = 2]] )

Parameters

$hWnd | Handle to the owner window for the dialog box
$sRemoteName | [optional] Name of the network resource to connect to
$iFlags | [optional] Dialog box options. Can be one or more of the following: 1 - Display a read-only path instead of allowing the user to type in a path 2 - Enter the most recently used paths into the combination box 4 - Do not show the restore the connection at logon checkbox 8 - Restore the connection at logon 16 - Do not restore the connection at logon

Return Value

Success: | the number of the connected device. The value is 1 for A:, 2 for B:, 3 for C: and so on. If the user made a deviceless connection, the value is –1.
Failure: | sets the @error flag to non-zero.

Related

_WinNet_ConnectionDialog

See Also

Search WNetConnectionDialog1 in MSDN Library.


Function _WinNet_DisconnectDialog

Function Reference

_WinNet_DisconnectDialog

Starts a general browsing dialog box for disconnecting from network resources

#include <WinNet.au3>
_WinNet_DisconnectDialog ( $hWnd )

Parameters

$hWnd Handle to the owner window for the dialog box

Return Value

Success: | True.
Failure: | False.

Related

_WinNet_DisconnectDialog1

See Also

Search WNetDisconnectDialog in MSDN Library.


Function _WinNet_DisconnectDialog1

Function Reference

_WinNet_DisconnectDialog1

Starts a general browsing dialog box for disconnecting from network resources

#include <WinNet.au3>
_WinNet_DisconnectDialog1 ( $hWnd, $sLocalName [, $sRemoteName = "" [, $iFlags = 1]] )

Parameters

$hWnd | Handle to the owner window for the dialog box
$sLocalName | Name of a local device, such as "F:" or "LPT1"
$sRemoteName | [optional] Name of the network resource to disconnect. This member can be 0 if $LocalName is specified. When $sLocalName is specified, the connection to the network resource redirected from $sLocalName is disconnected.
$iFlags | [optional] Flags describing the connection. Can be a combination of: 1 - If this value is set, the specified connection is no longer a persistent one. This flag is valid only if $sLocalName specifies a local device. 2 - If this value is NOT set, the system applies force when disconnecting

Return Value

Success: | 1. If the user cancels the dialog box, the return value is –1.
Failure: | 0 and sets the @error flag to non-zero.

Related

_WinNet_DisconnectDialog

See Also

Search WNetDisconnectDialog1 in MSDN Library.


Function _WinNet_EnumResource

Function Reference

_WinNet_EnumResource

Continues an enumeration of network resources

#include <WinNet.au3>
_WinNet_EnumResource ( $hEnum, ByRef $iCount, $pBuffer, ByRef $iBufSize )

Parameters

$hEnum | Handle that identifies an enumeration instance. The handle is returned by the _WinNet_OpenEnum() function.
$iCount | Number of entries requested. If the number requested is –1, the function returns as many entries as possible. If the function succeeds, on return the variable contains the number of entries actually read.
$pBuffer | Pointer to the buffer that receives the enumeration results. The results are returned as an array of $tagNETRESOURCE structures. The buffer must be large enough to hold the structures plus the strings to which their members point. The buffer is valid until the next call using the handle specified by $hEnum. The order of $tagNETRESOURCE structures in the array is not predictable.
$iBufSize | The size of the buffer, in bytes. If the buffer is too small to receive even one entry, this parameter receives the required size of the buffer.

Return Value

Success: | True.
Failure: | False.

Related

$tagNETRESOURCE, _WinNet_OpenEnum

See Also

Search WNetEnumResource in MSDN Library.


Function _WinNet_GetConnection

Function Reference

_WinNet_GetConnection

Retrieves the name of the network resource associated with a local device

#include <WinNet.au3>
_WinNet_GetConnection ( $sLocalName )

Parameters

$sLocalName The name of the local device to get the network name for

Return Value

Success: | the remote name used to make the connection.
Failure: | sets the @error flag to non-zero.

See Also

Search WNetGetConnection in MSDN Library.


Function _WinNet_GetConnectionPerformance

Function Reference

_WinNet_GetConnectionPerformance

Returns information about the performance of a network connection resource

#include <WinNet.au3>
_WinNet_GetConnectionPerformance ( $sLocalName, $sRemoteName )

Parameters

$sLocalName | Name of a local device, such as "F:" or "LPT1", that is redirected to a network resource to be queried. If blank, the network resource is specified in $sRemoteName. If this parameter specifies a local device $sRemoteName is ignored.
$sRemoteName | Name of the network resource to query. The resource must currently have an established connection. For example, if the resource is a file on a file server, then having the file open will ensure the connection.

Return Value

Success: | an array with the following format: $aInfo[0] - Connection description. Can be one of more of the following: 1 - The information returned applies to the performance of the network card 2 - The connection is not being routed 4 - The connection is over a medium that is typically slow 8 - Some of the information returned is calculated dynamically $aInfo[1] - Speed of the media to the network resource, in 100 bps $aInfo[2] - One-way delay time introduced when sending information $aInfo[3] - Size of data that an application should use when making a single request to the resource
Failure: | sets the @error flag to non-zero.

See Also

Search MultinetGetConnectionPerformance in MSDN Library.


Function _WinNet_GetLastError

Function Reference

_WinNet_GetLastError

Retrieves the most recent extended error

#include <WinNet.au3>
_WinNet_GetLastError ( ByRef $iError, ByRef $sError, ByRef $sName )

Parameters

$iError | On return, contains the most recent extended error code
$sError | On return, contains the most recent extended error code message
$sName | On return, the network provider that raised the error

Return Value

Success: | the most recent error message.
Failure: | sets the @error flag to non-zero.

See Also

Search WNetGetLastError in MSDN Library.


Function _WinNet_GetNetworkInformation

Function Reference

_WinNet_GetNetworkInformation

Returns extended information about a specific network provider

#include <WinNet.au3>
_WinNet_GetNetworkInformation ( $sName )

Parameters

$sName The network provider for which information is required

Return Value

Success: | an array with the following format: $aInfo[0] - Version number of the network provider software $aInfo[1] - Current status of the network provider software: 0 - The network is running 1 - The network is unavailable 2 - The network is not currently able to service requests $aInfo[2] - Instance handle for the network provider $aInfo[3] - High word of the network type unique to the running network $aInfo[4] - Set of bit flags indicating the valid print numbers for redirecting local printer devices, with the low-order bit corresponding to LPT1. $aInfo[5] - Set of bit flags indicating the valid local disk devices that can be used for redirecting disk drives, with the low-order bit corresponding to A:.
Failure: | sets the @error flag to non-zero.

See Also

Search WNetGetNetworkInformation in MSDN Library.


Function _WinNet_GetProviderName

Function Reference

_WinNet_GetProviderName

Obtains the provider name for a specific type of network

#include <WinNet.au3>
_WinNet_GetProviderName ( $iType )

Parameters

$iType Network type that is unique to the network

Return Value

Success: | the network provider .
Failure: | sets the @error flag to non-zero.

See Also

Search WNetGetProviderName in MSDN Library.


Function _WinNet_GetResourceInformation

Function Reference

_WinNet_GetResourceInformation

Identifies the network provider that owns the resource

#include <WinNet.au3>
_WinNet_GetResourceInformation ( $sRemoteName [, $sProvider = "" [, $iType = 0]] )

Parameters

$sRemoteName | The remote path name of the resource
$sProvider | [optional] The name of the provider that owns the resource. This member can be blank if the provider name is unknown.
$iType | [optional] Type of resource. This member can be 0 if it is not known.

Return Value

Success: | an array with the following format: $aResource[0] - Scope of enumeration: 0 - Connected 1 - All resources 2 - Remembered $aResource[1] - Type of resource: 0 - Disk 1 - Print 2 - Unknown $aResource[2] - Display option: 0 - Generic 1 - Domain 2 - Server 3 - Share 4 - File 5 - Group 6 - Network 7 - Root 8 - Admin Share 9 - Directory 10 - Tree 11 - NDS Container $aResource[3] - Resource usage. Can be one or more of the following: 1 - The resource is a connectable resource 2 - The resource is a container resource 4 - The resource is attached 8 - The resource is reserved $aResource[4] - Local name $aResource[5] - Remote name $aResource[6] - Comment supplied by the network provider $aResource[7] - The name of the provider that owns the resource $aResource[8] - The part of the resource that is accessed through system functions
Failure: | sets the @error flag to non-zero.

See Also

Search WNetGetResourceInformation in MSDN Library.


Function _WinNet_GetResourceParent

Function Reference

_WinNet_GetResourceParent

Returns the parent of a network resource in the network browse hierarchy

#include <WinNet.au3>
_WinNet_GetResourceParent ( $sRemoteName, $sProvider [, $iType = 0] )

Parameters

$sRemoteName | The remote path name of the resource
$sProvider | The name of the provider that owns the resource
$iType | [optional] Type of resource. This member can be 0 if it is not known.

Return Value

Success: | an array with the following format: $aResource[0] - Scope of enumeration: 0 - Connected 1 - All resources 2 - Remembered $aResource[1] - Type of resource: 0 - Disk 1 - Print 2 - Unknown $aResource[2] - Display option: 0 - Generic 1 - Domain 2 - Server 3 - Share 4 - File 5 - Group 6 - Network 7 - Root 8 - Admin Share 9 - Directory 10 - Tree 11 - NDS Container $aResource[3] - Resource usage. Can be one or more of the following: 1 - The resource is a connectable resource 2 - The resource is a container resource 4 - The resource is attached 8 - Thre resource is reserved $aResource[4] - Local name $aResource[5] - Remote name $aResource[6] - Comment supplied by the network provider $aResource[7] - The name of the provider that owns the resource
Failure: | sets the @error flag to non-zero.

See Also

Search WNetGetResourceParent in MSDN Library.


Function _WinNet_GetUniversalName

Function Reference

_WinNet_GetUniversalName

Converts drived based path to universal form

#include <WinNet.au3>
_WinNet_GetUniversalName ( $sLocalPath )

Parameters

$sLocalPath Drive based path for a network resource

Return Value

Success: | an array with the following format: $aPath[0] - UNC name string that identifies a network resource $aPath[1] - Name of the network connection $aPath[2] - Remaining path string
Failure: | sets the @error flag to non-zero.

See Also

Search WNetGetUniversalName in MSDN Library.


Function _WinNet_GetUser

Function Reference

_WinNet_GetUser

Retrieves the default user name, or the user name used to establish a connection

#include <WinNet.au3>
_WinNet_GetUser ( $sName )

Parameters

$sName Either the name of a local device that has been redirected to a network resource, or the remote
name of a network resource to which a connection has been made without redirecting a local device.
If blank, the system returns the name of the current user for the process.

Return Value

Success: | the user name.
Failure: | sets the @error flag to non-zero.

See Also

Search WNetGetUser in MSDN Library.


Function _WinNet_OpenEnum

Function Reference

_WinNet_OpenEnum

Starts an enumeration of network resources or existing connections

#include <WinNet.au3>
_WinNet_OpenEnum ( $iScope, $iType, $iUsage, $tResource, ByRef $hEnum )

Parameters

$iScope | Scope of the enumeration: 0 - Enumerate all currently connected resources 1 - Enumerate all resources on the network 2 - Enumerate all remembered (persistent) connections 3 - Enumerate only resources in the network context of the caller
$iType | Resource types: 0 - All resources 1 - Disk resources 2 - Print resources
$iUsage | Resource usage types: 0 - All resources 1 - All connectable resources 2 - All container resources 4 - Forces the function to fail if the user is not authenticated
$tResource | a $tagNETRESOURCE structure that specifies the container to enumerate or a pointer to it. If $iScope is not 1, this must be 0. If 0, the root of the network is assumed.
$hEnum | On return, a handle that can be used in calls to _WinNet_EnumResource()

Return Value

Success: | True.
Failure: | False.

Related

$tagNETRESOURCE, _WinNet_CloseEnum, _WinNet_EnumResource

See Also

Search WNetOpenEnum in MSDN Library.


Function _WinNet_RestoreConnection

Function Reference

_WinNet_RestoreConnection

Restores the connection to a network resource

#include <WinNet.au3>
_WinNet_RestoreConnection ( [$sDevice = "" [, $hWnd = 0 [, $bUseUI = True]]] )

Parameters

$sDevice | [optional] The local name of the drive to connect to, such as "Z:". If blank, the function reconnects all persistent drives stored in the registry for the current user.
$hWnd | [optional] Handle to the parent window that the function uses to display the user interface that prompts the user for a name and password when making the network connection. If 0, there is no owner window.
$bUseUI | [optional] If True, display a username/password prompt to the caller

Return Value

Success: | True.
Failure: | False.

See Also

Search WNetRestoreConnection in MSDN Library.


Function _WinNet_UseConnection

Function Reference

_WinNet_UseConnection

Connects a local device to a network resource

#include <WinNet.au3>
_WinNet_UseConnection ( $hWnd, $sLocalName, $sRemoteName [, $sUserName = 0 [, $sPassword = 0 [, $iType = 1 [, $iOptions = 1]]]] )

Parameters

$hWnd Handle to a window that the provider of network resources can use as an owner window for dialogs.
Use this parameter if you set bit 2 (interactive) in the Options parameter.
This parameter can be 0.
$sLocalName Name of a local device to be redirected, such as "F:" or "LPT1".
The string is treated in a case-insensitive manner.
If 0, a connection to the network resource is made without redirecting the local device.
$sRemoteName Name of the network resource to connect to
$sUsername [optional] User name for making the connection.
If 0, the function uses the default user name.
$sPassword [optional] Password to be used to make a connection.
If 0, the default password is used. If the string is empty, no password is used.
$iType [optional] Specifies the type of network resource to connect to:
0 - Any (only if $sLocalName is blank)
1 - Disk
2 - Print
$iOptions [optional] Connection options. Can be one or more of the following:
1 - The network resource connection should be remembered
2 - The operating system may interact with the user for authentication purposes
4 - The system does not use any default setting for user names or passwords without offering the user the
opportunity to supply an alternative.
This flag is ignored unless bit 2 (interactive) is also set.
8 - Forces the redirection of a local device when making the connection
16 - The operating system prompts the user for authentication using the command line instead of a GUI.
This flag is ignored unless bit 2 (interactive) is also set.
32 - If this bit is set, and the operating system prompts for a credential, the credential is saved by the credential manager.
If the credential manager is disabled for the caller's logon session, or if the network
provider does not support saving credentials, this flag is ignored.
This flag is also ignored unless you set bit 5 (command line instead of GUI).

Return Value

Success: | an array with the following format: $aInfo[0] - If True, the connection was made using a local device redirection $aInfo[1] - If $sLocalName specifies a local device, this is the local device name. If $sLocalName does not specify a device and the network requires a local device redirection, or if bit 4 (force redirection) is set, this buffer receives the name of the redirected local device. Otherwise, the name copied into the buffer is that of a remote resource.
Failure: | sets the @error flag to non-zero.

See Also

Search WNetUseConnection in MSDN Library.


User Defined Functions

Word user defined functions Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

When using them you need to add a #include <Word.au3>.

User Defined Function | Description
_Word_Create | Connects to an existing Word instance or creates a new Word application object
_Word_DocAdd | Adds a new or empty document to the specified Word application
_Word_DocAttach | Attaches to the first instance of a Word document where the search string matches based on the selected mode
_Word_DocClose | Closes the specified Word document
_Word_DocExport | Exports the document or a range as PDF or XPS
_Word_DocFind | Runs or repeats the specified find operation
_Word_DocFindReplace | Runs the specified find and replace operation
_Word_DocGet | Returns a collection object containing all documents or an object for a single document
_Word_DocLinkAdd | Adds a hyperlink to the document
_Word_DocLinkGet | Returns a collection object containing all links in the document or a single link object
_Word_DocOpen | Opens a Word document
_Word_DocPictureAdd | Adds a picture to the document
_Word_DocPrint | Prints all or parts of the specified document
_Word_DocRangeSet | Sets or modifies a range in a document
_Word_DocSave | Saves the specified Word document
_Word_DocSaveAs | Saves the specified Word document with a new name or format
_Word_DocTableRead | Reads a Word table and returns the content as a two-dimensional array
_Word_DocTableWrite | Writes a one or two dimensional array to a Word table
_Word_Quit | Closes all documents, the Word application and removes the object reference to it


Function _Word_Create

Function Reference

_Word_Create

Connects to an existing Word instance or creates a new Word application object

#include <Word.au3>
_Word_Create ( [$bVisible = True [, $bForceNew = False]] )

Parameters

$bVisible | [optional] True specifies that the window will be visible (default)
$bForceNew | [optional] True forces to create a new Word instance even if there is already a running instance (default = False)

Return Value

Success: | a variable pointing to a Word.Application object. Sets @extended to: 0 - Word was already running 1 - Word was not running or $bForceNew was set to True. Word has been started by this function
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - Error returned by function ObjCreate(). @extended is set to the COM error code

Related

_Word_Quit

Example

#include <MsgBoxConstants.au3>
#include <Word.au3>

; *****************************************************************************
; Create a new Word object
; *****************************************************************************
_Word_Create()
If @error <> 0 Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_Create Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
If @extended = 1 Then
    MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_Create Example", "MS Word was not running when _Word_Create was called.")
Else
    MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_Create Example", "MS Word was already running when _Word_Create was called.")
EndIf


Function _Word_DocAdd

Function Reference

_Word_DocAdd

Adds a new or empty document to the specified Word application

#include <Word.au3>
_Word_DocAdd ( $oAppl [, $iDocumentType = $WdNewBlankDocument [, $sDocumentTemplate = "" [, $bNewTemplate = False]]] )

Parameters

$oAppl | Word object returned by a preceding call to _Word_Create()
$iDocumentType | [optional] Can be one of the following WdNewDocumentType constants: $WdNewBlankDocument, $WdNewEmailMessage, $WdNewFrameset or $WdNewWebPage (default = $WdNewBlankDocument)
$sDocumentTemplate | [optional] The name of the template to be used for the new document. If this argument is omitted, the Normal template is used (default = "")
$bNewTemplate | [optional] True to open the document as a template (default = False)

Return Value

Success: | a variable pointing to the new document object.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $oAppl is not an object 2 - The specified template file does not exist 3 - Error returned by method Documents.Add. @extended is set to the COM error code

Related

_Word_DocClose, _Word_DocSave, _Word_DocSaveAs

Example

#include <MsgBoxConstants.au3>
#include <Word.au3>

Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocAdd Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Add a new empty document
; *****************************************************************************
_Word_DocAdd($oWord)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocAdd Example", "Error creating a new Word document." _
         & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocAdd Example", "A new empty document has successfully been added.")


Function _Word_DocAttach

Function Reference

_Word_DocAttach

Attaches to the first instance of a Word document where the search string matches based on the selected mode

#include <Word.au3>
_Word_DocAttach ( $oAppl, $sString [, $sMode = "FilePath" [, $iCase = 0]] )

Parameters

$oAppl | Word object returned by a preceding call to _Word_Create()
$sString | String to search for
$sMode | [optional] Search mode to use. Valid modes are: "FileName" - Name of the open document "FilePath" - Full path to the open document (default) "Text" - Text in the body of the document
$iCase | [optional] Specifies case-sensitivity of function StringInStr() used for search mode "Text": 0 - not case-sensitive, using the user's locale (default) 1 - case sensitive 2 - not case sensitive, using a basic/faster comparison

Return Value

Success: | a variable pointing to the document object.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $oAppl is not an object 2 - $sString is empty 3 - $sMode is invalid. Must be "FilePath", "FileName" or "Text" 4 - No match could be found

Remarks

This function only returns the object of the found document.
To access the corresponding Word application use: $oAppl = $oDoc.Application.

Related

_Word_DocClose, _Word_DocGet

Example

Example 1

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocAttach Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open test document read-only
_Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocAttach Example", "Error opening '.\Extras\Test.doc'." & _
        @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Attach to the test document by "FileName" and set focus to the window
; *****************************************************************************
Local $oDoc = _Word_DocAttach($oWord, "Test.doc", "Filename")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocAttach Example", _
        "Error attaching to '.\Extras\Test.doc' by 'FileName'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Set focus to the word document - $f_takeFocus parameter of the old _WordCreate function
WinActivate($oWord.ActiveWindow.Caption & " - " & $oWord.Caption)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocAttach Example", "Attach to document by 'FileName' successfull!" & @CRLF & _
        @CRLF & "Text of the attached document:" & @CRLF & $oDoc.Range().Text)

Example 2

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocAttach Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open test document read-only
_Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocAttach Example", "Error opening '.\Extras\Test.doc'." & _
        @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Attach to the test document by "Text"
; *****************************************************************************
Local $oDoc = _Word_DocAttach($oWord, "Test", "Text")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocAttach Example", _
        "Error attaching to '\Extras\Test.doc' by 'Text'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocAttach Example", "Attach to document by 'Text' successfull!" & _
        @CRLF & @CRLF & "Text of the attached document:" & @CRLF & $oDoc.Range().Text)


Function _Word_DocClose

Function Reference

_Word_DocClose

Closes the specified Word document

#include <Word.au3>
_Word_DocClose ( $oDoc [, $iSaveChanges = $WdDoNotSaveChanges [, $iOriginalFormat = $WdOriginalDocumentFormat]] )

Parameters

$oDoc | Word document object
$iSaveChanges | [optional] Specifies the save action for the document (default = $WdDoNotSaveChanges). Can be one of the WdSaveOptions constants: $WdDoNotSaveChanges, $WdPromptToSaveChanges or $WdSaveChanges
$iOriginalFormat | [optional] Specifies the save format for the document. Can be one of the WdOriginalFormat constants: $WdOriginalDocumentFormat, $WdPromptUser or $WdWordDocument (default = $WdOriginalDocumentFormat)

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $oDoc is not an object 2 - Error retuned when closing the specified document. @extended is set to the COM error code

Related

_Word_DocAdd, _Word_DocAttach, _Word_DocOpen

Example

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocClose Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open test document read-only
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocClose Example", _
        "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Close a Word coument
; *****************************************************************************
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocClose Example", "Press 'OK' to close document '.\Extras\Test.doc'.")
_Word_DocClose($oDoc)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocClose Example", _
        "Error closing document '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocClose Example", "The document has been closed successfully.")


Function _Word_DocExport

Function Reference

_Word_DocExport

Exports the document or a range as PDF or XPS

#include <Word.au3>
_Word_DocExport ( $oDoc, $sFileName [, $iFormat = $WdExportFormatPDF [, $iRange = $WdExportAllDocument [, $iFrom = Default [, $iTo = Default [, $bOpenAfterExport = False [, $bIncludeProperties = True [, $iCreateBookmarks = Default [, $bUseISO19005 = False]]]]]]]] )

Parameters

$oDoc | Word document object to be exported
$sFileName | Path/name of the exported file
$iFormat | [optional] Format to use for the export. Can be any of the WdExportFormat enumeration (default = $WdExportFormatPDF)
$iRange | [optional] Specifies what to export. Can be any of the WdExportRange enumeration (default = $WdExportAllDocument)
$iFrom | [optional] The page number at which to start publishing (default = start at the beginning)
$iTo | [optional] The page number at which to end publishing (default = end at the last page)
$bOpenAfterExport | [optional] True displays the file in a viewer after it is published (default = False)
$bIncludeProperties | [optional] True indicates that document properties should be included (default = True)
$iCreateBookmarks | [optional] Specifies whether to export bookmarks and the type of bookmarks to export. Can be any of the WdExportCreateBookmarks enumeration (default)
$bUseISO19005 | [optional] Specifies whether the export should be created as PDF/A (self-contained PDF) (default = False)

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $oDoc is not an object 2 - $sFileName is empty 3 - Error returned when exporting the object. @extended is set to the COM error code

Related

_Word_DocPrint

Example

Example 1

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocPrint Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open test document
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocPrint Example", _
        "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Export the complete document with default values
; *****************************************************************************
Local $sFileName = @TempDir & "\Test1.pdf"
_Word_DocExport($oDoc, $sFileName)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocExport Example", _
        "Error exporting the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
ShellExecute($sFileName)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocExport Example", _
        "The whole document has successfully been exported to: " & $sFileName)

Example 2

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocPrint Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open test document
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocPrint Example", _
        "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Export a range as PDF/A and display the exported file
; *****************************************************************************
; Set the range to lines 2 and 3
Local $oRange = _Word_DocRangeSet($oDoc, -1, $wdParagraph, 1, $wdParagraph, 2)
Local $sFileName = @TempDir & "\Test2.pdf"
_Word_DocExport($oRange, $sFileName, Default, $wdExportFromTo, Default, Default, True, Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocExport Example", "Error exporting the document." & _
        @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocExport Example", _
        "The specified range has successfully been exported to: " & $sFileName)

Example 3

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocPrint Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open test document
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocPrint Example", _
        "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Export the current page
; *****************************************************************************
Local $sFileName = @TempDir & "\Test3.pdf"
_Word_DocExport($oDoc, $sFileName, Default, $wdExportCurrentPage)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocExport Example", _
        "Error exporting the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocExport Example", _
        "The current page has successfully been exported to: " & $sFileName)
ShellExecuteWait($sFileName)


Function _Word_DocFind

Function Reference

_Word_DocFind

Runs or repeats the specified find operation

#include <Word.au3>
_Word_DocFind ( $oDoc [, $sFindText = "" [, $vSearchRange = 0 [, $oFindRange = Default [, $bForward = True [, $bMatchCase = False [, $bMatchWholeWord = False [, $bMatchWildcards = False [, $bMatchSoundsLike = False [, $bMatchAllWordForms = False [, $bFormat = False]]]]]]]]]] )

Parameters

$oDoc | Word document object
$sFindText | [optional] The text to be searched for. Use an empty string ("") to search for formatting only. You can search for special characters by specifying appropriate character codes. For example, "^p" corresponds to a paragraph mark and "^t" corresponds to a tab character (default = "")
$vSearchRange | [optional] Specifies the selection or range to search. Can be: -1 - Specifies the current selection 0 - Specifies the entire document (default) Any Word range object
$oFindRange | [optional] Specifies the range returned by the last call to _Word_DocFind(). This is required if you want to search for the next or previous occurrence of $sFindText. If set to Default then the search starts at the start of the $vSearchRange (default)
$bForward | [optional] True to search forward (toward the end of the document) (default = True)
$bMatchCase | [optional] If True the find is case sensitive (default = False)
$bMatchWholeWord | [optional] If True only find entire words (default = False)
$bMatchWildcards | [optional] If True the find text has special search operators (default = False)
$bMatchSoundsLike | [optional] If True finds words that sound similar to the find text (default = False)
$bMatchAllWordForms | [optional] If True finds all forms of the find text (e.g. "sit" locates "sitting" and "sat") (default = False)
$bFormat | [optional] True to have the find operation locate formatting in addition to or instead of the find text (default = False)

Return Value

Success: | a range object for the found text.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $oDoc is not an object 2 - $vSearchRange is not an object 3 - $oFindRange is not an object 4 - $sFindText could not be found. @extended is set to the COM error code

Related

_Word_DocFindReplace

Example

Example 1

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open test document read-only
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _
        "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Find the last text "test document" in the document and mark it bold.
; *****************************************************************************
Local $oRangeFound
#forceref $oRangeFound
$oRangeFound = _Word_DocFind($oDoc, "test document", 0, Default, False)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _
        "Error locating the specified text in the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
$oRangeFound.Bold = True
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _
        "Last occurrence of string 'test document' in the document marked as bold.")

Example 2

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open test document read-only
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _
        "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Underline text "line" in lines 2-4.
; *****************************************************************************
Local $oRangeFound, $oSearchRange
$oSearchRange = _Word_DocRangeSet($oDoc, -1, $wdParagraph, 1, $wdParagraph, 3)
$oRangeFound = _Word_DocFind($oDoc, "line", $oSearchRange)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _
        "Error locating the specified text in the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
$oRangeFound.Underline = True
While 1
    $oRangeFound = _Word_DocFind($oDoc, "line", $oSearchRange, $oRangeFound)
    If @error Then ExitLoop
    $oRangeFound.Underline = True
WEnd
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _
        "All occurrences of string 'line' in paragraphs 2-4 marked as underlined.")

Example 3

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open test document read-only
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _
        "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Search for text "line" in lines 2-4 and mark the following number as bold.
; If the number is "3" insert text before text "line".
; *****************************************************************************
Local $oRangeFound, $oSearchRange, $oRangeText
$oSearchRange = _Word_DocRangeSet($oDoc, -1, $wdParagraph, 1, $wdParagraph, 3)
$oRangeFound = _Word_DocFind($oDoc, "line", $oSearchRange)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _
        "Error locating the specified text in the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Mark the line number as bold. Create a new range moved one word to the right
$oRangeText = _Word_DocRangeSet($oDoc, $oRangeFound, Default, 1, Default, 1)
$oRangeText.Bold = True
While 1
    $oRangeFound = _Word_DocFind($oDoc, "line", $oSearchRange, $oRangeFound)
    If @error Then ExitLoop
    ; Mark the line number as bold. Create a new range (duplicate to not alter the result of the find operating) and move it one word to the right
    $oRangeText = $oRangeFound.Duplicate
    $oRangeText = _Word_DocRangeSet($oDoc, $oRangeText, Default, 1, Default, 1)
    $oRangeText.Bold = True
    ; Insert text if linenumber = 3
    If StringStripWS($oRangeText.Text, 8) = "3" Then $oRangeFound.InsertBefore("(maybe) ")
WEnd
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _
        "All line numbers in paragraphs 2-4 marked as bold." & @CRLF & "Text inserted before 'line 3'.")

Example 4

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open test document read-only
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _
        "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Replace paragraph control character with paragraph + text + paragraph.
; Only change first occurence.
; *****************************************************************************
Local $oRangeFound
$oRangeFound = _Word_DocFind($oDoc, "^p")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _
        "Error locating paragraph control character in the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
$oRangeFound.InsertAfter("[New Line] ")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _
        "Error inserting text after the paragraph control character in the document." & @CRLF & "@error = " & @error & _
        ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", "Paragraph control character successfully replaced." & @CRLF & _
        "Text inserted in paragraph 2.")


Function _Word_DocFindReplace

Function Reference

_Word_DocFindReplace

Runs the specified find and replace operation

#include <Word.au3>
_Word_DocFindReplace ( $oDoc [, $sFindText = "" [, $sReplaceWith = "" [, $iReplace = $WdReplaceAll [, $vSearchRange = 0 [, $bMatchCase = False [, $bMatchWholeWord = False [, $bMatchWildcards = False [, $bMatchSoundsLike = False [, $bMatchAllWordForms = False [, $bForward = True [, $iWrap = $WdFindContinue [, $bFormat = False]]]]]]]]]]]] )

Parameters

$oDoc | Word document object
$sFindText | [optional] The text to be searched for. Use an empty string ("") to search for formatting only. You can search for special characters by specifying appropriate character codes. For example, "^p" corresponds to a paragraph mark and "^t" corresponds to a tab character (default = "")
$sReplaceWith | [optional] The replacement text. To delete found text use an empty string (""). You specify special characters and advanced search criteria just as you do for the Find argument (default = "")
$iReplace | [optional] How many replacements are to be made: one, all, or none. Can be anyWdReplace constant (default = $WdReplaceAll)
$vSearchRange | [optional] Specifies the selection or range to search. Can be: -1 - Specifies the current selection 0 - Specifies the entire document (default) Any Word range object.
$bMatchCase | [optional] If True the find is case sensitive (default = False)
$bMatchWholeWord | [optional] If True only find entire words (default = False)
$bMatchWildcards | [optional] If True the find text has special search operators (default = False)
$bMatchSoundsLike | [optional] If True finds words that sound similar to the find text (default = False)
$bMatchAllWordForms | [optional] If True finds all forms of the find text (e.g. "sit" locates "sitting" and "sat") (default = False)
$bForward | [optional] True to search forward (toward the end of the document) (default = True)
$iWrap | [optional] True wraps when the bottom or top of the document, selection or range is reached. Can be one of the WdFindWrap constants (default = $WdFindContinue)
$bFormat | [optional] True to have the find operation locate formatting in addition to or instead of the find text (default = False)

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $oDoc is not an object 2 - $vSearchRange is not an object 3 - An error occurred when the replace operation was executed. @extended is set to the COM error code

Related

_Word_DocFind

Example

Example 1

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open test document read-only
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", _
        "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Change "test document" to "test document with replaced text".
; *****************************************************************************
_Word_DocFindReplace($oDoc, "test document", "test document with replaced text")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", _
        "Error replacing text in the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", "Text successfully replaced.")

Example 2

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open test document read-only
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", _
        "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Replace paragraph control character with paragraph + text + paragraph.
; Only change first occurrence.
; *****************************************************************************
_Word_DocFindReplace($oDoc, "^p", "^pInserted Line^p", $wdReplaceOne)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", _
        "Error replacing text in the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", "Paragraph control character successfully replaced.")


Function _Word_DocGet

Function Reference

_Word_DocGet

Returns a collection object containing all documents or an object for a single document

#include <Word.au3>
_Word_DocGet ( $oAppl [, $vIndex = -1] )

Parameters

$oAppl | Word object returned by a preceding call to _Word_Create()
$vIndex | [optional] Specifies what to return: -1 - Returns a collection of all documents (default) 0 - Returns the active document n - The index number of the document to return (1 based) x - The name of the document to return

Return Value

Success: | a variable pointing to the collection of documents or a single document object. @extended is set to the total number of documents
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $oAppl is not an object 2 - $vIndex is invalid (< -1 or > Documents.Count) 3 - Specified document could not be found or error occurred. @extended is set to the COM error code 4 - Error returned when accessing the Documents collection. @extended is set to the COM error code

Related

_Word_DocAttach

Example

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocGet Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open \Extras\test.doc read-only
_Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocGet Example", "Error opening '.\Extras\Test.doc'." & @CRLF & _
        "@error = " & @error & ", @extended = " & @extended)
; Open \Extras\test2.doc read-only
_Word_DocOpen($oWord, @ScriptDir & "\Extras\Test2.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocGet Example", "Error opening '.\Extras\Test2.doc'." & @CRLF & _
        "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Get the first document in the collection, write name and total # of documents
; to the console.
; *****************************************************************************
Local $oDoc = _Word_DocGet($oWord, 1)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocGet Example", _
        "Error accessing collection of documents." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocGet Example", "First document in the document collection has been selected." & _
        @CRLF & "Name is: " & $oDoc.Name & @CRLF & "Total number of documents in the collection: " & @extended)


Function _Word_DocLinkAdd

Function Reference

_Word_DocLinkAdd

Adds a hyperlink to the document

#include <Word.au3>
_Word_DocLinkAdd ( $oDoc [, $oAnchor = Default [, $sAddress = Default [, $sSubAddress = Default [, $sScreenTip = Default [, $sTextToDisplay = Default [, $sTarget = Default]]]]]] )

Parameters

$oDoc | Word document object
$oAnchor | [optional] Range object for the text or graphic to be turned into a hyperlink (default = Use entire document as range)
$sAddress | [optional] The address for the specified link. The address can be an E-mail address, an Internet address or a file name (default = link to the specified document is used)
$sSubAddress | [optional] The name of a location within the destination file, such as a bookmark, named range or slide number (default = None)
$sScreenTip | [optional] The text that appears as a ScreenTip when the mouse pointer is positioned over the specified hyperlink (default = Uses value of $sAddress)
$sTextToDisplay | [optional] The display text of the specified hyperlink. The value of this argument replaces the text or graphic specified by $oAnchor (default = Uses value of $sAddress)
$sTarget | [optional] The name of the frame or window in which you want to load the specified hyperlink

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $oDoc is not an object 2 - Error occurred when adding the link. @extended is set to the COM error code 3 - $oAnchor is not 0 but is not a range object

Related

_Word_DocLinkGet

Example

Example 1

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkAdd Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open test.doc read-only
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkAdd Example", _
        "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Make the fourth word of the document a link to the AutoIt homepage
; *****************************************************************************
Local $oRange = _Word_DocRangeSet($oDoc, -1, $wdWord, 3, $wdWord, 1)
_Word_DocLinkAdd($oDoc, $oRange, "http://www.autoitscript.com")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkAdd Example", _
        "Error adding a link to the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkAdd Example", "Word 4 of the document is now a link to the AutoIt homepage.")

Example 2

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkAdd Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open test.doc read-only
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkAdd Example", _
        "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Add a link to the end of the document and set parameters
; ScreenTip and TextToDisplay
; *****************************************************************************
Local $oRange = _Word_DocRangeSet($oDoc, -2) ; Go to end of document
$oRange.Text = " " ; Add a space at the end of the document
$oRange = _Word_DocRangeSet($oDoc, -2)
_Word_DocLinkAdd($oDoc, $oRange, "http://www.autoitscript.com", Default, "AutoIt homepage", _
        "Hyperlink 3 - Another link to the AutoIt homepage")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkAdd Example", _
        "Error adding a link to the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkAdd Example", "Hyperlink added to the end of the document.")


Function _Word_DocLinkGet

Function Reference

_Word_DocLinkGet

Returns a collection object containing all links in the document or a single link object

#include <Word.au3>
_Word_DocLinkGet ( $oDoc [, $iIndex = Default] )

Parameters

$oDoc | Word document object
$iIndex | [optional] Specifies what to return: Default - Returns a collection of all links (default) n - The index number of the link to return (1 based)

Return Value

Success: | a variable pointing to the collection of links or a single link object. @extended is set to the total number of links
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $oDoc is not an object 2 - $iIndex is invalid (must be an integer > 0 and <= Hyperlinks.Count) or the keyword Default 3 - Error occurred when accessing the Hyperlinks collection. @extended is set to the COM error code

Related

_Word_DocLinkAdd

Example

Example 1

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkGet Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open test.doc read-only
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkGet Example", "Error opening '.\Extras\Test.doc'. @error = " & _
        @error & ", @extended = " & @extended)

; *****************************************************************************
; Get the collection of hyperlinks and display some properties
; *****************************************************************************
Local $oLinks = _Word_DocLinkGet($oDoc)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkGet Example", _
        "Error accessing link collection of the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $sResult = "Total number of hyperlinks in the document: " & @extended & @CRLF & @CRLF
For $oLink In $oLinks
    $sResult = $sResult & "Text: " & $oLink.TextToDisplay & @CRLF & "Address: " & $oLink.Address & _
            @CRLF & "------------------------------------------" & @CRLF
Next
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkGet Example - Process all hyperlinks", $sResult)

Example 2

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkGet Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open test.doc read-only
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkGet Example", "Error opening '.\Extras\Test.doc'. @error = " & _
        @error & ", @extended = " & @extended)

; *****************************************************************************
; Return hyperlink number 2 and display some properties
; *****************************************************************************
Local $oLink = _Word_DocLinkGet($oDoc, 2)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkGet Example", _
        "Error accessing link collection of the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $sResult = "Total number of hyperlinks in the document: " & @extended & @CRLF & @CRLF & _
        "Text: " & $oLink.TextToDisplay & @CRLF & _
        "Address: " & $oLink.Address & @CRLF & _
        "Screentip: " & $oLink.Screentip
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocLinkGet Example - Process hyperlink #2", $sResult)


Function _Word_DocOpen

Function Reference

_Word_DocOpen

Opens a Word document

#include <Word.au3>
_Word_DocOpen ( $oAppl, $sFilePath [, $bConfirmConversions = False [, $iFormat = $WdOpenFormatAuto [, $bReadOnly = False [, $bRevert = False [, $bAddToRecentFiles = False [, $sOpenPassword = "" [, $sWritePassword = ""]]]]]]] )

Parameters

$oAppl | Word object returned by a preceding call to _Word_Create()
$sFilePath | The name or full path of the document to open
$bConfirmConversions | [optional] True displays the Convert File dialog if the file isn't in Word format (default = False)
$iFormat | [optional] Specifies the format to use when opening the document. Can be any of the WdOpenFormat enumeration (default = $WdOpenFormatAuto = the existing format)
$bReadOnly | [optional] True to open the document as read-only (default = False). Note: This argument doesn't override the read-only recommended setting on a saved document.
$bRevert | [optional] Controls what happens if $sFilePath is the name of an open document. True to discard any unsaved changes to the open document and reopen the file. False to activate the open document (default = False)
$bAddToRecentFiles | [optional] True adds the file name to the list of recently used files at the bottom of the File menu (default = False)
$sOpenPassword | [optional] The password for opening the document
$sWritePassword | [optional] The password for saving changes to the document

Return Value

Success: | a variable pointing to the document object. @extended is set to 1 if $bReadOnly = False but read-write access could not be granted. Please see the Remarks section for details.
Failure: | sets the @error flag to non-zero.
@error: | 1 - $oAppl is not an object 2 - The specified document does not exist 3 - Error occurred when opening specified document. @extended is set to the COM error code

Remarks

When you set $bReadOnly = False but the document can't be opened read-write @extended is set to 1.
The document was opened read-only because it has already been opened by another user/task or the file is set to read-only by the filesystem.
If you modify the document you need to use _Word_DocSaveAs() to save it to another location or with another name.

Related

_Word_DocClose, _Word_DocSave, _Word_DocSaveAs

Example

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocOpen Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Open a document read-only
; *****************************************************************************
Local $sDocument = @ScriptDir & "\Extras\Test.doc"
_Word_DocOpen($oWord, $sDocument, Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocOpen Example 1", "Error opening '.\Extras\Test.doc'." & _
        @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocOpen Example 1", "Document '" & $sDocument & "' has been opened successfully.")


Function _Word_DocPictureAdd

Function Reference

_Word_DocPictureAdd

Adds a picture to the document

#include <Word.au3>
_Word_DocPictureAdd ( $oDoc, $sFilePath [, $bLinkToFile = False [, $bSaveWithDocument = False [, $oRange = 0]]] )

Parameters

$oDoc | Word document object
$sFilePath | The path and file name of the picture
$bLinkToFile | [optional] Specifies whether to link the picture to the file from which it was created. True - Link the picture to the file from which it was created False - Make the picture an independent copy of the file (default)
$bSaveWithDocument | [optional] Specifies whether to save the linked picture with the document. True - Save the linked picture with the document False - Do not save the linked picture with the document (default)
$oRange | [optional] The location where the picture will be placed in the text. Can be 0 (the picture is placed automatically) or any range object (default = 0)

Return Value

Success: | a variable pointing to the shape object
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $oDoc is not an object 2 - The specified picture does not exist 3 - Error occurred when adding the specified picture. @extended is set to the COM error code 4 - $oRange is not 0 but is not a range object

Example

Example 1

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocPictureAdd Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open the test document
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocPictureAdd Example", _
        "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Insert a picture after the fourth word of the document
; *****************************************************************************
; Set the range as insert marker after the 4th word
Local $oRange = _Word_DocRangeSet($oDoc, -1, Default, 4, Default, 4)
_Word_DocPictureAdd($oDoc, @ScriptDir & "\Extras\Screenshot.png", Default, Default, $oRange)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocPictureAdd Example", _
        "Error adding the picture to the document" & @CRLF & " @error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocPictureAdd Example", _
        "Picture has successfully been added after word 4 in the document.")

Example 2

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocPictureAdd Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open the test document
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocPictureAdd Example", _
        "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Add a picture to the end of the document
; *****************************************************************************
; Set the range as insert marker to the end of the document
Local $oRange = _Word_DocRangeSet($oDoc, -2)
_Word_DocPictureAdd($oDoc, @ScriptDir & "\Extras\Screenshot.png", Default, Default, $oRange)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocPictureAdd Example", _
        "Error adding the picture to the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocPictureAdd Example", _
        "Picture has successfully been added at the end of the document.")


Function _Word_DocPrint

Function Reference

_Word_DocPrint

Prints all or parts of the specified document

#include <Word.au3>
_Word_DocPrint ( $oDoc [, $bBackground = False [, $iCopies = 1 [, $iOrientation = -1 [, $bCollate = True [, $sPrinter = "" [, $iRange = $WdPrintAllDocument [, $vFrom = 0 [, $vTo = 0 [, $sPages = "" [, $iPageType = $WdPrintAllPages [, $iItem = $WdPrintDocumentContent]]]]]]]]]]] )

Parameters

$oDoc | Word document object
$bBackground | [optional] True lets the script continue while the document is printed (default = False)
$iCopies | [optional] The number of copies to be printed (default = 1)
$iOrientation | [optional] Sets the orientation of the page: -1 - Use current document orientation (default) 0 - Portrait ($WdOrientPortrait of the WdOrientation enumeration) 1 - Landscape ($WdOrientLandscape of the WdOrientation enumeration)
$bCollate | [optional] True prints all pages of the document before printing the next copy (default = True)
$sPrinter | [optional] Sets the name of the printer (default = "" = Active printer)
$iRange | [optional] Specifies the page range to print. Can be any of the WdPrintOutRange enumeration. (default = $WdPrintAllDocument = print the entire document)
$vFrom | [optional] The starting page number (integer) when $iRange is set to $WdPrintFromTo
$vTo | [optional] The ending page number (integer) when $iRange is set to $WdPrintFromTo
$sPages | [optional] The page numbers and page ranges to be printed, separated by commas when $iRange is set to 4. For example, "2, 6-10" prints page 2 and pages 6 through 10 (default = "")
$iPageType | [optional] The type of pages to be printed. Can be any of the WdPrintOutPages enumeration (default = $WdPrintAllPages = print all pages)
$iItem | [optional] The item to be printed. Can be any of the WdPrintOutItem enumeration (default = $WdPrintDocumentContent = document content)

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $oDoc is not an object 2 - Error setting page orientation. @extended is set to the COM error code 3 - @error returned when setting the active printer to $sPrinter 4 - Error occurred when printing the file. @extended is set to the COM error code

Remarks

Specifying $bBackground does NOT pause the script until the document is finished printing, it only pauses
until Microsoft Word finishes sending the document to the printer.
If you specify a printer note that the \\servername\printer seems to be case sensitive.

Related

_Word_DocExport

Example

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocPrint Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open the test document
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocPrint Example", _
        "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Print the complete document with default values
; *****************************************************************************
Local $sActivePrinter = $oDoc.Application.ActivePrinter
MsgBox($MB_SYSTEMMODAL, "", "The name of the active printer is: " & $sActivePrinter)
_Word_DocPrint($oDoc)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocPrint Example", _
        "Error printing the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocPrint Example", "The document has successfully been printed to: " & _
        $sActivePrinter)


Function _Word_DocRangeSet

Function Reference

_Word_DocRangeSet

Sets or modifies a range in a document

#include <Word.au3>
_Word_DocRangeSet ( $oDoc, $vRange [, $iStartUnit = Default [, $iStartCount = Default [, $iEndUnit = Default [, $iEndCount = Default]]]] )

Parameters

$oDoc | Word document object
$vRange | Range to set or extend. You can pass an existing range which then is extended. Also valid is: 0 - uses the current selection as range -1 - sets the range start/end at the start of the document -2 - sets the range start/end at the end of the document
$iStartUnit | [optional] Unit by/to which the start position of the range is to be moved/set. Can be any of the WdUnit enumeration (default = $WdWord). When set to -1 the range is collapsed to the start of the range
$iStartCount | [optional] Number of units by/to which the start of range is moved/set. Positive numbers move the range forward in the document. If the position is moved forward to a position beyond the end position of the range, the range is collapsed and both the start and end positions are moved together(default = don't move the start position)
$iEndUnit | [optional] Unit by/to which the end position of the range is to be moved/set. Can be any of the WdUnit enumeration (default = $WdWord). When set to -1 the range is collapsed to the end of the range
$iEndCount | [optional] Number of units by/to which the end of the range is moved/set. If this number is negative, the end is moved backward. If the ending position overtakes the starting position, the range collapses and both positions move together (default = don't move the end position)

Return Value

Success: | the modified range object.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $oDoc is not an object 2 - $vRange has to be a range object, 0 or -1 3 - Error occurred when setting the start of the range. @extended is set to the COM error code 4 - Error occurred when setting the end of the range. @extended is set to the COM error code

Example

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oRange, $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocRangeSet Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open the test document
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocRangeSet Example", _
        "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Scene 1
; Move the start of the range to the next paragraph and extend the end by 2
; words. Insert text before and after the range and display some statistics
; *****************************************************************************
; Move the start of the range to the next paragraph and extend the end by 2 words
$oRange = _Word_DocRangeSet($oDoc, -1, $wdParagraph, 1, Default, 2)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocRangeSet Example", _
        "Error setting/expanding range." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
$oRange.Select
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocRangeSet Example", _
        "Range has been successfully set to the first two words in the second paragraph.")

; Insert some text before the range
$oRange.InsertBefore("Inserted text at the start! ")
$oRange.Select
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocRangeSet Example", "Inserted text at the start of the range.")

; Insert some text after the range
$oRange.InsertAfter("inserted text at the end! ")
$oRange.Select
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocRangeSet Example", "Inserted text at the end of the range.")

; Display some statistics
Local $iWords = $oRange.ComputeStatistics(0)
Local $iCharacters = $oRange.ComputeStatistics(3)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocRangeSet Example", "The selected range has:" & @CRLF & _
        $iWords & " words " & @CRLF & $iCharacters & " characters.")

; *****************************************************************************
; Scene 2
; Move the end of the range one character to the left so the space to the next
; word isn't formatted and format the text bold, italic and underlined
; *****************************************************************************
$oRange = _Word_DocRangeSet($oDoc, $oRange, Default, Default, $wdCharacter, -1)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocRangeSet Example", _
        "Error setting/expanding range." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Format the range bold, italic und underline
$oRange.Bold = True
$oRange.Italic = True
$oRange.Underline = True
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocRangeSet Example", "Added some formatting.")

; *****************************************************************************
; Scene 3
; Collapse the range to 0 length (insert mark) and insert a line break
; *****************************************************************************
$oRange = _Word_DocRangeSet($oDoc, $oRange, Default, Default, -1, Default)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocRangeSet Example", _
        "Error setting/expanding range." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
$oRange.InsertBreak($wdLineBreak)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocRangeSet Example", "Inserted a break.")

; *****************************************************************************
; Scene 4
; Move the range to the first character in the next line (space) and remove it
; *****************************************************************************
$oRange = _Word_DocRangeSet($oDoc, $oRange, Default, Default, $wdCharacter, 1)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocRangeSet Example", _
        "Error setting/expanding range." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
$oRange.Delete
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocRangeSet Example", "Deleted a character.")


Function _Word_DocSave

Function Reference

_Word_DocSave

Saves the specified Word document

#include <Word.au3>
_Word_DocSave ( $oDoc )

Parameters

$oDoc Word document object

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $oDoc is not an object 2 - The specified document has not been saved before, please use _Word_DocSaveAs() first 3 - Error occurred when saving the specified document. @extended is set to the COM error code

Remarks

If the document hasn't been saved before or has been opened read-only, the Save As dialog box prompts the user for a file name.

Related

_Word_DocSaveAs

Example

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <Word.au3>

; Copy \Extras\Test.doc to @TempDir
If FileCopy(@ScriptDir & "\Extras\Test.doc", @TempDir & "\_Word_Test.doc", $FC_OVERWRITE) = 0 Then Exit MsgBox($MB_SYSTEMMODAL, _
        "Word UDF: _Word_DocSave Example", "Couldn't copy '.\Extras\Test.doc' as '_Word_Test.doc' to the @TempDir directory.")
; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSave Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open the test document
Local $oDoc = _Word_DocOpen($oWord, @TempDir & "\_Word_Test.doc")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSave Example", _
        "Error opening '_Word_Test.doc'." & @CRLF & "error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Save the document
; *****************************************************************************
; Insert text at the beginning
Local $oRange = _Word_DocRangeSet($oDoc, -1)
$oRange.Text = "Bold text at the beginning. "
$oRange.Bold = True
; Save document
_Word_DocSave($oDoc)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSave Example", _
        "Error saving the Word document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSave Example", "Document successfully saved as '" & _
        $oDoc.FullName & "'")


Function _Word_DocSaveAs

Function Reference

_Word_DocSaveAs

Saves the specified Word document with a new name or format

#include <Word.au3>
_Word_DocSaveAs ( $oDoc [, $sFileName = Default [, $iFileFormat = $WdFormatDocument [, $bReadOnlyRecommended = False [, $bAddToRecentFiles = True [, $sPassword = "" [, $sWritePassword = ""]]]]]] )

Parameters

$oDoc | Word document object
$sFileName | [optional] The full path name for the document (default = Current folder and current file name). If the document has never been saved, the default name is used (for example, Doc1.doc)
$iFileFormat | [optional] The format in which the document is saved. Can be any WdSaveFormat constant (default = $WdFormatDocument)
$bReadOnlyRecommended | [optional] True to have Word suggest read-only status whenever the document is opened (default = False)
$bAddToRecentFiles | [optional] True to add the document to the list of recently used files (default = True)
$sPassword | [optional] A password string for opening the document (default = "")
$sWritePassword | [optional] A password string for saving changes to the document (default = "")

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $oDoc is not an object 2 - Error occurred when saving the specified document. @extended is set to the COM error code

Remarks

If a document with the specified file name already exists, the document is overwritten without the user being prompted first.

Related

_Word_DocSave

Example

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <Word.au3>

; Copy \Extras\Test.doc to @TempDir
If FileCopy(@ScriptDir & "\Extras\Test.doc", @TempDir & "\_Word_Test.doc", $FC_OVERWRITE) = 0 Then Exit MsgBox($MB_SYSTEMMODAL, _
        "Word UDF: _Word_DocSaveAs Example", "Couldn't copy '.\Extras\Test.doc' as '_Word_Test.doc' to the @TempDir directory.")
; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSaveAs Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open the test document
Local $oDoc = _Word_DocOpen($oWord, @TempDir & "\_Word_Test.doc")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSaveAs Example", _
        "Error opening '_Word_Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Save the document as _Word_Test2.doc
; *****************************************************************************
; Insert text at the beginning
Local $oRange = _Word_DocRangeSet($oDoc, -1)
$oRange.Text = "Bold text at the beginning. "
$oRange.Bold = True
; Save document
_Word_DocSaveAs($oDoc, @TempDir & "\_Word_Test2.doc")
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSaveAs Example", _
        "Error saving the Word document." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSaveAs Example", "Document successfully saved as '" & _
        @TempDir & "\_Word_Test2.doc'.")


Function _Word_DocTableRead

Function Reference

_Word_DocTableRead

Reads a Word table and returns the content as a two-dimensional array

#include <Word.au3>
_Word_DocTableRead ( $oDoc, $vTable [, $iIndexBase = Default [, $sDelimiter = Default]] )

Parameters

$oDoc | Word document object
$vTable | Table object or index of the table in the table collection
$iIndexBase | [optional] Can be 0 or 1 and specifies if the array starts with row 0 or 1 (default = 1)
$sDelimiter | [optional] Specifies the character used to separate text into cells (default = @TAB)

Return Value

Success: | Two-dimensional array with the content of the Word table.
Failure: | "" and sets the @error flag to non-zero.
@error: | 1 - $oDoc is not an object 2 - Error occurred when accessing the specified table index in the table collection. @extended is set to the COM error code 3 - Error occurred when accessing the specified table. @extended is set to the COM error code 4 - Error occurred when converting the text to a table. @extended is set to the COM error code

Remarks

Nested tables are ignored.
If $iIndexBase is set to 1 then row 0 of the array contains the row and column count.

Related

_Word_DocTableWrite

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocTableRead Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open the test document
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocTableRead Example", _
        "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Create a table from an array
Local $asArray[3][3] = [[1, 2, 3], ["a", "b", "c"], ["x", "y", "z"]]
Local $oRange = _Word_DocRangeSet($oDoc, -2)
Local $oTable = _Word_DocTableWrite($oRange, $asArray, 0)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocTableRead Example", _
        "Error creating the table." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Read the first table in the document and return the content
; *****************************************************************************
Local $asResult = _Word_DocTableRead($oDoc, 1, 1)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocTableRead Example", _
        "Error reading the table to an array." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
_ArrayDisplay($asResult, "Word UDF: _Word_DocTableRead Example")


Function _Word_DocTableWrite

Function Reference

_Word_DocTableWrite

Writes a one or two dimensional array to a Word table

#include <Word.au3>
_Word_DocTableWrite ( $oRange, ByRef $aArray [, $iIndexBase = Default [, $sDelimiter = Default]] )

Parameters

$oRange | Word range object where the table should be inserted
$aArray | one or two-dimensional array to be converted to a table. Can be zero or 1-based
$iIndexBase | [optional] Can be 0 or 1 and specifies if the array starts with row 0 or 1 (default = 1)
$sDelimiter | [optional] Specifies the character used to separate text into cells (default = @TAB)

Return Value

Success: | the Word table object.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $oRange is not an object 2 - $aArray is not an array or has more than 2 dimensions 3 - Error occurred when accessing the specified range object. @extended is set to the COM error code 4 - Error occurred when converting the text to a table. @extended is set to the COM error code

Remarks

The array can not contain @CR, @CRLF or @LF in any cell.
If the array contains @TAB characters you have to set parameter $sDelimiter to another character.

Related

_Word_DocTableRead

Example

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocTableWrite Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open the test document
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocTableWrite Example", _
        "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; Write the content of a 0-based two dimensional array to a Word table
; *****************************************************************************
Local $asArray[3][3] = [[1, 2, 3], ["a", "b", "c"], ["x", "y", "z"]]
Local $oRange = _Word_DocRangeSet($oDoc, -2)
_Word_DocTableWrite($oRange, $asArray, 0)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocTableWrite Example", _
        "Error creating the table." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocTableWrite Example", _
        "Table successfully added to the end of the document.")


Function _Word_Quit

Function Reference

_Word_Quit

Closes all documents, the Word application and removes the object reference to it

#include <Word.au3>
_Word_Quit ( $oAppl [, $iSaveChanges = $WdDoNotSaveChanges [, $iOriginalFormat = $WdWordDocument [, $bForceClose = False]]] )

Parameters

$oAppl | Word object returned by a preceding call to _Word_Create()
$iSaveChanges | [optional] Specifies if changed documents should be saved before closing. Can be one of the WdSaveOptions enumeration (default = $WdDoNotSaveChanges)
$iOriginalFormat | [optional] Specifies how Word saves documents whose original format was not Word document format. Can be any of the WdOriginalFormat enumeration (default = $WdWordDocument)
$bForceClose | [optional] If True the Word application is closed even when it was running at _Word_Create() time (default = False)

Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $oAppl is not an object 2 - Error returned by method Application.Quit. @extended is set to the COM error code

Remarks

If Word was not running when _Word_Create() was called then _Word_Quit() closes all documents of the specified
instance (even those opened manually by the user after _Word_Create() ) and the Word application.
If Word was running you have to set $bForceClose to True to do the same.

Related

_Word_Create

Example

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocQuit Example", _
        "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $bWordClose = @extended
; Open the test document read-only
_Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocQuit Example", _
        "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; If Word was running when this script is started only the reference to the
; object will be removed.
; If Word was started by this example all documents and Word will be closed.
; *****************************************************************************
Local $iResult
If $bWordClose Then
    $iResult = MsgBox(BitOR($MB_OKCANCEL, $MB_SYSTEMMODAL), "Word UDF: _Word_Quit Example", _
            "If you click OK ALL unsaved changes in ALL open documents of this Word instance will be lost and the instance will be closed.")
Else
    $iResult = MsgBox(BitOR($MB_OKCANCEL, $MB_SYSTEMMODAL), "Word UDF: _Word_Quit Example", _
            "Word was already running when function _Word_Create was called. Hence only the reference to the object will be removed.")
EndIf
If $iResult = 2 Then Exit
_Word_Quit($oWord)
If @error Then MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_Quit Example", _
        "Error closing the Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)


AutoIt Changelog
================

3.3.14.0 (10th July, 2015) (Release)
AutoIt:
- Changed: Minimum OS requirements are now Windows XP SP3 and Windows Server 2003 SP2.
- Changed: PCRE regular expression engine updated to 8.35.
- Changed: Default text file encoding changed to UTF8 without BOM.
- Changed: FileOpen() has new modes for forcing ANSI, UTF16-BE/LE without BOM.

- Added #2761: AutoIt.chm title version.
- Added #2365: FileFindNextFile() - information in @extended.
- Added #2647: Return the line count from FileReadToArray() in @extended.
- Added #2665: FileCopy() no longer fails when copying EFS files to destinations that don't support encryption.
- Added #2686: Random() to return max value when min equals max.
- Added #2346: FileSetEnd().
- Added: Regular expression caching. Small performance improvements when using the same pattern multiple times.
- Added: Constants for native Functions in AutoItConstants.au3.
- Added #3012: GUISetFont() default value doc.
- Added: @OSVersion supports Windows 10 and Windows Server 2016.

- Fixed: Functions fixed for extended length paths: FileOpen(), FileCopy(), FileMove(), FileDelete().
- Fixed #2755: SetError() doc precision.
- Fixed #2743: Hex() crash with invalid len.
- Fixed #2685: HotKeySet() fails to register a Hungarian letter.
- Fixed #2588: Menu/Statusbar location problem.
- Fixed #2471: Bad restore for script using $WS_EX_LAYOUTRTL.
- Fixed #2287: GUICtrlSetState() $GUI_ONTOP not set.
- Fixed #1573: TCPTimeout for Connect.
- Fixed #2596: TCP/UDP @error values to be unique.
- Fixed #2626: ControlGetText(), WinGetText(), WinGetTitle() wrong encoding for some words.
- Fixed #2538: GuiSetAccelerators() was still firing events on disabled button controls.
- Fixed #2671: StringSplit() was splitting incorrectly with regards to case sensitivity.
- Fixed #2372: Incorrect line number given on a bad function call. (Still issues with Callback line errors).
- Fixed #2805: FileWriteLine() was not returning a failure when disk was full.
- Fixed #2623: RegDelete() returning 0 rather than 2 when a key exists but no write permissions to delete it.
- Fixed #2813: Accessing "last created control" once GUI deleted caused a hard crash.
- Fixed #2640: Odd conversion of strings containing numbers in expressions.
- Fixed #2363: Call() with invalid user function was not setting @error correctly when used as an expression within another function call.
- Fixed #2364: Call() with CallArgArray and no parameters.
- Fixed #2789: With EndWith parameter issue.
- Fixed #2820: WinExists() and other Win functions were incorrectly converting strings containing numbers into window handles and causing false matches.
- Fixed #2502: Copy-on-write optimization when passing array and map elements ByRef was incorrect.
- Fixed: Assigning objects by reference to COM properties like "$obj(some, params) = $obj2".
- Fixed #2639: Unable to Copy/Paste from Embedded IE object.
- Fixed #2839: GUISetAccelerators() with an invalid array can cause a hard crash.
- Fixed #2920: Doc precision about no control position/resizing on initially window for GUiCreate()/WinMove().
- Fixed #2924: Progress bar style documentation.
- Fixed #3028: GUICtrlCreateCombo() doc formatting.
- Fixed #3040: Int() doc typos.
- Fixed #3042: Number() doc clarifications.
- Fixed #3041: AutoItWinGetTitle() doc example typos.
- Fixed #3039: AutoItWinSetTitle() doc example typos.
- Fixed #3057: StringSplit() Return Value if $STR_NOCOUNT doc.
- Fixed #2993: _Excel_RangeFind returns only last occurrence of string found.

AutoItX:
- Changed: AutoItX3.psd1 renamed to AutoItX.psd. PSModulePath updated on install so that the system will auto-import.

- Fixed #2694: ControlListView not finding controls in x64 mode.

UDFs:
- Changed: _SQLite 3.8.4.3 -> 3.8.10.0.
- Changed: Reduced duplicate code for finding the maximum and minimum value in an array.
- Changed: _ArrayAdd() now uses constants to change addition behaviour and datatype forcing.
- Changed: _ArrayInsert now uses constants to change addition behaviour and datatype forcing.
- Changed: _GDIPlus_Startup() need explicit Dll for GDI+ v1.1 support under Vista or Server 2008.
- Changed: Removed internal redraw code from _GUIListView_DeleteAllItems() and _GUIListView_DeleteSelectedItems().
- Changed: _ArrayUnique() can now deal with Int64 values via new parameter.
- Changed: Re-wrote _StringInsert() using native functions.
- Changed: _HexToString() to _StringToHex() now handles strings and binary as UTF-8 by default.
- Changed: _FileWriteToLine() overwrite optional parameter is now boolean and not an integer of zero or one. The old values are still supported for now.
- Changed: _Excel_BookOpen() changed from @error = 4 to @error = 0 and @extended = 1 if Workbook could not be opened Read-Write. THIS IS A SCRIPT BREAKING CHANGE
- Changed: _Word_DocOpen() changed from @error = 4 to @error = 0 and @extended = 1 if document could not be opened Read-Write. THIS IS A SCRIPT BREAKING CHANGE
- Changed: Re-wrote _MathCheckDiv().
- Changed: _ArrayTranspose() algorithm.

- Added #2732: ObjName() doc example.
- Added #2751: Regions and GUI control tip labels to the control sample example.
- Added #2764: _WinAPI_ShellExecuteEx(), _WinAPI_GetPriorityClass() doc constants.
- Added: $SS_ENHMETAFILE, $SS_REALSIZECONTROL, $STM_SETICON, $STM_GETICON, $STM_SETIMAGE, $STM_GETIMAGE to StaticConstants.au3.
- Added #2826: Quit to close the browser.
- Added #2836: _WinAPI_SfcIsKeyProtected() doc example.
- Added: More _GDIPlus_Font* functions.
- Added: _WinAPI_GetFontResourceInfo() return more Font information.
- Added: _WinAPI_GetFontMemoryResourceInfo().
- Added #2922: _VersionCompare() with different number of fields.
- Added #2968: Optional parameter $iMSeconds to _SetTime().
- Added: $SB_ANSI, $SB_UTF16LE, $SB_UTF16BE and $SB_UTF8 constants to StringConstants.au3, for use with BinaryToString() and StringToBinary().
- Added: Constants to Assign() and IsDeclared().
- Added #2982: _FTP_Connect() example improvement.
- Added #2976: #pragma default value.
- Added #2998: Added missing key (03 - control-break processing) to the _IsPressed() documentation.
- Added: _GDIPlus_ImageGetDimension().
- Added: _GDIPlus_BitmapCreateDIBFromBitmap() can be used to allow .PNG in GUICtrlCreatePic().
- Added: _GDIPlus_ImageGetThumbnail().
- Added #3034: _Timer_SetTimer() doc example.

- Fixed #2734: Incorrectly setting the wrong member.
- Fixed #2736: DriveGetType() and _WinAPI_SetWindowPos() doc Constants.au3 to AutoItConstants.au3.
- Fixed #2737: _WinAPI_ShellGetStockIconInfo() doc $SIID_ constants.
- Fixed #2744: Requires IE5 removal as Min OS = Windows XP.
- Fixed #2741: _WinAPI_DrawThemeEdge() constants reference in BorderConstants.au3.
- Fixed #2740: _WinAPI_IsProcessorFeaturePresent() doc $PF_* constants.
- Fixed #2739: _WinAPI_SetLocaleInfo() doc $LOCALE_* constants.
- Fixed #2738: _WinAPI_ShellRestricted() doc $REST_* constants.
- Fixed #2745: Mismatch of supported operating system with the official AutoIt site.
- Fixed #2746: IE6Example.htm refreshing and associated COMRef.htm.
- Fixed #2749: Bad Include in COM example.
- Fixed #2748: Variable used before declaration.
- Fixed #2758: _ArrayPermute() with multicharacter delimiter.
- Fixed #2782: Documentation of various constants.
- Fixed #2803: _ArrayMinIndex() and _ArrayMaxIndex() failing with 1-dimensional arrays that had 1 element only.
- Fixed: _ArrayAdd() failing with a trailing delimiter in $vValue.
- Fixed #2816: Doc precision with _GDIPlus_ImageLoadFromFile() specifying -1 when it's 0 on failure.
- Fixed: _Crypt_DecryptData() and _Crypt_EncryptData() failing with a blank string when using the RC4 algorithm.
- Fixed #2821: Example comment was incorrect for _DateToDayOfWeekISO().
- Fixed #2823: _ChooseFont() default color BGR not RGB.
- Fixed: Limit bug in _ArrayToClip(), _ArrayExtract() and _ArrayToString().
- Fixed #2828: Typo of security in _IEFormElementSetValue().
- Fixed: Limit bug in _ArraySwap().
- Fixed #2861: _WinAPI_ReadDirectoryChanges() example.
- Fixed #2874: _GUICtrlRichEdit_SetCharColor() not at insertpoint.
- Fixed #2909: Backslash was not appended in _PathMake() if $sDir was blank.
- Fixed #2908: _ScreenCapture_Capture() failing due to out of bounds error.
- Fixed #2917: _WinAPI_AddMRUString() example crash when run in X64 mode (Msdn Bug CreateMRUListW !!!).
- Fixed #2918: _GDIPlus_GetEncoderParameterList() not working.
- Fixed: Range setting in _ArrayDisplay().
- Fixed: _Array_FindAll() return array incorrectly dimesioned for row search.
- Fixed #2964: Incorrect structure for $tagWNDCLASS.
- Fixed: _WinAPI_IsWritable() wrong detection when the device is not ready.
- Fixed: The seconds parameter in _SetTime() being set as milliseconds.
- Fixed #2967: Incorrect format of AM/PM when the time was 00:00.
- Fixed #2983: _WinApi_GetString() doc.
- Fixed #3011: _FileListToArrayRec() not closing the open handle.
- Fixed: _Word_DocFind(), _Word_DocFindReplace() and _Word_DocPrint() did not set @extended to the COM error code.
- Fixed: _StringExplode not using full delimiter to split.
- Fixed #3018: _GDIPlus_EffectCreateHueSaturationLightness () doc and _GDIPlus_BitmapApplyEffect() crash.
- Fixed #3038: _Timer_SetTimer() callback function parameters.
- Fixed #3037: _RunDOS() waits for command completion.
- Fixed #3055: Bad link in _WinAPI_IOCTL() doc.
- Fixed #3052: _ArraySort() doc clarification for 2D.
- Fixed #3059: Miscelaneous => Miscellaneous in Help : Typos.
- Fixed #3063: Removed additional param in the $tagRAWKEYBOARD structure.

Au3Check:
- Fixed: False error report on COM variable.
- Fixed: False error report on With statement.
- Added: Support of UTF8 with BOM files.

Others:
- Changed: Improved highlighting AutoIt code inside the HTML files.

- Added: Icons\MyAutoit3_*.ico to be used when compiling user scripts (small footprint).
- Added: lang-autoit.js code highlighting file for Google Prettify. See the Extras\Prettify folder.

- Fixed: Re-writing the scripts which generate the syntax files for the editors and GeSHi, resulted in missing descriptions being added and correct sorting of functions.

3.3.12.0 (1st June, 2014) (Release)
AutoIt:
- Changed: PCRE regular expression engine updated to 8.34.

- Added #2557: Send() special control strings will no longer treat 0 repetitions as 1. No keys will be sent.
- Added #2489: HttpSetUserAgent() now returns the previous user agent string.
- Added #2481: FileSelectFolder() will use the Windows Vista style if available.

- Fixed #2562: StringRegExp() & Null character.
- Fixed #2581: Dec() wasn't working correctly for flags 0, 1, 2.
- Fixed #2568: StringStripWS() and StringIsSpace() now treats null as a whitespace character.
- Fixed #2566: "override" cursor in GUISetCursor() fails inside client area.
- Fixed #2573: "override" cursor in GUISetCursor() fails outside of client area.
- Fixed #2478: Assign() and Eval() do not restrict variable names.
- Fixed #2316: PowerPoint COM event handler initialization error.
- Fixed #2512: ObjName() crash.
- Fixed #2613: AutoIt crashes whenever an array value returned from a WMI query is null.
- Fixed #2309: Bad conversion of VT_BSTR|VT_BYREF COM variants when the referenced string is null.
- Fixed #2648: FileSaveDialog() not adding extension when user types manually.
- Fixed #2717: Appendix constants page precision about Inet Constants.

UDFs:
- Removed: Usage of Call() in _FTP_ProgressDownload(), _FTP_ProgressUpload() and _SQLite_Startup(). See documentation for changes to $hFunctionCall and $hPrintCallback parameters. THIS IS A SCRIPT BREAKING CHANGE.
- Removed: http://api.exip.org/?call=ip from _GetIP() as the site was taken offline.
- Removed: _WinAPI_GetUDFVersion() as all UDFs share the same version number as the AutoIt version they are shipped with.

- Changed: Constant variables are now used in the UDFs rather than their value.
- Changed: Re-wrote _FileWriteToLine() to use FileReadToArray().
- Changed: Re-wrote _DateDayOfWeek() which can now return the days of the week of the user's locale.
- Changed: _FileReadToArray() now returns a 1D/2D array depending on parameters used.
- Changed: Re-wrote _DateToMonth() which can now return the months of the user's locale.
- Changed: Re-wrote Array UDF to add 2D support and add some functions. THIS IS A SCRIPT BREAKING CHANGE.
- Changed: Excel UDF was re-written. Functions and/or parameters have been renamed, removed or added. THIS IS A SCRIPT BREAKING CHANGE.
- Changed: _SQLite 3.8.2.0 -> 3.8.4.3.

- Added: Error checking to _ArrayDelete() when $iElement was out of bounds.
- Added: Example for _WinAPI_SystemParametersInfo().
- Added: A timer of 5 minutes to _GetIP() between each public IP retrieval. This is to reduce overloading the IP discovery sites.
- Added: $STR_REGEXP* contants in StringConstants.au3 for StringRegExp().
- Added: _SQLite_SQLiteExe() download sqlite3.exe when needed.
- Added: http://bot.whatismyipaddress.com as an IP disovery site to _GetIP().
- Added: _Array1DToHistogram().
- Added #2726: Group ID to return array for _GUICtrlListView_GetGroupInfoByIndex().

- Fixed: _FileListToArrayRec() array concatenation bug.
- Fixed #2550: _GUICtrlComboBox_GetEditText() struct sizing.
- Fixed: _INetSmtpMail() SmtpServer IPaddr checking.
- Fixed #2618: _StringBetween() behaviour when $sStart and $sEnd are identical.
- Fixed #2660: Button on GUI example.
- Fixed: _IECreate() disable use of Windows Key.
- Fixed #2689: When $bCursor in _ScreenCapture_Capture() was set to True and the PC was locked.
- Fixed #2693: _GUICtrlListView_GetItemTextArray() return value doc.
- Fixed #2697: missing $GW_ENABLEDPOPUP constant.
- Fixed #2700: _GUICtrlRichEdit_SetCharBkColor() not at insertpoint.
- Fixed #2706: $tagWINDOWINFO bad struct.
- Fixed: _GUICtrlListView_GetView() and _GUICtrlListView_SetView() were using 0 for detailed view and 1 for large icon view, when it's the opposite way around. THIS IS A SCRIPT BREAKING CHANGE.
- Fixed: Incorrect default style for _GUICtrlMenu_CreateMenu() and _GUICtrlMenu_CreatePopup() and changed documentation to use constant values.

Au3Check:
- Fixed #2612: Function reference ByRef.
- Fixed: Undetected errors.

AutoIt3Help:
- Changed: Version number to 1.0.0.6.

- Added: Windows activation when already open.

Others:
- Changed: Help file syntax variable names to a standard naming convention for easier understanding and consitency in the calltip syntax files.

- Added: Keywords and Macros to the Notepad++ autoit.xml file.

- Fixed #2677: AutoIt.chm Installdir.htm reference.
- Fixed #2676: AutoIt.chm Installdir.htm \Sqlite reference.
- Fixed #2725: AutoIt3.chm printing example.

3.3.10.2 (30th December, 2013) (Release)
AutoIt:
- Fixed #2576: All AutoIt EXEs and tools not working on older Athlon XP processors due to SSE compiler options.

Aut2Exe:
- Fixed #2580: Aut2Exe failing to run multiple times on Windows XP prior to SP3.

Others:
- Fixed #2571: Notepad++ autoit.xml was incorrectly formatted and not displaying calltips.

3.3.10.1 (28th December, 2013) (Release)
AutoIt:

Aut2Exe:
- Fixed: Aut2Exe was leaving a temporary file around.

UDFs:
- Added: Error checking to _GDIPlus_GraphicsDrawString() in case _GDIPlus_GraphicsMeasureString() fails to return an array.

- Fixed: Incorrect function being called for _GDIPlus_BitmapCloneArea().
- Fixed: _ArrayDisplay() user function call and range bug.

3.3.10.0 (23rd December, 2013) (Release)
AutoIt:
- Removed: PluginOpen() and PlugInClose() removed to due to not being used and never having progressed past the experimental stage.

- Changed: Removed Windows 2000 support. Minimum supported OS is now Windows XP RTM / Windows Server 2003.
- Changed: upx.exe from 3.07 -> 3.91.
- Changed: PCRE regular expression engine updated to 8.33.
- Changed: Default newline character for PCRE regexes changed to ANYCRLF.
- Changed: ReDim works on arrays declared as static.
- Changed: Run-time errors on objects no longer fatal (execution of the script is not halted).
- Changed: Allowing multiple COM Error Handlers. Last one registered and alive gets called.
- Changed: VT_NULL VARIANT converts to Null keyword (previously empty string).
- Changed: Default manifest file on AutoIt and compiled exes is set for "AsInvoker" and tagged with compatibility for Vista/Win7/Win8 and Win8.1.
- Changed: #NoAutoIt3Execute option replaced with #pragma compile(AutoItExecuteAllowed, false). Default is false.
- Changed: IsAdmin() function changed to be based on token membership. Maybe more acurate for Sandbox type environments.
- Changed: ShellExecute() will return the process ID.

- Added: DriveGetType() updated so that it can detect SSD, and also bus types (SATA, USB, etc.).
- Added: Interpreter accepts 64bit hex numbers.
- Added: Keyword Null.
- Added #488: Third parameter for ObjGet() function to specify object instance.
- Added: Compound assignment operators for object properties.
- Added #1191: Explicit size of arrays optional for explicit initialization.
- Added: Array access on expression: StringSplit("a,b", ",")[1].
- Added: Dot access on expression: ObjCreate("Shell.Application").GetSystemInformation("DirectoryServiceAvailable").
- Added: Empty arrays.
- Added: Functions can now be referenced in variables and the function can be called through the variable.
- Added: FuncName().
- Added: Built-in functions that take a callback now be passed directly in addition to the old method of passing as a string. Built-in functions can also be passed now (be careful that the function you pass matches what the caller expects).
- Added: C++ style ternary operators: Local $fResult = ("foo" = "bar") ? True : False.
- Added: Expression as default function parameter.
- Added: With...EndWith can be used on expressions having dot-access.
- Added: Nested "With...EndWith".
- Added: Call() calls built-in functions.
- Added: ByRef with Call() function.
- Added: Support for more COM VARIANT types.
- Added: @OSVersion supports Windows 8.1 and Windows 2012 R2.
- Added: Regular expressions (PCRE engine) now using the new native 16bit mode and also compiled with full UCP support. Prefix patterns with (*UCP) to enable.
- Added: @LocalAppDataDir for local AppData (@AppDataDir is the roaming location).
- Added: StringReverse() - a UTF16 compatible string reversal function.
- Added: FileReadToArray() - native version of _FileReadToArray().
- Added #2358: FileInstall() accepts @ScriptFullPath as the first parameter to allow easy inclusion of the script source.
- Added #2433: Monospaced in Fonts appendix.

- Fixed #2067: -2147483648 not stored as int32.
- Fixed #2003: ProcessWaitClose() using too much CPU.
- Fixed #2076: COM VARIANT not correctly set for boolean True.
- Fixed #2015: DllCallbackRegister() mangles floating point numbers under x64.
- Fixed: x64 DllCall not setting double type parameters correctly.
- Fixed: DllCallbackRegister() not returning floating point types correctly.
- Fixed: Different issues with Static keyword.
- Fixed #2078: Error in COM expression.
- Fixed #2073: Unexpected termination with ContinueLoop.
- Fixed #1485: Unexpected termination with ContinueCase.
- Fixed: Crash in ObjEvent() for ByRef object parameters.
- Fixed #2068: Repeated calls to Acos() no longer produce strange results. NOTE: This fix increases the size of AutoIt by approximately 60KB.
- Fixed: ObjGet() fails validating class identifier properly when first parameter for the function is specified.
- Fixed #2111: RunAs() could fail even if a user had the correct permissions to use it.
- Fixed #1395: DLLCallbacks on Exit.
- Fixed: Ptr() returns null pointer for objects.
- Fixed #1319: Hang at exit for RichEdit user controls.
- Fixed #2138: Fixed GUICtrlRead() on dummy controls was corrupting strings and possibly crashing AutoIt.
- Fixed #1760: #OnAutoItStartRegister ignores single quoted function names.
- Fixed #2146: Crash when closing AutoIt when started from a console window.
- Fixed: DLLStruct type forgotten in comparison operations.
- Fixed: "struct" type parameter in DllCall() overwrites possibly following parameters.
- Fixed #1566: Array as its own element issue.
- Fixed #1551: Crash the script when changing array.
- Fixed: ReDim allows initialization to non-array.
- Fixed #2166: StringToASCIIArray() and StringFromASCIIArray() did not correctly return an empty string when the start index is greater than the end index.
- Fixed #1901: 32-bit compiled scripts now work from the system32 directory on 64-bit Windows.
- Fixed #2157: ProcessList() would crash if there were more than 512 running processes.
- Fixed #2215: Bad syntax check for default function parameters.
- Fixed #2222: Non-ASCII characters not allowed in object properties/methods.
- Fixed #2235: ProcessGetStats() defaulted to using the current process if an invalid process was specified.
- Fixed #2253: Ping() returns success with no connection.
- Fixed #1498: #RequireAdmin endless loop for disabled UAC.
- Fixed #1698: GUICtrlSetLimit(), limit 32767
- Fixed: Subtle bugs with Ping()
- Fixed #2286: GUICtrtlGetState() without a controlID parameter runs but aborts AutoIt.
- Fixed #2350: Strange issue when using $SS_ETCHEDVERT and $SS_ETCHEDHORZ.
- Fixed #2311: Wrong handling of casesense parameter in StringReplace()
- Fixed #2361: RegRead() doesn't read REG_QWORD values.
- Fixed #2362: WinGetText() and ControlGetText() would sometimes give invalid results due to the target application's handling of WM_GETTEXT.
- Fixed #2075: GUICtrlSetImage() changes icon position on resizable window.
- Fixed #1667: WinMove() Child window.
- Fixed #2367: Sometimes two COM objects wouldn't be classed as equal during comparisons.
- Fixed #1024: GUICtrlSetTip() for tabitems sets incorrectly in certain situations.
- Fixed #2366: For loop not working as expected.
- Fixed #2384: UDPRecv() and TCPRecv() not setting @error correctly in some instances.
- Fixed #2314: Cursor flickers when moving over certain GUI controls.
- Fixed #2066: DllStructSetData() returning int64 instead of int32 in some cases.
- Fixed #2427: ControlTreeView() does not used Option2.
- Fixed #2105: RegRead() and DWORD types incorrectly stored as double.
- Fixed #2299: GUI Button Text Left-Justify for colored button.
- Fixed #1954: ListViewItem returns 0 (failure) even though it populates the ListView.
- Fixed #2152: X^2 Not Working in Hex().
- Fixed #1870: @GUI_DRAGFILE.
- Fixed #2461: GUICtrlSetImage doesn't handle certain types of .gif file.
- Fixed #2167: $WS_EX_LAYOUTRTL and GUICtrlCreateMenu causes bug.
- Fixed #2468: #OnAutoItStartRegister function doc precision.
- Fixed #2315: @OSVersion WIN_2012 support.
- Fixed #2171: TCPTimeout inconsistent.
- Fixed #2518: Static keyword not working correctly.
- Fixed: StringStripCR() and StringAddCR() not working with strings that contain nulls.

UDFs:
- Removed #2174: Explicitly checking if the source and insert strings for _StringInsert() were strings and forcing an @error return value. (@error values 2 and 3 have been removed, please check the documentation.)
- Removed #2187: Forcing _GUICtrlRichEdit_Create() to create a richedit control in a positive position. (@error values 103 and 104 have been removed, please check the documentation.)
- Removed #2172: Select...EndSelect statement from _StringRepeat() and replaced with an If...EndIf as well as optimised the code.
- Removed: Documentation and example for _Iif(). Scripts should be updated to use ternary operators instead. THIS IS A SCRIPT BREAKING CHANGE.
- Removed: Documentation and example for _StringEncrypt(). Scripts should be updated to use the Crypt functions instead. Look at _Crypt_EncryptData() for an alternative example.
- Removed: _ArrayCreate() from Array.au3.
- Removed: Function headers in the UDFs, as information about the function can be found in the help file, This removal resulted in a 32.23% size reduction to the includes folder (7.01MB ->> 4.40MB).
- Removed: Documentation and example for _StringReverse(). Scripts should be updated to use the native function StringReverse() instead.
- Removed: $tagGDIPPENCODERPARAMS (duplicate of $tagGDIPENCODERPARAMS).

- Changed #2117: _FileCountLines() writing to a temporary array to calculate the number of lines in a file.
- Changed: _FileListToArray() to accept the Default keyword to use the default parameters.
- Changed: _FileReadToArray() to parse the file using a regular expression. Now various line endings (not recommended) are displayed correctly in the array.
- Changed: Word UDF was completely re-written. Function names changed from _Word* to _Word_*. THIS IS A SCRIPT BREAKING CHANGE.
- Changed: _Max() and _Min() functions now use the ternary operator.
- Changed: Re-wrote _ReplaceStringInFile() by removing the need to write to a temporary array. (@error values 4, 5 and 6 have been removed, please check the documentation.)
- Changed: Re-wrote _GetIP() for improved efficency and added http://www.myexternalip.com/raw to find the external IP address.
- Changed: _SQLite 3.7.2.0 -> 3.8.2.0.
- Changed: IE3.au3 v3.0-0 to v3.0-1 (see header info for changes).
- Changed: Array UDF now takes into consideration empty arrays.
- Changed: Re-wrote _ProcessGetName() for speed enhancements.
- Changed: Re-wrote _PathSplit() by using a regular expression. Contributed by DXRW4E.
- Changed: _GDIPlus_GraphicsGetSmoothingMode(), _GDIPlus_GraphicsSetSmoothingMode() functions.
- Changed: _FileWriteToLine() can read a file with various line endings (not recommended).
- Changed: $tagGDIPENCODERPARAMS using $tagGDIPENCODERPARAM.
- Changed: _GDIPlus...() using integer or float for positioning.
- Changed: Modified _ArrayUnique() with a faster version and improved error checking.
- Changed: $INTERNET_FLAG_NO_CACHE_WRITE default value for _FTP_ListToArray*().
- Changed: _ArrayDisplay() - new function with new functionalities.
- Changed: GUIListView - new _Delete* functions.

- Added: _WinAPI_GetProcAddress() function.
- Added #2126: Documentation remark about _ArrayDisplay() being able to display a maximum of 65530 items.
- Added #1158: WinAPIEx integrated, split under WinAPI*.au3.
- Added #2250: DirMove() to the related section of DirCopy().
- Added #2155: Missing documentation for the default working directory of Run() / RunWait().
- Added #2224: Optional parameter to _FileReadToArray() to return the array count in the first element.
- Added #2114: Disabling and enabling the redrawing message to increase the speed of displaying _ArrayDisplay(). (Only noticeable on large arrays.)
- Added #2120: Disabling and enabling the redrawing message to increase the speed of deleting items with _GUICtrlListView_DeleteAllItems(). (Only noticeable when deleting many items in a ListView.)
- Added #966: Optional parameter to return the full path of the file/folder in _FileListToArray().
- Added #2193: _StringTitleCase(), to create a title case string.
- Added #2263: _Crypt_GenRandom(), fills a buffer with random data.
- Added #2354: _ArrayTranspose() to the Array UDF.
- Added #2338: Regular expression pattern matching. See the documentation of _ArraySearch() for more details.
- Added #2340: Optional parameter to _GUICtrlListView_SimpleSort() of whether or not to reverse $vSortSense (previously $vDescending.)
- Added: _FileListToArrayRec() to the UDFs. A recursive file search by Melba23. See the documentation for more details.
- Added: Example for _VersionCompare().
- Added: Graphic SmoothingMode constants (GDIPlusConstants).
- Added: _GDIPlus_CustomLineCapCreate(), _GDIPlus_BitmapCreateFromScan() functions.
- Added: Constants for DriveGetType() and StringSplit(). See related function documentation for more details.
- Added: InetConstants.au3 for use with Inet functions. See related function documentation for more details.
- Added: GDIPlus functions and their respective documentation and example.
- Added: _GDIPlus_ParamSize() to handle X64 compatibility.
- Added #2540: _ArrayDisplay() can copy Header and Row.

- Fixed #2077: hwnd safety check in _GUICtrlRichEdit_Create().
- Fixed #2088: _ArrayDisplay() not handling Default parameters correctly.
- Fixed #2112: "Report Log Window" unresponsive when the script is closed.
- Fixed: _GUICtrlRichEdit_* documentation error return codes.
- Fixed #1970: _FTP_ListToArray() fails to retrieve Dir or File only.
- Fixed #2084: Clipboard not being closed if an error occurred with _ClipBoard_SetDataEx().
- Fixed #2125: Writing a 2-dimensional array would only write the first two columns of the array.
- Fixed #2070: Unexpected crash on certain systems when using _GUICtrlStatusBar_GetText().
- Fixed #2132: Documentation of _WinAPI_GetModuleHandle() and the parameter to return the handle of the calling process. (Use the Null keyword, not 0.)
- Fixed #2162: Documentation link in the IE Management section was broken for _IEFormElementCheckBoxSelect().
- Fixed #2170: _ArrayDisplay() fails handling arrays with no elements.
- Fixed: _PathMake() not appending backslash to the root path.
- Fixed #2223: Incorrect UDF being referenced in _WordErrorHandlerRegister().
- Fixed #2252: _GUICtrlListView_DeleteAllItems() failed to remove items created using _GUICtrlListView_AddItem() on an AutoIt native listview.
- Fixed #1861: _ArrayDisplay() incorrectly displayed an array when using the $sHeader parameter and the array contained the default separator.
- Fixed: Using non-supported characters in the file prefix for _TempFile().
- Fixed #2186: Documentation of _WinNet_AddConnection()* and $sLocalName. (Use the Null keyword or an empty string, not 0.)
- Fixed #2148: Crash when passing a number instead of a string.
- Fixed #2219: _ExcelReadSheetToArray() would cause AutoIt to hang when reading a protected worksheet.
- Fixed #2242: Unable to write the 0th element in _FileWriteFromArray(). Now the Default keyword is supported for the parameters $iBase and $iUBound, therefore use this instead of the value 0 for default parameters. (Please check the documentation.)
- Fixed #2218: AutoIt crash when using _GUICtrlListView_SetGroupInfo() before _GUICtrlListView_SetItemGroupID() had been called.
- Fixed #1996: _GUICtrlListView_SimpleSort() failed to retain the ItemParam of an item.
- Fixed #1759: Strange listview sort.
- Fixed #2298: Failing to detect when EnumDisplayDevices returns 0.
- Fixed: _FileWriteFromArray() failing to pass the $aArray parameter as a constant reference.
- Fixed: $tagREBARBANDINFO not working on XP, due referencing parameters intended for Vista and above.
- Fixed #2305: Reports the wrong width and height of the desktop when using default parameters.
- Fixed #2335: _WinAPI_EnumWindows() and _WinAPI_EnumWindowsPopup() order
- Fixed #2347: _WinAPI_GetMonitorInfo() wrong data.
- Fixed #2320: Incorrect return values for certain IE functions.
- Fixed: _GUICtrlListView_InsertItem() would fail to insert -1 if passed as the $sText parameter.
- Fixed #2460: _StringBetween() $sStart = $sSend.
- Fixed #2459: _StringBetween() doc Description info.
- Fixed #2465: _IEPropertyGet() - out of date links in "ClientInfo Properties".
- Fixed: _GDIPlus_...() functions compatible with X64.
- Fixed #2486: _GUICtrlRichEdit_GetFont() bad multi Font return. Solved also #2485.
- Fixed #2492: _GUIToolbar_... doc example.
- Fixed: _SQLite_...() running in X64 Mode.
- Fixed: _SQLite_Startup() parameter checking and doc.
- Fixed #2550: _GUICtrlComboBox_GetEditText() struct sizing.

AutoItX:
- Removed: Removed DevC files and Visual Studio 6 files.
- Removed: ANSI versions of Send/WinWait functions from the native DLL.
- Removed: DLL Imports: AU3_WinGetPosX, AU3_WinGetPosY, AU3_WinGetPosWidth, AU3_WinGetPosHeight.
- Removed: DLL Imports: AU3_ControlGetPosX, AU3_ControlGetPosY, AU3_ControlGetPosWidth, AU3_ControlGetPosHeight.
- Removed: DLL Imports: AU3_MousePosX, AU3_MouseGetPosY
- Removed: DLL Imports: AU3_WinGetClientSizeWidth, AU3_WinGetClientSizeHeight.
- Removed: DLL Imports: AU3_WinGetCaretPosX, AU3_WinGetCaretPosY.
- Removed: DLL Imports: AU3_CDTray, AU3_BlockInput.
- Removed: DLL Imports: AU3_RunAsSet.
- Removed: COM Methods: CDTray, BlockInput.
- Removed: COM Methods: RunAsSet.
- Removed: All registry functions. The support was limited and the host language will certainly have registry functions.
- Removed: All Ini file functions. As per registry functions.

- Changed: Renamed AutoIt3.h to AutoItX3_DLL.h.

- Added: AutoItX3.Assembly.dll - a .NET Assembly wrapper for the DLL.
- Added: AutoItX3.PowerShell.dll and AutoItX3.psd1 - a set of PowerShell CmdLets.
- Added: Visual Studio 2010 C++ Project files (easy to use in 2010 or later).
- Added: DLL Import: AU3_WinGetPos.
- Added: DLL Import: AU3_ControlGetPos.
- Added: DLL Imports: AU3_MouseGetPos.
- Added: DLL Import: AU3_WinGetClientSize.
- Added: DLL Import: AU3_WinGetCaretPos.
- Added: DLL Imports: AU3_RunAs, AU3_RunAsWait.
- Added: COM Methods: RunAs, RunAsWait.

- Fixed: Crash in AU3_PixelSearch when function fails.
- Fixed: AutoItX3.lib files weren't correctly being copied to the install file.

Au3Check:
- Changed: Message case changed to support SciTE inline errors.
- Changed: An error is now generated for non-supported file encodings (Previous behavior was to silently pass the script).
- Changed: Au3Check version numbers now match AutoIt's.
- Changed: Explicit size of arrays optional for explicit initialization.

- Added: Generating error for hex numbers longer than 16 characters.
- Added: Compound assignment operators for object properties.
- Added: Array access on expression.
- Added: Dot access on expression.

- Fixed #2113: Object's properties in names of keywords treated as keywords.
- Fixed #2141: #IgnoreFunc was generating an incorrect error.

Others:
- Added: Notepad++ autoit.xml file to the Extras\Editors folder. This contains a list of up to date functions.
- Added: Sublime Text AutoIt.tmLanguage file to the Extras\Editors folder. This contains a list of up to date functions.
- Added: 3rd party syntax files in Extras\Editors now include UDF functions.

- Fixed: StringRegExpGUI missing from the help file index menu.

Au3Record:
- Fixed #2083: There is no longer an error about a missing DLL.
- Fixed #2337: Support of non english keyboard.

AutoIt3Help:
- Changed: Manifest resource suggests Windows common controls v6.0.
- Changed: Version number to 1.0.0.5.

- Fixed #2519: Wrong page opening if launch without parameter.

3.3.8.1 (29th January, 2012) (Release)
AutoIt:
- Fixed: Built-in editor would not compile/go when installed on x64 or in a non-standard location.

3.3.8.0 (23rd December, 2011) (Release)
AutoIt:
- Changed: Compiling with VC10. Added workarounds for Win2000/XP RTM to allow execution of AutoIt, Aut2Exe, Au3Info, Au3Check and AutoItHelp.
- Changed: COM Error handler passes error object as first parameter to user defined error function.
- Changed: COM Error handler properties are read-only.
- Changed: Dec() and Hex() work with 64bit integers.
- Changed: Parentheses are required when invoking objects after all method names in order to have correct internal handling.
- Changed: Dec(), Int(), Number() have second optional parameter defining non-default behavior.
- Changed: Hex() detects doubles internally and processes them respecting binary format.
- Changed: New visual style for the documentation.
- Changed: 64bit integers have 16 characters display by default.

- Removed: COM Error object no longer exposes methods Raise() and Clear().
- Removed: Int() and Hex() no longer set @error.

- Added: Struct/EndStruct in DllStructCreate() to solve X86/X64 data alignment.
- Added: COM support for pure "OUT" parameters.
- Added: Additional flags added to ObjName().
- Added: DllCallAddress().
- Added: ObjCreateInterface()
- Added #1947: CHM help files now have a Forward button.
- Added #1813: Better cross referencing for Int() and Mod().
- Added: "struct" as DllCall() and InterfaceDispatch data type.
- Added #2042: @OSVersion returns "Win_8" on Windows 8.

- Fixed #1040: _ScreenCapture_Capture(): GDI object leak with cursor capture.
- Fixed #1599: TraySetItemText() regression for default menu item.
- Fixed #1282: WinMove before GUICtrlSetPos during GUICreation.
- Fixed #1397: Bad HotKeySet() not detected on keyboard as Russian one.
- Fixed #1531: default txtcolor for iput edit list combo updown with black theme.
- Fixed #1617: GUICreate() failure after GUIDelete() can lead to a loop on Autoit exit.
- Fixed #1596: GUICtrlSetPos() default = no change.
- Fixed #1626: TCPRecv()/TCPSend() doc about Unicode transmission.
- Fixed #1633: Second AdlibRegister() function starts at once when first function is too slow.
- Fixed #1653: Doc for WM_KEYLAST Windows 2000 message.
- Fixed #1669: StringRegExpReplace() doc about doubling of "\" in replace string.
- Fixed #1673: WinGetProcess() doc example.
- Fixed #1677: Invalid ContinueLoop with multiple levels.
- Fixed #1684: FileRead() binary read memory allocation error.
- Fixed #1685: BitRotate() shift parameter.
- Fixed #1734: GUICtrlCreateAvi() crash with negative subfield.
- Fixed #1923: Memory consumption while FileOpen/FileClose.
- Fixed #1883: IsHWnd(), Return Value. (Nitpick: Value = Bool).
- Fixed #1860: DriveStatus() Returns Ready with blank value.
- Fixed #1854: StringIsFloat() returns 1 on non float numbers.
- Fixed #1910: Please change $TTN_GETDISPINFO to $TTN_GETDISPINFOW.
- Fixed #1844: SplashTextOn() crops variable when used with opt 32 and @CRLF / @LF.
- Fixed #1932: Uninstaller, windows-register, App Paths. (+beta).
- Fixed #1929: SetMenuColor() does not work on 64bit OS.
- Fixed #1479: X64 ListView WM_NOTIFY Message.
- Fixed: GUICtrlCreateLabel() related text sizing bug when no height was used.
- Fixed #1586: DllStructSetData(char, 1, string-with-NUL-character), junk data(?).
- Fixed #1908: ObjName() returns empty string for HTMLDocument with IE9.
- Fixed #1658: COM / OLE object access causes error code 80020003 - member not found.
- Fixed #1410: Using Pointer type with COM-object throws error.
- Fixed #1565: Arrays as object properties; memory leak.
- Fixed: ObjCreate() memory leak when using a remote computer.
- Fixed #865: winhttp.winhttprequest.5.1 ObjEvent unhandled exception.
- Fixed: Remote COM bug caused by incorrect CoCreateInstanceEx() parameter.
- Fixed: Potential memory leak in COM error event code.
- Fixed #1660: Crash on Mod() with a divisor of 0.
- Fixed: COM methods no longer change the type of AutoIt variables.
- Fixed #2001: Example for _GUICtrlToolbar_SetButtonText() did not work correctly.
- Fixed #1994: Documentation for _ScreenCapture_Capture() and _ScreenCapture_CaptureWnd() incorrectly stated the functions had no return value. Moved information from Remarks up to Return area.
- Fixed #1948: Documentation for _GUICtrlButton_SetImage() had the wrong description.
- Fixed #1519, #1694: Int() and Number() returning wrong.
- Fixed: Various documentation typos and grammatical errors.
- Fixed #1982: Crash in FileGetShortName() and FileGetLongName().
- Fixed #2046: DirGetSize("") was returning the size of the working directory root instead of -1 and setting @error.

AutoItX:
- Fixed #1686: AU3_PixelSearch crashes.

Au3Info:
- Added: Option "Use Spy++ control detection logic" toggle added to Au3Info (this was the mode always used in recent
    releases, but the very old method that used to be used is useful in certain applications (for example, putty.exe).

- Fixed #1746: Option "Use Spy++ control detection logic" toggle added to Au3Info.

UDFs:
- Changed: _SQLite 3.6.22 -> 3.7.2.0.
- Changed: _IEFormElementSetValue() examples #3 removed (login to Hotmail).
- Changed: _IEFormElementSetValue() examples #4 and #5 (now #3 and #4) use the text input instead of the file input. The file input is read-only on IE9 so the Send()/ControlSend() produced no results.

- Added: _DebugSetup() can report to a Notepad Window.
- Added #1371: Allow Default keyword in _TempFile().
- Added #1527: Test example to have doc example working.
- Added #1636: _Security__LookupAccountSid() for Remote Systems.
- Added #1569: _ArraySearch() $iPartial (->$iCompare) extended to match on variables of same type.
- Added #1557: VK_xBUTTON in Constants.au3.
- Added #1890: Better cross-referencing for _WinAPI_GetParent() and _WinAPI_GetAncestor().
- Added #1925: $WS_EX_LAYOUTRTL control style to the documentation.
- Added #2049: Missing windows message codes to WindowsConstants.au3.
- Added: _WinAPI_StringLenA() and _WinAPI_StringLenW() functions.
- Added: _WinAPI_DuplicateHandle() function.
- Added: _Security__CreateProcessWithToken(), _Security__DuplicateTokenEx() and _Security__SetTokenInformation() functions.

- Fixed #1542: _DebugSetup() closing when use with GUI handling events.
- Fixed #1549: _SQLite_Escape() crash for strings > 64K (> 3.3.0.0).
- Fixed #1517: _GUICtrlListView_SimpleSort() with checkbox.
- Fixed #1588: AutoIt3.exe stay active for all processes using the Window report.
- Fixed #1615: _GUICtrlTreeView_SetStateImageIndex() with index = 0.
- Fixed #1620: _DebugOut() or _DebugReportVar() containing '.
- Fixed #1513: Allow _GUI...() to use notification callback (LPSTR_TEXTCALLBACK).
- Fixed #1608: _Crypt_EncryptFile() for file >1Mb.
- Fixed #1644: _INetMail() with Windows Live mail.
- Fixed #1453: _Net_Share_ShareCheck() return always 0.
- Fixed #1664: _GUICtrlTab_GetItem() does not return text.
- Fixed #1671: _WinAPI_WideCharToMultiByte() doc.
- Fixed #1672: _WinAPI_GetObject() reference ANSI version.
- Fixed #1665: _ScreenCapture_CaptureWnd() when running with Aero theme.
- Fixed #1689: _Debug...() cannot be obfuscated.
- Fixed #1712: _FileWriteFromArray() crash on array.
- Fixed #1754: _PathFull() optional parameter doc.
- Fixed #1756: _GDIPlus_Startup() Flaw on error.
- Fixed #1920: Script crashes with error reported in Security.au3 at line 85.
- Fixed #1895: Bugs in _GUIScrollBars_Init().
- Fixed #1891: _ArrayDisplay() (......,i$iTranspose,...) wrong description.
- Fixed #1933: _GetIP() is outdated and could possibly fail.
- Fixed #1859: Bug in _WeekNumberISO().
- Fixed #2009: Incorrect styles listed in _GUICtrlToolbar_Create().
- Fixed #1009: SQLite library needs to support a user-defined callback for diagnostic messages instead of hard-coding ConsoleWrite().
- Fixed #1985: _IECreate() now ensures focus is given to the document when an about URI is loaded (such as about:blank). IE9 gives focus to the URL bar which can cause later issues setting focus to elements.
- Fixed #2004: Functions that accept Control ID/Handle were not correctly documented.
- Fixed #1951: Missing parameter in documentation for _SQLite_SQLiteExe().
- Fixed #1442: File handle can now be passed to _FileWriteLog().
- Fixed #1777: Issues with Security.au3.
- Fixed #2055: replaced DllStructGetPtr with "struct*" throughout UDFs.
- Fixed #2048: Windows constants $WM_RBUTTONDBLCLK and $WM_MBUTTONDBLCLK were named incorrectly.
- Fixed #2034: _GUICtrlMenu_AppendMenu() DllCall type set wrong.
- Fixed #2060: Various documentation errors.

Au3Check:
- Added: #forcedef directive to force var definition as after Assign().
- Added: -w 7 to check ByRef parameter passing.

- Fixed: Const Enum wrong ERROR.
- Fixed: Global declared in func not detected.
- Fixed #1051: no ERROR if keyword not followed by a separator as Local$a.

3.3.6.1 (16th April, 2010) (Release)
AutoIt:
- Fixed #1515: FileOpen still opening in exclusive mode in some situations.

3.3.6.0 (7th March, 2010) (Release)
AutoIt:
- Changed: Send() and ControlSend() code reworked to allow for more Unicode characters to be used.
- Changed: FileWriteLine() performance improved.

- Added #1376: FileOpen() mode parameter is now optional. Default mode is read.
- Added #1054: Added FileGetEncoding().
- Added: ControlCommand() "SendCommandID" - used to send WM_COMMAND Control ID messages. Allows the
  automation of ToolBarWindow32 controls (amongst others). For example, the "Back" button of
  Internet Explorer. Use Au3Info to get the Command ID from the ToolBar tab.

- Fixed #1428: AdlibRegister/Unregister() were incorrectly using case-sensitive function names.
- Fixed #1448: #OnAutoItStartRegister did not work in compiled scripts.
- Fixed #961: RegDelete() was not working properly on 64bit keys when using the 32bit version of AutoIt and HKLM64.
- Fixed: Regression in FileOpen() where it wasn't allowed to open files in read mode if they were already open in write mode.
- Fixed #1449: GUICtrlDelete() not working for GUICtrlCreateDummy() types.
- Fixed #1458: Inet sizes were capped to 32-bits.
- Fixed #1459: Hard crash when too much recursion is used.
- Fixed #1464: Regular expressions with a single character * pattern were stopping after the first null match.
- Fixed #1463: StringToASCIIArray() working incorrectly with UTF8 characters.
- Fixed #1475: TrayItemSetState($Value, $Tray_Checked) incorrectly enables a disabled TrayItem.

Aut2Exe:
- Fixed #1409: Ctrl+C is no longer the shortcut for Convert. It is now Ctrl+G (Go) to avoid clashing with a Ctrl+C copy operation.

Au3Info:
- Changed: Better identification of the control under the mouse.

- Fixed #1444: Controls in applications like RegEdit were left highlighted.
- Fixed #1391: ToolbarWindow32 info only showing the first toolbar.

AutoIt3Help:
- Fixed #1423: "Open Script" button stopped working.

AutoItX:
- Fixed: Missing .lib files readded.

UDFs:
- Fixed #1438: AutoIt error when using _ArrayCombinations().
- Fixed #1454: StringBetween() not working correctly.
- Fixed #1441: _GUICtrlRichEdit_GetText() using wrong buffer length.
- Fixed #1446: _ScreenCapture_Capture() was using height/width of 1 pixel less.
- Fixed #1445: Documentation updated for _MemGlobalFree().
- Fixed #1469: _GDIPlus_BitmapCloneArea() documentation updated.
- Fixed #1466: _GUICtrlEdit_GetLine() returns an unexpected character.
- Fixed #1487: _DateToDayOfWeekISO() returned 0-6 but should be 1-7 where Monday = 1.

3.3.4.0 (15th January, 2010) (Release)
AutoIt:
- Removed: The "RAW" reading mode from FileOpen() has been removed.
- Removed: InetGet("abort"), @InetGetActive and @InetGetBytesRead have been removed.
- Removed: AdlibEnable() and AdlibDisable() have been removed.
- Removed: OnAutoItStart and OnAutoItExit have been removed.

- Added: Ability to read and write UTF-8 files with no BOM including automatic detection during reading.
- Added #682: Removed the 64KB limitation for FileReadLine().
- Added: AutoIt scripts using the line continuation character "_" are no longer limited to a combined line length of 4095 characters.
- Added: FileRead() returns the number of characters/bytes read in @extended.
- Added #1311: MouseGetCursor() returns hand cursor.

- Fixed #384: Under certain circumstances the network credentials flag would prevent the process from starting when launched with RunAs() or RunAsWait().
- Fixed #1370: StringInStr() would crash with a negative occurrence and start position greater than the string length.
- Fixed #1367: Calling GUIDelete() from a GUIRegisterMsg() callback that returns $GUI_RUNDEFMSG would crash AutoIt.
- Fixed #1363: FileSetPos() did not work when the origin was the current position.
- Fixed #1355: Regression in how unsigned numbers are displayed when returned from DllCall().
- Fixed #1396: Crash in DllCallbackGetPtr() with invalid handle.
- Fixed #1352: StringSplit() hard crash with binary data.
- Fixed #1398: Fixed declaration of $tagPARAFORMAT2 from GuiRichEdit.au3.

UDFs:
- Changed: _SQLite 3.6.19 -> 3.6.22

- Fixed #1338: bad _ArrayDisplay() GUI position error.
- Fixed #1362: _WinAPI_WindowFromPoint() did not work with 64-bit AutoIt.
- Fixed #1389: _IEAttach() could fail if called multiple times.
- Fixed #1353: _FileWriteToLine() excessively strict on input text type.
- Fixed: SQLite.au3 various errors in _SQLite_FetchData(), $iCharSize, _SQLite_QuerySingleRow(), _SQLite_GetTable2d(), _SQLite_Display2DResult() by jchd.

AutoIt3Help:
- Fixed #1327: Some keywords would fail to open correctly in rare cases.

3.3.2.0 (18th December, 2009) (Release)
AutoIt:
- Removed: Long deprecate URLDownloadToFile() alias for InetGet().

- Changed: It is now possible to read from files opened for writing.
- Changed: PCRE regular expression engine updated to 8.00.
- Changed #899: ShellExecute[Wait]() no longer uses "open" as the default verb. See remarks section for those functions for more information.
- Changed: Inet functions rewritten with the following additions.
- Changed: InetGet() returns a handle which must be closed.
- Changed: @InetGetBytes, @InetGetActive and InetGet("abort") are deprecated and will be removed in the future.
- Changed #968: AutoUpdateIt updated by ProgAndy to use new Inet features.
- Changed: @YDAY now returns values in the range 001 - 366 instead of 1 - 366. This makes the macro more consistent with other languages (like C/C++) and more consistent with all other date related macros which return strings with leading 0s to pad the length. THIS IS A SCRIPT BREAKING CHANGE.
- Changed #1080: InetGet background downloads now return immediately instead of connecting to the remote host first.
- Changed #1137: RegEnumKey() and RegEnumVal() now correctly return an empty string on failure instead of an error message string.
- Changed: PixelChecksum() can calculate checksums from right-to-left and bottom-to-top.
- Changed: InputBox() no longer requires passing both x and y or w and h.
- Changed #1056: Added new Inet option to by-pass forcing the connection online.

- Added #529: Added the "NAME" property to allow direct search for .NET WinForm control names.
- Added #757: Set defaults for MouseClick()'s x/y parameters.
- Added #764: Return Pid on ProcessWait() and handle on WinWait(), WinWaitActive, WinActivate(), WinActive(), WinMove() when successful.
- Added #414: better handling of OnAutoItStart/OnAutoItExit, now #OnAutoItStartRegister, OnAutoItExitRegister() and OnAutoItExitUnRegister().
- Added: Better handling of AdlibEnable/AdlibDisable, now AdlibRegister(), AdlibUnRegister() and AdlibDisable().
- Added #351: Reverse PixelSearch().
- Added #769: FileFlush() function.
- Added #333: #NoAutoIt3Execute Directive for disabling /AutoIt3ExecuteScript or /AutoIt3ExecuteLine.
- Added #604: $GUI_BKCOLOR_TRANSPARENT can be used with label, group, radio, checkbox controls.
- Added #135: FileSetPos(), FileGetPos() functions for moving the file pointer around.
- Added #582: GUICtrlSetTip() can be used on TabItem controls.
- Added #699: Shutdown() now return @error=GetLastError() when failing.
- Added #461: StringReplace() from right to left if occurrence <0 as for StringInStr().
- Added: GUICtrlSetColor() and GUICtrlSetBkColor() for Combo Controls.
- Added: GUI without title bar (no $WS_CAPTION) can be moved with the mouse.
- Added #815: Temporary variables can be passed ByRef.
- Added #837: FileFindNextFile() set @extended if a directory is returned.
- Added #839: Shutdown() rewritten and now works properly when run as a non-interactive user.
- Added: Shutdown() now takes an optional reason code.
- Added #846: _PathFull() now supports strange but valid syntax where drives do not have a trailing slash.
- Added #869: @MUILang macro to help MUI environment scripts.
- Added #918: Added Quality parameter to GUICtrlSetFont() and GUISetFont().
- Added: ProcessClose() return info on error.
- Added: PixelChecksum() extra parameter to select CRC32 instead of ADLER.
- Added #984: @OSVersion now returns "WIN_XPe" for Windows XP Embedded.
- Added #938: UDPOpen() flag to allow broadcasting with 255.255.255.255.
- Added: new types to DllCall and DllStruct to avoid confusion with MSDN description. That avoid specially X64 errors.
- Added #351: PixelSearch() now supports both right-to-left and bottom-to-top searches.
- Added #508: Static keyword.
- Added #1056: New Inet option to by-pass forcing the connection online.
- Added: DllStructSetData() and DllStructGetData() index parameter now supports the Default keyword.
- Added #1270: GUISetIcon() now finds suitable large and small icons.
- Added: HttpSetUserAgent(), InetClose(), InetGetInfo() and InetRead() functions.
- Added: Multiple background downloads are now supported with InetGet().
- Added #408: New flag for ignoring SSL errors for HTTPS connections.
- Added #884: Better proxy support with mode 0.
- Added #949: The user-agent can be changed.

- Fixed: CtrlSetStyle listview on non selected tab.
- Fixed #763: GUICtrlCreateIcon() create an empty icon on error.
- Fixed: no mouse move when invalid button used in MouseClick() or MouseClickDrag().
- Fixed #779: infinite loop on Exit due to GUICreate() child badly created.
- Fixed #774: GUICtrlSetBkColor() bad label display.
- Fixed #790: Windows region constant $ERROR rename in $ERRORREGION.
- Fixed: StringInStr("aaa", "aa", 2) does not return 0.
- Fixed #802: Searching for controls by Height property.
- Fixed: Checkbox or radio painting on tab.
- Fixed #816: data for GUI date control doc clarification.
- Fixed #819: Crash with EventLog functions.
- Fixed #814: InetGet() through a proxy requiring authentication did not work.
- Fixed #813: bad handling of Windows advanced matching for [HANDLE:...] in X64 version.
- Fixed #863: DirMove() extra dot.
- Fixed #867: UDPRecv() can return from IP/Port.
- Fixed #886: More explicit documentation that operator == is a forced string comparison.
- Fixed #885: Default compared to False returned True instead of False.
- Fixed #888: Send("{}}") Extra null char.
- Fixed: DllCall() returning 64-bit int.
- Fixed: GUICtrlSetImage() after GUI resized.
- Fixed: DirMove() return code wrong under XP.
- Fixed #931: bad GUICtrlSetResizing() for graphic control.
- Fixed #934: MouseGetCursor() hogging mouse double click.
- Fixed #615: License updated to be less restrictive.
- Fixed #919: Remarks added to ConsoleWrite(), ConsoleWriteError() and StdinWrite() regarding how those functions handle binary data and non-ANSI characters.
- Fixed #897: Documented that StringToASCIIArray() does not accept binary input (convert to a string first).
- Fixed #937: Bad event handling of Opt("TrayMenuMode",1)
- Fixed #969: FileFindNextFile() does not set @extended if first found is a dir.
- Fixed #1006: @MSEC returned wrong value for values < 100.
- Fixed #1010: FileRead() UTF8 with BOM files return too many chars.
- Fixed #1013: MDI childs doesn't adjust to parent windows client area.
- Fixed #1005: TraySetClick(64) = hovering.
- Fixed: ClipPut("") not emptying.
- Fixed #1068: Binary to Int.
- Fixed: Bad painting on double GUICtrlSetPos() for label.
- Fixed #1094: Send("{LSHIFT UP}") stay down.
- Fixed #1074: InputBox() positionning on multi monitor.
- Fixed #1105: disable colored Multiline button not properly displayed.
- Fixed #1077: GUICtrlSetBkColor() bad recoloring.
- Fixed #1116: GUICtrlCreateGraphic don't follow ResizeMode.
- Fixed #1102: Better documentation of the StringInStr() count parameter.
- Fixed #1161: Removed all documentation references to ColorMode.
- Fixed #1156: AutoItSetOption()/Opt() now set @error instead of generating a fatal error with invalid input.
- Fixed: Comparing pointers now works correctly.
- Fixed #906: ActiveX controls were not told what their initial size was.
- Fixed: Boolean tests on binary strings now behaves properly.
- Fixed #1234: COM methods that modified boolean arguments could change them to ints.
- Fixed #1258: System menu could display when trying to dismiss a control menu.
- Fixed #1288: Documented how DllStructSetData() and DllStructGetData() work with arrays when omitting the index parameter.
- Fixed #1300: DLLs could unload when calling DllCall() with an invalid function.
- Fixed #1295: Unicode to ANSI conversion was crashing in certain situations.
- Fixed #1304: _GDIPlus_BitmapLockBits() now correctly takes a Width and Height parameter instead of a Right and Bottom.
- Fixed #1294: Fixed AutoIt deadlock when using the following functions with hanged windows: WinGetTitle, WinSetTitle, WinGetText, WinFlash, WinSetOnTop
- Fixed #1332: Mod() forced a conversion to floating point numbers when it didn't need to which can cause unexpected output.
- Fixed #1321: DllStructCreate() did not support _ in data names. Documented valid characters for data name.
- Fixed #1322: Crash when using ControlCommand("GetSelected") on non-Edit controls.
- Fixed #1325: Some date functions could attempt to access an invalid array.
- Fixed #1345: Number() failed to handle numbers with a trailing decimal point.

AutoItX:
- Removed: "ColorMode" option removed from AutoItSetOption().

Au3Info:
- Removed: ColorMode BGR option removed since AutoIt no longer supports the option to use BGR mode.

- Added: Control information now includes the .NET WinForm if available.
- Added #140: ToolsBar button info.

Aut2Exe:
- Fixed #1283: Added new option /x86 to force a 32-bit build and re-added /unicode which also forces a 32-bit build.

Au3Check:
- Fixed #1239: Incorrect library search order.

Others:
- Added #1050: TextPad v5 syntax files installation.

UDFs:
- Removed: _StringAddThousandsSep() has been removed. Too many opinions on how the function should work means nobody is happy with it.
- Removed #1112: __WinAPI_Check() has been removed as have all calls to it.

- Changed: _StringBetween() removed last optional param (not needed after change)(SmOke_N)
- Changed: _StringToHex(), _HexToString() and _StringReverse() have been rewritten and are faster.
- Changed: _SQLite 3.6.7 -> 3.6.19 (SQL statement support UNICODE characters)
- Changed: _INetGetSource() now uses InetRead().

- Added: _GDIPlus_BrushGetSolidColor(), _GDIPlus_BrushSetSolidColor().
- Added: $tagWIN32_FIND_DATA and corresponding attribute constants.
- Added #868: _WinAPI_GetLayeredWindowAttributes(), _WinAPI_SetLayeredWindowAttributes().
- Added: _Date_Time_ ... Str() can return date as yyyy/mm/dd.
- Added #271: FTPEx.au3 for _FTP_...().
- Added #932: mouse event constants in WinDowsConstants.au3.
- Added #952: _ArrayDisplay() extra parameter for column header text.
- Added #957: _Assert() in Debug.au3.
- Added: _WinAPI_GetGuiResources()
- Added #981: _WinAPI_WideCharToMultiByte(), _WinAPI_MultiByteToWideChar() support IN/OUT as "strings"
- Added #1157: Encryption functions in Crypt.au3.
- Added #1128: _WinAPI_PathFindOnPath() in WinAPI.au3.
- Added #1228: _FTP_SetStatusCallback(), _FTP_DecodeInternetStatus() in FTPEx.au3.

- Fixed #755: _FileReadToArray() removing empty end lines.
- Fixed #773: Doc for _GUICtrlStatusBar_SetParts().
- Fixed #786: _SQLite_Exec() does not return @error.
- Fixed #809: _Soundxxx() with first parameter as filename.
- Fixed #887: Related section based on Tweaky work.
- Fixed #951: _ArrayDisplay() speed improvement for nb entries >4000.
- Fixed: _SoundOpen() set @error on MCI Error.
- Fixed #1015: _SQLite_SaveMode() renamed as _SQLite_SafeMode().
- Fixed #1016: _WordDocSaveAs() Doc for error handling.
- Fixed: Sound positioning in case of VBR Format Sound.
- Fixed #1028: _ClipBoard_GetData() fix.
- Fixed #1031: _ClipBoard_SetData() fix.
- Fixed #1040: _ScreenCapture_Capture() leak memory.
- Fixed #1026: _Gdiplus_BitmapCreate*() doc examples.
- Fixed #1092: _Timer_...() datatype for X64.
- Fixed #1059: Incorrect error handling in _FileListToArray().
- Fixed #1101: _NowTime(), _NowDate() Doc.
- Fixed: _WinAPI_GetWindowLong(), _WinAPI_SetWindowLong() support X64.
- Fixed #1111: Bad grammar in comments for _DateAdd().
- Fixed: UDF library now uses #include "" instead of #include <>.
- Fixed #1033: UDF library now has better and more consistent error handling when DllCall() is used.
- Fixed #1215: _ArraySearch() not searching on 2D array.
- Fixed #1168: _ExcelBookOpen() now selects the first visible worksheet to prevent a COM error.
- Fixed #1247: Documented that some _GUICtrlComboBoxEx_* functions don't work with certain ComboBox styles.
- Fixed #1260: Potential buffer overflow in _WinAPI_GetLastErrorMessage().
- Fixed #1276: _TicksToTime() incorrectly rounded seconds up.
- Fixed #1277: Resource clean-up in example script for _GDIPlus_ImageGetGraphicsContext().
- Fixed #1290: Invalid Left coordinate when using _GUICtrlTreeView_DisplayRectEx().
- Fixed #1296: _GUICtrlTreeView_ClickItem() could click outside the control's parent window.
- Fixed #1312: Errors with _GUIImageList_BeginDrag() example.
- Fixed #1320: _GUIImageList_DragMove() documentation contained a parameter that doesn't exist.

3.3.0.0 (24th December, 2008) (Release)
AutoIt:
- Removed: Windows 9x and Windows NT 4.0 Operating System support has been removed.

- Changed #393: Documented that SoundSetWaveVolume() works differently in Windows Vista.
- Changed: PCRE regular expression engine updated to 7.8.
- Changed: @ProcessorArch changed to @OSArch as it was misleading.
- Changed: Size limits removed from RegRead() and RegWrite() (previously 64KB for some registry types).
- Changed: RegRead() and RegWrite() no longer use hex strings for REG_BINARY types - native binary datatypes are enforced.

- Added: New flag for StringSplit() to not return the count in element 0.
- Added #328: StringToASCIIArray(), StringFromASCIIArray() functions.
- Added: New flag to Run()/RunAs() to fix issue #415 (Adds new Constants.au3 constant: $STDIO_INHERIT_PARENT).
- Added: New flag to all Run functions for better CUI compatibility (Adds new Constants.au3 constant: $RUN_CREATE_NEW_CONSOLE).
- Added #481: 11 pixel margin around the text in SplashTextOn() (Meets Vista UI guidelines).
- Added #468: Added @MSEC macro for obtaining the current milliseconds for the current second.
- Added #277: @CPUArch macro to return the capability of the processor.
- Added #454: $FO_UTF8 allowing FileOpen() in Read mode for reading UTF8 files without BOM.
- Added: $FO_UTF16_LE, $FO_UTF16_BE allowing FileOpen() in Read mode for reading UTF16 files without BOM.
- Added #407: Documented that For...In loops are read-only.
- Added #645: IniDelete() now supports the Default keyword for the 3rd parameter.

- Fixed: Send() was incorrectly inserting a leading zero when using the {ASC 0xNNNN} format.
- Fixed #305: GUICtrlSetFont() for Combo causing highlight.
- Fixed #318: GUICtrlSetTip() on TreeViewItem must return 0.
- Fixed #339: GUICtrlDelete() crashes.
- Fixed #345: @OSVersion for Windows 2008.
- Fixed #366: AutoIt crash on bad syntax.
- Fixed #380: @OSVersion for Windows XP 64-bit Edition.
- Fixed #346: FileOpenDialog/FileSaveDialog filter length limit.
- Fixed #387: DllClose() and DllCallbackFree() crashing when an invalid handle used.
- Fixed #449: @SystemDir does not return SysWOW64 under X64 in 32-bit mode.
- Fixed #440: Fatal error when script ends with EOF (0x1A).
- Fixed #464: Example script for GUICtrlCreateAvi() did not work on Vista.
- Fixed #484: ObjGet() would crash when invalid files were specified.
- Fixed #501: ProcessGetStats() failed for processes running as other users (including SYSTEM).
- Fixed #92: DllStruct data truncated with char[]/wchar[].
- Fixed: GUICtrlSetState($graphic, $GUI_HIDE) does not hide.
- Fixed: GUICtrlSetResizing($graphic, ) not moving.
- Fixed: GUICreate(...,Style without caption) does not resize properly.
- Fixed: GUISetStyle(caption change) does not resize properly.
- Fixed: GUICtrlSetState($listviewitem) does not return error.
- Fixed #562: Specifying the TITLE property caused all other properties to be lost (Window title matching).
- Fixed #569 TCPRecv doc example.
- Fixed #589: Some comparison operators did not return a boolean value.
- Fixed #583: Bad formatting of @MSEC in documentation.
- Fixed #574: Using 0 for the SendKeyDelay or SendKeyDownDelay removes the respective delay when using Send().
- Fixed #542: Crash with regular expressions.
- Fixed #531: Clarification of some of the remarks for GUICtrlSetGraphic().
- Fixed #539: StringSplit() with flag 2 and no matching delimiters wasn't returning the full string.
- Fixed #601: Tooltip return 0 when title length >99.
- Fixed #608: listView GUICtrlSetBkColor not redrawn.
- Fixed #628: GUICtrlRead($ctxmenu, $adv) bad return (Saunders)
- Fixed #640: PCRE does not support \L, \l, \N, \U, or \u : doc updated
- Fixed #642: Installer now correctly opens the merged helpfile to the history page instead of the AutoIt-only helpfile.
- Fixed #646: Call() now sets specific @error and @extended values when it fails to find a function.
- Fixed #669: Typo in Dec() example.
- Fixed #659: Documented that UNC paths are not supported when using FileSelectFolder().
- Fixed #671: Crash when using $WS_EX_MDICHILD without specifying a valid parent.
- Fixed: Crash when using BinaryToString() with invalid UTF16 input string. BinaryToString() now has new @error codes to support diagnosing invalid input.
- Fixed #743: AutoIt Crash when Tray functions are use with invalid ID.
- Fixed #748: AutoIt Crash with DllCall(0,...).

Aut2Exe:
- Added #460: More verbose UPX errors.

- Fixed #436: Compression level was ignored when performing compilation from the GUI.

AutoItX:
- Changed: Native DLL: All string methods in the native API are now Unicode. The majority of functions no longer have ANSI versions.

- Added: COM: WinList method.

- Fixed: Native DLL: Return strings were sometimes incorrectly terminated.
- Fixed: PixelChecksum() not returning correct values.

UDFs:
- Removed: _StringSplit(), no longer needed.

- Changed: StringAddThousandsSep params in regards to #442.
- Changed #733: Doc for _GUICtrlButton_SetImageList().
- Changed: _SQLite -> 3.6.7.
- Changed #442: _StringAddThousandsSep() allows for regional settings.
- Changed #290: _GDIPlus_DrawImagePoints().
- Changed: _Sound...() functions.
- Changed #599: _FileListToArray() speed optimization.

- Added: _GDIPlus_StringFormatSetAlign().
- Added: _StringExplode().
- Added: _GDIPlus_ImageGetFlags(), _GDIPlus_ImageGetHorizontalResolution(), _GDIPlus_ImageGetPixelFormat(), _GDIPlus_ImageGetRawFormat()
  _GDIPlus_ImageGetType(), _GDIPlus_ImageGetVerticalResolution().
- Added: _PathGetRelative().
- Added: _ArrayCombinations(), _ArrayPermute(), _ArrayUnique().
- Added: _WinAPI_CreatePen(), _WinAPI_DrawLine(), _WinAPI_LineTo(), _WinAPI_MoveTo(), _WinAPI_GetBkMode(), _WinAPI_SetBkMode().
- Added: _WinAPI_CombineRgn(), _WinAPI_CreateRectRgn(), _WinAPI_CreateRoundRectRgn(), _WinAPI_SetWindowRgn().
- Added: _ExcelHorizontalAlignSet(), _ExcelFontSetProperties(), _ExcelBookAttach().
- Added: _WinAPI_SetEndOfFile(), _WinAPI_SetFilePointer().
- Added: Missing FrameConstants.au3.
- Added: Excel UDFs.
- Added: _Timer_GetIdleTime(), _WinAPI_GetWindowPlacement(), _WinAPI_SetWindowPlacement().
- Added #332: Remarks to _GUICtrlStatusBar_Create().
- Added #275: _GDIPlus_GraphicsFillPolygon().
- Added: _GUICtrlTab_ClickTab().
- Added: _GUICtrlComboBoxEx_GetUnicode(), _GUICtrlComboBoxEx_SetUnicode().

- Fixed #693: _DateTimeFormat() time format
- Fixed #701: _GUICtrlListView_ClickItem() Clicks in the wrong place when $fMove = True.
- Fixed #700: _GUICtrlTreeView_ClickItem() Clicks in the wrong place when $fMove = True.
- Fixed #703: _GUICtrlListBox_ClickItem() Clicks in the wrong place when $fMove = True.
- Fixed #705: _GUICtrlToolbar_ClickButton() Clicks in the wrong place when $fMove = True.
- Fixed #707: _GUICtrlMonthCal_Create() width and height.
- Fixed #674: _GUICtrlTab_ClickTab() Clicks in the wrong place when $fMove = True.
- Fixed #610: _WinAPI_CreateFile() wrong return value upon failure.
- Fixed #619: _GUICtrlListView_SetItemSelected() memory allocation.
- Fixed #617: corrections to six GDI+ ImageGet help file examples.
- Fixed #621: _StringAddThousandsSep don't work with negative number.
- Fixed #635: _GUICtrlTab_ClickTab() docs list unused $fPopupScan parameter.
- Fixed #650: Missing BorderConstants.au3.
- Fixed #656: _FileCountLines() returns 0 if file only contains 1 line.
- Fixed #600: _ArraySearch() fails with 2D array.
- Fixed #603: _FileReadToArray() does not return an array if the file contains only a single line of text.
- Fixed #495: _GUICtrlTreeView_GetTree() returns only 1 parent.
- Fixed #503: _Date_Time_FileTimeToLocalFileTime() example.
- Fixed #510: _GUICtrlListView_ClickItem(): If columns inside listview exceed visible area, clicks outside of the control.
- Fixed #500: _ChooseColor() run on 64bit.
- Fixed #517: WinAPI UDF - bad error checking after DllCall().
- Fixed #533: Array functions dimension check.
- Fixed: various Timer Functions.
- Fixed #506: _FileCountLines() deal with all common line-end-chars.
- Fixed #485: WinAPI missing related links in helpfile.
- Fixed #571: return value doc for _GUICtrlListBox_FindString(), _GUICtrlListBox_GetAnchorIndex() and _GUICtrlListBox_GetText().
- Fixed #586: _GUICtrlListView_SetGroupInfo() destroyed group ID's.
- Fixed #516: _ChooseFont() run on 64bit.
- Fixed #595: _WinAPI_SetWindowsHookEx() help file description of $WH_KEYBOARD_LL.
- Fixed #465: _DateTimeSplit() if seconds omitted defaulted to -1, now defaults to 0.
- Fixed: Excel Examples.
- Fixed #422: _GDIPlus_GraphicsSetSmoothingMode() $iSmooth accepts only 0 - 4, doc updated.
- Fixed #388: _GUICtrlToolbar_SetButtonSize() Example.
- Fixed #400: SQLite.dll.au3 @ProcessorArch replaced with @OSArch.
- Fixed #390: _viPrintf replaced return type.
- Fixed #371: _GDIPlus_Startup() return value.
- Fixed #368: _ArrayToClip() return value.
- Fixed #361, #362: _GUICtrlListView_InsertItem() doc.
- Fixed #285: _ChooseColor() Example.
- Fixed #299: _GUICtrlTab_SetItemText() buffer length for Unicode.
- Fixed #292: _EventLog__Clear() not clearing log when backup parameter is empty.
- Fixed #258: _ClipBoard_GetData().
- Fixed #294: _FileReadToArray() where the file contains no @LF.
- Fixed #303: Clock.au3 in Examples\GUI\Advanced.
- Fixed: _GUICtrlListView_SetItemEx() text buffer.
- Fixed #320: _WinNet_EnumResource() struct pointers.
- Fixed #321: _GUICtrlStatusBar_GetText() buffer length for Unicode.

3.2.12.1 (12th June, 2008) (Release)
AutoIt:
- Fixed #309: RunAs() and RunAsWait() now use @SystemDir as the working directory instead of @WorkingDir when a user-supplied working directory is not specified.
- Fixed #325: contextmenuitem not firing events.
- Fixed #282: Icon transparency refresh when on tab regression.
- Fixed #360: RunAs() under Windows 2000.

3.2.12.0 (16th May, 2008) (Release)
AutoIt:
- Removed: Unnecessary optional parameter from ProcessClose().
- Removed: RunAsSet(). (Replaced with RunAs() and RunAsWait())
- Removed: RunErrorsFatal option ( Opt() ).
- Removed: ColorMode option ( Opt() ).

- Changed: @Unicode renamed in @AutoItUnicode. @Unicode is an alias for now. It will be removed > 3.2.14.0.
- Changed: The behavior of StdoutRead(), StderrRead(), StdinWrite() and ConsoleRead() has been changed.
- Changed: PCRE regular expression engine updated to 7.6.
- Changed: AutoIt internet functions (e.g. InetGet()) now use "AutoIt" as a user-agent. Previously using blank
  which was blocked by many websites.
- Changed: ControlClick() now accepts the same mouse buttons as MouseClick() - left/right/middle/primary/secondary/main/menu.
- Changed: Maximum controls in a GUI window 4093 -> 65532.
- Changed: @OSVersion can now return "WIN_2008" for Windows Server 2008.

- Added: RunAs(), RunAsWait().
- Added: GUISetAccelerators().
- Added: REGEXPCLASS in Advanced Window and control definitions.
- Added: X, Y, W, H in advanced window/control definitions.
- Added: DllCall() new types int_ptr, uint_ptr, long_ptr, ulong_ptr. Special types that change size on x86/x64.
- Added: "REG_QWORD" type for RegWrite().
- Added: HotKeySet() modified to work with the {} notation.
- Added: FileReadLine( ,-1) read last line.
- Added: Std I/O redirection works with RunAs...().
- Added: Std I/O merged flag for using the same stream for stdout/stderr.
- Added: Std I/O supports binary data.
- Added: ConsoleWrite()/ConsoleWriteError() now return the amount of data written.
- Added: Remarks in Run() about how to close streams/release resources associated with STDIO.
- Added: StdioClose() function to force STDIO data closed for a process.
- Added: ProcessClose() now closes processes started by other users.
- Added: ProcessWaitClose() returns exitcode in @extended
- Added: Pixel...() can specified a window handle as last parameter.
- Added: "start" and "count" parameters added to StringInStr().
- Added: GUICtrlSetDefColor(), GUICtrlSetDefBkColor().
- Added: Added parent window parameter to MsgBox(), FileSelectFolder(), FileOpenDialog(), FileSaveDialog().

- Fixed: DllCall() setting wrong @error values.
- Fixed: BlockInput() returns errors.
- Fixed: WinWaitActive() not matching (more frequent with Windows Vista).
- Fixed: GUICtrlSetState($GUI_SHOW) on hidden radio on an active tab.
- Fixed: SciTE Lite not installed in the AutoIt Choosen release dir.
- Fixed: WinMove() with Speed = 0 crash the script.
- Fixed: Mysterious return value of 1 when no explicit value was set.
- Fixed: ControlCommand(), "GetLineCount"
- Fixed: _FileListToArray() when using root drive dir as c:\ under Win9x.
- Fixed: TraySetState(4) flashing tray icon for Windows Vista.
- Fixed: ProcessExists() wrong return.
- Fixed: StringRegExp() crashing under Win95.
- Fixed: Handle leak when using Run() with I/O redirection.
- Fixed: Disabled input control background on Tab.
- Fixed: GUICtrlDelete() of a tab if two GUI windows are used.
- Fixed: AutoIt crash in Random() when range exceeds 2^31.
- Fixed: #include parsing error detection.
- Fixed: Array entry passed ByRef to a UDF.
- Fixed: FileSetTime() erronously rounds UP on non NTFS partition.
- Fixed: STDIO redirection sometimes failed on Windows 9x.
- Fixed: IniReadSectionNames() returning incorrect number of sections under Win9x.
- Fixed: AutoIt tray icon removal on script exiting.
- Fixed: AutoIt crash when removing ObjEvent() object.
- Fixed: ObjEvent() handler can destroy return of AutoIt Function : as WinWait("title") can return 0.
- Fixed: DirMove() on different volume.
- Fixed: Crash with RegRead() and REG_MULTI_SZ on x64.
- Fixed: GuiCtrlListView() behind BG Picture. Doc updated.
- Fixed: Various Edit control focus and DefPushButton issues.
- Fixed: ControlTreeView() returning @error=1 on success.
- Fixed: COM objects could lose numeric precision.
- Fixed: StringReplace() with start float number.
- Fixed: ControlCommand() "SelectString" wrong selection.
- Fixed: StringSplit() flag=1 delimiters not case sensitive.
- Fixed: In advanced Window descriptions only semi-colon must be escaped.
- Fixed: ObjGet() memory leak.
- Fixed: Modified AutoUpdateIt.au3 to work under x64.
- Fixed: Resizing GUI before GUISetState().
- Fixed: Radio events fired when GUI reactivated.
- Fixed: GUICtrlDelete() on contextMenuItem.
- Fixed: An attempt to FileDelete() a file that was just executed with RunWait() would sometimes fail.
- Fixed: GUI performance problem when creating a large number of windows.
- Fixed: GUIGetCursorInfo() with swapped mouse buttons.
- Fixed: Random(Min,Max,1). Previously this would never actually return Max,
  so if Max was artificially incremented by one the script will now need to be changed.

AutoItX:
- Added: ControlTreeView().

- Fixed: ControlListView() for native DLL version.

Aut2Exe:
- Added: Option to compile scripts as console applications.

Au3Info:
- Changed: Controls are always highlighted when using the finder tool.
- Changed: Controls are not highlighted by default.
- Changed: Control description gives the advanced version of class and instance.

SciTE-lite:
- Changed: the source to version 1.76

- Added Save Dialog extension.

UDFs:
- See the script breaking changes page.

3.2.10.0 (25th November, 2007) (Release)
AutoIt:
- Changed: DllCall() new method of passing types by reference using *.
- Changed: DllCall(): short_ptr, long_ptr, int_ptr types deprecated. Use short*, long* and int* respectively.
- Changed: Limits on Execute() removed.
- Changed: PCRE regular expression engine updated to 7.4.

- Added: 64bit (x64) versions of AutoIt, Aut2Exe, Au3Info and AutoItX.
- Added: DllCallbackRegister(), DllCallbackGetPtr() and DllCallbackFree().
- Added: DllCall() now accept doubles, int64, uint64, wparam and lparam types.
- Added: SendKeepActive().
- Added: ControlTreeView().
- Added: ProcessGetStats().
- Added: VarGetType().
- Added: @AutoItX64 macro.
- Added: Au3Info : Handle info for windows and controls.
- Added: DllStructCreate() added "align" keyword to set structure alignment.

- Fixed: Control...() functions using CLASS and TEXT together sometimes incorrect.
- Fixed: Control...() functions using CLASSNN sometimes incorrect.
- Fixed: Windows Vista taskbar previews causing problems with windows matching.
- Fixed: $var = $var was not giving an error when $var didn't already exist.
- Fixed: GUICtrlSetImage() sizing regression from 3.2.4.9.
- Fixed: GUICtrlCreateListView() with no column.
- Fixed: _GUICtrlListViewInsertColumn() after _GUICtrlListViewDeleteColumn() of the first column of a ListView control.
- Fixed: Extra notification on colored button.
- Fixed: IniReadSectionNames() for [] sections.
- Fixed: Opt("WinTitleMatchMode", Default) fatal error.
- Fixed: GUICtrlSetStyle() with $ES_READONLY bad $WS_TABSTOP.
- Fixed: AutoIt Crash on exit if Win...() used with a Title being a COM object.
- Fixed: ProcessExists() on service process under Win2K.
- Fixed: DefPushButton behavior.
- Fixed: ControlCommand(SelectString) order selection.
- Fixed: Array cannot have 2^24 entries.
- Fixed: GuiCreateMenu() on a windows without title and without client area.
- Fixed: WinWaitActive() sometimes failing after a WinActivate().
- Fixed: _SQLite_SQLiteExe() referencing by default "Extras\SQLite\SQlite3.exe".
- Fixed: _Sound...() when refering to a file with "!" characters.
- Fixed: Looping GUIRegisterMsg() doesn't unregister.
- Fixed: Focus on ES_READONLY edit control.

3.2.8.1 (10th September, 2007) (Release)
AutoIt:
- Fixed: Possible crash with StringRegExp().

3.2.8.0 (8th September, 2007) (Release)
AutoIt:
- Changed: General speed improvements (currently up to 24% in some cases compared to 3.2.6.0).
- Changed: PCRE regular expression engine updated to 7.3.
- Changed: Recursion-based code limits relaxed.

- Added: wchar type added to DllStructCreate().
- Added: WinMove() speed parameter.

- Fixed: Crash on AutoIt exit if TrayCreateItem() is not deleted.
- Fixed: AutoIt crash on bad parameter when calling TrayCreateMenu()
- Fixed: Character positions used in StringRegExp() not correct for characters > 127 (accents, non-Western)
- Fixed: ProcessExist() under Windows 9x.
- Fixed: GUISetState(@SW_DISABLE) not disabling keyboard input.
- Fixed: Sometimes AutoIt crashes on DllStructGetData() with char[] types.
- Fixed: Au3Info restoring last settings at startup.
- Fixed: Better handling of notifications when using colored buttons.
- Fixed: ControlGetText() crash on SciTE windows.
- Fixed: $LVSCW_AUTOSIZE column truncates display string.
- Fixed: Incorrect listview creation with GUICtrlCreateListView().
- Fixed: Memory leak when AutoIt needed to get long file name.
- Fixed: ListviewItem not created after other child Window creation/deletion.
- Fixed: ControlGetFocus() returning bad ClassNN values.
- Fixed: Detection of invalid ContinueLoop statement.

3.2.6.0 (25th August, 2007) (Release)

WARNING:
    Previous scripts using GUICtrlSetImage(), GUISetIcon(), TraySetIcon() and TraySetPauseIcon()
  may display a wrong Icon. To get the same icon "if nId > 0 Then newId = - nId - 1".

AutoIt:
- Changed: iconID in all GUI functions is now the same as GUICtrlSetImage().
- Changed: AutoIt .a3x and compiled script format. Exe2Aut will only decompile 3.2.5.1
  and earlier files. No ExeAut utility is supplied for ongoing versions.
- Changed: General performance improvements (currently around 30-40% over 3.2.4.9)
- Changed: Limited Unicode support added in regular expressions.
- Changed: ControlMove() just resizing as WinMove() if X=Y=Default.
- Changed: PCRE engine updated from 7.0 to 7.1.
- Changed: Suppress delay when speed=0 in MouseMove().

- Added: GUIGetStyle().
- Added: byte and ubyte type to DllCall().
- Added: ClassnameNN in control and summary info in Au3Info.
- Added: Float type to DllCall().
- Added: AU3Check v1.54.8 support for both "#AutoIt3Wrapper_plugin_funcs" and "#Compiler_plugin_funcs".
- Added: Extra parameter in ProcessClose() to close Stream handles.

- Fixed: AutoIt crash on WinWait("","text") when a SciTE is open.
- Fixed: Some crashes on Chinese systems during Unicode/ANSI conversions.
- Fixed: Aut2Exe crashing on Chinese systems when running in ANSI.
- Fixed: Wrong Notification on {ENTER} after clicking on a listviewItem.
- Fixed: Wrong resetting of image on listviewitems if image set on the listview.
- Fixed: Resizing of listview control.
- Fixed: @error not set on bad WinGetPos() return.
- Fixed: LVM_EDITLABEL hogging cpu.
- Fixed: AutoIt (non UNICODE version) crash with some COM objects.
- Fixed: GUISetState() on GUI with W=0 or H=0.
- Fixed: GUI control Tip not reappearing after a click or timeout.
- Fixed: GUI controls not at the right position if a Control menu is in use.
- Fixed: EnvUpdate() in UNICODE AutoIt version not working since 3.2.3.3.
- Fixed: FileRead(..., count) returning count-1 chars.
- Fixed: Unicode filenames in FileInstall().
- Fixed: LVS_EX_HEADERDRAGDROP extendedstyle.
- Fixed: UpDown control shows through tabbed pages.
- Fixed: GUICtrlSetState() on UPDOWN control without changing the state.
- Fixed: FileInstall() in compiled scripts causing GUI problems.
- Fixed: ControlGetFocus() on control not created with AutoIt GUI.
- Fixed: @AutoItPID and ProcessList() coherency under Win9x.
- Fixed: GUICtrlSetResizing() not returning error on non resizable control.
- Fixed: Regression for ControlSend() SHIFTDOWN/UP since 3.2.3.13.
- Fixed: Drag and drop on a listview control after clicking on its header.
- Fixed: Support "resource only" dlls for GUISetImage().
- Fixed: Default minimum for GUICtrlSetLimit() set to 0.
- Fixed: Z order after GUICtrlSetStyle() on edit or input control.
- Fixed: FileReadLine() getting bad cached data when reading specific line numbers with file handles.
- Fixed: Slight lag in GUIGetMsg() under certain circumstances.
- Fixed: StringReplace() and occurances parameter.
- Fixed: GUICtrlSetFont() on Tab control.
- Fixed: Leading blanks before #include cannot be compiled.
- Fixed: Notification on ENTER on Colored button.
- Fixed: RegWrite() setting bad registry entry in certain circumstances.
- Fixed: AutoIt hogging CPU when text MsgBox too big.
- Fixed: ControlSend() sometime to wrong control when using empty controlID.
- Fixed: ProcessExists() under Win2K with processname >15 chars.
- Fixed: Int() with string comparison wrong match.
- Fixed: InetGetSize() in unicode version returns 0.
- Fixed: GUICtrlCreateListView() with more than 254 columns.
- Fixed: AutoIt Crash on recursive RegExp.
- Fixed: BitRotate() with left bit set.
- Fixed: FileMove() returning 1 without any move.
- Fixed: FileRead() returning Chr(0) in ANSI mode.
- Fixed: Au3Info control coords relative to client.
- Fixed: StringInStr() not returning 0 when searching backward and search length greater than string.

3.2.4.9 (25th May, 2007) (Release)
AutoIt:
- Added: StringCompare()

- Fixed: Basic string comparisons were not working with locale as in previous versions.

3.2.4.8 (23rd May, 2007) (Release)
AutoIt:
- Fixed: Errors with non-western codepages and ANSI format scripts.

3.2.4.7 (22nd May, 2007) (Release)
AutoIt:
- Added: Aut2Exe options for forcing ANSI mode compilation (/ansi and /unicode)
- Added: StringToBinary()
- Added: Additional unicode related options for BinaryToString()

3.2.4.6 (20th May, 2007) (Release)
AutoIt:
- Fixed: StringReplace() and occurances parameter.

3.2.4.5 (20th May, 2007) (Release)
AutoIt:
- Changed: StringReplace() speeded up - a lot.
- Changed: Au3Info is now resizable.

- Added: BinaryToString() for binary buffer to ANSI string quick conversions.
- Added: @Unicode to show if AutoIt is being run in Unicode or ANSI mode.

- Fixed: Chr(0) now properly works with Binary()

3.2.4.4 (17th May, 2007) (Release)
AutoIt:
- Fixed: Chr(0) now acting more sensible (now acts in a similar way to VBScript).

3.2.4.3 (17th May, 2007) (Release)
AutoIt:
- Fixed: FileRead() not working properly with unicode files.

3.2.4.2 (15th May, 2007) (Release)
AutoIt:
- Changed: Au3Info graphical tweaks and Summary tab.

- Fixed: FileReadLine() getting bad cached data when reading specific line numbers with file handles.
- Fixed: Slight lag in GUIGetMsg() under certain circumstances.

3.2.4.1 (13th May, 2007) (Release)
AutoIt:
- Added: ChrW() and AscW() for unicode operations.

- Fixed: Chr() and Asc() for character codes 128-255 in unicode mode.
- Fixed: Unicode BOM was not being written in file append modes if the file was empty.
- Fixed: Error in Include\GuiCombo.au3 and Include\IE.au3.

3.2.4.0 (10th May, 2007) (Release)

WARNING:
    AutoIt is now compiled for Unicode! AutoIt3.exe is Unicode - AutoIt3A.exe is ANSI.
    Au3Info tool rewritten.
    Binary data functions completely rewritten - scripts using these functions will need to be changed.

AutoIt:
- Changed: Removed restrictions on the maximum number of #include directives.
- Changed: Removed restrictions on the maximum number of DllOpen() handles.
- Changed: Removed restrictions on the maximum number of open files.
- Changed: Removed restrictions on the maximum number of hotkeys.
- Changed: Performance improvements in StringStripWS().
- Changed: Binary data in variants are now treated as a special type, separate from normal strings.
- Changed: BinaryString() renamed to Binary()
- Changed: IsBinaryString() renamed to IsBinary()
- Changed: ControlClick() can now click a control at a certain position.
- Changed: ControlClick() can now properly simulate double-clicks.
- Changed: ControlClick() no longer forces the activation of the parent window (up to the user now).
- Changed: ControlClick() related coordinates added to Au3Info.
- Changed: Improved the searches that can be done for windows/controls/instances.
- Changed: From DEFAULT_QUALITY to PROOF_QUALITY for Change/Set Font functions.
- Changed: x^y compatible with C99 standard.

- Added: New modes for FileOpen() to force Unicode and binary operations.
- Added: BinaryLen(), BinaryMid()
- Added: Colored GUI buttons.
- Added: DllStruct...() can reference elements by name rather than index.

- Fixed: Possible crash when using StringStripWS(), flag 4 and empty strings.
- Fixed: GUICtrlSetLimit() for UpDown controls wher min = max.
- Fixed: GUICtrlSetTip() not always working correctly.
- Fixed: Slow GUI tab redrawing under Windows Vista fixed.
- Fixed: HotKeySet() bad notification.
- Fixed: FileGetAttrib() on pagefile.sys.
- Fixed: Invalid default parameter in GUICtrlSetData() not detected.
- Fixed: Assign does return error on array element.
- Fixed: FileOpen("test.txt", 2+8) returning error.
- Fixed: Error detection in Enum statement.
- Fixed: Opt("WinTitleMatchMode").
- Fixed: Stack corruption resulting from improper use of DllCall() now gracefully aborts the script instead of hard crashing.
- Fixed: Crash when reading empty REG_MULTI_SZ.
- Fixed: Round() not returning an integer.
- Fixed: ControlSend() to empty "" ctrl fixed for inactive window. Also shift state behavior.
- Fixed: O^(-1).
- Fixed: Non detection of illegal statement.
- Fixed: HotKeySet("^{PAUSE]",...) notification.
- Fixed: {CTRLBREAK} ->{BREAK} as ctrl is user responsability.
- Fixed: $var = Default passed as parameter to COM object.
- Fixed: Edit control would always have focus the first time the GUI was displayed even if it shouldn't. This behavior also ignored $GUI_FOCUS.
- Fixed: range value for seed Number in SRandom().
- Fixed: FileRead() crash if no count in raw mode.
- Fixed: Opt("WinTitleMatchMode", <0) really matching case insensitive.
- Fixed: FileSetAttrib/FileSetTime wrong setting.
- Fixed: Execute/Call recursive overflow display error message.
- Fixed: Aut2exe warning message if icon not found.
- Fixed: WinGetTitle() returns 1 on error.
- Fixed: Memory leak on keyword variable deallocation.

3.2.2.0 (23rd December, 2006) (Release)
AutoIt:
- Removed: old WinShow, TimerStart and TimerStop functions.

- Changed: Performance improvements (up to 100% on some scripts!).
- Changed: @error set to GetLastError WinAPI for Run().
- Changed: Small tweak to Floor() to ensure it is not as susceptible to floating point precision errors.
- Changed: Small tweak to Ceiling() to ensure it is not as susceptible to floating point precision errors.
- Changed: PixelChecksum() is now over 30x faster.
- Changed: FileGetVersion() extra parameter to retrieve string file info.

- Added: StringRegExp() and StringRegExpReplace() regular expression support (Perl compatible)
- Added: Regular expression support for Window title matching.
- Added: ShellExecute() and ShellExecuteWait() functions.
- Added: #RequireAdmin for UAC/Windows Vista.
- Added: Windows Vista help file entry.
- Added: GUICtrlSetState() $GUI_DROPNOTACCEPTED.
- Added: $GUI_FOCUS, $GUINOFOCUS for listviewitem control.
- Added: IsDllStruct().
- Added: SRandom() to set seed for random number generation.
- Added: WinTitleMatchMode for case insensitive matching.
- Added: iconID can be reference by ordinal value if negative 1-based index is use.
- Added: CompiledScript string file info for compiled script.
- Added: Support >32x32 icon from .exe/.dll in GUICtrlCreateIcon() or GUICtrlSetImage().
- Added: Expanded GUICtrlSetTip() to allow creation of tooltips with titles, icons and using the balloon tip style.
- Added: Tooltip() supports Default keyword.
- Added: Remark added to _PathSplit() mentioning that it does not accept command line strings, only paths.
- Added: 2 UDF's to GUIStatusBar.au3.
- Added: GUICtrlCreateIcon() and GUICtrlSetImage() can select in multiple icon file by name.
- Added: @KBLayout to retrieve the current keyboard configuration.
- Added: ToolTip() option to ensure the tooltip is always displaying on a monitor.
- Added: IniWriteSection() function.
- Added: @extended error code on DriveMapAdd error.
- Added: Listview Alternate coloring with $GUI_BKCOLOR_LV_ALTERNATE.

- Fixed: MsgBox() timeout on Windows Vista.
- Fixed: GUICtrlRead() on listview control when sorted.
- Fixed: @OSVersion on Windows 9x.
- Fixed: GUIGetCursorInfo() with Handle not retrieving mouse click info.
- Fixed: DllCall() crashes when using uint, ushort.
- Fixed: List control height when font size changes.
- Fixed: GUICtrlSetImage() not testing icon on error.
- Fixed: @ScriptDir equal @WorkingDir for rootdir (x:\).
- Fixed: GUIGetCursorInfo() (winhandle) when child not active.
- Fixed: _StringAddComma().
- Fixed: drag & drop $GUI_EVENT_DROPPED notification on edit control.
- Fixed: Coherency of type parameter for DllCall() and DLLSructCreate()
- Fixed: Default keyword didn't always work correctly with COM objects.
- Fixed: COM property write fails when using arguments.
- Fixed: Send()/ControlSend() for US international keyboard.
- Fixed: Send()/ControlSend() char>=Chr(128) for english keyboards.
- Fixed: COM property write fails when using arguments.
- Fixed: MsgBox() with task modal flag left GUI's disabled on timeout.
- Fixed: Error reporting by messagebox even with /ErrorStdOut.
- Fixed: GUICtrlSetImage default icon value for Icon Ctrl.
- Fixed: GUIRegisterMsg() destroyed @error.
- Fixed: $LVS_SORTASCENDING with GUICtrlSetImage() icon gave bad display.
- Fixed: Some Object Collections could not be parsed in one AutoIt statement.
- Fixed: Bad screen updating of already unchecked radiobuttons.
- Fixed: Tray icon tooltip not displaying the scriptname when compiled.
- Fixed: UDP...() return code on error.
- Fixed: UDPRecv() crashed on bad parameter.
- Fixed: COM was corrupting floating point values.
- Fixed: GUICtrlSetState() doc remarks about menu control.
- Fixed: Refresh after a GUICtrlSetBkColor().
- Fixed: Crash on line beginning with ~ : "Unable to parse line".
- Fixed: IniReadSectionNames() returned bogus data in Windows 98 when the INI file was empty or did not exist.
- Fixed: @Compiled when the script is compiled.
- Fixed: Send() to italian keyboard.
- Fixed: MouseMove() in secondary screen.
- Fixed: StringInStr() not converting to string search parameter.
- Fixed: Int() of a binarystring.
- Fixed: ControlSend sending() special characters.
- Fixed: Crash in Au3exe with badly formed input file in FileInstall().
- Fixed: Wrong execution of a compiled script containing FileInstall() inside #CS-#CE.
- Fixed: FileInstall() referencing a file without any path will reference it from the ScriptDir to be coherent with the compiled script.
- Fixed: Aut2exe crashed using cmdline with shortnames.
- Fixed: Tooltip state (such as icon or title) was showing up on subsequent tooltips that didn't want those items. This affected both ToolTip() and GUICtrlSetTip().
- Fixed: GUIRegisterMsg() destroy @error.
- Fixed: $LVS_SORTASCENDING with GUICtrlSetImage() icon bad display.
- Fixed: Wrong default arguments for _ArrayToString().
- Fixed: Bad "#" instruction inhibit whole script.
- Fixed: Installer SciTE bad link creation.
- Fixed: Uninstaller include file removal

3.2.0.1 (13th August, 2006) (Release)
Au3Info:
- Fixed: Buffer overrun in control code.

Exe2Aut:
- Fixed: Exe2Aut.exe was missing its digital signature.

3.2.0 (12th August, 2006) (Release)
AutoIt:
- Changed: #include search algorithm modified.
- Changed: The /c command line option has been replaced by /AutoIt3ExecuteLine.
- Changed: RegEnumKey() and RegEnumVal() return more precise @error to help diagnostic.
- Changed: Return @error, @extended have to be explicit to be return by an UDF.
- Changed: FileFindFirstFile() no longer returns "." or "..".
- Changed: Set _ to be a continuation character ONLY after whitespace.
- Changed: FileClose() with an invalid handle no longer triggers an AutoIt runtime error.
- Changed: Fatal error message is now displayed if DllCall() cannot be executed.
- Changed: The default setting on Au3Info was changed so that it doesn't highlight controls.
- Changed: RegEnumKey and RegEnumVal return more precise @error values to help diagnostics.
- Changed: "OnAutoItExit" function is now called on system shutdown or user logoff.
- Changed: Opt() with just the "option" will now return the current value for that option.
- Changed: DllCall @error is set when function not found.
- Changed: SplashTextOn() opt=32 to center vertically.
- Changed: GUICtrlCreateList() now forces the style $LBS_NOTIFY.
- Changed: GUICtrlCreateIcon() default size is 32x32.

- Added: COM object support.
- Added: Aut2Exe can now created .a3x encoded files (similar to .zip for .au3).
- Added: Support for custom tray icons.
- Added: "default" keyword.
- Added: IsKeyword() so "default" keyword can be used as parameter in a user function call.
- Added: Boolean support and keywords of 'false' and 'true'.
- Added: IsBool().
- Added: +=, -=, *=, /= operators.
- Added: DllCall() cdecl and stdcall support.
- Added: DLLStruct...() functions.
- Added: Limited TCP and UDP functions.
- Added: Added support for reading and writing stdio.
- Added: ConsoleRead(), ConsoleWriteError().
- Added: Ability to initialize arrays in DIM and CONST keywords.
- Added: Switch, EndSwitch structure.
- Added: HWnd() and IsHWnd() functions.
- Added: BinaryString(), IsBinaryString() functions.
- Added: FileCreateNTFSLink().
- Added: /AutoIt3ExecuteScript command line option.
- Added: Call() now supports parameters.
- Added: Execute().
- Added: @HotKeyPressed macro.
- Added: Unary NOT operations on strings are now allowed. A NOT operation on a non-empty string will result in FALSE.
- Added: Beep() and WinFlash() functions.
- Added: Floor() and Ceiling() functions.
- Added: SetError() can optionally set @extended.
- Added: RegRead(), RegEnumVal() return the type of the value in @extended.
- Added: FileSaveDialog(), FileOpenDialog() supports multiple filter groups.
- Added: @ScriptLineNumber, @ProcessorArch, @AutoItPID.
- Added: BitRotate().
- Added: FileOpen(), FileCopy(), FileMove() additional flags to create non existent subfolders.
- Added: FileRead(), FileWrite() work with binary files.
- Added: GUICtrlSetData() text for treeview.
- Added: $WS_EX_MDICHILD support for GUICreate().
- Added: GUICtrlCreateGraphic(), GUICtrlSetGraphic().
- Added: Opt('GUIEventOptions',1) to suppress window action when clicking on Minimize,restore or Maximize buttons.
- Added: Right-click support for List/Treeview GUI control.
- Added: GUICtrlRead() return controlID if Opt("GUIEventCompatibilityMode',2).
- Added: GUICtrlCreateMonthCal().
- Added: Opt("GUIDataSeparatorChar",...).
- Added: GUICtrlCreateObj().
- Added: GUICtrlSetColor(), GUICtrlSetBkColor(), GUICtrlSetImage() for ListviewItem controls.
- Added: GUISwitch() tabitemID optional parameter to allow dynamic control creation on a tabitem.
- Added: GuiCtrlListView() support Icon view.
- Added: $GUI_WS_EX_PARENTDRAG Allow the label or pic control to be used as the title bar to drag the whole the parent window.
- Added: GUICtrlGetHandle().
- Added: $GUI_EVENT_DROPPED @GUI_DragId, @GUI_DropId.
- Added: GUISetCursor(16), GUICtrlSetCursor(16) hide the cursor.
- Added: Allow Dragfile to any control. @GUI_DragFile contain the filename to be used in the $GUI_EVENT_DROPPED.
- Added: GUIRegisterMsg() to work with GUI WM_Message-routines at runtime.
- Added: GUICtrlRegisterListViewSort() to create a real sorting routine for GUI ListView's.
- Added: Icons for GUI tab items.

- Fixed: ContinueCase to keywords allowed after IF.
- Fixed: Mouse...() invalid button definition.
- Fixed: IniDelete() could create an empty file if the file did not exist.
- Fixed: ToolTip Centering go around.
- Fixed: Menu/ContextMenu enable/disable.
- Fixed: Hotkey for FileCreateShortcut().
- Fixed: MemGetStats') >2Gb.
- Fixed: StringInStr() return 0 when searching for "".
- Fixed: RegRead() under Windows 2000.
- Fixed: Bad refresh on double GUICtrlSetPos.
- Fixed: ControlSend (...,"{CTRLDOWN}b{CTRLUP}).
- Fixed: ContextMenu position.
- Fixed: Made sure that declaring a UDF parameter in a Local or Global statement will raise an error.
- Fixed: File...Dialog browse through links.
- Fixed: ControlCommand() "GetCurrentSelection".
- Fixed: Mouse...() returns.
- Fixed: MouseClick, MouseUp bad behavior.
- Fixed: StringReplace("abc","","") returns 1 instead of "".
- Fixed: WinSetTrans() returns error.
- Fixed: Assign not creating/assigning macro variable.
- Fixed: Assign() respect Opt("MustDeclareVars",1).
- Fixed: @NumParams destroyed after UDF call.
- Fixed: MouseClickDelay option.
- Fixed: ReDim of array ByRef parameter.
- Fixed: InputBox left,top values when not defined.
- Fixed: FileFindNextFile return error.
- Fixed: HWND string concatanation.
- Fixed: Exit inside UDF.
- Fixed: SendKeyDelay, SendKeyDownDelay when no shift required.
- Fixed: FileReadLine with line=0.
- Fixed: Listview sorting with using styles: $LVS_SORTASCENDING and $LVS_SORTDESCENDING.
- Fixed: StringLen(integer) returning 0.
- Fixed: Reg...() functions on IA64/X64.
- Fixed: FileFindFirstFile() leak handles.
- Fixed: @IpAddress when not network installed.
- Fixed: FileCopy, FileInstall, DirCopy, FileMove replacing the same file.
- Fixed: FileClose,FileFindNextFile, FileRead, FileReadLine, FileWrite, FileWriteLine, PluginClose, DllClose return 0 on bad handle.
- Fixed: FileCopy() when creating subdir.
- Fixed: String...() on nonstring parameters.
- Fixed: Float to Integer precision.
- Fixed: Bad FatalError after Exit in UDF. Only the first FatalError will be displayed if any before Exit.
- Fixed: Integer to string conversion.
- Fixed: StringMid($a,3).
- Fixed: StringSplit($a,"").
- Fixed: Refreshing of dispayed tabitem after a tabitem delete.
- Fixed: StringSplit($a," - ",1) string delimiter.
- Fixed: Return code from delayed function as WinWait destroyed by Adlib execution.
- Fixed: FileInstall() on same dir.
- Fixed: Func definition with ByRef and default value.
- Fixed: FileRead() returning @error=-1 on empty file.
- Fixed: InetGetSize(), InetGet() @error return.
- Fixed: Run("a.tmp") a.tmp being a compiled script.
- Fixed: StringSplit("a : b + "," : ").
- Fixed: #include-once in main script.
- Fixed: PixelSearch() performance.
- Fixed: HotKeySet("",...) return 0.
- Fixed: ExpandVarStrings $$, ExpandEnvStrings %%.
- Fixed: FileInstall() in a compiled script whose name is not .exe or .a3x.
- Fixed: RegRead() return right number of fields on REG_MULTI_SZ type.
- Fixed: FileRead($handle).
- Fixed: ElseIf ... Then statement not detected.
- Fixed: Illegal #include with no error message.
- Fixed: SplashTextOn() Memory Leak.
- Fixed: #include recursion depth enforced.
- Fixed: @OSVersion for WIN_XP running under X64 edition.
- Fixed: Comparison case insensitive accentuated upper case.
- Fixed: DriveMapDel() / DriveMapAdd() interaction.
- Fixed: RegRead() MULTI_REG_SZ malformed key.
- Fixed: For Next with boundary,stepping being a string (no conversion to integer).
- Fixed: InetGet() could block the foreground execution even when run in background mode.
- Fixed: WinGetProcess() and ProcessExist() return same pid precision.
- Fixed: InetGet("abort") and exiting AutoIt with a download in progres now correctly stop the download immediately.
- Fixed: @InetGetBytesRead Byte count could be wrong due to a race condition.
- Fixed: DirCreate() not creating subdir on dir with read/hidden/system attributes.
- Fixed: FileSetAttrib(), FileSetTime() destroy @WorkingDir.
- Fixed: GUICtrlSetImage() for 16x16 icon not repainting.
- Fixed: The use of $GUI_GR_RECT and $GUI_GR_ELLIPSE under fixed under Win98.
- Fixed: GUI Edit/Input control change notification.
- Fixed: Avoid GUISwitch() when only one remain.
- Fixed: GUI Multiple files drag & drop on edit/input control.
- Fixed: GUI Colors on edit/input control.
- Fixed: GUICtrlSetImage() return 0 on error.
- Fixed: crash Autoit when click on header button of a listview control.
- Fixed: GUICtrlState(@SW_MAXIMIZE or @SW_RESTORE).
- Fixed: GUICtrlSetStyle() ES_READONLY on input/edit control.
- Fixed: GUICtrlCreateTab() disapearing.
- Fixed: Resizing of GUI Combo control.
- Fixed: GUICtrlSetData() for list or combo not inserting.
- Fixed: GUICtrlSetState() for Menu/menuitem.
- Fixed: GUICtrlDelete() of a Listview control lead to crash after recreation with more columns.
- Fixed: GUICtrlCreateListViewItem() with more field than column.
- Fixed: GUISetFont() and Input Control not displayed.
- Fixed: GUICtrlRead() return on expanded TreeviewItem.
- Fixed: Windows centering of GUICreate().
- Fixed: GUICtrlSetPos() on Icon control.
- Fixed: GUIGetCursorInfo() on tab.
- Fixed: Some flickering in GUICtrlSetImage().
- Fixed: GUICtrlSetState() on non active tab.
- Fixed: TreeviewItem notify when clicking a second time on the same item.
- Fixed: GUICtrlSetData() on inactive tabitem not refreshing active item.
- Fixed: GUICtrlSetState() on control tab.
- Fixed: GUICtrlSetState() disable on hidden control tab.
- Fixed: GUIGetCursorInfo() with nonactive GUI.
- Fixed: Bug with accelerator keys (Alt+...) and tabs.
- Fixed: Treeview painting under OS <XP.
- Fixed: GUICtrlSetData() with float value.
- Fixed: GUICtrlSetImage() repainting.
- Fixed: Weird behavior when resizing column of listview on a tab.
- Fixed: GUICtrlSetState($tabitem,$GUI_SHOW) on visible GUI.
- Fixed: GUIGetCursorInfo() primary/secondary under nonXP.
- Fixed: GUICtrlSendMsg(), TraySetState() doc link.
- Fixed: Crash when deleting an input control.
- Fixed: GUICtrlCreateCombo() and $CBS_DROPDOWNLIST color.
- Fixed: GUICtrlCreateDate() and $DTS_UPDOWN.
- Fixed: GUI click return position.
- Fixed: GUIGetMsg() returning on Input control change.
- Fixed: GUICtrlCreateInput() /Edit forcing WS_TABSTOP when ES_READONLY.
- Fixed: Resizing of GUI controls dynamically created.
- Fixed: a small flickering bug in GUICtrlSetImage() for treeview items.
- Fixed: GUICtrlSetPos(), GUICtrlSetResizing() use visible window.
- Fixed: GUICtrlCreateIcon() icon size in multiple icon .ico file.
- Fixed: Pic GUI control size inside a group control.
- Fixed: GUICtrlL()istview repainting on tab.
- Fixed: Memory overflow in customdraw operations in GUI while scrolling.
- Fixed: Bad GUICtrlSetResizing() when no first show has occured.
- Fixed: bkcolor label on tab if GUICtrlListViewItem.
- Fixed: $SS_CENTERIMAGE on pic GUI control.
- Fixed: AutoIt Crash when creating a control on a minimized window.
- Fixed: GUICtrlSetImage() icon.
- Fixed: Grey coloring of input/edit GUI control when disabled.
- Fixed: Crash after GUICtrlDelete() of a control having the focus.
- Fixed: GUICreate() with WS_VISIBLE do an implicit GUISetState().
- Fixed: Background label bad firing when overlayed by an GUI edit control.
- Fixed: GUICtrlSetData() can delete a specific column.
- Fixed: memory leak on GUIDelete($tabitem with icon).
- Fixed: GUI updown control notification if change with keyboard.
- Fixed: GUIGetCursorInfo() on listview header.
- Fixed: GUICreate() WS_POPUP Centering.
- Fixed: Bad Notification on end of drag when $GUI_DROPACCEPTED not set on a control.
- Fixed: GUISetState(@SW_UNLOCK) force repainting.
- Fixed: GUICtrlSetState() $GUI_SHOW on tab with $TCS_BUTTON style.
- Fixed: Bad GUI tabitem creation when no tab defined.
- Fixed: Bad GUI combo disable 16-bit color under W2K.
- Fixed: GUISetBkColor() freezing the display.
- Fixed: GUICreate() $WS_CHILD+$WS_VISIBLE w=0 or h=0 lead to crash AutoIt.
- Fixed: GUICtrlCreatePic() w=h=0.
- Fixed: GUICtrlRead() menuitem checked.
- Fixed: Labels were not painted correctly on GUI tab controls.
- Fixed: GUICtrlSetState(tabitem,@SW_SHOW) under creation bad tabitem display.
- Fixed: GUICtrlSetData() on listview/listviewItem bad erasing.
- Fixed: GUICtrlSetImage() on a GUI defined with $WS_VISIBLE.
- Fixed: GUICtrlSetState( ,$GUI_FOCUS) changing tab ordering. Need to create a new state $GUI_ONTOP.
- Fixed: Extra notification on first/default control after GUISetState().
- Fixed: Event notification on {enter} on an GUI edit control.
- Fixed: $GUI_EVENT_MOUSE firing without any mouse movement.
- Fixed: GUICtrlSetState( ,$GUI_FOCUS) on button repainting.
- Fixed: Drag&Drop of listviewitem onto another listview. $GUI_ACCEPTFILES has been renamed in $GUI_DROPACCEPTED.
- Fixed: TabStop order.
- Fixed: GUICtrlSetPos() with a Child window.

Au3Info:
- Added: Now shows Style and exStyle values for the controls.

3.1.1 (7th Apr, 2005) (Release)
AutoIt:
- Fixed: @OSVersion did not work for Windows Server 2003
- Fixed: $LVS_EX_FULLROWSELECT in GuiConstants.au3 was defined $LBS...
- Fixed: @YDAY was incorrect (one day out)

3.1.0 (7th Feb, 2005) (Release)
AutoIt:
- Removed: URLDownloadToFile() replaced by InetGet().

- Changed: For loops automatically declare the counter variable as a Local variable.
- Changed: IniDelete() can also delete entire sections.
- Changed: StringReplace() also returns the number of replacements in the @extended macro.
- Changed: StringMid() the "count" parameter is now optional (assumes remainder of the string).
- Changed: PixelChecksum() now has optional step parameter.
- Changed: Control...() functions now accept the Control ID as an extra way to identify a control.
- Changed: InetGet() function can download in the background.
- Changed: Reg...() functions no longer give a hard error when an unknown key is used.
- Changed: The mouse and pixel functions now have an additional "client area" mode
- Changed: Added WIN_2003 to the possible values for @OS_VERSION.
- Changed: AU3Spy.exe renamed to Au3Info.exe.
- Changed: Major upgrades to the AutoIt Window Spy (control highlighting, magnify).
- Changed: FileSelectFolder supports an initial directory as well as a root directory.
- Changed: File functions no longer give fatal errors when -1 is used as a handle.
- Changed: (Internal) new quicker variable lookup using a binary tree.
- Changed: (Internal) new shared process memory class used for StatusbarGetText().
- Changed: (Internal) Unified structure stacks (If, Func, Select, While, Do, For).
- Changed: (Internal) Variant rewrite (now handles int32, int64, double, string, HWND data).

- Added: GUI creation capabilities.
- Added: DllCall(), DllOpen(), DllClose().
- Added: ControlListView().
- Added: WinList().
- Added: DirGetSize()?
- Added: IniReadSectionNames(), IniReadSection().
- Added: InetGet(), InetGetSize().
- Added: HttpSetProxy(), FtpSetProxy().
- Added: FtpBinaryMode (Option).
- Added: Ping().
- Added: ControlGetHandle().
- Added: WinGetProcess() and ProcessList().
- Added: SetExtended().
- Added: WinSetTrans().
- Added: Assign().
- Added: ConsoleWrite().
- Added: @AutoItExe macro.
- Added: Const keyword.
- Added: Optional parameter support for user functions.
- Added: "main", "primary", "menu", "secondary" added as valid mouse button types.
- Added: ExpandVarStrings (Option).
- Added: The user functions OnAutoItStart() and OnAutoItExit() are called during startup/exit.
- Added: OnExitFunc (Option).
- Added: (Internal) Native HWND datatype added to variants.

- Fixed: Memory leak in SplashImageOn().
- Fixed: Expressions like "$var = $var" will now give an error if the variable wasn't previously defined.
- Fixed: StringFormat() with \\ characters.
- Fixed: Under rare situations after closing a script AutoIt3.exe would still appear in task manager for a while.
- Fixed: Certain paths like @WindowsDir were incorrect under Windows Terminal Server.
- Fixed: FileSetTime() systems in non-GMT timezones had incorrect results.
- Fixed: FileMove() with UNC paths (does a real move when in the same dir rather than a copy).
- Fixed: ^ operator.
- Fixed: Chr().
- Fixed: StatusbarGetText() failed when used with no "Text" parameter.
- Fixed: InputBox() didn't return focus to the previously active window.

3.0.102 (4th August, 2004) (Release)

WARNING:
    Colors now default to the standard RGB format rather than the previous BGR format.
    This affects PixelSearch(), PixelGetColor().

    The "ColorMode" option has been added to allow old scripts to run with the old BGR mode, just
    place this line at the top of your script to use the old method:

    Opt("ColorMode", 1)

AutoIt:
- Changed: TimerStart() renamed to TimerInit(). TimerStop() renamed to TimerDiff().
- Changed: FileSelectFolder() flag parameter changed.
- Changed: REG_MULTI_SZ values allow double NULL values.
- Changed: BirOr(), BitAND() and BitXOR() take up to 255 parameters.
- Changed: Icon and windowstate options added to FileCreateShortcut().
- Changed: RunAsSet() supports extra profile handling options.
- Changed: RegWrite() now accepts just the keyname in order to create a keyname with no value.
- Changed: "Allow Decompilation" option added to Aut2Exe.
- Changed: Aut2Exe gives feedback during compilation and gives the option to abort.
- Changed: Compiled scripts run/extract much faster when using FileInstall and medium/large files.
- Changed: Max number of user function limits removed.
- Changed: Max number of variable limits removed.
- Changed: -1 does no sleep at all for Send/Mouse delays (SendKeyDelay, etc...).
- Changed: Optional occurance parameter added to StringInStr().
- Changed: Optional default filename added to FileOpenDialog() and FileSaveDialog().
- Changed: Registry functions accept 4 letters keys (HKLM instead of HKEY_LOCAL_MACHINE, etc.).
- Changed: Remote registry keys are accepted in the form "\\computername\key\subkey".
- Changed: AutoItSetOption returns the previous setting.
- Changed: (Internal) Built-in function lookups completely rewritten.
- Changed: (Internal) String functions speeded up (concat in astring and variants).
- Changed: (Internal) ControlSearch modified to include the windowsearch.

- Added: DriveMapAdd(), DriveMapDel() and DriveMapGet().
- Added: @SW_SHOWDEFAULT, @SW_SHOWMAXIMIZED, @SW_SHOWMINIMIZED, @SW_SHOWMINNOACTIVE,
  @SW_SHOWNA, @SW_SHOWNOACTIVATE, @SW_SHOWNORMAL
- Added: FileGetShortcut().
- Added: Predefined $CmdLineRaw variable now holds the original command line in full.
- Added: @DesktopDepth.
- Added: ReDim.
- Added: Command line option /ErrorStdOut.
- Added: More command line params for Aut2Exe.exe: /nodecompile and /comp 0-4 (compression level, 4=best).
- Added: Process ID (PID) support for Process...() and Run() functions.
- Added: ProcessSetPriority().
- Added: Decompiler (Exe2Aut) added.
- Added: PixelChecksum().
- Added: Strings starting with "0x" are converted from hex when used numerically.
- Added: Multi-directory #include <> paths.
- Added: MouseWheel().
- Added: FileRecycleEmpty().
- Added: RegEnumKey() and RegEnumVal().

- Fixed: FileGetSize() works on >2GB files and in-use files.
- Fixed: The expression: If "non-blank" And 1 - now evaluates as true.
- Fixed: /c command line use in compiled scripts.
- Fixed: ToolTip() when the mouse is near the bottom of the screen.
- Fixed: StringIsDigit().
- Fixed: Process...() functions under NT4 unable to see certain processes.
- Fixed: Some keywords incorrectly allowed after a THEN keyword.
- Fixed: (Internal) Hotkey registering logic.

3.0.101 (11th Mar, 2004) (Release)
AutoIt:
- Added: MemGetStats().

- Fixed: Compatibility problem under Windows 95a.
- Fixed: Some minor help file typos corrected.

3.0.100 (29th Feb, 2004) (Release)
AutoIt:
- Added: WinTextMatchMode (Option).

- Fixed: ExitLoop and ContinueLoop failed during a recursive function.
- Fixed: Sleep(0) (or < 0 ) no longer hangs.
- Fixed: $ with no name was allowed as a variable.
- Fixed: For Loop bug when used in recursion.
- Fixed: FileGetLongName() return value.
- Fixed: @UserProfileDir under 9x.
- Fixed: IsDeclared().
- Fixed: Random().

3.0.94 (21st Feb, 2004) (Beta)

SCRIPT BREAKING CHANGES
    FileReadLine() and FileWriteLine()

    FileWriteLine now automatically writes a DOS @CRLF pair UNLESS the last character of
    the string to write is already @CR or @LF (to make it possible to write non-DOS text files)

    FileReadLine will correctly read a DOS, UNIX or MAC line (@CRLF, @LF and @CR terminated respectively).

    FileWrite and FileRead added to add further support.

CHANGE YOUR SCRIPTS AS FOLLOWS:

    From: FileWriteLine($handle, "line" & @LF)
    To: FileWriteLine($handle, "line" & @CRLF) or FileWriteLine($handle, "line")

    From: FileWriteLine($handle, "line")
    To: FileWrite($handle, "line")

AutoIt:
- Changed: FileReadLine() and FileWriteLine().
- Changed: EnvSet().
- Changed: WinShow() renamed to WinSetState() (With WinShow() as an alias).

- Added: FileWrite() and FileRead().
- Added: ToolTip().
- Added: Eval() and IsDeclared().
- Added: "CaretCoordMode" in AutoItSetOption().
- Added: WinGetCaretPos().
- Added: WinGetState().
- Added: "MustDeclareVars" in AutoItSetOption()
- Added: Editors page in help.

- Fixed: Splash() and moveable flag (and -1 default flag in options).
- Fixed: Odd ElseIf error message showing wrong line.
- Fixed: Crashes with bad function calls: MsgBox(MsgBox(MsgBox)).
- Fixed: HotKey crashes when unregistering a key that was not registered.
- Fixed: (Internal) WinWaitDelay, SendKeyDelay, etc type commands now more accurate (previously only accurate to 10ms (NT) or 55ms (9x)).
- Fixed: (Internal) Execute() recursion limit dropped to 384 levels.
- Fixed: (Internal) Calls to Util_AttachThreadInput will not attach to hung windows.
- Fixed: (Internal) some RegRead/RegWrite() sizing problems (Ta, Chris).

3.0.93 (12th Feb, 2004)
AutoIt:
- Changed: Splash and Progress functions have a "moveable" option.
- Changed: StringStripWS() (new strip all ws mode).
- Changed: InputBox() (timeout param).
- Changed: Hot keys are no longer buffered when the script is paused.
- Changed: (Internal) Removed the only sscanf call and replaced with own code - saves 4KB.

- Added: "SendAttachMode" in AutoItSetOption().
- Added: Opt() is an alias for AutoItSetOption() :)
- Added: Doc updates.
- Added: "WinSearchChildren" in AutoItSetOption().

- Fixed: REG_MULTI_SZ support.
- Fixed: TrayIconDebug not showing correct filename.
- Fixed: ControlClick(), ControlCommand("CHECK").
- Fixed: Control...() functions now using return values rather than @error where appropriate.
- Fixed: Error with '' quotes in Aut2Exe.
- Fixed: StringFormat().
- Fixed: Lexer checks that potential user function calls are for existing functions.
- Fixed: Input thread attachment in Send() ( check Send("{... down}") still works).

3.0.92 (6th Feb, 2004)

SCRIPT BREAKING CHANGES
    ControlLeftClick(), FileFindFirstFile(), SendSetCapslockState()

AutoIt:
- Removed: SendSetCapslockState() - Use Send("{CAPSLOCK on/off}").

- Changed: FileFind works differently (handles used and multiple finds now supported).
- Changed: ControlLeftClick() renamed to ControlClick() and options added.
- Changed: Window Spy options added and ability to freeze display.
- Changed: StringSplit() will return each char if delimiters are "".
- Changed: WinMenuSelectItem() return value.
- Changed: optional variation added to PixelSearch().
- Changed: optional step value added to PixelSearch().
- Changed: FileMove() overwrite flag added.
- Changed: *.* assumed if a directory is used in FileCopy()/FileMove()/FileDelete().
- Changed: (Internal) DirRemove changed.
- Changed: (Internal) Sendkeys tweaked A LOT.

- Added: Dec().
- Added: BitNOT(), BitXOR(), BitShift().
- Added: "TrayIconDebug" in AutoItSetOption().
- Added: Dim single-line initialization and multiple variables.
- Added: "WinTitleMatchMode,4" in AutoItSetOption().
- Added: #comments-start and #comments-end for multiline comments.
- Added: DirCopy().
- Added: DirMove().
- Added: Controls will be checked by visible text as well as classname (waves to Chris :) ).
- Added: Macros: @UserProfileDir, @HomeDrive, @HomePath, @HomeShare, @LogonServer, @LogonDomain, @LogonDNSDomain.

- Fixed: @TempDir under certain conditions.
- Fixed: Hotkeys were ignored while another hotkey function was running.

3.0.91 (29th Jan, 2004)
AutoIt:
- Changed: FileGetTime outputs strings with leading 0s when required.
- Changed: Default value of Local/Global/Dim is the String "" (equates to 0 when used as a number).
- Changed: (Internal) More scriptfile.cpp optimization.
- Changed: (Internal) Execute() recursion levels limited to 512 to prevent stack overflows.

- Added: Options: "MouseClickDelay", "MouseClickDownDelay", "MouseClickDragDelay" in AutoItSetOption().
- Added: REG_BINARY type for RegRead() and RegWrite().
- Added: FileChangeDir().
- Added: ControlCommand() - added GETCURRENTSELECTION.
- Added: Added some standard library includes (See Program Files\AutoIt3\Include\).
- Added: "SendKeyDownDelay" in AutoItSetOption() (alters the amount a time a key is held down before released).
- Added: AutoIt returns an exit code of 1 if script could not be loaded.
- Added: FileSetAttrib(), FileSetTime().
- Added: In Au3_Spy pixel colour is also shown in hex.

- Fixed: While loops failing when used in recursive functions of themselves... (!?).
- Fixed: Small line continuation _ bug.
- Fixed: URLDownloadToFile().
- Fixed: FileRecycle() not always working.
- Fixed: FileRecycle() return value.
- Fixed: Relative #include use.
- Fixed: Smart boolean comparision re-added.
- Fixed: FileFindFirst() not releasing memory when called multiple times.

3.0.90 (20th Jan, 2004)
AutoIt:
- Changed: (Internal) Rollback of variabletable.cpp and stacks/vectors.

- Fixed: Serious nested IF bug.

3.0.89 (19th Jan, 2004)
AutoIt:
- Added: Method for standard library functions and includes.
- Added: #include < > support (must be fully installed to work).
- Added: #include-once directive (put at the top of a file to make sure it is only included once).
- Added: @UserName and @TempDir macros.

- Fixed: Nasty fatal bug in 3.0.88.

3.0.88 (18th Jan, 2004)
AutoIt:
- Changed: All block structures (IF/WHILE/FOR, etc.) are now checked before execution.
- Changed: (Internal) lots of error checking code removed as a nice side effect of initial block structure checking.
- Changed: (Internal) windows string functions (lstrcmp etc) moved back to C versions due to massive performance penalty.

- Added: ElseIf

- Fixed: Some single hotkeys not working.
- Fixed: Better detection of illegal nesting?

3.0.87 (15th Jan, 2004)
AutoIt:
- Changed: Aut2Exe stores files it can't compress (.zip etc) rather than expanding.
- Changed: (Internal) variable_table.cpp rewritten.
- Changed: (Internal) All stacks/vectors replaced with templated code.

- Fixed: Aut2Exe crashing if FileInstall used a file less than 4 bytes.
- Fixed: Aut2Exe crashing with uncompressable files.
- Fixed: RegRead() not working correctly with large DWORD values.
- Fixed: NOT fixed when skipped during a boolean expression.

3.0.86 (12th Jan, 2004)
AutoIt:
- Changed: Single keys of 0-9, a-z can no longer be used as hotkeys if alt,ctrl or win is NOT also used.
- Changed: (Internal) FPU assembler used for advanced math (sin,Cos,pow, etc) functions due to exe size problems under VC7.

- Added: Enhanced boolean comparisons.
- Added: Send can hold keys down, e.g. Send("{a down}") will hold the A key down (only works usefully with games).

- Fixed: 0 ^ 0 = 1.
- Fixed: on_top parameter of ProgressOn().
- Fixed: No longer hanging with blank search in StringReplace().
- Fixed: Asc() giving -1 in some cases.
- Fixed: Tray icon's tip not updating when un-pausing.

3.0.85 (9th Jan, 2004)
AutoIt:
- Changed: IniWrite/IniDelete() return 0 if they fail.
- Changed: No longer need to use virtual keys for FileCreateShortcut().
- Changed: (Internal) Send() tweaking.

- Added: HotKeySet().
- Added: Abs(), Sin(), Cos(), Tan(), ASin(), ACos(), ATan(), Sqrt(), Log(), Exp().
- Added: ^ operator.
- Added: Round().
- Added: Call().

- Fixed: Return value for FileCopy/FileInstall().
- Fixed: Incorrect use of ExitLoop/ContinueLoop trapped.
- Fixed: (Internal) Function calling/scope slightly bugged (Adlib, Hotkey).

3.0.84 (30th Dec, 2003)
AutoIt:
- Changed: The key # is no longer used as a delimiter but as a left Win key combination.
  So Send("#e") now presses the left win+e keys.
  don't think anyone actually used it as a delimiter anyway,
  - it was just a left over from v1 and it never made lines easier to read anyway.
- Changed: FileReadLine() and FileWriteLine() modified so that they optionally accept a filename
  instead of a filehandle for "quick 'n' dirty" file access
  - I'm sure this will be popular :)

- Added: New window WinTitleMatchMode of 3 (for exact title match).
- Added: Some more details added to helpfile.

3.0.83 (30th Dec, 2003)
AutoIt:
- Changed: Due to popular demand, by default functions now return 0 for error and 1 for success.
  This affects the following functions: FileWriteLine, CDTray, DriveSetLabel, DirCreate,
  DirRemove, FileCopy, FileMove, FileDelete, FileInstall, ClipPut, URLDownloadToFile,
  RunAsSet, Shutdown, RegWrite, RegDelete, WinWait, WinWaitActive, WinWaitClose, WinWaitNotActive,
  ProcessWait, ProcessWaitClose. If you were using the return values of one of
  these functions then please check your scripts.
- Changed: ControlSend() supports {} (for most things at least...).

3.0.82 (29th Dec, 2003)
AutoIt:
- Changed: (Internal) FileInstall() compression code updated.

- Added: Files installed with FileInstall() now have original timestamps (created/modified).
- Added: IsNumber().

- Fixed: Number to string conversions and general float parsing.

3.0.81 (17th Dec, 2003)
AutoIt:
- Fixed: Yet more bugs with single line IF - regretting adding this feature already...
- Fixed: Bugs with NOT operator and the new variant code.
- Fixed: Bug with clicking CANCEL on the open script window (introduced in 3.0.80).
- Fixed: StringIs... functions failing when using numbers as parameters.
- Fixed: (Internal) AVector<Variant> modified to allow reference access to variants (instead of copying everytime).

3.0.80 (15th Dec, 2003)
AutoIt:
- Changed: Number to String conversions tweaked.
- Changed: (Internal) script reading code updated for Aut2Exe and merged with AutoIt.

- Fixed: Massive bug fixed with arrays introduced in 3.0.76.
- Fixed: Line continuation crash.

3.0.79 (15th Dec, 2003)
AutoIt:
- Changed: Maximum line length (including total of combined lines) increased from 1023 to 4095 characters.
- Changed: "Then" keyword in If statements no longer optional (helps with single line IFs).

- Added: Lines can be continued over many lines - use _ at the end of a line to continue it (as VBScript).
- Added: Single line IF statements possible.

3.0.78 (15th Dec, 2003)
AutoIt:
- Changed: Variants work differently - no longer a seperate INTEGER type.
- Changed: Float() changed to Number().
  All numbers now 15digit precision (internal C double type).
  Also affects Random() you will get floating point numbers back unless you use Int() with the result.

3.0.77 (13th Dec, 2003)
AutoIt:
- Changed: "AutoIt -" prefix removed from compiled a script's tray icon.
- Changed: Compiled script's file properties point to a custom web page.

- Added: New option "TrayIconHide" in AutoItSetOption().

- Fixed: Tray icon should redraw after an explorer crash.

3.0.76 (12th Dec, 2003)
AutoIt:
- Fixed: Couple of bugs with ContinueLoop and ExitLoop.
- Fixed: Statements like $test[$test[0]] now working.

3.0.75 (1st Dec, 2003)
AutoIt:
- Changed: Dim (along with Local/Global) can now be used as in vbscript to declare variables.
- Changed: FileOpenDialog() uses "|" as the delimiter instead of ",".

- Added: ControlGetFocus().
- Added: Local and Global keywords.

- Fixed: PixelSearch().
- Fixed: SoundPlay()...maybe.
- Fixed: Splash() sizing issues.

3.0.74 (5th Nov, 2003)
AutoIt:
- Added: Hex notation for integer numbers ($var = 10 or $var = 0xa).
- Added: MouseDown(), MouseUp().
- Added: TrayTip().
- Fixed: PixelCoordMode not working correctly.
- Fixed: Compiled exes not producing random numbers.

3.0.73 (2nd Nov, 2003)
AutoIt:
- Changed: FileMove() moves/renames without affecting timestamps - can also be used for directories.
- Changed: RegRead/RegWrite() now supports REG_EXPAND_SZ.
- Changed: Extra options added to FileGetTime().
- Changed: Extra 250ms delay added to start and end of mouse drags.

- Added: New option "RunErrorsFatal" in AutoItSetOption().
- Added: New option "ExpandEnvStrings" in AutoItSetOption().

- Fixed: Odd error message fixed where a user function contained a badly formatted line.

3.0.72 (30th Oct, 2003)
AutoIt:
- Added: New option "PixelCoordMode" in AutoItSetOption().

- Fixed: Compiler was ignoring comments near FileInstall() functions.
- Fixed: Memory leak in StatusbarGetText().
- Fixed: PixelGetColor().

3.0.71 (29th Oct, 2003)

SCRIPT BREAKING CHANGES
    Get ready for some script rewriting...*holds up banner with BETA written on it :) *

AutoIt:
- Removed: MouseSetMode(), SendSetCapslockMode(), SendSetDelay(), WinSetDelay(), WinSetDetectHiddenText() and WinSetTitleMatchMode().

- Added: ControlSend().
- Added: Framework for AutoItSetOption()
  - NOTE: this function replaces all functions like WinSetDelay, SendSetDelay, MouseSetMode, etc.

3.0.70 (26th Oct, 2003)
AutoIt:
- Removed: AutoItWinShow(), AutoItWinWrite(), AutoItWinGetText().

- Changed: ControlCommand() (updated with Larry's recent changes).
- Changed: RegRead() extended error codes.

- Added: FileFindFirstFile(), FileFindNextFile().
- Added: AutoItWinGetTitle().
- Added: WinGetClientSize().
- Added: EnvUpdate().
- Added: SoundSetWaveVolume().
- Added: FileGetLongName(), FileGetShortName().
- Added: TimerStart(), TimerStop().

- Fixed: SoundPlay().

3.0.69 (23rd Oct, 2003)
AutoIt:
- Fixed: Small delay added into MouseClick() functions.
- Fixed: FileGetVersion().
- Fixed: WinMenuSelectItem().
- Fixed: StringSplit() buffer overrun.

3.0.68 (3rd Oct, 2003)
AutoIt:
- Changed: (Internal) Larry's nFlag functions split.

- Added: FileGetAttrib(), WinMenuSelectItem(), FileGetVersion().
- Added: Added options to ControlCommand().

3.0.67 (30th Sep, 2003)
AutoIt:
- Changed: InputBox() narrowed slightly.
- Changed: (Internal) MessagePump handled differently and recursion level of Execute() tracked.

- Fixed: AutoIt icon not refreshing if Return was used at top level of script.
- Fixed: Crash with extra long lines fixed.
- Fixed: @OS_VERSION weirdness fixed.

3.0.66 (25th Sep, 2003)
AutoIt:
- Changed: StringSplit() returns full string in array if no delimiters matched (and count=1 not 0).

- Fixed: Crash related to window titles and text fixed.

3.0.65 (23rd Sep, 2003)
AutoIt:
- Changed: (Internal) Window searching functions altered to check for hung windows.

- Added: ControlCommand() option GetCurrentLine.

- Fixed: Possible bug with optional "Then" statement fixed.

3.0.64 (19th Sep, 2003)
AutoIt:
- Added: Errors now include the file name that contained the error.

- Fixed: IniWrite/Delete() functions were not flushing immediately under 9x.

3.0.63 (18th Sep, 2003)
AutoIt:
- Changed: ControlCommand() various internal changes.
- Changed: Can now specify a custom time for AdlibEnable().

- Fixed: MsgBox() character limit bug fixed.

3.0.62 (17th Sep, 2003)
AutoIt:
- Changed: Timing of "paused" flash and icon modified a little.

- Fixed: Aut2Exe icon changing code bugged.

3.0.61 (16th Sep, 2003)
AutoIt:
- Changed: (Internal) Encryption code modified - check compiling thoroughly.

- Added: AutoIt icon flashes when in paused state.

- Fixed: FileOpenDialog().

3.0.60 (15th Sep, 2003)
AutoIt:
- Changed: Aut2Exe strips version info from compiled script. (Hoping to be custom versioninfo in future).

- Fixed: FileGetSize() (change made, unsure if problem fixed).
- Fixed: FileMove() wasn't supported on 9x (9x has no MoveFileEx function, Dave... :) ).

3.0.59 (13th Sep, 2003)
AutoIt:
- Fixed: InputBox was not returning "" on cancel.

3.0.58 (12th Sep, 2003)
AutoIt:
- Added: InputBox() (and very nice it is too...).
- Added: FileMove().

- Fixed: The window text searching in AutoIt was not the same as AU3_Spy or WinGetText().

3.0.57 (10th Sep, 2003)
AutoIt:
- Fixed: MsgBox under 9x was doing odd things with timeouts - tried something else.

3.0.56 (9th Sep, 2003)
AutoIt:
- Added: SysTabControl32 tabbing.

- Fixed: Selecting the default icon in Aut2Exe was not saved between sessions.
- Fixed: @OSLang under NT4...

3.0.55 (8th Sep, 2003)
AutoIt:
- Changed: Better icon support added to Aut2Exe.
- Changed: (Internal) upx.exe called during the compiler to compress data
  - necessary to do it this way as you can't edit the resources of a compressed exe.
- Changed: SoundPlay().

3.0.54 (7th Sep, 2003)
AutoIt:
- Fixed: Compiled scripts with custom icons were failing.
- Fixed: @OS_LANG under 9x.

3.0.53 (6th Sep, 2003)
AutoIt:
- Added: StringSplit().

3.0.52 (6th Sep, 2003)
AutoIt:
- Changed: SoundPlay() option to wait added.

- Added: ChangeIcon support back in Aut2Exe (32x32x16)
    - Slightly better than v2 in that a multiimage iconfile can be used
    - although only the 32x32x16 image is actually used.

3.0.51 (5th Sep, 2003)
AutoIt:
- Fixed: Aut2Exe still used ' comments when including files -whoops.

3.0.50 (5th Sep, 2003)
AutoIt:
- Changed: (Internal)A little error checking added to the lexer.
- Changed: MouseClick() parameters changed.

- Added: @TAB, @ComSpec.
- Added: MouseClickDrag().

3.0.49 (4th Sep, 2003)
AutoIt:
- Changed: Single line comment character is now ";".
- Changed: ' and " may now be used for strings.

- Fixed: Statusbar in Aut2Exe with Visual Styles.

3.0.48 (4th Sep, 2003)
AutoIt:
- Changed: StringReplace() count is now optional (assumes global).

- Added: StringIsFloat(), StringIsInt().
- Added: Aut2Exe and AutoIt3 now use Visual Styles.

- Fixed: MsgBox() wasn't returning -1 on timeout.
- Fixed: StringReplace() error if string to replace was at end of string.

3.0.47 (3rd Sep, 2003)
AutoIt:
- Changed: FileExists() to work with wildcards.
- Changed: Extra options added to AutoItWinShow().
- Changed: RegRead returns the string "" in addition to @error if the (default) key was requested and not found.

- Fixed: DriveGetDrive() (still an a: drive bug to find though).

3.0.46 (1st Sep, 2003)
AutoIt:
- Fixed: RegDelete() return value when value does not exist.
- Fixed: CDTray() open/closed problems.
- Fixed: FileSelectFolder() crash due to missing initialisers.

3.0.45 (1st Sep, 2003)
AutoIt:
- Changed: Set...() functions renamed (SendSetDelay, WinSetDelay, etc.).

- Added: StatusbarGetText().

3.0.44 (31st Aug, 2003)
AutoIt:
- Added: Break().

- Fixed: DriveStatus().
- Fixed: RegDelete().

3.0.43 (31st Aug, 2003)
AutoIt:
- Changed: UBound() back to how it was again (same as VBScript syntax).

- Added: Hex(), AutoItWinGetText().

- Fixed: @OSLang for 2000+.

3.0.42 (30th Aug, 2003)
AutoIt:
- Added: MouseSetMode() to allow for screen _and_ relative coords - yay everyone's happy.

- Fixed: Mouse coords were 1 pixel out.

3.0.41 (30th Aug, 2003)
AutoIt:
- Changed: Mouse commands may now work on multiple monitors.

- Fixed: Bug with invalid filehandles (again!).
- Fixed: $CmdLine wasn't working correctly for compiled scripts.
- Fixed: The operator == wasn't properly comparing strings.
- Fixed: INI functions, filename now doesn't need ".\file.ini" to work in the current directory.
- Fixed: Bug in Run() directory would not be set if last parameter was used.

3.0.40 (29th Aug, 2003)
AutoIt:
- Added: Windows API error messages added onto errors for the Run() commands (directory invalid, bad logon, etc).

3.0.39 (29th Aug, 2003)
AutoIt:
- Added: RunAsSet() (2000/XP only).
- Added: FileRecycle().

3.0.38 (28th Aug, 2003)
AutoIt:
- Changed: WinGetText() now correctly takes note of detecthiddentext setting.

- Added: StringStripWS().
- Added: DriveGetLabel(), DriveGetSerial(), DriveGetFileSystem(), DriveSetLabel(), DriveGetType(), MouseGetCursor().

3.0.37 (26th Aug, 2003)
AutoIt:
- Changed: Compression tweaked in Aut2Exe.
- Changed: UBound($aArray) now returns number of dimensions.
- Changed: Renamed all the IsUpper/IsAlpha, etc functions to StringIsUpper/StringIsAlpha, etc.

- Added: IsFloat(), IsArray(), IsInt(), IsString().
- Added: Mod().

3.0.36 (25th Aug, 2003)
AutoIt:
- Added: New compression code (slower but better at higher levels).

- Fixed: Main dialog in Aut2Exe?

3.0.35 (24th Aug, 2003)
AutoIt:
- Added: FileInstall() support.
- Added: SplashImageOn(), SplashTestOn(), SplashOff().
- Added: ProgressOn(), ProgressOff(), ProgressSet().
- Added: Compression level option in Aut2Exe.

3.0.34 (23rd Aug, 2003)
AutoIt:
- Added: Compiled script reading code added.
- Added: @Compiled.
- Added: Aut2Exe.

- Fixed: subscript must be > 0 in Dim statement.

3.0.33 (22nd Aug, 2003)
AutoIt:
- Changed: Parsing speeded up (doubled the speed).
- Changed: Optimized string handling in variants.

- Added: Case Else.
- Added: @DesktopWidth, @DesktopHeight.

- Fixed: CDTray() - closed/close.
- Fixed: Incorrect reference passing of global variables.
- Fixed: Bad file handle causing a crash in FileWrite/FileRead/FileClose().
- Fixed: Crash with badly formatted Func statements.

3.0.32 (20th Aug, 2003)
- Started proper version logging :)

First public beta binary - 4th Mar, 2003.

Development started - 20th Jan, 2003.


AutoIt Changelog (including beta version changes)
=================================================

3.3.14.0 (10th July, 2015) (Release)

3.3.13.22 (Unreleased) (Beta)
AutoIt:
- Changed: Moved GUICtrlCreatePic() PNG example to the appropriate UDF examples.

UDFs:
- Fixed #3063: Removed additional param in the $tagRAWKEYBOARD structure.

3.3.13.21 (July 8th, 2015) (Beta)
AutoIt:
- Added: @OSVersion supports Windows 10 and Windows Server 2016.
- Added: GUICtrlCreatePic() with PNG example.
- Added: Constants for native Functions in AutoItConstants.au3.
- Added #3012: GUISetFont() default value doc.

- Fixed #3028: GUICtrlCreateCombo() doc formatting.
- Fixed #3040: Int() doc typos.
- Fixed #3042: Number() doc clarifications.
- Fixed #3041: AutoItWinGetTitle() doc example typos.
- Fixed #3039: AutoItWinSetTitle() doc example typos.
- Fixed #3057: StringSplit() Return Value if $STR_NOCOUNT doc.
- Fixed #2901: Memory error when specifying a UTF file mode that includes a BOM when no BOM is present.

UDFs:
- Changed: _ArrayTranspose() algorithm.
- Changed: _SQLite 3.8.8.1 -> 3.8.10.0.

- Added: _GDIPlus_ImageGetDimension().
- Added: _GDIPlus_BitmapCreateDIBFromBitmap() can be used to allow .PNG in GUICtrlCreatePic().
- Added: _GDIPlus_ImageGetThumbnail().
- Added #3034: _Timer_SetTimer() doc example.

- Fixed #3011: _FileListToArrayRec() not closing the open handle.
- Fixed: _Word_DocFind(), _Word_DocFindReplace() and _Word_DocPrint() did not set @extended to the COM error code.
- Fixed #3018: _GDIPlus_EffectCreateHueSaturationLightness () doc and _GDIPlus_BitmapApplyEffect() crash.
- Fixed #3038: _Timer_SetTimer() callback function parameters.
- Fixed #3037: _RunDOS() waits for command completion.
- Fixed #3055: Bad link in _WinAPI_IOCTL() doc.
- Fixed #3052: _ArraySort() doc clarification for 2D .
- Fixed #3059: Miscelaneous => Miscellaneous in Help : Typos.
- Fixed #2993: _Excel_RangeFind returns only last occurrence of string found.

Others:
- Added: lang-autoit.js code highlighting file for Google Prettify. See the Extras\Prettify folder.
- Added: lang-autoit.js supports multiline comments.

3.3.13.20 (March 21th, 2015) (Beta)
AutoIt:
- Changed: Map uses 64-bit integers.

- Fixed #2920: Doc precision about no control position/resizing on initially window for GUiCreate()/WinMove().
- Fixed #2924: Progress bar style documentation.

UDFs:
- Changed: Removed internal redraw code from _GUIListView_DeleteAllItems() and _GUIListView_DeleteSelectedItems().
- Changed: _ArrayUnique() can now deal with Int64 values via new parameter,
- Changed: _SQLite 3.8.6.0 -> 3.8.8.1.
- Changed: Re-wrote _StringInsert() using native functions.
- Changed: _HexToString() to _StringToHex() now handles strings and binary as UTF-8 by default.
- Changed: _FileWriteToLine() overwrite optional parameter is now boolean and not an integer of zero or one. The old values are still supported for now.
- Changed: _Word_DocOpen() changed from @error = 4 to @error = 0 and @extended = 1 if document could not be opened Read-Write. THIS IS A SCRIPT BREAKING CHANGE
- Changed: Re-wrote _MathCheckDiv().

- Added #2877: _GUICtrlRichEdit_GetFont() example improvement.
- Added #2857: _GUICtrlEdit_GetCueBanner() and _GUICtrlEdit_SetCueBanner().
- Added #2860: Convert UDF's ptr to struct* type to allow direct passing of a structure.
- Added #2891:  _WinAPI_GetWindowDC() and _WinAPI_RedrawWindow() examples.
- Added: More _GDIPlus_Font* functions.
- Added: _WinAPI_GetFontResourceInfo() return more Font information.
- Added: _WinAPI_GetFontMemoryResourceInfo().
- Added #2922: _VersionCompare() with different number of fields.
- Added #2968: Optional parameter $iMSeconds to _SetTime().
- Added: $SB_ANSI, $SB_UTF16LE, $SB_UTF16BE and $SB_UTF8 constants to StringConstants.au3, for use with BinaryToString() and StringToBinary().
- Added: Constants to Assign() and IsDeclared().
- Added #2982: _FTP_Connect() example improvement.
- Added #2976: #pragma default value.
- Added #2998: Added missing key (03 - control-break processing) to the _IsPressed() documentation.

- Fixed #2868: _WinAPI_SfcIsKeyProtected() ->_WinAPI_SfcIsFileProtected() doc example.
- Fixed #2874: _GUICtrlRichEdit_SetCharColor() not at insertpoint.
- Fixed #2875: Broken link in _SendMessage() doc.
- Fixed #2876: examples running under Windows X64 in 32 bit mode.
- Fixed #2880: Example for _WinAPI_OpenProcess().
- Fixed #2881: HotKeySet() doc as "{ASC nnnn}" cannot be used
- Fixed #2885: Subscript error with _ArrayMax() and _ArrayMin().
- Fixed #2909: Backslash was not appended in _PathMake() if $sDir was blank.
- Fixed #2908: _ScreenCapture_Capture() failing due to out of bounds error.
- Fixed #2911: _ArrayDisplay() GUI controls have wrong coords.
- Fixed #2917: _WinAPI_AddMRUString() example crash when run in X64 mode (Msdn Bug CreateMRUListW !!!).
- Fixed #2918: _GDIPlus_GetEncoderParameterList() not working.
- Fixed: Range setting in _ArrayDisplay().
- Fixed #2923: Broken link in Related section.
- Fixed #2934: Typo in _GUICtrlRichEdit_SetZoom() doc.
- Fixed #2933: Constants reference in _GUICtrlRichEdit_StreamToVar() doc.
- Fixed: _Array_FindAll() return array incorrectly dimesioned for row search.
- Fixed #2964: Incorrect structure for $tagWNDCLASS.
- Fixed: _WinAPI_IsWritable() wrong detection when the device is not ready.
- Fixed: The seconds parameter in _SetTime() being set as milliseconds.
- Fixed #2967: Incorrect format of AM/PM when the time was 00:00.
- Fixed #2983: _WinAPI_GetString() doc.
- Fixed: _StringExplode not using full delimiter to split.

AutoItX:
- Fixed #2882: PixelChecksum bugs.

Au3Check:
- Added: Support of UTF8 with BOM files.

AutoIt3Help:
- Changed: Version number to 1.0.0.7.

- Fixed: Crash in SciTE when multiple lines are selected.

Others:
- Added: Icons\MyAutoit3_*.ico to be used when compiling user scripts (small footprint).

3.3.13.19 (24th August, 2014) (Beta)
AutoIt:
- Fixed: Map setting of property using dot notation was creating duplicates.
- Fixed #2862: Regression in Copy-on-write optimization in arrays.

UDFs:
- Changed: _Excel_BookOpen() changed from @error = 4 to @error = 0 and @extended = 1 if Workbook could not be opened Read-Write. THIS IS A SCRIPT BREAKING CHANGE

- Added #2863: MSDN Link to standard windows controls.

- Fixed #2853: Bad Run link in Notepad tutorial doc.
- Fixed #2854: Keyword reference doc page.
- Fixed #2861: _WinAPI_ReadDirectoryChanges() example.

Other:
- Fixed #2848: Script breaking changes not being highlighted.
- Fixed: Remarks missing in certain documentation pages.
- Fixed: Syntax highlighting missing in certain documentation pages.

3.3.13.18 (20th August, 2014) (Beta)
AutoIt:
- Fixed #2639: Unable to Copy/Paste from Embedded IE object.
- Fixed #2839: GUISetAccelerators() with an invalid array can cause a hard crash.

UDFs:
- Changed: _ArrayInsert() now uses constants to change addition behaviour and datatype forcing.

3.3.13.17 (19th August, 2014) (Beta)
AutoIt:
- Changed: Default text file encoding changed to UTF8 without BOM. THIS IS A SCRIPT BREAKING CHANGE
- Changed: FileOpen() has new modes for forcing ANSI, UTF16-BE/LE without BOM.

- Fixed #2834: FileOpen() and DirCreate() problem with relative paths when creating directories.

UDFs:
- Changed: _SQLite 3.8.5.0 -> 3.8.6.0.

- Added #2836: _WinAPI_SfcIsKeyProtected() doc example.
- Fixed: Limit bug in _ArraySwap().

Others:
- Changed: Improved highlighting AutoIt code inside the HTML files.

3.3.13.16 (7th August, 2014) (Beta)
AutoIt:
- Added: Regular expression caching. Small performance improvements when using the same pattern multiple times.

- Fixed: Assigning objects by reference to COM properties like "$obj(some, params) = $obj2".
- Fixed: Regression with ReDim.

UDFs:
- Added #2826: Quit to close the browser.

- Fixed #2828: Typo of security in _IEFormElementSetValue().

Others:
- Fixed: Re-writing the scripts which generate the syntax files for the editors and GeSHi, resulted in missing descriptions being added and correct sorting of functions.

3.3.13.15 (5th August, 2014) (Beta)
AutoIt:
- Fixed #2502: Copy-on-write optimization when passing array and map elements ByRef was incorrect.

UDFs:
- Fixed #2823: _ChooseFont() default color BGR not RGB.
- Fixed: Limit bug in _ArrayToClip(), _ArrayExtract() and _ArrayToString().

3.3.13.14 (2nd August, 2014) (Beta)
AutoIt:
- Changed: Maps re-implemented internally as hash tables. Massive performance improvements for large maps.

- Fixed #2820: WinExists() and other Win functions were incorrectly converting strings containing numbers into window handles and causing false matches.

UDFs:
- Changed: _GDIPlus_Startup() need explicit Dll for GDI+ v1.1 support under Vista or Server 2008. THIS IS A SCRIPT BREAKING CHANGE

- Fixed: _ArrayAdd() failing with a trailing delimiter in $vValue.
- Fixed #2816: Doc precision with _GDIPlus_ImageLoadFromFile() specifying -1 when it's 0 on failure.
- Fixed: _Crypt_DecryptData() and _Crypt_EncryptData() failing with a blank string when using the RC4 algorithm.
- Fixed #2821: Example comment was incorrect for _DateToDayOfWeekISO().

Others:
- Added: Additional example for FileSetEnd().

3.3.13.13 (31st July, 2014) (Beta)
AutoIt:
- Changed: PCRE regular expression engine updated to 8.35.

- Added: FileSetEnd() example.

- Fixed #2363: Call() with invalid user function was not setting @error correctly when used as an expression within another function call.
- Fixed #2364: Call() with CallArgArray and no parameters.
- Fixed #2789: With EndWith parameter issue.

AutoItX:
- Changed: AutoItX3.psd1 renamed to AutoItX.psd. PSModulePath updated on install so that the system will auto-import.

Others:
- Fixed: Using a static filepath instead of a temporary file.

3.3.13.12 (28th July, 2014) (Beta)
AutoIt:
- Fixed: Memory leak with rewritten array code.
- Fixed: Dim performance regression.

3.3.13.11 (27th July, 2014) (Beta)
AutoIt:
- Added #2346: FileSetEnd().

- Fixed #2372: Incorrect line number given on a bad function call. (Still issues with Callback line errors).
- Fixed #2805: FileWriteLine() was not returning a failure when disk was full.
- Fixed #2623: RegDelete() returning 0 rather than 2 when a key exists but no write permissions to delete it.
- Fixed #2813: Accessing "last created control" once GUI deleted caused a hard crash.
- Fixed #2640: Odd conversion of strings containing numbers in expressions.

AutoItX:
- Fixed #2694: ControlListView not finding controls in x64 mode.

3.3.13.10 (26th July, 2014) (Beta)
AutoIt:
- Added #2686: Random() to return max value when min equals max. THIS IS A SCRIPT BREAKING CHANGE

- Fixed: Regression in empty array handling.
- Fixed #2538: GuiSetAccelerators() was still firing events on disabled button controls.
- Fixed #2671: StringSplit() was splitting incorrectly with regards to case sensitivity.

3.3.13.9 (25th July, 2014) (Beta)
AutoIt:
- Added: MapAppend() returns the index of the element added.

- Fixed: Regression with Call() and CallArgArray.
- Fixed: Regression with speed of arrays.
- Fixed: Was silently failing when passing unsupported parameters ByRef - now shows an error message.
- Fixed: Map/Object properties starting with ".E3" were incorrectly classed as a number rather than property.

3.3.13.8 (22nd July, 2014) (Beta)
AutoIt:
- Added: MapRemove().

- Fixed: Regression in With .Method(...).

3.3.13.7 (22nd July, 2014) (Beta)
AutoIt:
- Changed: Internal rewrite of all array handling.
- Changed: Internal rewrite of map object.

- Fixed: Map elements being incorrectly auto-created during function calls to IsMap().
- Fixed: Regression with default COM properties.

UDFs:
- Changed: Reduced duplicate code for finding the maximum and minimum value in an array.
- Changed: _ArrayAdd() now uses constants to change addition behaviour and datatype forcing.

- Fixed #2803: _ArrayMinIndex() and _ArrayMaxIndex() failing with 1-dimensional arrays that had 1 element only.

Others:
- Fixed: Removal of related functions.

3.3.13.6 (18th, 2014) (Beta)
AutoIt:
- Changed: Tables now called Maps. IsTable() now IsMap()
- Changed: All Is... functions and UBound() now using internal ByRef optimization.
- Changed: Numerous internal rewrites for Dim, Local, Global, Static. Function param passing. Testing needed!

- Added: Test versions for MapAppend(), MapExists(), MapKeys() - dot notation versions still available for now.

- Fixed: Regression with Dim $var = [1,2] syntax.

UDFs:
- Fixed: Undeclared variable in File.au3 due to internal changes.

3.3.13.5 (17th July, 2014) (Beta)
AutoIt:
- Added: (Internal) Built-in functions can now be made that work in a ByRef way. Lots of new possibilities!

- Fixed: Regression with using subscript access on a non-array variable hard crashing.
- Fixed: Accessing a table within an array, or vice versa caused a hard crash.
- Fixed: Static keyword with tables.
- Fixed: Assigning objects to table elements.

UDFs:
- Fixed #2782: Documentation of various constants.
- Fixed: Syntax error in File.au3 due to internal changes.

3.3.13.4 (15th July, 2014) (Beta)
AutoIt:
- Fixed: Regression with array initialisation in last beta.

3.3.13.3 (15th July, 2014) (Beta)
AutoIt:
- Fixed #2626: ControlGetText(), WinGetText(), WinGetTitle() wrong encoding for some words.
- Fixed: FileCopy() regression from last beta on UNC paths.

UDFs:
- Added: $SS_ENHMETAFILE, $SS_REALSIZECONTROL, $STM_SETICON, $STM_GETICON, $STM_SETIMAGE, $STM_GETIMAGE to StaticConstants.au3.

3.3.13.2 (11th July, 2014) (Beta)
AutoIt:
- Changed: Minimum OS requirements are now Windows XP SP3 and Windows Server 2003 SP2.

- Added #2665: FileCopy() no longer fails when copying EFS files to destinations that don't support encryption.

- Fixed #2743: Hex() crash with invalid len.
- Fixed #2685: HotKeySet() fails to register a Hungarian letter.
- Fixed #2588: Menu/Statusbar location problem.
- Fixed #2471: Bad restore for script using $WS_EX_LAYOUTRTL.
- Fixed #2287: GUICtrlSetState() $GUI_ONTOP not set.
- Fixed #1573: TCPTimeout for Connect.
- Fixed #2596: TCPUDP @error values to be unique.

Au3Check:
- Fixed: False error report on With statement.

3.3.13.1 (9th July, 2014) (Beta)
AutoIt:
- Added: FileGetAttrib() returns encrypted attribute.
- Added #2365: FileFindNextFile() - information in @extended.
- Added #2647: Return the line count from FileReadToArray() in @extended.

- Fixed: Functions fixed for extended length paths: FileOpen(), FileCopy(), FileMove(), FileDelete().

3.3.13.0 (7th July, 2014) (Beta)
AutoIt:
- Added #2761: AutoIt.chm title versioning.

- Fixed #2755: SetError() doc precision.

UDFs:
- Changed: _SQLite 3.8.4.3 -> 3.8.5.0.

- Added #2732: ObjName() doc example.
- Added #2751: Regions and GUI control tip labels to the control sample example.
- Added #2764: _WinAPI_ShellExecuteEx(), _WinAPI_GetPriorityClass() doc constants.

- Fixed #2734: Incorrectly setting the wrong member.
- Fixed #2736: DriveGetType() and _WinAPI_SetWindowPos() doc Constants.au3 to AutoItConstants.au3.
- Fixed #2737: _WinAPI_ShellGetStockIconInfo() doc $SIID_ constants.
- Fixed #2744: Requires IE5 removal as Min OS = Windows XP.
- Fixed #2741: _WinAPI_DrawThemeEdge() constants reference in BorderConstants.au3.
- Fixed #2740: _WinAPI_IsProcessorFeaturePresent() doc $PF_* constants.
- Fixed #2739: _WinAPI_SetLocaleInfo() doc $LOCALE_* constants.
- Fixed #2738: _WinAPI_ShellRestricted() doc $REST_* constants.
- Fixed #2745: Mismatch of supported operating system with the official AutoIt site.
- Fixed #2746: IE6Example.htm refreshing and associated COMRef.htm.
- Fixed #2749: Bad Include in COM example.
- Fixed #2748: Variable used before declaration.
- Fixed #2758: _ArrayPermute() with multicharacter delimiter.

Au3Check:
- Fixed: False error report on COM variable.

3.3.12.0 (1st June, 2014) (Release)

3.3.11.7 (Unreleased) (Beta)
AutoIt:

UDFs:
- Fixed: Incorrect default style for _GUICtrlMenu_CreateMenu() and _GUICtrlMenu_CreatePopup() and changed documentation to use constant values.

3.3.11.6 (30th May, 2014) (Beta)
AutoIt:
- Changed #2718: SplashOff doc example.

- Fixed #2717: Appendix constants page precision about Inet Constants.

UDFs:
- Added: _Array1DToHistogram(). (thanks jchd)
- Added #2702: _ArrayTranspose() set @error to 2 if not Array.
- Added #2726: Group ID to return array for _GUICtrlListView_GetGroupInfoByIndex().

- Fixed #2701: _ArrayTranspose() doc for 1D Array.
- Fixed #2706: $tagWINDOWINFO bad struct.
- Fixed #2718: SplashOff doc example.
- Fixed: _GUICtrlListView_GetView() and _GUICtrlListView_SetView() were using 0 for detailed view and 1 for large icon view, when it's the opposite way around. THIS IS A SCRIPT BREAKING CHANGE.

Au3Check:
- Fixed: Undetected errors.

Others:
- Fixed #2725: AutoIt3.chm printing example.

3.3.11.5 (1st May, 2014) (Beta)
AutoIt:
- Fixed #2648: FileSaveDialog() not adding extension when user types manually.

UDFs:
- Changed: _FileReadToArray() now returns a 1D/2D array depending on parameters used.

- Fixed: sqlite3.* downloading if running in Admin mode.
- Fixed #2693: _GUICtrlListView_GetItemTextArray() return value doc.
- Fixed #2697: missing $GW_ENABLEDPOPUP constant.
- Fixed #2698: _ArrayAdd() wrong return value.
- Fixed #2699: _ArrayAdd() 6th parameter doc.
- Fixed: _ArraySearch() searching backward.
- Fixed #2700: _GUICtrlRichEdit_SetCharBkColor() not at insertpoint.

Au3Check:
- Fixed #2612: Function reference ByRef.

3.3.11.4 (7th April, 2014) (Beta)
UDFs:
- Removed: http://api.exip.org/?call=ip from _GetIP() as the site was taken offline.
- Removed: _WinAPI_GetUDFVersion() as all UDFs share the same version number as the AutoIt version they are shipped with.

- Changed: $DOW_* constants to $DMW_*.
- Changed: Reverted re-write of _PathFull() and _PathGetRelative().
- Changed: Re-wrote Array UDF to add 2D support and add some functions. THIS IS A SCRIPT BREAKING CHANGE.
- Changed: Excel UDF was re-written. Functions and/or parameters have been renamed, removed or added. THIS IS A SCRIPT BREAKING CHANGE.
- Changed: _SQLite 3.8.2.0 -> 3.8.4.3.
- Changed: 5 second timer in _GetIP() to 5 minutes, due to the requirements of http://www.whatismyipaddress.com.

- Added: _SQLite_SQLiteExe() download sqlite3.exe when needed.
- Added: http://bot.whatismyipaddress.com as an IP disovery site to _GetIP().

- Fixed #2660: Button on GUI example.
- Fixed: _IECreate() disable use of Windows Key.
- Fixed #2689: When $bCursor in _ScreenCapture_Capture() was set to True and the PC was locked.

Others:
- Fixed #2677: AutoIt.chm Installdir.htm reference.
- Fixed #2676: AutoIt.chm Installdir.htm \Sqlite reference.

3.3.11.3 (15th January, 2014) (Beta)
AutoIt:
- Fixed #2613: AutoIt crashes whenever an array value returned from a WMI query is null.
- Fixed #2309: Bad conversion of VT_BSTR COM variants when the referenced string is null.

UDFs:
- Changed: Re-wrote _PathFull() and _PathGetRelative() to use native WinAPI functions.
- Changed: Re-wrote _FileWriteToLine() to use FileReadToArray().
- Changed: Re-wrote _DateDayOfWeek() which can now return the days of the week of the user's locale.
- Changed: _FileReadToArray() now returns a 1D/2D array. THIS IS A SCRIPT BREAKING CHANGE.
- Changed: Re-wrote _DateToMonth() which can now return the months of the user's locale.

- Added: 5 second timer to _GetIP() between each public IP retrieval. This is to reduce overloading the IP discovery sites.
- Added: $STR_REGEXP* contants in StringConstants.au3 for StringRegExp().

- Fixed: _INetSmtpMail() SmtpServer IPaddr checking.
- Fixed #2618: _StringBetween() behaviour when $sStart and $sEnd are identical.

3.3.11.2 (5th January, 2014) (Beta)
AutoIt:
- Fixed #2316: PowerPoint COM event handler initialization error.
- Fixed: FileSelectFolder() uses the parent parameter.
- Fixed #2512: ObjName() crash.

UDFs:
- Added: Example for _WinAPI_SystemParametersInfo().

- Fixed: UBound() default was regarded as $UBOUND_DIMENSIONS (0) and not $UBOUND_ROWS (1).
- Fixed: _FileListToArrayRec() array concatenation bug.

AutoIt3Help:
- Changed: Version number to 1.0.0.6.

- Added: Windows activation when already open.

Others:
- Changed: Help file syntax variable names to a standard naming convention for easier understanding and consitency in the calltip syntax files.

3.3.11.1 (4th January, 2014) (Beta)
AutoIt:
- Fixed: Stack overflow with deep nested includes.
- Fixed: FileSelectFolder() not working correctly with title and root parameters.
- Fixed: StringIsSpace() for null characters.
- Fixed #2478: Assign() and Eval() do not restrict variable names.

UDFs:
- Changed: Constant variables are now used in the UDFs rather than their value.

3.3.11.0 (3rd January, 2014) (Beta)
AutoIt:
- Changed: PCRE regular expression engine updated to 8.34.

- Added #2557: Send() special control strings will no longer treat 0 repetitions as 1. No keys will be sent.
- Added #2489: HttpSetUserAgent() now returns the previous user agent string.
- Added #2481: FileSelectFolder() will use the Windows Vista style if available.

- Fixed #2562: StringRegExp() & Null character.
- Fixed #2581: Dec() wasn't working correctly for flags 0, 1, 2.
- Fixed #2568: StringStripWS() and StringIsSpace() now treats null as a whitespace character.
- Fixed #2566: "override" cursor in GUISetCursor() fails inside client area.
- Fixed #2573: "override" cursor in GUISetCursor() fails outside of client area.

UDFs:
- Removed: Usage of Call() in _FTP_ProgressDownload(), _FTP_ProgressUpload() and _SQLite_Startup(). See documentation for changes to $hFunctionCall and $hPrintCallback parameters. THIS IS A SCRIPT BREAKING CHANGE.

- Added: Error checking to _ArrayDelete() when $iElement was out of bounds.

Others:
- Added: Keywords and Macros to the Notepad++ autoit.xml file.

3.3.10.2 (30th December, 2013) (Release)
AutoIt:
- Fixed #2576: All AutoIt EXEs and tools not working on older Athlon XP processors due to SSE compiler options.

Aut2Exe:
- Fixed #2580: Aut2Exe failing to run multiple times on Windows XP prior to SP3.

Others:
- Fixed #2571: Notepad++ autoit.xml was incorrectly formatted and not displaying calltips.

3.3.10.1 (28th December, 2013) (Release)
Aut2Exe:
- Fixed: Aut2Exe was leaving a temporary file around.

UDFs:
- Added: Error checking to _GDIPlus_GraphicsDrawString() in case _GDIPlus_GraphicsMeasureString() fails to return an array.

- Fixed: Incorrect function being called for _GDIPlus_BitmapCloneArea().
- Fixed: _ArrayDisplay() user function call and range bug.

3.3.10.0 (23rd December, 2013) (Release)

3.3.9.26 (Unreleased) (Beta)
UDFs:
- Changed: _ArrayDisplay() - dialog layout changed.

3.3.9.25 (17th December, 2013) (Beta)
AutoIt:

UDFs:
- Changed: _SQLite 3.8.1.0 -> 3.8.2.0.
- Changed: _ArrayDisplay() - new function with new functionalities.
- Changed: GUIListView() - new _Delete* functions.

- Fixed #2550: _GUICtrlComboBox_GetEditText() struct sizing.

3.3.9.24 (7th December, 2013) (Beta)
AutoIt:
- Fixed: Regression caused by the fix to 2541 in previous beta.

3.3.9.23 (28th November, 2013) (Beta)
AutoIt:
- Fixed #2518: Static keyword not working correctly.
- Fixed #2541: Accessing object methods or properties on a non-object when error handler is installed.
- Fixed: StringStripCR() and StringAddCR() not working with strings that contain nulls.

UDFs:
- Changed: $INTERNET_FLAG_NO_CACHE_WRITE default value for _FTP_ListToArray*().

- Added #2540: _ArrayDisplay() can copy Header and Row.
- Added: _GDIPlusTextureCreateIA().

- Fixed #2539: _ArrayUnique() doc precision.
- Fixed #2521: Removed _IEFormElementSetValue[5].au3 example.
- Fixed: _SQLite_...() running in X64 Mode.
- Fixed: _SQLite_Startup() parameter checking and doc.

AutoIt3Help:
- Changed: Version number to 1.0.0.5.

- Fixed #2519: Wrong page opening if launch without parameter.

3.3.9.22 (5th November, 2013) (Beta)
AutoIt:
- Added: @OSVersion WIN_2012R2 support.

- Changed: upx.exe from 3.09 -> 3.91.

- Fixed: Regression with ^ in previous beta.
- Fixed #2461: GUICtrlSetImage() doesn't handle certain types of .gif file.
- Fixed #2167: $WS_EX_LAYOUTRTL and GUICtrlCreateMenu causes bug.
- Fixed #2468: #OnAutoItStartRegister function doc precision.
- Fixed #2315: @OSVersion WIN_2012 support.
- Fixed #2171: TCPTimeout inconsistent.

UDFs:
- Added: _GDIPlus_ParamSize() to handle X64 compatibility.
- Added #2426: TrayConstants.au3 for use with Tray functions. See related function documentation for more details.
- Added: more GDIPlus functions and their respective documentation and example.
- Added #2506: _GUICtrlListView...() doc formating + links.
- Added #2508: doc formating + links.

- Changed: _SQLite 3.8.0.0 -> 3.8.1.0.
- Changed: Swapped PixelFormat with Stride parameter for the _GDIPlus_BitmapCreateFromScan0() function.
- Changed: $tagGDIPENCODERPARAMS using $tagGDIPENCODERPARAM.
- Changed: _GDIPlus...() using integer or float for positioning.
- Changed: Modified _ArrayUnique() with a faster version and improved error checking.

- Removed: $tagGDIPPENCODERPARAMS (duplicate of $tagGDIPENCODERPARAMS).
- Removed: _GDIPlus...F() beta functions as they can be handle by corresponding without F.

- Fixed #2460: _StringBetween() $sStart = $sSend.
- Fixed #2459: _StringBetween() doc Description info.
- Fixed #2465: _IEPropertyGet() - out of date links in "ClientInfo Properties".
- Fixed: _GDIPlus_...() functions compatible with X64.
- Fixed #2486: _GUICtrlRichEdit_GetFont() bad multi Font return. Solved also #2485.
- Fixed #2492: _GUIToolbar_... doc example.
- Fixed #2493: _GUIToolbar_Get/SetMetrics() examples.
- Fixed #2494: _GUIToolbar_Get/SetHotItems() examples.

3.3.9.21 (11th September, 2013) (Beta)
AutoIt:
- Added #2433: Monospaced in Fonts appendix.

- Changed: Documentation for StringRegExp() re-written by jchd.
- Changed: Default newline character for PCRE regexes changed to ANYCRLF.

- Fixed #2066: DllStructSetData() returning int64 instead of int32 in some cases.
- Fixed #2427: ControlTreeView() does not used Option2.
- Fixed #2455: Mouse Cursor not changing on resizable GUIs.
- Fixed #2105: RegRead() and DWORD types incorrectly stored as double.
- Fixed #2299: GUI Button Text Left-Justify for colored button.
- Fixed #1954: ListViewItem returns 0 (failure) even though it populates the ListView.
- Fixed #2152: X^2 Not Working in Hex().
- Fixed #1870: @GUI_DRAGFILE.

UDFs:
- Added: some more GDI+ functions and examples.

3.3.9.20 (6th September, 2013) (Beta)
AutoIt:
- Fixed #2405: Documentation bug for FileGetVersion() and compiled scripts.
- Fixed #2314: Cursor flickers when moving over certain GUI controls.

AutoItX:
- Added: AutoItX3.Assembly.dll - a .NET Assembly wrapper for the DLL.
- Added: AutoItX3.PowerShell.dll and AutoItX3.psd1 - a set of PowerShell CmdLets.
- Added: DLL Import: AU3_WinGetPos.
- Added: DLL Import: AU3_ControlGetPos.
- Added: DLL Import: AU3_MouseGetPos.
- Added: DLL Import: AU3_WinGetClientSize.
- Added: DLL Import: AU3_WinGetCaretPos.
- Removed: DLL Imports: AU3_WinGetPosX, AU3_WinGetPosY, AU3_WinGetPosWidth, AU3_WinGetPosHeight.
- Removed: DLL Imports: AU3_ControlGetPosX, AU3_ControlGetPosY, AU3_ControlGetPosWidth, AU3_ControlGetPosHeight.
- Removed: DLL Imports: AU3_MousePosX, AU3_MouseGetPosY
- Removed: DLL Imports: AU3_WinGetClientSizeWidth, AU3_WinGetClientSizeHeight.
- Removed: DLL Imports: AU3_WinGetCaretPosX, AU3_WinGetCaretPosY.
- Removed: DLL Imports: AU3_CDTray, AU3_BlockInput.
- Removed: COM Methods: CDTray, BlockInput.
- Removed: All registry functions. The support was limited and the host language will certainly have registry functions.
- Removed: All Ini file functions. As per registry functions.

UDFs:
- Changed: _SQLite 3.7.17.0 -> 3.8.0.0.

3.3.9.19 (24th August, 2013) (Beta)
AutoIt:
- Changed: Default newline character for PCRE regexes changed from LF to CRLF.
- Changed: PCRE_UCP option is no longer used by default in regexes.

UDFs:
- Changed: _EventLog__ @error values in the respective documentation.

AutoItX:
- Added: AutoItX3_PS.dll - A PowerShell Cmdlet wrapper for AutoItX.
- Added: Visual Studio 2010 C++ Project files (easy to use in 2010 or later).

- Changed: Renamed AutoIt3.h to AutoItX3_DLL.h.

- Removed: Removed DevC files and Visual Studio 6 files.
- Removed: ANSI versions of Send/WinWait functions from the native DLL.

- Fixed: AutoItX3.lib files weren't correctly being copied to the install file.

Others:
- Added: Direct links to functions, keywords and macros in the help file.

- Changed: Merged both the AutoIt and UDF help files into a single chm file.

3.3.9.18 (20th August, 2013) (Beta)
AutoIt:
- Fixed #2384: UDPRecv() and TCPRecv() not setting @error correctly in some instances.
- Fixed #2367: Sometimes two COM objects wouldn't be classed as equal during comparisons.

UDFs:
- Added: GDIPlus functions and their respective documentation and example.

- Changed: _FileWriteToLine() can read a file with various line endings (not recommended).
- Changed: Re-wrote _FileReadToArray() to use the native function FileReadToArray() when $iFlag is set to 0.

- Removed: Documentation and example for _StringReverse(). Scripts should be updated to use the native function StringReverse() instead.

3.3.9.17 (15th August, 2013) (Beta)
AutoIt:
- Added: StringReverse() - a UTF16 compatible string reversal function.
- Added: FileReadToArray() - native version of _FileReadToArray().

- Changed: Some misc internal rewrites in array assignment mean that some large internal array assignments (StringRegExp() for example) may be slightly quicker. Maybe.

- Fixed #2366: For loop not working as expected.

Others:
- Added: Sublime Text AutoIt.tmLanguage file to the editors folder. This contains a list of up to date functions.

- Fixed: StringRegExpGUI missing from the help file index menu.

3.3.9.16 (10th August, 2013) (Beta)
AutoIt:
- Fixed: DriveGetType() was incorrectly reporting SSD on Windows XP.
- Fixed #1024: GUICtrlSetTip() for tabitems sets incorrectly in certain situations.

UDFs:
- Added: Constants for DriveGetType() and StringSplit(). See related function documentation for more details.
- Added: InetConstants.au3 for use with Inet functions. See related function documentation for more details.

- Changed: _FileListToArrayRec() to use functions in the Array UDF.

- Fixed: _ArrayTranspose() would crash with one dimension and 4096 elements or greater.
- Fixed #2378: BITMAPV4HEADER and BITMAPV5HEADER Structures using incorrect array values.

3.3.9.15 (4th August, 2013) (Beta)
AutoIt:
- Added: DriveGetType() updated so that it can detect SSD, and also bus types (SATA, USB, etc.).

UDFs:
- Added: Graphic SmoothingMode constants (GDIPlusConstants).
- Added: _GDIPlus_CustomLineCapCreate(), _GDIPlus_BitmapCreateFromScan0() functions.

- Changed: _GDIPlus_GraphicsGetSmoothingMode(), _GDIPlus_GraphicsSetSmoothingMode() functions.

3.3.9.14 (2nd August, 2013) (Beta)
AutoIt:
- Changed: IsAdmin() function changed to be based on token membership. Maybe more acurate for Sandbox type environments.
- Changed: ShellExecute() will return the process ID.

UDFs:
- Fixed: _GUICtrlListView_InsertItem() would fail to insert -1 if passed as the $sText parameter.
- Fixed #2371: _PathSplit() incorrectly working with relative paths.

Others:
- Added: Notepad++ autoit.xml file to the editors folder. These contains a list of up to date functions.

- Changed: Editor syntax files now include UDF functions.

3.3.9.13 (27th July, 2013) (Beta)
AutoIt:
- Fixed: Some expressions were not generating error messages. For example: MsgBox(0, "", UnknownFuncName)
- Fixed #2075: GUICtrlSetImage changes icon position on resizable window.
- Fixed #1667: WinMove() Child window.
- Fixed #2367: beta regression on retrieving twice same $oIE.document (NOTE: this was actually introduced in 3.3.8.0).

- Changed: SciTe compiled in high dpi aware mode. Looks epic on a retina resolution display.

- Removed: PluginOpen() and PlugInClose() removed to due to not being used and never having progressed past the experimental stage.

3.3.9.12 (24th July, 2013) (Beta)
AutoIt:
- Added: @LocalAppDataDir for local AppData (@AppDataDir is the roaming location).

- Fixed: 3rd time lucky changes for Windows XP RTM compatability. (Un)RegisterTypeLibForUser loaded dynamically.
- Fixed: Regression in WinGetClassList() with missing line feeds.
- Fixed: Better operator precedence handling for ternary operator.

Aut2Exe:
- Changed: Aut2Exe makes all resource changes (version info, manifest, etc) in a single pass. Should be quicker.

UDFs:
- Added: _FileListToArrayRec now accepts the Default keyword to use default parameters.

- Changed: _ReplaceStringInFile() will only overwrite the file if instances of the replacement were found.

3.3.9.11 (22nd July, 2013) (Beta)
AutoIt:
- Fixed #2311: Wrong handling of casesense parameter in StringReplace()
- Fixed #2361: RegRead() doesn't read REG_QWORD values.
- Fixed #2362: WinGetText() and ControlGetText() would sometimes give invalid results due to the target application's handling of WM_GETTEXT.

Au3Info:
- Fixed: Same text bug as #2362.

3.3.9.10 (21st July, 2013) (Beta)
AutoIt:
- Changed: #NoAutoIt3Execute option replaced with #pragma compile(AutoItExecuteAllowed, true). Default is false.

- Fixed #2286: GUICtrtlGetState() without a controlID parameter runs but aborts AutoIt.
- Fixed #2350: Strange issue when using $SS_ETCHEDVERT and $SS_ETCHEDHORZ.

Aut2Exe:
- Changed: Compiling uses a subfolder of %localappdata% instead of %temp% for temporary files. Hopefully this fixes warnings from over-zealous AV.

3.3.9.9 (19th July, 2013) (Beta)
AutoIt:
- Added: FuncName().

- Fixed: Subtle bugs with Ping()

Aut2Exe:
- Changed: FileInstall() files are now stored in the Resources section along with the script. No overlays are used anymore.
- Changed: Default changed to not use UPX.

UDFs:
- Added: Example for _VersionCompare().

- Fixed #2320: Incorrect return values for certain IE functions.

3.3.9.8 (18th July, 2013) (Beta)
AutoIt:
- Added: Documentation for IsFunc().

- Changed: Rewritten some Variant/UserFunction internals.
- Changed: FileCreateShortcut() will automatically convert paths so relative paths will continue to work on Windows 8.

- Fixed: WinXP RTM support should be fixed...again.
- Fixed: Some memory leaks when converting between unusual variant types like Keywords.

UDFs:
- Added #2357: $WM_SIZING back to WindowsConstants.au3, which was removed during the WinAPIEx integration.
- Added #2338: Regular expression pattern matching. See the documentation of _ArraySearch() for more details.
- Added #2340: Optional parameter to _GUICtrlListView_SimpleSort() of whether or not to reverse $vSortSense (previously $vDescending.)
- Added: _FileListToArrayRec() to the UDFs. A recursive file search by Melba23. See the documentation for more details.

- Changed: Re-wrote _StringReverse() by removing the use of msvcrt.dll.
- Changed: Re-wrote _ProcessGetName() for speed enhancements.
- Changed: Re-wrote _PathSplit() by using a regular expression. Contributed by DXRW4E.

- Fixed: _ScreenCapture_Capture() was broken.

- Removed: Documentation and example for _StringEncrypt(). Scripts should be updated to use the Crypt functions instead. Look at _Crypt_EncryptData() for an alternative example.
- Removed: Function headers in the UDFs, as information about the function can be found in the help file, This removal resulted in a 32.23% size reduction to the includes folder (7.01MB ->> 4.40MB).

3.3.9.7 (12th July, 2013) (Beta)
AutoIt:
- Added: @OSVersion supports Windows 8.1
- Added: Regular expressions (PCRE engine) now using the new native 16bit mode and also compiled with UCP/UTF support.

- Fixed #1698: GUICtrlSetLimit(), limit 32767.

- Changed: Lots of helpfile changes/fixes.
- Changed: Default manifest file on AutoIt and compiled exes is set for "AsInvoker" and tagged with compatibility for Vista/Win7/Win8 and Win8.1.

Aut2Exe:
- Added: OS manifest options now include Windows 8.1.

UDFs:
- Added #2354: _ArrayTranspose() to the Array UDF.

- Changed: Array UDF now takes into consideration empty arrays.

3.3.9.6 (10th July, 2013) (Beta)
AutoIt:
- Added: Empty arrays.
- Added: Functions are now first class objects which means variables can "point" to them and the function can be called through the variable.
- Added: Built-in functions that take a callback now be passed directly in addition to the old method of passing as a string. Built-in functions can also be passed now (be careful that the function you pass matches what the caller expects).
- Added: C++ style ternary operators: Local $fResult = ("foo" = "bar") ? True : False.
- Added: Expression as default function parameter.
- Added: With...EndWith can be used on expressions having dot-access.
- Added: Nested "With...EndWith".
- Added: Call calls built-in functions.
- Added: ByRef with Call function.
- Added: Support for more COM VARIANT types.

- Changed: Optional square brackets for array declaration with initialization.
- Changed: Allowing multiple COM Error Handlers. Last one registered and alive gets called.
- Changed: VT_NULL VARIANT converts to Null keyword (previously empty string).
- Changed: upx.exe from 3.08 -> 3.09.
- Changed: PCRE regular expression engine updated to 8.33.
- Changed: Removed Windows 2000 support. Minimum supported OS is now Windows XP RTM / Windows Server 2003.

- Fixed: ReDim allows initialization to non-array.
- Fixed #2166: StringToASCIIArray() and StringFromASCIIArray() did not correctly return an empty string when the start index is greater than the end index.
- Fixed #1901: 32-bit compiled scripts now work from the system32 directory on 64-bit Windows.
- Fixed #2157: ProcessList() would crash if there were more than 512 running processes.
- Fixed #2215: Bad syntax check for default function parameters.
- Fixed #2222: Non-ASCII characters not allowed in object properties/methods.
- Fixed #2235: ProcessGetStats() defaulted to using the current process if an invalid process was specified.
- Fixed #2253: Ping() returns success with no connection.
- Fixed #1498: #RequireAdmin endless loop for disabled UAC.

UDFs:
- Added #2250: DirMove() to the related section of DirCopy().
- Added #2155: Missing documentation for the default working directory of Run/RunWait.
- Added #2224: Optional parameter to _FileReadToArray() to return the array count in the first element.
- Added #2114: Disabling and enabling the redrawing message to increase the speed of displaying _ArrayDisplay(). (Only noticeable on large arrays.)
- Added #2120: Disabling and enabling the redrawing message to increase the speed of deleting items with _GUICtrlListView_DeleteAllItems(). (Only noticeable when deleting many items in a ListView.)
- Added #966: Optional parameter to return the full path of the file/folder in _FileListToArray().
- Added #2193: _StringTitleCase(), to create a title case string.
- Added #2263: _Crypt_GenRandom(), fills a buffer with random data.

- Changed #2117: _FileCountLines() writing to a temporary array to calculate the number of lines in a file.
- Changed: _FileListToArray() to accept the Default keyword to use the default parameters.
- Changed: _FileReadToArray() to parse the file using a regular expression. Now various line endings (not recommended) are displayed correctly in the array.
- Changed: Word UDF was re-written. Functions and/or parameters have been renamed, removed or added. THIS IS A SCRIPT BREAKING CHANGE.
- Changed: _Max() and _Min() functions now use the ternary operator.
- Changed: Re-wrote _ReplaceStringInFile() by removing the need to write to a temporary array. (@error values 4, 5 and 6 have been removed, please check the documentation.)
- Changed: Re-wrote _GetIP() for improved efficency and added http://www.myexternalip.com/raw to find the external IP address.
- Changed: _SQLite 3.7.16.1 -> 3.7.17.0.
- Changed: WinAPIEx.au3 split under WinAPI*.au3 + Doc.
- Changed: IE3.au3 v3.0-0 to v3.0-1 (see header info for changes).

- Fixed #2223: Incorrect UDF being referenced in _WordErrorHandlerRegister.
- Fixed #2252: _GUICtrlListView_DeleteAllItems() failed to remove items created using _GUICtrlListView_AddItem() on an AutoIt native listview.
- Fixed #1861: _ArrayDisplay() incorrectly displayed an array when using the $sHeader parameter and the array contained the default separator.
- Fixed: Using non-supported characters in the file prefix for _TempFile().
- Fixed #2186: Documentation of _WinNet_AddConnection()* and $sLocalName. (Use the Null keyword or an empty string, not 0.)
- Fixed #2148: Crash when passing a number instead of a string.
- Fixed #2219: _ExcelReadSheetToArray() would cause AutoIt to hang when reading a protected worksheet.
- Fixed #2242: Unable to write the 0th element in _FileWriteFromArray(). Now the Default keyword is supported for the parameters $iBase and $iUBound, therefore use this instead of the value 0 for default parameters. (Please check the documentation.)
- Fixed #2218: AutoIt crash when using _GUICtrlListView_SetGroupInfo() before _GUICtrlListView_SetItemGroupID() had been called.
- Fixed #1996: _GUICtrlListView_SimpleSort() failed to retain the ItemParam of an item.
- Fixed #1759: Strange listview sort.
- Fixed #2268: _StringReverse() unable to reverse unicode characters.
- Fixed #2298: Failing to detect when EnumDisplayDevices returns 0.
- Fixed: _FileWriteFromArray() failing to pass the $aArray parameter as a constant reference.
- Fixed: $tagREBARBANDINFO not working on XP, due referencing parameters intended for Vista and above.
- Fixed #2305: Reports the wrong width and height of the desktop when using default parameters.
- Fixed #2335: _WinAPI_EnumWindows() and _WinAPI_EnumWindowsPopup() order.
- Fixed #2347: _WinAPI_GetMonitorInfo() wrong data.

- Removed #2174: Explicitly checking if the source and insert strings for _StringInsert() were strings and forcing an @error return value. (@error values 2 and 3 have been removed, please check the documentation.)
- Removed #2187: Forcing _GUICtrlRichEdit_Create() to create a richedit control in a positive position. (@error values 103 and 104 have been removed, please check the documentation.)
- Removed #2172: Select...EndSelect statement from _StringRepeat() and replaced with an If...EndIf as well as optimised the code.
- Removed: Documentation and example for _Iif(). Scripts should be updated to use ternary operators instead. THIS IS A SCRIPT BREAKING CHANGE.
- Removed: _ArrayCreate() from Array.au3.

Au3Check:
- Changed: Optional square brackets for array declaration with initialization.

Au3Record:
- Fixed #2337: Support of non english keyboard.

AutoIt3Help:
- Changed: Manifest resource suggests Windows common controls v6.0.
- Changed: Version number to 1.0.0.3.

AutoItX:
- Fixed: Crash in AU3_PixelSearch when function fails.

3.3.9.4 (9th April, 2012) (Beta)
AutoIt:
- Fixed: Aut2Exe and UPX will now correctly work on compiled scripts with custom icons. This references ticket #2180 but does not close it as more work is needed.

3.3.9.3 (8th April, 2012) (Beta)
AutoIt:
- Added #1191: Explicit size of arrays optional for explicit initialization.
- Added: Array access on expression: StringSplit("a,b", ",")[1].
- Added: Dot access on expression: ObjCreate("Shell.Application").GetSystemInformation("DirectoryServiceAvailable").

- Fixed #1566: Array as its own element issue.
- Fixed #1551: Crash the script when changing array.
- Fixed #2176: DllCallbackRegister crash on x64.

UDFs:
- Added #1158: WinAPIEx integrated (Files-only, no documentation currently).

- Changed: _SQLite 3.7.15.2 -> 3.7.16.1

- Fixed #2162: Documentation link in the IE Management section was broken for _IEFormElementCheckBoxSelect().
- Fixed #2170: _ArrayDisplay() fails handling arrays with no elements.
- Fixed: _PathMake() not appending backslash to the root path.

Au3Check:
- Added: Compound assignment operators for object properties.
- Added: Array access on expression.
- Added: Dot access on expression.

- Changed: Explicit size of arrays optional for explicit initialization.

3.3.9.2 (10th March, 2012) (Beta)
AutoIt:
- Changed: @error is set to 0 for successful object invocation.

- Fixed: ObjCreate() may not set @error in case of failure.
- Fixed #2146: Crash when closing AutoIt when started from a console window.
- Fixed: DLLStruct type forgotten in comparison operations.
- Fixed: "struct" type parameter in DllCall overwrites possibly following parameters.

UDFs:
- Changed: _SQLite 3.7.2.0 -> 3.7.15.2

3.3.9.1 (29th February, 2012) (Beta)
AutoIt:
- Added: Compound assignment operators for object properties.

- Changed: x86 callback function touches FPU stack only when necessary.

- Fixed: ObjGet() forgets non-file monikers since last beta.
- Fixed #1395: DLLCallbacks on Exit.
- Fixed: Ptr() returns null pointer for objects.
- Fixed #1319: Hang at exit for RichEdit user controls.
- Fixed #2138: Fixed GUICtrlRead() on dummy controls was corrupting strings and possibly crashing AutoIt.
- Fixed #1760: #OnAutoItStartRegister ignores single quoted function names.

UDFs:
- Added #2126: Documentation remark about _ArrayDisplay() being able to display a maximum of 65530 items.

- Fixed #2084: Clipboard not being closed if an error occurred with _ClipBoard_SetDataEx().
- Fixed #2125: Writing a 2-dimensional array would only write the first two columns of the array.
- Fixed #2070: Unexpected crash on certain systems when using _GUICtrlStatusBar_GetText().
- Fixed #2132: Documentation of _WinAPI_GetModuleHandle() and the parameter to return the handle of the calling process. (Use the Null keyword, not 0.)

Au3Check:
- Changed: Au3Check version numbers now match AutoIt's.

3.3.9.0 (4th February, 2012) (Beta)
AutoIt:
- Added: Interpreter accepts 64bit hex numbers.
- Added: Keyword Null.
- Added #488: Third parameter for ObjGet() function to specify object instance.

- Changed: upx.exe from 3.07 -> 3.08.
- Changed: ReDim works on arrays declared as static.
- Changed: Run-time errors on objects no longer fatal (execution of the script is not halted).

- Fixed #2067: -2147483648 not stored as int32.
- Fixed #2003: ProcessWaitClose() using too much CPU.
- Fixed #2076: COM VARIANT not correctly set for boolean True.
- Fixed #2015: DllCallbackRegister() mangles floating point numbers under x64.
- Fixed: x64 DllCall not setting double type parameters correctly.
- Fixed: DllCallbackRegister() not returning floating point types correctly.
- Fixed: Different issues with Static keyword.
- Fixed #2078: Error in COM expression.
- Fixed #2073: Unexpected termination with ContinueLoop.
- Fixed #1485: Unexpected termination with ContinueCase.
- Fixed: Crash in ObjEvent() for ByRef object parameters.
- Fixed #2068: Repeated calls to Acos() no longer produce strange results. NOTE: This fix increases the size of AutoIt by approximately 60KB.
- Fixed: ObjGet() fails validating class identifier properly when first parameter for the function is specified.
- Fixed #2111: RunAs() could fail even if a user had the correct permissions to use it.

UDFs:
- Added: _WinAPI_GetProcAddress() function.

- Fixed #2077: hwnd safety check in _GUICtrlRichEdit_Create().
- Fixed #2088: _ArrayDisplay() not handling Default parameters correctly.
- Fixed #2112: "Report Log Window" unresponsive when the script is closed.
- Fixed: _GUICtrlRichEdit_* documentation error return codes.
- Fixed #1970: _FTP_ListToArray() fails to retrieve Dir or File only.

Au3Check:
- Added: Generating error for hex numbers longer than 16 characters.

- Fixed #2113: Object's properties in names of keywords treated as keywords.
- Fixed #2141: #IgnoreFunc was generating an incorrect error.

- Changed: Message case changed to support SciTE inline errors.
- Changed: An error is now generated for non-supported file encodings (Previous behavior was to silently pass the script).

Au3Record:
- Fixed #2083: There is no longer an error about a missing DLL.

3.3.8.1 (29th January, 2012) (Release)

3.3.8.0 (23rd December, 2011) (Release)

3.3.7.23 (12th December, 2011) (Beta)
AutoIt:
- Changed: Dec(), Int() and Number() default conversion behavior improved.
- Changed: Adjustments to the documentation visual style.
- Changed: Various documentation and example fixes.

3.3.7.22 (7th December, 2011) (Beta)
AutoIt:
- Added #2042: @OSVersion returns "Win_8" on Windows 8.

- Changed: Dec(), Int(), Number() have second optional parameter defining non-default behavior.
- Changed: Hex() detects doubles internally and processes them respecting binary format.
- Changed: New visual style for the documentation.

UDFs:
- Added: _WinAPI_StringLenA() and _WinAPI_StringLenW() functions.
- Added: _WinAPI_DuplicateHandle() function.
- Added: _Security__CreateProcessWithToken(), _Security__DuplicateTokenEx() and _Security__SetTokenInformation() functions.
- Added #1925: $WS_EX_LAYOUTRTL control style to the documentation.
- Added #2049: Missing windows message codes to WindowsConstants.au3.

- Fixed #1777: Issues with Security.au3.
- Fixed #2055: replaced DllStructGetPtr with "struct*" throughout UDFs.
- Fixed #2048: Windows constants $WM_RBUTTONDBLCLK and $WM_MBUTTONDBLCLK were named incorrectly.
- Fixed #2034: _GUICtrlMenu_AppendMenu() DllCall type set wrong.
- Fixed #2060: Various documentation errors.

3.3.7.21 (6th November, 2011) (Beta)
AutoIt:
- Fixed: Various documentation typos and grammatical errors.
- Fixed #1982: Crash in FileGetShortName() and FileGetLongName().
- Fixed #2046: DirGetSize("") was returning the size of the working directory root instead of -1 and setting @error.
- Fixed #2037: COM execution slowdown.

- Changed: Parentheses are required when invoking objects after all method names in order to have correct internal handling.
- Changed: Hex() default sizing for pointer types.

UDFs:
- Fixed #2004: Functions that accept Control ID/Handle were not correctly documented.
- Fixed #1951: Missing parameter in documentation for _SQLite_SQLiteExe().
- Fixed #1442: File handle can now be passed to _FileWriteLog().

3.3.7.20 (22nd October, 2011 (Beta)

AutoIt:
- Added: "struct" as DllCall and InterfaceDispatch data type.

- Fixed #1519, #1694: Int() and Number() returning wrong.

- Changed: Dec() and Hex() work with 64bit integers.

- Removed: Int() and Hex() no longer set @error.

3.3.7.19 (15th October, 2011 (Beta)

AutoIt:
- Added: "clsid" InterfaceDispatch data type.

- Changed: "str" and "wstr" InterfaceDispatch data types treated as true ByRef types.
- Changed: COM Error handler event has precedence in execution over events fired by other objects.
- Changed: COM Error handler passes error object as first parameter to user defined error function.
- Changed: ObjEvent() has new example and more detailed explanation.
- Changed: COM Error handler properties are read-only.

- Removed: COM Error object no longer exposes methods Raise() and Clear().

3.3.7.18 (26th September, 2011 (Beta)

AutoIt:
- Added #1947: CHM help files now have a Forward button.
- Added #1813: Better cross referencing for Int() and Mod().
- Added: Something resembling complete documentation for ObjCreateInterface().

- Fixed: IE click action on a form submit button works again.

UDFs:
- Added #1890: Better cross-referencing for _WinAPI_GetParent() and _WinAPI_GetAncestor().

- Fixed #1975: IE.au3 used old names returned from ObjName(). Fixes _IELoadWait() hang.
- Fixed #1933: URL used in _GetIP() was out-of-date.
- Fixed #2001: Example for _GUICtrlToolbar_SetButtonText() did not work correctly.
- Fixed #1994: Documentation for _ScreenCapture_Capture() and _ScreenCapture_CaptureWnd() incorrectly stated the functions had no return value. Moved information from Remarks up to Return area.
- Fixed #1948: Documentation for _GUICtrlButton_SetImage() had the wrong description.
- Fixed #1985: _IECreate() now ensures focus is given to the document when an about URI is loaded (such as about:blank). IE9 gives focus to the URL bar which can cause later issues setting focus to elements.

- Changed: _IEFormElementSetValue() examples #3 removed (login to Hotmail).
- Changed: _IEFormElementSetValue() examples #4 and #5 (now #3 and #4) use the text input instead of the file input. The file input is read-only on IE9 so the Send()/ControlSend() produced no results.

3.3.7.17 (20th September, 2011) (Beta)
AutoIt:
- Added: DllCallAddress() now has an example.
- Added: Example and incomplete documentation for ObjCreateInterface().

- Fixed #1660: Crash on Mod() with a divisor of 0.
- Fixed: COM methods no longer change the type of AutoIt variables.

UDFs:
- Fixed #2009: Incorrect styles listed in _GUICtrlToolbar_Create().
- Fixed #1009: SQLite library needs to support a user-defined callback for diagnostic messages instead of hard-coding ConsoleWrite().

Au3Check:
- Fixed #1934: #forceref after a single-line If statement ending with a single keyword would cause an incorrect error to be displayed.

3.3.7.16 (20th September, 2011) (Beta)

- This version was released but immediately pulled due to an error. See 3.3.7.17 for changes.

3.3.7.15 (11th September, 2011) (Beta)

- Added: DllCallAddress().
- Added: ObjCreateInterface() (By trancexx).

- Fixed #1975: IE object does not recognized as valid object type.

3.3.7.14 (10th July, 2011) (Beta)

- Fixed: Bad change to IE.au3 made in 3.3.7.8
- Fixed #1956: 3.3.7.10 COM error getting reference to document in frame.
- Fixed: Attempts to use values for COM OUT parameters trapped.

3.3.7.13 (6th July, 2011) (Beta)

- Fixed: ObjName() crash introduced in 3.3.7.12.

3.3.7.12 (6th July, 2011) (Beta)

- Added: Additional flags added to ObjName(). (Plus rewrite of ObjName() from trancexx)
- Fixed: COM regression from previous beta.

3.3.7.11 (4th July, 2011) (Beta)

AutoIt:
- Changed: PCRE updated to 8.12.
- Added: COM support for pure "OUT" parameters.

- Fixed: Potential memory leak in COM error event code.

UDFs:
- Fixed #1946: _WordCreate Error.

3.3.7.10 (14th June, 2011) (Beta)
- Fixed #1565: Arrays as object properties; memory leak. (trancexx)
- Fixed: ObjCreate() memory leak when using a remote computer. (trancexx)
- Fixed #865: winhttp.winhttprequest.5.1 ObjEvent unhandled exception. (trancexx)
- Fixed: Remote COM bug caused by incorrect CoCreateInstanceEx() parameter. (trancexx)

3.3.7.9 (6th June, 2011) (Beta)
- Fixed #1658: COM / OLE object access causes error code 80020003 - member not found.
- Fixed #1410: Using Pointer type with COM-object throws error. (thanks trancexx)

3.3.7.8 (2nd June, 2011) (Beta)
AutoIt:
- Fixed #1908: ObjName() returns empty string for HTMLDocument with IE9.

UDFs:
- Fixed #1859: Bug in _WeekNumberISO().

3.3.7.7 (31st May, 2011) (Beta)

AutoIt:
- Fixed #1586: DllStructSetData(char, 1, string-with-NUL-character), junk data(?).
- Fixed #1633: Second AdlibRegister function starts at once when first function is too slow.

Au3Info:
- Added: Option "Use Spy++ control detection logic" toggle added to Au3Info (this was the mode always used in recent
  releases, but the very old method that used to be used is useful in certain applications (for example, putty.exe).
- Fixed #1746: Option "Use Spy++ control detection logic" toggle added to Au3Info.

Misc:
- x64 installer options tweaked.

3.3.7.6 (29th May, 2011) (Beta)
- Fixed: Include parsing bug introduced in 3.3.7.3
- Fixed: GUICtrlCreateLabel() related text sizing bug when no height was used.

3.3.7.5 (28th May, 2011) (Beta)
- Fixed: StringFormat memory error introduced in 3.3.7.3.

3.3.7.4 (28th May, 2011) (Beta)

- Fixed: More DllStruct alignment fixes and crash.
- Fixed: All VC10 Code Analysis warnings fixed. Check for subtle bugs.

3.3.7.3 (27th May, 2011) (Beta)

- Fixed: More DllStruct alignment fixes.

UDFs:
- Fixed #1933: _GetIP() is outdated and could possibly fail.

3.3.7.2 (25th May, 2011) (Beta)
- Added: Struct/EndStruct in DllStructCreate() to solve X86/X64 data alignment.

- Changed: Compiling with VC10. Added workarounds for Win2000/XP RTM to allow execution of AutoIt, Aut2Exe, Au3Info, Au3Check and AutoItHelp.

- Fixed #1860: DriveStatus Returns Ready with blank value.
- Fixed #1854: StringIsFloat returns 1 on non float numbers.
- Fixed #1910: Please change $TTN_GETDISPINFO to $TTN_GETDISPINFOW.
- Fixed #1844: SplashTextOn crops variable when used with opt 32 and @CRLF / @LF.
- Fixed #1932: Uninstaller, windows-register, App Paths. (+beta).
- Fixed #1929: SetMenuColor() does not work on 64bit OS.
- Fixed #1479: X64 ListView WM_NOTIFY Message.

UDFs:
- Fixed #1920: Script crashes with error reported in Security.au3 at line 85.
- Fixed #1895: Bugs in _GUIScrollBars_Init().
- Fixed #1891: _ArrayDisplay() (......,i$iTranspose,...) wrong description.

3.3.7.1 (23rd May, 2011) (Beta)
- Fixed: Some files not compiled with static library switches.

3.3.7.0 (23rd May, 2011) (Beta)
AutoIt:
- Fixed #1040: _ScreenCapture_Capture(): GDI object leak with cursor capture.
- Fixed #1599: TraySetItemText() regression for default menu item.
- Fixed #1282: WinMove before GUICtrlSetPos during GUICreation.
- Fixed #1397: Bad HotKeySet() not detected on keyboard as Russian one.
- Fixed #1531: default txtcolor for iput edit list combo updown with black theme.
- Fixed #1617: GUICreate failure after GUIDelete can lead to a loop on Autoit exit.
- Fixed #1596: GUICtrlSetPos() default = no change.
- Fixed #1626: TCPRecv()/TCPSend() doc about Unicode transmission.
- Fixed #1653: Doc for WM_KEYLAST Windows 2000 message.
- Fixed #1669: StringRegExpReplace() doc about doubling of "\" in replace string.
- Fixed #1673: WinGetProcess() doc example.
- Fixed #1677: Invalid ContinueLoop with multiple levels.
- Fixed #1684: FileRead() binary read memory allocation error.
- Fixed #1685: BitRotate() shift parameter.
- Fixed #1734: GUICtrlCreateAvi() crash with negative subfield.
- Fixed #1923: Memory consumption while FileOpen/FileClose.
- Fixed #1883: IsHWnd(), Return Value. (Nitpick: Value = Bool).

AutoItX:
- Fixed #1686: AU3_PixelSearch crashes.

UDFs:
- Added: _DebugSetup() can report to a Notepad Window.
- Added #1371: Allow Default keyword in _TempFile().
- Added #1527: Test example to have doc example working.
- Added #1636: _Security__LookupAccountSid() for Remote Systems.
- Added #1569: _ArraySearch() $iPartial (->$iCompare) extended to match on variables of same type.
- Added #1557: VK_xBUTTON in Constants.au3.

- Fixed #1542: _DebugSetup() closing when use with GUI handling events.
- Fixed #1549: _SQLite_Escape() crash for strings > 64K (> 3.3.0.0).
- Fixed #1517: _GUICtrlListView_SimpleSort() with checkbox.
- Fixed #1588: AutoIt3.exe stay active for all processes using the Window report.
- Fixed #1615: _GUICtrlTreeView_SetStateImageIndex() with index = 0.
- Fixed #1620: _DebugOut() or _DebugReportVar() containing '.
- Fixed #1513: Allow _GUI...() to use notification callback (LPSTR_TEXTCALLBACK).
- Fixed #1608: _Crypt_EncryptFile() for file >1Mb.
- Fixed #1644: _INetMail() with Windows Live mail.
- Fixed #1453: _Net_Share_ShareCheck() return always 0.
- Fixed #1664: _GUICtrlTab_GetItem() does not return text.
- Fixed #1671: _WinAPI_WideCharToMultiByte() doc.
- Fixed #1672: _WinAPI_GetObject() reference ANSI version.
- Fixed #1665: _ScreenCapture_CaptureWnd() when running with Aero theme.
- Fixed #1689: _Debug...() cannot be obfuscated.
- Fixed #1712: _FileWriteFromArray() crash on array.
- Fixed #1754: _PathFull() optional parameter doc.
- Fixed #1756: _GDIPlus_Startup() Flaw on error.

- Changed: _SQLite 3.6.22 -> 3.7.2.0

Au3Check:
- Added: #forcedef directive to force var definition as after Assign().
- Added: -w 7 to check ByRef parameter passing.

- Fixed: Const Enum wrong ERROR.
- Fixed: Global declared in func not detected.
- Fixed #1051: no ERROR if keyword not followed by a separator as Local$a.

3.3.6.1 (16th April, 2010) (Release)
AutoIt:
- Fixed #1515: FileOpen still opening in exclusive mode in some situations.

3.3.6.0 (7th March, 2010) (Release)

3.3.5.6 (28th February, 2010) (Beta)
AutoIt:
- Fixed: StringRegExp() functions were accidentally removed.

3.3.5.5 (28th February, 2010) (Beta)
AutoIt:
- Fixed #1475: TrayItemSetState($Value, $Tray_Checked) incorrectly enables a disabled TrayItem.
- Fixed: StringToASCIIArray() was incorrectly truncating UTF-16 values at 8 bits.

UDFs:
- Fixed #1445: Documentation updated for _MemGlobalFree().
- Fixed #1469: _GDIPlus_BitmapCloneArea() documentation updated.
- Fixed #1466: _GUICtrlEdit_GetLine() returns an unexpected character.
- Fixed #1487: _DateToDayOfWeekISO() returned 0-6 but should be 1-7 where Monday = 1.

3.3.5.4 (13th February, 2010) (Beta)
AutoIt:
- Changed: FileWriteLine() performance improved.

- Added: ControlCommand() "SendCommandID" - used to send WM_COMMAND Control ID messages. Allows the
  automation of ToolBarWindow32 controls (amongst others). For example, the "Back" button of
  Internet Explorer. Use Au3Info to get the Command ID from the ToolBar tab.

- Fixed #1458: Inet sizes were capped to 32-bits.
- Fixed #1459: Hard crash when too much recursion is used.
- Fixed #1464: Regular expressions with a single character * pattern were stopping after the first null match.
- Fixed #1463: StringToASCIIArray() working incorrectly with UTF8 characters.

Au3Info:
- Fixed #1391: ToolbarWindow32 info only showing the first toolbar.

- Changed: Better identification of the control under the mouse (again...)

UDFs:
- Fixed #1441: _GUICtrlRichEdit_GetText() using wrong buffer length.
- Fixed #1446: _ScreenCapture_Capture() was using height/width of 1 pixel less.

3.3.5.3 (6th February, 2010) (Beta)
AutoIt:
- Fixed: Regression in FileOpen() where it wasn't allowed to open files in read mode if they were already open in write mode.
- Fixed #1449: GUICtrlDelete() not working for GUICtrlCreateDummy() types.
- Fixed: Error loading on Windows XP due to previous RegDelete() fix.

Au3Info:
- Fixed #1444: Controls in applications like RegEdit were left highlighted.

- Changed: Better identification of the control under the mouse.

UDFs:
- Fixed #1454: StringBetween() not working correctly.

3.3.5.2 (6th February, 2010) (Beta)
AutoIt:
- Fixed #1448: #OnAutoItStartRegister did not work in compiled scripts.
- Fixed #961: RegDelete() was not working properly on 64bit keys when using the 32bit version of AutoIt and HKLM64.

AutoItX:
- Fixed: Missing .lib files readded.

UDFs:
- Fixed #1438: AutoIt error when using _ArrayCombinations().

3.3.5.1 (26th January, 2010) (Beta)
AutoIt:
- Fixed #1428: AdlibRegister/Unregister() were incorrectly using case-sensitive function names.

- Changed: Send() and ControlSend() code reworked to allow for more Unicode characters to be used.

Aut2Exe:
- Fixed #1409: Ctrl+C is no longer the shortcut for Convert. It is now Ctrl+G (Go) to avoid clashing with a Ctrl+C copy operation.

3.3.5.0 (22nd January, 2010) (Beta)
AutoIt:
- Added #1376: FileOpen() mode parameter is now optional. Default mode is read.
- Added #1054: Added FileGetEncoding().

AutoIt3Help:
- Fixed #1423: "Open Script" button stopped working.

3.3.4.0 (15th January, 2010) (Release)

3.3.3.3 (10th January, 2010) (Beta)
AutoIt:
- Added #1311: MouseGetCursor() returns hand cursor.

- Fixed #1403: Error with FileWrite() and UTF8 output streams not being correctly converted to UTF8.

UDFs:
- Fixed #1398: Fixed declaration of $tagPARAFORMAT2 from GuiRichEdit.au3.
- Fixed #1353: _FileWriteToLine() excessively strict on input text type.
- Fixed: SQLite.au3 various errors in _SQLite_FetchData(), $iCharSize, _SQLite_QuerySingleRow(), _SQLite_GetTable2d(), _SQLite_Display2DResult() by jchd.

3.3.3.2 (7th January, 2010) (Beta)
AutoIt:
- Added: FileRead() returns the number of characters/bytes read in @extended.
- Added: AutoIt scripts using the line continuation character "_" are no longer limited to a combined line length of 4095 characters.

- Fixed #1392: Crash with OnAutoItExitRegister().
- Fixed #1396: Crash in DllCallbackGetPtr() with invalid handle.
- Fixed #1352: StringSplit() hard crash with binary data.

UDFs:
- Changed: _SQLite 3.6.21 -> 3.6.22

3.3.3.1 (4th January, 2010) (Beta)
AutoIt:
- Added #682: Removed the 64KB limitation for FileReadLine().

- Fixed: Crash when using Stdio redirection.

- Removed: InetGet("abort"), @InetGetActive and @InetGetBytesRead have been removed.
- Removed: AdlibEnable() and AdlibDisable() have been removed.
- Removed: OnAutoItStart and OnAutoItExit have been removed.

UDFs:
- Fixed #1389: _IEAttach() could fail if called multiple times.

3.3.3.0 (3rd January, 2010) (Beta)
AutoIt:
- Added: Ability to read and write UTF-8 files with no BOM including automatic detection during reading.

- Fixed #1345: Number() failed to handle numbers with a trailing decimal point.
- Fixed #384: Under certain circumstances the network credentials flag would prevent the process from starting when launched with RunAs() or RunAsWait().
- Fixed #1370: StringInStr() would crash with a negative occurrence and start position greater than the string length.
- Fixed #1367: Calling GUIDelete() from a GUIRegisterMsg() callback that returns $GUI_RUNDEFMSG would crash AutoIt.
- Fixed #1363: FileSetPos() did not work when the origin was the current position.
- Fixed #1355: Regression in how unsigned numbers are displayed when returned from DllCall().

- Removed: The "RAW" reading mode from FileOpen() has been removed.

UDFs:
- Changed: _SQLite 3.6.19 -> 3.6.21
- Fixed #1338: bad _ArrayDisplay() GUI position error.
- Fixed #1362: _WinAPI_WindowFromPoint() did not work with 64-bit AutoIt.

AutoIt3Help:
- Fixed #1327: Some keywords would fail to open correctly in rare cases.

3.3.2.0 (18th December, 2009) (Release)

3.3.1.7 (10th December, 2009) (Beta)
AutoIt:
- Fixed #1332: Mod() forced a conversion to floating point numbers when it didn't need to which can cause unexpected output.
- Fixed #1321: DllStructCreate() did not support _ in data names. Documented valid characters for data name.
- Fixed #1322: Crash when using ControlCommand("GetSelected") on non-Edit controls.
- Fixed #1328: StringFormat() was no longer accepting sequences such as %000s.

UDFs:
- Fixed #1312: Errors with _GUIImageList_BeginDrag() example.
- Fixed #1320: _GUIImageList_DragMove() documentation contained a parameter that doesn't exist.
- Fixed #1325: Some date functions could attempt to access an invalid array.
- Fixed: Invalid syntax in MenuConstants.au3.

3.3.1.6 (22nd November, 2009) (Beta)
AutoIt:
- Added: DllStructSetData() and DllStructGetData() index parameter now supports the Default keyword.
- Added #1270: GUISetIcon() now finds suitable large and small icons.

- Fixed #1285: Reverted revision 5025 and all it's bad changes to the way numbers are handled.
- Fixed #1288: Documented how DllStructSetData() and DllStructGetData() work with arrays when omitting the index parameter.
- Fixed #1300: DLLs could unload when calling DllCall() with an invalid function.
- Fixed #1295: Unicode to ANSI conversion was crashing in certain situations.
- Fixed #1294: Fixed AutoIt deadlock when using the following functions with hanged windows: WinGetTitle, WinSetTitle, WinGetText, WinFlash, WinSetOnTop
- Fixed #975: Backgrounds of controls on tabs should be less likely to corrupt.

UDFs:
- Fixed #1287: _Debug functions were blocking input.
- Fixed #1276: _TicksToTime() incorrectly rounded seconds up.
- Fixed #1277: Resource clean-up in example script for _GDIPlus_ImageGetGraphicsContext().
- Fixed #1304: _GDIPlus_BitmapLockBits() now correctly takes a Width and Height parameter instead of a Right and Bottom.
- Fixed #1290: Invalid Left coordinate when using _GUICtrlTreeView_DisplayRectEx().
- Fixed #1296: _GUICtrlTreeView_ClickItem() could click outside the control's parent window.

Aut2Exe:
- Fixed #1283: Added new option /x86 to force a 32-bit build and re-added /unicode which also forces a 32-bit build.

Au3Check:
- Fixed #1299: Using single quotes in #include now works again.

3.3.1.5 (5th November, 2009) (Beta)
AutoIt:
- Added #1056: New Inet option to by-pass forcing the connection online.

- Fixed #1248: Regression in IsHWnd() that caused it to erroneously return true in some cases.
- Fixed #1234: COM methods that modified boolean arguments could change them to ints.
- Fixed #1066: FileOpen() with mode 1 now allows text to be overwrriten if the write pointer is repositioned.
- Fixed #1258: System menu could display when trying to dismiss a control menu.

- Changed: InputBox() no longer requires passing both x and y or w and h.

UDFs:
- Added #1228: _FTP_SetStatusCallback(), _FTP_DecodeInternetStatus() in FTPEx.au3.

- Fixed: Regression in _INetGetSource(). Also includes a new parameter to control how the data is returned.
- Fixed #1247: Documented that some _GUICtrlComboBoxEx_* functions don't work with certain ComboBox styles.
- Fixed #1260: Potential buffer overflow in _WinAPI_GetLastErrorMessage().

Au3Check:
- Fixed #1239: Incorrect library search order.

3.3.1.4 (26 October, 2009) (Beta)
AutoIt:
- Added #508: Static keyword.

- Fixed #906: ActiveX controls were not told what their initial size was.
- Fixed: Boolean tests on binary strings now behaves properly.
- Fixed #1242: Beta Regression in _WinAPI_WideCharToMultiByte().
- Fixed: Fatal error under certain conditions when using minus sign.

- Changed: PCRE regular expression engine updated to 8.00.

UDFs:
- Fixed #1223: _GUICtrlStatusBar_EmbedControl() failing.
- Fixed #1226: _DateDayOfWeek() had an off-by-one error.
- Fixed: Order of parameters was documented wrong for _WinAPI_MakeQWord().
- Fixed #1168: _ExcelBookOpen() now selects the first visible worksheet to prevent a COM error.

- Changed: _SQLite 3.6.18 -> 3.6.19

3.3.1.3 (15th October, 2009) (Beta)
AutoIt:
- Fixed: Hex() no longer crashes.

UDFs:
- Fixed #1215: _ArraySearch() not searching on 2D array.
- Fixed: Typos in _Crypt_EncryptData() documentation and _Crypt_EncryptFile() example.
- Fixed: GDIPlus return values.
- Fixed #1026: GDIPlus Bitmap examples and documentation use the correct function to free resources.

3.3.1.2 (14th October, 2009) (Beta)
AutoIt:
- Added: new type to DllCall and DllStruct to avoid confusion with MSDN description. That avoid specially X64 errors.
- Added #967: Ftp via proxy now works for the Inet functions.
- Added #351: PixelSearch() now supports both right-to-left and bottom-to-top searches.

- Changed: AutoIt exit callback functions are called in reverse order of registration.
- Changed: AdlibUnRegister() now returns the count of remaining Adlib functions that are registered.
- Changed: AdlibUnRegister()'s function argument is now optional. Called without arguments causes the last registered function to be unregistered.
- Changed: @YDAY now returns values in the range 001 - 366 instead of 1 - 366. This makes it more consistent with other languages. THIS IS A SCRIPT BREAKING CHANGE.
- Changed #1080: InetGet background downloads now return immediately instead of connecting to the remote host first.
- Changed #1137: RegEnumKey() and RegEnumVal() now correctly return an empty string on failure instead of an error message string.
- Changed: PixelChecksum() can calculate checksums from right-to-left and bottom-to-top.

- Fixed #1013: MDI childs doesn't adjust to parent windows client area.
- Fixed: Crash due to unregistering an Adlib while an Adlib was firing.
- Fixed: Adlib functions no longer dominate when more than one are registered.
- Fixed #1005: TraySetClick(64) = hovering.
- Fixed #1049: InetRead() inserted arbitrary null terminators.
- Fixed: ClipPut("") not emptying.
- Fixed #1068: Binary to Int.
- Fixed #1087: Checkbox or Radio repainting when mouse hovering.
- Fixed: Bad painting on double GUICtrlSetPos() for label.
- Fixed #1094: Send("{LSHIFT UP}") stay down.
- Fixed #1074: InputBox() positionning on multi monitor.
- Fixed #1079: GUISetFont(), GUICrlSetFont() doc related to issue #918
- Fixed #1105: disable colored Multiline button not properly displayed.
- Fixed #1077: GUICtrlSetBkColor() bad recoloring.
- Fixed #1116: GUICtrlCreateGraphic don't follow ResizeMode.
- Fixed #1102: Better documentation of the StringInStr() count parameter.
- Fixed #1161: Removed all documentation references to ColorMode.
- Fixed #1156: AutoItSetOption()/Opt() now set @error instead of generating a fatal error with invalid input.
- Fixed #1093: StringFormat() beta regression for non latin chars
- Fixed: Comparing pointers now works correctly.

AutoItX:
- Removed: ColorMode option removed from AutoItSetOption().

Aut2Exe:
- Fixed #1036: Inet-related functions now work in compiled scripts.

Au3Info:
- Removed: ColorMode BGR option removed since AutoIt no longer supports the option to use BGR mode.

Others:
- Added #1050: TextPad v5 syntax files installation.

UDFs:
- Added: GuiRichEdit and functions
- Added: _WinAPI_GetGuiResources()
- Added #981: _WinAPI_WideCharToMultiByte(), _WinAPI_MultiByteToWideChar() support IN/OUT as "strings"
- Added #1157: Encryption functions in Crypt.au3.
- Added #1128: _WinAPI_PathFindOnPath() in WinAPI.au3.

- Fixed #999: _GUICtrlTreeView_SetFocused() documentation
- Fixed #1016: _WordDocSaveAs() Doc for error handling.
- Fixed: Sound positioning in case of VBR Format Sound.
- Fixed #1031: _ClipBoard_SetData() fix.
- Fixed #1040: _ScreenCapture_Capture() leak memory.
- Fixed #1026: _Gdiplus_BitmapCreate*() doc examples.
- Fixed #1092: _Timer_...() datatype for X64.
- Fixed #1059: Incorrect error handling in _FileListToArray().
- Fixed #1101: _NowTime(), _NowDate() Doc.
- Fixed: _WinAPI_GetWindowLong(), _WinAPI_SetWindowLong() support X64.
- Fixed #1111: Bad grammar in comments for _DateAdd().
- Fixed #1155: _WinAPI_CreateSolidBitmap() updated
- Fixed: all includes use Unicode for DllCall and SendMessage
- Fixed: _WinAPI_Get/SetWindowLong under X64
- Fixed: UDF library now uses #include "" instead of #include <>.
- Fixed #1033: UDF library now has better and more consistent error handling when DllCall() is used.

- Changed: _SQLite 3.6.14.2 -> 3.6.18
- Changed: _INetGetSource() now uses InetRead().

- Removed #1112: __WinAPI_Check() has been removed as have all calls to it.

3.3.1.1 (14th June, 2009) (Beta)
AutoIt:
- Added #529: Added the "NAME" property to allow direct search for .NET WinForm control names.
- Added: PixelChecksum() extra parameter to select CRC32 instead of ADLER.
- Added #984: @OSVersion now returns "WIN_XPe" for Windows XP Embedded.
- Added #938: UDPOpen() flag to allow broadcasting with 255.255.255.255.

- Fixed #969: FileFindNextFile() does not set @extended if first found is a dir.
- Fixed #975: Checkbox or Radio bkcolor on tab regression with Theme.
- Fixed #983: InetGet() crash with IE6.
- Fixed #1006: @MSEC returned wrong value for values < 100.
- Fixed #1010: FileRead() UTF8 with BOM files return too many chars.
- Fixed #1028: _ClipBoard_GetData() fix.

- Changed #968: AutoUpdateIt updated by ProgAndy to use new Inet features.

Au3Info:
- Added: Control information now includes the .NET WinForm if available.

UDFs:
- Fixed #979: _ArrayDisplay() - just old/incorrect syntax in header comment
- Fixed #974: _WinAPI_WindowFromPoint() tagPoint structure
- Fixed #1000: _GUICtrlListBox_Create() result error message _WinAPI_CreateWindowEx(): Cannot find window class
- Fixed #1004: _PathFull() was returning invalid results.
- Fixed #1015: _SQLite_SaveMode() renamed as _SQLite_SafeMode().
- Fixed #1019: _GUICtrlListView_SetItemCut(), _GUICtrlListView_SetItemFocused(), _GUICtrlListView_SetItemDropHilited() enabled flag not working correctly.

- Changed: Error msg with UTF8 info can be displayed on SciTE console. Extra parameter in _SQLite_Startup().
- Changed: _SQLite 3.6.14.1 -> 3.6.14.2

- Removed: _StringAddThousandsSep() has been removed. Too many opinions on how the function should work means nobody is happy with it.

3.3.1.0 (20th May, 2009) (Beta)
AutoIt:
- Added #757: Set defaults for MouseClick()'s x/y parameters.
- Added #764: Return Pid on ProcessWait() and handle on WinWait(), WinWaitActive, WinActivate(), WinActive(), WinMove() when successful.
- Added #414: better handling of OnAutoItStart/OnAutoItExit, now #OnAutoItStartRegister, OnAutoItExitRegister() and OnAutoItExitUnRegister().
- Added: Better handling of AdlibEnable/AdlibDisable, now AdlibRegister(), AdlibUnRegister() and AdlibDisable().
- Added #351: Reverse PixelSearch().
- Added #769: FileFlush() function.
- Added #333: #NoAutoIt3Execute Directive for disabling /AutoIt3ExecuteScript or /AutoIt3ExecuteLine.
- Added #604: $GUI_BKCOLOR_TRANSPARENT can be used with label, group, radio, checkbox controls.
- Added #135: FileSetPos(), FileGetPos() functions for moving the file pointer around.
- Added #582: GUICtrlSetTip() can be used on TabItem controls.
- Added #699: Shutdown() now return @error=GetLastError() when failing.
- Added #461: StringReplace() from right to left if occurrence <0 as for StringInStr().
- Added: GUICtrlSetColor() and GUICtrlSetBkColor() for Combo Controls.
- Added: GUI without title bar (no $WS_CAPTION) can be moved with the mouse.
- Added #815: Temporary variables can be passed ByRef.
- Added #837: FileFindNextFile() set @extended if a directory is returned.
- Added #839: Shutdown() rewritten and now works properly when run as a non-interactive user.
- Added: Shutdown() now takes an optional reason code.
- Added #846: _PathFull() now supports strange but valid syntax where drives do not have a trailing slash.
- Added #869: @MUILang macro to help MUI environment scripts.
- Added #918: Added Quality parameter to GUICtrlSetFont() and GUISetFont().
- Added: ProcessClose() return info on error.

- Fixed: CtrlSetStyle listview on non selected tab.
- Fixed #763: GUICtrlCreateIcon() create an empty icon on error.
- Fixed: no mouse move when invalid button used in MouseClick() or MouseClickDrag().
- Fixed #779: infinite loop on Exit due to GUICreate() child badly created.
- Fixed #774: GUICtrlSetBkColor() bad label display.
- Fixed #790: Windows region constant $ERROR rename in $ERRORREGION.
- Fixed: StringInStr("aaa", "aa", 2) does not return 0.
- Fixed #802: Searching for controls by Height property.
- Fixed: Checkbox or radio painting on tab.
- Fixed #816: data for GUI date control doc clarification.
- Fixed #819: Crash with EventLog functions.
- Fixed #814: InetGet() through a proxy requiring authentication did not work.
- Fixed #813: bad handling of Windows advanced matching for [HANDLE:...] in X64 version.
- Fixed #863: DirMove() extra dot.
- Fixed #867: UDPRecv() can return from IP/Port.
- Fixed #886: More explicit documentation that operator == is a forced string comparison.
- Fixed #885: Default compared to False returned True instead of False.
- Fixed #888: Send("{}}") Extra null char.
- Fixed #916: Line inversion in INet.au3
- Fixed: DllCall() returning 64-bit int.
- Fixed: GUICtrlSetImage() after GUI resized.
- Fixed: DirMove() return code wrong under XP.
- Fixed #931: bad GUICtrlSetResizing() for graphic control.
- Fixed #934: MouseGetCursor() hogging mouse double click.
- Fixed #615: License updated to be less restrictive.
- Fixed #919: Remarks added to ConsoleWrite(), ConsoleWriteError() and StdinWrite() regarding how those functions handle binary data and non-ANSI characters.
- Fixed #897: Documented that StringToASCIIArray() does not accept binary input (convert to a string first).
- Fixed #937: Bad event handling of Opt("TrayMenuMode",1)

- Changed: It is now possible to read from files opened for writing.
- Changed: PCRE regular expression engine updated to 7.9.
- Changed #899: ShellExecute[Wait]() no longer uses "open" as the default verb. See remarks section for those functions for more information.
- Changed: Inet functions rewritten with the following additions and changes:
    - Removed: Long deprecate URLDownloadToFile() alias for InetGet().
    - Added: HttpSetUserAgent(), InetClose(), InetGetInfo() and InetRead() functions.
    - Added: Multiple background downloads are now supported with InetGet().
    - Added #408: New flag for ignoring SSL errors for HTTPS connections.
    - Added #884: Better proxy support with mode 0.
    - Added #949: The user-agent can be changed.
    - Changed: InetGet() returns a handle which must be closed.
    - Changed: @InetGetBytes, @InetGetActive and InetGet("abort") are deprecated and will be removed in the future.

Au3Info:
- Added #140: ToolsBar button info.

UDFs:
- Added: _GDIPlus_BrushGetSolidColor(), _GDIPlus_BrushSetSolidColor(). (smashly)
- Added: $tagWIN32_FIND_DATA and corresponding attribute constants.
- Added #868: _WinAPI_GetLayeredWindowAttributes(), _WinAPI_SetLayeredWindowAttributes().
- Added: _Date_Time_ ... Str() can return date as yyyy/mm/dd.
- Added #271: FTPEx.au3 for _FTP_...().
- Added #932: mouse event constants in WinDowsConstants.au3.
- Added #952: _ArrayDisplay() extra parameter for column header text.
- Added #957: _Assert() in Debug.au3.

- Fixed #755: _FileReadToArray() removing empty end lines.
- Fixed #773: Doc for _GUICtrlStatusBar_SetParts()
- Fixed #786: _SQLite_Exec() does not return @error.
- Fixed: Doc for _ClipBoard_SetData()
- Fixed #793: _WinNet_EnumResource() error always returned
- Fixed #809: _Soundxxx() with first parameter as filename.
- Fixed #850: _ExcelReadSheetToArray() doesn't work with German Excel 2003 (Prog@ndy) NOTE: not tested with other languages
- Fixed #887: Related section based on Tweaky work.
- Fixed #958: _ArrayDisplay() - bad centering of window after adjust its width
- Fixed #951: _ArrayDisplay() speed improvement for nb entries >4000.
- Fixed: _SoundOpen() set @error on MCI Error.

- Changed: _StringBetween() removed last optional param (not needed after change)(SmOke_N)
- Changed: _StringAddThousandsSep() has been rewritten and now takes different input.
- Changed: _StringToHex(), _HexToString() and _StringReverse() have been rewritten and are faster.
- Changed: Excel docs (litlmike)
- Changed: _SQLite 3.6.7 -> 3.6.14.1 (SQL statement support UNICODE characters)
- Changed: _ArrayCombinations(), _ArrayPermute(), _ArrayUnique() (litlmike)

- Removed: _WinAPI_MakeDWord

3.3.0.0 (24th December, 2008) (Release)

AutoIt:
- Fixed: Send() was incorrectly inserting a leading zero when using the {ASC 0xNNNN} format.

UDFs:
- Added: _GDIPlus_MatrixScale(), _GDIPlus_MatrixTranslate() (monoceres)

3.2.13.13 (20th December, 2008) (Beta)

AutoIt:
- Added #744: StringFromASCIIArray() and StringToASCIIArray() now allow specifying an encoding.

- Fixed: Send() was incorrectly inserting a leading zero when using the {ASC 0xNNNN} format.
- Fixed: DllStructSetData() wasn't correctly terminating string buffers that had been used previously.
- Fixed #743: AutoIt Crash when Tray functions are use with invalid ID.
- Fixed #748: AutoIt Crash with DllCall(0,...).

- Updated #734: StringRegExpReplace() doc for backward reference.

UDFs:
- Updated: _SQLite 3.6.6.2 -> 3.6.7

3.2.13.12 (9th December, 2008) (Beta)

AutoIt:
- Changed #596: StringFromASCIIArray() and StringToASCIIArray() now correctly handle embedded terminators. Also, StringToASCIIArray() no longer inserts a trailing 0 into arrays.
- Fixed: Crash when using BinaryToString() with invalid UTF16 input string. BinaryToString() now has new @error codes to support diagnosing invalid input.
- Fixed: ControlGetText() regression from last beta.
- Updated: Shutdown documentation.

UDFs:
- Added: _GDIPlus_StringFormatSetAlign() (monoceres)

- Updated: StringAddThousandsSep params in regards to #442
- Updated: _SQLite 3.6.5 -> 3.6.6.2
- Updated #733: Doc for _GUICtrlButton_SetImageList()

- Fixed #693: _DateTimeFormat() time format
- Fixed #701: _GUICtrlListView_ClickItem() Clicks in the wrong place when $fMove = True
- Fixed #700: _GUICtrlTreeView_ClickItem() Clicks in the wrong place when $fMove = True
- Fixed #703: _GUICtrlListBox_ClickItem() Clicks in the wrong place when $fMove = True
- Fixed #705: _GUICtrlToolbar_ClickButton() Clicks in the wrong place when $fMove = True
- Fixed #707: _GUICtrlMonthCal_Create() width and height

3.2.13.11 (17th November, 2008) (Beta)

AutoIt:
- Fixed #669: Typo in Dec() example.
- Fixed #659: Documented that UNC paths are not supported when using FileSelectFolder().
- Fixed #671: Crash when using $WS_EX_MDICHILD without specifying a valid parent.

AutoItX:
- Added: COM: WinList method.
- Fixed: Native DLL: Return strings were sometimes incorrectly terminated.
- Fixed: PixelChecksum() not returning correct values.

UDFs:
- Fixed #674: _GUICtrlTab_ClickTab() Clicks in the wrong place when $fMove = True

- Updated: _SQLite 3.6.4 -> 3.6.5
- Updated #442: _StringAddThousandsSep() allows for regional settings

3.2.13.10 (8th November, 2008) (Beta)

AutoIt:
- Added #407: Documented that For...In loops are read-only.
- Added #645: IniDelete() now supports the Default keyword for the 3rd parameter.

- Fixed #628: GUICtrlRead($ctxmenu, $adv) bad return (Saunders)
- Fixed #640: PCRE does not support \L, \l, \N, \U, or \u : doc updated
- Fixed: StringToASCIIArray() crash (Part of issue #596).
- Fixed #642: Installer now correctly opens the merged helpfile to the history page instead of the AutoIt-only helpfile.
- Fixed #646: Call() now sets specific @error and @extended values when it fails to find a function.

- Changed: Documented StringToASCIIArray() and StringFromASCIIArray() use UNICODE codes (Part of issue #596)

AutoItX:
- Fixed: multiple unicode related problems introduced in a previous beta.

UDFs:
- Added: _StringExplode() (WeaponX)

- Fixed #610: _WinAPI_CreateFile() wrong return value upon failure
- Fixed #619: _GUICtrlListView_SetItemSelected() memory allocation
- Fixed #617: corrections to six GDI+ ImageGet help file examples
- Fixed #621: _StringAddThousandsSep don't work with negative number
- Fixed #635: _GUICtrlTab_ClickTab() docs list unused $fPopupScan parameter
- Fixed #650: Missing BorderConstants.au3
- Fixed #656: _FileCountLines() returns 0 if file only contains 1 line

- Changed: _Soundxxxx functions (RazerM)
- Changed #599: _FileListToArray() speed optimization (code65536)
- Changed: _SQLite 3.5.9 -> 3.6.4.

3.2.13.9 (12th October, 2008) (Beta)

AutoIt:
- Fixed #601: Tooltip return 0 when title length >99.
- Fixed #608: listView GUICtrlSetBkColor not redrawn.
- Fixed: Regression in writing Unicode files introduced in 3.2.13.8.

UDFs:
- Fixed #600: _ArraySearch() fails with 2D array.
- Fixed #603: _FileReadToArray() does not return an array if the file contains only a single line of text.

3.2.13.8 (4th October, 2008) (Beta)

AutoIt:
- Added #454: $FO_UTF8 allowing FileOpen() in Read mode for reading UTF8 files without BOM.
- Added: $FO_UTF16_LE, $FO_UTF16_BE allowing FileOpen() in Read mode for reading UTF16 files without BOM.

- Fixed #501: ProcessGetStats() failed for processes running as other users (including SYSTEM).
- Fixed #92: DllStruct data truncated with char[]/wchar[].
- Fixed #562: Specifying the TITLE property caused all other properties to be lost (Window title matching).
- Fixed: GUICtrlSetState($graphic, $GUI_HIDE) does not hide.
- Fixed: GUICtrlSetResizing($graphic, ) not moving.
- Fixed: GUICreate(...,Style without caption) does not resize properly.
- Fixed: GUISetStyle(caption change) does not resize properly.
- Fixed: GUICtrlSetState($listviewitem) does not return error.
- Fixed #569 TCPRecv doc example.
- Fixed #589: Some comparison operators did not return a boolean value.
- Fixed #583: Bad formatting of @MSEC in documentation.
- Fixed #574: Using 0 for the SendKeyDelay or SendKeyDownDelay removes the respective delay when using Send().
- Fixed #542: Crash with regular expressions.
- Fixed #531: Clarification of some of the remarks for GUICtrlSetGraphic().
- Fixed #539: StringSplit() with flag 2 and no matching delimiters wasn't returning the full string.

- Changed: PCRE regular expression engine updated to 7.8.

UDFs:
- Fixed #495: _GUICtrlTreeView_GetTree() returns only 1 parent
- Added: _WinAPI_CreatePen(), _WinAPI_DrawLine(), _WinAPI_LineTo(), _WinAPI_MoveTo(), _WinAPI_GetBkMode(), _WinAPI_SetBkMode() (Zedna)
- Fixed #503: _Date_Time_FileTimeToLocalFileTime() example (cbruce)
- Added: _ArrayCombinations(), _ArrayPermute(), _ArrayUnique() (litlmike)
- Fixed #510: _GUICtrlListView_ClickItem(): If columns inside listview exceed visible area, clicks outside of the control
- Added: _GDIPlus_ImageGetFlags(), _GDIPlus_ImageGetHorizontalResolution(), _GDIPlus_ImageGetPixelFormat(), _GDIPlus_ImageGetRawFormat()
  _GDIPlus_ImageGetType(), _GDIPlus_ImageGetVerticalResolution() (rover)
- Added: _PathGetRelative() (wraithdu)
- Fixed #500: _ChooseColor() run on 64bit
- Fixed #517: WinAPI UDF - bad error checking after DllCall()
- Added: _WinAPI_CombineRgn(), _WinAPI_CreateRectRgn(), _WinAPI_CreateRoundRectRgn(), _WinAPI_SetWindowRgn() (Zedna)
- Fixed #533: Array functions dimension check
- Fixed: various Timer Functions
- Fixed #506: _FileCountLines() deal with all common line-end-chars
- Fixed #485: WinAPI missing related links in helpfile
- Fixed #571: return value doc for _GUICtrlListBox_FindString(), _GUICtrlListBox_GetAnchorIndex() and _GUICtrlListBox_GetText()
- Fixed #586: _GUICtrlListView_SetGroupInfo() destroyed group ID's.
- Fixed #516: _ChooseFont() run on 64bit
- Fixed #595: _WinAPI_SetWindowsHookEx() help file description of $WH_KEYBOARD_LL

3.2.13.7 (6th August, 2008) (Beta)

AutoIt:
- Fixed: Really stupid mistake with Run functions.

- Added #481: 11 pixel margin around the text in SplashTextOn() (Meets Vista UI guidelines).
- Added #468: Added @MSEC macro for obtaining the current milliseconds for the current second.
- Added #277: @CPUArch macro to return the capability of the processor.

- Changed: Tweaked DEP and Image randomization linker options.

AutoItX:
- Changed: Converted to full unicode - ANSI DLL prototypes removed. (For now, depends on demand for adding in).

3.2.13.6 (30th July, 2008) (Beta)

AutoIt:
- Fixed #475: StringSplit() with flag 2 and empty delimiter did not work correctly.
- Fixed #464: Example script for GUICtrlCreateAvi() did not work on Vista.
- Fixed #484: ObjGet() would crash when invalid files were specified.

- Added #328: StringToASCIIArray(), StringFromASCIIArray() functions.
- Added: New flag to Run()/RunAs() to fix issue #415 (Adds new Constants.au3 constant: $STDIO_INHERIT_PARENT).
- Added: New flag to all Run functions for better CUI compatibility (Adds new Constants.au3 constant: $RUN_CREATE_NEW_CONSOLE).

- Changed #393: Documented that SoundSetWaveVolume() works differently in Windows Vista.
- Changed: PCRE regular expression engine updated to 7.7.

UDFs:
- Added: _ExcelHorizontalAlignSet(), _ExcelFontSetProperties(), _ExcelBookAttach() (litlmike)
- Fixed: Excel Examples
- Added: _WinAPI_SetEndOfFile(), _WinAPI_SetFilePointer() (Zedna)
- Fixed #465: _DateTimeSplit() if seconds omitted defaulted to -1, now defaults to 0

Aut2Exe:
- Added #460: More verbose UPX errors.

3.2.13.5 (24th July, 2008) (Beta)

AutoIt:
- Fixed #449: @SystemDir does not return SysWOW64 under X64 in 32-bit mode.
- Fixed #440: Fatal error when script ends with EOF (0x1A).
- Fixed: Error compiling with custom icons since last beta.

3.2.13.4 (19th July, 2008) (Beta)

AutoIt:
- Fixed #346: FileOpenDialog/FileSaveDialog filter length limit.
- Fixed #387: DllClose() and DllCallbackFree() crashing when an invalid handle used.

UDFs:
- Added #334: _SQLite 3.5.9 x86 and X64 version.
- Fixed #422: _GDIPlus_GraphicsSetSmoothingMode() $iSmooth accepts only 0 - 4, doc updated
- Added: Missing FrameConstants.au3
- Added: Excel UDFs
- Updated: GuiComboBox Documentation

Aut2Exe:
- Fixed #436: Compression level was ignored when performing compilation from the GUI.

3.2.13.3 (22nd June, 2008) (Beta)

AutoIt:
- Fixed #381: DirCreate() was trashing input variables (old bug brought to light by recent optimizations).

UDFs:
- Fixed #388: _GUICtrlToolbar_SetButtonSize() Example
- Fixed #400: SQLite.dll.au3 @ProcessorArch replaced with @OSArch
- Fixed #390: _viPrintf replaced return type
- Added: _Timer_GetIdleTime(), _WinAPI_GetWindowPlacement(), _WinAPI_SetWindowPlacement() (PsaltyDS)

3.2.13.2 (15th June, 2008) (Beta)

AutoIt:
- Changed: @ProcessorArch changed to @OSArch as it was misleading.
- Changed: Size limits removed from RegRead() and RegWrite() (previously 64KB for some registry types).
- Changed: RegRead() and RegWrite() no longer use hex strings for REG_BINARY types - native binary datatypes are enforced.

- Fixed #380: @OSVersion for Windows XP 64-bit Edition.
- Fixed: Increased memory use since last beta.

UDFs:
- Fixed #371: _GDIPlus_Startup() return value (wraithdu)
- Fixed #368: _ArrayToClip() return value

3.2.13.1 (10th June, 2008) (Beta)

AutoIt:
- Added: New flag for StringSplit() to not return the count in element 0.

- Fixed #358: Install dir documentation cleaned up.
- Fixed #355: Child not visible beta regression.
- Fixed #366: AutoIt crash on bad syntax.
- Fixed #360: RunAs() under Windows 2000.
- Fixed #367: STDIO functions in compiled scripts work again.

- Removed #357: @AutoItUnicode macro.

UDFs:
- Added: _GUICtrlTab_ClickTab() (Gary)
- Fixed #361, #362: _GUICtrlListView_InsertItem() doc (Zedna)
- Removed: _StringSplit, no longer needed
- Added: _GUICtrlComboBoxEx_GetUnicode(), _GUICtrlComboBoxEx_SetUnicode() (Gary)

3.2.13.0 (7th June, 2008) (Beta)

AutoIt:
- Fixed #309: RunAs() and RunAsWait() now use @SystemDir as the working directory instead of @WorkingDir when a user-supplied working directory is not specified.
- Fixed #325: contextmenuitem not firing events.
- Fixed #305: GUICtrlSetFont() for Combo causing highlight.
- Fixed #318: GUICtrlSetTip() on TreeViewItem must return 0.
- Fixed #282: Icon transparency refresh when on tab regression.
- Fixed #339: GUICtrlDelete() crashes.
- Fixed #345: @OSVersion for Windows 2008.

UDFs:
- Fixed #285: _ChooseColor() Example (water)
- Fixed #299: _GUICtrlTab_SetItemText() buffer length for Unicode (benners)
- Fixed #292: _EventLog__Clear() not clearing log when backup parameter is empty
- Updated #290: _GDIPlus_DrawImagePoints() (Zedna)
- Fixed #258: _ClipBoard_GetData()
- Fixed #294: _FileReadToArray() where the file contains no @LF (GEOSoft)
- Added #275: _GDIPlus_GraphicsFillPolygon() (smashly)
- Fixed #303: Clock.au3 in Examples\GUI\Advanced
- Fixed: _GUICtrlListView_SetItemEx() text buffer
- Fixed #320: _WinNet_EnumResource() struct pointers
- Fixed #321: _GUICtrlStatusBar_GetText() buffer length for Unicode
- Added #332: Remarks to _GUICtrlStatusBar_Create()

3.2.12.1 (12th June, 2008) (Release)

AutoIt:
- Fixed #309: RunAs() and RunAsWait() now use @SystemDir as the working directory instead of @WorkingDir when a user-supplied working directory is not specified.
- Fixed #325: contextmenuitem not firing events.
- Fixed #282: Icon transparency refresh when on tab regression.
- Fixed #360: RunAs() under Windows 2000.

3.2.12.0 (11th May, 2008) (Release)

AutoIt:
- Fixed #252: Edit control not correctly getting focus after ALT-TAB.
- Fixed #254: GUIGetCursorInfo() fixed again!
- Fixed #256: Multiple windows and multiple tab controls were messing each other up.
- Fixed #255: Random(Min, Max, 1). Previously this would never actually return Max,
  so if Max was artificially incremented by one the script will now need to be changed.
- Fixed #251: GUIRegisterMsg() and Return values.
- Fixed: Icon transparency refresh when on tab.

UDFs:
- Fixed #249: _WinAPI_UpdateLayeredWindow() error checking.
- Fixed #260: _ArrayToString() doc return value.
- Fixed #259: _ArraySort() not returning 1 on success.

3.2.11.12 (8th May, 2008) (Beta)

AutoIt:
- Removed #238: ColorMode option ( Opt() ).

- Fixed #246: GUIGetCursorInfo() with swapped mouse buttons.

AutoItX:
- Added #244: ControlTreeView().

- Fixed: ControlListView() for native DLL version.

UDFs:

- Fixed: _GUICtrlTreeView_GetText() for Unicode.

3.2.11.11 (7th May, 2008) (Beta)

AutoIt:

- Fixed #222: GUIRegisterMsg() regression.
- Fixed #230: GUICtrlSetResizing after GUISetState() regression.
- Fixed #89: The "Environment" flag and environment variables are correctly loaded.
- Fixed #90: RunAs() and RunAsWait() now correctly work with limited user accounts.

UDFs:

- Fixed #198: _FileReadToArray() removing empty lines at the end.
- Fixed: _WinAPI_CreateSolidBitmap() not releasing DC.
- Fixed: _ArrayDisplay() Separator handling.
- Fixed: _IEAttach(), windowtitle, fixed bug matching window title when IE windowtitle registry key is not set (DaleHohm)
- Fixed: _IEPropertyGet(), toolbars, broken, now works (DaleHohm)
- Added: Unicode support to _GUICtrlListView_xxxx, _GUICtrlStatusBar_xxxx, _GUICtrlComboBoxEx_xxxx
  _GUICtrlHeader_xxxx, _GUICtrlTab_xxxx, _GUICtrlToolBar_xxxx, _GUIToolTip_xxxx, _GUICtrlTreeView_xxxx functions (Gary)
- Fixed: _GUIImageList_GetIcon() using wrong variable for param (SmOke_N)
- Added: $iFlag parameter to _FileWriteLog() (MrCreatoR)

3.2.11.10 (20th April, 2008) (Beta)

AutoIt:
- Fixed #185: GUI performance problem when creating a large number of windows.

- Changed: Tried to make each GUI window have an independent accelerator table.

3.2.11.9 (19th April, 2008) (Beta)

AutoIt:
- Fixed: Regression in right-click/context menus.

3.2.11.8 (19th April, 2008) (Beta)

AutoIt:
- Added #212: Added parent window parameter to InputBox().

- Fixed #213: GUISetAccelerator() regression since 3.2.11.6.
- Fixed #214: Regression in GUI resizing code when menus are present.

Au3Info:
- Changed: Controls are always highlighted when using the finder tool.
- Changed: Controls are not highlighted by default.
- Changed: Control description gives the advanced version of class and instance.

3.2.11.7 (15th April, 2008) (Beta)

- Added: X, Y, W, H in advanced window definitions.

- Fixed: GUI crash introduced into last beta.
- Fixed: An attempt to FileDelete() a file that was just executed with RunWait() would sometimes fail.

3.2.11.6 (13th April, 2008) (Beta)

AutoIt:

- Added #39: Added parent window parameter to MsgBox(), FileSelectFolder(), FileOpenDialog(), FileSaveDialog().
- Added #79: X, Y, W, H in advanced control definitions.

- Fixed #195: Impossible to compile a script with GUICtrlSetDef..Color().
- Fixed #193: crash when GUICtrlDelete() of a already deleted Ctrl.
- Fixed: Resizing GUI before GUISetState() (again).
- Fixed #178: GUIRegisterMsg() return value.

UDFs:

- Added: _GDIPlus_DrawImagePoints() (Malkey)
- Added: 21 _WinAPI_xxxx examples (Gary)
- Fixed: Constants declared in Constants.au3 and ScrollBarConstants.au3
- Fixed: _GDIPlus_DrawImagePoints() Documentation (Malkey)
- Added: _GUICtrlAVI_IsPlaying() (Gary)
- Added: _GUICtrlButton_GetNote(), _GUICtrlButton_GetNoteLength(), _GUICtrlButton_GetSplitInfo()
  _GUICtrlButton_SetNote(), _GUICtrlButton_SetShield(), _GUICtrlButton_SetSplitInfo()
  _GUICtrlComboBox_GetCueBanner(), _GUICtrlComboBox_SetCueBanner(), _GUICtrlMonthCal_GetCalendarBorder()
  _GUICtrlMonthCal_GetCalendarCount(), _GUICtrlMonthCal_SetCalendarBorder(), _GUICtrlListView_GetFocusedGroup()
  _GUICtrlListView_GetGroupCount(), _GUICtrlListView_GetGroupInfoByIndex(), _GUICtrlListView_GetGroupRect() (Gary)
- Updated: _GUICtrlButton_Create(), _GUICtrlButton_GetIdealSize(), _GUICtrlMonthCal_Create(), _GUICtrlListView_SetGroupInfo() (Gary)
- Added: _GUICtrlButton_SetDontClick() (Gary)

3.2.11.5 (25th March, 2008) (Beta)

AutoIt:

- Added: REGEXPCLASS in Advanced control definition.
- Added: "start" and "count" parameters added to StringInStr().
- Added #182: GUICtrlSetDefColor(), GUICtrlSetDefBkColor().

- Fixed: Resizing GUI before GUISetState().
- Fixed #183: radio fired when GUI reactivated.
- Fixed: GUICtrlDelete on contextMenuItem.

UDFs:

- Added: _ArrayDisplay() GUI width adapted to column sizes (Jpm)

3.2.11.4 (20th March, 2008) (Beta)

AutoIt:

- Added #78: REGEXPCLASS in Advanced Windows definition.

- Fixed #177: Pixel...() does not accept optional hwnd parameter.
- Fixed #173: Advanced window descriptions only reading to the first ;

UDFs:

- Fixed: _Timer_KillTimer() array assignment correction (-Ultima-)

3.2.11.3 (18th March, 2008) (Beta)

AutoIt:

- Changed: PCRE regular expression engine updated to 7.6.

- Added #128: GUISetAccelerators().

- Fixed: Modified AutoUpdateIt.au3 to work under x64.

UDFs:

- Fixed: $tagREBARINFO declaration (Zedna)
- Added: _GUICtrlRebar_GetBarInfo(), _GUICtrlRebar_SetBarInfo() (Gary)

3.2.11.2 (14th March, 2008) (Beta)

AutoIt:

- Added: Pixel...() can specified a window handle as last parameter.

- Changed: Maximum controls in a GUI window 4093 -> 65532.
- Changed: @OSVersion can now return "WIN_2008" for Windows Server 2008.

- Fixed: ControlTreeView() returning @error=1 on success (more).
- Fixed: StringSplit() flag=1 delimiters not case sensitive.
- Fixed: In advanced Window descriptions only semi-colon must be escaped.
- Fixed: ObjGet() memory leak.
- Fixed #152: STDIO redirection could cause (AutoIt) child process to max CPU.

UDFs:

Added: _Debug...() can be used to debug concurrent scripts using the same Notepad session.
Fixed: UDF Doc for _StringSplit (Gary)
Changed: re-write _StringSpit (Randallc)
Fixed: Doc for _GUICtrlListView_InsertGroup() (MsCreatoR)
Added: UDF Examples _GDIPlus_GraphicsSetTransform(), _GDIPlus_MatrixCreate(), _GDIPlus_MatrixDispose(), _GDIPlus_MatrixRotate() (Malkey)
Fixed: UDF _Timer_KillTimer() subscript error if function called more times than number of Timers (Gary)
Fixed: Include file constant name from $DTS_SHORTDATECENTFORMAT to $DTS_SHORTDATECENTURYFORMAT as stated in the help
Fixed: _ScreenCapture_Capture() memory leak
Added: UDF _WinAPI_CallWindowProc()
Added: UDF _GUICtrlListBox_ClickItem()
Changed: _StringAddComma replaced with _StringAddThousandsSep

3.2.11.1 (9th February, 2008) (Beta)

AutoIt:

- Added: ProcessWaitClose() returns exitcode in @extended

- Fixed: Unexpected AutoIt exit code.
- Fixed: AutoIt tray icon removal on script exiting.
- Fixed: AutoIt crash when removing ObjEvent() object.
- Fixed: ObjEvent() handler can destroy return of AutoIt Function : as WinWait("title") can return 0.
- Fixed: DirMove() on different volume.
- Fixed: Crash with RegRead() and REG_MULTI_SZ on x64.
- Fixed: GuiCtrlListView() behind BG Picture. Doc updated.
- Fixed: Various Edit control focus and DefPushButton issues.
- Fixed: ControlTreeView() returning @error=1 on success.
- Fixed: COM objects could lose numeric precision.
- Fixed: StringReplace() with start float number.
- Fixed: ControlCommand() "SelectString" wrong selection.

UDFs:

Fixed: _GUICtrlListView_GetItemChecked() for use with external listviews (Siao)
Fixed: UDF _GUICtrlListView_Create() freezes window when dragging an item (Gary Frost)
Added: UDFs _GUICtrlHeader_Destroy(), _GUIToolTip_Destroy(), _WinAPI_SetSysColors() (Gary Frost)
Fixed: _IEPropertyGet() with "toolbar".
Fixed: UDF Doc _ChooseFont() missing $hWndOwner from parameter explanation (Bert)
Added: UDF Examples: _WinAPI_Beep(), _WinAPI_ClientToScreen(), _WinAPI_EnumDisplayDevices(), _WinAPI_EnumWindows()
  _WinAPI_EnumWindowsPopup(), _WinAPI_FlashWindow(), _WinAPI_FlashWindowEx(), _WinAPI_FloatToInt()
  _WinAPI_GetCursorInfo(), _WinAPI_GetDesktopWindow(), _WinAPI_GetFocus(), _WinAPI_GetModuleHandle()
  _WinAPI_HiWord(), _WinAPI_IntToFloat(), _WinAPI_LoWord(), _WinAPI_ScreenToClient() (Bert/Gary)
Updated: UDF Docs Remarks for _ScreenCapture_Capture(), _ScreenCapture_CaptureWnd(), _ScreenCapture_SaveImage() (Gary)
Updated: UDF description _Timer_SetTimer() (Gary)
Updated: UDF Documentation for _GUICtrlHeader_SetItemFormat(), _GUICtrlListView_RegisterSortCallBack() (Gary)
Fixed: UDF _ScreenCapture_Capture() Cursor is not on the right position (progandy)
Fixed: UDF Date function(s) documentation (JerryD)
Fixed: UDF _GUICtrlListView_RegisterSortCallBack() no longer depends on WM_NOTIFY
Added: UDFs _ColorConvertHSLtoRGB(), _ColorConvertRGBtoHSL() (-Ultima-)
Added: UDF _StringSplit (Randallc)

3.2.11.0 (25th January, 2008) (Beta)

AutoIt:

- Removed: Unnecessary optional parameter from ProcessClose().
- Removed: RunErrorsFatal Option.
- Removed: RunAsSet().

- Changed: @Unicode renamed in @AutoItUnicode. @Unicode is an alias for now. It will be removed > 3.2.14.0
- Changed: The behavior of StdoutRead(), StderrRead(), StdinWrite() and ConsoleRead() has been changed.
- Changed: PCRE regular expression engine updated to 7.5.
- Changed: AutoIt internet functions (e.g. InetGet()) now use "AutoIt" as a user-agent. Previously using blank
  which was blocked by many websites.
- Changed: ControlClick() now accepts the same mouse buttons as MouseClick() - left/right/middle/primary/secondary/main/menu.

- Added: DllCall() new types int_ptr, uint_ptr, long_ptr, ulong_ptr. Special types that change size on x86/x64.
- Added: "REG_QWORD" type for RegWrite().
- Added: Option to compile scripts as console applications.
- Added: HotKeySet() modified to work with the {} notation.
- Added: _DebugBugReportEnv() function in Debug.au3 to retrieve basic Info for Bug Reporting.
- Added: FileReadLine( ,-1) read last line.
- Added: Std I/O redirection works with RunAs...().
- Added: Std I/O merged flag for using the same stream for stdout/stderr.
- Added: Std I/O supports binary data.
- Added: ConsoleWrite()/ConsoleWriteError() now return the amount of data written.
- Added: Remarks in Run() about how to close streams/release resources associated with STDIO.
- Added: StdioClose() function to force STDIO data closed for a process.
- Added: ProcessClose() now closes processes started by other users.
- Added: RunAs(), RunAsWait().

- Fixed: DllCall() setting wrong @error values.
- Fixed: BlockInput() returns errors.
- Fixed: WinWaitActive() not matching (more frequent with Windows Vista).
- Fixed: GUICtrlSetState($GUI_SHOW) on hidden radio on an active tab.
- Fixed: SciTE Lite not installed in the AutoIt Choosen release dir.
- Fixed: WinMove() with Speed = 0 crash the script.
- Fixed: Mysterious return value of 1 when no explicit value was set.
- Fixed: ControlCommand(), "GetLineCount"
- Fixed: _FileListToArray() when using root drive dir as c:\ under Win9x.
- Fixed: TraySetState(4) flashing tray icon for Windows Vista.
- Fixed: ProcessExists() wrong return.
- Fixed: StringRegExp() crashing under Win95.
- Fixed: Handle leak when using Run() with I/O redirection.
- Fixed: Disabled input control background on Tab.
- Fixed: GUICtrlDelete() of a tab if two GUI windows are used.
- Fixed: AutoIt crash in Random() when range exceeds 2^31.
- Fixed: #include parsing error detection.
- Fixed: Array entry passed ByRef to a UDF.
- Fixed: FileSetTime() erronously rounds UP on non NTFS partition.
- Fixed: STDIO redirection sometimes failed on Windows 9x.
- Fixed: IniReadSectionNames() returning incorrect number of sections under Win9x.

UDFs:

Updated: _GDIPlus_ImageLoadFromFile(), error check after DllCall (martin)
Updated: GDIPlus functions error checking and Failure return types where needed (Gary Frost)
Moved: _SendMessage(), _SendMessageA() from Misc.au3 to SendMessage.au3 (Gary Frost)
Added: UDF Files: _GUICtrlListView_ClickItem(), _GUICtrlListView_RegisterSortCallBack(), _GUICtrlListView_UnRegisterSortCallBack()
  _GUICtrlTreeView_ClickItem(), _WinAPI_GetXYFromPoint(), _WinAPI_PointFromRect(), _WinAPI_CreateFont()
  _WinAPI_CreateSolidBrush(), _WinAPI_DrawEdge(), _WinAPI_DrawFrameControl(), _WinAPI_FillRect(), _WinAPI_FrameRect()
  _GUIImageList_BeginDrag(), _GUIImageList_DragEnter(), _GUIImageList_DragLeave(), _GUIImageList_DragMove(), _GUIImageList_EndDrag()
  _GUICtrlEdit_FmtLines(), _GUICtrlEdit_GetPasswordChar(), _GUICtrlEdit_HideBalloonTip(), _GUICtrlEdit_SetPasswordChar()
  _GUICtrlEdit_ShowBalloonTip(), _GUICtrlSlider_GetLogicalTics(), $tagLVHITTESTINFO, $tagNMLVCUSTOMDRAW
  _GUICtrlToolbar_ClickAccel(), _GUICtrlToolbar_ClickButton(), _GUICtrlToolbar_ClickIndex() (Gary Frost)
  _GDIPlus_GraphicsDrawImageRect() (smashly)
Updated: UDF Files: _GUICtrlListView_GetOrigin() - added check for dll call success
  _GUICtrlListView_SetItemSelected() now supports -1 for index and focus
  _GUICtrlEdit_Create() doc (Gary Frost)
Fixes: And Added Param Paremeter: _GUICtrlListView_AddItem(), _GUICtrlListView_InsertItem() (Gary Frost, Koder)
  _DateDiff() doc (Jos/tinjaw), _GUICtrlTreeView_GetNext(), _GUICtrlTreeView_SetState() (Gary Frost/Bowmore), _ScreenCapture_SaveImage() (christian)
  _IsPressed() doc (JustinReno), _Net_Share_ShareAdd() doc (Wooltown)
Changed: GUIConstants.au3 is now deprecated. It is the same as using GUIConstantsEx.au3 which should be used instead.
Fixed: _PathFull() did not handle paths with a leading \ correctly.
Removed: MsgBox from _GUICtrlListView_DeleteAllItems() and _GUICtrlListView_DeleteItem() (Gary Frost)
Updated: _GUIImageList_AddIcon() added Large Icon option (Gary Frost)
Added: _WinAPI_CallNextHookEx(), _WinAPI_SetWindowsHookEx(), _WinAPI_UnhookWindowsHookEx(), $tagKBDLLHOOKSTRUCT (Gary Frost)
Fixed: _ArrayDisplay() more that 3999 items (-Ultima-)
Added: _ArrayConcatenate(), _ArrayFindAll() (-Ultima-)
Changed: _Arrayxxxx functions/examples (-Ultima-)
Added: _DebugBugReportEnv() (jpm)
Fixed: _ClipPutFile() offset calculated incorrectly (Gary Frost)
Added: Advanced Examples _NamedPipes_Client, _NamedPipes_Server (Gary Frost)
Added: $tagOPENFILENAME, _WinAPI_CommDlgExtendedError(), _WinAPI_GetOpenFileName(), _WinAPI_GetSaveFileName() (Gary Frost)
Added: _Singleton() now supports a new flag for creating an insecure object accessible by anybody.
Changed: _Singleton() no longer does an over-zealous check to remove \ from the name.
Fixed: _SoundLength() badly formatted (jpm)
Fixed: _IELoadWait() nuisance console COM messages with small loadwait timeouts. (DaleHohm)
Fixed: _IEAttach() embedded and dialogbox modes failure (dependant on DllCall fix to 3.2.10.0). (DaleHohm)
Fixed: _IEAttach() embedded and dialogbox modes to work without explorer shell running. (DaleHohm)
Fixed: _IEFormElementGetValue() now returns NULL string if value is NULL instead of integer 0. (DaleHohm)
Fixed: _GUICtrlListView_AddArray() Example (Gary Frost)
Added: uniqueID to _IEPropertyGet(). (DaleHohm)
Added: "instance" mode and $i_instance parameter to _IEAttach(). (DaleHohm)
Fixed: _GUICtrlRebar_AddToolBarBand() Button height clipped when Toolbar added to Rebar (rover)
Fixed: _GUICtrlListView_InsertColumn(), _GUICtrlListView_SetColumn() align and image now work together (Gary Frost)
Fixed: _GUICtrlToolbar_SetButtonInfo() documentation, style and state param descriptions were reversed (Gary Frost)
Fixed: _GUICtrlStatusBar_Create() example documentation (Gary Frost)
Added: Timers UDFs - _Timer_Diff(), _Timer_GetTimerID(), _Timer_Init(), _Timer_KillAllTimers(), _Timer_KillTimer(), _Timer_SetTimer() (Gary Frost)
Fixed: UDF Doc for _WinAPI_LoadShell32Icon() (MadBoy)
Added: GuiScrollBars UDFs (Gary Frost)
Updated: _GUICtrlListView_DeleteAllItems(), _GUICtrlListView_DeleteItem(), _GUICtrlListView_DeleteItemsSelected() support control ID again (Gary Frost)
Fixed: _FileReadToArray() leaving last line feed in the array (mlowery)
Fixed: Doc Example for _ArrayTrim() (Emiel Wieldraaijer)
Fixed: _GUICtrlTab_GetItemState(), _GUICtrlTab_SetItemState(), _GUICtrlTab_GetItem(), _GUICtrlTab_SetItem() State Mask was missing (Gary Frost)
Fixed: UDF Docs for GUICtrlListBox_AddString, _GUICtrlListBox_DeleteString() (Gary Frost)
Fixed: Example using wrong function calls in _GUIImageList_AddBitmap() (Gary Frost)
Removed: UDF Documentation and Example for _ArrayCreate(), function no longer needed (Gary Frost)
Fixed: _GUICtrlTreeView_GetState() hard crashes external application(s) (Gary Frost)
Added: GuiButton UDFs (Gary Frost)

3.2.10.0 (25th November, 2007) (Release)

3.2.9.14 (21st November, 2007) (Beta)

- Fixed: Incorrect predicted stack size causing DllCallbacks with int64 parmeters to fail (e.g. CopyFileEx)

3.2.9.13 (19th November, 2007) (Beta)

- Fixed: DllCallbacks crashing when tray icon is clicked. (NOTE: Callbacks now cannot be paused).

- Added: DllCall() and DllCallbackRegister() now accept doubles, int64 and uint64 types.

3.2.9.12 (17th November, 2007) (Beta)

- Added: DllCallbackRegister(), DllCallbackGetPtr() and DllCallbackFree()

3.2.9.11 (15th November, 2007) (Beta)

- Changed: Added a temporary pop-up warning when deprecated DllCall types are used.

- Fixed: UPX is not used when creating a 64bit compiled script.

3.2.9.10 (12th November, 2007) (Beta)

- Fixed: DllCall() stack error if multiple DllCalls happen at the same time.

3.2.9.9 (10th November, 2007) (Beta)

- Changed: Limits on Execute() removed.

- Fixed: DllStructCreate() now properly aligns the end of the structure if required.

3.2.9.8 (6th November, 2007) (Beta)

- Added: DllStructCreate() added "align" keyword to set structure alignment.

3.2.9.7 (6th November, 2007) (Beta)

- Fixed: Arithmetic (addition and subtraction) not working on Variants containing pointers.

3.2.9.6 (4th November, 2007) (Beta)

- Fixed: Looping GUIRegisterMsg() doesn't unregister.
- Fixed: Focus on ES_READONLY edit control.

3.2.9.5 (2nd November, 2007) (Beta)

- Changed: DllCall() new method of passing types by reference using *.
- Changed: DllCall(): short_ptr, long_ptr, int_ptr types deprecated. Use short*, long* and int* respectively.

- Added: VarGetType().
- Added: @AutoItX64 macro.
- Added: DllCall() new types of wparam and lparam.
- Added: Au3Info : Handle info for windows and controls.

- Fixed: Control...() functions using CLASS and TEXT together sometimes incorrect.
- Fixed: Control...() functions using CLASSNN sometimes incorrect.
- Fixed: Windows Vista taskbar previews causing problems with windows matching.
- Fixed: _SQLite_SQLiteExe() referencing by default "Extras\SQLite\SQlite3.exe".
- Fixed: _Sound...() when refering to a file with "!" characters.

3.2.9.4 (25th October, 2007) (Beta)

- Fixed: ProcessExists() on service process under Win2K.
- Fixed: $GUI_DEFBUTTON behavior.
- Fixed: ProcessGetStats() retrieving IO counters for Win9x, WinNT, Win2000.
- Fixed: ControlCommand(SelectString) order selection.
- Fixed: GUISetStyle(), GUIGetStyle(), ProcessGetStats() cannot be compiled.
- Fixed: Array cannot have 2^24 entries.
- Fixed: DefPushButton behavior.
- Fixed: GuiCreateMenu() on a windows without title and without client area.
- Fixed: WinWaitActive() sometimes failing after a WinActivate().

3.2.9.3 (5th October, 2007) (Beta)

- Fixed: $var = $var was not giving an error when $var didn't already exist.
- Fixed: Opt("WinTitleMatchMode", Default) fatal error.
- Fixed: 3.2.9.2 AutoIt error when launched under Windows 2000.
- Fixed: GUICtrlSetStyle() with $ES_READONLY bad $WS_TABSTOP.
- Fixed: AutoIt Crash on exit if Win...() used with a Title being a COM object.

3.2.9.2 (30th September, 2007) (Beta)

- Changed: PCRE regular expression engine updated to 7.4.

- Added: ProcessGetStats().

- Fixed: Extra notification on colored button.
- Fixed: IniReadSectionNames() for [] sections.

3.2.9.1 (18th September, 2007) (Beta)

- Added: SendKeepActive().
- Added: More commands for ControlTreeView().

- Fixed: GUICtrlSetImage() sizing regression from 3.2.4.9.
- Fixed: GUICtrlCreateListView() with no column.
- Fixed: _GUICtrlListViewInsertColumn() after _GUICtrlListViewDeleteColumn() of the first column of a ListView control.

3.2.9.0 (12th September, 2007) (Beta)

- Added: ControlTreeView().

3.2.8.1 (10th September, 2007) (Release)

- Fixed: Possible crash with StringRegExp().

3.2.8.0 (8th September, 2007) (Release)

3.2.7.6 (7th September, 2007) (Beta)

- Added: WinMove() speed parameter.

- Fixed: Crash on AutoIt exit if TrayItemCreate is not deleted.
- Fixed: AutoIt crash on bad parameter when calling TrayCreateMenu

3.2.7.5 (6th September, 2007) (Beta)

- Fixed: Character positions returned by StringRegExp() not correct for characters > 127 (accents, non-Western)

3.2.7.4 (5th September, 2007) (Beta)

- Changed: General speed improvements (currently up to 24% in some cases compared to 3.2.6.0).

- Fixed: Memory leak when AutoIt need to get longfilename (a lot of file functions).
- Fixed: ListviewItem not created after other Child Windows creation/deletion.
- Fixed: ControlGetFocus() returning bad ClassNN.
- Fixed: Detection of invalid ContinueLoop.

3.2.7.3 (3rd September, 2007) (Beta)

- Fixed: String memory allocation error introduced in 3.2.7.2.

3.2.7.2 (2nd September, 2007) (Beta)

- Changed: PCRE regular expression engine updated to 7.3.
- Changed: Recursion-based code limits relaxed.

- Fixed: ProcessExist() under Windows 9x.
- Fixed: $LVSCW_AUTOSIZE column truncates display string.
- Fixed: Incorrect listview creation.

3.2.7.1 (30th August, 2007) (Beta)

- Changed: More speed improvements.

- Fixed: ControlGetText() crash on SciTE windows.

3.2.7.0 (25th August, 2007) (Beta)

- Added: wchar type added to DllStructCreate()

- Fixed: GUISetState(@SW_DISABLE) not disabling keyboard input.
- Fixed: Sometimes AutoIt crashes on DllStructGetData of char[].
- Fixed: Au3Info restoring last settings.
- Fixed: Better handling of notifications when using colored buttons.

3.2.6.0 (24th August, 2007) (Release)

3.2.5.7 (22nd August, 2007) (Beta)

- Changed: More speed improvements (currently around 30-40% over 3.2.4.9)

- Added: GUIGetStyle().
- Added: byte and ubyte type to DllCall().

- Fixed: AutoIt crash on WinWait("","text") when a SciTE is open.

3.2.5.6 (19th August, 2007) (Beta)

- Changed: Limited Unicode support added in regular expressions.

- Fixed: Some crashes on Chinese systems during conversions.

3.2.5.5 (18th August, 2007) (Beta)

- Fixed: Aut2Exe crashing on Chinese systems when running in ANSI.
- Fixed: resizing of treeview.
- Fixed: IE.au3 bad 3.2.5.4 version. (Sorry Dale)
- Fixed: Cmdline /ErrorStdOut working with /AutoItExecuteLine.
- Fixed: Detection of no separator after keyword or function.

3.2.5.4 (14th August, 2007) (Beta)

- Changed: Slight expression parsing speed improvement.

- Added: ControlMove() just resizing as WinMove() if X=Y=Default.

- Fixed: Wrong Notification on {ENTER} after clicking on a listviewItem.
- Fixed: Wrong resetting of image on listviewitems if image set on the listview.
- Fixed: FileSelectFolder() out-of-bounds popup.
- Fixed: Resizing of listview control.

3.2.5.3 (11th August, 2007) (Beta)

- Changed: Some speed improvements.

- Fixed: @error not set on bad WinGetPos() return.
- Fixed: LVM_EDITLABEL hogging cpu.
- Fixed: AutoIt (non UNICODE version) crash with some COM objects.

3.2.5.2 (9th August, 2007) (Beta)

- Changed: IconId in all GUI functions is coherent with the actual GUICtrlSetImage() for icon control.

WARNING Previous scripts using GUICtrlSetImage(), GUISetIcon(), TraySetIcon() and TraySetPauseIcon()
  may display a wrong Icon. To get the same icon "if nId > 0 Then newId = - nId - 1".

- Changed: AutoIt .a3x and compiled script format. Exe2Aut will only decompile 3.2.5.1
  and earlier files. The new format doesn't support decompilation.

- Fixed: GUISetState() on GUI with W=0 or H=0.
- Fixed: GUI control Tip not reappearing after a click or timeout.
- Fixed: GUI controls not at the right position if a Control menu is in use.
- Fixed: EnvUpdate() in UNICODE AutoIt version not working since 3.2.3.3.
- Fixed: FileRead(..., count) returning count-1 chars.
- Fixed: Unicode filenames in FileInstall().

3.2.5.1 (29th July, 2007) (Beta)

- Fixed: LVS_EX_HEADERDRAGDROP extendedstyle.
- Fixed: UpDown control shows through tabbed pages.
- Fixed: GUICtrlSetState on UPDOWN control without changing the state.
- Fixed: FileInstall() in compiled scripts causing GUI problems.
- Fixed: ControlGetFocus() on control not created with AutoIt GUI.
- Fixed: @AutoItPID and ProcessList coherency under Win9x.
- Fixed: GUICtrlSetResizing not returning error on non resizable control.
- Fixed: regression for ControlSend SHIFTDOWN/UP since 3.2.3.13.
- Fixed: FileRead bad return length.

3.2.5.0 (11th July, 2007) (Beta)

- Added: ClassnameNN in control and summary info.
- Added: Float type to DllCall.
- Added: AU3Check v1.54.8 support for both "#AutoIt3Wrapper_plugin_funcs" and "#Compiler_plugin_funcs".
- Added: Extra parameter in ProcessClose() to close Stream handles.

- Changed: GUICtrlSetImage() on Button Ctrl with id<0 coherent with icon ctrl setting.
- Changed: PCRE engine updated from 7.0 to 7.1

- Fixed: Drag and drop on a listview control after clicking on its header.
- Fixed: Support "resource only" dlls for GUISetImage().
- Fixed: Default minimum for GUICtrlSetLimit() set to 0.
- Fixed: Z order after GUICtrlSetStyle() on edit or input control.
- Fixed: FileReadLine() getting bad cached data when reading specific line numbers with file handles.
- Fixed: Slight lag in GUIGetMsg() under certain circumstances.
- Fixed: StringReplace() and occurances parameter.
- Fixed: GUICtrlSetFont() on Tab control.
- Fixed: Leading blanks before #include cannot be compiled.
- Fixed: Notification on ENTER on Colored button.
- Fixed: suppress delay when speed=0 in MouseMove.
- Fixed: RegWrite() setting bad registry entry.
- Fixed: AutoIt hogging CPU when text MsgBox too big.
- Fixed: ControlSend() sometime to wrong control when using empty controlID.
- Fixed: ProcesExists() under Win2K with processname >15 chars.
- Fixed: Int() with string comparison wrong match.
- Fixed: InetGetSize() in unicode version returns 0.
- Fixed: GUICtrlCreateListView() with more than 254 columns.
- Fixed: AutoIt Crash on wrong recursive RegExp.
- Fixed: BitRotate() with left bit set.
- Fixed: FileMove() returning 1 without any move.
- Fixed: FileRead() returning Chr(0) in ANSI mode.
- Fixed: Au3Info control coords relative to client.
- Fixed: StringInStr() not returniong 0 when searching backward and searh lenght greater than string.
- Fixed: AutoUpdateIT from Saunders.

UDF's
- Added _IEGetObjById() to IE.au3 (DaleHohm)
- Fixed _IEPropertyGet() directives appversion and appminorversion (Dale Hohm)
- Fixed _IELoadWait() to trap ClientDisconnected COM errors (DaleHohm)
- Fixed and enhanced web links in _IE_Introduction()('basic') (DaleHohm)
- Several updates to IE.au3 documentation and examples (DaleHohm)
- Total rewrite of _ArrayDisplay() with more options. (randallc)
- Fixed _ArrayDisplay() to set the Opt("GUIOnEventMode",0) before dsiplaying the Array and changing is back before returning.
- Added Optional: Handle of owner window to _ChooseColor() andf ChooseFont. (gafrost)
- Fixed _ArrayToString() for array with only one element.
- Fixed _SetDate() in Date.au3 if daylight saving is involved.
- Fixed: bad checking of SQlite version.
- Added: CompareVersion() in Misc.au3.
- Fixed: _IsClassName doc.

3.2.4.9 (25th May, 2007) (Release)

- Added: StringCompare()

- Fixed: Basic string comparisons were not working with locale as in previous versions.

3.2.4.8 (23rd May, 2007) (Release)

- Fixed: Errors with non-western codepages and ANSI format scripts.

3.2.4.7 (22nd May, 2007) (Release)

- Added: Aut2Exe options for forcing ANSI mode compilation (/ansi and /unicode)
- Added: StringToBinary()
- Added: Additional unicode related options for BinaryToString()

3.2.4.6 (20th May, 2007) (Release)

- Fixed: StringReplace() and occurances parameter.

3.2.4.5 (20th May, 2007) (Release)

- Added: BinaryToString() for binary buffer to ANSI string quick conversions.
- Added: @Unicode to show if AutoIt is being run in Unicode or ANSI mode.

- Changed: StringReplace() speeded up - a lot.
- Changed: Au3Info is now resizable.

- Fixed: Chr(0) now properly works with Binary()

3.2.4.4 (17th May, 2007) (Release)

- Fixed: Chr(0) now acting more sensible (now acts in a similar way to VBScript).

3.2.4.3 (17th May, 2007) (Release)

- Fixed: FileRead() not working properly with unicode files.

3.2.4.2 (15th May, 2007) (Release)

- Changed: Au3Info graphical tweaks and Summary tab.

- Fixed: FileReadLine() getting bad cached data when reading specific line numbers with file handles.
- Fixed: Slight lag in GUIGetMsg() under certain circumstances.

3.2.4.1 (13th May, 2007) (Release)

- Added: ChrW() and AscW() for unicode operations.

- Fixed: Chr() and Asc() for character codes 128-255 in unicode mode.
- Fixed: Unicode BOM was not being written in file append modes if the file was empty.
- Fixed: Error in Include\GuiCombo.au3 and Include\IE.au3.

3.2.4.0 (10th May, 2007) (Release)

Big Changes:

- AutoIt is now compiled for Unicode! AutoIt3.exe is Unicode - AutoIt3A.exe is ANSI.
- Au3Info tool rewritten.
- Binary data functions completely rewritten - scripts using these functions will need to be changed.

3.2.3.14 (6th May, 2007) (Beta)

- Added: Support for virtually all file formats (UTF16 LE/BE, UTF8) in scripts and File functions.
- Fixed: Possible Aut2Exe crash with #cs/#ce blocks.

3.2.3.13 (4th May, 2007) (Beta)

- Removed: Struct keyword and dot notation for accessing.

3.2.3.12 (29th April, 2007) (Beta)

- Changed: Removed restrictions on the maximum number of #include directives.
- Changed: Removed restrictions on the maximum number of DllOpen() handles.
- Changed: Removed restrictions on the maximum number of open files.
- Changed: Removed restrictions on the maximum number of hotkeys.

3.2.3.11 (28th April, 2007) (Beta)

- Fixed: Binary() crashed when passed an array.

3.2.3.10 (27th April, 2007) (Beta)

- Added: New modes for FileOpen() to force Unicode and binary operations.

3.2.3.9 (26th April, 2007) (Beta)

- Changed: Performance improvements in StringStripWS().

- Fixed: Unicode regression in StringIsAlpha(), StringIsAlNum(), StringIsDigit(), StringIsXDigit(),
  StringIsLower(), StringIsUpper(), StringIsSpace(), StringIsASCII()

3.2.3.8 (25th April, 2007) (Beta)

- Fixed: Regression in StringInStr().
- Fixed: Possible crash when using StringStripWS(), flag 4 and empty strings.

3.2.3.7 (25th April, 2007) (Beta)

- Fixed: GUICtrlSetTip() not always working correctly.
- Fixed: Regression in InetGetSize() that caused a crash.
- Fixed: GUICtrlSetLimit() for UpDown controls where min = max.

3.2.3.6 (17th April, 2007) (Beta)

- Fixed: Regression in #RequireAdmin and #NoTrayIcon in compiled scripts.
- Fixed: Aut2Exe crashed when using nodecompile option.
- Fixed: UDPSend() and UDPRecv() fixed for binary rewrite.

3.2.3.5 (15th April, 2007) (Beta)

- Fixed: Regression in ConsoleWrite()

3.2.3.4 (15th April, 2007) (Beta)

- Fixed: Regression in FileSetAttrib() and FileSetTime()

3.2.3.3 (15th April, 2007) (Beta)

AutoIt is now compiled for Unicode! AutoIt3.exe is Unicode - AutoIt3A.exe is ANSI.

- Added: BinaryLen(), BinaryMid()

- Changed: Binary data in variants are now treated as a special type, separate from normal strings.
- Changed: BinaryString() renamed to Binary()
- Changed: IsBinaryString() renamed to IsBinary()

3.2.3.2 (29th March, 2007) (Beta)

- Changed: ControlClick() can now click a control at a certain position.
- Changed: ControlClick() can now properly simulate double-clicks.
- Changed: ControlClick() no longer forces the activation of the parent window (up to the user now).
- Changed: ControlClick() related coordinates added to Au3Info.

3.2.3.1 (27th March, 2007) (Beta)

- Changed: Au3Info recoded.
- Changed: Improved the searches that can be done for windows/controls/instances.

- Fixed: Slow GUI tab redrawing under Windows Vista fixed.

3.2.3.0 (9th March, 2007) (Beta)

- Added: Colored Button based on gafrost UDF.
- Added: DllStruct...() can reference elements by name.
- Added: Struct variables

- Changed: From DEFAULT_QUALITY to PROOF_QUALITY for Change/Set Font functions.
- Changed: pcre from 6.7 to 6.10.
- Changed: x^y compatible with C99 standard.

- Fixed: HotKeySet bad notification. (Thanls litlmike)
- Fixed: FileGetAttrib on pagefil.sys.
- Fixed: BitXOR doc.
- Fixed: invalid default parameter in GUICtrlSetData not detected.
- Fixed: Assign does return error on array element.
- Fixed: FileOpen("test.txt", 2+8) returning error.
- Fixed: Error detection in Enum statement.
- Fixed: Help file does not open examples.
- Fixed: _GUICtrlStatusBarSetIcon
- Fixed: Opt("WinTitleMatchMode").
- Fixed: _Degree() in Math.au3
- Updated: refresh blocked during GUISetState(@SW_LOCK). (seems needed for Windows XP style)
- Fixed: Stack corruption resulting from improper use of DllCall() now gracefully aborts the script instead of hard crashing.
- Fixed: Crash when reading empty REG_MULTI_SZ.
- Fixed: Round() not returning an integer.
- Fixed: ControlSend() to empty "" ctrl fixed for inactive window. Also shift state behavior.
- Fixed: O^(-1).
- Fixed: non detection of illegal statement.
- Fixed: HotKeySet("^{PAUSE]",... notification.
- Fixed: {CTRLBREAK} ->{BREAK} as ctrl is user responsability.
- Fixed: _DateTimeSplit()
- Fixed: $var = Default passed as parameter to COM object.
- Fixed: Edit control would always have focus the first time the GUI was displayed even if it shouldn't. This behavior also ignored $GUI_FOCUS.
- Fixed: range value for seed Number in SRandom().
- Fixed: AutoIt Info last window memorization.
- Fixed: FileRead crash if no count in raw mode.
- Fixed: _GUICtrlEditGetLine().
- Fixed: Opt("WinTitleMatchMode", <0) really matching case insensitive.
- Fixed: FileSetAttrib/FileSetTime wrong setting.
- Fixed: Execute/Call recursive overflow display error message.
- Fixed: Aut2exe warning message if icon not found.
- Fixed: _ReplaceStringInFile() to keep the original file attributes.
- Fixed; issue with au3check when include file name contains trailing spaces.(Update version to 1.54.7)
- Fixed: WinGetTitle() returns 1 on error.
- Fixed: memory leak on keyword variable deallocation.

3.2.2.0 (19th December, 2006) (RC1)

- Changed: @error set to WinAPI GetLastError() for Run().

- Fixed: List control not displayed when using GUISetFont.
- Fixed: MsgBox() timeout on Windows Vista.
- Fixed: Fatal error on opt('TrayMenuMode",...).
- Fixed: Installer SciTE bad link creation.
- Fixed: Uninstaller include file removal

3.2.1.14 (9th December, 2006) (Beta)
- Added: GUICtrlSetState $GUI_DROPNOTACCEPTED.
- Added: $GUI_FOCUS, $GUINOFOCUS for listviewitem control.
- Added: IsDllStruct()
- Added: SRandom() to set seed for random number generation.
- Added: WinTitleMatchMode for case insensitive matching.

- Changed: Small tweak to Floor() to ensure it is not as susceptible to floating point precision errors.
- Changed: Small tweak to Ceiling() to ensure it is not as susceptible to floating point precision errors.

- Fixed: WorkingDir in ShellExecute(Wait).
- Fixed: DllCall() crashes when using uint, ushort.
- Fixed: PixelChecksum() GDI leak.
- Fixed: Window titles with "regexp=REGEXP" return 0 and @error=1 on bad pattern.
- Fixed: GUICtrlRead on listview control when sorted.
- Fixed: FileRecycleEmpty() regression.
- Fixed: @OSVersion on Windows 9x.
- Fixed: GUIGetCursorInfo with Handle not retrieving mouse click info.

3.2.1.13 (18th November, 2006) (Beta)
- Added: Listview Alternate coloring with $GUI_BKCOLOR_LV_ALTERNATE.
- Fixed: Recent crash under Windows 98.
- Fixed: List control height when font size changes.
- Fixed: GUICtrlSetImage not testing icon on error.
- Fixed: @ScriptDir equal @WorkingDir for rootdir (x:\).
- Fixed: GUIGetCursorInfo (winhandle) when child not active.
- Fixed: AutoIt error not displaying error line number.
- Fixed: Yet another MsgBox() timeout regression fixed.
- Fixed: au3check only checks for a string to terminate on the same line to. (v1.54.5)
- Fixed: _StringAddComma().
- Fixed: drag & drop $GUI_EVENT_DROPPED notification on edit control.

3.2.1.12 (5th November, 2006) (Beta)
- Fixed: Coherency of type parameter for DllCall() and DLLSructCreate()
- Added: IconId can be reference by ordinal value if negative 1-based index is use.
- Added: Executable and help files for SQLite in Extras dir.
- Updated: Draw lines ontop during CtrlSetGraphic rendering.
- Fixed: GUIGetCursorInfo eating msg.
- Fixed: Invalid THEN did not produce a syntax error.
- Fixed: StringMid with start <=0.
- Fixed: syntax checking on unmatching DO, WEnd, ....
- Fixed: Default keyword didn't always work correctly with COM objects.
- Fixed: MsgBox() timeout regression.

3.2.1.11 (20th October, 2006) (Beta)
- Fixed: GUICtrlRead, GUICtrlSetState, GUICtrlSetData with listviewitem sorted.
- Fixed: StringSplit every char on BinaryString.
- Fixed: When #include failed was not including filename in the error message.

3.2.1.10 (15th October, 2006) (Beta)
- Fixed: GUICtrlCreateIcon, GUICtrlSetImage with IconID=-1.
- Fixed: regression with StringMid("",5,2).
- Fixed: Typo that broke Ping().

3.2.1.9 (13th October, 2006) (Beta)
- Fixed: COM property write fails when using arguments.
- Fixed: Send/ControlSend for US international keyboard
- Fixed: Send/ControlSend char>=Chr(128) for english keyboards.
- Fixed: MsgBox() with task modal flag left GUI's disabled on timeout.
- Fixed: report reporting by messagebox even with /ErrorStdOut.
- Fixed: GUICtrlSetImage default icon value for Icon Ctrl.

3.2.1.8 (8th October, 2006) (Beta)
- Fixed: InetGet() regression.
- Fixed: StringRegExpReplace() wasn't returning number of replacements in @extended.

3.2.1.7 (6th October, 2006) (Beta)
- Added: StringRegExp() and StringRegExpReplace() regular expression support (Perl compatible)
- Added: Regular expression support for Window title matching
- Added: ShellExecute() and ShellExecuteWait() functions. (by Jon)
- Fixed: Mistake in IniWriteSection() documentation. (by Valik)
- Fixed: GUISetFont, GUICtrlSetFont bad parameter error return.
- Fixed: _GUITreeViewGetText doc typo. (gafrost)
- Fixed: GUIRegisterMsg destroy @error.
- Fixed: $LVS_SORTASCENDING with GUICtrlSetImage icon bad display.
- Fixed: Wrong default arguments for _ArrayToString().
- Fixed: GUIRegisterMsg destroyed @error.
- Fixed: $LVS_SORTASCENDING with GUICtrlSetImage icon gave bad display.
- Added: @extended error code on DriveMapAdd error.
- Fixed: bad "#" instruction inhibit whole script.

3.2.1.6 (6th October, 2006) (Beta)
Aborted upload due to last minute bugs.

3.2.1.5 (29th September, 2006) (Beta)
- Fixed: FtpSetProxy doc example.
- Added: 2 UDF's to GUIStatusBar.au3. (gafrost)
- Fixed: Several updates to GUIStatusBar.au3. (gafrost)
- Fixed: Several updates to Sound.au3. (RazerM)
- Fixed: Crash Aut2exe using cmdline with shortnames.
- Changed: PixelChecksum() is now over 30x faster. (by Valik)
- Fixed: _GUICtrlListViewGetItemText in GUIListView.au3.
- Fixed: WinMove, StderrRead Doc typos.
- Added: GUICtrlCreateIcon and GUICtrlSetImage can select in multiple icon file by name.
- Added: #RequireAdmin for UAC/Windows Vista. (By Jon)
- Added: ToolTip() option to ensure the tooltip is always displaying on a monitor. (by Valik)
- Fixed: Tooltip state (Such as icon or title) was showing up on subsequent tooltips that didn't want those items. This affected both ToolTip() and GUICtrlSetTip(). (by Valik)
- Added: IniWriteSection() function. (by Valik)
- Added: Windows vista help file entry.

3.2.1.4 (22nd September, 2006) (Beta)
- Fixed: ControlSend sending special characters.
- Added: Expanded GUICtrlSetTip() to allow creation of tooltips with titles, icons and using the balloon tip style. (by Valik)
- Added: Tooltip supports Default keyword. (by Valik)
- Changed: Modified _PathSplit() to be much faster.
- Added: Remark added to _PathSplit() mentioning that it does not accept command line strings, only paths.
- Changed: Rewrote _ArrayToString() removing a lot of unnecessary error checking.
- Fixed: crash in Au3exe with badly form input file in FileInstall.
- Fixed: wrong execution a compiled script containing FileInstall inside #CS-#CE.
- Fixed: FileInstall referencing a file without any path will refernce it from the ScriptDir to be coherent with the compiled script.

3.2.1.3 (15th September, 2006) (Beta)
- Fixed: "#include <Misc.au3>" in GuiIPAddress.au3 (gafrost)
- Fixed: StringInStr not converting to string search parameter.
- Added: Support >32x32 icon from .exe/.dll in GUICtrlCreateIcon or GUICtrlSetImage.
- Fixed: Syntax description for _DayValueToDate() showed _DateToDayValue() instead. (by Valik)
- Fixed: example in Language Reference->Conditional Statement doc page.
- Fixed: typo in GUICtrlCreateGraphic doc.
- Fixed: Int() of a binarystring.

3.2.1.2 (9th September, 2006) (Beta)
- Fixed: MouseMove in secondary screen.
- Fixed: _GUICtrlStatusBarCreate in GUICtrlStatusBar.au3.
- Fixed: str and wstr in DllCall doc (only up to 65536).
- Fixed: Send to italian keyboard.
- Added: @KBLayout to retrieve the current keyboard configuration.
- Fixed: GUICtrlSetState doc remarks about menu control.
- Fixed: refresh after a GUICtrlSetBkColor.
- Fixed: crash on line beginning with ~ : "Unable to parse line".
- Fixed: IniReadSectionNames() returned bogus data in Windows 98 when the INI file was empty or did not exist.
- Added: CompiledScript string file info for compiled script.
- Updated: FileGetVersion extra parameter to retrieve string file info.
- Fixed: _GUICtrlStatusBarSetIcon doc typo and precision. (by gafrost)
- Fixed: _GUICtrlTreeViewSetText doc typo. (by gafrost)
- Fixed: Doc precision about GUICtrlCreateTab that can be used only one by window.
- Fixed: include reference in doc example.
- Fixed: .a3x green icon.
- Fixed: _GUICtrlListViewGetHeader doc remarks. (by gafrost)
- Fixed: _GUICtrlTreeViewDeleteItem Help hyperlink error.
- Updated: @ScriptLineNumber doc description.
- Fixed: Installdir doc page.
- Fixed: @Compiled when the script is compiled.
- Fixed: _INetSmtpMail() doc precision.
- UDF's (27 August 2006)
- Added 2 UDF's to GUIStatusBar.au3. (gafrost)
- Added GuiIPAddress.au3 to Include directory. (gafrost)
- Added Sound.au3 with several sound UDFs to Include directory. (RazerM)
- Removed the version numbers from the include files.

3.2.1.1 (27th August, 2006) (Beta)

- Fixed: UDP... return code on error.
- Fixed: UDPRecv crashed on bad parameter.
- Fixed: COM was corrupting floating point values.
- Fixed: Aut2Exe was not finding includes correctly.

3.2.1.0 (26th August, 2006) (Beta)

- Changed: Performance improvement prototype (up to 100% on some scripts!).

- Fixed: Memory leak with prototype plugins.
- Fixed: Some Object Collections could not be parsed in one AutoIt statement .
- Fixed: Bad screen updating of already unchecked radiobuttons.
- Fixed: Tray icon tooltip not displaying the scriptname when compiled.

3.2.0.1 (13th August, 2006) (Release)

- Fixed: (Au3Info) Buffer overrun in control code.
- Fixed: Exe2Aut.exe was missing its digital signature.

3.2.0 (12th August, 2006) (Release)

- Added: in GuiTreeview.au3, _GUICtrlTreeViewGetParentHandle() and _GUICtrlTreeViewGetParentID() - supports now optional item handle/ID (by holger)
- Added: Hotkeys for Always On Top, Highlight Controls and Magnify options.

- Fixed: twice same link in SplashTextOn doc.
- Fixed: not working FileGetAttrib doc example.
- Fixed: GuiTreeview doc examples. (by gafrost)
- Fixed: autoitx bugs.
- Fixed: bad repainting of updown reenabled control.

3.1.1.133 (6th August, 2006) (beta)

- Added: Test for COM object comparison using = and <>.

- Fixed: Bad multi Drop in a edit control.
- Fixed: Brain-dead developer broke ConsoleRead().
- Fixed: Documentation for IniDelete() was wrong.
- Fixed: Uppercase in udf doc.
- Fixed: GUICtrlRegisterListViewSort doc examples..
- Fixed: Typo in Send doc..
- Fixed: Menu conventions changed in Aut2Exe and Exe2Aut.
- Fixed: Some precision on text vertical centering in SplashTextOn documentation.
- Fixed: Treeview does not refresh on tab.

3.1.1.132 (23rd July, 2006) (beta)

- Added: AutoItX beta 3.1.1.1.
- Added: Au3Check so it can be used without the Full SciTE. (by JdeB)

- Updated: TrayIcon is no more displayed when using /AutoIt3ExecuteLine.
- Changed: Compilation done with VC8 instead of VC6. (by Jon)
- Updated: SciTE updated to 1.70, it can be start with the AutoIt V3 menu. (by JdeB, Jon)

- Fixed: FileInstall() deleting output dir without backslash at the end.
- Fixed: GUICtrlRead bad return on Treeviewitem.
- Fixed: Background color of listbox changes in tab.
- Fixed: Reading std streams would fail if the stream was not a pipe.(internal change by Valik)
- Fixed: Doc examples referring constant already define in GUIConstants.au3. (by Jon)

3.1.1.131 (19th July, 2006) (beta)

- Fixed: GUIRegisterMsg() crash in "GUIOnEventMode"
- Fixed: GUIRegisterMsg() unregister a message
- Changed: GUICtrlRead() in advanced mode - returns extended info as single value. This change will possible break scripts! (Valik/changed by Holger)
- Added: Binary support for COM functions. It works only with variables passed between COM functions (so you can't display, convert or do mathematical actions with these variables yet). (by SvenP)
- Changed: GUICtrlRead() in advanced mode for Tab control return the controlID of the select tabitem. The Opt("GuiEventOption",2) is suppressed. This change will break scripts!
- Updated: GUI Standard includes split for better small inclusion. GUIConstants.au3 still give the whole stuff perhaps a little more. (by Valik)
- Fixed: Problem with Util_DoesFileExist and pagefile.sys .
- Fixed: GUICtrlSetGraphic,GUISetOnEvent,GUICtrlSetResizing, AutoItSetOption, MouseClick,Finc...EndFunc, For...in...Next, _GUICtrlTreeViewDeleteItem doc brolken links.
- Changed: StdioRead now sets a unique @error code for each error. Also, @extended is set to GetLastError() in each case. These are helpful for diagnosing I/O problems. The errors or the values should not be documented, it is enough to know that an error occurred, it is not necessary for users to know specifically what internal error occurred. (by Valik)
- Fixed: Slight precision on $CmdLineRaw for compiled scripts.
- Fixed: Crash after AutoIt exit.
- Changed: _FilesListToArray(): Added @error 4 meaning no files found. (gafrost)
- Changed: Constants seperated out into seperate files. (Valik)
- Changed: GUIConstants.au3 is now a stub including pretty much everything (Use GUIConstantsEx.au3 and the other Constants.au3 files for more granularity). (Valik)
- Updated: several Helpfile pages for ie.au3. (Big_Daddy)
- Updated: several functions in visa.au3. (Angel)
- Fixed: _viPrintf and _viExecCommand() would not work with certain GPIB cards (such as USB-GPIB cards).
- Changed: use of the VISA command "viWrite" method to be more generic.
- Added: Additional OPTIONAL parameter for _viPrintf and _viExecComand. Controls command send mode and terminator. Default value is "Use @LF terminator".
- Updated : _viPrintf and _viExecCommand() append an @LF to every VISA command by default. This can be changed by means of a new optional parameter.
- Updated : _viPrintf and _viExecCommand() do not "protect" for escape characters anymore by default. That causes problems with some GPIB cards. It is possible to go back to the original behaviour by setting the new optional parameter $s_mode to "str".

3.1.1.130 (12th July, 2006) (beta)

- Added: Check to ensure that FileInstall() can override the target file.
- Added: GUICtrlCreatePic doc precision when using overlayed tab control.
- Fixed: Extra .SVN directories created during installation.
- Fixed: FAQ#1 doc.
- Reverted: Conversion from floating point to string now shows less precision to prevent displaying unexpected values. (by Valik) The conversion will be back as in the official release.

3.1.1.129 (11th July, 2006) (beta)

- Fixed: Exit did not work in all situations where it should. (by Valik)
- Fixed: StringSplit on binaryString when delimiter not found.
- Fixed: GUICtrlCreatePic Doc typo.
- Fixed: COM/Obj Distinction between Null and 0
- Updated: v1.65 (6 July 2006)
- Added: IE.au3.
- Changed _INetSmtpMail(), change initial connection logic. (Neil)
- Fixed _TicksToTime() StringIsInt() problem. (JdeB)
- Fixed Bug in _GUICtrlListViewGetItemText on return if a subitem is empty. (gafrost)

3.1.1.128 (28th June, 2006) (beta)

- Fixed: GUISwitch crash after GUIDelete on another window.
- Fixed: Conversion from floating point to string now shows less precision to prevent displaying unexpected values. (by Valik)
- Fixed: Random doc example.
- Fixed: GUIRegisterMsg() - overlapping of same messages.
- Fixed: ConsoleWrite(), ConsoleWriteError() - @LF was expanded to @CRLF automatically which could result in badly formatted data. Now no automatic expansion is performed; what is passed to these two functions is written. (by Valik)
- Added: /nopack command line parameter added to Aut2Exe. This disables UPX packing from the command line. (by Valik)
- Fixed: Crash AutoiT if Win... with bad regExp.
- Updated: v1.64 (27 June 2006)
- Updated _GUICtrlListViewGetItemText: removed $v_ret variable to avoid au3check errors. (gafrost)
- Updated _GUIListView: Some bugfixes and Helpfile correction. (gafrost)
- Updated _GUIListView: Found a way I can live with the -1 being in the _GUICtrlListViewGetItemText
and _GUICtrlListViewGetItemTextArray for using selected index in the function calls. (gafrost)

3.1.1.127 (20th June, 2006) (beta)

- Fixed: bad Combo bkcolor : grey.
- Added: ClipGet return @error=1 on empty and @error=2 on nontext.
- Added: ClipPut("") empty the clipboard.
- Fixed: WinKill() referencing an explorer.exe window not closing.
- Updated: Upx.exe 2.00 -> 2.01.
- Added: FileGetLongName($relativefile, 1) and FileGetShortName($relativefile, 1) support relative path conventions.
- Fixed: Small precision in FileFindFirstFile doc about matching 3-char extension.
- Fixed: AutoIt Crash if too many includes in Opt(TrayIconDebug,1).
- Added: GUI_MAXCOLOURS added to AutoIt limits appendix.
- Fixed: GUISetOnEvent, GUICtrlSetOnEvent, TrayItemSetOnEvent and TraySetOnEvent can be disabled.
- Fixed: Wrong matching of While/WEnd, Do/Until, If/EndIf, ... .
- Fixed: ObjEvent() doc example.
- Fixed: ObjEvent() regression from .125.
- Updated: ClipGet() doc remarks on multiselection.
- Fixed: #include doc about lower case only removed.
- Fixed: BitShift() doc. (by Valik)
- Fixed: Remove MessageBox in Aut2exe.exe
- Updated: v1.63 (19 June 2006)
- Updated _DateTimeFormat() to use a default template when registry entries are missing
Like in Win9x/WinME for SLongDate.
- GuiListView updated .This update will possible break scripts. (gafrost)
Replaced ControlListView calls (will no longer need window title/text in params).
Functions updated to reflect new params.
Examples updated for consistancy.
Templates updated as needed.
- _ArrayBinarySearch(): (JdeB)
removed check for more than 1 entry to allow the use of this UDF on arrays with one entry.

3.1.1.126 (4th June, 2006) (beta)

- Fixed: Slight update on language variable doc precision.
- Added: Send("ASC 0x...}") to allow hex value.
- Fixed: The Clear() method on a COM Error object would cause the COM Errorhandler to stop functioning.
- Fixed: Bogus error messages on long lines when a COM Error handler is used
- Fixed: A lot of typo and grammar in Doc.
- Fixed: IniReadSection Invalid lines (Those without proper key=value pairs) would cause the returned data to be wrong. These lines are now stripped. (by Valik)
- Fixed: IniReadSection comments were not stripped on Windows 95/98/ME. (by Valik)
- Fixed: Wrong PID type return by ProcessList.
- Added: Some information in GUIGetMsg about control hovering.
- Added: List Box can be colored with GUICtrlSetColor and GUICtrlSetBkColor.
- Added: SplashTextOn return the handle of the splash window.
- Fixed: TrayItemGetState memory leak.
- Fixed: FileWrite of a binarystring return false.
- Fixed: @AutoItVersion bad return when compiled file is resource hacked.
- Updated: v1.62 (2 June 2006)
- Fixed _ClipPutFile() example include statement. (RazerM)
- Doc Fixes:
    _GUICtrlListViewEnsureVisible. (gafrost)
    _FileReadToArray(). (CyberSlug)
- Fixed _Now() which was returning "tt" at the end (JdeB)

3.1.1.125 (26th May, 2006) (beta)

- Fixed: WinMove not handling Default keyword for W or H.
- Changed: no more compaction of AutoIt3.exe, Au3Info.exe, AUT2Exe.exe and AutoIt3Help.exe files. Compiled script can still be compacted. (by Jon)
- Fixed: Some doc precision about FileDelete and DirMove.
- Fixed: RegRead, RegWrite and RegDelete coherent @error with other Reg functions.
- Fixed: Crash AutoIt with invalid "With" .
- Fixed: AutoIt limits doc typo.
- Removed: Exitcode 0x7ffff000-0x7fffffff are reserved for AutoIt. Exit of such code will produce a messagebox. (by Devs)
- Removed: ToolTip Centering go around. (by Valik)
- Fixed: The documentation for ToolTip() clarifies how the center flag works and the requirements for getting an icon to display on the title row. (by Valik)
- Fixed: GUICtrlSetColor(), GUICtrlSetBkColor() doc can set ListViewItem and TreeViewItem. (Holger forget to update them in .72)
- Fixed: some doc typos
- Fixed: bad formated #include.
- Fixed: TCPListen, TCPConnect, UDPSend, UDPBind not checking bad ipaddr or port.
- Fixed: Invalid lines (Those without proper key=value pairs) would cause the returned data to be wrong. These lines are now stripped. (by Valik)
- Fixed: Comments were not stripped on Windows 95/98/ME. (by Valik)
- Fixed: Memory leak on GUIDelete if some pic control where used.
- Updated: v1.61 (23 May 2006)
- Fixed _GuiCtrlListViewSort() avoiding insert/removal of spaces. (gafrost)
- Changed test in _DateIsValid() test from <1900 to <1000 to allow a startdate of 1600 used for UTC calculations. (JdeB)
- Fixed _GUICtrlListViewSort. (JPM,gafrost)
- Added _ClipPutFile() to misc.au3. (Piccaso)
- Updated _GUICtrlListViewSetItemSelState, added an optional focus state parameter. (gafrost)

3.1.1.124 (16th May, 2006) (beta)

- Fixed: Memory leak on object invoking error.
- Fixed: StringRegExp returning string instead of array withy flag=1.
- Fixed: AutoItSc.bin size.
- Fixed: GUICtrlSetImage for 16x16 icon not repainting.
- Added: Some doc precision about running under a Windows 64-bit Edition.
- Changed: Exitcode 0x7ffff000-0x7fffffff are reserved for AutoIt. Exit of such code will produce a messagebox.
- Changed: RegEnumKey and RegEnumVal return more precise @error to help diagnostic.
- Fixed: Mouse... invalid button definition.
- Fixed: Small precision in FileFindFirstFile doc about returning dir names too.
- Fixed: Hyperlink in CLSID doc page.
- Fixed: IniDelete() could create an empty file if the file did not exist.
- Fixed: ToolTip Centering go around.
- Fixed: $GUI_GR_RECT and $GUI_GR_ELLIPSE under win98.

3.1.1.123 (6th May, 2006) (beta)

- Changed: Empty parameter not allowed in COM reference.
- Fixed: GUIGetCursorInfo on listview header.
- Fixed: Func OnAutoItExit doc typo.
- Fixed: DllCall @error not equal 3 when function not found.
- Fixed: exitcode 0 when AutoIt exit on fatal error should be different from 0.
- Fixed: ubyte can be used as Array.
- Fixed: TrayCreateItem doc precision.

3.1.1.122 (1st May, 2006) (beta)

- Fixed: DirCreate not creating subdir on dir with read/hidden/system attributes.
- Changed: "GUIEventCompatibilityMode" Opt removed definetly use "GUIEventOptions".
- Fixed: FileSetAttrib, FileSetTime destroy @WorkingDir.
- Fixed: Some doc typos in the "Function Notes" page. (fixed by Herewasplato)
- Updated: Suppression of a validation of interface checking. (by SvenP)

3.1.1.121 (28th April, 2006) (beta)

- Fixed: Some doc clarification in the "Function Notes" page. (fixed by Herewasplato)
- Changed: doubleclick on titlebar trigger maximize/restore event.
- Fixed: FileCopy not creating subdir under Netware shared.
- Changed: Upx 1.25->2.00
- Updated: v1.60 (28 April 2006)
- Updated _GuiCtrlStatusBarResize example. (gafrost)
- Added 2 variables to GuiStatusBar.au3. (gafrost)
- Fixed typo in _ArraySort(). (Knight)

3.1.1.120 (21st April, 2006) (beta)

- Fixed: FileSetAttrib doc example.
- Fixed: WinGetProcess and ProcessExist return same pid precision.
- Fixed: GUICreate WS_POPUP Centering.
- Fixed: Bad Notification on end of drag when $GUI_DROPACCEPTED not set on a control.
- Fixed: InetGet("abort") and exiting AutoIt with a download in progres now correctly stop the download immediately. (by Valik)
- Fixed: @InetGetBytesRead Byte count could be wrong due to a race condition.
- Updated: v1.59 (20 April 2006)
- Updated _ProcessGetPriority() to use 0x0400. (Valik)
- Added _GUICtrlEditSetRECT to GuiEdit.au3. (gafrost)
- Updated Email addresses in UDF's to avoid retrieval by search engines. (JPM)

3.1.1.119 (14th April, 2006) (beta)

- Updated: FAQ page. (by JdeB)
- Fixed: open script in Gui concept page.
- Fixed: FileSetAttrib return 1 on non existing file.
- Fixed: InetGet() could block the foreground execution even when run in background mode.
- Fixed: GUISetBkColor freezing the display.
- Updated: Allow array to be initialized with another array in an element (see Dim doc). (by Nutster)
- Fixed: FileOpen doc.

3.1.1.118 (6th April, 2006) (beta)

- Changed: Example and Include files are readonly.
- Updated: GUICtrlCreateRadio doc example. (by Smoke_N)
- Added: An extra parameter in ControlSetText to force redraw.
- Changed: Opt("GUIEventCompatibilityMode", ) renamed in Opt("GUIEventOptions. both OK for this beta but will dropped in .122. (by Jon)
- Fixed: empty parameter in $cmdline.
- Updated: v1.58 (6 April 2006)
- updated _ProcessGetPriority() to accept either a name or PID argument. (valik)
- Fixed bug in _FileWriteLine() insert mode not inserting new line. (sasdad)

3.1.1.117 (31st March, 2006) (beta)

- Added: Value to TrayMenuMode (Option) to turn off auto radio menuitem checking
- Fixed: GUICtrlSetState $GUI_SHOW on tab with $TCS_BUTTON style.
- Fixed: GUICtrlCreateMonthCal positioning.
- Fixed: ProcessWait, ProcessWaitClose, TrayTip timeout unit doc precision.
- Fixed: CmdLine[] limited to 63 parameters.
- Updated: "Check for Updates" (AutoUpdateIt) display the current install beta.(by strik3r0475)
- Updated: TCPSend/TCPRecv Doc Examples. (by Larry)
- Fixed: Bad tabitem creation when no tab defined.
- Fixed: Bad combo disable 16-bit color under W2K.

3.1.1.116 (26th March, 2006) (beta)

- Added: StringRegExp Tutorial (by neogia)
- Added: DllCall :cdecl or :stdcall
- Updated: v1.57 (19 March 2006)
- Updated : GUICtrlTreeView
- Changed _GUICtrlTreeViewExpand (Parent GUI handle no longer needed) (Holger)
- Renamed _GUICtrlTreeViewItemGetTree to _GUICtrlTreeViewGetTree !!! (Holger)
- Added: _GUICtrlTreeViewGetState (Holger)
- Added: _GUICtrlTreeViewGetText (Holger)
- Added: _GUICtrlTreeViewInsertItem (Holger)
- Added: _GUICtrlTreeViewSetIcon (Holger)
- Added: _GUICtrlTreeViewSetState (Holger)
- Added: _GUICtrlTreeViewSetText (Holger)

3.1.1.115 (23rd March, 2006)(beta)

- Fixed: For Next with boundary,stepping being a string (no conversion to Float).
- Fixed: AutoIt3.exe high density icon. (by Jon)
- Fixed: GUICtrlRegisterListViewSort() and some issues while script pausing. (by holger)
- Changed: GUICtrlRegisterListViewSort() parameters maximum are 4 - less are OK. (by holger)
- Fixed: ControlSetText() (backchange to normal behaviour before beta 3.1.1.73) (by holger)
- Fixed: GUISetState(@SW_UNLOCK) force repainting.
- Fixed: Internal cleaning of Send/ControlSend(), SendKeyDownDelay =5 by default. (by Jon)

3.1.1.114 (17th March, 2006)(beta)

- Fixed: StdxxxYyy PID reuse.
- Fixed: RegRead MULTI_REG_SZ malformed key.
- Fixed: Not updating anymore the official include dir. Use RemoveIcludeBeta.bat in beta\include\3.1.1 if you want to clean the official include folder.
- Fixed: RegWrite Doc clarification.
- Fixed: examples referring GUICtrlCreateCombo with wrong size for Win2K SP4.
- Changed: the default setting on Au3Info so that it doesn't highlight controls. (by Jon)
- Fixed: Some doc cleaning about cursor/arrow.
- Fixed: StringLeft,StringRight doc typos.
- Fixed: For Next with boundary,stepping being a string (no conversion to integer).
- Updated: v1.56 (15 March 2006)
- Updated _GUICtrlListViewSort Helpfile example. (gafrost)
- Updated _GUICtrlCombo examples updated to proper height. (gafrost)
- Updated GUIComboau3. Added #include <GUIConstants.au3>. (andyswarbs)

3.1.1.113 (10th March, 2006) (beta)

- Fixed: Aut2exe, Exe2Aut in .ZIP

3.1.1.112 (10th March, 2006) (beta)

- Fixed: ObjEvent help example.
- Updated: Aut2Exe, Exe2Aut new compression algorithm. (by Jon)
- Fixed: FileFindFirst doc precision about wilcards.
- Fixed: DriveMapDel /DriveMapAdd interaction.
- Fixed: Doc optional parameter setting.
- Fixed: GUICtrlDelete Doc remarks.

3.1.1.111 (3rd March, 2006) (beta)

- Fixed: #include recursion depth enforced. (by Valik)
- Changed: #include search algorithm updated to be more consistent. (by Valik)
- Added: Documented #include search order. (by Valik)
- Updated: Some doc precision about IsDeclared(), Assign(), Eval(). (by Valik)
- Fixed: GUICtrlCreatePic w=h=0.
- Fixed: @OSVersion for WIN_XP running under X64 edition. I hope.
- Fixed: Hidden input control previously associated with updown control badly displayed during reshowing.
- Fixed: comparison case insensitive accentuated upper case.
- Fixed: GUICreate $WS_CHILD+$WS_VISIBLE w=0 or h=0 lead to crash AutoIt.
- Updated: v1.54 (23 February 2006)
- Added _GuiCtrlEditFind to GUIEDIT.AU3: - Find/Replace text in an Edit control. (gafrost)
- Added _FileWriteToLine() to FILE.AU3: Writes text to a specific line in a file. (cdkid)
- Updated: v1.55 (2 March 2006)
- Updated INetSmtpMail(),allow the "EHLO" to be send. (JPM)
- Added Attribute to _GUICtrlComboAddDir, _GUICtrlListAddDir. (gafrost)
- Added _GUICtrlListViewSetColumnHeaderText() to GuiListView. (gafrost)

Due to new #include search algorithm some problems can occurs with AU3Check.

3.1.1.110 (21st February, 2006) (beta)

- Fixed: Hidden Updown control badly displayed during resizing.
- Fixed: Extras\Check for Update (Extras\AutoUpdateIt\AutoUpdateIt.au3).
- Fixed: Labels were not painted correctly on tab controls.

3.1.1.109 (17th February, 2006) (beta)

- Fixed: GUICtrlSetData on listview/listviewItem bad erasing.
- Fixed: GUICtrlCreateInput help typo.
- Fixed: SplashTextOn centered vertically with embeded empty lines.
- Fixed: SplashTextOn Memory Leak.
- Fixed: GUICtrlRead menuitem checked.
- Updated: v1.53 (16 February 2006)
- Fixed _GuiCtrlListViewDeleteItem: Listview items can't be deleted after sorting. (gafrost)

3.1.1.108 (14th February, 2006) (beta)

- Updated: v1.52 (8 February 2006)
- Fixed typo in _ArraySearch() Helpfile. (theguy0000)
- Fixed _GuiCtrlListViewDeleteItem: Listview items can't be deleted after sorting. (gafrost)
- Fixed _ArraySort() Local $t decleration. (gafrost)
- Fixed _GUICtrlComboAutoComplete() move Variable definitions to the stat of the function. (gafrost)
- Fixed _GuiCtrlStatusBarCreate : corrected variable declarations in the function. (gafrost)
- Added: Setting error and extended in InetGet for debugging. purpose. Will be documented is suitable or removed in a following beta. Just post script,error and extended you will get the explanation if any.
- Fixed: Graphic controls should always have a transparent background.

3.1.1.107 (4th February, 2006) (beta)

- Fixed: PixelChecksum Doc related link.
- Fixed: Under certain conditions, GUICtrlSetPos() could cause a label to appear as if it had been painted multiple times. (Fixed by Valik)
- Changed: GUICtrlSetBkColor(). (by Valik)
- Updated: v1.51 (3 February 2006)
- Changed _INetGetSource() to return "" when error occurs. (erebus)
- Changed Dim to Local in GuiStatusBar.au3. (Jdeb)
- Change _GuiCtrlStatusBarSetIcon that will allow removing the icon from normal status bar. (gafrost)
- Added version at the top of each UDF file.

3.1.1.106 (30th January, 2006) (beta)

- Fixed: Some hangups and undefined closes by using GUIRegisterMsg(). (Fixed by holger)
- Changed: No more proceeding of Autoit's internal message procedures by default, see GUIRegisterMsg() for more infos. (by holger)
- Changed: GUI's internal system timer, so only userdefined Timers can be 'monitored'; fixes also interacting problem between WM_TIMER-monitoring and TrayIcon-handling. (by holger)
- Changed: GUIRegisterMsg() parameters maximum are 4 - less are OK. (by holger)

3.1.1.105 (28th January, 2006) (beta)

- Fixed: Event functions without a method name were not called.
- Fixed: Event function with too many declared parameters could crash script. (Fixed by SvenP)
- Added: Event Object .Stop() method to stop receiving events (see help). (by SvenP)
- Fixed: Typos and grammatical issues in the COM documentation.
- Updated: Different example script in COM documentation about handling Events. (by SvenP)
- Fixed: GUICtrlCreateObj: Keystrokes were not passed to controls that has embedded controls

3.1.1.104 (25th January, 2006) (beta)

- Fixed: Some keystrokes are not accepted by ActiveX controls (thanx SlimShady, Svenny, fixed by SvenP)
- Added: More Object information can now be retrieved with ObjName (see helpfile). (by SvenP)
- Fixed: ACos() bad result.
- Fixed: Doc typo.

3.1.1.103 ( 20th January, 2006) (beta)

- Fixed: Call with parameters doc. (Fixed by Valik)
- Fixed: DllStructGetPtr($struct,$i) wrong ptr returned.
- Fixed: DllCall doc for ordinals. (Fixed by holger)
- Fixed: GUICtrlRegisterListViewSort doc typo. (Fixed by holger)
- Fixed: "Windows Message Codes" in appendix doc tree. (Fixed by holger)
- Updated: v1.50 (19 January 2006)
- Added _GUIStatusBar.au3 UDF's. (gafrost, rysiora, JdeB, tonedef, eltorro)
- Added _GUICtrlComboGetList to GUICombo.au3 which retrieves all items in a combobox (Valik)
- Fixed _INetSmtpMail() parameter variable name.
- Added: A specially formatted array can be passed to Call() and each argument in they array will be treated as an argument to the function. See help-file for demonstration. (by Valik)
- Reverted fix in GUICtrlCreateObj to prevent crash with certain controls.
(Open bug: http://www.autoitscript.com/forum/index.php?showtopic=20530)

3.1.1.102 (18th January, 2006) (beta)

- Fixed: @COM_EventObj doc typo. (Fixed by Valik)
- Fixed: _INetSmtpMail() error doc.
- Fixed: GUICtrlSetState(tabitem,@SW_SHOW) under creation bad tabitem display.
- Fixed: Additional error number in DllCall() if "function" can not be found in the DLL. + doc. (Fixed by Holger)
- Fixed: _INetSmtpMail() again and I hope last.
- Fixed: Some docs.
- Updated: v1.49 (17 January 2006)
- Fixed bug in _ArrayPush() when Direction 1 is specified. (AnnA)
- Helpfile _ArraySearch() example corrected. (Valuater)
- Removed obsolete parameters from _GUICtrlTreeViewSelectItem(), Scripts need updating! (JdeB)
- Fixed: _INetSmtpMail() (by JPM).
- Updated all UDFs to get rid of any Errors from Au3Check v 1.50 will All checks enabled.
- Updated _ArrayDisplay() added Const to ByRef of the first parameter. (Valik)
- Fixed bug in _PathFull() when using root of a drive. (Valik)
- Fixed: A for..in loop could fail undeserved on certain type of collections. (Fixed by SvenP)
- Fixed: Controls created by GUICtrlCreateObj have now default window style WS_VISIBLE, so they can be seen on tabs. (Fixed by SvenP)
- Fixed: Permanent fix of old bug 2005-10-18, related to deletion of a RichText control. (Fixed by SvenP)
- Added: GUICtrlCreateObj now supports multiple GUIs. (by SvenP)
- Fixed: Memory leak when GUICtrlCreateObj failed in some situations. (Fixed by SvenP)
- Fixed: $DLG_TEXTVCENTER added to Constants.au3.
- Fixed: SetError(), SetExtended() can return a value. (Fixed by Valik)
- Added: GUIRegisterMsg() to modify GUI WM_Message-routines at runtime. (by holger)
- Added: GUICtrlListViewSortRegister() to create a real sorting routine for GUI ListView's. (by holger)
- Added: TrayItemGetHandle() to get the internal handle of tray menu items. (by holger)
- Fixed: TraySetClick doc.
- Fixed: cmdline /ErrorStdOut with /AutoIt3ExecuteLine. (Fixed by Valik)
- Added: Call with parameters (Doc missing but just add parameters as needed). (by Valik)

3.1.1.101 (10th January, 2006) (beta)

- Fixed: _INetSmtpMail().
- Added: @COM_EventObj. (by Valik)
- Fixed: AutoIt crash when using embedded OBJ on 2 child GUI.
- Added: DllCall with ordinal entry point (waiting Doc). (by Holger)
- Fixed: Support for the COM Currency (VT_CY) datatype.

3.1.1.100 (7th January, 2006) (beta)

- Fixed: SplashTextOn Doc for opt=32.
- Fixed: ElseIf ... Then statement not detected.
- Fixed: TCPRecv Doc.
- Fixed: Crash when using @IPADDRESSn and no network.
- Fixed: Illegal #include with no error message.
- Updated: v1.48 (7 January 2006)
- Fixed: _PathFull() 2 bugs. (by Valik)
- Fixed: _INetSmtpMail() @error 5 (by JPM).
- Fixed: _StringEncrypt() error return.
- Removed: /c command line, only /AutoIt3ExecuteLine working.

3.1.1.99 (30th December, 2005) (beta)

- Added: SplashTextOn opt=32 to center vertically.
- Fixed: RegRead return right number of fields on REG_MULTI_SZ type.
- Fixed: DllStructSetData element overflow. (Fixed by Larry)
- Added: DLLStruct...Data BinaryString support. (by Larry)
- Fixed: GUICtrlSetImage on a GUI defined with $WS_VISIBLE.
- Fixed: Fatal error $Object.ImageList.Images.Add($Array[0] & 'b').
- Fixed: GUICtrlSetState( ,$GUI_FOCUS) changing tab ordering. Need to create a new state $GUI_ONTOP for solving livewire problem (.93).
- Fixed: Extra notification on first/default control after GUISetState().
- Fixed: Allow Dragfile to any control. @GUI_DragFile contain the filename to be used in the $GUI_EVENT_DROPPED.
- Fixed: COM ref warning about doc examples.
- Fixed: FileRead($handle).
- Fixed: Event notification on {enter} on an edit control.
- Updated: UDF v1.47 (30 December 2005)
- Fixed _DateTimeFormat() to return LongTime notation for $sType=0 as specified in the Helpfile. (JdeB)
- Made Subject and Body optional in _INetSmtpMail(). (PartyPooper)

BUMP you have to change script which spawn other with the /c switch. Until beta 3.1.1.99 you will get a popup telling that the /c will soon be removed for ever. Will be removed in 3.1.1.100.

3.1.1.98 (23rd December, 2005) (beta)

- Fixed: HotKeySet("",... return 0 + doc typo.
- Fixed: GUICtrlSetState( ,$GUI_FOCUS) on button repainting.
- Fixed: _INetGetSource().
- Fixed: ExpandVarStrings $$, ExpandEnvStrings %%.
- Fixed: GUISetCursor(16),GUICtrlSetCursor(16) hide the cursor.
- Fixed: FileInstall in a compiled GUI whose name is not .exe or .a3x.
- Fixed: $GUI_EVENT_MOUSE firing without any mouse movement.
- Fixed: Typo in ASCII appendix.
- Fixed: WinWaitClose return doc.
- Updated: UDF v1.46 (21 December 2005)
- Fixed doc for _FileReadToArray(). (LxP)
- Fixed doc and Example for _ArraySearch(). (Knight)
- Fixed _ArraySearch() return value in case not found to -1. (SolidSnake)
- Added _INetSmtpMail() to Inet.au3. (Walkabout)

3.1.1.97 (15th December, 2005)(beta)

- Fixed: PixelSearch for 25% regression. (Fixed by Larry)
- Fixed: $GUI_EVENT_DROPPED @GUI_DragId, @GUI_DropId.

3.1.1.96 (14th December, 2005) (beta)

- Fixed: #include-once in main script.
- Fixed: Drag&Drop of listviewitem onto another listview. $GUI_ACCEPTFILES has been renamed in $GUI_DROPACCEPTED.
- Fixed: PixelSearch performance. (Fixed by Larry)
- Fixed: Send doc about minimum key repetition= 1.

3.1.1.95 (12th December, 2005) (beta)

- Fixed: InetGet regression from .94.

3.1.1.94 (11th December, 2005) (beta)

- Fixed: FileRead in raw mode on error skip read block.
- Updated: onAutoItStart and onAutoItExit in the help index.
- Fixed: InetGetSize, InetGet @error return.
- Fixed: Docs typo.
- Fixed: DLLStruct... return 1 on bad array passed.
- Fixed: GUICtrlSetPos with a Child window.
- Updated: Windows Titles and Texts (Advanced) for "regexp=".
- Cleaned : Old handle= in title definition. This parameter was not in the doc anymore since official release 3.1.1.
- Fixed: Run("a.tmp") a.tmp being a compiled script.
- Fixed: TabStop order.
- Fixed: StringSplit("a : b + "," : ").

Update your old script 3.1.0 for handle=. In a lot case the "handle=" & $gui was not working since 3.1.1.66 due to HWnd type.

3.1.1.93 (7th December, 2005) (beta)

- Updated: Include beta files are also stored in separate folders to anticipate no destruction of released includes as today.
- Added: GUICtrlGetHandle(). (by Holger)
- Fixed: DLLStruct... return 1 on error.
- Removed: DLLStructDelete($Struct) use $Struct=0 even nothing if it is local.
- Updated: Fatal error message if DllCall cannot be executed.
- Fixed: FileRead in raw mode return error.
- Updated: DllStructCreate can contain space.
- Fixed: FileRead no count non empty file.
- Fixed: Background label bad firing when overlayed by an edit control.
- Fixed: FileOpen() doc typo.
- Fixed: TraySetToolTip can be up to 128 with 2000/XP/2003. (Fixed by Holger)
- Fixed: GUI updown control notification if change with keyboard.
- Updated: Window title doc precision (not perfect).

You have to update your script using DLLStructDelete.

3.1.1.92 (2nd December, 2005) (beta)

- Fixed: AutoIt hard crash with /AutoItExecuteScript with no file.
- Fixed: TCPListen not registering.
- Updated: Some precision in Hello tutorial.
- Updated: UDF v1.45 (2 December 2005)
- Fixed _PathSplit(). Changed Dim $aArray[5] to Local $aArray[5]. (LxP)
- Updated _INetGetSource(), Remove stripping last character in return string. (w0uter)
- Fixed return value in _GUICtrlTreeViewDeleteItem when item id passed in. (gafrost)
- Updated GUI UDFs: Update Includes and Templates for use with external controls
Meaning controlID for autoit control, control hWnd for external control
Also replace all Dim statements with Local. (gafrost)

3.1.1.91 (27th November, 2005) (beta)

- Changed: /c command line switch change to /AutoIt3ExecuteLine to allow /c to be use by the scripter in compiled scripts.
- Updated: /AutoIt3ExecuteScript scriptfilename allow compiled script to execute script already install or just install by FileInstall.
- Fixed: FileRead returning @error=-1 on empty file.

YOU have to change script which spawn other with the /c switch. for beta 3.1.1.99 you will get a popup telling that the /c will soon be removed for ever.

3.1.1.90 (25th November, 2005) (beta)

- Fixed: GUICreate with WS_VISIBLE do an implicit GUISetState().
- Fixed: ObjEvent error when function does not exist.
- Added: FileCreateNTFSLink(). (by jpm)
- Updated: FileRead() count optional to read the entire file. (by LxP)
- Updated: Some doc clarification about command line switches.
- Fixed: RunWait related link in doc.
- Fixed: Crash Autoit Ending after not closing file open in raw mode.
- Fixed: StdoutRead with null StdIn, Stdout, Stderr applications.
- Updated: Some doc precision in For...Next and For...In...Next. (by JdeB)
- Updated: UDF v1.44 (25 November 2005)
- Fixed _ReplaceStringInFile() to avoid adding CRLF when missing at the EOF. (JdeB)
- Added _ProcessGetName() to Process.au3. (Erifash)

3.1.1.89 (21st November, 2005) (beta)

- Fixed: Compilation of include with #cs.

3.1.1.88 (19th November, 2005) (beta)

- Fixed: Refreshing of dispayed tabitem after a tabitem delete.
- Fixed: StringSplit($a," - ",1) string delimiter.
- Updated: Some checking in uninstaller waiting JON not agressive Uninstaller. Non AutoIt include are preserved.
- Fixed: Some doc typos.
- Fixed: Return code from delayed function as WinWait destroyed by Adlib execution.
- Fixed: MouseGetCursor doc example.
- Fixed: Invalid line continuation not detected.
- Fixed: FileInstall on same dir.
- Fixed: GUICtrlRead on ListViewItem doc precision.
- Fixed: Func definition with ByRef and default value.
- Fixed: missing #ce in #include. Still Aut2Exe to be corrected too.
- Updated: UDF v1.43 (18 November 2005)
- Fixed _DateAdd() Typo's in helpfile. (Gene)
- Updated _INetMail() with new logic to support environment variables. (JPM)
- Updated _GUICtrlListViewDeleteItemsSelected() with Test for Array. (CatchFish)
- Added a Constant to GUIList.au3 and changed all examples. (gafrost)

3.1.1.87 (7th November, 2005) (beta)

- Fixed: @DesktopHeight/Width doc typo.
- Added: VC8 compilation support. (by Valik)
- Fixed: Float to Integer precision.
- Fixed: Bad FatalError after Exit in UDF. Only the first FatalError will be displayed if any before Exit
- Updated: Internal change in Handle value.
- Fixed: Integer to string conversion.
- Fixed: Crash if ObjEvent refer to a function having ByRef parameter.
- Fixed: GUICtrlSetData can delete a specific column.
- Fixed: memory leak on GUIDelete($tabitem with icon). (Fixed by Holger, jpm)
- Fixed: StringMid($a,3).
- Fixed: StringSplit($a,"").

3.1.1.86 (3rd November, 2005) (beta)

- Fixed: String... on nonstring parameters.
- Changed: FileClose,File... suppression of AutoIt runtime error. (Valik suggestion)

3.1.1.85 (3rd November, 2005) (beta)

- Updated: GUICtrlCreateGraphic default size.
- Updated: AutoIt3Help.exe (no KeyHH.exe need)
- Fixed: ObjEvent() doc typo.
- Updated: Several tabular display in Doc.
- Removed: Binary(), IsBinary() to BinaryString(), IsBinaryString().
- Updated: String... support BinaryString variables.
- Updated: @OSVersion = WIN_6.0(Vista?), WIN_6.1(LongHorn?).
- Fixed: Crash on Exit Autoit after using GUICtrlCreateObj and GUICtrlDelete on another control.
- Fixed: Console... doc related links.
- Fixed: Empty command line parameter (""). (Fixed by Tylo, jpm)
- Updated: ControlSend Doc to make clearer ref to control/window.
- Fixed: @ScriptLineNumber not significant in compiled script.
- Fixed: FileCopy when creating subdir.
- Fixed: ControlClick doc precision.
- Fixed: Language->comments example.
- Fixed: IniReadSection doc.
- Fixed: bad var definition.
- Fixed: Crash after GUICtrlDelete of a control having the focus.
- Updated: UDF v1.42 (2 November 2005)
- Updated _ArrayToString() documentation, changed parameter order. (Josbe)
- Updated _FileList2Array: removed checking for "." and ".." from the return from FileFindNextFile(). (SolidSnake)
- Added _SetDate() and _SetTime() to Date.au3. (/dev/null)
- Added _StringInsert() to String.au3. (Celeri)
- Fixed bug in the _GUICtrlListViewDeleteItem. (gafrost)

3.1.1.84 (18th October, 2005) (beta)

- Updated: GUICtrlCreatePic("",... create an empty pic no more returning error. (Thank Larry, ...)
- Fixed: Default keyword = -1 in arithmetic computation.
- Fixed: False and False = False.
- Fixed: Grey coloring of input/edit control when disabled.
- Updated: Binary doc example.
- Fixed: Crash on AutoIt exit when GUICtrlCreateObj used with some .OCX. Temporary go around waiting SvenP correction.
- Updated: GUICtrlCreateEdit doc to include an example to how to have a richedit control using GUICtrlCreateObj. (Fixed by kjactive)
- Fixed: FileClose,FileFindNextFile, FileRead, FileReadLine, FileWrite, FileWriteLine, PluginClose, DllClose return 0 on bad handle.
- Fixed: Bad index when opening help thru SciTE editor.

3.1.1.83 (11th October, 2005) (beta)

- Removed: MsgBox, SplashTextOn and TrayTip text convert binary string to hex for display. (Valik disagree)
- Updated: UDF v1.41 (10 October 2005)
- Fixed BUG in _ReplaceStringInFile() always replacing multiple occurences on a single line. (Wooltown/LxP)
- Added _GUICtrlListSelectIndex to GuiList.au3 for single select listbox's. (gafrost)

3.1.1.82 (10th October, 2005) (beta)

- Fixed: FileCopy, FileInstall, DirCopy, FileMove replacing the same file.
- Fixed: DllStructCreate no more case sensitive but still space sensitive.
- Fixed: AutoIt Crash when creating a control on a minimized window.
- Added: MsgBox, SplashTextOn and TrayTip text convert binary string to hex for display.
- Fixed: TCPSend, UDPSend really send Binary strings (I hope). (Sorry VicTT)
- Fixed: GUICtrlSetImage icon.
- Updated: UDF v1.41- (10 October 2005)
- Added _GUICtrlListSelectIndex to GUIList.au3. (gafrost)

3.1.1.81 (7th October, 2005) (beta)

- Fixed: Some doc typos.
- Fixed: Reg... functions on IA64/X64.
- Fixed: FileFindFirstFile() leak handles.
- Fixed: @IpAddress when not network installed.
- Added: TCPSend, UDPSend can send Binary strings.
- Updated: UDF v1.40 (5 October 2005)
- Fixed error in _ArrayToString() example. (/dev/null)
- Changed _WeekNumberISO() to return the proper ISO weeknr.
Also removed startday parameter because ISO weeks always starts on Monday.
- Added _DateToDayOfWeekISO() which returns the ISO day number. 0=Monday - 6= Sunday
- Updated: UDF v1.39 (27 September 2005)
- Updated _INetGetSource(). (w0uter)
- Fixed: AutoIt crash on GUICtrlCreateObj with bad object.
- Fixed: ObjEvent returns "" on error.
- Fixed: _GUICtrlListViewDeleteAllItems (Fixed by gafrost)
- Restriction : ControlListView cannot reference a 64-bit process as Explorer.

3.1.1.80 (29th September, 2005) (beta)

- Fixed: Bad autoit-v3.1.1.79-beta-Setup.exe due to MS spyware which destroy the NSIS.

3.1.1.79 (28th September, 2005) (beta)

- Fixed: Reference to AutoIt functions in UDF doc.
- Fixed: UDPRecv regression.
- Fixed: Tabitem icons.
- Fixed: Listview sorting with using styles: $LVS_SORTASCENDING and $LVS_SORTDESCENDING.
- Fixed: @ProcessorArch on 64-bit Windows.
- Fixed: StringLen(integer) returning 0.

3.1.1.78 (27th September, 2005) (beta)

- Fixed: Real merging of Holger .77 submission. I just update the history!!! (Sorry Holger)

3.1.1.77 (26th September, 2005) (beta)

- Fixed: Binary, IsBinary in tree doc.
- Fixed: Binary on nonstring variable.
- Added: Hex() support binary.
- Updated: DriveGetDrive, DriveGetType, DriveSpaceFree, FileGetTime, WinGetClassList, WinGetClientSize, WinGetPos does not return 1 on error but 0 or "".
- Fixed: TCPRecv regression.
- Fixed: StringRegExpReplace regression.
- Fixed: Memory overflow in customdraw operations in GUI while scrolling. (Fixed by Holger)
- Added: icons for tab items. (by Holger)
- Added: set bold font/painting for treeview items. (by Holger)
- Updated: UDF v1.38 (26 September 2005)
- Fixed GUICtrlTreeViewDeleteItem() selection logic. (gafrost)
- Fixed GUICtrlTreeViewSelectItem() but removed Helpfile info because function is obsolete. (gafrost)

3.1.1.76 (23rd September, 2005) (beta)

- Fixed: Toggle AU3 Beta underscore.
- Fixed: FileOpen,FileMove Doc typos.
- Updated: GUI... optimisations. (By gafrost)
- Fixed: bkcolor label on tab if ListViewItem.
- Changed: No more minimum size with GUICreate.
- Fixed: $SS_CENTERIMAGE on pic control.
- Removed: Added 1 to the result of \# to compensate for the fact that c-strings are 0-based and AutoIt strings are 1-based. (by Nutster)
- Fixed: bug in line continuation inside strings. Line continuation now disabled inside strings. Use string concatenation instead. (Fixed by Nutster)
- Updated: Optimize internal trailing and leading (by Nutster)
- Changed: Now strips all whitespace if a line is made entirely of whitespace, instead of aborting the function. (by Nutster)
- Updated: GUISwitch doc precision.
- Updated: Internal split of AutoIt and UDF helps.
- Fixed: FileReadLine with line=0.
- Added: Binary, IsBinary Functions.
- Updated: FileRead, FileWrite binary files, just read and write
- Changed: TCPRecv, UDPRecv removed Flag as a Binary string will be generated if needed.
- Updated: UDF v1.37 (20 September 2005)
- Added _FileWriteFromArray() to file.au3. (jdeb)
- Updated _INetGetSource(). (w0uter)
- Updated _TempFile() with optional parameters. (hansh)
- Fixed documentation for _FileListToArray(). (mlazovjp/Dickb)
- Some code optimization changes: GuiList, GuiTreeView, GuiEdit (gafrost)
- Fixed logic issue with _GUICtrlListViewSetColumnOrder and _GUICtrlComboGetEditSel. (jdeb)
- Fixed a few minor documentation issues.

Outstanding bugs: Regular Expression: "(?i)<(.+?)>(.*?)</\1>" not matching properly.

3.1.1.75 (9th September, 2005) (beta)

- Fixed: StringRegExp doc (Sorry Nutster I miss it)
- Fixed: SendKeyDelay, SendKeyDownDelay when no shift required.
- Fixed: @HotKeyPressed added to macro doc.
- Added: FileOpen, FileCopy, FileMove additional flag to create non existent subfolder. (by Holger)
- Fixed: Bad GUICtrlSetResizing when not first show has occured.

3.1.1.74 (7th September, 2005) (beta)

- Added: TCPRecv,UPDRecv optional parameter to convert received data in Hex.
- Fixed: _StringToHex(), _HexToString() return error. (Fixed by jpm)
- Updated: RegRead doc.
- Fixed: Plugins for AU3_SetString. (/dev/null/Jon)
- Added: ContinueCase to keywords allowed after IF. (by Nutster)
- Changed: Set _ to be a continuation character only after whitespace. It does not matter if a comment follows the continuation character or not. \ is not a continuation character. (by Nutster)
- Added: Switch, EndSwitch, ContinueCase, Default to list of keywords in documentation file. (by Nutster)
* Update : regular expression classes to match those in use by other regular expression engines. Added blank, graph, print, cntrl classes. (by Nutster) (MISSING DOC)
- Fixed: bug in zero-count predictor that prevented characters from matching properly if skipped. (by Nutster)
- Changed: Added 1 to the result of \# to compensate for the fact that c-strings are 0-based and AutoIt strings are 1-based. (by Nutster)
- Fixed: bug that prevented pattern "^$" from matching an empty string. (by Nutster)
- Fixed: listview repainting on tab.
- Updated: UDF v1.36 (5 September 2005)
- Updated _DateTimeFormat(): Added option 5 which returns time in 24 hour HH:MM:SS format. (jdeb)
- Updated _NowTime(): Added optional parameter to select the return format. (jdeb)
- Fixed Documentation _MouseTrap() (JPM)
- Fixed _GUICtrlTreeViewDeleteItem bug in delete of item after adding child items. (gafrost)
- Updated _StringToHex() and _HexToString() error testing. (JPM)
- Updated Doc return Value formating. (JPM)

3.1.1.73 (2nd September, 2005) (beta)

- Fixed: For...In...Next doc example.
- Fixed: @SW_TRAY... doc removal.
- Fixed: GUICtrlCreateIcon icon size in multiple icon .ico file
- Fixed: Send("{SHIFTDOWN}") , ... before Jon reanalysis.
- Fixed: ControlSetText not refreshing group control.
- Updated: Slight doc precision.
- Updated: RegEnum... doc examples.
- Fixed: Pic control size inside a group control.
- Updated: UDF v1.35 (31 August 2005)
- Fixed _IsPressed() Example. (gafrost)

3.1.1.72 (30th August, 2005) (beta)

- Added: separate colors for listview/treeview items. (by Holger)
- Updated: Gets more exactly position for contextmenu for listview/treeview items. (by Holger)
- Fixed: a small flickering bug in CtrlSetImage() for treeview items. (Fixed by Holger)
- Changed: TraySetState() optional parameter values. (by Holger)
!!! Breaks current beta scripts if used TraySetState(x) with optional parameter !!!
- Fixed: GUICtrlSetPos, GUICtrlSetResizing use visible window.
- Fixed: Crash on rightclick on treeview or listview. (Fixed by Holger)
- Removed: @UserFuncName to much overhead for simple script constraint. (By Jon)
- Added: PluginOpen, PluginsClose. (By Jon)
- Updated: UDF v1.34 (30 August 2005)
- Fixed _ArraySearch() example to point to Array.au3.
- Updated _IsPressed() Added optional param to function for those that will use
the function heavily they can pass a handle to the function for the dll. (gafrost/w0uter)

3.1.1.71 (28th August, 2005) (beta)

- Fixed: GUIGetMsg returning on Input control change.
- Fixed: GUICtrlCreateInput/Edit forcing WS_TABSTOP when ES_READONLY.
- Fixed: Exit inside UDF.
- Fixed: Resizing of controls dynamically created.
- Updated: Some clarification on return value = none.
- Added: @UserFuncName useful for debugging. (by Kurt aka /dev/null)
- Updated: UDF v1.32 (28 August 2005)
- Added _IsPressed() (Ezzetabi/Jon)
- Updated Corrected return value for _MouseTrap() if no params passed. (gafrost)
- Added _GUICtrlComboAutoComplete (gafrost)
- Restored correct example for _GUICtrlListViewGetItemText (jdeb)
- Added _ArrayPush() to Array.au3 (hgeras)
- Added _ArraySearch() to Array.au3 (SolidSnake)
- Added _ReplaceStringInFile() to File.au3 (\dev\null)
- Updated: UDF v1.33 (28 August 2005)
- Updated _ProcessGetPriority() script logic and fixed example. (MSLx Fanboy)

3.1.1.70 (26th August, 2005) (beta)

- Fixed: GUI click return position(bad correction). (sorry Holger)

3.1.1.69 (26th August, 2005) (beta)

- Updated: GUICtrlSetImage doc for Treeview/Listview. (by Holger)
- Updated: Doc typos BitRotate doc.
- Fixed: GUICtrlCreateCombo and $CBS_DROPDOWNLIST color.
- Fixed: GUICtrlCreateDate and $DTS_UPDOWN.
- Fixed: GUI click return position. (Fixed by Holger)
- Updated: Internal code mainly keyword. (by Jon)
- Fixed: HWND string concatanation. (Fixed by Valik)
- Fixed: Au3Info dispalying styles (Bad update at icon change)
- Fixed: GUICtrlCreateTreeView doc example.
- Updated: UDF v1.31 (13 August 2005)
- Updated _MouseTrap() (gafrost)
- Updated _GUICtrlEditScroll: Added $SB_SCROLLCARET - Scrolls the caret into view. (gafrost)
- Added _ProcessGetPriority() to Process.au3 (MSLx Fanboy)
- Added _FilePrint() to File.au3 (Erifash)

3.1.1.68 (12th August, 2005) (beta)

- Fixed: FuncOnAutoItExit typo.
- Updated: UDF v1.30
- Fixed _DayValueToDate() to return Day and Month in the proper format.
- Fixed _DateTimeFormat() to return HH:MM in proper 24 hour notation for $sType=0.
- Added: BitRotate function. (By Nutster)
- Fixed: direction in BitShift documentation. (By Nutster)
- Updated: Made regular expression patterns \n and \r distinct in StringRegExp and StringRegExpReplace. Old \n became \N.
- Updated: Internal code. (by Nutster)
- backup : Aut2Exe allowing .a3x with old logo.

3.1.1.67 (11th August, 2005) (beta)

- Fixed: _ArrayReverse() example typo. (Fixed by gafrost)
- Fixed: StringSplit doc clarification.
- Fixed: lexer cache. (by Nutster)
- Fixed: Fixed bug (again) in AutoItSetOption to the definition of MouseClickDragDelay. (Fixed by Nutster)
- Updated: Internal code. (by Nutster)
- Removed: Check to InitScript to scan all variables in the script and make sure they are well-formed, not beginning with digits. (by Jon)
- Fixed: InputBox left,top values when not defined.
- Fixed: Crash when deleting an input control.
- Fixed: BitShift, Break, BlockInput doc.
- Fixed: FileFindNextFile return error.
- Added: @ScriptLineNumber, @ProcessorArch
- Fixed: MouseClick, WinFlash doc typo.

3.1.1.66 (5th August, 2005) (beta)

- Fixed: MouseClickDelay option. (Fixed by Nutster)
- Added: Check to InitScript to scan all variables in the script and make sure they are well-formed, not beginning with digits. (by Nutstser)
- Updated: Documentation for StringRegExp. (by Nutster)
- Changed: Simplify StackStructure(internal). (by Nutster)
- Fixed: GUIGetCursorInfo primary/secondary under nonXP. (Fixed by Holger)
- Fixed: GUICtrlSendMsg, TraySetState doc link.
- Fixed: Obj returning handle. (Fixed by SvenP)
- Added: $GUI_WS_EX_PARENTDRAG Allow the label or pic control to be used as the title bar to drag the whole the parent window.
- Updated: ComRef doc.(by SvenP)
- Fixed: ReDim of array ByRef parameter.
- Fixed: GUICtrlSetState($tabitem,$GUI_SHOW) on visible GUI.
- Fixed: FileFindFirstFile doc.
- Updated: New AutoIt Logo/icon. (by Jon)
- Added: _MouseTrap() to Misc.au3. (by gafrost)
- Updated: Internal ContinueCase perf optimisation. (by Nutster)
- Added: _Singleton() to Misc.au3. (Valik code+)
- Fixed: ContinueCase type doc.
- Fixed: _GUICtrlListViewSort if no items in listview.
- Added: HWnd and IsHWnd functions. (By Valik)

3.1.1.65 (28th July, 2005) (beta)

- Added: Silent beta install no messagebox warning.
- Fixed: Decompiler (beta) link.
- Added: FileSaveDialog, FileOpenDialog with multiple filter groups. (by Holger)
- Fixed: Weird behavior when resizing column of listview on a tab.
- Fixed: _ArrayReverse_ doc.
- Added: Extra page in the uninstaller to clean all AutoIt installations. (for Valik)
- Fixed: Default keyword check for third parameter of MsgBox. (Fixed by Nutster)
- Added: Switch, EndSwitch structure. (by Nutster)
- Added: ContinueCase keyword to have a case in Select or Switch continue executing in the next case. (by Nutster)

3.1.1.64 (25th July, 2005) (beta)

- Updated: FileInstall doc precision.
- Fixed: GUIGetCursorInfo() doc.
- Fixed: Run 4th parameter validity. (By DaveF)
- Added: GUISetState(@SW_LOCK/@SW_UNLOCK) to manage repainting.
- Fixed: Crash in ObjEvent() if Event Interface could not be found.
- Fixed: Crash in ObjName() if description could not be found. (Fixed by SvenP)
- Added: _GUICtrlListViewCopyItems to GUIListView.au3. (gafrost)
- Fixed: _INetGetSource() source/doc.
- Updated: Exe2Aut.exe works for any version .exe or .a3x. (By Jon)
- Added: Icon-View in GUI-ListView. (By Holger)
- Fixed: GUICtrlSetData flickering.

3.1.1.63 (22nd July, 2005) (beta)

- Removed: Assign respect Opt("MustDeclareVars",1).
- Fixed: IsBool() doc.
- Fixed: GUICtrlSetPos lead to a bad resizing.
- Added: ObjName() function. Returns the name or the interface description for the given Object variable. (By SvenP)
- Fixed: Object reference leaks in ObjEvent(). (By SvenP)
- Fixed: _GUICtrlListViewGetCurSel() returns.
- Fixed: Creation of item on non selected GUI.

3.1.1.62 (20th July, 2005) (beta)

- Fixed: _GUICtrlListViewDeleteItemsSelected()
- Fixed: ObjCreate bad link in doc.
- Fixed: @NumParams destroyed after UDF call.
- Fixed: Control Creation on an active tab (GUISwitch).
- Fixed: StringRegExp's group parentheses identification routine. A \( immediately followed by \) (or vice-versa) inside a group would cause problems. (Fixed by Nutster)
- Added: class identification to StringRegExp. See documentation file for details. (By Nutster)
- Fixed: InputBox width not working.
- Fixed: GUISetCoord typo
- Fixed: Obj/COM Error Handling example
- Added: IsBool() functions. (By Nutster)
- Updated: UDF v1.28
- Fixed _INetGetSource().au3 example (W0uter)
- Fixed _FileReadToArray(): added StringStripCR to avoid @CR characters in the Array values. (jdeb)
- Fixed _GUICtrlListViewDeleteItemsSelected was not working correctly (gafrost)

3.1.1.61 (17th July, 2005) (beta)

- Updated: String...() examples. (By Nutster)
- Fixed: Doc related links.
- Fixed: GUICtrlSetImage repainting.
- Fixed: InputBox, MsgBox default parameter. (Sorry Nutster for the bad modif I did to your code)
- Added: ConsoleWriteError(). (By Valik)
- Added: UDFs v1.27 (By JdeB/gafrost)
- Added _Radian() and _Degree() to Math.au3 (Erifash)
- Added _FileList2Array.au3 to File.au3 (Solid)
- Added _INetGetSource().au3 to Inet.au3 (W0uter)
- Fixed documentation for _ArraySort() (jdeb)

3.1.1.60 (16th July, 2005) (beta)

- Fixed: GUICtrlSetData with float value.
- Changed: Opt, InputBox, MsgBox can use default keyword (By Nutster)
- Added: Aut2Exe small compile file .A3X. (by JON, yes sometime he writes code, in fact very good one)
- Added: @AutoItPID macro. (By Valik)
- Added: ConsoleRead(). (By Dave)
- Fixed: GUIGetCursorInfo() doc typo.
- Added: COM properties or methods can now also be used immediately to array elements containing objects. (By SvenP)
- Added: Usage of 'Default' keyword instead of empty arguments to COM functions (only valid if COM function supports it). (By SvenP)
- Added: UDFs v1.25/26 (By JdeB/gafrost)
- Fixed _GUICtrlListViewGetNextItem. (gafrost)
- Fixed _GUICtrlListViewDeleteAllItems and _GUICtrlListViewDeleteItem when _GUICtrlListViewInsertItem used to populate the ListView. (gafrost)

3.1.1.59 (14th July, 2005) (beta)

- Added: Default keyword can be used to replace -1 in AutoIt Functions call.
- Fixed: DllStructCreate doc typo.
- Fixed: COM ref doc typo.
- Added: UDFs v1.24 (By JdeB/gafrost)
- Fixed _GUICtrlListViewGetNextItem.au3 example (gafrost)
- Fixed _DateIsValid() Documentation and Example.

3.1.1.58 (13th July, 2005) (beta)

- Fixed: Repainting label modify by GUICtrlSetData.
- Fixed: if $a = default
- Fixed: $a=30e-006.
- Fixed: RegEnumVal return type in @error instead os @extended.

3.1.1.57 (12th July, 2005) (beta)

- Updated: RegEnumVal return the type of the value in @extended (by Holger)
- Fixed: StringReplace("abc","","") returns 1 instead of "".
- Fixed: Execute() doc.
- Added: WinMove with x,y =default will not move just resize.
- Added: IsKeyword(), default keyword can be used as parameter in a function call.
- Fixed: GUITreeViewItem notifies wrong on first setting focus on a GUITreeView..
- Fixed: WinSetTrans return error.
- Added: False and Bool keywords doc.
- Fixed: Assign not creating/assigning macro variable.
- Fixed: Assign respect Opt("MustDeclareVars",1).
- Fixed: GUICtrlCreateObj() no longer closes the object after the control (or GUI) has been deleted. (Fixed by SvenP)
- Updated: GUICtrlRead with Checbox, Radio, doc precision.
- Fixed: Redeclare of local variable.
- Fixed: Prevent Assign from assigning to a constant. (Fixed by Nutster)
- Fixed: Crash Autoit in FileFindFirstFile on empty dir.
- Fixed: Array initialised as empty.
- Added: UDFs v1.23 (By JdeB/gafrost)
- Updated _TimeToTicks(): Make parameters optional defaulting to current time (slimshady)
- Corrected Example for _GUICtrlTreeViewGetParentHandle (gafrost)
- Fixed _StringEncrypt() parameter redeclaration
- Added _GUICtrlTreeViewGetParentID to GuiTreeView (gafrost)

3.1.1.56 (5th July, 2005) (beta)

- Updated: GUIGetCursorInfo doc.
- Updated: SplashImageOn, SplashTextOn doc.
- Fixed: Ping better return results. (Fixed by Holger)
- Updated: Authors contributions.
- Updated: UDPOpen, UDPBind return an array. UDPSend, UDPRecv use it instead of the socket/ip/port. (by /dev/null)
- Updated: RegRead return the type of the value in @extended
- Fixed: Window Titles and Text (Advanced) links doc
- Fixed: Mouse... returns.
- Fixed: MouseClick, MouseUp bad behavior.
- Changed: Split Eval()->Execute()
- Fixed: FileFindFirstFile does not return anymore "." or "..".
- Fixed: _GuiCtrlTreeView examples. (Fixed by gafrost)
- Added: _GUICtrlTreeViewGetParentHandle(). (by gafrost)
- Fixed: variables already declared in string.au3 (Fixed by jdeb)
- Fixed: Crash in tray functions

3.1.1.55 (27th June, 2005) (beta)

- Fixed: ControlCommand "GetCurrentSelection".
- Added: SetError setting optionally extended code.(by Valik)
- Fixed: GUICtrlCreateObj doc (Sorry SvenP I miss it)
- Fixed: bug in ByRef/Const keyword use in UDF's. (Fixed by Nutster)
- Fixed: bug in UDF calling which allowed a trailing comma. (Fixed by Nutster)
- Fixed: Prevent constants from being used to initialize themselves in CONST keyword. (Fixed by Nutster)
- Fixed: bug in Const init. (Fixed by Nutster)
- Fixed: bug in Const array init. (Fixed by Nutster)

3.1.1.54 (26th June, 2005) (beta)

- Fixed: Send("+{end}").
- Fixed: Issues in GUICtrlCreateObj() concerning 'document objects'. Document objects are now working in a GUI, however not all functions have been implemented yet. (Fixed by SvenP)
- Fixed: Some more issues when assigning object references to other object's properties. (Fixed by SvenP)

3.1.1.53 (25th June, 2005) (beta)

- Fixed: Several issues in GUICtrlCreateObj(). (Fixed by SvenP)
- Fixed: TCPRecv returning error(2) (Fixed by Larry)
- Added: Assigning Object variables to other Objects properties ('propputref') (By SvenP)
- Fixed: Object reference count bug in ObjCreate() since version 3.1.1.33. Objects would stay open after releasing their variable (Fixed by SvenP)
- Removed: bug in Const keyword to UDF parameters. (Waiting Nutster correction)
- Updated: UDP functions now UDPSend need the ip:port. Doc examples (By /dev/null)

3.1.1.52 (24th June, 2005) (beta)

- Fixed: UDPBind, UDPOpen return socket
- Added: UDPStartup, UDPShutdown
- Fixed: GUIListView GUITab Const
- Fixed: File...Dialog browse through links
- Fixed: Send("{SHIFTDOWN}") no permanent
- Fixed: TCPRecv() returning more error (Fixed by Larry)

3.1.1.51 (23rd June, 2005) (beta)

- Updated: TCPSend, TCPRecv examples (erifash/Larry)
- Added: Const keyword to UDF parameters.
- Fixed: Treeview painting under OS <XP (Fixed by holger)
- Fixed: Listview extend style in GuiConstant.au3 and in Doc.
- Updated: UDFs 1.21 (By JdeB/gafrost)
- Fixed Dim for $h_Tree in _GUICtrlTreeViewItemGetTree. (gafrost)
- Added variable passed in to _GUICtrlTreeViewItemGetTree and changed example to reflect this change for separator char. (gafrost)

3.1.1.50 (20th June, 2005) (beta)

- Updated: UDFs 1.20 (By JdeB/gafrost)
- Removed the following functions from GuiListView.au3: (gafrost) _GUICtrlListViewSetBkColor _GUICtrlListViewSetTextBkColor _GUICtrlListViewSetTextColor
- Fixed _GUICtrlTreeViewDeleteItem() to deleted more than 2 levels deep. (gafrost)
- GUICtrlTreeView.au3 UDF's (gafrost)

3.1.1.49 (20th June, 2005) (beta)

- Added: $COLOR_... in <Constants.au3>
- Updated: GUISwitch tabitemID optional parameter to allow dynamic control creation on a tabitem.
- Fixed: TraySetOnEvent, DllStructCreate, DllCall, UDP...doc.
- Fixed: Make sure that declaring a UDF parameter in a Local or Global statement will raise an error.
- Fixed: Bug with accelerator keys (Alt+...) and tabs.

3.1.1.48 (15th June, 2005) (beta)

- Fixed: GUIGetCursorInfo with nonactive GUI
- Removed: Bad refresh on double GUICtrlSetPos : AutoBuilder cannot resize control. Cannot work around a Windows bug.
- Added: Support for Type Libraries that don't register themselves using version 1.0 (like Crystal Report version 8.0) (By SvenP)

3.1.1.47 (14th June, 2005) (beta)

- Fixed: GUICtrlSetState disable on hidden control tab
- Fixed: Send("+{END}t)
- Added: GUICtrlSetImage for GuiListViewItem control (By Holger)
- Updated: Internal optimisation in AutoItSetOption() (By Nutster)
- Fixed: TrayItemGetText return
- Updated: GUICtrlSetColor, GUICtrlSetBkColor, GUICtrlSetImage for ListviewItem control. (by Holger)
- Added: Option to ObjEvent to retrieve the name of the current Error Handler function (By SvenP)
- Added: Preliminary GUICtrlCreateObj() support (bugware !). (By SvenP)

3.1.1.46 (10th June, 2005) (beta)

- Changed: Opt() with just the "option" return the current value.
- Fixed: Opt("GUIDataSeparatorChar",...) can be used in listview and listviewitem.
- Fixed: ContextMenu position
- Updated: UDFs 1.19 (By JdeB/gafrost)
- Fixed some merge issues.

3.1.1.45 (9th June, 2005) (beta)

- Fixed: Internal change in array updating bad merge (Sorry Tylo)
- Fixed: GUICtrlSetState on control tab
- Fixed: Tray/contextmenu treeview ... (Fixed by Holger)
- Updated: UDFs 1.18 (By JdeB/gafrost)
- Fixed descending sort issue in multi dimension arrays.
- Fixed _GUICtrlListViewSort() top handle numeric values correctly. (gafrost)
- Renamed _GUICtrlListViewGetColumnOrderArray to _GUICtrlListViewGetColumnOrder
Also corrected documentation for _GUICtrlListViewGetColumnOrder.
Returns a "|" delimited string instead of an array, now matches
the _GUICtrlListViewSetColumnOrder in the data type. (gafrost)

3.1.1.44 (7th June, 2005) (beta)

- Fixed: Crash using ContextMenuItem under NT4.
- Added: requested Regular Expression features: (by Nutster)
a) Add \-, \], and \^ to available escaped characters in sets.
b) Add \b for backspace to sets and to regular escaped characters.
c) Add \D, \S, and \W to be compliments of \d, \s and \w.
d) Add \e to match escape character.
e) Add (?: ... ) to be a non-capturing group. That is the group does not get stored in the array.
f) Add (?i) option to make case-INsensitive match
g) Add (?-i) option to use case-sensitive matching (default)
h) Add (?i: ... ) to be a non-capturing, case-insensitive group
i) Add (?-i: ... ) to be a non-capturing, case-sensitive group
- Added: Floor and Ceiling function (by Nutster)
- Updated: UDFs 1.17 (By JdeB/gafrost)
- Added _GUICtrlSliderGetPos functions in GUISlider.au3 (gafrost)
- Fixed _ArraySort() lockup Bug.

3.1.1.43 (5th June, 2005) (beta)

- Fixed: uninstaller deleting AutoIt Window info link.
- Fixed: Crash when using Obj

3.1.1.42 (3rd June, 2005) (beta)

- Fixed: GUICtrlSetData on inactive tabitem not refreshing active item.
- Fixed: ControlSend (...,"{CTRLDOWN}b{CTRLUP})
- Fixed: _ArraySort() (by JdeB)
- Fixed: ControlSend doc on "Windows control command"/game
- Fixed: Internal change in Array updating (Fixed by Tylo)
- Updated: UDFs 1.16 (By JdeB/gafrost)
- Fixed _ArraySort() to cope with Mixed values and string entries.
- Added _GUISlider??? functions in GUISlider.au3 (gafrost)

- Added _GUICtrlListViewInsertColumn, _GUICtrlListViewInsertItem, _GUICtrlListViewJustifyColumn,

_GUICtrlListViewSetColumnOrder, _GuiCtrlListViewSetItemCount, _GUICtrlListViewSort (gafrost)

3.1.1.41 (27th May, 2005) (beta)

- Fixed: Doc on @exitMethod in Func OnAutoItExit().
- Fixed: Prevent StringRegExpReplace from replacing on a zero-character match.

3.1.1.40 (26th May, 2005) (beta)

- Added: "OnAutoItExit" called on system shutdown or user logoff.
- Fixed: Doc on Func OnAutoItStart(), Func OnAutoItExit(), @exitMethod, @exitCode
- Fixed: OnAutoItExit() call on Fatal error.
- Fixed: Opt("GUIDataSeparatorChar", "\")
- Fixed: TreevieItem notify when clicking a second time on the same item.

3.1.1.39 (23rd May, 2005) (beta)

- Fixed: GUICtrlSetState on non active tab.
- Updated: UDFs 1.15 (By JdeB/gafrost)
- Added 2 Functions to GuiListView.au3: _GUICtrlListViewSetItemSelState and _GUICtrlListViewSetItemText (gafrost)
- fixed type in _GUICtrlListViewGetExtendedListViewStyle helppage.
- fixed typo in _viClose() helppage.

3.1.1.38 (22nd May, 2005) (beta)

- Updated: UDFs 1.14 (By JdeB/gafrost)
- Fixed _GUICtrlListGetSelItems: returned array, was an array of string numbers now an array of numbers. (gafrost)
- Fixed _GUICtrlListViewGetSelectedIndices returned array, was an array of string numbers now an array of numbers. (gafrost)
- Updated _GUICtrlListSetHorizontalExtent documentation. (gafrost)
- Fixed: Some flickering in GUICtrlSetImage.

3.1.1.37 (21st May, 2005) (beta)

- Fixed: Creating an Object on a remote computer failed under alternate credentials. Fixed. The username/password arguments are now available to ObjCreate(). (Fixed by SvenP)
- Fixed: GUIListView.au3 defining _GUICtrlListViewColumnOrderArray (Fixed by JdeB/gafrost)

3.1.1.36 (19th May, 2005) (beta)

- Fixed: DllStructGetSize badly reinserted.
- Fixed: StringRegExp doc (Fixed by Nutster)
- Updated: UDFs 1.13 (By JdeB/gafrost)
- Added _GUICtrlListViewSetCheckState (gafrost)
- Fixed _GUICtrlListViewGetCurSel: If more than 1 item in listview had same data was returning
the index of the 1st instance, now correctly returns the index of item selected. (gafrost)
- Added _GUICtrlMonthCal???? function located in GuiMonthCal.au3 (gafrost)

3.1.1.35 (19th May, 2005) (beta)

- Fixed: DllStructGetSize badly remove.
- Fixed: Some doc Typo.

3.1.1.34 (19th May, 2005) (beta)

- Changed: Eval ("expression") implying hazardeous functions will be rejected.
- Fixed: When an Object variable was placed in a return statement in a UDF, it would not be released on function exit.
- Added: Array initialization (By Nutster).

3.1.1.33 (18th May, 2005) (beta)

- Added: Suppression of message box on Eval with expression errors

3.1.1.32 (17th May, 2005) (beta)

- Added: Appendix defining AutoIt3 limits.
- Fixed: GUICtrlSetGraphic doc typo.
- Added: Eval("expression").
- Added: Ability to use empty parameters in COM functions (like $Object.Method(, , ,"value"). NOTE that parameters ending with a comma (like $Object.Method("value", ) are not allowed!
- Added: UDP... functions (not sure they work as I never be able to have sample true Fur!!!)
- Added: Beep() and WinFlash() functions (By Layer)

3.1.1.31 (15th May, 2005) (beta)

- Fixed: FOR..IN loops previously terminated a script when the given object could not be enumerated. Now, the loop will be skipped silently by default. An error can however still be caught using the AutoIt COM Errorhandler. (Fixed by SvenP)
- Added: Ability to use a default COM Event function, in case the event names of an object are unknown (see documentation). (By SvenP)
- Fixed: Some objects could not be created with ObjCreate() using the Dispatch interface. (Fixed by SvenP)
- Fixed: When a COM Error Handler was created and deleted afterwards (by unassigning it's variable), AutoIt could crash when a COM Error occurs. (Fixed by SvenP)
- Fixed: When an AutoIt script error occured within a FOR..IN loop and no COM Error handler was installed, it could crash AutoIt on exit. (Fixed by SvenP)
- Fixed: Using an Array in COM IADS-filter methods did not work. (Fixed by SvenP)
- Removed: Ability to initialize arrays in DIM and CONST keywords.(seems to introduce regression)

3.1.1.30 (13th May, 2005) (beta)

- Fixed: GUIGetCursorInfo on tab
- Updated: UDFs 1.0.12 (by gafrost/JdeB)
- Added _GUICtrlListViewGetCheckedState to GuiListView. (gafrost)
- Update several Helpfile pages for the _GUI?? functions. (gafrost)
- Update _ChooseColor(). (gafrost)
- Updated _Now(),_NowDate(), _NowTime() that it defauts to mm/dd/yyyy and hh:mm:ss when the pc's format isn't found in the registry (Win9X).
- Fixed: Const definition (Fixed by Nuster).
- Fixed: GUICtrlCreateIcon default size 32,32

3.1.1.29 (12th May, 2005) (beta)

- Fixed: GUICtrlSetPos on Icon control
- Fixed: FileOpenDialog, FileSaveDialog doc on update @WorkingDir.

3.1.1.28 (11th May, 2005) (beta)

- Fixed: Bad refresh on double GUICtrlSetPos
- Fixed: extra GUI_EVENT_RESIZED at first click
- Fixed: COM StorageGroups

3.1.1.27 (10th May, 2005) (beta)

- Fixed: RegRead under Windows 2000
- Fixed: Dim example

3.1.1.26 (10th May, 2005) (beta)

- Fixed: AutoIt Info focus with magnify option
- Fixed: DllCall set @error on bad parameter.
- Fixed: Windows centering of GUICreate
- Fixed: Cmd line option cohabitation /c and /errorstdout (Fixed by SvenP)
- Fixed: String "0" is false in boolean comparison (Fixed by SvenP)
- Fixed: RegExp : Indicate the pattern is invalid if a closing round bracket is not found for a group.
- Fixed: RegExp: excessive group clearing from regular expression predictor
- Added: Ability to initialize arrays in DIM and CONST keywords.
- Updated: docs for DIM .

3.1.1.25 (8th May, 2005) (beta)

- Updated: UDFs 1.11 (by gafrost/JdeB)

- Added GuiEdit.au3 which has a number of _GUIEdit??? functions for Edit controls. (gafrost)
- Updated _ChooseColor(), _ChooseFont() and _GUI??? function due to DllStruct renaming. (gafrost)
- Corrected wParam to variable name in _GUICtrlEditLineIndex.txt (gafrost)
- Fixed example and include for $CB_GETDROPPEDCONTROLRECT (gafrost)
- Typo in Example: _GUICtrlComboGetEditSel.au3 (gafrost)

- Fixed: Crash when compiling with a specified icon

3.1.1.24 (7th May, 2005) (beta)

- Removed: DLLStruct ... functions (by Jpm)
- Merged : DLLStructElementPtr in DllStructGetPtr (by Jpm)

3.1.1.23 (7th May, 2005) (beta)

- Fixed: Opt("GUICoorMode",2) doc
- Fixed: DllStructCreate return error (Fixed by Ejoc)

3.1.1.22 (5th May, 2005) (beta)

- Fixed: ChooseColor and _ChooseFont() doc (Sorry JdeB : bad merging).
- Fixed: FileOpenDialog, FileSaveDialog, HotKeySet doc
- Fixed: StringInStr return 0 when searching for ""
- Changed: GUICtrlSetGraphic default colors(black, transparent)
- Added: GUICtrlSetGraphic bkColor : $GUI_GR_NOCOLOR
- Added: DLLStructElementPtr (By Ejoc)
- Fixed: duplicate formal parameters in UDF's.

3.1.1.21 (3rd May, 2005) (beta)

- Fixed: GUICtrlRead doc in advanced mode (Fixed by Holger).
- Fixed: GUICtrlRead return on expanded TreeviewItem (Fixed by Holger)
- Added: AutoIt Info Style and exStyle for the control under the mouse.
- Fixed: MemGetStats >2Gb (Fixed by Valik).
- Fixed: _GUICtrlComboSetHorizontalExtent.txt (gafrost)
- Added: _ChooseColor() and _ChooseFont() to Misc.au3 (gafrost)

3.1.1.20 (2nd May, 2005) (beta)

- Added: _GUITab Functions located in GuiTab.au3. (gafrost)
- Fixed: Doc about Expand...Strings.
- Added: Opt("GuiDataSeparatorChar",...)
- Fixed: Return value of StringRegExp when a group is used and the user does not want the array.
- Fixed: bug that allowed run-away recursion in CRegExp::compare_group() when a group can map to no characters. This caused a stack overflow that killed the program.
- Fixed: COM crash

3.1.1.19 (1st May, 2005) (beta) com27/28

- Fixed: Rewrote AutoIt3-Array to COM-Array conversion. Can now handle the total number of Array dimensions that are allowed in AutoIt3. (Fixed by SvenP).
- Fixed: Std... doc (Fixed by DaveF).
- Fixed: "Check for update" to reference new beta download area.
- Fixed: GUISetFont and Input Control not displayed.
- Fixed: Typo on GUICtrlSetFont.
- Fixed: GUI_GR_COLOR default backcolor.
- Fixed: GUICtrlCreateListViewItem with more field than column..
- Fixed: GUICtrlDelete of a Listview control lead to crash after recreation with more columns.
- Added: Unary NOT operations on strings are now allowed. A NOT operation on a non-empty string will result in FALSE.
- Changed: Rewrote some COM documentation.

3.1.1.18 (28th April, 2005) (beta)

- Fixed: TrayItemSetOnEvent, TrayItemDelete doc.
- Added: DLLStruct....
- Fixed: GUICtrlSetState for Menu/menuitem, TrayItemSetState (Fixed by Holger).
- Fixed: GUICtrlSetData for list or combo not inserting.
- Fixed: sizing/resizing of list control : not too good but window does strange think with height size.
- Fixed: _ArrayTrim() (merge Udf 1.08).
- Fixed: WinSetTrans doc

3.1.1.17 (28th April, 2005) (beta)

- Fixed: Bad merge of @HotKeyPressed (Sorry Holger)
- Fixed: Date.au3
- Changed: boolean-to-string conversion. To stay compatible with existing expressions, a boolean false will be converted into a "0" and a boolean true into a "1".

3.1.1.16 (26th April, 2005) (beta)

- Fixed: some doc typo
- Changed: $GUI_EVENT_RESIZE -> $GUI_EVENT_RESIZED no Opt.
- Fixed: UDF udapted
- Fixed: Boolean comparisation with integer values as rightpart argument did always return 'false'. Now it is 0->false, anything <> 0 -> true

3.1.1.15 (25th April, 2005) (beta)

- Fixed: TCPListen min/max number of parameters (was not fixed)
- Added: $GUI_EVENT_RESIZE with Opt("GUIEventCompatibilityMode",1).
- Fixed: Doc on resizing
- Fixed: Resizing of Combo control
- Changed: GUICtrlCreateList forced style LBS_NOTIFY.
- Fixed: $GUI_NOTODAY... constants values..
- Fixed: Run use of 3rd param when 4th par is defined.
- Fixed: Tray/HotKeySet Doc.

3.1.1.14 (25th April, 2005) (beta) COM26 merge

- Fixed: TCPRecv doc.
- Fixed: TCPListen min/max number of parameters
- Added: GUICtrlCreateMonthCal
- Fixed: Optimized For..In loop for Arrays. It should run a bit faster now.
- Added: Usage of COM 'default properties' is now supported.
- Fixed: Some minor documentation changes.
- Fixed: GUICtrlCreateTab disapearing.

3.1.1.13 (24th April, 2005) (beta)

- Changed: UDF and UDF docs.
- Changed: STD I/O controlled by fourth, bit-flag parameter to Run() with $STDxxx_CHILD constants.
- Updated: doc files for Run, AutoItSetOption, StderrRead, StdinWrite, StdoutRead, macros, TOC.
- Moved : Stdxxxyyy functions to Process Management section of docs
- Removed: Options ProvideRunStderr, ProvideRunStdin, ProvideRunStdout.
- Changed: Tray... to TrayItem... renaming.
- Added: @HotKeyPressed macro.
- Fixed: Some fixes in Tray functions.
- Fixed: GUICtrlSetStyle(..., $GUI_SS_DEFAULT_INPUT/EDIT) (to have all forced values).
- Fixed: GUICtrlSetStyle refresh now the window.
- Added: TCP functions from Au3Xtra.

3.1.1.12 (21st April, 2005) (beta) COM25 merge

- Fixed: more than 15 GUI creation
- Fixed: Reference count problem when passing an Object variable as COM-function argument.
- Fixed: Memory leak in COM-Array conversions.

3.1.1.11 (20th April, 2005) (beta) COM23/24 merge

- Fixed: VC7 warnings (Fixed by SvenP).
- Fixed: An Object reference leak in DllCall().
- Added: Support for Arrays returned from COM functions.
- Fixed: A FOR..IN loop would still start when an Array contained no elements.
- Changed: Return,@error, @extended have to be explicit to be return by an UDF

3.1.1.10 (19th April, 2005) (beta) COM22 merge

- Fixed: When a COM method fails on variable assignment, it would silently discard the variable assigment. Changed that, so it will now produce a fatal COM-Error, unless the user has installed it's own errorhandler.
- Fixed: Two Object reference leaks in DllCall().
- Fixed: Minor memory leak in line tokens of type Object.
- Fixed: A boolean value as default value in a function declaration was not allowed.
- Fixed: Minor memory release bug in ObjEvent().

3.1.1.9 (18th April, 2005) (beta) dev only

- Fixed: doc @error setting, waiting Valik fixes on return @error/@extended

3.1.1.8 (17th Apr, 2005) (beta)

- Fixed: GUICtrlSetStyle ES_READONLY on input/edit control
- Fixed: Arguments in COM Methods did not accept expressions or other COM Objects.

3.1.1.7 (15th April, 2005) (beta) COM20 merge

- Added: +=, -=, *=, /= operators
- Added: Keywords 'false' and 'true'. Currently only supported in function arguments. In other assignments they will be converted to integers.
- Added: Full boolean support.

3.1.1.6 (14th April, 2005) (beta) COM19 merge

- Fixed: Reference leaks in Object Enumerator.
- Fixed: Object reference not released in ObjGet().
- Fixed: Object references not being released in FOR..IN loops.

3.1.1.5 (12th April, 2005) (beta)

- Fixed: Doc for "GUIEventCompatibilityMode"

3.1.1.4 (11th April, 2005) (beta)

- Changed: Opt("GUISpecialEventMode',1) by Opt("GUIEventCompatibilityMode',1).
- Added: GUICtrlRead return controlID if Opt("GUIEventCompatibilityMode',2).

3.1.1.3 (10th April, 2005) (beta) COM18 merge

- Fixed: Variant_Datatype ReInit() didn't release any Objects.
- Fixed: Double backslashes are no longer required in ObjGet() filename parameter.
- Added: idispatch_ptr support in DllCall(). (by Valik)

3.1.1.2 (10th April, 2005) (beta)

- Fixed: TraySetIcon default id.
- Added: right-click for List/Treeview control (By Holger).
- Fixed: regexp crash

3.1.1 (7th April, 2005) (Release)
- Fixed: @OSVersion did not work for Windows Server 2003
- Fixed: $LVS_EX_FULLROWSELECT in GuiConstants.au3 was defined $LBS...
- Fixed: @YDAY was incorrect (one day out)

3.1.0 (7th February, 2005) (Release)

- Added: GUI creation capabilties
- Added: DllCall(), DllOpen(), DllClose()
- Added: ControlListView()
- Added: WinList()
- Added: DirGetSize()
- Added: IniReadSectionNames(), IniReadSection()
- Added: InetGet(), InetGetSize()
- Added: HttpSetProxy(), FtpSetProxy()
- Added: FtpBinaryMode (Option)
- Added: Ping()
- Added: ControlGetHandle()
- Added: WinGetProcess() and ProcessList()
- Added: SetExtended()
- Added: WinSetTrans()
- Added: Assign()
- Added: ConsoleWrite()
- Added: @AutoItExe macro
- Added: Const keyword
- Added: Optional parameter support for user functions
- Added: "main", "primary", "menu", "secondary" added as valid mouse button types
- Added: ExpandVarStrings (Option)
- Added: The user functions OnAutoItStart() and OnAutoItExit() are called during startup/exit
- Added: OnExitFunc (Option)
- Added: (Internal) Native HWND datatype added to variants

- Removed: URLDownloadToFile() (Replaced by InetGet())

- Changed: For loops automatically declare the counter variable as a Local variable
- Changed: IniDelete() can also delete entire sections
- Changed: StringReplace() also returns the number of replacements in the @extended macro
- Changed: StringMid() the "count" parameter is now optional (assumes remainder of the string)
- Changed: PixelChecksum() now has optional step parameter
- Changed: Control...() functions now accept the Control ID as an extra way to identify a control
- Changed: InetGet() function can download in the background
- Changed: Reg...() functions no longer give a hard error when an unknown key is used.
- Changed: The mouse and pixel functions now have an additional "client area" mode
- Changed: Added WIN_2003 to the possible values for @OS_VERSION
- Changed: AU3Spy.exe renamed to Au3Info.exe
- Changed: Major upgrades to the AutoIt Window Spy (control highlighting, magnify)
- Changed: FileSelectFolder supports an initial directory as well as a root directory
- Changed: File functions no longer give fatal errors when -1 is used as a handle
- Changed: (Internal) new quicker variable lookup using a binary tree
- Changed: (Internal) new shared process memory class used for StatusbarGetText()
- Changed: (Internal) Unified structure stacks (If, Func, Select, While, Do, For)
- Changed: (Internal) Variant rewrite (now handles int32, int64, double, string, HWND data)

- Fixed: Memory leak in SplashImageOn()
- Fixed: Expressions like "$var = $var" will now give an error if the variable wasn't previously defined
- Fixed: StringFormat() with \\ characters
- Fixed: Under rare situations after closing a script AutoIt3.exe would still appear in task manager for a while
- Fixed: Certain paths like @WindowsDir were incorrect under Windows Terminal Server
- Fixed: FileSetTime() systems in non-GMT timezones had incorrect results
- Fixed: FileMove() with UNC paths (does a real move when in the same dir rather than a copy).
- Fixed: ^ operator
- Fixed: Chr()
- Fixed: StatusbarGetText() failed when used with no "Text" parameter
- Fixed: InputBox() didn't return focus to the previously active window

3.0.102 (4th August, 2004) (Release)

- Major Change: Colors now default to the standard RGB format rather than the previous BGR format.

    This affects PixelSearch, PixelGetColor.

    The "ColorMode" option has been added to allow old scripts to run with the old BGR mode, just
    place this line at the top of your script to use the old method:

    Opt("ColorMode", 1)

- Added: DriveMapAdd(), DriveMapDel() and DriveMapGet()
- Added: @SW_SHOWDEFAULT, @SW_SHOWMAXIMIZED, @SW_SHOWMINIMIZED, @SW_SHOWMINNOACTIVE,
  @SW_SHOWNA, @SW_SHOWNOACTIVATE, @SW_SHOWNORMAL
- Added: FileGetShortcut()
- Added: Predefined $CmdLineRaw variable now holds the original command line in full
- Added: @DesktopDepth
- Added: ReDim
- Added: Command line option /ErrorStdOut
- Added: More command line params for Aut2Exe.exe: /nodecompile and /comp 0-4 (compression level, 4=best)
- Added: Process ID (PID) support for Process...() and Run() functions
- Added: ProcessSetPriority()
- Added: Decompiler (Exe2Aut) added
- Added: PixelChecksum()
- Added: Strings starting with "0x" are converted from hex when used numerically
- Added: Multi-directory #include <> paths
- Added: MouseWheel()
- Added: FileRecycleEmpty()
- Added: RegEnumKey() and RegEnumVal()

- Changed: TimerStart() renamed to TimerInit(). TimerStop() renamed to TimerDiff()
- Changed: FileSelectFolder() flag parameter changed
- Changed: REG_MULTI_SZ values allow double NULL values.
- Changed: BirOr(), BitAND() and BitXOR() take up to 255 parameters
- Changed: Icon and windowstate options added to FileCreateShortcut()
- Changed: RunAsSet() supports extra profile handling options
- Changed: RegWrite() now accepts just the keyname in order to create a keyname with no value
- Changed: "Allow Decompilation" option added to Aut2Exe
- Changed: Aut2Exe gives feedback during compilation and gives the option to abort
- Changed: Compiled scripts run/extract much faster when using FileInstall and medium/large files
- Changed: Max number of user function limits removed
- Changed: Max number of variable limits removed
- Changed: -1 does no sleep at all for Send/Mouse delays (SendKeyDelay, etc...)
- Changed: Optional occurance parameter added to StringInStr()
- Changed: Optional default filename added to FileOpenDialog() and FileSaveDialog()
- Changed: Registry functions accept 4 letters keys (HKLM instead of HKEY_LOCAL_MACHINE, etc.)
- Changed: Remote registry keys are accepted in the form "\\computername\key\subkey"
- Changed: AutoItSetOption returns the previous setting
- Changed: (Internal) Built-in function lookups completely rewritten
- Changed: (Internal) String functions speeded up (concat in astring and variants)
- Changed: (Internal) ControlSearch modified to include the windowsearch

- Fixed: FileGetSize() works on >2GB files and in-use files
- Fixed: The expression: If "non-blank" And 1 - now evaluates as true
- Fixed: /c command line use in compiled scripts
- Fixed: ToolTip() when the mouse is near the bottom of the screen
- Fixed: StringIsDigit()
- Fixed: Process... functions under NT4 unable to see certain processes
- Fixed: Some keywords incorrectly allowed after a THEN keyword
- Fixed: (Internal) Hotkey registering logic

3.0.101 (11th March, 2004) (Release)
- Added: MemGetStats()
- Fixed: Compatibility problem under Windows 95a
- Fixed: Some minor help file typos corrected

3.0.100 (29th February, 2004) (Release)
- Added: WinTextMatchMode (Option)
- Fixed: ExitLoop and ContinueLoop failed during a recursive function
- Fixed: Sleep(0) (or < 0 ) no longer hangs
- Fixed: $ with no name was allowed as a variable
- Fixed: For Loop bug when used in recursion
- Fixed: FileGetLongName() return value
- Fixed: @UserProfileDir under 9x
- Fixed: IsDeclared()
- Fixed: Random()

3.0.94 (21st February, 2004) (Beta)

SCRIPT BREAKING CHANGES for FileReadLine and FileWriteLine:

FileWriteLine now automatically writes a DOS @CRLF pair UNLESS the last character of
the string to write is already @CR or @LF (to make it possible to write non-DOS text files)

FileReadLine will correctly read a DOS, UNIX or MAC line (@CRLF, @LF and @CR terminated respectively).

FileWrite and FileRead added to add further support.

CHANGE YOUR SCRIPTS AS FOLLOWS:

From: FileWriteLine($handle, "line" & @LF)
To: FileWriteLine($handle, "line" & @CRLF) or FileWriteLine($handle, "line")

From: FileWriteLine($handle, "line")
To: FileWrite($handle, "line")

- Added: FileWrite() and FileRead()
- Changed: FileReadLine() and FileWriteLine()
- Added: ToolTip()
- Added: Eval() and IsDeclared()
- Added: CaretCoordMode (AutoItSetOption)
- Added: WinGetCaretPos()
- Added: WinGetState()
- Added: MustDeclareVars (AutoItSetOption)
- Added: Editors page in help
- Changed: EnvSet()
- Changed: WinShow() renamed to WinSetState() (With WinShow() as an alias)
- Fixed: Splash() and moveable flag (and -1 default flag in options)
- Fixed: Odd ElseIf error message showing wrong line
- Fixed: Crashes with bad function calls: MsgBox(MsgBox(MsgBox))
- Fixed: HotKey crashes when unregistering a key that was not registered

- Fixed: (Internal) WinWaitDelay, SendKeyDelay, etc type commands now more accurate (previously only accurate to 10ms (NT) or 55ms (9x))
- Fixed: (Internal) Execute() recursion limit dropped to 384 levels
- FIxed: (Internal) Calls to Util_AttachThreadInput will not attach to hung windows
- Fixed: (Internal) some RegRead/RegWrite sizing problems (Ta, Chris)

3.0.93 (12th February, 2004)
- Added: SendAttachMode (AutoItSetOption)
- Added: Opt() is an alias for AutoItSetOption() :)
- Added: Doc updates
- Added: WinSearchChildren (AutoItSetOption)
- Changed: Splash and Progress functions have a "moveable" option
- Changed: StringStripWS (new strip all ws mode)
- Changed: InputBox (timeout param)
- Changed: Hot keys are no longer buffered when the script is paused.
- Fixed: REG_MULTI_SZ support
- Fixed: TrayIconDebug not showing correct filename
- Fixed: ControlClick, ControlCommand("CHECK")
- Fixed: Control functions now using return values rather than @error where appropriate.
- Fixed: Error with '' quotes in Aut2Exe
- Fixed: StringFormat()
- Fixed: Lexer checks that potential user function calls are for existing functions
- Fixed: Input thread attachment in Send() ( check Send("{... down}") still works)

- Changed: (Internal) Removed the only sscanf call and replaced with own code - saves 4KB.

3.0.92 (6th February, 2004)

NOTE: Script breaking changes to ControlLeftClick(), FileFindFirstFile(), SendSetCapslockState()

- Added: Dec()
- Added: BitNOT(), BitXOR(), BitShift()
- Added: TrayIconDebug (AutoItSetOption)
- Added: Dim single-line initialization and multiple variables
- Added WinTitleMatchMode 4 (AutoItSetOption)
- Added: #comments-start and #comments-end for multiline comments
- Added: DirCopy()
- Added: DirMove()
- Added: Controls will be checked by visible text as well as classname (waves to Chris :) )
- Added: Macros: @UserProfileDir, @HomeDrive, @HomePath, @HomeShare, @LogonServer, @LogonDomain, @LogonDNSDomain
- Removed: SendSetCapslockState() - Use Send("{CAPSLOCK on/off}")
- Changed: FileFind works differently (handles used and multiple finds now supported)
- Changed: ControlLeftClick() renamed to ControlClick() and options added.
- Changed: Window Spy options added and ability to freeze display
- Changed: StringSplit will return each char if delimiters are ""
- Changed: WinMenuSelectItem return value
- Changed: optional variation added to PixelSearch()
- Changed: optional step value added to PixelSearch()
- Changed: FileMove() overwrite flag added
- Changed: *.* assumed if a directory is used in FileCopy/FileMove/FileDelete
- Fixed: @TempDir under certain conditions
- Fixed: Hotkeys were ignored while another hotkey function was running

- Changed: (Internal) DirRemove changed
- Changed: (Internal) Sendkeys tweaked A LOT

3.0.91 (29th January, 2004)
- Added: Options: MouseClickDelay, MouseClickDownDelay, MouseClickDragDelay (AutoItSetOption)
- Added: REG_BINARY type for RegRead() and RegWrite()
- Added: FileChangeDir()
- Added: ControlCommand() - added GETCURRENTSELECTION
- Added: Added some standard library includes (See Program Files\AutoIt3\Include\)
- Added: SendKeyDownDelay (AutoItSetOption) (alters the amount a time a key is held down before released)
- Added: AutoIt returns an exit code of 1 if script could not be loaded
- Added: FileSetAttrib(), FileSetTime()
- Added: In Au3_Spy pixel colour is also shown in hex
- Fixed: While loops failing when used in recursive functions of themselves... (!?)
- Fixed: Small line coninuation _ bug
- Fixed: URLDownloadToFile()
- Fixed: FileRecycle() not always working
- Fixed: FileRecycle() return value
- Fixed: Relative #include use
- Fixed: Smart boolean comparision re-added
- Fixed: FileFindFirst() not releasing memory when called multiple times
- Changed: FileGetTime outputs strings with leading 0s when required
- Changed: Default value of Local/Global/Dim is the String "" (equates to 0 when used as a number)

- Changed: (Internal) More scriptfile.cpp optimization
- Changed: (Internal) Execute() recursion levels limited to 512 to prevent stack overflows

3.0.90 (20th January, 2004)
- Fixed: Serious nested IF bug

- Changed: (Internal) Rollback of variabletable.cpp and stacks/vectors

3.0.89 (19th January, 2004)
- Added: Method for standard library functions and includes
- Added: #include < > support (must be fully installed to work)
- Added: #include-once directive (put at the top of a file to make sure it is only
  included once)
- Added: @UserName and @TempDir macros
- Fixed: Nasty fatal bug in 3.0.88

3.0.88 (18th January, 2004)
- Added: ElseIf
- Changed: All block structures (IF/WHILE/FOR, etc.) are now checked before execution.
- Fixed: Some single hotkeys not working
- Fixed: Better detection of illegal nesting, e.g.:
 If 1 = 1
   While 1
 EndIf
   WEnd

- Changed: (Internal) lots of error checking code removed as a nice side effect of
  initial block structure checking
- Changed: (Internal) windows string functions (lstrcmp etc) moved back to C versions
  due to massive performance penalty

3.0.87 (15th January, 2004)
- Changed: Aut2Exe stores files it can't compress (.zip etc) rather than expanding
- Fixed: Aut2Exe crashing if FileInstall used a file less than 4 bytes
- Fixed: Aut2Exe crashing with uncompressable files
- Fixed: RegRead not working correctly with large DWORD values
- Fixed: NOT fixed when skipped during a boolean expression

- Changed: (Internal) variable_table.cpp rewritten
- Changed: (Internal) All stacks/vectors replaced with templated code

3.0.86 (12th January, 2004)
- Added: Enhanced boolean comparisons
- Added: Send can hold keys down, e.g. Send("{a down}") will hold the A key down (only works usefully with games)
- Fixed: 0 ^ 0 = 1
- Fixed: on_top parameter of ProgressOn()
- Fixed: No longer hanging with blank search in StringReplace()
- Fixed: Asc() giving -1 in some cases
- Fixed: Tray icon's tip not updating when un-pausing
- Changed: Single keys of 0-9, a-z can no longer be used as hotkeys if alt,ctrl or win is NOT also used.

- Changed: (Internal) FPU assembler used for advanced math (sin,Cos,pow, etc) functions due to
  exe size problems under VC7

3.0.85 (9th January, 2004)
- Added: HotKeySet()
- Added: Abs(), Sin(), Cos(), Tan(), ASin(), ACos(), ATan(), Sqrt(), Log(), Exp()
- Added: ^ operator
- Added: Round()
- Added: Call()
- Changed: IniWrite/IniDelete() return 0 if they fail
- Changed: No longer need to use virtual keys for FileCreateShortcut()
- Fixed: Return value for FileCopy/FileInstall()
- Fixed: Incorrect use of ExitLoop/ContinueLoop trapped

- Changed: (Internal) Send() tweaking
- Fixed: (Internal) Function calling/scope slightly bugged (Adlib, Hotkey)

3.0.84 (30th December, 2003)
- Added: New window WinTitleMatchMode of 3 (for exact title match)
- Added: Some more details added to helpfile
- Changed: The key # is no longer used as a delimiter but as a left Win key combination. So
  Send("#e") now presses the left win+e keys. I don't think anyone actually used
  it as a delimiter anyway - it was just a left over from v1 and it never made
  lines easier to read anyway
- Changed: FileReadLine() and FileWriteLine() modified so that they optionally accept a filename
  instead of a filehandle for "quick 'n' dirty" file access - I'm sure this will be
  popular :)

3.0.83 (30th December, 2003)
- Changed: Due to popular demand, by default functions now return 0 for error and 1 for success.
  This affects the following functions: FileWriteLine, CDTray, DriveSetLabel, DirCreate,
  DirRemove, FileCopy, FileMove, FileDelete, FileInstall, ClipPut, URLDownloadToFile,
  RunAsSet, Shutdown, RegWrite, RegDelete, WinWait, WinWaitActive, WinWaitClose, WinWaitNotActive,
  ProcessWait, ProcessWaitClose. If you were using the return values of one of
  these functions then please check your scripts.

- Changed: ControlSend() supports {} (for most things at least...)

3.0.82 (29th December, 2003)
- Added: Files installed with FileInstall() now have original timestamps (created/modified)
- Added: IsNumber()
- Fixed: Number to string conversions and general float parsing

- Changed: (Internal) FileInstall() compression code updated

3.0.81
- Fixed: Yet more bugs with single line IF - regretting adding this feature already...
- Fixed: Bugs with NOT operator and the new variant code
- Fixed: Bug with clicking CANCEL on the open script window (introduced in 3.0.80)
- Fixed: StringIs... functions failing when using numbers as parameters

- Fixed: (Internal) VectorVariant modified to allow reference access to variants (instead of copying everytime)

3.0.80 (15th December, 2003)
- Changed: Number to String conversions tweaked
- Fixed: Massive bug fixed with arrays introduced in 3.0.76
- Fixed: Line continuation crash

- Changed: (Internal) script reading code updated for Aut2Exe and merged with AutoIt

3.0.79 (15th December, 2003)
- Added: Lines can be continued over many lines - use _ at the end of a line to continue it (as VBScript)
- Added: Single line IF statements possible
- Changed: Maximum line length (including total of combined lines) increased from 1023 to 4095 characters.
- Changed: "Then" keyword in IF statements no longer optional (helps with single line IFs)

e.g.
MsgBox(0, "Test", "This is some text _
  And more text _
  And even more text")

3.0.78 (15th December, 2003)
- Changed: Variants work differently - no longer a seperate INTEGER type
- Changed: Float() changed to Number()

    All numbers now 15digit precision (internal C double type)
    Also affects Random() you will get floating point numbers back unless you use Int()
    with the result

3.0.77 (30th November, 2003)
- Added: New option "TrayIconHide" (AutoItSetOption)
- Changed: "AutoIt -" prefix removed from compiled a script's tray icon
- Changed: Compiled script's file properties point to a custom web page
- Fixed: Tray icon should redraw after an explorer crash

3.0.76 (30th November, 2003)
- Fixed: Couple of bugs with ContinueLoop and ExitLoop
- Fixed: Statements like $test[$test[0]] now working

3.0.75 (30th November, 2003)
- Added: ControlGetFocus()
- Added: Local and Global keywords
- Changed: Dim (along with Local/Global) can now be used as in vbscript to declare variables
- Changed: FileOpenDialog() uses "|" as the delimiter instead of ","
- Fixed: PixelSearch()
- Fixed: SoundPlay()...maybe
- Fixed: Splash() sizing issues

3.0.74
- Added: Hex notation for integer numbers ($var = 10 or $var = 0xa)
- Added: MouseDown(), MouseUp()
- Added: TrayTip()
- Fixed: PixelCoordMode not working correctly
- Fixed: Compiled exes not producing random numbers

3.0.73
- Added: New option "RunErrorsFatal" (AutoItSetOption)
- Added: New option "ExpandEnvStrings" (AutoItSetOption)
- Changed: FileMove() moves/renames without affecting timestamps - can also be used
  for directories
- Changed: RegRead/RegWrite() now supports REG_EXPAND_SZ
- Changed: Extra options added to FileGetTime()
- Changed: Extra 250ms delay added to start and end of mouse drags
- Fixed: Odd error message fixed where a user function contained a badly formatted line

3.0.72
- Fixed: Compiler was ignoring comments near FileInstall() functions
- Fixed: Memory leak in StatusbarGetText()
- Fixed: PixelGetColor
- Added: New option "PixelCoordMode" (AutoItSetOption)

3.0.71
Get ready for some script rewriting...*holds up banner with BETA written on it :) *

- Added: ControlSend()
- Added: Framework for AutoItSetOption() - NOTE: this function replaces all
  functions like WinSetDelay, SendSetDelay, MouseSetMode, etc.
- Removed: MouseSetMode(), SendSetCapslockMode(), SendSetDelay(), WinSetDelay(), WinSetDetectHiddenText()
  WinSetTitleMatchMode()

3.0.70
- Fixed: SoundPlay()
- Removed: AutoItWinShow(), AutoItWinWrite(), AutoItWinGetText()
- Changed: ControlCommand() (updated with Larry's recent changes)
- Changed: RegRead() extended error codes
- Added: FileFindFirstFile(), FileFindNextFile()
- Added: AutoItWinGetTitle()
- Added: WinGetClientSize()
- Added: EnvUpdate()
- Added: SoundSetWaveVolume()
- Added: FileGetLongName(), FileGetShortName()
- Added: TimerStart(), TimerStop()

3.0.69
- Fixed: Small delay added into MouseClick functions
- Fixed: FileGetVersion()
- Fixed: WinMenuSelectItem()
- Fixed: StringSplit() buffer overrun

3.0.68
- Added: FileGetAttrib(), WinMenuSelectItem(), FileGetVersion()
- Added: Added options to ControlCommand()

- Changed: (Internal) Larry's nFlag functions split

3.0.67
- Changed: InputBox() narrowed slightly
- Fixed: AutoIt icon not refreshing if Return was used at top level of script
- Fixed: Crash with extra long lines fixed
- Fixed: @OS_VERSION weirdness fixed

- Changed: (Internal) MessagePump handled differently and recursion level of Execute() tracked

3.0.66
- Changed: StringSplit() returns full string in array if no delimiters matched (and count=1 not 0)
- Fixed: Crash related to window titles and text fixed.

3.0.65
- Added: ControlCommand() option GetCurrentLine
- Fixed: Possible bug with optional "Then" statement fixed
- (Internal) Window searching functions altered to check for hung windows

3.0.64
Fixed: IniWrite/Delete() functions were not flushing immediately under 9x.
Added: Errors now include the file name that contained the error

3.0.63
- Changed: ControlCommand() various internal changes.
- Fixed: MsgBox() character limit bug fixed
- Changed: Can now specify a custom time for AdlibEnable()

3.0.62
- Fixed: Aut2Exe icon changing code bugged
- Changed: Timing of "paused" flash and icon modified a little.

3.0.61
- Fixed: FileOpenDialog()
- Changed: (Internal)Encryption code modified - check compiling thoroughly
- Added: AutoIt icon flashes when in paused state

3.0.60
- Changed: Aut2Exe strips version info from compiled script. (Hoping to be custom versioninfo in future)
- Fixed: FileGetSize() (change made, unsure if problem fixed)
- Fixed: FileMove wasn't supported on 9x (9x has no MoveFileEx function, Dave... :) )

3.0.59
- Fixed: InputBox was not returning "" on cancel

3.0.58
- Fixed: The window text searching in AutoIt was not the same as AU3_Spy or WinGetText()
- Added: InputBox() (and very nice it is too...)
- Added: FileMove()

3.0.57
- Fixed: MsgBox under 9x was doing odd things with timeouts - tried something else.

3.0.56
- Fixed: Selecting the default icon in Aut2Exe was not saved between sessions
- Fixed: @OSLang under NT4...
- Added: SysTabControl32 tabbing

3.0.55
- Changed: Better icon support added to Aut2Exe
- Changed: (Internal) upx.exe called during the compiler to compress data -
  necessary to do it this way as you can't edit the resources of a compressed
  exe
- Changed: SoundPlay()

3.0.54
- Fixed: Compiled scripts with custom icons were failing
- Fixed: @OS_LANG under 9x

3.0.53
- Added: StringSplit()

3.0.52
- Changed: SoundPlay() option to wait added
- Added: ChangeIcon support back in Aut2Exe (32x32x16) - Slightly better than v2 in that
  a multiimage iconfile can be used - although only the 32x32x16 image is actually used.

3.0.51
- Fixed: Aut2Exe still used ' comments when including files -whoops.

3.0.50
- Changed: (Internal)A little error checking added to the lexer
- Added: @TAB, @ComSpec
- Changed: MouseClick() parameters changed
- Added: MouseClickDrag()

3.0.49
- Fixed: Statusbar in Aut2Exe with Visual Styles
- Changed: Single line comment character is now ;
- Changed: ' and " may now be used for strings

3.0.48
- Added: StringIsFloat(), StringIsInt()
- Fixed: MsgBox() wasn't returning -1 on timeout
- Fixed: StringReplace() error if string to replace was at end of string
- Changed: StringReplace() count is now optional (assumes global)
- Added: Aut2Exe and AutoIt3 now use Visual Styles

3.0.47
- Changed: FileExists() to work with wildcards
- Changed: Extra options added to AutoItWinShow()
- Changed: RegRead returns the string "" in addition to @error if the (default) key was requested
  and not found.
- Fixed: DriveGetDrive() (still an a: drive bug to find though)

3.0.46
- Fixed: RegDelete() return value when value does not exist
- Fixed: CDTray() open/closed problems
- Fixed: FileSelectFolder() crash due to missing initialisers

3.0.45
- Changed: Set...() functions renamed (SendSetDelay, WinSetDelay, etc.)
- Added: StatusbarGetText()

3.0.44
- Added: Break()
- Fixed: DriveStatus()
- Fixed: RegDelete()

3.0.43
- Fixed: @OSLang for 2000+
- Added: Hex(), AutoItWinGetText()
- Changed: UBound() back to how it was again (same as VBScript syntax)

3.0.42 (30th August, 2003)
- Tweaked: Mouse coords were 1 pixel out
- Added: MouseSetMode() to allow for screen _and_ relative coords - yay everyone's happy

3.0.41 (30th August, 2003)
- Fixed: Bug with invalid filehandles (again!).
- Changed: Mouse commands may now work on multiple monitors.
- Fixed: $CmdLine wasn't working correctly for compiled scripts.
- Fixed: The operator == wasn't properly comparing strings
- Fixed: INI functions, filename now doesn't need ".\file.ini" to work in the current directory
- Fixed: Bug in Run() directory would not be set if last parameter was used

3.0.40
- Added: Windows API error messages added onto errors for the Run() commands
  (directory invalid, bad logon, etc).

3.0.39 (29th August, 2003)
- Added: RunAsSet() (2000/XP only)
- Added: FileRecycle()

3.0.38 (28th August, 2003)
- Changed: WinGetText now correctly takes NOTE of detecthiddentext setting
- Added: StringStripWS()
- Added: DriveGetLabel(), DriveGetSerial(), DriveGetFileSystem(),
  DriveSetLabel(), DriveGetType(), MouseGetCursor()

3.0.37
- Changed: Compression tweaked in Aut2Exe

- Changed: UBound($aArray) now returns number of dimensions
- Renamed all the IsUpper/IsAlpha, etc functions to StringIsUpper/StringIsAlpha, etc.
- Added: IsFloat(), IsArray(), IsInt(), IsString()
- Added: Mod()

3.0.36
- Fixed: Main dialog in Aut2Exe
- Added: New compression code (slower but better at higher levels)

3.0.35
- Added: FileInstall() support
- Added: SplashImageOn(), SplashTestOn(), SplashOff()
- Added: ProgressOn(), ProgressOff(), ProgressSet()
- Added: Compression level option in Aut2Exe

3.0.34
- Fixed: subscript must be > 0 in Dim statement
- Added: Compiled script reading code added
- Added: @Compiled
- Added: Aut2Exe

3.0.33 (22nd August, 2003)
- Added: Case Else
- Added: @DesktopWidth, @DesktopHeight
- Fixed: CDTray - closed/close
- Fixed: Incorrect reference passing of global variables
- Fixed: Bad file handle causing a crash in FileWrite/Read/Close
- Fixed: Crash with badly formatted Func statements
- Parsing speeded up (doubled the speed)
- Optimized string handling in variants

3.0.32 (20th August, 2003)
- Started proper version logging :)

First public beta binary - 4th March, 2003.

Development started - 20th January, 2003.


UDFs Constants include files

Below is a complete list of the UDFs Constants include files available in AutoIt.
List of related WinAPIEx complementary constants is available here

Using #include <APIConstants.au3> includes all WinAPI or WinAPIEx related constants.

File | Related Function(s) | Related Include(s)
#include <AVIConstants.au3> | _GUICtrlAVI_*() functions | GuiAVI.au3
#include <BorderConstants.au3> | _WinAPI_DrawEdge() function | WinAPI.au3
#include <ButtonsConstants.au3> | _GUICtrlButton_*() functions | GuiButton.au3
#include <ComboConstants.au3> | _GUICtrlComboBox_*(), _GUICtrlComboBoxEx_*() functions | GuiCombo.au3, GuiComboEx.au3
#include <DateTimeConstants.au3> | _GUICtrlDTP_*(), _GUICtrlMonthCal_*() functions | GuiDateTimePicker.au3, GuiMonthCal.au3
#include <EditConstants.au3> | _GUICtrlEdit_*() functions | GuiEdit.au3
#include <FrameConstants.au3> | _WinAPI_DrawFrameControl() function | WinAPI.au3
#include <GDIPlusConstants.au3> | _GDIPlus_*() functions | GDIPLus.au3
#include <HeaderConstants.au3> | _GUICtrlHeader_*() functions | GuiHeader.au3
#include <ImageListConstants.au3> | _GUIImageList_*() functions | GuiImageList.au3
#include <IPAddressConstants.au3> | _GUICtrlIpAddress_*() functions | GuiIPAddress.au3
#include <ListBoxConstants.au3> | _GUICtrlListBox_*() functions | GuiListBox.au3
#include <ListViewConstants.au3> | _GUICtrlListView_*() functions | GuiListView.au3
#include <MemoryConstants.au3> | _Mem*() functions | Memory.au3
#include <MenuConstants.au3> | _GUICtrlMenu_*() functions | GuiMenu.au3
#include <NTSTATUSConstants.au3> | NTSTATUS Constants |
#include <ProcessConstants.au3> | _Process*() functions | Process.au3
#include <RebarConstants.au3> | _GUICtrlRebar_*() functions | GuiRebar.au3
#include <RichEditConstants.au3> | _GUICtrlRichEdit_*() functions | GuiRichEdit.au3
#include <ScrollbarsConstants.au3> | _GUIScrollbars_*() functions | Scrollbars.au3
#include <SecurityConstants.au3> | _Security_*() functions | Security.au3
#include <SliderConstants.au3> | _GUICtrlSlider_*() functions | GuiSlider.au3
#include <StatusBarConstants.au3> | _GUICtrlStatusBar_*() functions | GuiStatusBar.au3
#include <StructureConstants.au3> | DLLStruct Windows API constants |
#include <TabConstants.au3> | _GUICtrlTab_*() functions | GuiTab.au3
#include <ToolbarConstants.au3> | _GUICtrlToolbar_*() functions | GuiToolbar.au3
#include <ToolTipConstants.au3> | _GUIToolTip_*() functions | GuiToolTip.au3
#include <TreeViewConstants.au3> | _GUICtrlTreeView_*() functions | GuiTreeView.au3
#include <WinAPIConstants.au3> | WinAPI functions | WinAPI.au3
#include <WinAPILangConstants.au3> | Language identifier constants | WinAPI.au3
#include <WinAPIsysinfoConstants.au3> | Constants for _WinAPI_SystemParameterInfo() function | WinAPI.au3
#include <WordConstants.au3> | _Word_*() functions | Word.au3

Below is a complete list of the WinAPIEx UDFs Constants include files available in AutoIt.

File | Related Function(s) | Related Include(s)
#include <APIComConstants.au3> | COM functions | WinAPICom.au3
#include <APIDiagConstants.au3> | Diagnostic functions | WinAPIDiag.au3
#include <APIDlgConstants.au3> | Dialog functions | WinAPIDlg.au3
#include <APIErrorsConstants.au3> | WinAPI Errors constants | APIErrorsConstants.au3
#include <APIFilesConstants.au3> | Files & Devices functions | WinAPIFiles.au3
#include <APIGdiConstants.au3> | GDI functions | WinAPIGdi.au3
#include <APILocaleConstants.au3> | Internationalization functions | WinAPILocale.au3
#include <APIMiscConstants.au3> | Miscelaneous functions | WinAPIMisc.au3
#include <APIProcConstants.au3> | Process & Synchronization functions | WinAPIProc.au3
#include <APIRegConstants.au3> | Registry functions | WinAPIReg.au3
#include <APIResConstants.au3> | Menus & Resources functions | WinAPIRes.au3
#include <APIShellExConstants.au3> | ShellEx functions | WinAPIShellEx.au3
#include <APIShPathConstants.au3> | ShellPath functions | WinAPIShPath.au3
#include <APISysConstants.au3> | System functions | WinAPISys.au3
#include <APIThemeConstants.au3> | Theme functions | WinAPITheme.au3
#include <WinAPIvkeysConstants.au3> | Virtual keys constants for functions as _WinAPI_GetKeyState() | WinAPISys.au3


Script Breaking Changes in Recent Versions

This page contains a list of all changes made in recent updates that will almost certainly break existing scripts. Please read this list carefully when upgrading if you have not been keeping up with developments in the beta versions. If any of these issues affect you then you will need to modify your scripts.

v3.3.14.0

AutoIt:

  • If Min and Max are the same value then Random() will now return that value and the @error flag will no longer be set.
  • Under Vista or Server 2008 _GDIPlus_Startup() need explicit Dll for GDI+ v1.1 support.
  • File operations on text files not opened with FileOpen() and explicit unicode flags now auto-detect encoding slightly differently to be more in line with modern editors. This includes all file functions that are used with a filename, for example FileRead("filename.txt"). Specifically:
    • Files containing a BOM will be opened in the relevant mode as per that BOM. UTF-8 and UTF-16 BOMs are checked.
    • UTF-8 and UTF-16 files without a BOM will be automatically detected and opened in the relevant mode.
    • Files containing nulls are opened in Binary ($FO_BINARY) mode by default (unless they are detected as valid UTF-16). Previously they would be opened in ANSI mode. Use the $FO_ANSI flag to override.
    • Files containing only characters 1-127 are opened in UTF-8 with no BOM ($FO_UTF8_NOBOM) mode by default. Previously they would be opened in ANSI mode. Use the $FO_ANSI flag to override.
    • Files containing only characters 1-255 are opened in ANSI ($FO_ANSI) mode by default.
    • Due to the above FileGetEncoding() now returns 512 ($FO_ANSI) or 256 ($FO_UTF8_NOBOM) instead of 0 which was undocumented but indicated ANSI.
  • New files are written in UTF-8 with no BOM ($FO_UTF8_NOBOM) mode by default. Use FileOpen() to override.
  • UTF-16 files without a BOM are now automatically detected in most cases.

UDFs:

  • Excel UDF, function _Excel_BookOpen: When parameter $bReadOnly = False and read-write access could not be granted @error was set to 4 and the Workbook was opened read-only. Now @error = 0, @extended = 1 and the Workbook is opened read-only.
  • Word UDF, function _Word_DocOpen: When parameter $bReadOnly = False and read-write access could not be granted @error was set to 4 and the document was opened read-only. Now @error = 0, @extended = 1 and the document is opened read-only.

v3.3.12.0

UDFs:

  • The parameter $hPrintCallback (formerly $sPrintCallback) in _SQLite_Startup() now requires a function object rather than a function string. This is due to the usage of Call() being removed from the UDF.
  • The parameter $hFunctionCall (formerly $sFunctionCall) in _FTP_ProgressDownload() and _FTP_ProgressUpload() now requires a function object rather than a function string. This is due to the usage of Call() being removed from the UDF.
  • _ArrayDelete() sets @error to non-zero if $iElement is out of bounds. Please see documentation for more details.
  • _StringBetween() change in behaviour and parameter order change. Please see documentation for more details.
  • _GUICtrlListView_GetView() and _GUICtrlListView_SetView() were using 0 for detailed view and 1 for large icon view, when it's 0 for large icon view and 1 for detailed view.
  • Array UDF was re-written. Functions and/or parameters have been changed, removed or added. A detailed list can be found here.
  • Excel UDF was re-written. Functions and/or parameters have been renamed, removed or added. A detailed list can be found here.

Missing information from the v3.3.10.0 notes:

  • _ArrayDisplay() re-written with additional parameters. Please see documentation for more details.

v3.3.10.1

UDFs:

Missing information from the v3.3.10.0 notes:

  • $tagBITMAPINFO fields changed by using the prefix of "bi".

v3.3.10.0

AutoIt:

  • The return value of ShellExecute() has now changed. Instead of returning 1, it returns the PID of the executed process or -1 if no PID exists.

UDFs:

  • _Iif() documentation has been removed. The function is still present in Misc.au3, but may be removed at a later date. Scripts should be updated to use ternary operators instead.
  • _IEErrorHandlerRegister() has been removed. It's not required due to COM errors no longer being fatal.
  • _StringEncrypt() documentation has been removed. The function is still present in String.au3, but may be removed at a later date. Scripts should be updated to use the Crypt functions instead.
    Look at _Crypt_EncryptData() for an example of an alternative _StringEncrypt.
  • _StringReverse() documentation has been removed. The function is still present in String.au3, but may be removed at a later date. Scripts should be updated to use the native function StringReverse() instead.
  • With the introduction of WinAPIEx functions some constants of Constants.au3 include file have been moved to WinAPIConstants.au3.
  • Word UDF was re-written. Functions and/or parameters have been renamed, removed or added. A detailed list can be found here.
  • $tagGDIPPENCODERPARAMS removed, use $tagGDIPENCODERPARAMS.
  • $tagGDIPENCODERPARAMS use $tagGDIPENCODERPARAM as a first structure of the array.
  • $tagGDIPENCODERPARAM "count" field renamed in "nbOfValues".
  • $tagBITMAPINFO fields changed by using the prefix of "bi".
  • _ArrayUnique() re-written with improved speed. The final parameter is used to select whether to return count of returned strings in $aArray[0]
  • ToolTip UDF was re-written. Functions and/or parameters have been renamed, removed or added. A detailed list can be found here.
  • _ArrayDisplay() re-written with additional parameters. Please see documentation for more details.

v3.3.8.0

AutoIt:

  • ObjName() has had a number of bug fixes and changes that may affect data returned. Built-in UDFs have been changed to accommodate this but custom scripts may need to be edited.
  • ObjEvent() AutoIt.Error objects no longer have Raise() or Clear() methods and the properties are read-only.
  • Int() and Hex() no longer set @error.
  • COM methods now require parenthesis so the language can internally detect properties versus methods easier.

v3.3.6.0

UDFs:

  • _DateToDayOfWeekISO returned 0-6 and is changed to 1-7 where Monday = 1.

v3.3.4.0

Some of the following features are deprecated. Deprecated features are no longer documented but continue to work. Deprecated features will be removed after version 3.3.4.0. It is strongly recommended that scripts relying on deprecated features be updated to work with the new behavior. Some features have already been removed and will be noted as such.

AutoIt:

  • The raw reading mode for FileOpen() has been removed.
  • InetGet("abort"), @InetGetActive and @InetGetBytesRead have been removed. The following list shows the new functions used to access the old behavior:
    • InetGet("abort") - Calling the new InetClose() function with a handle returned from InetGet() will abort a download.
    • @InetGetActive - Calling the new InetGetInfo() function with no parameters returns a count of active downloads.
    • @InetGetBytesRead - Calling the new InetGetInfo() function with a handle returned from InetGet()will return the bytes read (and more) for a download.
  • AdlibEnable() and AdlibDisable() have been removed. See the new functions AdlibRegister() and AdlibUnRegister().
  • OnAutoItStart() has been removed. See the new pre-processor statement #OnAutoItStartRegister.
  • OnAutoItExit() has been removed. See the new functions OnAutoItExitRegister() and OnAutoItExitUnRegister().

v3.3.2.0

Some of the following features are deprecated. Deprecated features are no longer documented but continue to work. Deprecated features will be removed after version 3.3.2.0. It is strongly recommended that scripts relying on deprecated features be updated to work with the new behavior. Some features have already been removed and will be noted as such.

AutoIt:

  • ShellExecute() and ShellExecuteWait() no longer use the "open" verb by default. See the remarks section for those functions for more details.
  • The return value of InetGet() has changed. It is important to read and understand the changes because it is possible to leak resources if InetGet() is used incorrectly.
  • InetGet("abort"), @InetGetActive and @InetGetBytesRead are now deprecated. The following list shows the new functions used to access the old behavior:
    • InetGet("abort") - Calling the new InetClose() function with a handle returned from InetGet() will abort a download.
    • @InetGetActive - Calling the new InetGetInfo() function with no parameters returns a count of active downloads.
    • @InetGetBytesRead - Calling the new InetGetInfo() function with a handle returned from InetGet()will return the bytes read (and more) for a download.
  • The FtpBinaryMode option set with AutoItSetOption() has been removed. Now InetGet() takes a flag to specify the transfer mode.
  • The URLDownloadToFile() alias for InetGet() has been removed.
  • AdlibEnable() and AdlibDisable() are deprecated. See the new functions AdlibRegister() and AdlibUnRegister().
  • OnAutoItStart() is deprecated. See the new pre-processor statement #OnAutoItStartRegister.
  • OnAutoItExit() is deprecated. See the new functions OnAutoItExitRegister() and OnAutoItExitUnRegister().
  • The AutoItSetOption() option OnExitFunc has been removed. See the new functions OnAutoItExitRegister() and OnAutoItExitUnRegister().
  • GUICreate() with $WS_EX_MDICHILD has been fixed to be relative to client area as documented.
  • ProcessWait() now returns a PID instead of 1 on success.
  • WinWait(), WinWaitActive(), WinActivate(), WinActive() and WinMove() now return an HWND instead of 1 on success.
  • The macro @YDAY now uses the range 001 - 366 instead of 1 - 366. This makes the macro more consistent with other languages (like C/C++) and more consistent with all other date related macros which return strings with leading 0s to pad the length.
  • RegEnumKey() and RegEnumVal() now return an empty string instead of an error message.

UDFs:

  • The last optional parameter for _StringBetween() has been removed.
  • _StringAddThousandsSep() has been removed. There are too many opinions on what this function should do and too many revisions of this function have been made.
  • _SQLite_SaveMode() has been renamed to _SQLite_SafeMode().

v3.3.0.0

AutoIt:

  • Windows 9x and Windows NT 4.0 Operating System support has been removed. Use v3.2.12.1 of AutoIt if you really need this.
  • @ProcessorArch changed to @OSArch as it was misleading.
  • RegRead() and RegWrite() no longer use hex strings for REG_BINARY types - native binary datatypes are enforced.

AutoItX:

  • The native version of the DLL now exclusively uses Unicode strings (LPWSTR and LPCWTSR). If you really need ANSI strings then continue to use v3.2.12.1. The easiest workaround though is to use a "wrapper" function to simply convert between Unicode and ANSI. A limited selection of functions (WinWait... and Send) have an ANSI version but it is not intended to add ANSI versions for any others unless there is a large demand.

v3.2.12.0

AutoIt:

  • RunAsSet() has been removed. Use the new RunAs() and RunAsWait() functions instead. They have been enhanced with slightly better security (It is still not recommended to store important passwords in your scripts) and more functionality.
  • The option RunErrorsFatal has been removed. Run(), RunWait(), ShellExecute() and ShellExecuteWait() now all set @error when they fail to run the application. AutoIt will no longer throw a fatal error when an application fails to run.
  • StdoutRead(), StderrRead() and ConsoleRead() have undergone significant changes. They no longer block, they return immediately. The parameters have changed as well. It's no longer possible to read count parameters. The peek parameter has moved to the second parameter. The third parameter now specifies you want the data to be returned in binary format (default is text). The macro @extended now holds the number of bytes/characters read.
  • StdinWrite(), ConsoleWrite() and ConsoleWriteError() will now behave differently when given binary data. The binary data is written as-is instead of converting it to a string. Also, the return value from these functions is the number of bytes written instead of a generic value of 1.
  • Removed: ColorMode option ( Opt() ).
  • Fixed: Random(Min,Max,1). Previously this would never actually return Max, so if Max was artificially incremented by one the script will now need to be changed.

UDFs:

  • (Please see this forum thread for more details and help with these changes.)
  • GUIConstants.au3 is identical to GUIConstantsEx.au3. This means that many scripts using advanced GUI functionality will need to use additional #include statements to include files containing constants that were previously and erroneously included.
  • GUIDefaultConstants.au3 no longer exists. You must now #include the corresponding individual constants file for the control type you need. For example, ListBoxConstants.au3, ComboConstants.au3, EditConstants.au3, etc.
  • _ArrayCreate() documentation has been removed. The function is still present but may be removed at a later time. Scripts should be updated to use the array initialization syntax built into AutoIt.

v3.2.10.0

AutoIt

  • DllCall(): short_ptr, long_ptr, int_ptr types deprecated. Use short*, long* and int* respectively.

UDFs

  • _GUICtrlXXXYYY() have been renamed _GUICtrlXXX_YYY() without any functional changes.


Array UDF - Script Breaking Changes

The Array UDF has been almost completely rewritten to support 2D arrays, to improve the speed of multiple insertion and deletions and correct bugs.
This means that scripts written for AutoIt up to version 3.3.12.0 might not run correctly with later versions and may need to be modified.
The following table lists the differences between the old and the new version.

Changed functions/parameters
UDF Function/Parameter | Comments
All changed functions | Values returned in @error on function error may well have changed - details on specific Help file pages.
_ArrayAdd | Now supports 2D arrays and can add multiple lines in one call.
$vValue | Altered: Value(s) to add - can be a single item, a delimited string or an array.
$iStart | Added: If adding data to a 2D array, the column at which the insertion starts in each row (default = 0).
$sDelim_Item $sDelim_Row | Added: If data passed as a delimited string these determine the number of rows/columns to be added.
$iForce | Added: Changes function behaviour - either forces addtion of added data as a single item or forces datatype for added items
_ArrayBinarySearch | Now supports 2D arrays.
$iColumn | Added: 0-based index of column to search (default = 0).
_ArrayConcatenate | Now supports 2D array swith equal number of columns.
_ArrayDelete | Now support multiple deletions.
$vRange | Altered: Element(s) to delete - either a single index, a range string or a 1D array with a count in the [0] element
_ArrayDisplay | Buttons at bottom of dialog can be hidden
_ArrayFindAll | Now supports searching 2D arrays by row as well as by column
$fRow | Added: If set to True, $iSubItem determines the row and not the column in a 2D array.
_ArrayInsert | Now supports 2D arrays and can insert multiple lines in the same or different positions in one call.
$vRange | Altered: Element(s) above which the insertion is to take place - either a single index, a range string or a 1D array with a count in the [0] element
$vValue | Added: Value(s) to insert - can be a single item, a delimited string or an array.
$iStart | Added: If inserting data to a 2D array, the column at which the insertion starts in each row (default = 0).
$sDelim_Item $sDelim_Row | Added: If data is passed as a delimited string these determine the number of rows/columns to be added.
$hDataType | Added: If $vValue is a delimited string the data is converted to a string. Assigning a datatype function (Number, HWnd, etc) forces it into that datatype
_ArrayMax | Now supports 2D arrays.
$iSubItem | Added: 0-based column to search.
_ArrayMaxIndex | Now supports 2D arrays.
$iSubItem | Added: 0-based column to search.
_ArrayMin | Now supports 2D arrays.
$iSubItem | Added: 0-based column to search.
_ArrayMinIndex | Now supports 2D arrays.
$iSubItem | Added: 0-based column to search.
_ArraySearch | Now supports searching 2D arrays by row as well as by column
$fRow | Added: If set to True, $iSubItem determines the row and not the column in a 2D array.
_ArraySwap | Completely rewritten to swap full or part columns/rows within a 2D array
$iIndex_1 $iIndex_2 | Altered: Index of the rows/columns to swap
$bCol | Added: If set to True, $iIndex_1 and $iIndex_2 determine the column and not the row.
$iStart $iEnd | Added: Elements within the rows/columns to swap.
_ArrayToClip | Now just a simple wrapper for _ArrayToString. See details of parameters for that function.
_ArrayToString | Now supports 2D arrays
$sDelim_Item $sDelim_Row | Added: Determine the column/row delimiters.
$iStart_Row $iEnd_Row | Added: Limit the rows to extract.
$iStart_Col $iEnd_Col | Added: Limit the columns to extract.
_ArrayTranspose | Now transposes 1D arrays
_ArrayTrim | Now supports 2D arrays
$iSubItem | Added: Column to trim
_ArrayUnique | For consistency with all other functions $iColumn is now 0-based, not 1-based

New functions/parameters
New UDF Function | Comments
_ArrayColInsert | This function is used to insert columns into 1D or 2D arrays.
_ArrayColDelete | This function is used to delete columns from 2D arrays.
_ArrayExtract | This function extracts a smaller array from inside 1D and 2D arrays.
_ArrayShuffle | This function uses the FisherYates algorithm to shuffle all or some of the rows of 1D and 2D arrays. The shuffle can be limited to a specific column in a 2D array.

Unchanged functions
Unchanged UDF Function
_ArrayCombinations
_ArrayPermute
_ArrayPop
_ArrayPush
_ArrayReverse


Excel UDF - Script Breaking Changes

The Excel UDF was completely rewritten to support new file formats and new features of Microsoft Excel.
This means that scripts written for AutoIt up to version 3.3.8.1 won't run with later versions and need to be modified.
The following table lists the differences between the old and the new version.
More information can be found in the wiki.

Renamed, removed and changed functions/parameters
Old UDF Function/Parameter | New UDF Function/Parameter | Comments
_ExcelBookAttach | _Excel_BookAttach |
 | $oInstance | Added. Object of the Excel instance to be searched.
_ExcelBookClose | _Excel_BookClose |
$fAlerts |  | Removed.
_ExcelBookNew | _Excel_BookNew |
$fVisible |  | Removed.
 | $iSheets | Added. Number of sheets to be added to the new workbook.
_ExcelBookOpen | _Excel_BookOpen |
 | $oExcel | Added. Excel application object where you want to open the workbook.
_ExcelBookSave | _Excel_BookSave |
$fAlerts |  | Removed.
_ExcelBookSaveAs | _Excel_BookSaveAs |
$vType |  | Name changed to $iFormat. Can be any value of the XlFileFormat enumeration.
$fAlerts |  | Removed.
$iAccessMode |  | Removed.
$iConflictResolution |  | Removed.
 | $bReadOnlyRecommended | Added. Allows to display a message when the file is opened, recommending that the file be opened as read-only.
_ExcelColumnDelete | _Excel_RangeDelete |
$iColumn |  | Changed to $vRange range object.
_ExcelColumnInsert | _Excel_RangeInsert |
$iColumn |  | Changed to $vRange range object.
_ExcelFontSetProperties |  | Removed.
_ExcelHorizontalAlignSet |  | Removed.
_ExcelHyperlinkInsert | _Excel_RangeLinkAddRemove | Changed parameters so specific sheets can be addressed.
_ExcelReadArray | _Excel_RangeRead | Changed parameters so specific sheets can be addressed.
_ExcelReadCell | _Excel_RangeRead | Changed parameters so specific sheets can be addressed.
_ExcelReadSheetToArray | _Excel_RangeRead | Changed parameters so specific sheets can be addressed.
_ExcelRowDelete | _Excel_RangeDelete |
$iRow |  | Changed to $vRange range object.
_ExcelRowInsert | _Excel_RangeInsert |
$iRow |  | Changed to $vRange range object.
_ExcelSheetActivate |  | Removed.
_ExcelSheetNameGet |  | Removed.
_ExcelSheetNameSet |  | Removed.
_ExcelWriteArray | _Excel_RangeWrite | Changed parameters so specific sheets can be addressed.
_ExcelWriteCell | _Excel_RangeWrite | Changed parameters so specific sheets can be addressed.
_ExcelWriteFormula | _Excel_RangeWrite | Changed parameters so specific sheets can be addressed.
_ExcelWriteSheetFromArray | _Excel_RangeWrite | Changed parameters so specific sheets can be addressed.
_ExcelSheetAddNew | _Excel_SheetAdd | Changed parameters so specific sheets can be addressed.
_ExcelSheetDelete | _Excel_SheetDelete |
$fAlerts |  | Removed.
_ExcelSheetList | _Excel_SheetList |
_ExcelSheetMove | _Excel_SheetCopyMove | Changed parameters so specific sheets can be addressed.

New functions
New UDF Function/Parameter | Comments
_Excel_BookList | Returns a list of workbooks of a specified or all Excel instances.
_Excel_BookOpenText | Opens a text file and parses the content to a new workbook with a single sheet.
_Excel_Close | Closes all worksheets and the instance of the Excel application.
_Excel_Open | Connects to an existing Excel instance or creates a new one. It's mandatory now to call function _Excel_Open before any other function.
_Excel_ColumnToLetter | Converts the column number to letter(s).
_Excel_ColumnToNumber | Converts the column letter(s) to a number.
_Excel_ConvertFormula | Converts cell references in a formula between A1 and R1C1 reference styles, relative and absolute reference type, or both.
_Excel_Export | Exports a workbook, worksheet, chart or range as PDF or XPS.
_Excel_FilterGet | Returns a list of set filters.
_Excel_FilterSet | Sets/unsets filter definitions and filters the range.
_Excel_PictureAdd | Adds a picture on the specified workbook and worksheet.
_Excel_Print | Prints a workbook, worksheet, chart or range.
_Excel_RangeCopyPaste | Cuts or copies one or multiple cells, rows or columns to a range or from/to the clipboard.
_Excel_RangeDelete | Deletes one or multiple cells, rows or columns from the specified worksheet.
_Excel_RangeFind | Finds matching cells in a range or workbook and returns an array with information about the found cells.
_Excel_RangeInsert | Inserts one or multiple empty cells, rows or columns into the specified worksheet.
_Excel_RangeLinkAddRemove | Adds or removes a hyperlink to/from a specified range.
_Excel_RangeRead | Reads the value, formula or displayed text from a cell or range of cells of the specified workbook and worksheet.
_Excel_RangeReplace | Finds and replaces matching strings in a range or worksheet.
_Excel_RangeSort | Sorts a cell range.
_Excel_RangeValidate | Adds data validation to the specified range.
_Excel_RangeWrite | Writes value(s) or formula(s) to a cell or a cell range on the specified workbook and worksheet.
_Excel_SheetCopyMove | Copies or moves the specified sheet before or after a specified sheet in the same or a different workbook.


ToolTip UDF - Script Breaking Changes

The ToolTip UDF was completely rewritten to remove magic numbers, make it easier to implement ToolTips in scripts, standardize the parameters and documentation, and correct bugs.
This means that scripts written for AutoIt up to version 3.3.8.1 won't run with later versions and need to be modified.
The following table lists the differences between the old and the new version.

Changed and removed functions/parameters
Old UDF Function/Parameter | Comments
_GUIToolTip_Activate | $fActivate parameter removed, only used to activate a tooltip as it no longer is used to deactivate one
_GUIToolTip_AddTool | The $iFlags parameters have been changed to use the ToolTip constants instead of magic numbers, also the default setting has changed to BitOr($TTF_SUBCLASS, $TTF_IDISHWND)
_GUIToolTip_BitsToTTF | Functionality of this has been totally altered, because there are no longer any magic numbers for the tool flags, this function now translates the value of the flags to a comma delimited text string containing the constants used in the flags parameter.
_GUIToolTip_Create | New default constant for tooltip control creation
$_TT_ghTTDefaultStyle | Its value is equal to BitOr($TTS_ALWAYSTIP, $TTS_NOPREFIX)
_GUIToolTip_Destroy | Documented @error return values
_GUIToolTip_EnumTools | The return values have changed to reflect the changes in _GUIToolTip_Add and _GUIToolTip_BitsToTTF, the returned array's [0] element is now a text string containing the return from the _GUIToolTip_BitsToTTF function instead of the magic numbers used previously.
_GUIToolTip_GetBubbleHeight | Default value for the $iFlags parameter changed to BitOR($TTF_IDISHWND, $TTF_SUBCLASS)
_GUIToolTip_GetBubbleSize | Default value for the $iFlags parameter changed to BitOR($TTF_IDISHWND, $TTF_SUBCLASS)
_GUIToolTip_GetBubbleWidth | Default value for the $iFlags parameter changed to BitOR($TTF_IDISHWND, $TTF_SUBCLASS)
_GUIToolTip_GetCurrentTools | The return values have changed to reflect the changes in _GUIToolTip_Add and _GUIToolTip_BitsToTTF, the returned array's [0] element is now a text string containing the return from the _GUIToolTip_BitsToTTF function instead of the magic numbers used previously.
_GUIToolTip_GetDelayTime | The function now correctly uses the ToolTip constants to retrieve the tooltip delay times. The previous values used were 0 - 2, the correct values for the duration constants are 1 - 3
_GUIToolTip_GetTitleBitMap | Corrected a long standing bug in the function that prevented it from returning the correct information.
_GUIToolTip_GetTitleText | Corrected a long standing bug in the function that prevented it from returning the correct information.
_GUIToolTip_GetToolInfo | The return values have changed to reflect the changes in _GUIToolTip_Add and _GUIToolTip_BitsToTTF, the returned array's [0] element is now a text string containing the return from the _GUIToolTip_BitsToTTF function instead of the magic numbers used previously.
_GUIToolTip_HitTest | The return values have changed to reflect the changes in _GUIToolTip_Add and _GUIToolTip_BitsToTTF, the returned array's [0] element is now a text string containing the return from the _GUIToolTip_BitsToTTF function instead of the magic numbers used previously.
_GUIToolTip_SetToolInfo | The $iFlags parameters have been changed to use the ToolTip constants instead of magic numbers, also the default setting has changed to BitOr($TTF_SUBCLASS, $TTF_IDISHWND)
_GUIToolTip_ToolToArray | The [0] element of the returned array now correctly returns the flag value based on the tooltip constants instead of the magic numbers used previously
_GUIToolTip_TTFToBits | Removed

New functions/parameters
New UDF Function/Parameter | Comments
_GUIToolTip_Deactivate | This function is used to deactivate a tooltip, replaces the dual functionality of the _GUIToolTip_Activate function.


Word UDF - Script Breaking Changes

The Word UDF was completely rewritten to support new file formats and new features of Microsoft Word.
This means that scripts written for AutoIt up to version 3.3.8.1 won't run with later versions and need to be modified.
The following table lists the differences between the old and the new version.
More information can be found in the wiki.

Renamed, removed and changed functions/parameters
Old UDF Function/Parameter | New UDF Function/Parameter | Comments
All Functions |  | @extended no longer contains invalid parameter number.
_Word_VersionInfo |  | Removed.
_WordAttach | _Word_DocAttach |
$s_mode = HWND |  | Removed.
$s_mode = Title |  | Removed.
 | $iCase | Added. Specifies case-sensitivity for search mode "Text".
_WordCreate | _Word_Create | It's mandatory now to call this function before any other function. You could have used _WordCreate or _WordAttach in the old Word UDF. @extended is set if Word was already running.
$s_FilePath |  | Removed. Use _Word_DocOpen or _Word_DocAdd.
$f_takeFocus |  | Removed.
$f_tryAttach |  | Removed.
 | $bForceNew | Added. Forces to create a new Word instance even if there is already a running instance.
_WordDocAdd | _Word_DocAdd |
_WordDocAddLink | _Word_DocLinkAdd |
_WordDocAddPicture | _Word_DocPictureAdd |
_WordDocClose | _Word_DocClose |
$f_RouteDocument |  | Removed.
_WordDocFindReplace | _Word_DocFindReplace |
_WordDocGetCollection | _Word_DocGet | @extended is set to the total number of documents.
_WordDocLinkGetCollection | _Word_DocLinkGet | @extended is set to the total number of links.
_WordDocOpen | _Word_DocOpen |
_WordDocPrint | _Word_DocPrint |
_WordDocPropertyGet |  | Removed.
_WordDocPropertySet |  | Removed.
_WordDocSave | _Word_DocSave |
_WordDocSaveAs | _Word_DocSaveAs |
$f_LockComments |  | Removed.
_WordErrorHandlerDeRegister |  | Removed.
_WordErrorHandlerRegister |  | Removed.
_WordErrorNotify |  | Removed.
_WordMacroRun |  | Removed.
_WordPropertyGet |  | Removed.
_WordPropertySet |  | Removed.
_WordQuit | _Word_Quit | Now only closes the Word application if created by this UDF.
$f_RouteDocument |  | Removed.
 | $bForceClose | Added. If True the Word application is closed even when it was running at _Word_Create time.

New functions
New UDF Function/Parameter | Comments
_Word_DocExport | Exports the document or a range as PDF or XPS.
_Word_DocFind | Runs or repeats the specified find operation.
_Word_DocRangeSet | Sets or modifies a range in a document.
_Word_DocTableRead | Reads a Word table into a 2D-array.
_Word_DocTableWrite | Writes a 1D or 2D-array to a Word table.


#pragma compile

Pragma Compile Directives

This is a special directive that controls special Aut2Exe properties that affect how the resulting script is compiled to an .exe. For example, changing the file properties or file icon.

Directive | Parameters | Description | Example
Out | Filename | Sets the file name of the compiled executable. | #pragma compile(Out, AutoIt_Example.exe)
Icon | Filename | Sets the compiled executable icon. | #pragma compile(Icon, \..\back2.ico)
ExecLevel | none, asInvoker, highestAvailable, requireAdministrator | Sets the execution level in the compiled executable manifest. | #pragma compile(ExecLevel, highestavailable)
UPX | true, false (default) | Compresses the compiled executable using UPX. | #pragma compile(UPX, false)
AutoItExecuteAllowed | true, false (default) | Allows the compiled executable to execute non compiled scripts. | #pragma compile(AutoItExecuteAllowed, true)
Console | true, false (default) | Compile the executable in console mode. | #pragma compile(Console, false)
Compression | 1, 3, 5, 7, 9 | Sets the compiled executable FileInstall() resources compression. | #pragma compile(Compression, 3)
Compatibility | vista, win7, win8, win81, win10 | Sets the compatibility in the compiled executable manifest. | #pragma compile(Compatibility, win10)
x64 | true, false (default) | Compiles the executable in 64-bits. | #pragma compile(x64, false)
inputboxres | true, false (default) | Omits the InputBox() resources from being included with the compiled executable. | #pragma compile(inputboxres, false)
Comments | Comment remarks with quotes or without | Sets a comment to the compiled executable. | #pragma compile(Comments, 'Some, ''Apostrophe'')
CompanyName | Company name remark with quotes or without | Sets a company name to the compiled executable. | #pragma compile(CompanyName, 'AutoIt')
FileDescription | File description with quotes or without | Sets a file description to the compiled executable. | #pragma compile(FileDescription, AutoIt is a freeware BASIC-like scripting language.)
FileVersion | File version with the last parameter being optional | Sets a file version to the compiled executable. | #pragma compile(FileVersion, 1.2.3.4, 11.12.13.14)
InternalName | Internal name with or without quotes | Sets an internal name to the compiled executable. | #pragma compile(InternalName, "Internal Name")
LegalCopyright | Legal copyright remark with or without quotes | Sets a legal copyright to the compiled executable. | #pragma compile(LegalCopyright, Legal stuff here)
LegalTrademarks, | Legal trademark comment with or without quotes | Sets a legal trademark to the compiled executable. | #pragma compile(LegalTrademarks, '"Trademark something, and some text in "quotes" and stuff')
OriginalFilename | Filename | Sets an original filename to the compiled executable. | #pragma compile(OriginalFilename, OriginalName.exe)
ProductName | Product name remark with or without quotes | Sets a product name to the compiled executable. | #pragma compile(ProductName, No Name)
ProductVersion | File version with the last parameter being optional | Sets a product version to the compiled executable. | #pragma compile(ProductVersion, 0.1.3.7, 6.7.4.3)


TESTTest-IE6.au3

; Example script, showing the usage of COM Event functions.
;
; See also: http://msdn.microsoft.com/en-us/library/aa768400.aspx

; We use a very simple GUI to show the results of our Events.

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Global $g_idGUIEdit, $g_idGUIProg

Example()
Exit ; End of our Demo.

Func Example()
Local $hGUIMain = GUICreate ("Event Test", 600, 500)
$g_idGUIEdit = GUICtrlCreateEdit ("Test Log:" & @CRLF , 10, 20, 580, 400)
$g_idGUIProg = GUICtrlCreateProgress (10, 5, 580, 10)
Local $idGUIExit = GUICtrlCreateButton (" Close ", 250, 450, 80, 30)
GUISetState () ;Show GUI

; We prepare the Internet Explorer as our test subject
Local $oIE = ObjCreate ("InternetExplorer.Application.1")
With $oIE
.Visible = 1
.Top = ( @DesktopHeight - 400) / 2
.Height = 400 ; Make it a bit smaller than our GUI.
.Width = 600
.Silent = 1 ; Don't show IE's dialog boxes
Local $hIEWnd = HWnd (.hWnd) ; Remember the Window, in case user decides to close it
EndWith

; We choose for a specific Internet Explorer interface 'DWebBrowserEvents' because the IE is subject
; to modifications by e.g. Visual Studio and Adobe Acrobat Reader. If you have IE-plugins installed,
; AutoIt might not be able to find the correct interface automatically.
Local $oEventObject = ObjEvent ($oIE, "IEEvent_", "DWebBrowserEvents")
If @error Then
MsgBox ($MB_OK, "AutoIt COM Test", _
"ObjEvent: Can't use event interface 'DWebBrowserEvents'. Error code: " & Hex ( @error , 8))
Exit
EndIf

; Now starting to load an example Web page.
Local $sURL = "http://www.AutoItScript.com/"
$oIE.Navigate($sURL)
Sleep (1000) ; Give it some time to load the web page

GUISwitch ($hGUIMain) ; Switch back to our GUI in case IE stole the focus

; Waiting for user to close the GUI.
Local $iMsg
While 1
$iMsg = GUIGetMsg ()
If $iMsg = $GUI_EVENT_CLOSE Or $iMsg = $idGUIExit Then ExitLoop
WEnd

$oEventObject.Stop ; Tell IE we don't want to receive events.
$oEventObject = 0 ; Kill the Event Object
If WinExists ($hIEWnd) Then $oIE.Quit ; Close IE Window
$oIE = 0 ; Remove IE from memory (not really necessary).

GUIDelete () ; Remove GUI
EndFunc ;==>Example

; A few Internet Explorer Event Functions
; See also: http://msdn.microsoft.com/en-us/library/aa768400.aspx
Func IEEvent_BeforeNavigate($sURL, $iFlags, $sTargetFrameName, $dPostData, $sHeaders, $bCancel)
; Note: the declaration is different from the one on MSDN.
GUICtrlSetData ($g_idGUIEdit, "BeforeNavigate: " & $sURL & " Flags: " & $iFlags & " tgframe: " & $sTargetFrameName & " Postdat: " & $dPostData & " Hdrs: " & $sHeaders & " canc: " & $bCancel & @CRLF , "append")
EndFunc ;==>IEEvent_BeforeNavigate

Func IEEvent_ProgressChange($iProgress, $iProgressMax)
If $iProgressMax > 0 Then
GUICtrlSetData ($g_idGUIProg, ($iProgress * 100) / $iProgressMax)
EndIf
EndFunc ;==>IEEvent_ProgressChange

Func IEEvent_StatusTextChange($sText)
GUICtrlSetData ($g_idGUIEdit, "IE Status text changed to: " & $sText & @CRLF , "append")
EndFunc ;==>IEEvent_StatusTextChange

Func IEEvent_PropertyChange($szProperty)
GUICtrlSetData ($g_idGUIEdit, "IE Changed the value of the property: " & $szProperty & @CRLF , "append")
EndFunc ;==>IEEvent_PropertyChange

Func IEEvent_DownloadComplete()
GUICtrlSetData ($g_idGUIEdit, "IE has finished a navigation operation" & @CRLF , "append")
EndFunc ;==>IEEvent_DownloadComplete

Func IEEvent_NavigateComplete($sURL)
; Note: the declaration is different from the one on MSDN.
GUICtrlSetData ($g_idGUIEdit, "IE has finished loading URL: " & $sURL & @CRLF , "append")
EndFunc ;==>IEEvent_NavigateComplete

Func IEEvent_($sEventName)
; This is an optional event function to catch non-defined events.
; The parameter contains the name of the event being called.
GUICtrlSetData ($g_idGUIEdit, "Uncatched event: " & $sEventName & @CRLF , "append")
EndFunc ;==>IEEvent_


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	WinZip® 9.0 SR-1 Setup
Class:	#32770
Size:	X: 493    Y: 455    W: 413    H: 139

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
&Setup
Cancel
&Info...
Thank you for your interest in WinZip!

Click the "Setup" button to install WinZip 9.0 SR-1.

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	WinZip Setup
Class:	#32770
Size:	X: 540    Y: 425    W: 320    H: 199

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
Setup will install WinZip into the following folder, which it will create if necessary.
If you want to install WinZip in a different folder and/or drive, type the name of the folder below:
&Install to:
C:\Program Files\WinZip
&Browse...
OK
Cancel

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	WinZip Setup
Class:	#32770
Size:	X: 464    Y: 341    W: 471    H: 333

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
&Help
< &Back
&Next >
Close
Thank you for installing WinZip!
WinZip features include:

* Quick and easy zip and unzip
* Optional Wizard interface
* E-mail support, including Zip and E-Mail from Explorer
* Tight integration with the Windows shell
* Internet file format support, including MIME, TAR, & CAB
* 128-bit and 256-bit AES encryption

Press the F1 key on your keyboard at any time while running WinZip for context sensitive help and complete documentation.

Click Next to continue.

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<
&WinZip Classic


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	License Agreement and Warranty Disclaimer
Class:	#32770
Size:	X: 473    Y: 368    W: 452    H: 279

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
As with other software, WinZip is subject to WARRANTY DISCLAIMERS and
LIABILITY LIMITATIONS, including (but not limited to) the following:
THIS SOFTWARE, AND ALL ACCOMPANYING FILES, DATA AND MATERIALS, ARE
DISTRIBUTED "AS IS", and ANY LIABILITY OF WINZIP COMPUTING, INC. (WCI)
WILL BE LIMITED EXCLUSIVELY TO REFUND OF THE LICENSE FEE PAID TO WCI.
In addition, this version of WinZip is subject to the complete
WinZip License Agreement, which you can view by clicking on the
"View License Agreement" button now.
I agree that by clicking on the "Yes" button below (or otherwise installing
or using WinZip), I accept all terms of the License Agreement, and that I
have read the License Agreement.
&Yes
&No
&View License Agreement

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	WinZip Setup
Class:	#32770
Size:	X: 464    Y: 341    W: 471    H: 333

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
&Help
< &Back
&Next >
Close
WinZip Quick Start
For helpful information on installing and using WinZip, print a copy of the "WinZip Quick Start Guide." Click "Print Quick Start".

To see the Guide without printing it, click "View Quick Start".
You can also view or print the Quick Start Guide later by choosing Quick Start from the WinZip Help Contents.

Click Next when you are ready to continue.
&Print Quick Start
&View Quick Start

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<
&WinZip Classic


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	WinZip Setup
Class:	#32770
Size:	X: 464    Y: 341    W: 471    H: 333

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
&Help
< &Back
&Next >
Close
Choose "Classic" or "Wizard", then click "Next"
You can start with the "Classic" or "Wizard" interface.  It is easy to switch between the two interfaces, and you can always change the default later.
WinZip Classic is the more powerful of the two interfaces and is recommended if you are comfortable with Windows and Zip files. Most WinZip users choose this interface.
The WinZip Wizard automates the most common tasks involving Zip files and is most useful for users who are new to Windows and Zip files.
Start with WinZip &Classic
&Start with the WinZip Wizard

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<
&WinZip Classic


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	WinZip Setup
Class:	#32770
Size:	X: 464    Y: 341    W: 471    H: 333

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
&Help
< &Back
&Next >
Close
Click "Next" to continue.
&Express setup (recommended)
&Custom setup (for advanced users)
Express Setup associates WinZip with archives, creates a program group, and puts WinZip icons on the desktop and Start menu.

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<
&WinZip Classic


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	WinZip Setup
Class:	#32770
Size:	X: 464    Y: 341    W: 471    H: 333

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
&Help
< &Back
&Next >
Close
WinZip needs to associate itself with your archives.
Associations allow WinZip to be used to open archives from My Computer, Windows Explorer, etc.
Click "Next" to associate WinZip with all supported archive types.  Click "Associations" if you want more information or would like to specify the archive types with which WinZip is associated.
&Associations...

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<
&WinZip Classic


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	WinZip Setup
Class:	#32770
Size:	X: 464    Y: 341    W: 471    H: 333

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
&Help
< &Back
Finish
Close
Thank you for installing this evaluation version.
New WinZip Users:

For a quick introduction to WinZip select "Brief Tutorial" from the "Help" pull-down menu at any time or press the F1 key now.

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<
&WinZip Classic


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	WinZip (Evaluation Version)
Class:	WinZipWClass
Size:	X: 417    Y: 334    W: 566    H: 347

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
Choose "New" to create or "Open" to open an archive
ListView

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<


script.au3

 ; Run the winzip installer
Run("winzip90.exe")

; Initial Setup Screen
WinWaitActive("WinZip® 9.0 SR-1 Setup", "&Setup")
Send("!s")

; Install location
WinWaitActive("WinZip Setup", "into the following folder")
Send("{ENTER}")

; Features overview
WinWaitActive("WinZip Setup", "WinZip features include")
Send("!n")

; License agreement
WinWaitActive("License Agreement")
Send("!y")

; Quick start
WinWaitActive("WinZip Setup", "Quick Start Guide")
Send("!n")

; Choose interface
WinWaitActive("WinZip Setup", "switch between the two interfaces")
Send("!c")
Send("!n")

; Installation type (custom/express)
WinWaitActive("WinZip Setup", "&Express setup (recommended)")
Send("!e")
Send("!n")

; Select file associations
WinWaitActive("WinZip Setup", "WinZip needs to associate itself with your archives")
Send("!n")

; Completed installation screen
WinWaitActive("WinZip Setup", "Thank you for installing this evaluation version")
Send("{ENTER}")

; Wait for winzip to load then close it
WinWaitActive("WinZip (Evaluation Version)")
WinClose("WinZip (Evaluation Version)")